Remove non-working __part_load_locale function and any related code

Add TODO markers in case somebody wants to pick this up again

Signed-off by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen 2016-07-23 14:19:25 +02:00
parent c402f0388f
commit cf2cd696da
11 changed files with 9 additions and 459 deletions

View File

@ -4,15 +4,13 @@ AUTOMAKE_OPTIONS = cygnus
INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
GENERAL_SOURCES = timelocal.h ldpart.h locale.c lnumeric.h lmonetary.h lmessages.h
GENERAL_SOURCES = setlocale.h
## The following interfaces are EL/IX level 2
if ELIX_LEVEL_1
ELIX_SOURCES =
else
ELIX_SOURCES = \
fix_grouping.c \
ldpart.c \
lmessages.c \
lnumeric.c \
lmonetary.c \

View File

@ -73,9 +73,7 @@ ARFLAGS = cru
lib_a_AR = $(AR) $(ARFLAGS)
lib_a_LIBADD =
am__objects_1 = lib_a-locale.$(OBJEXT)
@ELIX_LEVEL_1_FALSE@am__objects_2 = lib_a-fix_grouping.$(OBJEXT) \
@ELIX_LEVEL_1_FALSE@ lib_a-ldpart.$(OBJEXT) \
@ELIX_LEVEL_1_FALSE@ lib_a-lmessages.$(OBJEXT) \
@ELIX_LEVEL_1_FALSE@am__objects_2 = lib_a-lmessages.$(OBJEXT) \
@ELIX_LEVEL_1_FALSE@ lib_a-lnumeric.$(OBJEXT) \
@ELIX_LEVEL_1_FALSE@ lib_a-lmonetary.$(OBJEXT) \
@ELIX_LEVEL_1_FALSE@ lib_a-nl_langinfo.$(OBJEXT) \
@ -87,8 +85,7 @@ lib_a_OBJECTS = $(am_lib_a_OBJECTS)
LTLIBRARIES = $(noinst_LTLIBRARIES)
liblocale_la_LIBADD =
am__objects_3 = locale.lo
@ELIX_LEVEL_1_FALSE@am__objects_4 = fix_grouping.lo ldpart.lo \
@ELIX_LEVEL_1_FALSE@ lmessages.lo lnumeric.lo lmonetary.lo \
@ELIX_LEVEL_1_FALSE@am__objects_4 = lmessages.lo lnumeric.lo lmonetary.lo \
@ELIX_LEVEL_1_FALSE@ nl_langinfo.lo timelocal.lo lctype.lo
@USE_LIBTOOL_TRUE@am_liblocale_la_OBJECTS = $(am__objects_3) \
@USE_LIBTOOL_TRUE@ $(am__objects_4)
@ -264,10 +261,8 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
AUTOMAKE_OPTIONS = cygnus
INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
GENERAL_SOURCES = timelocal.h ldpart.h locale.c lnumeric.h lmonetary.h lmessages.h
GENERAL_SOURCES = setlocale.h
@ELIX_LEVEL_1_FALSE@ELIX_SOURCES = \
@ELIX_LEVEL_1_FALSE@ fix_grouping.c \
@ELIX_LEVEL_1_FALSE@ ldpart.c \
@ELIX_LEVEL_1_FALSE@ lmessages.c \
@ELIX_LEVEL_1_FALSE@ lnumeric.c \
@ELIX_LEVEL_1_FALSE@ lmonetary.c \
@ -371,18 +366,6 @@ lib_a-locale.o: locale.c
lib_a-locale.obj: locale.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-locale.obj `if test -f 'locale.c'; then $(CYGPATH_W) 'locale.c'; else $(CYGPATH_W) '$(srcdir)/locale.c'; fi`
lib_a-fix_grouping.o: fix_grouping.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fix_grouping.o `test -f 'fix_grouping.c' || echo '$(srcdir)/'`fix_grouping.c
lib_a-fix_grouping.obj: fix_grouping.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fix_grouping.obj `if test -f 'fix_grouping.c'; then $(CYGPATH_W) 'fix_grouping.c'; else $(CYGPATH_W) '$(srcdir)/fix_grouping.c'; fi`
lib_a-ldpart.o: ldpart.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-ldpart.o `test -f 'ldpart.c' || echo '$(srcdir)/'`ldpart.c
lib_a-ldpart.obj: ldpart.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-ldpart.obj `if test -f 'ldpart.c'; then $(CYGPATH_W) 'ldpart.c'; else $(CYGPATH_W) '$(srcdir)/ldpart.c'; fi`
lib_a-lmessages.o: lmessages.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-lmessages.o `test -f 'lmessages.c' || echo '$(srcdir)/'`lmessages.c

View File

@ -1,82 +0,0 @@
/*
* Copyright (c) 2001 Alexey Zelkin <phantom@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <ctype.h>
#include <limits.h>
#include <stddef.h>
static const char nogrouping[] = { CHAR_MAX, '\0' };
/*
* "3;3;-1" -> "\003\003\177"
*/
const char *
__fix_locale_grouping_str(const char *str) {
char *src, *dst;
char n;
if (str == NULL || *str == '\0') {
return nogrouping;
}
for (src = (char*)str, dst = (char*)str; *src != '\0'; src++) {
/* input string examples: "3;3", "3;2;-1" */
if (*src == ';')
continue;
if (*src == '-' && *(src+1) == '1') {
*dst++ = CHAR_MAX;
src++;
continue;
}
if (!isdigit((unsigned char)*src)) {
/* broken grouping string */
return nogrouping;
}
/* assume all numbers <= 99 */
n = *src - '0';
if (isdigit((unsigned char)*(src+1))) {
src++;
n *= 10;
n += *src - '0';
}
*dst = n;
/* NOTE: assume all input started with "0" as 'no grouping' */
if (*dst == '\0')
return (dst == (char*)str) ? nogrouping : str;
dst++;
}
*dst = '\0';
return str;
}

View File

@ -21,7 +21,6 @@
* SUCH DAMAGE.
*/
#include "ldpart.h"
#include "setlocale.h"
#define LCCTYPE_SIZE (sizeof(struct lc_ctype_T) / sizeof(char *))
@ -40,16 +39,6 @@ const struct lc_ctype_T _C_ctype_locale = {
#endif
};
static struct lc_ctype_T _ctype_locale;
static int _ctype_using_locale;
#ifdef __HAVE_LOCALE_INFO_EXTENDED__
static char *_ctype_locale_buf;
#else
/* Max encoding_len + NUL byte + 1 byte mb_cur_max plus trailing NUL byte */
#define _CTYPE_BUF_SIZE (ENCODING_LEN + 3)
static char _ctype_locale_buf[_CTYPE_BUF_SIZE];
#endif
/* NULL locale indicates global locale (called from setlocale) */
int
__ctype_load_locale (struct __locale_t *locale, const char *name,
@ -91,39 +80,8 @@ __ctype_load_locale (struct __locale_t *locale, const char *name,
}
ret = 0;
}
#elif !defined (__HAVE_LOCALE_INFO_EXTENDED__)
ret = 0;
if (!strcmp (name, "C"))
locale->lc_cat[LC_CTYPE].ptr = NULL;
else
{
if (locale == __get_global_locale ())
bufp = _ctype_locale_buf;
else
bufp = (char *) malloc (_CTYPE_BUF_SIZE);
if (*bufp)
{
_ctype_locale.codeset = strcpy (bufp, charset);
char *mbc = bufp + _CTYPE_BUF_SIZE - 2;
mbc[0] = mb_cur_max;
mbc[1] = '\0';
_ctype_locale.mb_cur_max = mbc;
if (locale->lc_cat[LC_CTYPE].buf
&& locale->lc_cat[LC_CTYPE].buf != _ctype_locale_buf)
free (locale->lc_cat[LC_CTYPE].buf);
locale->lc_cat[LC_CTYPE].buf = bufp;
}
else
ret = -1;
}
#else
ret = __part_load_locale(name, &_ctype_using_locale,
_ctype_locale_buf, "LC_CTYPE",
LCCTYPE_SIZE, LCCTYPE_SIZE,
(const char **)&_ctype_locale);
if (ret == 0 && _ctype_using_locale)
_ctype_locale.grouping =
__fix_locale_grouping_str(_ctype_locale.grouping);
/* TODO */
#endif
return ret;
}

View File

@ -1,194 +0,0 @@
/*
* Copyright (c) 2000, 2001 Alexey Zelkin <phantom@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/syslimits.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "setlocale.h"
#include "ldpart.h"
static int split_lines(char *, const char *);
static void set_from_buf(const char *, int, const char **);
int
__part_load_locale(const char *name,
int *using_locale,
char *locale_buf,
const char *category_filename,
int locale_buf_size_max,
int locale_buf_size_min,
const char **dst_localebuf) {
static char locale_buf_C[] = "C";
static int num_lines;
int fd;
char *lbuf;
char *p;
const char *plim;
char filename[PATH_MAX];
#ifdef __USE_INTERNAL_STAT64
struct stat64 st;
#else
struct stat st;
#endif
size_t namesize;
size_t bufsize;
int save_using_locale;
char *nptr;
save_using_locale = *using_locale;
*using_locale = 0;
if (name == NULL)
goto no_locale;
if (!strcmp(name, "C") || !strcmp(name, "POSIX"))
return 0;
/*
* If the locale name is the same as our cache, use the cache.
*/
lbuf = locale_buf;
if (lbuf != NULL && strcmp(name, lbuf) == 0) {
set_from_buf(lbuf, num_lines, dst_localebuf);
*using_locale = 1;
return 0;
}
/*
* Slurp the locale file into the cache.
*/
namesize = strlen(name) + 1;
if (!_PathLocale)
goto no_locale;
/* Range checking not needed, 'name' size is limited */
strcpy(filename, _PathLocale);
strcat(filename, "/");
strcat(filename, name);
strcat(filename, "/");
strcat(filename, category_filename);
fd = open(filename, O_RDONLY);
if (fd < 0)
goto no_locale;
#ifdef __USE_INTERNAL_STAT64
if (fstat64(fd, &st) != 0)
#else
if (fstat(fd, &st) != 0)
#endif
goto bad_locale;
if (st.st_size <= 0)
goto bad_locale;
bufsize = namesize + st.st_size + 1;
locale_buf = NULL;
if (lbuf == NULL || lbuf == locale_buf_C)
{
lbuf = malloc(bufsize);
}
else
{
nptr = realloc(lbuf, bufsize);
if (!nptr && lbuf)
free (lbuf);
lbuf = nptr;
}
if (lbuf == NULL)
goto bad_locale;
(void) strcpy(lbuf, name);
p = lbuf + namesize;
plim = p + st.st_size;
if (read(fd, p, (size_t) st.st_size) != st.st_size)
goto bad_lbuf;
if (close(fd) != 0)
goto bad_lbuf;
/*
* Parse the locale file into localebuf.
*/
p[st.st_size] = '\0';
if (plim[-1] != '\n')
goto bad_lbuf;
num_lines = split_lines(p, plim);
if (num_lines >= locale_buf_size_max)
num_lines = locale_buf_size_max;
else if (num_lines >= locale_buf_size_min)
num_lines = locale_buf_size_min;
else
goto reset_locale;
set_from_buf(lbuf, num_lines, dst_localebuf);
/*
* Record the successful parse in the cache.
*/
locale_buf = lbuf;
*using_locale = 1;
return 0;
reset_locale:
locale_buf = locale_buf_C;
save_using_locale = 0;
bad_lbuf:
free(lbuf);
bad_locale:
(void)close(fd);
no_locale:
*using_locale = save_using_locale;
return -1;
}
static int
split_lines(char *p, const char *plim) {
int i;
for (i = 0; p < plim; i++) {
p = strchr(p, '\n');
if (!p)
break;
*p++ = '\0';
}
return i;
}
static void
set_from_buf(const char *p, int num_lines, const char **dst_localebuf) {
const char **ap;
int i;
for (ap = dst_localebuf, i = 0; i < num_lines; ++ap, ++i)
*ap = p += strlen(p) + 1;
}

View File

@ -1,35 +0,0 @@
/*-
* Copyright (c) 2000, 2001 Alexey Zelkin <phantom@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD: src/lib/libc/locale/ldpart.h,v 1.4 2001/12/20 18:28:52 phantom Exp $
*/
#ifndef _LDPART_H_
#define _LDPART_H_
int __part_load_locale(const char *, int*, char *, const char *,
int, int, const char **);
#endif /* !_LDPART_H_ */

View File

@ -27,9 +27,7 @@
#include <sys/cdefs.h>
#include <stddef.h>
#include "setlocale.h"
#include "ldpart.h"
#define LCMESSAGES_SIZE_FULL (sizeof(struct lc_messages_T) / sizeof(char *))
#define LCMESSAGES_SIZE_MIN \
@ -102,33 +100,7 @@ __messages_load_locale (struct __locale_t *locale, const char *name,
ret = 0;
}
#else
/*
* Propose that we can have incomplete locale file (w/o "{yes,no}str").
* Initialize them before loading. In case of complete locale, they'll
* be initialized to loaded value, otherwise they'll not be touched.
*/
_messages_locale.yesstr = empty;
_messages_locale.nostr = empty;
ret = __part_load_locale(name, &_messages_using_locale,
_messages_locale_buf, "LC_MESSAGES",
LCMESSAGES_SIZE_FULL, LCMESSAGES_SIZE_MIN,
(const char **)&_messages_locale);
/* TODO */
#endif
return ret;
}
#ifdef LOCALE_DEBUG
void
msgdebug() {
printf( "yesexpr = %s\n"
"noexpr = %s\n"
"yesstr = %s\n"
"nostr = %s\n",
_messages_locale.yesexpr,
_messages_locale.noexpr,
_messages_locale.yesstr,
_messages_locale.nostr
);
}
#endif /* LOCALE_DEBUG */

View File

@ -29,9 +29,6 @@
#include <limits.h>
#include <stdlib.h>
#include "setlocale.h"
#include "ldpart.h"
extern const char * __fix_locale_grouping_str(const char *);
#define LCMONETARY_SIZE (sizeof(struct lc_monetary_T) / sizeof(char *))
@ -130,26 +127,7 @@ __monetary_load_locale (struct __locale_t *locale, const char *name ,
ret = 0;
}
#else
ret = __part_load_locale(name, &_monetary_using_locale,
_monetary_locale_buf, "LC_MONETARY",
LCMONETARY_SIZE, LCMONETARY_SIZE,
(const char **)&_monetary_locale);
if (ret == 0 && _monetary_using_locale) {
_monetary_locale.mon_grouping =
__fix_locale_grouping_str(_monetary_locale.mon_grouping);
#define M_ASSIGN_CHAR(NAME) (((char *)_monetary_locale.NAME)[0] = \
cnv(_monetary_locale.NAME))
M_ASSIGN_CHAR(int_frac_digits);
M_ASSIGN_CHAR(frac_digits);
M_ASSIGN_CHAR(p_cs_precedes);
M_ASSIGN_CHAR(p_sep_by_space);
M_ASSIGN_CHAR(n_cs_precedes);
M_ASSIGN_CHAR(n_sep_by_space);
M_ASSIGN_CHAR(p_sign_posn);
M_ASSIGN_CHAR(n_sign_posn);
}
/* TODO */
#endif
return ret;
}

View File

@ -25,9 +25,6 @@
*/
#include "setlocale.h"
#include "ldpart.h"
extern const char *__fix_locale_grouping_str(const char *);
#define LCNUMERIC_SIZE (sizeof(struct lc_numeric_T) / sizeof(char *))
@ -44,12 +41,6 @@ const struct lc_numeric_T _C_numeric_locale = {
#endif
};
#ifndef __CYGWIN__
static struct lc_numeric_T _numeric_locale;
static int _numeric_using_locale;
static char *_numeric_locale_buf;
#endif
int
__numeric_load_locale (struct __locale_t *locale, const char *name ,
void *f_wctomb, const char *charset)
@ -92,13 +83,7 @@ __numeric_load_locale (struct __locale_t *locale, const char *name ,
ret = 0;
}
#else
ret = __part_load_locale(name, &_numeric_using_locale,
_numeric_locale_buf, "LC_NUMERIC",
LCNUMERIC_SIZE, LCNUMERIC_SIZE,
(const char **)&_numeric_locale);
if (ret == 0 && _numeric_using_locale)
_numeric_locale.grouping =
__fix_locale_grouping_str(_numeric_locale.grouping);
/* TODO */
#endif
return ret;
}

View File

@ -302,8 +302,6 @@ extern void __set_charset_from_locale (const char *locale, char *charset);
extern char *__set_locale_from_locale_alias (const char *, char *);
#endif
extern char *_PathLocale;
__END_DECLS
#endif /* !_SETLOCALE_H_ */

View File

@ -28,8 +28,6 @@
#include <sys/cdefs.h>
#include <stddef.h>
#include "ldpart.h"
#include "setlocale.h"
#define LCTIME_SIZE (sizeof(struct lc_time_T) / sizeof(char *))
@ -145,12 +143,6 @@ const struct lc_time_T _C_time_locale = {
#endif
};
#ifndef __CYGWIN__
static struct lc_time_T _time_locale;
static int _time_using_locale;
static char *time_locale_buf;
#endif
int
__time_load_locale (struct __locale_t *locale, const char *name,
void *f_wctomb, const char *charset)
@ -192,10 +184,7 @@ __time_load_locale (struct __locale_t *locale, const char *name,
ret = 0;
}
#else
ret = __part_load_locale(name, &_time_using_locale,
time_locale_buf, "LC_TIME",
LCTIME_SIZE, LCTIME_SIZE,
(const char **)&_time_locale);
/* TODO */
#endif
return (ret);
}