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 5, 2023
1 parent c73b9d3 commit 7b69eaf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
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 7b69eaf

Please sign in to comment.