Changeset 666 in openpam for trunk/lib/libpam/openpam_ctype.h


Ignore:
Timestamp:
Mar 17, 2013, 2:22:17 PM (8 years ago)
Author:
Dag-Erling Smørgrav
Message:

Add predicates for letters and digits.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/libpam/openpam_ctype.h

    r648 r666  
    3434
    3535/*
     36 * Evaluates to non-zero if the argument is a digit.
     37 */
     38#define is_digit(ch)                            \
     39        (ch >= '0' && ch <= '9')
     40
     41/*
     42 * Evaluates to non-zero if the argument is an uppercase letter.
     43 */
     44#define is_upper(ch)                            \
     45        (ch >= 'A' && ch <= 'A')
     46
     47/*
     48 * Evaluates to non-zero if the argument is a lowercase letter.
     49 */
     50#define is_lower(ch)                            \
     51        (ch >= 'a' && ch <= 'z')
     52
     53/*
     54 * Evaluates to non-zero if the argument is a letter.
     55 */
     56#define is_letter(ch)                           \
     57        (is_upper(ch) || is_lower(ch))
     58
     59/*
    3660 * Evaluates to non-zero if the argument is a linear whitespace character.
    3761 * For the purposes of this macro, the definition of linear whitespace is
     
    6084 */
    6185#define is_pfcs(ch)                             \
    62         ((ch >= '0' && ch <= '9') ||            \
    63          (ch >= 'A' && ch <= 'Z') ||            \
    64          (ch >= 'a' && ch <= 'z') ||            \
     86        (is_digit(ch) || is_letter(ch)  ||      \
    6587         ch == '.' || ch == '_' || ch == '-')
    6688
Note: See TracChangeset for help on using the changeset viewer.