Locale support for status-time
authorStiletto <blasux@blasux.ru>
Fri, 24 Oct 2014 14:13:46 +0400
changeset 10 442bed4a072e
parent 9 96b47c0505b5
child 11 ad3d40f11f6d
Locale support for status-time
config.mk
status-time/Makefile
status-time/config.def.h
status-time/config.mk
status-time/time.c
--- a/config.mk	Thu Oct 23 20:49:34 2014 +0400
+++ b/config.mk	Fri Oct 24 14:13:46 2014 +0400
@@ -13,8 +13,8 @@
 STATUS_LIBS = -L/usr/lib
 STATUS_INCS =
 STATUS_CPPFLAGS = -DVERSION=\"${VERSION}\"
-STATUS_CFLAGS = -std=c99 -pedantic -Wall -Os ${STATUS_INCS} ${STATUS_CPPFLAGS}
-STATUS_LDFLAGS = ${STATUS_LIBS} -static
+STATUS_CFLAGS = -g -std=c99 -pedantic -Wall -Os ${STATUS_INCS} ${STATUS_CPPFLAGS}
+STATUS_LDFLAGS = -g ${STATUS_LIBS} -static
 
 STATUS = status-time status-mem status-loadavg status-wifi status-bat
 # compiler and linker
--- a/status-time/Makefile	Thu Oct 23 20:49:34 2014 +0400
+++ b/status-time/Makefile	Fri Oct 24 14:13:46 2014 +0400
@@ -2,6 +2,7 @@
 # See LICENSE file for copyright and license details.
 
 include ../config.mk
+include config.mk
 
 OUT = status-time
 SRC = time.c
--- a/status-time/config.def.h	Thu Oct 23 20:49:34 2014 +0400
+++ b/status-time/config.def.h	Fri Oct 24 14:13:46 2014 +0400
@@ -1,3 +1,4 @@
 #define TIMEZONE "Europe/Moscow"
 #define TIMEFORMAT "%d.%m.%Y %H:%M"
+#define LOCALE "" // comment out to disable locale support
 #define UPDATE_PERIOD 1
--- a/status-time/config.mk	Thu Oct 23 20:49:34 2014 +0400
+++ b/status-time/config.mk	Fri Oct 24 14:13:46 2014 +0400
@@ -0,0 +1,3 @@
+# setlocale is broken in statically-linked binaries
+# comment out the following line if you don't need it
+STATUS_LDFLAGS = ${STATUS_LIBS}
--- a/status-time/time.c	Thu Oct 23 20:49:34 2014 +0400
+++ b/status-time/time.c	Fri Oct 24 14:13:46 2014 +0400
@@ -8,6 +8,9 @@
 #include <time.h>
 
 #include "config.h"
+#ifdef LOCALE
+#include <locale.h>
+#endif
 
 int
 main(void)
@@ -15,6 +18,9 @@
     char buf[129];
     time_t tim;
     struct tm *timtm;
+#ifdef LOCALE
+    setlocale(LC_TIME, LOCALE);
+#endif
 
     setenv("TZ", TIMEZONE, 1);