Skip to content

Commit

Permalink
Add - as stdout for -P flag
Browse files Browse the repository at this point in the history
  • Loading branch information
lefessan committed Jul 6, 2023
1 parent 8bdc60f commit f1d0612
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 8 deletions.
12 changes: 11 additions & 1 deletion NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,12 @@ NEWS - user visible changes -*- outline -*-
callee modules that use BY VALUE must be compiled with the same version of
GnuCOBOL, either prior this release, or since.

** cobc now uses a two-pass preprocessing algorithm, where replacements for
COPY-REPLACING are done in a first pass, and the replacements for
REPLACE are done in a second pass. Note that, however, both
statements are parsed before the first replacement pass, so
COPY-REPLACING cannot impact a REPLACE statement itself.

* Changes to the COBOL compiler (cobc) options:

** new -fformat dialect option, and extended SOURCE FORMAT directives,
Expand Down Expand Up @@ -321,7 +327,9 @@ NEWS - user visible changes -*- outline -*-
and fatality `cobc --list-exceptions`

** new compiler command line option -ftcmd to enable printing of the command
line in the source listing
line in the source listing, -fno-timestamp to suppress printing of the time
and -ftittle to set a title instead of GnuCOBOL and version (_ chars are
replaced by spaces in the title)

** new compiler command line option --coverage to instrument binaries
for coverage checks
Expand Down Expand Up @@ -349,6 +357,8 @@ NEWS - user visible changes -*- outline -*-
the option -fdiagnostics-plain-output was added to request that diagnostic
output look as plain as possible and stay more stable over time

** the -P flag accepts - as argument for stdout

* Important Bugfixes:

** for dialects other than the GnuCOBOL default different reserved "alias" words
Expand Down
5 changes: 3 additions & 2 deletions cobc/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
of tokens, while the second phase perform REPLACE on the resulting
stream of tokens. This rewriting is closer to the COBOL standard
and fixes bug #831 partially.
* cobc.c: flag -P now accepts - as argument to mean stdout

2023-07-02 Fabrice Le Fessant <[email protected]>

Expand Down Expand Up @@ -97,8 +98,8 @@
* typeck.c (cb_build_expr): remove cb_ prefix from static functions
and comment algorithm

Bugs #875 V IS ZERO AND, #880 error compiling abbreviated conditions
and #887 error compiling parenthesized relation
Bugs #875 V IS ZERO AND, #880 error compiling abbreviated conditions
and #887 error compiling parenthesized relation
* typeck.c (cb_build_expr): additional generate 'invalid conditional
expression' error", translate NOT comparison to inversed comparison
* typeck.c (cb_build_expr), tree.c (cb_build_binary_op): give more
Expand Down
10 changes: 8 additions & 2 deletions cobc/cobc.c
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ static const char *const cob_csyns[] = {

#define COB_NUM_CSYNS sizeof(cob_csyns) / sizeof(cob_csyns[0])

static const char short_options[] = "hVivqECScbmxjdFOPgwo:t:T:I:L:l:D:K:k:";
static const char short_options[] = "hVivqECScbmxjdFOgwo:P:t:T:I:L:l:D:K:k:";

#define CB_NO_ARG no_argument
#define CB_RQ_ARG required_argument
Expand Down Expand Up @@ -9184,6 +9184,9 @@ main (int argc, char **argv)
memset (cb_listing_header, 0, sizeof (cb_listing_header));
/* If -P=file specified, all lists go to this file */
if (cobc_list_file) {
if (strcmp (cobc_list_file, COB_DASH) == 0) {
cb_listing_file = stdout;
} else
if (cb_unix_lf) {
cb_listing_file = fopen (cobc_list_file, "wb");
} else {
Expand Down Expand Up @@ -9269,7 +9272,10 @@ main (int argc, char **argv)
}

if (cobc_list_file) {
fclose (cb_listing_file);
if (cb_listing_file != stdout)
fclose (cb_listing_file);
else
fflush (stdout);
cb_listing_file = NULL;
}

Expand Down
4 changes: 1 addition & 3 deletions tests/testsuite.src/syn_copy.at
Original file line number Diff line number Diff line change
Expand Up @@ -946,9 +946,7 @@ AT_DATA([prog.cob], [
REPLACE OFF.
])

AT_CHECK([$COMPILE_ONLY -P=preproc.lst prog.cob])

AT_CHECK([cat preproc.lst], [0],
AT_CHECK([$COMPILE_ONLY -P- prog.cob], [0],
[ 1 @&t@
2 IDENTIFICATION DIVISION.
3 PROGRAM-ID. prog.
Expand Down

0 comments on commit f1d0612

Please sign in to comment.