1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* dln.c (dln_find_1): removed duplication.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25886 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2009-11-23 01:52:21 +00:00
parent cd4a0ce764
commit 5f9a6d1dee
2 changed files with 10 additions and 7 deletions

View file

@ -1,3 +1,7 @@
Mon Nov 23 10:52:19 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* dln.c (dln_find_1): removed duplication.
Mon Nov 23 04:12:00 2009 Tanaka Akira <akr@fsij.org> Mon Nov 23 04:12:00 2009 Tanaka Akira <akr@fsij.org>
* enc/trans/newline.trans (fun_so_universal_newline): generate \n * enc/trans/newline.trans (fun_so_universal_newline): generate \n

13
dln.c
View file

@ -1560,6 +1560,10 @@ dln_find_1(const char *fname, const char *path, char *fbuf, size_t size,
const char *p = fname; const char *p = fname;
#endif #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; #define RETURN_IF(expr) if (expr) return (char *)fname;
RETURN_IF(!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); i = strlen(fname);
if (fspace < i) { if (fspace < i) {
toolong: toolong:
fprintf(stderr, "openpath: pathname too long (ignored)\n"); PATHNAME_TOO_LONG();
*bp = '\0';
fprintf(stderr, "\tDirectory \"%s\"\n", fbuf);
fprintf(stderr, "\tFile \"%s\"\n", fname);
goto next; goto next;
} }
fspace -= i; fspace -= i;
@ -1695,9 +1696,7 @@ dln_find_1(const char *fname, const char *path, char *fbuf, size_t size,
needs_extension: needs_extension:
for (j = 0; j < sizeof(extension) / sizeof(extension[0]); j++) { for (j = 0; j < sizeof(extension) / sizeof(extension[0]); j++) {
if (fspace < strlen(extension[j])) { if (fspace < strlen(extension[j])) {
fprintf(stderr, "openpath: pathname too long (ignored)\n"); PATHNAME_TOO_LONG();
fprintf(stderr, "\tDirectory \"%.*s\"\n", (int) (bp - fbuf), fbuf);
fprintf(stderr, "\tFile \"%s%s\"\n", fname, extension[j]);
continue; continue;
} }
strlcpy(bp + i, extension[j], fspace); strlcpy(bp + i, extension[j], fspace);