The following commit has been merged in the master branch:
commit 90526758c5cfc9bbec8d7c7e214e9393892a1b67
Author: Guillem Jover <[email protected]>
Date: Sun Sep 6 06:45:39 2009 +0200
Use m_output instead of fflush, ferror and werr
diff --git a/dpkg-deb/build.c b/dpkg-deb/build.c
index 9be1fa9..1db5038 100644
--- a/dpkg-deb/build.c
+++ b/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.
diff --git a/dpkg-deb/info.c b/dpkg-deb/info.c
index 6f6ec84..0f2375c 100644
--- a/dpkg-deb/info.c
+++ b/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) {
diff --git a/dpkg-split/info.c b/dpkg-split/info.c
index 3ea50e5..10fc9d0 100644
--- a/dpkg-split/info.c
+++ b/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>"));
}
}
diff --git a/dpkg-split/main.c b/dpkg-split/main.c
index b019a2b..0e0c8f6 100644
--- a/dpkg-split/main.c
+++ b/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);
diff --git a/dpkg-split/queue.c b/dpkg-split/queue.c
index 183598e..edfa5fc 100644
--- a/dpkg-split/queue.c
+++ b/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 };
diff --git a/dselect/method.cc b/dselect/method.cc
index fcb7319..b1d9878 100644
--- a/dselect/method.cc
+++ b/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"));
diff --git a/lib/dpkg/database.c b/lib/dpkg/database.c
index cc9dd85..1fb79cb 100644
--- a/lib/dpkg/database.c
+++ b/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);
}
diff --git a/src/archives.c b/src/archives.c
index 598b5df..f9f95a8 100644
--- a/src/archives.c
+++ b/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);
diff --git a/src/enquiry.c b/src/enquiry.c
index dcea3ae..3829df6 100644
--- a/src/enquiry.c
+++ b/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 {
diff --git a/src/packages.c b/src/packages.c
index b176581..a9983c4 100644
--- a/src/packages.c
+++ b/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);
}
diff --git a/src/query.c b/src/query.c
index 48eacc0..46bdfde 100644
--- a/src/query.c
+++ b/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);
diff --git a/src/select.c b/src/select.c
index 8d8a963..1cd1060 100644
--- a/src/select.c
+++ b/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);
}
--
dpkg's main repository
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]