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

📄 locale.c

📁 Axis 221 camera embedded programing interface
💻 C
📖 第 1 页 / 共 3 页
字号:
		+ (((unsigned long)(cdb->wcs2colidt_offset_hi)) << 16)		+ cdb->wcs2colidt_offset_low;/* 	fprintf(stderr,"wcs = %lu\n", n	+ (((unsigned long)(cdb->wcs2colidt_offset_hi)) << 16) *//* 			+ cdb->wcs2colidt_offset_low); */	cur_collate->MAX_WEIGHTS = cdh->MAX_WEIGHTS;#ifdef __UCLIBC_MJN3_ONLY__#warning CONSIDER: Fix the +1 by increasing max_col_index?#warning CONSIDER: Since this collate info is dependent only on LC_COLLATE ll_cc and not on codeset, we could just globally allocate this for each in a table#endif	cur_collate->index2weight = calloc(2*cur_collate->max_col_index+2,									   sizeof(uint16_t));	if (!cur_collate->index2weight) {		return 0;	}	cur_collate->index2ruleidx = cur_collate->index2weight		+ cur_collate->max_col_index + 1;	memcpy(cur_collate->index2weight, cur_collate->index2weight_tbl,		   cur_collate->num_col_base * sizeof(uint16_t));	memcpy(cur_collate->index2ruleidx, cur_collate->index2ruleidx_tbl,		   cur_collate->num_col_base * sizeof(uint16_t));	/* now do the overrides */	p = cur_collate->overrides_tbl;	while (*p > 1) {/* 		fprintf(stderr, "processing override -- count = %d\n", *p); */		n = *p++;		w = *p++;		do {			i = *p++;/* 			fprintf(stderr, "	i=%d (%#x) w=%d *p=%d\n", i, i, w, *p); */			cur_collate->index2weight[i-1] = w++;			cur_collate->index2ruleidx[i-1] = *p++;		} while (--n);	}	assert(*p == 1);	while (*++p) {		i = *p;/* 		fprintf(stderr, "	i=%d (%#x) w=%d *p=%d\n", i, i, p[1], p[2]); */		cur_collate->index2weight[i-1] = *++p;		cur_collate->index2ruleidx[i-1] = *++p;	}	for (i=0 ; i < cur_collate->multistart_tbl[0] ; i++) {		p = cur_collate->multistart_tbl;/* 		fprintf(stderr, "%2d of %2d: %d ", i,  cur_collate->multistart_tbl[0], p[i]); */		p += p[i];		do {			n = *p++;			do {				if (!*p) {		/* found it *//* 					fprintf(stderr, "found: n=%d (%#lx) |%.*ls|\n", n, (int) *cs->s, n, cs->s); *//* 					fprintf(stderr, ": %d - single\n", n); */					goto FOUND; 				}				/* the lookup check here is safe since we're assured that *p is a valid colidex *//* 				fprintf(stderr, "lookup(%lc)==%d  *p==%d\n", cs->s[n], lookup(cs->s[n]), (int) *p); *//* 				fprintf(stderr, ": %d - ", n); */				do {/* 					fprintf(stderr, "%d|",  *p); */				} while (*p++);				break;			} while (1);		} while (1);	FOUND:		continue;	}	return 1;}int _locale_set_l(const unsigned char *p, __locale_t base){	const char **x;	unsigned char *s = base->cur_locale + 1;	const size_t *stp;	const unsigned char *r;	const uint16_t *io;	const uint16_t *ii;	const unsigned char *d;	int row;					/* locale row */	int crow;					/* category row */	int len;	int c;	int i = 0;	__collate_t newcol;	++p;	newcol.index2weight = NULL;	if ((p[2*LC_COLLATE] != s[2*LC_COLLATE])		|| (p[2*LC_COLLATE + 1] != s[2*LC_COLLATE + 1])		) {		row  = (((int)(*p & 0x7f)) << 7) + (p[1] & 0x7f);		assert(row < __LOCALE_DATA_NUM_LOCALES);		if (!init_cur_collate(__locale_mmap->locales[ __LOCALE_DATA_WIDTH_LOCALES													  * row + 3 + LC_COLLATE ],							  &newcol)			) {			return 0;			/* calloc failed. */		}		free(base->collate.index2weight);		memcpy(&base->collate, &newcol, sizeof(__collate_t));	}	do {		if ((*p != *s) || (p[1] != s[1])) {			row  = (((int)(*p & 0x7f)) << 7) + (p[1] & 0x7f);			assert(row < __LOCALE_DATA_NUM_LOCALES);			*s = *p;			s[1] = p[1];			if ((i != LC_COLLATE)				&& ((len = __locale_mmap->lc_common_item_offsets_LEN[i]) != 0)				) {				crow = __locale_mmap->locales[ __LOCALE_DATA_WIDTH_LOCALES * row											   + 3 + i ]					* len;				x = (const char **)(((char *) base)                                    + base->category_offsets[i]); 				stp = __locale_mmap->lc_common_tbl_offsets + 4*i;				r = (const unsigned char *)( ((char *)__locale_mmap) + *stp );				io = (const uint16_t *)( ((char *)__locale_mmap) + *++stp );				ii = (const uint16_t *)( ((char *)__locale_mmap) + *++stp );				d = (const unsigned char *)( ((char *)__locale_mmap) + *++stp );				for (c=0 ; c < len ; c++) {					*(x + c) = d + ii[ r[crow + c] + io[c] ];				}			}			if (i == LC_CTYPE) {				c = __locale_mmap->locales[ __LOCALE_DATA_WIDTH_LOCALES * row											+ 2 ]; /* codeset */				if (c <= 2) {					if (c == 2) {						base->codeset = utf8;						base->encoding = __ctype_encoding_utf8;						/* TODO - fix for bcc */						base->mb_cur_max = 6;					} else {						assert(c==1);						base->codeset = ascii;						base->encoding = __ctype_encoding_7_bit;						base->mb_cur_max = 1;					}				} else {					const __codeset_8_bit_t *c8b;					r = CODESET_LIST;					base->codeset = r + r[c -= 3];					base->encoding = __ctype_encoding_8_bit;#ifdef __UCLIBC_MJN3_ONLY__#warning REMINDER: update 8 bit mb_cur_max when translit implemented!#endif					/* TODO - update when translit implemented! */					base->mb_cur_max = 1;					c8b = __locale_mmap->codeset_8_bit + c;#ifdef __CTYPE_HAS_8_BIT_LOCALES					base->idx8ctype = c8b->idx8ctype;					base->idx8uplow = c8b->idx8uplow;#ifdef __UCLIBC_HAS_WCHAR__					base->idx8c2wc = c8b->idx8c2wc;					base->idx8wc2c = c8b->idx8wc2c;					/* translit  */#endif /* __UCLIBC_HAS_WCHAR__ */					/* What follows is fairly bloated, but it is just a hack					 * to get the 8-bit codeset ctype stuff functioning.					 * All of this will be replaced in the next generation					 * of locale support anyway... */					memcpy(base->__ctype_b_data,						   __C_ctype_b - __UCLIBC_CTYPE_B_TBL_OFFSET,						   (256 + __UCLIBC_CTYPE_B_TBL_OFFSET)						   * sizeof(__ctype_mask_t));					memcpy(base->__ctype_tolower_data,						   __C_ctype_tolower - __UCLIBC_CTYPE_TO_TBL_OFFSET,						   (256 + __UCLIBC_CTYPE_TO_TBL_OFFSET)						   * sizeof(__ctype_touplow_t));					memcpy(base->__ctype_toupper_data,						   __C_ctype_toupper - __UCLIBC_CTYPE_TO_TBL_OFFSET,						   (256 + __UCLIBC_CTYPE_TO_TBL_OFFSET)						   * sizeof(__ctype_touplow_t));#define Cctype_TBL_MASK		((1 << __LOCALE_DATA_Cctype_IDX_SHIFT) - 1)#define Cctype_IDX_OFFSET	(128 >> __LOCALE_DATA_Cctype_IDX_SHIFT)					{						int u;						__ctype_mask_t m;						for (u=0 ; u < 128 ; u++) {#ifdef __LOCALE_DATA_Cctype_PACKED							c = base->tbl8ctype								[ ((int)(c8b->idx8ctype										 [(u >> __LOCALE_DATA_Cctype_IDX_SHIFT) ])								   << (__LOCALE_DATA_Cctype_IDX_SHIFT - 1))								  + ((u & Cctype_TBL_MASK) >> 1)];							c = (u & 1) ? (c >> 4) : (c & 0xf);#else							c = base->tbl8ctype								[ ((int)(c8b->idx8ctype										 [(u >> __LOCALE_DATA_Cctype_IDX_SHIFT) ])								   << __LOCALE_DATA_Cctype_IDX_SHIFT)								  + (u & Cctype_TBL_MASK) ];#endif							m = base->code2flag[c];							base->__ctype_b_data								[128 + __UCLIBC_CTYPE_B_TBL_OFFSET + u]								= m;#ifdef __UCLIBC_HAS_CTYPE_SIGNED__							if (((signed char)(128 + u)) != -1) {								base->__ctype_b_data[__UCLIBC_CTYPE_B_TBL_OFFSET													 + ((signed char)(128 + u))]									= m;							}#endif							base->__ctype_tolower_data								[128 + __UCLIBC_CTYPE_TO_TBL_OFFSET + u]								= 128 + u;							base->__ctype_toupper_data								[128 + __UCLIBC_CTYPE_TO_TBL_OFFSET + u]								= 128 + u;							if (m & (_ISlower|_ISupper)) {								c = base->tbl8uplow									[ ((int)(c8b->idx8uplow											 [u >> __LOCALE_DATA_Cuplow_IDX_SHIFT])									   << __LOCALE_DATA_Cuplow_IDX_SHIFT)									  + ((128 + u) 										 & ((1 << __LOCALE_DATA_Cuplow_IDX_SHIFT)											- 1)) ];								if (m & _ISlower) {									base->__ctype_toupper_data										[128 + __UCLIBC_CTYPE_TO_TBL_OFFSET + u]										= (unsigned char)(128 + u + c);#ifdef __UCLIBC_HAS_CTYPE_SIGNED__									if (((signed char)(128 + u)) != -1) {										base->__ctype_toupper_data											[__UCLIBC_CTYPE_TO_TBL_OFFSET											 + ((signed char)(128 + u))]											= (unsigned char)(128 + u + c);									}#endif								} else {									base->__ctype_tolower_data										[128 + __UCLIBC_CTYPE_TO_TBL_OFFSET + u]										= (unsigned char)(128 + u - c);#ifdef __UCLIBC_HAS_CTYPE_SIGNED__									if (((signed char)(128 + u)) != -1) {										base->__ctype_tolower_data											[__UCLIBC_CTYPE_TO_TBL_OFFSET											 + ((signed char)(128 + u))]											= (unsigned char)(128 + u - c);									}#endif								}							}						}					}#ifdef __UCLIBC_HAS_XLOCALE__					base->__ctype_b = base->__ctype_b_data						+ __UCLIBC_CTYPE_B_TBL_OFFSET;					base->__ctype_tolower = base->__ctype_tolower_data						+ __UCLIBC_CTYPE_TO_TBL_OFFSET;					base->__ctype_toupper = base->__ctype_toupper_data						+ __UCLIBC_CTYPE_TO_TBL_OFFSET;#else  /* __UCLIBC_HAS_XLOCALE__ */					__ctype_b = base->__ctype_b_data						+ __UCLIBC_CTYPE_B_TBL_OFFSET;					__ctype_tolower = base->__ctype_tolower_data						+ __UCLIBC_CTYPE_TO_TBL_OFFSET;					__ctype_toupper = base->__ctype_toupper_data						+ __UCLIBC_CTYPE_TO_TBL_OFFSET;#endif /* __UCLIBC_HAS_XLOCALE__ */#endif /* __CTYPE_HAS_8_BIT_LOCALES */				}#ifdef __UCLIBC_MJN3_ONLY__#warning TODO: Put the outdigit string length in the locale_mmap object.#endif				d = base->outdigit_length;				x = &base->outdigit0_mb;				for (c = 0 ; c < 10 ; c++) {					((unsigned char *)d)[c] = strlen(x[c]);					assert(d[c] > 0);				}			} else if (i == LC_NUMERIC) {				assert(LC_NUMERIC > LC_CTYPE); /* Need ctype initialized. */				base->decimal_point_len					= __locale_mbrtowc_l(&base->decimal_point_wc,											base->decimal_point, base);				assert(base->decimal_point_len > 0);				assert(base->decimal_point[base->decimal_point_len] == 0);				if (*base->grouping) {					base->thousands_sep_len						= __locale_mbrtowc_l(&base->thousands_sep_wc,											 base->thousands_sep, base);#if 1#ifdef __UCLIBC_MJN3_ONLY__#warning TODO: Remove hack involving grouping without a thousep char (bg_BG).#endif					assert(base->thousands_sep_len >= 0);					if (base->thousands_sep_len == 0) {						base->grouping = base->thousands_sep; /* empty string */					}					assert(base->thousands_sep[base->thousands_sep_len] == 0);#else					assert(base->thousands_sep_len > 0);					assert(base->thousands_sep[base->thousands_sep_len] == 0);#endif				}					/* 			} else if (i == LC_COLLATE) { *//* 				init_cur_collate(__locale_mmap->locales[ __LOCALE_DATA_WIDTH_LOCALES *//* 														 * row + 3 + i ], *//* 								 &base->collate); */			}		}		++i;		p += 2;		s += 2;	} while (i < LC_ALL);	return 1;}static const uint16_t __code2flag[16] = {	0,							/* unclassified = 0 */	_ISprint|_ISgraph|_ISalnum|_ISalpha, /* alpha_nonupper_nonlower */	_ISprint|_ISgraph|_ISalnum|_ISalpha|_ISlower, /* alpha_lower */	_ISprint|_ISgraph|_ISalnum|_ISalpha|_ISlower|_ISupper, /* alpha_upper_lower */	_ISprint|_ISgraph|_ISalnum|_ISalpha|_ISupper, /* alpha_upper */	_ISprint|_ISgraph|_ISalnum|_ISdigit, /* digit */	_ISprint|_ISgraph|_ISpunct,	/* punct */	_ISprint|_ISgraph,			/* graph */	_ISprint|_ISspace,			/* print_space_nonblank */	_ISprint|_ISspace|_ISblank,	/* print_space_blank */	         _ISspace,			/* space_nonblank_noncntrl */	         _ISspace|_ISblank,	/* space_blank_noncntrl */	_IScntrl|_ISspace,			/* cntrl_space_nonblank */	_IScntrl|_ISspace|_ISblank,	/* cntrl_space_blank */	_IScntrl					/* cntrl_nonspace */};void _locale_init_l(__locale_t base){	memset(base->cur_locale, 0, LOCALE_SELECTOR_SIZE);	base->cur_locale[0] = '#';	memcpy(base->category_item_count,		   __locale_mmap->lc_common_item_offsets_LEN,		   LC_ALL);	++base->category_item_count[0]; /* Increment for codeset entry. */	base->category_offsets[0] = offsetof(__uclibc_locale_t, outdigit0_mb);	base->category_offsets[1] = offsetof(__uclibc_locale_t, decimal_point);	base->category_offsets[2] = offsetof(__uclibc_locale_t, int_curr_symbol);	base->category_offsets[3] = offsetof(__uclibc_locale_t, abday_1);/*  	base->category_offsets[4] = offsetof(__uclibc_locale_t, collate???); */	base->category_offsets[5] = offsetof(__uclibc_locale_t, yesexpr);#ifdef __CTYPE_HAS_8_BIT_LOCALES	base->tbl8ctype		= (const unsigned char *) &__locale_mmap->tbl8ctype;    base->tbl8uplow		= (const unsigned char *) &__locale_mmap->tbl8uplow;#ifdef __UCLIBC_HAS_WCHAR__	base->tbl8c2wc		= (const uint16_t *) &__locale_mmap->tbl8c2wc;	base->tbl8wc2c		= (const unsigned char *) &__locale_mmap->tbl8wc2c;	/* translit  */#endif /* __UCLIBC_HAS_WCHAR__ */#endif /* __CTYPE_HAS_8_BIT_LOCALES */#ifdef __UCLIBC_HAS_WCHAR__	base->tblwctype		= (const unsigned char *) &__locale_mmap->tblwctype;	base->tblwuplow		= (const unsigned char *) &__locale_mmap->tblwuplow;	base->tblwuplow_diff		= (const uint16_t *) &__locale_mmap->tblwuplow_diff;/* 	base->tblwcomb *//* 		= (const unsigned char *) &__locale_mmap->tblwcomb; */	/* width?? */#endif /* __UCLIBC_HAS_WCHAR__ */	/* Initially, set things up to use the global C ctype tables.	 * This is correct for C (ASCII) and UTF-8 based locales (except tr_TR). */#ifdef __UCLIBC_HAS_XLOCALE__	base->__ctype_b = __C_ctype_b;	base->__ctype_tolower = __C_ctype_tolower;	base->__ctype_toupper = __C_ctype_toupper;#else  /* __UCLIBC_HAS_XLOCALE__ */	__ctype_b = __C_ctype_b;	__ctype_tolower = __C_ctype_tolower;	__ctype_toupper = __C_ctype_toupper;#endif /* __UCLIBC_HAS_XLOCALE__ */#ifdef __UCLIBC_MJN3_ONLY__#warning TODO: Initialize code2flag correctly based on locale_mmap.#endif	base->code2flag = __code2flag;	_locale_set_l(C_LOCALE_SELECTOR, base);}void _locale_init(void){	/* TODO: mmap the locale file  */	/* TODO - ??? */	_locale_init_l(__global_locale);}#endif/**********************************************************************/#if defined(L_nl_langinfo) || defined(L_nl_langinfo_l)#ifdef __LOCALE_C_ONLY/* We need to index 320 bytes of data, so you might initially think we * need to store the offsets in shorts.  But since the offset of the * 64th item is 182, we'll store "offset - 2*64" for all items >= 64 * and always calculate the data offset as "offset[i] + 2*(i & 64)". * This allows us to pack the data offsets in an unsigned char while * also avoiding an "if". * * Note: Category order is assumed to be: *   ctype, numeric, monetary, time, collate, messages, all */#define C_LC_ALL 6/* Combine the data to avoid size penalty for seperate char arrays when * compiler aligns objects.  The original code is left in as documentation. */#define cat_start nl_data#define C_locale_data (nl_data + C_LC_ALL + 1 + 90)static const unsigned char nl_data[C_LC_ALL + 1 + 90 + 320] = {/* static const char cat_start[LC_ALL + 1] = { */        '\x00', '\x0b', '\x0e', '\x24', '\x56', '\x56', '\x5a', /* }; *//* static const char item_offset[90] = { */	'\x00', '\x02', '\x04', '\x06', '\x08', '\x0a', '\x0c', '\x0e', 	'\x10', '\x12', '\x14', '\x1a', '\x1b', '\x1b', '\x1b', '\x1b', 	'\x1b', '\x1b', '\x1b', '\x1b', '\x1b', '\x1c', '\x1c', '\x1c', 	'\x1c', '\x1c', '\x1c', '\x1c', '\x1c', '\x1c', '\x1c', '\x1c', 	'\x1c', '\x1c', '\x1c', '\x1e', '\x20', '\x24', '\x28', '\x2c', 	'\x30', '\x34', '\x38', '\x3c', '\x43', '\x4a', '\x52', '\x5c', 	'\x65', '\x6c', '\x75', '\x79', '\x7d', '\x81', '\x85', '\x89', 	'\x8d', '\x91', '\x95', '\x99', '\x9d', '\xa1', '\xa5', '\xad', 	'\x36', '\x3c', '\x42', '\x46', '\x4b', '\x50', '\x57', '\x61', 	'\x69', '\x72', '\x7b', '\x7e', '\x81', '\x96', '\x9f', '\xa8', 	'\xb3', '\xb3', '\xb3', '\xb3', '\xb3', '\xb3', '\xb4', '\xba', 	'\xbf', '\xbf', /* }; *//* static const char C_locale_data[320] = { */	   '0', '\x00',    '1', '\x00',    '2', '\x00',    '3', '\x00', 	   '4', '\x00',    '5', '\x00',    '6', '\x00',    '7', '\x00', 	   '8', '\x00',    '9', '\x00',    'A',    'S',    'C',    'I', 	   'I', '\x00',    '.', '\x00', '\x7f', '\x00',    '-', '\x00', 	   'S',    'u',    'n', '\x00',    'M',    'o',    'n', '\x00', 	   'T',    'u',    'e', '\x00',    'W',    'e',    'd', '\x00', 	   'T',    'h',    'u', '\x00',    'F',    'r',    'i', '\x00', 	   'S',    'a',    't', '\x00',    'S',    'u',    'n',    'd', 	   'a',    'y', '\x00',    'M',    'o',    'n',    'd',    'a', 	   'y', '\x00',    'T',    'u',    'e',    's',    'd',    'a', 	   'y', '\x00',    'W',    'e',    'd',    'n',    'e',    's', 	   'd',    'a',    'y', '\x00',    'T',    'h',    'u',    'r', 	   's',    'd',    'a',    'y', '\x00',    'F',    'r',    'i', 	   'd',    'a',    'y', '\x00',    'S',    'a',    't',    'u', 	   'r',    'd',    'a',    'y', '\x00',    'J',    'a',    'n', 

⌨️ 快捷键说明

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