Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
1066dbfb
Commit
1066dbfb
authored
Jan 09, 2011
by
Michael Meskes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
There is no need to have to identical functions in ecpg thus removing one of them.
parent
fdf2dbda
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
371 additions
and
381 deletions
+371
-381
src/interfaces/ecpg/preproc/descriptor.c
src/interfaces/ecpg/preproc/descriptor.c
+2
-2
src/interfaces/ecpg/preproc/ecpg.addons
src/interfaces/ecpg/preproc/ecpg.addons
+46
-46
src/interfaces/ecpg/preproc/ecpg.header
src/interfaces/ecpg/preproc/ecpg.header
+15
-24
src/interfaces/ecpg/preproc/ecpg.trailer
src/interfaces/ecpg/preproc/ecpg.trailer
+286
-286
src/interfaces/ecpg/preproc/extern.h
src/interfaces/ecpg/preproc/extern.h
+1
-2
src/interfaces/ecpg/preproc/parse.pl
src/interfaces/ecpg/preproc/parse.pl
+2
-2
src/interfaces/ecpg/preproc/type.c
src/interfaces/ecpg/preproc/type.c
+9
-9
src/interfaces/ecpg/preproc/variable.c
src/interfaces/ecpg/preproc/variable.c
+10
-10
No files found.
src/interfaces/ecpg/preproc/descriptor.c
View file @
1066dbfb
...
@@ -188,7 +188,7 @@ output_get_descr(char *desc_name, char *index)
...
@@ -188,7 +188,7 @@ output_get_descr(char *desc_name, char *index)
break
;
break
;
}
}
fprintf
(
yyout
,
"%s,"
,
get_dtype
(
results
->
value
));
fprintf
(
yyout
,
"%s,"
,
get_dtype
(
results
->
value
));
ECPGdump_a_type
(
yyout
,
v
->
name
,
v
->
type
,
v
->
brace_level
,
NULL
,
NULL
,
-
1
,
NULL
,
NULL
,
m
ake_str
(
"0"
),
NULL
,
NULL
);
ECPGdump_a_type
(
yyout
,
v
->
name
,
v
->
type
,
v
->
brace_level
,
NULL
,
NULL
,
-
1
,
NULL
,
NULL
,
m
m_strdup
(
"0"
),
NULL
,
NULL
);
}
}
drop_assignments
();
drop_assignments
();
fputs
(
"ECPGd_EODT);
\n
"
,
yyout
);
fputs
(
"ECPGd_EODT);
\n
"
,
yyout
);
...
@@ -293,7 +293,7 @@ output_set_descr(char *desc_name, char *index)
...
@@ -293,7 +293,7 @@ output_set_descr(char *desc_name, char *index)
case
ECPGd_length
:
case
ECPGd_length
:
case
ECPGd_type
:
case
ECPGd_type
:
fprintf
(
yyout
,
"%s,"
,
get_dtype
(
results
->
value
));
fprintf
(
yyout
,
"%s,"
,
get_dtype
(
results
->
value
));
ECPGdump_a_type
(
yyout
,
v
->
name
,
v
->
type
,
v
->
brace_level
,
NULL
,
NULL
,
-
1
,
NULL
,
NULL
,
m
ake_str
(
"0"
),
NULL
,
NULL
);
ECPGdump_a_type
(
yyout
,
v
->
name
,
v
->
type
,
v
->
brace_level
,
NULL
,
NULL
,
-
1
,
NULL
,
NULL
,
m
m_strdup
(
"0"
),
NULL
,
NULL
);
break
;
break
;
default:
default:
...
...
src/interfaces/ecpg/preproc/ecpg.addons
View file @
1066dbfb
...
@@ -41,7 +41,7 @@ ECPG: stmtPrepareStmt block
...
@@ -41,7 +41,7 @@ ECPG: stmtPrepareStmt block
if ($1.type == NULL || strlen($1.type) == 0)
if ($1.type == NULL || strlen($1.type) == 0)
output_prepare_statement($1.name, $1.stmt);
output_prepare_statement($1.name, $1.stmt);
else
else
output_statement(cat_str(5, m
ake_str("prepare"), $1.name, $1.type, make_str
("as"), $1.stmt), 0, ECPGst_normal);
output_statement(cat_str(5, m
m_strdup("prepare"), $1.name, $1.type, mm_strdup
("as"), $1.stmt), 0, ECPGst_normal);
}
}
ECPG: stmtTransactionStmt block
ECPG: stmtTransactionStmt block
{
{
...
@@ -212,21 +212,21 @@ ECPG: var_valueNumericOnly addon
...
@@ -212,21 +212,21 @@ ECPG: var_valueNumericOnly addon
if ($1[0] == '$')
if ($1[0] == '$')
{
{
free($1);
free($1);
$1 = m
ake_str
("$0");
$1 = m
m_strdup
("$0");
}
}
ECPG: fetch_argscursor_name addon
ECPG: fetch_argscursor_name addon
add_additional_variables($1, false);
add_additional_variables($1, false);
if ($1[0] == ':')
if ($1[0] == ':')
{
{
free($1);
free($1);
$1 = m
ake_str
("$0");
$1 = m
m_strdup
("$0");
}
}
ECPG: fetch_argsfrom_incursor_name addon
ECPG: fetch_argsfrom_incursor_name addon
add_additional_variables($2, false);
add_additional_variables($2, false);
if ($2[0] == ':')
if ($2[0] == ':')
{
{
free($2);
free($2);
$2 = m
ake_str
("$0");
$2 = m
m_strdup
("$0");
}
}
ECPG: fetch_argsNEXTopt_from_incursor_name addon
ECPG: fetch_argsNEXTopt_from_incursor_name addon
ECPG: fetch_argsPRIORopt_from_incursor_name addon
ECPG: fetch_argsPRIORopt_from_incursor_name addon
...
@@ -237,19 +237,19 @@ ECPG: fetch_argsALLopt_from_incursor_name addon
...
@@ -237,19 +237,19 @@ ECPG: fetch_argsALLopt_from_incursor_name addon
if ($3[0] == ':')
if ($3[0] == ':')
{
{
free($3);
free($3);
$3 = m
ake_str
("$0");
$3 = m
m_strdup
("$0");
}
}
ECPG: fetch_argsSignedIconstopt_from_incursor_name addon
ECPG: fetch_argsSignedIconstopt_from_incursor_name addon
add_additional_variables($3, false);
add_additional_variables($3, false);
if ($3[0] == ':')
if ($3[0] == ':')
{
{
free($3);
free($3);
$3 = m
ake_str
("$0");
$3 = m
m_strdup
("$0");
}
}
if ($1[0] == '$')
if ($1[0] == '$')
{
{
free($1);
free($1);
$1 = m
ake_str
("$0");
$1 = m
m_strdup
("$0");
}
}
ECPG: fetch_argsFORWARDALLopt_from_incursor_name addon
ECPG: fetch_argsFORWARDALLopt_from_incursor_name addon
ECPG: fetch_argsBACKWARDALLopt_from_incursor_name addon
ECPG: fetch_argsBACKWARDALLopt_from_incursor_name addon
...
@@ -257,7 +257,7 @@ ECPG: fetch_argsBACKWARDALLopt_from_incursor_name addon
...
@@ -257,7 +257,7 @@ ECPG: fetch_argsBACKWARDALLopt_from_incursor_name addon
if ($4[0] == ':')
if ($4[0] == ':')
{
{
free($4);
free($4);
$4 = m
ake_str
("$0");
$4 = m
m_strdup
("$0");
}
}
ECPG: fetch_argsABSOLUTE_PSignedIconstopt_from_incursor_name addon
ECPG: fetch_argsABSOLUTE_PSignedIconstopt_from_incursor_name addon
ECPG: fetch_argsRELATIVE_PSignedIconstopt_from_incursor_name addon
ECPG: fetch_argsRELATIVE_PSignedIconstopt_from_incursor_name addon
...
@@ -267,12 +267,12 @@ ECPG: fetch_argsBACKWARDSignedIconstopt_from_incursor_name addon
...
@@ -267,12 +267,12 @@ ECPG: fetch_argsBACKWARDSignedIconstopt_from_incursor_name addon
if ($4[0] == ':')
if ($4[0] == ':')
{
{
free($4);
free($4);
$4 = m
ake_str
("$0");
$4 = m
m_strdup
("$0");
}
}
if ($2[0] == '$')
if ($2[0] == '$')
{
{
free($2);
free($2);
$2 = m
ake_str
("$0");
$2 = m
m_strdup
("$0");
}
}
ECPG: cursor_namename rule
ECPG: cursor_namename rule
| char_civar
| char_civar
...
@@ -287,7 +287,7 @@ ECPG: PrepareStmtPREPAREprepared_nameprep_type_clauseASPreparableStmt block
...
@@ -287,7 +287,7 @@ ECPG: PrepareStmtPREPAREprepared_nameprep_type_clauseASPreparableStmt block
{
{
$$.name = $2;
$$.name = $2;
$$.type = $3;
$$.type = $3;
$$.stmt = cat_str(3, m
ake_str("\""), $5, make_str
("\""));
$$.stmt = cat_str(3, m
m_strdup("\""), $5, mm_strdup
("\""));
}
}
| PREPARE prepared_name FROM execstring
| PREPARE prepared_name FROM execstring
{
{
...
@@ -300,7 +300,7 @@ ECPG: ExecuteStmtEXECUTEprepared_nameexecute_param_clauseexecute_rest block
...
@@ -300,7 +300,7 @@ ECPG: ExecuteStmtEXECUTEprepared_nameexecute_param_clauseexecute_rest block
ECPG: DeclareCursorStmtDECLAREcursor_namecursor_optionsCURSORopt_holdFORSelectStmt block
ECPG: DeclareCursorStmtDECLAREcursor_namecursor_optionsCURSORopt_holdFORSelectStmt block
{
{
struct cursor *ptr, *this;
struct cursor *ptr, *this;
char *cursor_marker = $2[0] == ':' ? m
ake_str
("$0") : mm_strdup($2);
char *cursor_marker = $2[0] == ':' ? m
m_strdup
("$0") : mm_strdup($2);
char *comment, *c1, *c2;
char *comment, *c1, *c2;
int (* strcmp_fn)(const char *, const char *) = ($2[0] == ':' ? strcmp : pg_strcasecmp);
int (* strcmp_fn)(const char *, const char *) = ($2[0] == ':' ? strcmp : pg_strcasecmp);
...
@@ -322,7 +322,7 @@ ECPG: DeclareCursorStmtDECLAREcursor_namecursor_optionsCURSORopt_holdFORSelectSt
...
@@ -322,7 +322,7 @@ ECPG: DeclareCursorStmtDECLAREcursor_namecursor_optionsCURSORopt_holdFORSelectSt
this->function = (current_function ? mm_strdup(current_function) : NULL);
this->function = (current_function ? mm_strdup(current_function) : NULL);
this->connection = connection;
this->connection = connection;
this->opened = false;
this->opened = false;
this->command = cat_str(7, m
ake_str("declare"), cursor_marker, $3, make_str("cursor"), $5, make_str
("for"), $7);
this->command = cat_str(7, m
m_strdup("declare"), cursor_marker, $3, mm_strdup("cursor"), $5, mm_strdup
("for"), $7);
this->argsinsert = argsinsert;
this->argsinsert = argsinsert;
this->argsinsert_oos = NULL;
this->argsinsert_oos = NULL;
this->argsresult = argsresult;
this->argsresult = argsresult;
...
@@ -337,31 +337,31 @@ ECPG: DeclareCursorStmtDECLAREcursor_namecursor_optionsCURSORopt_holdFORSelectSt
...
@@ -337,31 +337,31 @@ ECPG: DeclareCursorStmtDECLAREcursor_namecursor_optionsCURSORopt_holdFORSelectSt
c2[0] = '.';
c2[0] = '.';
c2[1] = '.';
c2[1] = '.';
}
}
comment = cat_str(3, m
ake_str("/*"), c1, make_str
("*/"));
comment = cat_str(3, m
m_strdup("/*"), c1, mm_strdup
("*/"));
if ((braces_open > 0) && INFORMIX_MODE) /* we're in a function */
if ((braces_open > 0) && INFORMIX_MODE) /* we're in a function */
$$ = cat_str(3, adjust_outofscope_cursor_vars(this),
$$ = cat_str(3, adjust_outofscope_cursor_vars(this),
m
ake_str
("ECPG_informix_reset_sqlca();"),
m
m_strdup
("ECPG_informix_reset_sqlca();"),
comment);
comment);
else
else
$$ = cat2_str(adjust_outofscope_cursor_vars(this), comment);
$$ = cat2_str(adjust_outofscope_cursor_vars(this), comment);
}
}
ECPG: ClosePortalStmtCLOSEcursor_name block
ECPG: ClosePortalStmtCLOSEcursor_name block
{
{
char *cursor_marker = $2[0] == ':' ? m
ake_str
("$0") : $2;
char *cursor_marker = $2[0] == ':' ? m
m_strdup
("$0") : $2;
$$ = cat2_str(m
ake_str
("close"), cursor_marker);
$$ = cat2_str(m
m_strdup
("close"), cursor_marker);
}
}
ECPG: opt_hold block
ECPG: opt_hold block
{
{
if (compat == ECPG_COMPAT_INFORMIX_SE && autocommit)
if (compat == ECPG_COMPAT_INFORMIX_SE && autocommit)
$$ = m
ake_str
("with hold");
$$ = m
m_strdup
("with hold");
else
else
$$ = EMPTY;
$$ = EMPTY;
}
}
ECPG: into_clauseINTOOptTempTableName block
ECPG: into_clauseINTOOptTempTableName block
{
{
FoundInto = 1;
FoundInto = 1;
$$= cat2_str(m
ake_str
("into"), $2);
$$= cat2_str(m
m_strdup
("into"), $2);
}
}
| ecpg_into { $$ = EMPTY; }
| ecpg_into { $$ = EMPTY; }
ECPG: table_refselect_with_parens addon
ECPG: table_refselect_with_parens addon
...
@@ -369,16 +369,16 @@ ECPG: table_refselect_with_parens addon
...
@@ -369,16 +369,16 @@ ECPG: table_refselect_with_parens addon
ECPG: TypenameSimpleTypenameopt_array_bounds block
ECPG: TypenameSimpleTypenameopt_array_bounds block
{ $$ = cat2_str($1, $2.str); }
{ $$ = cat2_str($1, $2.str); }
ECPG: TypenameSETOFSimpleTypenameopt_array_bounds block
ECPG: TypenameSETOFSimpleTypenameopt_array_bounds block
{ $$ = cat_str(3, m
ake_str
("setof"), $2, $3.str); }
{ $$ = cat_str(3, m
m_strdup
("setof"), $2, $3.str); }
ECPG: opt_array_boundsopt_array_bounds'['']' block
ECPG: opt_array_boundsopt_array_bounds'['']' block
{
{
$$.index1 = $1.index1;
$$.index1 = $1.index1;
$$.index2 = $1.index2;
$$.index2 = $1.index2;
if (strcmp($$.index1, "-1") == 0)
if (strcmp($$.index1, "-1") == 0)
$$.index1 = m
ake_str
("0");
$$.index1 = m
m_strdup
("0");
else if (strcmp($1.index2, "-1") == 0)
else if (strcmp($1.index2, "-1") == 0)
$$.index2 = m
ake_str
("0");
$$.index2 = m
m_strdup
("0");
$$.str = cat_str(2, $1.str, m
ake_str
("[]"));
$$.str = cat_str(2, $1.str, m
m_strdup
("[]"));
}
}
| opt_array_bounds '[' Iresult ']'
| opt_array_bounds '[' Iresult ']'
{
{
...
@@ -388,12 +388,12 @@ ECPG: opt_array_boundsopt_array_bounds'['']' block
...
@@ -388,12 +388,12 @@ ECPG: opt_array_boundsopt_array_bounds'['']' block
$$.index1 = strdup($3);
$$.index1 = strdup($3);
else if (strcmp($1.index2, "-1") == 0)
else if (strcmp($1.index2, "-1") == 0)
$$.index2 = strdup($3);
$$.index2 = strdup($3);
$$.str = cat_str(4, $1.str, m
ake_str("["), $3, make_str
("]"));
$$.str = cat_str(4, $1.str, m
m_strdup("["), $3, mm_strdup
("]"));
}
}
ECPG: opt_array_bounds
ECPG: opt_array_bounds
{
{
$$.index1 = m
ake_str
("-1");
$$.index1 = m
m_strdup
("-1");
$$.index2 = m
ake_str
("-1");
$$.index2 = m
m_strdup
("-1");
$$.str= EMPTY;
$$.str= EMPTY;
}
}
ECPG: IconstICONST block
ECPG: IconstICONST block
...
@@ -404,8 +404,8 @@ ECPG: AexprConstNULL_P rule
...
@@ -404,8 +404,8 @@ ECPG: AexprConstNULL_P rule
ECPG: ColIdcol_name_keyword rule
ECPG: ColIdcol_name_keyword rule
| ECPGKeywords { $$ = $1; }
| ECPGKeywords { $$ = $1; }
| ECPGCKeywords { $$ = $1; }
| ECPGCKeywords { $$ = $1; }
| CHAR_P { $$ = m
ake_str
("char"); }
| CHAR_P { $$ = m
m_strdup
("char"); }
| VALUES { $$ = m
ake_str
("values"); }
| VALUES { $$ = m
m_strdup
("values"); }
ECPG: type_function_nametype_func_name_keyword rule
ECPG: type_function_nametype_func_name_keyword rule
| ECPGKeywords { $$ = $1; }
| ECPGKeywords { $$ = $1; }
| ECPGTypeName { $$ = $1; }
| ECPGTypeName { $$ = $1; }
...
@@ -418,60 +418,60 @@ ECPG: VariableShowStmtSHOWALL block
...
@@ -418,60 +418,60 @@ ECPG: VariableShowStmtSHOWALL block
ECPG: FetchStmtMOVEfetch_args rule
ECPG: FetchStmtMOVEfetch_args rule
| FETCH fetch_args ecpg_fetch_into
| FETCH fetch_args ecpg_fetch_into
{
{
$$ = cat2_str(m
ake_str
("fetch"), $2);
$$ = cat2_str(m
m_strdup
("fetch"), $2);
}
}
| FETCH FORWARD cursor_name opt_ecpg_fetch_into
| FETCH FORWARD cursor_name opt_ecpg_fetch_into
{
{
char *cursor_marker = $3[0] == ':' ? m
ake_str
("$0") : $3;
char *cursor_marker = $3[0] == ':' ? m
m_strdup
("$0") : $3;
add_additional_variables($3, false);
add_additional_variables($3, false);
$$ = cat_str(2, m
ake_str
("fetch forward"), cursor_marker);
$$ = cat_str(2, m
m_strdup
("fetch forward"), cursor_marker);
}
}
| FETCH FORWARD from_in cursor_name opt_ecpg_fetch_into
| FETCH FORWARD from_in cursor_name opt_ecpg_fetch_into
{
{
char *cursor_marker = $4[0] == ':' ? m
ake_str
("$0") : $4;
char *cursor_marker = $4[0] == ':' ? m
m_strdup
("$0") : $4;
add_additional_variables($4, false);
add_additional_variables($4, false);
$$ = cat_str(2, m
ake_str
("fetch forward from"), cursor_marker);
$$ = cat_str(2, m
m_strdup
("fetch forward from"), cursor_marker);
}
}
| FETCH BACKWARD cursor_name opt_ecpg_fetch_into
| FETCH BACKWARD cursor_name opt_ecpg_fetch_into
{
{
char *cursor_marker = $3[0] == ':' ? m
ake_str
("$0") : $3;
char *cursor_marker = $3[0] == ':' ? m
m_strdup
("$0") : $3;
add_additional_variables($3, false);
add_additional_variables($3, false);
$$ = cat_str(2, m
ake_str
("fetch backward"), cursor_marker);
$$ = cat_str(2, m
m_strdup
("fetch backward"), cursor_marker);
}
}
| FETCH BACKWARD from_in cursor_name opt_ecpg_fetch_into
| FETCH BACKWARD from_in cursor_name opt_ecpg_fetch_into
{
{
char *cursor_marker = $4[0] == ':' ? m
ake_str
("$0") : $4;
char *cursor_marker = $4[0] == ':' ? m
m_strdup
("$0") : $4;
add_additional_variables($4, false);
add_additional_variables($4, false);
$$ = cat_str(2, m
ake_str
("fetch backward from"), cursor_marker);
$$ = cat_str(2, m
m_strdup
("fetch backward from"), cursor_marker);
}
}
| MOVE FORWARD cursor_name
| MOVE FORWARD cursor_name
{
{
char *cursor_marker = $3[0] == ':' ? m
ake_str
("$0") : $3;
char *cursor_marker = $3[0] == ':' ? m
m_strdup
("$0") : $3;
add_additional_variables($3, false);
add_additional_variables($3, false);
$$ = cat_str(2, m
ake_str
("move forward"), cursor_marker);
$$ = cat_str(2, m
m_strdup
("move forward"), cursor_marker);
}
}
| MOVE FORWARD from_in cursor_name
| MOVE FORWARD from_in cursor_name
{
{
char *cursor_marker = $4[0] == ':' ? m
ake_str
("$0") : $4;
char *cursor_marker = $4[0] == ':' ? m
m_strdup
("$0") : $4;
add_additional_variables($4, false);
add_additional_variables($4, false);
$$ = cat_str(2, m
ake_str
("move forward from"), cursor_marker);
$$ = cat_str(2, m
m_strdup
("move forward from"), cursor_marker);
}
}
| MOVE BACKWARD cursor_name
| MOVE BACKWARD cursor_name
{
{
char *cursor_marker = $3[0] == ':' ? m
ake_str
("$0") : $3;
char *cursor_marker = $3[0] == ':' ? m
m_strdup
("$0") : $3;
add_additional_variables($3, false);
add_additional_variables($3, false);
$$ = cat_str(2, m
ake_str
("move backward"), cursor_marker);
$$ = cat_str(2, m
m_strdup
("move backward"), cursor_marker);
}
}
| MOVE BACKWARD from_in cursor_name
| MOVE BACKWARD from_in cursor_name
{
{
char *cursor_marker = $4[0] == ':' ? m
ake_str
("$0") : $4;
char *cursor_marker = $4[0] == ':' ? m
m_strdup
("$0") : $4;
add_additional_variables($4, false);
add_additional_variables($4, false);
$$ = cat_str(2, m
ake_str
("move backward from"), cursor_marker);
$$ = cat_str(2, m
m_strdup
("move backward from"), cursor_marker);
}
}
ECPG: limit_clauseLIMITselect_limit_value','select_offset_value block
ECPG: limit_clauseLIMITselect_limit_value','select_offset_value block
{
{
mmerror(PARSE_ERROR, ET_WARNING, "no longer supported LIMIT #,# syntax passed to server");
mmerror(PARSE_ERROR, ET_WARNING, "no longer supported LIMIT #,# syntax passed to server");
$$ = cat_str(4, m
ake_str("limit"), $2, make_str
(","), $4);
$$ = cat_str(4, m
m_strdup("limit"), $2, mm_strdup
(","), $4);
}
}
ECPG: SignedIconstIconst rule
ECPG: SignedIconstIconst rule
| civar { $$ = $1; }
| civar { $$ = $1; }
src/interfaces/ecpg/preproc/ecpg.header
View file @
1066dbfb
...
@@ -148,15 +148,6 @@ cat_str(int count, ...)
...
@@ -148,15 +148,6 @@ cat_str(int count, ...)
return(res_str);
return(res_str);
}
}
char *
make_str(const char *str)
{
char * res_str = (char *)mm_alloc(strlen(str) + 1);
strcpy(res_str, str);
return res_str;
}
static char *
static char *
make2_str(char *str1, char *str2)
make2_str(char *str1, char *str2)
{
{
...
@@ -219,7 +210,7 @@ create_questionmarks(char *name, bool array)
...
@@ -219,7 +210,7 @@ create_questionmarks(char *name, bool array)
for (; count > 0; count --)
for (; count > 0; count --)
{
{
sprintf(pacounter_buffer, "$%d", pacounter++);
sprintf(pacounter_buffer, "$%d", pacounter++);
result = cat_str(3, result, mm_strdup(pacounter_buffer), m
ake_str
(" , "));
result = cat_str(3, result, mm_strdup(pacounter_buffer), m
m_strdup
(" , "));
}
}
/* removed the trailing " ," */
/* removed the trailing " ," */
...
@@ -242,7 +233,7 @@ adjust_outofscope_cursor_vars(struct cursor *cur)
...
@@ -242,7 +233,7 @@ adjust_outofscope_cursor_vars(struct cursor *cur)
* instead of the variable. Do it only for local variables, not for globals.
* instead of the variable. Do it only for local variables, not for globals.
*/
*/
char *result = m
ake_str
("");
char *result = m
m_strdup
("");
int insert;
int insert;
for (insert = 1; insert >= 0; insert--)
for (insert = 1; insert >= 0; insert--)
...
@@ -277,12 +268,12 @@ adjust_outofscope_cursor_vars(struct cursor *cur)
...
@@ -277,12 +268,12 @@ adjust_outofscope_cursor_vars(struct cursor *cur)
}
}
else if ((ptr->variable->type->type != ECPGt_varchar && ptr->variable->type->type != ECPGt_char && ptr->variable->type->type != ECPGt_unsigned_char && ptr->variable->type->type != ECPGt_string) && atoi(ptr->variable->type->size) > 1)
else if ((ptr->variable->type->type != ECPGt_varchar && ptr->variable->type->type != ECPGt_char && ptr->variable->type->type != ECPGt_unsigned_char && ptr->variable->type->type != ECPGt_string) && atoi(ptr->variable->type->size) > 1)
{
{
newvar = new_variable(cat_str(4, m
ake_str("("), mm_strdup(ecpg_type_name(ptr->variable->type->u.element->type)), make_str(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_array_type(ECPGmake_simple_type(ptr->variable->type->u.element->type, make_str
("1"), ptr->variable->type->u.element->counter), ptr->variable->type->size), 0);
newvar = new_variable(cat_str(4, m
m_strdup("("), mm_strdup(ecpg_type_name(ptr->variable->type->u.element->type)), mm_strdup(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_array_type(ECPGmake_simple_type(ptr->variable->type->u.element->type, mm_strdup
("1"), ptr->variable->type->u.element->counter), ptr->variable->type->size), 0);
sprintf(temp, "%d, (", ecpg_internal_var++);
sprintf(temp, "%d, (", ecpg_internal_var++);
}
}
else if ((ptr->variable->type->type == ECPGt_varchar || ptr->variable->type->type == ECPGt_char || ptr->variable->type->type == ECPGt_unsigned_char || ptr->variable->type->type == ECPGt_string) && atoi(ptr->variable->type->size) > 1)
else if ((ptr->variable->type->type == ECPGt_varchar || ptr->variable->type->type == ECPGt_char || ptr->variable->type->type == ECPGt_unsigned_char || ptr->variable->type->type == ECPGt_string) && atoi(ptr->variable->type->size) > 1)
{
{
newvar = new_variable(cat_str(4, m
ake_str("("), mm_strdup(ecpg_type_name(ptr->variable->type->type)), make_str
(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->variable->type->type, ptr->variable->type->size, ptr->variable->type->counter), 0);
newvar = new_variable(cat_str(4, m
m_strdup("("), mm_strdup(ecpg_type_name(ptr->variable->type->type)), mm_strdup
(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->variable->type->type, ptr->variable->type->size, ptr->variable->type->counter), 0);
if (ptr->variable->type->type == ECPGt_varchar)
if (ptr->variable->type->type == ECPGt_varchar)
sprintf(temp, "%d, &(", ecpg_internal_var++);
sprintf(temp, "%d, &(", ecpg_internal_var++);
else
else
...
@@ -291,7 +282,7 @@ adjust_outofscope_cursor_vars(struct cursor *cur)
...
@@ -291,7 +282,7 @@ adjust_outofscope_cursor_vars(struct cursor *cur)
else if (ptr->variable->type->type == ECPGt_struct || ptr->variable->type->type == ECPGt_union)
else if (ptr->variable->type->type == ECPGt_struct || ptr->variable->type->type == ECPGt_union)
{
{
sprintf(temp, "%d)))", ecpg_internal_var);
sprintf(temp, "%d)))", ecpg_internal_var);
newvar = new_variable(cat_str(4, m
ake_str("(*("), mm_strdup(ptr->variable->type->type_name), make_str
(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_struct_type(ptr->variable->type->u.members, ptr->variable->type->type, ptr->variable->type->type_name, ptr->variable->type->struct_sizeof), 0);
newvar = new_variable(cat_str(4, m
m_strdup("(*("), mm_strdup(ptr->variable->type->type_name), mm_strdup
(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_struct_type(ptr->variable->type->u.members, ptr->variable->type->type, ptr->variable->type->type_name, ptr->variable->type->struct_sizeof), 0);
sprintf(temp, "%d, &(", ecpg_internal_var++);
sprintf(temp, "%d, &(", ecpg_internal_var++);
}
}
else if (ptr->variable->type->type == ECPGt_array)
else if (ptr->variable->type->type == ECPGt_array)
...
@@ -299,24 +290,24 @@ adjust_outofscope_cursor_vars(struct cursor *cur)
...
@@ -299,24 +290,24 @@ adjust_outofscope_cursor_vars(struct cursor *cur)
if (ptr->variable->type->u.element->type == ECPGt_struct || ptr->variable->type->u.element->type == ECPGt_union)
if (ptr->variable->type->u.element->type == ECPGt_struct || ptr->variable->type->u.element->type == ECPGt_union)
{
{
sprintf(temp, "%d)))", ecpg_internal_var);
sprintf(temp, "%d)))", ecpg_internal_var);
newvar = new_variable(cat_str(4, m
ake_str("(*("), mm_strdup(ptr->variable->type->u.element->type_name), make_str
(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_struct_type(ptr->variable->type->u.element->u.members, ptr->variable->type->u.element->type, ptr->variable->type->u.element->type_name, ptr->variable->type->u.element->struct_sizeof), 0);
newvar = new_variable(cat_str(4, m
m_strdup("(*("), mm_strdup(ptr->variable->type->u.element->type_name), mm_strdup
(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_struct_type(ptr->variable->type->u.element->u.members, ptr->variable->type->u.element->type, ptr->variable->type->u.element->type_name, ptr->variable->type->u.element->struct_sizeof), 0);
sprintf(temp, "%d, (", ecpg_internal_var++);
sprintf(temp, "%d, (", ecpg_internal_var++);
}
}
else
else
{
{
newvar = new_variable(cat_str(4, m
ake_str("("), mm_strdup(ecpg_type_name(ptr->variable->type->type)), make_str
(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_array_type(ECPGmake_simple_type(ptr->variable->type->u.element->type, ptr->variable->type->u.element->size, ptr->variable->type->u.element->counter), ptr->variable->type->size), 0);
newvar = new_variable(cat_str(4, m
m_strdup("("), mm_strdup(ecpg_type_name(ptr->variable->type->type)), mm_strdup
(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_array_type(ECPGmake_simple_type(ptr->variable->type->u.element->type, ptr->variable->type->u.element->size, ptr->variable->type->u.element->counter), ptr->variable->type->size), 0);
sprintf(temp, "%d, &(", ecpg_internal_var++);
sprintf(temp, "%d, &(", ecpg_internal_var++);
}
}
}
}
else
else
{
{
newvar = new_variable(cat_str(4, m
ake_str("*("), mm_strdup(ecpg_type_name(ptr->variable->type->type)), make_str
(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->variable->type->type, ptr->variable->type->size, ptr->variable->type->counter), 0);
newvar = new_variable(cat_str(4, m
m_strdup("*("), mm_strdup(ecpg_type_name(ptr->variable->type->type)), mm_strdup
(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->variable->type->type, ptr->variable->type->size, ptr->variable->type->counter), 0);
sprintf(temp, "%d, &(", ecpg_internal_var++);
sprintf(temp, "%d, &(", ecpg_internal_var++);
}
}
/* create call to "ECPGset_var(<counter>, <pointer>. <line number>)" */
/* create call to "ECPGset_var(<counter>, <pointer>. <line number>)" */
if (!skip_set_var)
if (!skip_set_var)
result = cat_str(5, result, m
ake_str("ECPGset_var("), mm_strdup(temp), mm_strdup(original_var), make_str
("), __LINE__);\n"));
result = cat_str(5, result, m
m_strdup("ECPGset_var("), mm_strdup(temp), mm_strdup(original_var), mm_strdup
("), __LINE__);\n"));
/* now the indicator if there is one and it's not a global variable */
/* now the indicator if there is one and it's not a global variable */
if ((ptr->indicator->type->type == ECPGt_NO_INDICATOR) || (ptr->indicator->brace_level == 0))
if ((ptr->indicator->type->type == ECPGt_NO_INDICATOR) || (ptr->indicator->brace_level == 0))
...
@@ -332,7 +323,7 @@ adjust_outofscope_cursor_vars(struct cursor *cur)
...
@@ -332,7 +323,7 @@ adjust_outofscope_cursor_vars(struct cursor *cur)
if (ptr->indicator->type->type == ECPGt_struct || ptr->indicator->type->type == ECPGt_union)
if (ptr->indicator->type->type == ECPGt_struct || ptr->indicator->type->type == ECPGt_union)
{
{
sprintf(temp, "%d)))", ecpg_internal_var);
sprintf(temp, "%d)))", ecpg_internal_var);
newind = new_variable(cat_str(4, m
ake_str("(*("), mm_strdup(ptr->indicator->type->type_name), make_str
(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_struct_type(ptr->indicator->type->u.members, ptr->indicator->type->type, ptr->indicator->type->type_name, ptr->indicator->type->struct_sizeof), 0);
newind = new_variable(cat_str(4, m
m_strdup("(*("), mm_strdup(ptr->indicator->type->type_name), mm_strdup
(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_struct_type(ptr->indicator->type->u.members, ptr->indicator->type->type, ptr->indicator->type->type_name, ptr->indicator->type->struct_sizeof), 0);
sprintf(temp, "%d, &(", ecpg_internal_var++);
sprintf(temp, "%d, &(", ecpg_internal_var++);
}
}
else if (ptr->indicator->type->type == ECPGt_array)
else if (ptr->indicator->type->type == ECPGt_array)
...
@@ -340,28 +331,28 @@ adjust_outofscope_cursor_vars(struct cursor *cur)
...
@@ -340,28 +331,28 @@ adjust_outofscope_cursor_vars(struct cursor *cur)
if (ptr->indicator->type->u.element->type == ECPGt_struct || ptr->indicator->type->u.element->type == ECPGt_union)
if (ptr->indicator->type->u.element->type == ECPGt_struct || ptr->indicator->type->u.element->type == ECPGt_union)
{
{
sprintf(temp, "%d)))", ecpg_internal_var);
sprintf(temp, "%d)))", ecpg_internal_var);
newind = new_variable(cat_str(4, m
ake_str("(*("), mm_strdup(ptr->indicator->type->u.element->type_name), make_str
(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_struct_type(ptr->indicator->type->u.element->u.members, ptr->indicator->type->u.element->type, ptr->indicator->type->u.element->type_name, ptr->indicator->type->u.element->struct_sizeof), 0);
newind = new_variable(cat_str(4, m
m_strdup("(*("), mm_strdup(ptr->indicator->type->u.element->type_name), mm_strdup
(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_struct_type(ptr->indicator->type->u.element->u.members, ptr->indicator->type->u.element->type, ptr->indicator->type->u.element->type_name, ptr->indicator->type->u.element->struct_sizeof), 0);
sprintf(temp, "%d, (", ecpg_internal_var++);
sprintf(temp, "%d, (", ecpg_internal_var++);
}
}
else
else
{
{
newind = new_variable(cat_str(4, m
ake_str("("), mm_strdup(ecpg_type_name(ptr->indicator->type->u.element->type)), make_str
(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_array_type(ECPGmake_simple_type(ptr->indicator->type->u.element->type, ptr->indicator->type->u.element->size, ptr->indicator->type->u.element->counter), ptr->indicator->type->size), 0);
newind = new_variable(cat_str(4, m
m_strdup("("), mm_strdup(ecpg_type_name(ptr->indicator->type->u.element->type)), mm_strdup
(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_array_type(ECPGmake_simple_type(ptr->indicator->type->u.element->type, ptr->indicator->type->u.element->size, ptr->indicator->type->u.element->counter), ptr->indicator->type->size), 0);
sprintf(temp, "%d, &(", ecpg_internal_var++);
sprintf(temp, "%d, &(", ecpg_internal_var++);
}
}
}
}
else if (atoi(ptr->indicator->type->size) > 1)
else if (atoi(ptr->indicator->type->size) > 1)
{
{
newind = new_variable(cat_str(4, m
ake_str("("), mm_strdup(ecpg_type_name(ptr->indicator->type->type)), make_str
(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->indicator->type->type, ptr->indicator->type->size, ptr->variable->type->counter), 0);
newind = new_variable(cat_str(4, m
m_strdup("("), mm_strdup(ecpg_type_name(ptr->indicator->type->type)), mm_strdup
(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->indicator->type->type, ptr->indicator->type->size, ptr->variable->type->counter), 0);
sprintf(temp, "%d, (", ecpg_internal_var++);
sprintf(temp, "%d, (", ecpg_internal_var++);
}
}
else
else
{
{
newind = new_variable(cat_str(4, m
ake_str("*("), mm_strdup(ecpg_type_name(ptr->indicator->type->type)), make_str
(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->indicator->type->type, ptr->indicator->type->size, ptr->variable->type->counter), 0);
newind = new_variable(cat_str(4, m
m_strdup("*("), mm_strdup(ecpg_type_name(ptr->indicator->type->type)), mm_strdup
(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->indicator->type->type, ptr->indicator->type->size, ptr->variable->type->counter), 0);
sprintf(temp, "%d, &(", ecpg_internal_var++);
sprintf(temp, "%d, &(", ecpg_internal_var++);
}
}
/* create call to "ECPGset_var(<counter>, <pointer>. <line number>)" */
/* create call to "ECPGset_var(<counter>, <pointer>. <line number>)" */
result = cat_str(5, result, m
ake_str("ECPGset_var("), mm_strdup(temp), mm_strdup(original_var), make_str
("), __LINE__);\n"));
result = cat_str(5, result, m
m_strdup("ECPGset_var("), mm_strdup(temp), mm_strdup(original_var), mm_strdup
("), __LINE__);\n"));
}
}
add_variable_to_tail(&newlist, newvar, newind);
add_variable_to_tail(&newlist, newvar, newind);
...
...
src/interfaces/ecpg/preproc/ecpg.trailer
View file @
1066dbfb
...
@@ -34,7 +34,7 @@ CreateAsStmt: CREATE OptTemp TABLE create_as_target AS {FoundInto = 0;} SelectSt
...
@@ -34,7 +34,7 @@ CreateAsStmt: CREATE OptTemp TABLE create_as_target AS {FoundInto = 0;} SelectSt
if (FoundInto == 1)
if (FoundInto == 1)
mmerror(PARSE_ERROR, ET_ERROR, "CREATE TABLE AS cannot specify INTO");
mmerror(PARSE_ERROR, ET_ERROR, "CREATE TABLE AS cannot specify INTO");
$$ = cat_str(6, m
ake_str("create"), $2, make_str("table"), $4, make_str
("as"), $7);
$$ = cat_str(6, m
m_strdup("create"), $2, mm_strdup("table"), $4, mm_strdup
("as"), $7);
}
}
;
;
...
@@ -55,14 +55,14 @@ at: AT connection_object
...
@@ -55,14 +55,14 @@ at: AT connection_object
* the exec sql connect statement: connect to the given database
* the exec sql connect statement: connect to the given database
*/
*/
ECPGConnect: SQL_CONNECT TO connection_target opt_connection_name opt_user
ECPGConnect: SQL_CONNECT TO connection_target opt_connection_name opt_user
{ $$ = cat_str(5, $3, m
ake_str(","), $5, make_str
(","), $4); }
{ $$ = cat_str(5, $3, m
m_strdup(","), $5, mm_strdup
(","), $4); }
| SQL_CONNECT TO DEFAULT
| SQL_CONNECT TO DEFAULT
{ $$ = m
ake_str
("NULL, NULL, NULL, \"DEFAULT\""); }
{ $$ = m
m_strdup
("NULL, NULL, NULL, \"DEFAULT\""); }
/* also allow ORACLE syntax */
/* also allow ORACLE syntax */
| SQL_CONNECT ora_user
| SQL_CONNECT ora_user
{ $$ = cat_str(3, m
ake_str("NULL,"), $2, make_str
(", NULL")); }
{ $$ = cat_str(3, m
m_strdup("NULL,"), $2, mm_strdup
(", NULL")); }
| DATABASE connection_target
| DATABASE connection_target
{ $$ = cat2_str($2, m
ake_str
(", NULL, NULL, NULL")); }
{ $$ = cat2_str($2, m
m_strdup
(", NULL, NULL, NULL")); }
;
;
connection_target: opt_database_name opt_server opt_port
connection_target: opt_database_name opt_server opt_port
...
@@ -75,7 +75,7 @@ connection_target: opt_database_name opt_server opt_port
...
@@ -75,7 +75,7 @@ connection_target: opt_database_name opt_server opt_port
if ($1[0] == '\"')
if ($1[0] == '\"')
$$ = $1;
$$ = $1;
else
else
$$ = make3_str(m
ake_str("\""), make3_str($1, $2, $3), make_str
("\""));
$$ = make3_str(m
m_strdup("\""), make3_str($1, $2, $3), mm_strdup
("\""));
}
}
| db_prefix ':' server opt_port '/' opt_database_name opt_options
| db_prefix ':' server opt_port '/' opt_database_name opt_options
{
{
...
@@ -91,7 +91,7 @@ connection_target: opt_database_name opt_server opt_port
...
@@ -91,7 +91,7 @@ connection_target: opt_database_name opt_server opt_port
strncmp($3 + strlen("//"), "127.0.0.1", strlen("127.0.0.1")) != 0)
strncmp($3 + strlen("//"), "127.0.0.1", strlen("127.0.0.1")) != 0)
mmerror(PARSE_ERROR, ET_ERROR, "Unix-domain sockets only work on \"localhost\" but not on \"%s\"", $3 + strlen("//"));
mmerror(PARSE_ERROR, ET_ERROR, "Unix-domain sockets only work on \"localhost\" but not on \"%s\"", $3 + strlen("//"));
$$ = make3_str(make3_str(m
ake_str("\""), $1, make_str(":")), $3, make3_str(make3_str($4, make_str("/"), $6), $7, make_str
("\"")));
$$ = make3_str(make3_str(m
m_strdup("\""), $1, mm_strdup(":")), $3, make3_str(make3_str($4, mm_strdup("/"), $6), $7, mm_strdup
("\"")));
}
}
| char_variable
| char_variable
{
{
...
@@ -120,7 +120,7 @@ db_prefix: ecpg_ident cvariable
...
@@ -120,7 +120,7 @@ db_prefix: ecpg_ident cvariable
if (strcmp($1, "tcp") != 0 && strcmp($1, "unix") != 0)
if (strcmp($1, "tcp") != 0 && strcmp($1, "unix") != 0)
mmerror(PARSE_ERROR, ET_ERROR, "invalid connection type: %s", $1);
mmerror(PARSE_ERROR, ET_ERROR, "invalid connection type: %s", $1);
$$ = make3_str($1, m
ake_str
(":"), $2);
$$ = make3_str($1, m
m_strdup
(":"), $2);
}
}
;
;
...
@@ -138,30 +138,30 @@ opt_server: server { $$ = $1; }
...
@@ -138,30 +138,30 @@ opt_server: server { $$ = $1; }
;
;
server_name: ColId { $$ = $1; }
server_name: ColId { $$ = $1; }
| ColId '.' server_name { $$ = make3_str($1, m
ake_str
("."), $3); }
| ColId '.' server_name { $$ = make3_str($1, m
m_strdup
("."), $3); }
| IP { $$ = make_name(); }
| IP { $$ = make_name(); }
;
;
opt_port: ':' Iconst { $$ = make2_str(m
ake_str
(":"), $2); }
opt_port: ':' Iconst { $$ = make2_str(m
m_strdup
(":"), $2); }
| /*EMPTY*/ { $$ = EMPTY; }
| /*EMPTY*/ { $$ = EMPTY; }
;
;
opt_connection_name: AS connection_object { $$ = $2; }
opt_connection_name: AS connection_object { $$ = $2; }
| /*EMPTY*/ { $$ = m
ake_str
("NULL"); }
| /*EMPTY*/ { $$ = m
m_strdup
("NULL"); }
;
;
opt_user: USER ora_user { $$ = $2; }
opt_user: USER ora_user { $$ = $2; }
| /*EMPTY*/ { $$ = m
ake_str
("NULL, NULL"); }
| /*EMPTY*/ { $$ = m
m_strdup
("NULL, NULL"); }
;
;
ora_user: user_name
ora_user: user_name
{ $$ = cat2_str($1, m
ake_str
(", NULL")); }
{ $$ = cat2_str($1, m
m_strdup
(", NULL")); }
| user_name '/' user_name
| user_name '/' user_name
{ $$ = cat_str(3, $1, m
ake_str
(","), $3); }
{ $$ = cat_str(3, $1, m
m_strdup
(","), $3); }
| user_name SQL_IDENTIFIED BY user_name
| user_name SQL_IDENTIFIED BY user_name
{ $$ = cat_str(3, $1, m
ake_str
(","), $4); }
{ $$ = cat_str(3, $1, m
m_strdup
(","), $4); }
| user_name USING user_name
| user_name USING user_name
{ $$ = cat_str(3, $1, m
ake_str
(","), $3); }
{ $$ = cat_str(3, $1, m
m_strdup
(","), $3); }
;
;
user_name: RoleId
user_name: RoleId
...
@@ -169,14 +169,14 @@ user_name: RoleId
...
@@ -169,14 +169,14 @@ user_name: RoleId
if ($1[0] == '\"')
if ($1[0] == '\"')
$$ = $1;
$$ = $1;
else
else
$$ = make3_str(m
ake_str("\""), $1, make_str
("\""));
$$ = make3_str(m
m_strdup("\""), $1, mm_strdup
("\""));
}
}
| ecpg_sconst
| ecpg_sconst
{
{
if ($1[0] == '\"')
if ($1[0] == '\"')
$$ = $1;
$$ = $1;
else
else
$$ = make3_str(m
ake_str("\""), $1, make_str
("\""));
$$ = make3_str(m
m_strdup("\""), $1, mm_strdup
("\""));
}
}
| civar
| civar
{
{
...
@@ -188,7 +188,7 @@ user_name: RoleId
...
@@ -188,7 +188,7 @@ user_name: RoleId
/* handle varchars */
/* handle varchars */
if (type == ECPGt_varchar)
if (type == ECPGt_varchar)
$$ = make2_str(mm_strdup(argsinsert->variable->name), m
ake_str
(".arr"));
$$ = make2_str(mm_strdup(argsinsert->variable->name), m
m_strdup
(".arr"));
else
else
$$ = mm_strdup(argsinsert->variable->name);
$$ = mm_strdup(argsinsert->variable->name);
}
}
...
@@ -217,7 +217,7 @@ char_variable: cvariable
...
@@ -217,7 +217,7 @@ char_variable: cvariable
$$ = $1;
$$ = $1;
break;
break;
case ECPGt_varchar:
case ECPGt_varchar:
$$ = make2_str($1, m
ake_str
(".arr"));
$$ = make2_str($1, m
m_strdup
(".arr"));
break;
break;
default:
default:
mmerror(PARSE_ERROR, ET_ERROR, "invalid data type");
mmerror(PARSE_ERROR, ET_ERROR, "invalid data type");
...
@@ -236,7 +236,7 @@ opt_options: Op connect_options
...
@@ -236,7 +236,7 @@ opt_options: Op connect_options
if (strcmp($1, "?") != 0)
if (strcmp($1, "?") != 0)
mmerror(PARSE_ERROR, ET_ERROR, "unrecognized token \"%s\"", $1);
mmerror(PARSE_ERROR, ET_ERROR, "unrecognized token \"%s\"", $1);
$$ = make2_str(m
ake_str
("?"), $2);
$$ = make2_str(m
m_strdup
("?"), $2);
}
}
| /*EMPTY*/ { $$ = EMPTY; }
| /*EMPTY*/ { $$ = EMPTY; }
;
;
...
@@ -258,11 +258,11 @@ connect_options: ColId opt_opt_value
...
@@ -258,11 +258,11 @@ connect_options: ColId opt_opt_value
opt_opt_value: /*EMPTY*/
opt_opt_value: /*EMPTY*/
{ $$ = EMPTY; }
{ $$ = EMPTY; }
| '=' Iconst
| '=' Iconst
{ $$ = make2_str(m
ake_str
("="), $2); }
{ $$ = make2_str(m
m_strdup
("="), $2); }
| '=' ecpg_ident
| '=' ecpg_ident
{ $$ = make2_str(m
ake_str
("="), $2); }
{ $$ = make2_str(m
m_strdup
("="), $2); }
| '=' civar
| '=' civar
{ $$ = make2_str(m
ake_str
("="), $2); }
{ $$ = make2_str(m
m_strdup
("="), $2); }
;
;
prepared_name: name {
prepared_name: name {
...
@@ -275,7 +275,7 @@ prepared_name: name {
...
@@ -275,7 +275,7 @@ prepared_name: name {
for (i = 0; i< strlen($1); i++)
for (i = 0; i< strlen($1); i++)
$1[i] = tolower((unsigned char) $1[i]);
$1[i] = tolower((unsigned char) $1[i]);
$$ = make3_str(m
ake_str("\""), $1, make_str
("\""));
$$ = make3_str(m
m_strdup("\""), $1, mm_strdup
("\""));
}
}
}
}
| char_variable { $$ = $1; }
| char_variable { $$ = $1; }
...
@@ -288,7 +288,7 @@ prepared_name: name {
...
@@ -288,7 +288,7 @@ prepared_name: name {
ECPGCursorStmt: DECLARE cursor_name cursor_options CURSOR opt_hold FOR prepared_name
ECPGCursorStmt: DECLARE cursor_name cursor_options CURSOR opt_hold FOR prepared_name
{
{
struct cursor *ptr, *this;
struct cursor *ptr, *this;
char *cursor_marker = $2[0] == ':' ? m
ake_str
("$0") : mm_strdup($2);
char *cursor_marker = $2[0] == ':' ? m
m_strdup
("$0") : mm_strdup($2);
int (* strcmp_fn)(const char *, const char *) = ($2[0] == ':' ? strcmp : pg_strcasecmp);
int (* strcmp_fn)(const char *, const char *) = ($2[0] == ':' ? strcmp : pg_strcasecmp);
struct variable *thisquery = (struct variable *)mm_alloc(sizeof(struct variable));
struct variable *thisquery = (struct variable *)mm_alloc(sizeof(struct variable));
const char *con = connection ? connection : "NULL";
const char *con = connection ? connection : "NULL";
...
@@ -313,7 +313,7 @@ ECPGCursorStmt: DECLARE cursor_name cursor_options CURSOR opt_hold FOR prepared
...
@@ -313,7 +313,7 @@ ECPGCursorStmt: DECLARE cursor_name cursor_options CURSOR opt_hold FOR prepared
this->name = $2;
this->name = $2;
this->function = (current_function ? mm_strdup(current_function) : NULL);
this->function = (current_function ? mm_strdup(current_function) : NULL);
this->connection = connection;
this->connection = connection;
this->command = cat_str(6, m
ake_str("declare"), cursor_marker, $3, make_str("cursor"), $5, make_str
("for $1"));
this->command = cat_str(6, m
m_strdup("declare"), cursor_marker, $3, mm_strdup("cursor"), $5, mm_strdup
("for $1"));
this->argsresult = NULL;
this->argsresult = NULL;
this->argsresult_oos = NULL;
this->argsresult_oos = NULL;
...
@@ -335,11 +335,11 @@ ECPGCursorStmt: DECLARE cursor_name cursor_options CURSOR opt_hold FOR prepared
...
@@ -335,11 +335,11 @@ ECPGCursorStmt: DECLARE cursor_name cursor_options CURSOR opt_hold FOR prepared
cur = this;
cur = this;
comment = cat_str(3, m
ake_str("/*"), mm_strdup(this->command), make_str
("*/"));
comment = cat_str(3, m
m_strdup("/*"), mm_strdup(this->command), mm_strdup
("*/"));
if ((braces_open > 0) && INFORMIX_MODE) /* we're in a function */
if ((braces_open > 0) && INFORMIX_MODE) /* we're in a function */
$$ = cat_str(3, adjust_outofscope_cursor_vars(this),
$$ = cat_str(3, adjust_outofscope_cursor_vars(this),
m
ake_str
("ECPG_informix_reset_sqlca();"),
m
m_strdup
("ECPG_informix_reset_sqlca();"),
comment);
comment);
else
else
$$ = cat2_str(adjust_outofscope_cursor_vars(this), comment);
$$ = cat2_str(adjust_outofscope_cursor_vars(this), comment);
...
@@ -368,10 +368,10 @@ opt_scale: ',' NumericOnly { $$ = $2; }
...
@@ -368,10 +368,10 @@ opt_scale: ',' NumericOnly { $$ = $2; }
;
;
ecpg_interval: opt_interval { $$ = $1; }
ecpg_interval: opt_interval { $$ = $1; }
| YEAR_P TO MINUTE_P { $$ = m
ake_str
("year to minute"); }
| YEAR_P TO MINUTE_P { $$ = m
m_strdup
("year to minute"); }
| YEAR_P TO SECOND_P { $$ = m
ake_str
("year to second"); }
| YEAR_P TO SECOND_P { $$ = m
m_strdup
("year to second"); }
| DAY_P TO DAY_P { $$ = m
ake_str
("day to day"); }
| DAY_P TO DAY_P { $$ = m
m_strdup
("day to day"); }
| MONTH_P TO MONTH_P { $$ = m
ake_str
("month to month"); }
| MONTH_P TO MONTH_P { $$ = m
m_strdup
("month to month"); }
;
;
/*
/*
...
@@ -417,7 +417,7 @@ type_declaration: S_TYPEDEF
...
@@ -417,7 +417,7 @@ type_declaration: S_TYPEDEF
fprintf(yyout, "typedef %s %s %s %s;\n", $3.type_str, *$4 ? "*" : "", $5, $6.str);
fprintf(yyout, "typedef %s %s %s %s;\n", $3.type_str, *$4 ? "*" : "", $5, $6.str);
output_line_number();
output_line_number();
$$ = m
ake_str
("");
$$ = m
m_strdup
("");
};
};
var_declaration: storage_declaration
var_declaration: storage_declaration
...
@@ -433,7 +433,7 @@ var_declaration: storage_declaration
...
@@ -433,7 +433,7 @@ var_declaration: storage_declaration
}
}
variable_list ';'
variable_list ';'
{
{
$$ = cat_str(5, actual_startline[struct_level], $1, $2.type_str, $4, m
ake_str
(";\n"));
$$ = cat_str(5, actual_startline[struct_level], $1, $2.type_str, $4, m
m_strdup
(";\n"));
}
}
| var_type
| var_type
{
{
...
@@ -447,15 +447,15 @@ var_declaration: storage_declaration
...
@@ -447,15 +447,15 @@ var_declaration: storage_declaration
}
}
variable_list ';'
variable_list ';'
{
{
$$ = cat_str(4, actual_startline[struct_level], $1.type_str, $3, m
ake_str
(";\n"));
$$ = cat_str(4, actual_startline[struct_level], $1.type_str, $3, m
m_strdup
(";\n"));
}
}
| struct_union_type_with_symbol ';'
| struct_union_type_with_symbol ';'
{
{
$$ = cat2_str($1, m
ake_str
(";"));
$$ = cat2_str($1, m
m_strdup
(";"));
}
}
;
;
opt_bit_field: ':' Iconst { $$ =cat2_str(m
ake_str
(":"), $2); }
opt_bit_field: ':' Iconst { $$ =cat2_str(m
m_strdup
(":"), $2); }
| /* EMPTY */ { $$ = EMPTY; }
| /* EMPTY */ { $$ = EMPTY; }
;
;
...
@@ -465,29 +465,29 @@ storage_declaration: storage_clause storage_modifier
...
@@ -465,29 +465,29 @@ storage_declaration: storage_clause storage_modifier
| storage_modifier {$$ = $1; }
| storage_modifier {$$ = $1; }
;
;
storage_clause : S_EXTERN { $$ = m
ake_str
("extern"); }
storage_clause : S_EXTERN { $$ = m
m_strdup
("extern"); }
| S_STATIC { $$ = m
ake_str
("static"); }
| S_STATIC { $$ = m
m_strdup
("static"); }
| S_REGISTER { $$ = m
ake_str
("register"); }
| S_REGISTER { $$ = m
m_strdup
("register"); }
| S_AUTO { $$ = m
ake_str
("auto"); }
| S_AUTO { $$ = m
m_strdup
("auto"); }
;
;
storage_modifier : S_CONST { $$ = m
ake_str
("const"); }
storage_modifier : S_CONST { $$ = m
m_strdup
("const"); }
| S_VOLATILE { $$ = m
ake_str
("volatile"); }
| S_VOLATILE { $$ = m
m_strdup
("volatile"); }
;
;
var_type: simple_type
var_type: simple_type
{
{
$$.type_enum = $1;
$$.type_enum = $1;
$$.type_str = mm_strdup(ecpg_type_name($1));
$$.type_str = mm_strdup(ecpg_type_name($1));
$$.type_dimension = m
ake_str
("-1");
$$.type_dimension = m
m_strdup
("-1");
$$.type_index = m
ake_str
("-1");
$$.type_index = m
m_strdup
("-1");
$$.type_sizeof = NULL;
$$.type_sizeof = NULL;
}
}
| struct_union_type
| struct_union_type
{
{
$$.type_str = $1;
$$.type_str = $1;
$$.type_dimension = m
ake_str
("-1");
$$.type_dimension = m
m_strdup
("-1");
$$.type_index = m
ake_str
("-1");
$$.type_index = m
m_strdup
("-1");
if (strncmp($1, "struct", sizeof("struct")-1) == 0)
if (strncmp($1, "struct", sizeof("struct")-1) == 0)
{
{
...
@@ -504,8 +504,8 @@ var_type: simple_type
...
@@ -504,8 +504,8 @@ var_type: simple_type
{
{
$$.type_str = $1;
$$.type_str = $1;
$$.type_enum = ECPGt_int;
$$.type_enum = ECPGt_int;
$$.type_dimension = m
ake_str
("-1");
$$.type_dimension = m
m_strdup
("-1");
$$.type_index = m
ake_str
("-1");
$$.type_index = m
m_strdup
("-1");
$$.type_sizeof = NULL;
$$.type_sizeof = NULL;
}
}
| ECPGColLabelCommon '(' precision opt_scale ')'
| ECPGColLabelCommon '(' precision opt_scale ')'
...
@@ -513,22 +513,22 @@ var_type: simple_type
...
@@ -513,22 +513,22 @@ var_type: simple_type
if (strcmp($1, "numeric") == 0)
if (strcmp($1, "numeric") == 0)
{
{
$$.type_enum = ECPGt_numeric;
$$.type_enum = ECPGt_numeric;
$$.type_str = m
ake_str
("numeric");
$$.type_str = m
m_strdup
("numeric");
}
}
else if (strcmp($1, "decimal") == 0)
else if (strcmp($1, "decimal") == 0)
{
{
$$.type_enum = ECPGt_decimal;
$$.type_enum = ECPGt_decimal;
$$.type_str = m
ake_str
("decimal");
$$.type_str = m
m_strdup
("decimal");
}
}
else
else
{
{
mmerror(PARSE_ERROR, ET_ERROR, "only data types numeric and decimal have precision/scale argument");
mmerror(PARSE_ERROR, ET_ERROR, "only data types numeric and decimal have precision/scale argument");
$$.type_enum = ECPGt_numeric;
$$.type_enum = ECPGt_numeric;
$$.type_str = m
ake_str
("numeric");
$$.type_str = m
m_strdup
("numeric");
}
}
$$.type_dimension = m
ake_str
("-1");
$$.type_dimension = m
m_strdup
("-1");
$$.type_index = m
ake_str
("-1");
$$.type_index = m
m_strdup
("-1");
$$.type_sizeof = NULL;
$$.type_sizeof = NULL;
}
}
| ECPGColLabelCommon ecpg_interval
| ECPGColLabelCommon ecpg_interval
...
@@ -543,81 +543,81 @@ var_type: simple_type
...
@@ -543,81 +543,81 @@ var_type: simple_type
if (strcmp($1, "varchar") == 0)
if (strcmp($1, "varchar") == 0)
{
{
$$.type_enum = ECPGt_varchar;
$$.type_enum = ECPGt_varchar;
$$.type_str = EMPTY; /*m
ake_str
("varchar");*/
$$.type_str = EMPTY; /*m
m_strdup
("varchar");*/
$$.type_dimension = m
ake_str
("-1");
$$.type_dimension = m
m_strdup
("-1");
$$.type_index = m
ake_str
("-1");
$$.type_index = m
m_strdup
("-1");
$$.type_sizeof = NULL;
$$.type_sizeof = NULL;
}
}
else if (strcmp($1, "float") == 0)
else if (strcmp($1, "float") == 0)
{
{
$$.type_enum = ECPGt_float;
$$.type_enum = ECPGt_float;
$$.type_str = m
ake_str
("float");
$$.type_str = m
m_strdup
("float");
$$.type_dimension = m
ake_str
("-1");
$$.type_dimension = m
m_strdup
("-1");
$$.type_index = m
ake_str
("-1");
$$.type_index = m
m_strdup
("-1");
$$.type_sizeof = NULL;
$$.type_sizeof = NULL;
}
}
else if (strcmp($1, "double") == 0)
else if (strcmp($1, "double") == 0)
{
{
$$.type_enum = ECPGt_double;
$$.type_enum = ECPGt_double;
$$.type_str = m
ake_str
("double");
$$.type_str = m
m_strdup
("double");
$$.type_dimension = m
ake_str
("-1");
$$.type_dimension = m
m_strdup
("-1");
$$.type_index = m
ake_str
("-1");
$$.type_index = m
m_strdup
("-1");
$$.type_sizeof = NULL;
$$.type_sizeof = NULL;
}
}
else if (strcmp($1, "numeric") == 0)
else if (strcmp($1, "numeric") == 0)
{
{
$$.type_enum = ECPGt_numeric;
$$.type_enum = ECPGt_numeric;
$$.type_str = m
ake_str
("numeric");
$$.type_str = m
m_strdup
("numeric");
$$.type_dimension = m
ake_str
("-1");
$$.type_dimension = m
m_strdup
("-1");
$$.type_index = m
ake_str
("-1");
$$.type_index = m
m_strdup
("-1");
$$.type_sizeof = NULL;
$$.type_sizeof = NULL;
}
}
else if (strcmp($1, "decimal") == 0)
else if (strcmp($1, "decimal") == 0)
{
{
$$.type_enum = ECPGt_decimal;
$$.type_enum = ECPGt_decimal;
$$.type_str = m
ake_str
("decimal");
$$.type_str = m
m_strdup
("decimal");
$$.type_dimension = m
ake_str
("-1");
$$.type_dimension = m
m_strdup
("-1");
$$.type_index = m
ake_str
("-1");
$$.type_index = m
m_strdup
("-1");
$$.type_sizeof = NULL;
$$.type_sizeof = NULL;
}
}
else if (strcmp($1, "date") == 0)
else if (strcmp($1, "date") == 0)
{
{
$$.type_enum = ECPGt_date;
$$.type_enum = ECPGt_date;
$$.type_str = m
ake_str
("date");
$$.type_str = m
m_strdup
("date");
$$.type_dimension = m
ake_str
("-1");
$$.type_dimension = m
m_strdup
("-1");
$$.type_index = m
ake_str
("-1");
$$.type_index = m
m_strdup
("-1");
$$.type_sizeof = NULL;
$$.type_sizeof = NULL;
}
}
else if (strcmp($1, "timestamp") == 0)
else if (strcmp($1, "timestamp") == 0)
{
{
$$.type_enum = ECPGt_timestamp;
$$.type_enum = ECPGt_timestamp;
$$.type_str = m
ake_str
("timestamp");
$$.type_str = m
m_strdup
("timestamp");
$$.type_dimension = m
ake_str
("-1");
$$.type_dimension = m
m_strdup
("-1");
$$.type_index = m
ake_str
("-1");
$$.type_index = m
m_strdup
("-1");
$$.type_sizeof = NULL;
$$.type_sizeof = NULL;
}
}
else if (strcmp($1, "interval") == 0)
else if (strcmp($1, "interval") == 0)
{
{
$$.type_enum = ECPGt_interval;
$$.type_enum = ECPGt_interval;
$$.type_str = m
ake_str
("interval");
$$.type_str = m
m_strdup
("interval");
$$.type_dimension = m
ake_str
("-1");
$$.type_dimension = m
m_strdup
("-1");
$$.type_index = m
ake_str
("-1");
$$.type_index = m
m_strdup
("-1");
$$.type_sizeof = NULL;
$$.type_sizeof = NULL;
}
}
else if (strcmp($1, "datetime") == 0)
else if (strcmp($1, "datetime") == 0)
{
{
$$.type_enum = ECPGt_timestamp;
$$.type_enum = ECPGt_timestamp;
$$.type_str = m
ake_str
("timestamp");
$$.type_str = m
m_strdup
("timestamp");
$$.type_dimension = m
ake_str
("-1");
$$.type_dimension = m
m_strdup
("-1");
$$.type_index = m
ake_str
("-1");
$$.type_index = m
m_strdup
("-1");
$$.type_sizeof = NULL;
$$.type_sizeof = NULL;
}
}
else if ((strcmp($1, "string") == 0) && INFORMIX_MODE)
else if ((strcmp($1, "string") == 0) && INFORMIX_MODE)
{
{
$$.type_enum = ECPGt_string;
$$.type_enum = ECPGt_string;
$$.type_str = m
ake_str
("char");
$$.type_str = m
m_strdup
("char");
$$.type_dimension = m
ake_str
("-1");
$$.type_dimension = m
m_strdup
("-1");
$$.type_index = m
ake_str
("-1");
$$.type_index = m
m_strdup
("-1");
$$.type_sizeof = NULL;
$$.type_sizeof = NULL;
}
}
else
else
...
@@ -632,7 +632,7 @@ var_type: simple_type
...
@@ -632,7 +632,7 @@ var_type: simple_type
if (this->type->type_sizeof && strlen(this->type->type_sizeof) != 0)
if (this->type->type_sizeof && strlen(this->type->type_sizeof) != 0)
$$.type_sizeof = this->type->type_sizeof;
$$.type_sizeof = this->type->type_sizeof;
else
else
$$.type_sizeof = cat_str(3, m
ake_str("sizeof("), mm_strdup(this->name), make_str
(")"));
$$.type_sizeof = cat_str(3, m
m_strdup("sizeof("), mm_strdup(this->name), mm_strdup
(")"));
struct_member_list[struct_level] = ECPGstruct_member_dup(this->struct_member_list);
struct_member_list[struct_level] = ECPGstruct_member_dup(this->struct_member_list);
}
}
...
@@ -663,24 +663,24 @@ var_type: simple_type
...
@@ -663,24 +663,24 @@ var_type: simple_type
{
{
$$.type_str = name;
$$.type_str = name;
$$.type_enum = ECPGt_long;
$$.type_enum = ECPGt_long;
$$.type_dimension = m
ake_str
("-1");
$$.type_dimension = m
m_strdup
("-1");
$$.type_index = m
ake_str
("-1");
$$.type_index = m
m_strdup
("-1");
$$.type_sizeof = m
ake_str
("");
$$.type_sizeof = m
m_strdup
("");
struct_member_list[struct_level] = NULL;
struct_member_list[struct_level] = NULL;
}
}
}
}
;
;
enum_type: ENUM_P symbol enum_definition
enum_type: ENUM_P symbol enum_definition
{ $$ = cat_str(3, m
ake_str
("enum"), $2, $3); }
{ $$ = cat_str(3, m
m_strdup
("enum"), $2, $3); }
| ENUM_P enum_definition
| ENUM_P enum_definition
{ $$ = cat2_str(m
ake_str
("enum"), $2); }
{ $$ = cat2_str(m
m_strdup
("enum"), $2); }
| ENUM_P symbol
| ENUM_P symbol
{ $$ = cat2_str(m
ake_str
("enum"), $2); }
{ $$ = cat2_str(m
m_strdup
("enum"), $2); }
;
;
enum_definition: '{' c_list '}'
enum_definition: '{' c_list '}'
{ $$ = cat_str(3, m
ake_str("{"), $2, make_str
("}")); };
{ $$ = cat_str(3, m
m_strdup("{"), $2, mm_strdup
("}")); };
struct_union_type_with_symbol: s_struct_union_symbol
struct_union_type_with_symbol: s_struct_union_symbol
{
{
...
@@ -723,13 +723,13 @@ struct_union_type_with_symbol: s_struct_union_symbol
...
@@ -723,13 +723,13 @@ struct_union_type_with_symbol: s_struct_union_symbol
this->type = (struct this_type *) mm_alloc(sizeof(struct this_type));
this->type = (struct this_type *) mm_alloc(sizeof(struct this_type));
this->type->type_enum = su_type.type_enum;
this->type->type_enum = su_type.type_enum;
this->type->type_str = mm_strdup(su_type.type_str);
this->type->type_str = mm_strdup(su_type.type_str);
this->type->type_dimension = m
ake_str
("-1"); /* dimension of array */
this->type->type_dimension = m
m_strdup
("-1"); /* dimension of array */
this->type->type_index = m
ake_str
("-1"); /* length of string */
this->type->type_index = m
m_strdup
("-1"); /* length of string */
this->type->type_sizeof = ECPGstruct_sizeof;
this->type->type_sizeof = ECPGstruct_sizeof;
this->struct_member_list = struct_member_list[struct_level];
this->struct_member_list = struct_member_list[struct_level];
types = this;
types = this;
$$ = cat_str(4, su_type.type_str, m
ake_str("{"), $4, make_str
("}"));
$$ = cat_str(4, su_type.type_str, m
m_strdup("{"), $4, mm_strdup
("}"));
}
}
;
;
...
@@ -745,29 +745,29 @@ struct_union_type: struct_union_type_with_symbol { $$ = $1; }
...
@@ -745,29 +745,29 @@ struct_union_type: struct_union_type_with_symbol { $$ = $1; }
ECPGfree_struct_member(struct_member_list[struct_level]);
ECPGfree_struct_member(struct_member_list[struct_level]);
struct_member_list[struct_level] = NULL;
struct_member_list[struct_level] = NULL;
struct_level--;
struct_level--;
$$ = cat_str(4, $1, m
ake_str("{"), $4, make_str
("}"));
$$ = cat_str(4, $1, m
m_strdup("{"), $4, mm_strdup
("}"));
}
}
;
;
s_struct_union_symbol: SQL_STRUCT symbol
s_struct_union_symbol: SQL_STRUCT symbol
{
{
$$.su = m
ake_str
("struct");
$$.su = m
m_strdup
("struct");
$$.symbol = $2;
$$.symbol = $2;
ECPGstruct_sizeof = cat_str(3, m
ake_str("sizeof("), cat2_str(mm_strdup($$.su), mm_strdup($$.symbol)), make_str
(")"));
ECPGstruct_sizeof = cat_str(3, m
m_strdup("sizeof("), cat2_str(mm_strdup($$.su), mm_strdup($$.symbol)), mm_strdup
(")"));
}
}
| UNION symbol
| UNION symbol
{
{
$$.su = m
ake_str
("union");
$$.su = m
m_strdup
("union");
$$.symbol = $2;
$$.symbol = $2;
}
}
;
;
s_struct_union: SQL_STRUCT
s_struct_union: SQL_STRUCT
{
{
ECPGstruct_sizeof = m
ake_str
(""); /* This must not be NULL to distinguish from simple types. */
ECPGstruct_sizeof = m
m_strdup
(""); /* This must not be NULL to distinguish from simple types. */
$$ = m
ake_str
("struct");
$$ = m
m_strdup
("struct");
}
}
| UNION { $$ = m
ake_str
("union"); }
| UNION { $$ = m
m_strdup
("union"); }
;
;
simple_type: unsigned_type { $$=$1; }
simple_type: unsigned_type { $$=$1; }
...
@@ -832,7 +832,7 @@ opt_signed: SQL_SIGNED
...
@@ -832,7 +832,7 @@ opt_signed: SQL_SIGNED
variable_list: variable
variable_list: variable
{ $$ = $1; }
{ $$ = $1; }
| variable_list ',' variable
| variable_list ',' variable
{ $$ = cat_str(3, $1, m
ake_str
(","), $3); }
{ $$ = cat_str(3, $1, m
m_strdup
(","), $3); }
;
;
variable: opt_pointer ECPGColLabel opt_array_bounds opt_bit_field opt_initializer
variable: opt_pointer ECPGColLabel opt_array_bounds opt_bit_field opt_initializer
...
@@ -864,9 +864,9 @@ variable: opt_pointer ECPGColLabel opt_array_bounds opt_bit_field opt_initialize
...
@@ -864,9 +864,9 @@ variable: opt_pointer ECPGColLabel opt_array_bounds opt_bit_field opt_initialize
type = ECPGmake_array_type(ECPGmake_simple_type(actual_type[struct_level].type_enum, length, varchar_counter), dimension);
type = ECPGmake_array_type(ECPGmake_simple_type(actual_type[struct_level].type_enum, length, varchar_counter), dimension);
if (strcmp(dimension, "0") == 0 || abs(atoi(dimension)) == 1)
if (strcmp(dimension, "0") == 0 || abs(atoi(dimension)) == 1)
dim_str=m
ake_str
("");
dim_str=m
m_strdup
("");
else
else
dim_str=cat_str(3, m
ake_str("["), mm_strdup(dimension), make_str
("]"));
dim_str=cat_str(3, m
m_strdup("["), mm_strdup(dimension), mm_strdup
("]"));
/* cannot check for atoi <= 0 because a defined constant will yield 0 here as well */
/* cannot check for atoi <= 0 because a defined constant will yield 0 here as well */
if (atoi(length) < 0 || strcmp(length, "0") == 0)
if (atoi(length) < 0 || strcmp(length, "0") == 0)
mmerror(PARSE_ERROR, ET_ERROR, "pointers to varchar are not implemented");
mmerror(PARSE_ERROR, ET_ERROR, "pointers to varchar are not implemented");
...
@@ -875,9 +875,9 @@ variable: opt_pointer ECPGColLabel opt_array_bounds opt_bit_field opt_initialize
...
@@ -875,9 +875,9 @@ variable: opt_pointer ECPGColLabel opt_array_bounds opt_bit_field opt_initialize
vcn = (char *) mm_alloc(strlen($2) + sizeof(int) * CHAR_BIT * 10 / 3);
vcn = (char *) mm_alloc(strlen($2) + sizeof(int) * CHAR_BIT * 10 / 3);
sprintf(vcn, "%s_%d", $2, varchar_counter);
sprintf(vcn, "%s_%d", $2, varchar_counter);
if (strcmp(dimension, "0") == 0)
if (strcmp(dimension, "0") == 0)
$$ = cat_str(7, make2_str(m
ake_str(" struct varchar_"), vcn), make_str(" { int len; char arr["), mm_strdup(length), make_str
("]; } *"), mm_strdup($2), $4, $5);
$$ = cat_str(7, make2_str(m
m_strdup(" struct varchar_"), vcn), mm_strdup(" { int len; char arr["), mm_strdup(length), mm_strdup
("]; } *"), mm_strdup($2), $4, $5);
else
else
$$ = cat_str(8, make2_str(m
ake_str(" struct varchar_"), vcn), make_str(" { int len; char arr["), mm_strdup(length), make_str
("]; } "), mm_strdup($2), dim_str, $4, $5);
$$ = cat_str(8, make2_str(m
m_strdup(" struct varchar_"), vcn), mm_strdup(" { int len; char arr["), mm_strdup(length), mm_strdup
("]; } "), mm_strdup($2), dim_str, $4, $5);
varchar_counter++;
varchar_counter++;
break;
break;
...
@@ -905,9 +905,9 @@ variable: opt_pointer ECPGColLabel opt_array_bounds opt_bit_field opt_initialize
...
@@ -905,9 +905,9 @@ variable: opt_pointer ECPGColLabel opt_array_bounds opt_bit_field opt_initialize
default:
default:
if (atoi(dimension) < 0)
if (atoi(dimension) < 0)
type = ECPGmake_simple_type(actual_type[struct_level].type_enum, m
ake_str
("1"), 0);
type = ECPGmake_simple_type(actual_type[struct_level].type_enum, m
m_strdup
("1"), 0);
else
else
type = ECPGmake_array_type(ECPGmake_simple_type(actual_type[struct_level].type_enum, m
ake_str
("1"), 0), dimension);
type = ECPGmake_array_type(ECPGmake_simple_type(actual_type[struct_level].type_enum, m
m_strdup
("1"), 0), dimension);
$$ = cat_str(5, $1, mm_strdup($2), $3.str, $4, $5);
$$ = cat_str(5, $1, mm_strdup($2), $3.str, $4, $5);
break;
break;
...
@@ -927,13 +927,13 @@ opt_initializer: /*EMPTY*/
...
@@ -927,13 +927,13 @@ opt_initializer: /*EMPTY*/
| '=' c_term
| '=' c_term
{
{
initializer = 1;
initializer = 1;
$$ = cat2_str(m
ake_str
("="), $2);
$$ = cat2_str(m
m_strdup
("="), $2);
}
}
;
;
opt_pointer: /*EMPTY*/ { $$ = EMPTY; }
opt_pointer: /*EMPTY*/ { $$ = EMPTY; }
| '*' { $$ = m
ake_str
("*"); }
| '*' { $$ = m
m_strdup
("*"); }
| '*' '*' { $$ = m
ake_str
("**"); }
| '*' '*' { $$ = m
m_strdup
("**"); }
;
;
/*
/*
...
@@ -942,7 +942,7 @@ opt_pointer: /*EMPTY*/ { $$ = EMPTY; }
...
@@ -942,7 +942,7 @@ opt_pointer: /*EMPTY*/ { $$ = EMPTY; }
ECPGDeclare: DECLARE STATEMENT ecpg_ident
ECPGDeclare: DECLARE STATEMENT ecpg_ident
{
{
/* this is only supported for compatibility */
/* this is only supported for compatibility */
$$ = cat_str(3, m
ake_str("/* declare statement"), $3, make_str
("*/"));
$$ = cat_str(3, m
m_strdup("/* declare statement"), $3, mm_strdup
("*/"));
}
}
;
;
/*
/*
...
@@ -952,20 +952,20 @@ ECPGDisconnect: SQL_DISCONNECT dis_name { $$ = $2; }
...
@@ -952,20 +952,20 @@ ECPGDisconnect: SQL_DISCONNECT dis_name { $$ = $2; }
;
;
dis_name: connection_object { $$ = $1; }
dis_name: connection_object { $$ = $1; }
| CURRENT_P { $$ = m
ake_str
("\"CURRENT\""); }
| CURRENT_P { $$ = m
m_strdup
("\"CURRENT\""); }
| ALL { $$ = m
ake_str
("\"ALL\""); }
| ALL { $$ = m
m_strdup
("\"ALL\""); }
| /* EMPTY */ { $$ = m
ake_str
("\"CURRENT\""); }
| /* EMPTY */ { $$ = m
m_strdup
("\"CURRENT\""); }
;
;
connection_object: database_name { $$ = make3_str(m
ake_str("\""), $1, make_str
("\"")); }
connection_object: database_name { $$ = make3_str(m
m_strdup("\""), $1, mm_strdup
("\"")); }
| DEFAULT { $$ = m
ake_str
("\"DEFAULT\""); }
| DEFAULT { $$ = m
m_strdup
("\"DEFAULT\""); }
| char_variable { $$ = $1; }
| char_variable { $$ = $1; }
;
;
execstring: char_variable
execstring: char_variable
{ $$ = $1; }
{ $$ = $1; }
| CSTRING
| CSTRING
{ $$ = make3_str(m
ake_str("\""), $1, make_str
("\"")); }
{ $$ = make3_str(m
m_strdup("\""), $1, mm_strdup
("\"")); }
;
;
/*
/*
...
@@ -973,7 +973,7 @@ execstring: char_variable
...
@@ -973,7 +973,7 @@ execstring: char_variable
* prepared statement
* prepared statement
*/
*/
ECPGFree: SQL_FREE cursor_name { $$ = $2; }
ECPGFree: SQL_FREE cursor_name { $$ = $2; }
| SQL_FREE ALL { $$ = m
ake_str
("all"); }
| SQL_FREE ALL { $$ = m
m_strdup
("all"); }
;
;
/*
/*
...
@@ -1040,11 +1040,11 @@ UsingValue: UsingConst
...
@@ -1040,11 +1040,11 @@ UsingValue: UsingConst
;
;
UsingConst: Iconst { $$ = $1; }
UsingConst: Iconst { $$ = $1; }
| '+' Iconst { $$ = cat_str(2, m
ake_str
("+"), $2); }
| '+' Iconst { $$ = cat_str(2, m
m_strdup
("+"), $2); }
| '-' Iconst { $$ = cat_str(2, m
ake_str
("-"), $2); }
| '-' Iconst { $$ = cat_str(2, m
m_strdup
("-"), $2); }
| ecpg_fconst { $$ = $1; }
| ecpg_fconst { $$ = $1; }
| '+' ecpg_fconst { $$ = cat_str(2, m
ake_str
("+"), $2); }
| '+' ecpg_fconst { $$ = cat_str(2, m
m_strdup
("+"), $2); }
| '-' ecpg_fconst { $$ = cat_str(2, m
ake_str
("-"), $2); }
| '-' ecpg_fconst { $$ = cat_str(2, m
m_strdup
("-"), $2); }
| ecpg_sconst { $$ = $1; }
| ecpg_sconst { $$ = $1; }
| ecpg_bconst { $$ = $1; }
| ecpg_bconst { $$ = $1; }
| ecpg_xconst { $$ = $1; }
| ecpg_xconst { $$ = $1; }
...
@@ -1093,7 +1093,7 @@ ECPGDescribe: SQL_DESCRIBE INPUT_P prepared_name using_descriptor
...
@@ -1093,7 +1093,7 @@ ECPGDescribe: SQL_DESCRIBE INPUT_P prepared_name using_descriptor
}
}
;
;
opt_output: SQL_OUTPUT { $$ = m
ake_str
("output"); }
opt_output: SQL_OUTPUT { $$ = m
m_strdup
("output"); }
| /* EMPTY */ { $$ = EMPTY; }
| /* EMPTY */ { $$ = EMPTY; }
;
;
...
@@ -1210,7 +1210,7 @@ AllConstVar: ecpg_fconst
...
@@ -1210,7 +1210,7 @@ AllConstVar: ecpg_fconst
| '-' ecpg_fconst
| '-' ecpg_fconst
{
{
char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
char *var = cat2_str(m
ake_str
("-"), $2);
char *var = cat2_str(m
m_strdup
("-"), $2);
sprintf(length, "%d", (int) strlen(var));
sprintf(length, "%d", (int) strlen(var));
new_variable(var, ECPGmake_simple_type(ECPGt_const, length, 0), 0);
new_variable(var, ECPGmake_simple_type(ECPGt_const, length, 0), 0);
...
@@ -1219,7 +1219,7 @@ AllConstVar: ecpg_fconst
...
@@ -1219,7 +1219,7 @@ AllConstVar: ecpg_fconst
| '-' Iconst
| '-' Iconst
{
{
char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
char *var = cat2_str(m
ake_str
("-"), $2);
char *var = cat2_str(m
m_strdup
("-"), $2);
sprintf(length, "%d", (int) strlen(var));
sprintf(length, "%d", (int) strlen(var));
new_variable(var, ECPGmake_simple_type(ECPGt_const, length, 0), 0);
new_variable(var, ECPGmake_simple_type(ECPGt_const, length, 0), 0);
...
@@ -1262,8 +1262,8 @@ ECPGSetAutocommit: SET SQL_AUTOCOMMIT '=' on_off { $$ = $4; }
...
@@ -1262,8 +1262,8 @@ ECPGSetAutocommit: SET SQL_AUTOCOMMIT '=' on_off { $$ = $4; }
| SET SQL_AUTOCOMMIT TO on_off { $$ = $4; }
| SET SQL_AUTOCOMMIT TO on_off { $$ = $4; }
;
;
on_off: ON { $$ = m
ake_str
("on"); }
on_off: ON { $$ = m
m_strdup
("on"); }
| OFF { $$ = m
ake_str
("off"); }
| OFF { $$ = m
m_strdup
("off"); }
;
;
/*
/*
...
@@ -1289,13 +1289,13 @@ ECPGTypedef: TYPE_P
...
@@ -1289,13 +1289,13 @@ ECPGTypedef: TYPE_P
add_typedef($3, $6.index1, $6.index2, $5.type_enum, $5.type_dimension, $5.type_index, initializer, *$7 ? 1 : 0);
add_typedef($3, $6.index1, $6.index2, $5.type_enum, $5.type_dimension, $5.type_index, initializer, *$7 ? 1 : 0);
if (auto_create_c == false)
if (auto_create_c == false)
$$ = cat_str(7, m
ake_str("/* exec sql type"), mm_strdup($3), make_str("is"), mm_strdup($5.type_str), mm_strdup($6.str), $7, make_str
("*/"));
$$ = cat_str(7, m
m_strdup("/* exec sql type"), mm_strdup($3), mm_strdup("is"), mm_strdup($5.type_str), mm_strdup($6.str), $7, mm_strdup
("*/"));
else
else
$$ = cat_str(6, m
ake_str("typedef "), mm_strdup($5.type_str), *$7?make_str("*"):make_str(""), mm_strdup($6.str), mm_strdup($3), make_str
(";"));
$$ = cat_str(6, m
m_strdup("typedef "), mm_strdup($5.type_str), *$7?mm_strdup("*"):mm_strdup(""), mm_strdup($6.str), mm_strdup($3), mm_strdup
(";"));
}
}
;
;
opt_reference: SQL_REFERENCE { $$ = m
ake_str
("reference"); }
opt_reference: SQL_REFERENCE { $$ = m
m_strdup
("reference"); }
| /*EMPTY*/ { $$ = EMPTY; }
| /*EMPTY*/ { $$ = EMPTY; }
;
;
...
@@ -1354,9 +1354,9 @@ ECPGVar: SQL_VAR
...
@@ -1354,9 +1354,9 @@ ECPGVar: SQL_VAR
mmerror(PARSE_ERROR, ET_ERROR, "multidimensional arrays for simple data types are not supported");
mmerror(PARSE_ERROR, ET_ERROR, "multidimensional arrays for simple data types are not supported");
if (atoi(dimension) < 0)
if (atoi(dimension) < 0)
type = ECPGmake_simple_type($5.type_enum, m
ake_str
("1"), 0);
type = ECPGmake_simple_type($5.type_enum, m
m_strdup
("1"), 0);
else
else
type = ECPGmake_array_type(ECPGmake_simple_type($5.type_enum, m
ake_str
("1"), 0), dimension);
type = ECPGmake_array_type(ECPGmake_simple_type($5.type_enum, m
m_strdup
("1"), 0), dimension);
break;
break;
}
}
...
@@ -1364,7 +1364,7 @@ ECPGVar: SQL_VAR
...
@@ -1364,7 +1364,7 @@ ECPGVar: SQL_VAR
p->type = type;
p->type = type;
}
}
$$ = cat_str(7, m
ake_str("/* exec sql var"), mm_strdup($3), make_str("is"), mm_strdup($5.type_str), mm_strdup($6.str), $7, make_str
("*/"));
$$ = cat_str(7, m
m_strdup("/* exec sql var"), mm_strdup($3), mm_strdup("is"), mm_strdup($5.type_str), mm_strdup($6.str), $7, mm_strdup
("*/"));
}
}
;
;
...
@@ -1376,19 +1376,19 @@ ECPGWhenever: SQL_WHENEVER SQL_SQLERROR action
...
@@ -1376,19 +1376,19 @@ ECPGWhenever: SQL_WHENEVER SQL_SQLERROR action
{
{
when_error.code = $<action>3.code;
when_error.code = $<action>3.code;
when_error.command = $<action>3.command;
when_error.command = $<action>3.command;
$$ = cat_str(3, m
ake_str("/* exec sql whenever sqlerror "), $3.str, make_str
("; */"));
$$ = cat_str(3, m
m_strdup("/* exec sql whenever sqlerror "), $3.str, mm_strdup
("; */"));
}
}
| SQL_WHENEVER NOT SQL_FOUND action
| SQL_WHENEVER NOT SQL_FOUND action
{
{
when_nf.code = $<action>4.code;
when_nf.code = $<action>4.code;
when_nf.command = $<action>4.command;
when_nf.command = $<action>4.command;
$$ = cat_str(3, m
ake_str("/* exec sql whenever not found "), $4.str, make_str
("; */"));
$$ = cat_str(3, m
m_strdup("/* exec sql whenever not found "), $4.str, mm_strdup
("; */"));
}
}
| SQL_WHENEVER SQL_SQLWARNING action
| SQL_WHENEVER SQL_SQLWARNING action
{
{
when_warn.code = $<action>3.code;
when_warn.code = $<action>3.code;
when_warn.command = $<action>3.command;
when_warn.command = $<action>3.command;
$$ = cat_str(3, m
ake_str("/* exec sql whenever sql_warning "), $3.str, make_str
("; */"));
$$ = cat_str(3, m
m_strdup("/* exec sql whenever sql_warning "), $3.str, mm_strdup
("; */"));
}
}
;
;
...
@@ -1396,55 +1396,55 @@ action : CONTINUE_P
...
@@ -1396,55 +1396,55 @@ action : CONTINUE_P
{
{
$<action>$.code = W_NOTHING;
$<action>$.code = W_NOTHING;
$<action>$.command = NULL;
$<action>$.command = NULL;
$<action>$.str = m
ake_str
("continue");
$<action>$.str = m
m_strdup
("continue");
}
}
| SQL_SQLPRINT
| SQL_SQLPRINT
{
{
$<action>$.code = W_SQLPRINT;
$<action>$.code = W_SQLPRINT;
$<action>$.command = NULL;
$<action>$.command = NULL;
$<action>$.str = m
ake_str
("sqlprint");
$<action>$.str = m
m_strdup
("sqlprint");
}
}
| SQL_STOP
| SQL_STOP
{
{
$<action>$.code = W_STOP;
$<action>$.code = W_STOP;
$<action>$.command = NULL;
$<action>$.command = NULL;
$<action>$.str = m
ake_str
("stop");
$<action>$.str = m
m_strdup
("stop");
}
}
| SQL_GOTO name
| SQL_GOTO name
{
{
$<action>$.code = W_GOTO;
$<action>$.code = W_GOTO;
$<action>$.command = strdup($2);
$<action>$.command = strdup($2);
$<action>$.str = cat2_str(m
ake_str
("goto "), $2);
$<action>$.str = cat2_str(m
m_strdup
("goto "), $2);
}
}
| SQL_GO TO name
| SQL_GO TO name
{
{
$<action>$.code = W_GOTO;
$<action>$.code = W_GOTO;
$<action>$.command = strdup($3);
$<action>$.command = strdup($3);
$<action>$.str = cat2_str(m
ake_str
("goto "), $3);
$<action>$.str = cat2_str(m
m_strdup
("goto "), $3);
}
}
| DO name '(' c_args ')'
| DO name '(' c_args ')'
{
{
$<action>$.code = W_DO;
$<action>$.code = W_DO;
$<action>$.command = cat_str(4, $2, m
ake_str("("), $4, make_str
(")"));
$<action>$.command = cat_str(4, $2, m
m_strdup("("), $4, mm_strdup
(")"));
$<action>$.str = cat2_str(m
ake_str
("do"), mm_strdup($<action>$.command));
$<action>$.str = cat2_str(m
m_strdup
("do"), mm_strdup($<action>$.command));
}
}
| DO SQL_BREAK
| DO SQL_BREAK
{
{
$<action>$.code = W_BREAK;
$<action>$.code = W_BREAK;
$<action>$.command = NULL;
$<action>$.command = NULL;
$<action>$.str = m
ake_str
("break");
$<action>$.str = m
m_strdup
("break");
}
}
| SQL_CALL name '(' c_args ')'
| SQL_CALL name '(' c_args ')'
{
{
$<action>$.code = W_DO;
$<action>$.code = W_DO;
$<action>$.command = cat_str(4, $2, m
ake_str("("), $4, make_str
(")"));
$<action>$.command = cat_str(4, $2, m
m_strdup("("), $4, mm_strdup
(")"));
$<action>$.str = cat2_str(m
ake_str
("call"), mm_strdup($<action>$.command));
$<action>$.str = cat2_str(m
m_strdup
("call"), mm_strdup($<action>$.command));
}
}
| SQL_CALL name
| SQL_CALL name
{
{
$<action>$.code = W_DO;
$<action>$.code = W_DO;
$<action>$.command = cat2_str($2, m
ake_str
("()"));
$<action>$.command = cat2_str($2, m
m_strdup
("()"));
$<action>$.str = cat2_str(m
ake_str
("call"), mm_strdup($<action>$.command));
$<action>$.str = cat2_str(m
m_strdup
("call"), mm_strdup($<action>$.command));
}
}
;
;
...
@@ -1455,48 +1455,48 @@ ECPGKeywords: ECPGKeywords_vanames { $$ = $1; }
...
@@ -1455,48 +1455,48 @@ ECPGKeywords: ECPGKeywords_vanames { $$ = $1; }
| ECPGKeywords_rest { $$ = $1; }
| ECPGKeywords_rest { $$ = $1; }
;
;
ECPGKeywords_vanames: SQL_BREAK { $$ = m
ake_str
("break"); }
ECPGKeywords_vanames: SQL_BREAK { $$ = m
m_strdup
("break"); }
| SQL_CALL { $$ = m
ake_str
("call"); }
| SQL_CALL { $$ = m
m_strdup
("call"); }
| SQL_CARDINALITY { $$ = m
ake_str
("cardinality"); }
| SQL_CARDINALITY { $$ = m
m_strdup
("cardinality"); }
| SQL_COUNT { $$ = m
ake_str
("count"); }
| SQL_COUNT { $$ = m
m_strdup
("count"); }
| SQL_DATETIME_INTERVAL_CODE { $$ = m
ake_str
("datetime_interval_code"); }
| SQL_DATETIME_INTERVAL_CODE { $$ = m
m_strdup
("datetime_interval_code"); }
| SQL_DATETIME_INTERVAL_PRECISION { $$ = m
ake_str
("datetime_interval_precision"); }
| SQL_DATETIME_INTERVAL_PRECISION { $$ = m
m_strdup
("datetime_interval_precision"); }
| SQL_FOUND { $$ = m
ake_str
("found"); }
| SQL_FOUND { $$ = m
m_strdup
("found"); }
| SQL_GO { $$ = m
ake_str
("go"); }
| SQL_GO { $$ = m
m_strdup
("go"); }
| SQL_GOTO { $$ = m
ake_str
("goto"); }
| SQL_GOTO { $$ = m
m_strdup
("goto"); }
| SQL_IDENTIFIED { $$ = m
ake_str
("identified"); }
| SQL_IDENTIFIED { $$ = m
m_strdup
("identified"); }
| SQL_INDICATOR { $$ = m
ake_str
("indicator"); }
| SQL_INDICATOR { $$ = m
m_strdup
("indicator"); }
| SQL_KEY_MEMBER { $$ = m
ake_str
("key_member"); }
| SQL_KEY_MEMBER { $$ = m
m_strdup
("key_member"); }
| SQL_LENGTH { $$ = m
ake_str
("length"); }
| SQL_LENGTH { $$ = m
m_strdup
("length"); }
| SQL_NULLABLE { $$ = m
ake_str
("nullable"); }
| SQL_NULLABLE { $$ = m
m_strdup
("nullable"); }
| SQL_OCTET_LENGTH { $$ = m
ake_str
("octet_length"); }
| SQL_OCTET_LENGTH { $$ = m
m_strdup
("octet_length"); }
| SQL_RETURNED_LENGTH { $$ = m
ake_str
("returned_length"); }
| SQL_RETURNED_LENGTH { $$ = m
m_strdup
("returned_length"); }
| SQL_RETURNED_OCTET_LENGTH { $$ = m
ake_str
("returned_octet_length"); }
| SQL_RETURNED_OCTET_LENGTH { $$ = m
m_strdup
("returned_octet_length"); }
| SQL_SCALE { $$ = m
ake_str
("scale"); }
| SQL_SCALE { $$ = m
m_strdup
("scale"); }
| SQL_SECTION { $$ = m
ake_str
("section"); }
| SQL_SECTION { $$ = m
m_strdup
("section"); }
| SQL_SQL { $$ = m
ake_str
("sql"); }
| SQL_SQL { $$ = m
m_strdup
("sql"); }
| SQL_SQLERROR { $$ = m
ake_str
("sqlerror"); }
| SQL_SQLERROR { $$ = m
m_strdup
("sqlerror"); }
| SQL_SQLPRINT { $$ = m
ake_str
("sqlprint"); }
| SQL_SQLPRINT { $$ = m
m_strdup
("sqlprint"); }
| SQL_SQLWARNING { $$ = m
ake_str
("sqlwarning"); }
| SQL_SQLWARNING { $$ = m
m_strdup
("sqlwarning"); }
| SQL_STOP { $$ = m
ake_str
("stop"); }
| SQL_STOP { $$ = m
m_strdup
("stop"); }
;
;
ECPGKeywords_rest: SQL_CONNECT { $$ = m
ake_str
("connect"); }
ECPGKeywords_rest: SQL_CONNECT { $$ = m
m_strdup
("connect"); }
| SQL_DESCRIBE { $$ = m
ake_str
("describe"); }
| SQL_DESCRIBE { $$ = m
m_strdup
("describe"); }
| SQL_DISCONNECT { $$ = m
ake_str
("disconnect"); }
| SQL_DISCONNECT { $$ = m
m_strdup
("disconnect"); }
| SQL_OPEN { $$ = m
ake_str
("open"); }
| SQL_OPEN { $$ = m
m_strdup
("open"); }
| SQL_VAR { $$ = m
ake_str
("var"); }
| SQL_VAR { $$ = m
m_strdup
("var"); }
| SQL_WHENEVER { $$ = m
ake_str
("whenever"); }
| SQL_WHENEVER { $$ = m
m_strdup
("whenever"); }
;
;
/* additional keywords that can be SQL type names (but not ECPGColLabels) */
/* additional keywords that can be SQL type names (but not ECPGColLabels) */
ECPGTypeName: SQL_BOOL { $$ = m
ake_str
("bool"); }
ECPGTypeName: SQL_BOOL { $$ = m
m_strdup
("bool"); }
| SQL_LONG { $$ = m
ake_str
("long"); }
| SQL_LONG { $$ = m
m_strdup
("long"); }
| SQL_OUTPUT { $$ = m
ake_str
("output"); }
| SQL_OUTPUT { $$ = m
m_strdup
("output"); }
| SQL_SHORT { $$ = m
ake_str
("short"); }
| SQL_SHORT { $$ = m
m_strdup
("short"); }
| SQL_STRUCT { $$ = m
ake_str
("struct"); }
| SQL_STRUCT { $$ = m
m_strdup
("struct"); }
| SQL_SIGNED { $$ = m
ake_str
("signed"); }
| SQL_SIGNED { $$ = m
m_strdup
("signed"); }
| SQL_UNSIGNED { $$ = m
ake_str
("unsigned"); }
| SQL_UNSIGNED { $$ = m
m_strdup
("unsigned"); }
;
;
symbol: ColLabel { $$ = $1; }
symbol: ColLabel { $$ = $1; }
...
@@ -1508,8 +1508,8 @@ ECPGColId: ecpg_ident { $$ = $1; }
...
@@ -1508,8 +1508,8 @@ ECPGColId: ecpg_ident { $$ = $1; }
| ECPGunreserved_interval { $$ = $1; }
| ECPGunreserved_interval { $$ = $1; }
| ECPGKeywords { $$ = $1; }
| ECPGKeywords { $$ = $1; }
| ECPGCKeywords { $$ = $1; }
| ECPGCKeywords { $$ = $1; }
| CHAR_P { $$ = m
ake_str
("char"); }
| CHAR_P { $$ = m
m_strdup
("char"); }
| VALUES { $$ = m
ake_str
("values"); }
| VALUES { $$ = m
m_strdup
("values"); }
;
;
/*
/*
...
@@ -1527,8 +1527,8 @@ ColId: ecpg_ident { $$ = $1; }
...
@@ -1527,8 +1527,8 @@ ColId: ecpg_ident { $$ = $1; }
| col_name_keyword { $$ = $1; }
| col_name_keyword { $$ = $1; }
| ECPGKeywords { $$ = $1; }
| ECPGKeywords { $$ = $1; }
| ECPGCKeywords { $$ = $1; }
| ECPGCKeywords { $$ = $1; }
| CHAR_P { $$ = m
ake_str
("char"); }
| CHAR_P { $$ = m
m_strdup
("char"); }
| VALUES { $$ = m
ake_str
("values"); }
| VALUES { $$ = m
m_strdup
("values"); }
;
;
/* Type/function identifier --- names that can be type or function names.
/* Type/function identifier --- names that can be type or function names.
...
@@ -1546,13 +1546,13 @@ type_function_name: ecpg_ident { $$ = $1; }
...
@@ -1546,13 +1546,13 @@ type_function_name: ecpg_ident { $$ = $1; }
*/
*/
ColLabel: ECPGColLabel { $$ = $1; }
ColLabel: ECPGColLabel { $$ = $1; }
| ECPGTypeName { $$ = $1; }
| ECPGTypeName { $$ = $1; }
| CHAR_P { $$ = m
ake_str
("char"); }
| CHAR_P { $$ = m
m_strdup
("char"); }
| CURRENT_P { $$ = m
ake_str
("current"); }
| CURRENT_P { $$ = m
m_strdup
("current"); }
| INPUT_P { $$ = m
ake_str
("input"); }
| INPUT_P { $$ = m
m_strdup
("input"); }
| INT_P { $$ = m
ake_str
("int"); }
| INT_P { $$ = m
m_strdup
("int"); }
| TO { $$ = m
ake_str
("to"); }
| TO { $$ = m
m_strdup
("to"); }
| UNION { $$ = m
ake_str
("union"); }
| UNION { $$ = m
m_strdup
("union"); }
| VALUES { $$ = m
ake_str
("values"); }
| VALUES { $$ = m
m_strdup
("values"); }
| ECPGCKeywords { $$ = $1; }
| ECPGCKeywords { $$ = $1; }
| ECPGunreserved_interval { $$ = $1; }
| ECPGunreserved_interval { $$ = $1; }
;
;
...
@@ -1561,7 +1561,7 @@ ECPGColLabel: ECPGColLabelCommon { $$ = $1; }
...
@@ -1561,7 +1561,7 @@ ECPGColLabel: ECPGColLabelCommon { $$ = $1; }
| unreserved_keyword { $$ = $1; }
| unreserved_keyword { $$ = $1; }
| reserved_keyword { $$ = $1; }
| reserved_keyword { $$ = $1; }
| ECPGKeywords_rest { $$ = $1; }
| ECPGKeywords_rest { $$ = $1; }
| CONNECTION { $$ = m
ake_str
("connection"); }
| CONNECTION { $$ = m
m_strdup
("connection"); }
;
;
ECPGColLabelCommon: ecpg_ident { $$ = $1; }
ECPGColLabelCommon: ecpg_ident { $$ = $1; }
...
@@ -1570,13 +1570,13 @@ ECPGColLabelCommon: ecpg_ident { $$ = $1; }
...
@@ -1570,13 +1570,13 @@ ECPGColLabelCommon: ecpg_ident { $$ = $1; }
| ECPGKeywords_vanames { $$ = $1; }
| ECPGKeywords_vanames { $$ = $1; }
;
;
ECPGCKeywords: S_AUTO { $$ = m
ake_str
("auto"); }
ECPGCKeywords: S_AUTO { $$ = m
m_strdup
("auto"); }
| S_CONST { $$ = m
ake_str
("const"); }
| S_CONST { $$ = m
m_strdup
("const"); }
| S_EXTERN { $$ = m
ake_str
("extern"); }
| S_EXTERN { $$ = m
m_strdup
("extern"); }
| S_REGISTER { $$ = m
ake_str
("register"); }
| S_REGISTER { $$ = m
m_strdup
("register"); }
| S_STATIC { $$ = m
ake_str
("static"); }
| S_STATIC { $$ = m
m_strdup
("static"); }
| S_TYPEDEF { $$ = m
ake_str
("typedef"); }
| S_TYPEDEF { $$ = m
m_strdup
("typedef"); }
| S_VOLATILE { $$ = m
ake_str
("volatile"); }
| S_VOLATILE { $$ = m
m_strdup
("volatile"); }
;
;
/* "Unreserved" keywords --- available for use as any kind of name.
/* "Unreserved" keywords --- available for use as any kind of name.
...
@@ -1595,15 +1595,15 @@ ECPGCKeywords: S_AUTO { $$ = make_str("auto"); }
...
@@ -1595,15 +1595,15 @@ ECPGCKeywords: S_AUTO { $$ = make_str("auto"); }
*/
*/
all_unreserved_keyword: unreserved_keyword { $$ = $1; }
all_unreserved_keyword: unreserved_keyword { $$ = $1; }
| ECPGunreserved_interval { $$ = $1; }
| ECPGunreserved_interval { $$ = $1; }
| CONNECTION { $$ = m
ake_str
("connection"); }
| CONNECTION { $$ = m
m_strdup
("connection"); }
;
;
ECPGunreserved_interval: DAY_P { $$ = m
ake_str
("day"); }
ECPGunreserved_interval: DAY_P { $$ = m
m_strdup
("day"); }
| HOUR_P { $$ = m
ake_str
("hour"); }
| HOUR_P { $$ = m
m_strdup
("hour"); }
| MINUTE_P { $$ = m
ake_str
("minute"); }
| MINUTE_P { $$ = m
m_strdup
("minute"); }
| MONTH_P { $$ = m
ake_str
("month"); }
| MONTH_P { $$ = m
m_strdup
("month"); }
| SECOND_P { $$ = m
ake_str
("second"); }
| SECOND_P { $$ = m
m_strdup
("second"); }
| YEAR_P { $$ = m
ake_str
("year"); }
| YEAR_P { $$ = m
m_strdup
("year"); }
;
;
...
@@ -1737,14 +1737,14 @@ ecpg_sconst:
...
@@ -1737,14 +1737,14 @@ ecpg_sconst:
ecpg_xconst: XCONST { $$ = make_name(); } ;
ecpg_xconst: XCONST { $$ = make_name(); } ;
ecpg_ident: IDENT { $$ = make_name(); }
ecpg_ident: IDENT { $$ = make_name(); }
| CSTRING { $$ = make3_str(m
ake_str("\""), $1, make_str
("\"")); }
| CSTRING { $$ = make3_str(m
m_strdup("\""), $1, mm_strdup
("\"")); }
| UIDENT { $$ = $1; }
| UIDENT { $$ = $1; }
;
;
quoted_ident_stringvar: name
quoted_ident_stringvar: name
{ $$ = make3_str(m
ake_str("\""), $1, make_str
("\"")); }
{ $$ = make3_str(m
m_strdup("\""), $1, mm_strdup
("\"")); }
| char_variable
| char_variable
{ $$ = make3_str(m
ake_str("("), $1, make_str
(")")); }
{ $$ = make3_str(m
m_strdup("("), $1, mm_strdup
(")")); }
;
;
/*
/*
...
@@ -1752,9 +1752,9 @@ quoted_ident_stringvar: name
...
@@ -1752,9 +1752,9 @@ quoted_ident_stringvar: name
*/
*/
c_stuff_item: c_anything { $$ = $1; }
c_stuff_item: c_anything { $$ = $1; }
| '(' ')' { $$ = m
ake_str
("()"); }
| '(' ')' { $$ = m
m_strdup
("()"); }
| '(' c_stuff ')'
| '(' c_stuff ')'
{ $$ = cat_str(3, m
ake_str("("), $2, make_str
(")")); }
{ $$ = cat_str(3, m
m_strdup("("), $2, mm_strdup
(")")); }
;
;
c_stuff: c_stuff_item { $$ = $1; }
c_stuff: c_stuff_item { $$ = $1; }
...
@@ -1763,91 +1763,91 @@ c_stuff: c_stuff_item { $$ = $1; }
...
@@ -1763,91 +1763,91 @@ c_stuff: c_stuff_item { $$ = $1; }
;
;
c_list: c_term { $$ = $1; }
c_list: c_term { $$ = $1; }
| c_list ',' c_term { $$ = cat_str(3, $1, m
ake_str
(","), $3); }
| c_list ',' c_term { $$ = cat_str(3, $1, m
m_strdup
(","), $3); }
;
;
c_term: c_stuff { $$ = $1; }
c_term: c_stuff { $$ = $1; }
| '{' c_list '}' { $$ = cat_str(3, m
ake_str("{"), $2, make_str
("}")); }
| '{' c_list '}' { $$ = cat_str(3, m
m_strdup("{"), $2, mm_strdup
("}")); }
;
;
c_thing: c_anything { $$ = $1; }
c_thing: c_anything { $$ = $1; }
| '(' { $$ = m
ake_str
("("); }
| '(' { $$ = m
m_strdup
("("); }
| ')' { $$ = m
ake_str
(")"); }
| ')' { $$ = m
m_strdup
(")"); }
| ',' { $$ = m
ake_str
(","); }
| ',' { $$ = m
m_strdup
(","); }
| ';' { $$ = m
ake_str
(";"); }
| ';' { $$ = m
m_strdup
(";"); }
;
;
c_anything: ecpg_ident { $$ = $1; }
c_anything: ecpg_ident { $$ = $1; }
| Iconst { $$ = $1; }
| Iconst { $$ = $1; }
| ecpg_fconst { $$ = $1; }
| ecpg_fconst { $$ = $1; }
| ecpg_sconst { $$ = $1; }
| ecpg_sconst { $$ = $1; }
| '*' { $$ = m
ake_str
("*"); }
| '*' { $$ = m
m_strdup
("*"); }
| '+' { $$ = m
ake_str
("+"); }
| '+' { $$ = m
m_strdup
("+"); }
| '-' { $$ = m
ake_str
("-"); }
| '-' { $$ = m
m_strdup
("-"); }
| '/' { $$ = m
ake_str
("/"); }
| '/' { $$ = m
m_strdup
("/"); }
| '%' { $$ = m
ake_str
("%"); }
| '%' { $$ = m
m_strdup
("%"); }
| NULL_P { $$ = m
ake_str
("NULL"); }
| NULL_P { $$ = m
m_strdup
("NULL"); }
| S_ADD { $$ = m
ake_str
("+="); }
| S_ADD { $$ = m
m_strdup
("+="); }
| S_AND { $$ = m
ake_str
("&&"); }
| S_AND { $$ = m
m_strdup
("&&"); }
| S_ANYTHING { $$ = make_name(); }
| S_ANYTHING { $$ = make_name(); }
| S_AUTO { $$ = m
ake_str
("auto"); }
| S_AUTO { $$ = m
m_strdup
("auto"); }
| S_CONST { $$ = m
ake_str
("const"); }
| S_CONST { $$ = m
m_strdup
("const"); }
| S_DEC { $$ = m
ake_str
("--"); }
| S_DEC { $$ = m
m_strdup
("--"); }
| S_DIV { $$ = m
ake_str
("/="); }
| S_DIV { $$ = m
m_strdup
("/="); }
| S_DOTPOINT { $$ = m
ake_str
(".*"); }
| S_DOTPOINT { $$ = m
m_strdup
(".*"); }
| S_EQUAL { $$ = m
ake_str
("=="); }
| S_EQUAL { $$ = m
m_strdup
("=="); }
| S_EXTERN { $$ = m
ake_str
("extern"); }
| S_EXTERN { $$ = m
m_strdup
("extern"); }
| S_INC { $$ = m
ake_str
("++"); }
| S_INC { $$ = m
m_strdup
("++"); }
| S_LSHIFT { $$ = m
ake_str
("<<"); }
| S_LSHIFT { $$ = m
m_strdup
("<<"); }
| S_MEMBER { $$ = m
ake_str
("->"); }
| S_MEMBER { $$ = m
m_strdup
("->"); }
| S_MEMPOINT { $$ = m
ake_str
("->*"); }
| S_MEMPOINT { $$ = m
m_strdup
("->*"); }
| S_MOD { $$ = m
ake_str
("%="); }
| S_MOD { $$ = m
m_strdup
("%="); }
| S_MUL { $$ = m
ake_str
("*="); }
| S_MUL { $$ = m
m_strdup
("*="); }
| S_NEQUAL { $$ = m
ake_str
("!="); }
| S_NEQUAL { $$ = m
m_strdup
("!="); }
| S_OR { $$ = m
ake_str
("||"); }
| S_OR { $$ = m
m_strdup
("||"); }
| S_REGISTER { $$ = m
ake_str
("register"); }
| S_REGISTER { $$ = m
m_strdup
("register"); }
| S_RSHIFT { $$ = m
ake_str
(">>"); }
| S_RSHIFT { $$ = m
m_strdup
(">>"); }
| S_STATIC { $$ = m
ake_str
("static"); }
| S_STATIC { $$ = m
m_strdup
("static"); }
| S_SUB { $$ = m
ake_str
("-="); }
| S_SUB { $$ = m
m_strdup
("-="); }
| S_TYPEDEF { $$ = m
ake_str
("typedef"); }
| S_TYPEDEF { $$ = m
m_strdup
("typedef"); }
| S_VOLATILE { $$ = m
ake_str
("volatile"); }
| S_VOLATILE { $$ = m
m_strdup
("volatile"); }
| SQL_BOOL { $$ = m
ake_str
("bool"); }
| SQL_BOOL { $$ = m
m_strdup
("bool"); }
| ENUM_P { $$ = m
ake_str
("enum"); }
| ENUM_P { $$ = m
m_strdup
("enum"); }
| HOUR_P { $$ = m
ake_str
("hour"); }
| HOUR_P { $$ = m
m_strdup
("hour"); }
| INT_P { $$ = m
ake_str
("int"); }
| INT_P { $$ = m
m_strdup
("int"); }
| SQL_LONG { $$ = m
ake_str
("long"); }
| SQL_LONG { $$ = m
m_strdup
("long"); }
| MINUTE_P { $$ = m
ake_str
("minute"); }
| MINUTE_P { $$ = m
m_strdup
("minute"); }
| MONTH_P { $$ = m
ake_str
("month"); }
| MONTH_P { $$ = m
m_strdup
("month"); }
| SECOND_P { $$ = m
ake_str
("second"); }
| SECOND_P { $$ = m
m_strdup
("second"); }
| SQL_SHORT { $$ = m
ake_str
("short"); }
| SQL_SHORT { $$ = m
m_strdup
("short"); }
| SQL_SIGNED { $$ = m
ake_str
("signed"); }
| SQL_SIGNED { $$ = m
m_strdup
("signed"); }
| SQL_STRUCT { $$ = m
ake_str
("struct"); }
| SQL_STRUCT { $$ = m
m_strdup
("struct"); }
| SQL_UNSIGNED { $$ = m
ake_str
("unsigned"); }
| SQL_UNSIGNED { $$ = m
m_strdup
("unsigned"); }
| YEAR_P { $$ = m
ake_str
("year"); }
| YEAR_P { $$ = m
m_strdup
("year"); }
| CHAR_P { $$ = m
ake_str
("char"); }
| CHAR_P { $$ = m
m_strdup
("char"); }
| FLOAT_P { $$ = m
ake_str
("float"); }
| FLOAT_P { $$ = m
m_strdup
("float"); }
| TO { $$ = m
ake_str
("to"); }
| TO { $$ = m
m_strdup
("to"); }
| UNION { $$ = m
ake_str
("union"); }
| UNION { $$ = m
m_strdup
("union"); }
| VARCHAR { $$ = m
ake_str
("varchar"); }
| VARCHAR { $$ = m
m_strdup
("varchar"); }
| '[' { $$ = m
ake_str
("["); }
| '[' { $$ = m
m_strdup
("["); }
| ']' { $$ = m
ake_str
("]"); }
| ']' { $$ = m
m_strdup
("]"); }
| '=' { $$ = m
ake_str
("="); }
| '=' { $$ = m
m_strdup
("="); }
| ':' { $$ = m
ake_str
(":"); }
| ':' { $$ = m
m_strdup
(":"); }
;
;
DeallocateStmt: DEALLOCATE prepared_name { $$ = $2; }
DeallocateStmt: DEALLOCATE prepared_name { $$ = $2; }
| DEALLOCATE PREPARE prepared_name { $$ = $3; }
| DEALLOCATE PREPARE prepared_name { $$ = $3; }
| DEALLOCATE ALL { $$ = m
ake_str
("all"); }
| DEALLOCATE ALL { $$ = m
m_strdup
("all"); }
| DEALLOCATE PREPARE ALL { $$ = m
ake_str
("all"); }
| DEALLOCATE PREPARE ALL { $$ = m
m_strdup
("all"); }
;
;
Iresult: Iconst { $$ = $1; }
Iresult: Iconst { $$ = $1; }
| '(' Iresult ')' { $$ = cat_str(3, m
ake_str("("), $2, make_str
(")")); }
| '(' Iresult ')' { $$ = cat_str(3, m
m_strdup("("), $2, mm_strdup
(")")); }
| Iresult '+' Iresult { $$ = cat_str(3, $1, m
ake_str
("+"), $3); }
| Iresult '+' Iresult { $$ = cat_str(3, $1, m
m_strdup
("+"), $3); }
| Iresult '-' Iresult { $$ = cat_str(3, $1, m
ake_str
("-"), $3); }
| Iresult '-' Iresult { $$ = cat_str(3, $1, m
m_strdup
("-"), $3); }
| Iresult '*' Iresult { $$ = cat_str(3, $1, m
ake_str
("*"), $3); }
| Iresult '*' Iresult { $$ = cat_str(3, $1, m
m_strdup
("*"), $3); }
| Iresult '/' Iresult { $$ = cat_str(3, $1, m
ake_str
("/"), $3); }
| Iresult '/' Iresult { $$ = cat_str(3, $1, m
m_strdup
("/"), $3); }
| Iresult '%' Iresult { $$ = cat_str(3, $1, m
ake_str
("%"), $3); }
| Iresult '%' Iresult { $$ = cat_str(3, $1, m
m_strdup
("%"), $3); }
| ecpg_sconst { $$ = $1; }
| ecpg_sconst { $$ = $1; }
| ColId { $$ = $1; }
| ColId { $$ = $1; }
;
;
...
...
src/interfaces/ecpg/preproc/extern.h
View file @
1066dbfb
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
/* defines */
/* defines */
#define STRUCT_DEPTH 128
#define STRUCT_DEPTH 128
#define EMPTY m
ake_str
("")
#define EMPTY m
m_strdup
("")
/* variables */
/* variables */
...
@@ -62,7 +62,6 @@ extern struct ECPGstruct_member *struct_member_list[STRUCT_DEPTH];
...
@@ -62,7 +62,6 @@ extern struct ECPGstruct_member *struct_member_list[STRUCT_DEPTH];
extern
const
char
*
get_dtype
(
enum
ECPGdtype
);
extern
const
char
*
get_dtype
(
enum
ECPGdtype
);
extern
void
lex_init
(
void
);
extern
void
lex_init
(
void
);
extern
char
*
make_str
(
const
char
*
);
extern
void
output_line_number
(
void
);
extern
void
output_line_number
(
void
);
extern
void
output_statement
(
char
*
,
int
,
enum
ECPG_statement_type
);
extern
void
output_statement
(
char
*
,
int
,
enum
ECPG_statement_type
);
extern
void
output_prepare_statement
(
char
*
,
char
*
);
extern
void
output_prepare_statement
(
char
*
,
char
*
);
...
...
src/interfaces/ecpg/preproc/parse.pl
View file @
1066dbfb
...
@@ -397,7 +397,7 @@ sub dump_fields {
...
@@ -397,7 +397,7 @@ sub dump_fields {
&
add_to_buffer
('
rules
',
"
\
$
\
$=EMPTY; }
");
&
add_to_buffer
('
rules
',
"
\
$
\
$=EMPTY; }
");
}
}
else
{
else
{
# Go through each field and try to 'aggregate' the tokens into a single 'm
ake_str
' where possible
# Go through each field and try to 'aggregate' the tokens into a single 'm
m_strdup
' where possible
$cnt
=
0
;
$cnt
=
0
;
for
(
$z
=
0
;
$z
<
$len
;
$z
++
)
{
for
(
$z
=
0
;
$z
<
$len
;
$z
++
)
{
if
(
substr
(
$flds
{
$z
},
1
,
1
)
eq
"
\
$
")
{
if
(
substr
(
$flds
{
$z
},
1
,
1
)
eq
"
\
$
")
{
...
@@ -410,7 +410,7 @@ sub dump_fields {
...
@@ -410,7 +410,7 @@ sub dump_fields {
while
(
1
)
{
while
(
1
)
{
if
(
$z
>=
$len
-
1
||
substr
(
$flds
{
$z
+
1
},
1
,
1
)
eq
"
\
$
")
{
if
(
$z
>=
$len
-
1
||
substr
(
$flds
{
$z
+
1
},
1
,
1
)
eq
"
\
$
")
{
# We're at the end...
# We're at the end...
$flds_new
{
$cnt
++
}
=
"
m
ake_str
(
\"
"
.
$str
.
"
\"
)
";
$flds_new
{
$cnt
++
}
=
"
m
m_strdup
(
\"
"
.
$str
.
"
\"
)
";
last
;
last
;
}
}
$z
++
;
$z
++
;
...
...
src/interfaces/ecpg/preproc/type.c
View file @
1066dbfb
...
@@ -120,7 +120,7 @@ ECPGmake_array_type(struct ECPGtype * type, char *size)
...
@@ -120,7 +120,7 @@ ECPGmake_array_type(struct ECPGtype * type, char *size)
struct
ECPGtype
*
struct
ECPGtype
*
ECPGmake_struct_type
(
struct
ECPGstruct_member
*
rm
,
enum
ECPGttype
type
,
char
*
type_name
,
char
*
struct_sizeof
)
ECPGmake_struct_type
(
struct
ECPGstruct_member
*
rm
,
enum
ECPGttype
type
,
char
*
type_name
,
char
*
struct_sizeof
)
{
{
struct
ECPGtype
*
ne
=
ECPGmake_simple_type
(
type
,
m
ake_str
(
"1"
),
0
);
struct
ECPGtype
*
ne
=
ECPGmake_simple_type
(
type
,
m
m_strdup
(
"1"
),
0
);
ne
->
type_name
=
mm_strdup
(
type_name
);
ne
->
type_name
=
mm_strdup
(
type_name
);
ne
->
u
.
members
=
ECPGstruct_member_dup
(
rm
);
ne
->
u
.
members
=
ECPGstruct_member_dup
(
rm
);
...
@@ -308,7 +308,7 @@ ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * type, const int bra
...
@@ -308,7 +308,7 @@ ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * type, const int bra
if
(
ind_type
!=
NULL
)
if
(
ind_type
!=
NULL
)
{
{
if
(
ind_type
->
type
==
ECPGt_NO_INDICATOR
)
if
(
ind_type
->
type
==
ECPGt_NO_INDICATOR
)
ECPGdump_a_simple
(
o
,
ind_name
,
ind_type
->
type
,
ind_type
->
size
,
m
ake_str
(
"-1"
),
NULL
,
ind_prefix
,
0
);
ECPGdump_a_simple
(
o
,
ind_name
,
ind_type
->
type
,
ind_type
->
size
,
m
m_strdup
(
"-1"
),
NULL
,
ind_prefix
,
0
);
else
else
{
{
ECPGdump_a_simple
(
o
,
ind_name
,
ind_type
->
u
.
element
->
type
,
ECPGdump_a_simple
(
o
,
ind_name
,
ind_type
->
u
.
element
->
type
,
...
@@ -321,7 +321,7 @@ ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * type, const int bra
...
@@ -321,7 +321,7 @@ ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * type, const int bra
if
(
indicator_set
&&
ind_type
->
type
!=
ECPGt_struct
)
if
(
indicator_set
&&
ind_type
->
type
!=
ECPGt_struct
)
mmerror
(
INDICATOR_NOT_STRUCT
,
ET_FATAL
,
"indicator for struct has to be a struct"
);
mmerror
(
INDICATOR_NOT_STRUCT
,
ET_FATAL
,
"indicator for struct has to be a struct"
);
ECPGdump_a_struct
(
o
,
name
,
ind_name
,
m
ake_str
(
"1"
),
type
,
ind_type
,
prefix
,
ind_prefix
);
ECPGdump_a_struct
(
o
,
name
,
ind_name
,
m
m_strdup
(
"1"
),
type
,
ind_type
,
prefix
,
ind_prefix
);
break
;
break
;
case
ECPGt_union
:
/* cannot dump a complete union */
case
ECPGt_union
:
/* cannot dump a complete union */
base_yyerror
(
"type of union has to be specified"
);
base_yyerror
(
"type of union has to be specified"
);
...
@@ -330,25 +330,25 @@ ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * type, const int bra
...
@@ -330,25 +330,25 @@ ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * type, const int bra
if
(
indicator_set
&&
(
ind_type
->
type
==
ECPGt_struct
||
ind_type
->
type
==
ECPGt_array
))
if
(
indicator_set
&&
(
ind_type
->
type
==
ECPGt_struct
||
ind_type
->
type
==
ECPGt_array
))
mmerror
(
INDICATOR_NOT_SIMPLE
,
ET_FATAL
,
"indicator for simple data type has to be simple"
);
mmerror
(
INDICATOR_NOT_SIMPLE
,
ET_FATAL
,
"indicator for simple data type has to be simple"
);
ECPGdump_a_simple
(
o
,
name
,
type
->
type
,
m
ake_str
(
"1"
),
(
arr_str_siz
&&
strcmp
(
arr_str_siz
,
"0"
)
!=
0
)
?
arr_str_siz
:
make_str
(
"1"
),
struct_sizeof
,
prefix
,
0
);
ECPGdump_a_simple
(
o
,
name
,
type
->
type
,
m
m_strdup
(
"1"
),
(
arr_str_siz
&&
strcmp
(
arr_str_siz
,
"0"
)
!=
0
)
?
arr_str_siz
:
mm_strdup
(
"1"
),
struct_sizeof
,
prefix
,
0
);
if
(
ind_type
!=
NULL
)
if
(
ind_type
!=
NULL
)
ECPGdump_a_simple
(
o
,
ind_name
,
ind_type
->
type
,
ind_type
->
size
,
(
arr_str_siz
&&
strcmp
(
arr_str_siz
,
"0"
)
!=
0
)
?
arr_str_siz
:
m
ake_str
(
"-1"
),
ind_struct_sizeof
,
ind_prefix
,
0
);
ECPGdump_a_simple
(
o
,
ind_name
,
ind_type
->
type
,
ind_type
->
size
,
(
arr_str_siz
&&
strcmp
(
arr_str_siz
,
"0"
)
!=
0
)
?
arr_str_siz
:
m
m_strdup
(
"-1"
),
ind_struct_sizeof
,
ind_prefix
,
0
);
break
;
break
;
case
ECPGt_descriptor
:
case
ECPGt_descriptor
:
if
(
indicator_set
&&
(
ind_type
->
type
==
ECPGt_struct
||
ind_type
->
type
==
ECPGt_array
))
if
(
indicator_set
&&
(
ind_type
->
type
==
ECPGt_struct
||
ind_type
->
type
==
ECPGt_array
))
mmerror
(
INDICATOR_NOT_SIMPLE
,
ET_FATAL
,
"indicator for simple data type has to be simple"
);
mmerror
(
INDICATOR_NOT_SIMPLE
,
ET_FATAL
,
"indicator for simple data type has to be simple"
);
ECPGdump_a_simple
(
o
,
name
,
type
->
type
,
NULL
,
m
ake_str
(
"-1"
),
NULL
,
prefix
,
0
);
ECPGdump_a_simple
(
o
,
name
,
type
->
type
,
NULL
,
m
m_strdup
(
"-1"
),
NULL
,
prefix
,
0
);
if
(
ind_type
!=
NULL
)
if
(
ind_type
!=
NULL
)
ECPGdump_a_simple
(
o
,
ind_name
,
ind_type
->
type
,
ind_type
->
size
,
m
ake_str
(
"-1"
),
NULL
,
ind_prefix
,
0
);
ECPGdump_a_simple
(
o
,
ind_name
,
ind_type
->
type
,
ind_type
->
size
,
m
m_strdup
(
"-1"
),
NULL
,
ind_prefix
,
0
);
break
;
break
;
default:
default:
if
(
indicator_set
&&
(
ind_type
->
type
==
ECPGt_struct
||
ind_type
->
type
==
ECPGt_array
))
if
(
indicator_set
&&
(
ind_type
->
type
==
ECPGt_struct
||
ind_type
->
type
==
ECPGt_array
))
mmerror
(
INDICATOR_NOT_SIMPLE
,
ET_FATAL
,
"indicator for simple data type has to be simple"
);
mmerror
(
INDICATOR_NOT_SIMPLE
,
ET_FATAL
,
"indicator for simple data type has to be simple"
);
ECPGdump_a_simple
(
o
,
name
,
type
->
type
,
type
->
size
,
(
arr_str_siz
&&
strcmp
(
arr_str_siz
,
"0"
)
!=
0
)
?
arr_str_siz
:
m
ake_str
(
"-1"
),
struct_sizeof
,
prefix
,
type
->
counter
);
ECPGdump_a_simple
(
o
,
name
,
type
->
type
,
type
->
size
,
(
arr_str_siz
&&
strcmp
(
arr_str_siz
,
"0"
)
!=
0
)
?
arr_str_siz
:
m
m_strdup
(
"-1"
),
struct_sizeof
,
prefix
,
type
->
counter
);
if
(
ind_type
!=
NULL
)
if
(
ind_type
!=
NULL
)
ECPGdump_a_simple
(
o
,
ind_name
,
ind_type
->
type
,
ind_type
->
size
,
(
arr_str_siz
&&
strcmp
(
arr_str_siz
,
"0"
)
!=
0
)
?
arr_str_siz
:
m
ake_str
(
"-1"
),
ind_struct_sizeof
,
ind_prefix
,
0
);
ECPGdump_a_simple
(
o
,
ind_name
,
ind_type
->
type
,
ind_type
->
size
,
(
arr_str_siz
&&
strcmp
(
arr_str_siz
,
"0"
)
!=
0
)
?
arr_str_siz
:
m
m_strdup
(
"-1"
),
ind_struct_sizeof
,
ind_prefix
,
0
);
break
;
break
;
}
}
}
}
...
...
src/interfaces/ecpg/preproc/variable.c
View file @
1066dbfb
...
@@ -446,7 +446,7 @@ dump_variables(struct arguments * list, int mode)
...
@@ -446,7 +446,7 @@ dump_variables(struct arguments * list, int mode)
/* Then the current element and its indicator */
/* Then the current element and its indicator */
ECPGdump_a_type
(
yyout
,
list
->
variable
->
name
,
list
->
variable
->
type
,
list
->
variable
->
brace_level
,
ECPGdump_a_type
(
yyout
,
list
->
variable
->
name
,
list
->
variable
->
type
,
list
->
variable
->
brace_level
,
list
->
indicator
->
name
,
list
->
indicator
->
type
,
list
->
indicator
->
brace_level
,
list
->
indicator
->
name
,
list
->
indicator
->
type
,
list
->
indicator
->
brace_level
,
NULL
,
NULL
,
m
ake_str
(
"0"
),
NULL
,
NULL
);
NULL
,
NULL
,
m
m_strdup
(
"0"
),
NULL
,
NULL
);
/* Then release the list element. */
/* Then release the list element. */
if
(
mode
!=
0
)
if
(
mode
!=
0
)
...
@@ -542,7 +542,7 @@ adjust_array(enum ECPGttype type_enum, char **dimension, char **length, char *ty
...
@@ -542,7 +542,7 @@ adjust_array(enum ECPGttype type_enum, char **dimension, char **length, char *ty
if
(
pointer_len
)
if
(
pointer_len
)
{
{
*
length
=
*
dimension
;
*
length
=
*
dimension
;
*
dimension
=
m
ake_str
(
"0"
);
*
dimension
=
m
m_strdup
(
"0"
);
}
}
if
(
atoi
(
*
length
)
>=
0
)
if
(
atoi
(
*
length
)
>=
0
)
...
@@ -552,13 +552,13 @@ adjust_array(enum ECPGttype type_enum, char **dimension, char **length, char *ty
...
@@ -552,13 +552,13 @@ adjust_array(enum ECPGttype type_enum, char **dimension, char **length, char *ty
case
ECPGt_varchar
:
case
ECPGt_varchar
:
/* pointer has to get dimension 0 */
/* pointer has to get dimension 0 */
if
(
pointer_len
)
if
(
pointer_len
)
*
dimension
=
m
ake_str
(
"0"
);
*
dimension
=
m
m_strdup
(
"0"
);
/* one index is the string length */
/* one index is the string length */
if
(
atoi
(
*
length
)
<
0
)
if
(
atoi
(
*
length
)
<
0
)
{
{
*
length
=
*
dimension
;
*
length
=
*
dimension
;
*
dimension
=
m
ake_str
(
"-1"
);
*
dimension
=
m
m_strdup
(
"-1"
);
}
}
break
;
break
;
...
@@ -568,13 +568,13 @@ adjust_array(enum ECPGttype type_enum, char **dimension, char **length, char *ty
...
@@ -568,13 +568,13 @@ adjust_array(enum ECPGttype type_enum, char **dimension, char **length, char *ty
/* char ** */
/* char ** */
if
(
pointer_len
==
2
)
if
(
pointer_len
==
2
)
{
{
*
length
=
*
dimension
=
m
ake_str
(
"0"
);
*
length
=
*
dimension
=
m
m_strdup
(
"0"
);
break
;
break
;
}
}
/* pointer has to get length 0 */
/* pointer has to get length 0 */
if
(
pointer_len
==
1
)
if
(
pointer_len
==
1
)
*
length
=
m
ake_str
(
"0"
);
*
length
=
m
m_strdup
(
"0"
);
/* one index is the string length */
/* one index is the string length */
if
(
atoi
(
*
length
)
<
0
)
if
(
atoi
(
*
length
)
<
0
)
...
@@ -589,13 +589,13 @@ adjust_array(enum ECPGttype type_enum, char **dimension, char **length, char *ty
...
@@ -589,13 +589,13 @@ adjust_array(enum ECPGttype type_enum, char **dimension, char **length, char *ty
* do not change this for typedefs since it will be
* do not change this for typedefs since it will be
* changed later on when the variable is defined
* changed later on when the variable is defined
*/
*/
*
length
=
m
ake_str
(
"1"
);
*
length
=
m
m_strdup
(
"1"
);
else
if
(
strcmp
(
*
dimension
,
"0"
)
==
0
)
else
if
(
strcmp
(
*
dimension
,
"0"
)
==
0
)
*
length
=
m
ake_str
(
"-1"
);
*
length
=
m
m_strdup
(
"-1"
);
else
else
*
length
=
*
dimension
;
*
length
=
*
dimension
;
*
dimension
=
m
ake_str
(
"-1"
);
*
dimension
=
m
m_strdup
(
"-1"
);
}
}
break
;
break
;
default:
default:
...
@@ -603,7 +603,7 @@ adjust_array(enum ECPGttype type_enum, char **dimension, char **length, char *ty
...
@@ -603,7 +603,7 @@ adjust_array(enum ECPGttype type_enum, char **dimension, char **length, char *ty
if
(
pointer_len
)
if
(
pointer_len
)
{
{
*
length
=
*
dimension
;
*
length
=
*
dimension
;
*
dimension
=
m
ake_str
(
"0"
);
*
dimension
=
m
m_strdup
(
"0"
);
}
}
if
(
atoi
(
*
length
)
>=
0
)
if
(
atoi
(
*
length
)
>=
0
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment