freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
- From: "Lowden, James K" <LowdenJK AT bernstein.com>
- To: "FreeTDS Development Group" <freetds AT lists.ibiblio.org>
- Subject: Re: [freetds] FW: dblib patch
- Date: Fri, 1 Jul 2005 13:58:56 -0400
> From: Ian Ashley
> Sent: Friday, July 01, 2005 12:13 PM
>
> > for (t = istr + ilen; --t > istr && *t == ' '; )
> > *t = '\0';
> > return t - str + 1;
> >
> > About char/varchar is the same, server fill needed spaces if
> > necessary.
> >
> > freddy77
>
> Shouldn¹t it be
>
> for (t = istr + ilen; --t >= istr && *t == ' '; )
> *t = '\0';
> return t - str + 1;
>
> to cope the string being all spaces. I assume the return value is
> meant to be the number of characters excluding the '\0'
No, Frediano is right. The loop exits when --t > str is false or when *t ==
' ' is false.
Whether or not t points to a blank, if t == str we don't want to return a
length of zero. We want to return a length of 1, else the server will
interpret ' ' as NULL.
If the input is 'abc ', the loop exits when *t == 'c'. At that point, t -
str == 2, telling the caller to trim the string to 'ab'. Hence t - str + 1,
or (as I think is slightly clearer) ++t - str.
Your loop would exit when t < str, in which case t - str would be a really
big number, to which adding 1 would (on most architectures, I think) yield
zero. Not that it matters in this case, but I don't know what ANSI has to
say about pointer arithmetic overflow.
--jkl
-----------------------------------------
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
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.
-
[freetds] FW: dblib patch,
Lowden, James K, 07/01/2005
- <Possible follow-up(s)>
- Re: [freetds] FW: dblib patch, Thompson, Bill D (London), 07/01/2005
-
Re: [freetds] FW: dblib patch,
ZIGLIO, Frediano, VF-IT, 07/01/2005
- Re: [freetds] FW: dblib patch, Ian Ashley, 07/01/2005
- Re: [freetds] FW: dblib patch, Lowden, James K, 07/01/2005
Archive powered by MHonArc 2.6.24.