diff --git a/gcc/cobol/UAT/testsuite.src/run_misc.at b/gcc/cobol/UAT/testsuite.src/run_misc.at index dea7deebd7568ef06ce73d1edb4034dfbd49d6b2..008f6ca70d4cc4b0e7b7baad4831d0cd7e125a15 100644 --- a/gcc/cobol/UAT/testsuite.src/run_misc.at +++ b/gcc/cobol/UAT/testsuite.src/run_misc.at @@ -4680,7 +4680,7 @@ AT_DATA([prog.cob], [ identification division. AT_CHECK([$COMPILE -o prog prog.cob], [0], [], []) AT_CHECK([./prog Yngvi is a louse!], [0], [Demonstrate reading the command line using GCOBOL ACCEPT -Entire command line is "./prog Yngvi is a louse!" +Entire command line is "Yngvi is a louse!" argc is 005 argument 1 is "./prog" argument 2 is "Yngvi" @@ -4724,7 +4724,7 @@ AT_CHECK([gcc -c main.c]) AT_CHECK([$COMPILE -nomain -o prog prog.cob main.o], [0], [], []) AT_CHECK([./prog Yngvi is a louse!], [0], [Demonstrate reading the command line using GCOBOL ACCEPT -Entire command line is "./prog Yngvi is a louse!" +Entire command line is "Yngvi is a louse!" argc is 005 argument 1 is "./prog" argument 2 is "Yngvi" diff --git a/gcc/cobol/etests/Listing-4-1/known-good.txt b/gcc/cobol/etests/Listing-4-1/known-good.txt index 1514f7183ef32c47efd11a93fcf90df6474eecc4..84009fbd8e547cc074a2cf319456553060741cca 100644 --- a/gcc/cobol/etests/Listing-4-1/known-good.txt +++ b/gcc/cobol/etests/Listing-4-1/known-good.txt @@ -7,7 +7,7 @@ getenv("USER") is Third getenv("USER") is Fourth getenv("USER") is Fifth Command Line Count is 004 -Entire command line is ./test poppa momma baby +Entire command line is poppa momma baby First parameter is ./test Second parameter is poppa Third parameter is momma diff --git a/gcc/cobol/genapi.cc b/gcc/cobol/genapi.cc index b81a4df428111b30fe3e9b875ced7bcc68099cfd..cae09ffdb0e6e42716d8e540328752ce2df17861 100644 --- a/gcc/cobol/genapi.cc +++ b/gcc/cobol/genapi.cc @@ -4206,7 +4206,6 @@ parser_accept_command_line( cbl_refer_t tgt, cbl_label_t *error, cbl_label_t *not_error ) { - cbl_field_t *src = source.field; Analyze(); SHOW_PARSE { @@ -4224,7 +4223,7 @@ parser_accept_command_line( cbl_refer_t tgt, static tree erf = gg_define_variable(INT, "..pac_erf", vs_file_static); - if( !src ) + if( !source.field ) { // The whole command-line is wanted gg_assign(erf, @@ -4280,7 +4279,9 @@ parser_accept_command_line( cbl_refer_t tgt, gg_get_address_of(tgt.field->var_decl_node), refer_offset_dest(tgt), refer_size_dest(tgt), - gg_get_address_of(src->var_decl_node), + gg_get_address_of(source.field->var_decl_node), + refer_offset_dest(source), + refer_size_dest(source), NULL_TREE)); if( error ) { diff --git a/gcc/cobol/tests/Listing-4-1/known-good.txt b/gcc/cobol/tests/Listing-4-1/known-good.txt index dd82238447e2192e316c579ed0c7c5c1e1e8d22f..5d7e968b62b1004e2d06fe6fc4198ff4b82bdfb3 100644 --- a/gcc/cobol/tests/Listing-4-1/known-good.txt +++ b/gcc/cobol/tests/Listing-4-1/known-good.txt @@ -7,7 +7,7 @@ getenv("USER") is Third getenv("USER") is Fourth getenv("USER") is Fifth Command Line Count is 004 -Entire command line is ./test poppa momma baby +Entire command line is poppa momma baby First parameter is ./test Second parameter is poppa Third parameter is momma diff --git a/libgcobol/libgcobol.cc b/libgcobol/libgcobol.cc index c20918115a07103d988ed02000cad2254a262d52..366d368ebe86cc75e18b8621bc432952e64d9fbf 100644 --- a/libgcobol/libgcobol.cc +++ b/libgcobol/libgcobol.cc @@ -9866,20 +9866,24 @@ __gg__get_argc(cblc_field_t *dest, size_t offset, size_t length) extern "C" int __gg__get_argv( cblc_field_t *dest, - size_t offset, - size_t length, - cblc_field_t *index) + size_t dest_offset, + size_t dest_length, + cblc_field_t *index, + size_t index_offset, + size_t index_size) { int retcode; command_line_plan_b(); int rdigits; - __int128 N = __gg__binary_value_from_field( &rdigits, - index ) ; + __int128 N = get_binary_value_local(&rdigits, + index, + index->data + index_offset, + index_size); // N is 1-based, per normal COBOL. We have to decrement it here: N -= 1; - length = length ? length : dest->capacity; + dest_length = dest_length ? dest_length : dest->capacity; // If he gives us fractional digits, just truncate N /= __gg__power_of_ten(rdigits); @@ -9893,7 +9897,7 @@ __gg__get_argv( cblc_field_t *dest, { char *retval = strdup(stashed_argv[N]); console_to_internal(retval, strlen(retval)); - move_string(dest, offset, length, retval); + move_string(dest, dest_offset, dest_length, retval); free(retval); retcode = 0; // Okay } @@ -9912,7 +9916,7 @@ __gg__get_command_line( cblc_field_t *field, char *retval = (char *)malloc(length); *retval = NULLCH; - for( int i=0; i<stashed_argc; i++ ) + for( int i=1; i<stashed_argc; i++ ) { while( strlen(retval) + strlen(stashed_argv[i]) + 2 > length ) {