8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-23 22:43:04 +01:00

const correctness and vars in scope

This commit is contained in:
robocop 2003-10-07 09:58:26 +00:00
parent 2eb944200f
commit b6c93778f4
5 changed files with 1072 additions and 1028 deletions

View File

@ -19,7 +19,7 @@
* *
* All Rights Reserved. * All Rights Reserved.
* Contributor(s): ______________________________________. * Contributor(s): ______________________________________.
* $Id: gpre.h,v 1.45 2003-10-06 09:48:43 robocop Exp $ * $Id: gpre.h,v 1.46 2003-10-07 09:58:26 robocop Exp $
* Revision 1.3 2000/11/27 09:26:13 fsg * Revision 1.3 2000/11/27 09:26:13 fsg
* Fixed bugs in gpre to handle PYXIS forms * Fixed bugs in gpre to handle PYXIS forms
* and allow edit.e and fred.e to go through * and allow edit.e and fred.e to go through
@ -64,6 +64,7 @@
#include "../jrd/ib_stdio.h" #include "../jrd/ib_stdio.h"
#include "../jrd/common.h" #include "../jrd/common.h"
#include "../jrd/y_ref.h" #include "../jrd/y_ref.h"
#include "../jrd/gdsassert.h"
#ifdef GPRE_FORTRAN #ifdef GPRE_FORTRAN
#if defined AIX || defined AIX_PPC || defined sun #if defined AIX || defined AIX_PPC || defined sun
@ -173,7 +174,7 @@ typedef struct adl {
adl* adl_next; /* Next declared array identifier */ adl* adl_next; /* Next declared array identifier */
} *ADL; } *ADL;
#define ADL_LEN sizeof(adl) const size_t ADL_LEN = sizeof(adl);
/* database block data, for generating block data section in fussy fortran */ /* database block data, for generating block data section in fussy fortran */
@ -198,7 +199,7 @@ typedef struct dim {
dim* dim_previous; /* Information for dimension i-1 */ dim* dim_previous; /* Information for dimension i-1 */
} *DIM; } *DIM;
#define DIM_LEN sizeof(dim) const size_t DIM_LEN = sizeof(dim);
typedef struct fil { typedef struct fil {
@ -215,7 +216,7 @@ typedef struct fil {
#define FIL_raw 2 /* On raw device */ #define FIL_raw 2 /* On raw device */
#define FIL_conditional 4 /* Conditional shadow */ #define FIL_conditional 4 /* Conditional shadow */
#define FIL_LEN sizeof(fil) const size_t FIL_LEN = sizeof(fil);
/* filter block */ /* filter block */
@ -228,7 +229,7 @@ typedef struct fltr {
SSHORT fltr_output_type; SSHORT fltr_output_type;
} *FLTR; } *FLTR;
#define FLTR_LEN sizeof(fltr) const size_t FLTR_LEN = sizeof(fltr);
/* General Syntax node, produced by parser */ /* General Syntax node, produced by parser */
@ -279,14 +280,19 @@ typedef struct gpre_nod {
#define nod_arg1 nod_arg[1] #define nod_arg1 nod_arg[1]
#define nod_arg2 nod_arg[2] #define nod_arg2 nod_arg[2]
#define NOD_LEN(cnt) (sizeof(gpre_nod) + (cnt - 1) * sizeof(gpre_nod*)) inline size_t NOD_LEN(const size_t cnt)
{
fb_assert(cnt != 0);
return sizeof(gpre_nod) + (cnt - 1) * sizeof(gpre_nod*);
}
//#define NOD_LEN(cnt) (sizeof(gpre_nod) + (cnt - 1) * sizeof(gpre_nod*))
typedef struct sdt { typedef struct sdt {
USHORT sdt_dialect; /* Dialect value as specified by SET stmt */ USHORT sdt_dialect; /* Dialect value as specified by SET stmt */
} *SDT; } *SDT;
#define SDT_LEN sizeof(sdt) const size_t SDT_LEN = sizeof(sdt);
/* Set generator block */ /* Set generator block */
@ -298,7 +304,7 @@ typedef struct sgen {
SINT64 sgen_int64value; SINT64 sgen_int64value;
} *SGEN; } *SGEN;
#define SGEN_LEN sizeof(sgen) const size_t SGEN_LEN = sizeof(sgen);
/* STRing block - holds a null terminated string */ /* STRing block - holds a null terminated string */
@ -307,7 +313,10 @@ typedef struct str {
TEXT str_string[1]; /* pretty simple, no? */ TEXT str_string[1]; /* pretty simple, no? */
} *STR; } *STR;
#define STR_LEN(size) (sizeof(str) + size) inline size_t STR_LEN(const size_t size)
{
return sizeof(str) + size;
}
/* SQL WHENEVER BLOCK */ /* SQL WHENEVER BLOCK */
@ -332,7 +341,7 @@ typedef struct txt {
USHORT txt_length; USHORT txt_length;
} *TXT; } *TXT;
#define TXT_LEN sizeof(txt) const size_t TXT_LEN = sizeof(txt);
/* User name -- used for SQL GRANT/REVOKE */ /* User name -- used for SQL GRANT/REVOKE */
@ -344,7 +353,7 @@ typedef struct usn {
i.e. gds__dyn_grant_user/view/proc/trig */ i.e. gds__dyn_grant_user/view/proc/trig */
} *USN; } *USN;
#define USN_LEN sizeof(usn) const size_t USN_LEN = sizeof(usn);
/* value block, used to store a set of values */ /* value block, used to store a set of values */
@ -354,13 +363,15 @@ typedef struct val {
TEXT *val_value; /* value */ TEXT *val_value; /* value */
} *VAL; } *VAL;
#define VAL_LEN sizeof(val) const size_t VAL_LEN = sizeof(val);
/* Array information block. Used to hold info about an array field. /* Array information block. Used to hold info about an array field.
Note: the dimension (DIM) block used to hold dimension information. Note: the dimension (DIM) block used to hold dimension information.
The preferred mechanism is the repeating tail on the array block. */ The preferred mechanism is the repeating tail on the array block. */
#define MAX_ARRAY_DIMENSIONS 16
typedef struct ary { typedef struct ary {
USHORT ary_dtype; /* data type of array */ USHORT ary_dtype; /* data type of array */
int ary_dimension_count; /* Number of dimensions in this array */ int ary_dimension_count; /* Number of dimensions in this array */
@ -371,11 +382,13 @@ typedef struct ary {
struct ary_repeat { struct ary_repeat {
SLONG ary_lower; SLONG ary_lower;
SLONG ary_upper; SLONG ary_upper;
} ary_rpt[16]; } ary_rpt[MAX_ARRAY_DIMENSIONS];
} *ARY; } *ARY;
#define ARY_LEN(count) (sizeof(ary)) // CVC: The count is ignored, the array is hardcoded at 16.
#define MAX_ARRAY_DIMENSIONS 16 const size_t ARY_LEN = sizeof(ary);
//#define ARY_LEN(count) (sizeof(ary))
/* Trigger block */ /* Trigger block */
@ -391,7 +404,7 @@ typedef struct gpre_trg {
str* trg_message; /* Message the trigger prints */ str* trg_message; /* Message the trigger prints */
} *GPRE_TRG; } *GPRE_TRG;
#define TRG_LEN sizeof(gpre_trg) const size_t TRG_LEN = sizeof(gpre_trg);
#define PRE_STORE_TRIGGER 1 #define PRE_STORE_TRIGGER 1
#define POST_STORE_TRIGGER 2 #define POST_STORE_TRIGGER 2
@ -408,7 +421,7 @@ typedef struct lls {
lls* lls_next; /* next item on stack */ lls* lls_next; /* next item on stack */
} *LLS; } *LLS;
#define LLS_LEN sizeof(lls) const size_t LLS_LEN = sizeof(lls);
/* Constraint block, used to hold information about integrity constraints */ /* Constraint block, used to hold information about integrity constraints */
@ -428,7 +441,8 @@ typedef struct cnstrt {
USHORT cnstrt_flags; /* see below */ USHORT cnstrt_flags; /* see below */
} *CNSTRT; } *CNSTRT;
#define CNSTRT_LEN sizeof(cnstrt) const size_t CNSTRT_LEN = sizeof(cnstrt);
/* Values for cnstrt_fkey_def_type */ /* Values for cnstrt_fkey_def_type */
@ -475,7 +489,7 @@ typedef struct prv {
prv* prv_next; /* next grant/revoke block (with different user) */ prv* prv_next; /* next grant/revoke block (with different user) */
} *PRV; } *PRV;
#define PRV_LEN (sizeof(prv)) const size_t PRV_LEN = sizeof(prv);
#define PRV_no_privs 0 /* no privileges being granted or revoked */ #define PRV_no_privs 0 /* no privileges being granted or revoked */
#define PRV_select 1 /* select privilege being granted or revoked */ #define PRV_select 1 /* select privilege being granted or revoked */
@ -495,7 +509,7 @@ typedef struct sts {
USHORT sts_flags; /* Miscellaneous flags */ USHORT sts_flags; /* Miscellaneous flags */
} *STS; } *STS;
#define STS_LEN sizeof(sts) const size_t STS_LEN = sizeof(sts);
#define STS_index 1 /* Object is an index */ #define STS_index 1 /* Object is an index */
@ -506,10 +520,11 @@ typedef struct cmpf {
gpre_nod* cmpf_boolean; /* expression, for computed field */ gpre_nod* cmpf_boolean; /* expression, for computed field */
} *CMPF; } *CMPF;
#define CMPF_LEN sizeof(cmpf) const size_t CMPF_LEN = sizeof(cmpf);
/***************** end of tree top **********************/ /***************** end of tree top **********************/
// Forward declarations // Forward declarations
struct gpre_ctx; struct gpre_ctx;
@ -654,7 +669,7 @@ typedef struct act {
#define ACT_main 32 /* action is the main routine in the program/module */ #define ACT_main 32 /* action is the main routine in the program/module */
#define ACT_back_token 128 /* end of action marked by prior token */ #define ACT_back_token 128 /* end of action marked by prior token */
#define ACT_LEN sizeof(act) const size_t ACT_LEN = sizeof(act);
/* Symbol block, also used for hash table */ /* Symbol block, also used for hash table */
@ -695,7 +710,7 @@ typedef struct sym {
SCHAR sym_name[1]; /* space for name, if necessary */ SCHAR sym_name[1]; /* space for name, if necessary */
} *SYM; } *SYM;
#define SYM_LEN sizeof(sym) const size_t SYM_LEN = sizeof(sym);
/* Blob block. Used for blob calls */ /* Blob block. Used for blob calls */
@ -735,7 +750,7 @@ public:
}; };
typedef blb* BLB; typedef blb* BLB;
#define BLB_LEN sizeof(blb) const size_t BLB_LEN = sizeof(blb);
#define BLB_create 1 #define BLB_create 1
#define BLB_symbol_released 2 #define BLB_symbol_released 2
@ -750,7 +765,8 @@ typedef struct rrl {
gpre_rel* rrl_relation; /* relation block */ gpre_rel* rrl_relation; /* relation block */
} *RRL; } *RRL;
#define RRL_LEN sizeof(rrl) const size_t RRL_LEN = sizeof(rrl);
struct tpb; // forward declaration struct tpb; // forward declaration
@ -818,7 +834,7 @@ typedef struct dbb {
fil* dbb_files; fil* dbb_files;
} *DBB; } *DBB;
#define DBB_LEN sizeof(dbb) const size_t DBB_LEN = sizeof(dbb);
#define DBB_no_arrays 1 #define DBB_no_arrays 1
#define DBB_sqlca 2 /* Created as default for a sqlca */ #define DBB_sqlca 2 /* Created as default for a sqlca */
@ -846,7 +862,10 @@ typedef struct tpb {
UCHAR tpb_string[1]; /* actual TPB */ UCHAR tpb_string[1]; /* actual TPB */
} *TPB; } *TPB;
#define TPB_LEN(tpb_string) (sizeof(tpb) + tpb_string) inline size_t TPB_LEN(const size_t tpb_string_len)
{
return sizeof(tpb) + tpb_string_len;
}
/* Procedure structure */ /* Procedure structure */
@ -864,7 +883,7 @@ typedef struct gpre_prc {
SSHORT prc_flags; /* procedure flags */ SSHORT prc_flags; /* procedure flags */
} *GPRE_PRC; } *GPRE_PRC;
#define PRC_LEN sizeof(gpre_prc) const size_t PRC_LEN = sizeof(gpre_prc);
#define PRC_scanned 1 #define PRC_scanned 1
@ -907,9 +926,13 @@ typedef struct gpre_rse {
} *GPRE_RSE; } *GPRE_RSE;
inline size_t RSE_LEN(size_t nItems) inline size_t RSE_LEN(const size_t cnt)
{ {
return offsetof(gpre_rse, rse_context) + nItems * sizeof(int*); fb_assert(cnt != 0);
return sizeof(gpre_rse) + (cnt - 1) * sizeof (int*);
// CVC: The statement below avoids problem with cnt==0 but at the
// cost of a possible run-time memory error.
//return offsetof(gpre_rse, rse_context) + nItems * sizeof(int*);
} }
//#define RSE_LEN(cnt) (sizeof(gpre_rse) + (cnt - 1) * sizeof (int *)) //#define RSE_LEN(cnt) (sizeof(gpre_rse) + (cnt - 1) * sizeof (int *))
@ -936,7 +959,7 @@ typedef struct gpre_rel {
USHORT rel_flags; USHORT rel_flags;
} *GPRE_REL; } *GPRE_REL;
#define REL_LEN sizeof(gpre_rel) const size_t REL_LEN = sizeof(gpre_rel);
#define REL_view_check 1 /* View created with check option */ #define REL_view_check 1 /* View created with check option */
@ -950,7 +973,8 @@ typedef struct ind {
USHORT ind_flags; /* Miscellaneous flags */ USHORT ind_flags; /* Miscellaneous flags */
} *IND; } *IND;
#define IND_LEN sizeof(ind) const size_t IND_LEN = sizeof(ind);
#define IND_dup_flag 1 /* if false, duplicates not allowed */ #define IND_dup_flag 1 /* if false, duplicates not allowed */
#define IND_meta 2 /* if true, created for a metadata operation */ #define IND_meta 2 /* if true, created for a metadata operation */
#define IND_descend 4 /* if true, a descending-order index */ #define IND_descend 4 /* if true, a descending-order index */
@ -974,7 +998,7 @@ typedef struct intlsym { /* International symbol */
TEXT intlsym_name[2]; TEXT intlsym_name[2];
} *INTLSYM; } *INTLSYM;
#define INTLSYM_LEN sizeof(intlsym) const size_t INTLSYM_LEN = sizeof(intlsym);
/* values used in intlsym_type */ /* values used in intlsym_type */
@ -1024,7 +1048,7 @@ typedef struct gpre_fld {
SSHORT fld_ttype; /* ID of text type's implementation */ SSHORT fld_ttype; /* ID of text type's implementation */
} *GPRE_FLD; } *GPRE_FLD;
#define FLD_LEN sizeof(gpre_fld) const size_t FLD_LEN = sizeof(gpre_fld);
#define FLD_blob 1 #define FLD_blob 1
#define FLD_text 2 #define FLD_text 2
@ -1056,7 +1080,7 @@ typedef struct por {
USHORT por_count; /* number of items in port */ USHORT por_count; /* number of items in port */
} *POR; } *POR;
#define POR_LEN (sizeof(por)) const size_t POR_LEN = sizeof(por);
/* Slice description block */ /* Slice description block */
@ -1074,7 +1098,12 @@ typedef struct slc {
} slc_rpt[1]; } slc_rpt[1];
} *SLC; } *SLC;
#define SLC_LEN(count) (sizeof(slc) + sizeof(slc::slc_repeat) * (count - 1)) inline size_t SLC_LEN(const size_t count)
{
fb_assert(count != 0);
return sizeof(slc) + sizeof(slc::slc_repeat) * (count - 1);
}
//#define SLC_LEN(count) (sizeof(slc) + sizeof(slc::slc_repeat) * (count - 1))
/* Request block, corresponds to a single JRD request */ /* Request block, corresponds to a single JRD request */
@ -1165,7 +1194,7 @@ typedef struct gpre_req {
#endif #endif
#define REQ_blr_version4 262144 /* request must generate blr_version4 */ #define REQ_blr_version4 262144 /* request must generate blr_version4 */
#define REQ_LEN sizeof(gpre_req) const size_t REQ_LEN = sizeof(gpre_req);
/* Context block, used to define context symbols, etc. */ /* Context block, used to define context symbols, etc. */
@ -1183,7 +1212,7 @@ typedef struct gpre_ctx {
gpre_rse* ctx_stream; /* stream for context */ gpre_rse* ctx_stream; /* stream for context */
} *GPRE_CTX; } *GPRE_CTX;
#define CTX_LEN sizeof(gpre_ctx) const size_t CTX_LEN = sizeof(gpre_ctx);
/* Field reference */ /* Field reference */
@ -1226,7 +1255,7 @@ typedef struct ref {
#define REF_sql_time 256 /* Reference is to a time constant */ #define REF_sql_time 256 /* Reference is to a time constant */
#define REF_timestamp 512 /* Reference is to a timestamp constant */ #define REF_timestamp 512 /* Reference is to a timestamp constant */
#define REF_LEN sizeof(ref) const size_t REF_LEN = sizeof(ref);
/**************** start of tree roots *****************/ /**************** start of tree roots *****************/
@ -1243,7 +1272,7 @@ typedef struct bas {
char bas_terminator[2]; /* terminating character */ char bas_terminator[2]; /* terminating character */
} *BAS; } *BAS;
#define BAS_LEN (sizeof(bas)) const size_t BAS_LEN = sizeof(bas);
#define BAS_segment 1 /* Based on a blob segment length */ #define BAS_segment 1 /* Based on a blob segment length */
#define BAS_ambiguous 2 /* Ambiguous reference to segment */ #define BAS_ambiguous 2 /* Ambiguous reference to segment */
@ -1262,7 +1291,7 @@ typedef struct decl_udf {
} *DECL_UDF; } *DECL_UDF;
#define DECL_UDF_LEN sizeof(decl_udf) const size_t DECL_UDF_LEN = sizeof(decl_udf);
/* Dynamic statement block, used for dynamic SQL */ /* Dynamic statement block, used for dynamic SQL */
@ -1278,7 +1307,7 @@ typedef struct dyn {
gpre_nod* dyn_using; /* dependent on action type */ gpre_nod* dyn_using; /* dependent on action type */
} *DYN; } *DYN;
#define DYN_LEN sizeof(dyn) const size_t DYN_LEN = sizeof(dyn);
/* Start transaction block */ /* Start transaction block */
@ -1291,7 +1320,7 @@ typedef struct gpre_tra {
int tra_db_count; /* number of db's and TPB's */ int tra_db_count; /* number of db's and TPB's */
} *GPRE_TRA; } *GPRE_TRA;
#define TRA_LEN sizeof(gpre_tra) const size_t TRA_LEN = sizeof(gpre_tra);
/* values for tra_flags */ /* values for tra_flags */
@ -1326,7 +1355,7 @@ typedef struct opn {
ref* opn_using; /* Using variables */ ref* opn_using; /* Using variables */
} *OPN; } *OPN;
#define OPN_LEN (sizeof(opn)) const size_t OPN_LEN = sizeof(opn);
/* Ready block */ /* Ready block */
@ -1339,7 +1368,7 @@ typedef struct rdy {
TEXT *rdy_filename; TEXT *rdy_filename;
} *RDY; } *RDY;
#define RDY_LEN sizeof(rdy) const size_t RDY_LEN = sizeof(rdy);
/* Enumerated field type block */ /* Enumerated field type block */
@ -1350,7 +1379,7 @@ typedef struct typ {
SSHORT typ_value; /* Value of type */ SSHORT typ_value; /* Value of type */
} *TYP; } *TYP;
#define TYP_LEN sizeof(typ) const size_t TYP_LEN = sizeof(typ);
/* User Defined Function */ /* User Defined Function */
@ -1371,7 +1400,7 @@ typedef struct udf {
TEXT udf_function[1]; /* Function name */ TEXT udf_function[1]; /* Function name */
} *UDF; } *UDF;
#define UDF_LEN (sizeof(udf)) const size_t UDF_LEN = sizeof(udf);
#define UDF_value 0 #define UDF_value 0
#define UDF_boolean 1 #define UDF_boolean 1
@ -1393,7 +1422,7 @@ typedef struct upd {
ref* upd_array_references; /* array references under modify */ ref* upd_array_references; /* array references under modify */
} *UPD; } *UPD;
#define UPD_LEN sizeof(upd) const size_t UPD_LEN = sizeof(upd);
#include "../jrd/dsc.h" #include "../jrd/dsc.h"

File diff suppressed because it is too large Load Diff

View File

@ -24,29 +24,29 @@
#ifndef GPRE_GPRE_META_H #ifndef GPRE_GPRE_META_H
#define GPRE_GPRE_META_H #define GPRE_GPRE_META_H
GPRE_FLD MET_context_field(GPRE_CTX, char*); GPRE_FLD MET_context_field(GPRE_CTX, const char*);
bool MET_database(DBB, bool); bool MET_database(DBB, bool);
bool MET_domain_lookup(GPRE_REQ, GPRE_FLD, char*); bool MET_domain_lookup(GPRE_REQ, GPRE_FLD, const char*);
GPRE_FLD MET_field(GPRE_REL, char*); GPRE_FLD MET_field(GPRE_REL, const char*);
GPRE_NOD MET_fields(GPRE_CTX); GPRE_NOD MET_fields(GPRE_CTX);
void MET_fini(DBB); void MET_fini(DBB);
const SCHAR* MET_generator(const TEXT*, DBB); const SCHAR* MET_generator(const TEXT*, DBB);
bool MET_get_column_default(GPRE_REL, TEXT*, TEXT*, USHORT); bool MET_get_column_default(GPRE_REL, const TEXT*, TEXT*, USHORT);
bool MET_get_domain_default(DBB, const TEXT*, TEXT*, USHORT); bool MET_get_domain_default(DBB, const TEXT*, TEXT*, USHORT);
USHORT MET_get_dtype(USHORT, USHORT, USHORT*); USHORT MET_get_dtype(USHORT, USHORT, USHORT*);
LLS MET_get_primary_key(DBB, TEXT*); LLS MET_get_primary_key(DBB, const TEXT*);
GPRE_PRC MET_get_procedure(DBB, TEXT*, TEXT*); GPRE_PRC MET_get_procedure(DBB, const TEXT*, const TEXT*);
GPRE_REL MET_get_relation(DBB, TEXT*, TEXT*); GPRE_REL MET_get_relation(DBB, const TEXT*, const TEXT*);
INTLSYM MET_get_text_subtype(SSHORT); INTLSYM MET_get_text_subtype(SSHORT);
UDF MET_get_udf(DBB, TEXT*); UDF MET_get_udf(DBB, const TEXT*);
GPRE_REL MET_get_view_relation(GPRE_REQ, const char*, const char*, USHORT); GPRE_REL MET_get_view_relation(GPRE_REQ, const char*, const char*, USHORT);
IND MET_index(DBB, TEXT*); IND MET_index(DBB, TEXT*);
void MET_load_hash_table(DBB); void MET_load_hash_table(DBB);
GPRE_FLD MET_make_field(SCHAR*, SSHORT, SSHORT, bool); GPRE_FLD MET_make_field(const SCHAR*, SSHORT, SSHORT, bool);
IND MET_make_index(SCHAR*); IND MET_make_index(const SCHAR*);
GPRE_REL MET_make_relation(SCHAR*); GPRE_REL MET_make_relation(const SCHAR*);
bool MET_type(GPRE_FLD, TEXT*, SSHORT*); bool MET_type(GPRE_FLD, const TEXT*, SSHORT*);
bool MET_trigger_exists(DBB, TEXT*); bool MET_trigger_exists(DBB, const TEXT*);
#endif // GPRE_GPRE_META_H #endif // GPRE_GPRE_META_H

View File

@ -26,7 +26,7 @@
* *
*____________________________________________________________ *____________________________________________________________
* *
* $Id: gpre_meta_boot.cpp,v 1.25 2003-10-06 09:48:44 robocop Exp $ * $Id: gpre_meta_boot.cpp,v 1.26 2003-10-07 09:58:26 robocop Exp $
*/ */
#include "firebird.h" #include "firebird.h"
@ -62,10 +62,10 @@ static SCHAR db_version_info[] = { gds__info_base_level };
#endif #endif
#ifdef NOT_USED_OR_REPLACED #ifdef NOT_USED_OR_REPLACED
static SLONG array_size(GPRE_FLD); static SLONG array_size(GPRE_FLD);
static void get_array(DBB, TEXT *, GPRE_FLD); static void get_array(DBB, const TEXT*, GPRE_FLD);
static int get_intl_char_subtype(SSHORT *, UCHAR *, USHORT, DBB); static bool get_intl_char_subtype(SSHORT*, const UCHAR*, USHORT, DBB);
static int resolve_charset_and_collation(SSHORT *, UCHAR *, UCHAR *); static bool resolve_charset_and_collation(SSHORT*, const UCHAR*, const UCHAR*);
static int symbol_length(TEXT*); static int symbol_length(const TEXT*);
static int upcase(const TEXT*, TEXT*); static int upcase(const TEXT*, TEXT*);
#endif #endif
@ -75,11 +75,8 @@ static int upcase(const TEXT*, TEXT*);
* If found, return field block. If not, return NULL. * If found, return field block. If not, return NULL.
*/ */
GPRE_FLD MET_context_field( GPRE_CTX context, char *string) GPRE_FLD MET_context_field( GPRE_CTX context, const char* string)
{ {
SYM symbol;
GPRE_PRC procedure;
GPRE_FLD field;
SCHAR name[NAME_SIZE]; SCHAR name[NAME_SIZE];
if (context->ctx_relation) { if (context->ctx_relation) {
@ -91,14 +88,14 @@ GPRE_FLD MET_context_field( GPRE_CTX context, char *string)
} }
strcpy(name, string); strcpy(name, string);
procedure = context->ctx_procedure; GPRE_PRC procedure = context->ctx_procedure;
/* At this point the procedure should have been scanned, so all /* At this point the procedure should have been scanned, so all
* its fields are in the symbol table. * its fields are in the symbol table.
*/ */
field = NULL; GPRE_FLD field = NULL;
for (symbol = HSH_lookup(name); symbol; symbol = symbol->sym_homonym) { for (SYM symbol = HSH_lookup(name); symbol; symbol = symbol->sym_homonym) {
if (symbol->sym_type == SYM_field && if (symbol->sym_type == SYM_field &&
(field = (GPRE_FLD) symbol->sym_object) && (field = (GPRE_FLD) symbol->sym_object) &&
field->fld_procedure == procedure) field->fld_procedure == procedure)
@ -150,11 +147,9 @@ bool MET_database(DBB db,
bool MET_domain_lookup(GPRE_REQ request, bool MET_domain_lookup(GPRE_REQ request,
GPRE_FLD field, GPRE_FLD field,
char *string) const char* string)
{ {
SYM symbol;
SCHAR name[NAME_SIZE]; SCHAR name[NAME_SIZE];
GPRE_FLD d_field;
strcpy(name, string); strcpy(name, string);
@ -163,9 +158,12 @@ bool MET_domain_lookup(GPRE_REQ request,
* database. * database.
*/ */
for (symbol = HSH_lookup(name); symbol; symbol = symbol->sym_homonym) for (SYM symbol = HSH_lookup(name); symbol; symbol = symbol->sym_homonym)
{
GPRE_FLD d_field;
if ((symbol->sym_type == SYM_field) && if ((symbol->sym_type == SYM_field) &&
((d_field = (GPRE_FLD) symbol->sym_object) && (d_field != field))) { ((d_field = (GPRE_FLD) symbol->sym_object) && (d_field != field)))
{
field->fld_length = d_field->fld_length; field->fld_length = d_field->fld_length;
field->fld_scale = d_field->fld_scale; field->fld_scale = d_field->fld_scale;
field->fld_sub_type = d_field->fld_sub_type; field->fld_sub_type = d_field->fld_sub_type;
@ -176,6 +174,7 @@ bool MET_domain_lookup(GPRE_REQ request,
field->fld_char_length = d_field->fld_char_length; field->fld_char_length = d_field->fld_char_length;
return true; return true;
} }
}
if (!request) if (!request)
return false; return false;
@ -195,7 +194,6 @@ bool MET_get_domain_default(DBB db,
TEXT* buffer, TEXT* buffer,
USHORT buff_length) USHORT buff_length)
{ {
assert(0); assert(0);
return false; return false;
} }
@ -214,7 +212,7 @@ bool MET_get_domain_default(DBB db,
*/ */
bool MET_get_column_default(GPRE_REL relation, bool MET_get_column_default(GPRE_REL relation,
TEXT * column_name, const TEXT* column_name,
TEXT* buffer, TEXT* buffer,
USHORT buff_length) USHORT buff_length)
{ {
@ -230,7 +228,7 @@ bool MET_get_column_default(GPRE_REL relation,
* of the fields. * of the fields.
*/ */
LLS MET_get_primary_key(DBB db, TEXT * relation_name) LLS MET_get_primary_key(DBB db, const TEXT* relation_name)
{ {
SCHAR name[NAME_SIZE]; SCHAR name[NAME_SIZE];
@ -244,7 +242,7 @@ LLS MET_get_primary_key(DBB db, TEXT * relation_name)
assert(db->dbb_transaction == NULL); assert(db->dbb_transaction == NULL);
assert(0); assert(0);
return FALSE; return 0;
} }
@ -254,26 +252,30 @@ LLS MET_get_primary_key(DBB db, TEXT * relation_name)
* If found, return field block. If not, return NULL. * If found, return field block. If not, return NULL.
*/ */
GPRE_FLD MET_field(GPRE_REL relation, char *string) GPRE_FLD MET_field(GPRE_REL relation, const char* string)
{ {
SYM symbol;
GPRE_FLD field; GPRE_FLD field;
SCHAR name[NAME_SIZE]; SCHAR name[NAME_SIZE];
SSHORT length;
strcpy(name, string); strcpy(name, string);
length = strlen(name); //const SSHORT length = strlen(name);
/* Lookup field. If we find it, nifty. If not, look it up in the /* Lookup field. If we find it, nifty. If not, look it up in the
* database. * database.
*/ */
for (symbol = HSH_lookup(name); symbol; symbol = symbol->sym_homonym) for (SYM symbol = HSH_lookup(name); symbol; symbol = symbol->sym_homonym)
if (symbol->sym_type == SYM_keyword && if (symbol->sym_type == SYM_keyword &&
symbol->sym_keyword == (int) KW_DBKEY) return relation->rel_dbkey; symbol->sym_keyword == (int) KW_DBKEY)
{
return relation->rel_dbkey;
}
else if (symbol->sym_type == SYM_field && else if (symbol->sym_type == SYM_field &&
(field = (GPRE_FLD) symbol->sym_object) && (field = (GPRE_FLD) symbol->sym_object) &&
field->fld_relation == relation) return field; field->fld_relation == relation)
{
return field;
}
if (sw_language == lang_internal) if (sw_language == lang_internal)
return NULL; return NULL;
@ -292,37 +294,37 @@ GPRE_NOD MET_fields(GPRE_CTX context)
GPRE_FLD field; GPRE_FLD field;
GPRE_NOD node, field_node; GPRE_NOD node, field_node;
REF reference; REF reference;
GPRE_PRC procedure;
GPRE_REL relation;
int count;
if (procedure = context->ctx_procedure) { GPRE_PRC procedure = context->ctx_procedure;
if (procedure) {
node = MAKE_NODE(nod_list, procedure->prc_out_count); node = MAKE_NODE(nod_list, procedure->prc_out_count);
count = 0; //int count = 0;
for (field = procedure->prc_outputs; field; field = field->fld_next) { for (field = procedure->prc_outputs; field; field = field->fld_next) {
reference = (REF) ALLOC(REF_LEN); reference = (REF) ALLOC(REF_LEN);
reference->ref_field = field; reference->ref_field = field;
reference->ref_context = context; reference->ref_context = context;
field_node = MSC_unary(nod_field, (GPRE_NOD)reference); field_node = MSC_unary(nod_field, (GPRE_NOD)reference);
node->nod_arg[field->fld_position] = field_node; node->nod_arg[field->fld_position] = field_node;
count++; //count++;
} }
return node; return node;
} }
relation = context->ctx_relation; GPRE_REL relation = context->ctx_relation;
if (relation->rel_meta) { if (relation->rel_meta) {
for (count = 0, field = relation->rel_fields; field; int count = 0;
field = field->fld_next) count++; for (field = relation->rel_fields; field; field = field->fld_next) {
count++;
}
node = MAKE_NODE(nod_list, count); node = MAKE_NODE(nod_list, count);
count = 0; //count = 0;
for (field = relation->rel_fields; field; field = field->fld_next) { for (field = relation->rel_fields; field; field = field->fld_next) {
reference = (REF) ALLOC(REF_LEN); reference = (REF) ALLOC(REF_LEN);
reference->ref_field = field; reference->ref_field = field;
reference->ref_context = context; reference->ref_context = context;
field_node = MSC_unary(nod_field, (GPRE_NOD)reference); field_node = MSC_unary(nod_field, (GPRE_NOD)reference);
node->nod_arg[field->fld_position] = field_node; node->nod_arg[field->fld_position] = field_node;
count++; //count++;
} }
return node; return node;
} }
@ -375,9 +377,9 @@ const SCHAR* MET_generator(const TEXT* string, DBB db)
USHORT MET_get_dtype(USHORT blr_dtype, USHORT sub_type, USHORT* length) USHORT MET_get_dtype(USHORT blr_dtype, USHORT sub_type, USHORT* length)
{ {
USHORT l, dtype; USHORT dtype;
l = *length; USHORT l = *length;
switch (blr_dtype) { switch (blr_dtype) {
case blr_varying: case blr_varying:
@ -464,17 +466,15 @@ USHORT MET_get_dtype(USHORT blr_dtype, USHORT sub_type, USHORT * length)
* This function has been cloned into MET_get_udf * This function has been cloned into MET_get_udf
*/ */
GPRE_PRC MET_get_procedure(DBB db, TEXT * string, TEXT * owner_name) GPRE_PRC MET_get_procedure(DBB db, const TEXT* string, const TEXT* owner_name)
{ {
SYM symbol;
GPRE_PRC procedure;
SCHAR name[NAME_SIZE], owner[NAME_SIZE]; SCHAR name[NAME_SIZE], owner[NAME_SIZE];
strcpy(name, string); strcpy(name, string);
strcpy(owner, owner_name); strcpy(owner, owner_name);
procedure = NULL; GPRE_PRC procedure = NULL;
for (symbol = HSH_lookup(name); symbol; symbol = symbol->sym_homonym) for (SYM symbol = HSH_lookup(name); symbol; symbol = symbol->sym_homonym)
if (symbol->sym_type == SYM_procedure && if (symbol->sym_type == SYM_procedure &&
(procedure = (GPRE_PRC) symbol->sym_object) && (procedure = (GPRE_PRC) symbol->sym_object) &&
procedure->prc_database == db && procedure->prc_database == db &&
@ -502,16 +502,15 @@ GPRE_PRC MET_get_procedure(DBB db, TEXT * string, TEXT * owner_name)
* Return a relation block (if name is found) or NULL. * Return a relation block (if name is found) or NULL.
*/ */
GPRE_REL MET_get_relation(DBB db, TEXT * string, TEXT * owner_name) GPRE_REL MET_get_relation(DBB db, const TEXT* string, const TEXT* owner_name)
{ {
SYM symbol;
GPRE_REL relation; GPRE_REL relation;
SCHAR name[NAME_SIZE], owner[NAME_SIZE]; SCHAR name[NAME_SIZE], owner[NAME_SIZE];
strcpy(name, string); strcpy(name, string);
strcpy(owner, owner_name); strcpy(owner, owner_name);
for (symbol = HSH_lookup(name); symbol; symbol = symbol->sym_homonym) for (SYM symbol = HSH_lookup(name); symbol; symbol = symbol->sym_homonym)
if (symbol->sym_type == SYM_relation && if (symbol->sym_type == SYM_relation &&
(relation = (GPRE_REL) symbol->sym_object) && (relation = (GPRE_REL) symbol->sym_object) &&
relation->rel_database == db && relation->rel_database == db &&
@ -533,9 +532,7 @@ GPRE_REL MET_get_relation(DBB db, TEXT * string, TEXT * owner_name)
INTLSYM MET_get_text_subtype(SSHORT ttype) INTLSYM MET_get_text_subtype(SSHORT ttype)
{ {
INTLSYM p; for (INTLSYM p = text_subtypes; p; p = p->intlsym_next)
for (p = text_subtypes; p; p = p->intlsym_next)
if (p->intlsym_ttype == ttype) if (p->intlsym_ttype == ttype)
return p; return p;
@ -551,15 +548,13 @@ INTLSYM MET_get_text_subtype(SSHORT ttype)
* This function was cloned from MET_get_procedure * This function was cloned from MET_get_procedure
*/ */
UDF MET_get_udf(DBB db, TEXT * string) UDF MET_get_udf(DBB db, const TEXT* string)
{ {
SYM symbol;
UDF udf_val;
SCHAR name[NAME_SIZE]; SCHAR name[NAME_SIZE];
strcpy(name, string); strcpy(name, string);
udf_val = NULL; UDF udf_val = NULL;
for (symbol = HSH_lookup(name); symbol; symbol = symbol->sym_homonym) for (SYM symbol = HSH_lookup(name); symbol; symbol = symbol->sym_homonym)
if (symbol->sym_type == SYM_udf && if (symbol->sym_type == SYM_udf &&
(udf_val = (UDF) symbol->sym_object) && udf_val->udf_database == db) (udf_val = (UDF) symbol->sym_object) && udf_val->udf_database == db)
{ {
@ -596,17 +591,15 @@ GPRE_REL MET_get_view_relation(GPRE_REQ request,
* Return an index block (if name is found) or NULL. * Return an index block (if name is found) or NULL.
*/ */
IND MET_index(DBB db, TEXT * string) IND MET_index(DBB db, const TEXT* string)
{ {
SYM symbol;
IND index; IND index;
SCHAR name[NAME_SIZE]; SCHAR name[NAME_SIZE];
SSHORT length;
strcpy(name, string); strcpy(name, string);
length = strlen(name); //const SSHORT length = strlen(name);
for (symbol = HSH_lookup(name); symbol; symbol = symbol->sym_homonym) for (SYM symbol = HSH_lookup(name); symbol; symbol = symbol->sym_homonym)
if (symbol->sym_type == SYM_index && if (symbol->sym_type == SYM_index &&
(index = (IND) symbol->sym_object) && (index = (IND) symbol->sym_object) &&
index->ind_relation->rel_database == db) index->ind_relation->rel_database == db)
@ -646,19 +639,17 @@ void MET_load_hash_table( DBB db)
* Make a field symbol. * Make a field symbol.
*/ */
GPRE_FLD MET_make_field(SCHAR * name, GPRE_FLD MET_make_field(const SCHAR* name,
SSHORT dtype, SSHORT dtype,
SSHORT length, SSHORT length,
bool insert_flag) bool insert_flag)
{ {
GPRE_FLD field; GPRE_FLD field = (GPRE_FLD) ALLOC(FLD_LEN);
SYM symbol;
field = (GPRE_FLD) ALLOC(FLD_LEN);
field->fld_length = length; field->fld_length = length;
field->fld_dtype = dtype; field->fld_dtype = dtype;
field->fld_symbol = symbol = SYM symbol = MSC_symbol(SYM_field, name, strlen(name), (GPRE_CTX)field);
MSC_symbol(SYM_field, name, strlen(name), (GPRE_CTX)field); field->fld_symbol = symbol;
if (insert_flag) if (insert_flag)
HSH_insert(symbol); HSH_insert(symbol);
@ -671,11 +662,9 @@ GPRE_FLD MET_make_field(SCHAR * name,
* Make an index symbol. * Make an index symbol.
*/ */
IND MET_make_index(SCHAR * name) IND MET_make_index(const SCHAR* name)
{ {
IND index; IND index = (IND) ALLOC(IND_LEN);
index = (IND) ALLOC(IND_LEN);
index->ind_symbol = MSC_symbol(SYM_index, name, strlen(name), (GPRE_CTX)index); index->ind_symbol = MSC_symbol(SYM_index, name, strlen(name), (GPRE_CTX)index);
return index; return index;
@ -687,11 +676,9 @@ IND MET_make_index(SCHAR * name)
* Make an relation symbol. * Make an relation symbol.
*/ */
GPRE_REL MET_make_relation(SCHAR * name) GPRE_REL MET_make_relation(const SCHAR* name)
{ {
GPRE_REL relation; GPRE_REL relation = (GPRE_REL) ALLOC(REL_LEN);
relation = (GPRE_REL) ALLOC(REL_LEN);
relation->rel_symbol = relation->rel_symbol =
MSC_symbol(SYM_relation, name, strlen(name), (GPRE_CTX)relation); MSC_symbol(SYM_relation, name, strlen(name), (GPRE_CTX)relation);
@ -705,13 +692,12 @@ GPRE_REL MET_make_relation(SCHAR * name)
*/ */
bool MET_type(GPRE_FLD field, bool MET_type(GPRE_FLD field,
TEXT * string, const TEXT* string,
SSHORT* ptr) SSHORT* ptr)
{ {
SYM symbol;
TYP type; TYP type;
for (symbol = HSH_lookup(string); symbol; symbol = symbol->sym_homonym) for (SYM symbol = HSH_lookup(string); symbol; symbol = symbol->sym_homonym)
if (symbol->sym_type == SYM_type && if (symbol->sym_type == SYM_type &&
(type = (TYP) symbol->sym_object) && (type = (TYP) symbol->sym_object) &&
(!type->typ_field || type->typ_field == field)) (!type->typ_field || type->typ_field == field))
@ -734,11 +720,11 @@ bool MET_type(GPRE_FLD field,
*/ */
bool MET_trigger_exists(DBB db, bool MET_trigger_exists(DBB db,
TEXT * trigger_name) const TEXT* trigger_name)
{ {
SCHAR name[NAME_SIZE]; //SCHAR name[NAME_SIZE];
strcpy(name, trigger_name); //strcpy(name, trigger_name);
assert(0); assert(0);
return false; return false;
@ -752,15 +738,14 @@ bool MET_trigger_exists(DBB db,
static SLONG array_size( GPRE_FLD field) static SLONG array_size( GPRE_FLD field)
{ {
ARY array_block; ARY array_block = field->fld_array_info;
DIM dimension; SLONG count = field->fld_array->fld_length;
SLONG count; for (DIM dimension = array_block->ary_dimension; dimension;
dimension = dimension->dim_next)
array_block = field->fld_array_info; {
count = field->fld_array->fld_length; count =
for (dimension = array_block->ary_dimension; dimension;
dimension = dimension->dim_next) count =
count * (dimension->dim_upper - dimension->dim_lower + 1); count * (dimension->dim_upper - dimension->dim_lower + 1);
}
return count; return count;
} }
@ -771,7 +756,7 @@ static SLONG array_size( GPRE_FLD field)
* See if field is array. * See if field is array.
*/ */
static void get_array( DBB db, TEXT * field_name, GPRE_FLD field) static void get_array( DBB db, const TEXT* field_name, GPRE_FLD field)
{ {
assert(0); assert(0);
return; return;
@ -792,12 +777,12 @@ static void get_array( DBB db, TEXT * field_name, GPRE_FLD field)
* (in which case c) and d) are not tried). * (in which case c) and d) are not tried).
* *
* Return: * Return:
* 1 if no errors (and *id is set). * true if no errors (and *id is set).
* 0 if the name could not be resolved. * false if the name could not be resolved.
*/ */
static int get_intl_char_subtype(SSHORT * id, static bool get_intl_char_subtype(SSHORT* id,
UCHAR * name, const UCHAR* name,
USHORT length, USHORT length,
DBB db) DBB db)
{ {
@ -806,7 +791,7 @@ static int get_intl_char_subtype(SSHORT * id,
assert(db != NULL); assert(db != NULL);
assert(0); assert(0);
return (0); return false;
} }
@ -831,20 +816,20 @@ static int get_intl_char_subtype(SSHORT * id,
* Set to subtype specified by this name. * Set to subtype specified by this name.
* *
* Return: * Return:
* 1 if no errors (and *id is set). * true if no errors (and *id is set).
* 0 if either name not found. * false if either name not found.
* or if names found, but the collation isn't for the specified * or if names found, but the collation isn't for the specified
* character set. * character set.
*/ */
static int resolve_charset_and_collation( static bool resolve_charset_and_collation(
SSHORT* id, SSHORT* id,
UCHAR * charset, UCHAR * collation) const UCHAR* charset, const UCHAR* collation)
{ {
assert(id != NULL); assert(id != NULL);
assert(0); assert(0);
return (0); return (false);
} }
@ -855,7 +840,7 @@ static int resolve_charset_and_collation(
static int symbol_length(const TEXT* string) static int symbol_length(const TEXT* string)
{ {
size_t len = strlen(string); const size_t len = strlen(string);
const TEXT* p = string + (len - 1); const TEXT* p = string + (len - 1);
@ -875,10 +860,10 @@ static int symbol_length(const TEXT* string)
static int upcase(const TEXT* from, TEXT* to) static int upcase(const TEXT* from, TEXT* to)
{ {
TEXT *p, *end, c; TEXT c;
p = to; TEXT* p = to;
end = to + NAME_SIZE; TEXT* const end = to + NAME_SIZE;
while (p < end && (c = *from++)) { while (p < end && (c = *from++)) {
*p++ = UPPER(c); *p++ = UPPER(c);

View File

@ -24,7 +24,7 @@
// //
//____________________________________________________________ //____________________________________________________________
// //
// $Id: pas.cpp,v 1.25 2003-10-06 09:48:44 robocop Exp $ // $Id: pas.cpp,v 1.26 2003-10-07 09:58:26 robocop Exp $
// //
#include "firebird.h" #include "firebird.h"
@ -50,10 +50,10 @@
static void align(const int); static void align(const int);
static void asgn_from(const act*, REF, int); static void asgn_from(const act*, const ref*, int);
static void asgn_sqlda_from(REF, int, TEXT *, int); static void asgn_sqlda_from(const ref*, int, TEXT*, int);
static void asgn_to(const act*, REF, int); static void asgn_to(const act*, const ref*, int);
static void asgn_to_proc(REF, int); static void asgn_to_proc(const ref*, int);
static void gen_at_end(const act*, int); static void gen_at_end(const act*, int);
static void gen_based(const act*, int); static void gen_based(const act*, int);
static void gen_blob_close(const act*, USHORT); static void gen_blob_close(const act*, USHORT);
@ -63,9 +63,9 @@ static void gen_blob_open(const act*, USHORT);
static void gen_blr(void*, SSHORT, const char*); static void gen_blr(void*, SSHORT, const char*);
static void gen_compile(const act*, int); static void gen_compile(const act*, int);
static void gen_create_database(const act*, int); static void gen_create_database(const act*, int);
static int gen_cursor_close(const act*, GPRE_REQ, int); static int gen_cursor_close(const act*, const gpre_req*, int);
static void gen_cursor_init(const act*, int); static void gen_cursor_init(const act*, int);
static int gen_cursor_open(const act*, GPRE_REQ, int); static int gen_cursor_open(const act*, const gpre_req*, int);
static void gen_database(const act*, int); static void gen_database(const act*, int);
static void gen_ddl(const act*, int); static void gen_ddl(const act*, int);
static void gen_drop_database(const act*, int); static void gen_drop_database(const act*, int);
@ -88,10 +88,10 @@ static void gen_event_wait(const act*, int);
static void gen_fetch(const act*, int); static void gen_fetch(const act*, int);
static void gen_finish(const act*, int); static void gen_finish(const act*, int);
static void gen_for(const act*, int); static void gen_for(const act*, int);
static void gen_get_or_put_slice(const act*, REF, bool, int); static void gen_get_or_put_slice(const act*, const ref*, bool, int);
static void gen_get_segment(const act*, int); static void gen_get_segment(const act*, int);
static void gen_loop(const act*, int); static void gen_loop(const act*, int);
static TEXT *gen_name(TEXT *, REF, bool); static TEXT *gen_name(TEXT *, const ref*, bool);
static void gen_on_error(const act*, USHORT); static void gen_on_error(const act*, USHORT);
static void gen_procedure(const act*, int); static void gen_procedure(const act*, int);
static void gen_put_segment(const act*, int); static void gen_put_segment(const act*, int);
@ -99,7 +99,7 @@ static void gen_raw(UCHAR *, int, int);
static void gen_ready(const act*, int); static void gen_ready(const act*, int);
static void gen_receive(const act*, int, POR); static void gen_receive(const act*, int, POR);
static void gen_release(const act*, int); static void gen_release(const act*, int);
static void gen_request(GPRE_REQ, int); static void gen_request(const gpre_req*, int);
static void gen_return_value(const act*, int); static void gen_return_value(const act*, int);
static void gen_routine(const act*, int); static void gen_routine(const act*, int);
static void gen_s_end(const act*, int); static void gen_s_end(const act*, int);
@ -116,16 +116,16 @@ static void gen_tpb(TPB, int);
static void gen_trans(const act*, int); static void gen_trans(const act*, int);
static void gen_update(const act*, int); static void gen_update(const act*, int);
static void gen_variable(const act*, int); static void gen_variable(const act*, int);
static void gen_whenever(SWE, int); static void gen_whenever(const swe*, int);
static void make_array_declaration(REF); static void make_array_declaration(const ref*);
static TEXT* make_name(TEXT*, SYM); static TEXT* make_name(TEXT*, SYM);
static void make_ok_test(const act*, GPRE_REQ, int); static void make_ok_test(const act*, const gpre_req*, int);
static void make_port(POR, int); static void make_port(POR, int);
static void make_ready(DBB, TEXT *, TEXT *, USHORT, GPRE_REQ); static void make_ready(DBB, TEXT*, TEXT*, USHORT, const gpre_req*);
static void printa(int, const char*, ...); static void printa(int, const char*, ...);
static const TEXT* request_trans(const act*, GPRE_REQ); static const TEXT* request_trans(const act*, const gpre_req*);
static TEXT* status_vector(const act*); static TEXT* status_vector(const act*);
static void t_start_auto(const act*, GPRE_REQ, TEXT *, int); static void t_start_auto(const act*, const gpre_req*, TEXT *, int);
static int first_flag; static int first_flag;
@ -545,7 +545,7 @@ static void align(const int column)
// a port variable. // a port variable.
// //
static void asgn_from( const act* action, REF reference, int column) static void asgn_from( const act* action, const ref* reference, int column)
{ {
GPRE_FLD field; GPRE_FLD field;
TEXT *value, name[64], variable[20], temp[20]; TEXT *value, name[64], variable[20], temp[20];
@ -598,7 +598,7 @@ static void asgn_from( const act* action, REF reference, int column)
// a sqlda variable. // a sqlda variable.
// //
static void asgn_sqlda_from( REF reference, int number, TEXT * string, int column) static void asgn_sqlda_from( const ref* reference, int number, TEXT * string, int column)
{ {
TEXT *value, temp[20]; TEXT *value, temp[20];
@ -621,13 +621,12 @@ static void asgn_sqlda_from( REF reference, int number, TEXT * string, int colum
// a port variable. // a port variable.
// //
static void asgn_to(const act* action, REF reference, int column) static void asgn_to(const act* action, const ref* reference, int column)
{ {
GPRE_FLD field; GPRE_FLD field;
REF source;
TEXT s[128]; TEXT s[128];
source = reference->ref_friend; ref* source = reference->ref_friend;
field = source->ref_field; field = source->ref_field;
if (field && field->fld_array_info) { if (field && field->fld_array_info) {
@ -660,7 +659,7 @@ static void asgn_to(const act* action, REF reference, int column)
// a port variable. // a port variable.
// //
static void asgn_to_proc(REF reference, int column) static void asgn_to_proc(const ref* reference, int column)
{ {
GPRE_FLD field; GPRE_FLD field;
TEXT s[64]; TEXT s[64];
@ -692,7 +691,7 @@ static void asgn_to_proc(REF reference, int column)
static void gen_at_end( const act* action, int column) static void gen_at_end( const act* action, int column)
{ {
GPRE_REQ request; const gpre_req* request;
TEXT s[20]; TEXT s[20];
request = action->act_request; request = action->act_request;
@ -884,7 +883,7 @@ static void gen_blob_open( const act* action, USHORT column)
{ {
BLB blob; BLB blob;
PAT args; PAT args;
REF reference; const ref* reference;
TEXT s[20]; TEXT s[20];
TEXT *pattern1 = TEXT *pattern1 =
"GDS__%IFCREATE%ELOPEN%EN_BLOB2 (%V1, %RF%DH, %RF%RT, %RF%BH, %RF%FR, %N1, %RF%I1);", "GDS__%IFCREATE%ELOPEN%EN_BLOB2 (%V1, %RF%DH, %RF%RT, %RF%BH, %RF%FR, %N1, %RF%I1);",
@ -1008,7 +1007,7 @@ static void gen_blr(void* user_arg, SSHORT offset, const char* string)
static void gen_compile( const act* action, int column) static void gen_compile( const act* action, int column)
{ {
GPRE_REQ request; const gpre_req* request;
DBB db; DBB db;
SYM symbol; SYM symbol;
TEXT *filename; TEXT *filename;
@ -1061,7 +1060,7 @@ static void gen_compile( const act* action, int column)
static void gen_create_database( const act* action, int column) static void gen_create_database( const act* action, int column)
{ {
GPRE_REQ request; const gpre_req* request;
DBB db; DBB db;
request = ((MDBB) action->act_object)->mdbb_dpb_request; request = ((MDBB) action->act_object)->mdbb_dpb_request;
@ -1097,7 +1096,7 @@ static void gen_create_database( const act* action, int column)
// Generate substitution text for END_STREAM. // Generate substitution text for END_STREAM.
// //
static int gen_cursor_close( const act* action, GPRE_REQ request, int column) static int gen_cursor_close( const act* action, const gpre_req* request, int column)
{ {
PAT args; PAT args;
TEXT *pattern1 = "if %RIs <> nil then"; TEXT *pattern1 = "if %RIs <> nil then";
@ -1145,7 +1144,7 @@ static void gen_cursor_init( const act* action, int column)
// Generate text to open an embedded SQL cursor. // Generate text to open an embedded SQL cursor.
// //
static int gen_cursor_open( const act* action, GPRE_REQ request, int column) static int gen_cursor_open( const act* action, const gpre_req* request, int column)
{ {
PAT args; PAT args;
TEXT s[64]; TEXT s[64];
@ -1195,13 +1194,13 @@ static int gen_cursor_open( const act* action, GPRE_REQ request, int column)
static void gen_database( const act* action, int column) static void gen_database( const act* action, int column)
{ {
DBB db; DBB db;
GPRE_REQ request; const gpre_req* request;
POR port; POR port;
BLB blob; BLB blob;
USHORT count; USHORT count;
TPB tpb_val; TPB tpb_val;
int indent; int indent;
REF reference; const ref* reference;
SSHORT event_count; SSHORT event_count;
SSHORT max_count; SSHORT max_count;
LLS stack_ptr; LLS stack_ptr;
@ -1438,7 +1437,7 @@ static void gen_database( const act* action, int column)
static void gen_ddl( const act* action, int column) static void gen_ddl( const act* action, int column)
{ {
GPRE_REQ request; const gpre_req* request;
if (sw_auto) { if (sw_auto) {
printa(column, "if (gds__trans = nil) then"); printa(column, "if (gds__trans = nil) then");
@ -1806,16 +1805,16 @@ static void gen_dyn_prepare( const act* action, int column)
static void gen_emodify( const act* action, int column) static void gen_emodify( const act* action, int column)
{ {
UPD modify;
REF reference, source;
GPRE_FLD field; GPRE_FLD field;
TEXT s1[20], s2[20]; TEXT s1[20], s2[20];
modify = (UPD) action->act_object; UPD modify = (UPD) action->act_object;
for (reference = modify->upd_port->por_references; reference; for (const ref* reference = modify->upd_port->por_references; reference;
reference = reference->ref_next) { reference = reference->ref_next)
if (!(source = reference->ref_source)) {
const ref* source = reference->ref_source;
if (!source)
continue; continue;
field = reference->ref_field; field = reference->ref_field;
align(column); align(column);
@ -1836,7 +1835,7 @@ static void gen_emodify( const act* action, int column)
static void gen_estore( const act* action, int column) static void gen_estore( const act* action, int column)
{ {
GPRE_REQ request; const gpre_req* request;
request = action->act_request; request = action->act_request;
// if we did a store ... returning_values aka store2 // if we did a store ... returning_values aka store2
@ -1861,7 +1860,7 @@ static void gen_estore( const act* action, int column)
static void gen_endfor( const act* action, int column) static void gen_endfor( const act* action, int column)
{ {
GPRE_REQ request; const gpre_req* request;
request = action->act_request; request = action->act_request;
column += INDENT; column += INDENT;
@ -1934,7 +1933,7 @@ static SSHORT gen_event_block( const act* action)
static void gen_event_init( const act* action, int column) static void gen_event_init( const act* action, int column)
{ {
GPRE_NOD init, event_list, *ptr, *end, node; GPRE_NOD init, event_list, *ptr, *end, node;
REF reference; const ref* reference;
PAT args; PAT args;
SSHORT count; SSHORT count;
TEXT variable[20]; TEXT variable[20];
@ -1964,7 +1963,7 @@ static void gen_event_init( const act* action, int column)
count++; count++;
node = *ptr; node = *ptr;
if (node->nod_type == nod_field) { if (node->nod_type == nod_field) {
reference = (REF) node->nod_arg[0]; reference = (const ref*) node->nod_arg[0];
gen_name(variable, reference, true); gen_name(variable, reference, true);
printa(column, "gds__event_names2[%d] := %s;", count, variable); printa(column, "gds__event_names2[%d] := %s;", count, variable);
} }
@ -2062,7 +2061,7 @@ static void gen_event_wait( const act* action, int column)
static void gen_fetch( const act* action, int column) static void gen_fetch( const act* action, int column)
{ {
GPRE_REQ request; const gpre_req* request;
GPRE_NOD var_list; GPRE_NOD var_list;
int i; int i;
TEXT s[20]; TEXT s[20];
@ -2071,7 +2070,7 @@ static void gen_fetch( const act* action, int column)
#ifdef SCROLLABLE_CURSORS #ifdef SCROLLABLE_CURSORS
POR port; POR port;
REF reference; const ref* reference;
VAL value; VAL value;
TEXT* direction; TEXT* direction;
TEXT* offset; TEXT* offset;
@ -2210,9 +2209,9 @@ static void gen_finish( const act* action, int column)
static void gen_for( const act* action, int column) static void gen_for( const act* action, int column)
{ {
POR port; POR port;
GPRE_REQ request; const gpre_req* request;
TEXT s[20]; TEXT s[20];
REF reference; const ref* reference;
gen_s_start(action, column); gen_s_start(action, column);
request = action->act_request; request = action->act_request;
@ -2247,7 +2246,7 @@ static void gen_for( const act* action, int column)
// //
static void gen_get_or_put_slice(const act* action, static void gen_get_or_put_slice(const act* action,
REF reference, const ref* reference,
bool get, bool get,
int column) int column)
{ {
@ -2308,7 +2307,7 @@ static void gen_get_segment( const act* action, int column)
{ {
BLB blob; BLB blob;
PAT args; PAT args;
REF into; const ref* into;
TEXT *pattern1 = TEXT *pattern1 =
"%IFgds__status[2] := %ENGDS__GET_SEGMENT (%V1, %BH, %I1, %S1 (%I2), %RF%I2);"; "%IFgds__status[2] := %ENGDS__GET_SEGMENT (%V1, %BH, %I1, %S1 (%I2), %RF%I2);";
@ -2357,7 +2356,7 @@ static void gen_get_segment( const act* action, int column)
static void gen_loop( const act* action, int column) static void gen_loop( const act* action, int column)
{ {
GPRE_REQ request; const gpre_req* request;
POR port; POR port;
TEXT name[20]; TEXT name[20];
@ -2383,7 +2382,7 @@ static void gen_loop( const act* action, int column)
// //
static TEXT *gen_name(TEXT * string, static TEXT *gen_name(TEXT * string,
REF reference, const ref* reference,
bool as_blob) bool as_blob)
{ {
@ -2427,7 +2426,7 @@ static void gen_procedure( const act* action, int column)
{ {
PAT args; PAT args;
TEXT *pattern; TEXT *pattern;
GPRE_REQ request; const gpre_req* request;
POR in_port, out_port; POR in_port, out_port;
column += INDENT; column += INDENT;
@ -2484,7 +2483,7 @@ static void gen_put_segment( const act* action, int column)
{ {
BLB blob; BLB blob;
PAT args; PAT args;
REF from; const ref* from;
TEXT *pattern1 = TEXT *pattern1 =
"%IFgds__status[2] := %ENGDS__PUT_SEGMENT (%V1, %BH, %I1, %I2);"; "%IFgds__status[2] := %ENGDS__PUT_SEGMENT (%V1, %BH, %I1, %I2);";
@ -2592,7 +2591,7 @@ static void gen_ready( const act* action, int column)
static void gen_receive( const act* action, int column, POR port) static void gen_receive( const act* action, int column, POR port)
{ {
GPRE_REQ request; const gpre_req* request;
align(column); align(column);
@ -2622,7 +2621,7 @@ static void gen_receive( const act* action, int column, POR port)
static void gen_release( const act* action, int column) static void gen_release( const act* action, int column)
{ {
DBB db, exp_db; DBB db, exp_db;
GPRE_REQ request; const gpre_req* request;
exp_db = (DBB) action->act_object; exp_db = (DBB) action->act_object;
@ -2645,12 +2644,12 @@ static void gen_release( const act* action, int column)
// Generate definitions associated with a single request. // Generate definitions associated with a single request.
// //
static void gen_request( GPRE_REQ request, int column) static void gen_request( const gpre_req* request, int column)
{ {
BLB blob; BLB blob;
POR port; POR port;
TEXT *sw_volatile, *string_type; TEXT *sw_volatile, *string_type;
REF reference; const ref* reference;
// generate request handle, blob handles, and ports // generate request handle, blob handles, and ports
@ -2791,8 +2790,8 @@ static void gen_request( GPRE_REQ request, int column)
static void gen_return_value( const act* action, int column) static void gen_return_value( const act* action, int column)
{ {
UPD update; UPD update;
REF reference; const ref* reference;
GPRE_REQ request; const gpre_req* request;
request = action->act_request; request = action->act_request;
if (action->act_pair->act_error) if (action->act_pair->act_error)
@ -2813,12 +2812,12 @@ static void gen_return_value( const act* action, int column)
static void gen_routine( const act* action, int column) static void gen_routine( const act* action, int column)
{ {
BLB blob; BLB blob;
GPRE_REQ request; const gpre_req* request;
POR port; POR port;
column += INDENT; column += INDENT;
for (request = (GPRE_REQ) action->act_object; request; for (request = (const gpre_req*) action->act_object; request;
request = request->req_routine) { request = request->req_routine) {
for (port = request->req_ports; port; port = port->por_next) { for (port = request->req_ports; port; port = port->por_next) {
printa(column - INDENT, "type"); printa(column - INDENT, "type");
@ -2857,7 +2856,7 @@ static void gen_routine( const act* action, int column)
static void gen_s_end( const act* action, int column) static void gen_s_end( const act* action, int column)
{ {
GPRE_REQ request; const gpre_req* request;
if (action->act_error) if (action->act_error)
begin(column); begin(column);
@ -2888,7 +2887,7 @@ static void gen_s_end( const act* action, int column)
static void gen_s_fetch( const act* action, int column) static void gen_s_fetch( const act* action, int column)
{ {
GPRE_REQ request; const gpre_req* request;
request = action->act_request; request = action->act_request;
if (request->req_sync) if (request->req_sync)
@ -2908,7 +2907,7 @@ static void gen_s_fetch( const act* action, int column)
static void gen_s_start( const act* action, int column) static void gen_s_start( const act* action, int column)
{ {
GPRE_REQ request; const gpre_req* request;
POR port; POR port;
request = action->act_request; request = action->act_request;
@ -2968,7 +2967,7 @@ static void gen_segment( const act* action, int column)
static void gen_select( const act* action, int column) static void gen_select( const act* action, int column)
{ {
GPRE_REQ request; const gpre_req* request;
POR port; POR port;
GPRE_NOD var_list; GPRE_NOD var_list;
int i; int i;
@ -2990,7 +2989,7 @@ static void gen_select( const act* action, int column)
if (var_list = (GPRE_NOD) action->act_object) if (var_list = (GPRE_NOD) action->act_object)
for (i = 0; i < var_list->nod_count; i++) { for (i = 0; i < var_list->nod_count; i++) {
align(column); align(column);
asgn_to(action, reinterpret_cast<REF>(var_list->nod_arg[i]), column); asgn_to(action, reinterpret_cast<const ref*>(var_list->nod_arg[i]), column);
} }
if (request->req_database->dbb_flags & DBB_v3) { if (request->req_database->dbb_flags & DBB_v3) {
@ -3014,7 +3013,7 @@ static void gen_select( const act* action, int column)
static void gen_send( const act* action, POR port, int column) static void gen_send( const act* action, POR port, int column)
{ {
GPRE_REQ request; const gpre_req* request;
request = action->act_request; request = action->act_request;
align(column); align(column);
@ -3036,21 +3035,18 @@ static void gen_send( const act* action, POR port, int column)
static void gen_slice( const act* action, int column) static void gen_slice( const act* action, int column)
{ {
GPRE_REQ request, parent_request;
REF reference, upper, lower;
SLC slice;
PAT args; PAT args;
slc::slc_repeat *tail, *end; slc::slc_repeat *tail, *end;
TEXT *pattern1 = const TEXT* pattern1 =
"GDS__GET_SLICE (%V1, %RF%DH%RE, %RF%RT%RE, %RF%FR%RE, %N1, \ "GDS__GET_SLICE (%V1, %RF%DH%RE, %RF%RT%RE, %RF%FR%RE, %N1, \
%I1, %N2, %I1v, %I1s, %RF%S5%RE, %RF%S6%RE);"; %I1, %N2, %I1v, %I1s, %RF%S5%RE, %RF%S6%RE);";
TEXT *pattern2 = const TEXT* pattern2 =
"GDS__PUT_SLICE (%V1, %RF%DH%RE, %RF%RT%RE, %RF%FR%RE, %N1, \ "GDS__PUT_SLICE (%V1, %RF%DH%RE, %RF%RT%RE, %RF%FR%RE, %N1, \
%I1, %N2, %I1v, %I1s, %RF%S5%RE);"; %I1, %N2, %I1v, %I1s, %RF%S5%RE);";
request = action->act_request; const gpre_req* request = action->act_request;
slice = (SLC) action->act_object; SLC slice = (SLC) action->act_object;
parent_request = slice->slc_parent_request; const gpre_req* parent_request = slice->slc_parent_request;
// Compute array size // Compute array size
@ -3060,8 +3056,8 @@ static void gen_slice( const act* action, int column)
for (tail = slice->slc_rpt, end = tail + slice->slc_dimensions; for (tail = slice->slc_rpt, end = tail + slice->slc_dimensions;
tail < end; ++tail) tail < end; ++tail)
if (tail->slc_upper != tail->slc_lower) { if (tail->slc_upper != tail->slc_lower) {
lower = (REF) tail->slc_lower->nod_arg[0]; const ref* lower = (const ref*) tail->slc_lower->nod_arg[0];
upper = (REF) tail->slc_upper->nod_arg[0]; const ref* upper = (const ref*) tail->slc_upper->nod_arg[0];
if (lower->ref_value) if (lower->ref_value)
ib_fprintf(out_file, " * ( %s - %s + 1)", upper->ref_value, ib_fprintf(out_file, " * ( %s - %s + 1)", upper->ref_value,
lower->ref_value); lower->ref_value);
@ -3072,12 +3068,15 @@ static void gen_slice( const act* action, int column)
ib_fprintf(out_file, ";"); ib_fprintf(out_file, ";");
// Make assignments to variable vector // Make assignments to variable vector
const ref* reference;
for (reference = request->req_values; reference; for (reference = request->req_values; reference;
reference = reference =
reference->ref_next) printa(column, "gds__%dv [%d] := %s;", reference->ref_next)
{
printa(column, "gds__%dv [%d] := %s;",
request->req_ident, reference->ref_id, request->req_ident, reference->ref_id,
reference->ref_value); reference->ref_value);
}
args.pat_reference = slice->slc_field_ref; args.pat_reference = slice->slc_field_ref;
args.pat_request = parent_request; /* blob id request */ args.pat_request = parent_request; /* blob id request */
@ -3088,7 +3087,7 @@ static void gen_slice( const act* action, int column)
args.pat_ident1 = request->req_ident; /* request name */ args.pat_ident1 = request->req_ident; /* request name */
args.pat_value2 = slice->slc_parameters * sizeof(SLONG); /* parameter length */ args.pat_value2 = slice->slc_parameters * sizeof(SLONG); /* parameter length */
reference = (REF) slice->slc_array->nod_arg[0]; reference = (const ref*) slice->slc_array->nod_arg[0];
args.pat_string5 = reference->ref_value; /* array name */ args.pat_string5 = reference->ref_value; /* array name */
args.pat_string6 = "gds__array_length"; args.pat_string6 = "gds__array_length";
@ -3106,9 +3105,9 @@ static void gen_slice( const act* action, int column)
static void gen_start( const act* action, POR port, int column) static void gen_start( const act* action, POR port, int column)
{ {
GPRE_REQ request; const gpre_req* request;
TEXT *vector; TEXT *vector;
REF reference; const ref* reference;
request = action->act_request; request = action->act_request;
vector = status_vector(action); vector = status_vector(action);
@ -3148,8 +3147,8 @@ static void gen_start( const act* action, POR port, int column)
static void gen_store( const act* action, int column) static void gen_store( const act* action, int column)
{ {
GPRE_REQ request; const gpre_req* request;
REF reference; const ref* reference;
GPRE_FLD field; GPRE_FLD field;
POR port; POR port;
TEXT name[64]; TEXT name[64];
@ -3364,7 +3363,7 @@ static void gen_variable( const act* action, int column)
// Generate tests for any WHENEVER clauses that may have been declared. // Generate tests for any WHENEVER clauses that may have been declared.
// //
static void gen_whenever( SWE label, int column) static void gen_whenever( const swe* label, int column)
{ {
TEXT *condition; TEXT *condition;
@ -3398,7 +3397,7 @@ static void gen_whenever( SWE label, int column)
// output file. // output file.
// //
static void make_array_declaration( REF reference) static void make_array_declaration( const ref* reference)
{ {
GPRE_FLD field; GPRE_FLD field;
TEXT s[64]; TEXT s[64];
@ -3496,7 +3495,7 @@ static TEXT *make_name( TEXT * string, SYM symbol)
// active transaction // active transaction
// //
static void make_ok_test( const act* action, GPRE_REQ request, int column) static void make_ok_test( const act* action, const gpre_req* request, int column)
{ {
if (sw_auto) if (sw_auto)
@ -3515,7 +3514,7 @@ static void make_ok_test( const act* action, GPRE_REQ request, int column)
static void make_port( POR port, int column) static void make_port( POR port, int column)
{ {
GPRE_FLD field; GPRE_FLD field;
REF reference; const ref* reference;
SYM symbol; SYM symbol;
bool flag = false; bool flag = false;
TEXT s[80]; TEXT s[80];
@ -3592,7 +3591,7 @@ static void make_port( POR port, int column)
static void make_ready( static void make_ready(
DBB db, DBB db,
TEXT * filename, TEXT * vector, USHORT column, GPRE_REQ request) TEXT * filename, TEXT * vector, USHORT column, const gpre_req* request)
{ {
TEXT s1[32], s2[32]; TEXT s1[32], s2[32];
@ -3644,7 +3643,7 @@ static void printa( int column, const char* string, ...)
// Generate the appropriate transaction handle. // Generate the appropriate transaction handle.
// //
static const TEXT* request_trans( const act* action, GPRE_REQ request) static const TEXT* request_trans( const act* action, const gpre_req* request)
{ {
if (action->act_type == ACT_open) { if (action->act_type == ACT_open) {
const TEXT* trname = ((OPN) action->act_object)->opn_trans; const TEXT* trname = ((OPN) action->act_object)->opn_trans;
@ -3681,7 +3680,7 @@ static TEXT *status_vector( const act* action)
// any thing fails so we don't trash the status vector. // any thing fails so we don't trash the status vector.
// //
static void t_start_auto( const act* action, GPRE_REQ request, TEXT * vector, int column) static void t_start_auto( const act* action, const gpre_req* request, TEXT * vector, int column)
{ {
DBB db; DBB db;
int count, stat, and_count; int count, stat, and_count;