Skip to content

Commit

Permalink
xxx
Browse files Browse the repository at this point in the history
  • Loading branch information
lefessan committed Mar 15, 2024
1 parent 5f4f4bc commit 8dc9eed
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 11 deletions.
7 changes: 1 addition & 6 deletions cobc/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -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 <target> to Makefile-quote target

2024-03-15 Fabrice Le Fessant <[email protected]>

* 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.
Expand Down
30 changes: 27 additions & 3 deletions cobc/cobc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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; i<len; i++){
char c = src[i];
if ( c == '\\' )
dst[i] = '/';
else
dst[i] = c;
}
dst[i] = 0;
return dst;
}

static int
process_file (struct filename *fn, int status)
{
Expand Down Expand Up @@ -9301,11 +9322,14 @@ process_file (struct filename *fn, int status)
fprintf (file, "%s:%s", cb_depend_target, sep);
} else {
const char *basename = file_basename (fn->source, 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){
Expand Down
4 changes: 2 additions & 2 deletions tests/testsuite.src/used_binaries.at
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8dc9eed

Please sign in to comment.