freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
Re: [freetds] hard-coded UCS-2 strings and the C standard
- From: Brian Bruns <brian.bruns AT gmail.com>
- To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
- Subject: Re: [freetds] hard-coded UCS-2 strings and the C standard
- Date: Sat, 11 Jun 2005 15:15:08 -0400
Jim,
I like the change. I find the null embeded string hard to read and
frankly ugly. We don't run these things often enough for the slight
processing time to add the nulls to matter. Plus, if you wanted to
get down to that level, the old version increases the size of the
binaries. ;-)
Brian
2005/6/11, James K. Lowden <jklowden AT freetds.org>:
> Frediano Ziglio wrote:
> > Il giorno ven, 10-06-2005 alle 14:55 -0400, Lowden, James K ha scritto:
> > > In src/tds/query.c we have several hard-coded UCS-2 strings e.g.:
> > >
> > > tds_put_n(tds, "s\0p\0_\0c\0u\0r\0s\0o\0r\0c\0l\0o\0s\0e", 28);
> > >
> > > Standard C (C99?) lets this be written as:
> > >
> > > tds_put_n(tds, L"sp_cursorclose", 28);
> > >
> >
> > This is a wide string, not a UCS-2 string. On many Unix systems (*BSD,
> > Linux) is encoded in UCS-4, not UCS-2. "s\0p\0_\0c\0u\0r\0s\0o\0r\0c\0l
> > \0o\0s\0e" is always UCS2-LE.
>
> Oh. Thanks for the education. :-)
>
> I find the hard-coded strings unpretty and hard to read (and scan for).
> So, I wrote the attached patch. It would let us replace:
>
> $ grep put_n *.c |grep s..p.._
> query.c: tds_put_n(tds,
> "s\0p\0_\0e\0x\0e\0c\0u\0t\0e\0s\0q\0l", 26);
> query.c: tds_put_n(tds,
> "s\0p\0_\0p\0r\0e\0p\0a\0r\0e", 20);
> query.c: tds_put_n(tds,
> "s\0p\0_\0e\0x\0e\0c\0u\0t\0e\0s\0q\0l", 26);
> query.c: tds_put_n(tds, "s\0p\0_\0e\0x\0e\0c\0u\0t\0e",
> 20);
> query.c: tds_put_n(tds,
> "s\0p\0_\0u\0n\0p\0r\0e\0p\0a\0r\0e", 24);
> query.c: tds_put_n(tds,
> "s\0p\0_\0c\0u\0r\0s\0o\0r\0o\0p\0e\0n", 26);
> query.c: tds_put_n(tds,
> "s\0p\0_\0c\0u\0r\0s\0o\0r\0f\0e\0t\0c\0h", 28);
> query.c: tds_put_n(tds,
> "s\0p\0_\0c\0u\0r\0s\0o\0r\0c\0l\0o\0s\0e", 28);
>
> with:
>
> $ grep put_n *.c |grep s..p.._ \
> |sed 's/, 2[0-9]//;s/tds_put_n/&_as_UCS2/;s:\\0::g'
> query.c: tds_put_n_as_UCS2(tds, "sp_executesql");
> query.c: tds_put_n_as_UCS2(tds, "sp_prepare");
> query.c: tds_put_n_as_UCS2(tds, "sp_executesql");
> query.c: tds_put_n_as_UCS2(tds, "sp_execute");
> query.c: tds_put_n_as_UCS2(tds, "sp_unprepare");
> query.c: tds_put_n_as_UCS2(tds, "sp_cursoropen");
> query.c: tds_put_n_as_UCS2(tds, "sp_cursorfetch");
> query.c: tds_put_n_as_UCS2(tds, "sp_cursorclose");
>
> What do you think?
>
> --jkl
>
>
> _______________________________________________
> FreeTDS mailing list
> FreeTDS AT lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/freetds
>
>
>
>
-
[freetds] hard-coded UCS-2 strings and the C standard,
Lowden, James K, 06/10/2005
-
Re: [freetds] hard-coded UCS-2 strings and the C standard,
Frediano Ziglio, 06/11/2005
-
Re: [freetds] hard-coded UCS-2 strings and the C standard,
James K. Lowden, 06/11/2005
- Re: [freetds] hard-coded UCS-2 strings and the C standard, Brian Bruns, 06/11/2005
-
Re: [freetds] hard-coded UCS-2 strings and the C standard,
James K. Lowden, 06/11/2005
- <Possible follow-up(s)>
- RE: [freetds] hard-coded UCS-2 strings and the C standard, ZIGLIO, Frediano, VF-IT, 06/13/2005
-
RE: [freetds] hard-coded UCS-2 strings and the C standard,
ZIGLIO, Frediano, VF-IT, 06/13/2005
- Re: [freetds] hard-coded UCS-2 strings and the C standard, James K. Lowden, 06/13/2005
-
RE: [freetds] hard-coded UCS-2 strings and the C standard,
ZIGLIO, Frediano, VF-IT, 06/14/2005
-
[freetds] Connection issue,
Chris parent, 06/14/2005
-
[freetds] Re: Connection issue,
Daniel Fazekas, 06/14/2005
-
Re: [freetds] Re: Connection issue,
Chris parent, 06/14/2005
-
Re: [freetds] Re: Connection issue,
Daniel Fazekas, 06/14/2005
- Re: [freetds] Re: Connection issue, Chris parent, 06/14/2005
-
Re: [freetds] Re: Connection issue,
Daniel Fazekas, 06/14/2005
-
Re: [freetds] Re: Connection issue,
Chris parent, 06/14/2005
-
[freetds] Re: Connection issue,
Daniel Fazekas, 06/14/2005
- Re: [freetds] hard-coded UCS-2 strings and the C standard, James K. Lowden, 06/14/2005
-
[freetds] Connection issue,
Chris parent, 06/14/2005
-
Re: [freetds] hard-coded UCS-2 strings and the C standard,
Frediano Ziglio, 06/11/2005
Archive powered by MHonArc 2.6.24.