diff options
author | fluxgen <fluxgen> | 2003-04-26 15:46:03 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2003-04-26 15:46:03 (GMT) |
commit | 2065e654a357c6bf45c5747e25b713415eab8983 (patch) | |
tree | 04cd4df7b046c78aa96eb6160ac181cdd237a1bf /src | |
parent | 00dc4656ea45071c9d2bbd1545493ea391ac4668 (diff) | |
download | fluxbox_paul-2065e654a357c6bf45c5747e25b713415eab8983.zip fluxbox_paul-2065e654a357c6bf45c5747e25b713415eab8983.tar.bz2 |
removed nl_types_cygnus and did some cleaning
Diffstat (limited to 'src')
-rw-r--r-- | src/i18n.cc | 22 | ||||
-rw-r--r-- | src/i18n.hh | 29 |
2 files changed, 22 insertions, 29 deletions
diff --git a/src/i18n.cc b/src/i18n.cc index 929b3fd..5b3b2ca 100644 --- a/src/i18n.cc +++ b/src/i18n.cc | |||
@@ -1,5 +1,5 @@ | |||
1 | // i18n.hh for Fluxbox Window Manager | 1 | // i18n.hh for Fluxbox Window Manager |
2 | // Copyright (c) 2001 - 2002 Henrik Kinnunen (fluxgen@linuxmail.org) | 2 | // Copyright (c) 2001 - 2003 Henrik Kinnunen (fluxgen(at)users.sourceforge.net) |
3 | // | 3 | // |
4 | // i18n.cc for Blackbox - an X11 Window manager | 4 | // i18n.cc for Blackbox - an X11 Window manager |
5 | // Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) | 5 | // Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) |
@@ -22,27 +22,21 @@ | |||
22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
23 | // DEALINGS IN THE SOFTWARE. | 23 | // DEALINGS IN THE SOFTWARE. |
24 | 24 | ||
25 | // $Id: i18n.cc,v 1.8 2002/12/02 22:50:57 fluxgen Exp $ | 25 | // $Id: i18n.cc,v 1.9 2003/04/26 15:46:03 fluxgen Exp $ |
26 | 26 | ||
27 | //usr GNU extensions | 27 | //usr GNU extensions |
28 | #ifndef _GNU_SOURCE | 28 | #ifndef _GNU_SOURCE |
29 | #define _GNU_SOURCE | 29 | #define _GNU_SOURCE |
30 | #endif // _GNU_SOURCE | 30 | #endif // _GNU_SOURCE |
31 | 31 | ||
32 | #ifdef HAVE_CONFIG_H | ||
33 | #include "../config.h" | ||
34 | #endif // HAVE_CONFIG_H | ||
35 | |||
36 | #include "i18n.hh" | 32 | #include "i18n.hh" |
37 | 33 | ||
38 | #include <X11/Xlocale.h> | 34 | #include <X11/Xlocale.h> |
39 | 35 | ||
40 | |||
41 | #include <cstdlib> | 36 | #include <cstdlib> |
42 | #include <cstring> | 37 | #include <cstring> |
43 | #include <cstdio> | 38 | #include <cstdio> |
44 | 39 | ||
45 | |||
46 | #ifdef HAVE_LOCALE_H | 40 | #ifdef HAVE_LOCALE_H |
47 | #include <locale.h> | 41 | #include <locale.h> |
48 | #endif // HAVE_LOCALE_H | 42 | #endif // HAVE_LOCALE_H |
@@ -59,15 +53,18 @@ void NLSInit(const char *catalog) { | |||
59 | 53 | ||
60 | 54 | ||
61 | I18n::I18n():m_multibyte(false), m_catalog_fd((nl_catd)(-1)) { | 55 | I18n::I18n():m_multibyte(false), m_catalog_fd((nl_catd)(-1)) { |
62 | #ifdef HAVE_SETLOCALE | 56 | #ifdef HAVE_SETLOCALE |
63 | //make sure we don't get 0 to m_locale string | 57 | //make sure we don't get 0 to m_locale string |
64 | char *temp = setlocale(LC_ALL, ""); | 58 | char *temp = setlocale(LC_ALL, ""); |
65 | m_locale = ( temp ? temp : ""); | 59 | m_locale = ( temp ? temp : ""); |
66 | if (m_locale.size() == 0) { | 60 | if (m_locale.size() == 0) { |
67 | cerr<<"Warning: Failed to set locale, reverting to \"C\""<<endl; | 61 | cerr<<"Warning: Failed to set locale, reverting to \"C\""<<endl; |
68 | #endif // HAVE_SETLOCALE | 62 | #endif // HAVE_SETLOCALE |
63 | |||
69 | m_locale = "C"; | 64 | m_locale = "C"; |
70 | #ifdef HAVE_SETLOCALE | 65 | |
66 | #ifdef HAVE_SETLOCALE | ||
67 | |||
71 | } else { | 68 | } else { |
72 | // MB_CUR_MAX returns the size of a char in the current locale | 69 | // MB_CUR_MAX returns the size of a char in the current locale |
73 | if (MB_CUR_MAX > 1) | 70 | if (MB_CUR_MAX > 1) |
@@ -109,7 +106,7 @@ void I18n::openCatalog(const char *catalog) { | |||
109 | catalog_filename += '/'; | 106 | catalog_filename += '/'; |
110 | catalog_filename += catalog; | 107 | catalog_filename += catalog; |
111 | 108 | ||
112 | #ifdef MCLoadBySet | 109 | #ifdef MCLoadBySet |
113 | m_catalog_fd = catopen(catalog_filename.c_str(), MCLoadBySet); | 110 | m_catalog_fd = catopen(catalog_filename.c_str(), MCLoadBySet); |
114 | #else // !MCLoadBySet | 111 | #else // !MCLoadBySet |
115 | m_catalog_fd = catopen(catalog_filename.c_str(), NL_CAT_LOCALE); | 112 | m_catalog_fd = catopen(catalog_filename.c_str(), NL_CAT_LOCALE); |
@@ -125,7 +122,8 @@ void I18n::openCatalog(const char *catalog) { | |||
125 | } | 122 | } |
126 | 123 | ||
127 | 124 | ||
128 | const char *I18n::getMessage(int set_number, int message_number, const char *default_message) { | 125 | const char *I18n::getMessage(int set_number, int message_number, |
126 | const char *default_message) { | ||
129 | 127 | ||
130 | #if defined(NLS) && defined(HAVE_CATGETS) | 128 | #if defined(NLS) && defined(HAVE_CATGETS) |
131 | if (m_catalog_fd != (nl_catd)-1) | 129 | if (m_catalog_fd != (nl_catd)-1) |
diff --git a/src/i18n.hh b/src/i18n.hh index 6f5febf..32503e0 100644 --- a/src/i18n.hh +++ b/src/i18n.hh | |||
@@ -22,7 +22,7 @@ | |||
22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
23 | // DEALINGS IN THE SOFTWARE. | 23 | // DEALINGS IN THE SOFTWARE. |
24 | 24 | ||
25 | // $Id: i18n.hh,v 1.10 2002/12/01 13:42:07 rathnor Exp $ | 25 | // $Id: i18n.hh,v 1.11 2003/04/26 15:46:03 fluxgen Exp $ |
26 | 26 | ||
27 | #ifndef I18N_HH | 27 | #ifndef I18N_HH |
28 | #define I18N_HH | 28 | #define I18N_HH |
@@ -30,37 +30,32 @@ | |||
30 | #include "../nls/blackbox-nls.hh" | 30 | #include "../nls/blackbox-nls.hh" |
31 | 31 | ||
32 | #ifdef HAVE_CONFIG_H | 32 | #ifdef HAVE_CONFIG_H |
33 | #include "../config.h" | 33 | #include "config.h" |
34 | #endif // HAVE_CONFIG_H | 34 | #endif // HAVE_CONFIG_H |
35 | 35 | ||
36 | #ifdef HAVE_LOCALE_H | 36 | #ifdef HAVE_LOCALE_H |
37 | # include <locale.h> | 37 | #include <locale.h> |
38 | #endif // HAVE_LOCALE_H | 38 | #endif // HAVE_LOCALE_H |
39 | 39 | ||
40 | #ifdef HAVE_NL_TYPES_H | 40 | #ifdef HAVE_NL_TYPES_H |
41 | // this is needed for linux libc5 systems | 41 | // this is needed for linux libc5 systems |
42 | extern "C" { | 42 | extern "C" { |
43 | # include <nl_types.h> | 43 | #include <nl_types.h> |
44 | } | 44 | } |
45 | #else // HAVE_NL_TYPES_H | ||
46 | #include "nl_types_cygnus.h" | ||
47 | #endif // HAVE_NL_TYPES_H | 45 | #endif // HAVE_NL_TYPES_H |
48 | 46 | ||
49 | #ifdef __CYGWIN32__ | ||
50 | # include "nl_types_cygnus.h" | ||
51 | #endif | ||
52 | |||
53 | #include <string> | 47 | #include <string> |
54 | 48 | ||
55 | class I18n { | 49 | class I18n { |
56 | public: | 50 | public: |
57 | static I18n *instance(); | 51 | static I18n *instance(); |
58 | inline const char *getLocale(void) const { return m_locale.c_str(); } | 52 | inline const char *getLocale() const { return m_locale.c_str(); } |
59 | inline bool multibyte(void) const { return m_multibyte; } | 53 | inline bool multibyte() const { return m_multibyte; } |
60 | inline const nl_catd &getCatalogFd(void) const { return m_catalog_fd; } | 54 | inline const nl_catd &getCatalogFd() const { return m_catalog_fd; } |
61 | 55 | ||
62 | const char *getMessage(int set_number, int message_number, const char *default_messsage = 0); | 56 | const char *getMessage(int set_number, int message_number, |
63 | void openCatalog(const char *); | 57 | const char *default_messsage = 0); |
58 | void openCatalog(const char *catalog); | ||
64 | private: | 59 | private: |
65 | I18n(); | 60 | I18n(); |
66 | ~I18n(); | 61 | ~I18n(); |