Skip to content

Commit 9b3314e

Browse files
basavaraj-sm05mkj
authored andcommitted
dbctype.h: avoid the inline keyword for c89 compatibility
gcc and clang accept __inline__ in any mode, so use that where available, and fall back to plain static functions on other c89 compilers.
1 parent 86baa66 commit 9b3314e

1 file changed

Lines changed: 16 additions & 6 deletions

File tree

src/dbctype.h

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,38 @@
88
about ASCII ranges, so simple comparisons suffice. Bytes outside
99
0-127 never match. */
1010

11-
static inline int ascii_isdigit(char c) {
11+
/* c89 has no "inline" keyword. gcc and clang accept __inline__ in
12+
any mode; otherwise fall back to plain static functions. */
13+
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
14+
#define DBCTYPE_INLINE static inline
15+
#elif defined(__GNUC__)
16+
#define DBCTYPE_INLINE static __inline__
17+
#else
18+
#define DBCTYPE_INLINE static
19+
#endif
20+
21+
DBCTYPE_INLINE int ascii_isdigit(char c) {
1222
return c >= '0' && c <= '9';
1323
}
1424

15-
static inline int ascii_isalpha(char c) {
25+
DBCTYPE_INLINE int ascii_isalpha(char c) {
1626
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
1727
}
1828

19-
static inline int ascii_isalnum(char c) {
29+
DBCTYPE_INLINE int ascii_isalnum(char c) {
2030
return ascii_isalpha(c) || ascii_isdigit(c);
2131
}
2232

23-
static inline int ascii_isspace(char c) {
33+
DBCTYPE_INLINE int ascii_isspace(char c) {
2434
return c == ' ' || c == '\t' || c == '\n'
2535
|| c == '\v' || c == '\f' || c == '\r';
2636
}
2737

28-
static inline int ascii_isprint(char c) {
38+
DBCTYPE_INLINE int ascii_isprint(char c) {
2939
return c >= 0x20 && c <= 0x7e;
3040
}
3141

32-
static inline char ascii_tolower(char c) {
42+
DBCTYPE_INLINE char ascii_tolower(char c) {
3343
if (c >= 'A' && c <= 'Z') {
3444
return c + ('a' - 'A');
3545
}

0 commit comments

Comments
 (0)