added qse_isuniblank() and changed qse_isblank() to use it.
regenerated various build files
This commit is contained in:
		| @ -1,5 +1,5 @@ | ||||
|  | ||||
| AUTOMAKE_OPTIONS = no-dependencies | ||||
|  | ||||
| EXTRA_DIST = gencp.sh gencp0.awk gencp1.awk testcp.c | ||||
| EXTRA_DIST = gencp.sh gencp0.awk gencp1.awk testcp.c uni-case.c uni-trait.c | ||||
|  | ||||
|  | ||||
| @ -1,9 +1,8 @@ | ||||
| # Makefile.in generated by automake 1.11.6 from Makefile.am. | ||||
| # Makefile.in generated by automake 1.14.1 from Makefile.am. | ||||
| # @configure_input@ | ||||
|  | ||||
| # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, | ||||
| # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software | ||||
| # Foundation, Inc. | ||||
| # Copyright (C) 1994-2013 Free Software Foundation, Inc. | ||||
|  | ||||
| # This Makefile.in is free software; the Free Software Foundation | ||||
| # gives unlimited permission to copy and/or distribute it, | ||||
| # with or without modifications, as long as this notice is preserved. | ||||
| @ -15,23 +14,51 @@ | ||||
|  | ||||
| @SET_MAKE@ | ||||
| VPATH = @srcdir@ | ||||
| am__make_dryrun = \ | ||||
|   { \ | ||||
|     am__dry=no; \ | ||||
| am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' | ||||
| am__make_running_with_option = \ | ||||
|   case $${target_option-} in \ | ||||
|       ?) ;; \ | ||||
|       *) echo "am__make_running_with_option: internal error: invalid" \ | ||||
|               "target option '$${target_option-}' specified" >&2; \ | ||||
|          exit 1;; \ | ||||
|   esac; \ | ||||
|   has_opt=no; \ | ||||
|   sane_makeflags=$$MAKEFLAGS; \ | ||||
|   if $(am__is_gnu_make); then \ | ||||
|     sane_makeflags=$$MFLAGS; \ | ||||
|   else \ | ||||
|     case $$MAKEFLAGS in \ | ||||
|       *\\[\ \	]*) \ | ||||
|         echo 'am--echo: ; @echo "AM"  OK' | $(MAKE) -f - 2>/dev/null \ | ||||
|           | grep '^AM OK$$' >/dev/null || am__dry=yes;; \ | ||||
|       *) \ | ||||
|         for am__flg in $$MAKEFLAGS; do \ | ||||
|           case $$am__flg in \ | ||||
|             *=*|--*) ;; \ | ||||
|             *n*) am__dry=yes; break;; \ | ||||
|           esac; \ | ||||
|         done;; \ | ||||
|         bs=\\; \ | ||||
|         sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | ||||
|           | sed "s/$$bs$$bs[$$bs $$bs	]*//g"`;; \ | ||||
|     esac; \ | ||||
|     test $$am__dry = yes; \ | ||||
|   } | ||||
|   fi; \ | ||||
|   skip_next=no; \ | ||||
|   strip_trailopt () \ | ||||
|   { \ | ||||
|     flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ | ||||
|   }; \ | ||||
|   for flg in $$sane_makeflags; do \ | ||||
|     test $$skip_next = yes && { skip_next=no; continue; }; \ | ||||
|     case $$flg in \ | ||||
|       *=*|--*) continue;; \ | ||||
|         -*I) strip_trailopt 'I'; skip_next=yes;; \ | ||||
|       -*I?*) strip_trailopt 'I';; \ | ||||
|         -*O) strip_trailopt 'O'; skip_next=yes;; \ | ||||
|       -*O?*) strip_trailopt 'O';; \ | ||||
|         -*l) strip_trailopt 'l'; skip_next=yes;; \ | ||||
|       -*l?*) strip_trailopt 'l';; \ | ||||
|       -[dEDm]) skip_next=yes;; \ | ||||
|       -[JT]) skip_next=yes;; \ | ||||
|     esac; \ | ||||
|     case $$flg in \ | ||||
|       *$$target_option*) has_opt=yes; break;; \ | ||||
|     esac; \ | ||||
|   done; \ | ||||
|   test $$has_opt = yes | ||||
| am__make_dryrun = (target_option=n; $(am__make_running_with_option)) | ||||
| am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) | ||||
| pkgdatadir = $(datadir)/@PACKAGE@ | ||||
| pkgincludedir = $(includedir)/@PACKAGE@ | ||||
| pkglibdir = $(libdir)/@PACKAGE@ | ||||
| @ -51,7 +78,7 @@ POST_UNINSTALL = : | ||||
| build_triplet = @build@ | ||||
| host_triplet = @host@ | ||||
| subdir = tools | ||||
| DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in | ||||
| DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am | ||||
| ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 | ||||
| am__aclocal_m4_deps = $(top_srcdir)/m4/argz.m4 \ | ||||
| 	$(top_srcdir)/m4/ax_check_sign.m4 \ | ||||
| @ -67,14 +94,20 @@ mkinstalldirs = $(install_sh) -d | ||||
| CONFIG_HEADER = $(top_builddir)/include/qse/config.h | ||||
| CONFIG_CLEAN_FILES = | ||||
| CONFIG_CLEAN_VPATH_FILES = | ||||
| depcomp = | ||||
| am__depfiles_maybe = | ||||
| AM_V_P = $(am__v_P_@AM_V@) | ||||
| am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) | ||||
| am__v_P_0 = false | ||||
| am__v_P_1 = : | ||||
| AM_V_GEN = $(am__v_GEN_@AM_V@) | ||||
| am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) | ||||
| am__v_GEN_0 = @echo "  GEN   " $@; | ||||
| am__v_GEN_0 = @echo "  GEN     " $@; | ||||
| am__v_GEN_1 =  | ||||
| AM_V_at = $(am__v_at_@AM_V@) | ||||
| am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) | ||||
| am__v_at_0 = @ | ||||
| am__v_at_1 =  | ||||
| depcomp = | ||||
| am__depfiles_maybe = | ||||
| SOURCES = | ||||
| DIST_SOURCES = | ||||
| am__can_run_installinfo = \ | ||||
| @ -82,6 +115,7 @@ am__can_run_installinfo = \ | ||||
|     n|no|NO) false;; \ | ||||
|     *) (install-info --version) >/dev/null 2>&1;; \ | ||||
|   esac | ||||
| am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) | ||||
| DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) | ||||
| ACLOCAL = @ACLOCAL@ | ||||
| AMTAR = @AMTAR@ | ||||
| @ -259,7 +293,7 @@ top_build_prefix = @top_build_prefix@ | ||||
| top_builddir = @top_builddir@ | ||||
| top_srcdir = @top_srcdir@ | ||||
| AUTOMAKE_OPTIONS = no-dependencies | ||||
| EXTRA_DIST = gencp.sh gencp0.awk gencp1.awk testcp.c | ||||
| EXTRA_DIST = gencp.sh gencp0.awk gencp1.awk testcp.c uni-case.c uni-trait.c | ||||
| all: all-am | ||||
|  | ||||
| .SUFFIXES: | ||||
| @ -299,11 +333,11 @@ mostlyclean-libtool: | ||||
|  | ||||
| clean-libtool: | ||||
| 	-rm -rf .libs _libs | ||||
| tags: TAGS | ||||
| TAGS: | ||||
| tags TAGS: | ||||
|  | ||||
| ctags: CTAGS | ||||
| CTAGS: | ||||
| ctags CTAGS: | ||||
|  | ||||
| cscope cscopelist: | ||||
|  | ||||
|  | ||||
| distdir: $(DISTFILES) | ||||
| @ -439,15 +473,16 @@ uninstall-am: | ||||
| .MAKE: install-am install-strip | ||||
|  | ||||
| .PHONY: all all-am check check-am clean clean-generic clean-libtool \ | ||||
| 	distclean distclean-generic distclean-libtool distdir dvi \ | ||||
| 	dvi-am html html-am info info-am install install-am \ | ||||
| 	install-data install-data-am install-dvi install-dvi-am \ | ||||
| 	install-exec install-exec-am install-html install-html-am \ | ||||
| 	install-info install-info-am install-man install-pdf \ | ||||
| 	install-pdf-am install-ps install-ps-am install-strip \ | ||||
| 	installcheck installcheck-am installdirs maintainer-clean \ | ||||
| 	maintainer-clean-generic mostlyclean mostlyclean-generic \ | ||||
| 	mostlyclean-libtool pdf pdf-am ps ps-am uninstall uninstall-am | ||||
| 	cscopelist-am ctags-am distclean distclean-generic \ | ||||
| 	distclean-libtool distdir dvi dvi-am html html-am info info-am \ | ||||
| 	install install-am install-data install-data-am install-dvi \ | ||||
| 	install-dvi-am install-exec install-exec-am install-html \ | ||||
| 	install-html-am install-info install-info-am install-man \ | ||||
| 	install-pdf install-pdf-am install-ps install-ps-am \ | ||||
| 	install-strip installcheck installcheck-am installdirs \ | ||||
| 	maintainer-clean maintainer-clean-generic mostlyclean \ | ||||
| 	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ | ||||
| 	tags-am uninstall uninstall-am | ||||
|  | ||||
|  | ||||
| # Tell versions [3.59,3.63) of GNU make to not export all variables. | ||||
|  | ||||
							
								
								
									
										177
									
								
								qse/tools/uni-case.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										177
									
								
								qse/tools/uni-case.c
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,177 @@ | ||||
| #include <qse/types.h> | ||||
| #include <locale.h> | ||||
| #include <wchar.h> | ||||
| #include <wctype.h> | ||||
| #include <stdio.h> | ||||
| #include <stddef.h> | ||||
| #include <stdlib.h> | ||||
| #include <string.h> | ||||
| #include <limits.h> | ||||
|  | ||||
| #if QSE_SIZEOF_WCHAR_T == QSE_SIZEOF_SHORT | ||||
|         #define MAX_CHAR 0xFFFF | ||||
| #else | ||||
|         /*#define MAX_CHAR 0xE01EF*/ | ||||
|         #define MAX_CHAR 0x10FFFF | ||||
| #endif | ||||
|  | ||||
| #define CASE_PAGE_SIZE 512 | ||||
| #define MAX_CASE_PAGE_COUNT ((MAX_CHAR + CASE_PAGE_SIZE) / CASE_PAGE_SIZE) | ||||
|  | ||||
| /*  | ||||
|  * short is enough as the diff does not exceed | ||||
|  * the maixmum value of the short type. | ||||
|  */ | ||||
| typedef long int wcdiff_t; | ||||
|  | ||||
| typedef struct case_page_t case_page_t; | ||||
| struct case_page_t | ||||
| { | ||||
| 	size_t no; | ||||
| 	wcdiff_t upper[CASE_PAGE_SIZE]; | ||||
| 	wcdiff_t lower[CASE_PAGE_SIZE];  | ||||
| 	case_page_t* next; | ||||
| }; | ||||
|  | ||||
| size_t case_page_count = 0; | ||||
| case_page_t* case_pages = NULL; | ||||
|  | ||||
| size_t case_map_count = 0; | ||||
| case_page_t* case_maps[MAX_CASE_PAGE_COUNT]; | ||||
|  | ||||
| void make_case_page (qse_wcint_t start, qse_wcint_t end) | ||||
| { | ||||
| 	qse_wcint_t code, c; | ||||
| 	size_t i; | ||||
| 	wcdiff_t upper[CASE_PAGE_SIZE]; | ||||
| 	wcdiff_t lower[CASE_PAGE_SIZE]; | ||||
| 	case_page_t* page; | ||||
|  | ||||
| 	memset (upper, 0, sizeof(upper)); | ||||
| 	memset (lower, 0, sizeof(lower)); | ||||
| 	for (code = start; code <= end; code++)  | ||||
| 	{ | ||||
| 		c = code - start; | ||||
| 		upper[c] = (wcdiff_t)code - (wcdiff_t)towupper(code); | ||||
| 		lower[c] = (wcdiff_t)towlower(code) - (wcdiff_t)code; | ||||
| 	} | ||||
|  | ||||
| 	for (page = case_pages; page != NULL; page = page->next)  | ||||
| 	{ | ||||
| 		if (memcmp (upper, page->upper, sizeof(upper)) == 0 && | ||||
| 		    memcmp (lower, page->lower, sizeof(lower)) == 0)  | ||||
| 		{ | ||||
| 			case_maps[case_map_count++] = page; | ||||
| 			return; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	page = (case_page_t*)malloc (sizeof(case_page_t)); | ||||
| 	page->no = case_page_count++; | ||||
| 	memcpy (page->upper, upper, sizeof(upper)); | ||||
| 	memcpy (page->lower, lower, sizeof(lower)); | ||||
| 	page->next = case_pages; | ||||
|  | ||||
| 	case_pages = page; | ||||
| 	case_maps[case_map_count++] = page; | ||||
| } | ||||
|  | ||||
| void emit_case_page (case_page_t* page, int page_seq) | ||||
| { | ||||
| 	size_t i; | ||||
| 	wcdiff_t upper, lower;  | ||||
| 	int need_or; | ||||
| 	qse_wcint_t c; | ||||
|  | ||||
| 	printf ("static case_page_t case_page_%04X[%u] =\n{\n",  | ||||
| 		(unsigned int)page->no, (unsigned int)CASE_PAGE_SIZE); | ||||
|  | ||||
| 	for (i = 0; i < CASE_PAGE_SIZE; i++)  | ||||
| 	{ | ||||
| 		need_or = 0; | ||||
| 		upper = page->upper[i]; | ||||
| 		lower = page->lower[i]; | ||||
|  | ||||
| 		if (i != 0) printf (",\n"); | ||||
| 		printf ("\t"); | ||||
|  | ||||
| 		if (upper >  SHRT_MAX || upper < SHRT_MIN || | ||||
| 		    lower > SHRT_MAX || lower < SHRT_MIN)  | ||||
| 		{ | ||||
| 			fprintf (stderr, "WARNING: page %u, index %u: value out of range - upper %ld lower %ld\n",  | ||||
| 				(unsigned int)page->no, (unsigned int)i, (long int)upper, (long int)lower); | ||||
| 		} | ||||
|  | ||||
| 		printf ("{%ld, %ld}", (long int)upper, (long int)lower); | ||||
| 	} | ||||
|  | ||||
| 	printf ("\n};\n"); | ||||
| } | ||||
|  | ||||
| void emit_case_map () | ||||
| { | ||||
| 	size_t i; | ||||
|  | ||||
|  | ||||
| 	printf ("static case_page_t* case_map[%u] =\n{\n", (unsigned int)case_map_count); | ||||
|  | ||||
| 	for (i = 0; i < case_map_count; i++) { | ||||
| 		if (i != 0) printf (",\n"); | ||||
| 		printf ("\t /* 0x%X-0x%X */ ",  | ||||
| 			i * CASE_PAGE_SIZE, (i + 1) * CASE_PAGE_SIZE - 1); | ||||
| 		printf ("case_page_%04X", case_maps[i]->no); | ||||
| 	} | ||||
|  | ||||
| 	printf ("\n};\n"); | ||||
| } | ||||
|  | ||||
| static void emit_case_macros (void) | ||||
| { | ||||
| 	printf ("/* generated by tools/uni-case.c */\n\n"); | ||||
| 	printf ("#define CASE_MAX 0x%lX\n\n", (unsigned long)MAX_CHAR); | ||||
| 	printf ("typedef struct case_page_t case_page_t;\n\n"); | ||||
| 	printf ("struct case_page_t {\n"); | ||||
|  | ||||
| 	/* use a 16-bit integer to use less memory.  */ | ||||
| 	printf ("	qse_int16_t upper;\n");  | ||||
| 	printf ("	qse_int16_t lower;\n"); | ||||
| 	printf ("};\n\n"); | ||||
| 	printf ("\n"); | ||||
| } | ||||
|  | ||||
| int main () | ||||
| { | ||||
| 	qse_wcint_t code; | ||||
| 	case_page_t* page; | ||||
| 	char* locale; | ||||
| 	int page_seq = 0; | ||||
|  | ||||
| 	locale = setlocale (LC_ALL, ""); | ||||
| 	if (locale == NULL || | ||||
| 	    (strstr(locale, ".utf8") == NULL && strstr(locale, ".UTF8") == NULL && | ||||
| 	     strstr(locale, ".utf-8") == NULL && strstr(locale, ".UTF-8") == NULL))  | ||||
| 	{ | ||||
| 		fprintf (stderr, "error: the locale should be utf-8 compatible\n"); | ||||
| 		return -1; | ||||
| 	} | ||||
|  | ||||
|  | ||||
| 	for (code = 0; code < MAX_CHAR; code += CASE_PAGE_SIZE)  | ||||
| 	{ | ||||
| 		make_case_page (code, code + CASE_PAGE_SIZE - 1); | ||||
| 	} | ||||
|  | ||||
| 	emit_case_macros (); | ||||
|  | ||||
| 	for (page = case_pages; page != NULL; page = page->next)  | ||||
| 	{ | ||||
| 		emit_case_page (page, page_seq);	 | ||||
| 		printf ("\n"); | ||||
| 		page_seq++; | ||||
| 	} | ||||
|  | ||||
| 	emit_case_map (); | ||||
|  | ||||
| 	return 0; | ||||
| } | ||||
|  | ||||
							
								
								
									
										282
									
								
								qse/tools/uni-trait.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										282
									
								
								qse/tools/uni-trait.c
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,282 @@ | ||||
| #include <qse/types.h> | ||||
| #include <locale.h> | ||||
| #include <wchar.h> | ||||
| #include <wctype.h> | ||||
| #include <stdio.h> | ||||
| #include <stddef.h> | ||||
| #include <stdlib.h> | ||||
| #include <string.h> | ||||
|  | ||||
| #if QSE_SIZEOF_WCHAR_T == QSE_SIZEOF_SHORT | ||||
| 	#define MAX_CHAR 0xFFFF | ||||
| #else | ||||
| 	/*#define MAX_CHAR 0xE01EF*/ | ||||
| 	#define MAX_CHAR 0x10FFFF | ||||
| #endif | ||||
|  | ||||
| #define TRAIT_PAGE_SIZE 256 | ||||
| #define MAX_TRAIT_PAGE_COUNT ((MAX_CHAR + TRAIT_PAGE_SIZE) / TRAIT_PAGE_SIZE) | ||||
|  | ||||
| typedef struct trait_page_t trait_page_t; | ||||
| struct trait_page_t | ||||
| { | ||||
| 	size_t no; | ||||
| 	short traits[TRAIT_PAGE_SIZE]; | ||||
| 	trait_page_t* next; | ||||
| }; | ||||
|  | ||||
| size_t trait_page_count = 0; | ||||
| trait_page_t* trait_pages = NULL; | ||||
|  | ||||
| size_t trait_map_count = 0; | ||||
| trait_page_t* trait_maps[MAX_TRAIT_PAGE_COUNT]; | ||||
|  | ||||
| enum | ||||
| { | ||||
| 	TRAIT_UPPER  = (1 << 0), | ||||
| 	TRAIT_LOWER  = (1 << 1), | ||||
| 	TRAIT_ALPHA  = (1 << 2), | ||||
| 	TRAIT_DIGIT  = (1 << 3), | ||||
| 	TRAIT_XDIGIT = (1 << 4), | ||||
| 	TRAIT_ALNUM  = (1 << 5), | ||||
| 	TRAIT_SPACE  = (1 << 6), | ||||
| 	TRAIT_PRINT  = (1 << 8), | ||||
| 	TRAIT_GRAPH  = (1 << 9), | ||||
| 	TRAIT_CNTRL  = (1 << 10), | ||||
| 	TRAIT_PUNCT  = (1 << 11), | ||||
| 	TRAIT_BLANK  = (1 << 12) | ||||
| }; | ||||
|  | ||||
| int get_trait (qse_wcint_t code) | ||||
| { | ||||
| 	int trait = 0; | ||||
|  | ||||
| 	if (iswupper(code))    trait |= TRAIT_UPPER; | ||||
| 	if (iswlower(code))    trait |= TRAIT_LOWER; | ||||
| 	if (iswalpha(code))    trait |= TRAIT_ALPHA; | ||||
| 	if (iswdigit(code))    trait |= TRAIT_DIGIT; | ||||
| 	if (iswxdigit(code))   trait |= TRAIT_XDIGIT; | ||||
| 	if (iswalnum(code))    trait |= TRAIT_ALNUM; | ||||
| 	if (iswspace(code))    trait |= TRAIT_SPACE; | ||||
| 	if (iswprint(code))    trait |= TRAIT_PRINT; | ||||
| 	if (iswgraph(code))    trait |= TRAIT_GRAPH; | ||||
| 	if (iswcntrl(code))    trait |= TRAIT_CNTRL; | ||||
| 	if (iswpunct(code))    trait |= TRAIT_PUNCT; | ||||
| 	if (iswblank(code))    trait |= TRAIT_BLANK; | ||||
| 	/* | ||||
| 	if (iswascii(code))    trait |= TRAIT_ASCII; | ||||
| 	if (isphonogram(code)) trait |= TRAIT_PHONO; | ||||
| 	if (isideogram(code))  trait |= TRAIT_IDEOG; | ||||
| 	if (isenglish(code))   trait |= TRAIT_ENGLI; | ||||
| 	*/ | ||||
|  | ||||
| 	return trait; | ||||
| } | ||||
|  | ||||
| void make_trait_page (qse_wcint_t start, qse_wcint_t end) | ||||
| { | ||||
| 	qse_wcint_t code; | ||||
| 	size_t i; | ||||
| 	short traits[TRAIT_PAGE_SIZE]; | ||||
| 	trait_page_t* page; | ||||
|  | ||||
| 	memset (traits, 0, sizeof(traits)); | ||||
| 	for (code = start; code <= end; code++) { | ||||
| 		traits[code - start] = get_trait(code); | ||||
| 	} | ||||
|  | ||||
| 	for (page = trait_pages; page != NULL; page = page->next) { | ||||
| 		if (memcmp (traits, page->traits, sizeof(traits)) == 0) { | ||||
| 			trait_maps[trait_map_count++] = page; | ||||
| 			return; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	page = (trait_page_t*)malloc (sizeof(trait_page_t)); | ||||
| 	page->no = trait_page_count++; | ||||
| 	memcpy (page->traits, traits, sizeof(traits)); | ||||
| 	page->next = trait_pages; | ||||
|  | ||||
| 	trait_pages = page; | ||||
| 	trait_maps[trait_map_count++] = page; | ||||
| } | ||||
|  | ||||
| void emit_trait_page (trait_page_t* page) | ||||
| { | ||||
| 	size_t i; | ||||
| 	int trait, need_or; | ||||
|  | ||||
| 	printf ("static qse_uint16_t trait_page_%04X[%u] =\n{\n",  | ||||
| 		(unsigned int)page->no, (unsigned int)TRAIT_PAGE_SIZE); | ||||
|  | ||||
| 	for (i = 0; i < TRAIT_PAGE_SIZE; i++) { | ||||
|  | ||||
| 		need_or = 0; | ||||
| 		trait = page->traits[i]; | ||||
|  | ||||
| 		if (i != 0) printf (",\n"); | ||||
| 		printf ("\t"); | ||||
|  | ||||
| 		if (trait == 0) { | ||||
| 			printf ("0"); | ||||
| 			continue; | ||||
| 		} | ||||
|  | ||||
| 		if (trait & TRAIT_UPPER) { | ||||
| 			if (need_or) printf (" | "); | ||||
| 			printf ("TRAIT_UPPER"); | ||||
| 			need_or = 1; | ||||
| 		} | ||||
|  | ||||
| 		if (trait & TRAIT_LOWER) { | ||||
| 			if (need_or) printf (" | "); | ||||
| 			printf ("TRAIT_LOWER"); | ||||
| 			need_or = 1; | ||||
| 		} | ||||
|  | ||||
| 		if (trait & TRAIT_ALPHA) { | ||||
| 			if (need_or) printf (" | "); | ||||
| 			printf ("TRAIT_ALPHA"); | ||||
| 			need_or = 1; | ||||
| 		} | ||||
|  | ||||
| 		if (trait & TRAIT_DIGIT) { | ||||
| 			if (need_or) printf (" | "); | ||||
| 			printf ("TRAIT_DIGIT"); | ||||
| 			need_or = 1; | ||||
| 		} | ||||
|  | ||||
| 		if (trait & TRAIT_XDIGIT) { | ||||
| 			if (need_or) printf (" | "); | ||||
| 			printf ("TRAIT_XDIGIT"); | ||||
| 			need_or = 1; | ||||
| 		} | ||||
|  | ||||
| 		if (trait & TRAIT_ALNUM) { | ||||
| 			if (need_or) printf (" | "); | ||||
| 			printf ("TRAIT_ALNUM"); | ||||
| 			need_or = 1; | ||||
| 		} | ||||
|  | ||||
| 		if (trait & TRAIT_SPACE) { | ||||
| 			if (need_or) printf (" | "); | ||||
| 			printf ("TRAIT_SPACE"); | ||||
| 			need_or = 1; | ||||
| 		} | ||||
|  | ||||
| 		if (trait & TRAIT_PRINT) { | ||||
| 			if (need_or) printf (" | "); | ||||
| 			printf ("TRAIT_PRINT"); | ||||
| 			need_or = 1; | ||||
| 		} | ||||
|  | ||||
| 		if (trait & TRAIT_GRAPH) { | ||||
| 			if (need_or) printf (" | "); | ||||
| 			printf ("TRAIT_GRAPH"); | ||||
| 			need_or = 1; | ||||
| 		} | ||||
|  | ||||
| 		if (trait & TRAIT_CNTRL) { | ||||
| 			if (need_or) printf (" | "); | ||||
| 			printf ("TRAIT_CNTRL"); | ||||
| 			need_or = 1; | ||||
| 		} | ||||
|  | ||||
| 		if (trait & TRAIT_PUNCT) { | ||||
| 			if (need_or) printf (" | "); | ||||
| 			printf ("TRAIT_PUNCT"); | ||||
| 			need_or = 1; | ||||
| 		} | ||||
|  | ||||
| 		if (trait & TRAIT_BLANK) { | ||||
| 			if (need_or) printf (" | "); | ||||
| 			printf ("TRAIT_BLANK"); | ||||
| 			need_or = 1; | ||||
| 		} | ||||
|  | ||||
|  | ||||
| 		/* | ||||
| 		if (trait & TRAIT_ASCII) { | ||||
| 			if (need_or) printf (" | "); | ||||
| 			printf ("TRAIT_ASCII"); | ||||
| 			need_or = 1; | ||||
| 		} | ||||
|  | ||||
| 		if (trait & TRAIT_IDEOG) { | ||||
| 			if (need_or) printf (" | "); | ||||
| 			printf ("TRAIT_IDEOG"); | ||||
| 			need_or = 1; | ||||
| 		} | ||||
|  | ||||
| 		if (trait & TRAIT_PHONO) { | ||||
| 			if (need_or) printf (" | "); | ||||
| 			printf ("TRAIT_PHONO"); | ||||
| 			need_or = 1; | ||||
| 		} | ||||
|  | ||||
| 		if (trait & TRAIT_ENGLI) { | ||||
| 			if (need_or) printf (" | "); | ||||
| 			printf ("TRAIT_ENGLI"); | ||||
| 			need_or = 1; | ||||
| 		} | ||||
| 		*/ | ||||
|  | ||||
| 	} | ||||
|  | ||||
| 	printf ("\n};\n"); | ||||
| } | ||||
|  | ||||
| void emit_trait_map () | ||||
| { | ||||
| 	size_t i; | ||||
|  | ||||
| 	printf ("static qse_uint16_t* trait_map[%u] =\n{\n", (unsigned int)trait_map_count); | ||||
|  | ||||
| 	for (i = 0; i < trait_map_count; i++) { | ||||
| 		if (i != 0) printf (",\n"); | ||||
| 		printf ("\t /* 0x%X-0x%X */ ",  | ||||
| 			i * TRAIT_PAGE_SIZE, (i + 1) * TRAIT_PAGE_SIZE - 1); | ||||
| 		printf ("trait_page_%04X", trait_maps[i]->no); | ||||
| 	} | ||||
|  | ||||
| 	printf ("\n};\n"); | ||||
| } | ||||
|  | ||||
| static void emit_trait_macros (void) | ||||
| { | ||||
| 	printf ("/* generated by tools/uni-trait.c */\n\n"); | ||||
| 	printf ("#define TRAIT_MAX 0x%lX\n", (unsigned long)MAX_CHAR); | ||||
| 	printf ("\n"); | ||||
| } | ||||
|  | ||||
| int main () | ||||
| { | ||||
| 	qse_wcint_t code; | ||||
| 	trait_page_t* page; | ||||
| 	char* locale; | ||||
|  | ||||
| 	locale = setlocale (LC_ALL, ""); | ||||
| 	if (locale == NULL || | ||||
| 	    (strstr(locale, ".utf8") == NULL && strstr(locale, ".UTF8") == NULL && | ||||
| 	     strstr(locale, ".utf-8") == NULL && strstr(locale, ".UTF-8") == NULL)) { | ||||
| 		fprintf (stderr, "error: the locale should be utf-8 compatible\n"); | ||||
| 		return -1; | ||||
| 	} | ||||
|  | ||||
|  | ||||
| 	for (code = 0; code < MAX_CHAR; code += TRAIT_PAGE_SIZE) { | ||||
| 		make_trait_page (code, code + TRAIT_PAGE_SIZE - 1); | ||||
| 	} | ||||
|  | ||||
| 	emit_trait_macros (); | ||||
|  | ||||
| 	for (page = trait_pages; page != NULL; page = page->next) { | ||||
| 		emit_trait_page (page);	 | ||||
| 		printf ("\n"); | ||||
| 	} | ||||
|  | ||||
| 	emit_trait_map (); | ||||
|  | ||||
| 	return 0; | ||||
| } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user