diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2015-09-25 00:21:58 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2015-09-25 00:23:18 -0700 |
commit | 1657ba799a873a7758219dc0bdebf6ab91908fa2 (patch) | |
tree | 3605280690680eb218a5353dff1d981ae112593b /lib | |
parent | da38b6a7cdcdc7670a3e9088777b3f2829b08bbd (diff) | |
download | emacs-1657ba799a873a7758219dc0bdebf6ab91908fa2.tar.gz |
Merge from gnulib
This incorporates:
2015-09-25 c-ctype: rewrite to use inline functions
2015-09-24 maint: add coding cookies to non-ASCII sources
2015-09-24 gitlog-to-changelog: trim only trailing whitespaces
* build-aux/gitlog-to-changelog, doc/misc/texinfo.tex:
* lib/acl-internal.c, lib/acl-internal.h, lib/c-ctype.c:
* lib/c-ctype.h, lib/get-permissions.c, lib/qcopy-acl.c:
* lib/set-permissions.c:
Copy from gnulib.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/acl-internal.c | 2 | ||||
-rw-r--r-- | lib/acl-internal.h | 2 | ||||
-rw-r--r-- | lib/c-ctype.c | 394 | ||||
-rw-r--r-- | lib/c-ctype.h | 850 | ||||
-rw-r--r-- | lib/get-permissions.c | 2 | ||||
-rw-r--r-- | lib/qcopy-acl.c | 2 | ||||
-rw-r--r-- | lib/set-permissions.c | 2 |
7 files changed, 677 insertions, 577 deletions
diff --git a/lib/acl-internal.c b/lib/acl-internal.c index 1eaa671bd37..c1b70176ac0 100644 --- a/lib/acl-internal.c +++ b/lib/acl-internal.c @@ -1,4 +1,4 @@ -/* Test whether a file has a nontrivial access control list. +/* Test whether a file has a nontrivial ACL. -*- coding: utf-8 -*- Copyright (C) 2002-2003, 2005-2015 Free Software Foundation, Inc. diff --git a/lib/acl-internal.h b/lib/acl-internal.h index 38a4ab2eb3a..560d1464daa 100644 --- a/lib/acl-internal.h +++ b/lib/acl-internal.h @@ -1,4 +1,4 @@ -/* Internal implementation of access control lists. +/* Internal implementation of access control lists. -*- coding: utf-8 -*- Copyright (C) 2002-2003, 2005-2015 Free Software Foundation, Inc. diff --git a/lib/c-ctype.c b/lib/c-ctype.c index 1fb5fe675e9..5d9d4d87a61 100644 --- a/lib/c-ctype.c +++ b/lib/c-ctype.c @@ -1,395 +1,3 @@ -/* Character handling in C locale. - - Copyright 2000-2003, 2006, 2009-2015 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 -the Free Software Foundation; either version 3 of the License, or -(at your option) any later version. - -This program 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, see <http://www.gnu.org/licenses/>. */ - #include <config.h> - -/* Specification. */ -#define NO_C_CTYPE_MACROS +#define C_CTYPE_INLINE _GL_EXTERN_INLINE #include "c-ctype.h" - -/* The function isascii is not locale dependent. Its use in EBCDIC is - questionable. */ -bool -c_isascii (int c) -{ - return (c >= 0x00 && c <= 0x7f); -} - -bool -c_isalnum (int c) -{ -#if C_CTYPE_CONSECUTIVE_DIGITS \ - && C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE -#if C_CTYPE_ASCII - return ((c >= '0' && c <= '9') - || ((c & ~0x20) >= 'A' && (c & ~0x20) <= 'Z')); -#else - return ((c >= '0' && c <= '9') - || (c >= 'A' && c <= 'Z') - || (c >= 'a' && c <= 'z')); -#endif -#else - switch (c) - { - case '0': case '1': case '2': case '3': case '4': case '5': - case '6': case '7': case '8': case '9': - case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': - case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': - case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': - case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': - case 'Y': case 'Z': - case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': - case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': - case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': - case 's': case 't': case 'u': case 'v': case 'w': case 'x': - case 'y': case 'z': - return 1; - default: - return 0; - } -#endif -} - -bool -c_isalpha (int c) -{ -#if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE -#if C_CTYPE_ASCII - return ((c & ~0x20) >= 'A' && (c & ~0x20) <= 'Z'); -#else - return ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')); -#endif -#else - switch (c) - { - case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': - case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': - case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': - case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': - case 'Y': case 'Z': - case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': - case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': - case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': - case 's': case 't': case 'u': case 'v': case 'w': case 'x': - case 'y': case 'z': - return 1; - default: - return 0; - } -#endif -} - -bool -c_isblank (int c) -{ - return (c == ' ' || c == '\t'); -} - -bool -c_iscntrl (int c) -{ -#if C_CTYPE_ASCII - return ((c & ~0x1f) == 0 || c == 0x7f); -#else - switch (c) - { - case ' ': case '!': case '"': case '#': case '$': case '%': - case '&': case '\'': case '(': case ')': case '*': case '+': - case ',': case '-': case '.': case '/': - case '0': case '1': case '2': case '3': case '4': case '5': - case '6': case '7': case '8': case '9': - case ':': case ';': case '<': case '=': case '>': case '?': - case '@': - case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': - case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': - case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': - case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': - case 'Y': case 'Z': - case '[': case '\\': case ']': case '^': case '_': case '`': - case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': - case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': - case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': - case 's': case 't': case 'u': case 'v': case 'w': case 'x': - case 'y': case 'z': - case '{': case '|': case '}': case '~': - return 0; - default: - return 1; - } -#endif -} - -bool -c_isdigit (int c) -{ -#if C_CTYPE_CONSECUTIVE_DIGITS - return (c >= '0' && c <= '9'); -#else - switch (c) - { - case '0': case '1': case '2': case '3': case '4': case '5': - case '6': case '7': case '8': case '9': - return 1; - default: - return 0; - } -#endif -} - -bool -c_islower (int c) -{ -#if C_CTYPE_CONSECUTIVE_LOWERCASE - return (c >= 'a' && c <= 'z'); -#else - switch (c) - { - case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': - case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': - case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': - case 's': case 't': case 'u': case 'v': case 'w': case 'x': - case 'y': case 'z': - return 1; - default: - return 0; - } -#endif -} - -bool -c_isgraph (int c) -{ -#if C_CTYPE_ASCII - return (c >= '!' && c <= '~'); -#else - switch (c) - { - case '!': case '"': case '#': case '$': case '%': case '&': - case '\'': case '(': case ')': case '*': case '+': case ',': - case '-': case '.': case '/': - case '0': case '1': case '2': case '3': case '4': case '5': - case '6': case '7': case '8': case '9': - case ':': case ';': case '<': case '=': case '>': case '?': - case '@': - case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': - case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': - case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': - case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': - case 'Y': case 'Z': - case '[': case '\\': case ']': case '^': case '_': case '`': - case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': - case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': - case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': - case 's': case 't': case 'u': case 'v': case 'w': case 'x': - case 'y': case 'z': - case '{': case '|': case '}': case '~': - return 1; - default: - return 0; - } -#endif -} - -bool -c_isprint (int c) -{ -#if C_CTYPE_ASCII - return (c >= ' ' && c <= '~'); -#else - switch (c) - { - case ' ': case '!': case '"': case '#': case '$': case '%': - case '&': case '\'': case '(': case ')': case '*': case '+': - case ',': case '-': case '.': case '/': - case '0': case '1': case '2': case '3': case '4': case '5': - case '6': case '7': case '8': case '9': - case ':': case ';': case '<': case '=': case '>': case '?': - case '@': - case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': - case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': - case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': - case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': - case 'Y': case 'Z': - case '[': case '\\': case ']': case '^': case '_': case '`': - case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': - case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': - case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': - case 's': case 't': case 'u': case 'v': case 'w': case 'x': - case 'y': case 'z': - case '{': case '|': case '}': case '~': - return 1; - default: - return 0; - } -#endif -} - -bool -c_ispunct (int c) -{ -#if C_CTYPE_ASCII - return ((c >= '!' && c <= '~') - && !((c >= '0' && c <= '9') - || ((c & ~0x20) >= 'A' && (c & ~0x20) <= 'Z'))); -#else - switch (c) - { - case '!': case '"': case '#': case '$': case '%': case '&': - case '\'': case '(': case ')': case '*': case '+': case ',': - case '-': case '.': case '/': - case ':': case ';': case '<': case '=': case '>': case '?': - case '@': - case '[': case '\\': case ']': case '^': case '_': case '`': - case '{': case '|': case '}': case '~': - return 1; - default: - return 0; - } -#endif -} - -bool -c_isspace (int c) -{ - return (c == ' ' || c == '\t' - || c == '\n' || c == '\v' || c == '\f' || c == '\r'); -} - -bool -c_isupper (int c) -{ -#if C_CTYPE_CONSECUTIVE_UPPERCASE - return (c >= 'A' && c <= 'Z'); -#else - switch (c) - { - case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': - case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': - case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': - case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': - case 'Y': case 'Z': - return 1; - default: - return 0; - } -#endif -} - -bool -c_isxdigit (int c) -{ -#if C_CTYPE_CONSECUTIVE_DIGITS \ - && C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE -#if C_CTYPE_ASCII - return ((c >= '0' && c <= '9') - || ((c & ~0x20) >= 'A' && (c & ~0x20) <= 'F')); -#else - return ((c >= '0' && c <= '9') - || (c >= 'A' && c <= 'F') - || (c >= 'a' && c <= 'f')); -#endif -#else - switch (c) - { - case '0': case '1': case '2': case '3': case '4': case '5': - case '6': case '7': case '8': case '9': - case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': - case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': - return 1; - default: - return 0; - } -#endif -} - -int -c_tolower (int c) -{ -#if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE - return (c >= 'A' && c <= 'Z' ? c - 'A' + 'a' : c); -#else - switch (c) - { - case 'A': return 'a'; - case 'B': return 'b'; - case 'C': return 'c'; - case 'D': return 'd'; - case 'E': return 'e'; - case 'F': return 'f'; - case 'G': return 'g'; - case 'H': return 'h'; - case 'I': return 'i'; - case 'J': return 'j'; - case 'K': return 'k'; - case 'L': return 'l'; - case 'M': return 'm'; - case 'N': return 'n'; - case 'O': return 'o'; - case 'P': return 'p'; - case 'Q': return 'q'; - case 'R': return 'r'; - case 'S': return 's'; - case 'T': return 't'; - case 'U': return 'u'; - case 'V': return 'v'; - case 'W': return 'w'; - case 'X': return 'x'; - case 'Y': return 'y'; - case 'Z': return 'z'; - default: return c; - } -#endif -} - -int -c_toupper (int c) -{ -#if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE - return (c >= 'a' && c <= 'z' ? c - 'a' + 'A' : c); -#else - switch (c) - { - case 'a': return 'A'; - case 'b': return 'B'; - case 'c': return 'C'; - case 'd': return 'D'; - case 'e': return 'E'; - case 'f': return 'F'; - case 'g': return 'G'; - case 'h': return 'H'; - case 'i': return 'I'; - case 'j': return 'J'; - case 'k': return 'K'; - case 'l': return 'L'; - case 'm': return 'M'; - case 'n': return 'N'; - case 'o': return 'O'; - case 'p': return 'P'; - case 'q': return 'Q'; - case 'r': return 'R'; - case 's': return 'S'; - case 't': return 'T'; - case 'u': return 'U'; - case 'v': return 'V'; - case 'w': return 'W'; - case 'x': return 'X'; - case 'y': return 'Y'; - case 'z': return 'Z'; - default: return c; - } -#endif -} diff --git a/lib/c-ctype.h b/lib/c-ctype.h index 47644731782..50ebbb58293 100644 --- a/lib/c-ctype.h +++ b/lib/c-ctype.h @@ -25,6 +25,13 @@ along with this program; if not, see <http://www.gnu.org/licenses/>. */ #include <stdbool.h> +#ifndef _GL_INLINE_HEADER_BEGIN + #error "Please include config.h first." +#endif +_GL_INLINE_HEADER_BEGIN +#ifndef C_CTYPE_INLINE +# define C_CTYPE_INLINE _GL_INLINE +#endif #ifdef __cplusplus extern "C" { @@ -39,38 +46,6 @@ extern "C" { characters. */ -/* Check whether the ASCII optimizations apply. */ - -/* ANSI C89 (and ISO C99 5.2.1.3 too) already guarantees that - '0', '1', ..., '9' have consecutive integer values. */ -#define C_CTYPE_CONSECUTIVE_DIGITS 1 - -#if ('A' <= 'Z') \ - && ('A' + 1 == 'B') && ('B' + 1 == 'C') && ('C' + 1 == 'D') \ - && ('D' + 1 == 'E') && ('E' + 1 == 'F') && ('F' + 1 == 'G') \ - && ('G' + 1 == 'H') && ('H' + 1 == 'I') && ('I' + 1 == 'J') \ - && ('J' + 1 == 'K') && ('K' + 1 == 'L') && ('L' + 1 == 'M') \ - && ('M' + 1 == 'N') && ('N' + 1 == 'O') && ('O' + 1 == 'P') \ - && ('P' + 1 == 'Q') && ('Q' + 1 == 'R') && ('R' + 1 == 'S') \ - && ('S' + 1 == 'T') && ('T' + 1 == 'U') && ('U' + 1 == 'V') \ - && ('V' + 1 == 'W') && ('W' + 1 == 'X') && ('X' + 1 == 'Y') \ - && ('Y' + 1 == 'Z') -#define C_CTYPE_CONSECUTIVE_UPPERCASE 1 -#endif - -#if ('a' <= 'z') \ - && ('a' + 1 == 'b') && ('b' + 1 == 'c') && ('c' + 1 == 'd') \ - && ('d' + 1 == 'e') && ('e' + 1 == 'f') && ('f' + 1 == 'g') \ - && ('g' + 1 == 'h') && ('h' + 1 == 'i') && ('i' + 1 == 'j') \ - && ('j' + 1 == 'k') && ('k' + 1 == 'l') && ('l' + 1 == 'm') \ - && ('m' + 1 == 'n') && ('n' + 1 == 'o') && ('o' + 1 == 'p') \ - && ('p' + 1 == 'q') && ('q' + 1 == 'r') && ('r' + 1 == 's') \ - && ('s' + 1 == 't') && ('t' + 1 == 'u') && ('u' + 1 == 'v') \ - && ('v' + 1 == 'w') && ('w' + 1 == 'x') && ('x' + 1 == 'y') \ - && ('y' + 1 == 'z') -#define C_CTYPE_CONSECUTIVE_LOWERCASE 1 -#endif - #if (' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \ && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \ @@ -96,11 +71,99 @@ extern "C" { && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126) /* The character set is ASCII or one of its variants or extensions, not EBCDIC. Testing the value of '\n' and '\r' is not relevant. */ -#define C_CTYPE_ASCII 1 +# define C_CTYPE_ASCII 1 +#elif ! (' ' == '\x40' && '0' == '\xf0' \ + && 'A' == '\xc1' && 'J' == '\xd1' && 'S' == '\xe2' \ + && 'a' == '\x81' && 'j' == '\x91' && 's' == '\xa2') +# error "Only ASCII and EBCDIC are supported" +#endif + +#define _C_CTYPE_SIGNED_EBCDIC ('A' < 0) + +#if C_CTYPE_ASCII +# define _C_CTYPE_CNTRL \ + case '\x00': case '\x01': case '\x02': case '\x03': \ + case '\x04': case '\x05': case '\x06': case '\x07': \ + case '\x08': case '\x09': case '\x0a': case '\x0b': \ + case '\x0c': case '\x0d': case '\x0e': case '\x0f': \ + case '\x10': case '\x11': case '\x12': case '\x13': \ + case '\x14': case '\x15': case '\x16': case '\x17': \ + case '\x18': case '\x19': case '\x1a': case '\x1b': \ + case '\x1c': case '\x1d': case '\x1e': case '\x1f': \ + case '\x7f' +#else + /* Use EBCDIC code page 1047's assignments for ASCII control chars; + assume all EBCDIC code pages agree about these assignments. */ +# define _C_CTYPE_CNTRL \ + case '\x00': case '\x01': case '\x02': case '\x03': \ + case '\x05': case '\x07': case '\x0b': case '\x0c': \ + case '\x0d': case '\x0e': case '\x0f': case '\x10': \ + case '\x11': case '\x12': case '\x13': case '\x16': \ + case '\x18': case '\x19': case '\x1c': case '\x1d': \ + case '\x1e': case '\x1f': case '\x25': case '\x26': \ + case '\x27': case '\x2d': case '\x2e': case '\x2f': \ + case '\x32': case '\x37': case '\x3c': case '\x3d': \ + case '\x3f' #endif +/* Cases for hex letter digits, digits, lower, and upper, offset by N. */ + +#define _C_CTYPE_A_THRU_F_N(n) \ + case 'a' + (n): case 'b' + (n): case 'c' + (n): case 'd' + (n): \ + case 'e' + (n): case 'f' + (n): \ + case 'A' + (n): case 'B' + (n): case 'C' + (n): case 'D' + (n): \ + case 'E' + (n): case 'F' + (n) +#define _C_CTYPE_DIGIT_N(n) \ + case '0' + (n): case '1' + (n): case '2' + (n): case '3' + (n): \ + case '4' + (n): case '5' + (n): case '6' + (n): case '7' + (n): \ + case '8' + (n): case '9' + (n) +#define _C_CTYPE_LOWER_N(n) \ + case 'a' + (n): case 'b' + (n): case 'c' + (n): case 'd' + (n): \ + case 'e' + (n): case 'f' + (n): case 'g' + (n): case 'h' + (n): \ + case 'i' + (n): case 'j' + (n): case 'k' + (n): case 'l' + (n): \ + case 'm' + (n): case 'n' + (n): case 'o' + (n): case 'p' + (n): \ + case 'q' + (n): case 'r' + (n): case 's' + (n): case 't' + (n): \ + case 'u' + (n): case 'v' + (n): case 'w' + (n): case 'x' + (n): \ + case 'y' + (n): case 'z' + (n) +#define _C_CTYPE_UPPER_N(n) \ + case 'A' + (n): case 'B' + (n): case 'C' + (n): case 'D' + (n): \ + case 'E' + (n): case 'F' + (n): case 'G' + (n): case 'H' + (n): \ + case 'I' + (n): case 'J' + (n): case 'K' + (n): case 'L' + (n): \ + case 'M' + (n): case 'N' + (n): case 'O' + (n): case 'P' + (n): \ + case 'Q' + (n): case 'R' + (n): case 'S' + (n): case 'T' + (n): \ + case 'U' + (n): case 'V' + (n): case 'W' + (n): case 'X' + (n): \ + case 'Y' + (n): case 'Z' + (n) + +/* Given MACRO_N, expand to all the cases for the corresponding class. */ +#if _C_CTYPE_SIGNED_EBCDIC +# define _C_CTYPE_CASES(macro_n) macro_n (0): macro_n (256) +#else +# define _C_CTYPE_CASES(macro_n) macro_n (0) +#endif -/* Function declarations. */ +/* Cases for hex letter digits, digits, lower, and upper, with another + case for unsigned char if the original char is negative. */ + +#define _C_CTYPE_A_THRU_F _C_CTYPE_CASES (_C_CTYPE_A_THRU_F_N) +#define _C_CTYPE_DIGIT _C_CTYPE_CASES (_C_CTYPE_DIGIT_N) +#define _C_CTYPE_LOWER _C_CTYPE_CASES (_C_CTYPE_LOWER_N) +#define _C_CTYPE_UPPER _C_CTYPE_CASES (_C_CTYPE_UPPER_N) + +/* The punct class differs because some punctuation characters may be + negative while others are nonnegative. Instead of attempting to + define _C_CTYPE_PUNCT, define just the plain chars here, and do any + cases-plus-256 by hand after using this macro. */ +#define _C_CTYPE_PUNCT_PLAIN \ + case '!': case '"': case '#': case '$': \ + case '%': case '&': case '\'': case '(': \ + case ')': case '*': case '+': case ',': \ + case '-': case '.': case '/': case ':': \ + case ';': case '<': case '=': case '>': \ + case '?': case '@': case '[': case '\\': \ + case ']': case '^': case '_': case '`': \ + case '{': case '|': case '}': case '~' + +/* Function definitions. */ /* Unlike the functions in <ctype.h>, which require an argument in the range of the 'unsigned char' type, the functions here operate on values that are @@ -117,179 +180,608 @@ extern "C" { if (c_isalpha (*s)) ... */ -extern bool c_isascii (int c) _GL_ATTRIBUTE_CONST; /* not locale dependent */ +C_CTYPE_INLINE bool +c_isalnum (int c) +{ + switch (c) + { + _C_CTYPE_DIGIT: + _C_CTYPE_LOWER: + _C_CTYPE_UPPER: + return true; + + default: + return false; + } +} -extern bool c_isalnum (int c) _GL_ATTRIBUTE_CONST; -extern bool c_isalpha (int c) _GL_ATTRIBUTE_CONST; -extern bool c_isblank (int c) _GL_ATTRIBUTE_CONST; -extern bool c_iscntrl (int c) _GL_ATTRIBUTE_CONST; -extern bool c_isdigit (int c) _GL_ATTRIBUTE_CONST; -extern bool c_islower (int c) _GL_ATTRIBUTE_CONST; -extern bool c_isgraph (int c) _GL_ATTRIBUTE_CONST; -extern bool c_isprint (int c) _GL_ATTRIBUTE_CONST; -extern bool c_ispunct (int c) _GL_ATTRIBUTE_CONST; -extern bool c_isspace (int c) _GL_ATTRIBUTE_CONST; -extern bool c_isupper (int c) _GL_ATTRIBUTE_CONST; -extern bool c_isxdigit (int c) _GL_ATTRIBUTE_CONST; +C_CTYPE_INLINE bool +c_isalpha (int c) +{ + switch (c) + { + _C_CTYPE_LOWER: + _C_CTYPE_UPPER: + return true; + + default: + return false; + } +} -extern int c_tolower (int c) _GL_ATTRIBUTE_CONST; -extern int c_toupper (int c) _GL_ATTRIBUTE_CONST; +/* The function isascii is not locale dependent. + Its use in EBCDIC is questionable. */ +C_CTYPE_INLINE bool +c_isascii (int c) +{ + switch (c) + { + case ' ': + _C_CTYPE_CNTRL: + _C_CTYPE_DIGIT: + _C_CTYPE_LOWER: + _C_CTYPE_UPPER: + + _C_CTYPE_PUNCT_PLAIN: +#if '!' < 0 + case '!' + 256: +#endif +#if '"' < 0 + case '"' + 256: +#endif +#if '#' < 0 + case '#' + 256: +#endif +#if '$' < 0 + case '$' + 256: +#endif +#if '%' < 0 + case '%' + 256: +#endif +#if '&' < 0 + case '&' + 256: +#endif +#if '\'' < 0 + case '\'' + 256: +#endif +#if '(' < 0 + case '(' + 256: +#endif +#if ')' < 0 + case ')' + 256: +#endif +#if '*' < 0 + case '*' + 256: +#endif +#if '+' < 0 + case '+' + 256: +#endif +#if ',' < 0 + case ',' + 256: +#endif +#if '-' < 0 + case '-' + 256: +#endif +#if '.' < 0 + case '.' + 256: +#endif +#if '/' < 0 + case '/' + 256: +#endif +#if ':' < 0 + case ':' + 256: +#endif +#if ';' < 0 + case ';' + 256: +#endif +#if '<' < 0 + case '<' + 256: +#endif +#if '=' < 0 + case '=' + 256: +#endif +#if '>' < 0 + case '>' + 256: +#endif +#if '?' < 0 + case '?' + 256: +#endif +#if '@' < 0 + case '@' + 256: +#endif +#if '[' < 0 + case '[' + 256: +#endif +#if '\\' < 0 + case '\\' + 256: +#endif +#if ']' < 0 + case ']' + 256: +#endif +#if '^' < 0 + case '^' + 256: +#endif +#if '_' < 0 + case '_' + 256: +#endif +#if '`' < 0 + case '`' + 256: +#endif +#if '{' < 0 + case '{' + 256: +#endif +#if '|' < 0 + case '|' + 256: +#endif +#if '}' < 0 + case '}' + 256: +#endif +#if '~' < 0 + case '~' + 256: +#endif + return true; + default: + return false; + } +} -#if (defined __GNUC__ && !defined __STRICT_ANSI__ && defined __OPTIMIZE__ \ - && !defined __OPTIMIZE_SIZE__ && !defined NO_C_CTYPE_MACROS) +C_CTYPE_INLINE bool +c_isblank (int c) +{ + return c == ' ' || c == '\t'; +} -/* ASCII optimizations. */ +C_CTYPE_INLINE bool +c_iscntrl (int c) +{ + switch (c) + { + _C_CTYPE_CNTRL: + return true; + default: + return false; + } +} -#undef c_isascii -#define c_isascii(c) \ - ({ int __c = (c); \ - (__c >= 0x00 && __c <= 0x7f); \ - }) +C_CTYPE_INLINE bool +c_isdigit (int c) +{ + switch (c) + { + _C_CTYPE_DIGIT: + return true; + default: + return false; + } +} -#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') \ - || (__c >= 'A' && __c <= 'Z') \ - || (__c >= 'a' && __c <= 'z')); \ - }) +C_CTYPE_INLINE bool +c_isgraph (int c) +{ + switch (c) + { + _C_CTYPE_DIGIT: + _C_CTYPE_LOWER: + _C_CTYPE_UPPER: + + _C_CTYPE_PUNCT_PLAIN: +#if '!' < 0 + case '!' + 256: #endif +#if '"' < 0 + case '"' + 256: #endif - -#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')); \ - }) +#if '#' < 0 + case '#' + 256: +#endif +#if '$' < 0 + case '$' + 256: +#endif +#if '%' < 0 + case '%' + 256: +#endif +#if '&' < 0 + case '&' + 256: +#endif +#if '\'' < 0 + case '\'' + 256: +#endif +#if '(' < 0 + case '(' + 256: +#endif +#if ')' < 0 + case ')' + 256: +#endif +#if '*' < 0 + case '*' + 256: +#endif +#if '+' < 0 + case '+' + 256: +#endif +#if ',' < 0 + case ',' + 256: +#endif +#if '-' < 0 + case '-' + 256: +#endif +#if '.' < 0 + case '.' + 256: +#endif +#if '/' < 0 + case '/' + 256: +#endif +#if ':' < 0 + case ':' + 256: +#endif +#if ';' < 0 + case ';' + 256: +#endif +#if '<' < 0 + case '<' + 256: +#endif +#if '=' < 0 + case '=' + 256: +#endif +#if '>' < 0 + case '>' + 256: +#endif +#if '?' < 0 + case '?' + 256: +#endif +#if '@' < 0 + case '@' + 256: +#endif +#if '[' < 0 + case '[' + 256: +#endif +#if '\\' < 0 + case '\\' + 256: +#endif +#if ']' < 0 + case ']' + 256: +#endif +#if '^' < 0 + case '^' + 256: +#endif +#if '_' < 0 + case '_' + 256: +#endif +#if '`' < 0 + case '`' + 256: +#endif +#if '{' < 0 + case '{' + 256: +#endif +#if '|' < 0 + case '|' + 256: +#endif +#if '}' < 0 + case '}' + 256: #endif +#if '~' < 0 + case '~' + 256: #endif + return true; -#undef c_isblank -#define c_isblank(c) \ - ({ int __c = (c); \ - (__c == ' ' || __c == '\t'); \ - }) + default: + return false; + } +} -#if C_CTYPE_ASCII -#undef c_iscntrl -#define c_iscntrl(c) \ - ({ int __c = (c); \ - ((__c & ~0x1f) == 0 || __c == 0x7f); \ - }) -#endif +C_CTYPE_INLINE bool +c_islower (int c) +{ + switch (c) + { + _C_CTYPE_LOWER: + return true; + default: + return false; + } +} -#if C_CTYPE_CONSECUTIVE_DIGITS -#undef c_isdigit -#define c_isdigit(c) \ - ({ int __c = (c); \ - (__c >= '0' && __c <= '9'); \ - }) +C_CTYPE_INLINE bool +c_isprint (int c) +{ + switch (c) + { + case ' ': + _C_CTYPE_DIGIT: + _C_CTYPE_LOWER: + _C_CTYPE_UPPER: + + _C_CTYPE_PUNCT_PLAIN: +#if '!' < 0 + case '!' + 256: #endif - -#if C_CTYPE_CONSECUTIVE_LOWERCASE -#undef c_islower -#define c_islower(c) \ - ({ int __c = (c); \ - (__c >= 'a' && __c <= 'z'); \ - }) +#if '"' < 0 + case '"' + 256: #endif - -#if C_CTYPE_ASCII -#undef c_isgraph -#define c_isgraph(c) \ - ({ int __c = (c); \ - (__c >= '!' && __c <= '~'); \ - }) +#if '#' < 0 + case '#' + 256: #endif - -#if C_CTYPE_ASCII -#undef c_isprint -#define c_isprint(c) \ - ({ int __c = (c); \ - (__c >= ' ' && __c <= '~'); \ - }) +#if '$' < 0 + case '$' + 256: +#endif +#if '%' < 0 + case '%' + 256: +#endif +#if '&' < 0 + case '&' + 256: +#endif +#if '\'' < 0 + case '\'' + 256: +#endif +#if '(' < 0 + case '(' + 256: +#endif +#if ')' < 0 + case ')' + 256: +#endif +#if '*' < 0 + case '*' + 256: +#endif +#if '+' < 0 + case '+' + 256: +#endif +#if ',' < 0 + case ',' + 256: +#endif +#if '-' < 0 + case '-' + 256: +#endif +#if '.' < 0 + case '.' + 256: +#endif +#if '/' < 0 + case '/' + 256: +#endif +#if ':' < 0 + case ':' + 256: +#endif +#if ';' < 0 + case ';' + 256: #endif +#if '<' < 0 + case '<' + 256: +#endif +#if '=' < 0 + case '=' + 256: +#endif +#if '>' < 0 + case '>' + 256: +#endif +#if '?' < 0 + case '?' + 256: +#endif +#if '@' < 0 + case '@' + 256: +#endif +#if '[' < 0 + case '[' + 256: +#endif +#if '\\' < 0 + case '\\' + 256: +#endif +#if ']' < 0 + case ']' + 256: +#endif +#if '^' < 0 + case '^' + 256: +#endif +#if '_' < 0 + case '_' + 256: +#endif +#if '`' < 0 + case '`' + 256: +#endif +#if '{' < 0 + case '{' + 256: +#endif +#if '|' < 0 + case '|' + 256: +#endif +#if '}' < 0 + case '}' + 256: +#endif +#if '~' < 0 + case '~' + 256: +#endif + return true; -#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' \ - || __c == '\n' || __c == '\v' || __c == '\f' || __c == '\r'); \ - }) - -#if C_CTYPE_CONSECUTIVE_UPPERCASE -#undef c_isupper -#define c_isupper(c) \ - ({ int __c = (c); \ - (__c >= 'A' && __c <= 'Z'); \ - }) -#endif - -#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') \ - || (__c >= 'A' && __c <= 'F') \ - || (__c >= 'a' && __c <= 'f')); \ - }) + default: + return false; + } +} + +C_CTYPE_INLINE bool +c_ispunct (int c) +{ + switch (c) + { + _C_CTYPE_PUNCT_PLAIN: +#if '!' < 0 + case '!' + 256: +#endif +#if '"' < 0 + case '"' + 256: #endif +#if '#' < 0 + case '#' + 256: #endif +#if '$' < 0 + case '$' + 256: +#endif +#if '%' < 0 + case '%' + 256: +#endif +#if '&' < 0 + case '&' + 256: +#endif +#if '\'' < 0 + case '\'' + 256: +#endif +#if '(' < 0 + case '(' + 256: +#endif +#if ')' < 0 + case ')' + 256: +#endif +#if '*' < 0 + case '*' + 256: +#endif +#if '+' < 0 + case '+' + 256: +#endif +#if ',' < 0 + case ',' + 256: +#endif +#if '-' < 0 + case '-' + 256: +#endif +#if '.' < 0 + case '.' + 256: +#endif +#if '/' < 0 + case '/' + 256: +#endif +#if ':' < 0 + case ':' + 256: +#endif +#if ';' < 0 + case ';' + 256: +#endif +#if '<' < 0 + case '<' + 256: +#endif +#if '=' < 0 + case '=' + 256: +#endif +#if '>' < 0 + case '>' + 256: +#endif +#if '?' < 0 + case '?' + 256: +#endif +#if '@' < 0 + case '@' + 256: +#endif +#if '[' < 0 + case '[' + 256: +#endif +#if '\\' < 0 + case '\\' + 256: +#endif +#if ']' < 0 + case ']' + 256: +#endif +#if '^' < 0 + case '^' + 256: +#endif +#if '_' < 0 + case '_' + 256: +#endif +#if '`' < 0 + case '`' + 256: +#endif +#if '{' < 0 + case '{' + 256: +#endif +#if '|' < 0 + case '|' + 256: +#endif +#if '}' < 0 + case '}' + 256: +#endif +#if '~' < 0 + case '~' + 256: +#endif + return true; -#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); \ - }) + default: + return false; + } +} + +C_CTYPE_INLINE bool +c_isspace (int c) +{ + switch (c) + { + case ' ': case '\t': case '\n': case '\v': case '\f': case '\r': + return true; + default: + return false; + } +} + +C_CTYPE_INLINE bool +c_isupper (int c) +{ + switch (c) + { + _C_CTYPE_UPPER: + return true; + default: + return false; + } +} + +C_CTYPE_INLINE bool +c_isxdigit (int c) +{ + switch (c) + { + _C_CTYPE_DIGIT: + _C_CTYPE_A_THRU_F: + return true; + + default: + return false; + } +} + +C_CTYPE_INLINE int +c_tolower (int c) +{ + switch (c) + { + _C_CTYPE_UPPER_N (0): +#if _C_CTYPE_SIGNED_EBCDIC + c += 256; + /* Fall through. */ + _C_CTYPE_UPPER_N (256): #endif + return c - 'A' + 'a'; -#endif /* optimizing for speed */ + default: + return c; + } +} +C_CTYPE_INLINE int +c_toupper (int c) +{ + switch (c) + { + _C_CTYPE_LOWER_N (0): +#if _C_CTYPE_SIGNED_EBCDIC + c += 256; + /* Fall through. */ + _C_CTYPE_LOWER_N (256): +#endif + return c - 'a' + 'A'; + + default: + return c; + } +} #ifdef __cplusplus } #endif +_GL_INLINE_HEADER_END + #endif /* C_CTYPE_H */ diff --git a/lib/get-permissions.c b/lib/get-permissions.c index 459513c9251..9dfb0764ce4 100644 --- a/lib/get-permissions.c +++ b/lib/get-permissions.c @@ -1,4 +1,4 @@ -/* get-permissions.c - get permissions of a file +/* Get permissions of a file. -*- coding: utf-8 -*- Copyright (C) 2002-2003, 2005-2015 Free Software Foundation, Inc. diff --git a/lib/qcopy-acl.c b/lib/qcopy-acl.c index c4507424719..9db9033816d 100644 --- a/lib/qcopy-acl.c +++ b/lib/qcopy-acl.c @@ -1,4 +1,4 @@ -/* copy-acl.c - copy access control list from one file to another file +/* Copy access control list from one file to another. -*- coding: utf-8 -*- Copyright (C) 2002-2003, 2005-2015 Free Software Foundation, Inc. diff --git a/lib/set-permissions.c b/lib/set-permissions.c index 1aa5b4941c7..8e6ecf365d1 100644 --- a/lib/set-permissions.c +++ b/lib/set-permissions.c @@ -1,4 +1,4 @@ -/* set-permissions.c - set permissions of a file +/* Set permissions of a file. -*- coding: utf-8 -*- Copyright (C) 2002-2003, 2005-2015 Free Software Foundation, Inc. |