Changeset e30ed92
- Timestamp:
- Aug 17, 2009, 10:03:53 PM (15 years ago)
- Branches:
- master, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- 14acbbd
- Parents:
- 8bce750
- git-author:
- Nelson Elhage <nelhage@mit.edu> (08/17/09 22:03:45)
- git-committer:
- Nelson Elhage <nelhage@mit.edu> (08/17/09 22:03:53)
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
tester.c
r8bce750 re30ed92 70 70 FAIL_UNLESS("expand_tabs 3", 71 71 !strcmp(" 2 tabs", owl_text_expand_tabs("\t\t2 tabs"))); 72 73 FAIL_UNLESS("skiptokens 1", 74 !strcmp("world", skiptokens("hello world", 1))); 75 76 FAIL_UNLESS("skiptokens 2", 77 !strcmp("c d e", skiptokens("a b c d e", 2))); 78 79 FAIL_UNLESS("skiptokens 3", 80 !strcmp("\"b\" c d e", skiptokens("a \"b\" c d e", 1))); 81 82 FAIL_UNLESS("skiptokens 4", 83 !strcmp("c d e", skiptokens("a \"b\" c d e", 2))); 84 85 FAIL_UNLESS("skiptokens 5", 86 !strcmp("c d e", skiptokens("a \"'\" c d e", 2))); 72 87 73 88 /* if (numfailed) printf("*** WARNING: failures encountered with owl_util\n"); */ -
util.c
r8bce750 re30ed92 158 158 159 159 const char *skiptokens(const char *buff, int n) { 160 /* skips n tokens and returns where that would be. 161 * TODO: handle quotes more sanely. */ 162 163 int inquotes=0; 160 /* skips n tokens and returns where that would be. */ 161 char quote = 0; 164 162 while (*buff && n>0) { 165 163 while (*buff == ' ') buff++; 166 while (*buff && (inquotes || *buff != ' ')) { 167 if (*buff == '"' || *buff == '\'') inquotes=!inquotes; 168 buff++; 164 while (*buff && (quote || *buff != ' ')) { 165 if(quote) { 166 if(*buff == quote) quote = 0; 167 } else if(*buff == '"' || *buff == '\'') { 168 quote = *buff; 169 } 170 buff++; 169 171 } 170 172 while (*buff == ' ') buff++;
Note: See TracChangeset
for help on using the changeset viewer.