From d134b120de0eecc1975688bcdb5179c50a0f4bff Mon Sep 17 00:00:00 2001 From: Michael Ow Date: Fri, 27 Jul 2012 18:38:08 +0000 Subject: [PATCH] ICU-9426 Fix pkgdata option file detection X-SVN-Rev: 32074 --- icu4c/source/tools/pkgdata/pkgdata.cpp | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/icu4c/source/tools/pkgdata/pkgdata.cpp b/icu4c/source/tools/pkgdata/pkgdata.cpp index 97632494038..acc2a60f8dc 100644 --- a/icu4c/source/tools/pkgdata/pkgdata.cpp +++ b/icu4c/source/tools/pkgdata/pkgdata.cpp @@ -1965,29 +1965,21 @@ static void loadLists(UPKGOptions *o, UErrorCode *status) p = popen(cmdBuf, "r"); } - if(p == NULL) { + if(p == NULL || (n = fread(buf, 1, 511, p)) <= 0) { if(verbose) { fprintf(stdout, "# Calling icu-config: %s\n", cmd); } - p = popen(cmd, "r"); - } + pclose(p); - if(p == NULL) - { - fprintf(stderr, "%s: icu-config: No icu-config found. (fix PATH or use -O option)\n", progname); - return -1; + p = popen(cmd, "r"); + if(p == NULL || (n = fread(buf, 1, 511, p)) <= 0) { + fprintf(stderr, "%s: icu-config: No icu-config found. (fix PATH or use -O option)\n", progname); + return -1; + } } - n = fread(buf, 1, 511, p); - pclose(p); - if(n<=0) - { - fprintf(stderr,"%s: icu-config: Could not read from icu-config. (fix PATH or use -O option)\n", progname); - return -1; - } - for (int32_t length = strlen(buf) - 1; length >= 0; length--) { if (buf[length] == '\n' || buf[length] == ' ') { buf[length] = 0;