From: Ben Pfaff Date: Sat, 19 Dec 2020 05:10:28 +0000 (-0800) Subject: sys-file-reader: Omit @(#) from file strings in sfm_get_strings(). X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4045b0283a12c8fbc0211b0449cbd0e51f51470e;p=pspp 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. --- 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])