亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? cash.c

?? 關系型數據庫 Postgresql 6.5.2
?? C
?? 第 1 頁 / 共 2 頁
字號:
/* * cash.c * Written by D'Arcy J.M. Cain * * Functions to allow input and output of money normally but store * and handle it as int4s * * A slightly modified version of this file and a discussion of the * workings can be found in the book "Software Solutions in C" by * Dale Schumacher, Academic Press, ISBN: 0-12-632360-7. * * $Header: /usr/local/cvsroot/pgsql/src/backend/utils/adt/cash.c,v 1.28.2.1 1999/08/02 05:24:50 scrappy Exp $ */#include <limits.h>#include <ctype.h>#include <locale.h>#include "postgres.h"#include "miscadmin.h"#include "utils/builtins.h"#include "utils/cash.h"static const char *num_word(Cash value);/* when we go to 64 bit values we will have to modify this */#define CASH_BUFSZ		24#define TERMINATOR		(CASH_BUFSZ - 1)#define LAST_PAREN		(TERMINATOR - 1)#define LAST_DIGIT		(LAST_PAREN - 1)#ifdef USE_LOCALEstatic struct lconv *lconvert = NULL;#endif/* cash_in() * Convert a string to a cash data type. * Format is [$]###[,]###[.##] * Examples: 123.45 $123.45 $123,456.78 * * This is currently implemented as a 32-bit integer. * XXX HACK It looks as though some of the symbols for *	monetary values returned by localeconv() can be multiple *	bytes/characters. This code assumes one byte only. - tgl 97/04/14 * XXX UNHACK Allow the currency symbol to be multi-byte. *	- thomas 1998-03-01 */Cash *cash_in(const char *str){	Cash	   *result;	Cash		value = 0;	Cash		dec = 0;	Cash		sgn = 1;	int			seen_dot = 0;	const char *s = str;	int			fpoint;	char	   *csymbol;	char		dsymbol,				ssymbol,				psymbol,			   *nsymbol;#ifdef USE_LOCALE#ifdef CASHDEBUG	setlocale(LC_ALL, "");	lconvert = localeconv();#endif	if (lconvert == NULL)		lconvert = localeconv();	/* frac_digits in the C locale seems to return CHAR_MAX */	/* best guess is 2 in this case I think */	fpoint = ((lconvert->frac_digits != CHAR_MAX) ? lconvert->frac_digits : 2); /* int_frac_digits? */	dsymbol = ((*lconvert->mon_decimal_point != '\0') ? *lconvert->mon_decimal_point : '.');	ssymbol = ((*lconvert->mon_thousands_sep != '\0') ? *lconvert->mon_thousands_sep : ',');	csymbol = ((*lconvert->currency_symbol != '\0') ? lconvert->currency_symbol : "$");	psymbol = ((*lconvert->positive_sign != '\0') ? *lconvert->positive_sign : '+');	nsymbol = ((*lconvert->negative_sign != '\0') ? lconvert->negative_sign : "-");#else	fpoint = 2;	dsymbol = '.';	ssymbol = ',';	csymbol = "$";	psymbol = '+';	nsymbol = "-";#endif#ifdef CASHDEBUG	printf("cashin- precision '%d'; decimal '%c'; thousands '%c'; currency '%s'; positive '%c'; negative '%s'\n",		   fpoint, dsymbol, ssymbol, csymbol, psymbol, nsymbol);#endif	/* we need to add all sorts of checking here.  For now just */	/* strip all leading whitespace and any leading currency symbol */	while (isspace(*s))		s++;	if (strncmp(s, csymbol, strlen(csymbol)) == 0)		s += strlen(csymbol);#ifdef CASHDEBUG	printf("cashin- string is '%s'\n", s);#endif	/* a leading minus or paren signifies a negative number */	/* again, better heuristics needed */	if (strncmp(s, nsymbol, strlen(nsymbol)) == 0)	{		sgn = -1;		s += strlen(nsymbol);#ifdef CASHDEBUG		printf("cashin- negative symbol; string is '%s'\n", s);#endif	}	else if (*s == '(')	{		sgn = -1;		s++;	}	else if (*s == psymbol)		s++;#ifdef CASHDEBUG	printf("cashin- string is '%s'\n", s);#endif	while (isspace(*s))		s++;	if (strncmp(s, csymbol, strlen(csymbol)) == 0)		s += strlen(csymbol);#ifdef CASHDEBUG	printf("cashin- string is '%s'\n", s);#endif	for (;; s++)	{		/* we look for digits as int4 as we have less */		/* than the required number of decimal places */		if (isdigit(*s) && dec < fpoint)		{			value = (value * 10) + *s - '0';			if (seen_dot)				dec++;			/* decimal point? then start counting fractions... */		}		else if (*s == dsymbol && !seen_dot)		{			seen_dot = 1;			/* "thousands" separator? then skip... */		}		else if (*s == ssymbol)		{		}		else		{			/* round off */			if (isdigit(*s) && *s >= '5')				value++;			/* adjust for less than required decimal places */			for (; dec < fpoint; dec++)				value *= 10;			break;		}	}	while (isspace(*s) || *s == '0' || *s == ')')		s++;	if (*s != '\0')		elog(ERROR, "Bad money external representation %s", str);	if (!PointerIsValid(result = palloc(sizeof(Cash))))		elog(ERROR, "Memory allocation failed, can't input cash '%s'", str);	*result = (value * sgn);#ifdef CASHDEBUG	printf("cashin- result is %d\n", *result);#endif	return result;}	/* cash_in() *//* cash_out() * Function to convert cash to a dollars and cents representation. * XXX HACK This code appears to assume US conventions for *	positive-valued amounts. - tgl 97/04/14 */const char *cash_out(Cash *in_value){	Cash		value = *in_value;	char	   *result;	char		buf[CASH_BUFSZ];	int			minus = 0;	int			count = LAST_DIGIT;	int			point_pos;	int			comma_position = 0;	char		mon_group,				comma,				points;	char	   *csymbol,				dsymbol,			   *nsymbol;	char		convention;#ifdef USE_LOCALE	if (lconvert == NULL)		lconvert = localeconv();	mon_group = *lconvert->mon_grouping;	comma = ((*lconvert->mon_thousands_sep != '\0') ? *lconvert->mon_thousands_sep : ',');	/* frac_digits in the C locale seems to return CHAR_MAX */	/* best guess is 2 in this case I think */	points = ((lconvert->frac_digits != CHAR_MAX) ? lconvert->frac_digits : 2); /* int_frac_digits? */	convention = lconvert->n_sign_posn;	dsymbol = ((*lconvert->mon_decimal_point != '\0') ? *lconvert->mon_decimal_point : '.');	csymbol = ((*lconvert->currency_symbol != '\0') ? lconvert->currency_symbol : "$");	nsymbol = ((*lconvert->negative_sign != '\0') ? lconvert->negative_sign : "-");#else	mon_group = 3;	comma = ',';	csymbol = "$";	dsymbol = '.';	nsymbol = "-";	points = 2;	convention = 0;#endif	point_pos = LAST_DIGIT - points;	/* We're playing a little fast and loose with this.  Shoot me. */	/* Not me, that was the other guy. Haven't fixed it yet - thomas */	if (!mon_group || mon_group == CHAR_MAX)		mon_group = 3;	/* allow more than three decimal points and separate them */	if (comma)	{		point_pos -= (points - 1) / mon_group;		comma_position = point_pos % (mon_group + 1);	}	/* we work with positive amounts and add the minus sign at the end */	if (value < 0)	{		minus = 1;		value *= -1;	}	/* allow for trailing negative strings */	MemSet(buf, ' ', CASH_BUFSZ);	buf[TERMINATOR] = buf[LAST_PAREN] = '\0';	while (value || count > (point_pos - 2))	{		if (points && count == point_pos)			buf[count--] = dsymbol;		else if (comma && count % (mon_group + 1) == comma_position)			buf[count--] = comma;		buf[count--] = (value % 10) + '0';		value /= 10;	}	strncpy((buf + count - strlen(csymbol) + 1), csymbol, strlen(csymbol));	count -= strlen(csymbol) - 1;	if (buf[LAST_DIGIT] == ',')		buf[LAST_DIGIT] = buf[LAST_PAREN];	/* see if we need to signify negative amount */	if (minus)	{		if (!PointerIsValid(result = palloc(CASH_BUFSZ + 2 - count + strlen(nsymbol))))			elog(ERROR, "Memory allocation failed, can't output cash", NULL);		/* Position code of 0 means use parens */		if (convention == 0)			sprintf(result, "(%s)", buf + count);		else if (convention == 2)			sprintf(result, "%s%s", buf + count, nsymbol);		else			sprintf(result, "%s%s", nsymbol, buf + count);	}	else	{		if (!PointerIsValid(result = palloc(CASH_BUFSZ + 2 - count)))			elog(ERROR, "Memory allocation failed, can't output cash", NULL);		strcpy(result, buf + count);	}	return result;}	/* cash_out() */boolcash_eq(Cash *c1, Cash *c2){	if (!PointerIsValid(c1) || !PointerIsValid(c2))		return FALSE;	return *c1 == *c2;}	/* cash_eq() */boolcash_ne(Cash *c1, Cash *c2){	if (!PointerIsValid(c1) || !PointerIsValid(c2))		return FALSE;	return *c1 != *c2;}	/* cash_ne() */boolcash_lt(Cash *c1, Cash *c2){	if (!PointerIsValid(c1) || !PointerIsValid(c2))		return FALSE;	return *c1 < *c2;}	/* cash_lt() */boolcash_le(Cash *c1, Cash *c2){	if (!PointerIsValid(c1) || !PointerIsValid(c2))		return FALSE;	return *c1 <= *c2;}	/* cash_le() */boolcash_gt(Cash *c1, Cash *c2){	if (!PointerIsValid(c1) || !PointerIsValid(c2))		return FALSE;	return *c1 > *c2;}	/* cash_gt() */boolcash_ge(Cash *c1, Cash *c2){	if (!PointerIsValid(c1) || !PointerIsValid(c2))		return FALSE;	return *c1 >= *c2;}	/* cash_ge() *//* cash_pl() * Add two cash values. */Cash *cash_pl(Cash *c1, Cash *c2){	Cash	   *result;	if (!PointerIsValid(c1) || !PointerIsValid(c2))		return NULL;	if (!PointerIsValid(result = palloc(sizeof(Cash))))		elog(ERROR, "Memory allocation failed, can't add cash", NULL);	*result = (*c1 + *c2);	return result;}	/* cash_pl() *//* cash_mi() * Subtract two cash values. */Cash *cash_mi(Cash *c1, Cash *c2){	Cash	   *result;	if (!PointerIsValid(c1) || !PointerIsValid(c2))		return NULL;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲午夜久久久久久久久电影网| 一个色在线综合| 欧美日精品一区视频| 麻豆久久久久久久| 国产精品女人毛片| 日韩精品一区二区三区视频播放 | 精品国产凹凸成av人导航| 99久久伊人精品| 国产乱子伦一区二区三区国色天香| 亚洲精品视频一区二区| 久久久久久久久久电影| 欧美一区二区在线免费观看| 色噜噜夜夜夜综合网| 国产不卡视频一区| 美女视频第一区二区三区免费观看网站| 亚洲欧美aⅴ...| 日本一区二区成人| 久久久久久久久久久99999| 欧美丰满少妇xxxxx高潮对白| av影院午夜一区| 国产成人精品免费一区二区| 欧美96一区二区免费视频| 亚洲电影在线免费观看| 日韩理论片在线| 国产精品你懂的在线| 国产三级三级三级精品8ⅰ区| 在线成人免费视频| 欧美二区三区的天堂| 欧美体内she精高潮| 色婷婷精品大视频在线蜜桃视频 | 国产一区二区视频在线播放| 免费成人美女在线观看.| 午夜视黄欧洲亚洲| 亚洲妇熟xx妇色黄| 亚洲午夜羞羞片| 亚洲一区二区五区| 亚洲黄一区二区三区| 亚洲欧洲成人av每日更新| 国产日本亚洲高清| 国产亚洲精品7777| 中日韩免费视频中文字幕| 国产欧美视频一区二区| 国产欧美一区二区精品久导航| 久久久三级国产网站| 国产午夜亚洲精品不卡| 国产目拍亚洲精品99久久精品| 久久日韩粉嫩一区二区三区| 国产女人18毛片水真多成人如厕| 欧美激情在线看| 亚洲天堂2016| 亚洲成人午夜影院| 日本麻豆一区二区三区视频| 国精产品一区一区三区mba视频| 久久国产人妖系列| 懂色中文一区二区在线播放| 色综合中文字幕| 欧美午夜一区二区三区免费大片| 欧美乱妇一区二区三区不卡视频| 欧美一区二区私人影院日本| 26uuu另类欧美亚洲曰本| 国产欧美精品一区二区色综合 | 欧美丰满少妇xxxbbb| 日韩欧美一区电影| 国产精品三级在线观看| 一区二区三区毛片| 蜜桃av一区二区三区| 国产九九视频一区二区三区| av在线这里只有精品| 欧美日韩高清一区| 精品理论电影在线| 中文字幕日本不卡| 视频一区二区不卡| 粉嫩绯色av一区二区在线观看 | 欧美优质美女网站| 欧美mv日韩mv| 自拍偷拍亚洲欧美日韩| 日韩精品乱码av一区二区| 国产一区二区福利| 欧美最猛性xxxxx直播| 久久丝袜美腿综合| 亚洲影视在线播放| 国产福利91精品| 欧美日本不卡视频| 中文字幕乱码日本亚洲一区二区| 中文字幕亚洲精品在线观看| 精品午夜久久福利影院| 成人国产精品视频| 欧美在线色视频| 亚洲欧洲日韩综合一区二区| 美女爽到高潮91| 欧美日本一区二区三区四区 | 欧美在线播放高清精品| 精品国产免费久久 | www激情久久| 色综合久久综合| 欧美成人综合网站| 亚洲免费在线播放| 国产福利一区在线观看| 51精品国自产在线| 亚洲欧洲日韩女同| 国内不卡的二区三区中文字幕 | 欧美精品欧美精品系列| 亚洲午夜免费视频| 日本久久一区二区三区| 国产欧美一区二区精品忘忧草| 精品一区二区国语对白| 久久综合av免费| 精品国产一区二区三区久久久蜜月| 亚洲素人一区二区| 国内久久婷婷综合| 91精品国产乱码久久蜜臀| 亚洲视频小说图片| 国产传媒一区在线| 精品久久99ma| 五月婷婷色综合| 欧美自拍偷拍一区| 亚洲欧美另类久久久精品2019| 国产精品66部| 精品1区2区在线观看| 日本vs亚洲vs韩国一区三区二区| 欧美中文字幕一二三区视频| 亚洲免费色视频| 成人av资源在线观看| 中文字幕高清一区| 国产乱子伦一区二区三区国色天香| 欧美电影免费观看完整版| 日本欧美肥老太交大片| 在线成人免费观看| 日韩精品91亚洲二区在线观看| 91网站最新网址| 国产精品毛片高清在线完整版| 国产精品一二三四五| 26uuu国产电影一区二区| 久草中文综合在线| 欧美第一区第二区| 国产麻豆9l精品三级站| 国产丝袜在线精品| 不卡电影一区二区三区| 综合久久久久综合| 色94色欧美sute亚洲线路二| 亚洲精品国久久99热| 91麻豆产精品久久久久久 | 亚洲欧洲精品一区二区精品久久久 | 日韩国产精品久久| 8x8x8国产精品| 精品一区二区成人精品| 精品久久一二三区| 国产精品99久久不卡二区| 国产精品国产三级国产有无不卡| 成人免费va视频| 亚洲免费观看在线视频| 色欧美片视频在线观看在线视频| 一级做a爱片久久| 欧美男男青年gay1069videost| 蜜桃传媒麻豆第一区在线观看| 欧美精品一区二区三区蜜臀| 成人综合在线视频| 亚洲中国最大av网站| 欧美一区二区福利在线| 国产福利一区在线| 亚洲精品高清在线观看| 欧美一区二区三区小说| 国产成人高清视频| 亚洲精品国久久99热| 欧美一区二区三区色| 国产一区二区毛片| 亚洲精品免费播放| 精品国产三级a在线观看| 粉嫩久久99精品久久久久久夜| 夜夜精品视频一区二区| 欧美v日韩v国产v| 成人黄色av电影| 午夜精品福利一区二区三区av | 国产在线不卡一区| 中文字幕亚洲电影| 欧美一区二区三区的| 成人免费视频播放| 亚洲成人免费av| 欧美高清一级片在线观看| 欧美日韩小视频| 国产白丝精品91爽爽久久| 洋洋av久久久久久久一区| 日韩精品一区二区在线| 一本一道波多野结衣一区二区| 日本不卡的三区四区五区| 一区在线观看免费| 欧美一区二区三区电影| 91网址在线看| 国产乱对白刺激视频不卡| 亚洲一区二区三区四区在线观看 | 国产不卡免费视频| 日日夜夜免费精品视频| 国产精品欧美久久久久一区二区| 欧美人体做爰大胆视频| av激情成人网| 狠狠色丁香久久婷婷综合_中| 亚洲一区二区欧美| 国产精品萝li| 久久综合久久综合久久| 在线电影一区二区三区|