ソースを参照

Use m_output instead of fflush, ferror and werr

Guillem Jover 17 年 前
コミット
90526758c5
共有12 個のファイルを変更した36 個の追加32 個の削除を含む
  1. 1 1
      dpkg-deb/build.c
  2. 1 1
      dpkg-deb/info.c
  3. 1 1
      dpkg-split/info.c
  4. 1 1
      dpkg-split/main.c
  5. 3 3
      dpkg-split/queue.c
  6. 1 2
      dselect/method.cc
  7. 3 1
      lib/dpkg/database.c
  8. 2 2
      src/archives.c
  9. 9 8
      src/enquiry.c
  10. 2 2
      src/packages.c
  11. 9 8
      src/query.c
  12. 3 2
      src/select.c

+ 1 - 1
dpkg-deb/build.c

@@ -354,7 +354,7 @@ void do_build(const char *const *argv) {
     if (warns)
       warning(_("ignoring %d warnings about the control file(s)\n"), warns);
   }
-  if (ferror(stdout)) werr("stdout");
+  m_output(stdout, _("<standard output>"));
   
   /* Now that we have verified everything its time to actually
    * build something. Lets start by making the ar-wrapper.

+ 1 - 1
dpkg-deb/info.c

@@ -227,7 +227,7 @@ static void info_field(const char *debar, const char *directory,
   }
   if (ferror(cc)) ohshite(_("failed during read of `control' component"));
   if (doing) putc('\n',stdout);
-  if (ferror(stdout)) werr("stdout");
+  m_output(stdout, _("<standard output>"));
 }
 
 void do_showinfo(const char* const* argv) {

+ 1 - 1
dpkg-split/info.c

@@ -238,6 +238,6 @@ void do_info(const char *const *argv) {
     } else {
       printf(_("file `%s' is not an archive part\n"),thisarg);
     }
-    if (ferror(stdout)) werr("stdout");
+    m_output(stdout, _("<standard output>"));
   }
 }

+ 1 - 1
dpkg-split/main.c

@@ -191,7 +191,7 @@ int main(int argc, const char *const *argv) {
   setvbuf(stdout,NULL,_IONBF,0);
   action(argv);
 
-  if (ferror(stderr)) werr("stderr");
+  m_output(stderr, _("<standard error>"));
   
   standard_shutdown();
   exit(0);

+ 3 - 3
dpkg-split/queue.c

@@ -122,7 +122,7 @@ void do_auto(const char *const *argv) {
   if (!read_info(part,partfile,refi)) {
     if (!npquiet)
       printf(_("File `%.250s' is not part of a multipart archive.\n"),partfile);
-    if (fclose(stdout)) werr("stdout");
+    m_output(stdout, _("<standard output>"));
     exit(1);
   }
   fclose(part);
@@ -189,7 +189,7 @@ void do_auto(const char *const *argv) {
 
   }
 
-  if (ferror(stderr)) werr("stderr");
+  m_output(stderr, _("<standard error>"));
 }
 
 void do_queue(const char *const *argv) {
@@ -242,7 +242,7 @@ void do_queue(const char *const *argv) {
     }
     printf(_("(total %lu bytes)\n"),bytes);
   }
-  if (fclose(stdout)) werr("stdout");
+  m_output(stdout, _("<standard output>"));
 }
 
 enum discardwhich { ds_junk, ds_package, ds_all };

+ 1 - 2
dselect/method.cc

@@ -180,8 +180,7 @@ urqresult falliblesubprocess(const char *exepath, const char *name,
     fprintf(stderr,_("failed with an unknown wait return code %d.\n"),status);
   }
   fprintf(stderr,_("Press <enter> to continue.\n"));
-  if (ferror(stderr))
-    ohshite(_("write error on standard error"));
+  m_output(stderr, _("<standard error>"));
   do { c= fgetc(stdin); } while ((c == ERR && errno==EINTR) || ((c != '\n') && c != EOF));
   if ((c == ERR) || (c == EOF))
     ohshite(_("error reading acknowledgement of program failure message"));

+ 3 - 1
lib/dpkg/database.c

@@ -197,7 +197,9 @@ void hashreport(FILE *file) {
   }
   for (i=npackages; i>0 && freq[i]==0; i--);
   while (i>=0) { fprintf(file,_("size %7d occurs %5d times\n"),i,freq[i]); i--; }
-  if (ferror(file)) ohshite(_("failed write during hashreport"));
+
+  m_output(file, "<hash report>");
+
   free(freq);
 }
 

+ 2 - 2
src/archives.c

@@ -1218,8 +1218,8 @@ void archivefiles(const char *const *argv) {
     push_error_handler(&ejbuf,print_error_perpackage,thisarg);
     process_archive(thisarg);
     onerr_abort++;
-    if (ferror(stdout)) werr("stdout");
-    if (ferror(stderr)) werr("stderr");
+    m_output(stdout, _("<standard output>"));
+    m_output(stderr, _("<standard error>"));
     onerr_abort--;
     set_error_display(NULL, NULL);
     error_unwind(ehflag_normaltidy);

+ 9 - 8
src/enquiry.c

@@ -133,8 +133,7 @@ void audit(const char *const *argv) {
     if (head) putchar('\n');
   }
 
-  if (ferror(stdout))
-    werr("stdout");
+  m_output(stdout, _("<standard output>"));
 }
 
 struct sectionentry {
@@ -235,8 +234,8 @@ void unpackchk(const char *const *argv) {
     }
     putchar('\n');
   }
-  fflush(stdout);
-  if (ferror(stdout)) werr("stdout");
+
+  m_output(stdout, _("<standard output>"));
 }
 
 static void
@@ -378,7 +377,8 @@ void predeppackage(const char *const *argv) {
 
   /* OK, we've found it - pkg has no unsatisfied pre-dependencies ! */
   writerecord(stdout,"<stdout>",pkg,&pkg->available);
-  if (fflush(stdout)) werr("stdout");
+
+  m_output(stdout, _("<standard output>"));
 }
 
 void printarch(const char *const *argv) {
@@ -386,7 +386,8 @@ void printarch(const char *const *argv) {
     badusage(_("--%s takes no arguments"), cipaction->olong);
 
   if (printf("%s\n",architecture) == EOF) werr("stdout");
-  if (fflush(stdout)) werr("stdout");
+
+  m_output(stdout, _("<standard output>"));
 }
 
 void
@@ -445,7 +446,7 @@ void cmpversions(const char *const *argv) {
     if (emsg) {
       if (printf(_("dpkg: version '%s' has bad syntax: %s\n"), argv[0], emsg) == EOF)
         werr("stdout");
-      if (fflush(stdout)) werr("stdout");
+      m_output(stdout, _("<standard output>"));
       exit(1);
     }
   } else {
@@ -456,7 +457,7 @@ void cmpversions(const char *const *argv) {
     if (emsg) {
       if (printf(_("dpkg: version '%s' has bad syntax: %s\n"), argv[2], emsg) == EOF)
         werr("stdout");
-      if (fflush(stdout)) werr("stdout");
+      m_output(stdout, _("<standard output>"));
       exit(1);
     }
   } else {

+ 2 - 2
src/packages.c

@@ -265,8 +265,8 @@ void process_queue(void) {
     default:
       internerr("unknown action '%d'", cipaction->arg);
     }
-    if (ferror(stdout)) werr("stdout");
-    if (ferror(stderr)) werr("stderr");
+    m_output(stdout, _("<standard output>"));
+    m_output(stderr, _("<standard error>"));
     set_error_display(NULL, NULL);
     error_unwind(ehflag_normaltidy);
   }

+ 9 - 8
src/query.c

@@ -179,8 +179,8 @@ void listpackages(const char *const *argv) {
     }
   }
 
-  if (ferror(stdout)) werr("stdout");
-  if (ferror(stderr)) werr("stderr");  
+  m_output(stdout, _("<standard output>"));
+  m_output(stderr, _("<standard error>"));
 
   pkg_array_free(&array);
   modstatdb_shutdown();
@@ -272,9 +272,9 @@ void searchfiles(const char *const *argv) {
     if (!found) {
       fprintf(stderr,_("dpkg: %s not found.\n"),thisarg);
       failures++;
-      if (ferror(stderr)) werr("stderr");
+      m_output(stderr, _("<standard error>"));
     } else {
-      if (ferror(stdout)) werr("stdout");
+      m_output(stdout, _("<standard output>"));
     }
   }
   modstatdb_shutdown();
@@ -366,13 +366,14 @@ void enqperpackage(const char *const *argv) {
 
     if (*(argv + 1) == NULL)
       putchar('\n');
-    if (ferror(stdout)) werr("stdout");
+
+    m_output(stdout, _("<standard output>"));
   }
 
   if (failures) {
     fputs(_("Use dpkg --info (= dpkg-deb --info) to examine archive files,\n"
          "and dpkg --contents (= dpkg-deb --contents) to list their contents.\n"),stderr);
-    if (ferror(stdout)) werr("stdout");
+    m_output(stderr, _("<standard error>"));
   }
   modstatdb_shutdown();
 }
@@ -427,8 +428,8 @@ void showpackages(const char *const *argv) {
     }
   }
 
-  if (ferror(stdout)) werr("stdout");
-  if (ferror(stderr)) werr("stderr");  
+  m_output(stdout, _("<standard output>"));
+  m_output(stderr, _("<standard error>"));
 
   pkg_array_free(&array);
   freeformat(fmt);

+ 3 - 2
src/select.c

@@ -76,8 +76,9 @@ void getselections(const char *const *argv) {
         fprintf(stderr,_("No packages found matching %s.\n"),thisarg);
     }
   }
-  if (ferror(stdout)) werr("stdout");
-  if (ferror(stderr)) werr("stderr");
+
+  m_output(stdout, _("<standard output>"));
+  m_output(stderr, _("<standard error>"));
 
   pkg_array_free(&array);
 }