diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2010-07-05 16:28:48 +0400 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2010-07-05 16:28:48 +0400 |
commit | 96f158297795ebcf6033875cb43144cd39e4e3a6 (patch) | |
tree | 914ff4998491983ebaf059b70bfc35fca42831a9 | |
parent | 6259826eb42c86df34de98158c424060f98e3fa9 (diff) |
* dump_setup.cc (dump_file): Read requested content from setup.rc
file created by newer setup.exe.
-rw-r--r-- | winsup/utils/ChangeLog | 5 | ||||
-rw-r--r-- | winsup/utils/dump_setup.cc | 39 |
2 files changed, 31 insertions, 13 deletions
diff --git a/winsup/utils/ChangeLog b/winsup/utils/ChangeLog index a1747d59d..b72b39195 100644 --- a/winsup/utils/ChangeLog +++ b/winsup/utils/ChangeLog @@ -1,3 +1,8 @@ +2010-07-05 Corinna Vinschen <corinna@vinschen.de> + + * dump_setup.cc (dump_file): Read requested content from setup.rc + file created by newer setup.exe. + 2010-06-29 Corinna Vinschen <corinna@vinschen.de> * utils.sgml (locale): Change stray local cygdrive prefix to Cygwin's 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; } |