X-Git-Url: https://git.deb.at/w?a=blobdiff_plain;f=intl%2Fl10nflist.c;h=5124d73fd0637a5af81190f94ff5d048cc83adda;hb=69a912c0db0ac135fff332db4f0b05ad9ed2eec6;hp=7252d54e76f226724c5aeba2b600a7b419b501a0;hpb=ee5170ade20748797fdde09e370fbb07e585fc9a;p=pkg%2Fabook.git diff --git a/intl/l10nflist.c b/intl/l10nflist.c index 7252d54..5124d73 100644 --- a/intl/l10nflist.c +++ b/intl/l10nflist.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995-1999, 2000-2007 Free Software Foundation, Inc. +/* Copyright (C) 1995-1999, 2000-2004 Free Software Foundation, Inc. Contributed by Ulrich Drepper , 1995. This program is free software; you can redistribute it and/or modify it @@ -13,7 +13,7 @@ You should have received a copy of the GNU Library General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* Tell glibc's to provide a prototype for stpcpy(). @@ -82,12 +82,7 @@ static char *stpcpy (char *dest, const char *src); /* Define function which are usually not available. */ -#ifdef _LIBC -# define __argz_count(argz, len) INTUSE(__argz_count) (argz, len) -#elif defined HAVE_ARGZ_COUNT -# undef __argz_count -# define __argz_count argz_count -#else +#if !defined _LIBC && !defined HAVE___ARGZ_COUNT /* Returns the number of strings in ARGZ. */ static size_t argz_count__ (const char *argz, size_t len) @@ -104,15 +99,13 @@ argz_count__ (const char *argz, size_t len) } # undef __argz_count # define __argz_count(argz, len) argz_count__ (argz, len) -#endif /* !_LIBC && !HAVE_ARGZ_COUNT */ - -#ifdef _LIBC -# define __argz_stringify(argz, len, sep) \ - INTUSE(__argz_stringify) (argz, len, sep) -#elif defined HAVE_ARGZ_STRINGIFY -# undef __argz_stringify -# define __argz_stringify argz_stringify #else +# ifdef _LIBC +# define __argz_count(argz, len) INTUSE(__argz_count) (argz, len) +# endif +#endif /* !_LIBC && !HAVE___ARGZ_COUNT */ + +#if !defined _LIBC && !defined HAVE___ARGZ_STRINGIFY /* Make '\0' separated arg vector ARGZ printable by converting all the '\0's except the last into the character SEP. */ static void @@ -129,13 +122,14 @@ argz_stringify__ (char *argz, size_t len, int sep) } # undef __argz_stringify # define __argz_stringify(argz, len, sep) argz_stringify__ (argz, len, sep) -#endif /* !_LIBC && !HAVE_ARGZ_STRINGIFY */ - -#ifdef _LIBC -#elif defined HAVE_ARGZ_NEXT -# undef __argz_next -# define __argz_next argz_next #else +# ifdef _LIBC +# define __argz_stringify(argz, len, sep) \ + INTUSE(__argz_stringify) (argz, len, sep) +# endif +#endif /* !_LIBC && !HAVE___ARGZ_STRINGIFY */ + +#if !defined _LIBC && !defined HAVE___ARGZ_NEXT static char * argz_next__ (char *argz, size_t argz_len, const char *entry) { @@ -154,7 +148,7 @@ argz_next__ (char *argz, size_t argz_len, const char *entry) } # undef __argz_next # define __argz_next(argz, len, entry) argz_next__ (argz, len, entry) -#endif /* !_LIBC && !HAVE_ARGZ_NEXT */ +#endif /* !_LIBC && !HAVE___ARGZ_NEXT */ /* Return number of bits set in X. */ @@ -176,7 +170,8 @@ _nl_make_l10nflist (struct loaded_l10nfile **l10nfile_list, const char *dirlist, size_t dirlist_len, int mask, const char *language, const char *territory, const char *codeset, const char *normalized_codeset, - const char *modifier, + const char *modifier, const char *special, + const char *sponsor, const char *revision, const char *filename, int do_allocate) { char *abs_filename; @@ -195,14 +190,23 @@ _nl_make_l10nflist (struct loaded_l10nfile **l10nfile_list, /* Allocate room for the full file name. */ abs_filename = (char *) malloc (dirlist_len + strlen (language) - + ((mask & XPG_TERRITORY) != 0 + + ((mask & TERRITORY) != 0 ? strlen (territory) + 1 : 0) + ((mask & XPG_CODESET) != 0 ? strlen (codeset) + 1 : 0) + ((mask & XPG_NORM_CODESET) != 0 ? strlen (normalized_codeset) + 1 : 0) - + ((mask & XPG_MODIFIER) != 0 + + (((mask & XPG_MODIFIER) != 0 + || (mask & CEN_AUDIENCE) != 0) ? strlen (modifier) + 1 : 0) + + ((mask & CEN_SPECIAL) != 0 + ? strlen (special) + 1 : 0) + + (((mask & CEN_SPONSOR) != 0 + || (mask & CEN_REVISION) != 0) + ? (1 + ((mask & CEN_SPONSOR) != 0 + ? strlen (sponsor) : 0) + + ((mask & CEN_REVISION) != 0 + ? strlen (revision) + 1 : 0)) : 0) + 1 + strlen (filename) + 1); if (abs_filename == NULL) @@ -220,7 +224,7 @@ _nl_make_l10nflist (struct loaded_l10nfile **l10nfile_list, cp = stpcpy (cp, language); - if ((mask & XPG_TERRITORY) != 0) + if ((mask & TERRITORY) != 0) { *cp++ = '_'; cp = stpcpy (cp, territory); @@ -235,11 +239,29 @@ _nl_make_l10nflist (struct loaded_l10nfile **l10nfile_list, *cp++ = '.'; cp = stpcpy (cp, normalized_codeset); } - if ((mask & XPG_MODIFIER) != 0) + if ((mask & (XPG_MODIFIER | CEN_AUDIENCE)) != 0) { - *cp++ = '@'; + /* This component can be part of both syntaces but has different + leading characters. For CEN we use `+', else `@'. */ + *cp++ = (mask & CEN_AUDIENCE) != 0 ? '+' : '@'; cp = stpcpy (cp, modifier); } + if ((mask & CEN_SPECIAL) != 0) + { + *cp++ = '+'; + cp = stpcpy (cp, special); + } + if ((mask & (CEN_SPONSOR | CEN_REVISION)) != 0) + { + *cp++ = ','; + if ((mask & CEN_SPONSOR) != 0) + cp = stpcpy (cp, sponsor); + if ((mask & CEN_REVISION) != 0) + { + *cp++ = '_'; + cp = stpcpy (cp, revision); + } + } *cp++ = '/'; stpcpy (cp, filename); @@ -279,10 +301,7 @@ _nl_make_l10nflist (struct loaded_l10nfile **l10nfile_list, + (((dirlist_count << pop (mask)) + (dirlist_count > 1 ? 1 : 0)) * sizeof (struct loaded_l10nfile *))); if (retval == NULL) - { - free (abs_filename); - return NULL; - } + return NULL; retval->filename = abs_filename; @@ -313,7 +332,8 @@ _nl_make_l10nflist (struct loaded_l10nfile **l10nfile_list, normalized_codeset. */ for (cnt = dirlist_count > 1 ? mask : mask - 1; cnt >= 0; --cnt) if ((cnt & ~mask) == 0 - && !((cnt & XPG_CODESET) != 0 && (cnt & XPG_NORM_CODESET) != 0)) + && ((cnt & CEN_SPECIFIC) == 0 || (cnt & XPG_SPECIFIC) == 0) + && ((cnt & XPG_CODESET) == 0 || (cnt & XPG_NORM_CODESET) == 0)) { if (dirlist_count > 1) { @@ -325,14 +345,15 @@ _nl_make_l10nflist (struct loaded_l10nfile **l10nfile_list, retval->successor[entries++] = _nl_make_l10nflist (l10nfile_list, dir, strlen (dir) + 1, cnt, language, territory, codeset, - normalized_codeset, modifier, filename, - 1); + normalized_codeset, modifier, special, + sponsor, revision, filename, 1); } else retval->successor[entries++] = _nl_make_l10nflist (l10nfile_list, dirlist, dirlist_len, cnt, language, territory, codeset, - normalized_codeset, modifier, filename, 1); + normalized_codeset, modifier, special, + sponsor, revision, filename, 1); } retval->successor[entries] = NULL; @@ -346,7 +367,7 @@ _nl_make_l10nflist (struct loaded_l10nfile **l10nfile_list, const char * _nl_normalize_codeset (const char *codeset, size_t name_len) { - size_t len = 0; + int len = 0; int only_digit = 1; char *retval; char *wp;