From 4045b0283a12c8fbc0211b0449cbd0e51f51470e Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Fri, 18 Dec 2020 21:10:28 -0800 Subject: [PATCH] sys-file-reader: Omit @(#) from file strings in sfm_get_strings(). 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 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/data/sys-file-reader.c b/src/data/sys-file-reader.c index 0e8a9bfc68..ec8ae3b32f 100644 --- a/src/data/sys-file-reader.c +++ b/src/data/sys-file-reader.c @@ -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]) -- 2.30.2