diff options
Diffstat (limited to 'wcsmbs')
-rw-r--r-- | wcsmbs/Makefile | 6 | ||||
-rw-r--r-- | wcsmbs/Versions | 4 | ||||
-rw-r--r-- | wcsmbs/btowc.c | 22 | ||||
-rw-r--r-- | wcsmbs/mbrtowc.c | 40 | ||||
-rw-r--r-- | wcsmbs/mbsnrtowcs.c | 55 | ||||
-rw-r--r-- | wcsmbs/mbsrtowcs.c | 55 | ||||
-rw-r--r-- | wcsmbs/wchar.h | 181 | ||||
-rw-r--r-- | wcsmbs/wcrtomb.c | 49 | ||||
-rw-r--r-- | wcsmbs/wcschrnul.c | 36 | ||||
-rw-r--r-- | wcsmbs/wcsmbsload.c | 140 | ||||
-rw-r--r-- | wcsmbs/wcsmbsload.h | 10 | ||||
-rw-r--r-- | wcsmbs/wcsnrtombs.c | 71 | ||||
-rw-r--r-- | wcsmbs/wcsrtombs.c | 73 | ||||
-rw-r--r-- | wcsmbs/wctob.c | 28 | ||||
-rw-r--r-- | wcsmbs/wmemcpy.c | 7 | ||||
-rw-r--r-- | wcsmbs/wmemmove.c | 5 | ||||
-rw-r--r-- | wcsmbs/wmempcpy.c | 33 |
17 files changed, 557 insertions, 258 deletions
diff --git a/wcsmbs/Makefile b/wcsmbs/Makefile index fa5dbef..f1dc651 100644 --- a/wcsmbs/Makefile +++ b/wcsmbs/Makefile @@ -1,4 +1,4 @@ -# Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. +# Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc. # This file is part of the GNU C Library. # The GNU C Library is free software; you can redistribute it and/or @@ -26,10 +26,10 @@ distribute := wcwidth.h wcsmbsload.h routines := wcscat wcschr wcscmp wcscpy wcscspn wcsdup wcslen wcsncat \ wcsncmp wcsncpy wcspbrk wcsrchr wcsspn wcstok wcsstr wmemchr \ - wmemcmp wmemcpy wmemmove wmemset wcpcpy wcpncpy \ + wmemcmp wmemcpy wmemmove wmemset wcpcpy wcpncpy wmempcpy \ btowc wctob mbsinit \ mbrlen mbrtowc wcrtomb mbsrtowcs wcsrtombs \ - mbsnrtowcs wcsnrtombs wcsnlen \ + mbsnrtowcs wcsnrtombs wcsnlen wcschrnul \ wcstol wcstoul wcstoll wcstoull wcstod wcstold wcstof \ wcstol_l wcstoul_l wcstoll_l wcstoull_l \ wcstod_l wcstold_l wcstof_l \ diff --git a/wcsmbs/Versions b/wcsmbs/Versions index 54195ba..d0ba267 100644 --- a/wcsmbs/Versions +++ b/wcsmbs/Versions @@ -20,4 +20,8 @@ libc { wcscasecmp; wcsncasecmp; wcsnlen; wcstoll; wcstoimax; wcstoumax; wcstoull; wcswcs; wmemrtombs; wmemrtowcs; } + GLIBC_2.2 { + # w* + wcschrnul; wmempcpy; + } } diff --git a/wcsmbs/btowc.c b/wcsmbs/btowc.c index 1c6332e..bec0d48 100644 --- a/wcsmbs/btowc.c +++ b/wcsmbs/btowc.c @@ -30,7 +30,7 @@ __btowc (c) int c; { wchar_t result; - struct gconv_step_data data; + struct __gconv_step_data data; unsigned char inbuf[1]; const unsigned char *inptr = inbuf; size_t dummy; @@ -42,12 +42,12 @@ __btowc (c) return WEOF; /* Tell where we want the result. */ - data.outbuf = (unsigned char *) &result; - data.outbufend = data.outbuf + sizeof (wchar_t); - data.invocation_counter = 0; - data.internal_use = 1; - data.is_last = 1; - data.statep = &data.__state; + data.__outbuf = (unsigned char *) &result; + data.__outbufend = data.__outbuf + sizeof (wchar_t); + data.__invocation_counter = 0; + data.__internal_use = 1; + data.__is_last = 1; + data.__statep = &data.__state; /* Make sure we start in the initial state. */ memset (&data.__state, '\0', sizeof (mbstate_t)); @@ -58,11 +58,11 @@ __btowc (c) /* Create the input string. */ inbuf[0] = c; - status = (*__wcsmbs_gconv_fcts.towc->fct) (__wcsmbs_gconv_fcts.towc, &data, - &inptr, inptr + 1, &dummy, 0); + status = (*__wcsmbs_gconv_fcts.towc->__fct) (__wcsmbs_gconv_fcts.towc, &data, + &inptr, inptr + 1, &dummy, 0); /* The conversion failed. */ - if (status != GCONV_OK && status != GCONV_FULL_OUTPUT - && status != GCONV_EMPTY_INPUT) + if (status != __GCONV_OK && status != __GCONV_FULL_OUTPUT + && status != __GCONV_EMPTY_INPUT) result = WEOF; return result; diff --git a/wcsmbs/mbrtowc.c b/wcsmbs/mbrtowc.c index 78ff2a2..a68b0f2 100644 --- a/wcsmbs/mbrtowc.c +++ b/wcsmbs/mbrtowc.c @@ -35,7 +35,7 @@ size_t __mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps) { wchar_t buf[1]; - struct gconv_step_data data; + struct __gconv_step_data data; int status; size_t result; size_t dummy; @@ -43,18 +43,18 @@ __mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps) char *outbuf = (char *) (pwc ?: buf); /* Tell where we want the result. */ - data.outbuf = outbuf; - data.outbufend = outbuf + sizeof (wchar_t); - data.invocation_counter = 0; - data.internal_use = 1; - data.is_last = 1; - data.statep = ps ?: &state; + data.__outbuf = outbuf; + data.__outbufend = outbuf + sizeof (wchar_t); + data.__invocation_counter = 0; + data.__internal_use = 1; + data.__is_last = 1; + data.__statep = ps ?: &state; /* A first special case is if S is NULL. This means put PS in the initial state. */ if (s == NULL) { - data.outbuf = (char *) buf; + data.__outbuf = (char *) buf; s = ""; n = 1; } @@ -64,27 +64,27 @@ __mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps) /* Do a normal conversion. */ inbuf = (const unsigned char *) s; - status = (*__wcsmbs_gconv_fcts.towc->fct) (__wcsmbs_gconv_fcts.towc, - &data, &inbuf, inbuf + n, - &dummy, 0); + status = (*__wcsmbs_gconv_fcts.towc->__fct) (__wcsmbs_gconv_fcts.towc, + &data, &inbuf, inbuf + n, + &dummy, 0); /* There must not be any problems with the conversion but illegal input characters. The output buffer must be large enough, otherwise the definition of MB_CUR_MAX is not correct. All the other possible errors also must not happen. */ - assert (status == GCONV_OK || status == GCONV_EMPTY_INPUT - || status == GCONV_ILLEGAL_INPUT - || status == GCONV_INCOMPLETE_INPUT - || status == GCONV_FULL_OUTPUT); + assert (status == __GCONV_OK || status == __GCONV_EMPTY_INPUT + || status == __GCONV_ILLEGAL_INPUT + || status == __GCONV_INCOMPLETE_INPUT + || status == __GCONV_FULL_OUTPUT); - if (status == GCONV_OK || status == GCONV_EMPTY_INPUT - || status == GCONV_FULL_OUTPUT) + if (status == __GCONV_OK || status == __GCONV_EMPTY_INPUT + || status == __GCONV_FULL_OUTPUT) { - if (data.outbuf != (unsigned char *) outbuf + if (data.__outbuf != (unsigned char *) outbuf && *(wchar_t *) outbuf == L'\0') { /* The converted character is the NUL character. */ - assert (__mbsinit (data.statep)); + assert (__mbsinit (data.__statep)); result = 0; } else @@ -92,7 +92,7 @@ __mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps) } else { - result = status == GCONV_INCOMPLETE_INPUT ? (size_t) -2 : (size_t) -1; + result = status == __GCONV_INCOMPLETE_INPUT ? (size_t) -2 : (size_t) -1; __set_errno (EILSEQ); } diff --git a/wcsmbs/mbsnrtowcs.c b/wcsmbs/mbsnrtowcs.c index cb2d41c..b58a467 100644 --- a/wcsmbs/mbsnrtowcs.c +++ b/wcsmbs/mbsnrtowcs.c @@ -45,15 +45,16 @@ __mbsnrtowcs (dst, src, nmc, len, ps) mbstate_t *ps; { const unsigned char *srcend; - struct gconv_step_data data; + struct __gconv_step_data data; size_t result = 0; int status; + struct __gconv_step *towc; /* Tell where we want the result. */ - data.invocation_counter = 0; - data.internal_use = 1; - data.is_last = 1; - data.statep = ps ?: &state; + data.__invocation_counter = 0; + data.__internal_use = 1; + data.__is_last = 1; + data.__statep = ps ?: &state; if (nmc == 0) return 0; @@ -62,25 +63,27 @@ __mbsnrtowcs (dst, src, nmc, len, ps) /* Make sure we use the correct function. */ update_conversion_ptrs (); + /* Get the structure with the function pointers. */ + towc = __wcsmbs_gconv_fcts.towc; + /* We have to handle DST == NULL special. */ if (dst == NULL) { wchar_t buf[64]; /* Just an arbitrary size. */ const unsigned char *inbuf = *src; - data.outbufend = (char *) buf + sizeof (buf); + data.__outbufend = (char *) buf + sizeof (buf); do { - data.outbuf = (char *) buf; + data.__outbuf = (char *) buf; - status = (*__wcsmbs_gconv_fcts.towc->fct) (__wcsmbs_gconv_fcts.towc, - &data, &inbuf, srcend, - &result, 0); + status = (*towc->__fct) (__wcsmbs_gconv_fcts.towc, &data, &inbuf, + srcend, &result, 0); } - while (status == GCONV_FULL_OUTPUT); + while (status == __GCONV_FULL_OUTPUT); - if ((status == GCONV_OK || status == GCONV_EMPTY_INPUT) - && ((wchar_t *) data.outbuf)[-1] == L'\0') + if ((status == __GCONV_OK || status == __GCONV_EMPTY_INPUT) + && ((wchar_t *) data.__outbuf)[-1] == L'\0') /* Don't count the NUL character in. */ --result; } @@ -89,21 +92,20 @@ __mbsnrtowcs (dst, src, nmc, len, ps) /* This code is based on the safe assumption that all internal multi-byte encodings use the NUL byte only to mark the end of the string. */ - data.outbuf = (unsigned char *) dst; - data.outbufend = data.outbuf + len * sizeof (wchar_t); + data.__outbuf = (unsigned char *) dst; + data.__outbufend = data.__outbuf + len * sizeof (wchar_t); - status = (*__wcsmbs_gconv_fcts.towc->fct) (__wcsmbs_gconv_fcts.towc, - &data, - (const unsigned char **) src, - srcend, &result, 0); + status = (*towc->__fct) (__wcsmbs_gconv_fcts.towc, &data, + (const unsigned char **) src, srcend, + &result, 0); /* We have to determine whether the last character converted is the NUL character. */ - if ((status == GCONV_OK || status == GCONV_EMPTY_INPUT) + if ((status == __GCONV_OK || status == __GCONV_EMPTY_INPUT) && ((wchar_t *) dst)[result - 1] == L'\0') { assert (result > 0); - assert (__mbsinit (data.statep)); + assert (__mbsinit (data.__statep)); *src = NULL; --result; } @@ -111,12 +113,13 @@ __mbsnrtowcs (dst, src, nmc, len, ps) /* There must not be any problems with the conversion but illegal input characters. */ - assert (status == GCONV_OK || status != GCONV_EMPTY_INPUT - || status == GCONV_ILLEGAL_INPUT - || status == GCONV_INCOMPLETE_INPUT || status == GCONV_FULL_OUTPUT); + assert (status == __GCONV_OK || status != __GCONV_EMPTY_INPUT + || status == __GCONV_ILLEGAL_INPUT + || status == __GCONV_INCOMPLETE_INPUT + || status == __GCONV_FULL_OUTPUT); - if (status != GCONV_OK && status != GCONV_FULL_OUTPUT - && status != GCONV_EMPTY_INPUT) + if (status != __GCONV_OK && status != __GCONV_FULL_OUTPUT + && status != __GCONV_EMPTY_INPUT) { result = (size_t) -1; __set_errno (EILSEQ); diff --git a/wcsmbs/mbsrtowcs.c b/wcsmbs/mbsrtowcs.c index 84b7a38..f69247f 100644 --- a/wcsmbs/mbsrtowcs.c +++ b/wcsmbs/mbsrtowcs.c @@ -41,19 +41,23 @@ __mbsrtowcs (dst, src, len, ps) size_t len; mbstate_t *ps; { - struct gconv_step_data data; + struct __gconv_step_data data; size_t result = 0; int status; + struct __gconv_step *towc; /* Tell where we want the result. */ - data.invocation_counter = 0; - data.internal_use = 1; - data.is_last = 1; - data.statep = ps ?: &state; + data.__invocation_counter = 0; + data.__internal_use = 1; + data.__is_last = 1; + data.__statep = ps ?: &state; /* Make sure we use the correct function. */ update_conversion_ptrs (); + /* Get the structure with the function pointers. */ + towc = __wcsmbs_gconv_fcts.towc; + /* We have to handle DST == NULL special. */ if (dst == NULL) { @@ -61,21 +65,20 @@ __mbsrtowcs (dst, src, len, ps) const unsigned char *inbuf = (const unsigned char *) *src; const unsigned char *srcend = inbuf + strlen (inbuf) + 1; - data.outbufend = (char *) buf + sizeof (buf); + data.__outbufend = (char *) buf + sizeof (buf); do { - data.outbuf = (char *) buf; + data.__outbuf = (char *) buf; - status = (*__wcsmbs_gconv_fcts.towc->fct) (__wcsmbs_gconv_fcts.towc, - &data, &inbuf, srcend, - &result, 0); + status = (*towc->__fct) (__wcsmbs_gconv_fcts.towc, &data, &inbuf, + srcend, &result, 0); } - while (status == GCONV_FULL_OUTPUT); + while (status == __GCONV_FULL_OUTPUT); - if (status == GCONV_OK || status == GCONV_EMPTY_INPUT) + if (status == __GCONV_OK || status == __GCONV_EMPTY_INPUT) { /* There better should be a NUL wide char at the end. */ - assert (((wchar_t *) data.outbuf)[-1] == L'\0'); + assert (((wchar_t *) data.__outbuf)[-1] == L'\0'); /* Don't count the NUL character in. */ --result; } @@ -91,21 +94,20 @@ __mbsrtowcs (dst, src, len, ps) + __strnlen (*src, len * MB_CUR_MAX) + 1); - data.outbuf = (unsigned char *) dst; - data.outbufend = data.outbuf + len * sizeof (wchar_t); + data.__outbuf = (unsigned char *) dst; + data.__outbufend = data.__outbuf + len * sizeof (wchar_t); - status = (*__wcsmbs_gconv_fcts.towc->fct) (__wcsmbs_gconv_fcts.towc, - &data, - (const unsigned char **) src, - srcend, &result, 0); + status = (*towc->__fct) (__wcsmbs_gconv_fcts.towc, &data, + (const unsigned char **) src, srcend, + &result, 0); /* We have to determine whether the last character converted is the NUL character. */ - if ((status == GCONV_OK || status == GCONV_EMPTY_INPUT) + if ((status == __GCONV_OK || status == __GCONV_EMPTY_INPUT) && ((wchar_t *) dst)[result - 1] == L'\0') { assert (result > 0); - assert (__mbsinit (data.statep)); + assert (__mbsinit (data.__statep)); *src = NULL; --result; } @@ -113,12 +115,13 @@ __mbsrtowcs (dst, src, len, ps) /* There must not be any problems with the conversion but illegal input characters. */ - assert (status == GCONV_OK || status == GCONV_EMPTY_INPUT - || status == GCONV_ILLEGAL_INPUT - || status == GCONV_INCOMPLETE_INPUT || status == GCONV_FULL_OUTPUT); + assert (status == __GCONV_OK || status == __GCONV_EMPTY_INPUT + || status == __GCONV_ILLEGAL_INPUT + || status == __GCONV_INCOMPLETE_INPUT + || status == __GCONV_FULL_OUTPUT); - if (status != GCONV_OK && status != GCONV_FULL_OUTPUT - && status != GCONV_EMPTY_INPUT) + if (status != __GCONV_OK && status != __GCONV_FULL_OUTPUT + && status != __GCONV_EMPTY_INPUT) { result = (size_t) -1; __set_errno (EILSEQ); diff --git a/wcsmbs/wchar.h b/wcsmbs/wchar.h index fddb3d6..8be3f10 100644 --- a/wcsmbs/wchar.h +++ b/wcsmbs/wchar.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. +/* Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -22,19 +22,24 @@ */ #ifndef _WCHAR_H -#define _WCHAR_H 1 -#include <features.h> +#ifndef __need_mbstate_t +# define _WCHAR_H 1 +# include <features.h> +#endif +#ifdef _WCHAR_H /* Get FILE definition. */ -#define __need_FILE -#include <stdio.h> +# define __need_FILE +# include <stdio.h> +# include <stdarg.h> /* Get size_t, wchar_t, wint_t and NULL from <stddef.h>. */ -#define __need_size_t -#define __need_wchar_t +# define __need_size_t +# define __need_wchar_t +# define __need_NULL +#endif #define __need_wint_t -#define __need_NULL #include <stddef.h> /* We try to get wint_t from <stddef.h>, but not all GCC versions define it @@ -49,12 +54,24 @@ typedef unsigned int wint_t; #endif +#ifndef __mbstate_t_defined +# define __mbstate_t_defined 1 /* Conversion state information. */ typedef struct { int count; /* Number of bytes needed for the current character. */ wint_t value; /* Value so far. */ -} mbstate_t; +} __mbstate_t; +#endif +#undef __need_mbstate_t + + +/* The rest of the file is only used if used if __need_mbstate_t is not + defined. */ +#ifdef _WCHAR_H + +/* Public type. */ +typedef __mbstate_t mbstate_t; #ifndef WCHAR_MIN /* These constants might also be defined in <inttypes.h>. */ @@ -150,6 +167,12 @@ extern wchar_t *wcschr __P ((__const wchar_t *__wcs, wchar_t __wc)); /* Find the last occurrence of WC in WCS. */ extern wchar_t *wcsrchr __P ((__const wchar_t *__wcs, wchar_t __wc)); +#ifdef __USE_GNU +/* This funciton is similar to `wcschr'. But it returns a pointer to + the closing NUL wide character in case C is not found in S. */ +extern wchar_t *wcschrnul __P ((__const wchar_t *__s, wchar_t __wc)); +#endif + /* Return the length of the initial segmet of WCS which consists entirely of wide characters not in REJECT. */ extern size_t wcscspn __P ((__const wchar_t *__wcs, @@ -204,6 +227,13 @@ extern wchar_t *wmemmove __P ((wchar_t *__s1, __const wchar_t *__s2, /* Set N wide characters of S to C. */ extern wchar_t *wmemset __P ((wchar_t *__s, wchar_t __c, size_t __n)); +#ifdef __USE_GNU +/* Copy N wide characters of SRC to DEST and return pointer to following + wide character. */ +extern wchar_t *wmempcpy __P ((wchar_t *__restrict __s1, + __const wchar_t *__restrict __s2, size_t __n)); +#endif + /* Determine whether C constitutes a valid (one-byte) multibyte character. */ @@ -488,6 +518,137 @@ extern wchar_t *wcpncpy __P ((wchar_t *__dest, __const wchar_t *__src, #endif /* use GNU */ +/* Wide character I/O functions. */ + +/* Select orientation for stream. */ +extern int fwide __P ((FILE *__fp, int __mode)); + + +/* Write formatted output to STREAM. */ +extern int fwprintf __P ((FILE *__restrict __stream, + __const wchar_t *__restrict __format, ...)) + /* __attribute__ ((__format__ (__wprintf__, 2, 3))) */; +/* Write formatted output to stdout. */ +extern int wprintf __P ((__const wchar_t *__restrict __format, ...)) + /* __attribute__ ((__format__ (__wprintf__, 1, 2))) */; +/* Write formatted output of at most N characters to S. */ +extern int swprintf __P ((wchar_t *__restrict __s, size_t __n, + __const wchar_t *__restrict __format, ...)) + /* __attribute__ ((__format__ (__wprintf__, 3, 4))) */; + +/* Write formatted output to S from argument list ARG. */ +extern int vfwprintf __P ((FILE *__restrict __s, + __const wchar_t *__restrict __format, + va_list __arg)) + /* __attribute__ ((__format__ (__wprintf__, 2, 0))) */; +/* Write formatted output to stdout from argument list ARG. */ +extern int vwprintf __P ((__const wchar_t *__restrict __format, + va_list __arg)) + /* __attribute__ ((__format__ (__wprintf__, 1, 0))) */; +/* Write formatted output of at most N character to S from argument + list ARG. */ +extern int vswprintf __P ((wchar_t *__restrict __s, size_t __n, + __const wchar_t *__restrict __format, + va_list __arg)) + /* __attribute__ ((__format__ (__wprintf__, 3, 0))) */; + + +/* Read formatted input from STREAM. */ +extern int fwscanf __P ((FILE *__restrict __stream, + __const wchar_t *__restrict __format, ...)) + /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */; +/* Read formatted input from stdin. */ +extern int wscanf __P ((__const wchar_t *__restrict __format, ...)) + /* __attribute__ ((__format__ (__wscanf__, 1, 2))) */; +/* Read formatted input from S. */ +extern int swscanf __P ((__const wchar_t *__restrict __s, + __const wchar_t *__restrict __format, ...)) + /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */; + +/* Read formatted input from S into argument list ARG. */ +extern int vfwscanf __P ((FILE *__restrict __s, + __const wchar_t *__restrict __format, va_list __arg)) + /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */; +/* Read formatted input from stdin into argument list ARG. */ +extern int vwscanf __P ((__const wchar_t *__restrict __format, va_list __arg)) + /* __attribute__ ((__format__ (__wscanf__, 1, 0))) */; +/* Read formatted input from S into argument list ARG. */ +extern int vswscanf __P ((__const wchar_t *__restrict __s, + __const wchar_t *__restrict __format, va_list __arg)) + /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */; + + +/* Read a character from STREAM. */ +extern wint_t fgetwc __P ((FILE *__stream)); +extern wint_t getwc __P ((FILE *__stream)); + +/* Read a character from stdin. */ +extern wint_t getwchar __P ((void)); + +#ifdef __USE_GNU +/* These are defined to be equivalent to the `char' functions defined + in POSIX.1:1996. */ +extern wint_t getwc_unlocked __P ((FILE *__stream)); +extern wint_t getwchar_unlocked __P ((void)); + +/* This is the wide character version of a GNU extension. */ +extern wint_t fgetwc_unlocked __P ((FILE *__stream)); +#endif /* Use POSIX or MISC. */ + + +/* Write a character to STREAM. */ +extern wint_t fputwc __P ((wint_t __wc, FILE *__stream)); +extern wint_t putwc __P ((wint_t __wc, FILE *__stream)); + +/* Write a character to stdout. */ +extern wint_t putwchar __P ((wint_t __wc)); + +#ifdef __USE_GNU +/* Faster version when locking is not necessary. */ +extern wint_t fputwc_unlocked __P ((wint_t __wc, FILE *__stream)); + +/* These are defined to be equivalent to the `char' functions defined + in POSIX.1:1996. */ +extern wint_t putwc_unlocked __P ((wint_t __wc, FILE *__stream)); +extern wint_t putwchar_unlocked __P ((wint_t __wc)); +#endif + + +/* Get a newline-terminated wide character string of finite length + from STREAM. */ +extern wchar_t *fgetws __P ((wchar_t *__restrict __ws, int __n, + FILE *__restrict __stream)); + +#ifdef __USE_GNU +/* This function does the same as `fgetws' but does not lock the stream. */ +extern wchar_t *fgetws_unlocked __P ((wchar_t *__restrict __ws, int __n, + FILE *__restrict __stream)); +#endif + + +/* Write a string to STREAM. */ +extern int fputws __P ((__const wchar_t *__restrict __ws, + FILE *__restrict __stream)); + +#ifdef __USE_GNU +/* This function does the same as `fputws' but does not lock the stream. */ +extern int fputws_unlocked __P ((__const wchar_t *__restrict __ws, + FILE *__restrict __stream)); +#endif + + +/* Push a character back onto the input buffer of STREAM. */ +extern wint_t ungetwc __P ((wint_t __wc, FILE *__stream)); + + +/* Format TP into S according to FORMAT. + Write no more than MAXSIZE wide characters and return the number + of wide characters written, or 0 if it would exceed MAXSIZE. */ +extern size_t wcsftime __P ((wchar_t *__restrict __s, size_t __maxsize, + __const wchar_t *__restrict __format, + __const struct tm *__restrict __tp)); + + /* The X/Open standard demands that most of the functions defined in the <wctype.h> header must also appear here. This is probably because some X/Open members wrote their implementation before the @@ -501,4 +662,6 @@ extern wchar_t *wcpncpy __P ((wchar_t *__dest, __const wchar_t *__src, __END_DECLS +#endif /* _WCHAR_H defined */ + #endif /* wchar.h */ diff --git a/wcsmbs/wcrtomb.c b/wcsmbs/wcrtomb.c index b546c7a..91daf4d 100644 --- a/wcsmbs/wcrtomb.c +++ b/wcsmbs/wcrtomb.c @@ -37,24 +37,24 @@ size_t __wcrtomb (char *s, wchar_t wc, mbstate_t *ps) { char buf[MB_CUR_MAX]; - struct gconv_step_data data; + struct __gconv_step_data data; int status; size_t result; size_t dummy; /* Tell where we want the result. */ - data.outbuf = s; - data.outbufend = s + MB_CUR_MAX; - data.invocation_counter = 0; - data.internal_use = 1; - data.is_last = 1; - data.statep = ps ?: &state; + data.__outbuf = s; + data.__outbufend = s + MB_CUR_MAX; + data.__invocation_counter = 0; + data.__internal_use = 1; + data.__is_last = 1; + data.__statep = ps ?: &state; /* A first special case is if S is NULL. This means put PS in the initial state. */ if (s == NULL) { - data.outbuf = buf; + data.__outbuf = buf; wc = L'\0'; } @@ -66,35 +66,36 @@ __wcrtomb (char *s, wchar_t wc, mbstate_t *ps) by a NUL byte. */ if (wc == L'\0') { - status = (*__wcsmbs_gconv_fcts.tomb->fct) (__wcsmbs_gconv_fcts.tomb, - &data, NULL, NULL, &dummy, 1); + status = (*__wcsmbs_gconv_fcts.tomb->__fct) (__wcsmbs_gconv_fcts.tomb, + &data, NULL, NULL, + &dummy, 1); - if (status == GCONV_OK || status == GCONV_EMPTY_INPUT) - *data.outbuf++ = '\0'; + if (status == __GCONV_OK || status == __GCONV_EMPTY_INPUT) + *data.__outbuf++ = '\0'; } else { /* Do a normal conversion. */ const unsigned char *inbuf = (const unsigned char *) &wc; - status = (*__wcsmbs_gconv_fcts.tomb->fct) (__wcsmbs_gconv_fcts.tomb, - &data, &inbuf, - inbuf + sizeof (wchar_t), - &dummy, 0); + status = (*__wcsmbs_gconv_fcts.tomb->__fct) (__wcsmbs_gconv_fcts.tomb, + &data, &inbuf, + inbuf + sizeof (wchar_t), + &dummy, 0); } /* There must not be any problems with the conversion but illegal input characters. The output buffer must be large enough, otherwise the definition of MB_CUR_MAX is not correct. All the other possible errors also must not happen. */ - assert (status == GCONV_OK || status == GCONV_EMPTY_INPUT - || status == GCONV_ILLEGAL_INPUT - || status == GCONV_INCOMPLETE_INPUT - || status == GCONV_FULL_OUTPUT); - - if (status == GCONV_OK || status == GCONV_EMPTY_INPUT - || status == GCONV_FULL_OUTPUT) - result = data.outbuf - (unsigned char *) s; + assert (status == __GCONV_OK || status == __GCONV_EMPTY_INPUT + || status == __GCONV_ILLEGAL_INPUT + || status == __GCONV_INCOMPLETE_INPUT + || status == __GCONV_FULL_OUTPUT); + + if (status == __GCONV_OK || status == __GCONV_EMPTY_INPUT + || status == __GCONV_FULL_OUTPUT) + result = data.__outbuf - (unsigned char *) s; else { result = (size_t) -1; diff --git a/wcsmbs/wcschrnul.c b/wcsmbs/wcschrnul.c new file mode 100644 index 0000000..2ea9b2c --- /dev/null +++ b/wcsmbs/wcschrnul.c @@ -0,0 +1,36 @@ +/* Copyright (C) 1995, 1996, 1999 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <wchar.h> + + +/* Find the first occurrence of WC in WCS. */ +wchar_t * +__wcschrnul (wcs, wc) + register const wchar_t *wcs; + register const wchar_t wc; +{ + while (*wcs != L'\0') + if (*wcs == wc) + break; + else + ++wcs; + + return wcs; +} +weak_alias (__wcschrnul, wcschrnul) diff --git a/wcsmbs/wcsmbsload.c b/wcsmbs/wcsmbsload.c index b16aa6c..b02acad 100644 --- a/wcsmbs/wcsmbsload.c +++ b/wcsmbs/wcsmbsload.c @@ -36,64 +36,76 @@ const struct locale_data *__wcsmbs_last_locale = &_nl_C_LC_CTYPE; /* These are the descriptions for the default conversion functions. */ -static struct gconv_step to_wc = +static struct __gconv_step to_wc = { - shlib_handle: NULL, - modname: NULL, - counter: INT_MAX, - from_name: "ANSI_X3.4-1968//", - to_name: "INTERNAL", - fct: __gconv_transform_ascii_internal, - init_fct: NULL, - end_fct: NULL, - min_needed_from: 1, - max_needed_from: 1, - min_needed_to: 4, - max_needed_to: 4, - stateful: 0, - data: NULL + .__shlib_handle = NULL, + .__modname = NULL, + .__counter = INT_MAX, + .__from_name = "ANSI_X3.4-1968//", + .__to_name = "INTERNAL", + .__fct = __gconv_transform_ascii_internal, + .__init_fct = NULL, + .__end_fct = NULL, + .__min_needed_from = 1, + .__max_needed_from = 1, + .__min_needed_to = 4, + .__max_needed_to = 4, + .__stateful = 0, + .__data = NULL }; -static struct gconv_step to_mb = +static struct __gconv_step to_mb = { - shlib_handle: NULL, - modname: NULL, - counter: INT_MAX, - from_name: "INTERNAL", - to_name: "ANSI_X3.4-1968//", - fct: __gconv_transform_internal_ascii, - init_fct: NULL, - end_fct: NULL, - min_needed_from: 4, - max_needed_from: 4, - min_needed_to: 1, - max_needed_to: 1, - stateful: 0, - data: NULL + .__shlib_handle = NULL, + .__modname = NULL, + .__counter = INT_MAX, + .__from_name = "INTERNAL", + .__to_name = "ANSI_X3.4-1968//", + .__fct = __gconv_transform_internal_ascii, + .__init_fct = NULL, + .__end_fct = NULL, + .__min_needed_from = 4, + .__max_needed_from = 4, + .__min_needed_to = 1, + .__max_needed_to = 1, + .__stateful = 0, + .__data = NULL }; /* For the default locale we only have to handle ANSI_X3.4-1968. */ struct gconv_fcts __wcsmbs_gconv_fcts = { - towc: &to_wc, - tomb: &to_mb + .towc = &to_wc, + .tomb = &to_mb }; -static inline struct gconv_step * +static inline struct __gconv_step * getfct (const char *to, const char *from) { size_t nsteps; - struct gconv_step *result; + struct __gconv_step *result; + size_t nstateful; + size_t cnt; - if (__gconv_find_transform (to, from, &result, &nsteps) != GCONV_OK) + if (__gconv_find_transform (to, from, &result, &nsteps) != __GCONV_OK) /* Loading the conversion step is not possible. */ return NULL; - /* We must only have one step in this conversion. */ - if (nsteps != 1) - return NULL; + /* Count the number of stateful conversions. Since we will only + have one 'mbstate_t' object available we can only deal with one + stateful conversion. */ + nstateful = 0; + for (cnt = 0; cnt < nsteps; ++cnt) + if (result[cnt].__stateful) + ++nstateful; + if (nstateful > 1) + { + /* We cannot handle this case. */ + __gconv_close_transform (result, nsteps); + result = NULL; + } return result; } @@ -148,14 +160,15 @@ getfct (const char *to, const char *from) }) +/* We must modify global data. */ +__libc_lock_define_initialized (static, lock) + + /* Load conversion functions for the currently selected locale. */ void internal_function __wcsmbs_load_conv (const struct locale_data *new_category) { - /* We must modify global data. */ - __libc_lock_define_initialized (static, lock) - /* Acquire the lock. */ __libc_lock_lock (lock); @@ -174,6 +187,12 @@ __wcsmbs_load_conv (const struct locale_data *new_category) /* We must find the real functions. */ const char *charset_name; const char *complete_name; + struct __gconv_step *new_towc; + struct __gconv_step *new_tomb; + + /* Free the old conversions. */ + __gconv_close_transform (__wcsmbs_gconv_fcts.tomb, 1); + __gconv_close_transform (__wcsmbs_gconv_fcts.towc, 1); /* Get name of charset of the locale. We first examine whether we have a character set mentioned in the locale @@ -188,15 +207,23 @@ __wcsmbs_load_conv (const struct locale_data *new_category) complete lookup. */ complete_name = norm_add_slashes (charset_name); - __wcsmbs_gconv_fcts.tomb = getfct (complete_name, "INTERNAL"); - __wcsmbs_gconv_fcts.towc = getfct ("INTERNAL", complete_name); + new_towc = getfct ("INTERNAL", complete_name); + if (new_towc != NULL) + new_tomb = getfct (complete_name, "INTERNAL"); /* If any of the conversion functions is not available we don't use any since this would mean we cannot convert back and forth.*/ - if (__wcsmbs_gconv_fcts.towc == NULL - || __wcsmbs_gconv_fcts.tomb == NULL) - goto failed; + if (new_towc == NULL || new_tomb == NULL) + { + if (new_towc != NULL) + __gconv_close_transform (new_towc, 1); + + goto failed; + } + + __wcsmbs_gconv_fcts.tomb = new_tomb; + __wcsmbs_gconv_fcts.towc = new_towc; } /* Set last-used variable for current locale. */ @@ -205,3 +232,24 @@ __wcsmbs_load_conv (const struct locale_data *new_category) __libc_lock_unlock (lock); } + + +/* Clone the current conversion function set. */ +void +internal_function +__wcsmbs_clone_conv (struct gconv_fcts *copy) +{ + /* Make sure the data structures remain the same until we are finished. */ + __libc_lock_lock (lock); + + /* Copy the data. */ + *copy = __wcsmbs_gconv_fcts; + + /* Now increment the usage counters. */ + if (copy->towc->__shlib_handle != NULL) + ++copy->towc->__counter; + if (copy->tomb->__shlib_handle != NULL) + ++copy->tomb->__counter; + + __libc_lock_unlock (lock); +} diff --git a/wcsmbs/wcsmbsload.h b/wcsmbs/wcsmbsload.h index df0ba7b..a3652d2 100644 --- a/wcsmbs/wcsmbsload.h +++ b/wcsmbs/wcsmbsload.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1998 Free Software Foundation, Inc. +/* Copyright (C) 1998, 1999 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998. @@ -25,8 +25,8 @@ /* Contains pointers to the used functions in the `gconv' modules. */ struct gconv_fcts { - struct gconv_step *towc; - struct gconv_step *tomb; + struct __gconv_step *towc; + struct __gconv_step *tomb; }; /* Set of currently active conversion functions. */ @@ -41,6 +41,10 @@ extern const struct locale_data *__wcsmbs_last_locale; extern void __wcsmbs_load_conv (const struct locale_data *new_category) internal_function; +/* Clone the current `__wcsmbs_load_conv' value. */ +extern void __wcsmbs_clone_conv (struct gconv_fcts *copy) + internal_function; + /* Check whether the LC_CTYPE locale changed since the last call. Update the pointers appropriately. */ diff --git a/wcsmbs/wcsnrtombs.c b/wcsmbs/wcsnrtombs.c index f93d404..fb86992 100644 --- a/wcsmbs/wcsnrtombs.c +++ b/wcsmbs/wcsnrtombs.c @@ -1,6 +1,6 @@ -/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. +/* Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc. This file is part of the GNU C Library. - Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996. + Contributed by Ulrich Drepper <drepper@gnu.org>, 1996. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as @@ -43,16 +43,17 @@ __wcsnrtombs (dst, src, nwc, len, ps) size_t len; mbstate_t *ps; { - struct gconv_step_data data; + struct __gconv_step_data data; const wchar_t *srcend; int status; size_t result; + struct __gconv_step *tomb; /* Tell where we want the result. */ - data.invocation_counter = 0; - data.internal_use = 1; - data.is_last = 1; - data.statep = ps ?: &state; + data.__invocation_counter = 0; + data.__internal_use = 1; + data.__is_last = 1; + data.__statep = ps ?: &state; if (nwc == 0) return 0; @@ -61,6 +62,9 @@ __wcsnrtombs (dst, src, nwc, len, ps) /* Make sure we use the correct function. */ update_conversion_ptrs (); + /* Get the structure with the function pointers. */ + tomb = __wcsmbs_gconv_fcts.tomb; + /* We have to handle DST == NULL special. */ if (dst == NULL) { @@ -69,25 +73,23 @@ __wcsnrtombs (dst, src, nwc, len, ps) size_t dummy; result = 0; - data.outbufend = buf + sizeof (buf); + data.__outbufend = buf + sizeof (buf); do { - data.outbuf = buf; + data.__outbuf = buf; - status = (*__wcsmbs_gconv_fcts.tomb->fct) (__wcsmbs_gconv_fcts.tomb, - &data, - (const unsigned char **) &inbuf, - (const unsigned char *) srcend, - &dummy, 0); + status = (*tomb->__fct) (__wcsmbs_gconv_fcts.tomb, &data, + (const unsigned char **) &inbuf, + (const unsigned char *) srcend, &dummy, 0); /* Count the number of bytes. */ - result += data.outbuf - buf; + result += data.__outbuf - buf; } - while (status == GCONV_FULL_OUTPUT); + while (status == __GCONV_FULL_OUTPUT); - if ((status == GCONV_OK || status == GCONV_EMPTY_INPUT) - && data.outbuf[-1] == '\0') + if ((status == __GCONV_OK || status == __GCONV_EMPTY_INPUT) + && data.__outbuf[-1] == '\0') /* Don't count the NUL character in. */ --result; } @@ -98,25 +100,23 @@ __wcsnrtombs (dst, src, nwc, len, ps) of the string. */ size_t dummy; - data.outbuf = dst; - data.outbufend = dst + len; + data.__outbuf = dst; + data.__outbufend = dst + len; - status = (*__wcsmbs_gconv_fcts.tomb->fct) (__wcsmbs_gconv_fcts.tomb, - &data, - (const unsigned char **) src, - (const unsigned char *) srcend, - &dummy, 0); + status = (*tomb->__fct) (__wcsmbs_gconv_fcts.tomb, &data, + (const unsigned char **) src, + (const unsigned char *) srcend, &dummy, 0); /* Count the number of bytes. */ - result = data.outbuf - (unsigned char *) dst; + result = data.__outbuf - (unsigned char *) dst; /* We have to determine whether the last character converted is the NUL character. */ - if ((status == GCONV_OK || status == GCONV_EMPTY_INPUT) - && data.outbuf[-1] == '\0') + if ((status == __GCONV_OK || status == __GCONV_EMPTY_INPUT) + && data.__outbuf[-1] == '\0') { - assert (data.outbuf != (unsigned char *) dst); - assert (__mbsinit (data.statep)); + assert (data.__outbuf != (unsigned char *) dst); + assert (__mbsinit (data.__statep)); *src = NULL; --result; } @@ -124,12 +124,13 @@ __wcsnrtombs (dst, src, nwc, len, ps) /* There must not be any problems with the conversion but illegal input characters. */ - assert (status == GCONV_OK || status == GCONV_EMPTY_INPUT - || status == GCONV_ILLEGAL_INPUT - || status == GCONV_INCOMPLETE_INPUT || status == GCONV_FULL_OUTPUT); + assert (status == __GCONV_OK || status == __GCONV_EMPTY_INPUT + || status == __GCONV_ILLEGAL_INPUT + || status == __GCONV_INCOMPLETE_INPUT + || status == __GCONV_FULL_OUTPUT); - if (status != GCONV_OK && status != GCONV_FULL_OUTPUT - && status != GCONV_EMPTY_INPUT) + if (status != __GCONV_OK && status != __GCONV_FULL_OUTPUT + && status != __GCONV_EMPTY_INPUT) { result = (size_t) -1; __set_errno (EILSEQ); diff --git a/wcsmbs/wcsrtombs.c b/wcsmbs/wcsrtombs.c index 0257599..5ab8481 100644 --- a/wcsmbs/wcsrtombs.c +++ b/wcsmbs/wcsrtombs.c @@ -1,6 +1,6 @@ -/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. +/* Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc. This file is part of the GNU C Library. - Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996. + Contributed by Ulrich Drepper <drepper@gnu.org>, 1996. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as @@ -40,19 +40,23 @@ __wcsrtombs (dst, src, len, ps) size_t len; mbstate_t *ps; { - struct gconv_step_data data; + struct __gconv_step_data data; int status; size_t result; + struct __gconv_step *tomb; /* Tell where we want the result. */ - data.invocation_counter = 0; - data.internal_use = 1; - data.is_last = 1; - data.statep = ps ?: &state; + data.__invocation_counter = 0; + data.__internal_use = 1; + data.__is_last = 1; + data.__statep = ps ?: &state; /* Make sure we use the correct function. */ update_conversion_ptrs (); + /* Get the structure with the function pointers. */ + tomb = __wcsmbs_gconv_fcts.tomb; + /* We have to handle DST == NULL special. */ if (dst == NULL) { @@ -62,27 +66,25 @@ __wcsrtombs (dst, src, len, ps) size_t dummy; result = 0; - data.outbufend = buf + sizeof (buf); + data.__outbufend = buf + sizeof (buf); do { - data.outbuf = buf; + data.__outbuf = buf; - status = (*__wcsmbs_gconv_fcts.tomb->fct) (__wcsmbs_gconv_fcts.tomb, - &data, - (const unsigned char **) &inbuf, - (const unsigned char *) srcend, - &dummy, 0); + status = (*tomb->__fct) (__wcsmbs_gconv_fcts.tomb, &data, + (const unsigned char **) &inbuf, + (const unsigned char *) srcend, &dummy, 0); /* Count the number of bytes. */ - result += data.outbuf - buf; + result += data.__outbuf - buf; } - while (status == GCONV_FULL_OUTPUT); + while (status == __GCONV_FULL_OUTPUT); - if (status == GCONV_OK || status == GCONV_EMPTY_INPUT) + if (status == __GCONV_OK || status == __GCONV_EMPTY_INPUT) { /* There better should be a NUL byte at the end. */ - assert (data.outbuf[-1] == '\0'); + assert (data.__outbuf[-1] == '\0'); /* Don't count the NUL character in. */ --result; } @@ -95,26 +97,24 @@ __wcsrtombs (dst, src, len, ps) const wchar_t *srcend = *src + __wcsnlen (*src, len * MB_CUR_MAX) + 1; size_t dummy; - data.outbuf = dst; - data.outbufend = dst + len; + data.__outbuf = dst; + data.__outbufend = dst + len; - status = (*__wcsmbs_gconv_fcts.tomb->fct) (__wcsmbs_gconv_fcts.tomb, - &data, - (const unsigned char **) src, - (const unsigned char *) srcend, - &dummy, 0); + status = (*tomb->__fct) (__wcsmbs_gconv_fcts.tomb, &data, + (const unsigned char **) src, + (const unsigned char *) srcend, &dummy, 0); /* Count the number of bytes. */ - result = data.outbuf - (unsigned char *) dst; + result = data.__outbuf - (unsigned char *) dst; /* We have to determine whether the last character converted is the NUL character. */ - if ((status == GCONV_OK || status == GCONV_EMPTY_INPUT - || status == GCONV_FULL_OUTPUT) - && data.outbuf[-1] == '\0') + if ((status == __GCONV_OK || status == __GCONV_EMPTY_INPUT + || status == __GCONV_FULL_OUTPUT) + && data.__outbuf[-1] == '\0') { - assert (data.outbuf != (unsigned char *) dst); - assert (__mbsinit (data.statep)); + assert (data.__outbuf != (unsigned char *) dst); + assert (__mbsinit (data.__statep)); *src = NULL; --result; } @@ -122,12 +122,13 @@ __wcsrtombs (dst, src, len, ps) /* There must not be any problems with the conversion but illegal input characters. */ - assert (status == GCONV_OK || status == GCONV_EMPTY_INPUT - || status == GCONV_ILLEGAL_INPUT - || status == GCONV_INCOMPLETE_INPUT || status == GCONV_FULL_OUTPUT); + assert (status == __GCONV_OK || status == __GCONV_EMPTY_INPUT + || status == __GCONV_ILLEGAL_INPUT + || status == __GCONV_INCOMPLETE_INPUT + || status == __GCONV_FULL_OUTPUT); - if (status != GCONV_OK && status != GCONV_FULL_OUTPUT - && status != GCONV_EMPTY_INPUT) + if (status != __GCONV_OK && status != __GCONV_FULL_OUTPUT + && status != __GCONV_EMPTY_INPUT) { result = (size_t) -1; __set_errno (EILSEQ); diff --git a/wcsmbs/wctob.c b/wcsmbs/wctob.c index 0fba46a..565cbea 100644 --- a/wcsmbs/wctob.c +++ b/wcsmbs/wctob.c @@ -29,19 +29,19 @@ wctob (c) wint_t c; { char buf[MB_LEN_MAX]; - struct gconv_step_data data; + struct __gconv_step_data data; wchar_t inbuf[1]; wchar_t *inptr = inbuf; size_t dummy; int status; /* Tell where we want the result. */ - data.outbuf = buf; - data.outbufend = buf + MB_LEN_MAX; - data.invocation_counter = 0; - data.internal_use = 1; - data.is_last = 1; - data.statep = &data.__state; + data.__outbuf = buf; + data.__outbufend = buf + MB_LEN_MAX; + data.__invocation_counter = 0; + data.__internal_use = 1; + data.__is_last = 1; + data.__statep = &data.__state; /* Make sure we start in the initial state. */ memset (&data.__state, '\0', sizeof (mbstate_t)); @@ -52,14 +52,14 @@ wctob (c) /* Create the input string. */ inbuf[0] = c; - status = (*__wcsmbs_gconv_fcts.tomb->fct) (__wcsmbs_gconv_fcts.tomb, &data, - (const unsigned char **) &inptr, - (const unsigned char *) &inbuf[1], - &dummy, 0); + status = (*__wcsmbs_gconv_fcts.tomb->__fct) (__wcsmbs_gconv_fcts.tomb, &data, + (const unsigned char **) &inptr, + (const unsigned char *) &inbuf[1], + &dummy, 0); /* The conversion failed or the output is too long. */ - if ((status != GCONV_OK && status != GCONV_FULL_OUTPUT - && status != GCONV_EMPTY_INPUT) - || data.outbuf != (unsigned char *) (buf + 1)) + if ((status != __GCONV_OK && status != __GCONV_FULL_OUTPUT + && status != __GCONV_EMPTY_INPUT) + || data.__outbuf != (unsigned char *) (buf + 1)) return EOF; return buf[0]; diff --git a/wcsmbs/wmemcpy.c b/wcsmbs/wmemcpy.c index 6133a5a..8530a71 100644 --- a/wcsmbs/wmemcpy.c +++ b/wcsmbs/wmemcpy.c @@ -1,6 +1,6 @@ -/* Copyright (C) 1996, 1997 Free Software Foundation, Inc. +/* Copyright (C) 1996, 1997, 1999 Free Software Foundation, Inc. This file is part of the GNU C Library. - Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996. + Contributed by Ulrich Drepper <drepper@gnu.org>, 1996. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as @@ -22,10 +22,11 @@ wchar_t * -wmemcpy (s1, s2, n) +__wmemcpy (s1, s2, n) wchar_t *s1; const wchar_t *s2; size_t n; { return (wchar_t *) memcpy ((char *) s1, (char *) s2, n * sizeof (wchar_t)); } +weak_alias (__wmemcpy, wmemcpy) diff --git a/wcsmbs/wmemmove.c b/wcsmbs/wmemmove.c index fc4cead..5d41601 100644 --- a/wcsmbs/wmemmove.c +++ b/wcsmbs/wmemmove.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996, 1997 Free Software Foundation, Inc. +/* Copyright (C) 1996, 1997, 1999 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper, <drepper@gnu.ai.mit.edu> @@ -22,10 +22,11 @@ wchar_t * -wmemmove (s1, s2, n) +__wmemmove (s1, s2, n) wchar_t *s1; const wchar_t *s2; size_t n; { return (wchar_t *) memmove ((char *) s1, (char *) s2, n * sizeof (wchar_t)); } +weak_alias (__wmemmove, wmemmove) diff --git a/wcsmbs/wmempcpy.c b/wcsmbs/wmempcpy.c new file mode 100644 index 0000000..46cb958 --- /dev/null +++ b/wcsmbs/wmempcpy.c @@ -0,0 +1,33 @@ +/* Copyright (C) 1999 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper <drepper@gnu.org>, 1999. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <wchar.h> +#include <string.h> + + +wchar_t * +__wmempcpy (s1, s2, n) + wchar_t *s1; + const wchar_t *s2; + size_t n; +{ + return (wchar_t *) __mempcpy ((char *) s1, (char *) s2, + n * sizeof (wchar_t)); +} +weak_alias (__wmempcpy, wmempcpy) |