diff --git a/gcc/cobol/ChangeLog b/gcc/cobol/ChangeLog index 9e47d3161cb89121513b547a8ae2af84749a046e..3cbade39793cfaa3eb3ddb501ad42d012a66238c 100644 --- a/gcc/cobol/ChangeLog +++ b/gcc/cobol/ChangeLog @@ -20,6 +20,10 @@ trimmed .h files in structs.cc * Eliminate vestigial unused code from the PERFORM-PROC-AS_CALL experiment - * Introduce cbl_warning, cbl_error, cbl_internal_error. + * Introduce cbl_message, cbl_warning, cbl_error, cbl_internal_error convert genapi.cc to cbl_warning and cbl_internal_error + convert cdf-copy.cc to cbl_warning + convert cdf.y to cbl_warning + convert parse.y CDF display to cbl_message + diff --git a/gcc/cobol/UAT/testsuite.src/syn_misc.at b/gcc/cobol/UAT/testsuite.src/syn_misc.at index 4ea9a86c1b611b7a66ea999f4cb54965364eeb35..2e99aff04af9c3809399284ddaf223dc573024fe 100644 --- a/gcc/cobol/UAT/testsuite.src/syn_misc.at +++ b/gcc/cobol/UAT/testsuite.src/syn_misc.at @@ -721,9 +721,8 @@ AT_DATA([prog.cob], [ >>END-IF ]) -AT_CHECK([$COMPILE_ONLY prog.cob], [0], [], -[cobol1: OK -]) +AT_CHECK([$COMPILE_ONLY prog.cob], [0], [OK +], []) AT_CLEANUP AT_SETUP([error handling in conditional directives]) @@ -744,9 +743,9 @@ AT_DATA([prog.cob], [ ]) AT_CHECK([$COMPILE_ONLY -D X prog.cob], [1], -[], +[No BANANA here. +], [prog.cob:6: CDF syntax error: no such variable 'BANANA' at ' >>DISPLAY' -cobol1: No BANANA here. prog.cob:10: error: name already in dictionary: X at ' >> END-IF' prog.cob:10: error: X previously defined in :1 at ' >> END-IF' prog.cob:10: >>CDF parser failed at ' >> END-IF' diff --git a/gcc/cobol/cdf.y b/gcc/cobol/cdf.y index c3b31647fb926a49e27d9cc7950205801e214833..8c9239d13716fd41c694c84319eed7f0734e8ade 100644 --- a/gcc/cobol/cdf.y +++ b/gcc/cobol/cdf.y @@ -33,6 +33,7 @@ #include "symbols.h" #include "exceptl.h" #include "exceptg.h" +#include "util.h" #include <ctype.h> #include <fcntl.h> @@ -173,7 +174,7 @@ static class exception_turns_t { auto inserted = uniq.insert(file); if( ! inserted.second ) { auto prev = cbl_file_of(symbol_at(*inserted.first)); - warnx("%s:%d: %s No file-name shall be specified more than once " + cbl_warning("%s:%d: %s No file-name shall be specified more than once " "for one exception condition", __func__, __LINE__, prev->name); return false; } @@ -310,7 +311,7 @@ top: partials { YYACCEPT; } const char *library = copybook.current()->library; if( !library ) library = "SYSLIB"; const char *source = copybook.current()->source; - if( yydebug ) { warnx("COPY %s from %s", source, library); } + if( yydebug ) { cbl_warning("COPY %s from %s", source, library); } YYACCEPT; } | copy error { @@ -332,10 +333,14 @@ complete: cdf_define /* * To do: read ISO 2022 to see how >>DISPLAY is dictionary! + * To do: DISPLAY UPON + * To do: decide what to do about newlines, and when; DISPLAY has + * {}... in the specification. */ cdf_display: CDF_DISPLAY strings { if( scanner_parsing() ) { - warnx("%s", display_msg); + cbl_message(1, "%s", display_msg); // Sending to STDOUT by default + cbl_message(1, "%s", "\n"); free(display_msg); display_msg = NULL; } @@ -408,7 +413,7 @@ cdf_define: CDF_DEFINE cdf_constant NAME as cdf_expr[value] override */ { if( dictionary.end() == dictionary.find($NAME) ) { - warnx("CDF warning: '%s' defined AS PARAMETER " + cbl_warning("CDF warning: '%s' defined AS PARAMETER " "but was not defined", $NAME); } } @@ -518,12 +523,12 @@ cdf_cond_expr: BOOL if( p == dictionary.end() ) { $$ = !$2; if( yydebug ) - warnx("CDF: %s not found in dictionary (result %s)", + cbl_warning("CDF: %s not found in dictionary (result %s)", $1, $$? "true" : "false"); } else { $$ = $2; if( yydebug ) - warnx("CDF: %s found in dictionary (result %s)", + cbl_warning("CDF: %s found in dictionary (result %s)", $1, $$? "true" : "false"); } } @@ -532,7 +537,7 @@ cdf_cond_expr: BOOL const auto& feature($1); $$ = (feature == int(feature & cbl_gcobol_features)); if( yydebug ) - warnx("CDF: feature 0x%02x is %s", $1, $$? "ON" : "OFF"); + cbl_warning("CDF: feature 0x%02x is %s", $1, $$? "ON" : "OFF"); } ; @@ -809,9 +814,9 @@ defined_cmd( const char arg[] ) if( yydebug ) { if( cdf_name->second.is_numeric() ) { - warnx("%s: added -D %s = %ld", __func__, name, cdf_name->second.as_number()); + cbl_warning("%s: added -D %s = %ld", __func__, name, cdf_name->second.as_number()); } else { - warnx("%s: added -D %s = \"%s\"", __func__, name, cdf_name->second.string); + cbl_warning("%s: added -D %s = \"%s\"", __func__, name, cdf_name->second.string); } } return true; diff --git a/gcc/cobol/util.cc b/gcc/cobol/util.cc index fcda77bfc3fa02d362d2dad1e10fb1a1ed7e9c84..415936b6fae0647266f8cff5397a7b6cd6dac82d 100644 --- a/gcc/cobol/util.cc +++ b/gcc/cobol/util.cc @@ -2211,12 +2211,23 @@ cobol_parse_files (int nfile, const char **files) parse_file (files[i]); } } - + +void +cbl_message(int fd, const char *format_string, ...) + { + va_list ap; + va_start(ap, format_string); + char *ostring = xvasprintf(format_string, ap); + va_end(ap); + write(fd, ostring, strlen(ostring)); + free(ostring); + } void cbl_warning(const char *format_string, ...) { va_list ap; + va_start(ap, format_string); char *ostring = xvasprintf(format_string, ap); va_end(ap); warning(0, "%s", ostring); @@ -2227,6 +2238,7 @@ void cbl_error(const char *format_string, ...) { va_list ap; + va_start(ap, format_string); char *ostring = xvasprintf(format_string, ap); va_end(ap); error("%s", ostring); @@ -2237,6 +2249,7 @@ void cbl_internal_error(const char *format_string, ...) { va_list ap; + va_start(ap, format_string); char *ostring = xvasprintf(format_string, ap); va_end(ap); internal_error("%s", ostring); diff --git a/gcc/cobol/util.h b/gcc/cobol/util.h index c4ca3aea238ef74f29b6862cba68440ea60b8cd1..5701bdd884e0de235a3c0489577aee9c3a413096 100644 --- a/gcc/cobol/util.h +++ b/gcc/cobol/util.h @@ -31,6 +31,7 @@ #ifndef _UTIL_H_ #define _UTIL_H_ +void cbl_message(int fd, const char *format_string, ...); void cbl_warning(const char *format_string, ...); void cbl_error(const char *format_string, ...); void cbl_internal_error(const char *format_string, ...);