Package: dpkg
Version: 1.14.16.6

dpkg fails to compile if there are no gettext and libintl.h even with
the --disable-nls compile flag.

There are some nice defines in lib/dpkg.h that defines _() as gettext()
but unfortunally gettext() is used many places. The attatched patch
fixes the lib/dpkg.h header to only include libintl.h when ENABLE_NLS is
defined and it replaces gettext() with _() all places.

If you prefer the current style and mix gettext() and _() the please at
least add some dummy defines of gettext() in lib/dpkh.h (See
https://bugs.gentoo.org/attachment.cgi?id=143289 for example how this
can be done)

Thanks!

-nc
diff -ru dpkg-1.14.16.6.orig/dpkg-split/queue.c dpkg-1.14.16.6/dpkg-split/queue.c
--- dpkg-1.14.16.6.orig/dpkg-split/queue.c	2008-01-18 10:12:53 +0000
+++ dpkg-1.14.16.6/dpkg-split/queue.c	2008-02-12 10:04:16 +0000
@@ -198,7 +198,7 @@
   head= N_("Junk files left around in the depot directory:\n");
   for (pq= queue; pq; pq= pq->nextinqueue) {
     if (pq->info.md5sum) continue;
-    fputs(gettext(head),stdout); head= "";
+    fputs(_(head),stdout); head= "";
     if (lstat(pq->info.filename,&stab))
       ohshit(_("unable to stat `%.250s'"),pq->info.filename);
     if (S_ISREG(stab.st_mode)) {
@@ -214,7 +214,7 @@
   for (pq= queue; pq; pq= pq->nextinqueue) {
     if (!pq->info.md5sum) continue;
     mustgetpartinfo(pq->info.filename,&ti);
-    fputs(gettext(head),stdout); head= "";
+    fputs(_(head),stdout); head= "";
     printf(" Package %s: part(s) ",ti.package);
     bytes= 0;
     for (i=0; i<ti.maxpartn; i++) {
diff -ru dpkg-1.14.16.6.orig/dselect/basecmds.cc dpkg-1.14.16.6/dselect/basecmds.cc
--- dpkg-1.14.16.6.orig/dselect/basecmds.cc	2007-07-28 15:29:49 +0000
+++ dpkg-1.14.16.6/dselect/basecmds.cc	2008-02-12 09:59:58 +0000
@@ -166,10 +166,10 @@
     for (hme= helpmenu; hme->key && hme->key != key; hme++);
     if (hme->key) {
       attrset(helpscreen_attr);
-      mvaddstr(1,0, gettext(hme->msg->text));
+      mvaddstr(1,0, _(hme->msg->text));
       attrset(title_attr);
       mvaddstr(0,0, _("Help: "));
-      addstr(gettext(hme->msg->title));
+      addstr(_(hme->msg->title));
       getyx(stdscr,y,x);
       while (++x<maxx) addch(' ');
       attrset(thisstate_attr);
@@ -186,7 +186,7 @@
         attrset(A_BOLD);
         mvaddch(i+3,3, hme->key);
         attrset(A_NORMAL);
-        mvaddstr(i+3,6, gettext(hme->msg->title));
+        mvaddstr(i+3,6, _(hme->msg->title));
       }
       mvaddstr(i+4,1,
                _("Press a key from the list above, <space> or `q' to exit help,\n"
diff -ru dpkg-1.14.16.6.orig/dselect/baselist.cc dpkg-1.14.16.6/dselect/baselist.cc
--- dpkg-1.14.16.6.orig/dselect/baselist.cc	2008-01-18 10:12:53 +0000
+++ dpkg-1.14.16.6/dselect/baselist.cc	2008-02-12 10:00:11 +0000
@@ -265,7 +265,7 @@
   while ((ta= bindings->describenext()) != 0) {
     const char **tap= ta+1;
     for (;;) {
-      waddstr(infopad, gettext(*tap));
+      waddstr(infopad, _(*tap));
       tap++;  if (!*tap) break;
       waddstr(infopad, ", ");
     }
diff -ru dpkg-1.14.16.6.orig/dselect/main.cc dpkg-1.14.16.6/dselect/main.cc
--- dpkg-1.14.16.6.orig/dselect/main.cc	2007-07-28 15:29:49 +0000
+++ dpkg-1.14.16.6/dselect/main.cc	2008-02-12 10:01:12 +0000
@@ -156,10 +156,10 @@
       "See %s --license for copyright and license details.\n");
 
 static void printversion(void) {
-  if (printf(gettext(programdesc), DSELECT, DPKG_VERSION_ARCH) < 0)
+  if (printf(_(programdesc), DSELECT, DPKG_VERSION_ARCH) < 0)
     werr("stdout");
-  if (printf(gettext(copyrightstring)) < 0) werr("stdout");
-  if (printf(gettext(licensestring), DSELECT) < 0) werr("stdout");
+  if (printf(_(copyrightstring)) < 0) werr("stdout");
+  if (printf(_(licensestring), DSELECT) < 0) werr("stdout");
 }
 
 static void usage(void) {
@@ -364,8 +364,8 @@
   const menuentry *me= &menuentries[i];
   sprintf(buf," %c %d. %-11.11s %-80.80s ",
           so ? '*' : ' ', i,
-          gettext(me->option),
-          gettext(me->menuent));
+          _(me->option),
+          _(me->menuent));
   
   int y,x;
   getmaxyx(stdscr,y,x);
@@ -387,7 +387,7 @@
 
   clear();
   attrset(A_BOLD);
-  sprintf(buf, gettext(programdesc), DSELECT, DPKG_VERSION_ARCH);
+  sprintf(buf, _(programdesc), DSELECT, DPKG_VERSION_ARCH);
   mvaddnstr(0,0,buf,x-1);
 
   attrset(A_NORMAL);
@@ -401,8 +401,8 @@
          "Press <enter> to confirm selection.   ^L redraws screen.\n\n"));
 
   attrset(A_NORMAL);
-  addstr(gettext(copyrightstring));
-  sprintf(buf, gettext(licensestring), DSELECT);
+  addstr(_(copyrightstring));
+  sprintf(buf, _(licensestring), DSELECT);
   addstr(buf);
 
   l= strlen(admindir);
@@ -465,7 +465,7 @@
       }
     } else if (isalpha(c)) {
       c= tolower(c);
-      for (i=0; i<entries && gettext(menuentries[i].key)[0] != c; i++);
+      for (i=0; i<entries && _(menuentries[i].key)[0] != c; i++);
       if (i < entries) {
         dme(cursor,0); cursor=i; dme(cursor,1);
       } else {
diff -ru dpkg-1.14.16.6.orig/dselect/pkgdepcon.cc dpkg-1.14.16.6/dselect/pkgdepcon.cc
--- dpkg-1.14.16.6.orig/dselect/pkgdepcon.cc	2007-07-28 15:29:49 +0000
+++ dpkg-1.14.16.6/dselect/pkgdepcon.cc	2008-02-12 10:01:38 +0000
@@ -206,12 +206,12 @@
 
   if (depdebug && debug) {
     fprintf(debug,"packagelist[%p]::resolvedepcon([%p] %s --%s-->",
-          this,depends,depends->up->name,gettext(relatestrings[depends->type]));
+          this,depends,depends->up->name,_(relatestrings[depends->type]));
     for (possi=depends->list; possi; possi=possi->next)
       fprintf(debug," %s",possi->ed->name);
     fprintf(debug,"); (ing)->want=%s\n",
             depends->up->clientdata
-            ? gettext(wantstrings[depends->up->clientdata->suggested])
+            ? _(wantstrings[depends->up->clientdata->suggested])
             : _("(no clientdata)"));
   }
   
diff -ru dpkg-1.14.16.6.orig/dselect/pkgdisplay.cc dpkg-1.14.16.6/dselect/pkgdisplay.cc
--- dpkg-1.14.16.6.orig/dselect/pkgdisplay.cc	2007-07-28 15:29:49 +0000
+++ dpkg-1.14.16.6/dselect/pkgdisplay.cc	2008-02-12 10:02:01 +0000
@@ -123,7 +123,7 @@
 static int maximumstring(const char *const *array) {
   int maxlen= 0;
   while (*array) {
-    int l= strlen(gettext(*array));
+    int l= strlen(_(*array));
     const char *p= strchr(*array, '(');
     if (p && p > *array && *--p == ' ') l= p - *array;
     if (l > maxlen) maxlen= l;
diff -ru dpkg-1.14.16.6.orig/dselect/pkgsublist.cc dpkg-1.14.16.6/dselect/pkgsublist.cc
--- dpkg-1.14.16.6.orig/dselect/pkgsublist.cc	2007-07-28 15:29:49 +0000
+++ dpkg-1.14.16.6/dselect/pkgsublist.cc	2008-02-12 10:02:41 +0000
@@ -54,14 +54,14 @@
 
 void packagelist::add(pkginfo *pkg, pkginfo::pkgwant nw) {
   if (debug) fprintf(debug,"packagelist[%p]::add(pkginfo %s, %s)\n",
-                     this,pkg->name,gettext(wantstrings[nw]));
+                     this,pkg->name,_(wantstrings[nw]));
   add(pkg);  if (!pkg->clientdata) return;
   pkg->clientdata->direct= nw;
   selpriority np;
   np= would_like_to_install(nw,pkg) ? sp_selecting : sp_deselecting;
   if (pkg->clientdata->spriority > np) return;
   if (debug) fprintf(debug,"packagelist[%p]::add(pkginfo %s, %s) setting\n",
-                     this,pkg->name,gettext(wantstrings[nw]));
+                     this,pkg->name,_(wantstrings[nw]));
   pkg->clientdata->suggested= pkg->clientdata->selected= nw;
   pkg->clientdata->spriority= np;
     
@@ -114,7 +114,7 @@
   varbuf info;
   info(depends->up->name);
   info(' ');
-  info(gettext(relatestrings[depends->type]));
+  info(_(relatestrings[depends->type]));
   info(' ');
   deppossi *possi;
   for (possi=depends->list;
diff -ru dpkg-1.14.16.6.orig/dselect/pkgtop.cc dpkg-1.14.16.6/dselect/pkgtop.cc
--- dpkg-1.14.16.6.orig/dselect/pkgtop.cc	2007-07-28 15:29:49 +0000
+++ dpkg-1.14.16.6/dselect/pkgtop.cc	2008-02-12 10:04:02 +0000
@@ -41,7 +41,7 @@
     return pkg->otherpriority;
   } else {
     assert(pkg->priority <= pkginfo::pri_unknown);
-    return gettext(prioritystrings[pkg->priority]);
+    return _(prioritystrings[pkg->priority]);
   }
 }
 
@@ -75,25 +75,25 @@
   
   if (!prioritystring) {
     if (!section) {
-      strcpy(buf, ssostring ? gettext(ssostring) : _("All packages"));
+      strcpy(buf, ssostring ? _(ssostring) : _("All packages"));
       return statindent;
     } else {
       if (!*section) {
-        sprintf(buf,_("%s packages without a section"),gettext(ssoabbrev));
+        sprintf(buf,_("%s packages without a section"),_(ssoabbrev));
       } else {
-        sprintf(buf,_("%s packages in section %s"),gettext(ssoabbrev),section);
+        sprintf(buf,_("%s packages in section %s"),_(ssoabbrev),section);
       }
       return statindent+1;
     }
   } else {
     if (!section) {
-      sprintf(buf,_("%s %s packages"),gettext(ssoabbrev),prioritystring);
+      sprintf(buf,_("%s %s packages"),_(ssoabbrev),prioritystring);
       return statindent+1;
     } else {
       if (!*section) {
-        sprintf(buf,_("%s %s packages without a section"),gettext(ssoabbrev),prioritystring);
+        sprintf(buf,_("%s %s packages without a section"),_(ssoabbrev),prioritystring);
       } else {
-        sprintf(buf,_("%s %s packages in section %s"),gettext(ssoabbrev),prioritystring,section);
+        sprintf(buf,_("%s %s packages in section %s"),_(ssoabbrev),prioritystring,section);
       }
       return statindent+2;
     }
@@ -117,12 +117,12 @@
             _("%-*s %s%s%s;  %s (was: %s).  %s"),
             package_width,
             table[cursorline]->pkg->name,
-            gettext(statusstrings[table[cursorline]->pkg->status]),
+            _(statusstrings[table[cursorline]->pkg->status]),
             ((eflagstrings[table[cursorline]->pkg->eflag][0]==' ') &&
               (eflagstrings[table[cursorline]->pkg->eflag][1]=='\0'))  ? "" : " - ",
-            gettext(eflagstrings[table[cursorline]->pkg->eflag]),
-            gettext(wantstrings[table[cursorline]->selected]),
-            gettext(wantstrings[table[cursorline]->original]),
+            _(eflagstrings[table[cursorline]->pkg->eflag]),
+            _(wantstrings[table[cursorline]->selected]),
+            _(wantstrings[table[cursorline]->original]),
             priority);
   } else {
     describemany(buf,priority,section,table[cursorline]->pkg->clientdata);
@@ -148,26 +148,26 @@
 
       mvwprintw(listpad,index,0, "%-*.*s ",
                 status_hold_width, status_hold_width,
-                gettext(eflagstrings[pkg->eflag]));
+                _(eflagstrings[pkg->eflag]));
       wprintw(listpad, "%-*.*s ",
               status_status_width, status_status_width,
-              gettext(statusstrings[pkg->status]));
+              _(statusstrings[pkg->status]));
       wprintw(listpad, "%-*.*s ",
               status_want_width, status_want_width,
               /* fixme: keep this ? */
               /*table[index]->original == table[index]->selected ? "(same)"
-              : */gettext(wantstrings[table[index]->original]));
+              : */_(wantstrings[table[index]->original]));
       wattrset(listpad, selected ? selstatesel_attr : selstate_attr);
       wprintw(listpad, "%-*.*s",
               status_want_width, status_want_width,
-              gettext(wantstrings[table[index]->selected]));
+              _(wantstrings[table[index]->selected]));
       wattrset(listpad, selected ? listsel_attr : list_attr);
       waddch(listpad, ' ');
   
       mvwprintw(listpad,index,priority_column-1, " %-*.*s",
                 priority_width, priority_width,
                 pkg->priority == pkginfo::pri_other ? pkg->otherpriority :
-                gettext(prioritystrings[pkg->priority]));
+                _(prioritystrings[pkg->priority]));
 
     } else {
 
@@ -193,7 +193,7 @@
         while (i-- > 0) waddch(listpad,' ');
       } else {
         wprintw(listpad, "%-*.*s", priority_width, priority_width,
-                gettext(priorityabbrevs[pkg->priority]));
+                _(priorityabbrevs[pkg->priority]));
       }
 
     }
diff -ru dpkg-1.14.16.6.orig/lib/dpkg.h dpkg-1.14.16.6/lib/dpkg.h
--- dpkg-1.14.16.6.orig/lib/dpkg.h	2008-01-26 18:16:35 +0000
+++ dpkg-1.14.16.6/lib/dpkg.h	2008-02-12 09:57:18 +0000
@@ -436,13 +436,20 @@
 
 /* Take care of NLS matters.  */
 
-#include <gettext.h>
-#if HAVE_LOCALE_H
-# include <locale.h>
-#endif
-
+#if ENABLE_NLS
+# include <gettext.h>
+# if HAVE_LOCALE_H
+#  include <locale.h>
+# endif
 /* Make gettext a little friendlier */
-#define _(String) gettext (String)
-#define N_(String) gettext_noop (String)
+# define _(String) gettext (String)
+# define N_(String) gettext_noop (String)
+#else
+# define _(String) (String)
+# define N_(String) (String)
+# define textdomain(Domainname) ((char *) Domainname)
+# define bindtextdomain(Domainname, Dirname) ((char *) Dirname)
+# define setlocale(category, locale)
+#endif /* NLS */
 
 #endif /* DPKG_H */
diff -ru dpkg-1.14.16.6.orig/lib/ehandle.c dpkg-1.14.16.6/lib/ehandle.c
--- dpkg-1.14.16.6.orig/lib/ehandle.c	2007-07-28 15:29:49 +0000
+++ dpkg-1.14.16.6/lib/ehandle.c	2008-02-12 09:59:25 +0000
@@ -275,7 +275,7 @@
   va_start(al,fmt);
   vsnprintf(buf,sizeof(buf), fmt,al);
   va_end(al);
-  snprintf(errmsgbuf,sizeof(errmsgbuf),"%s\n\n%s", buf, gettext(printforhelp));
+  snprintf(errmsgbuf,sizeof(errmsgbuf),"%s\n\n%s", buf, _(printforhelp));
   errmsg= errmsgbuf; 
   longjmp(*econtext->jbufp,1);
 }
diff -ru dpkg-1.14.16.6.orig/src/depcon.c dpkg-1.14.16.6/src/depcon.c
--- dpkg-1.14.16.6.orig/src/depcon.c	2008-01-18 10:12:54 +0000
+++ dpkg-1.14.16.6/src/depcon.c	2008-02-12 09:58:19 +0000
@@ -313,7 +313,7 @@
           }
         default:
           sprintf(linebuf, _("  %.250s is %s.\n"),
-                  possi->ed->name, gettext(statusstrings[possi->ed->status]));
+                  possi->ed->name, _(statusstrings[possi->ed->status]));
           break;
         }
         break;
@@ -359,7 +359,7 @@
             if (provider->up->up->status == stat_installed) return 1;
             sprintf(linebuf, _("  %.250s provides %.250s but is %s.\n"),
                     provider->up->up->name, possi->ed->name,
-                    gettext(statusstrings[provider->up->up->status]));
+                    _(statusstrings[provider->up->up->status]));
             break;
           default:
             internerr("unknown istobe provider");
@@ -425,7 +425,7 @@
           sprintf(linebuf, _("  %.250s (version %.250s) is %s.\n"),
                   possi->ed->name,
                   versiondescribe(&possi->ed->installed.version,vdew_nonambig),
-                  gettext(statusstrings[possi->ed->status]));
+                  _(statusstrings[possi->ed->status]));
           varbufaddstr(whynot, linebuf);
           if (!canfixbyremove) return 0;
           nconflicts++;
@@ -486,7 +486,7 @@
           case stat_installed:
             sprintf(linebuf, _("  %.250s provides %.250s and is %s.\n"),
                     provider->up->up->name, possi->ed->name,
-                    gettext(statusstrings[provider->up->up->status]));
+                    _(statusstrings[provider->up->up->status]));
             varbufaddstr(whynot, linebuf);
             if (!canfixbyremove) return 0;
             nconflicts++;
diff -ru dpkg-1.14.16.6.orig/src/enquiry.c dpkg-1.14.16.6/src/enquiry.c
--- dpkg-1.14.16.6.orig/src/enquiry.c	2008-01-18 10:12:54 +0000
+++ dpkg-1.14.16.6/src/enquiry.c	2008-02-12 09:58:36 +0000
@@ -128,7 +128,7 @@
     while ((pkg= iterpkgnext(it))) {
       if (!bsi->yesno(pkg,bsi)) continue;
       if (!head) {
-        fputs(gettext(bsi->explanation),stdout);
+        fputs(_(bsi->explanation),stdout);
         head= 1;
       }
       describebriefly(pkg);
diff -ru dpkg-1.14.16.6.orig/src/packages.c dpkg-1.14.16.6/src/packages.c
--- dpkg-1.14.16.6.orig/src/packages.c	2008-01-18 10:12:54 +0000
+++ dpkg-1.14.16.6/src/packages.c	2008-02-12 09:59:00 +0000
@@ -363,7 +363,7 @@
                breaker->name,
                versiondescribe(&breaker->installed.version, vdew_nonambig),
                depmsg.buf,
-               gettext(statusstrings[breaker->status]));
+               _(statusstrings[breaker->status]));
   varbuffree(&depmsg);
 
   if (virtbroken) {

Reply via email to