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

Commit 91fed81

Browse files
committed
From: Michael Meskes <Michael.Meskes@usa.net> + + Wed Jan 27 12:42:22 CET 1999 + + - Fixed bug that caused ecpg to lose 'goto' information. + - Set ecpg version to 2.4.7 + + Fri Jan 29 18:03:52 CET 1999 + + - Fixed bug that caused 'enum' to be rejected in pure C code. + - Fixed bug that caused function names to be translated to lower case. + - Set ecpg version to 2.4.8 +
1 parent f7c4ec5 commit 91fed81

File tree

5 files changed

+50
-24
lines changed

5 files changed

+50
-24
lines changed

src/interfaces/ecpg/ChangeLog

+12
Original file line numberDiff line numberDiff line change
@@ -383,3 +383,15 @@ Thu Jan 21 21:29:00 CET 1999
383383
- Set library version to 2.6.3
384384
- Added 'exec sql whenever sqlwarning'.
385385
- Set ecpg version to 2.4.6
386+
387+
Wed Jan 27 12:42:22 CET 1999
388+
389+
- Fixed bug that caused ecpg to lose 'goto' information.
390+
- Set ecpg version to 2.4.7
391+
392+
Fri Jan 29 18:03:52 CET 1999
393+
394+
- Fixed bug that caused 'enum' to be rejected in pure C code.
395+
- Fixed bug that caused function names to be translated to lower case.
396+
- Set ecpg version to 2.4.8
397+

src/interfaces/ecpg/preproc/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ include $(SRCDIR)/Makefile.global
33

44
MAJOR_VERSION=2
55
MINOR_VERSION=4
6-
PATCHLEVEL=6
6+
PATCHLEVEL=8
77

88
CFLAGS+=-I../include -DMAJOR_VERSION=$(MAJOR_VERSION) \
99
-DMINOR_VERSION=$(MINOR_VERSION) -DPATCHLEVEL=$(PATCHLEVEL) \

src/interfaces/ecpg/preproc/pgc.l

+19-17
Original file line numberDiff line numberDiff line change
@@ -333,22 +333,23 @@ cppline {space}*#.*(\\{space}*\n)*\n*
333333
<SQL>{identifier}/{space}*-{number} {
334334
int i;
335335
ScanKeyword *keyword;
336+
char lower_text[NAMEDATALEN];
336337

337338
BEGIN(xm);
338-
for(i = 0; yytext[i]; i++)
339-
if (isascii((unsigned char)yytext[i]) && isupper(yytext[i]))
340-
yytext[i] = tolower(yytext[i]);
341-
342-
if (i >= NAMEDATALEN)
343-
yytext[NAMEDATALEN-1] = '\0';
344-
345-
keyword = ScanKeywordLookup((char*)yytext);
339+
/* this should leave the last byte set to '\0' */
340+
strncpy(lower_text, yytext, NAMEDATALEN-1);
341+
for(i = 0; lower_text[i]; i++)
342+
if (isascii((unsigned char)lower_text[i]) && isupper(lower_text[i]))
343+
lower_text[i] = tolower(lower_text[i]);
344+
345+
printf("yyt= %s, lt = %s\n", yytext, lower_text);
346+
keyword = ScanKeywordLookup((char*)lower_text);
346347
if (keyword != NULL) {
347348
return keyword->value;
348349
}
349350
else
350351
{
351-
keyword = ScanECPGKeywordLookup((char*)yytext);
352+
keyword = ScanECPGKeywordLookup((char*)lower_text);
352353
if (keyword != NULL) {
353354
return keyword->value;
354355
}
@@ -475,21 +476,22 @@ cppline {space}*#.*(\\{space}*\n)*\n*
475476
<SQL>{identifier} {
476477
int i;
477478
ScanKeyword *keyword;
479+
char lower_text[NAMEDATALEN];
478480

479-
for(i = 0; yytext[i]; i++)
480-
if (isascii((unsigned char)yytext[i]) && isupper(yytext[i]))
481-
yytext[i] = tolower(yytext[i]);
482-
483-
if (i >= NAMEDATALEN)
484-
yytext[NAMEDATALEN-1] = '\0';
481+
/* this should leave the last byte set to '\0' */
482+
strncpy(lower_text, yytext, NAMEDATALEN-1);
483+
for(i = 0; lower_text[i]; i++)
484+
if (isascii((unsigned char)lower_text[i]) && isupper(lower_text[i]))
485+
lower_text[i] = tolower(lower_text[i]);
485486

486-
keyword = ScanKeywordLookup((char*)yytext);
487+
printf("yyt= %s, lt = %s\n", yytext, lower_text);
488+
keyword = ScanKeywordLookup((char*)lower_text);
487489
if (keyword != NULL) {
488490
return keyword->value;
489491
}
490492
else
491493
{
492-
keyword = ScanECPGKeywordLookup((char*)yytext);
494+
keyword = ScanECPGKeywordLookup((char*)lower_text);
493495
if (keyword != NULL) {
494496
return keyword->value;
495497
}

src/interfaces/ecpg/preproc/preproc.y

+16-4
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,8 @@ output_statement(char * stmt, int mode)
521521
/* special embedded SQL token */
522522
%token SQL_BREAK SQL_CALL SQL_CONNECT SQL_CONNECTION SQL_CONTINUE
523523
%token SQL_DISCONNECT SQL_FOUND SQL_GO SQL_GOTO
524-
%token SQL_IDENTIFIED SQL_IMMEDIATE SQL_INDICATOR SQL_OPEN SQL_RELEASE
524+
%token SQL_IDENTIFIED SQL_IMMEDIATE SQL_INDICATOR SQL_OPEN
525+
%token SQL_PREPARE SQL_RELEASE
525526
%token SQL_SECTION SQL_SEMI SQL_SQLERROR SQL_SQLPRINT SQL_START
526527
%token SQL_STOP SQL_WHENEVER SQL_SQLWARNING
527528

@@ -813,6 +814,9 @@ stmt: AddAttrStmt { output_statement($1, 0); }
813814
output_line_number();
814815
free($1);
815816
}
817+
| ECPGPrepare {
818+
yyerror("PREPARE is not supported yet.");
819+
}
816820

817821
/*
818822
* We start with a lot of stuff that's very similar to the backend's parsing
@@ -4671,12 +4675,12 @@ action : SQL_CONTINUE {
46714675
}
46724676
| SQL_GOTO name {
46734677
$<action>$.code = W_GOTO;
4674-
$<action>$.command = $2;
4678+
$<action>$.command = strdup($2);
46754679
$<action>$.str = cat2_str(make1_str("goto "), $2);
46764680
}
46774681
| SQL_GO TO name {
46784682
$<action>$.code = W_GOTO;
4679-
$<action>$.command = $3;
4683+
$<action>$.command = strdup($3);
46804684
$<action>$.str = cat2_str(make1_str("goto "), $3);
46814685
}
46824686
| DO name '(' dotext ')' {
@@ -4695,8 +4699,15 @@ action : SQL_CONTINUE {
46954699
$<action>$.str = cat2_str(make1_str("call"), mm_strdup($<action>$.command));
46964700
}
46974701

4698-
/* some other stuff for ecpg */
4702+
/*
4703+
* As long as the prepare statement in not supported by the backend, we will
4704+
* try to simulate it here so we get dynamic SQL
4705+
*/
4706+
ECPGPrepare: SQL_PREPARE name FROM name
4707+
{
4708+
}
46994709

4710+
/* some other stuff for ecpg */
47004711
ecpg_expr: attr opt_indirection
47014712
{
47024713
$$ = cat2_str($1, $2);
@@ -5032,6 +5043,7 @@ c_anything: IDENT { $$ = $1; }
50325043
| S_CHAR { $$ = make1_str("char"); }
50335044
| S_CONST { $$ = make1_str("const"); }
50345045
| S_DOUBLE { $$ = make1_str("double"); }
5046+
| S_ENUM { $$ = make1_str("enum"); }
50355047
| S_EXTERN { $$ = make1_str("extern"); }
50365048
| S_FLOAT { $$ = make1_str("float"); }
50375049
| S_INT { $$ = make1_str("int"); }

src/interfaces/ecpg/test/header_test.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
exec sql include sqlca;
22

3-
exec sql whenever sqlerror do print_and_stop();
3+
exec sql whenever sqlerror do PrintAndStop();
44
exec sql whenever sqlwarning do warn();
55

6-
void print_and_stop(void)
6+
void PrintAndStop(void)
77
{
88
sqlprint();
99
exit(-1);

0 commit comments

Comments
 (0)