From 42adc9fa936eaf594c7a474012c65a8510740c07 Mon Sep 17 00:00:00 2001 From: Fabrice Le Fessant Date: Fri, 15 Mar 2024 11:53:15 +0100 Subject: [PATCH] xxx --- cobc/cobc.h | 1 + cobc/error.c | 10 +++++----- cobc/pplex.l | 3 ++- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/cobc/cobc.h b/cobc/cobc.h index b01338e45..084d9ad36 100644 --- a/cobc/cobc.h +++ b/cobc/cobc.h @@ -669,6 +669,7 @@ DECLNORET extern void flex_fatal_error (const char *, const char *, DECLNORET extern void cobc_terminate_exit (const char *, const char *) COB_A_NORETURN; extern void cobc_set_listing_header_code (void); + extern char * cobc_slashify (const char *); /* reserved.c */ diff --git a/cobc/error.c b/cobc/error.c index 447900f5a..f74b63dd3 100644 --- a/cobc/error.c +++ b/cobc/error.c @@ -63,8 +63,11 @@ size_t cb_msg_style; DECLNORET static void cobc_too_many_errors (void) COB_A_NORETURN; -/* Returns a copy of the argument with backslashes replaced by slashes -in filenames. Note that all Windows system calls accept slashes +/* Returns the argument with backslashes replaced by slashes +in filenames. Second argument explains whether the result should be +set in place or reallocated. + +Note that all Windows system calls accept slashes instead of backslashes. Only a few tools force the use of slashes, such as the cmd shell. */ char * @@ -89,8 +92,6 @@ print_error_prefix (const char *file, int line, const char *prefix) { if (file) { char *absfile = NULL ; - char *tmpfile = cobc_slashify (file); - file = tmpfile; if (cb_diagnostics_absolute_paths && strcmp (file, COB_DASH) != 0 && file[0] != '/' @@ -124,7 +125,6 @@ print_error_prefix (const char *file, int line, const char *prefix) fprintf (stderr, "%s:%d: ", file, line); } if (absfile) cobc_free (absfile); - cobc_free (tmpfile); } if (prefix) { fprintf (stderr, "%s", prefix); diff --git a/cobc/pplex.l b/cobc/pplex.l index 77aa3babe..5e6b2fcf8 100644 --- a/cobc/pplex.l +++ b/cobc/pplex.l @@ -1725,7 +1725,8 @@ ppcopy (const char *name, const char *lib, struct cb_replace_list *replace_list) /* ensure to have errno from name as specified, not from another file */ (void)access (plexbuff1, R_OK); /* pass file error as we have no more places to check */ - cb_error ("%s: %s", plexbuff1, cb_get_strerror ()); + cb_error ("%s: %s", + cobc_slashify (plexbuff1), cb_get_strerror ()); } } }