Checking errors when setting the locale

This commit is contained in:
Pierre Pronchery 2013-12-09 00:22:10 +01:00
parent d8504da7e2
commit 8fc6dbdd74

View File

@ -23,7 +23,6 @@
#include "../config.h" #include "../config.h"
#define _(string) gettext(string) #define _(string) gettext(string)
/* constants */ /* constants */
#ifndef PREFIX #ifndef PREFIX
# define PREFIX "/usr/local" # define PREFIX "/usr/local"
@ -36,11 +35,25 @@
#endif #endif
/* prototypes */
static int _error(char const * message, int ret);
static int _usage(void);
/* functions */ /* functions */
/* error */
static int _error(char const * message, int ret)
{
fputs("xmleditor: ", stderr);
perror(message);
return ret;
}
/* usage */ /* usage */
static int _usage(void) static int _usage(void)
{ {
fputs(_("Usage: xmleditor [file]\n"), stderr); fputs(_("Usage: xmleditor [filename]\n"), stderr);
return 1; return 1;
} }
@ -51,7 +64,8 @@ int main(int argc, char * argv[])
int o; int o;
XMLEditor * xmleditor; XMLEditor * xmleditor;
setlocale(LC_ALL, ""); if(setlocale(LC_ALL, "") == NULL)
_error("setlocale", 1);
bindtextdomain(PACKAGE, LOCALEDIR); bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE); textdomain(PACKAGE);
gtk_init(&argc, &argv); gtk_init(&argc, &argv);