Skip to Content.
Sympa Menu

freetds - RE: [freetds] convert.c (was: A small fix)

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Lowden, James K" <LowdenJK AT bernstein.com>
  • To: "FreeTDS Development Group" <freetds AT lists.ibiblio.org>
  • Subject: RE: [freetds] convert.c (was: A small fix)
  • Date: Fri, 10 Dec 2004 15:16:20 -0500

> From: Thompson, Bill D (London)
> Sent: Friday, December 10, 2004 11:07 AM
>
> Thanks Freddy,
>
> You've clearly understood what I've tried to do, and (as usual)
> improved on it.
> Feel free to apply your modified changes if you like - but tell James
> before he applies mine.

Applied, with editorial license, to CVS HEAD. Patch attached.

Regarding RC5, better the devil you know than the devil you don't.
Since it touches such fundamental functionality, I'd rather not apply it
to 0.63. Let's test it more carefully. If someone using 0.63 needs it
and wants to test it, he can apply the patch.

--jkl


>
> -----Original Message-----
> From: freetds-bounces AT lists.ibiblio.org
> [mailto:freetds-bounces AT lists.ibiblio.org] On Behalf Of ZIGLIO,
> Frediano, VF-IT
> Sent: 10 December 2004 16:01
> >
> > 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 */
>
> Mmmm... should work but it accept even " . " syntax...
> Perhaps another patch it's to change test from
>
> if (!digits)
>
> do
>
> if (digits + places == 0)
>
> and last if from
>
> } else /* first invalid character */
> return TDS_CONVERT_SYNTAX;
>
> to
>
> } else { /* first invalid character */
> while( pstr != pend && *pstr == ' ')
> ++pstr;
> if (pstr == pend)
> break;
> return TDS_CONVERT_SYNTAX;
> }
>
> So we avoid also a new variable (with all optimizations problems that
> can raise)
>
> freddy77

-----------------------------------------
The information contained in this transmission may contain privileged and
confidential information and is intended only for the use of the person(s)
named above. If you are not the intended recipient, or an employee or agent
responsible for delivering this message to the intended recipient, any
review, dissemination, distribution or duplication of this communication is
strictly prohibited. If you are not the intended recipient, please contact
the sender immediately by reply e-mail and destroy all copies of the original
message. Please note that we do not accept account orders and/or instructions
by e-mail, and therefore will not be responsible for carrying out such orders
and/or instructions.
If you, as the intended recipient of this message, the purpose of which is to
inform and update our clients, prospects and consultants of developments
relating to our services and products, would not like to receive further
e-mail correspondence from the sender, please "reply" to the sender
indicating your wishes. In the U.S.: 1345 Avenue of the Americas, New York,
NY 10105.

Attachment: convert.jkl.diff
Description: convert.jkl.diff



  • RE: [freetds] convert.c (was: A small fix), Lowden, James K, 12/10/2004

Archive powered by MHonArc 2.6.24.

Top of Page