]> granicus.if.org Git - icu/commitdiff
ICU-9426 Fix pkgdata option file detection
authorMichael Ow <mow@svn.icu-project.org>
Fri, 27 Jul 2012 18:38:08 +0000 (18:38 +0000)
committerMichael Ow <mow@svn.icu-project.org>
Fri, 27 Jul 2012 18:38:08 +0000 (18:38 +0000)
X-SVN-Rev: 32074

icu4c/source/tools/pkgdata/pkgdata.cpp

index 976324940382d13f1859e433cb88c269ecad7bc7..acc2a60f8dc476979a6bb3193d801910854a09b0 100644 (file)
@@ -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;