diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-11-23 01:52:21 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-11-23 01:52:21 +0000 |
commit | 5f9a6d1dee33e015f8750f38c46844047d9768b9 (patch) | |
tree | 581bc91de9fc25dc54f206a7a999237143b5fd18 /dln.c | |
parent | cd4a0ce764b6b2f378deb17cf69a13eddea85563 (diff) |
* dln.c (dln_find_1): removed duplication.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25886 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'dln.c')
-rw-r--r-- | dln.c | 13 |
1 files changed, 6 insertions, 7 deletions
@@ -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); |