[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
c-ctype tweak
From: |
Bruno Haible |
Subject: |
c-ctype tweak |
Date: |
Wed, 11 Oct 2006 14:37:37 +0200 |
User-agent: |
KMail/1.9.1 |
This patch makes it possible to #define c_isascii etc. to alias names.
2006-10-10 Bruno Haible <address@hidden>
Make it possible to #define c_isascii to an alias.
* lib/c-ctype.h: Don't define the macros if NO_C_CTYPE_MACROS is
defined. Undefine the macros before defining them, to avoid gcc
warnings.
* lib/c-ctype.c: Include config.h. Don't undefine the macros; instead,
define NO_C_CTYPE_MACROS early.
*** c-ctype.h 2006-07-30 19:03:34.000000000 +0200
--- c-ctype.h 2006-10-11 03:31:51.000000000 +0200
***************
*** 5,11 ****
<ctype.h> functions' behaviour depends on the current locale set via
setlocale.
! Copyright (C) 2000-2003 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
--- 5,11 ----
<ctype.h> functions' behaviour depends on the current locale set via
setlocale.
! Copyright (C) 2000-2003, 2006 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
***************
*** 117,126 ****
extern int c_toupper (int c);
! #if defined __GNUC__ && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__
/* ASCII optimizations. */
#define c_isascii(c) \
({ int __c = (c); \
(__c >= 0x00 && __c <= 0x7f); \
--- 117,127 ----
extern int c_toupper (int c);
! #if defined __GNUC__ && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__ &&
!defined NO_C_CTYPE_MACROS
/* ASCII optimizations. */
+ #undef c_isascii
#define c_isascii(c) \
({ int __c = (c); \
(__c >= 0x00 && __c <= 0x7f); \
***************
*** 129,140 ****
--- 130,143 ----
#if C_CTYPE_CONSECUTIVE_DIGITS \
&& C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
#if C_CTYPE_ASCII
+ #undef c_isalnum
#define c_isalnum(c) \
({ int __c = (c); \
((__c >= '0' && __c <= '9') \
|| ((__c & ~0x20) >= 'A' && (__c & ~0x20) <= 'Z')); \
})
#else
+ #undef c_isalnum
#define c_isalnum(c) \
({ int __c = (c); \
((__c >= '0' && __c <= '9') \
***************
*** 146,156 ****
--- 149,161 ----
#if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
#if C_CTYPE_ASCII
+ #undef c_isalpha
#define c_isalpha(c) \
({ int __c = (c); \
((__c & ~0x20) >= 'A' && (__c & ~0x20) <= 'Z'); \
})
#else
+ #undef c_isalpha
#define c_isalpha(c) \
({ int __c = (c); \
((__c >= 'A' && __c <= 'Z') || (__c >= 'a' && __c <= 'z')); \
***************
*** 158,169 ****
--- 163,176 ----
#endif
#endif
+ #undef c_isblank
#define c_isblank(c) \
({ int __c = (c); \
(__c == ' ' || __c == '\t'); \
})
#if C_CTYPE_ASCII
+ #undef c_iscntrl
#define c_iscntrl(c) \
({ int __c = (c); \
((__c & ~0x1f) == 0 || __c == 0x7f); \
***************
*** 171,176 ****
--- 178,184 ----
#endif
#if C_CTYPE_CONSECUTIVE_DIGITS
+ #undef c_isdigit
#define c_isdigit(c) \
({ int __c = (c); \
(__c >= '0' && __c <= '9'); \
***************
*** 178,183 ****
--- 186,192 ----
#endif
#if C_CTYPE_CONSECUTIVE_LOWERCASE
+ #undef c_islower
#define c_islower(c) \
({ int __c = (c); \
(__c >= 'a' && __c <= 'z'); \
***************
*** 185,190 ****
--- 194,200 ----
#endif
#if C_CTYPE_ASCII
+ #undef c_isgraph
#define c_isgraph(c) \
({ int __c = (c); \
(__c >= '!' && __c <= '~'); \
***************
*** 192,197 ****
--- 202,208 ----
#endif
#if C_CTYPE_ASCII
+ #undef c_isprint
#define c_isprint(c) \
({ int __c = (c); \
(__c >= ' ' && __c <= '~'); \
***************
*** 199,210 ****
--- 210,223 ----
#endif
#if C_CTYPE_ASCII
+ #undef c_ispunct
#define c_ispunct(c) \
({ int _c = (c); \
(c_isgraph (_c) && ! c_isalnum (_c)); \
})
#endif
+ #undef c_isspace
#define c_isspace(c) \
({ int __c = (c); \
(__c == ' ' || __c == '\t' \
***************
*** 212,217 ****
--- 225,231 ----
})
#if C_CTYPE_CONSECUTIVE_UPPERCASE
+ #undef c_isupper
#define c_isupper(c) \
({ int __c = (c); \
(__c >= 'A' && __c <= 'Z'); \
***************
*** 221,232 ****
--- 235,248 ----
#if C_CTYPE_CONSECUTIVE_DIGITS \
&& C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
#if C_CTYPE_ASCII
+ #undef c_isxdigit
#define c_isxdigit(c) \
({ int __c = (c); \
((__c >= '0' && __c <= '9') \
|| ((__c & ~0x20) >= 'A' && (__c & ~0x20) <= 'F')); \
})
#else
+ #undef c_isxdigit
#define c_isxdigit(c) \
({ int __c = (c); \
((__c >= '0' && __c <= '9') \
***************
*** 237,246 ****
--- 253,264 ----
#endif
#if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
+ #undef c_tolower
#define c_tolower(c) \
({ int __c = (c); \
(__c >= 'A' && __c <= 'Z' ? __c - 'A' + 'a' : __c); \
})
+ #undef c_toupper
#define c_toupper(c) \
({ int __c = (c); \
(__c >= 'a' && __c <= 'z' ? __c - 'a' + 'A' : __c); \
*** c-ctype.c 2006-07-30 19:03:34.000000000 +0200
--- c-ctype.c 2006-10-11 03:32:38.000000000 +0200
***************
*** 1,6 ****
/* Character handling in C locale.
! Copyright 2000-2003 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
--- 1,6 ----
/* Character handling in C locale.
! Copyright 2000-2003, 2006 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
***************
*** 16,40 ****
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
/* Specification. */
#include "c-ctype.h"
- #undef c_isalnum
- #undef c_isalpha
- #undef c_isascii
- #undef c_isblank
- #undef c_iscntrl
- #undef c_isdigit
- #undef c_islower
- #undef c_isgraph
- #undef c_isprint
- #undef c_ispunct
- #undef c_isspace
- #undef c_isupper
- #undef c_isxdigit
- #undef c_tolower
- #undef c_toupper
-
/* The function isascii is not locale dependent. Its use in EBCDIC is
questionable. */
bool
--- 16,27 ----
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+ #include <config.h>
+
/* Specification. */
+ #define NO_C_CTYPE_MACROS
#include "c-ctype.h"
/* The function isascii is not locale dependent. Its use in EBCDIC is
questionable. */
bool
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- c-ctype tweak,
Bruno Haible <=