diff options
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]; |