I'm fine with allowing escape sequences in string definitions. This means we should allow:
string a="\"c" to get "c and string b="\\" to get \ although this is backward incompatible. Using sprintf for such simple tasks is not convenient. chris ________________________________________ Von: gretl-users-bounces(a)lists.wfu.edu [gretl-users-bounces(a)lists.wfu.edu] im Auftrag von Allin Cottrell [cottrell(a)wfu.edu] Gesendet: Donnerstag, 3. September 2009 03:11 An: Gretl list Betreff: Re: [Gretl-users] GRETL string concatenation for use in SQL statement On Wed, 2 Sep 2009, Allin Cottrell wrote: > On Wed, 2 Sep 2009, chris wrote: > > > Allin Cottrell wrote: > > > > > > However, I'm not sure offhand whether gretl's ODBC routines will > > > handle this sort of input correctly. I'll have to test. > > > > > > > Did you change the string parsing code? Because with current windows > > snapshot the follwing snippet no longer works: > > > > <script> > > string a="\" > > </script> > > Yes, I considered that I had found a bug, in that you couldn't set > a string to contain literal quotes by doing, e.g. > > string quotefoo = "\"foo\"" > > That's now fixed, but it has broken the idiom you mentioned. But > I think that would be better done as > > string a = "\\" > > This doesn't yet work right, but it will soon. Sorry, let me not prejudge the issue. One option is to proceed in the direction I indicated, allowing backslash-escaped quotes (and so, therefore, other escapes, including backslash-escaped backslashes) in the definition of string literals using string s = "..." But another option is simply to revert the change I made, to which Chris has drawn attention. To clarify: before my recent change, when you defined a string literal using string s = "..." gretl followed the simple procedure of making the string start at the first '"' and end at the next '"'. So Chris's string a = "\" would produce a string containing a single, literal backslash. This means that if you did string quotefoo = "\"foo\"" (in the hope of getting a quote-wrapped string) you'd get an error, since gretl would see a string comprising a single backslash followed by the bare identifier 'foo', and most likely you'd get a complaint about the symbol 'foo' being undefined. It seemed to me that this was a bug, but maybe it's OK: it doesn't agree with C usage, but it was consistent. And if you wanted to get fancier with escapes you could use sprintf. Any thoughts? Should we just go back to the status quo ante? (And perhaps add a note to the manual.) Allin. _______________________________________________ Gretl-users mailing list Gretl-users(a)lists.wfu.edu http://lists.wfu.edu/mailman/listinfo/gretl-users