Browse Source

* Extended sv_escape_c to escape '\a','\b','\t','\v','\f','\?' characters to their respective representations instead of octal.

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@13414 54d463be-8e91-2dee-dedb-b68131a5f0ec
FlavioJS 16 năm trước cách đây
mục cha
commit
7263ae4f45
2 tập tin đã thay đổi với 18 bổ sung4 xóa
  1. 3 0
      Changelog-Trunk.txt
  2. 15 4
      src/common/strlib.c

+ 3 - 0
Changelog-Trunk.txt

@@ -3,6 +3,9 @@ Date	Added
 AS OF SVN REV. 5091, WE ARE NOW USING TRUNK.  ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK.
 IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
 
+2008/12/25
+	* Extended sv_escape_c to escape '\a','\b','\t','\v','\f','\?' characters 
+	  to their respective representations instead of octal. [FlavioJS]
 2008/12/22
 	* Added a few missing atcommands. [SketchyPhoenix]
 	* Added more commands to configurations (bugreport:2565)

+ 15 - 4
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];