From c7e479b2f12e7cfc376abd1db03dd80a485ec316 Mon Sep 17 00:00:00 2001 From: Bob Dubner <rdubner@symas.com> Date: Tue, 24 Dec 2024 15:03:00 -0500 Subject: [PATCH] lexio.cc uses cbl_warning --- gcc/cobol/ChangeLog | 2 ++ gcc/cobol/cdf_text.h | 31 +++++++++++++++++++------------ gcc/cobol/genapi.cc | 21 ++++----------------- gcc/cobol/lexio.cc | 2 ++ 4 files changed, 27 insertions(+), 29 deletions(-) diff --git a/gcc/cobol/ChangeLog b/gcc/cobol/ChangeLog index 3cbade39793c..cb9b78b1d51a 100644 --- a/gcc/cobol/ChangeLog +++ b/gcc/cobol/ChangeLog @@ -25,5 +25,7 @@ convert cdf-copy.cc to cbl_warning convert cdf.y to cbl_warning convert parse.y CDF display to cbl_message + convert lexio.cc CDF display to cbl_warning + diff --git a/gcc/cobol/cdf_text.h b/gcc/cobol/cdf_text.h index 1d784c57129d..143d27d9ae41 100644 --- a/gcc/cobol/cdf_text.h +++ b/gcc/cobol/cdf_text.h @@ -94,7 +94,8 @@ preprocess_filter_add( const char input[] ) { auto filename = find_filter(filter); if( !filename ) { - warnx("error: preprocessor '%s/%s' not found", getcwd(NULL, 0), filter); + cbl_warning("error: preprocessor '%s/%s' not found", + getcwd(NULL, 0), filter); return false; } preprocessor_filters.push_back( std::make_pair(strdup(filename), options) ); @@ -211,7 +212,7 @@ cdftext::lex_open( const char filename[] ) { filter, status); } } - warnx( "applied %s", filter ); + cbl_warning( "applied %s", filter ); } return fdopen( output, "r"); @@ -228,7 +229,7 @@ cdftext::open_input( const char filename[] ) { verbose_file_reader = NULL != getenv("GCOBOL_TEMPDIR"); if( verbose_file_reader ) { - warnx("verbose: opening %s for input", filename); + cbl_warning("verbose: opening %s for input", filename); } return fd; } @@ -243,7 +244,8 @@ cdftext::open_output() { sprintf(stem, "%sXXXXXX", name); if( -1 == (fd = mkstemp(stem)) ) { err(EXIT_FAILURE, - "error: could not open temporary file '%s' (%s)", name, realpath(name, stem)); + "error: could not open temporary file '%s' (%s)", + name, realpath(name, stem)); } return fd; } @@ -280,7 +282,8 @@ cdftext::map_file( int fd ) { err(EXIT_FAILURE, "%s: could not prepare map file from FIFO %d", __func__, input); } - if( false ) warnx("%s: copied %ld bytes from FIFO", __func__, nout); + if( false ) cbl_warning("%s: copied %ld bytes from FIFO", + __func__, nout); } } } while( S_ISFIFO(sb.st_mode) ); @@ -338,7 +341,7 @@ cdftext::free_form_reference_format( int input ) { if( valid_sequence_area(p, mfile.eodata) ) indicator.column = 7; if( yy_flex_debug ) { - warnx("%s:%d: %s format detected", __func__, __LINE__, + cbl_warning("%s:%d: %s format detected", __func__, __LINE__, indicator.column == 7? "FIXED" : "FREE"); } } @@ -349,7 +352,8 @@ cdftext::free_form_reference_format( int input ) { if( mfile.is_blank_line() ) continue; - char *indcol = indicated(mfile.cur, mfile.eol); // true only for fixed format + char *indcol = indicated(mfile.cur, mfile.eol); // true only for fixed + // // format if( is_fixed_format() && !indcol ) { // short line erase_source(mfile.cur, mfile.eol); @@ -378,7 +382,8 @@ cdftext::free_form_reference_format( int input ) { if( right_margin() ) { pend = std::min(mfile.cur + right_margin(), mfile.eol); } - // The appended segment has no newline because the erased line retains one. + // The appended segment has no newline because the erased line retains + // one. pend = std::find(indcol + 1, pend, '\n'); char *p = current.line.append(indcol + 1, pend ); if( (p = std::max(p, mfile.cur)) < mfile.eol ) { @@ -495,7 +500,7 @@ cdftext::process_file( filespan_t mfile, int output, bool second_pass ) { []( char ch ) { return ch == '\n'; } ); struct { int in, out; filespan_t mfile; } copy; if( yy_flex_debug ) - warnx("%s:%d: line %zu, opening %s on fd %d", __func__, __LINE__, + cbl_warning("%s:%d: line %zu, opening %s on fd %d", __func__, __LINE__, mfile.lineno, copybook.current()->source, copybook.current()->fd); copy.in = copybook.current()->fd; @@ -532,7 +537,8 @@ cdftext::process_file( filespan_t mfile, int output, bool second_pass ) { continue; // No active REPLACE directive. } - std::list<span_t> segments = segment_line(mfile); // no replace yields 1 segment + std::list<span_t> segments = segment_line(mfile); // no replace yields + // // 1 segment for( const auto& segment : segments ) { std::copy(segment.p, segment.pend, ofs); @@ -542,10 +548,11 @@ cdftext::process_file( filespan_t mfile, int output, bool second_pass ) { struct { size_t before, after; int delta() const { return before - after; } } nlines; - nlines.before = std::count(segments.front().p, segments.front().pend, '\n'); + nlines.before = std::count(segments.front().p, + segments.front().pend, '\n'); nlines.after = std::count(segments.back().p, segments.back().pend, '\n'); if( nlines.delta() < 0 ) { - warnx("warning: line %zu: REPLACED %zu lines with %zu lines, " + cbl_warning("warning: line %zu: REPLACED %zu lines with %zu lines, " "line count off by %d", mfile.lineno, nlines.before, nlines.after, nlines.delta()); } diff --git a/gcc/cobol/genapi.cc b/gcc/cobol/genapi.cc index 8d0fc965ed40..73f2e4a1784c 100644 --- a/gcc/cobol/genapi.cc +++ b/gcc/cobol/genapi.cc @@ -316,13 +316,11 @@ get_field_p(size_t index) if( !field->var_decl_node ) { - fprintf( stderr, - "%s (type: %s) improperly has a NULL var_decl_node\n", - field->name, - cbl_field_type_str(field->type)); - fprintf( stderr, + cbl_warning("%s (type: %s) improperly has a NULL var_decl_node\n", + field->name, + cbl_field_type_str(field->type)); + cbl_internal_error( "Probable cause: it was referenced without being defined.\n"); - exit(1); } return gg_get_address_of(field->var_decl_node); @@ -11437,17 +11435,6 @@ parser_release( cbl_field_t *record_area ) cbl_file_t *workfile = symbol_record_file(record_area); - // IF( member(workfile->var_decl_node, "file_pointer"), eq_op, null_pointer_node ) - // { - // gg_printf("parser_release(): the workfile %s assocated with record_area %s is not open\n", - // gg_string_literal(workfile->name), - // gg_string_literal(record_area->name), - // NULL_TREE); - // gg_exit(integer_one_node); - // } - // ELSE - // ENDIF - gg_call(VOID, "__gg__file_write", gg_get_address_of( workfile->var_decl_node), diff --git a/gcc/cobol/lexio.cc b/gcc/cobol/lexio.cc index 63d68c39059b..fa1649adef6c 100644 --- a/gcc/cobol/lexio.cc +++ b/gcc/cobol/lexio.cc @@ -1270,4 +1270,6 @@ lexer_input( char buf[], int max_size, FILE *input ) { return output.size(); } +#include "util.h" #include "cdf_text.h" + -- GitLab