From 5f9a6d1dee33e015f8750f38c46844047d9768b9 Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 23 Nov 2009 01:52:21 +0000 Subject: [PATCH] * dln.c (dln_find_1): removed duplication. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25886 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ dln.c | 13 ++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 379fc058a2..f0197d9359 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Mon Nov 23 10:52:19 2009 Nobuyoshi Nakada + + * dln.c (dln_find_1): removed duplication. + Mon Nov 23 04:12:00 2009 Tanaka Akira * enc/trans/newline.trans (fun_so_universal_newline): generate \n diff --git a/dln.c b/dln.c index 8b1556eedd..f674fc97a0 100644 --- a/dln.c +++ b/dln.c @@ -1560,6 +1560,10 @@ dln_find_1(const char *fname, const char *path, char *fbuf, size_t size, const char *p = fname; #endif + static const char pathname_too_long[] = "openpath: pathname too long (ignored)\n\ +\tDirectory \"%.*s\"\n\tFile \"%s\"\n" +#define PATHNAME_TOO_LONG() fprintf(stderr, pathname_too_long, (int)(bp - fbuf), fbuf, fname) + #define RETURN_IF(expr) if (expr) return (char *)fname; RETURN_IF(!fname); @@ -1681,10 +1685,7 @@ dln_find_1(const char *fname, const char *path, char *fbuf, size_t size, i = strlen(fname); if (fspace < i) { toolong: - fprintf(stderr, "openpath: pathname too long (ignored)\n"); - *bp = '\0'; - fprintf(stderr, "\tDirectory \"%s\"\n", fbuf); - fprintf(stderr, "\tFile \"%s\"\n", fname); + PATHNAME_TOO_LONG(); goto next; } fspace -= i; @@ -1695,9 +1696,7 @@ dln_find_1(const char *fname, const char *path, char *fbuf, size_t size, needs_extension: for (j = 0; j < sizeof(extension) / sizeof(extension[0]); j++) { if (fspace < strlen(extension[j])) { - fprintf(stderr, "openpath: pathname too long (ignored)\n"); - fprintf(stderr, "\tDirectory \"%.*s\"\n", (int) (bp - fbuf), fbuf); - fprintf(stderr, "\tFile \"%s%s\"\n", fname, extension[j]); + PATHNAME_TOO_LONG(); continue; } strlcpy(bp + i, extension[j], fspace);