Package: dpkg
Tags: patch

Here is a patch against the current dpkg source (1.10.9), which uses my
little "localeio" library to output UTF-8 strings in the user's current
locale encoding.

With this patch, the idea is that dpkg will use UTF-8 for all strings
internally, and only convert to the locale's encoding on output.  This
patch is still experimental, but it works for me on some tests.  

Wichert mentioned on IRC that he'd like to rename locale_* to just l*,
and I'm fine with that.

Now, one big remaining issue is that dpkg will need UTF-8 aware string
functions.  glib has a nice set of these...

Comments welcome!

--- dpkg-1.10.9/dpkg-deb/build.c        2002-05-20 01:56:02.000000000 -0400
+++ dpkg-1.10.10/dpkg-deb/build.c       2003-01-04 18:34:19.000000000 -0500
@@ -42,6 +42,7 @@
 #include <dpkg.h>
 #include <dpkg-db.h>
 #include "dpkg-deb.h"
+#include "localeio.h"
 
 #ifndef S_ISLNK
 # define S_ISLNK(mode) ((mode&0xF000) == S_IFLNK)
@@ -63,7 +64,7 @@
   const char *p;
   if (!vstring || !*vstring) return;
   for (p=vstring; *p; p++) if (cisdigit(*p)) return;
-  fprintf(stderr, _("dpkg-deb - error: %s (`%s') doesn't contain any 
digits\n"),
+  locale_fprintf(stderr, _("dpkg-deb - error: %s (`%s') doesn't contain any 
digits\n"),
           valuename, vstring);
   (*errs)++;
 }
@@ -249,7 +250,7 @@
   if (nocheckflag) {
     if (subdir)
       ohshit(_("target is directory - cannot skip control file check"));
-    printf(_("dpkg-deb: warning, not checking contents of control area.\n"
+    locale_printf(_("dpkg-deb: warning, not checking contents of control 
area.\n"
            "dpkg-deb: building an unknown package in `%s'.\n"), debar);
   } else {
     controlfile= m_malloc(strlen(directory) + sizeof(BUILDCONTROLDIR) +
@@ -269,12 +270,12 @@
         != strlen(checkedinfo->name))
       ohshit(_("package name has characters that aren't lowercase alphanums or 
`-+.'"));
     if (checkedinfo->priority == pri_other) {
-      fprintf(stderr, _("warning, `%s' contains user-defined Priority value 
`%s'\n"),
+      locale_fprintf(stderr, _("warning, `%s' contains user-defined Priority 
value `%s'\n"),
               controlfile, checkedinfo->otherpriority);
       warns++;
     }
     for (field= checkedinfo->available.arbs; field; field= field->next) {
-      fprintf(stderr, _("warning, `%s' contains user-defined field `%s'\n"),
+      locale_fprintf(stderr, _("warning, `%s' contains user-defined field 
`%s'\n"),
               controlfile, field->name);
       warns++;
     }
@@ -291,7 +292,7 @@
               arch[0] ? "_" : "", arch);
       debar= m;
     }
-    printf(_("dpkg-deb: building package `%s' in `%s'.\n"), checkedinfo->name, 
debar);
+    locale_printf(_("dpkg-deb: building package `%s' in `%s'.\n"), 
checkedinfo->name, debar);
 
     /* Check file permissions */
     strcpy(controlfile, directory);
@@ -328,7 +329,7 @@
         n= strlen(conffilename);
         if (!n) ohshite(_("empty string from fgets reading conffiles"));
         if (conffilename[n-1] != '\n') {
-          fprintf(stderr, _("warning, conffile name `%.50s...' is too long, or 
missing final newline\n"), 
+          locale_fprintf(stderr, _("warning, conffile name `%.50s...' is too 
long, or missing final newline\n"), 
                  conffilename);
           warns++;
           while ((c= getc(cf)) != EOF && c != '\n');
@@ -344,7 +345,7 @@
           else
             ohshite(_("conffile `%.250s' is not stattable"),conffilename);
         } else if (!S_ISREG(controlstab.st_mode)) {
-          fprintf(stderr, _("warning, conffile `%s'"
+          locale_fprintf(stderr, _("warning, conffile `%s'"
                   " is not a plain file\n"), conffilename);
           warns++;
         }
@@ -355,7 +356,7 @@
       ohshite(_("error opening conffiles file"));
     }
     if (warns) {
-      if (fprintf(stderr, _("dpkg-deb: ignoring %d warnings about the control"
+      if (locale_fprintf(stderr, _("dpkg-deb: ignoring %d warnings about the 
control"
                   " file(s)\n"), warns) == EOF) werr("stderr");
     }
   }
--- dpkg-1.10.9/lib/dump.c      2002-08-29 15:58:11.000000000 -0400
+++ dpkg-1.10.10/lib/dump.c     2003-01-04 19:20:07.000000000 -0500
@@ -35,6 +35,7 @@
 #include <dpkg.h>
 #include <dpkg-db.h>
 #include "parsedump.h"
+#include "localeio.h"
 
 void w_name(struct varbuf *vb,
             const struct pkginfo *pigp, const struct pkginfoperfile *pifp,
@@ -259,7 +260,7 @@
   varbufinit(&vb);
   varbufrecord(&vb,pigp,pifp);
   varbufaddc(&vb,'\0');
-  if (fputs(vb.buf,file) < 0)
+  if (locale_fprintf(file, "%s", vb.buf) < 0)
     ohshite("failed to write details of `%.50s' to `%.250s'", pigp->name, 
filename);
    varbuffree(&vb);
 }
--- dpkg-1.10.9/lib/ehandle.c   2002-05-06 12:18:15.000000000 -0400
+++ dpkg-1.10.10/lib/ehandle.c  2003-01-04 16:59:16.000000000 -0500
@@ -30,6 +30,7 @@
 #include <config.h>
 #include <dpkg.h>
 #include <dpkg-db.h>
+#include "localeio.h"
 
 static const char *errmsg; /* points to errmsgbuf or malloc'd */
 static char errmsgbuf[4096];
@@ -81,7 +82,7 @@
            _("out of memory pushing error handler: "), strerror(e));
     errmsg= errmsgbuf;
     if (econtext) longjmp(*econtext->jbufp,1);
-    fprintf(stderr, "%s: %s\n", thisname, errmsgbuf); exit(2);
+    locale_fprintf(stderr, "%s: %s\n", thisname, errmsgbuf); exit(2);
   }
   necp->next= econtext;
   necp->jbufp= jbufp;
@@ -93,7 +94,7 @@
 }
 
 static void print_error_cleanup(const char *emsg, const char *contextstring) {
-  fprintf(stderr, _("%s: error while cleaning up:\n %s\n"),thisname,emsg);
+  locale_fprintf(stderr, _("%s: error while cleaning up:\n 
%s\n"),thisname,emsg);
 }
 
 static void run_cleanups(struct errorcontext *econ, int flagsetin) {
@@ -108,7 +109,7 @@
      
   if (++preventrecurse > 3) {
     onerr_abort++;
-    fprintf(stderr, _("dpkg: too many nested errors during error recovery 
!!\n"));
+    locale_fprintf(stderr, _("dpkg: too many nested errors during error 
recovery !!\n"));
     flagset= 0;
   } else {
     flagset= flagsetin;
@@ -223,7 +224,7 @@
 }
 
 void print_error_fatal(const char *emsg, const char *contextstring) {
-  fprintf(stderr, "%s: %s\n",thisname,emsg);
+  locale_fprintf(stderr, "%s: %s\n",thisname,emsg);
 }
 
 void ohshitvb(struct varbuf *vb) {
@@ -272,7 +273,7 @@
 }
 
 void do_internerr(const char *string, int line, const char *file) {
-  fprintf(stderr,_("%s:%d: internal error `%s'\n"),file,line,string);
+  locale_fprintf(stderr,_("%s:%d: internal error `%s'\n"),file,line,string);
   abort();
 }
 
--- dpkg-1.10.9/lib/localeio.c  1969-12-31 19:00:00.000000000 -0500
+++ dpkg-1.10.10/lib/localeio.c 2003-01-04 16:53:31.000000000 -0500
@@ -0,0 +1,129 @@
+/* Functions to print strings in the user's locale encoding.  These
+   functions expect UTF-8 strings as input. */
+/* Copyright  2003 Colin Walters <[EMAIL PROTECTED]> */
+
+#include "localeio.h"
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <iconv.h>
+
+static char *locale_encoding = NULL;
+static int locale_is_utf8 = 0;
+
+void locale_printf_init()
+{
+  char *lang = getenv ("LANG");
+  char *dot;
+
+  if (locale_encoding)
+    return;
+
+  if (!lang)
+    goto out_ascii;
+  dot = strchr (lang, '.');
+  if (dot && dot+1)
+    locale_encoding = strdup(dot+1);
+  if (!locale_encoding)
+    goto out_ascii;
+  return;
+ out_ascii:
+  locale_encoding = strdup("US-ASCII");
+  if (!strcmp (locale_encoding, "UTF-8"))
+    locale_is_utf8 = 1;
+}
+
+size_t locale_printf (const char *format, ...) {
+  size_t ret;
+  va_list args;
+  va_start (args, format);
+  ret = locale_vfprintf (stdout, format, args);
+  va_end (args);
+  return ret;
+}
+
+size_t locale_fprintf (FILE *f, const char *format, ...) {
+  size_t ret;
+  va_list args;
+  va_start (args, format);
+  ret = locale_vfprintf (f, format, args);
+  va_end (args);
+  return ret;
+}
+
+size_t locale_vfprintf (FILE *f, const char *format, va_list args) {
+  char *str;
+  size_t len, ret;
+
+  if (locale_is_utf8)
+    return vfprintf (f, format, args);
+
+  len = locale_vasprintf (&str, format, args);
+  if (len < 0)
+    return len;
+  ret = fwrite (str, 1, len, f);
+  free (str);
+  return ret;
+}
+
+size_t locale_asprintf (char **ptr, const char *format, ...)
+{
+  size_t ret;
+  va_list args;
+  va_start (args, format);
+  ret = locale_vasprintf (ptr, format, args);
+  va_end (args);
+  return ret;
+}
+
+size_t locale_vasprintf (char **ptr, const char *format, va_list args)
+{
+  size_t iconv_ret;
+  size_t len, outbuf_size, inbytes_left, outbytes_left;
+  char *str;
+  char *input, *output, *input_end, *output_end;
+  iconv_t iconv_obj;
+
+  len = vasprintf (&str, format, args);
+
+  if (locale_is_utf8) {
+    *ptr = str;
+    return len;
+  }
+
+  if (len < 0)
+    return len;
+  iconv_obj = iconv_open (locale_encoding, "UTF-8");
+  if ((int) iconv_obj < 0)
+    return -1;
+  inbytes_left = len;
+  input = str;
+  outbytes_left = outbuf_size = len+1;
+  output = malloc (outbuf_size);
+  if (!output)
+    return -1;
+  input_end = input;
+  output_end = output;
+  
+  while ((iconv_ret = iconv (iconv_obj, &input_end, &inbytes_left,
+                            &output_end, &outbytes_left)) < 0
+        && errno == E2BIG)
+    {
+      output = realloc (output, outbuf_size *= 2);
+      if (!output)
+       return -1;
+      outbytes_left += outbuf_size;
+    }
+  iconv_close (iconv_obj);
+  output[outbuf_size-outbytes_left] = '\0';
+  *ptr = output;
+  free (str);
+  if (iconv_ret < 0) {
+    free (*ptr);
+    *ptr = NULL;
+    return iconv_ret;
+  }
+  return outbuf_size - outbytes_left;
+}
--- dpkg-1.10.9/lib/localeio.h  1969-12-31 19:00:00.000000000 -0500
+++ dpkg-1.10.10/lib/localeio.h 2003-01-04 16:53:31.000000000 -0500
@@ -0,0 +1,18 @@
+/* Functions to print strings in the user's locale encoding.  These
+   functions expect UTF-8 strings as input. */
+/* Copyright  2003 Colin Walters <[EMAIL PROTECTED]> */
+
+#ifndef DPKG_LOCALEIO_H
+#define DPKG_LOCALEIO_H 1
+
+#include <stdarg.h>
+#include <stdio.h>
+
+void locale_printf_init(void);
+size_t locale_printf (const char *format, ...) __attribute__ ((__format__ 
(__printf__, 1, 2)));
+size_t locale_fprintf (FILE *f, const char *format, ...) __attribute__ 
((__format__ (__printf__, 2, 3)));
+size_t locale_vfprintf (FILE *f, const char *format, va_list args) 
__attribute__ ((__format__ (__printf__, 2, 0)));
+size_t locale_asprintf (char **ptr, const char *format, ...) __attribute__ 
((__format__ (__printf__, 2, 3)));
+size_t locale_vasprintf (char **ptr, const char *format, va_list args) 
__attribute__ ((__format__ (__printf__, 2, 0)));
+
+#endif
--- dpkg-1.10.9/lib/mlib.c      2002-05-25 23:53:43.000000000 -0400
+++ dpkg-1.10.10/lib/mlib.c     2003-01-04 16:58:56.000000000 -0500
@@ -34,6 +34,7 @@
 #include <dpkg.h>
 #include <dpkg-db.h>
 #include <md5.h>
+#include "localeio.h"
 
 /* Incremented when we do some kind of generally necessary operation, so that
  * loops &c know to quit if we take an error exit.  Decremented again 
afterwards.
@@ -68,7 +69,7 @@
 }
 
 static void print_error_forked(const char *emsg, const char *contextstring) {
-  fprintf(stderr, _("%s (subprocess): %s\n"), thisname, emsg);
+  locale_fprintf(stderr, _("%s (subprocess): %s\n"), thisname, emsg);
 }
 
 static void cu_m_fork(int argc, void **argv) NONRETURNING;
@@ -111,7 +112,7 @@
     n= WEXITSTATUS(status); if (!n) return n;
     if(!(flags & PROCNOERR)) {
       if(flags & PROCWARN)
-        fprintf(stderr, _("dpkg: warning - %s returned error exit status 
%d\n"),description,n);
+        locale_fprintf(stderr, _("dpkg: warning - %s returned error exit 
status %d\n"),description,n);
       else
         ohshit(_("subprocess %s returned error exit status %d"),description,n);
     }
@@ -211,7 +212,7 @@
       MD5Update(&(((struct buffer_write_md5ctx *)data->data.ptr)->ctx), buf, 
length);
       break;
     default:
-      fprintf(stderr, _("unknown data type `%i' in buffer_write\n"), 
data->type);
+      locale_fprintf(stderr, _("unknown data type `%i' in buffer_write\n"), 
data->type);
    }
    return ret;
 }
@@ -237,7 +238,7 @@
        ohshite(_("error in buffer_read(stream): %s"), desc);
       break;
     default:
-      fprintf(stderr, _("unknown data type `%i' in buffer_read\n"), 
data->type);
+      locale_fprintf(stderr, _("unknown data type `%i' in buffer_read\n"), 
data->type);
    }
    return ret;
 }
--- dpkg-1.10.9/lib/nfmalloc.c  2002-09-03 19:34:50.000000000 -0400
+++ dpkg-1.10.10/lib/nfmalloc.c 2003-01-04 16:58:27.000000000 -0500
@@ -26,6 +26,7 @@
 #include <dpkg.h>
 #include <dpkg-db.h>
 
+#include "localeio.h"
 #include <obstack.h>
 
 #define obstack_chunk_alloc m_malloc
--- dpkg-1.10.9/lib/showpkg.c   2002-05-19 21:22:31.000000000 -0400
+++ dpkg-1.10.10/lib/showpkg.c  2003-01-04 16:57:48.000000000 -0500
@@ -26,6 +26,7 @@
 #include <dpkg-db.h>
 
 #include <parsedump.h>
+#include "localeio.h"
 
 
 typedef enum { invalid, string, field } itemtype_t;
@@ -66,7 +67,7 @@
 
                w=strtol(ws+1,&endptr,0);
                if (endptr[0]!='}') {
-                       fprintf(stderr, _("invalid character `%c' in field 
width\n"), *endptr);
+                       locale_fprintf(stderr, _("invalid character `%c' in 
field width\n"), *endptr);
                        return 0;
                }
 
@@ -153,7 +154,7 @@
                if (fmt[0]=='$' && fmt[1]=='{') {
                        fmtend=strchr(fmt, '}');
                        if (!fmtend) {
-                               fprintf(stderr, _("Closing brace missing in 
format\n"));
+                               locale_fprintf(stderr, _("Closing brace missing 
in format\n"));
                                freeformat(head);
                                return NULL;
                        }
--- dpkg-1.10.9/lib/startup.c   2002-09-01 00:47:05.000000000 -0400
+++ dpkg-1.10.10/lib/startup.c  2003-01-04 16:57:20.000000000 -0500
@@ -42,8 +42,11 @@
 
   setlocale(LC_ALL, "");
   bindtextdomain(PACKAGE, LOCALEDIR);
+  bind_textdomain_codeset(PACKAGE, "UTF-8");
   textdomain(PACKAGE);
 
+  locale_printf_init();
+
   if (setjmp(*ejbuf)) { /* expect warning about possible clobbering of argv */
     error_unwind(ehflag_bombout); exit(2);
   }
--- dpkg-1.10.9/main/archives.c 2002-08-24 15:22:33.000000000 -0400
+++ dpkg-1.10.10/main/archives.c        2003-01-04 17:02:39.000000000 -0500
@@ -43,6 +43,7 @@
 #include <tarfn.h>
 #include <myopt.h>
 
+#include "localeio.h"
 #include "filesdb.h"
 #include "main.h"
 #include "archives.h"
@@ -451,7 +452,7 @@
         /* Perhaps we're removing a conflicting package ? */
         if (otherpkg->clientdata->istobe == itb_remove) continue;
         if (does_replace(tc->pkg,&tc->pkg->available,otherpkg)) {
-          printf(_("Replacing files in old package %s ...\n"),otherpkg->name);
+          locale_printf(_("Replacing files in old package %s 
...\n"),otherpkg->name);
           otherpkg->clientdata->replacingfilesandsaid= 1;
         } else {
           if (!statr && S_ISDIR(stab.st_mode)) {
@@ -635,18 +636,18 @@
   struct packageinlist *newdeconf;
   
   if (force_depends(pdep)) {
-    fprintf(stderr, _("dpkg: warning - "
+    locale_fprintf(stderr, _("dpkg: warning - "
             "ignoring dependency problem with removal of %s:\n%s"),
             fixbyrm->name, why);
     return 1;
   } else if (f_autodeconf) {
     if (pdep->up->up->installed.essential) {
       if (fc_removeessential) {
-        fprintf(stderr, _("dpkg: warning - considering deconfiguration of 
essential\n"
+        locale_fprintf(stderr, _("dpkg: warning - considering deconfiguration 
of essential\n"
                 " package %s, to enable removal of %s.\n"),
                 pdep->up->up->name,fixbyrm->name);
       } else {
-        fprintf(stderr, _("dpkg: no, %s is essential, will not deconfigure\n"
+        locale_fprintf(stderr, _("dpkg: no, %s is essential, will not 
deconfigure\n"
                 " it in order to enable removal of %s.\n"),
                 pdep->up->up->name,fixbyrm->name);
         return 0;
@@ -659,7 +660,7 @@
     deconfigure= newdeconf;
     return 1;
   } else {
-    fprintf(stderr, _("dpkg: no, cannot remove %s (--auto-deconfigure will 
help):\n%s"),
+    locale_fprintf(stderr, _("dpkg: no, cannot remove %s (--auto-deconfigure 
will help):\n%s"),
             fixbyrm->name, why);
     return 0;
   }
@@ -693,10 +694,10 @@
           (!fixbyrm->installed.essential || fc_removeessential)))) {
       assert(fixbyrm->clientdata->istobe == itb_normal || 
fixbyrm->clientdata->istobe == itb_deconfigure);
       fixbyrm->clientdata->istobe= itb_remove;
-      fprintf(stderr, _("dpkg: considering removing %s in favour of %s ...\n"),
+      locale_fprintf(stderr, _("dpkg: considering removing %s in favour of %s 
...\n"),
               fixbyrm->name, pkg->name);
       if (fixbyrm->status != stat_installed) {
-        fprintf(stderr,
+        locale_fprintf(stderr,
                 _("%s is not properly installed - ignoring any dependencies on 
it.\n"),
                 fixbyrm->name);
         pdep= 0;
@@ -724,7 +725,7 @@
                 continue;
               if (depisok(pdep->up, &removalwhy, 0,0)) continue;
               varbufaddc(&removalwhy,0);
-              fprintf(stderr, _("dpkg"
+              locale_fprintf(stderr, _("dpkg"
                       ": may have trouble removing %s, as it provides %s 
...\n"),
                       fixbyrm->name, providecheck->list->ed->name);
               if (!try_remove_can(pdep,fixbyrm,removalwhy.buf))
@@ -739,10 +740,10 @@
       }
       if (!pdep && (fixbyrm->eflag & eflagf_reinstreq)) {
         if (fc_removereinstreq) {
-          fprintf(stderr, _("dpkg: package %s requires reinstallation, but 
will"
+          locale_fprintf(stderr, _("dpkg: package %s requires reinstallation, 
but will"
                   " remove anyway as you request.\n"), fixbyrm->name);
         } else {
-          fprintf(stderr, _("dpkg: package %s requires reinstallation, "
+          locale_fprintf(stderr, _("dpkg: package %s requires reinstallation, "
                   "will not remove.\n"), fixbyrm->name);
           pdep= &flagdeppossi;
         }
@@ -755,7 +756,7 @@
         /* This conflict is OK - we'll remove the conflictor. */
        conflictor[cflict_index++]= fixbyrm;
         varbuffree(&conflictwhy); varbuffree(&removalwhy);
-        fprintf(stderr, _("dpkg: yes, will remove %s in favour of %s.\n"),
+        locale_fprintf(stderr, _("dpkg: yes, will remove %s in favour of 
%s.\n"),
                 fixbyrm->name, pkg->name);
         return;
       }
@@ -763,11 +764,11 @@
     }
   }
   varbufaddc(&conflictwhy,0);
-  fprintf(stderr, _("dpkg: regarding %s containing %s:\n%s"),
+  locale_fprintf(stderr, _("dpkg: regarding %s containing %s:\n%s"),
           pfilename, pkg->name, conflictwhy.buf);
   if (!force_conflicts(dep->list))
     ohshit(_("conflicting packages - not installing %.250s"),pkg->name);
-  fprintf(stderr, _("dpkg: warning - ignoring conflict, may proceed anyway 
!\n"));
+  locale_fprintf(stderr, _("dpkg: warning - ignoring conflict, may proceed 
anyway !\n"));
   varbuffree(&conflictwhy);
   
   return;
@@ -939,12 +940,12 @@
   if (pkg->want != want_install && pkg->want != want_hold) {
     if (f_alsoselect) {
       if (saywhy) {
-   printf(_("Selecting previously deselected package %s.\n"),pkg->name);
+   locale_printf(_("Selecting previously deselected package %s.\n"),pkg->name);
    pkg->want= want_install;
       }
       return 1;
     } else {
-      if (saywhy) printf(_("Skipping deselected package %s.\n"),pkg->name);
+      if (saywhy) locale_printf(_("Skipping deselected package 
%s.\n"),pkg->name);
       return 0;
     }
   }
@@ -958,7 +959,7 @@
   } else if (r == 0) {
     if (f_skipsame && /* same version fully installed ? */
    pkg->status == stat_installed && !(pkg->eflag &= eflagf_reinstreq)) {
-      if (saywhy) fprintf(stderr, _("Version %.250s of %.250s already 
installed, "
+      if (saywhy) locale_fprintf(stderr, _("Version %.250s of %.250s already 
installed, "
              "skipping.\n"),
              versiondescribe(&pkg->installed.version,vdew_never),
              pkg->name);
@@ -970,13 +971,13 @@
     needepochs= epochsdiffer(&pkg->available.version,&pkg->installed.version) ?
       vdew_always : vdew_never;
     if (fc_downgrade) {
-      if (saywhy) fprintf(stderr, _("%s - warning: downgrading %.250s "
+      if (saywhy) locale_fprintf(stderr, _("%s - warning: downgrading %.250s "
              "from %.250s to %.250s.\n"), DPKG, pkg->name,
              versiondescribe(&pkg->installed.version,needepochs),
              versiondescribe(&pkg->available.version,needepochs));
       return 1;
     } else {
-      if (saywhy) fprintf(stderr, _("Will not downgrade %.250s from version 
%.250s "
+      if (saywhy) locale_fprintf(stderr, _("Will not downgrade %.250s from 
version %.250s "
              "to %.250s, skipping.\n"), pkg->name,
              versiondescribe(&pkg->installed.version,needepochs),
              versiondescribe(&pkg->available.version,needepochs));
--- dpkg-1.10.9/main/configure.c        2002-08-29 15:58:11.000000000 -0400
+++ dpkg-1.10.10/main/configure.c       2003-01-04 17:02:29.000000000 -0500
@@ -40,6 +40,7 @@
 #include <dpkg.h>
 #include <dpkg-db.h>
 
+#include "localeio.h"
 #include "filesdb.h"
 #include "main.h"
 
@@ -106,14 +107,14 @@
        } else if (ok == 0) {
                sincenothing= 0;
                varbufaddc(&aemsgs,0);
-               fprintf(stderr,
+               locale_fprintf(stderr,
                                _("dpkg: dependency problems prevent 
configuration of %s:\n%s"),
                                pkg->name, aemsgs.buf);
                varbuffree(&aemsgs);
                ohshit(_("dependency problems - leaving unconfigured"));
        } else if (aemsgs.used) {
                varbufaddc(&aemsgs,0);
-               fprintf(stderr,
+               locale_fprintf(stderr,
                                _("dpkg: %s: dependency problems, but 
configuring anyway as you request:\n%s"),
                                pkg->name, aemsgs.buf);
        }
@@ -125,7 +126,7 @@
                                _("Package is in a very bad inconsistent state 
- you should\n"
                                        " reinstall it before attempting 
configuration."));
 
-       printf(_("Setting up %s (%s) ...\n"),pkg->name,
+       locale_printf(_("Setting up %s (%s) ...\n"),pkg->name,
                        versiondescribe(&pkg->installed.version,vdew_never));
 
        if (f_noact) {
@@ -191,7 +192,7 @@
                                distedited= -1;
                                what= cfo_identical;
                        } else if (!strcmp(currenthash,NONEXISTENTFLAG) && 
fc_conff_miss) {
-                               fprintf(stderr, _("\nConfiguration file `%s', 
does not exist on system.\n"
+                               locale_fprintf(stderr, _("\nConfiguration file 
`%s', does not exist on system.\n"
                                                        "Installing new config 
file as you request.\n"), conff->name);
                                what= cfo_newconff;
                                useredited= -1;
@@ -222,7 +223,7 @@
                                case cfo_keep | cfof_backup:
                                        strcpy(cdr2rest,DPKGOLDEXT);
                                        if (unlink(cdr2.buf) && errno != ENOENT)
-                                               fprintf(stderr,
+                                               locale_fprintf(stderr,
                                                                _("dpkg: %s: 
warning - failed to remove old backup `%.250s': %s\n"),
                                                                pkg->name, 
cdr2.buf, strerror(errno));
                                        cdr.used--;
@@ -230,7 +231,7 @@
                                        varbufaddc(&cdr,0);
                                        strcpy(cdr2rest,DPKGNEWEXT);
                                        if (rename(cdr2.buf,cdr.buf))
-                                               fprintf(stderr,
+                                               locale_fprintf(stderr,
                                                                _("dpkg: %s: 
warning - failed to rename `%.250s' to `%.250s': %s\n"),
                                                                pkg->name, 
cdr2.buf, cdr.buf, strerror(errno));
                                        break;
@@ -238,7 +239,7 @@
                                case cfo_keep:
                                        strcpy(cdr2rest,DPKGNEWEXT);
                                        if (unlink(cdr2.buf))
-                                               fprintf(stderr,
+                                               locale_fprintf(stderr,
                                                                _("dpkg: %s: 
warning - failed to remove `%.250s': %s\n"),
                                                                pkg->name, 
cdr2.buf, strerror(errno));
                                        break;
@@ -246,16 +247,16 @@
                                case cfo_install | cfof_backup:
                                        strcpy(cdr2rest,DPKGDISTEXT);
                                        if (unlink(cdr2.buf) && errno != ENOENT)
-                                               fprintf(stderr,
+                                               locale_fprintf(stderr,
                                                                _("dpkg: %s: 
warning - failed to remove old distrib version `%.250s': %s\n"),
                                                                pkg->name, 
cdr2.buf, strerror(errno));
                                        strcpy(cdr2rest,DPKGOLDEXT);
                                        if (unlink(cdr2.buf) && errno != ENOENT)
-                                               fprintf(stderr,
+                                               locale_fprintf(stderr,
                                                                _("dpkg: %s: 
warning - failed to remove `%.250s' (before overwrite): %s\n"),
                                                                pkg->name, 
cdr2.buf, strerror(errno));
                                        if (link(cdr.buf,cdr2.buf))
-                                               fprintf(stderr,
+                                               locale_fprintf(stderr,
                                                                _("dpkg: %s: 
warning - failed to link `%.250s' to `%.250s': %s\n"),
                                                                pkg->name, 
cdr.buf, cdr2.buf, strerror(errno));
                                        /* fall through */
@@ -325,7 +326,7 @@
                debug(dbg_conffdetail,"conffderef in=`%s' current 
working=`%s'", in, result->buf);
                if (lstat(result->buf,&stab)) {
                        if (errno != ENOENT)
-                               fprintf(stderr, _("dpkg: %s: warning - unable 
to stat config file `%s'\n"
+                               locale_fprintf(stderr, _("dpkg: %s: warning - 
unable to stat config file `%s'\n"
                                                        " (= `%s'): %s\n"),
                                                pkg->name, in, result->buf, 
strerror(errno));
                        debug(dbg_conffdetail,"conffderef nonexistent");
@@ -336,7 +337,7 @@
                } else if (S_ISLNK(stab.st_mode)) {
                        debug(dbg_conffdetail,"conffderef symlink 
loopprotect=%d",loopprotect);
                        if (loopprotect++ >= 25) {
-                               fprintf(stderr, _("dpkg: %s: warning - config 
file `%s' is a circular link\n"
+                               locale_fprintf(stderr, _("dpkg: %s: warning - 
config file `%s' is a circular link\n"
                                                        " (= `%s')\n"), 
pkg->name, in, result->buf);
                                return -1;
                        }
@@ -349,7 +350,7 @@
                                }
                                r= 
readlink(result->buf,linkreadbuf,linkreadbufsize-1);
                                if (r < 0) {
-                                       fprintf(stderr, _("dpkg: %s: warning - 
unable to readlink conffile `%s'\n"
+                                       locale_fprintf(stderr, _("dpkg: %s: 
warning - unable to readlink conffile `%s'\n"
                                                                " (= `%s'): 
%s\n"),
                                                        pkg->name, in, 
result->buf, strerror(errno));
                                        return -1;
@@ -368,7 +369,7 @@
                                for (r=result->used-2; r>0 && result->buf[r] != 
'/'; r--)
                                        ;
                                if (r < 0) {
-                                       fprintf(stderr,
+                                       locale_fprintf(stderr,
                                                        _("dpkg: %s: warning - 
conffile `%.250s' resolves to degenerate filename\n"
                                                                " (`%s' is a 
symlink to `%s')\n"),
                                                        pkg->name, in, 
result->buf, linkreadbuf);
@@ -382,7 +383,7 @@
                        varbufaddstr(result,linkreadbuf);
                        varbufaddc(result,0);
                } else {
-                       fprintf(stderr, _("dpkg: %s: warning - conffile 
`%.250s' is not a plain"
+                       locale_fprintf(stderr, _("dpkg: %s: warning - conffile 
`%.250s' is not a plain"
                                                " file or symlink (= `%s')\n"),
                                        pkg->name, in, result->buf);
                        return -1;
@@ -406,7 +407,7 @@
        } else if (errno==ENOENT) {
                *hashbuf= strdup(NONEXISTENTFLAG);
        } else {
-               fprintf(stderr, _("dpkg: %s: warning - unable to open conffile 
%s for hash: %s\n"),
+               locale_fprintf(stderr, _("dpkg: %s: warning - unable to open 
conffile %s for hash: %s\n"),
                                pkg->name, fn, strerror(errno));
                *hashbuf= strdup("-");
        }
@@ -526,21 +527,21 @@
                return what;
 
        do {
-               fprintf(stderr, _("\nConfiguration file `%s'"), cfgfile);
+               locale_fprintf(stderr, _("\nConfiguration file `%s'"), cfgfile);
                if (strcmp(cfgfile, realold))
-                       fprintf(stderr,_(" (actually `%s')"), realold);
+                       locale_fprintf(stderr,_(" (actually `%s')"), realold);
 
                if (what & cfof_isnew) {
-                       fprintf(stderr,
+                       locale_fprintf(stderr,
                                        _("\n"
                                                " ==> File on system created by 
you or by a script.\n"
                                                " ==> File also in package 
provided by package maintainer.\n"));
                } else {
-                       fprintf(stderr, useredited ?
+                       locale_fprintf(stderr, useredited ?
                                        _("\n ==> Modified (by you or by a 
script) since installation.\n") :
                                        _("\n     Not modified since 
installation.\n"));
 
-                       fprintf(stderr, distedited ?
+                       locale_fprintf(stderr, distedited ?
                                        _(" ==> Package distributor has shipped 
an updated version.\n") :
                                        _("     Version in package is the same 
as at last installation.\n"));
                }
@@ -549,11 +550,11 @@
                /* TODO: check if this condition can not be simplified to just 
!fc_conff_def */
                if (!(fc_conff_def && (what&(cfof_install|cfof_keep)))) {
                        if (fc_conff_new) {
-                               fprintf(stderr, _(" ==> Using new file as you 
requested.\n"));
+                               locale_fprintf(stderr, _(" ==> Using new file 
as you requested.\n"));
                                cc = 'y';
                                break;
                        } else if (fc_conff_old) {
-                               fprintf(stderr, _(" ==> Using current old file 
as you requested.\n"));
+                               locale_fprintf(stderr, _(" ==> Using current 
old file as you requested.\n"));
                                cc = 'n';
                                break;
                        }
@@ -563,18 +564,18 @@
                /* Force the default action (if there is one */
                if (fc_conff_def) {
                        if (what&cfof_keep) {
-                               fprintf(stderr, _(" ==> Keeping old config file 
as default.\n"));
+                               locale_fprintf(stderr, _(" ==> Keeping old 
config file as default.\n"));
                                cc = 'n';
                                break;
                        } else if (what&cfof_install) {
-                               fprintf(stderr, _(" ==> Using new config file 
as default.\n"));
+                               locale_fprintf(stderr, _(" ==> Using new config 
file as default.\n"));
                                cc = 'y';
                                break;
                        }
                }
 
 
-               fprintf(stderr,
+               locale_fprintf(stderr,
                                _("   What would you like to do about it ?  
Your options are:\n"
                                        "    Y or I  : install the package 
maintainer's version\n"
                                        "    N or O  : keep your 
currently-installed version\n"
@@ -582,13 +583,13 @@
                                        "      Z     : background this process 
to examine the situation\n"));
 
                if (what & cfof_keep)
-                       fprintf(stderr, _(" The default action is to keep your 
current version.\n"));
+                       locale_fprintf(stderr, _(" The default action is to 
keep your current version.\n"));
                else if (what & cfof_install)
-                       fprintf(stderr, _(" The default action is to install 
the new version.\n"));
+                       locale_fprintf(stderr, _(" The default action is to 
install the new version.\n"));
 
                s= strrchr(cfgfile,'/');
                if (!s || !*++s) s= cfgfile;
-               fprintf(stderr, "*** %s (Y/I/N/O/D/Z) %s ? ",
+               locale_fprintf(stderr, "*** %s (Y/I/N/O/D/Z) %s ? ",
                                s,
                                (what & cfof_keep) ? _("[default=N]") :
                                (what & cfof_install) ? _("[default=Y]") : 
_("[no default]"));
--- dpkg-1.10.9/main/depcon.c   2002-05-06 12:18:15.000000000 -0400
+++ dpkg-1.10.10/main/depcon.c  2003-01-04 17:02:12.000000000 -0500
@@ -29,6 +29,7 @@
 #include <dpkg.h>
 #include <dpkg-db.h>
 
+#include "localeio.h"
 #include "main.h"
 
 struct cyclesofarlink {
@@ -95,9 +96,9 @@
   struct pkginfo *provider;
 
   if (f_debug & dbg_depcondetail) {
-    fprintf(stderr,"D0%05o: findbreakcycle %s ",dbg_depcondetail,pkg->name);
-    for (sol=sofar; sol; sol=sol->back) fprintf(stderr," <- 
%s",sol->pkg->name);
-    fprintf(stderr,"\n");
+    locale_fprintf(stderr,"D0%05o: findbreakcycle %s 
",dbg_depcondetail,pkg->name);
+    for (sol=sofar; sol; sol=sol->back) locale_fprintf(stderr," <- 
%s",sol->pkg->name);
+    locale_fprintf(stderr,"\n");
   }
   thislink.pkg= pkg;
   thislink.back= sofar;
--- dpkg-1.10.9/main/enquiry.c  2002-05-20 01:56:01.000000000 -0400
+++ dpkg-1.10.10/main/enquiry.c 2003-01-04 17:02:01.000000000 -0500
@@ -38,6 +38,7 @@
 #include <dpkg-db.h>
 #include <myopt.h>
 
+#include "localeio.h"
 #include "filesdb.h"
 #include "main.h"
 
@@ -109,7 +110,7 @@
   l= strlen(pkg->name);
   if (l>20) maxl -= (l-20);
   limiteddescription(pkg,maxl,&pdesc,&l);
-  printf(" %-20s %.*s\n",pkg->name,l,pdesc);
+  locale_printf(" %-20s %.*s\n",pkg->name,l,pdesc);
 }
 
 void audit(const char *const *argv) {
@@ -208,7 +209,7 @@
   } else if (sects <= 12) {
     for (se= sectionentries; se; se= se->next) {
       sprintf(buf,"%d",se->count);
-      printf(_(" %d in %s: "),se->count,se->name);
+      locale_printf(_(" %d in %s: "),se->count,se->name);
       width= 70-strlen(se->name)-strlen(buf);
       while (width > 59) { putchar(' '); width--; }
       it= iterpkgstart(); 
@@ -216,20 +217,20 @@
         if (!yettobeunpacked(pkg,&thissect)) continue;
         if (strcasecmp(thissect,se->name)) continue;
         width -= strlen(pkg->name); width--;
-        if (width < 4) { printf(" ..."); break; }
-        printf(" %s",pkg->name);
+        if (width < 4) { locale_printf(" ..."); break; }
+        locale_printf(" %s",pkg->name);
       }
       iterpkgend(it);
       putchar('\n');
     }
   } else {
-    printf(_(" %d packages, from the following sections:"),totalcount);
+    locale_printf(_(" %d packages, from the following sections:"),totalcount);
     width= 0;
     for (se= sectionentries; se; se= se->next) {
       sprintf(buf,"%d",se->count);
       width -= (6 + strlen(se->name) + strlen(buf));
       if (width < 0) { putchar('\n'); width= 73 - strlen(se->name) - 
strlen(buf); }
-      printf("   %s (%d)",se->name,se->count);
+      locale_printf("   %s (%d)",se->name,se->count);
     }
     putchar('\n');
   }
@@ -257,11 +258,11 @@
   case stat_unpacked: case stat_halfconfigured: case stat_halfinstalled:
     if (versionsatisfied3(&pkg->configversion,verrev_buf,dvr_laterequal))
       break;
-    printf(_("Version of dpkg with working epoch support not yet configured.\n"
+    locale_printf(_("Version of dpkg with working epoch support not yet 
configured.\n"
            " Please use `dpkg --configure dpkg', and then try again.\n"));
     exit(1);
   default:
-    printf(_("dpkg not recorded as installed, cannot check for epoch support 
!\n"));
+    locale_printf(_("dpkg not recorded as installed, cannot check for epoch 
support !\n"));
     exit(1);
   }
 }
@@ -356,7 +357,7 @@
       varbufreset(&vb);
       describedepcon(&vb,dep);
       varbufaddc(&vb,0);
-      fprintf(stderr, _("dpkg: cannot see how to satisfy pre-dependency:\n 
%s\n"),vb.buf);
+      locale_fprintf(stderr, _("dpkg: cannot see how to satisfy 
pre-dependency:\n %s\n"),vb.buf);
       ohshit(_("cannot satisfy pre-dependencies for %.250s (wanted due to 
%.250s)"),
              dep->up->name,startpkg->name);
     }
@@ -376,7 +377,7 @@
 static void badlgccfn(const char *compiler, const char *output, const char 
*why)
      NONRETURNING;
 static void badlgccfn(const char *compiler, const char *output, const char 
*why) {
-  fprintf(stderr,
+  locale_fprintf(stderr,
           _("dpkg: unexpected output from `%s --print-libgcc-file-name':\n"
           " `%s'\n"),
           compiler,output);
@@ -449,7 +450,7 @@
   }
   if (!arch) {
     *q= 0; arch= p;
-    fprintf(stderr, _("dpkg: warning, architecture `%s' not in remapping 
table\n"),arch);
+    locale_fprintf(stderr, _("dpkg: warning, architecture `%s' not in 
remapping table\n"),arch);
   }
   if (printf("%s\n",arch) == EOF) werr("stdout");
   if (fflush(stdout)) werr("stdout");
--- dpkg-1.10.9/main/errors.c   2002-05-06 12:18:15.000000000 -0400
+++ dpkg-1.10.10/main/errors.c  2003-01-04 17:01:51.000000000 -0500
@@ -37,6 +37,7 @@
 #include <dpkg-db.h>
 #include <myopt.h>
 
+#include "localeio.h"
 #include "main.h"
 
 int nerrs= 0;
@@ -53,7 +54,7 @@
 void print_error_perpackage(const char *emsg, const char *arg) {
   struct error_report *nr;
   
-  fprintf(stderr, _("%s: error processing %s (--%s):\n %s\n"),
+  locale_fprintf(stderr, _("%s: error processing %s (--%s):\n %s\n"),
           DPKG, arg, cipaction->olong, emsg);
   nr= malloc(sizeof(struct error_report));
   if (!nr) {
@@ -67,7 +68,7 @@
   lastreport= &nr->next;
     
   if (nerrs++ < errabort) return;
-  fprintf(stderr, _("dpkg: too many errors, stopping\n"));
+  locale_fprintf(stderr, _("dpkg: too many errors, stopping\n"));
   onerr_abort++;
 }
 
@@ -75,7 +76,7 @@
   if (reports) {
     fputs(_("Errors were encountered while processing:\n"),stderr);
     while (reports) {
-      fprintf(stderr," %s\n",reports->what);
+      locale_fprintf(stderr," %s\n",reports->what);
       reports= reports->next;
     }
   }
@@ -88,12 +89,12 @@
 int skip_due_to_hold(struct pkginfo *pkg) {
   if (pkg->want != want_hold) return 0;
   if (fc_hold) {
-    fprintf(stderr, _("Package %s was on hold, processing it anyway as you 
request\n"),
-            pkg->name);
+    locale_fprintf(stderr, _("Package %s was on hold, processing it anyway as 
you request\n"),
+                  pkg->name);
     return 0;
   }
-  printf(_("Package %s is on hold, not touching it.  Use --force-hold to 
override.\n"),
-         pkg->name);
+  locale_printf(_("Package %s is on hold, not touching it.  Use --force-hold 
to override.\n"),
+               pkg->name);
   return 1;
 }
 
@@ -102,7 +103,7 @@
   va_start(al,fmt);
   if (forceflag) {
     fputs(_("dpkg - warning, overriding problem because --force enabled:\n 
"),stderr);
-    vfprintf(stderr,fmt,al);
+    locale_vfprintf(stderr,fmt,al);
     fputc('\n',stderr);
   } else {
     ohshitv(fmt,al);
--- dpkg-1.10.9/main/filesdb.c  2002-08-29 17:44:43.000000000 -0400
+++ dpkg-1.10.10/main/filesdb.c 2003-01-04 17:01:40.000000000 -0500
@@ -35,6 +35,7 @@
 #include <dpkg.h>
 #include <dpkg-db.h>
 
+#include "localeio.h"
 #include "filesdb.h"
 #include "main.h"
 
@@ -124,7 +125,7 @@
     onerr_abort--;
     if (pkg->status != stat_configfiles) {
       if (saidread == 1) putc('\n',stderr);
-      fprintf(stderr,
+      locale_fprintf(stderr,
               _("dpkg: serious warning: files list file for package `%.250s' 
missing,"
               " assuming package has no files currently installed.\n"), 
pkg->name);
     }
@@ -206,7 +207,7 @@
   allpackagesdone= 1;
 
   if (saidread==1) {
-    printf(_("%d files and directories currently installed.)\n"),nfiles);
+    locale_printf(_("%d files and directories currently 
installed.)\n"),nfiles);
     saidread=2;
   }
 }
--- dpkg-1.10.9/main/help.c     2002-09-15 13:55:51.000000000 -0400
+++ dpkg-1.10.10/main/help.c    2003-01-04 17:01:23.000000000 -0500
@@ -34,6 +34,7 @@
 #include <version.h>
 #include <dpkg-db.h>
 
+#include "localeio.h"
 #include "filesdb.h"
 #include "main.h"
 
@@ -99,7 +100,7 @@
       s= p; if (s) s++;
     }
     if (!s) {
-      fprintf(stderr,_("dpkg: `%s' not found on PATH.\n"),*clp);
+      locale_fprintf(stderr,_("dpkg: `%s' not found on PATH.\n"),*clp);
       warned++;
     }
   }
@@ -179,8 +180,8 @@
     if (chroot(instdir)) ohshite(_("failed to chroot to `%.250s'"),instdir);
   }
   if (f_debug & dbg_scripts) {
-    fprintf(stderr,"D0%05o: fork/exec %s (",dbg_scripts,path);
-    while (*argv) fprintf(stderr," %s",*argv++);
+    locale_fprintf(stderr,"D0%05o: fork/exec %s (",dbg_scripts,path);
+    while (*argv) locale_fprintf(stderr," %s",*argv++);
     fputs(" )\n",stderr);
   }
   instdirl= strlen(instdir);
@@ -224,7 +225,7 @@
   int i;
   for (i=0; i<NSCRIPTCATCHSIGNALS; i++) {
     if (sigaction(script_catchsignallist[i],&script_uncatchsignal[i],0)) {
-      fprintf(stderr,_("error un-catching signal %s: %s\n"),
+      locale_fprintf(stderr,_("error un-catching signal %s: %s\n"),
               strsignal(script_catchsignallist[i]),strerror(errno));
       onerr_abort++;
     }
@@ -350,7 +351,7 @@
             scriptname,oldscriptpath);
       return 0;
     }
-    fprintf(stderr,
+    locale_fprintf(stderr,
             _("dpkg: warning - unable to stat %s `%.250s': %s\n"),
             buf,oldscriptpath,strerror(errno));
   } else {
@@ -358,7 +359,7 @@
       return 1;
     ensure_diversions();
   }
-  fprintf(stderr, _("dpkg - trying script from the new package instead 
...\n"));
+  locale_fprintf(stderr, _("dpkg - trying script from the new package instead 
...\n"));
 
   arglist= buildarglist(scriptname,
                         iffallback,versiondescribe(&pkg->installed.version,
@@ -375,7 +376,7 @@
   }
 
   do_script(pkg->name, scriptname, cidir, &stab, arglist, _("unable to execute 
%s"), buf, 0);
-  fprintf(stderr, _("dpkg: ... it looks like that went OK.\n"));
+  locale_fprintf(stderr, _("dpkg: ... it looks like that went OK.\n"));
 
   ensure_diversions();
   return 1;
@@ -396,9 +397,9 @@
 void debug(int which, const char *fmt, ...) {
   va_list ap;
   if (!(f_debug & which)) return;
-  fprintf(stderr,"D0%05o: ",which);
+  locale_fprintf(stderr,"D0%05o: ",which);
   va_start(ap,fmt);
-  vfprintf(stderr,fmt,ap);
+  locale_vfprintf(stderr,fmt,ap);
   va_end(ap);
   putc('\n',stderr);
 }
--- dpkg-1.10.9/main/packages.c 2002-05-06 12:18:15.000000000 -0400
+++ dpkg-1.10.10/main/packages.c        2003-01-04 17:01:15.000000000 -0500
@@ -37,6 +37,7 @@
 #include <dpkg-db.h>
 #include <myopt.h>
 
+#include "localeio.h"
 #include "filesdb.h"
 #include "main.h"
 
@@ -147,11 +148,11 @@
       /* Remove it from the queue - this is a second copy ! */
       switch (cipaction->arg) {
       case act_configure: case act_remove: case act_purge:
-        printf(_("Package %s listed more than once, only processing once.\n"),
+        locale_printf(_("Package %s listed more than once, only processing 
once.\n"),
                rundown->pkg->name);
         break;
       case act_install:
-        printf(_("More than one copy of package %s has been unpacked\n"
+        locale_printf(_("More than one copy of package %s has been unpacked\n"
                " in this run !  Only configuring it once.\n"),
                rundown->pkg->name);
         break;
@@ -300,7 +301,7 @@
       debug(dbg_depcondetail,"      unpacked/halfconfigured, defer");
       return 1;
     } else if (!removing && fc_configureany && 
!skip_due_to_hold(possdependee)) {
-      fprintf(stderr,
+      locale_fprintf(stderr,
               _("dpkg: also configuring `%s' (required by `%s')\n"),
               possdependee->name, requiredby->name);
       add_to_queue(possdependee); sincenothing=0; return 1;
--- dpkg-1.10.9/main/processarc.c       2002-05-25 23:53:43.000000000 -0400
+++ dpkg-1.10.10/main/processarc.c      2003-01-04 17:01:03.000000000 -0500
@@ -40,6 +40,7 @@
 #include <tarfn.h>
 #include <myopt.h>
 
+#include "localeio.h"
 #include "filesdb.h"
 #include "main.h"
 #include "archives.h"
@@ -138,7 +139,7 @@
   
   /* Verify the package. */
   if (!f_nodebsig && (stat(DEBSIGVERIFY, &stab)==0)) {
-    printf(_("Authenticating %s ...\n"), filename);
+    locale_printf(_("Authenticating %s ...\n"), filename);
     fflush(stdout);
     c1 = m_fork();
     if (!c1) {
@@ -151,10 +152,10 @@
        if (! fc_badverify) {
          ohshit(_("Verification on package %s failed!"), filename);
        } else {
-         fprintf(stderr, _("Verification on package %s failed,\nbut installing 
anyway as you request.\n"), filename);
+         locale_fprintf(stderr, _("Verification on package %s failed,\nbut 
installing anyway as you request.\n"), filename);
        }
       } else {
-       printf(_("passed\n"));
+       locale_printf(_("passed\n"));
       }
     }
   }
@@ -202,7 +203,7 @@
   sprintf(pkg->files->size,"%lu",(unsigned long)stab.st_size);
 
   if (cipaction->arg == act_avail) {
-    printf(_("Recorded info about %s from %s.\n"),pkg->name,pfilename);
+    locale_printf(_("Recorded info about %s from %s.\n"),pkg->name,pfilename);
     pop_cleanup(ehflag_normaltidy);
     return;
   }
@@ -262,11 +263,11 @@
     case dep_predepends:
       if (!depisok(dsearch,&depprobwhy,0,1)) {
         varbufaddc(&depprobwhy,0);
-        fprintf(stderr, _("dpkg: regarding %s containing %s, pre-dependency 
problem:\n%s"),
+        locale_fprintf(stderr, _("dpkg: regarding %s containing %s, 
pre-dependency problem:\n%s"),
                 pfilename, pkg->name, depprobwhy.buf);
         if (!force_depends(dsearch->list))
           ohshit(_("pre-dependency problem - not installing 
%.250s"),pkg->name);
-        fprintf(stderr, _("dpkg: warning - ignoring pre-dependency problem 
!\n"));
+        locale_fprintf(stderr, _("dpkg: warning - ignoring pre-dependency 
problem !\n"));
       }
     }
   }
@@ -280,12 +281,12 @@
   filesdbinit();
   
   if (pkg->status != stat_notinstalled && pkg->status != stat_configfiles)
-    printf(_("Preparing to replace %s %s (using %s) ...\n"),
+    locale_printf(_("Preparing to replace %s %s (using %s) ...\n"),
            pkg->name,
            versiondescribe(&pkg->installed.version,vdew_nonambig),
            pfilename);
   else
-    printf(_("Unpacking %s (from %s) ...\n"),pkg->name,pfilename);
+    locale_printf(_("Unpacking %s (from %s) ...\n"),pkg->name,pfilename);
 
   if (f_noact) {
     pop_cleanup(ehflag_normaltidy);
@@ -396,7 +397,7 @@
     if (!(conflictor[i]->status == stat_halfconfigured ||
          conflictor[i]->status == stat_installed)) continue;
     for (deconpil= deconfigure; deconpil; deconpil= deconpil->next) {
-      printf(_("De-configuring %s, so that we can remove %s ...\n"),
+      locale_printf(_("De-configuring %s, so that we can remove %s ...\n"),
              deconpil->pkg->name, conflictor[i]->name);
       deconpil->pkg->status= stat_halfconfigured;
       modstatdb_note(deconpil->pkg);
@@ -454,7 +455,7 @@
                           "upgrade", versiondescribe(&pkg->installed.version,
                                                      vdew_nonambig),
                           (char*)0);
-    printf(_("Unpacking replacement %.250s ...\n"),pkg->name);
+    locale_printf(_("Unpacking replacement %.250s ...\n"),pkg->name);
   }
   
   /*
@@ -642,7 +643,7 @@
       if (!unlink(fnamevb.buf)) continue;
       if (errno == ENOTDIR) continue;
     }
-    fprintf(stderr,
+    locale_fprintf(stderr,
             _("dpkg: warning - unable to delete old file `%.250s': %s\n"),
             namenode->name, strerror(errno));
   }
@@ -722,7 +723,7 @@
       continue; /* ignore the control file */
     }
     if (!strcmp(de->d_name,LISTFILE)) {
-      fprintf(stderr, _("dpkg: warning - package %s"
+      locale_fprintf(stderr, _("dpkg: warning - package %s"
               " contained list as info file"), pkg->name);
       continue;
     }
@@ -882,7 +883,7 @@
     otherpkg->clientdata->istobe= itb_normal;
     if (pdep) continue;
 
-    printf(_("(Noting disappearance of %s, which has been completely 
replaced.)\n"),
+    locale_printf(_("(Noting disappearance of %s, which has been completely 
replaced.)\n"),
            otherpkg->name);
     debug(dbg_general, "process_archive disappearing %s",otherpkg->name);
     /* No, we're disappearing it.  This is the wrong time to go and
--- dpkg-1.10.9/main/query.c    2002-09-01 00:47:05.000000000 -0400
+++ dpkg-1.10.10/main/query.c   2003-01-04 17:00:52.000000000 -0500
@@ -40,6 +40,7 @@
 #include <dpkg-db.h>
 #include <myopt.h>
 
+#include "localeio.h"
 #include "filesdb.h"
 #include "main.h"
 
@@ -141,17 +142,17 @@
 Desired=Unknown/Install/Remove/Purge/Hold\n\
 | Status=Not/Installed/Config-files/Unpacked/Failed-config/Half-installed\n\
 |/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: 
uppercase=bad)\n"), stdout);
-    printf(format,'|','|','/', _("Name"), _("Version"), 40, _("Description"));
-    printf("+++-");                                    /* status */
-    for (l=0;l<nw;l++) printf("="); printf("-");       /* packagename */
-    for (l=0;l<vw;l++) printf("="); printf("-");       /* version */
-    for (l=0;l<dw;l++) printf("=");                    /* description */
-    printf("\n");
+    locale_printf(format,'|','|','/', _("Name"), _("Version"), 40, 
_("Description"));
+    locale_printf("+++-");                                     /* status */
+    for (l=0;l<nw;l++) locale_printf("="); locale_printf("-"); /* packagename 
*/
+    for (l=0;l<vw;l++) locale_printf("="); locale_printf("-"); /* version */
+    for (l=0;l<dw;l++) locale_printf("=");                     /* description 
*/
+    locale_printf("\n");
     *head= 1;
   }
   if (!pkg->installed.valid) blankpackageperfile(&pkg->installed);
   limiteddescription(pkg,dw,&pdesc,&l);
-  printf(format,
+  locale_printf(format,
          "uihrp"[pkg->want],
          "nUFiHc"[pkg->status],
          " R?#"[pkg->eflag],
@@ -197,7 +198,7 @@
         list1package(pkg,&head); found++;
       }
       if (!found) {
-        fprintf(stderr,_("No packages found matching %s.\n"),thisarg);
+        locale_fprintf(stderr,_("No packages found matching %s.\n"),thisarg);
        nerrs++;
       }
     }
@@ -213,9 +214,9 @@
 
   if (namenode->divert) {
     for (i=0; i<2; i++) {
-      if (namenode->divert->pkg) printf(_("diversion by 
%s"),namenode->divert->pkg->name);
-      else printf(_("local diversion"));
-      printf(" %s: %s\n", i ? _("to") : _("from"),
+      if (namenode->divert->pkg) locale_printf(_("diversion by 
%s"),namenode->divert->pkg->name);
+      else locale_printf(_("local diversion"));
+      locale_printf(" %s: %s\n", i ? _("to") : _("from"),
              i ?
              (namenode->divert->useinstead
               ? namenode->divert->useinstead->name
@@ -236,7 +237,7 @@
       found++;
     }
   }
-  if (found) printf(": %s\n",namenode->name);
+  if (found) locale_printf(": %s\n",namenode->name);
   return found + (namenode->divert ? 1 : 0);
 }
 
@@ -276,7 +277,7 @@
       iterfileend(it);
     }
     if (!found) {
-      fprintf(stderr,_("dpkg: %s not found.\n"),thisarg);
+      locale_fprintf(stderr,_("dpkg: %s not found.\n"),thisarg);
       nerrs++;
       if (ferror(stderr)) werr("stderr");
     } else {
@@ -314,7 +315,7 @@
           !pkg->files &&
           pkg->want == want_unknown &&
           !informative(pkg,&pkg->installed)) {
-        fprintf(stderr,_("Package `%s' is not installed and no info is 
available.\n"),pkg->name);
+        locale_fprintf(stderr,_("Package `%s' is not installed and no info is 
available.\n"),pkg->name);
         failures++;
       } else {
         writerecord(stdout, "<stdout>", pkg, &pkg->installed);
@@ -323,7 +324,7 @@
 
     case act_printavail:
       if (!informative(pkg,&pkg->available)) {
-        fprintf(stderr,_("Package `%s' is not available.\n"),pkg->name);
+        locale_fprintf(stderr,_("Package `%s' is not available.\n"),pkg->name);
         failures++;
       } else {
         writerecord(stdout, "<stdout>", pkg, &pkg->available);
@@ -333,7 +334,7 @@
     case act_listfiles:
       switch (pkg->status) {
       case stat_notinstalled: 
-        fprintf(stderr,_("Package `%s' is not installed.\n"),pkg->name);
+        locale_fprintf(stderr,_("Package `%s' is not installed.\n"),pkg->name);
         failures++;
         break;
         
@@ -342,16 +343,16 @@
         ensure_diversions();
         file= pkg->clientdata->files;
         if (!file) {
-          printf(_("Package `%s' does not contain any files (!)\n"),pkg->name);
+          locale_printf(_("Package `%s' does not contain any files 
(!)\n"),pkg->name);
         } else {
           while (file) {
             namenode= file->namenode;
             puts(namenode->name);
             if (namenode->divert && !namenode->divert->camefrom) {
-              if (!namenode->divert->pkg) printf(_("locally diverted"));
-              else if (pkg == namenode->divert->pkg) printf(_("package diverts 
others"));
-              else printf(_("diverted by %s"),namenode->divert->pkg->name);
-              printf(_(" to: %s\n"),namenode->divert->useinstead->name);
+              if (!namenode->divert->pkg) locale_printf(_("locally diverted"));
+              else if (pkg == namenode->divert->pkg) locale_printf(_("package 
diverts others"));
+              else locale_printf(_("diverted by 
%s"),namenode->divert->pkg->name);
+              locale_printf(_(" to: %s\n"),namenode->divert->useinstead->name);
             }
             file= file->next;
           }
@@ -419,7 +420,7 @@
         show1package(fmt,pkg); found++;
       }
       if (!found) {
-        fprintf(stderr,_("No packages found matching %s.\n"),thisarg);
+        locale_fprintf(stderr,_("No packages found matching %s.\n"),thisarg);
        nerrs++;
       }
     }
--- dpkg-1.10.9/main/remove.c   2002-05-06 12:18:16.000000000 -0400
+++ dpkg-1.10.10/main/remove.c  2003-01-04 17:00:35.000000000 -0500
@@ -38,6 +38,7 @@
 #include <dpkg-db.h>
 #include <myopt.h>
 
+#include "localeio.h"
 #include "filesdb.h"
 #include "main.h"
 
@@ -74,7 +75,7 @@
   debug(dbg_general,"deferred_remove package %s",pkg->name);
   
   if (pkg->status == stat_notinstalled) {
-    fprintf(stderr,
+    locale_fprintf(stderr,
             _("dpkg - warning: ignoring request to remove %.250s which isn't 
installed.\n"),
             pkg->name);
     pkg->clientdata->istobe= itb_normal;
@@ -82,7 +83,7 @@
   } else if (!f_pending &&
              pkg->status == stat_configfiles &&
              cipaction->arg != act_purge) {
-    fprintf(stderr,
+    locale_fprintf(stderr,
             _("dpkg - warning: ignoring request to remove %.250s, only the 
config\n"
             " files of which are on the system.  Use --purge to remove them 
too.\n"),
             pkg->name);
@@ -117,13 +118,13 @@
   } else if (rok == 0) {
     sincenothing= 0;
     varbufaddc(&raemsgs,0);
-    fprintf(stderr,
+    locale_fprintf(stderr,
             _("dpkg: dependency problems prevent removal of %s:\n%s"),
             pkg->name, raemsgs.buf);
     ohshit(_("dependency problems - not removing"));
   } else if (raemsgs.used) {
     varbufaddc(&raemsgs,0);
-    fprintf(stderr,
+    locale_fprintf(stderr,
             _("dpkg: %s: dependency problems, but removing anyway as you 
request:\n%s"),
             pkg->name, raemsgs.buf);
   }
@@ -139,7 +140,7 @@
   filesdbinit();
 
   if (f_noact) {
-    printf(_("Would remove or purge %s ...\n"),pkg->name);
+    locale_printf(_("Would remove or purge %s ...\n"),pkg->name);
     pkg->status= stat_notinstalled;
     pkg->clientdata->istobe= itb_normal;
     return;
@@ -147,7 +148,7 @@
 
   oldconffsetflags(pkg->installed.conffiles);
     
-  printf(_("Removing %s ...\n"),pkg->name);
+  locale_printf(_("Removing %s ...\n"),pkg->name);
   if (pkg->status == stat_halfconfigured || pkg->status == stat_installed) {
 
     if (pkg->status == stat_installed || pkg->status == stat_halfconfigured) {
@@ -242,14 +243,14 @@
       debug(dbg_eachfiledetail, "removal_bulk removing `%s'", fnvb.buf);
       if (!rmdir(fnvb.buf) || errno == ENOENT || errno == ELOOP) continue;
       if (errno == ENOTEMPTY) {
-        fprintf(stderr,
+        locale_fprintf(stderr,
                 _("dpkg - warning: while removing %.250s, directory `%.250s' 
not empty "
                 "so not removed.\n"),
                 pkg->name, namenode->name);
         push_leftover(&leftover,namenode);
         continue;
       } else if (errno == EBUSY || errno == EPERM) {
-        fprintf(stderr, _("dpkg - warning: while removing %.250s,"
+        locale_fprintf(stderr, _("dpkg - warning: while removing %.250s,"
                 " unable to remove directory `%.250s':"
                 " %s - directory may be a mount point ?\n"),
                 pkg->name, namenode->name, strerror(errno));
@@ -335,7 +336,7 @@
 
   } else if (pkg->want == want_purge) {
 
-    printf(_("Purging configuration files for %s ...\n"),pkg->name);
+    locale_printf(_("Purging configuration files for %s ...\n"),pkg->name);
     ensure_packagefiles_available(pkg); /* We may have modified this above. */
 
     /* We're about to remove the configuration, so remove the note
--- dpkg-1.10.9/main/select.c   2002-05-06 12:18:16.000000000 -0400
+++ dpkg-1.10.10/main/select.c  2003-01-04 16:59:39.000000000 -0500
@@ -29,6 +29,7 @@
 #include <dpkg.h>
 #include <dpkg-db.h>
 
+#include "localeio.h"
 #include "filesdb.h"
 #include "main.h"
 
@@ -37,7 +38,7 @@
 
   if (pkg->want == want_unknown) return;
   l= strlen(pkg->name); l >>= 3; l= 6-l; if (l<1) l=1;
-  printf("%s%.*s%s\n",pkg->name,l,"\t\t\t\t\t\t",wantinfos[pkg->want].name);
+  
locale_printf("%s%.*s%s\n",pkg->name,l,"\t\t\t\t\t\t",wantinfos[pkg->want].name);
 }         
 
 void getselections(const char *const *argv) {
@@ -77,7 +78,7 @@
         getsel1package(pkg); found++;
       }
       if (!found)
-        fprintf(stderr,_("No packages found matching %s.\n"),thisarg);
+        locale_fprintf(stderr,_("No packages found matching %s.\n"),thisarg);
     }
   }
   if (ferror(stdout)) werr("stdout");
--- dpkg-1.10.9/main/update.c   2002-05-06 12:18:16.000000000 -0400
+++ dpkg-1.10.10/main/update.c  2003-01-04 16:57:20.000000000 -0500
@@ -63,10 +63,10 @@
   
   switch (cipaction->arg) {
   case act_avreplace:
-    printf(_("Replacing available packages info, using %s.\n"),sourcefile);
+    locale_printf(_("Replacing available packages info, using 
%s.\n"),sourcefile);
     break;
   case act_avmerge:
-    printf(_("Updating available packages info, using %s.\n"),sourcefile);
+    locale_printf(_("Updating available packages info, using 
%s.\n"),sourcefile);
     break;
   case act_avclear:
     break;
@@ -90,7 +90,7 @@
   }
 
   if (cipaction->arg != act_avclear)
-    printf(_("Information about %d package(s) was updated.\n"),count);
+    locale_printf(_("Information about %d package(s) was updated.\n"),count);
 }
 
 void forgetold(const char *const *argv) {
--- dpkg-1.10.9/split/info.c    2002-05-06 12:18:16.000000000 -0400
+++ dpkg-1.10.10/split/info.c   2003-01-04 17:03:24.000000000 -0500
@@ -33,6 +33,7 @@
 #include <dpkg.h>
 #include <dpkg-db.h>
 #include "dpkg-split.h"
+#include "localeio.h"
 
 static unsigned long unsignedlong(const char *value, const char *fn, const 
char *what) {
   unsigned long r;
@@ -185,7 +186,7 @@
 }
 
 void print_info(const struct partinfo *pi) {
-  printf(_("%s:\n"
+  locale_printf(_("%s:\n"
          "    Part format version:            %s\n"
          "    Part of package:                %s\n"
          "        ... version:                %s\n"
@@ -225,7 +226,7 @@
     if (pi) {
       print_info(pi);
     } else {
-      printf(_("file `%s' is not an archive part\n"),thisarg);
+      locale_printf(_("file `%s' is not an archive part\n"),thisarg);
     }
     if (ferror(stdout)) werr("stdout");
   }
--- dpkg-1.10.9/split/queue.c   2002-05-06 12:18:16.000000000 -0400
+++ dpkg-1.10.10/split/queue.c  2003-01-04 17:02:55.000000000 -0500
@@ -42,6 +42,7 @@
 #include <dpkg.h>
 #include <dpkg-db.h>
 #include "dpkg-split.h"
+#include "localeio.h"
 
 static int decompose_filename(const char *filename, struct partqueue *pq) {
   const char *p;
@@ -113,7 +114,7 @@
   if (!part) ohshite(_("unable to read part file `%.250s'"),partfile);
   if (!read_info(part,partfile,refi)) {
     if (!npquiet)
-      printf(_("File `%.250s' is not part of a multipart 
archive.\n"),partfile);
+      locale_printf(_("File `%.250s' is not part of a multipart 
archive.\n"),partfile);
     if (fclose(stdout)) werr("stdout");
     exit(1);
   }
@@ -159,12 +160,12 @@
     if (fclose(part)) werr(p);
     if (rename(p,q)) ohshite(_("unable to rename new depot file `%.250s' to 
`%.250s'"),p,q);
 
-    printf(_("Part %d of package %s filed (still want 
"),refi->thispartn,refi->package);
+    locale_printf(_("Part %d of package %s filed (still want 
"),refi->thispartn,refi->package);
     /* There are still some parts missing. */
     for (i=0, ap=0; i<refi->maxpartn; i++)
       if (!partlist[i])
-        printf("%s%d", !ap++ ? "" : i==j ? _(" and ") : ", ", i+1);
-    printf(").\n");
+        locale_printf("%s%d", !ap++ ? "" : i==j ? _(" and ") : ", ", i+1);
+    locale_printf(").\n");
 
   } else {
 
@@ -202,9 +203,9 @@
       ohshit(_("unable to stat `%.250s'"),pq->info.filename);
     if (S_ISREG(stab.st_mode)) {
       bytes= stab.st_size;
-      printf(_(" %s (%lu bytes)\n"),pq->info.filename,bytes);
+      locale_printf(_(" %s (%lu bytes)\n"),pq->info.filename,bytes);
     } else {
-      printf(_(" %s (not a plain file)\n"),pq->info.filename);
+      locale_printf(_(" %s (not a plain file)\n"),pq->info.filename);
     }
   }
   if (!*head) putchar('\n');
@@ -214,14 +215,14 @@
     if (!pq->info.md5sum) continue;
     mustgetpartinfo(pq->info.filename,&ti);
     fputs(gettext(head),stdout); head= "";
-    printf(" Package %s: part(s) ",ti.package);
+    locale_printf(" Package %s: part(s) ",ti.package);
     bytes= 0;
     for (i=0; i<ti.maxpartn; i++) {
       for (qq= pq;
            qq && !(partmatches(&qq->info,&ti) && qq->info.thispartn == i+1);
            qq= qq->nextinqueue);
       if (qq) {
-        printf("%d ",i+1);
+        locale_printf("%d ",i+1);
         if (lstat(qq->info.filename,&stab))
           ohshite(_("unable to stat `%.250s'"),qq->info.filename);
         if (!S_ISREG(stab.st_mode))
@@ -230,7 +231,7 @@
         qq->info.md5sum= NULL; /* don't find this package again */
       }
     }
-    printf(_("(total %lu bytes)\n"),bytes);
+    locale_printf(_("(total %lu bytes)\n"),bytes);
   }
   if (fclose(stdout)) werr("stdout");
 }
@@ -254,7 +255,7 @@
     }
     if (unlink(pq->info.filename))
       ohshite(_("unable to discard `%.250s'"),pq->info.filename);
-    printf(_("Deleted %s.\n"),pq->info.filename);
+    locale_printf(_("Deleted %s.\n"),pq->info.filename);
   }
 }
 

Reply via email to