Quellcode durchsuchen

Move locale.h inclusion and locale setup to each program main

Guillem Jover vor 18 Jahren
Ursprung
Commit
3fffee5e70
8 geänderte Dateien mit 55 neuen und 9 gelöschten Zeilen
  1. 11 0
      ChangeLog
  2. 8 0
      dpkg-deb/main.c
  3. 8 0
      dpkg-split/main.c
  4. 4 0
      dselect/main.cc
  5. 0 9
      lib/dpkg.h
  6. 8 0
      src/main.c
  7. 8 0
      src/query.c
  8. 8 0
      src/trigcmd.c

+ 11 - 0
ChangeLog

@@ -1,3 +1,14 @@
+2008-09-14  Guillem Jover  <guillem@debian.org>
+
+	* lib/dpkg.h: Move <locale.h> inclusion and standard_startup locale
+	setup to ...
+	* dpkg-deb/main.c (main): ... here.
+	* dpkg-split/main.c (main): Likewise.
+	* dselect/main.cc (main): Likewise.
+	* src/main.c (main): Likewise.
+	* src/query.c (main): Likewise.
+	* src/trigcmd.c (main): Likewise.
+
 2008-09-14  Guillem Jover  <guillem@debian.org>
 
 	* lib/Makefile.am (libdpkg_a_SOURCES): Add 'dpkg-i18n.h'.

+ 8 - 0
dpkg-deb/main.c

@@ -36,6 +36,10 @@
 #include <ctype.h>
 #include <assert.h>
 
+#if HAVE_LOCALE_H
+#include <locale.h>
+#endif
+
 #include <dpkg.h>
 #include <dpkg-db.h>
 #include <dpkg-priv.h>
@@ -198,6 +202,10 @@ int main(int argc, const char *const *argv) {
   jmp_buf ejbuf;
 
   setlocale(LC_NUMERIC, "POSIX");
+  setlocale(LC_ALL, "");
+  bindtextdomain(PACKAGE, LOCALEDIR);
+  textdomain(PACKAGE);
+
   standard_startup(&ejbuf, argc, &argv, NULL, NULL, cmdinfos);
   if (!cipaction) badusage(_("need an action option"));
 

+ 8 - 0
dpkg-split/main.c

@@ -30,6 +30,10 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 
+#if HAVE_LOCALE_H
+#include <locale.h>
+#endif
+
 #include <dpkg.h>
 #include <dpkg-db.h>
 #include <dpkg-priv.h>
@@ -164,6 +168,10 @@ int main(int argc, const char *const *argv) {
   int l;
   char *p;
 
+  setlocale(LC_ALL, "");
+  bindtextdomain(PACKAGE, LOCALEDIR);
+  textdomain(PACKAGE);
+
   standard_startup(&ejbuf, argc, &argv, NULL, 0, cmdinfos);
   if (!cipaction) badusage(_("need an action option"));
 

+ 4 - 0
dselect/main.cc

@@ -38,6 +38,10 @@
 #include <ctype.h>
 #include <assert.h>
 
+#if HAVE_LOCALE_H
+#include <locale.h>
+#endif
+
 #include <ncursesw/term.h>
 
 #include <dpkg.h>

+ 0 - 9
lib/dpkg.h

@@ -155,9 +155,6 @@ extern const char printforhelp[];
 /*** from startup.c ***/
 
 #define standard_startup(ejbuf, argc, argv, prog, loadcfg, cmdinfos) do {\
-  setlocale(LC_ALL, "");\
-  bindtextdomain(PACKAGE, LOCALEDIR);\
-  textdomain(PACKAGE);\
   if (setjmp(*ejbuf)) { /* expect warning about possible clobbering of argv */\
     error_unwind(ehflag_bombout); exit(2);\
   }\
@@ -451,12 +448,6 @@ void unsetenv(const char *x);
 #define BUILDOLDPKGFORMAT 0
 #endif
 
-/* Take care of NLS matters.  */
-
-#if HAVE_LOCALE_H
-# include <locale.h>
-#endif
-
 DPKG_END_DECLS
 
 #endif /* DPKG_H */

+ 8 - 0
src/main.c

@@ -36,6 +36,10 @@
 #include <ctype.h>
 #include <fcntl.h>
 
+#if HAVE_LOCALE_H
+#include <locale.h>
+#endif
+
 #include <dpkg.h>
 #include <dpkg-db.h>
 #include <dpkg-priv.h>
@@ -623,6 +627,10 @@ int main(int argc, const char *const *argv) {
   jmp_buf ejbuf;
   static void (*actionfunction)(const char *const *argv);
 
+  setlocale(LC_ALL, "");
+  bindtextdomain(PACKAGE, LOCALEDIR);
+  textdomain(PACKAGE);
+
   standard_startup(&ejbuf, argc, &argv, DPKG, 1, cmdinfos);
   if (!cipaction) badusage(_("need an action option"));
 

+ 8 - 0
src/query.c

@@ -35,6 +35,10 @@
 #include <sys/termios.h>
 #include <fcntl.h>
 
+#if HAVE_LOCALE_H
+#include <locale.h>
+#endif
+
 #include <dpkg.h>
 #include <dpkg-db.h>
 #include <dpkg-priv.h>
@@ -555,6 +559,10 @@ int main(int argc, const char *const *argv) {
   jmp_buf ejbuf;
   static void (*actionfunction)(const char *const *argv);
 
+  setlocale(LC_ALL, "");
+  bindtextdomain(PACKAGE, LOCALEDIR);
+  textdomain(PACKAGE);
+
   standard_startup(&ejbuf, argc, &argv, NULL, 0, cmdinfos);
   if (!cipaction) badusage(_("need an action option"));
 

+ 8 - 0
src/trigcmd.c

@@ -35,6 +35,10 @@
 #include <sys/termios.h>
 #include <fcntl.h>
 
+#if HAVE_LOCALE_H
+#include <locale.h>
+#endif
+
 #include <dpkg.h>
 #include <dpkg-db.h>
 #include <myopt.h>
@@ -184,6 +188,10 @@ main(int argc, const char *const *argv)
 	const char *badname;
 	enum trigdef_updateflags tduf;
 
+	setlocale(LC_ALL, "");
+	bindtextdomain(PACKAGE, LOCALEDIR);
+	textdomain(PACKAGE);
+
 	standard_startup(&ejbuf, argc, &argv, NULL, 0, cmdinfos);
 	setvbuf(stdout, NULL, _IONBF, 0);