bug-hello
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 4/7] use standard error printing facilities


From: Sami Kerola
Subject: [PATCH 4/7] use standard error printing facilities
Date: Mon, 30 Dec 2013 11:58:22 +0000

* bootstrap.conf: add error module
* src/hello.c: use error() where needed
---
 bootstrap.conf |  1 +
 src/hello.c    | 10 ++++------
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/bootstrap.conf b/bootstrap.conf
index a1ca8b5..82766f3 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -23,6 +23,7 @@ gnulib_modules="
     configmake
     do-release-commit-and-tag
     dirname
+    error
     fdl
     gendocs
     getopt-gnu
diff --git a/src/hello.c b/src/hello.c
index 90b1c08..c475840 100644
--- a/src/hello.c
+++ b/src/hello.c
@@ -18,6 +18,8 @@
 
 #include <config.h>
 #include "system.h"
+#include "errno.h"
+#include "error.h"
 #include "progname.h"
 #include "progname.h"
 #include "propername.h"
@@ -88,17 +90,13 @@ main (int argc, char *argv[])
   if (optind < argc)
     {
       /* Print error message and exit.  */
-      fprintf (stderr, _("%s: extra operand: %s\n"), program_name,
-               argv[optind]);
+      error (0, 0, "%s: %s", _("extra operand"), argv[optind]);
       usage (EXIT_FAILURE);
     }
 
   len = mbsrtowcs(NULL, &greeting_msg, 0, NULL);
   if (len == (size_t)-1)
-    {
-      fprintf (stderr, _("%s: conversion to a multibyte string failed\n"), 
program_name);
-      exit (EXIT_FAILURE);
-    }
+    error (EXIT_FAILURE, errno, _("conversion to a multibyte string failed"));
   mb_greeting = xmalloc((len + 1) * sizeof(wchar_t));
   mbsrtowcs(mb_greeting, &greeting_msg, len + 1, NULL);
 
-- 
1.8.5.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]