source: branches/stable/SOURCE_TOOLS/arb_main.h

Last change on this file was 16936, checked in by westram, 6 years ago
File size: 2.5 KB
Line 
1// ================================================================ //
2//                                                                  //
3//   File      : arb_main.h                                         //
4//   Purpose   : code executed at start of main()                   //
5//                                                                  //
6//   Coded by Ralf Westram (coder@reallysoft.de) in February 2014   //
7//   http://www.arb-home.de/                                        //
8//                                                                  //
9// ================================================================ //
10
11#ifndef ARB_MAIN_H
12#define ARB_MAIN_H
13
14#include <locale.h>
15
16static void start_of_main() {
17    // ARB code depends on locale settings.
18    // To avoid problems we setlocale here!
19
20    // const char *USER_LOCALE = ""; // -> use user-defined locale
21    // const char *USER_LOCALE = "de_DE.UTF-8"; // use german locale
22
23    // --------------------------------------------------------------------------------
24    // Fails-counts mentioned below were determined under ubuntu 13.10/64bit.
25    // Make sure only one of the following sections is enabled!
26
27#if 1
28    // enabling this section does not fail any unit test
29    setlocale(LC_ALL,  "C");
30#endif
31
32#if 0
33    // enabling this section does not fail any unit test
34    // (but this might cause problems with databases edited using different locales)
35    setlocale(LC_ALL,     USER_LOCALE);
36    setlocale(LC_NUMERIC, "C");
37#endif
38
39#if 0
40    // enabling this section does not fail any unit test
41    setlocale(LC_ALL,      "C");
42    setlocale(LC_COLLATE,  USER_LOCALE);
43    setlocale(LC_CTYPE,    USER_LOCALE);
44    setlocale(LC_MESSAGES, USER_LOCALE);
45    setlocale(LC_MONETARY, USER_LOCALE);
46    setlocale(LC_TIME,     USER_LOCALE);
47#endif
48
49
50#if 0
51    // enabling this section fails 57 unit tests (for german USER_LOCALE)
52    setlocale(LC_ALL, USER_LOCALE);
53#endif
54
55#if 0
56    // enabling this section fails 57 unit tests (for german USER_LOCALE)
57    setlocale(LC_COLLATE,  "C");
58    setlocale(LC_CTYPE,    "C");
59    setlocale(LC_MESSAGES, "C");
60    setlocale(LC_MONETARY, "C");
61    setlocale(LC_NUMERIC,  USER_LOCALE);
62    setlocale(LC_TIME,     "C");
63#endif
64
65#if 0
66    // enabling this section fails 57 unit tests (for german USER_LOCALE)
67    // (fails 57 unit tests under ubuntu 13.10, centos 5 and 6)
68    setlocale(LC_ALL,     "C");
69    setlocale(LC_NUMERIC, USER_LOCALE);
70#endif
71}
72
73#else
74#error arb_main.h included twice
75#endif // ARB_MAIN_H
Note: See TracBrowser for help on using the repository browser.