Skip to content

Commit

Permalink
Remove unrelated parts
Browse files Browse the repository at this point in the history
  • Loading branch information
ddeclerck committed Sep 20, 2024
1 parent 8833591 commit cdac268
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 95 deletions.
1 change: 1 addition & 0 deletions .github/workflows/windows-msvc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ jobs:
- name: Upload testsuite-${{ matrix.arch }}-${{ matrix.target }}.log
uses: actions/upload-artifact@v4
if: failure()
with:
name: testsuite-${{ matrix.arch }}-${{ matrix.target }}.log
path: ${{ env.GITHUB_WORKSPACE }}/tests/testsuite.log
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/windows-msys1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ jobs:

- name: Upload testsuite-${{ matrix.target }}.log
uses: actions/upload-artifact@v4
if: failure()
with:
name: testsuite-${{ matrix.target }}.log
path: ${{ env.GITHUB_WORKSPACE }}/_build/tests/testsuite.log
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/windows-msys2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ jobs:
- name: Upload testsuite-${{matrix.sys}}-${{matrix.target}}.log
uses: actions/upload-artifact@v4
if: failure()
with:
name: testsuite-${{matrix.sys}}-${{matrix.target}}.log
path: ${{ env.GITHUB_WORKSPACE }}/_build/tests/testsuite.log
Expand Down
2 changes: 0 additions & 2 deletions cobc/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,6 @@
of file paths. -fcopybook-deps also forces -E, -foneline-deps,
-MT=copybooks, disables errors on missing copybooks and removes
output on stdout.
* error.c (print_error_prefix): add cobc_slashify to replace backslashes
by slashes, only if COB_IS_RUNNING_IN_TESTMODE is set.
* typeck.c (check_argument_conformance): check that param is well defined
to prevent a segfault

Expand Down
8 changes: 2 additions & 6 deletions cobc/cobc.c
Original file line number Diff line number Diff line change
Expand Up @@ -9311,16 +9311,12 @@ process_file (struct filename *fn, int status)
}

for (l = cb_depend_list; l; l = l->next) {
char* filename = cobc_slashify (l->text);
fprintf (file, " %s%s", filename, l->next ? sep : "\n\n");
cobc_free (filename);
fprintf (file, " %s%s", l->text, l->next ? sep : "\n\n");
}
/* These lines should only be added with -MP */
if (cb_depend_add_phony){
for (l = cb_depend_list; l; l = l->next) {
char* filename = cobc_slashify (l->text);
fprintf (file, "%s:\n", filename);
cobc_free (filename);
fprintf (file, "%s:\n", l->text);
}
}
if (!cb_depend_file){
Expand Down
2 changes: 0 additions & 2 deletions cobc/cobc.h
Original file line number Diff line number Diff line change
Expand Up @@ -672,8 +672,6 @@ DECLNORET extern void cobc_terminate_exit (const char *, const char *) COB_A_NO

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
32 changes: 0 additions & 32 deletions cobc/error.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,42 +62,11 @@ size_t cb_msg_style;

DECLNORET static void cobc_too_many_errors (void) COB_A_NORETURN;

static int is_test = -1;

/* Returns a copy of the argument with backslashes replaced by slashes
in filenames, only if COB_IS_RUNNING_IN_TESTMODE. This mode simplifies
the test of outputs, as they will be similar on Unix and Windows.
*/
char *
cobc_slashify (const char *src)
{
if (is_test < 0)
is_test = !!getenv ("COB_IS_RUNNING_IN_TESTMODE");

if (is_test){
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;
} else
return cobc_strdup (src);
}

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 @@ -131,7 +100,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);
Expand Down
6 changes: 3 additions & 3 deletions cobc/pplex.l
Original file line number Diff line number Diff line change
Expand Up @@ -1288,7 +1288,7 @@ ppopen_get_file (const char *name)
loc.source_file = name;
loc.source_line = -1;
cb_error_x (&loc, _("recursive inclusion"));
return 0;
return 0;
}
}

Expand All @@ -1299,7 +1299,7 @@ ppopen_get_file (const char *name)
ppin = fopen (name, "rb");
#endif
if (!ppin) {
cb_error ("%s: %s", cobc_slashify (name), cb_get_strerror ());
cb_error ("%s: %s", name, cb_get_strerror ());
/* Note: postpone error exit as we need the saved buffers later on */
return 0;
}
Expand Down Expand Up @@ -1753,7 +1753,7 @@ ppcopy (const char *name, const char *lib, struct cb_replace_list *replace_list)
(void)access (plexbuff1, R_OK);
/* pass file error as we have no more places to check */
cb_error ("%s: %s",
cobc_slashify (plexbuff1), cb_get_strerror ());
plexbuff1, cb_get_strerror ());
}
}
}
Expand Down
89 changes: 39 additions & 50 deletions tests/testsuite.src/used_binaries.at
Original file line number Diff line number Diff line change
Expand Up @@ -372,28 +372,13 @@ AT_DATA([prog.cob], [
EXIT PROGRAM.
])

AT_CHECK([TMPDIR="" TMP="notthere" TEMP="" $COMPILE prog.cob 2> compiler.output], [0], [],
[],[
# On Windows, we get a failure from gcc, so the binary is not created, the stderr is mixed and exit code is 1.
AT_CHECK([grep libcob: compiler.output], [0], [libcob: warning: Temporary directory TMP is invalid, adjust TMPDIR!
AT_CHECK([TMPDIR="" TMP="notthere" TEMP="" $COMPILE prog.cob], [0], [],
[libcob: warning: Temporary directory TMP is invalid, adjust TMPDIR!
])
],
[
AT_CHECK([cat compiler.output], [0], [libcob: warning: Temporary directory TMP is invalid, adjust TMPDIR!
])
AT_CHECK([$COBCRUN_DIRECT ./prog], [0], [OK], [])
])

AT_CHECK([TMPDIR="" TMP="" TEMP="./prog.cob" $COMPILE prog.cob 2> compiler.output], [0], [],
[],[
AT_CHECK([grep libcob: compiler.output], [0], [libcob: warning: Temporary directory TEMP is invalid, adjust TMPDIR!
])
],
[
AT_CHECK([cat compiler.output], [0], [libcob: warning: Temporary directory TEMP is invalid, adjust TMPDIR!
AT_CHECK([$COBCRUN_DIRECT ./prog], [0], [OK], [])
AT_CHECK([TMPDIR="" TMP="" TEMP="./prog.cob" $COMPILE prog.cob], [0], [],
[libcob: warning: Temporary directory TEMP is invalid, adjust TMPDIR!
])
])

# TMPDIR is only checked when actually needed which is currently only the case
# for SORT
#AT_CHECK([TMPDIR="./prog.cob" $COBCRUN_DIRECT ./prog], [0], [OK],
Expand Down Expand Up @@ -1072,16 +1057,15 @@ AT_CHECK([$COBC -fdiagnostics-plain-output -fdiagnostics-show-caret -Wno-others
]])

AT_CHECK([$COMPILE -fdiagnostics-absolute-paths -Wall prog.cob 2> compiler.output], [1])
AT_CAPTURE_FILE([compiler.output])

AT_CHECK([echo "$PWD/prog.cob:7: error: CRUD.CPY: No such file or directory" > expected.output])
AT_CHECK([echo "$PWD/prog.cob:6: warning: numeric value is expected" >> expected.output])
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([diff compiler.output2 expected.output2])
# note: -fdiagnostics-absolute-paths will show the realpath,
# so for MSYS/MSVC builds that will be x:\something\prog.cob, not the output of PWD,
# but the _return_path function from atlocal may adjust that
AT_CHECK([cat compiler.output | tr '\\' '/' | $SED "s|$(_return_path "$(pwd)")|DIR|"], [0],
[DIR/prog.cob:7: error: CRUD.CPY: No such file or directory
DIR/prog.cob:6: warning: numeric value is expected
DIR/prog.cob:14: warning: ignoring redundant .
], [], [echo set: $SED "s|$(_return_path "$(pwd)")|DIR|"])

AT_CLEANUP

Expand All @@ -1091,13 +1075,13 @@ AT_SETUP([check include header file])

AT_DATA([filec.h], [
/* COB_EXT_IMPORT will be defined by libcob.h up-front */
COB_EXT_IMPORT void rename (const char *, const char*);
COB_EXT_IMPORT void f (char *, long);
])
AT_DATA([prog.cob], [
IDENTIFICATION DIVISION.
PROGRAM-ID. prog.
PROCEDURE DIVISION.
CALL "rename" USING "Hello".
CALL "f" USING "Hello".
])

# dynamic call - program seems correct
Expand All @@ -1111,8 +1095,10 @@ AT_DATA([prog2.cob], [
IDENTIFICATION DIVISION.
PROGRAM-ID. prog.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 long USAGE BINARY-C-LONG.
PROCEDURE DIVISION.
CALL "rename" USING "Hello" "Hello2" RETURNING NOTHING.
CALL "f" USING "Hello" BY VALUE long RETURNING NOTHING.
])

# note: we likely need to build an import library for some environments
Expand Down Expand Up @@ -1143,22 +1129,22 @@ AT_CHECK([$COMPILE_MODULE -I . --include "filec.h" -fstatic-call prog2.cob -o pr
# * putting RETURNING NOTHING is not supported
# * putting RETURNING OMITTED is ok, but triggers a warning (see stderr)

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

AT_CHECK([$COMPILE_MODULE -Wno-unfinished --copy "rename.copy" -fstatic-call prog2.cob -o prog2c], [0], [],
AT_CHECK([$COMPILE_MODULE -Wno-unfinished --copy "f.copy" -fstatic-call prog2.cob -o prog2c], [0], [],
[prog2.cob:8: warning: unexpected RETURNING item
], [
# Previous test "failed" --> retry with import library
AT_CHECK([$COMPILE_MODULE -Wno-unfinished --copy "rename.copy" -fstatic-call -L. -lfilec prog2.cob -o prog2c], [0], ignore, ignore)]
AT_CHECK([$COMPILE_MODULE -Wno-unfinished --copy "f.copy" -fstatic-call -L. -lfilec prog2.cob -o prog2c], [0], ignore, ignore)]
)

AT_CLEANUP
Expand Down Expand Up @@ -1193,7 +1179,7 @@ AT_DATA([sub/COPY3.CPY], [])
AT_CHECK([$COMPILE_ONLY prog.cob])

AT_CHECK([$COMPILE_ONLY -M prog.cob prog.cob > compiler.output], [0])
AT_CHECK([$SED "s/prog.$COB_OBJECT_EXT/prog.COB_OBJECT_EXT/g" compiler.output], [0],
AT_CHECK([$SED "s/prog.$COB_OBJECT_EXT/prog.COB_OBJECT_EXT/g;s/sub\\\\/sub\//g" compiler.output], [0],
[prog.COB_OBJECT_EXT: \
prog.cob \
COPY1.CPY \
Expand All @@ -1210,7 +1196,7 @@ prog.COB_OBJECT_EXT: \

AT_CHECK([$COMPILE_ONLY -M -MF prog.dep prog.cob])

AT_CHECK([$SED "s/prog.$COB_OBJECT_EXT/prog.COB_OBJECT_EXT/g" prog.dep], [0],
AT_CHECK([$SED "s/prog.$COB_OBJECT_EXT/prog.COB_OBJECT_EXT/g;s/sub\\\\/sub\//g" prog.dep], [0],
[prog.COB_OBJECT_EXT: \
prog.cob \
COPY1.CPY \
Expand All @@ -1220,13 +1206,13 @@ AT_CHECK([$SED "s/prog.$COB_OBJECT_EXT/prog.COB_OBJECT_EXT/g" prog.dep], [0],
])

AT_CHECK([$COMPILE_ONLY -M -fcopybook-deps prog.cob > compiler.output], [0])
AT_CHECK([$SED "s/prog.$COB_OBJECT_EXT/prog.COB_OBJECT_EXT/g" compiler.output], [0],
AT_CHECK([$SED "s/prog.$COB_OBJECT_EXT/prog.COB_OBJECT_EXT/g;s/sub\\\\/sub\//g" compiler.output], [0],
[prog.COB_OBJECT_EXT: COPY1 COPY2 sub/COPY3

])

AT_CHECK([$COMPILE -g -M -MT prog.$COB_MODULE_EXT prog.cob > compiler.output], [0])
AT_CHECK([$SED "s/prog.$COB_MODULE_EXT/prog.COB_MODULE_EXT/g" compiler.output], [0],
AT_CHECK([$SED "s/prog.$COB_MODULE_EXT/prog.COB_MODULE_EXT/g;s/sub\\\\/sub\//g" compiler.output], [0],
[prog.COB_MODULE_EXT: \
prog.cob \
COPY1.CPY \
Expand All @@ -1238,7 +1224,8 @@ AT_CHECK([$SED "s/prog.$COB_MODULE_EXT/prog.COB_MODULE_EXT/g" compiler.output],
AT_CHECK([test -f prog.c], [1])
AT_CHECK([test -f prog.o], [1])

AT_CHECK([$COMPILE_ONLY -M -MQ '$(target)#toto' prog.cob], [0],
AT_CHECK([$COMPILE_ONLY -M -MQ '$(target)#toto' prog.cob > compiler.output], [0])
AT_CHECK([$SED "s/sub\\\\/sub\//g" compiler.output], [0],
[$$(target)\#toto: \
prog.cob \
COPY1.CPY \
Expand All @@ -1252,7 +1239,7 @@ AT_CAPTURE_FILE([prog.d])

AT_CHECK([$COMPILE -MD prog.cob])

AT_CHECK([$SED "s/prog.$COB_OBJECT_EXT/prog.COB_OBJECT_EXT/g" prog.d], [0],
AT_CHECK([$SED "s/prog.$COB_OBJECT_EXT/prog.COB_OBJECT_EXT/g;s/sub\\\\/sub\//g" prog.d], [0],
[prog.COB_OBJECT_EXT: \
prog.cob \
COPY1.CPY \
Expand All @@ -1265,7 +1252,7 @@ AT_CHECK([$COMPILE -MD -o sub/prog.exe prog.cob])

AT_CHECK([test -f sub/prog.exe])

AT_CHECK([$SED "s/prog.$COB_OBJECT_EXT/prog.COB_OBJECT_EXT/g" sub/prog.d], [0],
AT_CHECK([$SED "s/prog.$COB_OBJECT_EXT/prog.COB_OBJECT_EXT/g;s/sub\\\\/sub\//g" sub/prog.d], [0],
[prog.COB_OBJECT_EXT: \
prog.cob \
COPY1.CPY \
Expand All @@ -1276,9 +1263,7 @@ AT_CHECK([$SED "s/prog.$COB_OBJECT_EXT/prog.COB_OBJECT_EXT/g" sub/prog.d], [0],

AT_CHECK([rm sub/COPY3.CPY])

AT_CHECK([$COMPILE_ONLY -M prog.cob > compiler.output], [1], [],
[prog.cob:12: error: sub/COPY3: No such file or directory
])
AT_CHECK([$COMPILE_ONLY -M prog.cob > compiler.output 2> compiler.error], [1], [], [])

AT_CHECK([$SED "s/prog.$COB_OBJECT_EXT/prog.COB_OBJECT_EXT/g" compiler.output], [0],
[prog.COB_OBJECT_EXT: \
Expand All @@ -1288,8 +1273,12 @@ AT_CHECK([$SED "s/prog.$COB_OBJECT_EXT/prog.COB_OBJECT_EXT/g" compiler.output],

])

AT_CHECK([$SED "s/sub\\\\/sub\//g" compiler.error], [0],
[prog.cob:12: error: sub/COPY3: No such file or directory
])

AT_CHECK([$COMPILE_ONLY -M -MG prog.cob > compiler.output], [0])
AT_CHECK([$SED "s/prog.$COB_OBJECT_EXT/prog.COB_OBJECT_EXT/g" compiler.output], [0],
AT_CHECK([$SED "s/prog.$COB_OBJECT_EXT/prog.COB_OBJECT_EXT/g;s/sub\\\\/sub\//g" compiler.output], [0],
[prog.COB_OBJECT_EXT: \
prog.cob \
COPY1.CPY \
Expand Down

0 comments on commit cdac268

Please sign in to comment.