Project Info Name.......: gnu-hello
Description: GNU Hello


gnu-hello       
Info
Commit...:5085e1f1fae577ed553e5660300338ce9c4518f5
Author...:Sami Kerola
Committer:Sami Kerola
Date.....:Sat Dec 28 18:13:08 2013 +0000
Parents..:e480417a611ac479f235d423322fadfc1c99f1d7

Message
use standard error printing facilities

* bootstrap.conf: add error module
* src/hello.c: use error() where needed

Changes
diff --git a/bootstrap.conf b/bootstrap.conf
line changes: +2/-0
index 21a1ecd..451a106
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -22,6 +22,8 @@ gnulib_modules="
     closeout
     configmake
     do-release-commit-and-tag
+    dirname
+    error
     fdl
     gendocs
     getopt-gnu

diff --git a/src/hello.c b/src/hello.c
line changes: +5/-10
index fe85539..090a566
--- 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 "xalloc.h"
 
@@ -88,20 +90,13 @@ main (int argc, char *argv[])
   if (lose || optind < argc)
     {
       /* Print error message and exit.  */
-      if (optind < argc)
-	fprintf (stderr, _("%s: extra operand: %s\n"), program_name,
-		 argv[optind]);
-      fprintf (stderr, _("Try `%s --help' for more information.\n"),
-	       program_name);
-      exit (EXIT_FAILURE);
+      error (0, 0, "%s: %s", _("extra operand"), argv[optind]);
+      print_help ();
     }
 
   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);
 

This website is licensed under AGPL-3.0. Feel free to copy!