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

📄 str.c

📁 一个内存数据库的源代码这是服务器端还有客户端
💻 C
📖 第 1 页 / 共 4 页
字号:
	{ 0x1EE5, 0x1EE4, },	{ 0x1EE7, 0x1EE6, },	{ 0x1EE9, 0x1EE8, },	{ 0x1EEB, 0x1EEA, },	{ 0x1EED, 0x1EEC, },	{ 0x1EEF, 0x1EEE, },	{ 0x1EF1, 0x1EF0, },	{ 0x1EF3, 0x1EF2, },	{ 0x1EF5, 0x1EF4, },	{ 0x1EF7, 0x1EF6, },	{ 0x1EF9, 0x1EF8, },	{ 0x1F00, 0x1F08, },	{ 0x1F01, 0x1F09, },	{ 0x1F02, 0x1F0A, },	{ 0x1F03, 0x1F0B, },	{ 0x1F04, 0x1F0C, },	{ 0x1F05, 0x1F0D, },	{ 0x1F06, 0x1F0E, },	{ 0x1F07, 0x1F0F, },	{ 0x1F10, 0x1F18, },	{ 0x1F11, 0x1F19, },	{ 0x1F12, 0x1F1A, },	{ 0x1F13, 0x1F1B, },	{ 0x1F14, 0x1F1C, },	{ 0x1F15, 0x1F1D, },	{ 0x1F20, 0x1F28, },	{ 0x1F21, 0x1F29, },	{ 0x1F22, 0x1F2A, },	{ 0x1F23, 0x1F2B, },	{ 0x1F24, 0x1F2C, },	{ 0x1F25, 0x1F2D, },	{ 0x1F26, 0x1F2E, },	{ 0x1F27, 0x1F2F, },	{ 0x1F30, 0x1F38, },	{ 0x1F31, 0x1F39, },	{ 0x1F32, 0x1F3A, },	{ 0x1F33, 0x1F3B, },	{ 0x1F34, 0x1F3C, },	{ 0x1F35, 0x1F3D, },	{ 0x1F36, 0x1F3E, },	{ 0x1F37, 0x1F3F, },	{ 0x1F40, 0x1F48, },	{ 0x1F41, 0x1F49, },	{ 0x1F42, 0x1F4A, },	{ 0x1F43, 0x1F4B, },	{ 0x1F44, 0x1F4C, },	{ 0x1F45, 0x1F4D, },	{ 0x1F51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	{ 0x1FC3, 0x1FCC, },	{ 0x1FD0, 0x1FD8, },	{ 0x1FD1, 0x1FD9, },	{ 0x1FE0, 0x1FE8, },	{ 0x1FE1, 0x1FE9, },	{ 0x1FE5, 0x1FEC, },	{ 0x1FF3, 0x1FFC, },	{ 0x2170, 0x2160, },	{ 0x2171, 0x2161, },	{ 0x2172, 0x2162, },	{ 0x2173, 0x2163, },	{ 0x2174, 0x2164, },	{ 0x2175, 0x2165, },	{ 0x2176, 0x2166, },	{ 0x2177, 0x2167, },	{ 0x2178, 0x2168, },	{ 0x2179, 0x2169, },	{ 0x217A, 0x216A, },	{ 0x217B, 0x216B, },	{ 0x217C, 0x216C, },	{ 0x217D, 0x216D, },	{ 0x217E, 0x216E, },	{ 0x217F, 0x216F, },	{ 0x24D0, 0x24B6, },	{ 0x24D1, 0x24B7, },	{ 0x24D2, 0x24B8, },	{ 0x24D3, 0x24B9, },	{ 0x24D4, 0x24BA, },	{ 0x24D5, 0x24BB, },	{ 0x24D6, 0x24BC, },	{ 0x24D7, 0x24BD, },	{ 0x24D8, 0x24BE, },	{ 0x24D9, 0x24BF, },	{ 0x24DA, 0x24C0, },	{ 0x24DB, 0x24C1, },	{ 0x24DC, 0x24C2, },	{ 0x24DD, 0x24C3, },	{ 0x24DE, 0x24C4, },	{ 0x24DF, 0x24C5, },	{ 0x24E0, 0x24C6, },	{ 0x24E1, 0x24C7, },	{ 0x24E2, 0x24C8, },	{ 0x24E3, 0x24C9, },	{ 0x24E4, 0x24CA, },	{ 0x24E5, 0x24CB, },	{ 0x24E6, 0x24CC, },	{ 0x24E7, 0x24CD, },	{ 0x24E8, 0x24CE, },	{ 0x24E9, 0x24CF, },	{ 0xFF41, 0xFF21, },	{ 0xFF42, 0xFF22, },	{ 0xFF43, 0xFF23, },	{ 0xFF44, 0xFF24, },	{ 0xFF45, 0xFF25, },	{ 0xFF46, 0xFF26, },	{ 0xFF47, 0xFF27, },	{ 0xFF48, 0xFF28, },	{ 0xFF49, 0xFF29, },	{ 0xFF4A, 0xFF2A, },	{ 0xFF4B, 0xFF2B, },	{ 0xFF4C, 0xFF2C, },	{ 0xFF4D, 0xFF2D, },	{ 0xFF4E, 0xFF2E, },	{ 0xFF4F, 0xFF2F, },	{ 0xFF50, 0xFF30, },	{ 0xFF51, 0xFF31, },	{ 0xFF52, 0xFF32, },	{ 0xFF53, 0xFF33, },	{ 0xFF54, 0xFF34, },	{ 0xFF55, 0xFF35, },	{ 0xFF56, 0xFF36, },	{ 0xFF57, 0xFF37, },	{ 0xFF58, 0xFF38, },	{ 0xFF59, 0xFF39, },	{ 0xFF5A, 0xFF3A, },#if 0	    /* these codes don't fit in an unsigned short, else they	       should be included */	{ 0x10428, 0x10400, },	{ 0x10429, 0x10401, },	{ 0x1042A, 0x10402, },	{ 0x1042B, 0x10403, },	{ 0x1042C, 0x10404, },	{ 0x1042D, 0x10405, },	{ 0x1042E, 0x10406, },	{ 0x1042F, 0x10407, },	{ 0x10430, 0x10408, },	{ 0x10431, 0x10409, },	{ 0x10432, 0x1040A, },	{ 0x10433, 0x1040B, },	{ 0x10434, 0x1040C, },	{ 0x10435, 0x1040D, },	{ 0x10436, 0x1040E, },	{ 0x10437, 0x1040F, },	{ 0x10438, 0x10410, },	{ 0x10439, 0x10411, },	{ 0x1043A, 0x10412, },	{ 0x1043B, 0x10413, },	{ 0x1043C, 0x10414, },	{ 0x1043D, 0x10415, },	{ 0x1043E, 0x10416, },	{ 0x1043F, 0x10417, },	{ 0x10440, 0x10418, },	{ 0x10441, 0x10419, },	{ 0x10442, 0x1041A, },	{ 0x10443, 0x1041B, },	{ 0x10444, 0x1041C, },	{ 0x10445, 0x1041D, },	{ 0x10446, 0x1041E, },	{ 0x10447, 0x1041F, },	{ 0x10448, 0x10420, },	{ 0x10449, 0x10421, },	{ 0x1044A, 0x10422, },	{ 0x1044B, 0x10423, },	{ 0x1044C, 0x10424, },	{ 0x1044D, 0x10425, },	{ 0x1044E, 0x10426, },	{ 0x1044F, 0x10427, },#endif};#define UTF8_CONVERSIONS (sizeof(UTF8_lower_upper) / sizeof(UTF8_lower_upper[0]))static BAT *UTF8_toupperBat = NULL, *UTF8_tolowerBat;bat *strPrelude(void){	if (!UTF8_toupperBat) {		int i = UTF8_CONVERSIONS;		UTF8_toupperBat = BATnew(TYPE_int, TYPE_int, UTF8_CONVERSIONS);		if (UTF8_toupperBat == NULL)			return NULL;		while (--i >= 0) {			int lower = UTF8_lower_upper[i].lower;			int upper = UTF8_lower_upper[i].upper;			BUNins(UTF8_toupperBat, &lower, &upper, FALSE);		}		UTF8_tolowerBat = BATmirror(UTF8_toupperBat);		BATname(UTF8_toupperBat, "monet_unicode_case");	}	return NULL;}str strEpilogue(int *ret){	(void)ret;	if (UTF8_toupperBat) {		BBPreclaim(UTF8_toupperBat);		BBPreclaim(UTF8_tolowerBat);	}	return MAL_SUCCEED;}#line 1283 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/atoms/str.mx"static INLINE intUTF8_strlen(str val){	unsigned char *s = (unsigned char *) val;	int pos = 0;	while (*s) {		int c = *s++;		pos++;		if (c < 0xC0)			continue;		if (*s++ < 0x80)			return int_nil;		if (c < 0xE0)			continue;		if (*s++ < 0x80)			return int_nil;		if (c < 0xF0)			continue;		if (*s++ < 0x80)			return int_nil;		if (c < 0xF8)			continue;		if (*s++ < 0x80)			return int_nil;		if (c < 0xFC)			continue;		if (*s++ < 0x80)			return int_nil;	}	return pos;}static INLINE intUTF8_strpos(str val, str end){	unsigned char *s = (unsigned char *) val;	int pos = 0;	if (s > (unsigned char *) end) {		return -1;	}	while (s < (unsigned char *) end) {		int c = *s++;		pos++;		if (c == 0)			return -1;		if (c < 0xC0)			continue;		if (*s++ < 0x80)			return -1;		if (c < 0xE0)			continue;		if (*s++ < 0x80)			return -1;		if (c < 0xF0)			continue;		if (*s++ < 0x80)			return -1;		if (c < 0xF8)			continue;		if (*s++ < 0x80)			return -1;		if (c < 0xFC)			continue;		if (*s++ < 0x80)			return -1;	}	return pos;}static INLINE strUTF8_strtail(str val, int pos){	unsigned char *s = (unsigned char *) val;	while (*s && pos-- > 0) {		int c = *s++;		if (c < 0xC0)			continue;		if (*s++ < 0x80)			return NULL;		if (c < 0xE0)			continue;		if (*s++ < 0x80)			return NULL;		if (c < 0xF0)			continue;		if (*s++ < 0x80)			return NULL;		if (c < 0xF8)			continue;		if (*s++ < 0x80)			return NULL;		if (c < 0xFC)			continue;		if (*s++ < 0x80)			return NULL;	}	return (str) s;}#define RETURN_NIL_IF(b,t)						\	if (b) {							\		if (ATOMextern(t)) {					\			*(ptr*) res = (ptr) ATOMnil(t);			\		} else {						\			memcpy(res, ATOMnilptr(t), ATOMsize(t));	\ 		}							\		return GDK_SUCCEED;					\	}#ifdef MAX#undef MAX#endif#define MAX(x, y) ((x) > (y) ? (x) : (y))#ifdef MIN#undef MIN#endif#define MIN(x, y) ((x) < (y) ? (x) : (y))intstrConcat(str *res, str s, ptr val, int t){	str valstr = NULL;	size_t l1;	int l2 = 0;	char buf[7], *p = buf;	RETURN_NIL_IF(strNil(s) || ATOMcmp(t, val, ATOMnilptr(t)) == 0, TYPE_str);	if (t <= 0)		return GDK_FAIL;	l1 = strlen(s);	if (t != TYPE_str) {		if (t == TYPE_chr) {			/* put value in int to avoid warning from compiler */			l2 = * (char *) val;			#line 1248 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/atoms/str.mx"	if ((l2) < 0#if SIZEOF_INT > 4	    || (int) (l2) >= 0x80000000#endif	   ) {		*(p)++ = chr_nil;	} else if ((l2) < 0x80) {		*(p)++ = (l2);	} else if ((l2) < 0x800) {		*(p)++ = 0xC0 | ((l2) >> 6);		*(p)++ = 0x80 | ((l2) & 0x3F);	} else if ((l2) < 0x10000) {		*(p)++ = 0xE0 | ((l2) >> 12);		*(p)++ = 0x80 | (((l2) >> 6) & 0x3F);		*(p)++ = 0x80 | ((l2) & 0x3F);	} else if ((l2) < 0x200000) {		*(p)++ = 0xF0 | ((l2) >> 18);		*(p)++ = 0x80 | (((l2) >> 12) & 0x3F);		*(p)++ = 0x80 | (((l2) >> 6) & 0x3F);		*(p)++ = 0x80 | ((l2) & 0x3F);	} else if ((l2) < 0x4000000) {		*(p)++ = 0xF8 | ((l2) >> 24);		*(p)++ = 0x80 | (((l2) >> 18) & 0x3F);		*(p)++ = 0x80 | (((l2) >> 12) & 0x3F);		*(p)++ = 0x80 | (((l2) >> 6) & 0x3F);		*(p)++ = 0x80 | ((l2) & 0x3F);	} else /* if ((l2) < 0x80000000) */ {		*(p)++ = 0xFC | ((l2) >> 30);		*(p)++ = 0x80 | (((l2) >> 24) & 0x3F);		*(p)++ = 0x80 | (((l2) >> 18) & 0x3F);		*(p)++ = 0x80 | (((l2) >> 12) & 0x3F);		*(p)++ = 0x80 | (((l2) >> 6) & 0x3F);		*(p)++ = 0x80 | ((l2) & 0x3F);	}#line 1424 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/atoms/str.mx"			l2 = p - buf;			val = (ptr) buf;		} else {			BATatoms[t].atomToStr(&valstr, &l2, val);			val = (ptr) valstr;		}	} else {		l2 = strlen((str) val);	}	*res = (str) GDKmalloc(l1 + l2 + 1);	memcpy(*res, s, l1);	memcpy(*res + l1, (str) val, l2);	(*res)[l1 + l2] = '\0';	if (valstr)		GDKfree(valstr);	return GDK_SUCCEED;}intstrLength(int *res, str s){	RETURN_NIL_IF(strNil(s), TYPE_int);	*res = UTF8_strlen(s);	return GDK_SUCCEED;}intstrBytes(int *res, str s){	*res = strlen(s);	return GDK_SUCCEED;}intstrTail(str *res, str s, int *offset){	int off = *offset;	RETURN_NIL_IF(strNil(s) || off == int_nil, TYPE_str);	if (off < 0) {		int len = UTF8_strlen(s);		RETURN_NIL_IF(len == int_nil, TYPE_str);		off = len + off;		if (off < 0)			off = 0;	}	*res = (char *) GDKstrdup(UTF8_strtail(s, off));	return GDK_SUCCEED;}intstrSubString(str *res, str s, int *offset, int *length){	int len, off = *offset;	RETURN_NIL_IF(strNil(s) || off == int_nil || *length == int_nil, TYPE_str);	if (off < 0) {		len = UTF8_strlen(s);		RETURN_NIL_IF(len == int_nil, TYPE_str);		off = len + off;		if (off < 0) {			*length += off;			off = 0;		}	}	if (*length < 0) {		*res = GDKstrdup("");		return GDK_SUCCEED;	}	s = UTF8_strtail(s, MAX(0, off));	len = UTF8_strtail(s, *length) - s;	if (off < 0) {		len += off;		off = 0;	}	*res = (char *) GDKmalloc(len + 1);	strncpy(*res, s, len);	(*res)[len] = 0;	return GDK_SUCCEED;}intstrFromWChr(str *res, int *c){	str s = *res = GDKmalloc(7);	#line 1248 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/atoms/str.mx"	if ((*c) < 0#if SIZEOF_INT > 4	    || (int) (*c) >= 0x80000000#endif	   ) {		*(s)++ = chr_nil;	} else if ((*c) < 0x80) {		*(s)++ = (*c);	} else if ((*c) < 0x800) {		*(s)++ = 0xC0 | ((*c) >> 6);		*(s)++ = 0x80 | ((*c) & 0x3F);	} else if ((*c) < 0x10000) {		*(s)++ = 0xE0 | ((*c) >> 12);		*(s)++ = 0x80 | (((*c) >> 6) & 0x3F);		*(s)++ = 0x80 | ((*c) & 0x3F);	} else if ((*c) < 0x200000) {		*(s)++ = 0xF0 | ((*c) >> 18);		*(s)++ = 0x80 | (((*c) >> 12) & 0x3F);		*(s)++ = 0x80 | (((*c) >> 6) & 0x3F);		*(s)++ = 0x80 | ((*c) & 0x3F);	} else if ((*c) < 0x4000000) {		*(s)++ = 0xF8 | ((*c) >> 24);		*(s)++ = 0x80 | (((*c) >> 18) & 0x3F);		*(s)++ = 0x80 | (((*c) >> 12) & 0x3F);		*(s)++ = 0x80 | (((*c) >> 6) & 0x3F);		*(s)++ = 0x80 | ((*c) & 0x3F);	} else /* if ((*c) < 0x80000000) */ {		*(s)++ = 0xFC | ((*c) >> 30);		*(s)++ = 0x80 | (((*c) >> 24) & 0x3F);		*(s)++ = 0x80 | (((*c) >> 18) & 0x3F);		*(s)++ = 0x80 | (((*c) >> 12) & 0x3F);		*(s)++ = 0x80 | (((*c) >> 6) & 0x3F);		*(s)++ = 0x80 | ((*c) & 0x3F);	}#line 1512 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/atoms/str.mx"	*s = 0;	return GDK_SUCCEED;}intstrWChrAt(int *res, str val, int *at){	unsigned char *s = (unsigned char *) val;	RETURN_NIL_IF(strNil(val) || *at == int_nil || *at < 0, TYPE_chr);	s = (unsigned char *) UTF8_strtail((str) s, *at);	RETURN_NIL_IF(*s == 0, TYPE_chr);	#line 1217 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/atoms/str.mx"	if (*s < 0x80) {		(*res) = *(s)++;	} else if (*(s) < 0xE0) {		(*res)  = (*(s)++ & 0x1F) << 6;		(*res) |= (*(s)++ & 0x3F);	} else if (*(s) < 0xF0) {		(*res)  = (*(s)++ & 0x0F) << 12;		(*res) |= (*(s)++ & 0x3F) << 6;		(*res) |= (*(s)++ & 0x3F);	} else if (*s < 0xF8) {		(*res)  = (*(s)++ & 0x07) << 18;		(*res) |= (*(s)++ & 0x3F) << 12;		(*res) |= (*(s)++ & 0x3F) << 6;		(*res) |= (*(s)++ & 0x3F);	} else if (*s < 0xFC) {		(*res)  = (*(s)++ & 0x03) << 24;		(*res) |= (*(s)++ & 0x3F) << 18;		(*res) |= (*(s)++ & 0x3F) << 12;		(*res) |= (*(s)++ & 0x3F) << 6;		(*res) |= (*(s)++ & 0x3F);	} else if (*s < 0xFE) {		(*res)  = (*(s)++ & 0x01) << 30;		(*res) |= (*(s)++ & 0x3F) << 24;		(*res) |= (*(s)++ & 0x3F) << 18;		(*res) |= (*(s)++ & 0x3F) << 12;		(*res) |= (*(s)++ & 0x3F) << 6;		(*res) |= (*(s)++ & 0x3F);	} else {		(*res) = int_nil;	}#line 1526 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/atoms/str.mx"

⌨️ 快捷键说明

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