Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/posix/ctype.c

    r491e1ee r21abb9a  
    3838#include "ctype.h"
    3939
     40// TODO: propose for inclusion in libc
     41
    4042/**
    41  *
    42  * @param ch
     43 * Checks whether character is a hexadecimal digit.
     44 *
     45 * @param c
    4346 * @return
    4447 */
    45 int posix_isxdigit(int ch)
     48int posix_isxdigit(int c)
    4649{
    47         return isdigit(ch) ||
    48             (ch >= 'a' && ch <= 'f') ||
    49             (ch >= 'A' && ch <= 'F');
     50        return isdigit(c) ||
     51            (c >= 'a' && c <= 'f') ||
     52            (c >= 'A' && c <= 'F');
     53}
     54
     55/**
     56 * Checks whether character is a word separator.
     57 *
     58 * @param c
     59 * @return
     60 */
     61int posix_isblank(int c)
     62{
     63        return c == ' ' || c == '\t';
     64}
     65
     66/**
     67 * Checks whether character is a control character.
     68 *
     69 * @param c
     70 * @return
     71 */
     72int posix_iscntrl(int c)
     73{
     74        return c < 0x20 || c == 0x7E;
     75}
     76
     77/**
     78 * Checks whether character is any printing character except space.
     79 *
     80 * @param c
     81 * @return
     82 */
     83int posix_isgraph(int c)
     84{
     85        return posix_isprint(c) && c != ' ';
     86}
     87
     88/**
     89 * Checks whether character is a printing character.
     90 *
     91 * @param c
     92 * @return
     93 */
     94int posix_isprint(int c)
     95{
     96        return !posix_iscntrl(c);
     97}
     98
     99/**
     100 * Checks whether character is a punctuation.
     101 *
     102 * @param c
     103 * @return
     104 */
     105int posix_ispunct(int c)
     106{
     107        return !isspace(c) && !isalnum(c);
    50108}
    51109
Note: See TracChangeset for help on using the changeset viewer.