From c82f853ea1e61de6849ddf93dc58ee58734865dc Mon Sep 17 00:00:00 2001 From: Bob Dubner <rdubner@symas.com> Date: Sat, 13 Apr 2024 23:28:37 -0400 Subject: [PATCH] Remove references to FldLiteralA from __gg__move_literala --- libgcobol/libgcobol.cc | 243 ++++++++++++++--------------------------- 1 file changed, 80 insertions(+), 163 deletions(-) diff --git a/libgcobol/libgcobol.cc b/libgcobol/libgcobol.cc index d3e270f3029e..aa1f1e329578 100644 --- a/libgcobol/libgcobol.cc +++ b/libgcobol/libgcobol.cc @@ -5158,13 +5158,6 @@ __gg__move_literala(struct cblc_refer_t *dest, cbl_figconst_t source_figconst = (cbl_figconst_t)(source->field->attr & FIGCONST_MASK); cbl_field_type_t dest_type = (cbl_field_type_t)dest->field->type; - cbl_field_type_t source_type = (cbl_field_type_t)source->field->type; - - if( source_type != FldLiteralA ) - { - fprintf(stderr, "KILROY How the fuck did this happen?\n"); - abort(); - } if( var_is_refmod(dest->field) ) { @@ -5223,74 +5216,35 @@ __gg__move_literala(struct cblc_refer_t *dest, switch( dest_type ) { case FldGroup: - switch( source_type ) - { - // For all other types, we just do a straight byte-for-byte move - case FldLiteralA: - alpha_to_alpha_move(dest, source, source->move_all); - break; - - default: - abort(); - moved = false; - break; - } - - break; - case FldAlphanumeric: { - switch( source_type ) - { - case FldLiteralA: - alpha_to_alpha_move(dest, source, source->move_all); - break; - - - default: - moved = false; - break; - } + alpha_to_alpha_move(dest, source, source->move_all); break; } case FldNumericBinary: { - switch( source_type ) + value = __gg__binary_value_from_refer(&rdigits, source); + + if( truncation_mode == trunc_std_e ) { - case FldLiteralA: + if( value < 0 ) { - // We are moving a number to a number: - value = __gg__binary_value_from_refer(&rdigits, source); - - if( truncation_mode == trunc_std_e ) - { - if( value < 0 ) - { - value = -value; - value %= __gg__power_of_ten(dest->field->digits); - value = -value; - } - else - { - value %= __gg__power_of_ten(dest->field->digits); - } - } - - __gg__int128_to_refer(dest, - value, - rdigits, - rounded, - &size_error ); - break; + value = -value; + value %= __gg__power_of_ten(dest->field->digits); + value = -value; } - - default: + else { - moved = false; - break; + value %= __gg__power_of_ten(dest->field->digits); } } + + __gg__int128_to_refer(dest, + value, + rdigits, + rounded, + &size_error ); break; } @@ -5301,125 +5255,88 @@ __gg__move_literala(struct cblc_refer_t *dest, case FldIndex: // Bin5 and Index are treated with no truncation, as if they were // trunc_bin_e. The other types aren't subject to truncation. - switch( source_type ) - { - case FldLiteralA: - { - // We are moving a number to a number: - value = __gg__binary_value_from_refer(&rdigits, source); - __gg__int128_to_refer( dest, - value, - rdigits, - rounded, - &size_error ); - break; - } - - default: - moved = false; - break; - } + // We are moving a number to a number: + value = __gg__binary_value_from_refer(&rdigits, source); + __gg__int128_to_refer( dest, + value, + rdigits, + rounded, + &size_error ); break; case FldAlphaEdited: { - switch( source_type ) - { - case FldLiteralA: - { - static size_t display_string_size = MINIMUM_ALLOCATION_SIZE; - static char *display_string = (char *)MALLOC(display_string_size); + static size_t display_string_size = MINIMUM_ALLOCATION_SIZE; + static char *display_string = (char *)MALLOC(display_string_size); - size_t display_string_length = dest->qual_size; - __gg__realloc_if_necessary( &display_string, - &display_string_size, - display_string_length); + size_t display_string_length = dest->qual_size; + __gg__realloc_if_necessary( &display_string, + &display_string_size, + display_string_length); - if( source_figconst == low_value_e ) - { - memset(display_string, ascii_to_internal(__gg__low_value_character), dest->qual_size); - } - else if( source_figconst == zero_value_e ) - { - memset(display_string, internal_zero, dest->qual_size); - } - else if( source_figconst == space_value_e ) - { - memset(display_string, internal_space, dest->qual_size); - } - else if( source_figconst == quote_value_e ) - { - memset(display_string, ascii_to_internal(__gg__quote_character), dest->qual_size); - } - else if( source_figconst == high_value_e ) - { - memset(display_string, ascii_to_internal(__gg__high_value_character), dest->qual_size); - } - else - { - display_string = format_for_display_internal( - &display_string, - &display_string_size, - source->field, - (unsigned char *)source->qual_data, - source->qual_size, - source->address_of); - display_string_length = strlen(display_string); - } - __gg__string_to_alpha_edited( (char *)dest->qual_data, - display_string, - display_string_length, - dest->field->picture); - break; - } - - default: - { - moved=false; - break; - } + if( source_figconst == low_value_e ) + { + memset(display_string, ascii_to_internal(__gg__low_value_character), dest->qual_size); } + else if( source_figconst == zero_value_e ) + { + memset(display_string, internal_zero, dest->qual_size); + } + else if( source_figconst == space_value_e ) + { + memset(display_string, internal_space, dest->qual_size); + } + else if( source_figconst == quote_value_e ) + { + memset(display_string, ascii_to_internal(__gg__quote_character), dest->qual_size); + } + else if( source_figconst == high_value_e ) + { + memset(display_string, ascii_to_internal(__gg__high_value_character), dest->qual_size); + } + else + { + display_string = format_for_display_internal( + &display_string, + &display_string_size, + source->field, + (unsigned char *)source->qual_data, + source->qual_size, + source->address_of); + display_string_length = strlen(display_string); + } + __gg__string_to_alpha_edited( (char *)dest->qual_data, + display_string, + display_string_length, + dest->field->picture); break; } case FldFloat: { - switch( source_type ) + char ach[256]; + size_t len = std::min(source->qual_size, sizeof(ach)-1); + memcpy(ach, source->qual_data, len); + ach[len] = '\0'; + __gg__internal_to_console_in_place(ach, len); + switch( dest->field->capacity ) { - case FldLiteralA: + case 4: { - char ach[256]; - size_t len = std::min(source->qual_size, sizeof(ach)-1); - memcpy(ach, source->qual_data, len); - ach[len] = '\0'; - __gg__internal_to_console_in_place(ach, len); - switch( dest->field->capacity ) - { - case 4: - { - *(float *)(dest->qual_data) = strtof32(ach, NULL); - break; - } - case 8: - { - *(double *)(dest->qual_data) = strtof64(ach, NULL); - break; - } - case 16: - { - *(_Float128 *)(dest->qual_data) = strtof128(ach, NULL); - break; - } - break; - } + *(float *)(dest->qual_data) = strtof32(ach, NULL); break; } - - default: + case 8: { - moved = false; + *(double *)(dest->qual_data) = strtof64(ach, NULL); break; } + case 16: + { + *(_Float128 *)(dest->qual_data) = strtof128(ach, NULL); + break; + } + break; } break; } @@ -5430,7 +5347,7 @@ __gg__move_literala(struct cblc_refer_t *dest, } if( !moved ) { - fprintf(stderr, "%s() %s:%d -- We were unable to do a move from " + fprintf(stderr, "%s() %s:%d -- We were unable to do a move from " "type %d to %d\n", __func__, __FILE__, __LINE__, source->field->type, dest->field->type); -- GitLab