Looks like a bug: const char *infile, *outfile; FILE *out, *in; ... outfile = poptGetArg(pc); if(outfile) { out = fopen(outfile, "w+"); if(!out) { perror("fopen"); fprintf(stderr, "Can't find %s, using stdout...\n", outfile); } } if(!outfile) out = stdout; When we can't open specified file program should use stdout, but out variable not assigned to stdout because outfile contains filename. So, we should NULL'ify outfile to pass this checks, or change condition to compare out with NULL (in this case we also should initialize this variable). I made a trivial patch which just assign NULL to outfile when we can't open file.
Created attachment 4186 [details] Really use stdout if file cannot be opened. Proposal fix.
I'd rather see the program to exit if we can't open a file a user explicitly asked to open. Do you want to provide a new patch with that, or do you want me to do it? Thanks, Volker
(In reply to comment #2) > I'd rather see the program to exit if we can't open a file a user explicitly > asked to open. Do you want to provide a new patch with that, or do you want me > to do it? It's not my idea, so I think it would be better if you implement it.
Pushed to master with c8d63d47cd38. I hope you don't mind I don't push this into the other branches, I don't think this is really criticial enough. Thanks, Volker