mirror of
https://github.com/moparisthebest/wget
synced 2024-07-03 16:38:41 -04:00
[svn] Applied Philipp Thomas's safe-ctype patch. Published in
<20010330025159.U21662@jeffreys.suse.de>.
This commit is contained in:
parent
f78e97c5b7
commit
1a6058b1ec
@ -1,3 +1,33 @@
|
|||||||
|
2001-03-09 Philipp Thomas <pthomas@suse.de>
|
||||||
|
|
||||||
|
* safe-ctype.h: New file. Locale independent ctype.h
|
||||||
|
replacement taken from libiberty.
|
||||||
|
safe-ctype.c: New file. Tables for above.
|
||||||
|
Makefile.in: Add safe-ctype$o to OBJS.
|
||||||
|
Add dependencies for safe-ctype$o.
|
||||||
|
cmpt.c: Remove include of ctype.h. Use ISSPACE instead
|
||||||
|
of isspace.
|
||||||
|
ftp-basic.c: Don't include ctype.h.
|
||||||
|
ftp-ls.c: Likewise.
|
||||||
|
ftp.c: Likewise.
|
||||||
|
headers.c: Likewise.
|
||||||
|
host.c: Likewise.
|
||||||
|
html-parse.c: Likewise.
|
||||||
|
html-url.c: Likewise.
|
||||||
|
http.c: Likewise.
|
||||||
|
init.c: Likewise.
|
||||||
|
main.c: Likewise. Set LC_CTYPE along with LC_MESSAGES.
|
||||||
|
netrc.c: Likewise.
|
||||||
|
recur.c: Likewise.
|
||||||
|
retr.c: Likewise.
|
||||||
|
snprintf.c: Replace ctype.h with safe-ctype.h. Use
|
||||||
|
ISDIGIT instead of isdigit.
|
||||||
|
sysdep.h: Remove defines of ctype macros as they aren't
|
||||||
|
needed for safe-ctype-h.
|
||||||
|
url.c: Don't include ctype.h.
|
||||||
|
utils.c: Likewise.
|
||||||
|
wget.h: Include safe-ctype.h.
|
||||||
|
|
||||||
2001-03-27 Dan Harkless <wget@harkless.org>
|
2001-03-27 Dan Harkless <wget@harkless.org>
|
||||||
|
|
||||||
* Makefile.in: Moved top_builddir out of "User configuration
|
* Makefile.in: Moved top_builddir out of "User configuration
|
||||||
|
@ -63,7 +63,7 @@ OBJ = $(ALLOCA) cmpt$o connect$o fnmatch$o ftp$o ftp-basic$o \
|
|||||||
ftp-ls$o $(OPIE_OBJ) getopt$o hash$o headers$o host$o \
|
ftp-ls$o $(OPIE_OBJ) getopt$o hash$o headers$o host$o \
|
||||||
html-parse$o html-url$o http$o init$o log$o main$o \
|
html-parse$o html-url$o http$o init$o log$o main$o \
|
||||||
$(MD5_OBJ) netrc$o rbuf$o recur$o retr$o snprintf$o \
|
$(MD5_OBJ) netrc$o rbuf$o recur$o retr$o snprintf$o \
|
||||||
$(SSL_OBJ) url$o utils$o version$o
|
$(SSL_OBJ) url$o utils$o version$o safe-ctype$o
|
||||||
|
|
||||||
.SUFFIXES:
|
.SUFFIXES:
|
||||||
.SUFFIXES: .c .o ._c ._o
|
.SUFFIXES: .c .o ._c ._o
|
||||||
@ -162,6 +162,7 @@ rbuf$o: wget.h rbuf.h connect.h
|
|||||||
recur$o: wget.h url.h recur.h utils.h retr.h ftp.h fnmatch.h host.h hash.h
|
recur$o: wget.h url.h recur.h utils.h retr.h ftp.h fnmatch.h host.h hash.h
|
||||||
retr$o: wget.h utils.h retr.h url.h recur.h ftp.h host.h connect.h hash.h
|
retr$o: wget.h utils.h retr.h url.h recur.h ftp.h host.h connect.h hash.h
|
||||||
snprintf$o:
|
snprintf$o:
|
||||||
|
safe-ctype$o: safe-ctype.h
|
||||||
url$o: wget.h utils.h url.h host.h
|
url$o: wget.h utils.h url.h host.h
|
||||||
utils$o: wget.h utils.h fnmatch.h hash.h
|
utils$o: wget.h utils.h fnmatch.h hash.h
|
||||||
version$o:
|
version$o:
|
||||||
|
@ -26,7 +26,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
|||||||
#else
|
#else
|
||||||
# include <strings.h>
|
# include <strings.h>
|
||||||
#endif /* HAVE_STRING_H */
|
#endif /* HAVE_STRING_H */
|
||||||
#include <ctype.h>
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#ifdef HAVE_UNISTD_H
|
#ifdef HAVE_UNISTD_H
|
||||||
@ -657,9 +656,9 @@ strptime_internal (buf, format, tm, decided)
|
|||||||
{
|
{
|
||||||
/* A white space in the format string matches 0 more or white
|
/* A white space in the format string matches 0 more or white
|
||||||
space in the input string. */
|
space in the input string. */
|
||||||
if (isspace (*fmt))
|
if (ISSPACE (*fmt))
|
||||||
{
|
{
|
||||||
while (isspace (*rp))
|
while (ISSPACE (*rp))
|
||||||
++rp;
|
++rp;
|
||||||
++fmt;
|
++fmt;
|
||||||
continue;
|
continue;
|
||||||
@ -851,7 +850,7 @@ strptime_internal (buf, format, tm, decided)
|
|||||||
case 'n':
|
case 'n':
|
||||||
case 't':
|
case 't':
|
||||||
/* Match any white space. */
|
/* Match any white space. */
|
||||||
while (isspace (*rp))
|
while (ISSPACE (*rp))
|
||||||
++rp;
|
++rp;
|
||||||
break;
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
|
@ -26,7 +26,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
|||||||
#else
|
#else
|
||||||
# include <strings.h>
|
# include <strings.h>
|
||||||
#endif
|
#endif
|
||||||
#include <ctype.h>
|
|
||||||
#ifdef HAVE_UNISTD_H
|
#ifdef HAVE_UNISTD_H
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -31,7 +31,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
|||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <ctype.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include "wget.h"
|
#include "wget.h"
|
||||||
|
@ -26,7 +26,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
|||||||
#else
|
#else
|
||||||
# include <strings.h>
|
# include <strings.h>
|
||||||
#endif
|
#endif
|
||||||
#include <ctype.h>
|
|
||||||
#ifdef HAVE_UNISTD_H
|
#ifdef HAVE_UNISTD_H
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -26,7 +26,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
|||||||
#else
|
#else
|
||||||
# include <strings.h>
|
# include <strings.h>
|
||||||
#endif
|
#endif
|
||||||
#include <ctype.h>
|
|
||||||
|
|
||||||
#include "wget.h"
|
#include "wget.h"
|
||||||
#include "connect.h"
|
#include "connect.h"
|
||||||
|
@ -21,7 +21,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <ctype.h>
|
|
||||||
#ifdef HAVE_STRING_H
|
#ifdef HAVE_STRING_H
|
||||||
# include <string.h>
|
# include <string.h>
|
||||||
#else
|
#else
|
||||||
|
@ -85,7 +85,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <ctype.h>
|
|
||||||
#ifdef HAVE_STRING_H
|
#ifdef HAVE_STRING_H
|
||||||
# include <string.h>
|
# include <string.h>
|
||||||
#else
|
#else
|
||||||
|
@ -26,7 +26,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
|||||||
# include <strings.h>
|
# include <strings.h>
|
||||||
#endif
|
#endif
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <ctype.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
|
@ -27,7 +27,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
|||||||
#else
|
#else
|
||||||
# include <strings.h>
|
# include <strings.h>
|
||||||
#endif
|
#endif
|
||||||
#include <ctype.h>
|
|
||||||
#ifdef HAVE_UNISTD_H
|
#ifdef HAVE_UNISTD_H
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -20,7 +20,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
|||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <ctype.h>
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#ifdef HAVE_UNISTD_H
|
#ifdef HAVE_UNISTD_H
|
||||||
|
@ -21,7 +21,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <ctype.h>
|
|
||||||
#ifdef HAVE_UNISTD_H
|
#ifdef HAVE_UNISTD_H
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
#endif /* HAVE_UNISTD_H */
|
#endif /* HAVE_UNISTD_H */
|
||||||
@ -90,6 +89,7 @@ i18n_initialize (void)
|
|||||||
makes http_atotm() malfunction. */
|
makes http_atotm() malfunction. */
|
||||||
#ifdef LC_MESSAGES
|
#ifdef LC_MESSAGES
|
||||||
setlocale (LC_MESSAGES, "");
|
setlocale (LC_MESSAGES, "");
|
||||||
|
setlocale (LC_CTYPE, "");
|
||||||
#else
|
#else
|
||||||
setlocale (LC_ALL, "");
|
setlocale (LC_ALL, "");
|
||||||
#endif
|
#endif
|
||||||
|
@ -25,7 +25,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <ctype.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#ifdef HAVE_STRING_H
|
#ifdef HAVE_STRING_H
|
||||||
# include <string.h>
|
# include <string.h>
|
||||||
|
@ -31,7 +31,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
|||||||
#endif /* HAVE_UNISTD_H */
|
#endif /* HAVE_UNISTD_H */
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <ctype.h>
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include "wget.h"
|
#include "wget.h"
|
||||||
|
@ -31,7 +31,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
|||||||
#else
|
#else
|
||||||
# include <strings.h>
|
# include <strings.h>
|
||||||
#endif /* HAVE_STRING_H */
|
#endif /* HAVE_STRING_H */
|
||||||
#include <ctype.h>
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include "wget.h"
|
#include "wget.h"
|
||||||
|
163
src/safe-ctype.c
Normal file
163
src/safe-ctype.c
Normal file
@ -0,0 +1,163 @@
|
|||||||
|
/* <ctype.h> replacement macros.
|
||||||
|
|
||||||
|
Copyright (C) 2000 Free Software Foundation, Inc.
|
||||||
|
Contributed by Zack Weinberg <zackw@stanford.edu>.
|
||||||
|
|
||||||
|
This file is part of the libiberty library.
|
||||||
|
Libiberty 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.
|
||||||
|
|
||||||
|
Libiberty 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 libiberty; see the file COPYING.LIB. If
|
||||||
|
not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
/* This is a compatible replacement of the standard C library's <ctype.h>
|
||||||
|
with the following properties:
|
||||||
|
|
||||||
|
- Implements all isxxx() macros required by C99.
|
||||||
|
- Also implements some character classes useful when
|
||||||
|
parsing C-like languages.
|
||||||
|
- Does not change behavior depending on the current locale.
|
||||||
|
- Behaves properly for all values in the range of a signed or
|
||||||
|
unsigned char. */
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
#include <safe-ctype.h>
|
||||||
|
#include <stdio.h> /* for EOF */
|
||||||
|
|
||||||
|
/* Shorthand */
|
||||||
|
#define bl _sch_isblank
|
||||||
|
#define cn _sch_iscntrl
|
||||||
|
#define di _sch_isdigit
|
||||||
|
#define is _sch_isidst
|
||||||
|
#define lo _sch_islower
|
||||||
|
#define nv _sch_isnvsp
|
||||||
|
#define pn _sch_ispunct
|
||||||
|
#define pr _sch_isprint
|
||||||
|
#define sp _sch_isspace
|
||||||
|
#define up _sch_isupper
|
||||||
|
#define vs _sch_isvsp
|
||||||
|
#define xd _sch_isxdigit
|
||||||
|
|
||||||
|
/* Masks. */
|
||||||
|
#define L lo|is |pr /* lower case letter */
|
||||||
|
#define XL lo|is|xd|pr /* lowercase hex digit */
|
||||||
|
#define U up|is |pr /* upper case letter */
|
||||||
|
#define XU up|is|xd|pr /* uppercase hex digit */
|
||||||
|
#define D di |xd|pr /* decimal digit */
|
||||||
|
#define P pn |pr /* punctuation */
|
||||||
|
#define _ pn|is |pr /* underscore */
|
||||||
|
|
||||||
|
#define C cn /* control character */
|
||||||
|
#define Z nv |cn /* NUL */
|
||||||
|
#define M nv|sp |cn /* cursor movement: \f \v */
|
||||||
|
#define V vs|sp |cn /* vertical space: \r \n */
|
||||||
|
#define T nv|sp|bl|cn /* tab */
|
||||||
|
#define S nv|sp|bl|pr /* space */
|
||||||
|
|
||||||
|
/* Are we ASCII? */
|
||||||
|
#if '\n' == 0x0A && ' ' == 0x20 && '0' == 0x30 \
|
||||||
|
&& 'A' == 0x41 && 'a' == 0x61 && '!' == 0x21 \
|
||||||
|
&& EOF == -1
|
||||||
|
|
||||||
|
const unsigned short _sch_istable[256] =
|
||||||
|
{
|
||||||
|
Z, C, C, C, C, C, C, C, /* NUL SOH STX ETX EOT ENQ ACK BEL */
|
||||||
|
C, T, V, M, M, V, C, C, /* BS HT LF VT FF CR SO SI */
|
||||||
|
C, C, C, C, C, C, C, C, /* DLE DC1 DC2 DC3 DC4 NAK SYN ETB */
|
||||||
|
C, C, C, C, C, C, C, C, /* CAN EM SUB ESC FS GS RS US */
|
||||||
|
S, P, P, P, P, P, P, P, /* SP ! " # $ % & ' */
|
||||||
|
P, P, P, P, P, P, P, P, /* ( ) * + , - . / */
|
||||||
|
D, D, D, D, D, D, D, D, /* 0 1 2 3 4 5 6 7 */
|
||||||
|
D, D, P, P, P, P, P, P, /* 8 9 : ; < = > ? */
|
||||||
|
P, XU, XU, XU, XU, XU, XU, U, /* @ A B C D E F G */
|
||||||
|
U, U, U, U, U, U, U, U, /* H I J K L M N O */
|
||||||
|
U, U, U, U, U, U, U, U, /* P Q R S T U V W */
|
||||||
|
U, U, U, P, P, P, P, _, /* X Y Z [ \ ] ^ _ */
|
||||||
|
P, XL, XL, XL, XL, XL, XL, L, /* ` a b c d e f g */
|
||||||
|
L, L, L, L, L, L, L, L, /* h i j k l m n o */
|
||||||
|
L, L, L, L, L, L, L, L, /* p q r s t u v w */
|
||||||
|
L, L, L, P, P, P, P, C, /* x y z { | } ~ DEL */
|
||||||
|
|
||||||
|
/* high half of unsigned char is locale-specific, so all tests are
|
||||||
|
false in "C" locale */
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
const unsigned char _sch_tolower[256] =
|
||||||
|
{
|
||||||
|
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
|
||||||
|
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
|
||||||
|
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
|
||||||
|
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
|
||||||
|
64,
|
||||||
|
|
||||||
|
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
|
||||||
|
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
|
||||||
|
|
||||||
|
91, 92, 93, 94, 95, 96,
|
||||||
|
|
||||||
|
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
|
||||||
|
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
|
||||||
|
|
||||||
|
123,124,125,126,127,
|
||||||
|
|
||||||
|
128,129,130,131, 132,133,134,135, 136,137,138,139, 140,141,142,143,
|
||||||
|
144,145,146,147, 148,149,150,151, 152,153,154,155, 156,157,158,159,
|
||||||
|
160,161,162,163, 164,165,166,167, 168,169,170,171, 172,173,174,175,
|
||||||
|
176,177,178,179, 180,181,182,183, 184,185,186,187, 188,189,190,191,
|
||||||
|
|
||||||
|
192,193,194,195, 196,197,198,199, 200,201,202,203, 204,205,206,207,
|
||||||
|
208,209,210,211, 212,213,214,215, 216,217,218,219, 220,221,222,223,
|
||||||
|
224,225,226,227, 228,229,230,231, 232,233,234,235, 236,237,238,239,
|
||||||
|
240,241,242,243, 244,245,246,247, 248,249,250,251, 252,253,254,255,
|
||||||
|
};
|
||||||
|
|
||||||
|
const unsigned char _sch_toupper[256] =
|
||||||
|
{
|
||||||
|
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
|
||||||
|
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
|
||||||
|
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
|
||||||
|
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
|
||||||
|
64,
|
||||||
|
|
||||||
|
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
|
||||||
|
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
|
||||||
|
|
||||||
|
91, 92, 93, 94, 95, 96,
|
||||||
|
|
||||||
|
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
|
||||||
|
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
|
||||||
|
|
||||||
|
123,124,125,126,127,
|
||||||
|
|
||||||
|
128,129,130,131, 132,133,134,135, 136,137,138,139, 140,141,142,143,
|
||||||
|
144,145,146,147, 148,149,150,151, 152,153,154,155, 156,157,158,159,
|
||||||
|
160,161,162,163, 164,165,166,167, 168,169,170,171, 172,173,174,175,
|
||||||
|
176,177,178,179, 180,181,182,183, 184,185,186,187, 188,189,190,191,
|
||||||
|
|
||||||
|
192,193,194,195, 196,197,198,199, 200,201,202,203, 204,205,206,207,
|
||||||
|
208,209,210,211, 212,213,214,215, 216,217,218,219, 220,221,222,223,
|
||||||
|
224,225,226,227, 228,229,230,231, 232,233,234,235, 236,237,238,239,
|
||||||
|
240,241,242,243, 244,245,246,247, 248,249,250,251, 252,253,254,255,
|
||||||
|
};
|
||||||
|
|
||||||
|
#else
|
||||||
|
#error "Unsupported host character set"
|
||||||
|
#endif /* not ASCII */
|
100
src/safe-ctype.h
Normal file
100
src/safe-ctype.h
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
/* <ctype.h> replacement macros.
|
||||||
|
|
||||||
|
Copyright (C) 2000 Free Software Foundation, Inc.
|
||||||
|
Contributed by Zack Weinberg <zackw@stanford.edu>.
|
||||||
|
|
||||||
|
This file is part of the libiberty library.
|
||||||
|
Libiberty 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.
|
||||||
|
|
||||||
|
Libiberty 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 libiberty; see the file COPYING.LIB. If
|
||||||
|
not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
/* This is a compatible replacement of the standard C library's <ctype.h>
|
||||||
|
with the following properties:
|
||||||
|
|
||||||
|
- Implements all isxxx() macros required by C99.
|
||||||
|
- Also implements some character classes useful when
|
||||||
|
parsing C-like languages.
|
||||||
|
- Does not change behavior depending on the current locale.
|
||||||
|
- Behaves properly for all values in the range of a signed or
|
||||||
|
unsigned char.
|
||||||
|
|
||||||
|
To avoid conflicts, this header defines the isxxx functions in upper
|
||||||
|
case, e.g. ISALPHA not isalpha. */
|
||||||
|
|
||||||
|
#ifndef SAFE_CTYPE_H
|
||||||
|
#define SAFE_CTYPE_H
|
||||||
|
|
||||||
|
#ifdef isalpha
|
||||||
|
#error "safe-ctype.h and ctype.h may not be used simultaneously"
|
||||||
|
#else
|
||||||
|
|
||||||
|
/* Categories. */
|
||||||
|
|
||||||
|
enum {
|
||||||
|
/* In C99 */
|
||||||
|
_sch_isblank = 0x0001, /* space \t */
|
||||||
|
_sch_iscntrl = 0x0002, /* nonprinting characters */
|
||||||
|
_sch_isdigit = 0x0004, /* 0-9 */
|
||||||
|
_sch_islower = 0x0008, /* a-z */
|
||||||
|
_sch_isprint = 0x0010, /* any printing character including ' ' */
|
||||||
|
_sch_ispunct = 0x0020, /* all punctuation */
|
||||||
|
_sch_isspace = 0x0040, /* space \t \n \r \f \v */
|
||||||
|
_sch_isupper = 0x0080, /* A-Z */
|
||||||
|
_sch_isxdigit = 0x0100, /* 0-9A-Fa-f */
|
||||||
|
|
||||||
|
/* Extra categories useful to cpplib. */
|
||||||
|
_sch_isidst = 0x0200, /* A-Za-z_ */
|
||||||
|
_sch_isvsp = 0x0400, /* \n \r */
|
||||||
|
_sch_isnvsp = 0x0800, /* space \t \f \v \0 */
|
||||||
|
|
||||||
|
/* Combinations of the above. */
|
||||||
|
_sch_isalpha = _sch_isupper|_sch_islower, /* A-Za-z */
|
||||||
|
_sch_isalnum = _sch_isalpha|_sch_isdigit, /* A-Za-z0-9 */
|
||||||
|
_sch_isidnum = _sch_isidst|_sch_isdigit, /* A-Za-z0-9_ */
|
||||||
|
_sch_isgraph = _sch_isalnum|_sch_ispunct, /* isprint and not space */
|
||||||
|
_sch_iscppsp = _sch_isvsp|_sch_isnvsp /* isspace + \0 */
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Character classification. */
|
||||||
|
extern const unsigned short _sch_istable[256];
|
||||||
|
|
||||||
|
#define _sch_test(c, bit) (_sch_istable[(c) & 0xff] & (bit))
|
||||||
|
|
||||||
|
#define ISALPHA(c) _sch_test(c, _sch_isalpha)
|
||||||
|
#define ISALNUM(c) _sch_test(c, _sch_isalnum)
|
||||||
|
#define ISBLANK(c) _sch_test(c, _sch_isblank)
|
||||||
|
#define ISCNTRL(c) _sch_test(c, _sch_iscntrl)
|
||||||
|
#define ISDIGIT(c) _sch_test(c, _sch_isdigit)
|
||||||
|
#define ISGRAPH(c) _sch_test(c, _sch_isgraph)
|
||||||
|
#define ISLOWER(c) _sch_test(c, _sch_islower)
|
||||||
|
#define ISPRINT(c) _sch_test(c, _sch_isprint)
|
||||||
|
#define ISPUNCT(c) _sch_test(c, _sch_ispunct)
|
||||||
|
#define ISSPACE(c) _sch_test(c, _sch_isspace)
|
||||||
|
#define ISUPPER(c) _sch_test(c, _sch_isupper)
|
||||||
|
#define ISXDIGIT(c) _sch_test(c, _sch_isxdigit)
|
||||||
|
|
||||||
|
#define ISIDNUM(c) _sch_test(c, _sch_isidnum)
|
||||||
|
#define ISIDST(c) _sch_test(c, _sch_isidst)
|
||||||
|
#define IS_VSPACE(c) _sch_test(c, _sch_isvsp)
|
||||||
|
#define IS_NVSPACE(c) _sch_test(c, _sch_isnvsp)
|
||||||
|
#define IS_SPACE_OR_NUL(c) _sch_test(c, _sch_iscppsp)
|
||||||
|
|
||||||
|
/* Character transformation. */
|
||||||
|
extern const unsigned char _sch_toupper[256];
|
||||||
|
extern const unsigned char _sch_tolower[256];
|
||||||
|
#define TOUPPER(c) _sch_toupper[(c) & 0xff]
|
||||||
|
#define TOLOWER(c) _sch_tolower[(c) & 0xff]
|
||||||
|
|
||||||
|
#endif /* no ctype.h */
|
||||||
|
#endif /* SAFE_CTYPE_H */
|
@ -78,9 +78,9 @@
|
|||||||
#if !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF)
|
#if !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF)
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <stdio.h> /* for NULL */
|
#include <stdio.h> /* for NULL */
|
||||||
|
#include <safe-ctype.h>
|
||||||
|
|
||||||
/* varargs declarations: */
|
/* varargs declarations: */
|
||||||
|
|
||||||
@ -227,7 +227,7 @@ static int dopr (char *buffer, size_t maxlen, const char *format, va_list args)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DP_S_MIN:
|
case DP_S_MIN:
|
||||||
if (isdigit(ch))
|
if (ISDIGIT(ch))
|
||||||
{
|
{
|
||||||
min = 10*min + char_to_int (ch);
|
min = 10*min + char_to_int (ch);
|
||||||
ch = *format++;
|
ch = *format++;
|
||||||
@ -251,7 +251,7 @@ static int dopr (char *buffer, size_t maxlen, const char *format, va_list args)
|
|||||||
state = DP_S_MOD;
|
state = DP_S_MOD;
|
||||||
break;
|
break;
|
||||||
case DP_S_MAX:
|
case DP_S_MAX:
|
||||||
if (isdigit(ch))
|
if (ISDIGIT(ch))
|
||||||
{
|
{
|
||||||
if (max < 0)
|
if (max < 0)
|
||||||
max = 0;
|
max = 0;
|
||||||
|
20
src/sysdep.h
20
src/sysdep.h
@ -125,26 +125,6 @@ do { \
|
|||||||
# define VERY_LONG_FORMAT "%llu"
|
# define VERY_LONG_FORMAT "%llu"
|
||||||
#endif /* use long long */
|
#endif /* use long long */
|
||||||
|
|
||||||
/* OK, now define a decent interface to ctype macros. The regular
|
|
||||||
ones misfire when you feed them chars > 127, as they understand
|
|
||||||
them as "negative", which results in out-of-bound access at
|
|
||||||
table-lookup, yielding random results. This is, of course, totally
|
|
||||||
bogus. One way to "solve" this is to use `unsigned char'
|
|
||||||
everywhere, but it is nearly impossible to do that cleanly, because
|
|
||||||
all of the library functions and system calls accept `char'.
|
|
||||||
|
|
||||||
Thus we define our wrapper macros which simply cast the argument to
|
|
||||||
unsigned char before passing it to the <ctype.h> macro. These
|
|
||||||
versions are used consistently across the code. */
|
|
||||||
#define ISASCII(x) isascii ((unsigned char)(x))
|
|
||||||
#define ISALPHA(x) isalpha ((unsigned char)(x))
|
|
||||||
#define ISALNUM(x) isalnum ((unsigned char)(x))
|
|
||||||
#define ISSPACE(x) isspace ((unsigned char)(x))
|
|
||||||
#define ISDIGIT(x) isdigit ((unsigned char)(x))
|
|
||||||
#define ISXDIGIT(x) isxdigit ((unsigned char)(x))
|
|
||||||
#define TOUPPER(x) toupper ((unsigned char)(x))
|
|
||||||
#define TOLOWER(x) tolower ((unsigned char)(x))
|
|
||||||
|
|
||||||
/* Defined in cmpt.c: */
|
/* Defined in cmpt.c: */
|
||||||
#ifndef HAVE_STRERROR
|
#ifndef HAVE_STRERROR
|
||||||
char *strerror ();
|
char *strerror ();
|
||||||
|
@ -26,7 +26,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
|||||||
#else
|
#else
|
||||||
# include <strings.h>
|
# include <strings.h>
|
||||||
#endif
|
#endif
|
||||||
#include <ctype.h>
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#ifdef HAVE_UNISTD_H
|
#ifdef HAVE_UNISTD_H
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
|
@ -26,7 +26,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
|||||||
#else /* not HAVE_STRING_H */
|
#else /* not HAVE_STRING_H */
|
||||||
# include <strings.h>
|
# include <strings.h>
|
||||||
#endif /* not HAVE_STRING_H */
|
#endif /* not HAVE_STRING_H */
|
||||||
#include <ctype.h>
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#ifdef HAVE_UNISTD_H
|
#ifdef HAVE_UNISTD_H
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
|
@ -66,6 +66,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
|||||||
/* Include these, so random files need not include them. */
|
/* Include these, so random files need not include them. */
|
||||||
#include "sysdep.h"
|
#include "sysdep.h"
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
|
/* locale independent replacement for ctype.h */
|
||||||
|
#include "safe-ctype.h"
|
||||||
|
|
||||||
#define DO_NOTHING do {} while (0)
|
#define DO_NOTHING do {} while (0)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user