]> pd.if.org Git - pdclib/blobdiff - includes/ctype.h
Started out on v0.6.
[pdclib] / includes / ctype.h
index a9ecc256456fc02c9fd7577fbc103a9428d0d25f..a4ac53449bfd52e529860d95358dbe24ccf7d24e 100644 (file)
@@ -1,60 +1,93 @@
-// ----------------------------------------------------------------------------
-// $Id$
-// ----------------------------------------------------------------------------
-// Public Domain C Library - http://pdclib.sourceforge.net
-// This code is Public Domain. Use, modify, and redistribute at will.
-// ----------------------------------------------------------------------------
-// Provides functions for determining the locale-dependent type of a character,
-// plus locale-aware uppercase / lowercase conversions. (See also locale.h.)
-// ----------------------------------------------------------------------------
-
-#ifndef __CTYPE_H
-#define __CTYPE_H __CTYPE_H
-
-// ----------------------------------------------------------------------------
-// FUNCTIONS
-
-// returns nonzero if c is alphanumeric in the locale.
+/* $Id$ */
+
+/* 7.4 Character handling <ctype.h>
+
+   This file is part of the Public Domain C Library (PDCLib).
+   Permission is granted to use, modify, and / or redistribute at will.
+*/
+
+#ifndef _PDCLIB_CTYPE_H
+#define _PDCLIB_CTYPE_H _PDCLIB_CTYPE_H
+
+/* Character classification functions */
+
+/* Note that there is a difference between "whitespace" (any printing, non-
+   graph character, like horizontal and vertical tab), and "blank" (the literal
+   ' ' space character).
+
+   There will be masking macros for each of these later on, but right now I
+   focus on the functions only.
+*/
+
+/* Returns isalpha( c ) || isdigit( c ) */
 int isalnum( int c );
 
-// returns nonzero if c is alphabetic character in the locale.
+/* Returns isupper( c ) || islower( c ) in the "C" locale.
+   In any other locale, also returns true for a locale-specific set of
+   alphabetic characters which are neither control characters, digits,
+   punctation, or whitespace.
+*/
 int isalpha( int c );
 
-// returns nonzero if c is a horizontal blank in the locale.
+/* Returns true if the character is a whitespace. In the "C" locale, only ' '
+   and '\t' are considered whitespace.
+*/
 int isblank( int c );
 
-// returns nonzero if c is a control character in the locale.
+/* Returns true if the character is a control character. */
 int iscntrl( int c );
 
-// returns nonzero if c is a digit in the locale.
+/* Returns true if the character is a decimal digit. */
 int isdigit( int c );
 
-// returns nonzero if c is alphanumeric or a punctuation in the locale.
+/* Returns true for every printing character except space (' '). */
 int isgraph( int c );
 
-// returns nonzero if c is a lowercase alphabetic character in the locale.
+/* Returns true for lowercase letters in the "C" locale.
+   In any other locale, also returns true for a locale-specific set of
+   characters which are neither control characters, digits, punctation, or
+   space (' '). In a locale other than the "C" locale, a character might test
+   true for both islower() and isupper().
+*/
 int islower( int c );
 
-// returns nonzero if c is a printable character ( isgraph(  ) or isblank(  ) ) in
-// the locale.
+/* Returns true for every printing character including space (' '). */
 int isprint( int c );
 
-// returns nonzero if c is a punctuation in the locale.
+/* Returns true for every printing character that is neither whitespace
+   nor alphanumeric in the "C" locale. In any other locale, there might be
+   characters that are printing characters, but neither whitespace nor
+   alphanumeric.
+*/
 int ispunct( int c );
 
-// returns nonzero if c is a whitespace in the locale.
+/* Returns true for every standard whitespace character (' ', '\f', '\n', '\r',
+   '\t', '\v') in the "C" locale. In any other locale, also returns true for a
+   locale-specific set of characters for which isalnum() is false.
+*/ 
 int isspace( int c );
 
-// returns nonzero if c is an uppercase alphabetical character in the locale.
+/* Returns true for uppercase letters in the "C" locale.
+   In any other locale, also returns true for a locale-specific set of
+   characters which are neither control characters, digits, punctation, or
+   space (' '). In a locale other than the "C" locale, a character might test
+   true for both islower() and isupper().
+*/
 int isupper( int c );
 
-// returns nonzero if c is a hexedecimal digit in the locale.
+/* Returns true for any hexadecimal-digit character. */
 int isxdigit( int c );
 
-// returns lowercase equivalent for c in locale.
-int tolower( int c );
+/* Character case mapping functions */
+
+/* Converts an uppercase letter to a corresponding lowercase letter. Input that
+   is not an uppercase letter remains unchanged.
+*/
+int tolower( c );
 
-// returns uppercase equivalent for c in locale.
-int toupper( int c );
+/* Converts a lowercase letter to a corresponding uppercase letter. Input that
+   is not a lowercase letter remains unchanged.
+*/
+int toupper( c );
 
-#endif // __CTYPE_H
+#endif