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

Commit 4b04b01

Browse files
author
Michael Meskes
committed
*** empty log message ***
1 parent b122e16 commit 4b04b01

File tree

2 files changed

+28
-20
lines changed

2 files changed

+28
-20
lines changed

src/interfaces/ecpg/ChangeLog

+4
Original file line numberDiff line numberDiff line change
@@ -586,5 +586,9 @@ Mon May 17 18:13:30 CEST 1999
586586
Fri May 21 18:13:44 CEST 1999
587587

588588
- Synced preproc.y with gram.y.
589+
590+
Sun May 23 11:19:32 CEST 1999
591+
592+
- Add braces around each statement so that a simple if/else works.
589593
- Set library version to 3.0.0
590594
- Set ecpg version to 2.6.0

src/interfaces/ecpg/preproc/preproc.y

+24-20
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ print_action(struct when *w)
8080
static void
8181
whenever_action(int mode)
8282
{
83-
if (mode == 1 && when_nf.code != W_NOTHING)
83+
if ((mode&1) == 1 && when_nf.code != W_NOTHING)
8484
{
8585
output_line_number();
8686
fprintf(yyout, "\nif (sqlca.sqlcode == ECPG_NOT_FOUND) ");
@@ -98,6 +98,8 @@ whenever_action(int mode)
9898
fprintf(yyout, "\nif (sqlca.sqlcode < 0) ");
9999
print_action(&when_error);
100100
}
101+
if ((mode&2) == 2)
102+
fputc('}', yyout);
101103
output_line_number();
102104
}
103105

@@ -525,7 +527,7 @@ output_statement(char * stmt, int mode)
525527
{
526528
int i, j=strlen(stmt);
527529

528-
fprintf(yyout, "ECPGdo(__LINE__, %s, \"", connection ? connection : "NULL");
530+
fprintf(yyout, "{ ECPGdo(__LINE__, %s, \"", connection ? connection : "NULL");
529531

530532
/* do this char by char as we have to filter '\"' */
531533
for (i = 0;i < j; i++)
@@ -538,6 +540,7 @@ output_statement(char * stmt, int mode)
538540
fputs("ECPGt_EOIT, ", yyout);
539541
dump_variables(argsresult, 1);
540542
fputs("ECPGt_EORT);", yyout);
543+
mode |= 2;
541544
whenever_action(mode);
542545
free(stmt);
543546
if (connection != NULL)
@@ -854,7 +857,7 @@ prog: statements;
854857
statements: /* empty */
855858
| statements statement
856859

857-
statement: ecpgstart opt_at stmt ';' { connection = NULL; }
860+
statement: ecpgstart opt_at stmt ';' { connection = NULL; }
858861
| ecpgstart stmt ';'
859862
| ECPGDeclaration
860863
| c_thing { fprintf(yyout, "%s", $1); free($1); }
@@ -903,8 +906,8 @@ stmt: AddAttrStmt { output_statement($1, 0); }
903906
}
904907
| RuleStmt { output_statement($1, 0); }
905908
| TransactionStmt {
906-
fprintf(yyout, "ECPGtrans(__LINE__, %s, \"%s\");", connection ? connection : "NULL", $1);
907-
whenever_action(0);
909+
fprintf(yyout, "{ ECPGtrans(__LINE__, %s, \"%s\");", connection ? connection : "NULL", $1);
910+
whenever_action(2);
908911
free($1);
909912
}
910913
| ViewStmt { output_statement($1, 0); }
@@ -919,8 +922,8 @@ stmt: AddAttrStmt { output_statement($1, 0); }
919922
if (connection)
920923
yyerror("no at option for connect statement.\n");
921924

922-
fprintf(yyout, "ECPGconnect(__LINE__, %s, %d);", $1, autocommit);
923-
whenever_action(0);
925+
fprintf(yyout, "{ ECPGconnect(__LINE__, %s, %d);", $1, autocommit);
926+
whenever_action(2);
924927
free($1);
925928
}
926929
| ECPGCursorStmt {
@@ -930,8 +933,9 @@ stmt: AddAttrStmt { output_statement($1, 0); }
930933
if (connection)
931934
yyerror("no at option for connect statement.\n");
932935

936+
fputc('{', yyout);
933937
fputs($1, yyout);
934-
whenever_action(0);
938+
whenever_action(2);
935939
free($1);
936940
}
937941
| ECPGDeclare {
@@ -941,16 +945,16 @@ stmt: AddAttrStmt { output_statement($1, 0); }
941945
if (connection)
942946
yyerror("no at option for disconnect statement.\n");
943947

944-
fprintf(yyout, "ECPGdisconnect(__LINE__, \"%s\");", $1);
945-
whenever_action(0);
948+
fprintf(yyout, "{ ECPGdisconnect(__LINE__, \"%s\");", $1);
949+
whenever_action(2);
946950
free($1);
947951
}
948952
| ECPGExecute {
949953
output_statement($1, 0);
950954
}
951955
| ECPGFree {
952-
fprintf(yyout, "ECPGdeallocate(__LINE__, %s, \"%s\");", connection ? connection : "NULL", $1);
953-
whenever_action(0);
956+
fprintf(yyout, "{ ECPGdeallocate(__LINE__, %s, \"%s\");", connection ? connection : "NULL", $1);
957+
whenever_action(2);
954958
free($1);
955959
}
956960
| ECPGOpen {
@@ -968,36 +972,36 @@ stmt: AddAttrStmt { output_statement($1, 0); }
968972
yyerror(errortext);
969973
}
970974

971-
fprintf(yyout, "ECPGdo(__LINE__, %s, \"%s\",", ptr->connection ? ptr->connection : "NULL", ptr->command);
975+
fprintf(yyout, "{ ECPGdo(__LINE__, %s, \"%s\",", ptr->connection ? ptr->connection : "NULL", ptr->command);
972976
/* dump variables to C file*/
973977
dump_variables(ptr->argsinsert, 0);
974978
dump_variables(argsinsert, 0);
975979
fputs("ECPGt_EOIT, ", yyout);
976980
dump_variables(ptr->argsresult, 0);
977981
fputs("ECPGt_EORT);", yyout);
978-
whenever_action(0);
982+
whenever_action(2);
979983
free($1);
980984
}
981985
| ECPGPrepare {
982986
if (connection)
983987
yyerror("no at option for set connection statement.\n");
984988

985-
fprintf(yyout, "ECPGprepare(__LINE__, %s);", $1);
986-
whenever_action(0);
989+
fprintf(yyout, "{ ECPGprepare(__LINE__, %s);", $1);
990+
whenever_action(2);
987991
free($1);
988992
}
989993
| ECPGRelease { /* output already done */ }
990994
| ECPGSetAutocommit {
991-
fprintf(yyout, "ECPGsetcommit(__LINE__, \"%s\", %s);", $1, connection ? connection : "NULL");
992-
whenever_action(0);
995+
fprintf(yyout, "{ ECPGsetcommit(__LINE__, \"%s\", %s);", $1, connection ? connection : "NULL");
996+
whenever_action(2);
993997
free($1);
994998
}
995999
| ECPGSetConnection {
9961000
if (connection)
9971001
yyerror("no at option for set connection statement.\n");
9981002

999-
fprintf(yyout, "ECPGsetconn(__LINE__, %s);", $1);
1000-
whenever_action(0);
1003+
fprintf(yyout, "{ ECPGsetconn(__LINE__, %s);", $1);
1004+
whenever_action(2);
10011005
free($1);
10021006
}
10031007
| ECPGTypedef {

0 commit comments

Comments
 (0)