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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? cash.c

?? PostgreSQL7.4.6 for Linux
?? C
?? 第 1 頁(yè) / 共 2 頁(yè)
字號(hào):
/* * 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: /cvsroot/pgsql/src/backend/utils/adt/cash.c,v 1.61 2003/09/25 06:58:03 petere Exp $ */#include "postgres.h"#include <limits.h>#include <ctype.h>#include <math.h>#include <locale.h>#include "libpq/pqformat.h"#include "miscadmin.h"#include "utils/builtins.h"#include "utils/cash.h"#include "utils/pg_locale.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)/* * Cash is a pass-by-ref SQL type, so we must pass and return pointers. * These macros and support routine hide the pass-by-refness. */#define PG_GETARG_CASH(n)  (* ((Cash *) PG_GETARG_POINTER(n)))#define PG_RETURN_CASH(x)  return CashGetDatum(x)static DatumCashGetDatum(Cash value){	Cash	   *result = (Cash *) palloc(sizeof(Cash));	*result = value;	return PointerGetDatum(result);}/* 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 multibyte. *	- thomas 1998-03-01 */Datumcash_in(PG_FUNCTION_ARGS){	char	   *str = PG_GETARG_CSTRING(0);	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;	struct lconv *lconvert = PGLC_localeconv();	/*	 * frac_digits will be CHAR_MAX in some locales, notably C.  However,	 * just testing for == CHAR_MAX is risky, because of compilers like	 * gcc that "helpfully" let you alter the platform-standard definition	 * of whether char is signed or not.  If we are so unfortunate as to	 * get compiled with a nonstandard -fsigned-char or -funsigned-char	 * switch, then our idea of CHAR_MAX will not agree with libc's. The	 * safest course is not to test for CHAR_MAX at all, but to impose a	 * range check for plausible frac_digits values.	 */	fpoint = lconvert->frac_digits;	if (fpoint < 0 || fpoint > 10)		fpoint = 2;				/* best guess in this case, I think */	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 : "-");#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((unsigned char) *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((unsigned char) *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((unsigned char) *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((unsigned char) *s) && *s >= '5')				value++;			/* adjust for less than required decimal places */			for (; dec < fpoint; dec++)				value *= 10;			break;		}	}	while (isspace((unsigned char) *s) || *s == '0' || *s == ')')		s++;	if (*s != '\0')		ereport(ERROR,				(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),				 errmsg("invalid input syntax for type money: \"%s\"", str)));	result = (value * sgn);#ifdef CASHDEBUG	printf("cashin- result is %d\n", result);#endif	PG_RETURN_CASH(result);}/* 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 */Datumcash_out(PG_FUNCTION_ARGS){	Cash		value = PG_GETARG_CASH(0);	char	   *result;	char		buf[CASH_BUFSZ];	int			minus = 0;	int			count = LAST_DIGIT;	int			point_pos;	int			comma_position = 0;	int			points,				mon_group;	char		comma;	char	   *csymbol,				dsymbol,			   *nsymbol;	char		convention;	struct lconv *lconvert = PGLC_localeconv();	/* see comments about frac_digits in cash_in() */	points = lconvert->frac_digits;	if (points < 0 || points > 10)		points = 2;				/* best guess in this case, I think */	/*	 * As with frac_digits, must apply a range check to mon_grouping to	 * avoid being fooled by variant CHAR_MAX values.	 */	mon_group = *lconvert->mon_grouping;	if (mon_group <= 0 || mon_group > 6)		mon_group = 3;	comma = ((*lconvert->mon_thousands_sep != '\0') ? *lconvert->mon_thousands_sep : ',');	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 : "-");	point_pos = LAST_DIGIT - points;	/* 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 = -value;	}	/* 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--] = ((unsigned int) value % 10) + '0';		value = ((unsigned int) 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))))			ereport(ERROR,					(errcode(ERRCODE_OUT_OF_MEMORY),					 errmsg("out of memory")));		/* 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)))			ereport(ERROR,					(errcode(ERRCODE_OUT_OF_MEMORY),					 errmsg("out of memory")));		strcpy(result, buf + count);	}	PG_RETURN_CSTRING(result);}/* *		cash_recv			- converts external binary format to cash */Datumcash_recv(PG_FUNCTION_ARGS){	StringInfo	buf = (StringInfo) PG_GETARG_POINTER(0);	PG_RETURN_CASH((Cash) pq_getmsgint(buf, sizeof(Cash)));}/* *		cash_send			- converts cash to binary format */Datumcash_send(PG_FUNCTION_ARGS){	Cash		arg1 = PG_GETARG_CASH(0);	StringInfoData buf;	pq_begintypsend(&buf);	pq_sendint(&buf, arg1, sizeof(Cash));	PG_RETURN_BYTEA_P(pq_endtypsend(&buf));}/* * Comparison functions */Datumcash_eq(PG_FUNCTION_ARGS){	Cash		c1 = PG_GETARG_CASH(0);	Cash		c2 = PG_GETARG_CASH(1);	PG_RETURN_BOOL(c1 == c2);}Datumcash_ne(PG_FUNCTION_ARGS){	Cash		c1 = PG_GETARG_CASH(0);	Cash		c2 = PG_GETARG_CASH(1);	PG_RETURN_BOOL(c1 != c2);}Datumcash_lt(PG_FUNCTION_ARGS){	Cash		c1 = PG_GETARG_CASH(0);	Cash		c2 = PG_GETARG_CASH(1);	PG_RETURN_BOOL(c1 < c2);}Datumcash_le(PG_FUNCTION_ARGS){	Cash		c1 = PG_GETARG_CASH(0);	Cash		c2 = PG_GETARG_CASH(1);	PG_RETURN_BOOL(c1 <= c2);}Datumcash_gt(PG_FUNCTION_ARGS){	Cash		c1 = PG_GETARG_CASH(0);	Cash		c2 = PG_GETARG_CASH(1);	PG_RETURN_BOOL(c1 > c2);}Datumcash_ge(PG_FUNCTION_ARGS){	Cash		c1 = PG_GETARG_CASH(0);	Cash		c2 = PG_GETARG_CASH(1);	PG_RETURN_BOOL(c1 >= c2);}Datumcash_cmp(PG_FUNCTION_ARGS){	Cash		c1 = PG_GETARG_CASH(0);	Cash		c2 = PG_GETARG_CASH(1);

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久精品久久99精品久久| 青椒成人免费视频| 日韩网站在线看片你懂的| 成人午夜精品在线| 五月激情六月综合| ...av二区三区久久精品| 日韩一级精品视频在线观看| 91亚洲国产成人精品一区二三| 久久精品国产精品亚洲红杏 | 日韩欧美亚洲国产另类 | 欧美大片在线观看| 一本色道亚洲精品aⅴ| 国产精品亚洲专一区二区三区| 亚洲电影欧美电影有声小说| 亚洲欧洲日产国码二区| 26uuu欧美日本| 日韩欧美国产三级电影视频| 欧美精品久久99| 在线观看免费成人| 色欧美日韩亚洲| 色婷婷综合久久久久中文| 成人精品免费看| 国内精品伊人久久久久av影院| 日韩精品一二三区| 亚洲第一在线综合网站| 一区二区三区四区不卡在线| 国产精品久久久久久久岛一牛影视 | 成人免费毛片app| 极品少妇xxxx精品少妇| 欧美aaa在线| 日韩av一区二区三区四区| 亚洲韩国一区二区三区| 亚洲午夜精品17c| 亚洲国产综合在线| 偷拍一区二区三区| 日本午夜一区二区| 青青草伊人久久| 久久精品久久综合| 国内精品自线一区二区三区视频| 看片的网站亚洲| 韩国v欧美v亚洲v日本v| 国产毛片一区二区| 国产一区美女在线| 成人午夜激情片| 波多野结衣91| 色婷婷av一区二区三区之一色屋| 色噜噜狠狠一区二区三区果冻| 一本久久a久久精品亚洲| 91黄色免费版| 欧美日韩国产在线观看| 欧美成人在线直播| 国产女人18水真多18精品一级做| 日本一区二区成人| 亚洲免费电影在线| 香蕉影视欧美成人| 人人精品人人爱| 激情文学综合网| 岛国精品在线观看| 色婷婷av一区二区三区软件 | 一本久道中文字幕精品亚洲嫩 | 国产午夜精品一区二区三区视频| 国产片一区二区三区| 最新国产精品久久精品| 亚洲a一区二区| 国产在线日韩欧美| 97久久久精品综合88久久| 欧美日韩精品一区二区三区四区 | 国产精品视频一二三区| 一个色妞综合视频在线观看| 午夜欧美在线一二页| 久久av老司机精品网站导航| 懂色av中文一区二区三区| 色婷婷久久综合| www精品美女久久久tv| 中文字幕欧美一| 日日噜噜夜夜狠狠视频欧美人 | 亚洲视频一区在线| 青青国产91久久久久久| 不卡的电影网站| 91麻豆精品国产91久久久久久久久| 26uuu成人网一区二区三区| 亚洲另类在线一区| 久久99国产精品麻豆| 91在线丨porny丨国产| 正在播放一区二区| 中文字幕在线一区| 久久国产尿小便嘘嘘| 色一区在线观看| 欧美精品一区二区三| 一区二区三区久久| 国产一区二区三区在线观看精品 | 日本不卡视频一二三区| 不卡的av在线播放| 精品乱人伦一区二区三区| 亚洲免费看黄网站| 国产精品一级黄| 欧美一区永久视频免费观看| 亚洲视频一区在线| 国产成人精品免费在线| 日韩一区二区在线观看| 一区二区三区欧美日韩| av在线一区二区三区| 久久久精品免费网站| 日本成人在线电影网| 91福利资源站| 人人爽香蕉精品| 欧美日韩亚洲综合一区二区三区| 中文字幕乱码亚洲精品一区| 九九久久精品视频| 欧美一区二区视频观看视频| 17c精品麻豆一区二区免费| 国产盗摄视频一区二区三区| 日韩欧美色综合| 亚洲国产中文字幕| 在线观看日韩电影| 亚洲老妇xxxxxx| 不卡一区二区中文字幕| 中文字幕电影一区| 国产成人鲁色资源国产91色综| 日韩欧美成人激情| 免费成人在线播放| 欧美一二三四在线| 免费看黄色91| 日韩精品一区二区三区在线观看| 日韩国产一二三区| 欧美另类久久久品| 舔着乳尖日韩一区| 69堂成人精品免费视频| 天堂成人免费av电影一区| 欧美日韩免费不卡视频一区二区三区| 一区二区欧美精品| 欧美性生交片4| 亚洲大片在线观看| 欧美日韩高清影院| 天天av天天翘天天综合网| 欧美片网站yy| 日本午夜一本久久久综合| 欧美xingq一区二区| 捆绑紧缚一区二区三区视频| 精品国产免费人成电影在线观看四季| 久久国产综合精品| 欧美aaaaaa午夜精品| 日韩精品一区二区三区蜜臀| 老司机午夜精品99久久| 日韩精品一区国产麻豆| 激情欧美日韩一区二区| 国产亚洲欧美在线| 懂色av中文字幕一区二区三区| 国产精品美女久久久久高潮| 一本色道综合亚洲| 午夜精品福利一区二区蜜股av| 91麻豆精品91久久久久久清纯| 蜜臀精品一区二区三区在线观看| 精品国产免费人成电影在线观看四季| 国产精品自产自拍| 中文字幕日韩欧美一区二区三区| 在线欧美一区二区| 日产精品久久久久久久性色| 精品日本一线二线三线不卡| 国产精品一区二区男女羞羞无遮挡| 国产精品福利一区二区三区| 精品视频资源站| 久久99久久精品欧美| 国产精品美日韩| 欧美日韩国产乱码电影| 国产一区二区三区精品视频| 亚洲天堂网中文字| 欧美一区二区国产| 国产.精品.日韩.另类.中文.在线.播放| 国产精品国产馆在线真实露脸 | eeuss鲁片一区二区三区在线看| 亚洲精品va在线观看| 欧美日韩的一区二区| 国产一区在线观看视频| 一区二区三区在线看| 精品国产乱码久久久久久1区2区 | 国产精品三级av| 在线看日本不卡| 国产麻豆欧美日韩一区| 中文字幕在线一区| 日韩区在线观看| 91麻豆精品在线观看| 久久国产精品第一页| 一区二区三区中文在线| 久久久蜜桃精品| 欧美日本在线观看| 成人免费毛片嘿嘿连载视频| 日韩福利视频网| 成人免费在线视频观看| 精品久久久久久久人人人人传媒| 99精品视频一区| 国产乱码精品一区二区三区av| 一区二区三区在线免费播放| 久久精品一区二区| 日韩午夜精品视频| 91福利资源站| 97国产一区二区| 高清成人免费视频| 蓝色福利精品导航| 视频在线观看91|