diff options
| author | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2026-09-28 22:45:27 +0200 |
|---|---|---|
| committer | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2026-10-01 13:29:27 +0200 |
| commit | 2306cd2d9ac4796cbefe841f05a006b6f44c007e (patch) | |
| tree | 5ca8540f8add9a0780dff7e7e5350900497799a2 | |
| parent | f463628639ca1e0c415d5acc952eda409df6d86e (diff) | |
remove c extension, provide strncasecmp if no avail
| -rw-r--r-- | CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/cross_os.h | 24 | ||||
| -rw-r--r-- | src/vkvg_context.c | 18 | ||||
| -rw-r--r-- | tests/font_tests/array.h | 81 | ||||
| -rw-r--r-- | tests/font_tests/font_tests.c | 645 | ||||
| -rw-r--r-- | tests/font_tests/format12.c | 154 | ||||
| -rw-r--r-- | tests/svg-parser-new/svg_att_keywords.gperf | 483 | ||||
| -rw-r--r-- | tests/svg-parser-new/svg_colors_gperf.h | 303 | ||||
| -rw-r--r-- | tests/svg-parser-new/svg_colors_names.gperf | 343 | ||||
| -rw-r--r-- | tests/svg-parser-new/svg_elt_keywords.gperf | 197 | ||||
| -rw-r--r-- | tests/svg-parser-new/vkvg_svg_internal.h | 1 |
11 files changed, 2081 insertions, 170 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index a9b0dff..bb38ebc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -271,7 +271,7 @@ SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION ${vkvg_VERSION_MAJOR} C_STANDARD 11 C_STANDARD_REQUIRED ON - C_EXTENSIONS ON + C_EXTENSIONS OFF POSITION_INDEPENDENT_CODE "${BUILD_SHARED_LIBS}" diff --git a/src/cross_os.h b/src/cross_os.h index b66f58d..4c7baa1 100644 --- a/src/cross_os.h +++ b/src/cross_os.h @@ -21,6 +21,8 @@ */ #pragma once +#include <stddef.h> + // cross platform os helpers #if defined(_WIN32) || defined(_WIN64) // disable warning on iostream functions on windows @@ -54,6 +56,28 @@ void _linux_register_error_handler(); #endif #endif + + +// 1. Check if we are in a POSIX environment that supports strncasecmp +#if defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200112L) +#include <strings.h> /* Provides the native strncasecmp */ +#else +/* 2. Fallback: Implement our own C11-compliant version */ +#include <ctype.h> + +static inline int strncasecmp(const char *s1, const char *s2, size_t n) { + while (n-- > 0) { + unsigned char u1 = (unsigned char)*s1; + unsigned char u2 = (unsigned char)*s2; + int diff = tolower(u1) - tolower(u2); + if (diff != 0 || u1 == '\0') return diff; + s1++; s2++; + } + return 0; +} +#endif + + const char* getUserDir(); int create_dir(const char* path); int create_dir_tree(const char* path); diff --git a/src/vkvg_context.c b/src/vkvg_context.c index 83240cf..c2a2764 100644 --- a/src/vkvg_context.c +++ b/src/vkvg_context.c @@ -1491,24 +1491,6 @@ void vkvg_restore(VkvgContext ctx) { memcpy((void*)&(ctx->curColor), (void*)sav, (void*)&(ctx->pattern) - (void*)&(ctx->curColor)); - /*ctx->curColor = sav->curColor; - ctx->lineWidth = sav->lineWidth; - ctx->miterLimit = sav->miterLimit; - ctx->dashCount = sav->dashCount; - ctx->dashOffset = sav->dashOffset; - if (ctx->dashCount > 0) { - memcpy(ctx->dashes, sav->dashes, sizeof(float) * ctx->dashCount); - } - - ctx->curOperator = sav->curOperator; - ctx->lineCap = sav->lineCap; - ctx->lineJoin = sav->lineJoint; - ctx->curFillRule = sav->curFillRule; - ctx->textDirection = sav->textDirection; - ctx->selectedCharSize = sav->selectedCharSize; - ctx->selectedFont = sav->selectedFont; - ctx->pushConsts = sav->pushConsts;*/ - ctx->pushCstDirty = true; if (sav->pattern) { diff --git a/tests/font_tests/array.h b/tests/font_tests/array.h new file mode 100644 index 0000000..8ae05d3 --- /dev/null +++ b/tests/font_tests/array.h @@ -0,0 +1,81 @@ +#ifndef ARRAY_H_INCLUDED +#define ARRAY_H_INCLUDED + +#include <stdint.h> +#include <stdbool.h> +#include <stdlib.h> + +#ifndef ARRAY_ID +#define ARRAY_ID(x) (x) +#endif +#ifndef ARRAY_EXP_GROWTH +#define ARRAY_EXP_GROWTH 0 +#endif +#ifndef ARRAY_ELASTICITY +#define ARRAY_ELASTICITY 10 +#endif +#ifndef ARRAY_INIT +#define ARRAY_INIT 4 +#endif +#ifndef ARRAY_ELEMENT_TYPE +#define ARRAY_ELEMENT_TYPE void * +#endif + + + +typedef struct _array_t { + uint32_t count; + uint32_t size; + ARRAY_ELEMENT_TYPE *elements; +} array_t; + +struct _array_t * array_create(); +void array_destroy(struct _array_t *arr); +void array_clean(struct _array_t *arr); +static inline void array_add(struct _array_t *arr, ARRAY_ELEMENT_TYPE element); +static inline void array_add_unique(struct _array_t *arr, ARRAY_ELEMENT_TYPE element); + +#ifdef ARRAY_IMPLEMENTATION +array_t *array_create() { + array_t *arr = (array_t *)malloc(sizeof(array_t)); + arr->elements = (ARRAY_ELEMENT_TYPE *)malloc(ARRAY_INIT * sizeof(ARRAY_ELEMENT_TYPE)); + arr->count = 0; + arr->size = ARRAY_INIT; + return arr; +} + +void array_destroy(array_t *arr) { + free(arr->elements); + free(arr); +} +void _array_add(array_t *arr, ARRAY_ELEMENT_TYPE element, bool unique) { + if (unique) { + for(int i = 0; i < arr->count; ++i) { + if (ARRAY_ID(arr->elements[i]) == ARRAY_ID(element)) + return; + } + } + if (arr->size == arr->count) { + if (ARRAY_EXP_GROWTH) { + arr->size *= ARRAY_EXP_GROWTH; + } else { + arr->size += ARRAY_ELASTICITY; + } + arr->elements = (ARRAY_ELEMENT_TYPE *)realloc(arr->elements, (arr->size) * sizeof(ARRAY_ELEMENT_TYPE)); + } + // memcpy (&arr->elements[arr->count], &element, sizeof (ARRAY_ELEMENT_TYPE)); + arr->elements[arr->count] = element; + arr->count++; +} +static inline void array_add(array_t *arr, ARRAY_ELEMENT_TYPE element) { + _array_add(arr,element,false); +} +static inline void array_add_unique(array_t *arr, ARRAY_ELEMENT_TYPE element) { + _array_add(arr,element,true); +} + +void array_reset(array_t *arr) { + arr->count = 0; +} +#endif +#endif diff --git a/tests/font_tests/font_tests.c b/tests/font_tests/font_tests.c new file mode 100644 index 0000000..6cc2608 --- /dev/null +++ b/tests/font_tests/font_tests.c @@ -0,0 +1,645 @@ +#include <ft2build.h> +//#include "freetype/freetype.h" +#include FT_FREETYPE_H +#include FT_SFNT_NAMES_H +#include FT_TRUETYPE_TABLES_H +#include FT_TRUETYPE_IDS_H +#include FT_MULTIPLE_MASTERS_H + + + +/* + serif Liberation Serif, DejaVu Serif, Times + sans-serif Liberation Sans, DejaVu Sans, Arial + monospace Liberation Mono, DejaVu Sans Mono + cursive Comic Neue, URW Chancery + fantasy Impact, Western +-------- + system-ui + emoji noto color emoji + math + fangsong traditional chinese +*/ + +#include <sys/types.h> +#include <sys/stat.h> +#include <dirent.h> +#include <stdlib.h> +#include <stdio.h> +#include <stddef.h> +#include <stdint.h> +#include <ctype.h> + +#include <stdarg.h> +#include <string.h> + +#define MAX_PATH_LENGTH 1024 +#define MAX_FAM_LENGTH 64 + +typedef struct { + uint32_t hash; + char string[MAX_FAM_LENGTH]; +} hashed_string_t; + +#define ARRAY_INIT 16 +#define ARRAY_EXP_GROWTH 2 +#define ARRAY_ELEMENT_TYPE hashed_string_t +#define ARRAY_ID(x) ((x).hash) + +#define ARRAY_IMPLEMENTATION +#include "array.h" + +static char* filename = NULL; +static char* directory = NULL; +struct dirent* dir = NULL; + +struct stat file_stat; + + +#define NORMAL_COLOR "\x1B[0m" +#define GREEN "\x1B[32m" +#define BLUE "\x1B[34m" + +static int svg_file_count; +static float maxScroll; + +/* not defined in c11, ok to define here only for sample */ +#ifndef DT_DIR +#define DT_DIR 4 +#endif + +/** + * @brief Computes the 64-bit FNV-1a hash of a ascii string lowering case. + * + * @param str Pointer to the start of the null terminated ascii string to hash. + * @return uint64_t The 64-bit hash value. + */ +static inline uint64_t fnv1a_64_str(const char *const restrict str) { + uint64_t hash = 0xcbf29ce484222325ULL; + const uint8_t *restrict data = (const uint8_t *)str; + + while (*data) { + uint8_t c = *data; + // Fast branchless lowercase for ASCII font names/paths + if (c >= 'A' && c <= 'Z') { + c |= 0x20; + } + hash ^= c; + hash *= 0x00000100000001B3ULL; + data++; + } + + return hash; +} +#define FNV_32_PRIME 0x01000193 +#define FNV_32_OFFSET 0x811C9DC5 + +static inline uint32_t fnv1a_32_str(const char *const restrict str) { + const uint8_t *restrict data = (const uint8_t *)str; + uint32_t hash = FNV_32_OFFSET; + while (*data) { + uint8_t c = *data; + // Fast branchless lowercase for ASCII font names/paths + if (c >= 'A' && c <= 'Z') { + c |= 0x20; + } + hash ^= c; + hash *= FNV_32_PRIME; + data++; + } + return hash; +} + +void convert_utf16be_to_ascii(const FT_Byte* src, FT_UInt src_len, char* dest, FT_UInt dest_max_len) { + FT_UInt d_idx = 0; + // Iterate 2 bytes at a time + for (FT_UInt s_idx = 0; s_idx < src_len && d_idx < (dest_max_len - 1); s_idx += 2) { + // In UTF-16BE, the second byte contains the ASCII value for basic English + FT_Byte high_byte = src[s_idx]; + FT_Byte low_byte = src[s_idx + 1]; + + if (high_byte == 0) { + dest[d_idx++] = (char)low_byte; // Standard English character + } else { + dest[d_idx++] = '?'; // Non-ASCII character fallback + } + } + dest[d_idx] = '\0'; // Properly null-terminate the string +} + + +void print_help_and_exit() { + printf("\nUsage: fonttest [options] [path]\n\n"); + exit(-1); +} +#define CHECK_FACE_FLAG(flags, flag, buffer) \ + do { \ + if ((flags) & (flag)) { \ + if (buffer[0] != '\0') strcat(buffer, " | "); \ + strcat(buffer, #flag); \ + } \ + } while (0) + +/** + * Converts face_flags bitmask to a human-readable string. + * Make sure the output buffer is large enough (e.g., 512 bytes). + */ +void ft_face_flags_to_string(FT_Long face_flags, char* out_str, size_t max_len) { + if (!out_str || max_len == 0) return; + out_str[0] = '\0'; + + CHECK_FACE_FLAG(face_flags, FT_FACE_FLAG_SCALABLE, out_str); + CHECK_FACE_FLAG(face_flags, FT_FACE_FLAG_FIXED_SIZES, out_str); + CHECK_FACE_FLAG(face_flags, FT_FACE_FLAG_FIXED_WIDTH, out_str); + CHECK_FACE_FLAG(face_flags, FT_FACE_FLAG_SFNT, out_str); + CHECK_FACE_FLAG(face_flags, FT_FACE_FLAG_HORIZONTAL, out_str); + CHECK_FACE_FLAG(face_flags, FT_FACE_FLAG_VERTICAL, out_str); + CHECK_FACE_FLAG(face_flags, FT_FACE_FLAG_KERNING, out_str); + CHECK_FACE_FLAG(face_flags, FT_FACE_FLAG_MULTIPLE_MASTERS, out_str); + CHECK_FACE_FLAG(face_flags, FT_FACE_FLAG_GLYPH_NAMES, out_str); + CHECK_FACE_FLAG(face_flags, FT_FACE_FLAG_EXTERNAL_STREAM, out_str); + CHECK_FACE_FLAG(face_flags, FT_FACE_FLAG_HINTER, out_str); + CHECK_FACE_FLAG(face_flags, FT_FACE_FLAG_CID_KEYED, out_str); + CHECK_FACE_FLAG(face_flags, FT_FACE_FLAG_TRICKY, out_str); + CHECK_FACE_FLAG(face_flags, FT_FACE_FLAG_COLOR, out_str); + + if (out_str[0] == '\0') { + strncpy(out_str, "NONE", max_len); + } +} + +// Define explicit variation axis tags using FreeType's macro wrapper +#define AXIS_TAG_WGHT FT_MAKE_TAG('w', 'g', 'h', 't') +#define AXIS_TAG_WDTH FT_MAKE_TAG('w', 'd', 't', 'h') +#define AXIS_TAG_SLNT FT_MAKE_TAG('s', 'l', 'n', 't') +#define AXIS_TAG_ITAL FT_MAKE_TAG('i', 't', 'a', 'l') + +typedef enum { + font_weight_thin = 100, + font_weight_extra_light = 200, + font_weight_light = 300, + font_weight_normal = 400, + font_weight_medium = 500, + font_weight_semi_bold = 600, + font_weight_bold = 700, + font_weight_extra_bold = 800, + font_weight_black = 900, +} font_weight; + +typedef enum { + font_width_ultra_condensed = 1,//50% + font_width_extra_condensed = 2, + font_width_condensed = 3, + font_width_semi_condensed = 4, + font_width_normal = 5, + font_width_semi_expanded = 6, + font_width_expanded = 7, + font_width_extra_expanded = 8, + font_width_ultra_expanded = 9,//150% +} font_width; + +typedef enum { + font_slant_italic = 0b0000000000000001, + font_slant_regular = 0b0000000001000000, + font_slant_oblic = 0b0000001000000000 +} font_slant; + + +FT_Library library; + +typedef struct { + uint64_t pathHash; + uint32_t nameHash; + uint32_t styleHash; +} font_id_t; + + +font_id_t font_id_cache[7000]; +array_t* font_names; +array_t* font_sub_names; + +uint32_t fontIndex = 0; + + +const char* nameid_trimmed(const char* str) { + return str + 11; +} + + + +#define SFNT_NAME_VASE(value) \ +case value : \ + return nameid_trimmed(#value); + +const char* sfnt_nameid_to_string(int id) { + switch(id) { + SFNT_NAME_VASE(TT_NAME_ID_COPYRIGHT) + SFNT_NAME_VASE(TT_NAME_ID_FONT_FAMILY) + SFNT_NAME_VASE(TT_NAME_ID_FONT_SUBFAMILY) + SFNT_NAME_VASE(TT_NAME_ID_UNIQUE_ID) + SFNT_NAME_VASE(TT_NAME_ID_FULL_NAME) + SFNT_NAME_VASE(TT_NAME_ID_VERSION_STRING) + SFNT_NAME_VASE(TT_NAME_ID_PS_NAME) + SFNT_NAME_VASE(TT_NAME_ID_TRADEMARK) + SFNT_NAME_VASE(TT_NAME_ID_MANUFACTURER) + SFNT_NAME_VASE(TT_NAME_ID_DESIGNER) + SFNT_NAME_VASE(TT_NAME_ID_DESCRIPTION) + SFNT_NAME_VASE(TT_NAME_ID_VENDOR_URL) + SFNT_NAME_VASE(TT_NAME_ID_DESIGNER_URL) + SFNT_NAME_VASE(TT_NAME_ID_LICENSE) + SFNT_NAME_VASE(TT_NAME_ID_LICENSE_URL) + SFNT_NAME_VASE(TT_NAME_ID_TYPOGRAPHIC_FAMILY) + SFNT_NAME_VASE(TT_NAME_ID_TYPOGRAPHIC_SUBFAMILY) + SFNT_NAME_VASE(TT_NAME_ID_MAC_FULL_NAME) + SFNT_NAME_VASE(TT_NAME_ID_SAMPLE_TEXT) + SFNT_NAME_VASE(TT_NAME_ID_CID_FINDFONT_NAME) + SFNT_NAME_VASE(TT_NAME_ID_WWS_FAMILY) + SFNT_NAME_VASE(TT_NAME_ID_WWS_SUBFAMILY) + SFNT_NAME_VASE(TT_NAME_ID_LIGHT_BACKGROUND) + SFNT_NAME_VASE(TT_NAME_ID_DARK_BACKGROUND) + SFNT_NAME_VASE(TT_NAME_ID_VARIATIONS_PREFIX) + + } + return "\0"; +} + +static inline void strn_tolower_copy(char *restrict dest, const char *restrict src, size_t len) { + if (!dest || !src) return; + + for (size_t i = 0; i < len; ++i) { + // cast to unsigned char is required by standard to prevent undefined behavior with negative char values + dest[i] = (char)tolower((unsigned char)src[i]); + } + + dest[len] = '\0'; // Explicitly enforce null-termination +} +static inline bool sfnt_name_is_english(const FT_Short platform_id, const FT_Short language_id) { + return (platform_id == 3 && language_id == 0x0409) || + (platform_id == 0 && language_id == 0) || + (platform_id == 1 && language_id == 0); +} + +void process_font_file (const char* const fontDir, const char* fontFile) { + char path[MAX_PATH_LENGTH]; + sprintf(path, "%s/%s", fontDir, fontFile); + FT_Face face; + font_weight weight = font_weight_normal; + font_width width = font_width_normal; + font_slant slant = font_slant_regular; + + FT_Error error = FT_New_Face(library, path, 0, &face ); + if (error) { + fprintf(stdout, "error opening font: %s\n%s\n", path, FT_Error_String(error)); + return; + } + + printf("%-100s:", path); + printf("\tnum faces: %ld (%ld):\t%-40s%-20s#:%ld\n", face->num_faces, face->face_index, face->family_name, face->style_name,face->num_glyphs); + char flags[1024]; + ft_face_flags_to_string(face->face_flags, flags, 1024); + printf("\tFlags: %s\n", flags); + + if (face->face_flags & FT_FACE_FLAG_MULTIPLE_MASTERS) { + FT_MM_Var* mm_var; + FT_Get_MM_Var(face, &mm_var); + printf("\tAxis: %4d Named Instances: %4d\n", mm_var->num_axis, mm_var->num_namedstyles); + for (int i = 0; i < mm_var->num_namedstyles; ++i) { + printf("\t%4d %u\n", i, mm_var->namedstyle[i].strid); + } + //mm_var->axis[0].; + FT_Done_MM_Var(library, mm_var); + } + + TT_OS2* os2_table = (TT_OS2*)FT_Get_Sfnt_Table(face, FT_SFNT_OS2); + if (os2_table) { + // 1. Get the real numeric weight (e.g., 400, 700) + weight = os2_table->usWeightClass; + width = os2_table->usWidthClass; + slant = os2_table->fsSelection; + } + + printf("\tWeight: %4d width: %4d slant: %4d\n", weight, width, slant); + + + FT_UInt sfntCount = FT_Get_Sfnt_Name_Count(face); + FT_SfntName name; + char stringAscii[1024]; + + hashed_string_t famName = {0}; + hashed_string_t subFamName = {0}; + hashed_string_t typoFamName = {0}; + hashed_string_t typoSubFamName = {0}; + + for (int i = 0; i < sfntCount; ++i) { + error = FT_Get_Sfnt_Name(face, i, &name); + if (error) { + fprintf(stdout, "error reading sfnt name #%d, %s\n", i, FT_Error_String(error)); + continue; + } + /*FT_SfntLangTag langTag = {0}; + error = FT_Get_Sfnt_LangTag(face, name.language_id, &langTag); + if (langTag.string_len < 1) { + continue; + } + convert_utf16be_to_ascii(langTag.string, langTag.string_len, langTagAscii, 64);*/ + if (name.string_len < 1 || !sfnt_name_is_english(name.platform_id, name.language_id)) + continue; + if (name.name_id == TT_NAME_ID_FONT_FAMILY || + name.name_id == TT_NAME_ID_FONT_SUBFAMILY || + name.name_id == TT_NAME_ID_FULL_NAME || + name.name_id == TT_NAME_ID_TYPOGRAPHIC_FAMILY || + name.name_id == TT_NAME_ID_TYPOGRAPHIC_SUBFAMILY || + name.name_id == TT_NAME_ID_UNIQUE_ID) { + + fprintf(stdout, "sfntName(%1d:%3d:%4d:%6d): %-20s = ", name.platform_id, name.encoding_id, name.language_id, name.name_id, sfnt_nameid_to_string(name.name_id)); + if (name.platform_id == 3) { + convert_utf16be_to_ascii(name.string, name.string_len, stringAscii, 1024); + fprintf(stdout, "%s\n", stringAscii); + } else { + fprintf(stdout, "%.*s\n", name.string_len, name.string); + } + + fflush(stdout); + } else + continue; + + if (name.platform_id == 3) { + convert_utf16be_to_ascii(name.string, name.string_len, stringAscii, 1024); + } else { + strncpy(stringAscii, (char*)name.string, name.string_len < 1023 ? name.string_len : 1023); + stringAscii[name.string_len < 1023 ? name.string_len : 1023] = '\0'; + } + + switch (name.name_id) { + case TT_NAME_ID_TYPOGRAPHIC_FAMILY: + if (typoFamName.hash) + continue; + strn_tolower_copy(typoFamName.string, stringAscii, strlen(stringAscii)); + typoFamName.hash = fnv1a_32_str(typoFamName.string); + break; + case TT_NAME_ID_TYPOGRAPHIC_SUBFAMILY: + if (typoSubFamName.hash) + continue; + strn_tolower_copy(typoSubFamName.string, stringAscii, strlen(stringAscii)); + typoSubFamName.hash = fnv1a_32_str(typoSubFamName.string); + break; + case TT_NAME_ID_FONT_FAMILY: + if (famName.hash) + continue; + strn_tolower_copy(famName.string, stringAscii, strlen(stringAscii)); + famName.hash = fnv1a_32_str(famName.string); + break; + case TT_NAME_ID_FONT_SUBFAMILY: + if (subFamName.hash) + continue; + strn_tolower_copy(subFamName.string, stringAscii, strlen(stringAscii)); + subFamName.hash = fnv1a_32_str(subFamName.string); + break; + default: + break; + } + + + + } + + fflush(stdout); + + uint64_t pathHash = fnv1a_64_str(path); + if (pathHash) { + font_id_cache[fontIndex] = (font_id_t) { pathHash, fnv1a_32_str(face->family_name), fnv1a_32_str(face->style_name)}; + fontIndex++; + } else { + fprintf(stdout, "Path hash = 0 for %s\n", path); + } + + if (typoFamName.hash) + array_add_unique(font_names, typoFamName); + else if (famName.hash) + array_add_unique(font_names, famName); + if (typoSubFamName.hash) + array_add_unique(font_sub_names, typoSubFamName); + else if (subFamName.hash) + array_add_unique(font_sub_names, subFamName); + + FT_Done_Face(face); +} +void parse_font_dir (const char* const dir_path) { + char path[MAX_PATH_LENGTH]; + DIR* dir = opendir(dir_path); + if (!dir) { + printf("error opening directory: %s\n", dir_path); + return; + } + rewinddir(dir); + + struct dirent* de; + while ((de = readdir(dir)) != NULL) { + if (de->d_type == DT_DIR) { + if (de->d_name[0] == '.') + continue; + sprintf(path, "%s/%s", dir_path, de->d_name); + parse_font_dir(path); + } else { + if (!strcasecmp(strrchr(de->d_name, '\0') - 4, ".otf") || + !strcasecmp(strrchr(de->d_name, '\0') - 4, ".ttf") || + !strcasecmp(strrchr(de->d_name, '\0') - 5, ".woff") || + !strcasecmp(strrchr(de->d_name, '\0') - 6, ".woff2")) { + + process_font_file(dir_path, de->d_name); + } + } + } + closedir(dir); +} + +void sort_fonts_by_path_hash(font_id_t *array, size_t n) { + if (n < 2) return; + + // Allocate a temporary buffer for the 16-byte structs + font_id_t *buffer = (font_id_t *)malloc(n * sizeof(font_id_t)); + if (!buffer) return; + + font_id_t *src = array; + font_id_t *dst = buffer; + + // 8 passes of Radix Sort (8 bits per pass = 64 bits total) + for (int pass = 0; pass < 8; pass++) { + size_t count[256] = {0}; // 256 buckets for an 8-bit chunk + int shift = pass * 8; + + // 1. Calculate histograms directly using the unsigned pathHash + for (size_t i = 0; i < n; i++) { + uint8_t byte = (src[i].pathHash >> shift) & 0xFF; + count[byte]++; + } + + // 2. Transform counts into exclusive prefix sums (offsets) + size_t total = 0; + for (int i = 0; i < 256; i++) { + size_t old_count = count[i]; + count[i] = total; + total += old_count; + } + + // 3. Scatter entire structs safely into the destination buffer + for (size_t i = 0; i < n; i++) { + uint8_t byte = (src[i].pathHash >> shift) & 0xFF; + dst[count[byte]++] = src[i]; // Copies the full 16 bytes cleanly + } + + // Ping-pong buffer pointers to avoid unnecessary copying + font_id_t *temp = src; + src = dst; + dst = temp; + } + + // If the final sorted data landed in the temporary buffer, copy it back + if (src != array) { + memcpy(array, buffer, n * sizeof(font_id_t)); + } + + free(buffer); +} +void radix_sort_structs(font_id_t *array, size_t n) { + if (n < 2) return; + + // Allocate pointer arrays for the radix passes + font_id_t **src = (font_id_t **)malloc(n * sizeof(font_id_t *)); + font_id_t **dst = (font_id_t **)malloc(n * sizeof(font_id_t *)); + if (!src || !dst) { free(src); free(dst); return; } + + // Initialize the source pointer array + for (size_t i = 0; i < n; i++) { + src[i] = &array[i]; + } + + // 8 passes of Radix Sort (8 bits per pass) + for (int pass = 0; pass < 8; pass++) { + size_t count[256] = {0}; + int shift = pass * 8; + + // 1. Histogram (Extract the byte from the 64-bit ID) + // For signed int64_t, we flip the sign bit on the final pass (pass 7) + for (size_t i = 0; i < n; i++) { + uint64_t key = (uint64_t)src[i]->pathHash; + if (pass == 7) key ^= 0x8000000000000000ULL; // Handle signed values + uint8_t byte = (key >> shift) & 0xFF; + count[byte]++; + } + + // 2. Prefix Sums + size_t total = 0; + for (int i = 0; i < 256; i++) { + size_t old_count = count[i]; + count[i] = total; + total += old_count; + } + + // 3. Scatter pointers + for (size_t i = 0; i < n; i++) { + uint64_t key = (uint64_t)src[i]->pathHash; + if (pass == 7) key ^= 0x8000000000000000ULL; + uint8_t byte = (key >> shift) & 0xFF; + dst[count[byte]++] = src[i]; + } + + // Ping-pong pointer swap + font_id_t **temp = src; + src = dst; + dst = temp; + } + + // Reorder the original array in-place using cycle-walking (O(N) time, O(1) extra space) + // 'src' now holds the correct final pointers in sorted order. + for (size_t i = 0; i < n; i++) { + if (src[i] != &array[i]) { + font_id_t temp_struct = array[i]; + size_t j = i; + while (1) { + // Find where the element currently at array[j] belongs + size_t k = (src[j] - array); + if (k == i) { + array[j] = temp_struct; + src[j] = &array[j]; + break; + } + array[j] = array[k]; + src[j] = &array[j]; + j = k; + } + } + } + + free(src); + free(dst); +} + +int main(int argc, char* argv[]) { + int i = 1; + char* output = NULL; + + while (i < argc) { + int argLen = strlen(argv[i]); + if (argv[i][0] == '-') { + + if (argLen < 2) + print_help_and_exit(); + + switch (argv[i][1]) { + case 'f': + if (argc < ++i + 1) + print_help_and_exit(); + filename = argv[i]; + break; + default: + print_help_and_exit(); + } + } else + directory = argv[i]; + i++; + } + if (!directory) + print_help_and_exit(); + + FT_Error error = FT_Init_FreeType( &library ); + if (error) { + perror("error initializing freetype library\n"); + exit(-1); + } + + //font_id_cache = array_create(); + font_names = array_create(); + font_sub_names = array_create(); + + if (directory) { + parse_font_dir(directory); + } + printf("Total font files: %d\n", fontIndex); + + + radix_sort_structs(font_id_cache, fontIndex); + + /*for (int i = 0; i < fontIndex; ++i) { + printf("%lu %u %u\n", font_id_cache[i].pathHash, font_id_cache[i].nameHash, font_id_cache[i].styleHash); + } + + for (int i = 0; i < fontIndex - 1; ++i) { + if (font_id_cache[i].pathHash == font_id_cache[i+1].pathHash) + printf("Collision: %lu %u %u\n", font_id_cache[i].pathHash, font_id_cache[i].nameHash, font_id_cache[i].styleHash); + }*/ + /*printf("=== Font Names: %-5d ===\n", font_names->count); + for (int i = 0; i < font_names->count; ++i) { + printf("%s\n", font_names->elements[i].string); + } + printf("=============================\n"); + printf("=== Font Sub Names: %-5d ===\n", font_sub_names->count); + for (int i = 0; i < font_sub_names->count; ++i) { + printf("%s\n", font_sub_names->elements[i].string); + } + printf("==============================\n");*/ + + array_destroy(font_names); + array_destroy(font_sub_names); + +} diff --git a/tests/font_tests/format12.c b/tests/font_tests/format12.c new file mode 100644 index 0000000..af5e717 --- /dev/null +++ b/tests/font_tests/format12.c @@ -0,0 +1,154 @@ +#include <stdio.h> +#include <stdlib.h> +#include <stdint.h> + +#include <ft2build.h> +#include FT_FREETYPE_H +#include FT_TRUETYPE_TABLES_H // Required for SFNT structure macros + +/* --- OpenType Binary Byte Order Swapping Helpers --- */ +static uint16_t read_u16(const uint8_t* p) { + return (p[0] << 8) | p[1]; +} + +static uint32_t read_u32(const uint8_t* p) { + return ((uint32_t)p[0] << 24) | ((uint32_t)p[1] << 16) | ((uint32_t)p[2] << 8) | p[3]; +} + +/* --- Format 12 Structural Group Definition --- */ +typedef struct { + uint32_t startCharCode; + uint32_t endCharCode; + uint32_t startGlyphID; +} Format12Group; + +void parse_raw_sfnt_cmap(FT_Face face) { + // 1. Ensure the loaded font is an SFNT-based format (TrueType/OpenType) + if (!FT_IS_SFNT(face)) { + printf("Error: Loaded font face is not an SFNT (TrueType/OpenType) font.\n"); + return; + } + + // 2. Query FreeType to check if the 'cmap' table exists and find its length + FT_ULong table_len = 0; + FT_Error err = FT_Load_Sfnt_Table(face, TTAG_cmap, 0, NULL, &table_len); + if (err || table_len == 0) { + printf("Error: Could not read 'cmap' table metrics.\n"); + return; + } + + // 3. Allocate a memory buffer and download the raw 'cmap' bytes + uint8_t* cmap_raw = (uint8_t*)malloc(table_len); + err = FT_Load_Sfnt_Table(face, TTAG_cmap, 0, cmap_raw, &table_len); + if (err) { + printf("Error: Failed downloading raw 'cmap' block.\n"); + free(cmap_raw); + return; + } + + printf("Successfully extracted raw 'cmap' table. Size: %lu bytes.\n", table_len); + + /* --- Parse the CMap Index Header --- */ + // Bytes 0-1: version (must be 0) + // Bytes 2-3: numSubtables (number of encoding tables) + uint16_t numSubtables = read_u16(cmap_raw + 2); + printf("Number of encoding subtables found: %d\n\n", numSubtables); + + uint32_t format12_offset = 0; + + /* --- Loop Through Subtables to Find Format 12 --- */ + // The subtable dictionary begins at byte 4. Each entry is 8 bytes. + for (uint16_t i = 0; i < numSubtables; i++) { + uint32_t entry_offset = 4 + (i * 8); + uint16_t platform_id = read_u16(cmap_raw + entry_offset); + uint16_t encoding_id = read_u16(cmap_raw + entry_offset + 2); + uint32_t sub_offset = read_u32(cmap_raw + entry_offset + 4); + + // Peek at the first 2 bytes of the subtable to check its Format ID + uint16_t format = read_u16(cmap_raw + sub_offset); + + printf(" Subtable [%d]: Platform %d, Encoding %d, Format %d -> Offset 0x%X\n", + i, platform_id, encoding_id, format, sub_offset); + + if (format == 12) { + format12_offset = sub_offset; + // Stop looping if we find a standard Unicode/Windows full-plane table + if (platform_id == 3 && encoding_id == 10) { + break; + } + } + } + + if (format12_offset == 0) { + printf("\nThis font does not contain a Format 12 subtable (likely BMP-only/Format 4).\n"); + free(cmap_raw); + return; + } + + /* --- Parse the Format 12 Subtable --- */ + printf("\n--- Parsing Format 12 Subtable at Offset 0x%X ---\n", format12_offset); + const uint8_t* f12_ptr = cmap_raw + format12_offset; + + // Header Structure for Format 12: + // uint16 format (12) -> bytes 0-1 + // uint16 reserved -> bytes 2-3 + // uint32 length -> bytes 4-7 + // uint32 language -> bytes 8-11 + // uint32 numGroups -> bytes 12-15 + uint32_t f12_length = read_u32(f12_ptr + 4); + uint32_t numGroups = read_u32(f12_ptr + 12); + + printf(" Subtable Byte Length: %u\n", f12_length); + printf(" Total Compressed Segmented Groups: %u\n\n", numGroups); + + // Group Array begins at byte 16. Each group is 12 bytes. + const uint8_t* groups_ptr = f12_ptr + 16; + + // Print out the structural boundaries mapped by the font designer + for (uint32_t g = 0; g < numGroups; g++) { + uint32_t g_offset = g * 12; + Format12Group group; + group.startCharCode = read_u32(groups_ptr + g_offset); + group.endCharCode = read_u32(groups_ptr + g_offset + 4); + group.startGlyphID = read_u32(groups_ptr + g_offset + 8); + + printf(" Group %-4u: Unicode [U+%06X to U+%06X] -> maps to starting Glyph ID: %u\n", + g, group.startCharCode, group.endCharCode, group.startGlyphID); + + // Safety break to prevent console flooding on giant fonts like Noto Sans + if (g >= 15) { + printf(" ... (%u more groups omitted) ...\n", numGroups - 16); + break; + } + } + + // Clean up local buffers + free(cmap_raw); +} + +int main(int argc, char** argv) { + if (argc < 2) { + printf("Usage: %s <path_to_font.ttf>\n", argv[0]); + return 1; + } + + FT_Library library; + if (FT_Init_FreeType(&library)) { + printf("Could not init FreeType.\n"); + return 1; + } + + FT_Face face; + if (FT_New_Face(library, argv[1], 0, &face)) { + printf("Could not load font file %s\n", argv[1]); + FT_Done_FreeType(library); + return 1; + } + + parse_raw_sfnt_cmap(face); + + FT_Done_Face(face); + FT_Done_FreeType(library); + return 0; +} + diff --git a/tests/svg-parser-new/svg_att_keywords.gperf b/tests/svg-parser-new/svg_att_keywords.gperf new file mode 100644 index 0000000..ed3fb02 --- /dev/null +++ b/tests/svg-parser-new/svg_att_keywords.gperf @@ -0,0 +1,483 @@ +%{ +#include <string.h> + +/* Enum representing our supported SVG elements and attributes */ +typedef enum { + SVG_ATT_TOK_UNKNOWN, + SVG_ATT_TOK_ACCUMULATE, + SVG_ATT_TOK_ADDITIVE, + SVG_ATT_TOK_ATTRIBUTENAME, + SVG_ATT_TOK_ATTRIBUTETYPE, + SVG_ATT_TOK_BEGIN, + SVG_ATT_TOK_BY, + SVG_ATT_TOK_CALCMODE, + SVG_ATT_TOK_DUR, + SVG_ATT_TOK_END, + SVG_ATT_TOK_FILL, + SVG_ATT_TOK_FROM, + SVG_ATT_TOK_KEYPOINTS, + SVG_ATT_TOK_KEYSPLINES, + SVG_ATT_TOK_KEYTIMES, + SVG_ATT_TOK_MAX, + SVG_ATT_TOK_MIN, + SVG_ATT_TOK_ORIGIN, + SVG_ATT_TOK_PATH, + SVG_ATT_TOK_REPEATCOUNT, + SVG_ATT_TOK_REPEATDUR, + SVG_ATT_TOK_RESTART, + SVG_ATT_TOK_ROTATE, + SVG_ATT_TOK_TO, + SVG_ATT_TOK_TYPE, + SVG_ATT_TOK_VALUES, + SVG_ATT_TOK_CX, + SVG_ATT_TOK_CY, + SVG_ATT_TOK_R, + SVG_ATT_TOK_CLIPPATHUNITS, + SVG_ATT_TOK_REQUIREDEXTENSIONS, + SVG_ATT_TOK_REQUIREDFEATURES, + SVG_ATT_TOK_SYSTEMLANGUAGE, + SVG_ATT_TOK_CLASS, + SVG_ATT_TOK_ID, + SVG_ATT_TOK_STYLE, + SVG_ATT_TOK_TABINDEX, + SVG_ATT_TOK_XML_BASE, + SVG_ATT_TOK_XML_LANG, + SVG_ATT_TOK_XML_SPACE, + SVG_ATT_TOK_RX, + SVG_ATT_TOK_RY, + SVG_ATT_TOK_FEBLEND_MODE, + SVG_ATT_TOK_FECOLORMATRIX_TYPE, + SVG_ATT_TOK_FECOLORMATRIX_VALUES, + SVG_ATT_TOK_FECOMPONENTTRANSFER_TYPE, + SVG_ATT_TOK_FECOMPOSITE_K1, + SVG_ATT_TOK_FECOMPOSITE_K2, + SVG_ATT_TOK_FECOMPOSITE_K3, + SVG_ATT_TOK_FECOMPOSITE_K4, + SVG_ATT_TOK_FECOMPOSITE_OPERATOR, + SVG_ATT_TOK_FECONVOLVEMATRIX_BIAS, + SVG_ATT_TOK_FECONVOLVEMATRIX_DIVISOR, + SVG_ATT_TOK_FECONVOLVEMATRIX_EDGEMODE, + SVG_ATT_TOK_FECONVOLVEMATRIX_KERNELMATRIX, + SVG_ATT_TOK_FECONVOLVEMATRIX_KERNELUNITLENGTH, + SVG_ATT_TOK_FECONVOLVEMATRIX_ORDER, + SVG_ATT_TOK_FECONVOLVEMATRIX_PRESERVEALPHA, + SVG_ATT_TOK_FECONVOLVEMATRIX_TARGETX, + SVG_ATT_TOK_FECONVOLVEMATRIX_TARGETY, + SVG_ATT_TOK_FEDIFFUSELIGHTING_DIFFUSECONSTANT, + SVG_ATT_TOK_FEDIFFUSELIGHTING_KERNELUNITLENGTH, + SVG_ATT_TOK_FEDIFFUSELIGHTING_SURFACESCALE, + SVG_ATT_TOK_FEDISPLACEMENTMAP_SCALE, + SVG_ATT_TOK_FEDISPLACEMENTMAP_XCHANNELSELECTOR, + SVG_ATT_TOK_FEDISPLACEMENTMAP_YCHANNELSELECTOR, + SVG_ATT_TOK_FEDROPSHADOW_DX, + SVG_ATT_TOK_FEDROPSHADOW_DY, + SVG_ATT_TOK_FEDROPSHADOW_STDDEVIATION, + SVG_ATT_TOK_FEGAUSSIANBLUR_EDGEMODE, + SVG_ATT_TOK_FEGAUSSIANBLUR_STDDEVIATION, + SVG_ATT_TOK_FEIMAGE_PRESERVEASPECTRATIO, + SVG_ATT_TOK_FEMORPHOLOGY_OPERATOR, + SVG_ATT_TOK_FEMORPHOLOGY_RADIUS, + SVG_ATT_TOK_FESPECULARLIGHTING_KERNELUNITLENGTH, + SVG_ATT_TOK_FESPECULARLIGHTING_SPECULARCONSTANT, + SVG_ATT_TOK_FESPECULARLIGHTING_SPECULAREXPONENT, + SVG_ATT_TOK_FESPECULARLIGHTING_SURFACESCALE, + SVG_ATT_TOK_FETILE, + SVG_ATT_TOK_FETURBULENCE_BASEFREQUENCY, + SVG_ATT_TOK_FETURBULENCE_NUMOCTAVES, + SVG_ATT_TOK_FETURBULENCE_SEED, + SVG_ATT_TOK_FETURBULENCE_STITCHTILES, + SVG_ATT_TOK_FETURBULENCE_TYPE, + SVG_ATT_TOK_FILTERUNITS, + SVG_ATT_TOK_PRIMITIVEUNITS, + SVG_ATT_TOK_HEIGHT, + SVG_ATT_TOK_IN, + SVG_ATT_TOK_IN2, + SVG_ATT_TOK_RESULT, + SVG_ATT_TOK_WIDTH, + SVG_ATT_TOK_X, + SVG_ATT_TOK_Y, + SVG_ATT_TOK_CROSSORIGIN, + SVG_ATT_TOK_HREF, + SVG_ATT_TOK_PRESERVEASPECTRATIO, + SVG_ATT_TOK_ONABORT, + SVG_ATT_TOK_ONACTIVATE, + SVG_ATT_TOK_ONBEGIN, + SVG_ATT_TOK_ONCLICK, + SVG_ATT_TOK_ONEND, + SVG_ATT_TOK_ONERROR, + SVG_ATT_TOK_ONFOCUSIN, + SVG_ATT_TOK_ONFOCUSOUT, + SVG_ATT_TOK_ONKEYDOWN, + SVG_ATT_TOK_ONKEYPRESS, + SVG_ATT_TOK_ONKEYUP, + SVG_ATT_TOK_ONLOAD, + SVG_ATT_TOK_ONMOUSEDOWN, + SVG_ATT_TOK_ONMOUSEMOVE, + SVG_ATT_TOK_ONMOUSEOUT, + SVG_ATT_TOK_ONMOUSEOVER, + SVG_ATT_TOK_ONMOUSEUP, + SVG_ATT_TOK_ONREPEAT, + SVG_ATT_TOK_ONRESIZE, + SVG_ATT_TOK_ONSCROLL, + SVG_ATT_TOK_ONUNLOAD, + SVG_ATT_TOK_X1, + SVG_ATT_TOK_X2, + SVG_ATT_TOK_Y1, + SVG_ATT_TOK_Y2, + SVG_ATT_TOK_GRADIENTTRANSFORM, + SVG_ATT_TOK_GRADIENTUNITS, + SVG_ATT_TOK_SPREADMETHOD, + SVG_ATT_TOK_MARKERHEIGHT, + SVG_ATT_TOK_MARKERUNITS, + SVG_ATT_TOK_MARKERWIDTH, + SVG_ATT_TOK_ORIENT, + SVG_ATT_TOK_REFX, + SVG_ATT_TOK_REFY, + SVG_ATT_TOK_VIEWBOX, + SVG_ATT_TOK_MASKCONTENTUNITS, + SVG_ATT_TOK_MASKUNITS, + SVG_ATT_TOK_D, + SVG_ATT_TOK_PATHLENGTH, + SVG_ATT_TOK_PATTERNCONTENTUNITS, + SVG_ATT_TOK_PATTERNTRANSFORM, + SVG_ATT_TOK_PATTERNUNITS, + SVG_ATT_TOK_POINTS, + SVG_ATT_TOK_ALIGNMENT_BASELINE, + SVG_ATT_TOK_BASELINE_SHIFT, + SVG_ATT_TOK_CLIP, + SVG_ATT_TOK_CLIP_PATH, + SVG_ATT_TOK_CLIP_RULE, + SVG_ATT_TOK_COLOR, + SVG_ATT_TOK_COLOR_INTERPOLATION, + SVG_ATT_TOK_COLOR_INTERPOLATION_FILTERS, + SVG_ATT_TOK_COLOR_PROFILE, + SVG_ATT_TOK_COLOR_RENDERING, + SVG_ATT_TOK_CURSOR, + SVG_ATT_TOK_DIRECTION, + SVG_ATT_TOK_DISPLAY, + SVG_ATT_TOK_DOMINANT_BASELINE, + SVG_ATT_TOK_ENABLE_BACKGROUND, + SVG_ATT_TOK_FILL_OPACITY, + SVG_ATT_TOK_FILL_RULE, + SVG_ATT_TOK_FILTER, + SVG_ATT_TOK_FLOOD_COLOR, + SVG_ATT_TOK_FLOOD_OPACITY, + SVG_ATT_TOK_FONT_FAMILY, + SVG_ATT_TOK_FONT_SIZE, + SVG_ATT_TOK_FONT_SIZE_ADJUST, + SVG_ATT_TOK_FONT_STRETCH, + SVG_ATT_TOK_FONT_STYLE, + SVG_ATT_TOK_FONT_VARIANT, + SVG_ATT_TOK_FONT_WEIGHT, + SVG_ATT_TOK_GLYPH_ORIENTATION_HORIZONTAL, + SVG_ATT_TOK_GLYPH_ORIENTATION_VERTICAL, + SVG_ATT_TOK_IMAGE_RENDERING, + SVG_ATT_TOK_LIGHTING_COLOR, + SVG_ATT_TOK_MARKER_END, + SVG_ATT_TOK_MARKER_MID, + SVG_ATT_TOK_MARKER_START, + SVG_ATT_TOK_MASK, + SVG_ATT_TOK_OPACITY, + SVG_ATT_TOK_OVERFLOW, + SVG_ATT_TOK_PAINT_ORDER, + SVG_ATT_TOK_POINTER_EVENTS, + SVG_ATT_TOK_SHAPE_RENDERING, + SVG_ATT_TOK_STOP_COLOR, + SVG_ATT_TOK_STOP_OPACITY, + SVG_ATT_TOK_STROKE, + SVG_ATT_TOK_STROKE_DASHARRAY, + SVG_ATT_TOK_STROKE_DASHOFFSET, + SVG_ATT_TOK_STROKE_LINECAP, + SVG_ATT_TOK_STROKE_LINEJOIN, + SVG_ATT_TOK_STROKE_MITERLIMIT, + SVG_ATT_TOK_STROKE_OPACITY, + SVG_ATT_TOK_STROKE_WIDTH, + SVG_ATT_TOK_TEXT_ANCHOR, + SVG_ATT_TOK_TEXT_DECORATION, + SVG_ATT_TOK_TEXT_RENDERING, + SVG_ATT_TOK_UNICODE_BIDI, + SVG_ATT_TOK_VECTOR_EFFECT, + SVG_ATT_TOK_VISIBILITY, + SVG_ATT_TOK_WORD_SPACING, + SVG_ATT_TOK_WRITING_MODE, + SVG_ATT_TOK_FR, + SVG_ATT_TOK_FX, + SVG_ATT_TOK_FY, + SVG_ATT_TOK_OFFSET, + SVG_ATT_TOK_BASEPROFILE, + SVG_ATT_TOK_VERSION, + SVG_ATT_TOK_ZOOMANDPAN, + SVG_ATT_TOK_DX, + SVG_ATT_TOK_DY, + SVG_ATT_TOK_LENGTHADJUST, + SVG_ATT_TOK_TEXTLENGTH, + SVG_ATT_TOK_METHOD, + SVG_ATT_TOK_SIDE, + SVG_ATT_TOK_SPACING, + SVG_ATT_TOK_STARTOFFSET, + SVG_ATT_TOK_TRANSFORM, + SVG_ATT_TOK_XLINK_ACTUATE, + SVG_ATT_TOK_XLINK_ARCROLE, + SVG_ATT_TOK_XLINK_HREF, + SVG_ATT_TOK_XLINK_ROLE, + SVG_ATT_TOK_XLINK_SHOW, + SVG_ATT_TOK_XLINK_TITLE, + SVG_ATT_TOK_XLINK_TYPE +} SvgAttTokId; + +/* Structure returned by gperf */ +struct SvgAttKeyword { + const char *name; + SvgAttTokId id; +}; +%} + +%struct-type +%language=ANSI-C +%readonly-tables +%global-table +%define lookup-function-name lookup_svg_att_token_default +%define hash-function-name hash_svg_att +%define constants-prefix ATT_ +%define word-array-name svg_att_wordlist + +struct SvgAttKeyword; +%% +# attributes +accumulate, SVG_ATT_TOK_ACCUMULATE +additive, SVG_ATT_TOK_ADDITIVE +attributeName, SVG_ATT_TOK_ATTRIBUTENAME +attributeType, SVG_ATT_TOK_ATTRIBUTETYPE +begin, SVG_ATT_TOK_BEGIN +by, SVG_ATT_TOK_BY +calcMode, SVG_ATT_TOK_CALCMODE +dur, SVG_ATT_TOK_DUR +end, SVG_ATT_TOK_END +fill, SVG_ATT_TOK_FILL +from, SVG_ATT_TOK_FROM +keyPoints, SVG_ATT_TOK_KEYPOINTS +keySplines, SVG_ATT_TOK_KEYSPLINES +keyTimes, SVG_ATT_TOK_KEYTIMES +max, SVG_ATT_TOK_MAX +min, SVG_ATT_TOK_MIN +origin, SVG_ATT_TOK_ORIGIN +path, SVG_ATT_TOK_PATH +repeatCount, SVG_ATT_TOK_REPEATCOUNT +repeatDur, SVG_ATT_TOK_REPEATDUR +restart, SVG_ATT_TOK_RESTART +rotate, SVG_ATT_TOK_ROTATE +to, SVG_ATT_TOK_TO +type, SVG_ATT_TOK_TYPE +values, SVG_ATT_TOK_VALUES +cx, SVG_ATT_TOK_CX +cy, SVG_ATT_TOK_CY +r, SVG_ATT_TOK_R +clipPathUnits, SVG_ATT_TOK_CLIPPATHUNITS +requiredExtensions, SVG_ATT_TOK_REQUIREDEXTENSIONS +requiredFeatures, SVG_ATT_TOK_REQUIREDFEATURES +systemLanguage, SVG_ATT_TOK_SYSTEMLANGUAGE +class, SVG_ATT_TOK_CLASS +id, SVG_ATT_TOK_ID +style, SVG_ATT_TOK_STYLE +tabindex, SVG_ATT_TOK_TABINDEX +xml:base, SVG_ATT_TOK_XML_BASE +xml:lang, SVG_ATT_TOK_XML_LANG +xml:space, SVG_ATT_TOK_XML_SPACE +rx, SVG_ATT_TOK_RX +ry, SVG_ATT_TOK_RY +feBlend_mode, SVG_ATT_TOK_FEBLEND_MODE +feColorMatrix_type, SVG_ATT_TOK_FECOLORMATRIX_TYPE +feColorMatrix_values, SVG_ATT_TOK_FECOLORMATRIX_VALUES +feComponentTransfer_type, SVG_ATT_TOK_FECOMPONENTTRANSFER_TYPE +feComposite_k1, SVG_ATT_TOK_FECOMPOSITE_K1 +feComposite_k2, SVG_ATT_TOK_FECOMPOSITE_K2 +feComposite_k3, SVG_ATT_TOK_FECOMPOSITE_K3 +feComposite_k4, SVG_ATT_TOK_FECOMPOSITE_K4 +feComposite_operator, SVG_ATT_TOK_FECOMPOSITE_OPERATOR +feConvolveMatrix_bias, SVG_ATT_TOK_FECONVOLVEMATRIX_BIAS +feConvolveMatrix_divisor, SVG_ATT_TOK_FECONVOLVEMATRIX_DIVISOR +feConvolveMatrix_edgeMode, SVG_ATT_TOK_FECONVOLVEMATRIX_EDGEMODE +feConvolveMatrix_kernelMatrix, SVG_ATT_TOK_FECONVOLVEMATRIX_KERNELMATRIX +feConvolveMatrix_kernelUnitLength, SVG_ATT_TOK_FECONVOLVEMATRIX_KERNELUNITLENGTH +feConvolveMatrix_order, SVG_ATT_TOK_FECONVOLVEMATRIX_ORDER +feConvolveMatrix_preserveAlpha, SVG_ATT_TOK_FECONVOLVEMATRIX_PRESERVEALPHA +feConvolveMatrix_targetX, SVG_ATT_TOK_FECONVOLVEMATRIX_TARGETX +feConvolveMatrix_targetY, SVG_ATT_TOK_FECONVOLVEMATRIX_TARGETY +feDiffuseLighting_diffuseConstant, SVG_ATT_TOK_FEDIFFUSELIGHTING_DIFFUSECONSTANT +feDiffuseLighting_kernelUnitLength, SVG_ATT_TOK_FEDIFFUSELIGHTING_KERNELUNITLENGTH +feDiffuseLighting_surfaceScale, SVG_ATT_TOK_FEDIFFUSELIGHTING_SURFACESCALE +feDisplacementMap_scale, SVG_ATT_TOK_FEDISPLACEMENTMAP_SCALE +feDisplacementMap_xChannelSelector, SVG_ATT_TOK_FEDISPLACEMENTMAP_XCHANNELSELECTOR +feDisplacementMap_yChannelSelector, SVG_ATT_TOK_FEDISPLACEMENTMAP_YCHANNELSELECTOR +feDropShadow_dx, SVG_ATT_TOK_FEDROPSHADOW_DX +feDropShadow_dy, SVG_ATT_TOK_FEDROPSHADOW_DY +feDropShadow_stdDeviation, SVG_ATT_TOK_FEDROPSHADOW_STDDEVIATION +feGaussianBlur_edgeMode, SVG_ATT_TOK_FEGAUSSIANBLUR_EDGEMODE +feGaussianBlur_stdDeviation, SVG_ATT_TOK_FEGAUSSIANBLUR_STDDEVIATION +feImage_preserveAspectRatio, SVG_ATT_TOK_FEIMAGE_PRESERVEASPECTRATIO +feMorphology_operator, SVG_ATT_TOK_FEMORPHOLOGY_OPERATOR +feMorphology_radius, SVG_ATT_TOK_FEMORPHOLOGY_RADIUS +feSpecularLighting_kernelUnitLength, SVG_ATT_TOK_FESPECULARLIGHTING_KERNELUNITLENGTH +feSpecularLighting_specularConstant, SVG_ATT_TOK_FESPECULARLIGHTING_SPECULARCONSTANT +feSpecularLighting_specularExponent, SVG_ATT_TOK_FESPECULARLIGHTING_SPECULAREXPONENT +feSpecularLighting_surfaceScale, SVG_ATT_TOK_FESPECULARLIGHTING_SURFACESCALE +feTile, SVG_ATT_TOK_FETILE +feTurbulence_baseFrequency, SVG_ATT_TOK_FETURBULENCE_BASEFREQUENCY +feTurbulence_numOctaves, SVG_ATT_TOK_FETURBULENCE_NUMOCTAVES +feTurbulence_seed, SVG_ATT_TOK_FETURBULENCE_SEED +feTurbulence_stitchTiles, SVG_ATT_TOK_FETURBULENCE_STITCHTILES +feTurbulence_type, SVG_ATT_TOK_FETURBULENCE_TYPE +filterUnits, SVG_ATT_TOK_FILTERUNITS +primitiveUnits, SVG_ATT_TOK_PRIMITIVEUNITS +height, SVG_ATT_TOK_HEIGHT +in, SVG_ATT_TOK_IN +in2, SVG_ATT_TOK_IN2 +result, SVG_ATT_TOK_RESULT +width, SVG_ATT_TOK_WIDTH +x, SVG_ATT_TOK_X +y, SVG_ATT_TOK_Y +crossorigin, SVG_ATT_TOK_CROSSORIGIN +href, SVG_ATT_TOK_HREF +preserveAspectRatio, SVG_ATT_TOK_PRESERVEASPECTRATIO +onabort, SVG_ATT_TOK_ONABORT +onactivate, SVG_ATT_TOK_ONACTIVATE +onbegin, SVG_ATT_TOK_ONBEGIN +onclick, SVG_ATT_TOK_ONCLICK +onend, SVG_ATT_TOK_ONEND +onerror, SVG_ATT_TOK_ONERROR +onfocusin, SVG_ATT_TOK_ONFOCUSIN +onfocusout, SVG_ATT_TOK_ONFOCUSOUT +onkeydown, SVG_ATT_TOK_ONKEYDOWN +onkeypress, SVG_ATT_TOK_ONKEYPRESS +onkeyup, SVG_ATT_TOK_ONKEYUP +onload, SVG_ATT_TOK_ONLOAD +onmousedown, SVG_ATT_TOK_ONMOUSEDOWN +onmousemove, SVG_ATT_TOK_ONMOUSEMOVE +onmouseout, SVG_ATT_TOK_ONMOUSEOUT +onmouseover, SVG_ATT_TOK_ONMOUSEOVER +onmouseup, SVG_ATT_TOK_ONMOUSEUP +onrepeat, SVG_ATT_TOK_ONREPEAT +onresize, SVG_ATT_TOK_ONRESIZE +onscroll, SVG_ATT_TOK_ONSCROLL +onunload, SVG_ATT_TOK_ONUNLOAD +x1, SVG_ATT_TOK_X1 +x2, SVG_ATT_TOK_X2 +y1, SVG_ATT_TOK_Y1 +y2, SVG_ATT_TOK_Y2 +gradientTransform, SVG_ATT_TOK_GRADIENTTRANSFORM +gradientUnits, SVG_ATT_TOK_GRADIENTUNITS +spreadMethod, SVG_ATT_TOK_SPREADMETHOD +markerHeight, SVG_ATT_TOK_MARKERHEIGHT +markerUnits, SVG_ATT_TOK_MARKERUNITS +markerWidth, SVG_ATT_TOK_MARKERWIDTH +orient, SVG_ATT_TOK_ORIENT +refX, SVG_ATT_TOK_REFX +refY, SVG_ATT_TOK_REFY +viewBox, SVG_ATT_TOK_VIEWBOX +maskContentUnits, SVG_ATT_TOK_MASKCONTENTUNITS +maskUnits, SVG_ATT_TOK_MASKUNITS +d, SVG_ATT_TOK_D +pathLength, SVG_ATT_TOK_PATHLENGTH +patternContentUnits, SVG_ATT_TOK_PATTERNCONTENTUNITS +patternTransform, SVG_ATT_TOK_PATTERNTRANSFORM +patternUnits, SVG_ATT_TOK_PATTERNUNITS +points, SVG_ATT_TOK_POINTS +alignment-baseline, SVG_ATT_TOK_ALIGNMENT_BASELINE +baseline-shift, SVG_ATT_TOK_BASELINE_SHIFT +clip, SVG_ATT_TOK_CLIP +clip-path, SVG_ATT_TOK_CLIP_PATH +clip-rule, SVG_ATT_TOK_CLIP_RULE +color, SVG_ATT_TOK_COLOR +color-interpolation, SVG_ATT_TOK_COLOR_INTERPOLATION +color-interpolation-filters, SVG_ATT_TOK_COLOR_INTERPOLATION_FILTERS +color-profile, SVG_ATT_TOK_COLOR_PROFILE +color-rendering, SVG_ATT_TOK_COLOR_RENDERING +cursor, SVG_ATT_TOK_CURSOR +direction, SVG_ATT_TOK_DIRECTION +display, SVG_ATT_TOK_DISPLAY +dominant-baseline, SVG_ATT_TOK_DOMINANT_BASELINE +enable-background, SVG_ATT_TOK_ENABLE_BACKGROUND +fill-opacity, SVG_ATT_TOK_FILL_OPACITY +fill-rule, SVG_ATT_TOK_FILL_RULE +filter, SVG_ATT_TOK_FILTER +flood-color, SVG_ATT_TOK_FLOOD_COLOR +flood-opacity, SVG_ATT_TOK_FLOOD_OPACITY +font-family, SVG_ATT_TOK_FONT_FAMILY +font-size, SVG_ATT_TOK_FONT_SIZE +font-size-adjust, SVG_ATT_TOK_FONT_SIZE_ADJUST +font-stretch, SVG_ATT_TOK_FONT_STRETCH +font-style, SVG_ATT_TOK_FONT_STYLE +font-variant, SVG_ATT_TOK_FONT_VARIANT +font-weight, SVG_ATT_TOK_FONT_WEIGHT +glyph-orientation-horizontal, SVG_ATT_TOK_GLYPH_ORIENTATION_HORIZONTAL +glyph-orientation-vertical, SVG_ATT_TOK_GLYPH_ORIENTATION_VERTICAL +image-rendering, SVG_ATT_TOK_IMAGE_RENDERING +lighting-color, SVG_ATT_TOK_LIGHTING_COLOR +marker-end, SVG_ATT_TOK_MARKER_END +marker-mid, SVG_ATT_TOK_MARKER_MID +marker-start, SVG_ATT_TOK_MARKER_START +mask, SVG_ATT_TOK_MASK +opacity, SVG_ATT_TOK_OPACITY +overflow, SVG_ATT_TOK_OVERFLOW +paint-order, SVG_ATT_TOK_PAINT_ORDER +pointer-events, SVG_ATT_TOK_POINTER_EVENTS +shape-rendering, SVG_ATT_TOK_SHAPE_RENDERING +stop-color, SVG_ATT_TOK_STOP_COLOR +stop-opacity, SVG_ATT_TOK_STOP_OPACITY +stroke, SVG_ATT_TOK_STROKE +stroke-dasharray, SVG_ATT_TOK_STROKE_DASHARRAY +stroke-dashoffset, SVG_ATT_TOK_STROKE_DASHOFFSET +stroke-linecap, SVG_ATT_TOK_STROKE_LINECAP +stroke-linejoin, SVG_ATT_TOK_STROKE_LINEJOIN +stroke-miterlimit, SVG_ATT_TOK_STROKE_MITERLIMIT +stroke-opacity, SVG_ATT_TOK_STROKE_OPACITY +stroke-width, SVG_ATT_TOK_STROKE_WIDTH +text-anchor, SVG_ATT_TOK_TEXT_ANCHOR +text-decoration, SVG_ATT_TOK_TEXT_DECORATION +text-rendering, SVG_ATT_TOK_TEXT_RENDERING +unicode-bidi, SVG_ATT_TOK_UNICODE_BIDI +vector-effect, SVG_ATT_TOK_VECTOR_EFFECT +visibility, SVG_ATT_TOK_VISIBILITY +word-spacing, SVG_ATT_TOK_WORD_SPACING +writing-mode, SVG_ATT_TOK_WRITING_MODE +fr, SVG_ATT_TOK_FR +fx, SVG_ATT_TOK_FX +fy, SVG_ATT_TOK_FY +offset, SVG_ATT_TOK_OFFSET +baseProfile, SVG_ATT_TOK_BASEPROFILE +version, SVG_ATT_TOK_VERSION +zoomAndPan, SVG_ATT_TOK_ZOOMANDPAN +dx, SVG_ATT_TOK_DX +dy, SVG_ATT_TOK_DY +lengthAdjust, SVG_ATT_TOK_LENGTHADJUST +textLength, SVG_ATT_TOK_TEXTLENGTH +method, SVG_ATT_TOK_METHOD +side, SVG_ATT_TOK_SIDE +spacing, SVG_ATT_TOK_SPACING +startOffset, SVG_ATT_TOK_STARTOFFSET +transform, SVG_ATT_TOK_TRANSFORM +xlink:actuate, SVG_ATT_TOK_XLINK_ACTUATE +xlink:arcrole, SVG_ATT_TOK_XLINK_ARCROLE +xlink:href, SVG_ATT_TOK_XLINK_HREF +xlink:role, SVG_ATT_TOK_XLINK_ROLE +xlink:show, SVG_ATT_TOK_XLINK_SHOW +xlink:title, SVG_ATT_TOK_XLINK_TITLE + xlink:type, SVG_ATT_TOK_XLINK_TYPE +%% +const struct SvgAttKeyword* +lookup_svg_att_token (register const char *str, register size_t len) +{ + if (len <= ATT_MAX_WORD_LENGTH && len >= ATT_MIN_WORD_LENGTH) + { + register unsigned int key = hash_svg_att (str, len); + + if (key <= ATT_MAX_HASH_VALUE) + { + register const char *s = svg_att_wordlist[key].name; + + if (*str == *s && !memcmp (str + 1, s + 1, len -1) && s[len] == '\0') + return &svg_att_wordlist[key]; + } + } + return (struct SvgAttKeyword *) 0; +} diff --git a/tests/svg-parser-new/svg_colors_gperf.h b/tests/svg-parser-new/svg_colors_gperf.h index d3cf630..08cc198 100644 --- a/tests/svg-parser-new/svg_colors_gperf.h +++ b/tests/svg-parser-new/svg_colors_gperf.h @@ -31,12 +31,13 @@ #line 1 "src/svg_colors_names.gperf" -#include <string.h> +#include <stddef.h> #include <stdint.h> +#include "cross_os.h" /* Enum representing our supported SVG elements and attributes */ typedef enum { - SVG_COLOR_UNKNOWN, + SVG_COLOR_UNKNOWN, SVG_COLOR_ALICEBLUE, SVG_COLOR_ANTIQUEWHITE, SVG_COLOR_AQUA, @@ -192,7 +193,7 @@ struct SvgColorName { SvgColorTokId id; uint32_t value; }; -#line 175 "src/svg_colors_names.gperf" +#line 176 "src/svg_colors_names.gperf" struct SvgColorName; #define SVG_COL__TOTAL_KEYWORDS 147 @@ -354,398 +355,398 @@ hash_svg_color (register const char *str, register size_t len) static const struct SvgColorName svg_color_wordlist[] = { {""}, {""}, {""}, {""}, -#line 198 "src/svg_colors_names.gperf" +#line 199 "src/svg_colors_names.gperf" {"cyan", SVG_COLOR_CYAN, 0xffffff00}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, -#line 231 "src/svg_colors_names.gperf" +#line 232 "src/svg_colors_names.gperf" {"gray", SVG_COLOR_GRAY, 0xff808080}, {""}, {""}, {""}, {""}, {""}, -#line 192 "src/svg_colors_names.gperf" +#line 193 "src/svg_colors_names.gperf" {"chartreuse", SVG_COLOR_CHARTREUSE, 0xff00ff7f}, {""}, {""}, {""}, -#line 234 "src/svg_colors_names.gperf" +#line 235 "src/svg_colors_names.gperf" {"grey", SVG_COLOR_GREY, 0xff808080}, -#line 232 "src/svg_colors_names.gperf" +#line 233 "src/svg_colors_names.gperf" {"green", SVG_COLOR_GREEN, 0xff008000}, {""}, {""}, {""}, -#line 251 "src/svg_colors_names.gperf" +#line 252 "src/svg_colors_names.gperf" {"lightgrey", SVG_COLOR_LIGHTGREY, 0xffd3d3d3}, -#line 250 "src/svg_colors_names.gperf" +#line 251 "src/svg_colors_names.gperf" {"lightgreen", SVG_COLOR_LIGHTGREEN, 0xff90ee90}, {""}, {""}, {""}, -#line 249 "src/svg_colors_names.gperf" +#line 250 "src/svg_colors_names.gperf" {"lightgray", SVG_COLOR_LIGHTGRAY, 0xffd3d3d3}, {""}, {""}, -#line 307 "src/svg_colors_names.gperf" +#line 308 "src/svg_colors_names.gperf" {"skyblue", SVG_COLOR_SKYBLUE, 0xffebce87}, {""}, -#line 310 "src/svg_colors_names.gperf" +#line 311 "src/svg_colors_names.gperf" {"slategrey", SVG_COLOR_SLATEGREY, 0xff908070}, {""}, -#line 305 "src/svg_colors_names.gperf" +#line 306 "src/svg_colors_names.gperf" {"sienna", SVG_COLOR_SIENNA, 0xff2d52a0}, {""}, {""}, -#line 309 "src/svg_colors_names.gperf" +#line 310 "src/svg_colors_names.gperf" {"slategray", SVG_COLOR_SLATEGRAY, 0xff908070}, {""}, {""}, {""}, -#line 304 "src/svg_colors_names.gperf" +#line 305 "src/svg_colors_names.gperf" {"seashell", SVG_COLOR_SEASHELL, 0xffeef5ff}, -#line 315 "src/svg_colors_names.gperf" +#line 316 "src/svg_colors_names.gperf" {"teal", SVG_COLOR_TEAL, 0xff808000}, -#line 194 "src/svg_colors_names.gperf" +#line 195 "src/svg_colors_names.gperf" {"coral", SVG_COLOR_CORAL, 0xff507fff}, {""}, {""}, {""}, {""}, {""}, -#line 253 "src/svg_colors_names.gperf" +#line 254 "src/svg_colors_names.gperf" {"lightsalmon", SVG_COLOR_LIGHTSALMON, 0xff7aa0ff}, {""}, {""}, -#line 257 "src/svg_colors_names.gperf" +#line 258 "src/svg_colors_names.gperf" {"lightslategrey", SVG_COLOR_LIGHTSLATEGREY, 0xff998877}, -#line 185 "src/svg_colors_names.gperf" +#line 186 "src/svg_colors_names.gperf" {"black", SVG_COLOR_BLACK, 0xff000000}, {""}, {""}, {""}, -#line 256 "src/svg_colors_names.gperf" +#line 257 "src/svg_colors_names.gperf" {"lightslategray", SVG_COLOR_LIGHTSLATEGRAY, 0xff998877}, {""}, -#line 283 "src/svg_colors_names.gperf" +#line 284 "src/svg_colors_names.gperf" {"orange", SVG_COLOR_ORANGE, 0xff00a5ff}, {""}, {""}, -#line 284 "src/svg_colors_names.gperf" +#line 285 "src/svg_colors_names.gperf" {"orangered", SVG_COLOR_ORANGERED, 0xff0045ff}, {""}, -#line 184 "src/svg_colors_names.gperf" +#line 185 "src/svg_colors_names.gperf" {"bisque", SVG_COLOR_BISQUE, 0xffc4e4ff}, {""}, {""}, -#line 260 "src/svg_colors_names.gperf" +#line 261 "src/svg_colors_names.gperf" {"lime", SVG_COLOR_LIME, 0xff00ff00}, {""}, {""}, {""}, -#line 297 "src/svg_colors_names.gperf" +#line 298 "src/svg_colors_names.gperf" {"red", SVG_COLOR_RED, 0xff0000ff}, -#line 261 "src/svg_colors_names.gperf" +#line 262 "src/svg_colors_names.gperf" {"limegreen", SVG_COLOR_LIMEGREEN, 0xff32cd32}, -#line 246 "src/svg_colors_names.gperf" +#line 247 "src/svg_colors_names.gperf" {"lightcoral", SVG_COLOR_LIGHTCORAL, 0xff8080f0}, {""}, {""}, {""}, -#line 299 "src/svg_colors_names.gperf" +#line 300 "src/svg_colors_names.gperf" {"royalblue", SVG_COLOR_ROYALBLUE, 0xffe16941}, -#line 262 "src/svg_colors_names.gperf" +#line 263 "src/svg_colors_names.gperf" {"linen", SVG_COLOR_LINEN, 0xffe6f0fa}, {""}, -#line 226 "src/svg_colors_names.gperf" +#line 227 "src/svg_colors_names.gperf" {"fuchsia", SVG_COLOR_FUCHSIA, 0xffff00ff}, {""}, -#line 203 "src/svg_colors_names.gperf" +#line 204 "src/svg_colors_names.gperf" {"darkgreen", SVG_COLOR_DARKGREEN, 0xff006400}, {""}, {""}, {""}, {""}, -#line 245 "src/svg_colors_names.gperf" +#line 246 "src/svg_colors_names.gperf" {"lightblue", SVG_COLOR_LIGHTBLUE, 0xffe6d8ad}, -#line 209 "src/svg_colors_names.gperf" +#line 210 "src/svg_colors_names.gperf" {"darkorchid", SVG_COLOR_DARKORCHID, 0xffcc3299}, -#line 312 "src/svg_colors_names.gperf" +#line 313 "src/svg_colors_names.gperf" {"springgreen", SVG_COLOR_SPRINGGREEN, 0xff7fff00}, -#line 263 "src/svg_colors_names.gperf" +#line 264 "src/svg_colors_names.gperf" {"magenta", SVG_COLOR_MAGENTA, 0xffff00ff}, {""}, -#line 229 "src/svg_colors_names.gperf" +#line 230 "src/svg_colors_names.gperf" {"gold", SVG_COLOR_GOLD, 0xff00d7ff}, {""}, -#line 285 "src/svg_colors_names.gperf" +#line 286 "src/svg_colors_names.gperf" {"orchid", SVG_COLOR_ORCHID, 0xffd670da}, {""}, {""}, -#line 308 "src/svg_colors_names.gperf" +#line 309 "src/svg_colors_names.gperf" {"slateblue", SVG_COLOR_SLATEBLUE, 0xffcd5a6a}, {""}, -#line 206 "src/svg_colors_names.gperf" +#line 207 "src/svg_colors_names.gperf" {"darkmagenta", SVG_COLOR_DARKMAGENTA, 0xff8b008b}, {""}, -#line 199 "src/svg_colors_names.gperf" +#line 200 "src/svg_colors_names.gperf" {"darkblue", SVG_COLOR_DARKBLUE, 0xff8b0000}, -#line 258 "src/svg_colors_names.gperf" +#line 259 "src/svg_colors_names.gperf" {"lightsteelblue", SVG_COLOR_LIGHTSTEELBLUE, 0xffdec4b0}, {""}, -#line 306 "src/svg_colors_names.gperf" +#line 307 "src/svg_colors_names.gperf" {"silver", SVG_COLOR_SILVER, 0xffc0c0c0}, {""}, -#line 303 "src/svg_colors_names.gperf" +#line 304 "src/svg_colors_names.gperf" {"seagreen", SVG_COLOR_SEAGREEN, 0xff578b2e}, -#line 313 "src/svg_colors_names.gperf" +#line 314 "src/svg_colors_names.gperf" {"steelblue", SVG_COLOR_STEELBLUE, 0xffb48246}, {""}, {""}, {""}, -#line 314 "src/svg_colors_names.gperf" +#line 315 "src/svg_colors_names.gperf" {"tan", SVG_COLOR_TAN, 0xff8cb4d2}, -#line 292 "src/svg_colors_names.gperf" +#line 293 "src/svg_colors_names.gperf" {"peru", SVG_COLOR_PERU, 0xff3f85cd}, {""}, -#line 296 "src/svg_colors_names.gperf" +#line 297 "src/svg_colors_names.gperf" {"purple", SVG_COLOR_PURPLE, 0xff800080}, -#line 210 "src/svg_colors_names.gperf" +#line 211 "src/svg_colors_names.gperf" {"darkred", SVG_COLOR_DARKRED, 0xff00008b}, {""}, -#line 275 "src/svg_colors_names.gperf" +#line 276 "src/svg_colors_names.gperf" {"mintcream", SVG_COLOR_MINTCREAM, 0xfffafff5}, {""}, {""}, {""}, {""}, -#line 223 "src/svg_colors_names.gperf" +#line 224 "src/svg_colors_names.gperf" {"firebrick", SVG_COLOR_FIREBRICK, 0xff2222b2}, {""}, {""}, {""}, -#line 254 "src/svg_colors_names.gperf" +#line 255 "src/svg_colors_names.gperf" {"lightseagreen", SVG_COLOR_LIGHTSEAGREEN, 0xffaab220}, -#line 207 "src/svg_colors_names.gperf" +#line 208 "src/svg_colors_names.gperf" {"darkolivegreen", SVG_COLOR_DARKOLIVEGREEN, 0xff2f6b55}, {""}, {""}, {""}, {""}, -#line 276 "src/svg_colors_names.gperf" +#line 277 "src/svg_colors_names.gperf" {"mistyrose", SVG_COLOR_MISTYROSE, 0xffe1e4ff}, {""}, -#line 238 "src/svg_colors_names.gperf" +#line 239 "src/svg_colors_names.gperf" {"indigo", SVG_COLOR_INDIGO, 0xff82004b}, -#line 280 "src/svg_colors_names.gperf" +#line 281 "src/svg_colors_names.gperf" {"oldlace", SVG_COLOR_OLDLACE, 0xffe6f5fd}, {""}, -#line 293 "src/svg_colors_names.gperf" +#line 294 "src/svg_colors_names.gperf" {"pink", SVG_COLOR_PINK, 0xffcbc0ff}, -#line 211 "src/svg_colors_names.gperf" +#line 212 "src/svg_colors_names.gperf" {"darksalmon", SVG_COLOR_DARKSALMON, 0xff7a96e9}, {""}, {""}, -#line 241 "src/svg_colors_names.gperf" +#line 242 "src/svg_colors_names.gperf" {"lavender", SVG_COLOR_LAVENDER, 0xfffae6e6}, -#line 239 "src/svg_colors_names.gperf" +#line 240 "src/svg_colors_names.gperf" {"ivory", SVG_COLOR_IVORY, 0xfff0ffff}, {""}, {""}, {""}, -#line 277 "src/svg_colors_names.gperf" +#line 278 "src/svg_colors_names.gperf" {"moccasin", SVG_COLOR_MOCCASIN, 0xffb5e4ff}, {""}, {""}, {""}, {""}, {""}, -#line 191 "src/svg_colors_names.gperf" +#line 192 "src/svg_colors_names.gperf" {"cadetblue", SVG_COLOR_CADETBLUE, 0xffa09e5f}, -#line 217 "src/svg_colors_names.gperf" +#line 218 "src/svg_colors_names.gperf" {"darkviolet", SVG_COLOR_DARKVIOLET, 0xffd30094}, -#line 300 "src/svg_colors_names.gperf" +#line 301 "src/svg_colors_names.gperf" {"saddlebrown", SVG_COLOR_SADDLEBROWN, 0xff13458b}, {""}, -#line 213 "src/svg_colors_names.gperf" +#line 214 "src/svg_colors_names.gperf" {"darkslateblue", SVG_COLOR_DARKSLATEBLUE, 0xff8b3d48}, -#line 287 "src/svg_colors_names.gperf" +#line 288 "src/svg_colors_names.gperf" {"palegreen", SVG_COLOR_PALEGREEN, 0xff98fb98}, {""}, {""}, {""}, -#line 311 "src/svg_colors_names.gperf" +#line 312 "src/svg_colors_names.gperf" {"snow", SVG_COLOR_SNOW, 0xfffafaff}, -#line 237 "src/svg_colors_names.gperf" +#line 238 "src/svg_colors_names.gperf" {"indianred", SVG_COLOR_INDIANRED, 0xff5c5ccd}, -#line 248 "src/svg_colors_names.gperf" +#line 249 "src/svg_colors_names.gperf" {"lightgoldenrodyellow", SVG_COLOR_LIGHTGOLDENRODYELLOW, 0xffd2fafa}, -#line 317 "src/svg_colors_names.gperf" +#line 318 "src/svg_colors_names.gperf" {"tomato", SVG_COLOR_TOMATO, 0xff4763ff}, -#line 244 "src/svg_colors_names.gperf" +#line 245 "src/svg_colors_names.gperf" {"lemonchiffon", SVG_COLOR_LEMONCHIFFON, 0xffcdfaff}, {""}, -#line 252 "src/svg_colors_names.gperf" +#line 253 "src/svg_colors_names.gperf" {"lightpink", SVG_COLOR_LIGHTPINK, 0xffc1b6ff}, {""}, -#line 264 "src/svg_colors_names.gperf" +#line 265 "src/svg_colors_names.gperf" {"maroon", SVG_COLOR_MAROON, 0xff000080}, {""}, -#line 242 "src/svg_colors_names.gperf" +#line 243 "src/svg_colors_names.gperf" {"lavenderblush", SVG_COLOR_LAVENDERBLUSH, 0xfff5f0ff}, -#line 318 "src/svg_colors_names.gperf" +#line 319 "src/svg_colors_names.gperf" {"turquoise", SVG_COLOR_TURQUOISE, 0xffd0e040}, -#line 208 "src/svg_colors_names.gperf" +#line 209 "src/svg_colors_names.gperf" {"darkorange", SVG_COLOR_DARKORANGE, 0xff008cff}, {""}, {""}, {""}, -#line 279 "src/svg_colors_names.gperf" +#line 280 "src/svg_colors_names.gperf" {"navy", SVG_COLOR_NAVY, 0xff800000}, -#line 222 "src/svg_colors_names.gperf" +#line 223 "src/svg_colors_names.gperf" {"dodgerblue", SVG_COLOR_DODGERBLUE, 0xffff901e}, -#line 225 "src/svg_colors_names.gperf" +#line 226 "src/svg_colors_names.gperf" {"forestgreen", SVG_COLOR_FORESTGREEN, 0xff228b22}, -#line 274 "src/svg_colors_names.gperf" +#line 275 "src/svg_colors_names.gperf" {"midnightblue", SVG_COLOR_MIDNIGHTBLUE, 0xff701919}, {""}, -#line 269 "src/svg_colors_names.gperf" +#line 270 "src/svg_colors_names.gperf" {"mediumseagreen", SVG_COLOR_MEDIUMSEAGREEN, 0xff71b33c}, {""}, {""}, -#line 212 "src/svg_colors_names.gperf" +#line 213 "src/svg_colors_names.gperf" {"darkseagreen", SVG_COLOR_DARKSEAGREEN, 0xff8fbc8f}, {""}, -#line 180 "src/svg_colors_names.gperf" +#line 181 "src/svg_colors_names.gperf" {"aqua", SVG_COLOR_AQUA, 0xffffff00}, -#line 182 "src/svg_colors_names.gperf" +#line 183 "src/svg_colors_names.gperf" {"azure", SVG_COLOR_AZURE, 0xfffffff0}, -#line 301 "src/svg_colors_names.gperf" +#line 302 "src/svg_colors_names.gperf" {"salmon", SVG_COLOR_SALMON, 0xff7280fa}, {""}, {""}, {""}, -#line 320 "src/svg_colors_names.gperf" +#line 321 "src/svg_colors_names.gperf" {"wheat", SVG_COLOR_WHEAT, 0xffb3def5}, {""}, {""}, {""}, -#line 189 "src/svg_colors_names.gperf" +#line 190 "src/svg_colors_names.gperf" {"brown", SVG_COLOR_BROWN, 0xff2a2aa5}, -#line 181 "src/svg_colors_names.gperf" +#line 182 "src/svg_colors_names.gperf" {"aquamarine", SVG_COLOR_AQUAMARINE, 0xffd4ff7f}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, -#line 193 "src/svg_colors_names.gperf" +#line 194 "src/svg_colors_names.gperf" {"chocolate", SVG_COLOR_CHOCOLATE, 0xff1e69d2}, -#line 243 "src/svg_colors_names.gperf" +#line 244 "src/svg_colors_names.gperf" {"lawngreen", SVG_COLOR_LAWNGREEN, 0xff00fc7c}, -#line 302 "src/svg_colors_names.gperf" +#line 303 "src/svg_colors_names.gperf" {"sandybrown", SVG_COLOR_SANDYBROWN, 0xff60a4f4}, {""}, {""}, {""}, -#line 247 "src/svg_colors_names.gperf" +#line 248 "src/svg_colors_names.gperf" {"lightcyan", SVG_COLOR_LIGHTCYAN, 0xffffffe0}, {""}, {""}, {""}, {""}, {""}, -#line 319 "src/svg_colors_names.gperf" +#line 320 "src/svg_colors_names.gperf" {"violet", SVG_COLOR_VIOLET, 0xffee82ee}, -#line 259 "src/svg_colors_names.gperf" +#line 260 "src/svg_colors_names.gperf" {"lightyellow", SVG_COLOR_LIGHTYELLOW, 0xffeeffff}, {""}, {""}, {""}, -#line 266 "src/svg_colors_names.gperf" +#line 267 "src/svg_colors_names.gperf" {"mediumblue", SVG_COLOR_MEDIUMBLUE, 0xffcd0000}, {""}, {""}, {""}, -#line 291 "src/svg_colors_names.gperf" +#line 292 "src/svg_colors_names.gperf" {"peachpuff", SVG_COLOR_PEACHPUFF, 0xffb9daff}, {""}, -#line 233 "src/svg_colors_names.gperf" +#line 234 "src/svg_colors_names.gperf" {"greenyellow", SVG_COLOR_GREENYELLOW, 0xff2fffad}, {""}, {""}, {""}, {""}, {""}, -#line 179 "src/svg_colors_names.gperf" +#line 180 "src/svg_colors_names.gperf" {"antiquewhite", SVG_COLOR_ANTIQUEWHITE, 0xffd7ebfa}, {""}, -#line 187 "src/svg_colors_names.gperf" +#line 188 "src/svg_colors_names.gperf" {"blue", SVG_COLOR_BLUE, 0xffff0000}, -#line 273 "src/svg_colors_names.gperf" +#line 274 "src/svg_colors_names.gperf" {"mediumvioletred", SVG_COLOR_MEDIUMVIOLETRED, 0xff8515c7}, {""}, -#line 268 "src/svg_colors_names.gperf" +#line 269 "src/svg_colors_names.gperf" {"mediumpurple", SVG_COLOR_MEDIUMPURPLE, 0xffdb7093}, {""}, -#line 230 "src/svg_colors_names.gperf" +#line 231 "src/svg_colors_names.gperf" {"goldenrod", SVG_COLOR_GOLDENROD, 0xff20a5da}, {""}, {""}, {""}, {""}, -#line 186 "src/svg_colors_names.gperf" +#line 187 "src/svg_colors_names.gperf" {"blanchedalmond", SVG_COLOR_BLANCHEDALMOND, 0xffcdebff}, -#line 240 "src/svg_colors_names.gperf" +#line 241 "src/svg_colors_names.gperf" {"khaki", SVG_COLOR_KHAKI, 0xff8ce6f0}, {""}, {""}, {""}, -#line 294 "src/svg_colors_names.gperf" +#line 295 "src/svg_colors_names.gperf" {"plum", SVG_COLOR_PLUM, 0xffdda0dd}, {""}, {""}, -#line 267 "src/svg_colors_names.gperf" +#line 268 "src/svg_colors_names.gperf" {"mediumorchid", SVG_COLOR_MEDIUMORCHID, 0xffd355ba}, {""}, -#line 298 "src/svg_colors_names.gperf" +#line 299 "src/svg_colors_names.gperf" {"rosybrown", SVG_COLOR_ROSYBROWN, 0xff8f8fbc}, -#line 270 "src/svg_colors_names.gperf" +#line 271 "src/svg_colors_names.gperf" {"mediumslateblue", SVG_COLOR_MEDIUMSLATEBLUE, 0xffee687b}, {""}, -#line 216 "src/svg_colors_names.gperf" +#line 217 "src/svg_colors_names.gperf" {"darkturquoise", SVG_COLOR_DARKTURQUOISE, 0xffd1ce00}, {""}, {""}, {""}, {""}, {""}, -#line 289 "src/svg_colors_names.gperf" +#line 290 "src/svg_colors_names.gperf" {"palevioletred", SVG_COLOR_PALEVIOLETRED, 0xff9370db}, {""}, -#line 290 "src/svg_colors_names.gperf" +#line 291 "src/svg_colors_names.gperf" {"papayawhip", SVG_COLOR_PAPAYAWHIP, 0xffd5efff}, {""}, {""}, {""}, {""}, {""}, {""}, -#line 271 "src/svg_colors_names.gperf" +#line 272 "src/svg_colors_names.gperf" {"mediumspringgreen", SVG_COLOR_MEDIUMSPRINGGREEN, 0xff9afa00}, -#line 204 "src/svg_colors_names.gperf" +#line 205 "src/svg_colors_names.gperf" {"darkgrey", SVG_COLOR_DARKGREY, 0xffa9a9a9}, {""}, -#line 272 "src/svg_colors_names.gperf" +#line 273 "src/svg_colors_names.gperf" {"mediumturquoise", SVG_COLOR_MEDIUMTURQUOISE, 0xffccd148}, {""}, {""}, -#line 202 "src/svg_colors_names.gperf" +#line 203 "src/svg_colors_names.gperf" {"darkgray", SVG_COLOR_DARKGRAY, 0xffa9a9a9}, {""}, {""}, {""}, {""}, -#line 201 "src/svg_colors_names.gperf" +#line 202 "src/svg_colors_names.gperf" {"darkgoldenrod", SVG_COLOR_DARKGOLDENROD, 0xff0b86b8}, {""}, {""}, {""}, -#line 221 "src/svg_colors_names.gperf" +#line 222 "src/svg_colors_names.gperf" {"dimgrey", SVG_COLOR_DIMGREY, 0xff696969}, {""}, {""}, {""}, {""}, -#line 220 "src/svg_colors_names.gperf" +#line 221 "src/svg_colors_names.gperf" {"dimgray", SVG_COLOR_DIMGRAY, 0xff696969}, -#line 235 "src/svg_colors_names.gperf" +#line 236 "src/svg_colors_names.gperf" {"honeydew", SVG_COLOR_HONEYDEW, 0xfff0fff0}, {""}, {""}, {""}, {""}, {""}, {""}, -#line 183 "src/svg_colors_names.gperf" +#line 184 "src/svg_colors_names.gperf" {"beige", SVG_COLOR_BEIGE, 0xffdcf5f5}, {""}, -#line 316 "src/svg_colors_names.gperf" +#line 317 "src/svg_colors_names.gperf" {"thistle", SVG_COLOR_THISTLE, 0xffd8bfd8}, -#line 196 "src/svg_colors_names.gperf" +#line 197 "src/svg_colors_names.gperf" {"cornsilk", SVG_COLOR_CORNSILK, 0xffdcf8ff}, {""}, -#line 281 "src/svg_colors_names.gperf" +#line 282 "src/svg_colors_names.gperf" {"olive", SVG_COLOR_OLIVE, 0xff008080}, {""}, {""}, {""}, {""}, -#line 188 "src/svg_colors_names.gperf" +#line 189 "src/svg_colors_names.gperf" {"blueviolet", SVG_COLOR_BLUEVIOLET, 0xffe22b8a}, {""}, {""}, {""}, {""}, -#line 265 "src/svg_colors_names.gperf" +#line 266 "src/svg_colors_names.gperf" {"mediumaquamarine", SVG_COLOR_MEDIUMAQUAMARINE, 0xffaacd66}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, -#line 195 "src/svg_colors_names.gperf" +#line 196 "src/svg_colors_names.gperf" {"cornflowerblue", SVG_COLOR_CORNFLOWERBLUE, 0xffed9564}, {""}, {""}, {""}, {""}, -#line 178 "src/svg_colors_names.gperf" +#line 179 "src/svg_colors_names.gperf" {"aliceblue", SVG_COLOR_ALICEBLUE, 0xfffff8f0}, -#line 295 "src/svg_colors_names.gperf" +#line 296 "src/svg_colors_names.gperf" {"powderblue", SVG_COLOR_POWDERBLUE, 0xffe6e0b0}, {""}, -#line 288 "src/svg_colors_names.gperf" +#line 289 "src/svg_colors_names.gperf" {"paleturquoise", SVG_COLOR_PALETURQUOISE, 0xffeeeeaf}, {""}, {""}, {""}, {""}, {""}, -#line 215 "src/svg_colors_names.gperf" +#line 216 "src/svg_colors_names.gperf" {"darkslategrey", SVG_COLOR_DARKSLATEGREY, 0xff4f4f2f}, -#line 205 "src/svg_colors_names.gperf" +#line 206 "src/svg_colors_names.gperf" {"darkkhaki", SVG_COLOR_DARKKHAKI, 0xff6bb7bd}, {""}, {""}, {""}, -#line 214 "src/svg_colors_names.gperf" +#line 215 "src/svg_colors_names.gperf" {"darkslategray", SVG_COLOR_DARKSLATEGRAY, 0xff4f4f2f}, -#line 228 "src/svg_colors_names.gperf" +#line 229 "src/svg_colors_names.gperf" {"ghostwhite", SVG_COLOR_GHOSTWHITE, 0xfffff8f8}, {""}, {""}, {""}, {""}, -#line 282 "src/svg_colors_names.gperf" +#line 283 "src/svg_colors_names.gperf" {"olivedrab", SVG_COLOR_OLIVEDRAB, 0xff238e6b}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, -#line 286 "src/svg_colors_names.gperf" +#line 287 "src/svg_colors_names.gperf" {"palegoldenrod", SVG_COLOR_PALEGOLDENROD, 0xffaae8ee}, {""}, {""}, {""}, {""}, -#line 200 "src/svg_colors_names.gperf" +#line 201 "src/svg_colors_names.gperf" {"darkcyan", SVG_COLOR_DARKCYAN, 0xff8b8b00}, {""}, {""}, {""}, -#line 236 "src/svg_colors_names.gperf" +#line 237 "src/svg_colors_names.gperf" {"hotpink", SVG_COLOR_HOTPINK, 0xffb469ff}, {""}, {""}, {""}, {""}, {""}, {""}, -#line 227 "src/svg_colors_names.gperf" +#line 228 "src/svg_colors_names.gperf" {"gainsboro", SVG_COLOR_GAINSBORO, 0xffdcdcdc}, {""}, {""}, {""}, -#line 218 "src/svg_colors_names.gperf" +#line 219 "src/svg_colors_names.gperf" {"deeppink", SVG_COLOR_DEEPPINK, 0xff9314ff}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, -#line 197 "src/svg_colors_names.gperf" +#line 198 "src/svg_colors_names.gperf" {"crimson", SVG_COLOR_CRIMSON, 0xff3c14dc}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, -#line 190 "src/svg_colors_names.gperf" +#line 191 "src/svg_colors_names.gperf" {"burlywood", SVG_COLOR_BURLYWOOD, 0xff87b8de}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, -#line 224 "src/svg_colors_names.gperf" +#line 225 "src/svg_colors_names.gperf" {"floralwhite", SVG_COLOR_FLORALWHITE, 0xfff0faff}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, -#line 321 "src/svg_colors_names.gperf" +#line 322 "src/svg_colors_names.gperf" {"white", SVG_COLOR_WHITE, 0xffffffff}, -#line 278 "src/svg_colors_names.gperf" +#line 279 "src/svg_colors_names.gperf" {"navajowhite", SVG_COLOR_NAVAJOWHITE, 0xffaddeff}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, -#line 323 "src/svg_colors_names.gperf" +#line 324 "src/svg_colors_names.gperf" {"yellow", SVG_COLOR_YELLOW, 0xff00ffff}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, -#line 324 "src/svg_colors_names.gperf" +#line 325 "src/svg_colors_names.gperf" {"yellowgreen", SVG_COLOR_YELLOWGREEN, 0xff32cd9a}, -#line 255 "src/svg_colors_names.gperf" +#line 256 "src/svg_colors_names.gperf" {"lightskyblue", SVG_COLOR_LIGHTSKYBLUE, 0xffface87}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, @@ -755,10 +756,10 @@ static const struct SvgColorName svg_color_wordlist[] = {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, -#line 219 "src/svg_colors_names.gperf" +#line 220 "src/svg_colors_names.gperf" {"deepskyblue", SVG_COLOR_DEEPSKYBLUE, 0xffffbf00}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, -#line 322 "src/svg_colors_names.gperf" +#line 323 "src/svg_colors_names.gperf" {"whitesmoke", SVG_COLOR_WHITESMOKE, 0xfff5f5f5} }; #if (defined __GNUC__ && __GNUC__ + (__GNUC_MINOR__ >= 6) > 4) || (defined __clang__ && __clang_major__ >= 3) @@ -782,7 +783,7 @@ lookup_svg_color_names_default (register const char *str, register size_t len) } return (struct SvgColorName *) 0; } -#line 325 "src/svg_colors_names.gperf" +#line 326 "src/svg_colors_names.gperf" const struct SvgColorName * lookup_svg_color_names (register const char *str, register size_t len) diff --git a/tests/svg-parser-new/svg_colors_names.gperf b/tests/svg-parser-new/svg_colors_names.gperf new file mode 100644 index 0000000..8877bdf --- /dev/null +++ b/tests/svg-parser-new/svg_colors_names.gperf @@ -0,0 +1,343 @@ +%{ +#include <stddef.h> +#include <stdint.h> +#include "cross_os.h" + +/* Enum representing our supported SVG elements and attributes */ +typedef enum { + SVG_COLOR_UNKNOWN, + SVG_COLOR_ALICEBLUE, + SVG_COLOR_ANTIQUEWHITE, + SVG_COLOR_AQUA, + SVG_COLOR_AQUAMARINE, + SVG_COLOR_AZURE, + SVG_COLOR_BEIGE, + SVG_COLOR_BISQUE, + SVG_COLOR_BLACK, + SVG_COLOR_BLANCHEDALMOND, + SVG_COLOR_BLUE, + SVG_COLOR_BLUEVIOLET, + SVG_COLOR_BROWN, + SVG_COLOR_BURLYWOOD, + SVG_COLOR_CADETBLUE, + SVG_COLOR_CHARTREUSE, + SVG_COLOR_CHOCOLATE, + SVG_COLOR_CORAL, + SVG_COLOR_CORNFLOWERBLUE, + SVG_COLOR_CORNSILK, + SVG_COLOR_CRIMSON, + SVG_COLOR_CYAN, + SVG_COLOR_DARKBLUE, + SVG_COLOR_DARKCYAN, + SVG_COLOR_DARKGOLDENROD, + SVG_COLOR_DARKGRAY, + SVG_COLOR_DARKGREEN, + SVG_COLOR_DARKGREY, + SVG_COLOR_DARKKHAKI, + SVG_COLOR_DARKMAGENTA, + SVG_COLOR_DARKOLIVEGREEN, + SVG_COLOR_DARKORANGE, + SVG_COLOR_DARKORCHID, + SVG_COLOR_DARKRED, + SVG_COLOR_DARKSALMON, + SVG_COLOR_DARKSEAGREEN, + SVG_COLOR_DARKSLATEBLUE, + SVG_COLOR_DARKSLATEGRAY, + SVG_COLOR_DARKSLATEGREY, + SVG_COLOR_DARKTURQUOISE, + SVG_COLOR_DARKVIOLET, + SVG_COLOR_DEEPPINK, + SVG_COLOR_DEEPSKYBLUE, + SVG_COLOR_DIMGRAY, + SVG_COLOR_DIMGREY, + SVG_COLOR_DODGERBLUE, + SVG_COLOR_FIREBRICK, + SVG_COLOR_FLORALWHITE, + SVG_COLOR_FORESTGREEN, + SVG_COLOR_FUCHSIA, + SVG_COLOR_GAINSBORO, + SVG_COLOR_GHOSTWHITE, + SVG_COLOR_GOLD, + SVG_COLOR_GOLDENROD, + SVG_COLOR_GRAY, + SVG_COLOR_GREEN, + SVG_COLOR_GREENYELLOW, + SVG_COLOR_GREY, + SVG_COLOR_HONEYDEW, + SVG_COLOR_HOTPINK, + SVG_COLOR_INDIANRED, + SVG_COLOR_INDIGO, + SVG_COLOR_IVORY, + SVG_COLOR_KHAKI, + SVG_COLOR_LAVENDER, + SVG_COLOR_LAVENDERBLUSH, + SVG_COLOR_LAWNGREEN, + SVG_COLOR_LEMONCHIFFON, + SVG_COLOR_LIGHTBLUE, + SVG_COLOR_LIGHTCORAL, + SVG_COLOR_LIGHTCYAN, + SVG_COLOR_LIGHTGOLDENRODYELLOW, + SVG_COLOR_LIGHTGRAY, + SVG_COLOR_LIGHTGREEN, + SVG_COLOR_LIGHTGREY, + SVG_COLOR_LIGHTPINK, + SVG_COLOR_LIGHTSALMON, + SVG_COLOR_LIGHTSEAGREEN, + SVG_COLOR_LIGHTSKYBLUE, + SVG_COLOR_LIGHTSLATEGRAY, + SVG_COLOR_LIGHTSLATEGREY, + SVG_COLOR_LIGHTSTEELBLUE, + SVG_COLOR_LIGHTYELLOW, + SVG_COLOR_LIME, + SVG_COLOR_LIMEGREEN, + SVG_COLOR_LINEN, + SVG_COLOR_MAGENTA, + SVG_COLOR_MAROON, + SVG_COLOR_MEDIUMAQUAMARINE, + SVG_COLOR_MEDIUMBLUE, + SVG_COLOR_MEDIUMORCHID, + SVG_COLOR_MEDIUMPURPLE, + SVG_COLOR_MEDIUMSEAGREEN, + SVG_COLOR_MEDIUMSLATEBLUE, + SVG_COLOR_MEDIUMSPRINGGREEN, + SVG_COLOR_MEDIUMTURQUOISE, + SVG_COLOR_MEDIUMVIOLETRED, + SVG_COLOR_MIDNIGHTBLUE, + SVG_COLOR_MINTCREAM, + SVG_COLOR_MISTYROSE, + SVG_COLOR_MOCCASIN, + SVG_COLOR_NAVAJOWHITE, + SVG_COLOR_NAVY, + SVG_COLOR_OLDLACE, + SVG_COLOR_OLIVE, + SVG_COLOR_OLIVEDRAB, + SVG_COLOR_ORANGE, + SVG_COLOR_ORANGERED, + SVG_COLOR_ORCHID, + SVG_COLOR_PALEGOLDENROD, + SVG_COLOR_PALEGREEN, + SVG_COLOR_PALETURQUOISE, + SVG_COLOR_PALEVIOLETRED, + SVG_COLOR_PAPAYAWHIP, + SVG_COLOR_PEACHPUFF, + SVG_COLOR_PERU, + SVG_COLOR_PINK, + SVG_COLOR_PLUM, + SVG_COLOR_POWDERBLUE, + SVG_COLOR_PURPLE, + SVG_COLOR_RED, + SVG_COLOR_ROSYBROWN, + SVG_COLOR_ROYALBLUE, + SVG_COLOR_SADDLEBROWN, + SVG_COLOR_SALMON, + SVG_COLOR_SANDYBROWN, + SVG_COLOR_SEAGREEN, + SVG_COLOR_SEASHELL, + SVG_COLOR_SIENNA, + SVG_COLOR_SILVER, + SVG_COLOR_SKYBLUE, + SVG_COLOR_SLATEBLUE, + SVG_COLOR_SLATEGRAY, + SVG_COLOR_SLATEGREY, + SVG_COLOR_SNOW, + SVG_COLOR_SPRINGGREEN, + SVG_COLOR_STEELBLUE, + SVG_COLOR_TAN, + SVG_COLOR_TEAL, + SVG_COLOR_THISTLE, + SVG_COLOR_TOMATO, + SVG_COLOR_TURQUOISE, + SVG_COLOR_VIOLET, + SVG_COLOR_WHEAT, + SVG_COLOR_WHITE, + SVG_COLOR_WHITESMOKE, + SVG_COLOR_YELLOW, + SVG_COLOR_YELLOWGREEN +} SvgColorTokId; + +/* Structure returned by gperf */ +struct SvgColorName { + const char *name; + SvgColorTokId id; + uint32_t value; +}; +%} + +%struct-type +%language=ANSI-C +%readonly-tables +%ignore-case +%global-table +%define lookup-function-name lookup_svg_color_names_default +%define hash-function-name hash_svg_color +%define constants-prefix SVG_COL__ +%define word-array-name svg_color_wordlist + +struct SvgColorName; +%% +# Colors +aliceblue, SVG_COLOR_ALICEBLUE, 0xfffff8f0 +antiquewhite, SVG_COLOR_ANTIQUEWHITE, 0xffd7ebfa +aqua, SVG_COLOR_AQUA, 0xffffff00 +aquamarine, SVG_COLOR_AQUAMARINE, 0xffd4ff7f +azure, SVG_COLOR_AZURE, 0xfffffff0 +beige, SVG_COLOR_BEIGE, 0xffdcf5f5 +bisque, SVG_COLOR_BISQUE, 0xffc4e4ff +black, SVG_COLOR_BLACK, 0xff000000 +blanchedalmond, SVG_COLOR_BLANCHEDALMOND, 0xffcdebff +blue, SVG_COLOR_BLUE, 0xffff0000 +blueviolet, SVG_COLOR_BLUEVIOLET, 0xffe22b8a +brown, SVG_COLOR_BROWN, 0xff2a2aa5 +burlywood, SVG_COLOR_BURLYWOOD, 0xff87b8de +cadetblue, SVG_COLOR_CADETBLUE, 0xffa09e5f +chartreuse, SVG_COLOR_CHARTREUSE, 0xff00ff7f +chocolate, SVG_COLOR_CHOCOLATE, 0xff1e69d2 +coral, SVG_COLOR_CORAL, 0xff507fff +cornflowerblue, SVG_COLOR_CORNFLOWERBLUE, 0xffed9564 +cornsilk, SVG_COLOR_CORNSILK, 0xffdcf8ff +crimson, SVG_COLOR_CRIMSON, 0xff3c14dc +cyan, SVG_COLOR_CYAN, 0xffffff00 +darkblue, SVG_COLOR_DARKBLUE, 0xff8b0000 +darkcyan, SVG_COLOR_DARKCYAN, 0xff8b8b00 +darkgoldenrod, SVG_COLOR_DARKGOLDENROD, 0xff0b86b8 +darkgray, SVG_COLOR_DARKGRAY, 0xffa9a9a9 +darkgreen, SVG_COLOR_DARKGREEN, 0xff006400 +darkgrey, SVG_COLOR_DARKGREY, 0xffa9a9a9 +darkkhaki, SVG_COLOR_DARKKHAKI, 0xff6bb7bd +darkmagenta, SVG_COLOR_DARKMAGENTA, 0xff8b008b +darkolivegreen, SVG_COLOR_DARKOLIVEGREEN, 0xff2f6b55 +darkorange, SVG_COLOR_DARKORANGE, 0xff008cff +darkorchid, SVG_COLOR_DARKORCHID, 0xffcc3299 +darkred, SVG_COLOR_DARKRED, 0xff00008b +darksalmon, SVG_COLOR_DARKSALMON, 0xff7a96e9 +darkseagreen, SVG_COLOR_DARKSEAGREEN, 0xff8fbc8f +darkslateblue, SVG_COLOR_DARKSLATEBLUE, 0xff8b3d48 +darkslategray, SVG_COLOR_DARKSLATEGRAY, 0xff4f4f2f +darkslategrey, SVG_COLOR_DARKSLATEGREY, 0xff4f4f2f +darkturquoise, SVG_COLOR_DARKTURQUOISE, 0xffd1ce00 +darkviolet, SVG_COLOR_DARKVIOLET, 0xffd30094 +deeppink, SVG_COLOR_DEEPPINK, 0xff9314ff +deepskyblue, SVG_COLOR_DEEPSKYBLUE, 0xffffbf00 +dimgray, SVG_COLOR_DIMGRAY, 0xff696969 +dimgrey, SVG_COLOR_DIMGREY, 0xff696969 +dodgerblue, SVG_COLOR_DODGERBLUE, 0xffff901e +firebrick, SVG_COLOR_FIREBRICK, 0xff2222b2 +floralwhite, SVG_COLOR_FLORALWHITE, 0xfff0faff +forestgreen, SVG_COLOR_FORESTGREEN, 0xff228b22 +fuchsia, SVG_COLOR_FUCHSIA, 0xffff00ff +gainsboro, SVG_COLOR_GAINSBORO, 0xffdcdcdc +ghostwhite, SVG_COLOR_GHOSTWHITE, 0xfffff8f8 +gold, SVG_COLOR_GOLD, 0xff00d7ff +goldenrod, SVG_COLOR_GOLDENROD, 0xff20a5da +gray, SVG_COLOR_GRAY, 0xff808080 +green, SVG_COLOR_GREEN, 0xff008000 +greenyellow, SVG_COLOR_GREENYELLOW, 0xff2fffad +grey, SVG_COLOR_GREY, 0xff808080 +honeydew, SVG_COLOR_HONEYDEW, 0xfff0fff0 +hotpink, SVG_COLOR_HOTPINK, 0xffb469ff +indianred, SVG_COLOR_INDIANRED, 0xff5c5ccd +indigo, SVG_COLOR_INDIGO, 0xff82004b +ivory, SVG_COLOR_IVORY, 0xfff0ffff +khaki, SVG_COLOR_KHAKI, 0xff8ce6f0 +lavender, SVG_COLOR_LAVENDER, 0xfffae6e6 +lavenderblush, SVG_COLOR_LAVENDERBLUSH, 0xfff5f0ff +lawngreen, SVG_COLOR_LAWNGREEN, 0xff00fc7c +lemonchiffon, SVG_COLOR_LEMONCHIFFON, 0xffcdfaff +lightblue, SVG_COLOR_LIGHTBLUE, 0xffe6d8ad +lightcoral, SVG_COLOR_LIGHTCORAL, 0xff8080f0 +lightcyan, SVG_COLOR_LIGHTCYAN, 0xffffffe0 +lightgoldenrodyellow, SVG_COLOR_LIGHTGOLDENRODYELLOW, 0xffd2fafa +lightgray, SVG_COLOR_LIGHTGRAY, 0xffd3d3d3 +lightgreen, SVG_COLOR_LIGHTGREEN, 0xff90ee90 +lightgrey, SVG_COLOR_LIGHTGREY, 0xffd3d3d3 +lightpink, SVG_COLOR_LIGHTPINK, 0xffc1b6ff +lightsalmon, SVG_COLOR_LIGHTSALMON, 0xff7aa0ff +lightseagreen, SVG_COLOR_LIGHTSEAGREEN, 0xffaab220 +lightskyblue, SVG_COLOR_LIGHTSKYBLUE, 0xffface87 +lightslategray, SVG_COLOR_LIGHTSLATEGRAY, 0xff998877 +lightslategrey, SVG_COLOR_LIGHTSLATEGREY, 0xff998877 +lightsteelblue, SVG_COLOR_LIGHTSTEELBLUE, 0xffdec4b0 +lightyellow, SVG_COLOR_LIGHTYELLOW, 0xffeeffff +lime, SVG_COLOR_LIME, 0xff00ff00 +limegreen, SVG_COLOR_LIMEGREEN, 0xff32cd32 +linen, SVG_COLOR_LINEN, 0xffe6f0fa +magenta, SVG_COLOR_MAGENTA, 0xffff00ff +maroon, SVG_COLOR_MAROON, 0xff000080 +mediumaquamarine, SVG_COLOR_MEDIUMAQUAMARINE, 0xffaacd66 +mediumblue, SVG_COLOR_MEDIUMBLUE, 0xffcd0000 +mediumorchid, SVG_COLOR_MEDIUMORCHID, 0xffd355ba +mediumpurple, SVG_COLOR_MEDIUMPURPLE, 0xffdb7093 +mediumseagreen, SVG_COLOR_MEDIUMSEAGREEN, 0xff71b33c +mediumslateblue, SVG_COLOR_MEDIUMSLATEBLUE, 0xffee687b +mediumspringgreen, SVG_COLOR_MEDIUMSPRINGGREEN, 0xff9afa00 +mediumturquoise, SVG_COLOR_MEDIUMTURQUOISE, 0xffccd148 +mediumvioletred, SVG_COLOR_MEDIUMVIOLETRED, 0xff8515c7 +midnightblue, SVG_COLOR_MIDNIGHTBLUE, 0xff701919 +mintcream, SVG_COLOR_MINTCREAM, 0xfffafff5 +mistyrose, SVG_COLOR_MISTYROSE, 0xffe1e4ff +moccasin, SVG_COLOR_MOCCASIN, 0xffb5e4ff +navajowhite, SVG_COLOR_NAVAJOWHITE, 0xffaddeff +navy, SVG_COLOR_NAVY, 0xff800000 +oldlace, SVG_COLOR_OLDLACE, 0xffe6f5fd +olive, SVG_COLOR_OLIVE, 0xff008080 +olivedrab, SVG_COLOR_OLIVEDRAB, 0xff238e6b +orange, SVG_COLOR_ORANGE, 0xff00a5ff +orangered, SVG_COLOR_ORANGERED, 0xff0045ff +orchid, SVG_COLOR_ORCHID, 0xffd670da +palegoldenrod, SVG_COLOR_PALEGOLDENROD, 0xffaae8ee +palegreen, SVG_COLOR_PALEGREEN, 0xff98fb98 +paleturquoise, SVG_COLOR_PALETURQUOISE, 0xffeeeeaf +palevioletred, SVG_COLOR_PALEVIOLETRED, 0xff9370db +papayawhip, SVG_COLOR_PAPAYAWHIP, 0xffd5efff +peachpuff, SVG_COLOR_PEACHPUFF, 0xffb9daff +peru, SVG_COLOR_PERU, 0xff3f85cd +pink, SVG_COLOR_PINK, 0xffcbc0ff +plum, SVG_COLOR_PLUM, 0xffdda0dd +powderblue, SVG_COLOR_POWDERBLUE, 0xffe6e0b0 +purple, SVG_COLOR_PURPLE, 0xff800080 +red, SVG_COLOR_RED, 0xff0000ff +rosybrown, SVG_COLOR_ROSYBROWN, 0xff8f8fbc +royalblue, SVG_COLOR_ROYALBLUE, 0xffe16941 +saddlebrown, SVG_COLOR_SADDLEBROWN, 0xff13458b +salmon, SVG_COLOR_SALMON, 0xff7280fa +sandybrown, SVG_COLOR_SANDYBROWN, 0xff60a4f4 +seagreen, SVG_COLOR_SEAGREEN, 0xff578b2e +seashell, SVG_COLOR_SEASHELL, 0xffeef5ff +sienna, SVG_COLOR_SIENNA, 0xff2d52a0 +silver, SVG_COLOR_SILVER, 0xffc0c0c0 +skyblue, SVG_COLOR_SKYBLUE, 0xffebce87 +slateblue, SVG_COLOR_SLATEBLUE, 0xffcd5a6a +slategray, SVG_COLOR_SLATEGRAY, 0xff908070 +slategrey, SVG_COLOR_SLATEGREY, 0xff908070 +snow, SVG_COLOR_SNOW, 0xfffafaff +springgreen, SVG_COLOR_SPRINGGREEN, 0xff7fff00 +steelblue, SVG_COLOR_STEELBLUE, 0xffb48246 +tan, SVG_COLOR_TAN, 0xff8cb4d2 +teal, SVG_COLOR_TEAL, 0xff808000 +thistle, SVG_COLOR_THISTLE, 0xffd8bfd8 +tomato, SVG_COLOR_TOMATO, 0xff4763ff +turquoise, SVG_COLOR_TURQUOISE, 0xffd0e040 +violet, SVG_COLOR_VIOLET, 0xffee82ee +wheat, SVG_COLOR_WHEAT, 0xffb3def5 +white, SVG_COLOR_WHITE, 0xffffffff +whitesmoke, SVG_COLOR_WHITESMOKE, 0xfff5f5f5 +yellow, SVG_COLOR_YELLOW, 0xff00ffff +yellowgreen, SVG_COLOR_YELLOWGREEN, 0xff32cd9a +%% +const struct SvgColorName * +lookup_svg_color_names (register const char *str, register size_t len) +{ + if (len <= SVG_COL__MAX_WORD_LENGTH && len >= SVG_COL__MIN_WORD_LENGTH) + { + register unsigned int key = hash_svg_color (str, len); + + if (key <= SVG_COL__MAX_HASH_VALUE) + { + register const char *s = svg_color_wordlist[key].name; + + if (s && !strncasecmp (str, s, len) && s[len] == '\0') + return &svg_color_wordlist[key]; + } + } + return (struct SvgColorName *) 0; +} diff --git a/tests/svg-parser-new/svg_elt_keywords.gperf b/tests/svg-parser-new/svg_elt_keywords.gperf new file mode 100644 index 0000000..934c4f6 --- /dev/null +++ b/tests/svg-parser-new/svg_elt_keywords.gperf @@ -0,0 +1,197 @@ +%{ +#include <string.h> + +/* Enum representing our supported SVG elements and attributes */ +typedef enum { + SVG_TOK_UNKNOWN, + SVG_TOK_SVG, + SVG_TOK_G, + SVG_TOK_DEFS, + SVG_TOK_DESC, + SVG_TOK_TITLE, + SVG_TOK_SYMBOL, + SVG_TOK_USE, + SVG_TOK_SWITCH, + SVG_TOK_IMAGE, + SVG_TOK_STYLE, + SVG_TOK_PATH, + SVG_TOK_RECT, + SVG_TOK_CIRCLE, + SVG_TOK_LINE, + SVG_TOK_ELLIPSE, + SVG_TOK_POLYLINE, + SVG_TOK_POLYGON, + SVG_TOK_TEXT, + SVG_TOK_TSPAN, + SVG_TOK_TREF, + SVG_TOK_TEXTPATH, + SVG_TOK_ALTGLYPH, + SVG_TOK_GLYPHREF, + SVG_TOK_MARKER, + SVG_TOK_COLOR_PROFILE, + SVG_TOK_LINEARGRADIENT, + SVG_TOK_RADIALGRADIENT, + SVG_TOK_STOP, + SVG_TOK_PATTERN, + SVG_TOK_CLIPPATH, + SVG_TOK_MASK, + SVG_TOK_FILTER, + SVG_TOK_CURSOR, + SVG_TOK_A, + SVG_TOK_VIEW, + SVG_TOK_SCRIPT, + SVG_TOK_ANIMATE, + SVG_TOK_SET, + SVG_TOK_ANIMATEMOTION, + SVG_TOK_ANIMATECOLOR, + SVG_TOK_ANIMATETRANSFORM, + SVG_TOK_MPATH, + SVG_TOK_FONT, + SVG_TOK_FONT_FACE, + SVG_TOK_GLYPH, + SVG_TOK_MISSING_GLYPH, + SVG_TOK_HKERN, + SVG_TOK_VKERN, + SVG_TOK_FONT_FACE_URI, + SVG_TOK_FONT_FACE_FORMAT, + SVG_TOK_FONT_FACE_NAME, + SVG_TOK_FOREIGNOBJECT, + SVG_TOK_FEBLEND, + SVG_TOK_FECOLORMATRIX, + SVG_TOK_FECOMPONENTTRANSFER, + SVG_TOK_FECOMPOSITE, + SVG_TOK_FECONVOLVEMATRIX, + SVG_TOK_FEDIFFUSELIGHTING, + SVG_TOK_FEDISPLACEMENTMAP, + SVG_TOK_FEFLOOD, + SVG_TOK_FEGAUSSIANBLUR, + SVG_TOK_FEIMAGE, + SVG_TOK_FEMERGE, + SVG_TOK_FEMERGENODE, + SVG_TOK_FEMORPHOLOGY, + SVG_TOK_FEOFFSET, + SVG_TOK_FESPECULARLIGHTING, + SVG_TOK_FETILE, + SVG_TOK_FETURBULENCE, + SVG_TOK_FEDISTANTLIGHT, + SVG_TOK_FEPOINTLIGHT, + SVG_TOK_FESPOTLIGHT, + SVG_TOK_FEFUNCR, + SVG_TOK_FEFUNCG, + SVG_TOK_FEFUNCB, + SVG_TOK_FEFUNCA, +} SvgEltTokId; + +/* Structure returned by gperf */ +struct SvgEltKeyword { + const char *name; + SvgEltTokId id; +}; +%} + +%struct-type +%language=ANSI-C +%readonly-tables +%global-table +%define lookup-function-name lookup_svg_elt_token_default +%define hash-function-name hash_svg_elt +%define constants-prefix ELT_ +%define word-array-name svg_elt_wordlist + +struct SvgEltKeyword; +%% +# Elements +svg, SVG_TOK_SVG +g, SVG_TOK_G +defs, SVG_TOK_DEFS +desc, SVG_TOK_DESC +title, SVG_TOK_TITLE +symbol, SVG_TOK_SYMBOL +use, SVG_TOK_USE +switch, SVG_TOK_SWITCH +image, SVG_TOK_IMAGE +style, SVG_TOK_STYLE +path, SVG_TOK_PATH +rect, SVG_TOK_RECT +circle, SVG_TOK_CIRCLE +line, SVG_TOK_LINE +ellipse, SVG_TOK_ELLIPSE +polyline, SVG_TOK_POLYLINE +polygon, SVG_TOK_POLYGON +text, SVG_TOK_TEXT +tspan, SVG_TOK_TSPAN +tref, SVG_TOK_TREF +textPath, SVG_TOK_TEXTPATH +altGlyph, SVG_TOK_ALTGLYPH +glyphRef, SVG_TOK_GLYPHREF +marker, SVG_TOK_MARKER +color-profile, SVG_TOK_COLOR_PROFILE +linearGradient, SVG_TOK_LINEARGRADIENT +radialGradient, SVG_TOK_RADIALGRADIENT +stop, SVG_TOK_STOP +pattern, SVG_TOK_PATTERN +clipPath, SVG_TOK_CLIPPATH +mask, SVG_TOK_MASK +filter, SVG_TOK_FILTER +feBlend, SVG_TOK_FEBLEND +feColorMatrix, SVG_TOK_FECOLORMATRIX +feComponentTransfer, SVG_TOK_FECOMPONENTTRANSFER +feComposite, SVG_TOK_FECOMPOSITE +feConvolveMatrix, SVG_TOK_FECONVOLVEMATRIX +feDiffuseLighting, SVG_TOK_FEDIFFUSELIGHTING +feDisplacementMap, SVG_TOK_FEDISPLACEMENTMAP +feFlood, SVG_TOK_FEFLOOD +feGaussianBlur, SVG_TOK_FEGAUSSIANBLUR +feImage, SVG_TOK_FEIMAGE +feMerge, SVG_TOK_FEMERGE +feMergeNode, SVG_TOK_FEMERGENODE +feMorphology, SVG_TOK_FEMORPHOLOGY +feOffset, SVG_TOK_FEOFFSET +feSpecularLighting, SVG_TOK_FESPECULARLIGHTING +feTile, SVG_TOK_FETILE +feTurbulence, SVG_TOK_FETURBULENCE +feDistantLight, SVG_TOK_FEDISTANTLIGHT +fePointLight, SVG_TOK_FEPOINTLIGHT +feSpotLight, SVG_TOK_FESPOTLIGHT +feFuncR, SVG_TOK_FEFUNCR +feFuncG, SVG_TOK_FEFUNCG +feFuncB, SVG_TOK_FEFUNCB +feFuncA, SVG_TOK_FEFUNCA +cursor, SVG_TOK_CURSOR +a, SVG_TOK_A +view, SVG_TOK_VIEW +script, SVG_TOK_SCRIPT +animate, SVG_TOK_ANIMATE +set, SVG_TOK_SET +animateMotion, SVG_TOK_ANIMATEMOTION +animateColor, SVG_TOK_ANIMATECOLOR +animateTransform, SVG_TOK_ANIMATETRANSFORM +mpath, SVG_TOK_MPATH +font, SVG_TOK_FONT +font-face, SVG_TOK_FONT_FACE +glyph, SVG_TOK_GLYPH +missing-glyph, SVG_TOK_MISSING_GLYPH +hkern, SVG_TOK_HKERN +vkern, SVG_TOK_VKERN +font-face-uri, SVG_TOK_FONT_FACE_URI +font-face-format, SVG_TOK_FONT_FACE_FORMAT +font-face-name, SVG_TOK_FONT_FACE_NAME +foreignObject, SVG_TOK_FOREIGNOBJECT +%% +const struct SvgEltKeyword* +lookup_svg_elt_token (register const char *str, register size_t len) +{ + if (len <= ELT_MAX_WORD_LENGTH && len >= ELT_MIN_WORD_LENGTH) + { + register unsigned int key = hash_svg_elt (str, len); + + if (key <= ELT_MAX_HASH_VALUE) + { + register const char *s = svg_elt_wordlist[key].name; + + if (*str == *s && !memcmp (str + 1, s + 1, len -1) && s[len] == '\0') + return &svg_elt_wordlist[key]; + } + } + return (struct SvgEltKeyword *) 0; +} diff --git a/tests/svg-parser-new/vkvg_svg_internal.h b/tests/svg-parser-new/vkvg_svg_internal.h index 4a29e38..c8d4ff1 100644 --- a/tests/svg-parser-new/vkvg_svg_internal.h +++ b/tests/svg-parser-new/vkvg_svg_internal.h @@ -3,6 +3,7 @@ #include <stdint.h> #include <stdio.h> +#include <stddef.h> #include "svg_elt_gperf.h" #include "svg_att_gperf.h" |