Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 102427 Details for
Bug 93664
sys-apps/man: messages look like garbage (unicode issues)
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
use iconv for converting catgets texts to correct charset
man-1.6d-catgets-encoding.patch (text/plain), 5.26 KB, created by
Matthias Schwarzott
on 2006-11-20 13:13:22 UTC
(
hide
)
Description:
use iconv for converting catgets texts to correct charset
Filename:
MIME Type:
Creator:
Matthias Schwarzott
Created:
2006-11-20 13:13:22 UTC
Size:
5.26 KB
patch
obsolete
>diff -ru man-1.6d-orig/msgs/Makefile.in man-1.6d/msgs/Makefile.in >--- man-1.6d-orig/msgs/Makefile.in 2006-11-20 18:22:30.000000000 +0100 >+++ man-1.6d/msgs/Makefile.in 2006-11-20 21:43:36.000000000 +0100 >@@ -1,10 +1,17 @@ > > all: ../src/makemsg gencat > @for i in mess.??; do ../src/makemsg -c $$i $$i.catin; \ >- cat $$i.codeset $$i.catin > $$i.catin2; \ >- echo "==== Making $$i.cat ====" ;\ >- LC_ALL=en_US.UTF-8 ./gencat $$i.cat $$i.catin2; done; \ >- rm -f core *.catin *.catin2 >+ echo "==== Making $$i.cat ====" ;\ >+ echo '$$ codeset=UTF-8' > $$i.catin.utf8; \ >+ if [[ -e $$i.codeset ]]; then \ >+ codeset=$$(sed -e 's/.*=//' $$i.codeset); \ >+ iconv -f $$codeset -t UTF-8 < $$i.catin >> $$i.catin.utf8; \ >+ else \ >+ cat $$i.catin >> $$i.catin.utf8; \ >+ fi; \ >+ LC_ALL=C ./gencat $$i.cat $$i.catin.utf8; \ >+ done; \ >+ echo rm -f core *.catin *.catin.utf8 > > install: > sh ./inst.sh "@languages@" "$(DESTDIR)@locale@" >diff -ru man-1.6d-orig/src/gripes.c man-1.6d/src/gripes.c >--- man-1.6d-orig/src/gripes.c 2006-11-20 18:22:30.000000000 +0100 >+++ man-1.6d/src/gripes.c 2006-11-20 18:23:59.000000000 +0100 >@@ -4,6 +4,7 @@ > > #include "gripes.h" > #include "man.h" /* for progname */ >+#include "man-iconv.h" /*for get_locale_charset */ > > extern char *msg[]; > >@@ -113,27 +114,60 @@ > "man: internal error - cannot find message %d\n", n); > exit (1); > } >+ > return s; > } > > #endif /* NONLS */ > > void >-gripe (int n, ...) { >+gripe (int n, ...) { > va_list p; >+ char *mes; >+ char *conv_mes; >+ int free_mes; > > va_start(p, n); >- vfprintf (stderr, getmsg(n), p); >+ mes=getmsg(n); >+#ifdef USE_ICONV >+ free_mes=1; >+ if ((conv_mes=convert_with_iconv(mes, "UTF-8", >+ get_locale_charset()))==NULL) { >+#endif >+ conv_mes=mes; >+ free_mes=0; >+#ifdef USE_ICONV >+ } >+#endif >+ vfprintf (stderr, conv_mes, p); > va_end(p); > fflush (stderr); >+ if (free_mes) >+ free(conv_mes); > } > > void > fatal (int n, ...) { > va_list p; >+ char *mes, *conv_mes; >+ int free_mes; >+ > fprintf (stderr, "%s: ", progname); > va_start(p, n); >- vfprintf (stderr, getmsg(n), p); >+ mes=getmsg(n); >+#ifdef USE_ICONV >+ free_mes=1; >+ if ((conv_mes=convert_with_iconv(mes, "UTF-8", >+ get_locale_charset()))==NULL) { >+#endif >+ conv_mes=mes; >+ free_mes=0; >+#ifdef USE_ICONV >+ } >+#endif >+ vfprintf (stderr, conv_mes, p); > va_end(p); >+ if (free_mes) >+ free(conv_mes); > exit (1); > } >diff -ru man-1.6d-orig/src/Makefile.in man-1.6d/src/Makefile.in >--- man-1.6d-orig/src/Makefile.in 2006-11-20 18:22:30.000000000 +0100 >+++ man-1.6d/src/Makefile.in 2006-11-20 18:23:59.000000000 +0100 >@@ -17,7 +17,7 @@ > > pager = @pager@ > >-DEFS = @DEFS@ >+DEFS = @DEFS@ -DUSE_ICONV > CWARN = -Wall -Wstrict-prototypes -Wmissing-prototypes > CWARNNP = -Wall > >diff -ru man-1.6d-orig/src/man-iconv.c man-1.6d/src/man-iconv.c >--- man-1.6d-orig/src/man-iconv.c 2006-11-20 18:22:30.000000000 +0100 >+++ man-1.6d/src/man-iconv.c 2006-11-20 22:10:58.000000000 +0100 >@@ -20,7 +20,6 @@ > * By default iconv is not used - this is the wrong interface. > * But if you want it, define USE_ICONV. > */ >-#undef USE_ICONV > > #include <stdio.h> /* NULL */ > >@@ -31,6 +30,7 @@ > #include <locale.h> /* setlocale */ > #include <langinfo.h> /* nl_langinfo */ > #include <iconv.h> /* iconv_open */ >+#include <errno.h> /* errno variable */ > #include "man-iconv.h" /* get_converter */ > #include "util.h" /* my_strdup */ > #include "man.h" /* debug */ >@@ -65,7 +65,7 @@ > return iconv_flags; > } > >-static char * >+char * > get_locale_charset (void) { > char *old_lc_ctype, *charset; > >@@ -77,6 +77,50 @@ > return charset; > } > >+char * >+convert_with_iconv (const char *from, const char *from_codeset, >+ const char *to_codest) { >+ size_t inbytes_remaining; >+ size_t outbytes_remaining; >+ size_t outbuf_size; >+ char *dest, *outp; >+ size_t len; >+ const char *p; >+ iconv_t cd; >+ size_t err; >+ p=from; >+ if ((cd=iconv_open(to_codest, from_codeset))==(iconv_t)(-1)) >+ return NULL; >+ len=strlen(from); >+ inbytes_remaining = len; >+ outbuf_size = len + 1; /* + 1 for nul in case len == 1 */ >+ outbytes_remaining = outbuf_size - 1; /* -1 for nul */ >+ dest=outp=malloc(outbuf_size); >+ again: >+ err = iconv (cd, (char **)&p, &inbytes_remaining, &outp, &outbytes_remaining); >+ if (err == (size_t) -1) { >+ if (errno==E2BIG) { >+ size_t used = outp - dest; >+ >+ outbuf_size *= 2; >+ dest = realloc (dest, outbuf_size); >+ >+ outp = dest + used; >+ outbytes_remaining = outbuf_size - used - 1; /* -1 for nul */ >+ >+ goto again; >+ } else { >+ free(dest); >+ dest=NULL; >+ goto exit; >+ } >+ } >+ exit: >+ iconv_close(cd); >+ outp[0]=0; >+ return dest; >+} >+ > static char * > get_man_charset (const char *path) { > char *charset_env, *file, *path2, *p; >Nur in man-1.6d/src: .man-iconv.c.swp. >diff -ru man-1.6d-orig/src/man-iconv.h man-1.6d/src/man-iconv.h >--- man-1.6d-orig/src/man-iconv.h 2006-11-20 18:22:30.000000000 +0100 >+++ man-1.6d/src/man-iconv.h 2006-11-20 18:23:59.000000000 +0100 >@@ -1 +1,13 @@ >+#ifndef MAN_ICONV_H >+#define MAN_ICONV_H >+ > extern const char *get_converter (const char *path); >+ >+#ifdef USE_ICONV >+extern char *get_locale_charset (void); >+extern char *convert_with_iconv (const char *from, >+ const char *from_codeset, >+ const char *to_codest); >+#endif >+ >+#endif/*MAN_ICONV_H*/
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 93664
:
59618
|
61867
|
67503
|
75817
| 102427 |
144777
|
144781
|
240751