From a1d52589d26b47104fc322d98c15c505bb5e6011 Mon Sep 17 00:00:00 2001 From: robocop Date: Wed, 31 Dec 2008 09:35:52 +0000 Subject: [PATCH] Cleanup: style, get rid of typedef needed by plain C, other C++ legacy declarations, etc. Sixth pass. --- src/gpre/ada.cpp | 19 +- src/gpre/c_cxx.cpp | 220 ++++++------ src/gpre/cmd.cpp | 21 +- src/gpre/cme.cpp | 8 +- src/gpre/cmp.cpp | 6 +- src/gpre/cob.cpp | 13 +- src/gpre/exp.cpp | 6 +- src/gpre/ftn.cpp | 31 +- src/gpre/gpre.cpp | 8 +- src/gpre/gpre.h | 15 +- src/gpre/gpre_meta.epp | 5 +- src/gpre/gpre_meta_boot.cpp | 2 +- src/gpre/int_cxx.cpp | 24 +- src/gpre/par.cpp | 2 +- src/gpre/pas.cpp | 25 +- src/gpre/pretty.cpp | 4 +- src/gpre/rmc.cpp | 694 ++++++++++++++---------------------- src/gpre/sqe.cpp | 641 +++++++++++++++------------------ src/gpre/sql.cpp | 641 +++++++++++++++++---------------- 19 files changed, 1114 insertions(+), 1271 deletions(-) diff --git a/src/gpre/ada.cpp b/src/gpre/ada.cpp index 606d6a1ce8..d5a6ab501c 100644 --- a/src/gpre/ada.cpp +++ b/src/gpre/ada.cpp @@ -1270,7 +1270,7 @@ static void gen_ddl( const act* action, int column) static void gen_drop_database( const act* action, int column) { DBB db = (DBB) action->act_object; - gpre_req* request = action->act_request; + //gpre_req* request = action->act_request; printa(column, "firebird.DROP_DATABASE (%s %d, \"%s\", RDBK_DB_TYPE_GDS);", status_vector(action), strlen(db->dbb_filename), db->dbb_filename); @@ -1664,7 +1664,7 @@ static void gen_erase( const act* action, int column) static SSHORT gen_event_block( const act* action) { gpre_nod* init = (gpre_nod*) action->act_object; - gpre_sym* event_name = (gpre_sym*) init->nod_arg[0]; + //gpre_sym* event_name = (gpre_sym*) init->nod_arg[0]; const int ident = CMP_next_ident(); init->nod_arg[2] = (gpre_nod*) ident; @@ -1761,7 +1761,7 @@ static void gen_event_wait( const act* action, int column) // event has been initialized and getting the event identifier int ident = -1; - DBB database; + DBB database = NULL; for (gpre_lls* stack_ptr = gpreGlob.events; stack_ptr; stack_ptr = stack_ptr->lls_next) { const act* event_action = (const act*) stack_ptr->lls_object; @@ -3089,10 +3089,12 @@ static void gen_variable( const act* action, int column) static void gen_whenever(const swe* label, int column) { - while (label) { - const TEXT* condition; + while (label) + { + const TEXT* condition = NULL; - switch (label->swe_condition) { + switch (label->swe_condition) + { case SWE_error: condition = "SQLCODE < 0"; break; @@ -3104,6 +3106,11 @@ static void gen_whenever(const swe* label, int column) case SWE_not_found: condition = "SQLCODE = 100"; break; + + default: + // condition undefined + fb_assert(false); + return; } printa(column, "if %s then goto %s; end if;", condition, label->swe_label); label = label->swe_next; diff --git a/src/gpre/c_cxx.cpp b/src/gpre/c_cxx.cpp index 29b8f52ff7..21bfd7ddab 100644 --- a/src/gpre/c_cxx.cpp +++ b/src/gpre/c_cxx.cpp @@ -82,7 +82,7 @@ static void gen_emodify(const act*, int); static void gen_estore(const act*, int); static void gen_endfor(const act*, int); static void gen_erase(const act*, int); -static SSHORT gen_event_block(const act*); +static SSHORT gen_event_block(act*); static void gen_event_init(const act*, int); static void gen_event_wait(const act*, int); static void gen_fetch(const act*, int); @@ -135,7 +135,7 @@ static const TEXT* global_status_name = 0; const int INDENT = 3; -static const char* const NULL_STRING = "(char *)0"; +static const char* const NULL_STRING = "(char*) 0"; static const char* const NULL_STATUS = "NULL"; static const char* const NULL_SQLDA = "NULL"; @@ -554,7 +554,8 @@ static void asgn_from( const act* action, ref* reference, int column) { TEXT name[MAX_REF_SIZE], variable[MAX_REF_SIZE], temp[MAX_REF_SIZE]; - for (; reference; reference = reference->ref_next) { + for (; reference; reference = reference->ref_next) + { bool slice_flag = false; const gpre_fld* field = reference->ref_field; if (field->fld_array_info) { @@ -594,7 +595,7 @@ static void asgn_from( const act* action, ref* reference, int column) if (field->fld_length == 1) fprintf(gpreGlob.out_file, "%s = %s;", variable, value); else - fprintf(gpreGlob.out_file, "isc_ftof (%s, sizeof (%s), %s, %d);", value, + fprintf(gpreGlob.out_file, "isc_ftof (%s, sizeof(%s), %s, %d);", value, value, variable, field->fld_length); else if (field->fld_flags & FLD_dbkey) fprintf(gpreGlob.out_file, "isc_ftof (%s, %d, %s, %d);", value, @@ -605,11 +606,11 @@ static void asgn_from( const act* action, ref* reference, int column) "isc_vtov ((char*) %s, (char*) %s, %d);", value, variable, field->fld_length); else if (reference->ref_source) - fprintf(gpreGlob.out_file, "isc_ftof (%s, sizeof (%s), %s, %d);", + fprintf(gpreGlob.out_file, "isc_ftof (%s, sizeof(%s), %s, %d);", value, value, variable, field->fld_length); else - fprintf(gpreGlob.out_file, "isc_vtof (%s, %s, %d);", value, - variable, field->fld_length); + fprintf(gpreGlob.out_file, "isc_vtof (%s, %s, %d);", + value, variable, field->fld_length); } else if (!reference->ref_master || (reference->ref_flags & REF_literal)) { @@ -640,7 +641,8 @@ static void asgn_to( const act* action, ref* reference, int column) ref* source = reference->ref_friend; const gpre_fld* field = source->ref_field; - if (field) { + if (field) + { act* slice_action; if (field->fld_array_info && (slice_action = (act*) source->ref_slice)) { source->ref_value = reference->ref_value; @@ -668,14 +670,14 @@ static void asgn_to( const act* action, ref* reference, int column) fprintf(gpreGlob.out_file, "%s = %s;", reference->ref_value, s); else if (field->fld_flags & FLD_dbkey) fprintf(gpreGlob.out_file, "isc_ftof (%s, %d, %s, %d);", - s, field->fld_length, reference->ref_value, field->fld_length); + s, field->fld_length, reference->ref_value, field->fld_length); else if (!gpreGlob.sw_cstring || field->fld_sub_type == 1) - fprintf(gpreGlob.out_file, "isc_ftof (%s, %d, %s, sizeof (%s));", s, - field->fld_length, reference->ref_value, reference->ref_value); + fprintf(gpreGlob.out_file, "isc_ftof (%s, %d, %s, sizeof(%s));", + s, field->fld_length, reference->ref_value, reference->ref_value); else fprintf(gpreGlob.out_file, isLangCpp(gpreGlob.sw_language) ? - "isc_vtov ((const char*) %s, (char*) %s, sizeof (%s));" : - "isc_vtov ((char*) %s, (char*) %s, sizeof (%s));", + "isc_vtov ((const char*) %s, (char*) %s, sizeof(%s));" : + "isc_vtov ((char*) %s, (char*) %s, sizeof(%s));", s, reference->ref_value, reference->ref_value); } @@ -711,14 +713,14 @@ static void asgn_to_proc(const ref* reference, int column) fprintf(gpreGlob.out_file, "%s = %s;", reference->ref_value, s); else if (field->fld_flags & FLD_dbkey) fprintf(gpreGlob.out_file, "isc_ftof (%s, %d, %s, %d);", - s, field->fld_length, reference->ref_value, field->fld_length); + s, field->fld_length, reference->ref_value, field->fld_length); else if (!gpreGlob.sw_cstring || field->fld_sub_type == 1) - fprintf(gpreGlob.out_file, "isc_ftof (%s, %d, %s, sizeof (%s));", s, - field->fld_length, reference->ref_value, reference->ref_value); + fprintf(gpreGlob.out_file, "isc_ftof (%s, %d, %s, sizeof(%s));", + s, field->fld_length, reference->ref_value, reference->ref_value); else fprintf(gpreGlob.out_file, isLangCpp(gpreGlob.sw_language) ? - "isc_vtov ((const char*) %s, (char*) %s, sizeof (%s));" : - "isc_vtov ((char*) %s, (char*) %s, sizeof (%s));", + "isc_vtov ((const char*) %s, (char*) %s, sizeof(%s));" : + "isc_vtov ((char*) %s, (char*) %s, sizeof(%s));", s, reference->ref_value, reference->ref_value); } } @@ -771,11 +773,11 @@ static void gen_at_end( const act* action, int column) static void gen_based( const act* action, int column) { USHORT datatype; - SLONG length; + SLONG length = -1; align(column); bas* based_on = (bas*) action->act_object; - gpre_fld* field = based_on->bas_field; + const gpre_fld* field = based_on->bas_field; if (based_on->bas_flags & BAS_segment) { datatype = gpreGlob.sw_cstring ? dtype_cstring : dtype_text; @@ -789,7 +791,8 @@ static void gen_based( const act* action, int column) else datatype = field->fld_dtype; - switch (datatype) { + switch (datatype) + { case dtype_short: fprintf(gpreGlob.out_file, "short"); break; @@ -906,7 +909,7 @@ static void gen_blob_close( const act* action, USHORT column) if (action->act_error) begin(column); - blb* blob; + const blb* blob; if (action->act_flags & ACT_sql) { column = gen_cursor_close(action, action->act_request, column); blob = (blb*) action->act_request->req_blobs; @@ -942,7 +945,7 @@ static void gen_blob_end( const act* action, USHORT column) isc_close_blob (%V1, &%BH);\n\ }"; - args.pat_blob = (blb*) action->act_object; + args.pat_blob = (const blb*) action->act_object; if (action->act_error) { sprintf(s1, "%s2", global_status_name); args.pat_vector1 = s1; @@ -1001,12 +1004,12 @@ static void gen_blob_open( const act* action, USHORT column) } TEXT s[MAX_REF_SIZE]; - blb* blob; + const blb* blob; const ref* reference; if (action->act_flags & ACT_sql) { column = gen_cursor_open(action, action->act_request, column); blob = (blb*) action->act_request->req_blobs; - reference = ((open_cursor*) action->act_object)->opn_using; + reference = ((const open_cursor*) action->act_object)->opn_using; gen_name(s, reference, true); } else { @@ -1168,7 +1171,7 @@ static void gen_compile( const act* action, int column) { PAT args; const TEXT* pattern1 = - "isc_compile_request%IF2%EN (%V1, (FB_API_HANDLE*) &%DH, (FB_API_HANDLE*) &%RH, (short) sizeof (%RI), (char *) %RI);"; + "isc_compile_request%IF2%EN (%V1, (FB_API_HANDLE*) &%DH, (FB_API_HANDLE*) &%RH, (short) sizeof(%RI), (char*) %RI);"; const TEXT* pattern2 = "if (!%RH%IF && %S1%EN)"; const gpre_req* request = action->act_request; @@ -1209,13 +1212,12 @@ static void gen_compile( const act* action, int column) static void gen_create_database( const act* action, int column) { - PAT args; const TEXT* pattern1 = "isc_create_database (%V1, %N1, \"%DF\", &%DH, %IF%S1, %S2%EL(short) 0, (char*) 0%EN, 0);"; TEXT s1[32], s2[32], trname[32]; - gpre_req* request = ((mdbb*) action->act_object)->mdbb_dpb_request; - DBB db = (DBB) request->req_database; + const gpre_req* request = ((const mdbb*) action->act_object)->mdbb_dpb_request; + const dbb* db = (dbb*) request->req_database; sprintf(s1, "isc_%dl", request->req_ident); sprintf(trname, "isc_%dt", request->req_ident); @@ -1239,12 +1241,12 @@ static void gen_create_database( const act* action, int column) else sprintf(s2, "isc_%d", request->req_ident); + PAT args; args.pat_vector1 = status_vector(action); args.pat_request = request; args.pat_database = db; args.pat_value1 = strlen(db->dbb_filename); - args.pat_condition = (request->req_length - || (request->req_flags & REQ_extend_dpb)); + args.pat_condition = (request->req_length || (request->req_flags & REQ_extend_dpb)); args.pat_string1 = s1; args.pat_string2 = s2; @@ -1442,7 +1444,8 @@ static void gen_database( const act* action, int column) column -= INDENT; for (db = gpreGlob.isc_databases; db; db = db->dbb_next) - for (tpb* tpb_iterator = db->dbb_tpbs; tpb_iterator; tpb_iterator = tpb_iterator->tpb_dbb_next) + for (const tpb* tpb_iterator = db->dbb_tpbs; tpb_iterator; + tpb_iterator = tpb_iterator->tpb_dbb_next) { gen_tpb(tpb_iterator, column); } @@ -1451,7 +1454,7 @@ static void gen_database( const act* action, int column) SSHORT max_count = 0; for (gpre_lls* stack_ptr = gpreGlob.events; stack_ptr; stack_ptr = stack_ptr->lls_next) { - SSHORT count = gen_event_block((const act*) (stack_ptr->lls_object)); + SSHORT count = gen_event_block((act*) stack_ptr->lls_object); max_count = MAX(count, max_count); } @@ -1472,8 +1475,7 @@ static void gen_database( const act* action, int column) } fprintf(gpreGlob.out_file, "\n\n"); - gen_compatibility_symbol("blob_null", "isc_", - "\t/* compatibility symbols */"); + gen_compatibility_symbol("blob_null", "isc_", "\t/* compatibility symbols */"); // **** //gen_compatibility_symbol ("database", "isc_", ""); //gen_compatibility_symbol ("trans", "isc_", ""); @@ -1539,7 +1541,7 @@ static void gen_ddl( const act* action, int column) static void gen_drop_database( const act* action, int column) { - DBB db = (DBB) action->act_object; + const dbb* db = (dbb*) action->act_object; align(column); fprintf(gpreGlob.out_file, "isc_drop_database (%s, %d, \"%s\", rdb$k_db_type_gds);", @@ -1588,9 +1590,7 @@ static void gen_dyn_declare( const act* action, int column) // Generate a dynamic SQL statement. // -static void gen_dyn_describe(const act* action, - int column, - bool bind_flag) +static void gen_dyn_describe(const act* action, int column, bool bind_flag) { TEXT s[MAX_CURSOR_SIZE]; @@ -1951,10 +1951,10 @@ static void gen_erase( const act* action, int column) // with a particular call to isc_event_wait. // -static SSHORT gen_event_block( const act* action) +static SSHORT gen_event_block(act* action) { gpre_nod* init = (gpre_nod*) action->act_object; - gpre_sym* event_name = (gpre_sym*) init->nod_arg[0]; + //gpre_sym* event_name = (gpre_sym*) init->nod_arg[0]; int ident = CMP_next_ident(); init->nod_arg[2] = (gpre_nod*)(IPTR)ident; @@ -1962,7 +1962,7 @@ static SSHORT gen_event_block( const act* action) printa(0, "static %schar\n *isc_%da, *isc_%db;", CONST_STR, ident, ident); printa(0, "static short\n isc_%dl;", ident); - gpre_nod* list = init->nod_arg[1]; + const gpre_nod* list = init->nod_arg[1]; return list->nod_count; } @@ -1982,8 +1982,8 @@ static void gen_event_init( const act* action, int column) begin(column); begin(column); - gpre_nod* init = (gpre_nod*) action->act_object; - gpre_nod* event_list = init->nod_arg[1]; + const gpre_nod* init = (gpre_nod*) action->act_object; + const gpre_nod* event_list = init->nod_arg[1]; PAT args; args.pat_database = (DBB) init->nod_arg[3]; @@ -1996,12 +1996,12 @@ static void gen_event_init( const act* action, int column) PATTERN_expand((USHORT) column, pattern1, &args); TEXT variable[MAX_REF_SIZE]; - gpre_nod** ptr = event_list->nod_arg; + const gpre_nod* const* ptr = event_list->nod_arg; for (const gpre_nod* const* const end = ptr + event_list->nod_count; ptr < end; ptr++) { - gpre_nod* node = *ptr; + const gpre_nod* node = *ptr; if (node->nod_type == nod_field) { - ref* reference = (ref*) node->nod_arg[0]; + const ref* reference = (ref*) node->nod_arg[0]; gen_name(variable, reference, true); printb(", %s", variable); } @@ -2032,7 +2032,6 @@ static void gen_event_init( const act* action, int column) static void gen_event_wait( const act* action, int column) { - PAT args; TEXT s[64]; const TEXT* pattern1 = "isc_wait_for_event (%V1, &%DH, isc_%L1l, isc_%L1a, isc_%L1b);"; const TEXT* pattern2 = "isc_event_counts (isc_events, isc_%L1l, isc_%L1a, isc_%L1b);"; @@ -2041,17 +2040,17 @@ static void gen_event_wait( const act* action, int column) begin(column); begin(column); - gpre_sym* event_name = (gpre_sym*) action->act_object; + const gpre_sym* event_name = (gpre_sym*) action->act_object; // go through the stack of gpreGlob.events, checking to see if the // event has been initialized and getting the event identifier - DBB database; + const dbb* database = NULL; int ident = -1; - for (gpre_lls* stack_ptr = gpreGlob.events; stack_ptr; stack_ptr = stack_ptr->lls_next) { + for (const gpre_lls* stack_ptr = gpreGlob.events; stack_ptr; stack_ptr = stack_ptr->lls_next) { const act* event_action = (const act*) stack_ptr->lls_object; - gpre_nod* event_init = (gpre_nod*) event_action->act_object; - gpre_sym* stack_name = (gpre_sym*) event_init->nod_arg[0]; + const gpre_nod* event_init = (gpre_nod*) event_action->act_object; + const gpre_sym* stack_name = (gpre_sym*) event_init->nod_arg[0]; if (!strcmp(event_name->sym_string, stack_name->sym_string)) { ident = (IPTR) event_init->nod_arg[2]; database = (DBB) event_init->nod_arg[3]; @@ -2064,6 +2063,7 @@ static void gen_event_wait( const act* action, int column) return; } + PAT args; args.pat_database = database; args.pat_vector1 = status_vector(action); args.pat_long1 = ident; @@ -2092,7 +2092,8 @@ static void gen_fetch( const act* action, int column) #ifdef SCROLLABLE_CURSORS gpre_port* port = request->req_aport; - if (port) { + if (port) + { // set up the reference to point to the correct value // in the linked list of values, and prepare for the // next FETCH statement if applicable @@ -2158,6 +2159,7 @@ static void gen_fetch( const act* action, int column) align(column); asgn_to(action, (ref*) (var_list->nod_arg[i]), column); } + endp(column); printa(column - INDENT, "else"); printa(column, "SQLCODE = 100;"); @@ -2195,11 +2197,11 @@ static void gen_finish( const act* action, int column) PATTERN_expand((USHORT) column, pattern1, &args); } - DBB db = NULL; + const dbb* db = NULL; // the user supplied one or more db_handles - for (rdy* ready = (rdy*) action->act_object; ready; ready = ready->rdy_next) { + for (const rdy* ready = (rdy*) action->act_object; ready; ready = ready->rdy_next) { db = ready->rdy_database; printa(column, "isc_detach_database (%s, &%s);", status_vector(action), db->dbb_name->sym_string); @@ -2208,8 +2210,7 @@ static void gen_finish( const act* action, int column) if (!db) for (db = gpreGlob.isc_databases; db; db = db->dbb_next) { - if ((action->act_error || (action->act_flags & ACT_sql)) && - (db != gpreGlob.isc_databases)) + if ((action->act_error || (action->act_flags & ACT_sql)) && db != gpreGlob.isc_databases) { printa(column, "if (%s && !%s [1]) ", db->dbb_name->sym_string, global_status_name); } @@ -2231,7 +2232,7 @@ static void gen_finish( const act* action, int column) static void gen_for( const act* action, int column) { gen_s_start(action, column); - gpre_req* request = action->act_request; + const gpre_req* request = action->act_request; if (action->act_error || (action->act_flags & ACT_sql)) printa(column, "if (!%s [1]) {", global_status_name); @@ -2266,7 +2267,7 @@ static void gen_for( const act* action, int column) static void gen_function( const act* function, int column) { - ref* reference; + const ref* reference; const act* action = (const act*) function->act_object; @@ -2275,7 +2276,7 @@ static void gen_function( const act* function, int column) return; } - gpre_req* request = action->act_request; + const gpre_req* request = action->act_request; fprintf(gpreGlob.out_file, "static %s_r (request, transaction ", request->req_handle); @@ -2377,15 +2378,12 @@ static void gen_function( const act* function, int column) // or isc_put_slice for an array. // -static void gen_get_or_put_slice(const act* action, - const ref* reference, - bool get, - int column) +static void gen_get_or_put_slice(const act* action, const ref* reference, bool get, int column) { const TEXT* pattern1 = - "isc_get_slice (%V1, &%DH, &%RT, &%S2, (short) %N1, (char *) %S3, 0, (%S6*) 0, (%S6) %L1, %S5, &isc_array_length);"; + "isc_get_slice (%V1, &%DH, &%RT, &%S2, (short) %N1, (char*) %S3, 0, (%S6*) 0, (%S6) %L1, %S5, &isc_array_length);"; const TEXT* pattern2 = - "isc_put_slice (%V1, &%DH, &%RT, &%S2, (short) %N1, (char *) %S3, 0, (%S6*) 0, (%S6) %L1, (void *)%S5);"; + "isc_put_slice (%V1, &%DH, &%RT, &%S2, (short) %N1, (char*) %S3, 0, (%S6*) 0, (%S6) %L1, (void*) %S5);"; if (!(reference->ref_flags & REF_fetch_array)) return; @@ -2431,12 +2429,12 @@ static void gen_get_or_put_slice(const act* action, static void gen_get_segment( const act* action, int column) { const TEXT* pattern1 = - "%IF%S1 [1] = %ENisc_get_segment (%V1, &%BH, &%I1, (short) sizeof (%I2), %I2);"; + "%IF%S1 [1] = %ENisc_get_segment (%V1, &%BH, &%I1, (short) sizeof(%I2), %I2);"; if (action->act_error && (action->act_type != ACT_blob_for)) begin(column); - blb* blob; + const blb* blob; if (action->act_flags & ACT_sql) blob = (blb*) action->act_request->req_blobs; else @@ -2452,7 +2450,7 @@ static void gen_get_segment( const act* action, int column) PATTERN_expand((USHORT) column, pattern1, &args); if (action->act_flags & ACT_sql) { - ref* into = action->act_object; + const ref* into = action->act_object; set_sqlcode(action, column); printa(column, "if (!SQLCODE || SQLCODE == 101)"); column += INDENT; @@ -2481,8 +2479,8 @@ static void gen_loop( const act* action, int column) TEXT name[MAX_REF_SIZE]; gen_s_start(action, column); - gpre_req* request = action->act_request; - gpre_port* port = request->req_primary; + const gpre_req* request = action->act_request; + const gpre_port* port = request->req_primary; printa(column, "if (!SQLCODE) "); column += INDENT; begin(column); @@ -2550,14 +2548,13 @@ static void gen_on_error( const act* action, USHORT column) static void gen_procedure( const act* action, int column) { column += INDENT; - gpre_req* request = action->act_request; - gpre_port* in_port = request->req_vport; - gpre_port* out_port = request->req_primary; + const gpre_req* request = action->act_request; + const gpre_port* in_port = request->req_vport; + const gpre_port* out_port = request->req_primary; const dbb* database = request->req_database; PAT args; args.pat_database = database; - args.pat_request = action->act_request; args.pat_vector1 = status_vector(action); args.pat_request = request; args.pat_port = in_port; @@ -2565,10 +2562,10 @@ static void gen_procedure( const act* action, int column) const TEXT* pattern; if (in_port && in_port->por_length) pattern = - "isc_transact_request (%V1, %RF%DH%RE, %RF%RT%RE, sizeof (%RI), %RI, (short) %PL, (char *) %RF%PI%RE, (short) %QL, (char *) %RF%QI%RE);"; + "isc_transact_request (%V1, %RF%DH%RE, %RF%RT%RE, sizeof(%RI), %RI, (short) %PL, (char*) %RF%PI%RE, (short) %QL, (char*) %RF%QI%RE);"; else pattern = - "isc_transact_request (%V1, %RF%DH%RE, %RF%RT%RE, sizeof (%RI), %RI, 0, 0, (short) %QL, (char *) %RF%QI%RE);"; + "isc_transact_request (%V1, %RF%DH%RE, %RF%RT%RE, sizeof(%RI), %RI, 0, 0, (short) %QL, (char*) %RF%QI%RE);"; // Get database attach and transaction started @@ -2610,10 +2607,10 @@ static void gen_put_segment( const act* action, int column) if (action->act_error || (action->act_flags & ACT_sql)) begin(column); - blb* blob; + const blb* blob; if (action->act_flags & ACT_sql) { blob = (blb*) action->act_request->req_blobs; - ref* from = action->act_object; + const ref* from = action->act_object; align(column); fprintf(gpreGlob.out_file, "isc_%d = %s;", blob->blb_len_ident, from->ref_null_value); align(column); @@ -2683,7 +2680,7 @@ static void gen_ready( const act* action, int column) { const TEXT* vector = status_vector(action); - for (rdy* ready = (rdy*) action->act_object; ready; ready = ready->rdy_next) { + for (const rdy* ready = (rdy*) action->act_object; ready; ready = ready->rdy_next) { const dbb* db = ready->rdy_database; const TEXT* filename = ready->rdy_filename; if (!filename) @@ -2740,7 +2737,7 @@ static void gen_release( const act* action, int column) DBB exp_db = (DBB) action->act_object; for (gpre_req* request = gpreGlob.requests; request; request = request->req_next) { - DBB db = request->req_database; + const dbb* db = request->req_database; if (exp_db && db != exp_db) continue; if (db && request->req_handle && !(request->req_flags & REQ_exp_hand)) { @@ -2798,7 +2795,8 @@ static void gen_request(const gpre_req* request) printa(0, "static %schar\n isc_%d [] = {", CONST_STR, request->req_ident); const TEXT* string_type = "blr"; - if (gpreGlob.sw_raw) { + if (gpreGlob.sw_raw) + { gen_raw(request->req_blr, request->req_length); switch (request->req_type) { @@ -2819,7 +2817,8 @@ static void gen_request(const gpre_req* request) } } else - switch (request->req_type) { + switch (request->req_type) + { case REQ_create_database: case REQ_ready: string_type = "dpb"; @@ -2922,13 +2921,14 @@ static void gen_routine( const act* action, int column) { column += INDENT; - for (gpre_req* request = (gpre_req*) action->act_object; request; request = request->req_routine) + for (const gpre_req* request = (gpre_req*) action->act_object; request; + request = request->req_routine) { if (request->req_type == REQ_any) continue; - for (gpre_port* port = request->req_ports; port; port = port->por_next) + for (const gpre_port* port = request->req_ports; port; port = port->por_next) make_port(port, column); - for (blb* blob = request->req_blobs; blob; blob = blob->blb_next) { + for (const blb* blob = request->req_blobs; blob; blob = blob->blb_next) { printa(column, "isc_blob_handle\t\tisc_%d;\t\t/* blob handle */", blob->blb_ident); printa(column, "char\t\t\tisc_%d [%d];\t/* blob segment */", blob->blb_buff_ident, blob->blb_seg_length); @@ -2948,7 +2948,7 @@ static void gen_s_end( const act* action, int column) if (action->act_error) begin(column); - gpre_req* request = action->act_request; + const gpre_req* request = action->act_request; if (action->act_type == ACT_close) column = gen_cursor_close(action, request, column); @@ -3031,7 +3031,7 @@ static void gen_s_start( const act* action, int column) static void gen_segment( const act* action, int column) { - blb* blob = (blb*) action->act_object; + const blb* blob = (blb*) action->act_object; printa(column, "isc_%d", (action->act_type == ACT_segment) ? blob->blb_buff_ident : @@ -3114,13 +3114,13 @@ static void gen_send( const act* action, const gpre_port* port, int column) static void gen_slice( const act* action, ref* var_reference, int column) { const TEXT* pattern1 = "isc_get_slice (%V1, &%DH, &%RT, &%FR, (short) %N1, \ -(char *) %I1, (short) %N2, %I1v, %I1s, %S5, &isc_array_length);"; +(char*) %I1, (short) %N2, %I1v, %I1s, %S5, &isc_array_length);"; const TEXT* pattern2 = "isc_put_slice (%V1, &%DH, &%RT, &%FR, (short) %N1, \ -(char *) %I1, (short) %N2, %I1v, %I1s, %S5);"; +(char*) %I1, (short) %N2, %I1v, %I1s, %S5);"; - gpre_req* request = action->act_request; - slc* slice = (slc*) action->act_object; - gpre_req* parent_request = slice->slc_parent_request; + const gpre_req* request = action->act_request; + const slc* slice = (slc*) action->act_object; + const gpre_req* parent_request = slice->slc_parent_request; // Compute array size @@ -3143,7 +3143,7 @@ static void gen_slice( const act* action, ref* var_reference, int column) // Make assignments to variable vector - ref* reference; + const ref* reference; for (reference = request->req_values; reference; reference = reference->ref_next) { printa(column, "isc_%dv [%d] = %s;", @@ -3214,7 +3214,7 @@ static void gen_start(const act* action, static void gen_store( const act* action, int column) { - gpre_req* request = action->act_request; + const gpre_req* request = action->act_request; align(column); gen_compile(action, column); @@ -3230,9 +3230,9 @@ static void gen_store( const act* action, int column) TEXT name[MAX_REF_SIZE]; gpre_port* port = request->req_primary; - for (ref* reference = port->por_references; reference; reference = reference->ref_next) + for (const ref* reference = port->por_references; reference; reference = reference->ref_next) { - gpre_fld* field = reference->ref_field; + const gpre_fld* field = reference->ref_field; if (field->fld_flags & FLD_blob) printa(column, "%s = isc_blob_null;", gen_name(name, reference, true)); } @@ -3423,10 +3423,12 @@ static void gen_variable( const act* action, int column) static void gen_whenever( const swe* label, int column) { - const TEXT* condition; + const TEXT* condition = NULL; - while (label) { - switch (label->swe_condition) { + while (label) + { + switch (label->swe_condition) + { case SWE_error: condition = "SQLCODE < 0"; break; @@ -3438,6 +3440,11 @@ static void gen_whenever( const swe* label, int column) case SWE_not_found: condition = "SQLCODE == 100"; break; + + default: + // condition undefined + fb_assert(false); + return; } align(column); fprintf(gpreGlob.out_file, "if (%s) goto %s;", condition, label->swe_label); @@ -3466,7 +3473,8 @@ static void make_array_declaration(ref* reference) field->fld_array_info->ary_declared = true; const TEXT* dtype; - switch (field->fld_array_info->ary_dtype) { + switch (field->fld_array_info->ary_dtype) + { case dtype_short: dtype = "short"; break; @@ -3525,7 +3533,7 @@ static void make_array_declaration(ref* reference) // Print out the dimension part of the declaration - for (dim* dimension = field->fld_array_info->ary_dimension; dimension; + for (const dim* dimension = field->fld_array_info->ary_dimension; dimension; dimension = dimension->dim_next) { fprintf(gpreGlob.out_file, " [%ld]", dimension->dim_upper - dimension->dim_lower + 1); @@ -3619,7 +3627,8 @@ static void make_port(const gpre_port* port, int column) int fld_len = 0; const TEXT* dtype; - switch (field->fld_dtype) { + switch (field->fld_dtype) + { case dtype_short: dtype = "short"; break; @@ -3701,7 +3710,8 @@ static void make_ready(const dbb* db, { TEXT s1[32], s2[32]; - if (request) { + if (request) + { sprintf(s1, "isc_%dl", request->req_ident); if (request->req_flags & REQ_extend_dpb) diff --git a/src/gpre/cmd.cpp b/src/gpre/cmd.cpp index a9f5a7f5a3..2f87115b98 100644 --- a/src/gpre/cmd.cpp +++ b/src/gpre/cmd.cpp @@ -1752,8 +1752,8 @@ static bool create_view(gpre_req* request, fld = reference->ref_field; const gpre_req* slice_req; const slc* slice; - if ((value->nod_count >= 2) && (slice_req = (gpre_req*) value->nod_arg[2]) - && (slice = slice_req->req_slice)) + if ((value->nod_count >= 2) && (slice_req = (gpre_req*) value->nod_arg[2]) && + (slice = slice_req->req_slice)) { CPR_error("Array slices not supported in views"); } @@ -2274,8 +2274,8 @@ static void put_blr(gpre_req* request, static void put_computed_blr( gpre_req* request, const gpre_fld* field) { - const act* action = request->req_actions; - const gpre_rel* relation = (gpre_rel*) action->act_object; + //const act* action = request->req_actions; + //const gpre_rel* relation = (gpre_rel*) action->act_object; // Computed field context has to be 0 - so force it @@ -2308,8 +2308,8 @@ static void put_computed_blr( gpre_req* request, const gpre_fld* field) static void put_computed_source( gpre_req* request, const gpre_fld* field) { - const act* action = request->req_actions; - const gpre_rel* relation = (gpre_rel*) action->act_object; + //const act* action = request->req_actions; + //const gpre_rel* relation = (gpre_rel*) action->act_object; if (field->fld_computed->cmpf_text != NULL) { TEXT* computed_source = (TEXT*) MSC_alloc(field->fld_computed->cmpf_text->txt_length + 1); @@ -2343,12 +2343,13 @@ static void put_cstring(gpre_req* request, USHORT ddl_operator, static void put_dtype( gpre_req* request, const gpre_fld* field) { - USHORT dtype; + USHORT dtype = 0; USHORT length = field->fld_length; - const USHORT precision = field->fld_precision; - const USHORT sub_type = field->fld_sub_type; - switch (field->fld_dtype) { + //const USHORT precision = field->fld_precision; + //const USHORT sub_type = field->fld_sub_type; + switch (field->fld_dtype) + { case dtype_cstring: // If the user is defining a field as cstring then generate diff --git a/src/gpre/cme.cpp b/src/gpre/cme.cpp index f0cc844d2e..ad1c8cf3c6 100644 --- a/src/gpre/cme.cpp +++ b/src/gpre/cme.cpp @@ -2224,15 +2224,15 @@ static void get_dtype_of_list(const gpre_nod* node, gpre_fld* f) UCHAR max_dtype = 0; SCHAR max_scale = 0; USHORT max_length = 0, max_dtype_length = 0, maxtextlength = 0, max_significant_digits = 0; - SSHORT max_sub_type = 0, first_sub_type, ttype = ttype_ascii; // default type if all nodes are nod_null. + SSHORT max_sub_type = 0, first_sub_type = -1, ttype = ttype_ascii; // default type if all nodes are nod_null. SSHORT max_numeric_sub_type = 0; - bool firstarg = true, all_same_sub_type = true, all_equal = true, all_nulls = true; + bool firstarg = true, all_same_sub_type = true, all_equal = true; //, all_nulls = true; bool all_numeric = true, any_numeric = false, any_approx = false, any_float = false; bool all_text = true, any_text = false, any_varying = false; bool all_date = true, all_time = true, all_timestamp = true, any_datetime = false; bool all_blob = true, any_blob = false, any_text_blob = false; - bool nullable = false; - bool err = false; + //bool nullable = false; + //bool err = false; gpre_fld field_aux; // Set default values diff --git a/src/gpre/cmp.cpp b/src/gpre/cmp.cpp index c9f8fe7bbc..f9ce3a216e 100644 --- a/src/gpre/cmp.cpp +++ b/src/gpre/cmp.cpp @@ -240,8 +240,8 @@ void CMP_compile_request( gpre_req* request) // Assume that a general port needs to be constructed. gpre_port* port; - if ((request->req_type != REQ_insert) && (request->req_type != REQ_store2) - && (request->req_type != REQ_set_generator)) + if ((request->req_type != REQ_insert) && (request->req_type != REQ_store2) && + (request->req_type != REQ_set_generator)) { request->req_primary = port = make_port(request, reference); } @@ -1191,7 +1191,7 @@ static void cmp_ready( gpre_req* request) { dbb* db = request->req_database; - act* action = request->req_actions; + //act* action = request->req_actions; request->req_blr = request->req_base = MSC_alloc(250); request->req_length = 250; request->req_flags |= REQ_exp_hand; diff --git a/src/gpre/cob.cpp b/src/gpre/cob.cpp index 88c83490a1..d9362ab774 100644 --- a/src/gpre/cob.cpp +++ b/src/gpre/cob.cpp @@ -2318,7 +2318,7 @@ static void gen_event_wait( const act* action) return; // silence non initialized warning } - const SSHORT column = strlen(names[COLUMN]); + const USHORT column = strlen(names[COLUMN]); PAT args; args.pat_database = database; @@ -2966,8 +2966,7 @@ static void gen_release( const act* action) static void gen_receive( const act* action, const gpre_port* port) { const gpre_req* request = action->act_request; - sprintf(output_buffer, - "%sCALL \"%s\" USING %s, %s%s, %s%d%s, %s%d%s, %s%s%d, %s%s%s\n", + sprintf(output_buffer, "%sCALL \"%s\" USING %s, %s%s, %s%d%s, %s%d%s, %s%s%d, %s%s%s\n", names[COLUMN], ISC_RECEIVE, status_vector(action), @@ -3607,10 +3606,12 @@ static void gen_variable( const act* action) static void gen_whenever(const swe* label) { - const TEXT* condition; + const TEXT* condition = NULL; - while (label) { - switch (label->swe_condition) { + while (label) + { + switch (label->swe_condition) + { case SWE_error: condition = "SQLCODE < 0"; break; diff --git a/src/gpre/exp.cpp b/src/gpre/exp.cpp index 1366926ca7..63e19073dd 100644 --- a/src/gpre/exp.cpp +++ b/src/gpre/exp.cpp @@ -355,9 +355,9 @@ gpre_nod* EXP_literal() /** Do not put a default here **/ } // ** End date/time/timestamp * - if ((gpreGlob.token_global.tok_type == tok_sglquoted && (gpreGlob.token_global.tok_charset)) || - ((isQuoted(gpreGlob.token_global.tok_type) && (gpreGlob.sw_sql_dialect == 1)) - && (gpreGlob.token_global.tok_charset))) + if ((gpreGlob.token_global.tok_type == tok_sglquoted && gpreGlob.token_global.tok_charset) || + ((isQuoted(gpreGlob.token_global.tok_type) && gpreGlob.sw_sql_dialect == 1) && + gpreGlob.token_global.tok_charset)) { reference->ref_flags |= REF_ttype; gpre_sym* symbol = gpreGlob.token_global.tok_charset; diff --git a/src/gpre/ftn.cpp b/src/gpre/ftn.cpp index fa70ea1c3f..e4a237f01f 100644 --- a/src/gpre/ftn.cpp +++ b/src/gpre/ftn.cpp @@ -320,7 +320,8 @@ void FTN_action(const act* action, int column) if (action->act_flags & ACT_break) global_first_flag = false; - switch (action->act_type) { + switch (action->act_type) + { case ACT_alter_database: case ACT_alter_domain: case ACT_alter_table: @@ -1319,10 +1320,10 @@ static void gen_database(const act* action) { if (global_first_flag) return; + global_first_flag = true; - sprintf(output_buffer, - "\n%s **** GDS Preprocessor Definitions ****\n\n", COMMENT); + sprintf(output_buffer, "\n%s **** GDS Preprocessor Definitions ****\n\n", COMMENT); FTN_print_buffer(output_buffer); gen_database_decls(action); @@ -2552,8 +2553,7 @@ static void gen_put_segment(const act* action) else blob = (blb*) action->act_object; - sprintf(output_buffer, - "%sISC_STATUS(2) = ISC_PUT_SEGMENT (%s, isc_%d, %sisc_%d%s, %sisc_%d%s)\n", + sprintf(output_buffer, "%sISC_STATUS(2) = ISC_PUT_SEGMENT (%s, isc_%d, %sisc_%d%s, %sisc_%d%s)\n", COLUMN, status_vector(action), blob->blb_ident, @@ -3197,9 +3197,8 @@ static void gen_start(const act* action, const gpre_port* port) I2CONST_1, request->req_request_level, I2CONST_2); } else - sprintf(output_buffer, - "%sCALL ISC_START_REQUEST (%s, %s, %s, %s%s%s)\n", COLUMN, - vector, request->req_handle, request_trans(action, request), + sprintf(output_buffer, "%sCALL ISC_START_REQUEST (%s, %s, %s, %s%s%s)\n", + COLUMN, vector, request->req_handle, request_trans(action, request), I2CONST_1, request->req_request_level, I2CONST_2); FTN_print_buffer(output_buffer); @@ -3436,10 +3435,12 @@ static void gen_variable(const act* action) static void gen_whenever(const swe* label) { - const TEXT* condition; + const TEXT* condition = NULL; - while (label) { - switch (label->swe_condition) { + while (label) + { + switch (label->swe_condition) + { case SWE_error: condition = "SQLCODE .LT. 0"; break; @@ -3451,7 +3452,11 @@ static void gen_whenever(const swe* label) case SWE_not_found: condition = "SQLCODE .EQ. 100"; break; - //CVC: default: => error??? + + default: + // condition undefined + fb_assert(false); + return; } printa(COLUMN, "if (%s) goto %s", condition, label->swe_label); label = label->swe_next; @@ -4052,7 +4057,7 @@ static void gen_function(const act* function) for (const ref* reference = port->por_references; reference; reference = reference->ref_next) { const gpre_fld* field = reference->ref_field; - const TEXT* dtype; + const TEXT* dtype = NULL; switch (field->fld_dtype) { case dtype_short: diff --git a/src/gpre/gpre.cpp b/src/gpre/gpre.cpp index b435602d25..5ab6f6773f 100644 --- a/src/gpre/gpre.cpp +++ b/src/gpre/gpre.cpp @@ -1485,8 +1485,8 @@ static bool file_rename(TEXT* file_nameL, const TEXT* extension, const TEXT* new static void finish_based( act* action) { - gpre_rel* relation; - gpre_fld* field; + gpre_rel* relation = NULL; + gpre_fld* field = NULL; TEXT s[MAXPATHLEN << 1]; for (; action; action = action->act_rest) { @@ -2766,8 +2766,8 @@ static SSHORT skip_white() if (gpreGlob.sw_language == lang_cobol && (!isAnsiCobol(gpreGlob.sw_cob_dialect) && line_position == 1 && (c == 'C' || c == 'c' || c == '*' || c == '/' || c == '\\') || - (isAnsiCobol(gpreGlob.sw_cob_dialect) && line_position == 7 && c != '\t' && c != ' ' - && c != '-'))) + (isAnsiCobol(gpreGlob.sw_cob_dialect) && line_position == 7 && c != '\t' && + c != ' ' && c != '-'))) { while ((c = nextchar()) != '\n' && c != EOF) ; diff --git a/src/gpre/gpre.h b/src/gpre/gpre.h index 94e89e04bb..3ce0611753 100644 --- a/src/gpre/gpre.h +++ b/src/gpre/gpre.h @@ -318,13 +318,6 @@ inline size_t STR_LEN(const size_t size) /* SQL WHENEVER BLOCK */ -struct swe { - swe* swe_next; /* Next in chain */ - USHORT swe_condition; /* Condition */ - USHORT swe_length; /* Length of label */ - TEXT swe_label[1]; /* Label */ -}; - enum swe_condition_vals { SWE_error, SWE_warning, @@ -332,6 +325,14 @@ enum swe_condition_vals { SWE_max }; +struct swe +{ + swe* swe_next; // Next in chain + swe_condition_vals swe_condition; // Condition + USHORT swe_length; // Length of label + TEXT swe_label[1]; // Label +}; + /* Text block */ diff --git a/src/gpre/gpre_meta.epp b/src/gpre/gpre_meta.epp index 90100a8908..7b365f5fc9 100644 --- a/src/gpre/gpre_meta.epp +++ b/src/gpre/gpre_meta.epp @@ -702,7 +702,6 @@ gpre_fld* MET_field(gpre_rel* relation, const char* string) // Lookup field. If we find it, nifty. If not, look it up in the // database. - gpre_fld* field = NULL; gpre_sym* symbol; for (symbol = HSH_lookup(name); symbol; symbol = symbol->sym_homonym) { @@ -710,6 +709,8 @@ gpre_fld* MET_field(gpre_rel* relation, const char* string) { return relation->rel_dbkey; } + + gpre_fld* field; if (symbol->sym_type == SYM_field && (field = (gpre_fld*) symbol->sym_object) && field->fld_relation == relation) { @@ -728,7 +729,7 @@ gpre_fld* MET_field(gpre_rel* relation, const char* string) DB = database->dbb_handle; gds_trans = database->dbb_transaction; - field = NULL; + gpre_fld* field = NULL; if (!(database->dbb_flags & DBB_v3)) { FOR(REQUEST_HANDLE database->dbb_field_request) RFR IN RDB$RELATION_FIELDS CROSS F IN RDB$FIELDS WITH diff --git a/src/gpre/gpre_meta_boot.cpp b/src/gpre/gpre_meta_boot.cpp index 3cb1b31693..903be3aca1 100644 --- a/src/gpre/gpre_meta_boot.cpp +++ b/src/gpre/gpre_meta_boot.cpp @@ -235,7 +235,6 @@ gpre_lls* MET_get_primary_key(DBB db, const TEXT* relation_name) gpre_fld* MET_field(gpre_rel* relation, const char* string) { - gpre_fld* field; SCHAR name[NAME_SIZE]; strcpy(name, string); @@ -252,6 +251,7 @@ gpre_fld* MET_field(gpre_rel* relation, const char* string) return relation->rel_dbkey; } + gpre_fld* field; if (symbol->sym_type == SYM_field && (field = (gpre_fld*) symbol->sym_object) && field->fld_relation == relation) { diff --git a/src/gpre/int_cxx.cpp b/src/gpre/int_cxx.cpp index 9ef34db591..508de85811 100644 --- a/src/gpre/int_cxx.cpp +++ b/src/gpre/int_cxx.cpp @@ -73,7 +73,7 @@ const int INDENT = 3; static const char* const GDS_VTOV = "gds__vtov"; static const char* const JRD_VTOF = "jrd_vtof"; -static const char* const VTO_CALL = "%s ((const char*)%s, (char*)%s, %d);"; +static const char* const VTO_CALL = "%s ((const char*) %s, (char*) %s, %d);"; static inline void begin(const int column) { @@ -94,7 +94,8 @@ void INT_CXX_action( const act* action, int column) // Put leading braces where required - switch (action->act_type) { + switch (action->act_type) + { case ACT_for: case ACT_insert: case ACT_modify: @@ -105,7 +106,8 @@ void INT_CXX_action( const act* action, int column) align(column); } - switch (action->act_type) { + switch (action->act_type) + { case ACT_at_end: gen_at_end(action, column); return; @@ -242,10 +244,10 @@ static void asgn_to( ref* reference) // emitting jrd_ftof call. if (!field || field->fld_dtype == dtype_text) - fprintf(gpreGlob.out_file, "gds__ftov (%s, %d, %s, sizeof (%s));", + fprintf(gpreGlob.out_file, "gds__ftov (%s, %d, %s, sizeof(%s));", s, field ? field->fld_length : 0, reference->ref_value, reference->ref_value); else if (!field || field->fld_dtype == dtype_cstring) - fprintf(gpreGlob.out_file, "gds__vtov((const char*)%s, (char*)%s, sizeof (%s));", + fprintf(gpreGlob.out_file, "gds__vtov((const char*) %s, (char*) %s, sizeof(%s));", s, reference->ref_value, reference->ref_value); else fprintf(gpreGlob.out_file, "%s = %s;", reference->ref_value, s); @@ -285,11 +287,11 @@ static void gen_blr(void* user_arg, SSHORT offset, const char* string) static void gen_compile( const gpre_req* request, int column) { column += INDENT; - const dbb* db = request->req_database; - const gpre_sym* symbol = db->dbb_name; + //const dbb* db = request->req_database; + //const gpre_sym* symbol = db->dbb_name; fprintf(gpreGlob.out_file, "if (!%s)", request->req_handle); align(column); - fprintf(gpreGlob.out_file, "%s = CMP_compile2 (tdbb, (UCHAR*)jrd_%"ULONGFORMAT", TRUE);", + fprintf(gpreGlob.out_file, "%s = CMP_compile2 (tdbb, (UCHAR*) jrd_%"ULONGFORMAT", TRUE);", request->req_handle, request->req_ident); } @@ -340,7 +342,7 @@ static void gen_emodify( const act* action, int column) gen_name(s1, source), field->fld_length, gen_name(s2, reference), field->fld_length); break; case dtype_cstring: - fprintf(gpreGlob.out_file, "gds__vtov((const char*)%s, (char*)%s, %d);", + fprintf(gpreGlob.out_file, "gds__vtov((const char*) %s, (char*) %s, %d);", gen_name(s1, source), gen_name(s2, reference), field->fld_length); break; default: @@ -476,7 +478,7 @@ static void gen_receive( const gpre_req* request, const gpre_port* port) { fprintf(gpreGlob.out_file, - "EXE_receive (tdbb, %s, %d, %d, (UCHAR*)&jrd_%"ULONGFORMAT");", + "EXE_receive (tdbb, %s, %d, %d, (UCHAR*) &jrd_%"ULONGFORMAT");", request->req_handle, port->por_msg_number, port->por_length, port->por_ident); } @@ -585,7 +587,7 @@ static void gen_send( const gpre_req* request, const gpre_port* port, int column } align(column); - fprintf(gpreGlob.out_file, "EXE_send (tdbb, %s, %d, %d, (UCHAR*)&jrd_%"ULONGFORMAT");", + fprintf(gpreGlob.out_file, "EXE_send (tdbb, %s, %d, %d, (UCHAR*) &jrd_%"ULONGFORMAT");", request->req_handle, port->por_msg_number, port->por_length, port->por_ident); } diff --git a/src/gpre/par.cpp b/src/gpre/par.cpp index ff427f14ac..6ad55268ba 100644 --- a/src/gpre/par.cpp +++ b/src/gpre/par.cpp @@ -460,7 +460,7 @@ SSHORT PAR_blob_subtype(DBB db) // Check for symbol type name if (gpreGlob.token_global.tok_type == tok_ident) { - gpre_fld* field; + gpre_fld* field = NULL; gpre_rel* relation = MET_get_relation(db, "RDB$FIELDS", ""); if (!relation || !(field = MET_field(relation, "RDB$FIELD_SUB_TYPE"))) { diff --git a/src/gpre/pas.cpp b/src/gpre/pas.cpp index e5f147a055..39075eff82 100644 --- a/src/gpre/pas.cpp +++ b/src/gpre/pas.cpp @@ -1967,10 +1967,11 @@ static void gen_finish( const act* action, int column) } if (!db) for (db = gpreGlob.isc_databases; db; db = db->dbb_next) { - if ((action->act_error || (action->act_flags & ACT_sql)) - && (db != gpreGlob.isc_databases)) printa(column, - "if (%s <> nil) and (gds__status[2] = 0) then", - db->dbb_name->sym_string); + if ((action->act_error || (action->act_flags & ACT_sql)) && + (db != gpreGlob.isc_databases)) + { + printa(column, "if (%s <> nil) and (gds__status[2] = 0) then", db->dbb_name->sym_string); + } else printa(column, "if %s <> nil then", db->dbb_name->sym_string); printa(column + INDENT, "GDS__DETACH_DATABASE (%s, %s);", @@ -2064,8 +2065,7 @@ static void gen_get_or_put_slice(const act* action, args.pat_string5 = reference->ref_value; } else { - sprintf(s4, "gds__%d", - reference->ref_field->fld_array_info->ary_ident); + sprintf(s4, "gds__%d", reference->ref_field->fld_array_info->ary_ident); args.pat_string5 = s4; // array name } @@ -3049,13 +3049,15 @@ static void gen_variable( const act* action, int column) static void gen_whenever( const swe* label, int column) { - const TEXT* condition; + const TEXT* condition = NULL; if (label) fprintf(gpreGlob.out_file, ";"); - while (label) { - switch (label->swe_condition) { + while (label) + { + switch (label->swe_condition) + { case SWE_error: condition = "SQLCODE < 0"; break; @@ -3067,6 +3069,11 @@ static void gen_whenever( const swe* label, int column) case SWE_not_found: condition = "SQLCODE = 100"; break; + + default: + // condition undefined + fb_assert(false); + return; } align(column); fprintf(gpreGlob.out_file, "if %s then goto %s;", condition, label->swe_label); diff --git a/src/gpre/pretty.cpp b/src/gpre/pretty.cpp index cff4fa6857..78336f30c7 100644 --- a/src/gpre/pretty.cpp +++ b/src/gpre/pretty.cpp @@ -309,8 +309,8 @@ static int indent( ctl* control, SSHORT level) static int print_blr_dtype(ctl* control, bool print_object) { - const char* string; - SSHORT length; + const char* string = NULL; + SSHORT length = -1; const USHORT dtype = BLR_BYTE; diff --git a/src/gpre/rmc.cpp b/src/gpre/rmc.cpp index 2900d17cf6..bfc60c3540 100644 --- a/src/gpre/rmc.cpp +++ b/src/gpre/rmc.cpp @@ -563,7 +563,8 @@ void RMC_print_buffer(TEXT* output_bufferL, bool function_call) TEXT* p = s; - for (const TEXT* q = output_bufferL; *q; q++) { + for (const TEXT* q = output_bufferL; *q; q++) + { *p++ = *q; /* If we have a single or double quote, toggle the @@ -585,7 +586,8 @@ void RMC_print_buffer(TEXT* output_bufferL, bool function_call) if (function_call) { // Back up until we reach a comma - for (p--; (p > s); p--, q--) { + for (p--; (p > s); p--, q--) + { if (*(p + 1) == '\"' || *(p + 1) == '\'') { /* If we have a single or double quote, toggle the quote switch and indicate single or double quote */ @@ -633,8 +635,10 @@ void RMC_print_buffer(TEXT* output_bufferL, bool function_call) else { // back up to a blank - for (p--; p > s; p--, q--) { - if (*(p + 1) == '\"' || *(p + 1) == '\'') { + for (p--; p > s; p--, q--) + { + if (*(p + 1) == '\"' || *(p + 1) == '\'') + { /* If we have a single or double quote, toggle the quote switch and indicate single or double quote */ open_quote = !open_quote; @@ -933,50 +937,32 @@ static void asgn_to_proc( const ref* reference) { if ((reference->ref_field->fld_dtype == dtype_sql_date) && (strlen(gpreGlob.sw_cob_dformat) != 0)) { - sprintf(output_buffer, "%sMOVE ZERO TO ISC-TEMP-QUAD-LOW\n", - names[COLUMN]); + sprintf(output_buffer, "%sMOVE ZERO TO ISC-TEMP-QUAD-LOW\n", names[COLUMN]); RMC_print_buffer(output_buffer, false); - sprintf(output_buffer, - "%sMOVE %s TO ISC-TEMP-QUAD-HIGH\n", - names[COLUMN], - s); + sprintf(output_buffer, "%sMOVE %s TO ISC-TEMP-QUAD-HIGH\n", names[COLUMN], s); RMC_print_buffer(output_buffer, false); - sprintf(output_buffer, - "%sCALL \"rmc_ctod\" USING %s, ISC-TEMP-QUAD, \"%s\"\n", - names[COLUMN], - reference->ref_value, - gpreGlob.sw_cob_dformat); + sprintf(output_buffer, "%sCALL \"rmc_ctod\" USING %s, ISC-TEMP-QUAD, \"%s\"\n", + names[COLUMN], reference->ref_value, gpreGlob.sw_cob_dformat); RMC_print_buffer(output_buffer, false); } else { if ((reference->ref_field->fld_dtype == dtype_sql_time) && (strlen(gpreGlob.sw_cob_dformat) != 0)) { - sprintf(output_buffer, - "%sMOVE ZERO TO ISC-TEMP-QUAD-HIGH\n", - names[COLUMN]); + sprintf(output_buffer, "%sMOVE ZERO TO ISC-TEMP-QUAD-HIGH\n", names[COLUMN]); RMC_print_buffer(output_buffer, false); - sprintf(output_buffer, - "%sMOVE %s TO ISC-TEMP-QUAD-LOW\n", - names[COLUMN], - s); + sprintf(output_buffer, "%sMOVE %s TO ISC-TEMP-QUAD-LOW\n", names[COLUMN], s); RMC_print_buffer(output_buffer, false); - sprintf(output_buffer, - "%sCALL \"rmc_ctod\" USING %s, ISC-TEMP-QUAD, \"%s\"\n", - names[COLUMN], - reference->ref_value, - gpreGlob.sw_cob_dformat); + sprintf(output_buffer, "%sCALL \"rmc_ctod\" USING %s, ISC-TEMP-QUAD, \"%s\"\n", + names[COLUMN], reference->ref_value, gpreGlob.sw_cob_dformat); RMC_print_buffer(output_buffer, false); } else { if (reference->ref_field->fld_dtype == dtype_cstring) { - sprintf(output_buffer, - "%sCALL \"rmc_ctos\" USING %s GIVING %s\n", - names[COLUMN], - s, - reference->ref_value); + sprintf(output_buffer, "%sCALL \"rmc_ctos\" USING %s GIVING %s\n", + names[COLUMN], s, reference->ref_value); RMC_print_buffer(output_buffer, false); } else @@ -984,11 +970,8 @@ static void asgn_to_proc( const ref* reference) if ((reference->ref_field->fld_dtype == dtype_short) || (reference->ref_field->fld_dtype == dtype_long)) { - sprintf(output_buffer, - "%sCALL \"rmc_ctob\" USING %s GIVING %s\n", - names[COLUMN], - s, - s); + sprintf(output_buffer, "%sCALL \"rmc_ctob\" USING %s GIVING %s\n", + names[COLUMN], s, s); RMC_print_buffer(output_buffer, false); } sprintf(output_buffer, "%sMOVE %s TO %s\n", @@ -1013,14 +996,13 @@ static void gen_any( const act* action) const gpre_req* request = action->act_request; fprintf(gpreGlob.out_file, "%s_r (&%s, &%s", - request->req_handle, request->req_handle, request->req_trans); + request->req_handle, request->req_handle, request->req_trans); const gpre_port* port = request->req_vport; if (port) - for (const ref* reference = port->por_references; reference; - reference = reference->ref_next) + for (const ref* reference = port->por_references; reference; reference = reference->ref_next) { - fprintf(gpreGlob.out_file, ", %s", reference->ref_value); + fprintf(gpreGlob.out_file, ", %s", reference->ref_value); } fprintf(gpreGlob.out_file, ")"); @@ -1037,8 +1019,7 @@ static void gen_at_end( const act* action) TEXT s[MAX_REF_SIZE]; const gpre_req* request = action->act_request; - printa(names[COLUMN], false, - "IF %s = 0 THEN", gen_name(s, request->req_eof, true)); + printa(names[COLUMN], false, "IF %s = 0 THEN", gen_name(s, request->req_eof, true)); fprintf(gpreGlob.out_file, names[COLUMN]); } @@ -1078,7 +1059,8 @@ static void gen_based( const act* action) SSHORT digits; - switch (datatype) { + switch (datatype) + { case dtype_short: case dtype_long: digits = (datatype == dtype_short) ? 5 : 10; @@ -1087,16 +1069,13 @@ static void gen_based( const act* action) if (field->fld_scale > -digits) fprintf(gpreGlob.out_file, "9(%d)", digits + field->fld_scale); if (field->fld_scale) - fprintf(gpreGlob.out_file, "V9(%d)", - digits - (digits + field->fld_scale)); - fprintf(gpreGlob.out_file, - (datatype == dtype_short) ? USAGE_BINARY2 : USAGE_BINARY4); + fprintf(gpreGlob.out_file, "V9(%d)", digits - (digits + field->fld_scale)); + fprintf(gpreGlob.out_file, (datatype == dtype_short) ? USAGE_BINARY2 : USAGE_BINARY4); } else if (field->fld_scale > 0) fprintf(gpreGlob.out_file, "9(%d)P(%d)", digits, field->fld_scale); else - fprintf(gpreGlob.out_file, "VP(%d)9(%d)", -(field->fld_scale + digits), - digits); + fprintf(gpreGlob.out_file, "VP(%d)9(%d)", -(field->fld_scale + digits), digits); break; case dtype_date: @@ -1144,16 +1123,13 @@ static void gen_based( const act* action) if (field->fld_scale > -digits) fprintf(gpreGlob.out_file, "9(%d)", digits + field->fld_scale); if (field->fld_scale) - fprintf(gpreGlob.out_file, "V9(%d)", - digits - (digits + field->fld_scale)); - fprintf(gpreGlob.out_file, - (datatype == dtype_real) ? USAGE_BINARY4 : USAGE_BINARY8); + fprintf(gpreGlob.out_file, "V9(%d)", digits - (digits + field->fld_scale)); + fprintf(gpreGlob.out_file, (datatype == dtype_real) ? USAGE_BINARY4 : USAGE_BINARY8); } else if (field->fld_scale > 0) fprintf(gpreGlob.out_file, "9(%d)P(%d)", digits, field->fld_scale); else - fprintf(gpreGlob.out_file, "VP(%d)9(%d)", -(field->fld_scale + digits), - digits); + fprintf(gpreGlob.out_file, "VP(%d)9(%d)", -(field->fld_scale + digits), digits); break; default: @@ -1214,15 +1190,13 @@ static void gen_blob_end( const act* action) gen_get_segment(action); printa(names[COLUMN], false, "END-PERFORM"); if (action->act_error) - printa(names[COLUMN], true, - "%sCALL \"%s\" USING %s, %s%d", + printa(names[COLUMN], true, "%sCALL \"%s\" USING %s, %s%d", INDENT, ISC_CANCEL_BLOB, names[isc_status_vector2_pos], names[isc_a_pos], blob->blb_ident); else - printa(names[COLUMN], true, - "%sCALL \"%s\" USING %s, %s%d", + printa(names[COLUMN], true, "%sCALL \"%s\" USING %s, %s%d", INDENT, ISC_CANCEL_BLOB, status_vector(0), names[isc_a_pos], blob->blb_ident); } @@ -1287,8 +1261,7 @@ static void gen_blob_open( const act* action) args.pat_ident1 = blob->blb_bpb_ident; // blob parameter block if ((action->act_flags & ACT_sql) && action->act_type == ACT_blob_open) - printa(names[COLUMN], false, "MOVE %s TO %s", - reference->ref_value, s); + printa(names[COLUMN], false, "MOVE %s TO %s", reference->ref_value, s); if (args.pat_value1 = blob->blb_bpb_length) PATTERN_expand(column, pattern1, &args); @@ -1304,8 +1277,7 @@ static void gen_blob_open( const act* action) set_sqlcode(action); if (action->act_type == ACT_blob_create) { printa(names[COLUMN], false, "IF SQLCODE = 0 THEN"); - printa(names[COLUMN], false, "MOVE %s TO %s", - s, reference->ref_value); + printa(names[COLUMN], false, "MOVE %s TO %s", s, reference->ref_value); printa(names[COLUMN], false, "END-IF"); } } @@ -1334,16 +1306,15 @@ static void gen_blr(void* user_arg, SSHORT offset, const char* string) char buffer[256]; bool first_line = true; - while (length > 0 && length + indent + comment > max_line) { + while (length > 0 && length + indent + comment > max_line) + { /* if we did not find somewhere to break between the 200th and 256th character just print out 256 characters */ const char* q = p; - for (bool open_quote = false; (q - p + indent + comment) < max_line; - q++) + for (bool open_quote = false; (q - p + indent + comment) < max_line; q++) { - if ((q - p + indent + comment) > max_line - max_diff && *q == ',' - && !open_quote) + if ((q - p + indent + comment) > max_line - max_diff && *q == ',' && !open_quote) { break; } @@ -1414,8 +1385,7 @@ static void gen_compile( const act* action) printa(names[COLUMN], false, "IF %s = 0 THEN", request->req_handle); if (gpreGlob.sw_auto && action->act_error) - printa(names[COLUMN], false, "IF %s NOT = 0 THEN", - request_trans(action, request)); + printa(names[COLUMN], false, "IF %s NOT = 0 THEN", request_trans(action, request)); // Never use isc_compile_request2 here because if the request is // generated in a subprogram and that subprogram is subsequently CANCELed // the buffer containing the request handle will be freed. This will cause @@ -1423,8 +1393,7 @@ static void gen_compile( const act* action) // cause other difficult to find memory corruption problems. This implies // that the user must issue a RELEASE_REQUESTS request before exiting any // subprogram in order to clean up its handles. - sprintf(output_buffer, - "%sCALL \"%s\" USING %s, %s, %s, %d, %s%d\n", + sprintf(output_buffer, "%sCALL \"%s\" USING %s, %s, %s, %d, %s%d\n", names[COLUMN], ISC_COMPILE_REQUEST, status_vector(action), symbol->sym_string, request->req_handle, request->req_length, @@ -1442,7 +1411,8 @@ static void gen_compile( const act* action) const blb* blob = request->req_blobs; if (blob) - for (; blob; blob = blob->blb_next) { + for (; blob; blob = blob->blb_next) + { sprintf(output_buffer, "%sMOVE 0 TO %s%d\n", names[COLUMN], names[isc_a_pos], blob->blb_ident); @@ -1479,8 +1449,7 @@ static void gen_create_database( const act* action) names[COLUMN], names[isc_b_pos], request->req_ident, s2); } if (db->dbb_r_user) { - sprintf(output_buffer, - "%sCALL \"%s\" USING %s, %s, 28, %s, %d\n", + sprintf(output_buffer, "%sCALL \"%s\" USING %s, %s, 28, %s, %d\n", names[COLUMN], ISC_EXPAND_DPB, s2, @@ -1489,8 +1458,7 @@ static void gen_create_database( const act* action) RMC_print_buffer(output_buffer, true); } if (db->dbb_r_password) { - sprintf(output_buffer, - "%sCALL \"%s\" USING %s, %s, 29, %s, %d\n", + sprintf(output_buffer, "%sCALL \"%s\" USING %s, %s, 29, %s, %d\n", names[COLUMN], ISC_EXPAND_DPB, s2, @@ -1508,8 +1476,7 @@ static void gen_create_database( const act* action) */ if (db->dbb_r_sql_role) { - sprintf(output_buffer, - "%sCALL \"%s\" USING %s, %s, 60, %s, %d\n", + sprintf(output_buffer, "%sCALL \"%s\" USING %s, %s, 60, %s, %d\n", names[COLUMN], ISC_EXPAND_DPB, s2, @@ -1519,8 +1486,7 @@ static void gen_create_database( const act* action) } if (db->dbb_r_lc_messages) { - sprintf(output_buffer, - "%sCALL \"%s\" USING %s, %s, 47, %s, %d\n", + sprintf(output_buffer, "%sCALL \"%s\" USING %s, %s, 47, %s, %d\n", names[COLUMN], ISC_EXPAND_DPB, s2, @@ -1529,8 +1495,7 @@ static void gen_create_database( const act* action) RMC_print_buffer(output_buffer, true); } if (db->dbb_r_lc_ctype) { - sprintf(output_buffer, - "%sCALL \"%s\" USING %s %s, 48, %s, %d\n", + sprintf(output_buffer, "%sCALL \"%s\" USING %s %s, 48, %s, %d\n", names[COLUMN], ISC_EXPAND_DPB, s2, @@ -1552,12 +1517,14 @@ static void gen_create_database( const act* action) TEXT dbname[128]; for (const dbb* dbisc = gpreGlob.isc_databases; dbisc; dbisc = dbisc->dbb_next) + { if (strcmp(dbisc->dbb_filename, db->dbb_filename) == 0) db->dbb_id = dbisc->dbb_id; + } + sprintf(dbname, "%s%ddb", names[isc_b_pos], db->dbb_id); - sprintf(output_buffer, - "%sCALL \"%s\" USING %s, %d%, %s, %s, %s, %s, 0\n", + sprintf(output_buffer, "%sCALL \"%s\" USING %s, %d%, %s, %s, %s, %s, 0\n", names[COLUMN], ISC_CREATE_DATABASE, status_vector(action), @@ -1570,20 +1537,18 @@ static void gen_create_database( const act* action) RMC_print_buffer(output_buffer, true); // if the dpb was extended, free it here - if (request && request->req_flags & REQ_extend_dpb) { + if (request && request->req_flags & REQ_extend_dpb) + { if (request->req_length) { - sprintf(output_buffer, - "if (%s != %s%d)", s2, names[isc_b_pos], request->req_ident); + sprintf(output_buffer, "if (%s != %s%d)", s2, names[isc_b_pos], request->req_ident); RMC_print_buffer(output_buffer, true); } - sprintf(output_buffer, - "%sCALL \"%s\" USING %s\n", names[COLUMN], ISC_FREE, s2Tmp); + sprintf(output_buffer, "%sCALL \"%s\" USING %s\n", names[COLUMN], ISC_FREE, s2Tmp); RMC_print_buffer(output_buffer, true); // reset the length of the dpb - sprintf(output_buffer, "%sMOVE %d to %s", - names[COLUMN], request->req_length, s1); + sprintf(output_buffer, "%sMOVE %d to %s", names[COLUMN], request->req_length, s1); RMC_print_buffer(output_buffer, true); } const bool save_sw_auto = gpreGlob.sw_auto; @@ -1606,8 +1571,7 @@ static void gen_cursor_close( const act* action, const gpre_req* request) printa(names[COLUMN], false, "IF %s%dS NOT = 0 THEN", names[isc_a_pos], request->req_ident); - printa(names[COLUMN], true, - "CALL \"%s\" USING %s, %s%dS, %d", + printa(names[COLUMN], true, "CALL \"%s\" USING %s, %s%dS, %d", ISC_DSQL_FREE, status_vector(action), names[isc_a_pos], request->req_ident, 2); @@ -1627,8 +1591,8 @@ static void gen_cursor_init( const act* action) // point, the handles are the user's responsibility if (action->act_request->req_flags & (REQ_sql_blob_open | REQ_sql_blob_create)) - printa(names[COLUMN], false, "MOVE 0 TO %s%d", names[isc_a_pos], - action->act_request->req_blobs->blb_ident); + printa(names[COLUMN], false, "MOVE 0 TO %s%d", + names[isc_a_pos], action->act_request->req_blobs->blb_ident); } @@ -1657,24 +1621,19 @@ static void gen_cursor_open( const act* action, const gpre_req* request) printa(names[COLUMN], false, "END-IF"); printa(names[COLUMN], false, "END-IF"); - printa(names[COLUMN], false, "IF %s%dS NOT = 0 THEN", - names[isc_a_pos], request->req_ident); + printa(names[COLUMN], false, "IF %s%dS NOT = 0 THEN", names[isc_a_pos], request->req_ident); if (gpreGlob.sw_auto) - printa(names[COLUMN], false, "IF %s NOT = 0 THEN", - request_trans(action, request)); + printa(names[COLUMN], false, "IF %s NOT = 0 THEN", request_trans(action, request)); TEXT s[MAX_CURSOR_SIZE]; - make_name_formatted(s, "ISC-CONST-%s", - ((open_cursor*) action->act_object)->opn_cursor); - printa(names[COLUMN], true, - "CALL \"%s\" USING %s, %s%dS, %s, 0", + make_name_formatted(s, "ISC-CONST-%s", ((open_cursor*) action->act_object)->opn_cursor); + printa(names[COLUMN], true, "CALL \"%s\" USING %s, %s%dS, %s, 0", ISC_DSQL_SET_CURSOR, status_vector(action), names[isc_a_pos], request->req_ident, s); printa(names[COLUMN], false, "IF %s(2) = 0 THEN", names[isc_status_pos]); - printa(names[COLUMN], true, - "CALL \"%s\" USING %s, %s, %s%dS, 0, %s, -1, 0, %s", + printa(names[COLUMN], true, "CALL \"%s\" USING %s, %s, %s%dS, 0, %s, -1, 0, %s", ISC_DSQL_EXECUTE, status_vector(action), request_trans(action, request), @@ -1693,18 +1652,14 @@ static void gen_database( const act* action) { if (global_first_flag) return; + global_first_flag = true; - sprintf(output_buffer, "\n%s**** GDS Preprocessor Definitions ****\n\n", - names[COMMENT]); + sprintf(output_buffer, "\n%s**** GDS Preprocessor Definitions ****\n\n", names[COMMENT]); RMC_print_buffer(output_buffer, false); - printa(COLUMN8, false, "01 %s PIC S9(19) %s VALUE IS 0.", - names[isc_blob_null_pos], - USAGE_BINARY8); - printa(COLUMN8, false, "01 %s PIC S9(10) %s EXTERNAL.", - names[ISC_SQLCODE], - USAGE_BINARY4); + printa(COLUMN8, false, "01 %s PIC S9(19) %s VALUE IS 0.", names[isc_blob_null_pos], USAGE_BINARY8); + printa(COLUMN8, false, "01 %s PIC S9(10) %s EXTERNAL.", names[ISC_SQLCODE], USAGE_BINARY4); printa(COLUMN8, false, "01 ISC-TEMP-QUAD."); printa(COLUMN12, false, "03 ISC-TEMP-QUAD-HIGH PIC S9(10) %s.", USAGE_BINARY4); printa(COLUMN12, false, "03 ISC-TEMP-QUAD-LOW PIC S9(10) %s.", USAGE_BINARY4); @@ -1712,7 +1667,8 @@ static void gen_database( const act* action) bool all_static = true; bool all_extern = true; USHORT count = 0; - for (dbb* db = gpreGlob.isc_databases; db; db = db->dbb_next) { + for (dbb* db = gpreGlob.isc_databases; db; db = db->dbb_next) + { all_static = all_static && (db->dbb_scope == DBB_STATIC); all_extern = all_extern && (db->dbb_scope == DBB_EXTERN); const TEXT* name = db->dbb_name->sym_string; @@ -1726,14 +1682,12 @@ static void gen_database( const act* action) db->dbb_id = ++count; if (db->dbb_runtime) { - printa(COLUMN8, false, - "01 %s%ddb PIC X(%d) VALUE IS \"%s\".", names[isc_b_pos], - db->dbb_id, strlen(db->dbb_runtime), db->dbb_runtime); + printa(COLUMN8, false, "01 %s%ddb PIC X(%d) VALUE IS \"%s\".", + names[isc_b_pos], db->dbb_id, strlen(db->dbb_runtime), db->dbb_runtime); } else if (db->dbb_filename) { - printa(COLUMN8, false, - "01 %s%ddb PIC X(%d) VALUE IS \"%s\".", names[isc_b_pos], - db->dbb_id, strlen(db->dbb_filename), db->dbb_filename); + printa(COLUMN8, false, "01 %s%ddb PIC X(%d) VALUE IS \"%s\".", + names[isc_b_pos], db->dbb_id, strlen(db->dbb_filename), db->dbb_filename); } for (const tpb* tpb_iterator = db->dbb_tpbs; @@ -1753,7 +1707,8 @@ static void gen_database( const act* action) if (local_act->act_type == ACT_create_database) { // no statement; } - else if (local_act->act_type == ACT_ready) { + else if (local_act->act_type == ACT_ready) + { for (rdy* ready = (rdy*) local_act->act_object; ready; ready = ready->rdy_next) { const TEXT* s = ready->rdy_filename; @@ -1766,18 +1721,17 @@ static void gen_database( const act* action) strncpy(fname, s, len); fname[len - 1] = 0; ready->rdy_id = ++count; - printa(COLUMN8, false, - "01 %s%ddb PIC X(%d) VALUE IS \"%s\".", + printa(COLUMN8, false, "01 %s%ddb PIC X(%d) VALUE IS \"%s\".", names[isc_b_pos], ready->rdy_id, strlen(fname), fname); } } } else if ((local_act->act_flags & ACT_sql) && - (local_act->act_type == ACT_dyn_cursor || - local_act->act_type == ACT_dyn_prepare || - local_act->act_type == ACT_open || - local_act->act_type == ACT_blob_open || - local_act->act_type == ACT_blob_create)) + (local_act->act_type == ACT_dyn_cursor || + local_act->act_type == ACT_dyn_prepare || + local_act->act_type == ACT_open || + local_act->act_type == ACT_blob_open || + local_act->act_type == ACT_blob_create)) { const gpre_sym* cur_stmt; switch (local_act->act_type) @@ -1803,9 +1757,9 @@ static void gen_database( const act* action) else if (chck_dups->act_type == ACT_dyn_prepare) dup = ((dyn*) chck_dups->act_object)->dyn_statement_name; else if ((chck_dups->act_flags & ACT_sql) && - (chck_dups->act_type == ACT_open || - chck_dups->act_type == ACT_blob_open || - chck_dups->act_type == ACT_blob_create)) + (chck_dups->act_type == ACT_open || + chck_dups->act_type == ACT_blob_open || + chck_dups->act_type == ACT_blob_create)) { dup = ((open_cursor*) chck_dups->act_object)->opn_cursor; } @@ -1826,9 +1780,7 @@ static void gen_database( const act* action) else if (local_act->act_type == ACT_dyn_immediate) { if (!dyn_immed) { dyn_immed = true; - printa(COLUMN8, false, - "01 ISC-CONST-DYN-IMMEDL PIC S9(5) %s.", - USAGE_BINARY2); + printa(COLUMN8, false, "01 ISC-CONST-DYN-IMMEDL PIC S9(5) %s.", USAGE_BINARY2); } } else if (local_act->act_type == ACT_procedure) { @@ -1836,8 +1788,7 @@ static void gen_database( const act* action) const gpre_prc* procedure = (gpre_prc*) local_act->act_object; const gpre_sym* symbol = procedure->prc_symbol; const char* sname = symbol->sym_string; - printa(COLUMN8, false, - "01 %s%dprc PIC X(%d) VALUE IS \"%s\".", + printa(COLUMN8, false, "01 %s%dprc PIC X(%d) VALUE IS \"%s\".", names[isc_b_pos], request->req_ident, strlen(sname), sname); } } @@ -1866,7 +1817,8 @@ static void gen_database( const act* action) all_static ? "" : all_extern ? " IS EXTERNAL" : " IS GLOBAL", USAGE_BINARY4, all_extern ? "" : " VALUE IS 0"); - for (gpre_req* request = gpreGlob.requests; request; request = request->req_next) { + for (gpre_req* request = gpreGlob.requests; request; request = request->req_next) + { gen_request(request); gpre_port* port; for (port = request->req_ports; port; port = port->por_next) @@ -1885,8 +1837,7 @@ static void gen_database( const act* action) // Array declarations if (port = request->req_primary) - for (ref* reference = port->por_references; reference; - reference = reference->ref_next) + for (ref* reference = port->por_references; reference; reference = reference->ref_next) { if (reference->ref_field->fld_array_info) make_array_declaration(reference); @@ -1907,13 +1858,10 @@ static void gen_database( const act* action) printa(COLUMN12, false, "03 %s PIC S9(10) %s OCCURS %d TIMES.", names[ISC_EVENTS], USAGE_BINARY4, max_count); - printa(COLUMN8, false, "01 %s.", - names[ISC_EVENT_NAMES_VECTOR]); - printa(COLUMN12, false, - "03 %s PIC S9(10) %s OCCURS %d TIMES.", + printa(COLUMN8, false, "01 %s.", names[ISC_EVENT_NAMES_VECTOR]); + printa(COLUMN12, false, "03 %s PIC S9(10) %s OCCURS %d TIMES.", names[ISC_EVENT_NAMES], USAGE_BINARY4, max_count); - printa(COLUMN8, false, "01 %s.", - names[ISC_EVENT_NAMES_VECTOR2]); + printa(COLUMN8, false, "01 %s.", names[ISC_EVENT_NAMES_VECTOR2]); printa(COLUMN12, false, "03 %s PIC X(31) OCCURS %d TIMES.", names[ISC_EVENT_NAMES2], max_count); } @@ -1939,8 +1887,7 @@ static void gen_ddl( const act* action) } - sprintf(output_buffer, - "%sCALL \"%s\" USING %s, %s, %s, %d, %s%d\n", + sprintf(output_buffer, "%sCALL \"%s\" USING %s, %s, %s, %d, %s%d\n", names[COLUMN], ISC_DDL, status_vector(action), request->req_database->dbb_name->sym_string, names[isc_trans_pos], request->req_length, @@ -1951,14 +1898,11 @@ static void gen_ddl( const act* action) if (gpreGlob.sw_auto) { printa(names[COLUMN], false, "END-IF"); printa(names[COLUMN], false, "IF %s(2) = 0 THEN", names[isc_status_pos]); - printa(names[COLUMN], true, - "CALL \"%s\" USING %s, %s", ISC_COMMIT_TRANSACTION, + printa(names[COLUMN], true, "CALL \"%s\" USING %s, %s", ISC_COMMIT_TRANSACTION, status_vector(action), names[isc_trans_pos]); printa(names[COLUMN], false, "END-IF"); - printa(names[COLUMN], false, "IF %s(2) NOT = 0 THEN", - names[isc_status_pos]); - printa(names[COLUMN], true, - "CALL \"%s\" USING %s, %s", + printa(names[COLUMN], false, "IF %s(2) NOT = 0 THEN", names[isc_status_pos]); + printa(names[COLUMN], true, "CALL \"%s\" USING %s, %s", ISC_ROLLBACK_TRANSACTION, OMITTED, names[isc_trans_pos]); printa(names[COLUMN], false, "END-IF"); } @@ -1978,8 +1922,7 @@ static void gen_dyn_close( const act* action) const dyn* statement = (dyn*) action->act_object; make_name_formatted(s, "ISC-CONST-%s", statement->dyn_cursor_name); - printa(names[COLUMN], true, - "CALL \"%s\" USING %s, %s", + printa(names[COLUMN], true, "CALL \"%s\" USING %s, %s", ISC_CLOSE, status_vector(action), s); set_sqlcode(action); } @@ -1999,8 +1942,7 @@ static void gen_dyn_declare( const act* action) make_name_formatted(s1, "ISC-CONST-%s", statement->dyn_statement_name); make_name_formatted(s2, "ISC-CONST-%s", statement->dyn_cursor_name); - printa(names[COLUMN], true, - "CALL \"%s\" USING %s, %s, %s", + printa(names[COLUMN], true, "CALL \"%s\" USING %s, %s, %s", ISC_DECLARE, status_vector(action), s1, s2); set_sqlcode(action); } @@ -2011,8 +1953,7 @@ static void gen_dyn_declare( const act* action) // Generate a dynamic SQL statement. // -static void gen_dyn_describe(const act* action, - bool bind_flag) +static void gen_dyn_describe(const act* action, bool bind_flag) { TEXT s[MAX_CURSOR_SIZE]; @@ -2020,8 +1961,7 @@ static void gen_dyn_describe(const act* action, make_name_formatted(s, "ISC-CONST-%s", statement->dyn_statement_name); - printa(names[COLUMN], true, - "CALL \"%s\" USING %s, %s, %d, %s", + printa(names[COLUMN], true, "CALL \"%s\" USING %s, %s, %d, %s", bind_flag ? ISC_DESCRIBE_BIND : ISC_DESCRIBE, status_vector(action), s, @@ -2062,8 +2002,8 @@ static void gen_dyn_execute( const act* action) printa(names[COLUMN], true, statement->dyn_sqlda2 ? - "CALL \"%s\" USING %s, %s, %s, %d, %s, %s" : - "CALL \"%s\" USING %s, %s, %s, %d, %s", + "CALL \"%s\" USING %s, %s, %s, %d, %s, %s" : + "CALL \"%s\" USING %s, %s, %s, %d, %s", statement->dyn_sqlda2 ? ISC_EXECUTE2 : ISC_EXECUTE, status_vector(action), transaction, @@ -2133,8 +2073,7 @@ static void gen_dyn_immediate( const act* action) TEXT s[64]; const TEXT* s2 = "ISC-CONST-DYN-IMMEDL"; - printa(names[COLUMN], true, GET_LEN_CALL_TEMPLATE, - STRING_LENGTH, statement->dyn_string, s2); + printa(names[COLUMN], true, GET_LEN_CALL_TEMPLATE, STRING_LENGTH, statement->dyn_string, s2); sprintf(s, " %s,", s2); if (gpreGlob.sw_auto) { @@ -2144,8 +2083,8 @@ static void gen_dyn_immediate( const act* action) printa(names[COLUMN], true, statement->dyn_sqlda2 ? - "CALL \"%s\" USING %s, %s, %s,%s %s, %d, %s, %s" : - "CALL \"%s\" USING %s, %s, %s,%s %s, %d, %s", + "CALL \"%s\" USING %s, %s, %s,%s %s, %d, %s, %s" : + "CALL \"%s\" USING %s, %s, %s,%s %s, %d, %s", statement->dyn_sqlda2 ? ISC_EXECUTE_IMMEDIATE2 : ISC_EXECUTE_IMMEDIATE, status_vector(action), database->dbb_name->sym_string, transaction, s, statement->dyn_string, @@ -2173,8 +2112,7 @@ static void gen_dyn_insert( const act* action) make_name_formatted(s, "ISC-CONST-%s", statement->dyn_cursor_name); - printa(names[COLUMN], true, - "CALL \"%s\" USING %s, %s, %d, %s", + printa(names[COLUMN], true, "CALL \"%s\" USING %s, %s, %d, %s", ISC_INSERT, status_vector(action), s, @@ -2217,8 +2155,8 @@ static void gen_dyn_open( const act* action) printa(names[COLUMN], true, statement->dyn_sqlda2 ? - "CALL \"%s\" USING %s, %s, %s, %d, %s, %s" : - "CALL \"%s\" USING %s, %s, %s, %d, %s", + "CALL \"%s\" USING %s, %s, %s, %d, %s, %s" : + "CALL \"%s\" USING %s, %s, %s, %d, %s", statement->dyn_sqlda2 ? ISC_OPEN2 : ISC_OPEN, status_vector(action), transaction, @@ -2262,8 +2200,7 @@ static void gen_dyn_prepare( const act* action) make_name_formatted(s, "ISC-CONST-%s", statement->dyn_statement_name); TEXT s2[MAX_CURSOR_SIZE + 1]; sprintf(s2, "%sL", s); - printa(names[COLUMN], true, GET_LEN_CALL_TEMPLATE, - STRING_LENGTH, statement->dyn_string, s2); + printa(names[COLUMN], true, GET_LEN_CALL_TEMPLATE, STRING_LENGTH, statement->dyn_string, s2); fb_utils::snprintf(s3, sizeof(s3), " %s,", s2); if (gpreGlob.sw_auto) { @@ -2271,8 +2208,7 @@ static void gen_dyn_prepare( const act* action) printa(names[COLUMN], false, "IF %s NOT = 0 THEN", transaction); } - printa(names[COLUMN], true, - "CALL \"%s\" USING %s, %s, %s, %s,%s %s, %d, %s", + printa(names[COLUMN], true, "CALL \"%s\" USING %s, %s, %s, %s,%s %s, %d, %s", ISC_PREPARE, status_vector(action), database->dbb_name->sym_string, @@ -2310,15 +2246,13 @@ static void gen_emodify( const act* action) const gpre_fld* field = reference->ref_field; gen_name(s1, source, true); gen_name(s2, reference, true); - if (field->fld_dtype == dtype_blob || - field->fld_dtype == dtype_quad || field->fld_dtype == dtype_date) + if (field->fld_dtype == dtype_blob || field->fld_dtype == dtype_quad || + field->fld_dtype == dtype_date) { - sprintf(output_buffer, "%sCALL \"isc_qtoq\" USING %s, %s\n", - names[COLUMN], s1, s2); + sprintf(output_buffer, "%sCALL \"isc_qtoq\" USING %s, %s\n", names[COLUMN], s1, s2); } else - sprintf(output_buffer, "%sMOVE %s TO %s\n", - names[COLUMN], s1, s2); + sprintf(output_buffer, "%sMOVE %s TO %s\n", names[COLUMN], s1, s2); RMC_print_buffer(output_buffer, true); if (field->fld_array_info) gen_get_or_put_slice(action, reference, false); @@ -2394,12 +2328,9 @@ static SSHORT gen_event_block( const act* action) int ident = CMP_next_ident(); init->nod_arg[2] = (gpre_nod*) (IPTR) ident; - printa(COLUMN8, false, "01 %s%dA PIC S9(10) %s.", - names[isc_a_pos], ident, USAGE_BINARY4); - printa(COLUMN8, false, "01 %s%dB PIC S9(10) %s.", - names[isc_a_pos], ident, USAGE_BINARY4); - printa(COLUMN8, false, "01 %s%dL PIC S9(5) %s.", - names[isc_a_pos], ident, USAGE_BINARY2); + printa(COLUMN8, false, "01 %s%dA PIC S9(10) %s.", names[isc_a_pos], ident, USAGE_BINARY4); + printa(COLUMN8, false, "01 %s%dB PIC S9(10) %s.", names[isc_a_pos], ident, USAGE_BINARY4); + printa(COLUMN8, false, "01 %s%dL PIC S9(5) %s.", names[isc_a_pos], ident, USAGE_BINARY2); const gpre_nod* list = init->nod_arg[1]; @@ -2414,17 +2345,14 @@ static SSHORT gen_event_block( const act* action) static void gen_event_init( const act* action) { - const TEXT *pattern1 = - "CALL \"%S1\" USING %S4%N1A, %S4%N1B, %N2, %S6 GIVING %S4%N1L"; - const TEXT *pattern2 = - "CALL \"%S2\" USING %V1, %DH, %S4%N1L, %S4%N1A, %S4%N1B"; - const TEXT *pattern3 = - "CALL \"%S3\" USING %S5, %S4%N1L, %S4%N1A, %S4%N1B"; + const TEXT *pattern1 = "CALL \"%S1\" USING %S4%N1A, %S4%N1B, %N2, %S6 GIVING %S4%N1L"; + const TEXT *pattern2 = "CALL \"%S2\" USING %V1, %DH, %S4%N1L, %S4%N1A, %S4%N1B"; + const TEXT *pattern3 = "CALL \"%S3\" USING %S5, %S4%N1L, %S4%N1A, %S4%N1B"; const gpre_nod* init = (gpre_nod*) action->act_object; const gpre_nod* event_list = init->nod_arg[1]; - const SSHORT column = strlen(names[COLUMN]); + const USHORT column = strlen(names[COLUMN]); PAT args; args.pat_database = (DBB) init->nod_arg[3]; @@ -2443,20 +2371,19 @@ static void gen_event_init( const act* action) TEXT variable[MAX_REF_SIZE]; const gpre_nod *const *ptr, *const *end; SSHORT count; - for (ptr = event_list->nod_arg, count = 0, end = - ptr + event_list->nod_count; ptr < end; ptr++) + for (ptr = event_list->nod_arg, count = 0, end = ptr + event_list->nod_count; ptr < end; ptr++) { count++; const gpre_nod* node = *ptr; if (node->nod_type == nod_field) { const ref* reference = (ref*) node->nod_arg[0]; gen_name(variable, reference, true); - printa(names[COLUMN], false, "MOVE %s TO %s(%d)", variable, - names[ISC_EVENT_NAMES2], count); + printa(names[COLUMN], false, "MOVE %s TO %s(%d)", + variable, names[ISC_EVENT_NAMES2], count); } else printa(names[COLUMN], false, "MOVE %s TO %s(%d)", - (TEXT *) node->nod_arg[0], names[ISC_EVENT_NAMES2], count); + (TEXT*) node->nod_arg[0], names[ISC_EVENT_NAMES2], count); printa(names[COLUMN], true, EVENT_MOVE_TEMPLATE, ISC_BADDRESS, names[ISC_EVENT_NAMES2], count, names[ISC_EVENT_NAMES], count); @@ -2483,10 +2410,8 @@ static void gen_event_init( const act* action) static void gen_event_wait( const act* action) { - const TEXT *pattern1 = - "CALL \"%S2\" USING %V1, %DH, %S4%N1L, %S4%N1A, %S4%N1B"; - const TEXT *pattern2 = - "CALL \"%S3\" USING %S5, %S4%N1L, %S4%N1A, %S4%N1B"; + const TEXT *pattern1 = "CALL \"%S2\" USING %V1, %DH, %S4%N1L, %S4%N1A, %S4%N1B"; + const TEXT *pattern2 = "CALL \"%S3\" USING %S5, %S4%N1L, %S4%N1A, %S4%N1B"; gpre_sym* event_name = (gpre_sym*) action->act_object; @@ -2508,8 +2433,7 @@ static void gen_event_wait( const act* action) if (ident < 0) { TEXT s[64]; - fb_utils::snprintf(s, sizeof(s), - "event handle \"%s\" not found", event_name->sym_string); + fb_utils::snprintf(s, sizeof(s), "event handle \"%s\" not found", event_name->sym_string); CPR_error(s); return; // silence non initialized warning } @@ -2553,8 +2477,7 @@ static void gen_fetch( const act* action) next FETCH statement if applicable */ ref* reference; - for (reference = port->por_references; reference; - reference = reference->ref_next) + for (reference = port->por_references; reference; reference = reference->ref_next) { gpre_value* value = reference->ref_values; reference->ref_value = value->val_value; @@ -2573,9 +2496,8 @@ static void gen_fetch( const act* action) the offset is 1, then there is no need to pass the message; this prevents extra packets and allows for batch fetches in either direction */ - printa(names[COLUMN], false, - "IF %s%dDI MOD 2 NOT = %s || %s NOT = 1 THEN", names[isc_a_pos], - request->req_ident, direction, offset); + printa(names[COLUMN], false, "IF %s%dDI MOD 2 NOT = %s || %s NOT = 1 THEN", + names[isc_a_pos], request->req_ident, direction, offset); /* assign the direction and offset parameters to the appropriate message, then send the message to the engine */ @@ -2595,8 +2517,7 @@ static void gen_fetch( const act* action) SCHAR s[MAX_REF_SIZE]; gen_receive(action, request->req_primary); - printa(names[COLUMN], false, - "IF %s NOT = 0 THEN", gen_name(s, request->req_eof, true)); + printa(names[COLUMN], false, "IF %s NOT = 0 THEN", gen_name(s, request->req_eof, true)); printa(names[COLUMN], false, "MOVE 0 TO SQLCODE"); if (gpre_nod* var_list = (gpre_nod*) action->act_object) for (int i = 0; i < var_list->nod_count; i++) { @@ -2624,8 +2545,7 @@ static void gen_finish( const act* action) (action->act_type != ACT_disconnect))) { printa(names[COLUMN], false, "IF %s NOT = 0 THEN", names[isc_trans_pos]); - printa(names[COLUMN], true, - " CALL \"%s\" USING %s, %s", + printa(names[COLUMN], true, " CALL \"%s\" USING %s, %s", (action->act_type != ACT_rfinish) ? ISC_COMMIT_TRANSACTION : ISC_ROLLBACK_TRANSACTION, status_vector(action), names[isc_trans_pos]); @@ -2637,10 +2557,8 @@ static void gen_finish( const act* action) const dbb* db = NULL; for (const rdy* ready = (rdy*) action->act_object; ready; ready = ready->rdy_next) { db = ready->rdy_database; - printa(names[COLUMN], false, - "IF %s NOT = 0 THEN", db->dbb_name->sym_string); - printa(names[COLUMN], true, - "CALL \"%s\" USING %s, %s", + printa(names[COLUMN], false, "IF %s NOT = 0 THEN", db->dbb_name->sym_string); + printa(names[COLUMN], true, "CALL \"%s\" USING %s, %s", ISC_DETACH_DATABASE, status_vector(action), db->dbb_name->sym_string); printa(names[COLUMN], false, "END-IF"); @@ -2650,10 +2568,8 @@ static void gen_finish( const act* action) if (!db) for (db = gpreGlob.isc_databases; db; db = db->dbb_next) { - printa(names[COLUMN], false, - "IF %s NOT = 0 THEN", db->dbb_name->sym_string); - printa(names[COLUMN], true, - "CALL \"%s\" USING %s, %s", + printa(names[COLUMN], false, "IF %s NOT = 0 THEN", db->dbb_name->sym_string); + printa(names[COLUMN], true, "CALL \"%s\" USING %s, %s", ISC_DETACH_DATABASE, status_vector(action), db->dbb_name->sym_string); printa(names[COLUMN], false, "END-IF"); @@ -2674,13 +2590,11 @@ static void gen_for( const act* action) gen_s_start(action); const gpre_req* request = action->act_request; gen_receive(action, request->req_primary); - printa(names[COLUMN], false, "PERFORM UNTIL %s = 0", - gen_name(s, request->req_eof, true)); + printa(names[COLUMN], false, "PERFORM UNTIL %s = 0", gen_name(s, request->req_eof, true)); const gpre_port* port = action->act_request->req_primary; if (port) - for (const ref* reference = port->por_references; reference; - reference = reference->ref_next) + for (const ref* reference = port->por_references; reference; reference = reference->ref_next) { if (reference->ref_field->fld_array_info) gen_get_or_put_slice(action, reference, true); @@ -2711,23 +2625,20 @@ static void gen_function( const act* function) TEXT s[MAX_REF_SIZE]; const gpre_port* port = request->req_vport; if (port) - for (reference = port->por_references; reference; - reference = reference->ref_next) + for (reference = port->por_references; reference; reference = reference->ref_next) { - fprintf(gpreGlob.out_file, ", %s", - gen_name(s, reference->ref_source, true)); + fprintf(gpreGlob.out_file, ", %s", gen_name(s, reference->ref_source, true)); } - fprintf(gpreGlob.out_file, - ")\n isc_req_handle\trequest;\n isc_tr_handle\ttransaction;\n"); + fprintf(gpreGlob.out_file, ")\n isc_req_handle\trequest;\n isc_tr_handle\ttransaction;\n"); if (port) - for (reference = port->por_references; reference; - reference = reference->ref_next) + for (reference = port->por_references; reference; reference = reference->ref_next) { const char* dtype; const gpre_fld* field = reference->ref_field; - switch (field->fld_dtype) { + switch (field->fld_dtype) + { case dtype_short: dtype = "short"; break; @@ -2763,7 +2674,7 @@ static void gen_function( const act* function) return; } fprintf(gpreGlob.out_file, " %s\t%s;\n", dtype, - gen_name(s, reference->ref_source, true)); + gen_name(s, reference->ref_source, true)); } fprintf(gpreGlob.out_file, "{\n"); @@ -2775,16 +2686,14 @@ static void gen_function( const act* function) gen_receive(action, request->req_primary); for (port = request->req_ports; port; port = port->por_next) - for (reference = port->por_references; reference; - reference = reference->ref_next) + for (reference = port->por_references; reference; reference = reference->ref_next) { if (reference->ref_field->fld_array_info) gen_get_or_put_slice(action, reference, true); } port = request->req_primary; - fprintf(gpreGlob.out_file, "\nreturn %s;\n}\n", - gen_name(s, port->por_references, true)); + fprintf(gpreGlob.out_file, "\nreturn %s;\n}\n", gen_name(s, port->por_references, true)); } @@ -2794,14 +2703,10 @@ static void gen_function( const act* function) // or isc_put_slice for an array. // -static void gen_get_or_put_slice(const act* action, - const ref* reference, - bool get) +static void gen_get_or_put_slice(const act* action, const ref* reference, bool get) { - const TEXT* pattern1 = - "CALL \"%S7\" USING %V1, %DH, %S1, %S2, %N1, %S3, %N2, %S4, %L1, %S5, %S6"; - const TEXT* pattern2 = - "CALL \"%S7\" USING %V1, %DH, %S1, %S2, %N1, %S3, %N2, %S4, %L1, %S5"; + const TEXT* pattern1 = "CALL \"%S7\" USING %V1, %DH, %S1, %S2, %N1, %S3, %N2, %S4, %L1, %S5, %S6"; + const TEXT* pattern2 = "CALL \"%S7\" USING %V1, %DH, %S1, %S2, %N1, %S3, %N2, %S4, %L1, %S5"; if (!(reference->ref_flags & REF_fetch_array)) return; @@ -2835,8 +2740,7 @@ static void gen_get_or_put_slice(const act* action, args.pat_string5 = reference->ref_value; } else { - sprintf(s4, "%s%dL", names[isc_a_pos], - reference->ref_field->fld_array_info->ary_ident); + sprintf(s4, "%s%dL", names[isc_a_pos], reference->ref_field->fld_array_info->ary_ident); args.pat_string5 = s4; // array name } @@ -2856,16 +2760,13 @@ static void gen_get_or_put_slice(const act* action, static void gen_get_segment( const act* action) { const blb* blob; - TEXT buffer[128]; if (action->act_flags & ACT_sql) blob = (blb*) action->act_request->req_blobs; else blob = (blb*) action->act_object; - strcpy(buffer, GET_SEG_CALL_TEMPLATE); // Copy seems useless instead of using constant directly. - sprintf(output_buffer, - buffer, + sprintf(output_buffer, GET_SEG_CALL_TEMPLATE, names[COLUMN], ISC_GET_SEGMENT, names[isc_status_vector_pos], @@ -2965,11 +2866,9 @@ static void gen_procedure( const act* action) args.pat_port2 = out_port; const TEXT* pattern; if (in_port && in_port->por_length) - pattern = - "CALL \"isc_transact_request\" USING %V1, %DH, %RT, %RS, %RI, %PL, %PI, %QL, %QI\n"; + pattern = "CALL \"isc_transact_request\" USING %V1, %DH, %RT, %RS, %RI, %PL, %PI, %QL, %QI\n"; else - pattern = - "CALL \"isc_transact_request\" USING %V1, %DH, %RT, %RS, %RI, 0, 0, %QL, %QI\n"; + pattern = "CALL \"isc_transact_request\" USING %V1, %DH, %RT, %RS, %RI, 0, 0, %QL, %QI\n"; // Get database attach and transaction started @@ -3016,10 +2915,8 @@ static void gen_put_segment( const act* action) else blob = (blb*) action->act_object; - TEXT buffer[128]; - strcpy(buffer, PUT_SEG_CALL_TEMPLATE); - sprintf(output_buffer, - buffer, + + sprintf(output_buffer, PUT_SEG_CALL_TEMPLATE, names[COLUMN], ISC_PUT_SEGMENT, status_vector(action), @@ -3037,9 +2934,7 @@ static void gen_put_segment( const act* action) // Generate BLR in raw, hexadecmial form. Ugly but dense. // -static void gen_raw( - const UCHAR* blr, - req_t request_type, int request_length, int ident) +static void gen_raw(const UCHAR* blr, req_t request_type, int request_length, int ident) { int length = 1; ULONG ltemp = 0; @@ -3177,8 +3072,7 @@ static void gen_release( const act* action) static void gen_receive( const act* action, const gpre_port* port) { const gpre_req* request = action->act_request; - sprintf(output_buffer, - "%sCALL \"%s\" USING %s, %s, %d, %d, %s%d, %s\n", + sprintf(output_buffer, "%sCALL \"%s\" USING %s, %s, %d, %d, %s%d, %s\n", names[COLUMN], ISC_RECEIVE, status_vector(action), @@ -3204,70 +3098,62 @@ static void gen_receive( const act* action, const gpre_port* port) static void gen_request( gpre_req* request) { - if (!(request->req_flags & (REQ_exp_hand | REQ_sql_blob_open - | REQ_sql_blob_create)) && request->req_type != REQ_slice - && request->req_type != REQ_procedure) + if (!(request->req_flags & (REQ_exp_hand | REQ_sql_blob_open | REQ_sql_blob_create)) && + request->req_type != REQ_slice && request->req_type != REQ_procedure) { - printa(COLUMN8, false, - "01 %s PIC S9(10) %s VALUE IS 0.", + printa(COLUMN8, false, "01 %s PIC S9(10) %s VALUE IS 0.", request->req_handle, USAGE_BINARY4); } if (request->req_type == REQ_ready) - printa(COLUMN8, false, - "01 %s%dL PIC S9(5) %s VALUE IS %d.", names[isc_a_pos], - request->req_ident, USAGE_BINARY2, request->req_length); + printa(COLUMN8, false, "01 %s%dL PIC S9(5) %s VALUE IS %d.", + names[isc_a_pos], request->req_ident, USAGE_BINARY2, request->req_length); // check the case where we need to extend the dpb dynamically at runtime, // in which case we need dpb length and a pointer to be defined even if // there is no static dpb defined if (request->req_flags & REQ_extend_dpb) { - printa(COLUMN8, false, - "01 %s%dP PIC S9(10) %s VALUE IS 0.", + printa(COLUMN8, false, "01 %s%dP PIC S9(10) %s VALUE IS 0.", names[isc_a_pos], request->req_ident, USAGE_BINARY4); - printa(COLUMN8, false, - "01 %s%dP1 PIC S9(10) %s VALUE IS 0.", + printa(COLUMN8, false, "01 %s%dP1 PIC S9(10) %s VALUE IS 0.", names[isc_a_pos], request->req_ident, USAGE_BINARY4); } if (request->req_flags & (REQ_sql_blob_open | REQ_sql_blob_create)) - printa(COLUMN8, false, - "01 %s%dS PIC S9(10) %s VALUE IS 0.", names[isc_a_pos], - request->req_ident, USAGE_BINARY4); + printa(COLUMN8, false, "01 %s%dS PIC S9(10) %s VALUE IS 0.", + names[isc_a_pos], request->req_ident, USAGE_BINARY4); // generate the request as BLR long words - if (request->req_length) { + if (request->req_length) + { if (request->req_flags & REQ_sql_cursor) - printa(COLUMN8, false, - "01 %s%dS PIC S9(10) %s VALUE IS 0.", names[isc_a_pos], - request->req_ident, USAGE_BINARY4); + printa(COLUMN8, false, "01 %s%dS PIC S9(10) %s VALUE IS 0.", + names[isc_a_pos], request->req_ident, USAGE_BINARY4); #ifdef SCROLLABLE_CURSORS if (request->req_flags & REQ_scroll) - printa(COLUMN8, false, - "01 %s%dDI PIC S9(5) %s VALUE IS 0.", names[isc_a_pos], - request->req_ident, USAGE_BINARY2); + printa(COLUMN8, false, "01 %s%dDI PIC S9(5) %s VALUE IS 0.", + names[isc_a_pos], request->req_ident, USAGE_BINARY2); #endif - printa(COLUMN8, false, "01 %s%d.", - names[isc_a_pos], request->req_ident); - gen_raw(request->req_blr, request->req_type, request->req_length, - request->req_ident); + printa(COLUMN8, false, "01 %s%d.", names[isc_a_pos], request->req_ident); + gen_raw(request->req_blr, request->req_type, request->req_length, request->req_ident); const char* string_type; - if (!gpreGlob.sw_raw) { + if (!gpreGlob.sw_raw) + { printa(names[COMMENT], false, " "); printa(names[COMMENT], false, "FORMATTED REQUEST BLR FOR %s%d = ", names[isc_a_pos], request->req_ident); - switch (request->req_type) { + + switch (request->req_type) + { case REQ_create_database: case REQ_ready: string_type = "DPB"; if (PRETTY_print_cdb(request->req_blr, gen_blr, 0, 0)) CPR_error("internal error during parameter generation"); break; - - case REQ_ddl: string_type = "DYN"; if (PRETTY_print_dyn(request->req_blr, gen_blr, 0, 0)) @@ -3286,12 +3172,12 @@ static void gen_request( gpre_req* request) } } else { - switch (request->req_type) { + switch (request->req_type) + { case REQ_create_database: case REQ_ready: string_type = "DPB"; break; - case REQ_ddl: string_type = "DYN"; break; @@ -3311,17 +3197,17 @@ static void gen_request( gpre_req* request) // Print out slice description language if there are arrays associated with request for (gpre_port* port = request->req_ports; port; port = port->por_next) - for (const ref* reference = port->por_references; reference; - reference = reference->ref_next) + for (const ref* reference = port->por_references; reference; reference = reference->ref_next) { if (reference->ref_sdl) { - printa(COLUMN8, false, "01 %s%d.", names[isc_a_pos], - reference->ref_sdl_ident); + printa(COLUMN8, false, "01 %s%d.", names[isc_a_pos], reference->ref_sdl_ident); gen_raw(reference->ref_sdl, REQ_slice, reference->ref_sdl_length, reference->ref_sdl_ident); if (!gpreGlob.sw_raw) + { if (PRETTY_print_sdl(reference->ref_sdl, gen_blr, 0, 0)) CPR_error("internal error during SDL generation"); + } printa(names[COMMENT], false, " "); printa(names[COMMENT], false, @@ -3333,19 +3219,15 @@ static void gen_request( gpre_req* request) // Print out any blob parameter blocks required for (const blb* blob = request->req_blobs; blob; blob = blob->blb_next) if (blob->blb_const_from_type || blob->blb_const_to_type) { - printa(COLUMN8, false, "01 %s%d.", - names[isc_a_pos], blob->blb_bpb_ident); - gen_raw(blob->blb_bpb, request->req_type, blob->blb_bpb_length, - (int) (IPTR) request); + printa(COLUMN8, false, "01 %s%d.", names[isc_a_pos], blob->blb_bpb_ident); + gen_raw(blob->blb_bpb, request->req_type, blob->blb_bpb_length, (int) (IPTR) request); printa(names[COMMENT], false, " "); } // If this is a GET_SLICE/PUT_slice, allocate some variables if (request->req_type == REQ_slice) { - printa(COLUMN8, false, "01 %s%dv.", names[isc_b_pos], - request->req_ident); - printa(COLUMN12, false, - "03 %s%dv_3 PIC S9(10) %s OCCURS %d TIMES.", + printa(COLUMN8, false, "01 %s%dv.", names[isc_b_pos], request->req_ident); + printa(COLUMN12, false, "03 %s%dv_3 PIC S9(10) %s OCCURS %d TIMES.", names[isc_b_pos], request->req_ident, USAGE_BINARY4, @@ -3368,8 +3250,7 @@ static void gen_s_end( const act* action) if (action->act_type == ACT_close) gen_cursor_close(action, request); - printa(names[COLUMN], true, - "CALL \"%s\" USING %s, %s, %s", + printa(names[COLUMN], true, "CALL \"%s\" USING %s, %s, %s", ISC_UNWIND_REQUEST, status_vector(action), request->req_handle, @@ -3425,8 +3306,7 @@ static void gen_s_start( const act* action) printa(names[COLUMN], false, "IF %s NOT = 0 AND %s NOT = 0 THEN", request_trans(action, request), request->req_handle); else - printa(names[COLUMN], false, "IF %s NOT = 0 THEN", - request->req_handle); + printa(names[COLUMN], false, "IF %s NOT = 0 THEN", request->req_handle); } gen_start(action, port); @@ -3454,8 +3334,7 @@ static void gen_send( const act* action, const gpre_port* port) { const gpre_req* request = action->act_request; - sprintf(output_buffer, - "%sCALL \"%s\" USING %s, %s, %d, %d, %s%d, %s\n", + sprintf(output_buffer, "%sCALL \"%s\" USING %s, %s, %d, %d, %s%d, %s\n", names[COLUMN], ISC_SEND, status_vector(action), @@ -3479,8 +3358,7 @@ static void gen_slice( const act* action) { const TEXT *pattern1 = "CALL \"%S7\" USING %V1, %DH, %RT, %FR, %N1, %I1, %N2, %I1v, %I1s, %S5, %S6"; - const TEXT *pattern2 = - "CALL \"%S7\" USING %V1, %DH, %RT, %FR, %N1, %I1, %N2, %I1v, %I1s, %S5"; + const TEXT *pattern2 = "CALL \"%S7\" USING %V1, %DH, %RT, %FR, %N1, %I1, %N2, %I1v, %I1s, %S5"; const USHORT column = strlen(names[COLUMN]); const gpre_req* request = action->act_request; @@ -3490,19 +3368,16 @@ static void gen_slice( const act* action) // Compute array size fprintf(gpreGlob.out_file, " COMPUTE %s%ds = %d", - names[isc_b_pos], - request->req_ident, slice->slc_field->fld_array->fld_length); + names[isc_b_pos], request->req_ident, slice->slc_field->fld_array->fld_length); const slc::slc_repeat *tail, *end; - for (tail = slice->slc_rpt, end = tail + slice->slc_dimensions; - tail < end; ++tail) + for (tail = slice->slc_rpt, end = tail + slice->slc_dimensions; tail < end; ++tail) { if (tail->slc_upper != tail->slc_lower) { const ref* lower = (ref*) tail->slc_lower->nod_arg[0]; const ref* upper = (ref*) tail->slc_upper->nod_arg[0]; if (lower->ref_value) - fprintf(gpreGlob.out_file, " * ( %s - %s + 1)", upper->ref_value, - lower->ref_value); + fprintf(gpreGlob.out_file, " * ( %s - %s + 1)", upper->ref_value, lower->ref_value); else fprintf(gpreGlob.out_file, " * ( %s + 1)", upper->ref_value); } @@ -3512,8 +3387,7 @@ static void gen_slice( const act* action) // Make assignments to variable vector const ref* reference; - for (reference = request->req_values; reference; - reference = reference->ref_next) + for (reference = request->req_values; reference; reference = reference->ref_next) { printa(names[COLUMN], false, "MOVE %s TO %s%dv (%d)", reference->ref_value, names[isc_a_pos], @@ -3609,15 +3483,13 @@ static void gen_start( const act* action, const gpre_port* port) const TEXT* vector = status_vector(action); if (port) { - for (const ref* reference = port->por_references; reference; - reference = reference->ref_next) + for (const ref* reference = port->por_references; reference; reference = reference->ref_next) { if (reference->ref_field->fld_array_info) gen_get_or_put_slice(action, reference, false); } - sprintf(output_buffer, - "%sCALL \"%s\" USING %s, %s, %s, %d, %d, %s%d, %s\n", + sprintf(output_buffer, "%sCALL \"%s\" USING %s, %s, %s, %d, %d, %s%d, %s\n", names[COLUMN], ISC_START_AND_SEND, vector, @@ -3629,8 +3501,7 @@ static void gen_start( const act* action, const gpre_port* port) request->req_request_level); } else - sprintf(output_buffer, - "%sCALL \"%s\" USING %s, %s, %s, %s\n", + sprintf(output_buffer, "%sCALL \"%s\" USING %s, %s, %s, %s\n", names[COLUMN], ISC_START_REQUEST, vector, @@ -3659,8 +3530,7 @@ static void gen_store( const act* action) TEXT name[MAX_REF_SIZE]; const gpre_port* port = request->req_primary; - for (const ref* reference = port->por_references; reference; - reference = reference->ref_next) + for (const ref* reference = port->por_references; reference; reference = reference->ref_next) { const gpre_fld* field = reference->ref_field; if (field->fld_flags & FLD_blob) @@ -3691,37 +3561,30 @@ static void gen_t_start( const act* action) const tpb* tpb_iterator; if (gpreGlob.sw_auto) - for (tpb_iterator = trans->tra_tpb; - tpb_iterator; - tpb_iterator = tpb_iterator->tpb_tra_next) + for (tpb_iterator = trans->tra_tpb; tpb_iterator; tpb_iterator = tpb_iterator->tpb_tra_next) { const dbb* db = tpb_iterator->tpb_database; const TEXT* filename = db->dbb_runtime; if (filename || !(db->dbb_flags & DBB_sqlca)) { - printa(names[COLUMN], false, "IF %s = 0 THEN", - db->dbb_name->sym_string); + printa(names[COLUMN], false, "IF %s = 0 THEN", db->dbb_name->sym_string); const USHORT namelength = filename ? strlen(filename) : 0; if (filename) { sprintf(dbname, "%s%ddb", names[isc_b_pos], db->dbb_id); filename = dbname; } - make_ready(db, filename, status_vector(action), 0, - namelength); + make_ready(db, filename, status_vector(action), 0, namelength); set_sqlcode(action); printa(names[COLUMN], false, "END-IF"); } } - printa(names[COLUMN], true, - "CALL \"%s\" USING %s, %s, %d", + printa(names[COLUMN], true, "CALL \"%s\" USING %s, %s, %d", ISC_START_TRANSACTION, status_vector(action), trans->tra_handle ? trans->tra_handle : names[isc_trans_pos], trans->tra_db_count); - for (tpb_iterator = trans->tra_tpb; - tpb_iterator; - tpb_iterator = tpb_iterator->tpb_tra_next) + for (tpb_iterator = trans->tra_tpb; tpb_iterator; tpb_iterator = tpb_iterator->tpb_tra_next) { printa(names[CONTINUE], true, ", %s, %d, %s%d", tpb_iterator->tpb_database->dbb_name->sym_string, @@ -3748,8 +3611,7 @@ static void gen_tpb(const tpb* tpb_buffer) const UCHAR *text = tpb_buffer->tpb_string; // Generate the 01 group level - printa(COLUMN8, false, "01 %s%d.", - names[isc_tpb_pos], tpb_buffer->tpb_ident); + printa(COLUMN8, false, "01 %s%d.", names[isc_tpb_pos], tpb_buffer->tpb_ident); // Dump TPB to WORKING-STORAGE in 4 byte chunks while (text_len--) { ltemp += *(text++) << offset; @@ -3847,8 +3709,7 @@ static void gen_variable( const act* action) { TEXT s[MAX_REF_SIZE]; const ref* reference = action->act_object; - fprintf(gpreGlob.out_file, "\n%s%s", - names[COLUMN], gen_name(s, reference, false)); + fprintf(gpreGlob.out_file, "\n%s%s", names[COLUMN], gen_name(s, reference, false)); } @@ -3859,10 +3720,12 @@ static void gen_variable( const act* action) static void gen_whenever(const swe* label) { - const TEXT* condition; + const TEXT* condition = NULL; - while (label) { - switch (label->swe_condition) { + while (label) + { + switch (label->swe_condition) + { case SWE_error: condition = "SQLCODE < 0"; break; @@ -3881,7 +3744,7 @@ static void gen_whenever(const swe* label) return; } fprintf(gpreGlob.out_file, "%sIF (%s) THEN GO TO %s", - names[COLUMN], condition, label->swe_label); + names[COLUMN], condition, label->swe_label); if (label->swe_condition == SWE_warning) fprintf(gpreGlob.out_file, "\n%s", names[COLUMN_INDENT]); label = label->swe_next; @@ -3909,8 +3772,7 @@ static void make_array_declaration( ref* reference) field->fld_array_info->ary_declared = true; fprintf(gpreGlob.out_file, "%s01 %s%dL.\n", - COLUMN8, names[isc_a_pos], - field->fld_array_info->ary_ident); + COLUMN8, names[isc_a_pos], field->fld_array_info->ary_ident); TEXT space[128]; strcpy(space, " "); @@ -3936,7 +3798,8 @@ static void make_array_declaration( ref* reference) SSHORT digits, scale; - switch (field->fld_array_info->ary_dtype) { + switch (field->fld_array_info->ary_dtype) + { case dtype_short: case dtype_long: digits = (field->fld_array_info->ary_dtype == dtype_short) ? 5 : 10; @@ -4027,8 +3890,7 @@ static void make_array_declaration( ref* reference) default: { char s[ERROR_LENGTH]; - fb_utils::snprintf(s, sizeof(s), - "datatype %d unknown for field %s", + fb_utils::snprintf(s, sizeof(s), "datatype %d unknown for field %s", field->fld_array_info->ary_dtype, name); CPR_error(s); return; @@ -4063,8 +3925,7 @@ static void make_name(TEXT* const string, const gpre_sym* symbol) // Turn a symbol into a varying string. // -static void make_name_formatted(TEXT* const string, const TEXT* format, - const gpre_sym* symbol) +static void make_name_formatted(TEXT* const string, const TEXT* format, const gpre_sym* symbol) { fb_utils::snprintf(string, MAX_CURSOR_SIZE, format, symbol->sym_string); for (TEXT* s = string; *s; s++) @@ -4084,8 +3945,7 @@ static void make_port(const gpre_port* port) printa(COLUMN8, false, "01 %s%d.", names[isc_a_pos], port->por_ident); - for (const ref* reference = port->por_references; reference; - reference = reference->ref_next) + for (const ref* reference = port->por_references; reference; reference = reference->ref_next) { const gpre_fld* field = reference->ref_field; const TEXT* name; @@ -4096,7 +3956,9 @@ static void make_port(const gpre_port* port) name = ""; if (reference->ref_value && (reference->ref_flags & REF_array_elem)) field = field->fld_array; - switch (field->fld_dtype) { + + switch (field->fld_dtype) + { case dtype_short: case dtype_long: digits = (field->fld_dtype == dtype_short) ? 5 : 10; @@ -4106,16 +3968,13 @@ static void make_port(const gpre_port* port) if (field->fld_scale > -digits) fprintf(gpreGlob.out_file, "9(%d)", digits + field->fld_scale); if (field->fld_scale) - fprintf(gpreGlob.out_file, "V9(%d)", - digits - (digits + field->fld_scale)); + fprintf(gpreGlob.out_file, "V9(%d)", digits - (digits + field->fld_scale)); } else if (field->fld_scale > 0) fprintf(gpreGlob.out_file, "9(%d)P(%d)", digits, field->fld_scale); else - fprintf(gpreGlob.out_file, "VP(%d)9(%d)", - -(field->fld_scale + digits), digits); - fprintf(gpreGlob.out_file, - "%s.\n", + fprintf(gpreGlob.out_file, "VP(%d)9(%d)", -(field->fld_scale + digits), digits); + fprintf(gpreGlob.out_file, "%s.\n", (field->fld_dtype == dtype_short) ? USAGE_BINARY2 : USAGE_BINARY4); break; @@ -4151,23 +4010,19 @@ static void make_port(const gpre_port* port) if (field->fld_scale > -digits) fprintf(gpreGlob.out_file, "9(%d)", digits + field->fld_scale); if (field->fld_scale) - fprintf(gpreGlob.out_file, "V9(%d)", - digits - (digits + field->fld_scale)); + fprintf(gpreGlob.out_file, "V9(%d)", digits - (digits + field->fld_scale)); } else if (field->fld_scale > 0) fprintf(gpreGlob.out_file, "9(%d)P(%d)", digits, field->fld_scale); else - fprintf(gpreGlob.out_file, "VP(%d)9(%d)", - -(field->fld_scale + digits), digits); - fprintf(gpreGlob.out_file, - "%s.\n", + fprintf(gpreGlob.out_file, "VP(%d)9(%d)", -(field->fld_scale + digits), digits); + fprintf(gpreGlob.out_file, "%s.\n", (field->fld_dtype == dtype_real) ? USAGE_BINARY4 : USAGE_BINARY8); break; case dtype_sql_date: case dtype_sql_time: - fprintf(gpreGlob.out_file, - "%s03 %s%d PIC S9(10) %s.\n", + fprintf(gpreGlob.out_file, "%s03 %s%d PIC S9(10) %s.\n", COLUMN12, names[isc_a_pos], reference->ref_ident, @@ -4177,8 +4032,7 @@ static void make_port(const gpre_port* port) default: { TEXT s[ERROR_LENGTH]; - fb_utils::snprintf(s, sizeof(s), - "datatype %d unknown for field %s, msg %d", + fb_utils::snprintf(s, sizeof(s), "datatype %d unknown for field %s, msg %d", field->fld_dtype, name, port->por_msg_number); CPR_error(s); return; @@ -4195,8 +4049,7 @@ static void make_port(const gpre_port* port) // Generate the actual ready call. // -static void make_ready( - const dbb* db, +static void make_ready(const dbb* db, const TEXT* filename, const TEXT* vector, const gpre_req* request, USHORT namelength) @@ -4204,7 +4057,8 @@ static void make_ready( TEXT s1[32], s1Tmp[32], s2[32], s2Tmp[32]; const dbb* dbisc = (DBB) db->dbb_name->sym_object; - if (request) { + if (request) + { sprintf(s1, "%s%dL", names[isc_b_pos], request->req_ident); if (request->req_flags & REQ_extend_dpb) sprintf(s2, "%s%dp", names[isc_b_pos], request->req_ident); @@ -4215,10 +4069,10 @@ static void make_ready( in host variables, do so here; this assumes that there is always a request generated for runtime variables */ - if (request->req_flags & REQ_extend_dpb) { + if (request->req_flags & REQ_extend_dpb) + { if (request->req_length) - sprintf(output_buffer, - "%sCALL \"%s\" USING %s%d GIVING %s\n", + sprintf(output_buffer, "%sCALL \"%s\" USING %s%d GIVING %s\n", names[COLUMN], ISC_BADDRESS, names[isc_b_pos], @@ -4227,15 +4081,11 @@ static void make_ready( // sprintf(output_buffer, "%sMOVE %s%d to %s\n", // names[COLUMN], names[isc_b_pos], request->req_ident, s2); else - sprintf(output_buffer, - "%sMOVE 0 TO %s\n", - names[COLUMN], - s2); + sprintf(output_buffer, "%sMOVE 0 TO %s\n", names[COLUMN], s2); RMC_print_buffer(output_buffer, true); if (db->dbb_r_user) { - sprintf(output_buffer, - "%sCALL \"%s\" USING %s, %s, 28, %s\n", + sprintf(output_buffer, "%sCALL \"%s\" USING %s, %s, 28, %s\n", names[COLUMN], ISC_EXPAND_DPB, s2, @@ -4244,8 +4094,7 @@ static void make_ready( RMC_print_buffer(output_buffer, true); } if (db->dbb_r_password) { - sprintf(output_buffer, - "%sCALL \"%s\" USING %s, %s, 29, %s\n", + sprintf(output_buffer, "%sCALL \"%s\" USING %s, %s, 29, %s\n", names[COLUMN], ISC_EXPAND_DPB, s2, @@ -4263,8 +4112,7 @@ static void make_ready( */ if (db->dbb_r_sql_role) { - sprintf(output_buffer, - "%sCALL \"%s\" USING %s, %s, 60, %s, %d\n", + sprintf(output_buffer, "%sCALL \"%s\" USING %s, %s, 60, %s, %d\n", names[COLUMN], ISC_EXPAND_DPB, s2, @@ -4274,8 +4122,7 @@ static void make_ready( } if (db->dbb_r_lc_messages) { - sprintf(output_buffer, - "%sCALL \"%s\" USING %s, %s, 47, %s, %d\n", + sprintf(output_buffer, "%sCALL \"%s\" USING %s, %s, 47, %s, %d\n", names[COLUMN], ISC_EXPAND_DPB, s2, @@ -4284,8 +4131,7 @@ static void make_ready( RMC_print_buffer(output_buffer, true); } if (db->dbb_r_lc_ctype) { - sprintf(output_buffer, - "%sCALL \"%s\" USING %s %s, 48, %s, %d\n", + sprintf(output_buffer, "%sCALL \"%s\" USING %s %s, 48, %s, %d\n", names[COLUMN], ISC_EXPAND_DPB, s2, @@ -4312,8 +4158,7 @@ static void make_ready( namelength = strlen(db->dbb_filename); } - sprintf(output_buffer, - "%sCALL \"%s\" USING %s, %d, %s, %s, %s, %s\n", + sprintf(output_buffer, "%sCALL \"%s\" USING %s, %d, %s, %s, %s, %s\n", names[COLUMN], ISC_ATTACH_DATABASE, vector, @@ -4327,18 +4172,17 @@ static void make_ready( // if the dpb was extended, free it here - if (request && request->req_flags & REQ_extend_dpb) { + if (request && request->req_flags & REQ_extend_dpb) + { if (request->req_length) { - sprintf(output_buffer, - "%sCALL \"%s\" USING %s%d GIVING %s1\n", + sprintf(output_buffer, "%sCALL \"%s\" USING %s%d GIVING %s1\n", names[COLUMN], ISC_BADDRESS, names[isc_b_pos], request->req_ident, s2); RMC_print_buffer(output_buffer, true); - sprintf(output_buffer, - "%sIF %s NOT = %s1 THEN\n", + sprintf(output_buffer, "%sIF %s NOT = %s1 THEN\n", names[COLUMN], s2, s2); @@ -4346,8 +4190,7 @@ static void make_ready( RMC_print_buffer(output_buffer, true); } - sprintf(output_buffer, - "%sCALL \"%s\" USING %s\n", names[COLUMN], ISC_FREE, s2Tmp); + sprintf(output_buffer, "%sCALL \"%s\" USING %s\n", names[COLUMN], ISC_FREE, s2Tmp); RMC_print_buffer(output_buffer, true); if (request->req_length) { @@ -4356,8 +4199,7 @@ static void make_ready( } // reset the length of the dpb - sprintf(output_buffer, "%sMOVE %d to %s\n", - names[COLUMN], request->req_length, s1); + sprintf(output_buffer, "%sMOVE %d to %s\n", names[COLUMN], request->req_length, s1); RMC_print_buffer(output_buffer, true); } } @@ -4368,10 +4210,7 @@ static void make_ready( // Print a fixed string at a particular COLUMN. // -static void printa(const TEXT* column, - bool call, - const TEXT* string, - ...) +static void printa(const TEXT* column, bool call, const TEXT* string, ...) { va_list ptr; TEXT s[256]; @@ -4431,8 +4270,7 @@ static void set_sqlcode( const act* action) if (action && action->act_flags & ACT_sql) { strcpy(buffer, SQLCODE_CALL_TEMPLATE); - printa(names[COLUMN], true, - buffer, ISC_SQLCODE_CALL, names[isc_status_vector_pos]); + printa(names[COLUMN], true, buffer, ISC_SQLCODE_CALL, names[isc_status_vector_pos]); } } @@ -4478,14 +4316,14 @@ static void t_start_auto(const gpre_req* request, const dbb* db; int count; - if (gpreGlob.sw_auto) { + if (gpreGlob.sw_auto) + { buffer[0] = 0; for (count = 0, db = gpreGlob.isc_databases; db; db = db->dbb_next, count++) { const TEXT* filename = db->dbb_runtime; if (filename || !(db->dbb_flags & DBB_sqlca)) { - fprintf(gpreGlob.out_file, "%sIF %s = 0", names[COLUMN], - db->dbb_name->sym_string); + fprintf(gpreGlob.out_file, "%sIF %s = 0", names[COLUMN], db->dbb_name->sym_string); if (stat && buffer[0]) fprintf(gpreGlob.out_file, " AND %s(2) = 0", names[isc_status_pos]); fprintf(gpreGlob.out_file, " THEN\n"); @@ -4498,16 +4336,14 @@ static void t_start_auto(const gpre_req* request, printa(names[COLUMN], false, "END-IF"); if (buffer[0]) strcat(buffer, ") AND ("); - fb_utils::snprintf(temp, sizeof(temp), "%s NOT = 0", - db->dbb_name->sym_string); + fb_utils::snprintf(temp, sizeof(temp), "%s NOT = 0", db->dbb_name->sym_string); strcat(buffer, temp); } } fb_assert(strlen(buffer) < sizeof(buffer)); if (test) if (buffer[0]) - printa(names[COLUMN], false, "IF (%s) AND %s = 0 THEN", - buffer, trname); + printa(names[COLUMN], false, "IF (%s) AND %s = 0 THEN", buffer, trname); else printa(names[COLUMN], false, "IF %s = 0 THEN", trname); @@ -4515,15 +4351,15 @@ static void t_start_auto(const gpre_req* request, printa(names[COLUMN], false, "IF (%s) THEN", buffer); } else - for (count = 0, db = gpreGlob.isc_databases; db; db = db->dbb_next, count++); + for (count = 0, db = gpreGlob.isc_databases; db; db = db->dbb_next, count++) + ; const TEXT* col = stat ? names[COLUMN_INDENT] : names[COLUMN]; printa(col, true, "CALL \"%s\" USING %s, %s, %d", ISC_START_TRANSACTION, vector, trname, count); for (db = gpreGlob.isc_databases; db; db = db->dbb_next) - printa(names[CONTINUE], true, ", %s, %s, %s", - db->dbb_name->sym_string, OMITTED, OMITTED); + printa(names[CONTINUE], true, ", %s, %s, %s", db->dbb_name->sym_string, OMITTED, OMITTED); if (gpreGlob.sw_auto && (test || buffer[0])) printa(names[COLUMN], false, "END-IF"); diff --git a/src/gpre/sqe.cpp b/src/gpre/sqe.cpp index 003ad1b8c7..82f2f50138 100644 --- a/src/gpre/sqe.cpp +++ b/src/gpre/sqe.cpp @@ -56,7 +56,8 @@ #include "../common/utils_proto.h" -struct scope { +struct scope +{ gpre_ctx* req_contexts; USHORT req_scope_level; // scope level for SQL subquery parsing USHORT req_in_aggregate; // now processing value expr for aggr @@ -67,7 +68,7 @@ struct scope { USHORT req_in_subselect; // processing a subselect clause }; -static bool compare_expr(gpre_nod*, gpre_nod*); +static bool compare_expr(const gpre_nod*, const gpre_nod*); static gpre_nod* copy_fields(gpre_nod*, map*); static gpre_nod* explode_asterisk(gpre_nod*, int, gpre_rse*); static gpre_nod* explode_asterisk_all(gpre_nod*, int, gpre_rse*, bool); @@ -120,7 +121,8 @@ static bool validate_references(const gpre_nod*, const gpre_nod*); -struct ops { +struct ops +{ nod_t rel_op; kwwords_t rel_kw; nod_t rel_negation; @@ -182,7 +184,7 @@ static const nod_t relationals[] = // Parse an OR boolean expression. // -gpre_nod* SQE_boolean( gpre_req* request, USHORT * paren_count) +gpre_nod* SQE_boolean( gpre_req* request, USHORT* paren_count) { USHORT local_count; @@ -223,8 +225,7 @@ gpre_ctx* SQE_context(gpre_req* request) gpre_ctx* context = MSC_context(request); SQL_relation_name(r_name, db_name, owner_name); - if (!(context->ctx_relation = - SQL_relation(request, r_name, db_name, owner_name, false))) + if (!(context->ctx_relation = SQL_relation(request, r_name, db_name, owner_name, false))) { // check for a procedure gpre_prc* procedure = context->ctx_procedure = @@ -238,14 +239,12 @@ gpre_ctx* SQE_context(gpre_req* request) context->ctx_prc_inputs = SQE_list(SQE_value, request, false); USHORT local_count = 1; par_terminating_parens(&local_count, &local_count); - if (procedure->prc_in_count != - context->ctx_prc_inputs->nod_count) + if (procedure->prc_in_count != context->ctx_prc_inputs->nod_count) { PAR_error("count of input values doesn't match count of parameters"); } gpre_nod** input = context->ctx_prc_inputs->nod_arg; - for (gpre_fld* field = procedure->prc_inputs; field; - input++, field = field->fld_next) + for (gpre_fld* field = procedure->prc_inputs; field; input++, field = field->fld_next) { SQE_post_field(*input, field); } @@ -277,12 +276,10 @@ gpre_ctx* SQE_context(gpre_req* request) // at the same scoping level in this query gpre_ctx* conflict; - for (conflict = request->req_contexts; conflict; - conflict = conflict->ctx_next) + for (conflict = request->req_contexts; conflict; conflict = conflict->ctx_next) { if ((symbol = conflict->ctx_symbol) && - (symbol->sym_type == SYM_relation || - symbol->sym_type == SYM_context || + (symbol->sym_type == SYM_relation || symbol->sym_type == SYM_context || symbol->sym_type == SYM_procedure) && !strcmp(symbol->sym_string, gpreGlob.token_global.tok_string) && conflict->ctx_scope_level == request->req_scope_level) @@ -305,8 +302,7 @@ gpre_ctx* SQE_context(gpre_req* request) error_type = "context"; } - fb_utils::snprintf(s, sizeof(s), - "context %s conflicts with a %s in the same statement", + fb_utils::snprintf(s, sizeof(s), "context %s conflicts with a %s in the same statement", gpreGlob.token_global.tok_string, error_type); PAR_error(s); } @@ -333,10 +329,8 @@ gpre_ctx* SQE_context(gpre_req* request) // this will be turned into a reference later. // -gpre_nod* SQE_field(gpre_req* request, - bool aster_ok) +gpre_nod* SQE_field(gpre_req* request, bool aster_ok) { - gpre_nod* node; gpre_req* slice_req; assert_IS_REQ(request); @@ -347,7 +341,7 @@ gpre_nod* SQE_field(gpre_req* request, hold_token.tok_type = tok_t(0); if (aster_ok && MSC_match(KW_ASTERISK)) { - node = MSC_node(nod_asterisk, 1); + gpre_nod* node = MSC_node(nod_asterisk, 1); return node; } @@ -361,14 +355,10 @@ gpre_nod* SQE_field(gpre_req* request, TEXT s[ERROR_LENGTH]; act* action; - if (request && - request->req_type == REQ_ddl && - (action = request->req_actions) && - (action->act_type == ACT_create_domain || - action->act_type == ACT_alter_domain)) + if (request && request->req_type == REQ_ddl && (action = request->req_actions) && + (action->act_type == ACT_create_domain || action->act_type == ACT_alter_domain)) { - fb_utils::snprintf(s, sizeof(s), - "Illegal use of identifier: %s in domain constraint", + fb_utils::snprintf(s, sizeof(s), "Illegal use of identifier: %s in domain constraint", gpreGlob.token_global.tok_string); PAR_error(s); } @@ -388,8 +378,9 @@ gpre_nod* SQE_field(gpre_req* request, // if the request is null, make a deferred name block - if (!request || !request->req_contexts || request->req_in_select_list) { - node = MSC_node(nod_deferred, 3); + if (!request || !request->req_contexts || request->req_in_select_list) + { + gpre_nod* node = MSC_node(nod_deferred, 3); node->nod_count = 0; tok* f_token = (tok*) MSC_alloc(TOK_LEN); node->nod_arg[0] = (gpre_nod*) f_token; @@ -397,8 +388,9 @@ gpre_nod* SQE_field(gpre_req* request, SQL_resolve_identifier("", f_token->tok_string, f_token->tok_length + 1); CPR_token(); - if (MSC_match(KW_DOT)) { - if ((int) gpreGlob.token_global.tok_keyword == (int) KW_ASTERISK) { + if (MSC_match(KW_DOT)) + { + if (gpreGlob.token_global.tok_keyword == KW_ASTERISK) { if (aster_ok) node->nod_type = nod_asterisk; else @@ -413,10 +405,12 @@ gpre_nod* SQE_field(gpre_req* request, } CPR_token(); } - if (MSC_match(KW_L_BRCKET)) { + if (MSC_match(KW_L_BRCKET)) + { // We have a complete array or an array slice here - if (!MSC_match(KW_R_BRCKET)) { + if (!MSC_match(KW_R_BRCKET)) + { slice_req = MSC_request(REQ_slice); int count = 0; do { @@ -454,7 +448,8 @@ gpre_nod* SQE_field(gpre_req* request, */ node->nod_count = 3; } - else { + else + { slice_req = (gpre_req*) MSC_alloc(REQ_LEN); slice_req->req_type = REQ_slice; node->nod_arg[2] = (gpre_nod*) slice_req; @@ -466,10 +461,11 @@ gpre_nod* SQE_field(gpre_req* request, gpre_ctx* context; ref* reference = (ref*) MSC_alloc(REF_LEN); - node = MSC_unary(nod_field, (gpre_nod*) reference); + gpre_nod* node = MSC_unary(nod_field, (gpre_nod*) reference); gpre_sym* symbol = gpreGlob.token_global.tok_symbol; - if (symbol) { + if (symbol) + { /* if there is a homonym which is a context, use the context; otherwise we may match with a relation or procedure which is not in the request, resulting in a bogus error */ @@ -505,16 +501,16 @@ gpre_nod* SQE_field(gpre_req* request, PAR_error("context not part of this request"); SQL_resolve_identifier("", NULL, NAME_SIZE); if (!(reference->ref_field = - MET_context_field(context, gpreGlob.token_global.tok_string))) + MET_context_field(context, gpreGlob.token_global.tok_string))) { sprintf(s, "column \"%s\" not in context", gpreGlob.token_global.tok_string); PAR_error(s); } if (SQL_DIALECT_V5 == gpreGlob.sw_sql_dialect) { const USHORT field_dtype = reference->ref_field->fld_dtype; - if ((dtype_sql_date == field_dtype) || - (dtype_sql_time == field_dtype) || - (dtype_int64 == field_dtype)) + if (dtype_sql_date == field_dtype || + dtype_sql_time == field_dtype || + dtype_int64 == field_dtype) { SQL_dialect1_bad_type(field_dtype); } @@ -540,36 +536,37 @@ gpre_nod* SQE_field(gpre_req* request, ** current token, and hold the current token for later. */ - if (!MSC_match(KW_DOT)) { + if (!MSC_match(KW_DOT)) + { hold_token = gpreGlob.token_global; gpreGlob.token_global = gpreGlob.prior_token; gpreGlob.token_global.tok_symbol = 0; } - else { + else + { /** We've got the column name. resolve it **/ SQL_resolve_identifier("", NULL, NAME_SIZE); for (context = request->req_contexts; context; context = context->ctx_next) { if (context->ctx_relation == relation && - (reference->ref_field = - MET_field(context->ctx_relation, - gpreGlob.token_global.tok_string))) + (reference->ref_field = + MET_field(context->ctx_relation, gpreGlob.token_global.tok_string))) { - if (SQL_DIALECT_V5 == gpreGlob.sw_sql_dialect) { + if (SQL_DIALECT_V5 == gpreGlob.sw_sql_dialect) + { const USHORT field_dtype = reference->ref_field->fld_dtype; - if ((dtype_sql_date == field_dtype) || - (dtype_sql_time == field_dtype) || - (dtype_int64 == field_dtype)) + if (dtype_sql_date == field_dtype || + dtype_sql_time == field_dtype || + dtype_int64 == field_dtype) { SQL_dialect1_bad_type(field_dtype); } } reference->ref_context = context; CPR_token(); - if (reference->ref_field->fld_array_info) { - node = - EXP_array(request, reference->ref_field, - true, true); + if (reference->ref_field->fld_array_info) + { + node = EXP_array(request, reference->ref_field, true, true); node->nod_arg[0] = (gpre_nod*) reference; } return node; @@ -590,27 +587,25 @@ gpre_nod* SQE_field(gpre_req* request, if (!MSC_match(KW_DOT)) CPR_s_error(" in qualified column"); SQL_resolve_identifier("", NULL, NAME_SIZE); - for (context = request->req_contexts; context; - context = context->ctx_next) + for (context = request->req_contexts; context; context = context->ctx_next) { if (context->ctx_procedure == procedure && - (reference->ref_field = + (reference->ref_field = MET_context_field(context, gpreGlob.token_global.tok_string))) { if (SQL_DIALECT_V5 == gpreGlob.sw_sql_dialect) { const USHORT field_dtype = reference->ref_field->fld_dtype; - if ((dtype_sql_date == field_dtype) || - (dtype_sql_time == field_dtype) || - (dtype_int64 == field_dtype)) + if (dtype_sql_date == field_dtype || + dtype_sql_time == field_dtype || + dtype_int64 == field_dtype) { SQL_dialect1_bad_type(field_dtype); } } reference->ref_context = context; - if (reference->ref_field->fld_array_info) { - node = - EXP_array(request, reference->ref_field, true, - true); + if (reference->ref_field->fld_array_info) + { + node = EXP_array(request, reference->ref_field, true, true); node->nod_arg[0] = (gpre_nod*) reference; } CPR_token(); @@ -632,11 +627,12 @@ gpre_nod* SQE_field(gpre_req* request, { if (reference->ref_field = MET_context_field(context, gpreGlob.token_global.tok_string)) { - if (SQL_DIALECT_V5 == gpreGlob.sw_sql_dialect) { + if (SQL_DIALECT_V5 == gpreGlob.sw_sql_dialect) + { const USHORT field_dtype = reference->ref_field->fld_dtype; - if ((dtype_sql_date == field_dtype) || - (dtype_sql_time == field_dtype) || - (dtype_int64 == field_dtype)) + if (dtype_sql_date == field_dtype || + dtype_sql_time == field_dtype || + dtype_int64 == field_dtype) { SQL_dialect1_bad_type(field_dtype); } @@ -647,13 +643,15 @@ gpre_nod* SQE_field(gpre_req* request, ** switch token and prior_token back to their original values to ** continue. */ - if (hold_token.tok_type != 0) { + if (hold_token.tok_type != 0) + { gpreGlob.prior_token = gpreGlob.token_global; gpreGlob.token_global = hold_token; } else CPR_token(); - if (reference->ref_field->fld_array_info) { + if (reference->ref_field->fld_array_info) + { node = EXP_array(request, reference->ref_field, true, true); node->nod_arg[0] = (gpre_nod*) reference; } @@ -674,9 +672,7 @@ gpre_nod* SQE_field(gpre_req* request, // whole mess in a list node. // -gpre_nod* SQE_list(pfn_SQE_list_cb routine, - gpre_req* request, - bool aster_ok) +gpre_nod* SQE_list(pfn_SQE_list_cb routine, gpre_req* request, bool aster_ok) { assert_IS_REQ(request); @@ -706,8 +702,7 @@ gpre_nod* SQE_list(pfn_SQE_list_cb routine, // "INDICATOR". // -ref* SQE_parameter(gpre_req* request, - bool aster_ok) +ref* SQE_parameter(gpre_req* request, bool aster_ok) { ref* reference; SCHAR* string; @@ -727,11 +722,11 @@ ref* SQE_parameter(gpre_req* request, if ((isQuoted(gpreGlob.token_global.tok_type) && gpreGlob.sw_sql_dialect == 1) || gpreGlob.token_global.tok_type == tok_sglquoted) { - /** - Since we have stripped the quotes, it is time now to put it back - so that the host language will interpret it correctly as a string - literal. - ***/ + /** + Since we have stripped the quotes, it is time now to put it back + so that the host language will interpret it correctly as a string + literal. + ***/ reference = (ref*) MSC_alloc(REF_LEN); string = (TEXT *) MSC_alloc(gpreGlob.token_global.tok_length + 3); string[0] = '\"'; @@ -772,8 +767,7 @@ ref* SQE_parameter(gpre_req* request, reference = (ref*) MSC_alloc(REF_LEN); - for (gpre_sym* symbol = gpreGlob.token_global.tok_symbol; symbol; - symbol = symbol->sym_homonym) + for (gpre_sym* symbol = gpreGlob.token_global.tok_symbol; symbol; symbol = symbol->sym_homonym) { if (symbol->sym_type == SYM_variable) { reference->ref_field = (gpre_fld*) symbol->sym_object; @@ -837,8 +831,7 @@ void SQE_post_field( gpre_nod* input, gpre_fld* field) default: { gpre_nod** ptr = input->nod_arg; - for (const gpre_nod* const* const end = ptr + input->nod_count; - ptr < end; ptr++) + for (const gpre_nod* const* const end = ptr + input->nod_count; ptr < end; ptr++) { SQE_post_field(*ptr, field); } @@ -856,8 +849,7 @@ void SQE_post_field( gpre_nod* input, gpre_fld* field) // isn't a context, well, there isn't a context. // -ref* SQE_post_reference(gpre_req* request, gpre_fld* field, gpre_ctx* context, - gpre_nod* node) +ref* SQE_post_reference(gpre_req* request, gpre_fld* field, gpre_ctx* context, gpre_nod* node) { ref* reference; @@ -874,12 +866,11 @@ ref* SQE_post_reference(gpre_req* request, gpre_fld* field, gpre_ctx* context, // See if there is already a reference to this guy. If so, return it. - for (reference = request->req_references; reference; - reference = reference->ref_next) + for (reference = request->req_references; reference; reference = reference->ref_next) { - if ((reference->ref_expr && compare_expr(node, reference->ref_expr)) - || (!reference->ref_expr && field == reference->ref_field - && context == reference->ref_context)) + if ((reference->ref_expr && compare_expr(node, reference->ref_expr)) || + (!reference->ref_expr && field == reference->ref_field && + context == reference->ref_context)) { return reference; } @@ -920,9 +911,7 @@ ref* SQE_post_reference(gpre_req* request, gpre_fld* field, gpre_ctx* context, // otherwise false. // -bool SQE_resolve(gpre_nod* node, - gpre_req* request, - gpre_rse* selection) +bool SQE_resolve(gpre_nod* node, gpre_req* request, gpre_rse* selection) { bool result = false; act* slice_action = 0; @@ -930,7 +919,8 @@ bool SQE_resolve(gpre_nod* node, assert_IS_REQ(request); assert_IS_NOD(node); - switch (node->nod_type) { + switch (node->nod_type) + { case nod_plus: case nod_minus: case nod_times: @@ -969,15 +959,15 @@ bool SQE_resolve(gpre_nod* node, case nod_agg_total: case nod_agg_average: case nod_agg_count: - if (node->nod_arg[0]) { + if (node->nod_arg[0]) + { SQE_resolve(node->nod_arg[0], request, selection); gpre_nod* node_arg = node->nod_arg[0]; const ref* reference = (ref*) node_arg->nod_arg[0]; if (node_arg->nod_type == nod_field && reference && reference->ref_field && reference->ref_field->fld_array_info) { - PAR_error - ("Array columns not permitted in aggregate functions"); + PAR_error("Array columns not permitted in aggregate functions"); } } return true; @@ -1020,11 +1010,10 @@ bool SQE_resolve(gpre_nod* node, gpre_fld* field = NULL; - gpre_ctx* context; + gpre_ctx* context = NULL; if (request) { - for (context = request->req_contexts; context; - context = context->ctx_next) + for (context = request->req_contexts; context; context = context->ctx_next) { if (!context->ctx_stream && (field = resolve(node, context, 0, &slice_action))) break; @@ -1042,12 +1031,10 @@ bool SQE_resolve(gpre_nod* node, if (!field) { SCHAR s[ERROR_LENGTH]; if (q_token) - fb_utils::snprintf(s, sizeof(s), - "column \"%s.%s\" cannot be resolved", + fb_utils::snprintf(s, sizeof(s), "column \"%s.%s\" cannot be resolved", q_token->tok_string, f_token->tok_string); else - fb_utils::snprintf(s, sizeof(s), - "column \"%s\" cannot be resolved", + fb_utils::snprintf(s, sizeof(s), "column \"%s\" cannot be resolved", f_token->tok_string); PAR_error(s); } @@ -1055,9 +1042,8 @@ bool SQE_resolve(gpre_nod* node, // Make sure that a dialect-1 program isn't trying to select a // dialect-3-only field type. if ((SQL_DIALECT_V5 == gpreGlob.sw_sql_dialect) && - ((dtype_sql_date == field->fld_dtype) || - (dtype_sql_time == field->fld_dtype) || - (dtype_int64 == field->fld_dtype))) + (dtype_sql_date == field->fld_dtype || dtype_sql_time == field->fld_dtype || + dtype_int64 == field->fld_dtype)) { SQL_dialect1_bad_type(field->fld_dtype); } @@ -1071,7 +1057,6 @@ bool SQE_resolve(gpre_nod* node, if (node->nod_type != nod_deferred) node->nod_count = 0; - node->nod_type = nod_field; node->nod_arg[0] = (gpre_nod*) reference; @@ -1084,8 +1069,7 @@ bool SQE_resolve(gpre_nod* node, // Parse a SELECT (sans keyword) expression. // -gpre_rse* SQE_select(gpre_req* request, - bool view_flag) +gpre_rse* SQE_select(gpre_req* request, bool view_flag) { gpre_lls* context_stack = NULL; gpre_ctx* context = 0; @@ -1103,8 +1087,8 @@ gpre_rse* SQE_select(gpre_req* request, select = rse1 = par_select(request, NULL); // "Look for ... the UNION label ... " - while (MSC_match(KW_UNION)) { - + while (MSC_match(KW_UNION)) + { have_union = true; const bool union_all = MSC_match(KW_ALL); if (!MSC_match(KW_SELECT)) @@ -1169,10 +1153,7 @@ gpre_rse* SQE_select(gpre_req* request, // Parse either of the low precedence operators + and -. // -gpre_nod* SQE_value(gpre_req* request, - bool aster_ok, - USHORT * paren_count, - bool * bool_flag) +gpre_nod* SQE_value(gpre_req* request, bool aster_ok, USHORT* paren_count, bool* bool_flag) { USHORT local_count; bool local_flag; @@ -1197,7 +1178,8 @@ gpre_nod* SQE_value(gpre_req* request, } nod_t nod_type; - while (true) { + while (true) + { if (MSC_match(KW_PLUS)) nod_type = nod_plus; else if (MSC_match(KW_MINUS)) @@ -1208,9 +1190,7 @@ gpre_nod* SQE_value(gpre_req* request, par_terminating_parens(paren_count, &local_count); return node; } - gpre_nod* arg = node; - node = MSC_binary(nod_type, arg, - par_multiply(request, false, paren_count, bool_flag)); + node = MSC_binary(nod_type, node, par_multiply(request, false, paren_count, bool_flag)); } } @@ -1221,10 +1201,7 @@ gpre_nod* SQE_value(gpre_req* request, // expression. // -gpre_nod* SQE_value_or_null(gpre_req* request, - bool aster_ok, - USHORT * paren_count, - bool * bool_flag) +gpre_nod* SQE_value_or_null(gpre_req* request, bool aster_ok, USHORT* paren_count, bool* bool_flag) { if (MSC_match(KW_NULL)) return MSC_node(nod_null, 0); @@ -1240,10 +1217,7 @@ gpre_nod* SQE_value_or_null(gpre_req* request, // "INDICATOR". // -gpre_nod* SQE_variable(gpre_req* request, - bool aster_ok, - USHORT * paren_count, - bool * bool_flag) +gpre_nod* SQE_variable(gpre_req* request, bool aster_ok, USHORT* paren_count, bool* bool_flag) { assert_IS_REQ(request); @@ -1255,8 +1229,7 @@ gpre_nod* SQE_variable(gpre_req* request, ref* reference = (ref*) MSC_alloc(REF_LEN); - for (gpre_sym* symbol = gpreGlob.token_global.tok_symbol; symbol; - symbol = symbol->sym_homonym) + for (gpre_sym* symbol = gpreGlob.token_global.tok_symbol; symbol; symbol = symbol->sym_homonym) { if (symbol->sym_type == SYM_variable) { reference->ref_field = (gpre_fld*) symbol->sym_object; @@ -1281,43 +1254,30 @@ gpre_nod* SQE_variable(gpre_req* request, // return true, otherwise false. // -static bool compare_expr(gpre_nod* node1, - gpre_nod* node2) +static bool compare_expr(const gpre_nod* node1, const gpre_nod* node2) { - ref* ref1; - ref* ref2; - assert_IS_NOD(node1); assert_IS_NOD(node2); if (node1->nod_type != node2->nod_type) return false; - switch (node1->nod_type) { + switch (node1->nod_type) + { case nod_field: - ref1 = (ref*) node1->nod_arg[0]; - ref2 = (ref*) node2->nod_arg[0]; - if (ref1->ref_context != ref2->ref_context || - ref1->ref_field != ref2->ref_field || - ref1->ref_master != ref2->ref_master) { - return false; + const ref* ref1 = (ref*) node1->nod_arg[0]; + const ref* ref2 = (ref*) node2->nod_arg[0]; + return ref1->ref_context == ref2->ref_context && ref1->ref_field == ref2->ref_field && + ref1->ref_master == ref2->ref_master; } - return true; case nod_map_ref: - if (node1->nod_arg[0] != node2->nod_arg[0]) - return false; - return true; + return node1->nod_arg[0] == node2->nod_arg[0]; case nod_udf: case nod_gen_id: - if (node1->nod_arg[0] != node2->nod_arg[0] || - node1->nod_arg[1] != node2->nod_arg[1]) - { - return false; - } - return true; + return node1->nod_arg[0] == node2->nod_arg[0] && node1->nod_arg[1] == node2->nod_arg[1]; default: return false; @@ -1362,8 +1322,7 @@ static gpre_nod* explode_asterisk( gpre_nod* fields, int n, gpre_rse* selection) if (context) fields = merge_fields(fields, MET_fields(context), n, true); else { - sprintf(s, "columns \"%s.*\" cannot be resolved", - q_token->tok_string); + sprintf(s, "columns \"%s.*\" cannot be resolved", q_token->tok_string); PAR_error(s); } } @@ -1390,12 +1349,12 @@ static gpre_nod* explode_asterisk_all(gpre_nod* fields, { assert_IS_NOD(fields); - for (int i = 0; i < selection->rse_count; i++) { + for (int i = 0; i < selection->rse_count; i++) + { gpre_ctx* context = selection->rse_context[i]; const int old_count = fields->nod_count; if (context->ctx_stream) - fields = explode_asterisk_all(fields, n, context->ctx_stream, - replace); + fields = explode_asterisk_all(fields, n, context->ctx_stream, replace); else fields = merge_fields(fields, MET_fields(context), n, replace); n += fields->nod_count - old_count; @@ -1428,7 +1387,8 @@ static gpre_fld* get_ref( gpre_nod* expr) ref* reference; - switch (expr->nod_type) { + switch (expr->nod_type) + { case nod_field: reference = (ref*) expr->nod_arg[0]; return reference->ref_field; @@ -1453,8 +1413,7 @@ static gpre_fld* get_ref( gpre_nod* expr) case nod_concatenate: { gpre_nod** ptr = expr->nod_arg; - for (const gpre_nod* const* const end = ptr + expr->nod_count; - ptr < end; ptr++) + for (const gpre_nod* const* const end = ptr + expr->nod_count; ptr < end; ptr++) { if (field = get_ref(*ptr)) return field; @@ -1521,10 +1480,10 @@ static gpre_nod* implicit_any(gpre_req* request, value2 = selection->rse_fields->nod_arg[0]; gpre_rse* sub = selection->rse_aggregate; - if (sub) { + if (sub) + { if (validate_references(value2, sub->rse_group_by)) - PAR_error - ("simple column reference not allowed in aggregate context"); + PAR_error("simple column reference not allowed in aggregate context"); if (sub->rse_group_by) { node = MSC_binary(comparison, value, value2); pair(node->nod_arg[0], node->nod_arg[1]); @@ -1631,8 +1590,7 @@ static gpre_nod* merge_fields(gpre_nod* fields_1, } for (i = count; i < fields_1->nod_count; i++) - fields->nod_arg[i + fields_2->nod_count - offset] = - fields_1->nod_arg[i]; + fields->nod_arg[i + fields_2->nod_count - offset] = fields_1->nod_arg[i]; return fields; } @@ -1720,7 +1678,7 @@ static gpre_ctx* par_alias_list( gpre_req* request, gpre_nod* alias_list) // in the current context for a match gpre_rel* relation = 0; // unreliable test many lines below without initializing. - gpre_ctx* context = par_alias(request, (const TEXT*) * arg); + gpre_ctx* context = par_alias(request, (const TEXT*) *arg); if (context) { if (alias_list->nod_count == 1) return context; @@ -1734,16 +1692,13 @@ static gpre_ctx* par_alias_list( gpre_req* request, gpre_nod* alias_list) // a base table having a matching table name or alias if (!context) - for (context = request->req_contexts; context; - context = context->ctx_next) + for (context = request->req_contexts; context; context = context->ctx_next) { if (context->ctx_scope_level != request->req_scope_level) continue; if (!context->ctx_relation) continue; - if (relation = - par_base_table(request, context->ctx_relation, - (const TEXT*) * arg)) + if (relation = par_base_table(request, context->ctx_relation, (const TEXT*) *arg)) { break; } @@ -1752,7 +1707,7 @@ static gpre_ctx* par_alias_list( gpre_req* request, gpre_nod* alias_list) if (!context) { fb_utils::snprintf(error_string, sizeof(error_string), "there is no alias or table named %s at this scope level", - (TEXT *) * arg); + (TEXT*) *arg); PAR_error(error_string); } @@ -1761,14 +1716,14 @@ static gpre_ctx* par_alias_list( gpre_req* request, gpre_nod* alias_list) for (arg++; arg < end; arg++) { - if (!(relation = par_base_table(request, relation, (const TEXT*) * arg))) + if (!(relation = par_base_table(request, relation, (const TEXT*) *arg))) break; } if (!relation) { fb_utils::snprintf(error_string, sizeof(error_string), "there is no alias or table named %s at this scope level", - (TEXT *) * arg); + (TEXT*) *arg); PAR_error(error_string); } @@ -1784,9 +1739,9 @@ static gpre_ctx* par_alias_list( gpre_req* request, gpre_nod* alias_list) USHORT alias_length = alias_list->nod_count; for (arg = alias_list->nod_arg; arg < end; arg++) - alias_length += strlen((TEXT *) * arg); + alias_length += strlen((TEXT*) *arg); - TEXT* alias = (TEXT *) MSC_alloc(alias_length); + TEXT* alias = (TEXT*) MSC_alloc(alias_length); // CVC: Warning: Using space as separator may conflict with dialect 3's embedded blanks; // but gpre is not much worried about dialects... except in this file! @@ -1822,8 +1777,7 @@ static gpre_ctx* par_alias( gpre_req* request, const TEXT* alias) // name which matches the identifier passed gpre_ctx* relation_context = NULL; - for (gpre_ctx* context = request->req_contexts; context; - context = context->ctx_next) + for (gpre_ctx* context = request->req_contexts; context; context = context->ctx_next) { if (context->ctx_scope_level != request->req_scope_level) continue; @@ -1846,8 +1800,7 @@ static gpre_ctx* par_alias( gpre_req* request, const TEXT* alias) save the context in case there is an alias of the same name; also to check that there is no self-join in the query */ - if (context->ctx_relation && - !strcmp(context->ctx_relation->rel_symbol->sym_string, alias)) + if (context->ctx_relation && !strcmp(context->ctx_relation->rel_symbol->sym_string, alias)) { if (relation_context) { fb_utils::snprintf(error_string, sizeof(error_string), @@ -1869,14 +1822,12 @@ static gpre_ctx* par_alias( gpre_req* request, const TEXT* alias) // has a base table which matches the passed alias. // -static gpre_rel* par_base_table( gpre_req* request, const gpre_rel* relation, - const TEXT* alias) +static gpre_rel* par_base_table( gpre_req* request, const gpre_rel* relation, const TEXT* alias) { assert_IS_REQ(request); - return MET_get_view_relation(request, relation->rel_symbol->sym_string, - alias, 0); + return MET_get_view_relation(request, relation->rel_symbol->sym_string, alias, 0); } //____________________________________________________________ @@ -2041,19 +1992,21 @@ static gpre_nod* par_in( gpre_req* request, gpre_nod* value) if (MSC_match(KW_SELECT)) node = implicit_any(request, value, nod_eq, nod_ansi_any); - else { + else + { node = NULL; - while (true) { + while (true) + { gpre_nod* value2 = par_primitive_value(request, false, 0, NULL); - if (value2->nod_type == nod_value) { + if (value2->nod_type == nod_value) + { ref* ref2 = (ref*) value2->nod_arg[0]; if (value->nod_type == nod_field) { ref* ref1 = (ref*) value->nod_arg[0]; ref2->ref_field = ref1->ref_field; } else { - fb_utils::snprintf(s, sizeof(s), - "datatype of %s can not be determined", + fb_utils::snprintf(s, sizeof(s), "datatype of %s can not be determined", gpreGlob.token_global.tok_string); PAR_error(s); } @@ -2061,9 +2014,7 @@ static gpre_nod* par_in( gpre_req* request, gpre_nod* value) if (!node) node = MSC_binary(nod_eq, value, value2); else - node = - MSC_binary(nod_or, node, - MSC_binary(nod_eq, value, value2)); + node = MSC_binary(nod_or, node, MSC_binary(nod_eq, value, value2)); if (!MSC_match(KW_COMMA)) break; @@ -2172,10 +2123,7 @@ static nod_t par_join_type() // Parse either of the high precedence operators * and /. // -static gpre_nod* par_multiply(gpre_req* request, - bool aster_ok, - USHORT * paren_count, - bool * bool_flag) +static gpre_nod* par_multiply(gpre_req* request, bool aster_ok, USHORT* paren_count, bool* bool_flag) { assert_IS_REQ(request); gpre_nod* node = par_primitive_value(request, aster_ok, paren_count, bool_flag); @@ -2185,20 +2133,17 @@ static gpre_nod* par_multiply(gpre_req* request, if (gpreGlob.token_global.tok_keyword == KW_COLLATE) return par_collate(request, node); - gpre_nod* arg; nod_t nod_type; - while (true) { + while (true) + { if (MSC_match(KW_ASTERISK)) nod_type = nod_times; else if (MSC_match(KW_SLASH)) nod_type = nod_divide; else return node; - arg = node; - node = - MSC_binary(nod_type, arg, - par_primitive_value(request, false, paren_count, - bool_flag)); + + node = MSC_binary(nod_type, node, par_primitive_value(request, false, paren_count, bool_flag)); } } @@ -2221,7 +2166,8 @@ static gpre_nod* par_not( gpre_req* request, USHORT * paren_count) type = nod_any; else if (MSC_match(KW_SINGULAR)) type = nod_unique; - if (type == nod_any || type == nod_unique) { + if (type == nod_any || type == nod_unique) + { scope saved_scope; push_scope(request, &saved_scope); @@ -2285,13 +2231,9 @@ static gpre_nod* par_nullif(gpre_req* request) // refer to fields by position. // -static void par_order(gpre_req* request, - gpre_rse* select, - bool union_f, - bool view_flag) +static void par_order(gpre_req* request, gpre_rse* select, bool union_f, bool view_flag) { gpre_nod* sort; - map* request_map; USHORT i; assert_IS_REQ(request); @@ -2308,7 +2250,8 @@ static void par_order(gpre_req* request, bool direction = false; gpre_nod* values = select->rse_fields; - while (true) { + while (true) + { direction = false; if (gpreGlob.token_global.tok_type == tok_number) { i = EXP_USHORT_ordinal(false); @@ -2323,6 +2266,7 @@ static void par_order(gpre_req* request, if (union_f) CPR_s_error(""); sort = SQE_value(request, false, NULL, NULL); + map* request_map; if (request && (request_map = request->req_map)) sort = post_map(sort, request_map); } @@ -2395,18 +2339,20 @@ static gpre_nod* par_plan( gpre_req* request) // access plan. // -static gpre_nod* par_plan_item(gpre_req* request, - bool aster_ok, - USHORT * paren_count, - bool * bool_flag) +static gpre_nod* par_plan_item(gpre_req* request, bool aster_ok, USHORT* paren_count, bool* bool_flag) { assert_IS_REQ(request); // check for a plan expression - if (gpreGlob.token_global.tok_keyword == KW_JOIN || gpreGlob.token_global.tok_keyword == KW_SORT || - gpreGlob.token_global.tok_keyword == KW_MERGE || gpreGlob.token_global.tok_keyword == KW_LEFT_PAREN) + tok& token = gpreGlob.token_global; + + switch (token.tok_keyword) { + case KW_JOIN: + case KW_SORT: + case KW_MERGE: + case KW_LEFT_PAREN: return par_plan(request); } @@ -2416,15 +2362,15 @@ static gpre_nod* par_plan_item(gpre_req* request, int count; gpre_lls* stack = NULL; - for (count = 0; gpreGlob.token_global.tok_type == tok_ident; count++) { - if (gpreGlob.token_global.tok_keyword == KW_NATURAL || - gpreGlob.token_global.tok_keyword == KW_ORDER || - gpreGlob.token_global.tok_keyword == KW_INDEX) + for (count = 0; token.tok_type == tok_ident; count++) + { + if (token.tok_keyword == KW_NATURAL || token.tok_keyword == KW_ORDER || + token.tok_keyword == KW_INDEX) { break; } - MSC_push((gpre_nod*) upcase_string(gpreGlob.token_global.tok_string), &stack); + MSC_push((gpre_nod*) upcase_string(token.tok_string), &stack); PAR_get_token(); } @@ -2439,26 +2385,29 @@ static gpre_nod* par_plan_item(gpre_req* request, // lookup the contexts for the aliases + gpre_nod* index_list = 0; gpre_ctx* context = par_alias_list(request, alias_list); // parse the access type - gpre_nod* access_type; - if (gpreGlob.token_global.tok_keyword == KW_NATURAL) { + gpre_nod* access_type = NULL; + switch (token.tok_keyword) + { + case KW_NATURAL: access_type = MSC_node(nod_natural, 0); PAR_get_token(); - } - else if (gpreGlob.token_global.tok_keyword == KW_ORDER) { + break; + case KW_ORDER: access_type = MSC_node(nod_index_order, 1); access_type->nod_count = 0; PAR_get_token(); - if (gpreGlob.token_global.tok_type != tok_ident) + if (token.tok_type != tok_ident) CPR_s_error(""); - access_type->nod_arg[0] = (gpre_nod*) upcase_string(gpreGlob.token_global.tok_string); + access_type->nod_arg[0] = (gpre_nod*) upcase_string(token.tok_string); PAR_get_token(); - } - else if (gpreGlob.token_global.tok_keyword == KW_INDEX) { + break; + case KW_INDEX: access_type = MSC_node(nod_index, 1); access_type->nod_count = 0; PAR_get_token(); @@ -2466,8 +2415,9 @@ static gpre_nod* par_plan_item(gpre_req* request, EXP_left_paren(0); stack = NULL; - for (count = 0; gpreGlob.token_global.tok_type == tok_ident;) { - MSC_push((gpre_nod*) upcase_string(gpreGlob.token_global.tok_string), &stack); + for (count = 0; token.tok_type == tok_ident;) + { + MSC_push((gpre_nod*) upcase_string(token.tok_string), &stack); PAR_get_token(); count++; @@ -2478,15 +2428,15 @@ static gpre_nod* par_plan_item(gpre_req* request, if (!count) CPR_s_error(" or "); - gpre_nod* index_list = MSC_node(nod_list, (SSHORT) count); + index_list = MSC_node(nod_list, (SSHORT) count); access_type->nod_arg[0] = index_list; for (ptr = &index_list->nod_arg[count]; stack;) *--ptr = (gpre_nod*) MSC_pop(&stack); if (!EXP_match_paren()) return NULL; - } - else { + break; + default: CPR_s_error("NATURAL, ORDER, or INDEX"); } @@ -2518,10 +2468,8 @@ static gpre_nod* par_plan_item(gpre_req* request, // user defined function // -static gpre_nod* par_primitive_value(gpre_req* request, - bool aster_ok, - USHORT * paren_count, - bool * bool_flag) +static gpre_nod* par_primitive_value(gpre_req* request, bool aster_ok, + USHORT* paren_count, bool* bool_flag) { USHORT local_count; @@ -2538,8 +2486,7 @@ static gpre_nod* par_primitive_value(gpre_req* request, return par_stat(request); if (MSC_match(KW_MINUS)) - return MSC_unary(nod_negate, - par_primitive_value(request, false, paren_count, false)); + return MSC_unary(nod_negate, par_primitive_value(request, false, paren_count, false)); MSC_match(KW_PLUS); @@ -2554,10 +2501,8 @@ static gpre_nod* par_primitive_value(gpre_req* request, if (!request) PAR_error("VALUE cannot be used in this context"); const act* action = request->req_actions; - if (request->req_type != REQ_ddl || - !action || - !(action->act_type == ACT_create_domain || - action->act_type == ACT_alter_domain)) + if (request->req_type != REQ_ddl || !action || + !(action->act_type == ACT_create_domain || action->act_type == ACT_alter_domain)) { PAR_error("VALUE cannot be used in this context"); } @@ -2582,13 +2527,14 @@ static gpre_nod* par_primitive_value(gpre_req* request, // the sub-expressions. map* tmp_map = 0; - for (const ops *op = stat_ops; (int) op->rel_kw != (int) KW_none; op++) { + for (const ops* op = stat_ops; op->rel_kw != KW_none; op++) + { MSC_match(KW_ALL); if (MSC_match(op->rel_kw)) { - if (request && (request->req_in_aggregate || - !(request->req_in_select_list || - request->req_in_having_clause || - request->req_in_order_by_clause))) + if (request && + (request->req_in_aggregate || + !(request->req_in_select_list || request->req_in_having_clause || + request->req_in_order_by_clause))) { /* either nested aggregate, or not part of a select list, having clause, or order by clause (in any subquery) @@ -2612,8 +2558,7 @@ static gpre_nod* par_primitive_value(gpre_req* request, // Disallow arrays as arguments to aggregate functions const gpre_nod* node_arg = node->nod_arg[0]; if (node_arg && node_arg->nod_type == nod_array) - PAR_error - ("Array columns not permitted in aggregate functions"); + PAR_error("Array columns not permitted in aggregate functions"); } if (distinct) @@ -2647,7 +2592,7 @@ static gpre_nod* par_primitive_value(gpre_req* request, // If the next token is a colon, it is a variable reference - if ((int) gpreGlob.token_global.tok_keyword == (int) KW_COLON) { + if (gpreGlob.token_global.tok_keyword == KW_COLON) { if (!request) { /* We must be processing a subquery - and without the request to * post the :hostvar to we can't continue. @@ -2673,11 +2618,11 @@ static gpre_nod* par_primitive_value(gpre_req* request, // return post_map (node, map); // + // I don't know what it's good for, but let's try it anyway if we haven't found + // anything that makes sense until now if (!node) -// I don't know what it's good for, but let's try it anyway if we haven't found -// anything that makes sense until now { -// ** Begin date/time/timestamp support * + // ** Begin date/time/timestamp support * const kwwords_t kw_word = gpreGlob.token_global.tok_keyword; if (MSC_match(KW_DATE) || MSC_match(KW_TIME) || MSC_match(KW_TIMESTAMP)) { @@ -2686,8 +2631,7 @@ static gpre_nod* par_primitive_value(gpre_req* request, return node; } -// ** End date/time/timestamp support * - + // ** End date/time/timestamp support * } return node; @@ -2711,7 +2655,7 @@ static gpre_nod* par_relational(gpre_req* request, if (gpreGlob.token_global.tok_keyword == KW_SEMI_COLON) { for (const nod_t* relational_ops = relationals; *relational_ops != nod_nothing; - relational_ops++) + relational_ops++) { if (expr1->nod_type == *relational_ops) return expr1; @@ -2727,7 +2671,8 @@ static gpre_nod* par_relational(gpre_req* request, gpre_nod* node; if (MSC_match(KW_IN)) node = par_in(request, expr1); - else if (MSC_match(KW_BETWEEN)) { + else if (MSC_match(KW_BETWEEN)) + { node = MSC_node(nod_between, 3); node->nod_arg[0] = expr1; node->nod_arg[1] = SQE_value(request, false, NULL, NULL); @@ -2736,7 +2681,8 @@ static gpre_nod* par_relational(gpre_req* request, pair(node->nod_arg[0], node->nod_arg[1]); pair(node->nod_arg[0], node->nod_arg[2]); } - else if (MSC_match(KW_LIKE)) { + else if (MSC_match(KW_LIKE)) + { node = MSC_node(nod_like, 3); node->nod_arg[0] = expr1; node->nod_arg[1] = SQE_value(request, false, NULL, NULL); @@ -2746,8 +2692,7 @@ static gpre_nod* par_relational(gpre_req* request, node->nod_arg[2] = expr2; if (expr2->nod_type == nod_value) { ref* ref_value = (ref*) expr2->nod_arg[0]; - ref_value->ref_field = MET_make_field("like_escape_character", - dtype_text, 2, false); + ref_value->ref_field = MET_make_field("like_escape_character", dtype_text, 2, false); } } else @@ -2765,10 +2710,12 @@ static gpre_nod* par_relational(gpre_req* request, else { node = NULL; const ops* op; - for (op = rel_ops; (int) op->rel_kw != (int) KW_none; op++) + for (op = rel_ops; op->rel_kw != KW_none; op++) + { if (MSC_match(op->rel_kw)) break; - if ((int) op->rel_kw == (int) KW_none) { + } + if (op->rel_kw == KW_none) { for (const nod_t* relational_ops = relationals; *relational_ops != nod_nothing; relational_ops++) { @@ -2777,7 +2724,7 @@ static gpre_nod* par_relational(gpre_req* request, } CPR_s_error(""); } - if ((int) op->rel_kw == (int) KW_STARTING) + if (op->rel_kw == KW_STARTING) MSC_match(KW_WITH); if (MSC_match(KW_ANY)) { if (!MSC_match(KW_LEFT_PAREN) || !MSC_match(KW_SELECT)) @@ -2785,12 +2732,12 @@ static gpre_nod* par_relational(gpre_req* request, node = implicit_any(request, expr1, op->rel_op, nod_any); EXP_match_paren(); } - else if (MSC_match(KW_ALL)) { + else if (MSC_match(KW_ALL)) + { if (!MSC_match(KW_LEFT_PAREN) || !MSC_match(KW_SELECT)) CPR_s_error("