From 122bb298a32b3db3ddd879181ad2d5f3b0f1e40e Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Thu, 12 Jan 2006 11:58:59 +0000 Subject: [PATCH] Update call to dump_ld_config. --- tools/dump_ld_config.c | 43 +++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/tools/dump_ld_config.c b/tools/dump_ld_config.c index 95dd2ae..ca5431e 100644 --- a/tools/dump_ld_config.c +++ b/tools/dump_ld_config.c @@ -153,20 +153,37 @@ parse_include_pattern(const char *filename, const char *pattern) { char *newp = NULL, *p; - if (prefix && pattern[0] == '/') + if (prefix) { - newp = xmalloc(strlen(prefix) + strlen(pattern) + 1); - strcpy(newp, prefix); - strcat(newp, pattern); - pattern = newp; - } else if (pattern[0] != '/' && (p = strrchr(filename, '/'))) - { - size_t patlen = strlen(pattern) + 1; + if (pattern[0] == '/') + { + newp = xmalloc(strlen(prefix) + strlen(pattern) + 1); + strcpy(newp, prefix); + strcat(newp, pattern); + pattern = newp; + } else if ((p = strrchr(filename, '/'))) + { + size_t preflen = strlen(prefix); + size_t patlen = strlen(pattern) + 1; - newp = xmalloc(p - filename + 1 + patlen); - memcpy(newp, filename, p - filename + 1); - memcpy(newp + (p - filename + 1), pattern, patlen); - pattern = newp; + newp = xmalloc(p - filename + 1 + preflen + patlen); + memcpy(newp, prefix, preflen); + memcpy(newp + preflen, filename, p - filename + 1); + memcpy(newp + (p - filename + 1 + preflen), pattern, + patlen); + pattern = newp; + } + } else + { + if (pattern[0] != '/' && (p = strrchr(filename, '/'))) + { + size_t patlen = strlen(pattern) + 1; + + newp = xmalloc(p - filename + 1 + patlen); + memcpy(newp, filename, p - filename + 1); + memcpy(newp + (p - filename + 1), pattern, patlen); + pattern = newp; + } } glob_t gl; @@ -253,7 +270,7 @@ main(int ac, char **av) return 1; prefix = av[2]; } - if (ac > 1) + if (ac > 1 && av[1][0]) fname = av[1]; parse_file(fname);