From f3a77d3c00c095a53f37aa7efb39d56168799596 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Wed, 6 Jan 2010 16:32:59 +0000 Subject: Port to core buildsystem. The python module (and associated make runes) need some love (as does non-GCC building with the core buildsystem in general) svn path=/trunk/rufl/; revision=9792 --- src/rufl_character_set_test.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/rufl_character_set_test.c (limited to 'src/rufl_character_set_test.c') diff --git a/src/rufl_character_set_test.c b/src/rufl_character_set_test.c new file mode 100644 index 0000000..45fbcaf --- /dev/null +++ b/src/rufl_character_set_test.c @@ -0,0 +1,37 @@ +/* + * This file is part of RUfl + * Licensed under the MIT License, + * http://www.opensource.org/licenses/mit-license + * Copyright 2005 James Bursa + */ + +#include "rufl_internal.h" + + +/** + * Test if a character set contains a character. + * + * \param charset character set + * \param c character code + * \return true if present, false if absent + */ + +bool rufl_character_set_test(struct rufl_character_set *charset, + unsigned int c) +{ + unsigned int block = c >> 8; + unsigned int byte = (c >> 3) & 31; + unsigned int bit = c & 7; + + if (256 <= block) + return false; + + if (charset->index[block] == BLOCK_EMPTY) + return false; + else if (charset->index[block] == BLOCK_FULL) + return true; + else { + unsigned char z = charset->block[charset->index[block]][byte]; + return z & (1 << bit); + } +} -- cgit v1.2.3