]> pilppa.org Git - familiar-h63xx-build.git/blob - org.handhelds.familiar/packages/gnupg/gnupg-1.4.0/21_strgutil_update.patch
OE tree imported from monotone branch org.openembedded.oz354fam083 at revision 8b12e3...
[familiar-h63xx-build.git] / org.handhelds.familiar / packages / gnupg / gnupg-1.4.0 / 21_strgutil_update.patch
1 --- gnupg-1.4.0/util/strgutil.c 2004-11-17 15:50:58.000000000 +0000
2 +++ /tmp/dpep.GtChya/gnupg-1.4.0/util/strgutil.c        2005-02-05 00:53:22.921264222 +0000
3 @@ -1,6 +1,6 @@
4  /* strgutil.c -  string utilities
5   * Copyright (C) 1994, 1998, 1999, 2000, 2001,
6 - *               2003 Free Software Foundation, Inc.
7 + *               2003, 2004, 2005 Free Software Foundation, Inc.
8   *
9   * This file is part of GnuPG.
10   *
11 @@ -144,6 +144,8 @@
12          {
13            log_info (_("error loading `%s': %s\n"),
14                       "iconv.dll",  dlerror ());
15 +          log_info(_("please see http://www.gnupg.org/download/iconv.html "
16 +                     "for more information\n"));
17            iconv_open = NULL;
18            iconv = NULL;
19            iconv_close = NULL;
20 @@ -451,10 +453,33 @@
21  handle_iconv_error (const char *to, const char *from, int use_fallback)
22  {
23    if (errno == EINVAL)
24 -    log_error (_("conversion from `%s' to `%s' not available\n"),
25 -               from, to);
26 +    {
27 +      static int shown1, shown2;
28 +      int x;
29 +
30 +      if (to && !strcmp (to, "utf-8"))
31 +        {
32 +          x = shown1;
33 +          shown1 = 1;
34 +        }
35 +      else
36 +        {
37 +          x = shown2;
38 +          shown2 = 1;
39 +        }
40 +
41 +      if (!x)
42 +        log_info (_("conversion from `%s' to `%s' not available\n"),
43 +                  from, to);
44 +    }
45    else
46 -    log_error (_("iconv_open failed: %s\n"), strerror (errno));
47 +    {
48 +      static int shown;
49 +
50 +      if (!shown)
51 +        log_info (_("iconv_open failed: %s\n"), strerror (errno));
52 +      shown = 1;
53 +    }
54  
55    if (use_fallback)
56      {
57 @@ -479,28 +504,78 @@
58      if (!newset) {
59  #ifdef _WIN32
60          static char codepage[30];
61 +        unsigned int cpno;
62 +        const char *aliases;
63  
64          /* We are a console program thus we need to use the
65 -           GetConsoleOutputCP fucntion and not the the GetACP which
66 +           GetConsoleOutputCP function and not the the GetACP which
67             would give the codepage for a GUI program.  Note this is
68             not a bulletproof detection because GetConsoleCP might
69 -           retrun a different one for console input.  Not sure how to
70 -           cope with that.  */
71 -        sprintf (codepage, "CP%u", (unsigned int)GetConsoleOutputCP ());
72 -        /* If it is the Windows name for Latin-1 we use the standard
73 -           name instead to avoid loading of iconv.dll.  Unfortunately
74 -           it is often CP850 and we don't have a custom translation
75 -           for it. */
76 -        if (!strcmp (codepage, "CP1252"))
77 -            newset = "iso-8859-1";
78 -        else
79 -            newset = codepage;
80 +           return a different one for console input.  Not sure how to
81 +           cope with that.  If the console Code page is not known we
82 +           fall back to the system code page.  */
83 +        cpno = GetConsoleOutputCP ();
84 +        if (!cpno)
85 +          cpno = GetACP ();
86 +        sprintf (codepage, "CP%u", cpno );
87 +        /* Resolve alias.  We use a long string string and not the
88 +           usual array to optimize if the code is taken to a DSO.
89 +           Taken from libiconv 1.9.2. */
90 +        newset = codepage;
91 +        for (aliases = ("CP936"   "\0" "GBK" "\0"
92 +                        "CP1361"  "\0" "JOHAB" "\0"
93 +                        "CP20127" "\0" "ASCII" "\0"
94 +                        "CP20866" "\0" "KOI8-R" "\0"
95 +                        "CP21866" "\0" "KOI8-RU" "\0"
96 +                        "CP28591" "\0" "ISO-8859-1" "\0"
97 +                        "CP28592" "\0" "ISO-8859-2" "\0"
98 +                        "CP28593" "\0" "ISO-8859-3" "\0"
99 +                        "CP28594" "\0" "ISO-8859-4" "\0"
100 +                        "CP28595" "\0" "ISO-8859-5" "\0"
101 +                        "CP28596" "\0" "ISO-8859-6" "\0"
102 +                        "CP28597" "\0" "ISO-8859-7" "\0"
103 +                        "CP28598" "\0" "ISO-8859-8" "\0"
104 +                        "CP28599" "\0" "ISO-8859-9" "\0"
105 +                        "CP28605" "\0" "ISO-8859-15" "\0");
106 +             *aliases;
107 +             aliases += strlen (aliases) + 1, aliases += strlen (aliases) + 1)
108 +          {
109 +            if (!strcmp (codepage, aliases) ||(*aliases == '*' && !aliases[1]))
110 +              {
111 +                newset = aliases + strlen (aliases) + 1;
112 +                break;
113 +              }
114 +          }
115 +
116  #else
117  #ifdef HAVE_LANGINFO_CODESET
118          newset = nl_langinfo (CODESET);
119 -#else
120 -        newset = "iso-8859-1";
121 -#endif
122 +#else /* !HAVE_LANGINFO_CODESET */
123 +        /* Try to get the used charset from environment variables.  */
124 +        static char codepage[30];
125 +        const char *lc, *dot, *mod;
126 +
127 +        strcpy (codepage, "iso-8859-1");
128 +        lc = getenv ("LC_ALL");
129 +        if (!lc || !*lc) {
130 +            lc = getenv ("LC_CTYPE");
131 +            if (!lc || !*lc)
132 +                lc = getenv ("LANG");
133 +        }
134 +        if (lc && *lc) {
135 +            dot = strchr (lc, '.');
136 +            if (dot) {
137 +                mod = strchr (++dot, '@');
138 +                if (!mod)
139 +                    mod = dot + strlen (dot);
140 +                if (mod - dot < sizeof codepage && dot != mod) {
141 +                    memcpy (codepage, dot, mod - dot);
142 +                    codepage [mod - dot] = 0;
143 +                }
144 +            }
145 +        }
146 +        newset = codepage;
147 +#endif  /* !HAVE_LANGINFO_CODESET */
148  #endif
149      }
150  
151 @@ -511,9 +586,18 @@
152              newset++;
153      }
154  
155 +    /* Note that we silently assume that plain ASCII is actually meant
156 +       as Latin-1.  This makes sense because many Unix system don't
157 +       have their locale set up properly and thus would get annoying
158 +       error messages and we have to handle all the "bug"
159 +       reports. Latin-1 has always been the character set used for 8
160 +       bit characters on Unix systems. */
161      if( !*newset
162          || !ascii_strcasecmp (newset, "8859-1" )
163 -        || !ascii_strcasecmp (newset, "8859-15" ) ) {
164 +        || !ascii_strcasecmp (newset, "646" )
165 +        || !ascii_strcasecmp (newset, "ASCII" )
166 +        || !ascii_strcasecmp (newset, "ANSI_X3.4-1968" )
167 +        ) {
168          active_charset_name = "iso-8859-1";
169          no_translation = 0;
170         active_charset = NULL;
171 @@ -645,8 +729,12 @@
172        if ( iconv (cd, (ICONV_CONST char **)&inptr, &inbytes,
173                    &outptr, &outbytes) == (size_t)-1)
174          {
175 -          log_error (_("conversion from `%s' to `%s' failed: %s\n"),
176 -                       active_charset_name, "utf-8", strerror (errno));
177 +          static int shown;
178 +
179 +          if (!shown)
180 +            log_info (_("conversion from `%s' to `%s' failed: %s\n"),
181 +                      active_charset_name, "utf-8", strerror (errno));
182 +          shown = 1;
183            /* We don't do any conversion at all but use the strings as is. */
184            strcpy (buffer, string);
185          }
186 @@ -919,8 +1007,12 @@
187              outbuf = outptr = m_alloc (outbytes);
188              if ( iconv (cd, (ICONV_CONST char **)&inptr, &inbytes,
189                          &outptr, &outbytes) == (size_t)-1) {
190 -                log_error (_("conversion from `%s' to `%s' failed: %s\n"),
191 -                           "utf-8", active_charset_name, strerror (errno));
192 +                static int shown;
193 +                
194 +                if (!shown)
195 +                  log_info (_("conversion from `%s' to `%s' failed: %s\n"),
196 +                            "utf-8", active_charset_name, strerror (errno));
197 +                shown = 1;
198                  /* Didn't worked out.  Temporary disable the use of
199                   * iconv and fall back to our old code. */
200                  m_free (buffer);