Re: Syslog Facility Patch

From: Larry Rosenman <ler(at)lerctr(dot)org>
To: PostgreSQL Hackers List <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Syslog Facility Patch
Date: 2000-11-15 05:55:50
Message-ID: 20001114235550.A7035@lerami.lerctr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

* Larry Rosenman <ler(at)lerctr(dot)org> [001114 20:45]:
> * Larry Rosenman <ler(at)lerctr(dot)org> [001114 16:56]:
> > Ok, so what I think(?) needs to happen is the FIXME: tag needs to be
> > handled. We need to code a version of src/backend/parser/scansup.c
> > that doesn't use palloc, and also strips the apostrophes from the
> > front and end of the string? This doesn't look that hard. Do I have
> > "permission" to play with it, and submit a patch when I've got it
> > fixed?
> >
> > I ass/u/me we want to allow any of the 'C' escapes? or just
> > a-zA-Z0-9-. for a GUC_STRING?
> Ok, baring objections, I'm going to code up a routine to put into
> guc-file.l that removes the quotes/apostrophes from a GUC_STRING, and
> matches for [-.a-zA-Z0-9] within the string. We can tune more later.
>
> Probably won't get posted tonight, but in the next 48 hours.
Ok, I changed my mind, and brute forced it. Here's a patch that
accepts either 'string' or "string", and then kills off the ' or ".
Let me know if this violates style or portability guidelines.
It depends on ANSI memmove().

Index: guc-file.l
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/utils/misc/guc-file.l,v
retrieving revision 1.4
diff -c -r1.4 guc-file.l
*** guc-file.l 2000/07/27 19:49:18 1.4
--- guc-file.l 2000/11/15 05:52:57
***************
*** 45,51 ****

/* prototype, so compiler is happy with our high warnings setting */
int GUC_yylex(void);
-
%}

SIGN ("-"|"+")
--- 45,50 ----
***************
*** 69,76 ****
* work right. Now there are no string options, and if there were then
* the unquoted (`ID') tokens should still work. Of course this only
* affects the configuration file.
*/
! STRING \'([^'\n]|\\.)*'

%%

--- 68,79 ----
* work right. Now there are no string options, and if there were then
* the unquoted (`ID') tokens should still work. Of course this only
* affects the configuration file.
+ * LER 14NOV2000: I set it up to accept either a quoted string or a string
+ * in apostrophes. I then kill off the 1st and last characters. There is
+ * no special handling for doubled terminators or 'C' escapes.
+ * this allows most other characters to be used.
*/
! STRING (\'|\")([^'"\n]|\\.)*(\'|\")

%%

***************
*** 215,220 ****
--- 218,232 ----
opt_value = strdup(yytext);
if (opt_value == NULL)
goto out_of_memory;
+ if (token == GUC_STRING)
+ {
+ /* remove the beginning and ending quote/apostrophe */
+ /* first: shift the whole shooting match down one
+ character */
+ memmove(opt_value,opt_value+1,strlen(opt_value)-1);
+ /* second: null out the 2 characters we shifted */
+ opt_value[strlen(opt_value)-2]='\0';
+ }
parse_state = 2;
break;

--
Larry Rosenman http://www.lerctr.org/~ler
Phone: +1 972-414-9812 (voice) Internet: ler(at)lerctr(dot)org
US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Alfred Perlstein 2000-11-15 06:02:52 Re: One more 486 Optimizations...
Previous Message Andrew Snow 2000-11-15 05:48:32 Re: Problem with BETWEEN and a view.