… | |
… | |
233 | } |
233 | } |
234 | |
234 | |
235 | return path; |
235 | return path; |
236 | } |
236 | } |
237 | |
237 | |
238 | void |
238 | static void |
239 | path_normalize (char *path) |
239 | path_normalize (char *path) |
240 | { |
240 | { |
241 | char *p; /* points to the beginning of the path not yet processed; this is |
241 | char *p; /* points to the beginning of the path not yet processed; this is |
242 | either a path component or a path separator character */ |
242 | either a path component or a path separator character */ |
243 | char *q; /* points to the end of the path component p points to */ |
243 | char *q; /* points to the end of the path component p points to */ |
… | |
… | |
314 | path = path_combine (src, dst); |
314 | path = path_combine (src, dst); |
315 | path_normalize (path); |
315 | path_normalize (path); |
316 | return (path); |
316 | return (path); |
317 | } |
317 | } |
318 | |
318 | |
319 | char * |
|
|
320 | strcasestr_local (const char *s, const char *find) |
|
|
321 | { |
|
|
322 | char c, sc; |
|
|
323 | size_t len; |
|
|
324 | |
|
|
325 | if ((c = *find++) != 0) |
|
|
326 | { |
|
|
327 | c = tolower (c); |
|
|
328 | len = strlen (find); |
|
|
329 | do |
|
|
330 | { |
|
|
331 | do |
|
|
332 | { |
|
|
333 | if ((sc = *s++) == 0) |
|
|
334 | return NULL; |
|
|
335 | } |
|
|
336 | while (tolower (sc) != c); |
|
|
337 | } |
|
|
338 | while (strncasecmp (s, find, len) != 0); |
|
|
339 | s--; |
|
|
340 | } |
|
|
341 | return (char *) s; |
|
|
342 | } |
|
|
343 | |
|
|
344 | /** |
319 | /** |
345 | * open_and_uncompress() first searches for the original filename. If it exist, |
320 | * open_and_uncompress() first searches for the original filename. If it exist, |
346 | * then it opens it and returns the file-pointer. |
321 | * then it opens it and returns the file-pointer. |
347 | */ |
322 | */ |
348 | FILE * |
323 | FILE * |
… | |
… | |
388 | dest++; |
363 | dest++; |
389 | } |
364 | } |
390 | src++; |
365 | src++; |
391 | } |
366 | } |
392 | *dest = '\0'; |
367 | *dest = '\0'; |
393 | } |
|
|
394 | |
|
|
395 | const char * |
|
|
396 | strrstr (const char *haystack, const char *needle) |
|
|
397 | { |
|
|
398 | const char *lastneedle; |
|
|
399 | |
|
|
400 | lastneedle = NULL; |
|
|
401 | while ((haystack = strstr (haystack, needle)) != NULL) |
|
|
402 | { |
|
|
403 | lastneedle = haystack; |
|
|
404 | haystack++; |
|
|
405 | } |
|
|
406 | return lastneedle; |
|
|
407 | |
|
|
408 | } |
368 | } |
409 | |
369 | |
410 | #define EOL_SIZE (sizeof("\n")-1) |
370 | #define EOL_SIZE (sizeof("\n")-1) |
411 | void |
371 | void |
412 | strip_endline (char *buf) |
372 | strip_endline (char *buf) |