* 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>
* 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;
#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);