]> pd.if.org Git - pdclib/commitdiff
PDCLIB-1 uselocale
authorOwen Shepherd <owen.shepherd@e43.eu>
Tue, 1 Jan 2013 21:11:07 +0000 (21:11 +0000)
committerOwen Shepherd <owen.shepherd@e43.eu>
Tue, 1 Jan 2013 21:11:07 +0000 (21:11 +0000)
functions/locale/uselocale.c [new file with mode: 0644]

diff --git a/functions/locale/uselocale.c b/functions/locale/uselocale.c
new file mode 100644 (file)
index 0000000..718def7
--- /dev/null
@@ -0,0 +1,34 @@
+/* uselocale( locale_t )
+
+   This file is part of the Public Domain C Library (PDCLib).
+   Permission is granted to use, modify, and / or redistribute at will.
+*/
+
+#include <locale.h>
+#ifndef REGTEST
+#include <_PDCLIB_locale.h>
+
+locale_t uselocale( locale_t newloc )
+{
+    locale_t oldloc = _PDCLIB_threadlocale();
+
+    if(newloc == LC_GLOBAL_LOCALE) {
+        _PDCLIB_setthreadlocale(NULL);
+    } else if(newloc != NULL) {
+        _PDCLIB_setthreadlocale(newloc);
+    }
+
+    return oldloc;
+}
+
+#endif
+
+#ifdef TEST
+#include <_PDCLIB_test.h>
+
+int main( void )
+{
+    TESTCASE( NO_TESTDRIVER );
+    return TEST_RESULTS;
+}
+#endif