Changeset 15878 for trunk/Ohana/src/opihi/lib.shell/string.c
- Timestamp:
- Dec 16, 2007, 2:27:00 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/lib.shell/string.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/lib.shell/string.c
r10732 r15878 249 249 return (c); 250 250 } 251 252 // append string defined by range start - stop to the end of output, which 253 // currently has an allocated size of Noutput. if this operation would overshoot Noutput, 254 // output is reallocated to a sufficiently large size 255 char *opihi_append (char *output, int *Noutput, char *start, char *stop) { 256 257 int N1, N2, outlen; 258 259 // a NULL end pointer means 'go to end of line' 260 if (stop == NULL) { 261 stop = start + strlen(start); 262 } 263 264 // enough space? 265 N1 = strlen(output); 266 N2 = stop - start; 267 outlen = N1 + N2; 268 if (outlen >= *Noutput) { 269 *Noutput = outlen + 128; 270 REALLOCATE (output, char, *Noutput); 271 memset (&output[N1], 0, N2 + 128); 272 } 273 274 strncat (output, start, stop - start); 275 return output; 276 } 277 278 /* replace all instances of \A with A in line */ 279 void interpolate_slash (char *line) { 280 281 char *in, *out; 282 283 for (in = out = line; *in != 0; in++, out++) { 284 if (*in == 0x5c) in++; 285 *out = *in; 286 if (*in == 0) return; 287 } 288 *out = *in; 289 }
Note:
See TracChangeset
for help on using the changeset viewer.
