*
* Private string definitions for CUPS.
*
- * Copyright 2007-2010 by Apple Inc.
+ * Copyright 2007-2011 by Apple Inc.
* Copyright 1997-2006 by Easy Software Products.
*
* These coded instructions, statements, and computer programs are the
# endif /* HAVE_BSTRING_H */
-/*
- * Stuff for WIN32 and OS/2...
- */
-
-# if defined(WIN32) || defined(__EMX__)
-# define strcasecmp _stricmp
-# define strncasecmp _strnicmp
-# endif /* WIN32 || __EMX__ */
-
-
/*
* C++ magic...
*/
} _cups_sp_item_t;
+/*
+ * Replacements for the ctype macros that are not affected by locale, since we
+ * really only care about testing for ASCII characters when parsing files, etc.
+ *
+ * The _CUPS_INLINE definition controls whether we get an inline function body,
+ * and external function body, or an external definition.
+ */
+
+# if defined(__GNUC__) || __STDC_VERSION__ >= 199901L
+# define _CUPS_INLINE static inline
+# elif defined(_MSC_VER)
+# define _CUPS_INLINE static __inline
+# elif defined(_CUPS_STRING_C_)
+# define _CUPS_INLINE
+# endif /* __GNUC__ || __STDC_VERSION__ */
+
+# ifdef _CUPS_INLINE
+_CUPS_INLINE int /* O - 1 on match, 0 otherwise */
+_cups_isalnum(int ch) /* I - Character to test */
+{
+ return ((ch >= '0' && ch <= '9') ||
+ (ch >= 'A' && ch <= 'Z') ||
+ (ch >= 'a' && ch <= 'z'));
+}
+
+_CUPS_INLINE int /* O - 1 on match, 0 otherwise */
+_cups_isalpha(int ch) /* I - Character to test */
+{
+ return ((ch >= 'A' && ch <= 'Z') ||
+ (ch >= 'a' && ch <= 'z'));
+}
+
+_CUPS_INLINE int /* O - 1 on match, 0 otherwise */
+_cups_isspace(int ch) /* I - Character to test */
+{
+ return (ch == ' ' || ch == '\f' || ch == '\n' || ch == '\r' || ch == '\t' ||
+ ch == '\v');
+}
+
+_CUPS_INLINE int /* O - 1 on match, 0 otherwise */
+_cups_isupper(int ch) /* I - Character to test */
+{
+ return (ch >= 'A' && ch <= 'Z');
+}
+
+_CUPS_INLINE int /* O - Converted character */
+_cups_tolower(int ch) /* I - Character to convert */
+{
+ return (_cups_isupper(ch) ? ch - 'A' + 'a' : ch);
+}
+# else
+extern int _cups_isalnum(int ch);
+extern int _cups_isalpha(int ch);
+extern int _cups_isspace(int ch);
+extern int _cups_isupper(int ch);
+extern int _cups_tolower(int ch);
+# endif /* _CUPS_INLINE */
+
+
/*
* Prototypes...
*/
# define strdup _cups_strdup
# endif /* !HAVE_STRDUP */
-# ifndef HAVE_STRCASECMP
extern int _cups_strcasecmp(const char *, const char *);
-# define strcasecmp _cups_strcasecmp
-# endif /* !HAVE_STRCASECMP */
-# ifndef HAVE_STRNCASECMP
extern int _cups_strncasecmp(const char *, const char *, size_t n);
-# define strncasecmp _cups_strncasecmp
-# endif /* !HAVE_STRNCASECMP */
# ifndef HAVE_STRLCAT
extern size_t _cups_strlcat(char *, const char *, size_t);