From 60ed79f6b06645303ab7cadcede876b0c022fc8c Mon Sep 17 00:00:00 2001 From: Dmitry Yemanov Date: Wed, 16 Jan 2019 12:14:52 +0300 Subject: [PATCH] Reworked Alex's solution for modern compilers (GCC 5/6) --- src/gpre/c_cxx.cpp | 45 ++++++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/src/gpre/c_cxx.cpp b/src/gpre/c_cxx.cpp index 685da1c8fc..548ee8ccbc 100644 --- a/src/gpre/c_cxx.cpp +++ b/src/gpre/c_cxx.cpp @@ -2820,63 +2820,62 @@ static void gen_request(const gpre_req* request) printa(0, "static %sshort\n isc_%dl = %d;", (request->req_flags & REQ_extend_dpb) ? "" : CONST_STR, request->req_ident, request->req_length); - printa(0, "static %sunsigned char\n isc_%d [] = {", CONST_STR, request->req_ident); const TEXT* string_type = "blr"; - if (gpreGlob.sw_raw) - { - gen_raw(request->req_blr, request->req_length); + bool is_blr = true; - switch (request->req_type) - { + switch (request->req_type) + { case REQ_create_database: case REQ_ready: string_type = "dpb"; + is_blr = false; break; case REQ_ddl: string_type = "dyn"; - break; - case REQ_slice: - string_type = "sdl"; + is_blr = false; break; - default: - string_type = "blr"; - } + case REQ_slice: + string_type = "sdl"; + is_blr = false; + break; + } + + if (is_blr) + printa(0, "static %sunsigned char\n isc_%d [] = {", CONST_STR, request->req_ident); + else + printa(0, "static %schar\n isc_%d [] = {", CONST_STR, request->req_ident); + + if (gpreGlob.sw_raw) + { + gen_raw(request->req_blr, request->req_length); } else 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)) - { CPR_error("internal error during dynamic DDL generation"); - } break; + case REQ_slice: - string_type = "sdl"; if (PRETTY_print_sdl(request->req_blr, gen_blr, 0, 0)) - { CPR_error("internal error during SDL generation"); - } break; default: - string_type = "blr"; if (fb_print_blr(request->req_blr, request->req_length, gen_blr, 0, 0)) CPR_error("internal error during BLR generation"); } + printa(INDENT, "};\t/* end of %s string for request isc_%d */\n", string_type, request->req_ident); } @@ -3827,7 +3826,7 @@ static void make_ready(const gpre_dbb* db, // generate the attach database itself - const TEXT* dpb_size_ptr = "0"; + const TEXT* dpb_size_ptr = "(short) 0"; const TEXT* dpb_ptr = "(char*) 0"; align(column);