Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit e3740d2

Browse files
author
Michael Meskes
committed
Added just another test case.
Fixed missing continuation line character. Do not translate $-quoting. Bit field notation belongs to a variable not a variable list. Output of line number only done by one function.
1 parent 115e5dd commit e3740d2

File tree

10 files changed

+133
-65
lines changed

10 files changed

+133
-65
lines changed

src/interfaces/ecpg/ChangeLog

+11
Original file line numberDiff line numberDiff line change
@@ -1982,6 +1982,17 @@ Sa Feb 4 21:35:03 CET 2006
19821982
- Added C bit fields to ecpg parser.
19831983
- Added some default rules to lexer.
19841984
- Added log output to prepare statement.
1985+
1986+
Mo Feb 6 21:21:19 CET 2006
1987+
1988+
- Added just another test case.
1989+
- Fixed missing continuation line character.
1990+
- Do not translate $-quoting.
1991+
1992+
Tu Feb 7 18:48:14 CET 2006
1993+
1994+
- Bit field notation belongs to a variable not a variable list.
1995+
- Output of line number only done by one function.
19851996
- Set ecpg library version to 5.2.
19861997
- Set ecpg version to 4.2.1.
19871998

src/interfaces/ecpg/preproc/ecpg.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.93 2005/10/15 02:49:47 momjian Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.94 2006/02/08 09:10:04 meskes Exp $ */
22

33
/* New main for ecpg, the PostgreSQL embedded SQL precompiler. */
44
/* (C) Michael Meskes <meskes@postgresql.org> Feb 5th, 1998 */
@@ -418,7 +418,7 @@ main(int argc, char *const argv[])
418418
fprintf(yyout, "/* End of automatic include section */\n");
419419
}
420420

421-
fprintf(yyout, "#line 1 \"%s\"\n", input_filename);
421+
output_line_number();
422422

423423
/* and parse the source */
424424
yyparse();

src/interfaces/ecpg/preproc/output.c

+13-8
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,22 @@
22

33
#include "extern.h"
44

5-
static void ouput_escaped_str(char *cmd);
5+
static void output_escaped_str(char *cmd);
66

77
void
88
output_line_number(void)
99
{
10-
if (input_filename)
11-
fprintf(yyout, "\n#line %d \"%s\"\n", yylineno, input_filename);
10+
char *line = hashline_number();
11+
12+
/* output_escaped_str(line); */
13+
fprintf(yyout, "%s", line);
14+
free(line);
1215
}
1316

1417
void
1518
output_simple_statement(char *stmt)
1619
{
17-
ouput_escaped_str(stmt);
20+
output_escaped_str(stmt);
1821
output_line_number();
1922
free(stmt);
2023
}
@@ -83,7 +86,8 @@ whenever_action(int mode)
8386
char *
8487
hashline_number(void)
8588
{
86-
if (input_filename)
89+
/* do not print line numbers if we are in debug mode */
90+
if (input_filename && !yydebug)
8791
{
8892
char *line = mm_alloc(strlen("\n#line %d \"%s\"\n") + 21 + strlen(input_filename));
8993

@@ -99,7 +103,7 @@ void
99103
output_statement(char *stmt, int mode, char *con)
100104
{
101105
fprintf(yyout, "{ ECPGdo(__LINE__, %d, %d, %s, \"", compat, force_indicator, con ? con : "NULL");
102-
ouput_escaped_str(stmt);
106+
output_escaped_str(stmt);
103107
fputs("\", ", yyout);
104108

105109
/* dump variables to C file */
@@ -118,7 +122,7 @@ output_statement(char *stmt, int mode, char *con)
118122

119123

120124
static void
121-
ouput_escaped_str(char *str)
125+
output_escaped_str(char *str)
122126
{
123127
int i, len = strlen(str);
124128

@@ -128,7 +132,8 @@ ouput_escaped_str(char *str)
128132
if (str[i] == '"')
129133
fputs("\\\"", yyout);
130134
else if (str[i] == '\n')
131-
fputs("\\n\\\n", yyout);
135+
//fputs("\\n\\\n", yyout);
136+
fputs("\\\n", yyout);
132137
else
133138
fputc(str[i], yyout);
134139
}

src/interfaces/ecpg/preproc/pgc.l

+11-14
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*
1313
*
1414
* IDENTIFICATION
15-
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.142 2006/02/04 20:54:42 meskes Exp $
15+
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.143 2006/02/08 09:10:04 meskes Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -152,7 +152,7 @@ dolq_start [A-Za-z\200-\377_]
152152
dolq_cont [A-Za-z\200-\377_0-9]
153153
dolqdelim \$({dolq_start}{dolq_cont}*)?\$
154154
dolqfailed \${dolq_start}{dolq_cont}*
155-
dolqinside [^$']+
155+
dolqinside [^$]+
156156

157157
/* Double quote
158158
* Allows embedded spaces and other special characters into identifiers.
@@ -437,7 +437,7 @@ cppline {space}*#(.*\\{space})*.*{newline}
437437
addlit(yytext, yyleng);
438438
}
439439
<xq>{quotecontinue} { /* ignore */ }
440-
<xq>. {
440+
<xq>{other} {
441441
/* This is only needed for \ just before EOF */
442442
addlitchar(yytext[0]);
443443
}
@@ -453,14 +453,16 @@ cppline {space}*#(.*\\{space})*.*{newline}
453453
dolqstart = mm_strdup(yytext);
454454
BEGIN(xdolq);
455455
startlit();
456+
addlit(yytext, yyleng);
456457
}
457458
<xdolq>{dolqdelim} {
458459
if (strcmp(yytext, dolqstart) == 0)
459460
{
461+
addlit(yytext, yyleng);
460462
free(dolqstart);
461463
BEGIN(SQL);
462464
yylval.str = mm_strdup(literalbuf);
463-
return SCONST;
465+
return DOLCONST;
464466
}
465467
else
466468
{
@@ -475,15 +477,11 @@ cppline {space}*#(.*\\{space})*.*{newline}
475477
}
476478
<xdolq>{dolqinside} { addlit(yytext, yyleng); }
477479
<xdolq>{dolqfailed} { addlit(yytext, yyleng); }
478-
<xdolq>. {
479-
/* $$ is implemented as a single-quoted string, so double it? */
480-
if (yytext[0] == '\'')
481-
addlitchar(yytext[0]);
480+
<xdolq>{other} {
482481
/* single quote or dollar sign */
483482
addlitchar(yytext[0]);
484483
}
485-
<xdolq><<EOF>> { yyerror("unterminated dollar-quoted string"); }
486-
484+
<xdolq><<EOF>> { yyerror("unterminated dollar-quoted string"); }
487485
<SQL>{xdstart} {
488486
state_before = YYSTATE;
489487
BEGIN(xd);
@@ -625,8 +623,8 @@ cppline {space}*#(.*\\{space})*.*{newline}
625623
<SQL>{ip} {
626624
yylval.str = mm_strdup(yytext);
627625
return IP;
628-
}
629-
{decimal} {
626+
}
627+
<C,SQL>{decimal} {
630628
yylval.str = mm_strdup(yytext);
631629
return FCONST;
632630
}
@@ -797,7 +795,7 @@ cppline {space}*#(.*\\{space})*.*{newline}
797795
<C>"-" { return('-'); }
798796
<C>"(" { return('('); }
799797
<C>")" { return(')'); }
800-
<C,xskip>{space} { ECHO; }
798+
<C,xskip>{space} { ECHO; }
801799
<C>\{ { return('{'); }
802800
<C>\} { return('}'); }
803801
<C>\[ { return('['); }
@@ -1037,7 +1035,6 @@ cppline {space}*#(.*\\{space})*.*{newline}
10371035
if (strcmp(old, ptr->old) == 0)
10381036
{
10391037
free(ptr->new);
1040-
/* ptr->new = mm_strdup(scanstr(literalbuf));*/
10411038
ptr->new = mm_strdup(literalbuf);
10421039
}
10431040
}

0 commit comments

Comments
 (0)