diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2010-07-05 12:28:48 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2010-07-05 12:28:48 +0000 |
commit | 96f158297795ebcf6033875cb43144cd39e4e3a6 (patch) | |
tree | 914ff4998491983ebaf059b70bfc35fca42831a9 /winsup/utils/dump_setup.cc | |
parent | 6259826eb42c86df34de98158c424060f98e3fa9 (diff) | |
download | cygnal-96f158297795ebcf6033875cb43144cd39e4e3a6.tar.gz cygnal-96f158297795ebcf6033875cb43144cd39e4e3a6.tar.bz2 cygnal-96f158297795ebcf6033875cb43144cd39e4e3a6.zip |
* dump_setup.cc (dump_file): Read requested content from setup.rc
file created by newer setup.exe.
Diffstat (limited to 'winsup/utils/dump_setup.cc')
-rw-r--r-- | winsup/utils/dump_setup.cc | 39 |
1 files changed, 26 insertions, 13 deletions
diff --git a/winsup/utils/dump_setup.cc b/winsup/utils/dump_setup.cc index e3dacde6c..e788f3982 100644 --- a/winsup/utils/dump_setup.cc +++ b/winsup/utils/dump_setup.cc @@ -1,6 +1,6 @@ /* dump_setup.cc - Copyright 2001 Red Hat, Inc. + Copyright 2001, 2002, 2003, 2004, 2005, 2008, 2010 Red Hat, Inc. This file is part of Cygwin. @@ -141,21 +141,34 @@ parse_filename (const char *in_fn, fileparse& f) static bool dump_file (const char *msg, const char *fn) { - char *path = cygpath ("/etc/setup/", fn, NULL); - FILE *fp = fopen (path, "rt"); - bool printed; char buf[4096]; - if (!fp) - printed = false; - else if (!fgets (buf, 4096, fp)) - printed = false; + bool printed = false; + bool found = false; + size_t len = strlen (fn); + char *path = cygpath ("/etc/setup/setup.rc", NULL); + FILE *fp = fopen (path, "rt"); + + if (fp) { - char *p = strchr (buf, '\0'); - printf ("%s%s%s", msg, buf, (p == buf) || p[-1] != '\n' ? "\n" : ""); - printed = true; + while (fgets (buf, 4096, fp)) + { + if (found) + { + char *bufp = buf; + + if (*bufp == '\t') + ++bufp; + char *p = strchr (bufp, '\0'); + printf ("%s%s%s", msg, bufp, + (p == bufp) || p[-1] != '\n' ? "\n" : ""); + printed = true; + break; + } + if (!strncmp (buf, fn, len) && buf[len] == '\n') + found = true; + } + fclose (fp); } - if (fp) - fclose (fp); return printed; } |