Commit 59948c12 59948c12fe91a189a0b15b483f6247f1cabc6918 by Sergey Poznyakoff

(argcv_unescape_char,argcv_escape_char): New functions.

1 parent f5bb3117
...@@ -40,6 +40,8 @@ extern int argcv_get __P ((const char *command, const char *delim, ...@@ -40,6 +40,8 @@ extern int argcv_get __P ((const char *command, const char *delim,
40 int *argc, char ***argv)); 40 int *argc, char ***argv));
41 extern int argcv_string __P ((int argc, char **argv, char **string)); 41 extern int argcv_string __P ((int argc, char **argv, char **string));
42 extern int argcv_free __P ((int argc, char **argv)); 42 extern int argcv_free __P ((int argc, char **argv));
43 extern int argcv_unescape_char __P((int c));
44 extern int argcv_escape_char __P((int c));
43 45
44 #ifdef __cplusplus 46 #ifdef __cplusplus
45 } 47 }
......
...@@ -93,8 +93,8 @@ argcv_scan (int len, const char *command, const char *delim, const char* cmnt, ...@@ -93,8 +93,8 @@ argcv_scan (int len, const char *command, const char *delim, const char* cmnt,
93 93
94 static char escape_transtab[] = "\\\\a\ab\bf\fn\nr\rt\t"; 94 static char escape_transtab[] = "\\\\a\ab\bf\fn\nr\rt\t";
95 95
96 static int 96 int
97 unescape_char (int c) 97 argcv_unescape_char (int c)
98 { 98 {
99 char *p; 99 char *p;
100 100
...@@ -106,8 +106,8 @@ unescape_char (int c) ...@@ -106,8 +106,8 @@ unescape_char (int c)
106 return c; 106 return c;
107 } 107 }
108 108
109 static int 109 int
110 escape_char (int c) 110 argcv_escape_char (int c)
111 { 111 {
112 char *p; 112 char *p;
113 113
...@@ -154,7 +154,7 @@ escaped_length (const char *str, int *quote) ...@@ -154,7 +154,7 @@ escaped_length (const char *str, int *quote)
154 } 154 }
155 else if (isprint (*str)) 155 else if (isprint (*str))
156 len++; 156 len++;
157 else if (escape_char (*str) != -1) 157 else if (argcv_escape_char (*str) != -1)
158 len += 2; 158 len += 2;
159 else 159 else
160 len += 4; 160 len += 4;
...@@ -226,7 +226,7 @@ unescape_copy (char *dst, const char *src, size_t n) ...@@ -226,7 +226,7 @@ unescape_copy (char *dst, const char *src, size_t n)
226 break; 226 break;
227 227
228 default: 228 default:
229 *dst++ = unescape_char (*src++); 229 *dst++ = argcv_unescape_char (*src++);
230 n--; 230 n--;
231 } 231 }
232 } 232 }
...@@ -252,7 +252,7 @@ escape_copy (char *dst, const char *src) ...@@ -252,7 +252,7 @@ escape_copy (char *dst, const char *src)
252 *dst++ = *src; 252 *dst++ = *src;
253 else 253 else
254 { 254 {
255 int c = escape_char (*src); 255 int c = argcv_escape_char (*src);
256 *dst++ = '\\'; 256 *dst++ = '\\';
257 if (c != -1) 257 if (c != -1)
258 *dst++ = c; 258 *dst++ = c;
......