Changeset 10073 for trunk/Ohana/src/opihi/lib.shell/string.c
- Timestamp:
- Nov 17, 2006, 5:04:25 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/lib.shell/string.c (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/lib.shell/string.c
r7917 r10073 3 3 /**********************************************************************/ 4 4 /* returns a pointer to an isolated string containing the first word, 5 removing leading whitespace. A "word" is a contiguous set of5 removing leading WHITESPACE. A "word" is a contiguous set of 6 6 characters from the set: alphanumerics, and any of: / . _ - 7 Any other single, non- whitespacecharacters are considered to be7 Any other single, non-WHITESPACE characters are considered to be 8 8 complete words in themselves. Any characters surrounded by quotes 9 9 make a single word … … 17 17 if (string == (char *) NULL) return ((char *) NULL); 18 18 19 for (i = 0; whitespace(string[i]); i++);19 for (i = 0; OHANA_WHITESPACE (string[i]); i++); 20 20 if (string[i] == 0) return ((char *)NULL); 21 21 if (string[i] == ';') { … … 63 63 64 64 65 for (j = i; (string[j] != 0) && (string[j] != ';') && ! whitespace(string[j]); j++);65 for (j = i; (string[j] != 0) && (string[j] != ';') && !OHANA_WHITESPACE(string[j]); j++); 66 66 word = strncreate (&string[i], j - i); 67 67 return (word); … … 70 70 71 71 /* returns a pointer to an isolated string containing the first command, 72 removing leading whitespace. A command ends with the first non whitespace*/72 removing leading WHITESPACE. A command ends with the first non WHITESPACE */ 73 73 char *thiscomm (char *string) { 74 74 … … 78 78 if (string == (char *) NULL) return ((char *) NULL); 79 79 80 for (i = 0; whitespace(string[i]); i++);80 for (i = 0; OHANA_WHITESPACE (string[i]); i++); 81 81 if (string[i] == 0) return ((char *)NULL); 82 82 83 for (j = i; ((string[j] != 0) && ! whitespace(string[j])); j++);83 for (j = i; ((string[j] != 0) && !OHANA_WHITESPACE (string[j])); j++); 84 84 if (i == j) return ((char *) NULL); 85 85 … … 122 122 if (string == (char *) NULL) return ((char *) NULL); 123 123 124 for (i = 0; whitespace(string[i]); i++);124 for (i = 0; OHANA_WHITESPACE (string[i]); i++); 125 125 if (string[i] == 0) return ((char *)NULL); 126 126 … … 134 134 } 135 135 i++; 136 for (; (string[i] != 0) && whitespace(string[i]); i++);136 for (; (string[i] != 0) && OHANA_WHITESPACE (string[i]); i++); 137 137 if (string[i] == 0) return ((char *) NULL); 138 138 return (&string[i]); … … 155 155 return ((char *)NULL); 156 156 } 157 for (; (string[i] != 0) && whitespace(string[i]); i++);157 for (; (string[i] != 0) && OHANA_WHITESPACE (string[i]); i++); 158 158 if (string[i] == 0) return ((char *) NULL); 159 159 return (&string[i]); … … 161 161 162 162 if (string[i] == ';') i++; 163 for (; (string[i] != 0) && (string[i] != ';') && ! whitespace(string[i]); i++);164 for (; (string[i] != 0) && whitespace(string[i]); i++);163 for (; (string[i] != 0) && (string[i] != ';') && !OHANA_WHITESPACE(string[i]); i++); 164 for (; (string[i] != 0) && OHANA_WHITESPACE (string[i]); i++); 165 165 if (string[i] == 0) return ((char *) NULL); 166 166 … … 169 169 170 170 /* returns a pointer to the next command, or (char *) NULL 171 if there is not a next command. A command is bounded by whitespace*/171 if there is not a next command. A command is bounded by WHITESPACE */ 172 172 char *nextcomm (char *string) { 173 173 … … 176 176 if (string == (char *) NULL) return ((char *) NULL); 177 177 178 for (i = 0; (string[i] != 0) && ! whitespace(string[i]); i++);178 for (i = 0; (string[i] != 0) && !OHANA_WHITESPACE (string[i]); i++); 179 179 if (string[i] == 0) return ((char *) NULL); 180 180 181 for (; whitespace(string[i]); i++);181 for (; OHANA_WHITESPACE (string[i]); i++); 182 182 if (string[i] == 0) return ((char *) NULL); 183 183 … … 193 193 if (c == (char *) NULL) return ((char *) NULL); 194 194 195 for (; ! whitespace(*c) && (c >= string); c--);195 for (; !OHANA_WHITESPACE(*c) && (c >= string); c--); 196 196 if (c < string) return ((char *)NULL); 197 197 198 for (; whitespace(*c) && (c >= string); c--);198 for (; OHANA_WHITESPACE(*c) && (c >= string); c--); 199 199 if (c < string) 200 200 return ((char *)NULL); 201 for (; ! whitespace(*c) && (c >= string); c--);201 for (; !OHANA_WHITESPACE(*c) && (c >= string); c--); 202 202 c++; 203 203 return (c); … … 207 207 208 208 /* take a pointer to the beginning of a variable (ie $fred) and return 209 a pointer to the next thing (non whitespace) which is not part of the209 a pointer to the next thing (non WHITESPACE) which is not part of the 210 210 variable extract only the variable name */ 211 211 … … 224 224 if (i == start) return ((char *) NULL); 225 225 226 for (j = i; whitespace(string[j]); j++);226 for (j = i; OHANA_WHITESPACE (string[j]); j++); 227 227 if (string[j] == 0) return ((char *)NULL); 228 228 … … 240 240 if (c == (char *) NULL) return ((char *) NULL); 241 241 242 for (; (c >= string) && whitespace(*c); c--);242 for (; (c >= string) && OHANA_WHITESPACE(*c); c--); 243 243 if (c < string) return ((char *)NULL); 244 244
Note:
See TracChangeset
for help on using the changeset viewer.
