Browse Source

Add an iswblank compatibility API.

master
Reece H. Dunn 8 years ago
parent
commit
d585c77804
7 changed files with 45 additions and 1 deletions
  1. 4
    0
      CHANGELOG.md
  2. 2
    1
      README.md
  3. 13
    0
      src/ctype.c
  4. 17
    0
      src/include/ucd/ucd.h
  5. 3
    0
      tests/printcdata.c
  6. 3
    0
      tests/printucddata.c
  7. 3
    0
      tests/printucddata_cpp.cpp

+ 4
- 0
CHANGELOG.md View File

# Change Log # Change Log


## 9.0.0.1 - (In Progress)

* Add `iswblank` compatibility.

## 9.0.0 - 2016-12-28 ## 9.0.0 - 2016-12-28


* Update to Unicode Character Data 9.0.0. * Update to Unicode Character Data 9.0.0.

+ 2
- 1
README.md View File

|---------------|----------------| |---------------|----------------|
| `ucd_isalnum` | `ucd::isalnum` | | `ucd_isalnum` | `ucd::isalnum` |
| `ucd_isalpha` | `ucd::isalpha` | | `ucd_isalpha` | `ucd::isalpha` |
| `ucd_isblank` | `ucd::isblank` |
| `ucd_iscntrl` | `ucd::iscntrl` | | `ucd_iscntrl` | `ucd::iscntrl` |
| `ucd_isdigit` | `ucd::isdigit` | | `ucd_isdigit` | `ucd::isdigit` |
| `ucd_isgraph` | `ucd::isgraph` | | `ucd_isgraph` | `ucd::isgraph` |
| `ucd_isspace` | `ucd::isspace` | | `ucd_isspace` | `ucd::isspace` |
| `ucd_isupper` | `ucd::isupper` | | `ucd_isupper` | `ucd::isupper` |


__NOTE:__ Equivalents for `isblank` and `isxdigit` are not provided.
__NOTE:__ An equivalent for `isxdigit` is not provided.


## Build Dependencies ## Build Dependencies



+ 13
- 0
src/ctype.c View File

} }
} }


int ucd_isblank(codepoint_t c)
{
switch (ucd_lookup_category(c))
{
case UCD_CATEGORY_Zs:
return 1;
case UCD_CATEGORY_Cc:
return c == 0x09; // U+0009 : CHARACTER TABULATION
default:
return 0;
}
}

int ucd_iscntrl(codepoint_t c) int ucd_iscntrl(codepoint_t c)
{ {
return ucd_lookup_category(c) == UCD_CATEGORY_Cc; return ucd_lookup_category(c) == UCD_CATEGORY_Cc;

+ 17
- 0
src/include/ucd/ucd.h View File

*/ */
int ucd_isalpha(codepoint_t c); int ucd_isalpha(codepoint_t c);


/** @brief Is the codepoint a tab or Unicode whitespace character?
*
* @param c The Unicode codepoint to check.
* @return Non-zero if the codepoint is a whitespace character, zero otherwise.
*/
int ucd_isblank(codepoint_t c);

/** @brief Is the codepoint a control character? /** @brief Is the codepoint a control character?
* *
* @param c The Unicode codepoint to check. * @param c The Unicode codepoint to check.
return ucd_isalpha(c); return ucd_isalpha(c);
} }


/** @brief Is the codepoint a tab or Unicode whitespace character?
*
* @param c The Unicode codepoint to check.
* @return Non-zero if the codepoint is a whitespace character, zero otherwise.
*/
inline int isblank(codepoint_t c)
{
return ucd_isblank(c);
}

/** @brief Is the codepoint a control character? /** @brief Is the codepoint a control character?
* *
* @param c The Unicode codepoint to check. * @param c The Unicode codepoint to check.

+ 3
- 0
tests/printcdata.c View File

case 'a': // alpha case 'a': // alpha
fputc(iswalpha(c) ? '1' : '0', out); fputc(iswalpha(c) ? '1' : '0', out);
break; break;
case 'b': // blank
fputc(iswblank(c) ? '1' : '0', out);
break;
case 'c': // control case 'c': // control
fputc(iswcntrl(c) ? '1' : '0', out); fputc(iswcntrl(c) ? '1' : '0', out);
break; break;

+ 3
- 0
tests/printucddata.c View File

case 'a': // alpha case 'a': // alpha
fputc(ucd_isalpha(c) ? '1' : '0', out); fputc(ucd_isalpha(c) ? '1' : '0', out);
break; break;
case 'b': // blank
fputc(ucd_isblank(c) ? '1' : '0', out);
break;
case 'c': // control case 'c': // control
fputc(ucd_iscntrl(c) ? '1' : '0', out); fputc(ucd_iscntrl(c) ? '1' : '0', out);
break; break;

+ 3
- 0
tests/printucddata_cpp.cpp View File

case 'a': // alpha case 'a': // alpha
fputc(ucd::isalpha(c) ? '1' : '0', out); fputc(ucd::isalpha(c) ? '1' : '0', out);
break; break;
case 'b': // blank
fputc(ucd::isblank(c) ? '1' : '0', out);
break;
case 'c': // control case 'c': // control
fputc(ucd::iscntrl(c) ? '1' : '0', out); fputc(ucd::iscntrl(c) ? '1' : '0', out);
break; break;

Loading…
Cancel
Save