⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gen_wc8bit.c

📁 Axis 221 camera embedded programing interface
💻 C
📖 第 1 页 / 共 2 页
字号:
					fprintf(out, " %#4x,", j);				}#else				fprintf(out, " %#4x,", d);#endif			}#endif			fprintf(out, " }");#if 1			fprintf(out, ",\n\t\t/* idx8uplow data */\n\t\t{");			for (i = 128 ; i < 256 ; i++) {				wchar_t c, u, l;/*  				if (!(i & 0x7)) { *//*  					fprintf(out, "\n"); *//*  				} */				c = csd[numsets].c2w[i];				if ((c != 0) || 1) {					u = towupper(c);					l = towlower(c);										if (u >= 0x80) u = csd[numsets].w2c[u];					if (l >= 0x80) l = csd[numsets].w2c[l];					if (u == 0) u = i; /* upper is missing, so ignore */					if (l == 0) l = i; /* lower is missing, so ignore */#if 1					/* store as unsigned char and let overflow handle it. *//*  					if ((((u-i) < CHAR_MIN) || ((u-i) > CHAR_MAX)) *//*  						|| (((i-l) < CHAR_MIN) || ((i-l) > CHAR_MAX)) *//*  						) { *//*  						printf("error - uplow diff out of range! %d %ld %ld\n", *//*  							   i, u, l); *//*  						return EXIT_FAILURE; *//*  					} */					row[i & (UPLOW_ROW_LEN-1)] = ((l==i) ? (u-i) : (i-l));					if ((i & (UPLOW_ROW_LEN-1)) == (UPLOW_ROW_LEN-1)) {						p = uplow_tbl;						for (j=0 ; j < n_uplow_rows ; j++) {							if (!memcmp(p, row, UPLOW_ROW_LEN)) {								break;							}							p += UPLOW_ROW_LEN;						}						if (j == n_uplow_rows) { /* new entry */							if (++n_uplow_rows > 256) {								printf("error -- to many uplow rows!\n");								return EXIT_FAILURE;							}							memcpy(p, row, UPLOW_ROW_LEN);						}						csd[numsets].uplow_idx[i >> UPLOW_IDX_SHIFT] = j;						if (!((i >> UPLOW_IDX_SHIFT) & 0x7)							&& (i != (127 + UPLOW_ROW_LEN))							) {							fprintf(out, "\n\t\t ");						}						fprintf(out, " %#4x,", j);					}#elif 0					if (!(i & 0x7) && i) {						fprintf(out, "\n");					}					fprintf(out, " %4ld,", (l==i) ? (u-i) : (i-l));/*  					fprintf(out, " %4ld,", (l==i) ? u : l); */#else					if ((u != i) || (l != i)) {#if 0						fprintf(out, " %#08lx, %#08lx, %#08lx, %#08lx, %#08lx, %#08lx, \n",								(unsigned long) i,								(unsigned long) c,								(unsigned long) l,								(unsigned long) towlower(c),								(unsigned long) u,								(unsigned long) towupper(c));#else						fprintf(out, " %#08lx, %8ld, %d, %8ld, %d, %#08lx\n",								(unsigned long) i,								(long) (l - i),								iswupper(c),								(long) (i - u),								iswlower(c),								(unsigned long) c);#endif					}#endif				}			}			fprintf(out, " }");#endif#ifndef DO_WIDE_CHAR			fprintf(out,"\n");#else  /* DO_WIDE_CHAR */#if 1			fprintf(out, ",\n\t\t/* idx8c2wc data */\n\t\t{");			for (i = 128 ; i < 256 ; i++) {#if 1				wrow[i & (C2WC_ROW_LEN-1)] = csd[numsets].c2w[i];				if ((i & (C2WC_ROW_LEN-1)) == (C2WC_ROW_LEN-1)) {					p = (char *) c2wc_tbl;					for (j=0 ; j < n_c2wc_rows ; j++) {						if (!memcmp(p, (char *) wrow, 2*C2WC_ROW_LEN)) {							break;						}						p += 2*C2WC_ROW_LEN;					}					if (j == n_c2wc_rows) { /* new entry */						if (++n_c2wc_rows > 256) {							printf("error -- to many c2wc rows!\n");							return EXIT_FAILURE;						}						memcpy(p, (char *) wrow, 2*C2WC_ROW_LEN);					}					csd[numsets].c2wc_idx[i >> C2WC_IDX_SHIFT] = j;					if (!((i >> C2WC_IDX_SHIFT) & 0x7)						&& (i != (127 + C2WC_ROW_LEN))						) {						fprintf(out, "\n\t\t ");					}					fprintf(out, " %#4x,", j);				}#else				if (!(i & 0x7) && i) {					fprintf(out, "\n");				}				fprintf(out, " %#6lx,", csd[numsets].c2w[i]);#endif			}			fprintf(out, " },\n");#endif#if 1/*  			fprintf(out, "\nII_LEN = %d\n", II_LEN); */			fprintf(out, "\t\t/* idx8wc2c data */\n\t\t{");			for (i = 0 ; i < II_LEN ; i++) {				if (!(i & 0x7) && i) {					fprintf(out, "\n\t\t ");				}				fprintf(out, " %#4x,", csd[numsets].ii[i]);			}			fprintf(out, " }\n");#endif#endif /* DO_WIDE_CHAR */			fprintf(out, "\t},\n");		}		++numsets;		printf("done\n");	}	fprintf(out, "};\n");	fprintf(out, "\n#endif /* WANT_DATA */\n");#ifdef DO_WIDE_CHAR	fprintf(out, "\n");	fprintf(out, "#define __LOCALE_DATA_Cwc2c_DOMAIN_MAX\t%#x\n", RANGE);	fprintf(out, "#define __LOCALE_DATA_Cwc2c_TI_SHIFT\t\t%d\n", TI_SHIFT);	fprintf(out, "#define __LOCALE_DATA_Cwc2c_TT_SHIFT\t\t%d\n", TT_SHIFT);	fprintf(out, "#define __LOCALE_DATA_Cwc2c_II_LEN\t\t%d\n", II_LEN);	fprintf(out, "#define __LOCALE_DATA_Cwc2c_TI_LEN\t\t%d\n", ti_num << TI_SHIFT);	fprintf(out, "#define __LOCALE_DATA_Cwc2c_TT_LEN\t\t%d\n", tt_num << TT_SHIFT);	fprintf(out, "\n");	fprintf(out, "\n#define __LOCALE_DATA_Cwc2c_TBL_LEN\t\t%d\n",			(ti_num << TI_SHIFT) + (tt_num << TT_SHIFT));	fprintf(out, "#ifdef WANT_DATA\n\n");	fprintf(out, "static const unsigned char __LOCALE_DATA_Cwc2c_data[%d] = {\n",			(ti_num << TI_SHIFT) + (tt_num << TT_SHIFT));	fprintf(out, "\t/* ti_table */\n\t");	for (i=0 ; i < ti_num << TI_SHIFT ; i++) {		if (!(i & 7) && i) {			fprintf(out, "\n\t");		}		fprintf(out, " %#4x,", ti[i]);	}	fprintf(out, "\n");	fprintf(out, "\t/* tt_table */\n\t");	for (i=0 ; i < tt_num << TT_SHIFT ; i++) {		if (!(i & 7) && i) {			fprintf(out, "\n\t");		}		fprintf(out, " %#4x,", tt[i]);	}	fprintf(out, "\n};\n");	fprintf(out, "\n#endif /* WANT_DATA */\n");#endif /* DO_WIDE_CHAR */	fprintf(out, "\n#define __LOCALE_DATA_Cuplow_TBL_LEN\t\t%d\n",			n_uplow_rows * UPLOW_ROW_LEN);	fprintf(out, "\n#ifdef WANT_DATA\n\n");	fprintf(out, "\nstatic const unsigned char __LOCALE_DATA_Cuplow_data[%d] = {\n",			n_uplow_rows * UPLOW_ROW_LEN);	p = uplow_tbl;	for (j=0 ; j < n_uplow_rows ; j++) {		fprintf(out, "\t");		for (i=0 ; i < UPLOW_ROW_LEN ; i++) {			fprintf(out, " %#4x,", (unsigned int)((unsigned char) p[i]));		}		fprintf(out, "\n");		p += UPLOW_ROW_LEN;	}	fprintf(out, "};\n");	fprintf(out, "\n#endif /* WANT_DATA */\n");	fprintf(out, "\n#define __LOCALE_DATA_Cctype_TBL_LEN\t\t%d\n",#ifdef CTYPE_PACKED			n_ctype_rows * CTYPE_ROW_LEN / 2#else			n_ctype_rows * CTYPE_ROW_LEN#endif			);	fprintf(out, "\n#ifdef WANT_DATA\n\n");	fprintf(out, "\nstatic const unsigned char __LOCALE_DATA_Cctype_data[%d] = {\n",#ifdef CTYPE_PACKED			n_ctype_rows * CTYPE_ROW_LEN / 2#else			n_ctype_rows * CTYPE_ROW_LEN#endif			);	p = ctype_tbl;	for (j=0 ; j < n_ctype_rows ; j++) {		fprintf(out, "\t");		for (i=0 ; i < CTYPE_ROW_LEN ; i++) {#ifdef CTYPE_PACKED			fprintf(out, " %#4x,", (unsigned int)(p[i] + (p[i+1] << 4)));			++i;#else			fprintf(out, " %#4x,", (unsigned int)p[i]);#endif		}		fprintf(out, "\n");		p += CTYPE_ROW_LEN;	}	fprintf(out, "};\n");	fprintf(out, "\n#endif /* WANT_DATA */\n");#ifdef DO_WIDE_CHAR	fprintf(out, "\n#define __LOCALE_DATA_Cc2wc_TBL_LEN\t\t%d\n",			n_c2wc_rows * C2WC_ROW_LEN);	fprintf(out, "\n#ifdef WANT_DATA\n\n");	fprintf(out, "\nstatic const unsigned short __LOCALE_DATA_Cc2wc_data[%d] = {\n",			n_c2wc_rows * C2WC_ROW_LEN);	p = (char *) c2wc_tbl;	for (j=0 ; j < n_c2wc_rows ; j++) {		fprintf(out, "\t");		for (i=0 ; i < C2WC_ROW_LEN ; i++) {			fprintf(out, " %#6x,", (unsigned int)(((unsigned short *)p)[i]));		}		fprintf(out, "\n");		p += 2*C2WC_ROW_LEN;	}	fprintf(out, "};\n");	fprintf(out, "\n#endif /* WANT_DATA */\n");#endif /* DO_WIDE_CHAR */	fprintf(out, "\n\n");	fprintf(out, "#define __LOCALE_DATA_NUM_CODESETS\t\t%d\n", numsets);	fprintf(out, "#define __LOCALE_DATA_CODESET_LIST \\\n\t\"");	for (i=0 ; i < numsets ; i++) {		fprintf(out, "\\x%02x", numsets + 1 + (unsigned char) codeset_index[i]);		if (((i & 7) == 7) && (i + 1 < numsets)) {			fprintf(out, "\" \\\n\t\"");		}	}	fprintf(out, "\" \\\n\t\"\\0\"");	for (i=0 ; i < numsets ; i++) {		fprintf(out, " \\\n\t\"%s\\0\"",				codeset_list + ((unsigned char)codeset_index[i]));	}	fprintf(out, "\n\n");	for (i=0 ; i < numsets ; i++) {		char buf[30];		char *z;		strcpy(buf, codeset_list + ((unsigned char)codeset_index[i]));		for (z=buf ; *z ; z++) {			if (*z == '-') {				*z = '_';			}		}		fprintf(out, "#define __CTYPE_HAS_CODESET_%s\n", buf);	}#ifdef DO_WIDE_CHAR	fprintf(out, "#define __CTYPE_HAS_CODESET_UTF_8\n");#endif /* DO_WIDE_CHAR */#if 0	fprintf(out, "\n#endif /* __CTYPE_HAS_8_BIT_LOCALES */\n\n");#endif	fclose(out);	total_size = 0;#ifdef DO_WIDE_CHAR	printf("tt_num = %d   ti_num = %d\n", tt_num, ti_num);	printf("max_wchar = %#lx\n", max_wchar);	printf("size is %d * %d  +  %d * %d  + %d * %d  =  %d\n",		   tt_num, 1 << TT_SHIFT, ti_num, 1 << TI_SHIFT,		   ((MAX_WCHAR >> (TT_SHIFT + TI_SHIFT)) + 1), numsets, 		   j = tt_num * (1 << TT_SHIFT) + ti_num * (1 << TI_SHIFT)		   + ((MAX_WCHAR >> (TT_SHIFT + TI_SHIFT)) + 1) * numsets);	total_size += j;#endif /* DO_WIDE_CHAR */#ifdef CTYPE_PACKED	i = 2;#else	i = 1;#endif	printf("ctype - CTYPE_IDX_SHIFT = %d -- %d * %d + %d * %d = %d\n",		   CTYPE_IDX_SHIFT, numsets, CTYPE_IDX_LEN, n_ctype_rows, CTYPE_ROW_LEN / i,		   j = numsets * CTYPE_IDX_LEN +  n_ctype_rows * CTYPE_ROW_LEN / i);	total_size += j;	printf("uplow - UPLOW_IDX_SHIFT = %d -- %d * %d + %d * %d = %d\n",		   UPLOW_IDX_SHIFT, numsets, UPLOW_IDX_LEN, n_uplow_rows, UPLOW_ROW_LEN,		   j = numsets * UPLOW_IDX_LEN +  n_uplow_rows * UPLOW_ROW_LEN);	total_size += j;#ifdef DO_WIDE_CHAR	printf("c2wc - C2WC_IDX_SHIFT = %d -- %d * %d + 2 * %d * %d = %d\n",		   C2WC_IDX_SHIFT, numsets, C2WC_IDX_LEN, n_c2wc_rows, C2WC_ROW_LEN,		   j = numsets * C2WC_IDX_LEN +  2 * n_c2wc_rows * C2WC_ROW_LEN);	total_size += j;#endif /* DO_WIDE_CHAR */	printf("total size = %d\n", total_size);/*  	for (i=0 ; i < numsets ; i++) { *//*  		printf("codeset_index[i] = %d  codeset_list[ci[i]] = \"%s\"\n", *//*  			   (unsigned char) codeset_index[i], *//*  			   codeset_list + ((unsigned char)codeset_index[i])); *//*  	} */	return EXIT_SUCCESS;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -