Mercurial > flash_v2
comparison packages/redboot/current/src/parse.c @ 143:6b5f480c6929 ecos-sw-2000-12-08
Merge from eCos master repository on 2000-12-08-02:09:36-GMT
| author | jlarmour |
|---|---|
| date | Fri, 08 Dec 2000 03:30:06 +0000 |
| parents | eb9fd8c04db3 |
| children | ac086aa3217e |
comparison
equal
deleted
inserted
replaced
| 142:12eccf9656f3 | 143:6b5f480c6929 |
|---|---|
| 62 // | 62 // |
| 63 struct cmd * | 63 struct cmd * |
| 64 parse(char *line, int *argc, char **argv) | 64 parse(char *line, int *argc, char **argv) |
| 65 { | 65 { |
| 66 char *cp = line; | 66 char *cp = line; |
| 67 char *pp; | |
| 67 int indx = 0; | 68 int indx = 0; |
| 68 | 69 |
| 69 while (*cp) { | 70 while (*cp) { |
| 70 // Skip leading spaces | 71 // Skip leading spaces |
| 71 while (*cp && *cp == ' ') cp++; | 72 while (*cp && *cp == ' ') cp++; |
| 80 } else if (*cp == '"') { | 81 } else if (*cp == '"') { |
| 81 // Swallow quote, scan till following one | 82 // Swallow quote, scan till following one |
| 82 if (argv[indx-1] == cp) { | 83 if (argv[indx-1] == cp) { |
| 83 argv[indx-1] = ++cp; | 84 argv[indx-1] = ++cp; |
| 84 } | 85 } |
| 85 while (*cp && *cp != '"') cp++; | 86 pp = cp; |
| 87 while (*cp && *cp != '"') { | |
| 88 if (*cp == '\\') { | |
| 89 // Skip over escape - allows for escaped '"' | |
| 90 cp++; | |
| 91 } | |
| 92 // Move string to swallow escapes | |
| 93 *pp++ = *cp++; | |
| 94 } | |
| 86 if (!*cp) { | 95 if (!*cp) { |
| 87 printf("Unbalanced string!\n"); | 96 printf("Unbalanced string!\n"); |
| 88 } else { | 97 } else { |
| 98 if (pp != cp) *pp = '\0'; | |
| 89 *cp++ = '\0'; | 99 *cp++ = '\0'; |
| 90 break; | 100 break; |
| 91 } | 101 } |
| 92 } else { | 102 } else { |
| 93 cp++; | 103 cp++; |
| 296 } | 306 } |
| 297 first = false; | 307 first = false; |
| 298 c = *s++; | 308 c = *s++; |
| 299 if (_is_hex(c) && ((digit = _from_hex(c)) < radix)) { | 309 if (_is_hex(c) && ((digit = _from_hex(c)) < radix)) { |
| 300 // Valid digit | 310 // Valid digit |
| 311 #ifdef CYGPKG_HAL_MIPS | |
| 312 // FIXME: tx49 compiler generates 0x2539018 for MUL which | |
| 313 // isn't any good. | |
| 314 if (16 == radix) | |
| 315 result = result << 4; | |
| 316 else | |
| 317 result = 10 * result; | |
| 318 result += digit; | |
| 319 #else | |
| 301 result = (result * radix) + digit; | 320 result = (result * radix) + digit; |
| 321 #endif | |
| 302 } else { | 322 } else { |
| 303 if (delim != (char *)0) { | 323 if (delim != (char *)0) { |
| 304 // See if this character is one of the delimiters | 324 // See if this character is one of the delimiters |
| 305 char *dp = delim; | 325 char *dp = delim; |
| 306 while (*dp && (c != *dp)) dp++; | 326 while (*dp && (c != *dp)) dp++; |
