Skip to content

Commit

Permalink
COMMON: Add wrappers for iscntrl() and isgraph()
Browse files Browse the repository at this point in the history
  • Loading branch information
ccawley2011 authored and bluegr committed Jul 24, 2019
1 parent d1e0c91 commit 30edabf
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 13 deletions.
22 changes: 11 additions & 11 deletions common/util.cpp
Expand Up @@ -20,17 +20,7 @@
*
*/

#define FORBIDDEN_SYMBOL_EXCEPTION_isalnum
#define FORBIDDEN_SYMBOL_EXCEPTION_isalpha
#define FORBIDDEN_SYMBOL_EXCEPTION_isdigit
#define FORBIDDEN_SYMBOL_EXCEPTION_isxdigit
#define FORBIDDEN_SYMBOL_EXCEPTION_isnumber
#define FORBIDDEN_SYMBOL_EXCEPTION_islower
#define FORBIDDEN_SYMBOL_EXCEPTION_isspace
#define FORBIDDEN_SYMBOL_EXCEPTION_isupper
#define FORBIDDEN_SYMBOL_EXCEPTION_isprint
#define FORBIDDEN_SYMBOL_EXCEPTION_ispunct

#define FORBIDDEN_SYMBOL_EXCEPTION_ctype_h

#include "common/util.h"
#include "common/debug.h"
Expand Down Expand Up @@ -163,4 +153,14 @@ bool isPunct(int c) {
return ispunct((byte)c);
}

bool isCntrl(int c) {
ENSURE_ASCII_CHAR(c);
return iscntrl((byte)c);
}

bool isGraph(int c) {
ENSURE_ASCII_CHAR(c);
return isgraph((byte)c);
}

} // End of namespace Common
19 changes: 17 additions & 2 deletions common/util.h
Expand Up @@ -195,16 +195,31 @@ bool isUpper(int c);
*/
bool isPrint(int c);


/**
* Test whether the given character is a punctuation character,
* (i.e not alphanumeric.
* (i.e. not alphanumeric).
*
* @param c the character to test
* @return true if the character is punctuation, false otherwise.
*/
bool isPunct(int c);

/**
* Test whether the given character is a control character.
*
* @param c the character to test
* @return true if the character is a control character, false otherwise.
*/
bool isCntrl(int c);

/**
* Test whether the given character has a graphical representation.
*
* @param c the character to test
* @return true if the character is a graphic, false otherwise.
*/
bool isGraph(int c);

} // End of namespace Common

#endif

0 comments on commit 30edabf

Please sign in to comment.