From 9ac957ac5623e415418dcc7d522286587a871ab5 Mon Sep 17 00:00:00 2001 From: "Scott C. Livingston" Date: Thu, 26 Mar 2020 15:25:39 -0700 Subject: [PATCH] in rg, freopen instead of stdin l-value because stdin (and stdout and stderr) is specified to be a macro, and therefore, assignment as an l-value might not be portable. This changeset is motivated as part of work to support gr1c on Windows. --- src/rg_main.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/rg_main.c b/src/rg_main.c index 8dd358a..821aecc 100644 --- a/src/rg_main.c +++ b/src/rg_main.c @@ -57,7 +57,6 @@ extern anode_t *synthesize_reachgame_BDD( DdManager *manager, int main( int argc, char **argv ) { FILE *fp; - FILE *stdin_backup = NULL; byte run_option = RG_MODE_SYNTHESIS; bool help_flag = False; bool ptdump_flag = False; @@ -212,13 +211,11 @@ int main( int argc, char **argv ) /* If filename for specification given at command-line, then use it. Else, read from stdin. */ if (input_index > 0) { - fp = fopen( argv[input_index], "r" ); + fp = freopen( argv[input_index], "r", stdin ); if (fp == NULL) { perror( __FILE__ ", fopen" ); return -1; } - stdin_backup = stdin; - stdin = fp; } /* Parse the specification. */ @@ -229,9 +226,6 @@ int main( int argc, char **argv ) return 2; if (verbose) logprint( "Done." ); - if (stdin_backup != NULL) { - stdin = stdin_backup; - } if (spc.num_sgoals > 1) { fprintf( stderr,