sys-file-reader: Omit @(#) from file strings in sfm_get_strings().
authorBen Pfaff <blp@cs.stanford.edu>
Sat, 19 Dec 2020 05:10:28 +0000 (21:10 -0800)
committerBen Pfaff <blp@cs.stanford.edu>
Sat, 19 Dec 2020 05:12:59 +0000 (21:12 -0800)
This function returns strings so that the user can figure out the file's
correct encoding.  @(#) has different interpretations in a few encodings
(sometimes 0x23 is not #) and there's no value in displaying different
versions of it, so skip it.

src/data/sys-file-reader.c

index 0e8a9bfc68c988a17fb4ece5a6ea1e9509b59382..ec8ae3b32fd654c9f9ee0fcbbca007c0049fc075 100644 (file)
@@ -640,6 +640,13 @@ add_id (struct get_strings_aux *aux, const char *id, const char *title, ...)
   va_end (args);
 }
 
+static const char *
+skip_prefix (const char *s, const char *prefix)
+{
+  size_t prefix_len = strlen (prefix);
+  return !strncmp (s, prefix, prefix_len) ? s + prefix_len : s;
+}
+
 /* Retrieves significant string data from R in its raw format, to allow the
    caller to try to detect the encoding in use.
 
@@ -689,7 +696,7 @@ sfm_get_strings (const struct any_reader *r_, struct pool *pool,
 
   add_string (&aux, r->header.creation_date, _("Creation Date"));
   add_string (&aux, r->header.creation_time, _("Creation Time"));
-  add_string (&aux, r->header.eye_catcher, _("Product"));
+  add_string (&aux, skip_prefix (r->header.eye_catcher, "@(#) "), _("Product"));
   add_string (&aux, r->header.file_label, _("File Label"));
 
   if (r->extensions[EXT_PRODUCT_INFO])