Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitae64196

Browse files
committed
Change the version. We are moving towards the next release.
Fixed a nasty bug that messed up negative money amounts.
1 parent9e774ca commitae64196

File tree

1 file changed

+31
-9
lines changed

1 file changed

+31
-9
lines changed

‎src/interfaces/python/pgmodule.c

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
#include<string.h>
3737

3838
staticPyObject*PGError;
39-
staticconstchar*PyPgVersion="3.2";
39+
staticconstchar*PyPgVersion="3.3";
4040

4141
/* taken from fileobject.c */
4242
#defineBUF(v) PyString_AS_STRING((PyStringObject *)(v))
@@ -1844,21 +1844,32 @@ pgquery_getresult(pgqueryobject * self, PyObject * args)
18441844
val=PyFloat_FromDouble(strtod(s,NULL));
18451845
break;
18461846

1847-
case3:/* get rid of the '$' and commas */
1847+
case3:
1848+
{
1849+
intmult=1;
1850+
18481851
if (*s=='$')/* there's talk of getting rid of
18491852
* it */
18501853
s++;
18511854

1852-
if ((s[0]=='-'||s[0]=='(')&&s[1]=='$')
1853-
*(++s)='-';
1855+
if (*s=='-'||*s=='(')
1856+
{
1857+
s++;
1858+
mult=-1;
1859+
}
1860+
1861+
/* get rid of the '$' and commas */
1862+
if (*s=='$')/* Just in case we exposed one */
1863+
s++;
18541864

18551865
for (k=0;*s;s++)
18561866
if (*s!=',')
18571867
cashbuf[k++]=*s;
18581868

18591869
cashbuf[k]=0;
1860-
val=PyFloat_FromDouble(strtod(cashbuf,NULL));
1870+
val=PyFloat_FromDouble(strtod(cashbuf,NULL)*mult);
18611871
break;
1872+
}
18621873

18631874
default:
18641875
val=PyString_FromString(s);
@@ -1980,21 +1991,32 @@ pgquery_dictresult(pgqueryobject * self, PyObject * args)
19801991
val=PyFloat_FromDouble(strtod(s,NULL));
19811992
break;
19821993

1983-
case3:/* get rid of the '$' and commas */
1994+
case3:
1995+
{
1996+
intmult=1;
1997+
19841998
if (*s=='$')/* there's talk of getting rid of
19851999
* it */
19862000
s++;
19872001

1988-
if ((s[0]=='-'||s[0]=='(')&&s[1]=='$')
1989-
*(++s)='-';
2002+
if (*s=='-'||*s=='(')
2003+
{
2004+
s++;
2005+
mult=-1;
2006+
}
2007+
2008+
/* get rid of the '$' and commas */
2009+
if (*s=='$')/* Just in case we exposed one */
2010+
s++;
19902011

19912012
for (k=0;*s;s++)
19922013
if (*s!=',')
19932014
cashbuf[k++]=*s;
19942015

19952016
cashbuf[k]=0;
1996-
val=PyFloat_FromDouble(strtod(cashbuf,NULL));
2017+
val=PyFloat_FromDouble(strtod(cashbuf,NULL)*mult);
19972018
break;
2019+
}
19982020

19992021
default:
20002022
val=PyString_FromString(s);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp