diff --git a/cobc/ChangeLog b/cobc/ChangeLog index a2309333d..e34dd6d16 100644 --- a/cobc/ChangeLog +++ b/cobc/ChangeLog @@ -5,12 +5,7 @@ output deps only, -MD to output deps while compiling (in .d files), -MP to output phony targets, -MG to keep missing copybooks, -MQ to Makefile-quote target - -2024-03-15 Fabrice Le Fessant - - * cobc.c, flags.def: add new flags to output dependencies: - -foneline-deps outputs all dependencies on a single line instead of - multiple lines; -fcopybook-deps outputs only copybook names instead + * flags.def: -fcopybook-deps outputs only copybook names instead of file paths. -fcopybook-deps also forces -E, -foneline-deps, -MT=copybooks, disables errors on missing copybooks and removes output on stdout. diff --git a/cobc/cobc.c b/cobc/cobc.c index 088af6f47..52b2bc60b 100644 --- a/cobc/cobc.c +++ b/cobc/cobc.c @@ -9220,6 +9220,27 @@ finish_setup_internal_env (void) CB_TEXT_LIST_CHK (cb_include_list, COB_COPY_DIR); } +/* Replace a copy of the argument with backslashes replaced by slashes +in filenames. 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. */ +static char * +slashify (const char *src) +{ + int i; + int len = strlen (src); + char *dst = cobc_malloc (len+1); + for (i=0; isource, NULL); - const char *target = file_replace_extension (basename, "." COB_OBJECT_EXT); - fprintf (file, "%s:%s", target, sep); + basename = file_replace_extension (basename, "." COB_OBJECT_EXT); + fprintf (file, "%s:%s", basename, sep); } + for (l = cb_depend_list; l; l = l->next) { - fprintf (file, " %s%s", l->text, l->next ? sep : "\n\n"); + char* filename = slashify (l->text); + fprintf (file, " %s%s", filename, l->next ? sep : "\n\n"); + cobc_free (filename); } /* These lines should only be added with -MP */ if (cb_depend_add_phony){ diff --git a/tests/testsuite.src/used_binaries.at b/tests/testsuite.src/used_binaries.at index 5d80c1342..d36703c16 100644 --- a/tests/testsuite.src/used_binaries.at +++ b/tests/testsuite.src/used_binaries.at @@ -1070,8 +1070,8 @@ AT_CHECK([echo "$PWD/prog.cob:6: warning: numeric value is expected" >> expected AT_CHECK([echo "$PWD/prog.cob:14: warning: ignoring redundant ." >> expected.output]) AT_CAPTURE_FILE([expected.output]) -AT_CHECK([cat compiler.output | tr '[:upper:]' '[:lower:]' | tr -d ':/\\' > compiler.output2]) -AT_CHECK([cat expected.output | tr '[:upper:]' '[:lower:]' | tr -d ':/\\' > expected.output2]) +AT_CHECK([[cat compiler.output | tr '[:upper:]' '[:lower:]' | tr -d ':/\\' > compiler.output2]]) +AT_CHECK([[cat expected.output | tr '[:upper:]' '[:lower:]' | tr -d ':/\\' > expected.output2]]) AT_CHECK([diff compiler.output2 expected.output2]) AT_CLEANUP