From 82d86ad7c741c3048c0bccdc18f52576708602a4 Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Sat, 30 Jun 2012 12:33:55 +0200 Subject: Fix compilation with NLS disabled * src/utils.c: Only call setlocale() if NLS is enabled. * src/calcurse.h: Define a fallback macro ngettext() if NLS is disabled. Signed-off-by: Lukas Fleischer --- src/calcurse.h | 1 + src/utils.c | 4 ++++ 2 files changed, 5 insertions(+) (limited to 'src') diff --git a/src/calcurse.h b/src/calcurse.h index 9f01f48..7259dd1 100644 --- a/src/calcurse.h +++ b/src/calcurse.h @@ -76,6 +76,7 @@ #define gettext(String) (String) #define dgettext(String) (String) #define dcgettext(String) (String) +#define ngettext(String1,String2,n) ((n) == 1 ? (String1) : (String2)) #define bindtextdomain(String) (String) #define bind_textdomain_codeset(Domain,Codeset) (Codeset) #endif /* ENABLE_NLS */ diff --git a/src/utils.c b/src/utils.c index 3ca89c2..14de867 100644 --- a/src/utils.c +++ b/src/utils.c @@ -383,15 +383,19 @@ char *date_sec2date_str(long sec, const char *datefmt) /* Generic function to format date. */ void date_sec2date_fmt(long sec, const char *fmt, char *datef) { +#if ENABLE_NLS /* TODO: Find a better way to deal with localization and strftime(). */ char *locale_old = mem_strdup (setlocale (LC_ALL, NULL)); setlocale (LC_ALL, "C"); +#endif struct tm *lt = localtime((time_t *)&sec); strftime(datef, BUFSIZ, fmt, lt); +#if ENABLE_NLS setlocale (LC_ALL, locale_old); mem_free (locale_old); +#endif } /* -- cgit v1.2.3-70-g09d2