From 7a4555091701d850b2a1d9873da2f4245fb082be Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Sun, 10 Mar 2013 00:42:37 +0100 Subject: [PATCH] Report errors when setlocale() fails --- src/main.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main.c b/src/main.c index f304ad6..7107575 100644 --- a/src/main.c +++ b/src/main.c @@ -1,5 +1,5 @@ /* $Id$ */ -/* Copyright (c) 2011 Pierre Pronchery */ +/* Copyright (c) 2010-2013 Pierre Pronchery */ /* This file is part of DeforaOS Desktop Phone */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -37,12 +37,23 @@ #endif +/* phone */ /* private */ /* prototypes */ +static int _error(char const * message, int ret); static int _usage(void); /* functions */ +/* error */ +static int _error(char const * message, int ret) +{ + fputs("phone: ", stderr); + perror(message); + return ret; +} + + /* usage */ static int _usage(void) { @@ -65,7 +76,8 @@ int main(int argc, char * argv[]) int retry = -1; char * p; - setlocale(LC_ALL, ""); + if(setlocale(LC_ALL, "") == NULL) + _error("setlocale", 1); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); gtk_init(&argc, &argv);