@@ -80,7 +80,7 @@ print_action(struct when *w)
80
80
static void
81
81
whenever_action (int mode)
82
82
{
83
- if (mode == 1 && when_nf.code != W_NOTHING)
83
+ if (( mode& 1 ) == 1 && when_nf.code != W_NOTHING)
84
84
{
85
85
output_line_number ();
86
86
fprintf (yyout, " \n if (sqlca.sqlcode == ECPG_NOT_FOUND) " );
@@ -98,6 +98,8 @@ whenever_action(int mode)
98
98
fprintf (yyout, " \n if (sqlca.sqlcode < 0) " );
99
99
print_action (&when_error);
100
100
}
101
+ if ((mode&2 ) == 2 )
102
+ fputc (' }' , yyout);
101
103
output_line_number ();
102
104
}
103
105
@@ -525,7 +527,7 @@ output_statement(char * stmt, int mode)
525
527
{
526
528
int i, j=strlen (stmt);
527
529
528
- fprintf (yyout, " ECPGdo(__LINE__, %s, \" " , connection ? connection : " NULL" );
530
+ fprintf (yyout, " { ECPGdo(__LINE__, %s, \" " , connection ? connection : " NULL" );
529
531
530
532
/* do this char by char as we have to filter '\"' */
531
533
for (i = 0 ;i < j; i++)
@@ -538,6 +540,7 @@ output_statement(char * stmt, int mode)
538
540
fputs (" ECPGt_EOIT, " , yyout);
539
541
dump_variables (argsresult, 1 );
540
542
fputs (" ECPGt_EORT);" , yyout);
543
+ mode |= 2 ;
541
544
whenever_action (mode);
542
545
free (stmt);
543
546
if (connection != NULL )
@@ -854,7 +857,7 @@ prog: statements;
854
857
statements : /* empty */
855
858
| statements statement
856
859
857
- statement : ecpgstart opt_at stmt ' ;' { connection = NULL ; }
860
+ statement : ecpgstart opt_at stmt ' ;' { connection = NULL ; }
858
861
| ecpgstart stmt ' ;'
859
862
| ECPGDeclaration
860
863
| c_thing { fprintf(yyout, " %s" , $1 ); free($1 ); }
@@ -903,8 +906,8 @@ stmt: AddAttrStmt { output_statement($1, 0); }
903
906
}
904
907
| RuleStmt { output_statement($1 , 0 ); }
905
908
| 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 );
908
911
free ($1 );
909
912
}
910
913
| ViewStmt { output_statement($1 , 0 ); }
@@ -919,8 +922,8 @@ stmt: AddAttrStmt { output_statement($1, 0); }
919
922
if (connection)
920
923
yyerror (" no at option for connect statement.\n " );
921
924
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 );
924
927
free ($1 );
925
928
}
926
929
| ECPGCursorStmt {
@@ -930,8 +933,9 @@ stmt: AddAttrStmt { output_statement($1, 0); }
930
933
if (connection)
931
934
yyerror (" no at option for connect statement.\n " );
932
935
936
+ fputc (' {' , yyout);
933
937
fputs ($1 , yyout);
934
- whenever_action (0 );
938
+ whenever_action (2 );
935
939
free ($1 );
936
940
}
937
941
| ECPGDeclare {
@@ -941,16 +945,16 @@ stmt: AddAttrStmt { output_statement($1, 0); }
941
945
if (connection)
942
946
yyerror (" no at option for disconnect statement.\n " );
943
947
944
- fprintf (yyout, " ECPGdisconnect(__LINE__, \" %s\" );" , $1 );
945
- whenever_action (0 );
948
+ fprintf (yyout, " { ECPGdisconnect(__LINE__, \" %s\" );" , $1 );
949
+ whenever_action (2 );
946
950
free ($1 );
947
951
}
948
952
| ECPGExecute {
949
953
output_statement ($1 , 0 );
950
954
}
951
955
| 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 );
954
958
free ($1 );
955
959
}
956
960
| ECPGOpen {
@@ -968,36 +972,36 @@ stmt: AddAttrStmt { output_statement($1, 0); }
968
972
yyerror (errortext);
969
973
}
970
974
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);
972
976
/* dump variables to C file*/
973
977
dump_variables (ptr->argsinsert, 0 );
974
978
dump_variables (argsinsert, 0 );
975
979
fputs (" ECPGt_EOIT, " , yyout);
976
980
dump_variables (ptr->argsresult, 0 );
977
981
fputs (" ECPGt_EORT);" , yyout);
978
- whenever_action (0 );
982
+ whenever_action (2 );
979
983
free ($1 );
980
984
}
981
985
| ECPGPrepare {
982
986
if (connection)
983
987
yyerror (" no at option for set connection statement.\n " );
984
988
985
- fprintf (yyout, " ECPGprepare(__LINE__, %s);" , $1 );
986
- whenever_action (0 );
989
+ fprintf (yyout, " { ECPGprepare(__LINE__, %s);" , $1 );
990
+ whenever_action (2 );
987
991
free ($1 );
988
992
}
989
993
| ECPGRelease { /* output already done */ }
990
994
| 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 );
993
997
free ($1 );
994
998
}
995
999
| ECPGSetConnection {
996
1000
if (connection)
997
1001
yyerror (" no at option for set connection statement.\n " );
998
1002
999
- fprintf (yyout, " ECPGsetconn(__LINE__, %s);" , $1 );
1000
- whenever_action (0 );
1003
+ fprintf (yyout, " { ECPGsetconn(__LINE__, %s);" , $1 );
1004
+ whenever_action (2 );
1001
1005
free ($1 );
1002
1006
}
1003
1007
| ECPGTypedef {
0 commit comments