freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
- From: "Thompson, Bill D (London)" <bill_d_thompson AT ml.com>
- To: "FreeTDS Development Group" <freetds AT lists.ibiblio.org>
- Subject: [freetds] A small fix
- Date: Fri, 10 Dec 2004 14:38:48 -0000
Guys,
If RC5 turns out NOT to be the final release, I've got a small patch to
src/tds/convert.c
This corrects some small bugs in string_to_numeric().
as things stand we regard a string like
".1234"
as being malformed.
We also don't like trailing blanks on a string.
here's the diff:
--- convert.c 2004-10-14 15:47:39.000000000 +0100
+++ /home/thompbil/FREETDS/freetds-0.63RC2.mine/src/tds/convert.c
2004-12-10 13:55:53.099889000 +0000
@@ -1974,11 +1974,12 @@
char not_zero = 1;
int i = 0;
int j = 0;
- short int bytes, places, point_found, digits;
+ short int bytes, places, point_found, space_found, digits;
unsigned char sign;
sign = 0;
point_found = 0;
+ space_found = 0;
places = 0;
/* FIXME: application can pass invalid value for precision and
scale ?? */
@@ -2010,6 +2011,8 @@
pdigits = pstr;
for (; pstr != pend; ++pstr) { /* deal with the rest */
if (isdigit((unsigned char) *pstr)) { /* its a number
*/
+ if (space_found)
+ return TDS_CONVERT_SYNTAX; /*
return error. */
if (point_found) /* if we passed a
decimal point */
++places; /* count digits after
that point */
else
@@ -2017,13 +2020,17 @@
} else if (*pstr == '.') { /* found a decimal point
*/
if (point_found) /* already had one.
return error */
return TDS_CONVERT_SYNTAX;
+ if (space_found)
+ return TDS_CONVERT_SYNTAX; /*
return error. */
point_found = 1;
+ } else if (*pstr == ' ') {
+ space_found = 1;
} else /* first invalid character */
return TDS_CONVERT_SYNTAX; /* return error.
*/
}
/* no digits? no number! */
- if (!digits)
+ if (!digits && !point_found)
return TDS_CONVERT_SYNTAX;
/* truncate decimal digits */
--------------------------------------------------------
If you are not an intended recipient of this e-mail, please notify the
sender, delete it and do not read, act upon, print, disclose, copy, retain or
redistribute it. Click here for important additional terms relating to this
e-mail. http://www.ml.com/email_terms/
--------------------------------------------------------
-
[freetds] A small fix,
Thompson, Bill D (London), 12/10/2004
- <Possible follow-up(s)>
- RE: [freetds] A small fix, Lowden, James K, 12/10/2004
- RE: [freetds] A small fix, Thompson, Bill D (London), 12/10/2004
- RE: [freetds] A small fix, ZIGLIO, Frediano, VF-IT, 12/10/2004
- RE: [freetds] A small fix, Thompson, Bill D (London), 12/10/2004
Archive powered by MHonArc 2.6.24.