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 8dc9eed commit 30d087e
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 34 deletions.
23 changes: 1 addition & 22 deletions cobc/cobc.c
Original file line number Diff line number Diff line change
Expand Up @@ -9220,27 +9220,6 @@ 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 @@ -9327,7 +9306,7 @@ process_file (struct filename *fn, int status)
}

for (l = cb_depend_list; l; l = l->next) {
char* filename = slashify (l->text);
char* filename = cobc_slashify (l->text);
fprintf (file, " %s%s", filename, l->next ? sep : "\n\n");
cobc_free (filename);
}
Expand Down
1 change: 1 addition & 0 deletions cobc/cobc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
extern struct reserved_word_list *cobc_user_res_list;
Expand Down
24 changes: 24 additions & 0 deletions cobc/error.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,34 @@ 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
instead of backslashes. Only a few tools force the use of slashes,
such as the cmd shell. */
char *
cobc_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 void
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] != '/'
Expand Down Expand Up @@ -101,6 +124,7 @@ 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);
Expand Down
1 change: 1 addition & 0 deletions cobc/typeck.c
Original file line number Diff line number Diff line change
Expand Up @@ -3595,6 +3595,7 @@ check_argument_conformance (struct cb_program *program, cb_tree argument_tripple
} else {
arg_field = NULL;
}
if (!CB_FIELD_P(param)) return;
param_field = CB_FIELD_PTR(CB_VALUE(param));

/*
Expand Down
23 changes: 11 additions & 12 deletions tests/testsuite.src/used_binaries.at
Original file line number Diff line number Diff line change
Expand Up @@ -1081,13 +1081,13 @@ AT_SETUP([check include header file])
#AT_KEYWORDS([include])

AT_DATA([file.h], [
COB_EXT_IMPORT void f (char *, long);
COB_EXT_IMPORT void rename (const char *, const char*);
])
AT_DATA([prog.cob], [
IDENTIFICATION DIVISION.
PROGRAM-ID. prog.
PROCEDURE DIVISION.
CALL "f" USING "Hello".
CALL "rename" USING "Hello".
])

# No check, program seems correct
Expand All @@ -1097,14 +1097,13 @@ AT_CHECK([$COBC -m -fstatic-call prog.cob], [0], [], [])
# We ignore the error output, as it depends on the C compiler in use

AT_CHECK([$COBC -m --include "$PWD/file.h" -fstatic-call prog.cob], [1], [], [ignore])

AT_DATA([prog2.cob], [
IDENTIFICATION DIVISION.
PROGRAM-ID. prog.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 long USAGE BINARY-C-LONG.
PROCEDURE DIVISION.
CALL "f" USING "Hello" BY VALUE long RETURNING NOTHING.
CALL "rename" USING "Hello" "Hello2" RETURNING NOTHING.
])

AT_CHECK([$COBC -m --include "$PWD/file.h" -fstatic-call prog2.cob], [0], [], [])
Expand All @@ -1118,19 +1117,19 @@ AT_CHECK([$COBC -I . -m --include "file.h" -fstatic-call prog2.cob], [0], [], []
# * putting RETURNING NOTHING is not supported
# * putting RETURNING OMITTED is ok, but triggers a warning (see stderr)

AT_DATA([f.copy], [
AT_DATA([rename.copy], [
IDENTIFICATION DIVISION.
PROGRAM-ID. f PROTOTYPE.
PROGRAM-ID. rename PROTOTYPE.
DATA DIVISION.
LINKAGE SECTION.
01 a PIC X(20).
01 b BINARY-C-LONG.
PROCEDURE DIVISION USING a BY VALUE b RETURNING OMITTED.
END PROGRAM f.
01 b PIC X(20).
PROCEDURE DIVISION USING a b RETURNING OMITTED.
END PROGRAM rename.
])

AT_CHECK([$COMPILE_MODULE -Wno-unfinished --copy "f.copy" -fstatic-call prog2.cob], [0], [],
[prog2.cob:8: warning: unexpected RETURNING item
AT_CHECK([$COMPILE_MODULE -Wno-unfinished --copy "rename.copy" -fstatic-call prog2.cob], [0], [],
[prog2.cob:6: warning: unexpected RETURNING item
])

AT_CLEANUP
Expand Down

0 comments on commit 30d087e

Please sign in to comment.