Changeset 18 for trunk/src/sh_tools.c
- Timestamp:
- Jan 28, 2006, 9:07:52 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/sh_tools.c
r12 r18 125 125 char * sh_tools_safe_name (const char * instr, int flag) 126 126 { 127 unsigned char c ;127 unsigned char c, d; 128 128 const char * p; 129 129 char *q; … … 133 133 int i = 0; 134 134 unsigned char val_octal = '\0'; 135 static char ctable[16] = { '0', '1', '2', '3', '4', '5', '6', '7', 136 '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; 135 137 136 138 SL_ENTER(_("sh_tools_safe_name")); … … 202 204 { 203 205 --i; 204 sprintf(&outstr[i], "=%02x", c); /* known to fit */ 206 d = c % 16; c = c / 16; 207 outstr[i] = '='; ++i; 208 outstr[i] = ctable[c]; ++i; 209 outstr[i] = ctable[d]; ++i; 205 210 } 206 211 … … 274 279 break; 275 280 default: 276 if (strlen(p) < 3) 281 if (strlen(p) < 3) /* certainly not an octal number, skip */ 277 282 { 278 283 p += strlen(p); … … 284 289 if (val_octal != '\0') { 285 290 c = val_octal; 286 sprintf(&outstr[i], "=%02x", c); /* known to fit */ 287 i+=3; 291 d = c % 16; c = c / 16; 292 outstr[i] = '='; ++i; 293 outstr[i] = ctable[c]; ++i; 294 outstr[i] = ctable[d]; ++i; 288 295 } 289 296 p += 3; … … 294 301 { 295 302 ++p; 296 if (!p || !(*p)) 297 break; 303 if (!p || !(*p)) 304 { 305 outstr[i] = '&'; ++i; 306 break; 307 } 298 308 299 309 if (p[0] == 'a' && p[1] == 'm' && p[2] == 'p' && p[3] == ';')
Note:
See TracChangeset
for help on using the changeset viewer.