summaryrefslogtreecommitdiff
path: root/ctype
diff options
context:
space:
mode:
Diffstat (limited to 'ctype')
-rw-r--r--ctype/Makefile2
-rw-r--r--ctype/ctype-extn.c78
-rw-r--r--ctype/ctype-info.c28
-rw-r--r--ctype/ctype.c60
-rw-r--r--ctype/ctype.h79
-rw-r--r--ctype/ctype_l.c49
-rw-r--r--ctype/test_ctype.c35
7 files changed, 245 insertions, 86 deletions
diff --git a/ctype/Makefile b/ctype/Makefile
index f76edf0abd..a17ce2c445 100644
--- a/ctype/Makefile
+++ b/ctype/Makefile
@@ -21,7 +21,7 @@
#
subdir := ctype
-routines := ctype ctype-extn
+routines := ctype ctype-extn ctype_l
aux := ctype-info
tests := test_ctype
diff --git a/ctype/ctype-extn.c b/ctype/ctype-extn.c
index ccf5552c85..d229f60b77 100644
--- a/ctype/ctype-extn.c
+++ b/ctype/ctype-extn.c
@@ -1,32 +1,68 @@
-/* Copyright (C) 1991 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+/* Copyright (C) 1991, 1997 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 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.
+ 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., 675 Mass Ave,
-Cambridge, MA 02139, USA. */
-
-#include <ansidecl.h>
+ 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. */
#define __NO_CTYPE
#include <ctype.h>
/* Real function versions of the non-ANSI ctype functions. */
-int DEFUN(isblank, (c), int c) { return __isctype ((c), _ISblank); }
+int
+isblank (int c)
+{
+ return __isctype (c, _ISblank);
+}
+
+int
+_tolower (int c)
+{
+ return __tolower (c);
+}
+int
+_toupper (int c)
+{
+ return __toupper (c);
+}
+
+int
+toascii (int c)
+{
+ return __toascii (c);
+}
+int
+isascii (int c)
+{
+ return __isascii (c);
+}
+
-int DEFUN(_tolower, (c), int c) { return __tolower(c); }
-int DEFUN(_toupper, (c), int c) { return __toupper(c); }
+int
+__isblank_l (int c, __locale_t l)
+{
+ return __isctype_l (c, _ISblank, l);
+}
-int DEFUN(toascii, (c), int c) { return __toascii(c); }
-int DEFUN(isascii, (c), int c) { return __isascii(c); }
+int
+__toascii_l (int c, __locale_t l)
+{
+ return __toascii (c);
+}
+int
+__isascii_l (int c, __locale_t l)
+{
+ return __isascii (c);
+}
diff --git a/ctype/ctype-info.c b/ctype/ctype-info.c
index 70f86ea4ee..a7688f7d00 100644
--- a/ctype/ctype-info.c
+++ b/ctype/ctype-info.c
@@ -1,20 +1,20 @@
-/* Copyright (C) 1991, 1992, 1995, 1996 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+/* Copyright (C) 1991, 1992, 1995, 1996, 1997 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 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.
+ 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., 675 Mass Ave,
-Cambridge, MA 02139, USA. */
+ 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 <ctype.h>
#include "../locale/localeinfo.h"
diff --git a/ctype/ctype.c b/ctype/ctype.c
index ee874de057..f9ceb35c08 100644
--- a/ctype/ctype.c
+++ b/ctype/ctype.c
@@ -1,22 +1,20 @@
-/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+/* Copyright (C) 1991, 1992, 1997 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 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.
+ 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., 675 Mass Ave,
-Cambridge, MA 02139, USA. */
-
-#include <ansidecl.h>
+ 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. */
#define __NO_CTYPE
#include <ctype.h>
@@ -24,28 +22,28 @@ Cambridge, MA 02139, USA. */
/* Provide real-function versions of all the ctype macros. */
#define func(name, type) \
- int DEFUN(name, (c), int c) { return __isctype(c, type); }
-
-func(isalnum, _ISalnum)
-func(isalpha, _ISalpha)
-func(iscntrl, _IScntrl)
-func(isdigit, _ISdigit)
-func(islower, _ISlower)
-func(isgraph, _ISgraph)
-func(isprint, _ISprint)
-func(ispunct, _ISpunct)
-func(isspace, _ISspace)
-func(isupper, _ISupper)
-func(isxdigit, _ISxdigit)
+ int name (int c) { return __isctype (c, type); }
+
+func (isalnum, _ISalnum)
+func (isalpha, _ISalpha)
+func (iscntrl, _IScntrl)
+func (isdigit, _ISdigit)
+func (islower, _ISlower)
+func (isgraph, _ISgraph)
+func (isprint, _ISprint)
+func (ispunct, _ISpunct)
+func (isspace, _ISspace)
+func (isupper, _ISupper)
+func (isxdigit, _ISxdigit)
int
-DEFUN(tolower, (c), int c)
+tolower (int c)
{
return __tolower (c);
}
int
-DEFUN(toupper, (c), int c)
+toupper (int c)
{
return __toupper (c);
}
diff --git a/ctype/ctype.h b/ctype/ctype.h
index 64ca26e04f..bd128445bc 100644
--- a/ctype/ctype.h
+++ b/ctype/ctype.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 92, 93, 95, 96 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 92, 93, 95, 96, 97 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
@@ -159,6 +159,83 @@ __exctype (_tolower);
#endif /* Not __NO_CTYPE. */
+
+#ifdef __USE_GNU
+/* The concept of one static locale per category is not very well
+ thought out. Many applications will need to process its data using
+ information from several different locales. Another application is
+ the implementation of the internationalization handling in the
+ upcoming ISO C++ standard library. To support this another set of
+ the functions using locale data exist which have an additional
+ argument.
+
+ Attention: all these functions are *not* standardized in any form.
+ This is a proof-of-concept implementation. */
+
+/* Structure for reentrant locale using functions. This is an
+ (almost) opaque type for the user level programs. */
+# include <xlocale.h>
+
+/* These definitions are similar to the ones above but all functions
+ take as an argument a handle for the locale which shall be used. */
+#define __isctype_l(c, type, locale) \
+ ((locale)->__ctype_b[(int) (c)] & (unsigned short int) type)
+
+#define __tolower_l(c, locale) ((int) (locale)->__ctype_tolower[(int) (c)])
+#define __toupper_l(c, locale) ((int) (locale)->__ctype_toupper[(int) (c)])
+
+#define __exctype_l(name) extern int name __P ((int, __locale_t))
+
+/* The following names are all functions:
+ int isCHARACTERISTIC(int c, locale_t *locale);
+ which return nonzero iff C has CHARACTERISTIC.
+ For the meaning of the characteristic names, see the `enum' above. */
+__exctype_l (__isalnum_l);
+__exctype_l (__isalpha_l);
+__exctype_l (__iscntrl_l);
+__exctype_l (__isdigit_l);
+__exctype_l (__islower_l);
+__exctype_l (__isgraph_l);
+__exctype_l (__isprint_l);
+__exctype_l (__ispunct_l);
+__exctype_l (__isspace_l);
+__exctype_l (__isupper_l);
+__exctype_l (__isxdigit_l);
+
+__exctype_l (__isblank_l);
+
+
+/* Return the lowercase version of C in locale L. */
+extern int __tolower_l __P ((int __c, __locale_t __l));
+
+/* Return the uppercase version of C. */
+extern int __toupper_l __P ((int __c, __locale_t __l));
+
+
+#ifndef __NO_CTYPE
+#define __isalnum_l(c,l) __isctype_l((c), _ISalnum, (l))
+#define __isalpha_l(c,l) __isctype_l((c), _ISalpha, (l))
+#define __iscntrl_l(c,l) __isctype_l((c), _IScntrl, (l))
+#define __isdigit_l(c,l) __isctype_l((c), _ISdigit, (l))
+#define __islower_l(c,l) __isctype_l((c), _ISlower, (l))
+#define __isgraph_l(c,l) __isctype_l((c), _ISgraph, (l))
+#define __isprint_l(c,l) __isctype_l((c), _ISprint, (l))
+#define __ispunct_l(c,l) __isctype_l((c), _ISpunct, (l))
+#define __isspace_l(c,l) __isctype_l((c), _ISspace, (l))
+#define __isupper_l(c,l) __isctype_l((c), _ISupper, (l))
+#define __isxdigit_l(c,l) __isctype_l((c), _ISxdigit, (l))
+
+#define __isblank_l(c,l) __isctype_l((c), _ISblank, (l))
+
+#if defined(__USE_SVID) || defined(__USE_MISC) || defined(__USE_XOPEN)
+#define __isascii_l(c,l) __isascii(c)
+#define __toascii_l(c,l) __toascii(c)
+#endif
+
+#endif /* Not __NO_CTYPE. */
+
+#endif /* Use GNU. */
+
__END_DECLS
#endif /* ctype.h */
diff --git a/ctype/ctype_l.c b/ctype/ctype_l.c
new file mode 100644
index 0000000000..a1608df6e5
--- /dev/null
+++ b/ctype/ctype_l.c
@@ -0,0 +1,49 @@
+/* Copyright (C) 1991, 1992, 1997 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. */
+
+#define __NO_CTYPE
+#include <ctype.h>
+
+/* Provide real-function versions of all the ctype macros. */
+
+#define func(name, type) \
+ int name (int c, __locale_t l) { return __isctype_l (c, type, l); }
+
+func (__isalnum_l, _ISalnum)
+func (__isalpha_l, _ISalpha)
+func (__iscntrl_l, _IScntrl)
+func (__isdigit_l, _ISdigit)
+func (__islower_l, _ISlower)
+func (__isgraph_l, _ISgraph)
+func (__isprint_l, _ISprint)
+func (__ispunct_l, _ISpunct)
+func (__isspace_l, _ISspace)
+func (__isupper_l, _ISupper)
+func (__isxdigit_l, _ISxdigit)
+
+int
+(__tolower_l) (int c, __locale_t l)
+{
+ return __tolower_l (c, l);
+}
+
+int
+(__toupper_l) (int c, __locale_t l)
+{
+ return __toupper_l (c, l);
+}
diff --git a/ctype/test_ctype.c b/ctype/test_ctype.c
index de21b8adfe..a1f72492eb 100644
--- a/ctype/test_ctype.c
+++ b/ctype/test_ctype.c
@@ -1,22 +1,21 @@
-/* Copyright (C) 1991, 1994, 1996 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+/* Copyright (C) 1991, 1994, 1996, 1997 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 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.
+ 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., 675 Mass Ave,
-Cambridge, MA 02139, USA. */
+ 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 <ansidecl.h>
#include <limits.h>
#include <ctype.h>
#include <stdio.h>
@@ -30,7 +29,7 @@ Cambridge, MA 02139, USA. */
__inline
#endif
static void
-DEFUN(print_char, (c), unsigned char c)
+print_char (unsigned char c)
{
printf("%d/", (int) c);
if (isgraph(c))
@@ -40,9 +39,9 @@ DEFUN(print_char, (c), unsigned char c)
}
int
-DEFUN(main, (argc, argv), int argc AND char **argv)
+main (int argc, char **argv)
{
- register unsigned short int c;
+ unsigned short int c;
int lose = 0;
#define TRYEM do { \