From 8366e1be1cf82b9ee5b6337f032e614dda31737c Mon Sep 17 00:00:00 2001 From: sf-mensch Date: Thu, 2 May 2024 10:24:26 +0000 Subject: [PATCH 01/12] housekeeping * fixed changelog entries of [r228] (manual-merged with [r498]) * handled ar-lib --- build_aux/ar-lib | 0 cobc/ChangeLog | 6 +++++- libcob/ChangeLog | 18 ++++++++---------- 3 files changed, 13 insertions(+), 11 deletions(-) mode change 120000 => 100755 build_aux/ar-lib diff --git a/build_aux/ar-lib b/build_aux/ar-lib deleted file mode 120000 index be8806a2f..000000000 --- a/build_aux/ar-lib +++ /dev/null @@ -1,271 +0,0 @@ -#! /bin/sh -# Wrapper for Microsoft lib.exe - -me=ar-lib -scriptversion=2019-07-04.01; # UTC - -# Copyright (C) 2010-2019 Free Software Foundation, Inc. -# Written by Peter Rosin . -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# This file is maintained in Automake, please report -# bugs to or send patches to -# . - - -# func_error message -func_error () -{ - echo "$me: $1" 1>&2 - exit 1 -} - -file_conv= - -# func_file_conv build_file -# Convert a $build file to $host form and store it in $file -# Currently only supports Windows hosts. -func_file_conv () -{ - file=$1 - case $file in - / | /[!/]*) # absolute file, and not a UNC file - if test -z "$file_conv"; then - # lazily determine how to convert abs files - case `uname -s` in - MINGW*) - file_conv=mingw - ;; - CYGWIN* | MSYS*) - file_conv=cygwin - ;; - *) - file_conv=wine - ;; - esac - fi - case $file_conv in - mingw) - file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` - ;; - cygwin | msys) - file=`cygpath -m "$file" || echo "$file"` - ;; - wine) - file=`winepath -w "$file" || echo "$file"` - ;; - esac - ;; - esac -} - -# func_at_file at_file operation archive -# Iterate over all members in AT_FILE performing OPERATION on ARCHIVE -# for each of them. -# When interpreting the content of the @FILE, do NOT use func_file_conv, -# since the user would need to supply preconverted file names to -# binutils ar, at least for MinGW. -func_at_file () -{ - operation=$2 - archive=$3 - at_file_contents=`cat "$1"` - eval set x "$at_file_contents" - shift - - for member - do - $AR -NOLOGO $operation:"$member" "$archive" || exit $? - done -} - -case $1 in - '') - func_error "no command. Try '$0 --help' for more information." - ;; - -h | --h*) - cat <. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# This file is maintained in Automake, please report +# bugs to or send patches to +# . + + +# func_error message +func_error () +{ + echo "$me: $1" 1>&2 + exit 1 +} + +file_conv= + +# func_file_conv build_file +# Convert a $build file to $host form and store it in $file +# Currently only supports Windows hosts. +func_file_conv () +{ + file=$1 + case $file in + / | /[!/]*) # absolute file, and not a UNC file + if test -z "$file_conv"; then + # lazily determine how to convert abs files + case `uname -s` in + MINGW*) + file_conv=mingw + ;; + CYGWIN* | MSYS*) + file_conv=cygwin + ;; + *) + file_conv=wine + ;; + esac + fi + case $file_conv in + mingw) + file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` + ;; + cygwin | msys) + file=`cygpath -m "$file" || echo "$file"` + ;; + wine) + file=`winepath -w "$file" || echo "$file"` + ;; + esac + ;; + esac +} + +# func_at_file at_file operation archive +# Iterate over all members in AT_FILE performing OPERATION on ARCHIVE +# for each of them. +# When interpreting the content of the @FILE, do NOT use func_file_conv, +# since the user would need to supply preconverted file names to +# binutils ar, at least for MinGW. +func_at_file () +{ + operation=$2 + archive=$3 + at_file_contents=`cat "$1"` + eval set x "$at_file_contents" + shift + + for member + do + $AR -NOLOGO $operation:"$member" "$archive" || exit $? + done +} + +case $1 in + '') + func_error "no command. Try '$0 --help' for more information." + ;; + -h | --h*) + cat < - * Fixes so WARNING is given if no DETAIL lines in a report + * Fixes so WARNING is given if no DETAIL lines in a repor + +2014-06-17 Ron Norman + + * parser.y, tree.c, codegen.c: Added check to verify PAGE LIMITS of report 2014-06-16 Simon Sobisch diff --git a/libcob/ChangeLog b/libcob/ChangeLog index d5333b6e7..0d03d5c2b 100644 --- a/libcob/ChangeLog +++ b/libcob/ChangeLog @@ -1,6 +1,6 @@ 2024-03-17 Fabrice Le Fessant - Emilien Lemaire + Emilien Lemaire * Makefile.am: add `profiling.c` to sources * profiling.c: implement profiling functions @@ -4145,15 +4145,13 @@ after suggestions by Chuck Haatvedt 2014-06-17 Ron Norman - * parser.y, tree.c, codegen.c: Added check to verify PAGE LIMITS of report - -2014-06-14 Ron Norman - - * parser.y: Fixes for LINE|COL 0 to get error message + * reportio.c (limitCheck, limitCheckLine, limitCheckOneLine, + cob_report_initiate): added check to verify PAGE LIMITS of report + * reportio.c (do_page_footing): adjusted write options 2014-06-04 Eric Gallager - Makefile.am (install-data-hook): removed [merged 2020-09-23] + * Makefile.am (install-data-hook): removed [merged 2020-09-23] 2014-05-20 Philipp Böhme @@ -4171,11 +4169,11 @@ after suggestions by Chuck Haatvedt 2014-05-06 Philipp Böhme - * common.c, common.h: Added print_runtime_env showing all environment values + * common.c, common.h: added print_runtime_env showing all environment values along with resolved variables used in libcob - New string helper functions: cob_int_to_string, cob_strcat, cob_strjoin, + new string helper functions: cob_int_to_string, cob_strcat, cob_strjoin, cob_int_to_formatted_bytestring - * call.c: Remove duplicates when resolving COB_LIBRARY_PATH + * call.c: remove duplicates when resolving COB_LIBRARY_PATH 2014-04-25 Ron Norman From 6fd7c72cd16e6b1ed50fab065a4443cf9d67697b Mon Sep 17 00:00:00 2001 From: sf-mensch Date: Thu, 2 May 2024 10:27:25 +0000 Subject: [PATCH 02/12] build fix [patches:#64] libcob/common.c: add missing include libxml/parser.h --- libcob/ChangeLog | 4 ++++ libcob/common.c | 1 + 2 files changed, 5 insertions(+) diff --git a/libcob/ChangeLog b/libcob/ChangeLog index 0d03d5c2b..e4ae5f0d4 100644 --- a/libcob/ChangeLog +++ b/libcob/ChangeLog @@ -14,6 +14,10 @@ * fileio.c (cob_path_to_absolute): extracted from insert and cob_set_main_argv0 +2024-03-10 Alfredo Tupone + + * common.c: add missing include libxml/parser.h + 2024-01-25 David Declerck FR #459: support COLLATING SEQUENCE clause on SELECT / INDEXED files diff --git a/libcob/common.c b/libcob/common.c index 6b47f3f12..6f45b7564 100644 --- a/libcob/common.c +++ b/libcob/common.c @@ -134,6 +134,7 @@ #endif #if defined (WITH_XML2) +#include #include #include #endif From 4695ee78629d659ab9c1ca6cacd04952c3469786 Mon Sep 17 00:00:00 2001 From: sf-mensch Date: Thu, 2 May 2024 10:34:33 +0000 Subject: [PATCH 03/12] mf dialect: adjusted missing-statement configuration [bugs:#965] config/mf-strict.conf: set missing-statement to ok (according to MF tests) --- config/ChangeLog | 6 +++++- config/mf-strict.conf | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/config/ChangeLog b/config/ChangeLog index ce0049963..3bd0e0534 100644 --- a/config/ChangeLog +++ b/config/ChangeLog @@ -1,4 +1,8 @@ +2024-05-02 Simon Sobisch + + * mf-strict.conf: set missing-statement to ok (according to MF tests) + 2023-09-19 Simon Sobisch * rm-strict.conf (perform-osvs): enabled as noted in MF docs @@ -786,7 +790,7 @@ * default.inc, Makefile.am: New files. -Copyright 2003,2005-2007-2010,2014-2023 Free Software Foundation, Inc. +Copyright 2003,2005-2007-2010,2014-2024 Free Software Foundation, Inc. Copying and distribution of this file, with or without modification, are permitted provided the copyright notice and this notice are preserved. diff --git a/config/mf-strict.conf b/config/mf-strict.conf index e058757d0..4c0000f89 100644 --- a/config/mf-strict.conf +++ b/config/mf-strict.conf @@ -269,8 +269,8 @@ records-mismatch-record-clause ok # follows IBM "if not matching use the record record-delimiter: ok sequential-delimiters: ok record-delim-with-fixed-recs: ok -missing-statement: error # according to documentation -missing-period: warning #when format not in {fixed,free} +missing-statement: ok # according to tests, documentation partially disagrees +missing-period: warning # when format not in {fixed,free} zero-length-literals: unconformable xml-generate-extra-phrases: ok continue-after: unconformable From 1ea4059c6547e62752e26debb3589ad7ddef8c55 Mon Sep 17 00:00:00 2001 From: sf-mensch Date: Thu, 2 May 2024 14:37:26 +0000 Subject: [PATCH 04/12] configure now uses pkg-config/ncurses-config to search for ncurses and honors NCURSES_LIBS and NCURSES_CFLAGS configure.ac: use pkg-config (with a fallback to ncurses-config) for getting link / compile information for ncurses/ncursesw; now honoring NCURSES_CONFIG, NCURSES_LIBS and NCURSES_FLAGS; document XML2_CONFIG --- ChangeLog | 8 ++++- NEWS | 7 +++- config/ChangeLog | 1 + configure.ac | 88 ++++++++++++++++++++++++++++++++++++------------ 4 files changed, 81 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index b5d0995ab..ac27404aa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,10 @@ +2024-05-02 Simon Sobisch + + * configure.ac: use pkg-config (with a fallback to ncurses-config) for + getting link / compile information for ncurses/ncursesw; now honoring + NCURSES_CONFIG, NCURSES_LIBS and NCURSES_FLAGS; document XML2_CONFIG + 2023-10-17 David Declerck * configure.ac: add checks to allow using stdint.h and inttypes.h @@ -1563,7 +1569,7 @@ * Version 0.9 released. -Copyright 2002-2023 Free Software Foundation, Inc. +Copyright 2002-2024 Free Software Foundation, Inc. Copying and distribution of this file, with or without modification, are permitted provided the copyright notice and this notice are preserved. diff --git a/NEWS b/NEWS index f14ccc283..add56e92c 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,6 @@ NEWS - user visible changes -*- outline -*- - GnuCOBOL 3.3 (planned January 2023) + GnuCOBOL 3.3 (planned ASAP) work in progress @@ -71,6 +71,11 @@ NEWS - user visible changes -*- outline -*- $b for executable basename, $d for date in YYYYMMDD format, $t for time in HHMMSS format (before, only $$ was available for pid) +* New build features + +** configure now uses pkg-config/ncurses-config to search for ncurses and + honors NCURSES_LIBS and NCURSES_CFLAGS + * Known issues in 3.x ** testsuite: diff --git a/config/ChangeLog b/config/ChangeLog index 3bd0e0534..89dab2d0d 100644 --- a/config/ChangeLog +++ b/config/ChangeLog @@ -1,6 +1,7 @@ 2024-05-02 Simon Sobisch + fixing bug #965 * mf-strict.conf: set missing-statement to ok (according to MF tests) 2023-09-19 Simon Sobisch diff --git a/configure.ac b/configure.ac index 7d48ddf01..e6aded1e7 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ dnl dnl Configure template for GnuCOBOL dnl Process this file with autoconf to produce a configure script. dnl -dnl Copyright (C) 2001-2012, 2014-2023 Free Software Foundation, Inc. +dnl Copyright (C) 2001-2012, 2014-2024 Free Software Foundation, Inc. dnl Written by Keisuke Nishida, Roger While, Ron Norman, Simon Sobisch, dnl Edward Hart dnl @@ -32,7 +32,7 @@ AC_INIT([GnuCOBOL], AC_REVISION([GnuCOBOL snapshot $Revision$]) AC_COPYRIGHT([This file is part of GnuCOBOL. -Copyright (C) 2001-2012, 2014-2023 Free Software Foundation, Inc. +Copyright (C) 2001-2012, 2014-2024 Free Software Foundation, Inc. Written by Keisuke Nishida, Roger While, Ron Norman, Simon Sobisch, Edward Hart ]) @@ -514,6 +514,7 @@ AS_IF([test "x$LIBCOB_LIBS" != x], [ [AC_MSG_RESULT([no]) AC_MSG_FAILURE([cannot link with LIBCOB_LIBS="$LIBCOB_LIBS"])]) ]) +LIBCOB_LIBS_extern="$LIBCOB_LIBS" AC_ARG_VAR([PROGRAMS_LIBS], [see LIBS, but only applied during generation of programs: cobc, cobcrun]) AS_IF([test "x$PROGRAMS_LIBS" != x], [ @@ -536,7 +537,7 @@ LT_PREREQ([2.2]) LT_PROG_RC AM_PROG_AR -dnl CHECKME: do we want disable-static (mind libsupport) +dnl CHECKME: do we want disable-static (mind libsupport) dnl if yes then drop AM_PROG_AR + build_aux/ar-lib LT_INIT([dlopen win32-dll]) @@ -772,7 +773,7 @@ AS_IF([test "$with_math" = gmp -o "$with_math" = check], [ if test -z "${GMP_LIBS+x}"; then GMP_LIBS="-lgmp" fi - LIBS="$LIBS $LIBCOB_LIBS $GMP_LIBS" + LIBS="$LIBS $LIBCOB_LIBS_extern $GMP_LIBS" AC_CHECK_HEADERS([gmp.h], [ AC_MSG_CHECKING([whether linking against libgmp with "$GMP_LIBS" works]) AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], @@ -806,7 +807,7 @@ AS_IF([test "$with_math" = mpir -o "$with_math" = check], [ if test -z "${MPIR_LIBS+x}"; then MPIR_LIBS="-lmpir" fi - LIBS="$LIBS $LIBCOB_LIBS $MPIR_LIBS" + LIBS="$LIBS $LIBCOB_LIBS_extern $MPIR_LIBS" AC_CHECK_HEADERS([mpir.h], [ AC_MSG_CHECKING([whether linking against libmpir with "$MPIR_LIBS" works]) AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], @@ -918,6 +919,7 @@ AC_ARG_WITH([xml2], [], [with_xml2=check]) +AC_ARG_VAR([XML2_CONFIG], [path to xml2-config utility, fallback for pkg-config]) AS_IF([test "$with_xml2" = yes -o "$with_xml2" = check], [ PKG_CHECK_MODULES([XML2], [libxml-2.0], [], [ if test -z "${XML2_CFLAGS+x}" -o -z "${XML2_LIBS+x}"; then @@ -936,7 +938,7 @@ AS_IF([test "$with_xml2" = yes -o "$with_xml2" = check], [ if test -z "${XML2_LIBS+x}"; then XML2_LIBS="-lxml2" fi - LIBS="$LIBS $LIBCOB_LIBS $XML2_LIBS" + LIBS="$LIBS $LIBCOB_LIBS_extern $XML2_LIBS" # note: PKG_CONFIG and xml2-config set -I /path/to/libxml2 which contains a "libxml" folder where # all the files we look for are included for header in xmlwriter xmlversion uri parser tree; do @@ -1019,7 +1021,7 @@ AS_IF([test "$USE_JSON" = "cjson" -o "$USE_JSON" = "local" -o "$USE_JSON" = chec AS_IF([test -e ./libcob/cJSON.c], [AC_MSG_CHECKING([whether linking of ./libcob/cJSON.c works]) CPPFLAGS="$curr_cppflags -I./libcob" - LIBS="$LIBS $LIBCOB_LIBS " + LIBS="$LIBS $LIBCOB_LIBS_extern" AC_LINK_IFELSE([ AC_LANG_PROGRAM([[#include "cJSON.c"]], [[#if (CJSON_VERSION_MAJOR * 100 + CJSON_VERSION_MINOR) < 103 @@ -1037,7 +1039,7 @@ AS_IF([test "$USE_JSON" = "cjson" -o "$USE_JSON" = "local" -o "$USE_JSON" = chec AS_IF([test -e "$srcdir/libcob/cJSON.c"], [AC_MSG_CHECKING([whether linking of "$srcdir/libcob/cJSON.c" works]) CPPFLAGS="$curr_cppflags -I\"$srcdir/libcob\"" - LIBS="$LIBS $LIBCOB_LIBS" + LIBS="$LIBS $LIBCOB_LIBS_extern" AC_LINK_IFELSE([ AC_LANG_PROGRAM([[#include "cJSON.c"]], [[#if (CJSON_VERSION_MAJOR * 100 + CJSON_VERSION_MINOR) < 103 @@ -1064,7 +1066,7 @@ AS_IF([test "$USE_JSON" = "cjson" -o "$USE_JSON" = "local" -o "$USE_JSON" = chec if test -z "${CJSON_LIBS+x}"; then CJSON_LIBS="-lcjson" fi - LIBS="$LIBS $LIBCOB_LIBS $CJSON_LIBS" + LIBS="$LIBS $LIBCOB_LIBS_extern $CJSON_LIBS" AC_CHECK_HEADERS([cJSON.h cjson/cJSON.h], [break], [if test "$with_json" = "cjson"; then AC_MSG_ERROR([header for libcjson is required for --with-json=cjson, you may adjust CJSON_CFLAGS]) @@ -1114,7 +1116,7 @@ AS_IF([test "$USE_JSON" = "json-c" -o "$USE_JSON" = check], [ if test -z "${JSON_C_LIBS+x}"; then JSON_C_LIBS="-ljson-c" fi - LIBS="$LIBS $LIBCOB_LIBS $JSON_C_LIBS" + LIBS="$LIBS $LIBCOB_LIBS_extern $JSON_C_LIBS" AC_CHECK_HEADERS([json.h json-c/json.h], [break], [if test "$with_json" = "json-c"; then AC_MSG_ERROR([header for libjson-c is required for --with-json=json-c, you may adjust JSON_C_CFLAGS]) @@ -1203,7 +1205,7 @@ AC_DEFINE_UNQUOTED([WITH_VARSEQ], [$with_varseq]) curr_libs="$LIBS" -LIBS="$curr_libs $LIBCOB_LIBS" +LIBS="$curr_libs $LIBCOB_LIBS_extern" # Solaris has nanosleep in other libraries AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], @@ -1292,6 +1294,8 @@ AC_ARG_WITH([curses], esac], [USE_CURSES=check]) +CPPFLAGS="$CURSES_CFLAGS $curr_cppflags" + if test "x$CURSES_LIBS" != x; then LIBS="$CURSES_LIBS $LIBS" AC_MSG_CHECKING([whether linking initscr works with CURSES_LIBS, given as "$CURSES_LIBS"]) @@ -1304,17 +1308,32 @@ if test "x$CURSES_LIBS" != x; then AS_IF([test "$USE_CURSES" = check -o "$USE_CURSES" = no], [ AC_MSG_ERROR([[explicit selection with --with-curses=ARG needed, as CURSES_LIBS is set]]) ]) - LIBS="$curr_libs $LIBCOB_LIBS" + LIBS="$curr_libs $LIBCOB_LIBS_extern" fi dnl note: when switching to $ncurses all checks are done correctly but no generation in config.h is done +AC_ARG_VAR([NCURSES_CONFIG], [path to ncurses-config utility, fallback for pkg-config (ncursesw6-config, ncursesw5-config, ncurses6-config, ncurses5-config)]) if test "x$CURSES_LIBS" = x; then if test "$USE_CURSES" = "ncursesw" -o "$USE_CURSES" = check; then - AC_CHECK_LIB([ncursesw], [initscr], [true], - [AS_IF([test "$USE_CURSES" != check], [USE_CURSES="missing_lib"])]) + PKG_CHECK_MODULES([NCURSES], [ncursesw], [ac_cv_lib_ncursesw_initscr=yes], [ + AC_CHECK_PROGS([NCURSES_CONFIG], [ncursesw6-config ncursesw5-config], [no]) + AS_IF([test "$NCURSES_CONFIG" = no], [ + AC_CHECK_LIB([ncursesw], [initscr], [NCURSES_LIBS=-lncursesw], + [AS_IF([test "$USE_CURSES" != check], [USE_CURSES="missing_lib"])]) + ], [ + if test "x$NCURSES_LIBS" = x; then + NCURSES_LIBS=`$NCURSES_CONFIG --libs` + fi + if test "x$NCURSES_CFLAGS" = x; then + NCURSES_CFLAGS=`$NCURSES_CONFIG --cflags` + fi + ac_cv_lib_ncursesw_initscr=yes + ]) + ]) fi fi if test "$USE_CURSES" = "ncursesw" -o "x$ac_cv_lib_ncursesw_initscr" = xyes; then + CPPFLAGS="$NCURSES_CFLAGS $CPPFLAGS" dnl note: at least OpenBSD has ncursesw only with only ncurses.h in default header directory AC_CHECK_HEADERS([ncursesw/ncurses.h ncursesw/curses.h ncurses.h], [USE_CURSES="ncursesw" @@ -1322,23 +1341,46 @@ if test "$USE_CURSES" = "ncursesw" -o "x$ac_cv_lib_ncursesw_initscr" = xyes; the [AS_IF([test "$USE_CURSES" != check], [USE_CURSES="missing_header"]) ]) AS_IF([test $USE_CURSES="ncursesw" -a "x$CURSES_LIBS" = x], - [CURSES_LIBS="-l$USE_CURSES"]) + [CURSES_LIBS="$NCURSES_LIBS"]) + AS_IF([test $USE_CURSES="ncursesw" -a "x$CURSES_CFLAGS" = x], + [CURSES_CFLAGS="$NCURSES_CFLAGS"]) fi if test "x$CURSES_LIBS" = x; then if test "$USE_CURSES" = "ncurses" -o "$USE_CURSES" = check; then - AC_CHECK_LIB([ncurses], [initscr], [true], - [AS_IF([test "$USE_CURSES" != check], [USE_CURSES="missing_lib"])]) + PKG_CHECK_MODULES([NCURSES], [ncurses], [ac_cv_lib_ncurses_initscr=yes], [ + dnl note: dropping cached value from above if not found to trigger new check + if test "$ac_cv_prog_NCURSES_CONFIG" = "no"; then + unset NCURSES_CONFIG ac_cv_prog_NCURSES_CONFIG + fi + AC_CHECK_PROGS([NCURSES_CONFIG], [ncurses6-config ncurses5-config], [no]) + AS_IF([test "$NCURSES_CONFIG" = no], [ + AC_CHECK_LIB([ncurses], [initscr], [NCURSES_LIBS=-lncurses], + [AS_IF([test "$USE_CURSES" != check], [USE_CURSES="missing_lib"])]) + ], [ + if test "x$NCURSES_LIBS" = x; then + NCURSES_LIBS=`$NCURSES_CONFIG --libs` + fi + if test "x$NCURSES_CFLAGS" = x; then + NCURSES_CFLAGS=`$NCURSES_CONFIG --cflags` + fi + ac_cv_lib_ncurses_initscr=yes + ]) + ]) fi fi + if test "$USE_CURSES" = "ncurses" -o "x$ac_cv_lib_ncurses_initscr" = xyes; then + CPPFLAGS="$NCURSES_CFLAGS $CPPFLAGS" AC_CHECK_HEADERS([ncurses/ncurses.h ncurses/curses.h ncurses.h], [USE_CURSES="ncurses" break], [AS_IF([test "$USE_CURSES" != check], [USE_CURSES="missing_header"]) ]) AS_IF([test $USE_CURSES="ncurses" -a "x$CURSES_LIBS" = x], - [CURSES_LIBS="-l$USE_CURSES"]) + [CURSES_LIBS="$NCURSES_LIBS"]) + AS_IF([test $USE_CURSES="ncurses" -a "x$CURSES_CFLAGS" = x], + [CURSES_CFLAGS="$NCURSES_CFLAGS"]) fi if test "x$CURSES_LIBS" = x; then @@ -1406,10 +1448,12 @@ case "$USE_CURSES" in *curses*) AC_DEFINE_UNQUOTED([WITH_CURSES], ["$USE_CURSES"]) LIBCOB_LIBS="$LIBCOB_LIBS $CURSES_LIBS" + LIBCOB_CPPFLAGS="$CURSES_CFLAGS $LIBCOB_CPPFLAGS" ;; esac -LIBS="$LIBS $CURSES_LIBS" # adding found curses libraries to look for functions +LIBS="$curr_libs $LIBCOB_LIBS_extern $CURSES_LIBS" # adding found curses libraries to look for functions + if test "$USE_CURSES" = "ncurses" -o "$USE_CURSES" = "ncursesw"; then AC_MSG_CHECKING([for ncurses _nc_freeall function]) AC_LINK_IFELSE([AC_LANG_PROGRAM([[ @@ -1555,7 +1599,8 @@ if test "$USE_CURSES" != no -a "$USE_CURSES" != "not_found"; then [AC_MSG_RESULT([no])], []) fi -LIBS="$curr_libs $LIBCOB_LIBS" +LIBS="$curr_libs $LIBCOB_LIBS_extern" +CPPFLAGS="$curr_cppflags" AC_ARG_WITH([seqra-extfh], [AS_HELP_STRING([--with-seqra-extfh], @@ -2161,7 +2206,7 @@ fi if test "$COB_USES_CLANG_ONLY" = yes; then # don't warn if cobc uses arguments which aren't picked up (likely because of the translation phase) COB_CFLAGS="$COB_CFLAGS -Qunused-arguments" - + # don't warn for untyped function call - only possible if the interal repository would be enforced curr_cflags="$CFLAGS" CFLAGS="$CFLAGS -Wdeprecated-non-prototype $ERRWARN" @@ -2487,6 +2532,7 @@ AC_MSG_NOTICE([ CC ${CC}]) AC_MSG_NOTICE([ CFLAGS ${CFLAGS}]) AC_MSG_NOTICE([ LDFLAGS ${LDFLAGS}]) AC_MSG_NOTICE([ LIBCOB_LIBS ${LIBCOB_LIBS}]) +AC_MSG_NOTICE([ LIBCOB_CPPFLAGS ${LIBCOB_CPPFLAGS}]) if test "x$PROGRAMS_LIBS" != x; then AC_MSG_NOTICE([ PROGRAMS_LIBS ${PROGRAMS_LIBS}]) fi From 6a23e2ce5a8c0f37073853953be261f525614ff9 Mon Sep 17 00:00:00 2001 From: sf-mensch Date: Thu, 2 May 2024 15:36:28 +0000 Subject: [PATCH 05/12] housekeeping libcob/common.h [__MINGW32__]: drop ancient redefinition of strcasecmp and strncasecmp --- libcob/ChangeLog | 7 ++++++- libcob/common.h | 5 ----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libcob/ChangeLog b/libcob/ChangeLog index e4ae5f0d4..57927cb3d 100644 --- a/libcob/ChangeLog +++ b/libcob/ChangeLog @@ -1,4 +1,9 @@ +2024-05-02 Simon Sobisch + + * common.h [__MINGW32__]: drop ancient redefinition of + strcasecmp and strncasecmp + 2024-03-17 Fabrice Le Fessant Emilien Lemaire @@ -30,7 +35,7 @@ * fileio.c (indexed_keylen): signature change to directly take the keydesc * fileio.c [WITH_ANY_ISAM]: refactored to ease access to keydesc and keypart - * fileio.c (indexed_open) [WITH_ANY_ISAM]: refactored + * fileio.c (indexed_open) [WITH_ANY_ISAM]: refactored 2023-12-14 David Declerck diff --git a/libcob/common.h b/libcob/common.h index b49d78f89..d641f1c0e 100644 --- a/libcob/common.h +++ b/libcob/common.h @@ -360,11 +360,6 @@ only usable with COB_USE_VC2013_OR_GREATER */ #endif /* _MSC_VER */ -#ifdef __MINGW32__ /* needed by older versions */ -#define strncasecmp _strnicmp -#define strcasecmp _stricmp -#endif /* __MINGW32__ */ - #ifdef __BORLANDC__ #define strncasecmp strnicmp #define strcasecmp stricmp From 67f8f532e194db8d18365c20300c795e4fcf2c5b Mon Sep 17 00:00:00 2001 From: sf-mensch Date: Thu, 2 May 2024 20:49:07 +0000 Subject: [PATCH 06/12] follow up to [r5215] [feature-requests:#459]: support COLLATING SEQUENCE clause on SELECT / INDEXED files libcob/fileio.c (bdb_bt_compare) [WITH_DB]: cater for ABI break in BDB 12 --- libcob/ChangeLog | 1 + libcob/fileio.c | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/libcob/ChangeLog b/libcob/ChangeLog index 57927cb3d..9acf06fa6 100644 --- a/libcob/ChangeLog +++ b/libcob/ChangeLog @@ -3,6 +3,7 @@ * common.h [__MINGW32__]: drop ancient redefinition of strcasecmp and strncasecmp + * fileio.c (bdb_bt_compare) [WITH_DB]: cater for ABI break in BDB 12 2024-03-17 Fabrice Le Fessant Emilien Lemaire diff --git a/libcob/fileio.c b/libcob/fileio.c index c39b3403a..b15d1b041 100644 --- a/libcob/fileio.c +++ b/libcob/fileio.c @@ -912,7 +912,11 @@ bdb_close_index (cob_file *f, int index) } static int -bdb_bt_compare (DB *db, const DBT *k1, const DBT *k2) +bdb_bt_compare (DB *db, const DBT *k1, const DBT *k2 +#if DB_VERSION_MAJOR >= 12 /* ABI break in BDB 12...) */ + size_t *locp +#endif +) { const unsigned char *col = (unsigned char *)DBT_GET_APP_DATA(k1); /* LCOV_EXCL_START */ @@ -923,6 +927,9 @@ bdb_bt_compare (DB *db, const DBT *k1, const DBT *k2) cob_runtime_error ("bdb_bt_compare was given keys of different length"); } /* LCOV_EXCL_STOP */ +#if DB_VERSION_MAJOR >= 12 + locp = NULL; /* docs: must be set to NULL or corruption can occur ... */ +#endif return indexed_key_compare (k1->data, k2->data, k2->size, col); } From 442e6db6d430c208a42c1b25a6ccc870e5bddc12 Mon Sep 17 00:00:00 2001 From: sf-mensch Date: Fri, 3 May 2024 21:05:00 +0000 Subject: [PATCH 07/12] build and test fixes for Win32 cobc: * cobc.c (main): refactored to not need iterating via "iparams" * flag.def (cb_flag_use_constructor), cobc.c (main), cobc.h, codegen.c (codegen_internal, output_so_load_version_check): new flag -fuse-constructor to override possible use of that feature; internally disabling it for generation of libraries after first program as we only need that code once, fixing Win32 build errors and duplication warnings in other environments * flag.def: don't suppress the help of -fwinmain under Win32 tests/testsuite.src/used_binaries: * adjusted path handling * try to link against dynamic library if link without an actual object file does not work --- cobc/ChangeLog | 17 +++++- cobc/cobc.c | 86 +++++++++++++++------------- cobc/cobc.h | 5 +- cobc/codegen.c | 49 ++++++++-------- cobc/flag.def | 26 ++++++--- tests/testsuite.src/used_binaries.at | 51 ++++++++++++----- 6 files changed, 141 insertions(+), 93 deletions(-) diff --git a/cobc/ChangeLog b/cobc/ChangeLog index ebec0eb01..0222f0f21 100644 --- a/cobc/ChangeLog +++ b/cobc/ChangeLog @@ -1,4 +1,15 @@ +2024-05-03 Simon Sobisch + + * cobc.c (main): refactored to not need iterating via "iparams" + * flag.def (cb_flag_use_constructor), cobc.c (main), cobc.h, + codegen.c (codegen_internal, output_so_load_version_check): + new flag -fuse-constructor to override possible use of that feature; + internally disabling it for generation of libraries after first + program as we only need that code once, fixing Win32 build errors + and duplication warnings in other environments + * flag.def: don't suppress the help of -fwinmain under Win32 + 2024-04-24 Fabrice Le Fessant * replace.c: optimize speed and memory usage. For speed, we add two @@ -10,7 +21,7 @@ queue of tokens instead of a list. 2024-03-17 Fabrice Le Fessant - Emilien Lemaire + Emilien Lemaire * parser.y: generate calls to "cob_prof_function_call" in the parsetree when profiling is unabled, when entering/leaving @@ -35,7 +46,7 @@ 2024-01-28 Fabrice Le Fessant * parser.y: fix SEGFAULT when checking the BY VALUE arguments of a - prototype with ANY LENGTH + prototype with ANY LENGTH 2024-01-25 David Declerck @@ -10027,7 +10038,7 @@ dropping some options for now -Copyright 2001-2023 Free Software Foundation, Inc. +Copyright 2001-2024 Free Software Foundation, Inc. Copying and distribution of this file, with or without modification, are permitted provided the copyright notice and this notice are preserved. diff --git a/cobc/cobc.c b/cobc/cobc.c index d89878c7d..8a4ff3e03 100644 --- a/cobc/cobc.c +++ b/cobc/cobc.c @@ -3852,15 +3852,14 @@ process_command_line (const int argc, char **argv) case CB_FLAG_GETOPT_TTITLE: /* 6 */ /* -fttitle= : Title for listing */ { - size_t i, len; - + const size_t len = strlen (cob_optarg); + size_t i; if (cb_listing_with_title) cobc_main_free (cb_listing_with_title); cb_listing_with_title = cobc_main_strdup (cob_optarg); - len = strlen (cb_listing_with_title); - for (i=0; i<len; i++){ - if( cb_listing_with_title[i]=='_' ) - cb_listing_with_title[i]=' '; + for (i = 0; i < len; i++) { + if (cb_listing_with_title[i] == '_') + cb_listing_with_title[i] = ' '; } } break; @@ -3920,8 +3919,7 @@ process_command_line (const int argc, char **argv) if (strlen (cob_optarg) > (COB_MINI_MAX)) { cobc_err_exit (COBC_INV_PAR, "--copy"); } - CB_TEXT_LIST_ADD (cb_copy_list, - cobc_strdup (cob_optarg)); + CB_TEXT_LIST_ADD (cb_copy_list, cobc_strdup (cob_optarg)); break; case CB_FLAG_GETOPT_INCLUDE_FILE: /* 19 */ @@ -3930,8 +3928,7 @@ process_command_line (const int argc, char **argv) if (strlen (cob_optarg) > (COB_MINI_MAX)) { cobc_err_exit (COBC_INV_PAR, "--include"); } - CB_TEXT_LIST_ADD (cb_include_file_list, - cobc_strdup (cob_optarg)); + CB_TEXT_LIST_ADD (cb_include_file_list, cobc_strdup (cob_optarg)); cb_flag_c_decl_for_static_call = 0; break; @@ -4122,7 +4119,8 @@ process_command_line (const int argc, char **argv) } #if 0 /* TODO: */ - if (cb_compile_level == CB_LEVEL_PREPROCESS && output_name && strcmp (output_name, COB_DASH) != 0)) { + if (cb_compile_level == CB_LEVEL_PREPROCESS + && output_name && strcmp (output_name, COB_DASH) != 0)) { cb_depend_file = output_file; } #endif @@ -9233,7 +9231,6 @@ int main (int argc, char **argv) { struct filename *fn; - unsigned int iparams; unsigned int local_level; int status; int statuses = 0; @@ -9278,8 +9275,9 @@ main (int argc, char **argv) cb_compile_level = CB_LEVEL_MODULE; cobc_flag_module = 1; } - } else if (cb_compile_level != CB_LEVEL_PREPROCESS && - !cobc_flag_main && !cobc_flag_module && !cobc_flag_library) { + } else + if (cb_compile_level != CB_LEVEL_PREPROCESS + && !cobc_flag_main && !cobc_flag_module && !cobc_flag_library) { cobc_flag_module = 1; } } else { @@ -9302,15 +9300,13 @@ main (int argc, char **argv) { struct cb_text_list *l; - for (l = cb_copy_list; l; l=l->next){ - const char *filename; - int has_ext; + for (l = cb_copy_list; l; l = l->next) { + const size_t len = strlen (l->text) + 1; + const int has_ext = strchr (l->text, '.') != NULL; + /* note: check for COB_MINI_MAX was done when adding to cb_copy_list */ char name[COB_MINI_BUFF]; - int len = strlen (l->text); - memcpy (name, l->text, len+1); - has_ext = (strchr (name, '.') != NULL); - filename = cb_copy_find_file (name, has_ext); - if (!filename){ + memcpy (name, l->text, len); + if (cb_copy_find_file (name, has_ext) == NULL) { cobc_err_exit (_("fatal error: could not find --copy argument %s"), name); } } @@ -9380,40 +9376,48 @@ main (int argc, char **argv) } } + /* resolve runtime name from first file */ + if (cobc_flag_run) { + if (file_list->file_is_stdin + && cb_compile_level == CB_LEVEL_EXECUTABLE) { + run_name = COB_DASH_OUT; + } else { + run_name = file_basename (file_list->source, NULL); + } + run_name = cobc_main_strdup (run_name); + } + /* process all files */ status = 0; - iparams = 0; local_level = 0; for (fn = file_list; fn; fn = fn->next) { - iparams++; - if (iparams == 1 && cobc_flag_run) { - if (fn->file_is_stdin - && cb_compile_level == CB_LEVEL_EXECUTABLE) { - run_name = COB_DASH_OUT; - } else { - run_name = file_basename (fn->source, NULL); - } - run_name = cobc_main_strdup (run_name); - } - if (iparams > 1 && cb_compile_level == CB_LEVEL_EXECUTABLE) { - /* only the first source has the compile_level and main flag set */ - local_level = cb_compile_level; - cb_compile_level = CB_LEVEL_ASSEMBLE; - cobc_flag_main = 0; - } status = process_file (fn, status); statuses += status; /* take care for all intermediate files which aren't needed for linking */ clean_up_intermediates (fn, status); + + /* first source-only handling */ + if (cb_compile_level == CB_LEVEL_EXECUTABLE) { + /* only the first source has the compile_level and main flag set */ + local_level = cb_compile_level; + cb_compile_level = CB_LEVEL_ASSEMBLE; + cobc_flag_main = 0; + } else + if (cb_compile_level == CB_LEVEL_LIBRARY + && cb_flag_use_constructor == 1) { + /* we only need one check, already generated for first source */ + cb_flag_use_constructor = 2; + } } if (cobc_list_file) { - if (cb_listing_file != stdout) + if (cb_listing_file != stdout) { fclose (cb_listing_file); - else + } else { fflush (stdout); + } cb_listing_file = NULL; } diff --git a/cobc/cobc.h b/cobc/cobc.h index 7b5f30bbd..822f7381e 100644 --- a/cobc/cobc.h +++ b/cobc/cobc.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2001-2012, 2014-2022 Free Software Foundation, Inc. + Copyright (C) 2001-2012, 2014-2024 Free Software Foundation, Inc. Written by Keisuke Nishida, Roger While, Simon Sobisch, Edward Hart, Ron Norman, Dave Pitts @@ -440,7 +440,8 @@ extern int cb_flag_dump; extern int cb_unix_lf; extern int cb_flag_main; /* set if "main" requested by -x */ -extern int cobc_flag_main; /* set only until first program compiled, for general: use cb_flag_main*/ +/* set only until first program compiled, for general: use cb_flag_main */ +extern int cobc_flag_main; extern int cobc_wants_debug; extern int cb_listing_xref; extern int cobc_seen_stdin; diff --git a/cobc/codegen.c b/cobc/codegen.c index 2dd0c7520..400048926 100644 --- a/cobc/codegen.c +++ b/cobc/codegen.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2003-2023 Free Software Foundation, Inc. + Copyright (C) 2003-2024 Free Software Foundation, Inc. Written by Keisuke Nishida, Roger While, Ron Norman, Simon Sobisch, Edward Hart @@ -12635,18 +12635,17 @@ output_internal_function (struct cb_program *prog, cb_tree parameter_list) output_line ("P_initialize:"); output_newline (); - /* Check matching version */ -#if !defined (HAVE_ATTRIBUTE_CONSTRUCTOR) + /* Check matching version in program init */ + if ( (cb_flag_use_constructor == 0 /* if constructor option disabled */ #ifdef _WIN32 - if (prog->flag_main) /* otherwise we generate that in DllMain */ -#else - if (!prog->nested_level) + || prog->flag_main /* or under Win32 (where we can only use DllMain) for executables */ #endif - { + ) + /* no use in generating that for nested programs, as the outest program must be started first */ + && !prog->nested_level) { output_line ("cob_check_version (COB_SOURCE_FILE, COB_PACKAGE_VERSION, COB_PATCH_LEVEL);"); output_newline (); } -#endif /* Resolve user functions */ for (clp = func_call_cache; clp; clp = clp->next) { @@ -13906,25 +13905,28 @@ codegen_init (struct cb_program *prog, const char *translate_name) /* Check matching version via constructor attribute / DllMain */ static void output_so_load_version_check (struct cb_program *prog) { -#if defined (HAVE_ATTRIBUTE_CONSTRUCTOR) +#if defined (_WIN32) + if (prog->flag_main) { + return; + } + output_newline (); + output_line ("#include \"windows.h\""); + output_line ("BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved);"); + output_line ("BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)"); + output_block_open (); + output_line ("if (fdwReason == DLL_PROCESS_ATTACH)"); + output_line ("\tcob_check_version (COB_SOURCE_FILE, COB_PACKAGE_VERSION, COB_PATCH_LEVEL);"); + output_line ("return TRUE;"); + output_block_close (); + output_newline (); +#else + output_newline (); output_line ("static void gc_module_so_init () __attribute__ ((constructor));"); output_line ("static void gc_module_so_init ()"); output_block_open (); output_line ("cob_check_version (COB_SOURCE_FILE, COB_PACKAGE_VERSION, COB_PATCH_LEVEL);"); output_block_close (); output_newline (); -#elif defined (_WIN32) - if (!prog->flag_main) { - output_line ("#include \"windows.h\""); - output_line ("BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved);"); - output_line ("BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)"); - output_block_open (); - output_line ("if (fdwReason == DLL_PROCESS_ATTACH)"); - output_line ("\tcob_check_version (COB_SOURCE_FILE, COB_PACKAGE_VERSION, COB_PATCH_LEVEL);"); - output_line ("return TRUE;"); - output_block_close (); - output_newline (); - } #endif } @@ -13994,8 +13996,9 @@ codegen_internal (struct cb_program *prog, const int subsequent_call) if (!subsequent_call) { output ("/* Functions */"); output_newline (); - output_newline (); - output_so_load_version_check (prog); + if (cb_flag_use_constructor == 1) { + output_so_load_version_check (prog); + } } if (prog->prog_type == COB_MODULE_TYPE_FUNCTION) { diff --git a/cobc/flag.def b/cobc/flag.def index ff2a175ec..7d40570e7 100644 --- a/cobc/flag.def +++ b/cobc/flag.def @@ -1,5 +1,5 @@ /* - Copyright (C) 2003-2012, 2014-2023 Free Software Foundation, Inc. + Copyright (C) 2003-2012, 2014-2024 Free Software Foundation, Inc. Written by Keisuke Nishida, Roger While, Simon Sobisch, Ron Norman, Edward Hart @@ -28,7 +28,7 @@ /* Normal binary flags (standard: on) */ /* CB_FLAG_ON (var, help switch, name, help) */ -/* Flags with required parameter (standard: default)*/ +/* Flags with required parameter (standard: default) */ /* CB_FLAG_RQ (var, help switch, name, default, getopt return, help) */ /* Flags with required parameter and no associated variable */ @@ -107,13 +107,23 @@ CB_FLAG_NQ (1, "default-file-colseq", CB_FLAG_GETOPT_DEFAULT_FILE_COLSEQ, _(" -fdefault-file-colseq=[ASCII|EBCDIC|NATIVE]\tdefine default file collating sequence\n" " * default: NATIVE")) -/* Binary flags */ - -/* Flags with suppressed help */ - -CB_FLAG (cb_flag_winmain, 0, "winmain", +/* Binary flags, partially with suppressed help */ +#ifdef _WIN32 +#define COB_SHOW 1 +#else +#define COB_SHOW 0 +#endif +CB_FLAG (cb_flag_winmain, COB_SHOW, "winmain", _(" -fwinmain generate WinMain instead of main when compiling\n" " as executable")) +#undef COB_SHOW + +#ifdef HAVE_ATTRIBUTE_CONSTRUCTOR +CB_FLAG_ON (cb_flag_use_constructor, 1, "use-constructor", +#else +CB_FLAG (cb_flag_use_constructor, 0, "use-constructor", +#endif + _(" -fuse-constructor generate internal one-time code via constructor")) CB_FLAG (cb_flag_computed_goto, 0, "computed-goto", _(" -fcomputed-goto generate computed goto C statements")) @@ -134,8 +144,6 @@ CB_FLAG (cb_flag_stack_extended, 1, "stack-extended", CB_FLAG_ON (cb_flag_fast_compare, 0, "fast-compare", _(" -fno-fast-compare disables inline comparisions")) -/* Normal flags */ - CB_FLAG_ON (cb_flag_remove_unreachable, 1, "remove-unreachable", _(" -fno-remove-unreachable\tdisable remove of unreachable code\n" " * turned off by -g")) diff --git a/tests/testsuite.src/used_binaries.at b/tests/testsuite.src/used_binaries.at index d7266092e..421275a41 100644 --- a/tests/testsuite.src/used_binaries.at +++ b/tests/testsuite.src/used_binaries.at @@ -1073,19 +1073,22 @@ 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_CHECK([$SED -e "s|$PWD|HOME|" compiler.output], [0], -[HOME/prog.cob:7: error: CRUD.CPY: No such file or directory -HOME/prog.cob:6: warning: numeric value is expected -HOME/prog.cob:14: warning: ignoring redundant . +# note: -fdiagnostics-absolute-paths will show the realpath, +# so for MSYS/MSVC builds that will be x:\something\prog.cob +AT_CHECK([$SED -e "s|$(_return_path "$(pwd)/prog.cob")|DIR/prog.cob|" compiler.output], [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 . ]) AT_CLEANUP AT_SETUP([check include header file]) -#AT_KEYWORDS([include]) +#AT_KEYWORDS([cobc copy]) -AT_DATA([file.h], [ +AT_DATA([filec.h], [ +/* COB_EXT_IMPORT will be defined by libcob.h up-front */ COB_EXT_IMPORT void f (char *, long); ]) AT_DATA([prog.cob], [ @@ -1095,13 +1098,13 @@ AT_DATA([prog.cob], [ CALL "f" USING "Hello". ]) -# No check, program seems correct +# dynamic call - program seems correct +AT_CHECK([$COMPILE_MODULE prog.cob], [0], [], []) -AT_CHECK([$COBC -m -fstatic-call prog.cob], [0], [], []) +# mismatch in function signature - we ignore the error output, +# as it depends on the C compiler in use +AT_CHECK([$COMPILE_MODULE --include $(_return_path "$(pwd)/filec.h") -fstatic-call prog.cob], [1], [], [ignore]) -# 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. @@ -1112,9 +1115,24 @@ AT_DATA([prog2.cob], [ CALL "f" USING "Hello" BY VALUE long RETURNING NOTHING. ]) -AT_CHECK([$COBC -m --include "$PWD/file.h" -fstatic-call prog2.cob], [0], [], []) +# note: we likely need to build an import library for some environments +AT_DATA([filec.c], [ +/* for COB_EXT_EXPORT */ +#include <libcob.h> +COB_EXT_IMPORT void f (char *str, long num) {}; +]) +AT_CHECK([$COMPILE_MODULE --save-temps filec.c -o libfoo.$COB_MODULE_EXT], [0], [], []) + -AT_CHECK([$COBC -I . -m --include "file.h" -fstatic-call prog2.cob], [0], [], []) +# static build with correct function signature +AT_CHECK([$COMPILE_MODULE --include $(_return_path "$(pwd)/filec.h") -fstatic-call prog2.cob], [0], [], [], [ + # Previous test "failed" --> retry with import library + AT_CHECK([$COMPILE_MODULE --include $(_return_path "$(pwd)/filec.h") -fstatic-call -lfilec prog2.cob], [0], [], [])] +) +AT_CHECK([$COMPILE_MODULE -I . --include "filec.h" -fstatic-call prog2.cob -o prog2b], [0], [], [], [ + # Previous test "failed" --> retry with import library + AT_CHECK([$COMPILE_MODULE -I . --include "filec.h" -fstatic-call -lfilec prog2.cob -o prog2b], [0], [], [])] +) # We can use --copy to check a CALL against a prototype. However, this # feature is not fully supported by GnuCOBOL yet, so we get some @@ -1134,8 +1152,11 @@ AT_DATA([f.copy], [ END PROGRAM f. ]) -AT_CHECK([$COMPILE_MODULE -Wno-unfinished --copy "f.copy" -fstatic-call prog2.cob], [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 "f.copy" -fstatic-call -lfilec prog2.cob -o prog2c], [0], [], ignore)] +) AT_CLEANUP From 1b8af634e882db9e0a80bce46d97f24ca0eb58fb Mon Sep 17 00:00:00 2001 From: sf-mensch <sf-mensch@ed166372-6744-4ac0-a67f-bb1ae9efa102> Date: Fri, 3 May 2024 23:43:53 +0000 Subject: [PATCH 08/12] fixing [r5244] fix... libcob/fileio.c (bdb_bt_compare) [WITH_DB]: cater for ABI break in BDB 12 --- libcob/fileio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libcob/fileio.c b/libcob/fileio.c index b15d1b041..ecb13dca7 100644 --- a/libcob/fileio.c +++ b/libcob/fileio.c @@ -914,7 +914,7 @@ bdb_close_index (cob_file *f, int index) static int bdb_bt_compare (DB *db, const DBT *k1, const DBT *k2 #if DB_VERSION_MAJOR >= 12 /* ABI break in BDB 12...) */ - size_t *locp + , size_t *locp #endif ) { From a0937bf4920e68730746b89706a6edb1967184a9 Mon Sep 17 00:00:00 2001 From: sf-mensch <sf-mensch@ed166372-6744-4ac0-a67f-bb1ae9efa102> Date: Sat, 4 May 2024 00:26:13 +0000 Subject: [PATCH 09/12] fixing [bugs:#933] [bugs:#938] [bugs:#966] handling of broken expressions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit cobc/typeck.c: * use fallback error position token, fixing compiler aborts on broken expressions * minor refactoring within functions additional follow—up to [r5245] Win32 bugfixes --- cobc/ChangeLog | 7 +++-- cobc/cobc.c | 8 +++-- cobc/typeck.c | 46 +++++++++++++--------------- tests/testsuite.src/run_misc.at | 5 +-- tests/testsuite.src/syn_misc.at | 32 +++++++++++++++---- tests/testsuite.src/used_binaries.at | 2 +- 6 files changed, 63 insertions(+), 37 deletions(-) diff --git a/cobc/ChangeLog b/cobc/ChangeLog index 0222f0f21..f7a37003e 100644 --- a/cobc/ChangeLog +++ b/cobc/ChangeLog @@ -5,10 +5,13 @@ * flag.def (cb_flag_use_constructor), cobc.c (main), cobc.h, codegen.c (codegen_internal, output_so_load_version_check): new flag -fuse-constructor to override possible use of that feature; - internally disabling it for generation of libraries after first - program as we only need that code once, fixing Win32 build errors + internally disabling it for generation of libraries/executable after + first program as we only need that code once, fixing Win32 build errors and duplication warnings in other environments * flag.def: don't suppress the help of -fwinmain under Win32 + * typeck.c (build_expr_finish): use fallback error position token, fixing + compiler aborts on broken expressions, bugs #933, #938 and #966 + * typeck.c: minor refacting within functions 2024-04-24 Fabrice Le Fessant <fabrice.le_fessant@ocamlpro.com> diff --git a/cobc/cobc.c b/cobc/cobc.c index 8a4ff3e03..fa64d58b5 100644 --- a/cobc/cobc.c +++ b/cobc/cobc.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2001-2023 Free Software Foundation, Inc. + Copyright (C) 2001-2024 Free Software Foundation, Inc. Authors: Keisuke Nishida, Roger While, Ron Norman, Simon Sobisch, Brian Tiffin, @@ -2516,7 +2516,7 @@ static void cobc_print_version (void) { printf ("cobc (%s) %s.%d\n", PACKAGE_NAME, PACKAGE_VERSION, PATCH_LEVEL); - puts ("Copyright (C) 2023 Free Software Foundation, Inc."); + puts ("Copyright (C) 2024 Free Software Foundation, Inc."); printf (_("License GPLv3+: GNU GPL version 3 or later <%s>"), "https://gnu.org/licenses/gpl.html"); putchar ('\n'); puts (_("This is free software; see the source for copying conditions. There is NO\n" @@ -9404,6 +9404,10 @@ main (int argc, char **argv) local_level = cb_compile_level; cb_compile_level = CB_LEVEL_ASSEMBLE; cobc_flag_main = 0; + if (cb_flag_use_constructor == 1) { + /* we only need one check, already generated for first source */ + cb_flag_use_constructor = 2; + } } else if (cb_compile_level == CB_LEVEL_LIBRARY && cb_flag_use_constructor == 1) { diff --git a/cobc/typeck.c b/cobc/typeck.c index 7a7c5434c..2f4204146 100644 --- a/cobc/typeck.c +++ b/cobc/typeck.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2001-2023 Free Software Foundation, Inc. + Copyright (C) 2001-2024 Free Software Foundation, Inc. Written by Keisuke Nishida, Roger While, Simon Sobisch, Ron Norman, Edward Hart @@ -597,8 +597,6 @@ cb_is_compx_field (struct cb_field *f) static int cb_is_compx_expr (cb_tree x) { - struct cb_binary_op *p; - cb_tree y; if (!cb_flag_fast_math) return 0; if (current_statement @@ -607,7 +605,7 @@ cb_is_compx_expr (cb_tree x) || current_statement->handler_type != NO_HANDLER)) return 0; if (CB_REFERENCE_P (x)) { - y = cb_ref (x); + const cb_tree y = cb_ref (x); if (y == cb_error_node) { return 0; } @@ -619,7 +617,7 @@ cb_is_compx_expr (cb_tree x) return cb_is_compx_field (CB_FIELD_PTR (x)); } if (CB_BINARY_OP_P (x)) { - p = CB_BINARY_OP (x); + const struct cb_binary_op *p = CB_BINARY_OP (x); if (p->op == '+' || p->op == '-' || p->op == '*') { @@ -681,8 +679,6 @@ cb_is_compx_expr (cb_tree x) static int cb_is_integer_expr (cb_tree x) { - struct cb_binary_op *p; - cb_tree y; if (!cb_flag_fast_math) return 0; if (current_statement @@ -691,7 +687,7 @@ cb_is_integer_expr (cb_tree x) || current_statement->handler_type != NO_HANDLER)) return 0; if (CB_REFERENCE_P (x)) { - y = cb_ref (x); + cosnt cb_tree y = cb_ref (x); if (y == cb_error_node) { return 0; } @@ -709,7 +705,7 @@ cb_is_integer_expr (cb_tree x) return 0; } if (CB_BINARY_OP_P (x)) { - p = CB_BINARY_OP (x); + const struct cb_binary_op *p = CB_BINARY_OP (x); if (p->op == '+' || p->op == '-' || p->op == '*') { @@ -817,7 +813,6 @@ cb_check_needs_break (cb_tree stmt) static size_t cb_validate_one (cb_tree x) { - if (x == cb_error_node) { return 1; } @@ -877,14 +872,12 @@ cb_validate_list (cb_tree l) static cb_tree cb_check_group_name (cb_tree x) { - cb_tree y; - if (x == cb_error_node) { return cb_error_node; } if (CB_REFERENCE_P (x)) { - y = cb_ref (x); + const cb_tree y = cb_ref (x); if (y == cb_error_node) { return cb_error_node; } @@ -5842,18 +5835,24 @@ build_expr_expand (cb_tree *x) static cb_tree build_expr_finish (void) { + cb_tree pos; + struct cb_tree_common err_pos; + /* Reduce all (prio of token 0 is smaller than all other ones) */ (void)build_expr_reduce (0); - expr_stack[TOPSTACK].value->source_file = cb_source_file; - expr_stack[TOPSTACK].value->source_line = cb_exp_line; + pos = expr_stack[TOPSTACK].value; + if (!pos) pos = &err_pos; + + pos->source_file = cb_source_file; + pos->source_line = cb_exp_line; - if (expr_index != TOPSTACK+1) { - cb_error_x (expr_stack[TOPSTACK].value, _("invalid expression: unfinished expression")); + if (expr_index != TOPSTACK + 1) { + cb_error_x (pos, _("invalid expression: unfinished expression")); return cb_error_node; } - if (!expr_stack[TOPSTACK].value) { + if (pos == &err_pos) { /* TODO: Add test case for this to syn_misc.at invalid expression */ cb_error (_("invalid expression")); return cb_error_node; @@ -5862,7 +5861,7 @@ build_expr_finish (void) build_expr_expand (&expr_stack[TOPSTACK].value); if (expr_stack[TOPSTACK].token != 'x') { /* TODO: add a test case, for now, no idea how to reach this */ - cb_error_x (expr_stack[TOPSTACK].value, _("invalid expression")); + cb_error_x (pos, _("invalid expression")); return cb_error_node; } @@ -5878,8 +5877,6 @@ cb_build_expr (cb_tree list) build_expr_init (); - /* Checkme: maybe add validate_list(l) here */ - bad_cond = has_rel = has_con = has_var = 0; for (l = list; l; l = CB_CHAIN (l)) { op = CB_PURPOSE_INT (l); @@ -5928,10 +5925,10 @@ cb_build_expr (cb_tree list) has_rel = 1; break; default: - if(TOKEN (-1) == '!'){ + if (TOKEN (-1) == '!') { /* switch `NOT` relation, e.g. the two expression tokens `NOT` and `>` * are reduced to a single token `<=` */ - switch(op){ + switch (op){ case '=': TOKEN (-1) = '~'; continue; case '>': TOKEN (-1) = '['; continue; case '<': TOKEN (-1) = ']'; continue; @@ -5939,8 +5936,9 @@ cb_build_expr (cb_tree list) case '[': TOKEN (-1) = '>'; continue; } } - v = CB_VALUE (l); + v = NULL; if (op == 'x') { + v = CB_VALUE (l); if (has_var && v == cb_zero) { has_rel = 1; } diff --git a/tests/testsuite.src/run_misc.at b/tests/testsuite.src/run_misc.at index 34686150f..a5094d320 100644 --- a/tests/testsuite.src/run_misc.at +++ b/tests/testsuite.src/run_misc.at @@ -1,4 +1,4 @@ -## Copyright (C) 2003-2012, 2014-2023 Free Software Foundation, Inc. +## Copyright (C) 2003-2012, 2014-2024 Free Software Foundation, Inc. ## Written by Keisuke Nishida, Roger While, Simon Sobisch, Edward Hart, ## Ron Norman ## @@ -15010,7 +15010,8 @@ main (int argc, char **argv) { int i; - unsetenv("COB_IS_RUNNING_IN_TESTMODE"); + /* portable version from libcob */ + (void)(cob_unsetenv("COB_IS_RUNNING_IN_TESTMODE"); cob_init (argc, argv); diff --git a/tests/testsuite.src/syn_misc.at b/tests/testsuite.src/syn_misc.at index 5b9aff259..c3c7091f7 100644 --- a/tests/testsuite.src/syn_misc.at +++ b/tests/testsuite.src/syn_misc.at @@ -1,4 +1,4 @@ -## Copyright (C) 2007-2012, 2014-2023 Free Software Foundation, Inc. +## Copyright (C) 2007-2012, 2014-2024 Free Software Foundation, Inc. ## Written by Keisuke Nishida, Roger While, Simon Sobisch, Edward Hart, ## Ron Norman ## @@ -514,17 +514,32 @@ AT_DATA([prog.cob], [ CONTINUE END-PERFORM. IF NOTDEFINED = 1 OR 2 - CONTINUE - END-IF. + CONTINUE. IF (V = 1) AND V + CONTINUE. + + IF (1 = 2) *> valid + CONTINUE. + + IF 1 == 2 + CONTINUE. + + IF (1 == 2) + CONTINUE. + + IF + + CONTINUE. + + EVALUATE V + WHEN - CONTINUE - END-IF + END-EVALUATE. STOP RUN. ]) -AT_CHECK([$COMPILE_ONLY prog.cob], [1], [], +AT_CHECK([$COMPILE_ONLY -fmax-errors=0 prog.cob], [1], [], [prog.cob:10: error: incomplete expression prog.cob:14: error: incomplete expression prog.cob:18: error: incomplete expression @@ -541,7 +556,12 @@ prog.cob:60: error: incomplete expression prog.cob:66: error: incomplete expression prog.cob:72: error: incomplete expression prog.cob:76: error: 'NOTDEFINED' is not defined -prog.cob:80: error: invalid expression: boolean expected with logical operator +prog.cob:79: error: invalid expression: boolean expected with logical operator +prog.cob:82: warning: expression '1' EQUALS '2' is always FALSE +prog.cob:85: error: invalid expression: unfinished expression +prog.cob:88: error: invalid expression: unfinished expression +prog.cob:92: error: invalid expression +prog.cob:96: error: invalid expression ]) AT_CLEANUP diff --git a/tests/testsuite.src/used_binaries.at b/tests/testsuite.src/used_binaries.at index 421275a41..105c86137 100644 --- a/tests/testsuite.src/used_binaries.at +++ b/tests/testsuite.src/used_binaries.at @@ -1121,7 +1121,7 @@ AT_DATA([filec.c], [ #include <libcob.h> COB_EXT_IMPORT void f (char *str, long num) {}; ]) -AT_CHECK([$COMPILE_MODULE --save-temps filec.c -o libfoo.$COB_MODULE_EXT], [0], [], []) +AT_CHECK([$COMPILE_MODULE --save-temps filec.c -o libfilec.$COB_MODULE_EXT], [0], [], []) # static build with correct function signature From 7c60012c019be8b4f42ab9345081f6bd7ae4b1d5 Mon Sep 17 00:00:00 2001 From: sf-mensch <sf-mensch@ed166372-6744-4ac0-a67f-bb1ae9efa102> Date: Sat, 4 May 2024 00:57:42 +0000 Subject: [PATCH 10/12] fixing typo --- cobc/ChangeLog | 2 +- tests/testsuite.src/run_misc.at | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cobc/ChangeLog b/cobc/ChangeLog index f7a37003e..553792e12 100644 --- a/cobc/ChangeLog +++ b/cobc/ChangeLog @@ -11,7 +11,7 @@ * flag.def: don't suppress the help of -fwinmain under Win32 * typeck.c (build_expr_finish): use fallback error position token, fixing compiler aborts on broken expressions, bugs #933, #938 and #966 - * typeck.c: minor refacting within functions + * typeck.c: minor refactoring within functions 2024-04-24 Fabrice Le Fessant <fabrice.le_fessant@ocamlpro.com> diff --git a/tests/testsuite.src/run_misc.at b/tests/testsuite.src/run_misc.at index a5094d320..057f0ceb4 100644 --- a/tests/testsuite.src/run_misc.at +++ b/tests/testsuite.src/run_misc.at @@ -15011,7 +15011,7 @@ main (int argc, char **argv) int i; /* portable version from libcob */ - (void)(cob_unsetenv("COB_IS_RUNNING_IN_TESTMODE"); + (void)cob_unsetenv("COB_IS_RUNNING_IN_TESTMODE"); cob_init (argc, argv); From ed789c8a9bc2c66e3c314f82b47cc07c05b12f49 Mon Sep 17 00:00:00 2001 From: sf-mensch <sf-mensch@ed166372-6744-4ac0-a67f-bb1ae9efa102> Date: Sun, 5 May 2024 20:48:04 +0000 Subject: [PATCH 11/12] Win32 fixes, mostly testcases --- cobc/error.c | 12 +-- libcob/common.c | 10 +- libcob/fileio.c | 6 +- tests/atlocal.in | 6 +- tests/testsuite.src/run_extensions.at | 13 ++- tests/testsuite.src/run_file.at | 57 ++++++----- tests/testsuite.src/run_misc.at | 140 ++++++++++++++++---------- tests/testsuite.src/used_binaries.at | 13 +-- 8 files changed, 163 insertions(+), 94 deletions(-) diff --git a/cobc/error.c b/cobc/error.c index 9c971d66e..4fa9314b7 100644 --- a/cobc/error.c +++ b/cobc/error.c @@ -74,19 +74,19 @@ print_error_prefix (const char *file, int line, const char *prefix) && file[0] != '\\' && file[1] != ':'){ int filelen = strlen (file); - int dirlen = 256; - char *cwd ; - absfile = cobc_malloc( dirlen + 1 + filelen + 1 ); + int dirlen = COB_MINI_BUFF; + char *cwd; + absfile = cobc_malloc (dirlen + 1 + filelen + 1); cwd = getcwd (absfile, dirlen); if (cwd != NULL ){ #ifdef HAVE_SYS_STAT_H struct stat st; #endif dirlen = strlen (cwd); - absfile[dirlen] = '/'; - memcpy (absfile+dirlen+1, file, filelen+1); + absfile[dirlen] = SLASH_CHAR; + memcpy (absfile + dirlen + 1, file, filelen + 1); #ifdef HAVE_SYS_STAT_H - if (!stat (absfile,&st)) + if (!stat (absfile, &st)) #endif { file = absfile; diff --git a/libcob/common.c b/libcob/common.c index 6f45b7564..c3d3dc7c1 100644 --- a/libcob/common.c +++ b/libcob/common.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2001-2012, 2014-2023 Free Software Foundation, Inc. + Copyright (C) 2001-2012, 2014-2024 Free Software Foundation, Inc. Written by Keisuke Nishida, Roger While, Simon Sobisch, Ron Norman This file is part of GnuCOBOL. @@ -21,6 +21,14 @@ #include "tarstamp.h" #include "config.h" +#ifdef __MINGW32__ +/* Is this needed for other environments as well? + We want to use all POSIX extensions possible. */ +#ifndef _POSIX_C_SOURCE +#define _POSIX_C_SOURCE 200112 +#endif +#endif + #include <stdio.h> #include <stdlib.h> #include <stddef.h> diff --git a/libcob/fileio.c b/libcob/fileio.c index ecb13dca7..d4c900f88 100644 --- a/libcob/fileio.c +++ b/libcob/fileio.c @@ -913,7 +913,7 @@ bdb_close_index (cob_file *f, int index) static int bdb_bt_compare (DB *db, const DBT *k1, const DBT *k2 -#if DB_VERSION_MAJOR >= 12 /* ABI break in BDB 12...) */ +#if DB_VERSION_MAJOR >= 6 /* ABI break in DB_VERSION_FAMILY 12 ... */ , size_t *locp #endif ) @@ -927,8 +927,8 @@ bdb_bt_compare (DB *db, const DBT *k1, const DBT *k2 cob_runtime_error ("bdb_bt_compare was given keys of different length"); } /* LCOV_EXCL_STOP */ -#if DB_VERSION_MAJOR >= 12 - locp = NULL; /* docs: must be set to NULL or corruption can occur ... */ +#if DB_VERSION_MAJOR >= 6 + locp = NULL; /* docs: must be set to NULL or corruption can occur ... */ #endif return indexed_key_compare (k1->data, k2->data, k2->size, col); } diff --git a/tests/atlocal.in b/tests/atlocal.in index 62fac6a25..3d49ec140 100644 --- a/tests/atlocal.in +++ b/tests/atlocal.in @@ -197,7 +197,11 @@ _unset_option () { # that doesn't match the one where the tested binaries were built # Note: not needed for running the testsuite with MSYS as this translates the path _return_path () { - echo "$1" + if test "x$MSYSTEM" = x; then + echo "$1" + else + cmd //c echo "$1" # note: we want forward slashes here | $SED 's|/|\\|g' + fi } # ensure we don't execute windows paths within programs generated by cygwin diff --git a/tests/testsuite.src/run_extensions.at b/tests/testsuite.src/run_extensions.at index e937044f8..cfa04244e 100644 --- a/tests/testsuite.src/run_extensions.at +++ b/tests/testsuite.src/run_extensions.at @@ -1,4 +1,4 @@ -## Copyright (C) 2003-2012, 2014-2023 Free Software Foundation, Inc. +## Copyright (C) 2003-2012, 2014-2024 Free Software Foundation, Inc. ## Written by Keisuke Nishida, Roger While, Simon Sobisch, Edward Hart, ## Ron Norman ## @@ -2220,6 +2220,9 @@ AT_CHECK([$COBCRUN_DIRECT ./caller], [0], +000000004 ], []) +# same name sometimes leads to locks - especially on Win32 +AT_CHECK([mv callee.$COB_MODULE_EXT callee.old.$COB_MODULE_EXT]) + # no argument check leads to only check on use AT_CHECK([$COMPILE_MODULE -fno-ec=program-arg-mismatch callee.cob], [0], [], []) AT_CHECK([$COBCRUN_DIRECT ./caller], [0], @@ -2231,6 +2234,8 @@ AT_CHECK([$COBCRUN_DIRECT ./caller], [0], +000000004 ], []) +AT_CHECK([mv callee.$COB_MODULE_EXT callee.nocheck.$COB_MODULE_EXT]) + # sticky linkage leads to only check on use AT_CHECK([$COMPILE_MODULE -fsticky-linkage callee.cob], [0], [], []) AT_CHECK([$COBCRUN_DIRECT ./caller], [0], @@ -2242,6 +2247,8 @@ AT_CHECK([$COBCRUN_DIRECT ./caller], [0], +000000004 ], []) +AT_CHECK([mv callee.$COB_MODULE_EXT callee.stick.$COB_MODULE_EXT]) + AT_CHECK([$COMPILE_MODULE callee.cob], [0], [], []) AT_CHECK([$COBCRUN_DIRECT ./caller], [1], [], [libcob: callee.cob:12: error: LINKAGE item X not passed by caller @@ -2641,6 +2648,10 @@ AT_CHECK([$COBCRUN_DIRECT ./caller], [0], [Hello, COBOL! Bye, COBOL-ENTRY! ]) + +# same name sometimes leads to locks - especially on Win32 +AT_CHECK([mv hello.$COB_MODULE_EXT hello.old.$COB_MODULE_EXT]) + # no difference expected with sticky linkage (but other codegen) AT_CHECK([$COMPILE_MODULE -fentry-statement=ok -fsticky-linkage hello.cob], [0], [], []) AT_CHECK([$COBCRUN_DIRECT ./caller], [0], diff --git a/tests/testsuite.src/run_file.at b/tests/testsuite.src/run_file.at index ed9351e01..0dd083262 100644 --- a/tests/testsuite.src/run_file.at +++ b/tests/testsuite.src/run_file.at @@ -46,10 +46,11 @@ AT_DATA([prog.cob], [ WORKING-STORAGE SECTION. 01 WSFS PIC X(2). PROCEDURE DIVISION. - * + OUT. OPEN EXTEND FILE-OPT IF WSFS NOT = "05" - DISPLAY "STATUS EXTEND, missing optional file:" WSFS. + DISPLAY "STATUS EXTEND, missing optional file:" WSFS + IF WSFS (1:1) NOT = "0" GO TO INP. MOVE ALL "A" TO FOREC WRITE FOREC IF WSFS NOT = "00" @@ -64,19 +65,22 @@ AT_DATA([prog.cob], [ WRITE F0REC IF WSFS NOT = "00" DISPLAY "STATUS WRITE B:" WSFS. - CLOSE FILE0 + CLOSE FILE0. * + INP. OPEN INPUT FILE-OPT IF WSFS NOT = "00" - DISPLAY "STATUS INPUT:" WSFS. + DISPLAY "STATUS INPUT:" WSFS + IF WSFS (1:1) NOT = "0" GO TO EX. READ FILE-OPT NEXT IF WSFS NOT = "00" DISPLAY "STATUS READ A:" WSFS. READ FILE-OPT NEXT IF WSFS NOT = "00" DISPLAY "STATUS READ B:" WSFS. - CLOSE FILE-OPT + CLOSE FILE-OPT. * + EX. STOP RUN. ]) @@ -110,10 +114,11 @@ AT_DATA([prog.cob], [ WORKING-STORAGE SECTION. 01 WSFS PIC X(2). PROCEDURE DIVISION. - * + OUT. OPEN OUTPUT FILE-TBL IF WSFS NOT = "00" - DISPLAY "STATUS OPEN OUTPUT:" WSFS. + DISPLAY "STATUS OPEN OUTPUT:" WSFS + IF WSFS (1:1) NOT = "0" GO TO INP. MOVE ALL "A" TO FOREC WRITE FOREC IF WSFS NOT = "00" @@ -121,6 +126,7 @@ AT_DATA([prog.cob], [ CLOSE FILE-TBL WITH LOCK IF WSFS NOT = "00" DISPLAY "STATUS CLOSE WITH LOCK:" WSFS. + INP. OPEN INPUT FILE-TBL IF WSFS NOT = "38" DISPLAY "STATUS INPUT after CLOSE LOCK:" WSFS. @@ -128,14 +134,17 @@ AT_DATA([prog.cob], [ IF WSFS NOT = "42" DISPLAY "STATUS CLOSE non-opened:" WSFS. * + DEL. * Note: MicroFocus _does_ delete the file and returns status 00 here DELETE FILE FILE-TBL IF WSFS NOT = "38" DISPLAY "STATUS DELETE FILE after CLOSE LOCK:" WSFS. * + INP2. OPEN INPUT FILE0 IF WSFS NOT = "00" - DISPLAY "STATUS INPUT separate file:" WSFS. + DISPLAY "STATUS INPUT separate file:" WSFS + IF WSFS (1:1) NOT = "0" GO TO EX. READ FILE0 NEXT IF WSFS NOT = "00" DISPLAY "STATUS READ A:" WSFS. @@ -145,6 +154,7 @@ AT_DATA([prog.cob], [ IF WSFS NOT = "00" DISPLAY "STATUS CLOSE:" WSFS. * + EX. STOP RUN. ]) @@ -173,10 +183,11 @@ AT_DATA([prog.cob], [ WORKING-STORAGE SECTION. 01 WSFS PIC X(2). PROCEDURE DIVISION. - * + MAIN. OPEN OUTPUT FILE-TBL IF WSFS NOT = "00" - DISPLAY "STATUS OPEN OUTPUT:" WSFS. + DISPLAY "STATUS OPEN OUTPUT:" WSFS + IF WSFS (1:1) NOT = "0" GOBACK. MOVE ALL "A" TO FOREC WRITE FOREC IF WSFS NOT = "00" @@ -1190,7 +1201,7 @@ AT_DATA([prog.cob], [ SELECT test-file ASSIGN path ORGANIZATION LINE SEQUENTIAL. DATA DIVISION. - FILE SECTION. + FILE SECTION. FD test-file. 01 test-rec PIC X(5). LOCAL-STORAGE SECTION. @@ -1230,7 +1241,7 @@ AT_DATA([prog.cob], [ SELECT test-file ASSIGN path ORGANIZATION LINE SEQUENTIAL. DATA DIVISION. - FILE SECTION. + FILE SECTION. FD test-file. 01 test-rec PIC X(5). LOCAL-STORAGE SECTION. @@ -1267,7 +1278,7 @@ AT_DATA([prog.cob], [ SELECT test-file ASSIGN path ORGANIZATION LINE SEQUENTIAL. DATA DIVISION. - FILE SECTION. + FILE SECTION. FD test-file. 01 test-rec PIC X(5). WORKING-STORAGE SECTION. @@ -1300,7 +1311,7 @@ AT_DATA([prog2.cob], [ ORGANIZATION LINE SEQUENTIAL FILE STATUS TEST-STAT. DATA DIVISION. - FILE SECTION. + FILE SECTION. FD test-file. 01 test-rec PIC X(5). WORKING-STORAGE SECTION. @@ -1521,7 +1532,7 @@ AT_DATA([prog.cob], [ SELECT test-file ASSIGN path ORGANIZATION LINE SEQUENTIAL. DATA DIVISION. - FILE SECTION. + FILE SECTION. FD test-file. 01 test-rec PIC X(5). WORKING-STORAGE SECTION. @@ -1561,7 +1572,7 @@ AT_DATA([prog.cob], [ SELECT test-file ASSIGN fpath ORGANIZATION LINE SEQUENTIAL. DATA DIVISION. - FILE SECTION. + FILE SECTION. FD test-file. 01 test-rec PIC X(5). PROCEDURE DIVISION. @@ -2343,7 +2354,7 @@ AT_DATA([prog.cob], [ record is varying in size from 107 to 362 characters depending on end-tbw-record - . + . 01 tbw-record. 02 tbw-key pic x(100). 02 tbw-alt. @@ -14383,8 +14394,8 @@ AT_DATA([prog1.cob], [ FD FILE2. 01 FS-FILE2 PIC X(10). WORKING-STORAGE SECTION. - 01 STAT-FILE1 PIC XX. - 01 STAT-FILE2 PIC XX. + 01 STAT-FILE1 PIC XX. + 01 STAT-FILE2 PIC XX. PROCEDURE DIVISION. DECLARATIVES. F-FILE1 SECTION. USE AFTER ERROR PROCEDURE ON FILE1. @@ -14401,7 +14412,7 @@ AT_DATA([prog1.cob], [ PROGRAMME SECTION. MAIN. OPEN INPUT FILE1 - OPEN INPUT FILE2. + OPEN INPUT FILE2. DISPLAY "READ FILE1". READ FILE1. DISPLAY "READ FILE2". @@ -14431,8 +14442,8 @@ AT_DATA([prog2.cob], [ FD FILE2. 01 FS-FILE2 PIC X(10). WORKING-STORAGE SECTION. - 01 STAT-FILE1 PIC XX. - 01 STAT-FILE2 PIC XX. + 01 STAT-FILE1 PIC XX. + 01 STAT-FILE2 PIC XX. PROCEDURE DIVISION. DECLARATIVES. F-FILE1 SECTION. USE AFTER ERROR PROCEDURE ON FILE1. @@ -14449,7 +14460,7 @@ AT_DATA([prog2.cob], [ PROGRAMME SECTION. MAIN. OPEN INPUT FILE1 - FILE2. + FILE2. DISPLAY "READ FILE1". READ FILE1. DISPLAY "READ FILE2". diff --git a/tests/testsuite.src/run_misc.at b/tests/testsuite.src/run_misc.at index 057f0ceb4..a1c8da6dc 100644 --- a/tests/testsuite.src/run_misc.at +++ b/tests/testsuite.src/run_misc.at @@ -394,10 +394,14 @@ AT_DATA([caller.cob], [ AT_CHECK([$COMPILE_MODULE callee.cob], [0], [], []) AT_CHECK([$COMPILE -o prog caller.cob], [0], [], []) AT_CHECK([$COBCRUN_DIRECT ./prog], [0], [ 1212 2312 3412], []) + +# same name sometimes leads to locks - especially on Win32 +AT_CHECK([mv callee.$COB_MODULE_EXT callee.def.$COB_MODULE_EXT]) AT_CHECK([$COMPILE_MODULE -fdefaultbyte=0 callee.cob], [0], [], []) AT_CHECK([$COBCRUN_DIRECT ./prog], [0], [ 1111 2211 3311], []) # note: this is the tested MF result (INDEXED BY are USAGE COMP 9(08), 0-based !): +#AT_CHECK([mv callee.$COB_MODULE_EXT callee.zero.$COB_MODULE_EXT]) #AT_CHECK([$COMPILE_MODULE -std=mf-strict callee.cob], [0], [], []) #AT_CHECK([$COBCRUN_DIRECT ./prog], [0], [ 1018 2117 3216], []) @@ -422,6 +426,7 @@ AT_DATA([callee.cob], [ ]) +AT_CHECK([mv callee.$COB_MODULE_EXT callee.old.$COB_MODULE_EXT]) AT_CHECK([$COMPILE_MODULE -std=acu-strict callee.cob], [0], [], []) AT_CHECK([$COBCRUN_DIRECT ./prog], [0], [ 19 20 31], []) # note: tested result with 2 byte: AT_CHECK([$COBCRUN_DIRECT ./prog], [0], [ 15 26 37], []) @@ -7934,13 +7939,21 @@ Program-Id: caller Statement: AT END Line: 64 Program-Id: caller Statement: STOP RUN Line: 66 ]) +# same name sometimes leads to locks - especially on Win32 +AT_CHECK([mv callee1.$COB_MODULE_EXT callee1.old.$COB_MODULE_EXT]) +AT_CHECK([mv callee2.$COB_MODULE_EXT callee2.old.$COB_MODULE_EXT]) +AT_CHECK([mv preload.$COB_MODULE_EXT preload.old.$COB_MODULE_EXT]) +AT_CHECK([mv preload2.$COB_MODULE_EXT preload2.old.$COB_MODULE_EXT]) +AT_CHECK([mv callee2c.$COB_MODULE_EXT callee2c.old.$COB_MODULE_EXT]) + + AT_CHECK([$COBC -ftraceall callee1.cob], [0], [], []) AT_CHECK([$COBC callee2.cob], [0], [], []) AT_CHECK([$COBC -ftrace -w preload.cob], [0], [], []) AT_CHECK([$COBC -ftraceall preload2.cob], [0], [], []) AT_CHECK([$COBC -fsource-location -w callee2c.cob], [0], [], []) -AT_CHECK([$COBC -x -o prog -ftraceall caller.cob], [0], [], []) -AT_CHECK([COB_PHYSICAL_CANCEL=1 COB_PRE_LOAD="preload"$PATHSEP"preload2" $COBCRUN_DIRECT ./prog], [0], [], +AT_CHECK([$COBC -x -o prognew -ftraceall caller.cob], [0], [], []) +AT_CHECK([COB_PHYSICAL_CANCEL=1 COB_PRE_LOAD="preload"$PATHSEP"preload2" $COBCRUN_DIRECT ./prognew], [0], [], [Source: 'caller.cob' Program-Id: caller Program-Id: caller MOVE Line: 15 @@ -14657,7 +14670,6 @@ AT_DATA([prog.cob], [ PARA-0007. STOP RUN. ]) -AT_CAPTURE_FILE([prof-prog.csv]) AT_CHECK([$COMPILE prog.cob], [0], [], [prog.cob: in section '1ST': @@ -14665,6 +14677,8 @@ prog.cob: in paragraph 'PARA-0003': prog.cob:11: warning: GO TO SECTION '2ND' ]) +AT_CAPTURE_FILE([prof-prog.csv]) + AT_CHECK([COB_PROF_ENABLE=1 COB_PROF_FILE='prof-$b.csv' $COBCRUN_DIRECT ./prog], [0], [], []) AT_CHECK([$COMPILE -fprof prog.cob], [0], [], @@ -14677,7 +14691,7 @@ AT_CHECK([COB_PROF_ENABLE=0 COB_PROF_FILE='prof-$b.csv' $COBCRUN_DIRECT ./prog], # Specific test for $f, which is an absolute file name AT_CHECK([COB_PROF_ENABLE=1 COB_PROF_FILE='$f-prof.csv' $COBCRUN_DIRECT ./prog], [0], [], [ignore]) -AT_CHECK([ls prog-prof.csv], [0], [ignore], []) +AT_CHECK([ls prog$COB_EXE_EXT-prof.csv], [0], [ignore], []) AT_CHECK([COB_PROF_ENABLE=1 COB_PROF_FILE='prof-$$-$b.csv' COB_PROF_FORMAT=%i,%m,%s,%p,%e,%f,%l,%w,%k,%t,%h,%n,%x $COBCRUN_DIRECT ./prog], [0], [], [File prof-123456-prog.csv generated @@ -14714,10 +14728,10 @@ AT_DATA([prog.cob], [ DISPLAY "HELLO". DISPLAY "WORLD". ]) -AT_CAPTURE_FILE([prof.csv]) AT_CHECK([$COMPILE -fprof prog.cob]) +AT_CAPTURE_FILE([prof.csv]) AT_CHECK([COB_PROF_ENABLE=1 COB_PROF_FILE=prof.csv $COBCRUN_DIRECT ./prog], [0], [HELLO WORLD ], @@ -14746,10 +14760,10 @@ AT_DATA([prog.cob], [ 2ND. DISPLAY "WORLD". ]) -AT_CAPTURE_FILE([prof.csv]) AT_CHECK([$COMPILE -fprof prog.cob]) +AT_CAPTURE_FILE([prof.csv]) AT_CHECK([COB_PROF_ENABLE=1 COB_PROF_FILE=prof.csv $COBCRUN_DIRECT ./prog], [0], [HELLO WORLD ], @@ -14824,10 +14838,10 @@ AT_DATA([prog.cob], [ END PROGRAM inside-program. END PROGRAM prog. ]) -AT_CAPTURE_FILE([prof.csv]) AT_CHECK([$COMPILE -fprof prog.cob]) +AT_CAPTURE_FILE([prof.csv]) AT_CHECK([COB_PROF_ENABLE=1 COB_PROF_FILE=prof.csv $COBCRUN_DIRECT ./prog], [0], [HELLO WORLD end iter @@ -14866,16 +14880,18 @@ AT_DATA([prog1.cob], [ 01 PARAM PIC 9. 01 CALL-NAME PIC X(10). PROCEDURE DIVISION. - MOVE 'prog2' TO CALL-NAME. - PERFORM CALL-PROG2 - VARYING COUNTER FROM 0 BY 1 - UNTIL COUNTER = 300. - GOBACK. + *>PROG. test the non-standard "no main paragraph, but + *> later using one" for its expected profiling output + MOVE 'prog2' TO CALL-NAME. + PERFORM CALL-PROG2 + VARYING COUNTER FROM 0 BY 1 + UNTIL COUNTER = 300. + GOBACK. CALL-PROG2. - MOVE 1 TO PARAM. - CALL "prog2" USING PARAM. - MOVE 2 TO PARAM. - CALL CALL-NAME USING PARAM. + MOVE 1 TO PARAM. + CALL "prog2" USING PARAM. + MOVE 2 TO PARAM. + CALL CALL-NAME USING PARAM. END PROGRAM prog1. ]) AT_DATA([prog2.cob], [ @@ -14886,21 +14902,20 @@ AT_DATA([prog2.cob], [ 01 PARAM PIC 9. PROCEDURE DIVISION USING PARAM. DISPLAYER SECTION. - IF PARAM = 1 - DISPLAY "X" NO ADVANCING - ELSE - PERFORM OTHER-DISPLAY. - GOBACK. + IF PARAM = 1 + DISPLAY "X" NO ADVANCING + ELSE + PERFORM OTHER-DISPLAY. + GOBACK. OTHER-DISPLAY SECTION. - DISPLAY "Y" NO ADVANCING. + DISPLAY "Y" NO ADVANCING. END PROGRAM prog2. ]) -AT_CAPTURE_FILE([prof.csv]) AT_CHECK([$COMPILE -fprof prog1.cob]) - AT_CHECK([$COMPILE_MODULE prog2.cob]) +AT_CAPTURE_FILE([prof.csv]) AT_CHECK([COB_PROF_ENABLE=1 COB_PROF_FILE=prof.csv $COBCRUN_DIRECT ./prog1], [0], [XYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXY], [File prof.csv generated @@ -14909,13 +14924,15 @@ AT_CHECK([COB_PROF_ENABLE=1 COB_PROF_FILE=prof.csv $COBCRUN_DIRECT ./prog1], [0] AT_CHECK([cat prof.csv], [0], [program-id,section,paragraph,entry,location,kind,time-ns,time,ncalls prog1,,,,prog1.cob:9,PROGRAM,1803000000,1.803 s,1 -prog1,MAIN SECTION,,,prog1.cob:10,SECTION,3301000000,3.301 s,1 -prog1,MAIN SECTION,MAIN PARAGRAPH,,prog1.cob:10,PARAGRAPH,1801000000,1.801 s,1 -prog1,MAIN SECTION,CALL-PROG2,,prog1.cob:15,PARAGRAPH,1500000000,1.500 s,300 -prog1,MAIN SECTION,CALL-PROG2,prog2,prog1.cob:17,CALL,300000000,0.300 s,300 -prog1,MAIN SECTION,CALL-PROG2,(dynamic),prog1.cob:19,CALL,300000000,0.300 s,300 +prog1,MAIN SECTION,,,prog1.cob:12,SECTION,3301000000,3.301 s,1 +prog1,MAIN SECTION,MAIN PARAGRAPH,,prog1.cob:12,PARAGRAPH,1801000000,1.801 s,1 +prog1,MAIN SECTION,CALL-PROG2,,prog1.cob:17,PARAGRAPH,1500000000,1.500 s,300 +prog1,MAIN SECTION,CALL-PROG2,prog2,prog1.cob:19,CALL,300000000,0.300 s,300 +prog1,MAIN SECTION,CALL-PROG2,(dynamic),prog1.cob:21,CALL,300000000,0.300 s,300 ]) +# same name sometimes leads to locks - especially on Win32 +AT_CHECK([mv prog2.$COB_MODULE_EXT prog2.old.$COB_MODULE_EXT]) AT_CHECK([$COMPILE_MODULE -fprof prog2.cob]) AT_CHECK([COB_PROF_ENABLE=1 COB_PROF_FILE=prof.csv $COBCRUN_DIRECT ./prog1], [0], @@ -14931,11 +14948,11 @@ prog2,DISPLAYER,MAIN PARAGRAPH,,prog2.cob:8,PARAGRAPH,1200000000,1.200 s,600 prog2,OTHER-DISPLAY,,,prog2.cob:14,SECTION,300000000,0.300 s,300 prog2,OTHER-DISPLAY,MAIN PARAGRAPH,,prog2.cob:14,PARAGRAPH,300000000,0.300 s,300 prog1,,,,prog1.cob:9,PROGRAM,4803000000,4.803 s,1 -prog1,MAIN SECTION,,,prog1.cob:10,SECTION,9301000000,9.301 s,1 -prog1,MAIN SECTION,MAIN PARAGRAPH,,prog1.cob:10,PARAGRAPH,4801000000,4.801 s,1 -prog1,MAIN SECTION,CALL-PROG2,,prog1.cob:15,PARAGRAPH,4500000000,4.500 s,300 -prog1,MAIN SECTION,CALL-PROG2,prog2,prog1.cob:17,CALL,1500000000,1.500 s,300 -prog1,MAIN SECTION,CALL-PROG2,(dynamic),prog1.cob:19,CALL,2100000000,2.100 s,300 +prog1,MAIN SECTION,,,prog1.cob:12,SECTION,9301000000,9.301 s,1 +prog1,MAIN SECTION,MAIN PARAGRAPH,,prog1.cob:12,PARAGRAPH,4801000000,4.801 s,1 +prog1,MAIN SECTION,CALL-PROG2,,prog1.cob:17,PARAGRAPH,4500000000,4.500 s,300 +prog1,MAIN SECTION,CALL-PROG2,prog2,prog1.cob:19,CALL,1500000000,1.500 s,300 +prog1,MAIN SECTION,CALL-PROG2,(dynamic),prog1.cob:21,CALL,2100000000,2.100 s,300 ]) AT_CLEANUP @@ -14948,39 +14965,54 @@ AT_DATA([prog1.cob], [ IDENTIFICATION DIVISION. PROGRAM-ID. prog1. DATA DIVISION. + working-storage section. + 1 os-check pic x(7). + 88 os-is-windows-or-dos values 'WINDOWS' 'FREEDOS'. + 78 callee value "./prog2". + 78 callee-wdos value ".\prog2". PROCEDURE DIVISION. - CALL "SYSTEM" USING "./prog2" - GOBACK. + accept os-check from environment "COB_ON_CYGWIN". + if os-check = spaces + accept os-check from environment "OS". + if os-check = spaces + accept os-check from environment "OS_NAME". + inspect os-check converting "werfdosin" to "WERFDOSIN". + if os-is-windows-or-dos + call "SYSTEM" using callee-wdos + else + call "SYSTEM" using callee. + GOBACK. ]) AT_DATA([prog2.cob], [ IDENTIFICATION DIVISION. PROGRAM-ID. prog2. PROCEDURE DIVISION. MAIN. - SET ENVIRONMENT "COB_PROF_FILE" TO "prof2.csv" - PERFORM PARA 5 TIMES. - GOBACK. + SET ENVIRONMENT "COB_PROF_FILE" TO "prof2.csv" + PERFORM PARA 5 TIMES. + GOBACK. PARA. - CONTINUE. + CONTINUE. ]) -AT_CAPTURE_FILE([prof1.csv]) -AT_CAPTURE_FILE([prof2.csv]) - AT_CHECK([$COMPILE_MODULE -fprof prog1.cob]) AT_CHECK([$COMPILE -fprof prog2.cob]) -AT_CHECK([COB_PROF_ENABLE=1 COB_PROF_FILE=prof1.csv $COBCRUN ./prog1], [0], [], +AT_CAPTURE_FILE([prof1.csv]) +AT_CAPTURE_FILE([prof2.csv]) + +AT_CHECK([COB_PROF_ENABLE=1 COB_PROF_FILE=prof1.csv $COBCRUN prog1], [0], [], [File prof2.csv generated File prof1.csv generated ]) AT_CHECK([cat prof1.csv], [0], [program-id,section,paragraph,entry,location,kind,time-ns,time,ncalls -prog1,,,,prog1.cob:5,PROGRAM,5000000,0.005 s,1 -prog1,MAIN SECTION,,,prog1.cob:6,SECTION,3000000,0.003 s,1 -prog1,MAIN SECTION,MAIN PARAGRAPH,,prog1.cob:6,PARAGRAPH,3000000,0.003 s,1 -prog1,MAIN SECTION,MAIN PARAGRAPH,SYSTEM,prog1.cob:6,CALL,1000000,0.001 s,1 +prog1,,,,prog1.cob:10,PROGRAM,5000000,0.005 s,1 +prog1,MAIN SECTION,,,prog1.cob:11,SECTION,3000000,0.003 s,1 +prog1,MAIN SECTION,MAIN PARAGRAPH,,prog1.cob:11,PARAGRAPH,3000000,0.003 s,1 +prog1,MAIN SECTION,MAIN PARAGRAPH,SYSTEM,prog1.cob:18,CALL,1000000,0.001 s,1 +prog1,MAIN SECTION,MAIN PARAGRAPH,SYSTEM,prog1.cob:20,CALL,0,0.000 s,0 ]) AT_CHECK([cat prof2.csv], [0], @@ -15030,16 +15062,18 @@ AT_DATA([callee.cob], [ PROGRAM-ID. callee. PROCEDURE DIVISION. MAIN. - PERFORM PARA 5 TIMES. - GOBACK. + PERFORM PARA 5 TIMES. + GOBACK. PARA. - CONTINUE. + CONTINUE. ]) -AT_CAPTURE_FILE([prof.csv]) AT_CHECK([$COMPILE caller.c]) AT_CHECK([$COMPILE_MODULE -fprof callee.cob]) -AT_CHECK([COB_PROF_ENABLE=1 COB_PROF_FILE=prof.csv $COBCRUN_DIRECT ./caller], [0], [], [File prof.csv generated + +AT_CAPTURE_FILE([prof.csv]) +AT_CHECK([COB_PROF_ENABLE=1 COB_PROF_FILE=prof.csv $COBCRUN_DIRECT ./caller], [0], [], +[File prof.csv generated ]) AT_CLEANUP diff --git a/tests/testsuite.src/used_binaries.at b/tests/testsuite.src/used_binaries.at index 105c86137..118c45b85 100644 --- a/tests/testsuite.src/used_binaries.at +++ b/tests/testsuite.src/used_binaries.at @@ -1074,12 +1074,13 @@ AT_CHECK([$COBC -fdiagnostics-plain-output -fdiagnostics-show-caret -Wno-others AT_CHECK([$COMPILE -fdiagnostics-absolute-paths -Wall prog.cob 2> compiler.output], [1]) # note: -fdiagnostics-absolute-paths will show the realpath, -# so for MSYS/MSVC builds that will be x:\something\prog.cob -AT_CHECK([$SED -e "s|$(_return_path "$(pwd)/prog.cob")|DIR/prog.cob|" compiler.output], [0], +# 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 @@ -1127,11 +1128,11 @@ AT_CHECK([$COMPILE_MODULE --save-temps filec.c -o libfilec.$COB_MODULE_EXT], [0] # static build with correct function signature AT_CHECK([$COMPILE_MODULE --include $(_return_path "$(pwd)/filec.h") -fstatic-call prog2.cob], [0], [], [], [ # Previous test "failed" --> retry with import library - AT_CHECK([$COMPILE_MODULE --include $(_return_path "$(pwd)/filec.h") -fstatic-call -lfilec prog2.cob], [0], [], [])] + AT_CHECK([$COMPILE_MODULE --include $(_return_path "$(pwd)/filec.h") -fstatic-call -L. -lfilec prog2.cob], [0], ignore, ignore)] ) AT_CHECK([$COMPILE_MODULE -I . --include "filec.h" -fstatic-call prog2.cob -o prog2b], [0], [], [], [ # Previous test "failed" --> retry with import library - AT_CHECK([$COMPILE_MODULE -I . --include "filec.h" -fstatic-call -lfilec prog2.cob -o prog2b], [0], [], [])] + AT_CHECK([$COMPILE_MODULE -I . --include "filec.h" -fstatic-call -L. -lfilec prog2.cob -o prog2b], [0], ignore, ignore)] ) # We can use --copy to check a CALL against a prototype. However, this @@ -1156,7 +1157,7 @@ AT_CHECK([$COMPILE_MODULE -Wno-unfinished --copy "f.copy" -fstatic-call prog2.co [prog2.cob:8: warning: unexpected RETURNING item ], [ # Previous test "failed" --> retry with import library - AT_CHECK([$COMPILE_MODULE -Wno-unfinished --copy "f.copy" -fstatic-call -lfilec prog2.cob -o prog2c], [0], [], ignore)] + AT_CHECK([$COMPILE_MODULE -Wno-unfinished --copy "f.copy" -fstatic-call -L. -lfilec prog2.cob -o prog2c], [0], ignore, ignore)] ) AT_CLEANUP From 1daa3931493ba29cd649cd3ece9ea3621b3226a1 Mon Sep 17 00:00:00 2001 From: sf-mensch <sf-mensch@ed166372-6744-4ac0-a67f-bb1ae9efa102> Date: Mon, 6 May 2024 07:02:11 +0000 Subject: [PATCH 12/12] portability fix for [r5249] additional: adjusted indent in testsuite for improved COBOL85 compat --- tests/testsuite.src/run_file.at | 160 ++++++++++++++++---------------- tests/testsuite.src/run_misc.at | 18 ++-- 2 files changed, 89 insertions(+), 89 deletions(-) diff --git a/tests/testsuite.src/run_file.at b/tests/testsuite.src/run_file.at index 0dd083262..38e8963fd 100644 --- a/tests/testsuite.src/run_file.at +++ b/tests/testsuite.src/run_file.at @@ -4291,13 +4291,13 @@ fexists_signed (char *fid, char *signature, int signature_size) f = fopen (fid, "r"); if (f != NULL) { - bfr = (char *) cob_malloc (signature_size); - if (1 == fread (bfr, signature_size, 1, f)) { + bfr = (char *) cob_malloc (signature_size); + if (1 == fread (bfr, signature_size, 1, f)) { if (!memcmp (signature, bfr, signature_size)) { - res = 0; + res = 0; } - } - free (bfr); + } + free (bfr); } return res; } @@ -13787,7 +13787,7 @@ AT_DATA([prog.cob], [ ASCENDING sort-entry USING SORT-IN GIVING SORT-IN. - STOP RUN. + STOP RUN. ]) AT_CHECK([$COMPILE prog.cob], [0], [], []) @@ -13990,11 +13990,11 @@ AT_DATA([prog.cob], [ 2 file4-key2 pic 9. 2 filler pic x(10). PROCEDURE DIVISION. - MERGE file4 ON ASCENDING file4-key1 + MERGE file4 ON ASCENDING file4-key1 DESCENDING file4-key2 USING file1 file2 GIVING file3. - STOP RUN. + STOP RUN. ]) AT_CHECK([$COMPILE prog.cob], [0], [], []) @@ -14050,7 +14050,7 @@ AT_DATA([prog.cob], [ ASCENDING KEY WRK-REC USING SORT-IN GIVING SORT-OUT. - STOP RUN. + STOP RUN. ]) AT_CHECK([$COMPILE prog.cob], [0], [], []) @@ -14111,37 +14111,37 @@ AT_DATA([prog.cob], [ 3 1-data pic x(10). PROCEDURE DIVISION. a01-main. - SORT file1 ON ASCENDING file1-key - INPUT PROCEDURE a02-release-to-sort - OUTPUT PROCEDURE a03-return-from-sort. - STOP RUN. + SORT file1 ON ASCENDING file1-key + INPUT PROCEDURE a02-release-to-sort + OUTPUT PROCEDURE a03-return-from-sort. + STOP RUN. * a02-release-to-sort. - PERFORM VARYING ix-1 FROM 1 BY 2 UNTIL ix-1 > 26 - RELEASE file1-rec from 1-record(ix-1) - END-PERFORM. - PERFORM VARYING ix-1 FROM 2 BY 2 UNTIL ix-1 > 26 - RELEASE file1-rec from 1-record(ix-1) - END-PERFORM. + PERFORM VARYING ix-1 FROM 1 BY 2 UNTIL ix-1 > 26 + RELEASE file1-rec from 1-record(ix-1) + END-PERFORM. + PERFORM VARYING ix-1 FROM 2 BY 2 UNTIL ix-1 > 26 + RELEASE file1-rec from 1-record(ix-1) + END-PERFORM. * a03-return-from-sort. - PERFORM VARYING ix-1 FROM 1 BY 1 - UNTIL (ix-1 > 26) OR (w-eof = 1) - RETURN file1 RECORD - AT END MOVE 1 TO w-eof - END-RETURN - IF (file1-rec <> 1-record(ix-1)) - MOVE 1 TO w-eof - END-IF - END-PERFORM. - IF (w-eof = 1) - DISPLAY "FAILED: unexpected eof" - ELSE - RETURN file1 RECORD - AT END CONTINUE - NOT AT END DISPLAY "FAILED: expected eof" - END-RETURN - END-IF. + PERFORM VARYING ix-1 FROM 1 BY 1 + UNTIL (ix-1 > 26) OR (w-eof = 1) + RETURN file1 RECORD + AT END MOVE 1 TO w-eof + END-RETURN + IF (file1-rec <> 1-record(ix-1)) + MOVE 1 TO w-eof + END-IF + END-PERFORM. + IF (w-eof = 1) + DISPLAY "FAILED: unexpected eof" + ELSE + RETURN file1 RECORD + AT END CONTINUE + NOT AT END DISPLAY "FAILED: expected eof" + END-RETURN + END-IF. ]) AT_CHECK([$COMPILE prog.cob], [0], [], []) @@ -14189,11 +14189,11 @@ AT_DATA([prog.cob], [ 2 file3-key2 pic 9. 2 file3-dot pic x. PROCEDURE DIVISION. - SORT file3 ON ASCENDING file3-key1 - DESCENDING file3-key2 - USING file1 - GIVING file2. - STOP RUN. + SORT file3 ON ASCENDING file3-key1 + DESCENDING file3-key2 + USING file1 + GIVING file2. + STOP RUN. ]) AT_CHECK([$COMPILE prog.cob], [0], [], []) @@ -14242,38 +14242,38 @@ AT_DATA([prog.cob], [ PROCEDURE DIVISION. DECLARATIVES. P01 SECTION. - USE AFTER ERROR PROCEDURE ON FILE-EXT. + USE AFTER ERROR PROCEDURE ON FILE-EXT. P0101. - DISPLAY "ERROR ON FILE-EXT". + DISPLAY "ERROR ON FILE-EXT". P02 SECTION. - USE AFTER ERROR PROCEDURE ON OUTPUT. + USE AFTER ERROR PROCEDURE ON OUTPUT. P0201. - DISPLAY "ERROR ON OUTPUT". + DISPLAY "ERROR ON OUTPUT". END DECLARATIVES. MAIN SECTION. - OPEN OUTPUT FILE-EXT. - CALL "NESTED-PROGRAM-1-1". + OPEN OUTPUT FILE-EXT. + CALL "NESTED-PROGRAM-1-1". * The next line triggers a SILENT error in NESTED-PROGRAM-1-2 - CLOSE FILE-EXT. - CALL "NESTED-PROGRAM-1-2". - GOBACK. + CLOSE FILE-EXT. + CALL "NESTED-PROGRAM-1-2". + GOBACK. IDENTIFICATION DIVISION. PROGRAM-ID. NESTED-PROGRAM-1-1. PROCEDURE DIVISION. NESTED-PROGRAM . - WRITE FILE-EXT-REC FROM "Hello". - DISPLAY "1-1 TRIED TO WRITE". - GOBACK. + WRITE FILE-EXT-REC FROM "Hello". + DISPLAY "1-1 TRIED TO WRITE". + GOBACK. END PROGRAM NESTED-PROGRAM-1-1. IDENTIFICATION DIVISION. PROGRAM-ID. NESTED-PROGRAM-1-2. PROCEDURE DIVISION. NESTED-PROGRAM . - WRITE FILE-EXT-REC FROM "Hello". - DISPLAY "1-2 TRIED TO WRITE". - GOBACK. + WRITE FILE-EXT-REC FROM "Hello". + DISPLAY "1-2 TRIED TO WRITE". + GOBACK. END PROGRAM NESTED-PROGRAM-1-2. END PROGRAM NESTED-PROGRAM-1. @@ -14294,9 +14294,9 @@ AT_DATA([prog2.cob], [ IDENTIFICATION DIVISION. PROGRAM-ID. NESTED-FILES. PROCEDURE DIVISION. - CALL "NESTED-PROGRAM-1". - CALL "NESTED-PROGRAM-2". - STOP RUN. + CALL "NESTED-PROGRAM-1". + CALL "NESTED-PROGRAM-2". + STOP RUN. IDENTIFICATION DIVISION. PROGRAM-ID. NESTED-PROGRAM-1. @@ -14314,42 +14314,42 @@ AT_DATA([prog2.cob], [ DECLARATIVES. P01 SECTION. * This one is GLOBAL and should be called from within nested programs - USE GLOBAL AFTER ERROR PROCEDURE ON FILE-EXT. + USE GLOBAL AFTER ERROR PROCEDURE ON FILE-EXT. P0101. - DISPLAY "ERROR ON FILE-EXT". + DISPLAY "ERROR ON FILE-EXT". P02 SECTION. - USE AFTER ERROR PROCEDURE ON OUTPUT. + USE AFTER ERROR PROCEDURE ON OUTPUT. P0201. - DISPLAY "ERROR ON OUTPUT". + DISPLAY "ERROR ON OUTPUT". END DECLARATIVES. MAIN SECTION. - OPEN OUTPUT FILE-EXT. - CALL "NESTED-PROGRAM-1-1". - DISPLAY "CLOSING FILE DESCRIPTOR". - CLOSE FILE-EXT. - CALL "NESTED-PROGRAM-1-2". - GOBACK. + OPEN OUTPUT FILE-EXT. + CALL "NESTED-PROGRAM-1-1". + DISPLAY "CLOSING FILE DESCRIPTOR". + CLOSE FILE-EXT. + CALL "NESTED-PROGRAM-1-2". + GOBACK. IDENTIFICATION DIVISION. PROGRAM-ID. NESTED-PROGRAM-1-1. PROCEDURE DIVISION. NESTED-PROGRAM . - DISPLAY "ENTERING NESTED-PROGRAM-1-1". - DISPLAY "TRYING TO WRITE". - WRITE FILE-EXT-REC FROM "Hello". - DISPLAY "EXITING NESTED-PROGRAM-1-1". - GOBACK. + DISPLAY "ENTERING NESTED-PROGRAM-1-1". + DISPLAY "TRYING TO WRITE". + WRITE FILE-EXT-REC FROM "Hello". + DISPLAY "EXITING NESTED-PROGRAM-1-1". + GOBACK. END PROGRAM NESTED-PROGRAM-1-1. IDENTIFICATION DIVISION. PROGRAM-ID. NESTED-PROGRAM-1-2. PROCEDURE DIVISION. NESTED-PROGRAM . - DISPLAY "ENTERING NESTED-PROGRAM-1-2". - DISPLAY "TRYING TO WRITE". - WRITE FILE-EXT-REC FROM "Hello". - DISPLAY "EXITING NESTED-PROGRAM-1-2". - GOBACK. + DISPLAY "ENTERING NESTED-PROGRAM-1-2". + DISPLAY "TRYING TO WRITE". + WRITE FILE-EXT-REC FROM "Hello". + DISPLAY "EXITING NESTED-PROGRAM-1-2". + GOBACK. END PROGRAM NESTED-PROGRAM-1-2. END PROGRAM NESTED-PROGRAM-1. @@ -14357,7 +14357,7 @@ AT_DATA([prog2.cob], [ IDENTIFICATION DIVISION. PROGRAM-ID. NESTED-PROGRAM-2. PROCEDURE DIVISION. - GOBACK. + GOBACK. END PROGRAM NESTED-PROGRAM-2. END PROGRAM NESTED-FILES. diff --git a/tests/testsuite.src/run_misc.at b/tests/testsuite.src/run_misc.at index a1c8da6dc..879667ffe 100644 --- a/tests/testsuite.src/run_misc.at +++ b/tests/testsuite.src/run_misc.at @@ -14966,10 +14966,10 @@ AT_DATA([prog1.cob], [ PROGRAM-ID. prog1. DATA DIVISION. working-storage section. - 1 os-check pic x(7). + 01 os-check pic x(7). 88 os-is-windows-or-dos values 'WINDOWS' 'FREEDOS'. - 78 callee value "./prog2". - 78 callee-wdos value ".\prog2". + 01 callee pic x(8) value "./prog2". + 88 callee-wdos value ".\prog2". PROCEDURE DIVISION. accept os-check from environment "COB_ON_CYGWIN". if os-check = spaces @@ -14978,9 +14978,10 @@ AT_DATA([prog1.cob], [ accept os-check from environment "OS_NAME". inspect os-check converting "werfdosin" to "WERFDOSIN". if os-is-windows-or-dos - call "SYSTEM" using callee-wdos - else - call "SYSTEM" using callee. + set callee-wdos to true. + call "SYSTEM" using callee. + if callee = space + call 'impossible'. GOBACK. ]) AT_DATA([prog2.cob], [ @@ -14995,7 +14996,6 @@ AT_DATA([prog2.cob], [ CONTINUE. ]) AT_CHECK([$COMPILE_MODULE -fprof prog1.cob]) - AT_CHECK([$COMPILE -fprof prog2.cob]) AT_CAPTURE_FILE([prof1.csv]) @@ -15011,8 +15011,8 @@ AT_CHECK([cat prof1.csv], [0], prog1,,,,prog1.cob:10,PROGRAM,5000000,0.005 s,1 prog1,MAIN SECTION,,,prog1.cob:11,SECTION,3000000,0.003 s,1 prog1,MAIN SECTION,MAIN PARAGRAPH,,prog1.cob:11,PARAGRAPH,3000000,0.003 s,1 -prog1,MAIN SECTION,MAIN PARAGRAPH,SYSTEM,prog1.cob:18,CALL,1000000,0.001 s,1 -prog1,MAIN SECTION,MAIN PARAGRAPH,SYSTEM,prog1.cob:20,CALL,0,0.000 s,0 +prog1,MAIN SECTION,MAIN PARAGRAPH,SYSTEM,prog1.cob:19,CALL,1000000,0.001 s,1 +prog1,MAIN SECTION,MAIN PARAGRAPH,impossible,prog1.cob:21,CALL,0,0.000 s,0 ]) AT_CHECK([cat prof2.csv], [0],