Follow-up Comment #13, bug #55334 (project groff):

Thanks for fixing this!

I would like to raise a minor concern, maybe you can tweak your solution. 
Comparing the filename to "-" seems fragile.  There may be other ways to get a
non-seekable file descriptor, for example someone passing "/dev/stdin" on the
command line or someone passing the name of a file created with mkfifo(1).

Instead of strcmp(filename, "-") in do_file(), i suggest doing something like
the following inside detect_file_encoding():

-rewind(fp);
+if (fseek(fp, 0L, SEEK_SET) == -1)
+    goto end;

That seems like the canonical way to test for the feature actually needed,
which feels much more robust than some crude guesswork based on tangentially
related string data.  Testing at the place where the feature is really needed
(and where other error handling is already present) also seems easier to
understand than having an additional check one level up in the call stack.

What do you think?

    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?55334>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/


Reply via email to