ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/misc.C
(Generate patch)

Comparing rxvt-unicode/src/misc.C (file contents):
Revision 1.37 by root, Sat Jan 21 23:50:33 2006 UTC vs.
Revision 1.38 by root, Tue Jan 24 19:40:12 2006 UTC

429 429
430/*----------------------------------------------------------------------* 430/*----------------------------------------------------------------------*
431 * file searching 431 * file searching
432 */ 432 */
433 433
434/* #define DEBUG_SEARCH_PATH */
435
436#ifdef XPM_BACKGROUND 434#ifdef XPM_BACKGROUND
437/* 435/*
438 * search for FILE in the current working directory, and within the 436 * search for FILE in the current working directory, and within the
439 * colon-delimited PATHLIST, adding the file extension EXT if required. 437 * colon-delimited PATHLIST, adding the file extension EXT if required.
440 * 438 *
441 * FILE is either semi-colon or zero terminated 439 * FILE is either semi-colon or zero terminated
442 */ 440 */
443char * 441char *
444rxvt_File_search_path (const char *pathlist, const char *file, const char *ext) NOTHROW 442rxvt_File_search_path (const char *pathlist, const char *file, const char *ext) NOTHROW
445{ 443{
446 int maxpath, len; 444 int maxpath, len;
447 const char *p, *path; 445 const char *p, *path;
448 char name[256]; 446 char name[256];
453 /* semi-colon delimited */ 451 /* semi-colon delimited */
454 if ((p = strchr (file, ';'))) 452 if ((p = strchr (file, ';')))
455 len = (p - file); 453 len = (p - file);
456 else 454 else
457 len = strlen (file); 455 len = strlen (file);
458
459#ifdef DEBUG_SEARCH_PATH
460 getcwd (name, sizeof (name));
461 fprintf (stderr, "pwd: \"%s\"\n", name);
462 fprintf (stderr, "find: \"%.*s\"\n", len, file);
463#endif
464 456
465 /* leave room for an extra '/' and trailing '\0' */ 457 /* leave room for an extra '/' and trailing '\0' */
466 maxpath = sizeof (name) - (len + (ext ? strlen (ext) : 0) + 2); 458 maxpath = sizeof (name) - (len + (ext ? strlen (ext) : 0) + 2);
467 if (maxpath <= 0) 459 if (maxpath <= 0)
468 return NULL; 460 return NULL;
510 } 502 }
511 } 503 }
512 return NULL; 504 return NULL;
513} 505}
514 506
515char * 507char *
516rxvt_File_find (const char *file, const char *ext, const char *path) NOTHROW 508rxvt_File_find (const char *file, const char *ext, const char *path) NOTHROW
517{ 509{
518 char *f; 510 char *f;
519 511
520 if (file == NULL || *file == '\0') 512 if (file == NULL || *file == '\0')
521 return NULL; 513 return NULL;
522 514
523 f = rxvt_File_search_path (path, file, ext); 515 f = rxvt_File_search_path (path, file, ext);
524 516
525#ifdef DEBUG_SEARCH_PATH 517 return f;
526 if (f) 518}
527 fprintf (stderr, "found: \"%s\"\n", f);
528#endif 519#endif
529 520
530 return f;
531}
532#endif
533 521
534

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines