summaryrefslogtreecommitdiffstats
path: root/libc/misc
diff options
context:
space:
mode:
Diffstat (limited to 'libc/misc')
-rw-r--r--libc/misc/fnmatch/fnmatch_old.c2
-rw-r--r--libc/misc/ftw/ftw.c6
-rw-r--r--libc/misc/locale/locale.c66
-rw-r--r--libc/misc/regex/regex_old.c57
-rw-r--r--libc/misc/wchar/wchar.c20
-rw-r--r--libc/misc/wctype/_wctype.c45
6 files changed, 73 insertions, 123 deletions
diff --git a/libc/misc/fnmatch/fnmatch_old.c b/libc/misc/fnmatch/fnmatch_old.c
index 839c77579..69a8ede50 100644
--- a/libc/misc/fnmatch/fnmatch_old.c
+++ b/libc/misc/fnmatch/fnmatch_old.c
@@ -15,7 +15,7 @@ License along with this library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
-#if HAVE_CONFIG_H
+#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
diff --git a/libc/misc/ftw/ftw.c b/libc/misc/ftw/ftw.c
index afc55f88a..9325ab745 100644
--- a/libc/misc/ftw/ftw.c
+++ b/libc/misc/ftw/ftw.c
@@ -105,11 +105,11 @@ char *alloca ();
/* libc_hidden_proto(lstat) */
/* libc_hidden_proto(stat) */
-#if ! _LIBC && !HAVE_DECL_STPCPY && !defined stpcpy
+#if !defined _LIBC && !HAVE_DECL_STPCPY && !defined stpcpy
char *stpcpy ();
#endif
-#if ! _LIBC && ! defined HAVE_MEMPCPY && ! defined mempcpy
+#if !defined _LIBC && ! defined HAVE_MEMPCPY && ! defined mempcpy
/* Be CAREFUL that there are no side effects in N. */
# define mempcpy(D, S, N) ((void *) ((char *) memcpy (D, S, N) + (N)))
#endif
@@ -162,7 +162,7 @@ extern char *xgetcwd (void);
/* Arrange to make lstat calls go through the wrapper function
on systems with an lstat function that does not dereference symlinks
that are specified with a trailing slash. */
-#if ! _LIBC && ! LSTAT_FOLLOWS_SLASHED_SYMLINK && !defined __UCLIBC__
+#if !defined _LIBC && !defined LSTAT_FOLLOWS_SLASHED_SYMLINK && !defined __UCLIBC__
int rpl_lstat (const char *, struct stat *);
# undef lstat
# define lstat(Name, Stat_buf) rpl_lstat(Name, Stat_buf)
diff --git a/libc/misc/locale/locale.c b/libc/misc/locale/locale.c
index 71bd77951..a2a898fdd 100644
--- a/libc/misc/locale/locale.c
+++ b/libc/misc/locale/locale.c
@@ -230,7 +230,8 @@ static void update_hr_locale(const unsigned char *spec)
+ __LOCALE_DATA_WIDTH_LOCALES * ((((int)(*s & 0x7f)) << 7)
+ (s[1] & 0x7f));
if (category == LC_ALL) {
- n = stpcpy(n, CATEGORY_NAMES + (int) CATEGORY_NAMES[i]);
+ /* CATEGORY_NAMES is unsigned char* */
+ n = stpcpy(n, (char*) CATEGORY_NAMES + (int) CATEGORY_NAMES[i]);
*n++ = '=';
}
if (*loc == 0) {
@@ -248,12 +249,12 @@ static void update_hr_locale(const unsigned char *spec)
if (loc[2] == 2) {
n = stpcpy(n, utf8);
} else if (loc[2] >= 3) {
- n = stpcpy(n, CODESET_LIST + (int)(CODESET_LIST[loc[2] - 3]));
+ n = stpcpy(n, (char*) CODESET_LIST + (int)(CODESET_LIST[loc[2] - 3]));
}
if (at) {
const char *q;
*n++ = '@';
- q = LOCALE_AT_MODIFIERS;
+ q = (char*) LOCALE_AT_MODIFIERS;
do {
if (q[1] == at) {
n = stpcpy(n, q+2);
@@ -644,8 +645,8 @@ int attribute_hidden _locale_set_l(const unsigned char *p, __locale_t base)
io = (const uint16_t *)( ((char *)__locale_mmap) + *++stp );
ii = (const uint16_t *)( ((char *)__locale_mmap) + *++stp );
d = (const unsigned char *)( ((char *)__locale_mmap) + *++stp );
- for (c=0 ; c < len ; c++) {
- *(x + c) = d + ii[ r[crow + c] + io[c] ];
+ for (c = 0; c < len; c++) {
+ x[c] = (char*)(d + ii[r[crow + c] + io[c]]);
}
}
if (i == LC_CTYPE) {
@@ -658,7 +659,7 @@ int attribute_hidden _locale_set_l(const unsigned char *p, __locale_t base)
/* TODO - fix for bcc */
base->mb_cur_max = 6;
} else {
- assert(c==1);
+ assert(c == 1);
base->codeset = ascii;
base->encoding = __ctype_encoding_7_bit;
base->mb_cur_max = 1;
@@ -666,7 +667,8 @@ int attribute_hidden _locale_set_l(const unsigned char *p, __locale_t base)
} else {
const __codeset_8_bit_t *c8b;
r = CODESET_LIST;
- base->codeset = r + r[c -= 3];
+ c -= 3;
+ base->codeset = (char *) (r + r[c]);
base->encoding = __ctype_encoding_8_bit;
#ifdef __UCLIBC_MJN3_ONLY__
#warning REMINDER: update 8 bit mb_cur_max when translit implemented!
@@ -905,7 +907,7 @@ void attribute_hidden _locale_init_l(__locale_t base)
base->tblwuplow
= (const unsigned char *) &__locale_mmap->tblwuplow;
base->tblwuplow_diff
- = (const uint16_t *) &__locale_mmap->tblwuplow_diff;
+ = (const int16_t *) &__locale_mmap->tblwuplow_diff;
/* base->tblwcomb */
/* = (const unsigned char *) &__locale_mmap->tblwcomb; */
/* width?? */
@@ -928,8 +930,7 @@ void attribute_hidden _locale_init_l(__locale_t base)
#endif
base->code2flag = __code2flag;
-
- _locale_set_l(C_LOCALE_SELECTOR, base);
+ _locale_set_l((unsigned char*) C_LOCALE_SELECTOR, base);
}
void _locale_init(void) attribute_hidden;
@@ -1117,7 +1118,7 @@ static int find_locale(int category_mask, const char *p,
/* locale name at least 5 chars long and 3rd char is '_' */
s = LOCALE_AT_MODIFIERS;
do {
- if (!strcmp(s+2, q+1)) {
+ if (!strcmp((char*) (s + 2), q + 1)) {
break;
}
s += 2 + *s; /* TODO - fix this throughout */
@@ -1142,11 +1143,11 @@ static int find_locale(int category_mask, const char *p,
/* TODO: maybe CODESET_LIST + *s ??? */
/* 7bit is 1, UTF-8 is 2, 8-bit is >= 3 */
codeset = 2;
- if (strcasecmp(utf8,p+6) != 0) {/* TODO - fix! */
+ if (strcasecmp(utf8, p + 6) != 0) {/* TODO - fix! */
s = CODESET_LIST;
do {
++codeset; /* Increment codeset first. */
- if (!strcmp(CODESET_LIST+*s, p+6)) {
+ if (!strcmp((char*) CODESET_LIST + *s, p + 6)) {
goto FIND_LANG_CULT;
}
} while (*++s);
@@ -1159,7 +1160,7 @@ static int find_locale(int category_mask, const char *p,
do { /* TODO -- do a binary search? */
/* TODO -- fix gen_mmap!*/
++lang_cult; /* Increment first since C/POSIX is 0. */
- if (!strncmp(s,p,5)) { /* Found a matching locale name; */
+ if (!strncmp((char*) s, p, 5)) { /* Found a matching locale name; */
goto FIND_LOCALE;
}
s += 5;
@@ -1217,7 +1218,8 @@ static unsigned char *composite_locale(int category_mask, const char *locale,
t = strtok_r(buf, "=", &e); /* This can't fail because of strchr test above. */
do {
c = 0;
- while (strcmp(CATEGORY_NAMES + (int) CATEGORY_NAMES[c], t)) {
+ /* CATEGORY_NAMES is unsigned char* */
+ while (strcmp((char*) CATEGORY_NAMES + (int) CATEGORY_NAMES[c], t)) {
if (++c == LC_ALL) { /* Unknown category name! */
return NULL;
}
@@ -1242,7 +1244,7 @@ static unsigned char *composite_locale(int category_mask, const char *locale,
__locale_t newlocale(int category_mask, const char *locale, __locale_t base)
{
- const unsigned char *p;
+ const char *p;
int i, j, k;
unsigned char new_selector[LOCALE_SELECTOR_SIZE];
@@ -1250,8 +1252,8 @@ __locale_t newlocale(int category_mask, const char *locale, __locale_t base)
category_mask = LC_ALL_MASK;
}
- if (!locale || (((unsigned int)(category_mask)) > LC_ALL_MASK)) {
- INVALID:
+ if (!locale || ((unsigned)(category_mask) > LC_ALL_MASK)) {
+ INVALID:
__set_errno(EINVAL);
return NULL; /* No locale or illegal/unsupported category. */
}
@@ -1262,11 +1264,13 @@ __locale_t newlocale(int category_mask, const char *locale, __locale_t base)
strcpy((char *) new_selector,
(base ? (char *) base->cur_locale : C_LOCALE_SELECTOR));
- if (!*locale) { /* locale == "", so check environment. */
-#ifndef __UCLIBC_HAS_THREADS__
- static /* If no threads, then envstr can be static. */
-#endif /* __UCLIBC_HAS_THREADS__ */
- const char *envstr[4] = { "LC_ALL", NULL, "LANG", posix };
+ if (!locale[0]) { /* locale == "", so check environment. */
+ const char *envstr[4];
+
+ envstr[0] = "LC_ALL";
+ envstr[1] = NULL;
+ envstr[2] = "LANG";
+ envstr[3] = posix;
i = 1;
k = 0;
@@ -1275,12 +1279,16 @@ __locale_t newlocale(int category_mask, const char *locale, __locale_t base)
/* Note: SUSv3 doesn't define a fallback mechanism here.
* So, if LC_ALL is invalid, we do _not_ continue trying
* the other environment vars. */
- envstr[1] = CATEGORY_NAMES + CATEGORY_NAMES[k];
+ envstr[1] = (char*) CATEGORY_NAMES + CATEGORY_NAMES[k];
j = 0;
- do {
+ while (1) {
p = envstr[j];
- } while ((++j < 4) && (!(p = getenv(p)) || !*p));
-
+ if (++j >= 4)
+ break; /* now p == "POSIX" */
+ p = getenv(p);
+ if (p && p[0])
+ break;
+ };
/* The user set something... is it valid? */
/* Note: Since we don't support user-supplied locales and
@@ -1313,9 +1321,9 @@ __locale_t newlocale(int category_mask, const char *locale, __locale_t base)
}
#else
if (!base) {
- if ((base = malloc(sizeof(__uclibc_locale_t))) == NULL) {
+ base = malloc(sizeof(__uclibc_locale_t));
+ if (base == NULL)
return base;
- }
_locale_init_l(base);
}
diff --git a/libc/misc/regex/regex_old.c b/libc/misc/regex/regex_old.c
index 76350fc4e..65aec97f1 100644
--- a/libc/misc/regex/regex_old.c
+++ b/libc/misc/regex/regex_old.c
@@ -120,7 +120,7 @@
# endif
/* This is for other GNU distributions with internationalized messages. */
-# if HAVE_LIBINTL_H || defined _LIBC
+# if defined HAVE_LIBINTL_H || defined _LIBC
# include <libintl.h>
# ifdef _LIBC
# undef gettext
@@ -208,7 +208,7 @@ char *realloc ();
# endif /* not emacs */
-# if defined _LIBC || HAVE_LIMITS_H
+# if defined _LIBC || defined HAVE_LIMITS_H
# include <limits.h>
# endif
@@ -2091,33 +2091,12 @@ static reg_errcode_t byte_compile_range (unsigned int range_start,
# define MAX_BUF_SIZE (1L << 16)
# define REALLOC(p,s) realloc ((p), (s))
# endif
+# endif /* not DEFINED_ONCE */
/* Extend the buffer by twice its current size via realloc and
reset the pointers that pointed into the old block to point to the
correct places in the new one. If extending the buffer results in it
being larger than MAX_BUF_SIZE, then flag memory exhausted. */
-# if __BOUNDED_POINTERS__
-# define SET_HIGH_BOUND(P) (__ptrhigh (P) = __ptrlow (P) + bufp->allocated)
-# define MOVE_BUFFER_POINTER(P) \
- (__ptrlow (P) += incr, SET_HIGH_BOUND (P), __ptrvalue (P) += incr)
-# define ELSE_EXTEND_BUFFER_HIGH_BOUND \
- else \
- { \
- SET_HIGH_BOUND (b); \
- SET_HIGH_BOUND (begalt); \
- if (fixup_alt_jump) \
- SET_HIGH_BOUND (fixup_alt_jump); \
- if (laststart) \
- SET_HIGH_BOUND (laststart); \
- if (pending_exact) \
- SET_HIGH_BOUND (pending_exact); \
- }
-# else
-# define MOVE_BUFFER_POINTER(P) (P) += incr
-# define ELSE_EXTEND_BUFFER_HIGH_BOUND
-# endif
-# endif /* not DEFINED_ONCE */
-
# ifdef WCHAR
# define EXTEND_BUFFER() \
do { \
@@ -2141,16 +2120,15 @@ static reg_errcode_t byte_compile_range (unsigned int range_start,
if (old_buffer != COMPILED_BUFFER_VAR) \
{ \
int incr = COMPILED_BUFFER_VAR - old_buffer; \
- MOVE_BUFFER_POINTER (b); \
- MOVE_BUFFER_POINTER (begalt); \
+ b += incr; \
+ begalt += incr; \
if (fixup_alt_jump) \
- MOVE_BUFFER_POINTER (fixup_alt_jump); \
+ fixup_alt_jump += incr; \
if (laststart) \
- MOVE_BUFFER_POINTER (laststart); \
+ laststart += incr; \
if (pending_exact) \
- MOVE_BUFFER_POINTER (pending_exact); \
+ pending_exact += incr; \
} \
- ELSE_EXTEND_BUFFER_HIGH_BOUND \
} while (0)
# else /* BYTE */
# define EXTEND_BUFFER() \
@@ -2169,16 +2147,15 @@ static reg_errcode_t byte_compile_range (unsigned int range_start,
if (old_buffer != COMPILED_BUFFER_VAR) \
{ \
int incr = COMPILED_BUFFER_VAR - old_buffer; \
- MOVE_BUFFER_POINTER (b); \
- MOVE_BUFFER_POINTER (begalt); \
+ b += incr; \
+ begalt += incr; \
if (fixup_alt_jump) \
- MOVE_BUFFER_POINTER (fixup_alt_jump); \
+ fixup_alt_jump += incr; \
if (laststart) \
- MOVE_BUFFER_POINTER (laststart); \
+ laststart += incr; \
if (pending_exact) \
- MOVE_BUFFER_POINTER (pending_exact); \
+ pending_exact += incr; \
} \
- ELSE_EXTEND_BUFFER_HIGH_BOUND \
} while (0)
# endif /* WCHAR */
@@ -2253,7 +2230,7 @@ typedef struct
}
# ifndef DEFINED_ONCE
-# if defined _LIBC || WIDE_CHAR_SUPPORT
+# if defined _LIBC || defined WIDE_CHAR_SUPPORT
/* The GNU C library provides support for user-defined character classes
and the functions from ISO C amendement 1. */
# ifdef CHARCLASS_NAME_MAX
@@ -3309,7 +3286,7 @@ PREFIX(regex_compile) (
the leading `:' and `[' (but set bits for them). */
if (c == ':' && *p == ']')
{
-# if defined _LIBC || WIDE_CHAR_SUPPORT
+# if defined _LIBC || defined WIDE_CHAR_SUPPORT
boolean is_lower = STREQ (str, "lower");
boolean is_upper = STREQ (str, "upper");
wctype_t wt;
@@ -4565,7 +4542,7 @@ byte_compile_range (
unsigned this_char;
const char *p = *p_ptr;
reg_errcode_t ret;
-# if _LIBC
+# ifdef _LIBC
const unsigned char *collseq;
unsigned int start_colseq;
unsigned int end_colseq;
@@ -4583,7 +4560,7 @@ byte_compile_range (
/* Report an error if the range is empty and the syntax prohibits this. */
ret = syntax & RE_NO_EMPTY_RANGES ? REG_ERANGE : REG_NOERROR;
-# if _LIBC
+# ifdef _LIBC
collseq = (const unsigned char *) _NL_CURRENT (LC_COLLATE,
_NL_COLLATE_COLLSEQMB);
diff --git a/libc/misc/wchar/wchar.c b/libc/misc/wchar/wchar.c
index a28cd8f94..9bdaafe90 100644
--- a/libc/misc/wchar/wchar.c
+++ b/libc/misc/wchar/wchar.c
@@ -188,24 +188,24 @@ wint_t btowc(int c)
if (c != EOF) {
*buf = (unsigned char) c;
mbstate.__mask = 0; /* Initialize the mbstate. */
- if (mbrtowc(&wc, buf, 1, &mbstate) <= 1) {
+ if (mbrtowc(&wc, (char*) buf, 1, &mbstate) <= 1) {
return wc;
}
}
return WEOF;
-#else /* __CTYPE_HAS_8_BIT_LOCALES */
+#else /* !__CTYPE_HAS_8_BIT_LOCALES */
#ifdef __UCLIBC_HAS_LOCALE__
assert((ENCODING == __ctype_encoding_7_bit)
|| (ENCODING == __ctype_encoding_utf8));
-#endif /* __UCLIBC_HAS_LOCALE__ */
+#endif
/* If we don't have 8-bit locale support, then this is trivial since
* anything outside of 0-0x7f is illegal in C/POSIX and UTF-8 locales. */
return (((unsigned int)c) < 0x80) ? c : WEOF;
-#endif /* __CTYPE_HAS_8_BIT_LOCALES */
+#endif /* !__CTYPE_HAS_8_BIT_LOCALES */
}
libc_hidden_def(btowc)
@@ -223,7 +223,7 @@ int wctob(wint_t c)
unsigned char buf[MB_LEN_MAX];
- return (wcrtomb(buf, c, NULL) == 1) ? *buf : EOF;
+ return (wcrtomb((char*) buf, c, NULL) == 1) ? *buf : EOF;
#else /* __CTYPE_HAS_8_BIT_LOCALES */
@@ -1290,8 +1290,8 @@ static int find_codeset(const char *name)
const unsigned char *s;
int codeset;
- for (s = __iconv_codesets ; *s ; s += *s) {
- if (!strcasecmp(s+2, name)) {
+ for (s = __iconv_codesets; *s; s += *s) {
+ if (!strcasecmp((char*) (s + 2), name)) {
return s[1];
}
}
@@ -1301,7 +1301,7 @@ static int find_codeset(const char *name)
/* TODO: maybe CODESET_LIST + *s ??? */
/* 7bit is 1, UTF-8 is 2, 8-bit is >= 3 */
codeset = 2;
- s = __LOCALE_DATA_CODESET_LIST;
+ s = (const unsigned char *) __LOCALE_DATA_CODESET_LIST;
do {
++codeset; /* Increment codeset first. */
if (!strcasecmp(__LOCALE_DATA_CODESET_LIST+*s, name)) {
@@ -1590,8 +1590,8 @@ extern const unsigned char __iconv_codesets[];
#define IBUF BUFSIZ
#define OBUF BUFSIZ
-char *progname;
-int hide_errors;
+static char *progname;
+static int hide_errors;
static void error_msg(const char *fmt, ...)
__attribute__ ((noreturn, format (printf, 1, 2)));
diff --git a/libc/misc/wctype/_wctype.c b/libc/misc/wctype/_wctype.c
index 16bc5237a..c3303d247 100644
--- a/libc/misc/wctype/_wctype.c
+++ b/libc/misc/wctype/_wctype.c
@@ -70,43 +70,9 @@
* towctrans function. */
/* #define SMALL_UPLOW */
-/**********************************************************************/
-#ifdef __UCLIBC_MJN3_ONLY__
-#ifdef L_iswspace
-/* generates one warning */
-#warning TODO: Fix the __CTYPE_* codes!
-#endif
-#endif /* __UCLIBC_MJN3_ONLY__ */
-#if 1
-/* Taking advantage of the C99 mutual-exclusion guarantees for the various
- * (w)ctype classes, including the descriptions of printing and control
- * (w)chars, we can place each in one of the following mutually-exlusive
- * subsets. Since there are less than 16, we can store the data for
- * each (w)chars in a nibble. In contrast, glibc uses an unsigned int
- * per (w)char, with one bit flag for each is* type. While this allows
- * a simple '&' operation to determine the type vs. a range test and a
- * little special handling for the "blank" and "xdigit" types in my
- * approach, it also uses 8 times the space for the tables on the typical
- * 32-bit archs we supported.*/
-enum {
- __CTYPE_unclassified = 0,
- __CTYPE_alpha_nonupper_nonlower,
- __CTYPE_alpha_lower,
- __CTYPE_alpha_upper_lower,
- __CTYPE_alpha_upper,
- __CTYPE_digit,
- __CTYPE_punct,
- __CTYPE_graph,
- __CTYPE_print_space_nonblank,
- __CTYPE_print_space_blank,
- __CTYPE_space_nonblank_noncntrl,
- __CTYPE_space_blank_noncntrl,
- __CTYPE_cntrl_space_nonblank,
- __CTYPE_cntrl_space_blank,
- __CTYPE_cntrl_nonspace
-};
-#endif
+/* Pull in __CTYPE_xxx constants */
+#include <bits/uClibc_charclass.h>
/* The following is used to implement wctype(), but it is defined
@@ -502,7 +468,6 @@ libc_hidden_def(towupper)
#ifdef L_wctype
static const unsigned char typestring[] = __CTYPE_TYPESTRING;
-/* extern const unsigned char typestring[]; */
/* libc_hidden_proto(wctype) */
wctype_t wctype(const char *property)
@@ -513,7 +478,7 @@ wctype_t wctype(const char *property)
p = typestring;
i = 1;
do {
- if (!strcmp(property, ++p)) {
+ if (!strcmp(property, (const char *) ++p)) {
return i;
}
++i;
@@ -913,10 +878,10 @@ wctrans_t wctrans(const char *property)
const unsigned char *p;
int i;
- p = transstring;
+ p = (const unsigned char *) transstring;
i = 1;
do {
- if (!strcmp(property, ++p)) {
+ if (!strcmp(property, (const char*) ++p)) {
return i;
}
++i;