mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-03 12:11:33 +01:00
UTF-8 Fixes
This commit is contained in:
parent
3bcccb1666
commit
3c351d0232
@ -1,3 +1,8 @@
|
|||||||
|
2007-04-25 Werner Koch <wk@g10code.com>
|
||||||
|
|
||||||
|
* i18n.h (ngettext): New.
|
||||||
|
* simple-gettext.c (ngettext): New.
|
||||||
|
|
||||||
2007-04-20 Werner Koch <wk@g10code.com>
|
2007-04-20 Werner Koch <wk@g10code.com>
|
||||||
|
|
||||||
* miscellaneous.c (my_gcry_logger, my_gcry_outofcore_handler):
|
* miscellaneous.c (my_gcry_logger, my_gcry_outofcore_handler):
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
#ifdef USE_SIMPLE_GETTEXT
|
#ifdef USE_SIMPLE_GETTEXT
|
||||||
int set_gettext_file( const char *filename );
|
int set_gettext_file( const char *filename );
|
||||||
const char *gettext( const char *msgid );
|
const char *gettext( const char *msgid );
|
||||||
|
const char *ngettext(const char *msgid1, const char *msgid2,
|
||||||
|
unsigned long int n);
|
||||||
# define _(a) gettext (a)
|
# define _(a) gettext (a)
|
||||||
# define N_(a) (a)
|
# define N_(a) (a)
|
||||||
#else
|
#else
|
||||||
@ -34,6 +36,7 @@
|
|||||||
# else
|
# else
|
||||||
# define _(a) (a)
|
# define _(a) (a)
|
||||||
# define N_(a) (a)
|
# define N_(a) (a)
|
||||||
|
# define ngettext(a,b,c) ((c)==1? (a):(b))
|
||||||
# endif
|
# endif
|
||||||
#endif /*!USE_SIMPLE_GETTEXT*/
|
#endif /*!USE_SIMPLE_GETTEXT*/
|
||||||
|
|
||||||
|
@ -419,6 +419,15 @@ gettext( const char *msgid )
|
|||||||
return msgid;
|
return msgid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const char *
|
||||||
|
ngettext (const char *msgid1, const char *msgid2, unsigned long int n)
|
||||||
|
{
|
||||||
|
/* We use the simple Germanic plural rule. */
|
||||||
|
return gettext (n==1? msgid1 : msgid2);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
unsigned int cp1, cp2;
|
unsigned int cp1, cp2;
|
||||||
|
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
2007-04-25 Werner Koch <wk@g10code.com>
|
||||||
|
|
||||||
|
* argparse.c (long_opt_strlen): Fixed for utf-8.
|
||||||
|
|
||||||
2007-03-07 Werner Koch <wk@g10code.com>
|
2007-03-07 Werner Koch <wk@g10code.com>
|
||||||
|
|
||||||
* argparse.c (strusage): Set copyright year to 2007.
|
* argparse.c (strusage): Set copyright year to 2007.
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/* [argparse.c wk 17.06.97] Argument Parser for option handling
|
/* [argparse.c wk 17.06.97] Argument Parser for option handling
|
||||||
* Copyright (C) 1998, 1999, 2000, 2001, 2006 Free Software Foundation, Inc.
|
* Copyright (C) 1998, 1999, 2000, 2001, 2006
|
||||||
|
* 2007 Free Software Foundation, Inc.
|
||||||
*
|
*
|
||||||
* This file is part of JNLIB.
|
* This file is part of JNLIB.
|
||||||
*
|
*
|
||||||
@ -29,6 +30,9 @@
|
|||||||
#include "mischelp.h"
|
#include "mischelp.h"
|
||||||
#include "stringhelp.h"
|
#include "stringhelp.h"
|
||||||
#include "logging.h"
|
#include "logging.h"
|
||||||
|
#ifdef JNLIB_NEED_UTF8CONV
|
||||||
|
#include "utf8conv.h"
|
||||||
|
#endif
|
||||||
#include "argparse.h"
|
#include "argparse.h"
|
||||||
|
|
||||||
|
|
||||||
@ -438,7 +442,7 @@ find_long_option( ARGPARSE_ARGS *arg,
|
|||||||
for(i=0; opts[i].short_opt; i++ )
|
for(i=0; opts[i].short_opt; i++ )
|
||||||
if( opts[i].long_opt && !strcmp( opts[i].long_opt, keyword) )
|
if( opts[i].long_opt && !strcmp( opts[i].long_opt, keyword) )
|
||||||
return i;
|
return i;
|
||||||
#if 0
|
#if 0
|
||||||
{
|
{
|
||||||
ALIAS_DEF a;
|
ALIAS_DEF a;
|
||||||
/* see whether it is an alias */
|
/* see whether it is an alias */
|
||||||
@ -450,7 +454,7 @@ find_long_option( ARGPARSE_ARGS *arg,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
/* not found, see whether it is an abbreviation */
|
/* not found, see whether it is an abbreviation */
|
||||||
/* aliases may not be abbreviated */
|
/* aliases may not be abbreviated */
|
||||||
n = strlen( keyword );
|
n = strlen( keyword );
|
||||||
@ -699,18 +703,28 @@ set_opt_arg(ARGPARSE_ARGS *arg, unsigned flags, char *s)
|
|||||||
static size_t
|
static size_t
|
||||||
long_opt_strlen( ARGPARSE_OPTS *o )
|
long_opt_strlen( ARGPARSE_OPTS *o )
|
||||||
{
|
{
|
||||||
size_t n = strlen(o->long_opt);
|
size_t n = strlen (o->long_opt);
|
||||||
|
|
||||||
if( o->description && *o->description == '|' ) {
|
if ( o->description && *o->description == '|' )
|
||||||
const char *s;
|
{
|
||||||
|
const char *s;
|
||||||
s=o->description+1;
|
#ifdef JNLIB_NEED_UTF8CONV
|
||||||
if( *s != '=' )
|
int is_utf8 = is_native_utf8 ();
|
||||||
n++;
|
#endif
|
||||||
for(; *s && *s != '|'; s++ )
|
|
||||||
n++;
|
s=o->description+1;
|
||||||
|
if ( *s != '=' )
|
||||||
|
n++;
|
||||||
|
/* For a (mostly) correct length calculation we exclude
|
||||||
|
continuation bytes (10xxxxxx) if we are on a native utf8
|
||||||
|
terminal. */
|
||||||
|
for (; *s && *s != '|'; s++ )
|
||||||
|
#ifdef JNLIB_NEED_UTF8CONV
|
||||||
|
if ( is_utf8 && (*s&0xc0) != 0x80 )
|
||||||
|
#endif
|
||||||
|
n++;
|
||||||
}
|
}
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************
|
/****************
|
||||||
@ -954,17 +968,20 @@ main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
ARGPARSE_OPTS opts[] = {
|
ARGPARSE_OPTS opts[] = {
|
||||||
{ 'v', "verbose", 0 , "Laut sein"},
|
{ 'v', "verbose", 0 , "Laut sein"},
|
||||||
{ 'e', "echo" , 0 , "Zeile ausgeben, damit wir sehen, was wir einegegeben haben"},
|
{ 'e', "echo" , 0 , ("Zeile ausgeben, damit wir sehen, was wir ein"
|
||||||
{ 'd', "debug", 0 , "Debug\nfalls mal etasws\nSchief geht"},
|
" gegeben haben")},
|
||||||
|
{ 'd', "debug", 0 , "Debug\nfalls mal etwas\nschief geht"},
|
||||||
{ 'o', "output", 2 },
|
{ 'o', "output", 2 },
|
||||||
{ 'c', "cross-ref", 2|8, "cross-reference erzeugen\n" },
|
{ 'c', "cross-ref", 2|8, "cross-reference erzeugen\n" },
|
||||||
|
/* Note that on a non-utf8 terminal the ß might garble the output. */
|
||||||
|
{ 's', "street", 0, "|Straße|set the name of the street to Straße" },
|
||||||
{ 'm', "my-option", 1|8 },
|
{ 'm', "my-option", 1|8 },
|
||||||
{ 500, "a-long-option", 0 },
|
{ 500, "a-long-option", 0 },
|
||||||
{0} };
|
{0} };
|
||||||
ARGPARSE_ARGS pargs = { &argc, &argv, 2|4|32 };
|
ARGPARSE_ARGS pargs = { &argc, &argv, 2|4|32 };
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
while( ArgParse( &pargs, opts) ) {
|
while( arg_parse ( &pargs, opts) ) {
|
||||||
switch( pargs.r_opt ) {
|
switch( pargs.r_opt ) {
|
||||||
case -1 : printf( "arg=`%s'\n", pargs.r.ret_str); break;
|
case -1 : printf( "arg=`%s'\n", pargs.r.ret_str); break;
|
||||||
case 'v': opt.verbose++; break;
|
case 'v': opt.verbose++; break;
|
||||||
|
@ -256,6 +256,13 @@ get_native_charset ()
|
|||||||
return active_charset_name;
|
return active_charset_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Return true if the native charset is utf-8. */
|
||||||
|
int
|
||||||
|
is_native_utf8 (void)
|
||||||
|
{
|
||||||
|
return no_translation;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Convert string, which is in native encoding to UTF8 and return a
|
/* Convert string, which is in native encoding to UTF8 and return a
|
||||||
new allocated UTF-8 string. */
|
new allocated UTF-8 string. */
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
int set_native_charset (const char *newset);
|
int set_native_charset (const char *newset);
|
||||||
const char *get_native_charset (void);
|
const char *get_native_charset (void);
|
||||||
|
int is_native_utf8 (void);
|
||||||
|
|
||||||
char *native_to_utf8 (const char *string);
|
char *native_to_utf8 (const char *string);
|
||||||
char *utf8_to_native (const char *string, size_t length, int delim);
|
char *utf8_to_native (const char *string, size_t length, int delim);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user