diff options
author | FlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2008-12-25 22:05:16 +0000 |
---|---|---|
committer | FlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2008-12-25 22:05:16 +0000 |
commit | d85724ac4159d28c8269b52afdc6fa560326c2ec (patch) | |
tree | d6e2af1e9918adc1075ee92b3dc743b560e2c77d /src/common | |
parent | 880d754af62f2658b8c5ca94cf682626ad0b53ce (diff) | |
download | hercules-d85724ac4159d28c8269b52afdc6fa560326c2ec.tar.gz hercules-d85724ac4159d28c8269b52afdc6fa560326c2ec.tar.bz2 hercules-d85724ac4159d28c8269b52afdc6fa560326c2ec.tar.xz hercules-d85724ac4159d28c8269b52afdc6fa560326c2ec.zip |
* Extended sv_escape_c to escape '\a','\b','\t','\v','\f','\?' characters to their respective representations instead of octal.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@13414 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/strlib.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/common/strlib.c b/src/common/strlib.c index cdb092cfa..c0cc5b4ec 100644 --- a/src/common/strlib.c +++ b/src/common/strlib.c @@ -692,11 +692,22 @@ size_t sv_escape_c(char* out_dest, const char* src, size_t len, const char* esca break; default: if( strchr(escapes,src[i]) ) - {// escapes to octal + {// escape out_dest[j++] = '\\'; - out_dest[j++] = '0'+((char)(((unsigned char)src[i]&0700)>>6)); - out_dest[j++] = '0'+((char)(((unsigned char)src[i]&0070)>>3)); - out_dest[j++] = '0'+((char)(((unsigned char)src[i]&0007) )); + switch( src[i] ) + { + case '\a': out_dest[j++] = 'a'; break; + case '\b': out_dest[j++] = 'b'; break; + case '\t': out_dest[j++] = 't'; break; + case '\v': out_dest[j++] = 'v'; break; + case '\f': out_dest[j++] = 'f'; break; + case '\?': out_dest[j++] = '?'; break; + default:// to octal + out_dest[j++] = '0'+((char)(((unsigned char)src[i]&0700)>>6)); + out_dest[j++] = '0'+((char)(((unsigned char)src[i]&0070)>>3)); + out_dest[j++] = '0'+((char)(((unsigned char)src[i]&0007) )); + break; + } } else out_dest[j++] = src[i]; |