freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
Re: [freetds] hard-coded UCS-2 strings and the C standard
- From: "James K. Lowden" <jklowden AT freetds.org>
- 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 14:10:33 -0400
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
Attachment:
asucs.diff
Description: Binary data
-
[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
-
[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.