[girl] Add test of endianess.



commit fd5f80ccdc0a6457bc76b411debaf11dddadc1ef
Author: Ole Aamot <oka oka no>
Date:   Tue May 26 13:36:42 2015 +0200

    Add test of endianess.

 src/test-endianess.c |   55 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 55 insertions(+), 0 deletions(-)
---
diff --git a/src/test-endianess.c b/src/test-endianess.c
new file mode 100644
index 0000000..490df17
--- /dev/null
+++ b/src/test-endianess.c
@@ -0,0 +1,55 @@
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <locale.h>
+#include "date-endian.h"
+
+static int verbose = 0;
+
+static void
+print_endianess (const char *lang)
+{
+       DateEndianess endianess;
+
+       if (lang != NULL) {
+               setlocale (LC_TIME, lang);
+               endianess = date_endian_get_for_lang (lang, verbose);
+       } else {
+               endianess = date_endian_get_default (verbose);
+       }
+       if (verbose)
+               g_print ("\t\t%s\n", date_endian_to_string (endianess));
+}
+
+int main (int argc, char **argv)
+{
+       GDir *dir;
+       const char *name;
+
+       setlocale (LC_ALL, "");
+       bind_textdomain_codeset ("libc", "UTF-8");
+
+       if (argv[1] != NULL) {
+               verbose = 1;
+
+               if (g_str_equal (argv[1], "-c"))
+                       print_endianess (NULL);
+               else
+                       print_endianess (argv[1]);
+               return 0;
+       }
+
+       dir = g_dir_open ("/usr/share/i18n/locales/", 0, NULL);
+       if (dir == NULL) {
+               /* Try with /usr/share/locale/
+                * https://bugzilla.gnome.org/show_bug.cgi?id=646780 */
+               dir = g_dir_open ("/usr/share/locale/", 0, NULL);
+               if (dir == NULL) {
+                       return 1;
+               }
+       }
+
+       while ((name = g_dir_read_name (dir)) != NULL)
+               print_endianess (name);
+
+       return 0;
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]