diff --git a/.github/workflows/build_nightly.yml b/.github/workflows/build_nightly.yml new file mode 100644 index 000000000..0d3b44d51 --- /dev/null +++ b/.github/workflows/build_nightly.yml @@ -0,0 +1,701 @@ +name: Build, Test and provide Nightly (Ubuntu + MSYS1) + +on: + + pull_request: + branches: [ gcos4gnucobol-3.x ] + push: + # manual run in actions tab - for all branches + workflow_dispatch: + + +jobs: + + build: + name: Build, test and provide nightly + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + runs-on: ${{ matrix.os }} + + steps: + - name: Install packages + run: | + sudo apt -y update + sudo apt -y install automake libtool libdb5.3-dev libxml2-dev libcjson-dev \ + bison flex help2man gettext texlive + + - name: Set git user + run: | + git config --global user.name github-actions + git config --global user.email github-actions-bot@users.noreply.github.com + + - name: Checkout code + uses: actions/checkout@v4 + + - name: Bootstrap + run: | + ./build_aux/bootstrap + + # FIXME: With TERM="dumb" `make check` fails with: + # ... + # 571: ACCEPT OMITTED (SCREEN) FAILED (run_accept.at:307) + # ... + # 693: ON EXCEPTION clause of DISPLAY FAILED (run_misc.at:6335) + # 695: LINE/COLUMN 0 exceptions FAILED (run_misc.at:6414) + # 694: EC-SCREEN-LINE-NUMBER and -STARTING-COLUMN FAILED (run_misc.at:6376) + # ... + # Failure cases read: "Error opening terminal: unknown." on + # stderr, and exit with code 1. + # + # Another alternative is passing `--with-curses=no` to the + # configure script, yet distcheck does call configure too... + # + - name: Build environment setup + run: | + mkdir _build + export TERM="vt100" + echo "TERM=$TERM" >> $GITHUB_ENV + + - name: Configure + run: | + cd _build + ../configure --enable-cobc-internal-checks \ + --enable-hardening \ + --prefix /opt/gnucobol3 \ + --with-pkgversion="GnuCOBOL CI" + echo "VERSION=PACKAGE_VERSION" | cpp -P -imacros config.h | tr -d \" \ + >> $GITHUB_ENV + + - name: Build + run: | + make -C _build --jobs=$(($(nproc)+1)) + + - name: Upload config.log + uses: actions/upload-artifact@v4 + if: failure() + with: + name: config-${{ matrix.os }}-${{ github.job }}.log + path: _build/config.log + + # note: distcheck also creates the dist tarball + - name: Build distribution archive & run tests + run: | + make -C _build distcheck \ + TESTSUITEFLAGS="--jobs=$(($(nproc)+1))" \ + --jobs=$(($(nproc)+1)) || \ + make -C _build/gnucobol-$VERSION/_build/sub/tests check \ + TESTSUITEFLAGS="--recheck --verbose" + make -C _build --jobs=$(($(nproc)+1)) dist DIST_TARGETS="dist-gzip distwin-zip" + make -C _build --jobs=$(($(nproc)+1)) distbin DISTBIN_TARGETS="distbin-xz" + + - name: Upload testsuite.log + if: ${{ ! cancelled() }} #-> always upload as build result documentation + uses: actions/upload-artifact@v4 + with: + # Assume there's only one directory matching `build/gnucobol-*`: + name: testsuite-${{ matrix.os }}-${{ github.job }}.log + path: _build/gnucobol-${{ env.VERSION }}/_build/sub/tests/testsuite.log + + - name: Upload dist tarball + uses: actions/upload-artifact@v4 + with: + name: gnucobol-ci source distribution + path: _build/gnucobol*.tar.gz + if-no-files-found: error + retention-days: 0 + + - name: Upload dist tarball + uses: actions/upload-artifact@v4 + with: + name: gnucobol-ci windows source distribution + path: _build/gnucobol*.zip + if-no-files-found: error + retention-days: 0 + + - name: Upload test binaries + uses: actions/upload-artifact@v4 + with: + name: gnucobol-ci binary distribution + path: _build/gnucobol*.tar.xz + if-no-files-found: error + retention-days: 0 + + - name: Cache newcob.val + uses: actions/cache@v4 + with: + path: _build/tests/cobol85/newcob.val + key: newcob-val + save-always: true + enableCrossOsArchive: true + + - name: NIST85 Test Suite + run: | + make -C _build/tests/cobol85 EXEC85 test \ + --jobs=$(($(nproc)+1)) + + - name: Upload NIST85 Test Suite results + uses: actions/upload-artifact@v4 + with: + name: NIST85 results on ${{ matrix.os }}-${{ github.job }} + path: | + _build/tests/cobol85/summary.* + _build/tests/cobol85/**/*.log + _build/tests/cobol85/**/*.out + _build/tests/cobol85/**/duration.txt + + minmal_build: + name: Build and test with minimal dependencies + strategy: + fail-fast: true + matrix: + os: [ubuntu-latest] + needs: build + runs-on: ${{ matrix.os }} + + steps: + + - name: Install packages + run: | + sudo apt -y update + sudo apt -y install build-essential libgmp-dev + sudo apt -y remove bison flex + + - name: Get CI dist tarball + uses: actions/download-artifact@v4 + with: + name: gnucobol-ci source distribution + + - name: Build environment setup + run: | + tar -xvf gnucobol*.tar.* --strip-components=1 + mkdir _build + + - name: Configure + run: | + cd _build + ../configure --disable-dependency-tracking \ + --without-db --without-curses \ + --without-xml2 --without-json \ + --without-iconv --disable-nls + + - name: Build + run: | + make -C _build --jobs=$(($(nproc)+1)) + + - name: Upload config.log + if: failure() + uses: actions/upload-artifact@v4 + with: + name: config-${{ matrix.os }}-${{ github.job }}.log + path: _build/config.log + + - name: run internal tests + run: | + make -C _build check TESTSUITEFLAGS="--jobs=$(($(nproc)+1))" || \ + make -C _build check TESTSUITEFLAGS="--recheck --verbose" + + - name: Upload testsuite.log + if: ${{ ! cancelled() }} #-> always upload as build result documentation + uses: actions/upload-artifact@v4 + with: + name: testsuite-${{ matrix.os }}-${{ github.job }}.log + path: _build/tests/testsuite.log + + - name: Cache newcob.val + uses: actions/cache@v4 + with: + path: _build/tests/cobol85/newcob.val + key: newcob-val + save-always: true + enableCrossOsArchive: true + + - name: NIST85 Test Suite + run: | + make -C _build/tests/cobol85 EXEC85 test \ + --jobs=$(($(nproc)+1)) + + - name: Upload NIST85 Test Suite results + if: ${{ ! cancelled() }} #-> always upload as build result documentation + uses: actions/upload-artifact@v4 + with: + name: NIST85 results on ${{ matrix.os }}-${{ github.job }} + path: | + _build/tests/cobol85/summary.* + _build/tests/cobol85/**/*.log + _build/tests/cobol85/**/*.out + _build/tests/cobol85/**/duration.txt + + + coverage: + name: Coverage and Warnings + needs: build + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install dependencies + run: | + sudo apt -y install libdb5.3-dev libxml2-dev libcjson-dev lcov + + - name: Get CI dist tarball + uses: actions/download-artifact@v4 + with: + name: gnucobol-ci source distribution + + - name: Build environment setup + run: | + tar -xvf gnucobol*.tar.* --strip-components=1 + mkdir _build + export TERM="vt100" + echo "TERM=$TERM" >> $GITHUB_ENV + + # note: add additional C compiler syntax checks here to not need + # _another_ CI run + # + # TODO: try and pass -pedantic via CPPFLAGS + - name: Configure + run: | + cd _build + ../configure --enable-code-coverage \ + --with-db --with-xml2 --with-json=cjson --with-curses=ncursesw \ + CPPFLAGS="-Werror=declaration-after-statement" \ + CC="gcc -std=c89" + + - name: Build + run: | + make -C _build --jobs=$(($(nproc)+1)) + + - name: Upload config.log + if: failure() + uses: actions/upload-artifact@v4 + with: + name: config-${{ github.job }}.log + path: _build/config.log + + - name: Coverage + run: | + # make -C _build check-code-coverage # <- (ignores errors) + make -C _build check \ + TESTSUITEFLAGS="--jobs=$(($(nproc)+1))" + make -C _build code-coverage-capture \ + CODE_COVERAGE_DIRECTORY="$(realpath .)/_build" + + - name: Upload testsuite.log + if: ${{ ! cancelled() }} #-> always upload as build result documentation + uses: actions/upload-artifact@v4 + with: + name: testsuite-${{ github.job }}.log + path: _build/tests/testsuite.log + + - name: Upload coverage report + uses: actions/upload-artifact@v4 + with: + name: coverage + path: _build/GnuCOBOL-**-coverage + + - name: Cache newcob.val + uses: actions/cache@v4 + with: + path: _build/tests/cobol85/newcob.val + key: newcob-val + save-always: true + enableCrossOsArchive: true + + - name: Extended coverage + run: | + make -C _build/tests/cobol85 EXEC85 test \ + --jobs=$(($(nproc)+1)) \ + --keep-going + make -C _build code-coverage-capture \ + CODE_COVERAGE_OUTPUT_DIRECTORY=extended-coverage \ + CODE_COVERAGE_OUTPUT_FILE=extended-coverage.info \ + CODE_COVERAGE_DIRECTORY="$(realpath .)/_build" + + - name: Upload extended coverage report + uses: actions/upload-artifact@v4 + with: + name: extended-coverage + path: _build/extended-coverage + + - name: Upload coverage to codecov + uses: codecov/codecov-action@v3 + with: + # token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos + directory: _build + # Shall fail until we have a working account on codecov.io + fail_ci_if_error: false # optional (default = false) + verbose: true # optional (default = false) + + + msys_build_test_createdist: + + needs: build + runs-on: windows-latest + timeout-minutes: 30 + + env: + MSYS_ROOT: C:\MinGW + MSYS_BIN: C:\MinGW\msys\1.0\bin + #BISON_PKGDATADIR: C:\MinGW\share\bison + # M4: m4 + MSYSTEM: MINGW32 + MSYSPKGS: msys-m4 msys-coreutils msys-patch + #MSYSPKGS: msys-m4 msys-flex msys-coreutils msys-help2man msys-bison msys-patch GC3 from VCS + #MINGW_AUTOCONF_VERS: 2.7.0 # only needed to build from VCS, not from dist tarball + #MINGW_BISON_VERS: bison-3.6 # minimal for GC 4.x+ + MINGW_GMP_VERS: gmp-6.3.0 # always update for performance reasons + MINGW_BDB_VERS: db-6.0.19.NC + MINGW_PDCM_VERS: 4.4.0 + MINGW_CJSON_VERS: 1.7.18 + MINGW_XML2_VERS: 2.8.0 + + strategy: + fail-fast: false + matrix: + target: + - debug + - release + + steps: + + - name: Get CI dist tarball + uses: actions/download-artifact@v4 + with: + name: gnucobol-ci source distribution + + - name: Build environment setup + run: | + bash -lc "tar -xvf gnucobol*.tar.* --strip-components=1" + mkdir _build + + - name: Setup environment + run: | + echo GITHUB_WORKSPACE=$env:GITHUB_WORKSPACE >> $env:GITHUB_ENV + echo HOME=$env:GITHUB_WORKSPACE >> $env:GITHUB_ENV + echo PATH="$env:MSYS_BIN;$env:PATH" >> $env:GITHUB_ENV + If ("${{ matrix.target }}" -eq "release") { + echo DISTDIR=GnuCOBOL_mingw >> $env:GITHUB_ENV + echo CFGOPT="--with-pkgversion=GnuCOBOL-CI-MSYS" >> $env:GITHUB_ENV + } else { + echo DISTDIR=GnuCOBOL_mingw_dbg >> $env:GITHUB_ENV + echo CFGOPT="--with-pkgversion=GnuCOBOL-CI-MSYS-Debug --enable-debug --enable-cobc-internal-checks --enable-hardening" >> $env:GITHUB_ENV + } + + - name: Restore MSYS1 cache + id: restore-msys + uses: actions/cache/restore@v4 + with: + key: cache-msys + path: ${{ env.MSYS_ROOT }} + + - name: Install MSYS1 + if: steps.restore-msys.outputs.cache-hit != 'true' + run: | + curl -O https://www.arnoldtrembley.com/MinGW-bkup02.7z + 7z x -y MinGW-bkup02.7z -o${{ env.MSYS_ROOT }}\ + + - name: Install MSYS1 packages + if: steps.restore-msys.outputs.cache-hit != 'true' + run: | + ${{ env.MSYS_ROOT }}\bin\mingw-get install ${{ env.MSYSPKGS }} + + - name: Cleanup MSYS1 env + if: steps.restore-msys.outputs.cache-hit != 'true' + shell: cmd + run: | + rmdir /Q /S ${{ env.MSYS_ROOT }}\docs + rmdir /Q /S ${{ env.MSYS_ROOT }}\var + del /Q ${{ env.MSYS_ROOT }}\bin\gdb* + + - name: Save MSYS1 cache + if: steps.restore-msys.outputs.cache-hit != 'true' + uses: actions/cache/save@v4 + with: + key: cache-msys + path: ${{ env.MSYS_ROOT }} + + + # - name: Restore Bison cache + # id: restore-bison + # uses: actions/cache/restore@v4 + # with: + # key: cache-msys-bison + # path: ${{ env.MINGW_BISON_VERS }} + + # - name: Install Bison + # if: steps.restore-bison.outputs.cache-hit != 'true' + # run: | + # curl -L https://ftp.gnu.org/gnu/bison/%MINGW_BISON_VERS%.tar.gz -o %MINGW_BISON_VERS%.tar.gz + # tar -xvf %MINGW_BISON_VERS%.tar.gz + # bash -lc "cd %MINGW_BISON_VERS% && ./configure --prefix=/mingw && make" + + # - name: Install Bison + # run: | + # bash -lc "make -C %MINGW_BISON_VERS% install" + + # - name: Save Bison cache + # if: steps.restore-bison.outputs.cache-hit != 'true' + # uses: actions/cache/save@v4 + # with: + # key: cache-msys-bison + # path: ${{ env.MINGW_BISON_VERS }} + + + # - name: Restore Autoconf cache + # id: restore-autoconf + # uses: actions/cache/restore@v4 + # with: + # key: cache-msys-autoconf + # path: ${{ env.MINGW_BISON_VERS }} + + # - name: Install Autoconf 2.70 + # if: steps.restore-autoconf.outputs.cache-hit != 'true' + # run: | + # curl -L https://ftpmirror.gnu.org/autoconf/%MINGW_AUTOCONF_VERS%.tar.gz -o %MINGW_AUTOCONF_VERS%.tar.gz + # tar -xvzf %MINGW_AUTOCONF_VERS%.tar.gz + # bash -lc "cd %MINGW_AUTOCONF_VERS% && ./configure" + # bash -lc "cd %MINGW_AUTOCONF_VERS% && make" + + # - name: Install Autoconf + # run: | + # bash -lc "cd %MINGW_AUTOCONF_VERS% && make install" + + # - name: Save Autoconf cache + # if: steps.restore-autoconf.outputs.cache-hit != 'true' + # uses: actions/cache/save@v4 + # with: + # key: cache-msys-autoconf + # path: ${{ env.MINGW_BISON_VERS }} + + + - name: Restore GMP cache + id: restore-gmp + uses: actions/cache/restore@v4 + with: + key: cache-msys-gmp + path: ${{ env.MINGW_GMP_VERS }} + + - name: Build GMP + if: steps.restore-gmp.outputs.cache-hit != 'true' + shell: cmd + run: | + rem note: MSYS1 cannot connect to https://gmplib.org, so using GNU mirror side instead + curl -L https://ftp.gnu.org/gnu/gmp/${{ env.MINGW_GMP_VERS }}.tar.xz -o ${{ env.MINGW_GMP_VERS }}.tar.xz + tar -xvf ${{ env.MINGW_GMP_VERS }}.tar.xz + bash -lc "cd ${{ env.MINGW_GMP_VERS }} && ./configure --prefix=/mingw --enable-fat --enable-shared --disable-static CFLAGS=\"-Wno-attributes -Wno-ignored-attributes\" ABI=32 && make --jobs=$(($(nproc)+1))" + + - name: Install GMP + run: | + bash -lc "make -C ${{ env.MINGW_GMP_VERS }} install" + + - name: Save GMP cache + if: steps.restore-gmp.outputs.cache-hit != 'true' + uses: actions/cache/save@v4 + with: + key: cache-msys-gmp + path: ${{ env.MINGW_GMP_VERS }} + + + - name: Restore BDB cache + id: restore-bdb + uses: actions/cache/restore@v4 + with: + key: cache-msys-bdb + path: ${{ env.MINGW_BDB_VERS }} + + - name: Build BDB + if: steps.restore-bdb.outputs.cache-hit != 'true' + run: | + curl -L https://download.oracle.com/berkeley-db/${{ env.MINGW_BDB_VERS }}.tar.gz -o ${{ env.MINGW_BDB_VERS }}.tar.gz + curl -L https://raw.githubusercontent.com/msys2/MINGW-packages/refs/heads/master/mingw-w64-db/0001-db-tls-m4-fix-pthread.patch -o db-tls-m4-fix-pthread.patch + curl -L https://raw.githubusercontent.com/msys2/MINGW-packages/refs/heads/master/mingw-w64-db/mingw.patch -o mingw.patch + curl -L https://raw.githubusercontent.com/msys2/MINGW-packages/refs/heads/master/mingw-w64-db/cclang_cxx_11.patch -o cx11.patch + tar -xvf ${{ env.MINGW_BDB_VERS }}.tar.gz + sed -i 's/_tcsclen/_mbslen/' ${{ env.MINGW_BDB_VERS }}\src\os_windows\os_stat.c + bash -lc "cd ${{ env.MINGW_BDB_VERS }} && /bin/patch -p1 -i ../db-tls-m4-fix-pthread.patch" + bash -lc "cd ${{ env.MINGW_BDB_VERS }} && /bin/patch -p1 -i ../mingw.patch" + bash -lc "cd ${{ env.MINGW_BDB_VERS }} && /bin/patch -p1 -i ../cx11.patch" + bash -lc "cd ${{ env.MINGW_BDB_VERS }}/build_unix && ../dist/configure --prefix=/mingw --enable-mingw --enable-debug --disable-static --disable-replication --disable-tcl --without-cryptography LIBCSO_LIBS=-lwsock32 && make --jobs=$(($(nproc)+1))" + + - name: Install BDB + run: | + bash -lc "make -C ${{ env.MINGW_BDB_VERS }}/build_unix install" + + - name: Save BDB cache + if: steps.restore-bdb.outputs.cache-hit != 'true' + uses: actions/cache/save@v4 + with: + key: cache-msys-bdb + path: ${{ env.MINGW_BDB_VERS }} + + + - name: Restore LibXML2 cache + id: restore-xml2 + uses: actions/cache/restore@v4 + with: + key: cache-msys-xml2 + path: libxml2-${{ env.MINGW_XML2_VERS }} + + - name: Build LibXML2 + if: steps.restore-xml2.outputs.cache-hit != 'true' + run: | + curl -L https://github.com/GNOME/libxml2/archive/refs/tags/v${{ env.MINGW_XML2_VERS }}.tar.gz -o libxml2-${{ env.MINGW_XML2_VERS }}.tar.xz + tar -xvf libxml2-${{ env.MINGW_XML2_VERS }}.tar.xz + bash -lc "cd libxml2-${{ env.MINGW_XML2_VERS }} && ./autogen.sh" + bash -lc "cd libxml2-${{ env.MINGW_XML2_VERS }} && ./configure --prefix=/mingw --enable-debug && make --jobs=$(($(nproc)+1))" + + - name: Install LibXML2 + run: | + bash -lc "make -C libxml2-${{ env.MINGW_XML2_VERS }} install" + + - name: Save LibXML2 cache + if: steps.restore-xml2.outputs.cache-hit != 'true' + uses: actions/cache/save@v4 + with: + key: cache-msys-xml2 + path: libxml2-${{ env.MINGW_XML2_VERS }} + + + - name: Restore PDCursesMod cache + id: restore-pdcm + uses: actions/cache/restore@v4 + with: + key: cache-msys-pdcm + path: PDCursesMod-${{ env.MINGW_PDCM_VERS }} + + - name: Build PDCursesMod + if: steps.restore-pdcm.outputs.cache-hit != 'true' + shell: cmd + run: | + curl -L https://github.com/Bill-Gray/PDCursesMod/archive/refs/tags/v${{ env.MINGW_PDCM_VERS }}.tar.gz -o "PDCursesMod-${{ env.MINGW_PDCM_VERS }}.tar.xz" + tar -xvf PDCursesMod-${{ env.MINGW_PDCM_VERS }}.tar.xz + rem: consider inclusion of https://github.com/Bill-Gray/PDCursesMod/commit/45949000c3ac1375f5f821d72f46e4726a3a6a2f.patch + bash -lc "cd PDCursesMod-${{ env.MINGW_PDCM_VERS }} && make -C wincon --jobs=$(($(nproc)+1)) INFOEX=N CHTYPE_64=Y DEBUG=Y DLL=Y DLLNAME=libpdcurses LIBNAME=libpdcurses.dll" + bash -lc "cd PDCursesMod-${{ env.MINGW_PDCM_VERS }} && make -C wingui --jobs=$(($(nproc)+1)) CHTYPE_64=Y DEBUG=Y DLL=Y DLLNAME=libpdcurses LIBNAME=libpdcurses.dll" + bash -lc "cd PDCursesMod-${{ env.MINGW_PDCM_VERS }} && make -C vt --jobs=$(($(nproc)+1)) CHTYPE_64=Y DEBUG=Y DLL=Y DLLNAME=libpdcurses LIBNAME=libpdcurses.dll CFLAGS=\"-Wall -Wextra -pedantic -g -DPDCDEBUG -fPIC -DPDC_DLLbuild\"" + rem: only works this way on cmd + echo #define CHTYPE_64 > PDCursesMod-${{ env.MINGW_PDCM_VERS }}\pdcurses.h + echo #define PDC_DLLbuild >> PDCursesMod-${{ env.MINGW_PDCM_VERS }}\pdcurses.h + echo #include "pdcurses/curses.h" >> PDCursesMod-${{ env.MINGW_PDCM_VERS }}\pdcurses.h + + - name: Install PDCursesMod + run: | + bash -lc "cd PDCursesMod-${{ env.MINGW_PDCM_VERS }} && install wincon/libpdcurses.dll.a /mingw/lib/" + bash -lc "cd PDCursesMod-${{ env.MINGW_PDCM_VERS }} && install wincon/libpdcurses.dll /mingw/bin/" + bash -lc "cd PDCursesMod-${{ env.MINGW_PDCM_VERS }} && install wincon/libpdcurses.dll /mingw/bin/libpdcurses-wincon.dll" + bash -lc "cd PDCursesMod-${{ env.MINGW_PDCM_VERS }} && install wingui/libpdcurses.dll /mingw/bin/libpdcurses-wingui.dll" + bash -lc "cd PDCursesMod-${{ env.MINGW_PDCM_VERS }} && install vt/libpdcurses.dll /mingw/bin/libpdcurses-vt.dll" + bash -lc "install -d /mingw/include/pdcurses" + bash -lc "cd PDCursesMod-${{ env.MINGW_PDCM_VERS }} && install -m 0644 curses.h panel.h term.h /mingw/include/pdcurses/" + bash -lc "cd PDCursesMod-${{ env.MINGW_PDCM_VERS }} && install -m 0644 pdcurses.h /mingw/include/" + + - name: Save PDCursesMod cache + if: steps.restore-pdcm.outputs.cache-hit != 'true' + uses: actions/cache/save@v4 + with: + key: cache-msys-pdcm + path: PDCursesMod-${{ env.MINGW_PDCM_VERS }} + + + - name: get cJSON + run: | + curl -L https://raw.githubusercontent.com/DaveGamble/cJSON/v${{ env.MINGW_CJSON_VERS }}/cJSON.c -o .\libcob\cJSON.c + curl -L https://raw.githubusercontent.com/DaveGamble/cJSON/v${{ env.MINGW_CJSON_VERS }}/cJSON.h -o .\libcob\cJSON.h + + + # - name: Bootstrap GnuCOBOL + # run: | + # sed -i 's/AM_PROG_AR/m4_ifdef\(\[AM_PROG_AR\], \[AM_PROG_AR\]\)/g' .\configure.ac + # sed -i 's/po extras doc tests/po extras tests/g' .\Makefile.am + # bash -lc "./autogen.sh" + + + - name: Configure GnuCOBOL + shell: cmd + run: | + bash -lc "cd _build && ../configure %CFGOPT% --with-db --with-xml2 --with-json=local --with-curses=pdcurses --prefix=/mingw" + rem Note: GC4 may need CPPFLAGS="-I../libcob" for local cJSON + + - name: Build GnuCOBOL + shell: cmd + run: | + bash -lc "CPATH=$(pwd) make -C _build --jobs=$(($(nproc)+1))" + rem Note: the extra CPATH above is only required in debug builds (otherwise gcc invoked from cobc does not find libcob.h [pre-inst-env]), for some reason... + + - name: Upload config-${{ matrix.target }}.log + if: failure() + uses: actions/upload-artifact@v4 + with: + name: config-${{ matrix.target }}.log + path: _build/config.log + + - name: Cache newcob.val + uses: actions/cache@v4 + with: + path: _build/tests/cobol85/newcob.val + key: newcob-val + save-always: true + enableCrossOsArchive: true + + - name: Run NIST85 testsuite + # if we ever need to disable something in the tests: skip like here IF106A + # and later expect a failure + # perl -pi -e 's/^# OBNC1M/\$skip{IF106A} = 1; # OBNC1M/' tests/cobol85/report.pl + # bash -lc "CPATH=$(pwd) make -C _build/tests test --jobs=$(($(nproc)+1)) || echo \"WARNING: NIST85 did not pass!\"" + shell: cmd + run: | + bash -lc "CPATH=$(pwd) make -C _build/tests test --jobs=$(($(nproc)+1))" + rem Note: the extra CPATH above is only required in debug builds (otherwise gcc invoked from cobc does not find libcob.h [atlocal]), for some reason... + + - name: Upload NIST85 Test Suite results + if: ${{ ! cancelled() }} #-> always upload as build result documentation + uses: actions/upload-artifact@v4 + with: + name: NIST85 results on ${{ matrix.target }} + path: | + _build/tests/cobol85/summary.* + _build/tests/cobol85/**/*.log + _build/tests/cobol85/**/*.out + _build/tests/cobol85/**/duration.txt + + - name: Run testsuite + shell: cmd + run: | + rem skip test as it sometimes works and sometimes not... + rem instead of + rem sed -i '/AT_SETUP(\[temporary path invalid\])/a AT_SKIP_IF(\[true\])' tests/testsuite.src/used_binaries.at + rem use + bash -lc "sed -i '/used_binaries/{N;/temporary path invalid/{N;N;N;N;s/traceon/traceon; echo \"workflow:1\">\"$at_check_line_file\"; at_fn_check_skip 77/;}}' tests/testsuite" + + rem change to expected fail if there's an error specific to the CI that we don't want to change + rem in the testsuite for expected result (should normally only be a temporary thing) + rem instead of + rem sed -i '/AT_SETUP(\[Compare FLOAT-LONG with floating-point literal\])/a AT_XFAIL_IF(\[true\])' tests/testsuite.src/run_fundamental.at + rem use + rem sed -i '/run_fundamental/{N;/Compare FLOAT-LONG with floating-point literal/{N;s/at_xfail=no/at_xfail=yes/;}}' tests/testsuite + + rem to work around regular hangs we run NIST first, then the internal + rem and the later only with 2 jobs + bash -lc "CPATH=$(pwd) make -C _build/tests check TESTSUITEFLAGS=\"--jobs=2\"" + rem Note: the extra CPATH above is only required in debug builds (otherwise gcc invoked from cobc does not find libcob.h [atlocal]), for some reason... + + - name: Upload testsuite-${{ matrix.target }}.log + if: ${{ ! cancelled() }} #-> always upload as build result documentation + uses: actions/upload-artifact@v4 + with: + name: testsuite-${{ matrix.target }}.log + path: _build/tests/testsuite.log + + - name: Package GnuCOBOL MinGW nightly + run: | + bash -lc "make -C _build distmingw" + + - name: Upload GnuCOBOL_mingw-${{ matrix.target }} + uses: actions/upload-artifact@v4 + with: + name: GnuCOBOL_mingw-${{ matrix.target }} + path: _build/${{ env.DISTDIR }} diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 7115b1f94..28ccbce6b 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -22,7 +22,6 @@ jobs: - name: Configure git run: git config --global core.symlinks false - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - name: Checkout code uses: actions/checkout@v4 @@ -57,6 +56,10 @@ jobs: --enable-hardening \ --prefix /opt/cobol/gnucobol-gcos \ + - name: make + run: | + make -C _build --jobs=$((${NPROC}+1)) + - name: Upload config.log uses: actions/upload-artifact@v4 with: @@ -64,10 +67,6 @@ jobs: path: _build/config.log if: failure() - - name: make - run: | - make -C _build --jobs=$((${NPROC}+1)) - # make install must be done before make check, otherwise # execution of generated COBOL files fail for a missing # /usr/local/lib/libcob.dylib @@ -89,7 +88,7 @@ jobs: - name: Upload testsuite.log uses: actions/upload-artifact@v4 - if: failure() + if: ${{ ! cancelled() }} #-> always upload as build result documentation with: name: testsuite-${{ matrix.os }}.log path: _build/tests/testsuite.log @@ -102,7 +101,22 @@ jobs: save-always: true enableCrossOsArchive: true - - name: NIST85 Test Suite +# - name: NIST85 Test Suite +# run: | +# make -C _build/tests/cobol85 EXEC85 test \ +# --jobs=$((${NPROC}+1)) + + - name: Run NIST85 testsuite run: | - make -C _build/tests/cobol85 EXEC85 test \ - --jobs=$((${NPROC}+1)) + make -C _build/tests test --jobs=$((${NPROC}+1)) + + - name: Upload NIST85 Test Suite results + if: ${{ ! cancelled() }} #-> always upload as build result documentation + uses: actions/upload-artifact@v4 + with: + name: NIST85 results on ${{ matrix.os }} + path: | + _build/tests/cobol85/summary.* + _build/tests/cobol85/**/*.log + _build/tests/cobol85/**/*.out + _build/tests/cobol85/**/duration.txt diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml deleted file mode 100644 index edc22687c..000000000 --- a/.github/workflows/ubuntu.yml +++ /dev/null @@ -1,226 +0,0 @@ -name: Ubuntu Workflow - -on: - pull_request: - branches: [ gcos4gnucobol-3.x ] - push: - # manual run in actions tab - for all branches - workflow_dispatch: - -jobs: - build: - name: Build, test and provide nightly - strategy: - fail-fast: false - matrix: - os: [ ubuntu-latest ] - runs-on: ${{ matrix.os }} - - steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - name: Checkout code - uses: actions/checkout@v4 - - - name: Install packages - run: | - sudo apt-get update - sudo apt-get install automake libtool libdb5.3-dev libxml2-dev libcjson-dev \ - bison flex help2man gettext texlive - - - name: Set git user - run: | - git config --global user.name github-actions - git config --global user.email github-actions-bot@users.noreply.github.com - - - name: Bootstrap - run: | - ./build_aux/bootstrap - - # FIXME: With TERM="dumb" `make check` fails with: - # ... - # 571: ACCEPT OMITTED (SCREEN) FAILED (run_accept.at:307) - # ... - # 693: ON EXCEPTION clause of DISPLAY FAILED (run_misc.at:6335) - # 695: LINE/COLUMN 0 exceptions FAILED (run_misc.at:6414) - # 694: EC-SCREEN-LINE-NUMBER and -STARTING-COLUMN FAILED (run_misc.at:6376) - # ... - # Failure cases read: "Error opening terminal: unknown." on - # stderr, and exit with code 1. - # - # Another alternative is passing `--with-curses=no` to the - # configure script, yet distcheck does call configure too... - # - - name: Build environment setup - run: | - mkdir _build - export TERM="vt100" - echo "TERM=$TERM" >> $GITHUB_ENV - echo "INSTALL_PATH=$(pwd)/_install" >> $GITHUB_ENV - - - name: Configure - run: | - cd _build - ../configure --enable-cobc-internal-checks \ - --enable-hardening \ - --prefix ${INSTALL_PATH} - echo "VERSION=PACKAGE_VERSION" | cpp -P -imacros config.h | tr -d \" \ - >> $GITHUB_ENV - - - name: Upload config.log - uses: actions/upload-artifact@v4 - if: failure() - with: - name: config-${{ matrix.os }}.log - path: _build/config.log - - - name: Build - run: | - make -C _build --jobs=$(($(nproc)+1)) - - # note: distcheck also creates the dist tarball - - name: Build distribution archive & run tests - run: | - make -C _build distcheck \ - TESTSUITEFLAGS="--jobs=$(($(nproc)+1))" \ - --jobs=$(($(nproc)+1)) || \ - make -C _build/gnucobol-$VERSION/_build/sub/tests check \ - TESTSUITEFLAGS="--recheck --verbose" - - - name: Upload testsuite.log - uses: actions/upload-artifact@v4 - if: failure() - with: - # Assume there's only one directory matching `_build/gnucobol-*`: - name: testsuite-${{ matrix.os }}.log - path: _build/gnucobol-${{ env.VERSION }}/_build/sub/tests/testsuite.log - - - name: Upload dist tarball - uses: actions/upload-artifact@v4 - with: - name: gnucobol-ci source distribution - path: _build/gnucobol*.tar* - if-no-files-found: error - retention-days: 0 - - - name: Cache newcob.val - uses: actions/cache@v4 - with: - path: _build/tests/cobol85/newcob.val - key: newcob-val - save-always: true - enableCrossOsArchive: true - - - name: NIST85 Test Suite - run: | - make -C _build/tests/cobol85 EXEC85 test \ - --jobs=$(($(nproc)+1)) - - - name: Upload NIST85 Test Suite results - uses: actions/upload-artifact@v4 - with: - name: NIST85 results on ${{ matrix.os }} - path: | - _build/tests/cobol85/**/*.log - _build/tests/cobol85/**/*.out - - - coverage: - name: Coverage and Warnings - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - # note: less dependencies as we don't generate a dist tarball, one additional for lcov - - name: Install dependencies - run: | - sudo apt-get install automake libtool libdb5.3-dev libxml2-dev \ - libcjson-dev bison flex help2man gettext lcov - - - name: Bootstrap - run: | - ./build_aux/bootstrap - - - name: Build environment setup - run: | - mkdir _build - export TERM="vt100" - echo "TERM=$TERM" >> $GITHUB_ENV - - # note: add additional C compiler syntax checks here to not need - # _another_ CI run - # - # TODO: try and pass -pedantic via CPPFLAGS - - name: Configure - run: | - cd _build - ../configure --enable-code-coverage \ - CPPFLAGS="-Werror=declaration-after-statement" \ - CC="gcc -std=c89" - - - name: Upload config.log - uses: actions/upload-artifact@v4 - if: failure() - with: - name: config-${{ matrix.os }}.log - path: _build/config.log - - - name: Build - run: | - make -C _build --jobs=$(($(nproc)+1)) - - - name: Coverage - run: | - # make -C _build check-code-coverage # <- (ignores errors) - make -C _build check \ - TESTSUITEFLAGS="--jobs=$(($(nproc)+1))" - make -C _build code-coverage-capture \ - CODE_COVERAGE_DIRECTORY="$(realpath .)/_build" - - - name: Upload testsuite.log - uses: actions/upload-artifact@v4 - if: failure() - with: - name: testsuite-${{ matrix.os }}.log - path: _build/tests/testsuite.log - - - name: Upload coverage report - uses: actions/upload-artifact@v4 - with: - name: coverage-${{ matrix.os }} - path: _build/GnuCOBOL-**-coverage - - - name: Cache newcob.val - uses: actions/cache@v4 - with: - path: _build/tests/cobol85/newcob.val - key: newcob-val - save-always: true - enableCrossOsArchive: true - - - name: Extended coverage - run: | - make -C _build/tests/cobol85 EXEC85 test \ - --jobs=$(($(nproc)+1)) \ - --keep-going - make -C _build code-coverage-capture \ - CODE_COVERAGE_OUTPUT_DIRECTORY=extended-coverage \ - CODE_COVERAGE_OUTPUT_FILE=extended-coverage.info \ - CODE_COVERAGE_DIRECTORY="$(realpath .)/_build" - - - name: Upload extended coverage report - uses: actions/upload-artifact@v4 - with: - name: extended-coverage-${{ matrix.os }} - path: _build/extended-coverage - - - name: Upload coverage to codecov - uses: codecov/codecov-action@v2 - with: - # token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos - directory: _build - # Shall fail until we have a working account on codecov.io - fail_ci_if_error: false # optional (default = false) - verbose: true # optional (default = false) - diff --git a/.github/workflows/windows-msvc.yml b/.github/workflows/windows-msvc.yml index 134e7f18c..03211301c 100644 --- a/.github/workflows/windows-msvc.yml +++ b/.github/workflows/windows-msvc.yml @@ -33,15 +33,13 @@ jobs: strategy: fail-fast: false matrix: - os: - - windows-latest arch: - x86 - x64 target: - Debug - Release - runs-on: ${{ matrix.os }} + runs-on: windows-latest timeout-minutes: 45 steps: @@ -57,12 +55,12 @@ jobs: - name: Setup environment shell: pwsh run: | - echo GITHUB_WORKSPACE=$env:GITHUB_WORKSPACE >> $env:GITHUB_ENV + echo GITHUB_WORKSPACE=${{ env.GITHUB_WORKSPACE }} >> $env:GITHUB_ENV If ("${{ matrix.arch }}" -eq "x86") { echo VCVARS=$env:VCVARS32 >> $env:GITHUB_ENV echo VCPKGS=$env:VCPKGS32 >> $env:GITHUB_ENV echo ARCHDIR=Win32 >> $env:GITHUB_ENV - } Else { + } else { echo VCVARS=$env:VCVARS64 >> $env:GITHUB_ENV echo VCPKGS=$env:VCPKGS64 >> $env:GITHUB_ENV echo ARCHDIR=x64 >> $env:GITHUB_ENV @@ -78,24 +76,24 @@ jobs: ${{ env.VCPKG_ROOT }}/packages - name: Bootstrap VCPKG - if: steps.restore-vcpkg.outputs.cache-hit != 'true' run: | - cd /d %VCPKG_ROOT% - vcpkg update + cd /d ${{ env.VCPKG_ROOT }} git pull cmd /C .\bootstrap-vcpkg.bat -disableMetrics + vcpkg update - name: Integrate VCPKG run: | + cd /d ${{ env.VCPKG_ROOT }} vcpkg integrate install - name: Install VCPKG packages if: steps.restore-vcpkg.outputs.cache-hit != 'true' run: | + cd /d ${{ env.VCPKG_ROOT }} vcpkg install %VCPKGS% - name: Save VCPKG cache - if: steps.restore-vcpkg.outputs.cache-hit != 'true' uses: actions/cache/save@v4 with: key: cache-vcpkg-${{ matrix.arch }}-${{ matrix.target }} @@ -108,7 +106,7 @@ jobs: id: restore-flexbison with: key: cache-flexbison-${{ matrix.arch }}-${{ matrix.target }} - path: ${{ env.GITHUB_WORKSPACE }}/flexbison + path: flexbison - name: Install WinFlexBison if: steps.restore-flexbison.outputs.cache-hit != 'true' @@ -122,30 +120,30 @@ jobs: uses: actions/cache/save@v4 with: key: cache-flexbison-${{ matrix.arch }}-${{ matrix.target }} - path: ${{ env.GITHUB_WORKSPACE }}/flexbison + path: flexbison - name: Configure GnuCOBOL shell: pwsh run: | cd build_windows - Get-Content -Path 'config.h.in' | ForEach-Object { $_ ` + (('#define COB_MAIN_DIR "' + $env:GITHUB_WORKSPACE + '"') -replace '\\', '\\') + "`r`n" + ` + ((Get-Content -Path 'config.h.in' | ForEach-Object { $_ ` -replace '(#define\s+CONFIGURED_ISAM)\s.+$', '$1 BDB' ` -replace '(#define\s+CONFIGURED_CURSES)\s.+$', '$1 PDCURSES' ` -replace '(#define\s+CONFIGURED_XML)\s.+$', '$1 XML2' ` -replace '(#define\s+CONFIGURED_JSON)\s.+$', '$1 CJSON_CJSON' ` - } | Set-Content -Path 'config.h' + -replace '"\(" PACKAGE_NAME "\) "', '"(GnuCOBOL-CI ${{ matrix.target }}) "' ` + }) -join "`r`n" ) | Set-Content -Path 'config.h' & .\maketarstamp.ps1 > tarstamp.h - name: Generate parser run: | - cd build_windows set PATH=%GITHUB_WORKSPACE%\flexbison;%PATH% - cmd /C .\makebisonflex.cmd atlocal autom4te --lang=autotest -I ./testsuite.src ./testsuite.at -o ./testsuite + - name: Adjust testsuite + shell: C:\shells\msys2bash.cmd {0} + run: | + # sed -i '/AT_SETUP(\[runtime check: write to internal storage (1)\])/a AT_SKIP_IF(\[true\])' tests/testsuite.src/run_misc.at + sed -i '/run_misc/{N;/write to internal storage (1)/{N;N;N;N;s/traceon/traceon; echo "workflow:1">"$at_check_line_file"; at_fn_check_skip 77/;}}' tests/testsuite + + # Fail two tests that behave differently under MSVC Debug + # - System routine CBL_GC_HOSTED: fails because libcob is linked with the debug version + # of the C runtime while the generated module is linked with the release version + # - PROGRAM COLLATING SEQUENCE: fails because of a data loss in a cast, due + # to lack of specific handling of LOW/HIGH-VALUE for NATIONAL alphabets + # (see typeck.c:cb_validate_collating) + - name: Adjust testsuite for Debug target + if: ${{ matrix.target == 'Debug' }} + shell: C:\shells\msys2bash.cmd {0} + run: | + sed -i '/run_extensions/{N;/System routine CBL_GC_HOSTED/{N;s/at_xfail=no/at_xfail=yes/;}}' tests/testsuite + sed -i '/syn_definition/{N;/PROGRAM COLLATING SEQUENCE/{N;s/at_xfail=no/at_xfail=yes/;}}' tests/testsuite + - name: Run testsuite run: | - cd tests - set CL=/I "%VCPKG_ROOT%\installed\${{ matrix.arch }}-windows\include" + set CL=/I "${{ env.VCPKG_ROOT }}\installed\${{ matrix.arch }}-windows\include" call "%VCVARS%" set MSYS2_PATH_TYPE=inherit + cd tests C:\shells\msys2bash.cmd -c "./testsuite || ./testsuite --recheck --verbose" - name: Upload testsuite-${{ matrix.arch }}-${{ matrix.target }}.log uses: actions/upload-artifact@v4 + if: ${{ ! cancelled() }} #-> always upload as build result documentation with: name: testsuite-${{ matrix.arch }}-${{ matrix.target }}.log - path: ${{ env.GITHUB_WORKSPACE }}/tests/testsuite.log - - # - name: Package GnuCOBOL - # run: | - # cd build_windows - # set CL=/I "%VCPKG_ROOT%\installed\${{ matrix.arch }}-windows\include" - # call "%VCVARS%" - # cmd /C .\makedist.cmd > $env:GITHUB_ENV - echo HOME=$env:GITHUB_WORKSPACE >> $env:GITHUB_ENV - echo PATH="$env:MSYS_BIN;$env:PATH" >> $env:GITHUB_ENV - If ("${{ matrix.target }}" -eq "release") { - echo DISTDIR=GnuCOBOL_mingw >> $env:GITHUB_ENV - echo CFGOPT= >> $env:GITHUB_ENV - } Else { - echo DISTDIR=GnuCOBOL_mingw_dbg >> $env:GITHUB_ENV - echo CFGOPT="--enable-debug --enable-cobc-internal-checks --enable-hardening" >> $env:GITHUB_ENV - } - - - name: Restore MSYS1 cache - id: restore-msys - uses: actions/cache/restore@v4 - with: - key: cache-msys-${{ matrix.target }} - path: ${{ env.MSYS_ROOT }} - - - name: Install MSYS1 - if: steps.restore-msys.outputs.cache-hit != 'true' - run: | - curl -O https://www.arnoldtrembley.com/MinGW-bkup02.7z - 7z x MinGW-bkup02.7z -o%MSYS_ROOT%\ - - - name: Install MSYS1 packages - if: steps.restore-msys.outputs.cache-hit != 'true' - run: | - bash -lc "mingw-get install %MSYSPKGS%" - - - name: Install Bison 3.0 - if: steps.restore-msys.outputs.cache-hit != 'true' - run: | - curl -L https://mirror.ibcp.fr/pub/gnu/bison/%MINGW_BISON_VERS%.tar.xz -o %MINGW_BISON_VERS%.tar.xz - tar -xvf %MINGW_BISON_VERS%.tar.xz - bash -lc "cd %MINGW_BISON_VERS% && ./configure --prefix=/mingw && make" - bash -lc "cd %MINGW_BISON_VERS% && make install" - - # Note: actually unavailable, so skip (works with the GMP alredy provided) - # - name: Install GMP - # if: steps.restore-msys.outputs.cache-hit != 'true' - # run: | - # curl -L https://gmplib.org/download/gmp/%MINGW_GMP_VERS%.tar.xz -o %MINGW_GMP_VERS%.tar.xz - # tar -xvf %MINGW_GMP_VERS%.tar.xz - # bash -lc "cd %MINGW_GMP_VERS% && ./configure --prefix=/mingw --enable-fat --enable-shared --disable-static CFLAGS=\"-Wno-attributes -Wno-ignored-attributes\" ABI=32 && make" - # bash -lc "cd %MINGW_GMP_VERS% && make install" - - - name: Install BDB - if: steps.restore-msys.outputs.cache-hit != 'true' - run: | - curl -L https://download.oracle.com/berkeley-db/%MINGW_BDB_VERS%.tar.gz -o %MINGW_BDB_VERS%.tar.gz - tar -xvf %MINGW_BDB_VERS%.tar.gz - sed -i 's/_tcsclen/strlen/' %MINGW_BDB_VERS%\src\os_windows\os_stat.c - bash -lc "cd %MINGW_BDB_VERS%/build_unix && ../dist/configure --prefix=/mingw --enable-mingw --enable-debug --disable-static --disable-replication --disable-tcl LIBCSO_LIBS=-lwsock32 && make || make" - bash -lc "cd %MINGW_BDB_VERS%/build_unix && make install" - - - name: Install PDCurses - if: steps.restore-msys.outputs.cache-hit != 'true' - run: | - curl -L https://github.com/Bill-Gray/PDCursesMod/archive/refs/tags/v%MINGW_PDCM_VERS%.tar.gz -o "PDCursesMod-%MINGW_PDCM_VERS%.tar.xz" - tar -xvf PDCursesMod-%MINGW_PDCM_VERS%.tar.xz - bash -lc "cd PDCursesMod-%MINGW_PDCM_VERS%\wincon && make INFOEX=N CHTYPE_64=Y DEBUG=Y DLL=Y DLLNAME=libpdcurses LIBNAME=libpdcurses.dll" - bash -lc "cd PDCursesMod-%MINGW_PDCM_VERS%\wingui && make CHTYPE_64=Y DEBUG=Y DLL=Y DLLNAME=libpdcurses LIBNAME=libpdcurses.dll" - bash -lc "cd PDCursesMod-%MINGW_PDCM_VERS%\vt && make CHTYPE_64=Y DEBUG=Y DLL=Y DLLNAME=libpdcurses LIBNAME=libpdcurses.dll CFLAGS=\"-Wall -Wextra -pedantic -g -DPDCDEBUG -fPIC -DPDC_DLL_BUILD\"" - echo #define CHTYPE_64 > PDCursesMod-%MINGW_PDCM_VERS%\pdcurses.h - echo #define PDC_DLL_BUILD >> PDCursesMod-%MINGW_PDCM_VERS%\pdcurses.h - echo #include "pdcurses/curses.h" >> PDCursesMod-%MINGW_PDCM_VERS%\pdcurses.h - bash -lc "cd PDCursesMod-%MINGW_PDCM_VERS% && install wincon/libpdcurses.dll.a /mingw/lib/" - bash -lc "cd PDCursesMod-%MINGW_PDCM_VERS% && install wincon/libpdcurses.dll /mingw/bin/" - bash -lc "cd PDCursesMod-%MINGW_PDCM_VERS% && install wincon/libpdcurses.dll /mingw/bin/libpdcurses-wincon.dll" - bash -lc "cd PDCursesMod-%MINGW_PDCM_VERS% && install wingui/libpdcurses.dll /mingw/bin/libpdcurses-wingui.dll" - bash -lc "cd PDCursesMod-%MINGW_PDCM_VERS% && install vt/libpdcurses.dll /mingw/bin/libpdcurses-vt.dll" - bash -lc "install -d /mingw/include/pdcurses" - bash -lc "cd PDCursesMod-%MINGW_PDCM_VERS% && install -m 0644 curses.h panel.h term.h /mingw/include/pdcurses/" - bash -lc "cd PDCursesMod-%MINGW_PDCM_VERS% && install -m 0644 pdcurses.h /mingw/include/" - - - name: Install LibXML2 - if: steps.restore-msys.outputs.cache-hit != 'true' - run: | - curl -L https://github.com/GNOME/libxml2/archive/refs/tags/v%MINGW_XML2_VERS%.tar.gz -o libxml2-%MINGW_XML2_VERS%.tar.xz - tar -xvf libxml2-%MINGW_XML2_VERS%.tar.xz - bash -lc "cd libxml2-%MINGW_XML2_VERS% && ./autogen.sh" - bash -lc "cd libxml2-%MINGW_XML2_VERS% && ./configure --prefix=/mingw && make" - bash -lc "cd libxml2-%MINGW_XML2_VERS% && make install" - - - name: Cleanup MSYS1 env - if: steps.restore-msys.outputs.cache-hit != 'true' - run: | - rmdir /Q /S %MSYS_ROOT%\docs - rmdir /Q /S %MSYS_ROOT%\var - del /Q %MSYS_ROOT%\bin\gdb.exe - - - name: Save MSYS1 cache - if: steps.restore-msys.outputs.cache-hit != 'true' - uses: actions/cache/save@v4 - with: - key: cache-msys-${{ matrix.target }} - path: ${{ env.MSYS_ROOT }} - - - name: Download CJSON sources - run: | - curl -L https://github.com/DaveGamble/cJSON/archive/refs/tags/v%MINGW_CJSON_VERS%.tar.gz -o cjson-%MINGW_CJSON_VERS%.tar.xz - tar -xvf cjson-%MINGW_CJSON_VERS%.tar.xz - copy cjson-%MINGW_CJSON_VERS%\cJSON.* .\libcob - - - name: Bootstrap GnuCOBOL - run: | - sed -i 's/AM_PROG_AR/m4_ifdef\(\[AM_PROG_AR\], \[AM_PROG_AR\]\)/g' .\configure.ac - sed -i 's/po extras doc tests/po extras tests/g' .\Makefile.am - bash -lc "./autogen.sh" - - - name: Configure GnuCOBOL - run: | - mkdir _build - sed -i 'N;s/else/else :;/g' .\configure - sed -i 's/\} else \:;/} else/g' .\configure - sed -i 's/#else \:;/#else/g' .\configure - bash -lc "cd _build && CFLAGS=\"-I ../libcob\" ../configure %CFGOPT% --with-db --prefix=/opt/cobol/gnucobol" - - - name: Upload config-${{ matrix.target }}.log - uses: actions/upload-artifact@v4 - if: failure() - with: - name: config-${{ matrix.target }}.log - path: ${{ env.GITHUB_WORKSPACE }}/_build/config.log - - - name: Build GnuCOBOL - run: | - bash -lc "cd _build && CPATH=$(pwd)/.. make --jobs=$(($(nproc)+1))" - -# Note: the extra CPATH above is only required in debug builds, for some reason... - - - name: Install GnuCOBOL - run: | - bash -lc "cd _build && make install" - bash -lc "cd _build && find /opt/cobol > install.log" - - - name: Upload install-${{ matrix.target }}.log - uses: actions/upload-artifact@v4 - with: - name: install-${{ matrix.target }}.log - path: ${{ env.GITHUB_WORKSPACE }}/_build/install.log - - - name: Run testsuite - run: | - sed -i '/AT_SETUP(\[temporary path invalid\])/a AT_SKIP_IF(\[true\])' tests/testsuite.src/used_binaries.at - - sed -i '/AT_SETUP(\[Compare FLOAT-LONG with floating-point literal\])/a AT_SKIP_IF(\[true\])' tests/testsuite.src/run_fundamental.at - sed -i '/AT_SETUP(\[Numeric operations (3) PACKED-DECIMAL\])/a AT_SKIP_IF(\[true\])' tests/testsuite.src/run_fundamental.at - sed -i '/AT_SETUP(\[Numeric operations (7)\])/a AT_SKIP_IF(\[true\])' tests/testsuite.src/run_fundamental.at - sed -i '/AT_SETUP(\[integer arithmetic on floating-point var\])/a AT_SKIP_IF(\[true\])' tests/testsuite.src/run_fundamental.at - sed -i '/AT_SETUP(\[FLOAT-DECIMAL w\/o SIZE ERROR\])/a AT_SKIP_IF(\[true\])' tests/testsuite.src/run_misc.at - sed -i '/AT_SETUP(\[FLOAT-SHORT \/ FLOAT-LONG w\/o SIZE ERROR\])/a AT_SKIP_IF(\[true\])' tests/testsuite.src/run_misc.at - sed -i '/AT_SETUP(\[FLOAT-LONG with SIZE ERROR\])/a AT_SKIP_IF(\[true\])' tests/testsuite.src/run_misc.at - sed -i '/AT_SETUP(\[FUNCTION ANNUITY\])/a AT_SKIP_IF(\[true\])' tests/testsuite.src/run_functions.at - sed -i '/AT_SETUP(\[FUNCTION INTEGER\])/a AT_SKIP_IF(\[true\])' tests/testsuite.src/run_functions.at - sed -i '/AT_SETUP(\[FUNCTION MOD (valid)\])/a AT_SKIP_IF(\[true\])' tests/testsuite.src/run_functions.at - sed -i '/AT_SETUP(\[FUNCTION SECONDS-FROM-FORMATTED-TIME\])/a AT_SKIP_IF(\[true\])' tests/testsuite.src/run_functions.at - sed -i '/AT_SETUP(\[GCOS floating-point usages\])/a AT_SKIP_IF(\[true\])' tests/testsuite.src/run_extensions.at - sed -i '/AT_SETUP(\[BINARY: 64bit unsigned arithmetic notrunc\])/a AT_SKIP_IF(\[true\])' tests/testsuite.src/data_binary.at - sed -i '/AT_SETUP(\[DISPLAY: ADD and SUBTRACT w\/o SIZE ERROR\])/a AT_SKIP_IF(\[true\])' tests/testsuite.src/data_display.at - sed -i '/AT_SETUP(\[DISPLAY: ADD and SUBTRACT, all ROUNDED MODEs\])/a AT_SKIP_IF(\[true\])' tests/testsuite.src/data_display.at - sed -i '/AT_SETUP(\[BCD ADD and SUBTRACT w\/o SIZE ERROR\])/a AT_SKIP_IF(\[true\])' tests/testsuite.src/data_packed.at - sed -i '/AT_SETUP(\[BCD ADD and SUBTRACT, all ROUNDED MODEs\])/a AT_SKIP_IF(\[true\])' tests/testsuite.src/data_packed.at - - bash -lc "cd _build/tests && CPATH=/opt/cobol/gnucobol/include make check TESTSUITEFLAGS=\"--jobs=$(($(nproc)+1))\"" - -# Note: the extra CPATH above is only required in debug builds, for some reason... - -# The NIST testsuite hangs forever in IF -# bash -lc "CPATH=/opt/cobol/gnucobol/include make test" - - - name: Upload testsuite-${{ matrix.target }}.log - uses: actions/upload-artifact@v4 - with: - name: testsuite-${{ matrix.target }}.log - path: ${{ env.GITHUB_WORKSPACE }}/_build/tests/testsuite.log - - - name: Package GnuCOBOL - run: | - bash -lc "cd _build && make distmingw" - - - name: Upload GnuCOBOL_mingw-${{ matrix.target }} - uses: actions/upload-artifact@v4 - with: - name: GnuCOBOL_mingw-${{ matrix.target }} - path: ${{ env.GITHUB_WORKSPACE }}/_build/${{ env.DISTDIR }} diff --git a/.github/workflows/windows-msys2.yml b/.github/workflows/windows-msys2.yml index f2b5c13e9..689a489b1 100644 --- a/.github/workflows/windows-msys2.yml +++ b/.github/workflows/windows-msys2.yml @@ -8,18 +8,9 @@ on: workflow_dispatch: jobs: - build: - strategy: - fail-fast: false - matrix: - include: - - { os: windows-latest, target: release, sys: mingw64, env: x86_64 } - - { os: windows-latest, target: debug, sys: mingw64, env: x86_64 } - - { os: windows-latest, target: debug, sys: ucrt64, env: ucrt-x86_64 } - - { os: windows-latest, target: debug, sys: clang64, env: clang-x86_64 } - # - { target: debug, sys: mingw32, env: i686 } - runs-on: ${{matrix.os}} - timeout-minutes: 45 + prepare: + runs-on: windows-latest + timeout-minutes: 30 steps: @@ -31,54 +22,127 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - name: Setup environment + - name: Install packages + uses: msys2/setup-msys2@v2 + with: + update: true + msystem: mingw64 + install: autoconf automake libtool make flex bison help2man texinfo texinfo-tex + mingw-w64-x86_64-cc + mingw-w64-x86_64-gmp mingw-w64-x86_64-texlive-core + mingw-w64-x86_64-gettext-runtime gettext-devel + + - name: Bootstrap GnuCOBOL + shell: msys2 {0} + run: | + ./build_aux/bootstrap install + + - name: Configure GnuCOBOL + shell: msys2 {0} + run: | + mkdir _build + cd _build + ../configure --without-db --without-curses --without-xml2 --without-json + + - name: Build GnuCOBOL Source Distribution + shell: msys2 {0} + run: | + make -C _build --jobs=$(($(nproc)+1)) + make -C _build --jobs=$(($(nproc)+1)) dist + + - name: Upload config-dist.log + uses: actions/upload-artifact@v4 + if: ${{ ! cancelled() }} #-> always upload as build result documentation + with: + name: config-dist.log + path: _build/config.log + + - name: Upload dist tarball + uses: actions/upload-artifact@v4 + with: + name: gnucobol-ci source distribution msys2 + path: _build/gnucobol*.tar.gz + if-no-files-found: error + retention-days: 1 + + build: + strategy: + fail-fast: false + matrix: + include: + - { target: release, sys: mingw64, env: x86_64 } + - { target: debug, sys: mingw64, env: x86_64 } + - { target: release, sys: ucrt64, env: ucrt-x86_64 } + - { target: release, sys: clang64, env: clang-x86_64 } + - { target: release, sys: mingw32, env: i686 } + runs-on: windows-latest + needs: prepare + timeout-minutes: 45 + + steps: + + - name: Build environment setup run: | - echo GITHUB_WORKSPACE=$env:GITHUB_WORKSPACE >> $env:GITHUB_ENV - If ("${{ matrix.target }}" -eq "release") { + if ("${{ matrix.target }}" -eq "release") { echo DISTDIR=GnuCOBOL_mingw >> $env:GITHUB_ENV - echo CFGOPT= >> $env:GITHUB_ENV - } Else { + echo CFGOPT="--with-pkgversion=GnuCOBOL-CI-MSYS2" >> $env:GITHUB_ENV + } else { echo DISTDIR=GnuCOBOL_mingw_dbg >> $env:GITHUB_ENV - echo CFGOPT="--enable-debug --enable-cobc-internal-checks --enable-hardening" >> $env:GITHUB_ENV + echo CFGOPT="--with-pkgversion=GnuCOBOL-CI-MSYS2-debug --enable-debug --enable-cobc-internal-checks --enable-hardening" >> $env:GITHUB_ENV + } + # Common options (dependencies) + echo CFGOPT="$env:CFGOPT --with-math=gmp --with-curses=ncursesw --with-xml2 --with-json=json-c" >> $env:GITHUB_ENV + # Conditional inclusion of --with-db (MSYS2 does not provide 32bit builds for BDB any more) + if ("${{ matrix.sys }}" -ne "mingw32") { + echo CFGOPT="$env:CFGOPT --with-db" >> $env:GITHUB_ENV + } else { + echo CFGOPT="$env:CFGOPT --without-db" >> $env:GITHUB_ENV } - - name: Install packages + - name: Update and install packages uses: msys2/setup-msys2@v2 with: update: true msystem: ${{matrix.sys}} - install: autoconf automake libtool make flex bison help2man texinfo + install: make diffutils mingw-w64-${{matrix.env}}-cc - mingw-w64-${{matrix.env}}-gmp gmp-devel - mingw-w64-${{matrix.env}}-gettext-runtime gettext-devel + mingw-w64-${{matrix.env}}-gmp + mingw-w64-${{matrix.env}}-gettext-runtime mingw-w64-${{matrix.env}}-ncurses mingw-w64-${{matrix.env}}-libxml2 - mingw-w64-${{matrix.env}}-cjson - mingw-w64-${{matrix.env}}-db libdb-devel + mingw-w64-${{matrix.env}}-json-c - - name: Bootstrap GnuCOBOL - shell: msys2 {0} - run: | - ./build_aux/bootstrap install + - name: BDB package + uses: msys2/setup-msys2@v2 + if: matrix.sys != 'mingw32' # MSYS2 does not provide 32bit builds for it any more + with: + msystem: ${{matrix.sys}} + install: mingw-w64-${{matrix.env}}-db + + - name: Get CI dist tarball + uses: actions/download-artifact@v4 + with: + name: gnucobol-ci source distribution msys2 - name: Configure GnuCOBOL shell: msys2 {0} run: | + tar -xvf gnucobol*.tar.* --strip-components=1 mkdir _build cd _build - ../configure $CFGOPT --with-db --prefix=/opt/cobol/gnucobol + ../configure $CFGOPT + + - name: Build GnuCOBOL + shell: msys2 {0} + run: | + make -C _build --jobs=$(($(nproc)+1)) - name: Upload config-${{matrix.sys}}-${{matrix.target}}.log uses: actions/upload-artifact@v4 if: failure() with: name: config-${{matrix.sys}}-${{matrix.target}}.log - path: ${{ env.GITHUB_WORKSPACE }}/_build/config.log - - - name: Build GnuCOBOL - shell: msys2 {0} - run: | - make -C _build --jobs=$(($(nproc)+1)) + path: _build/config.log - name: Cache newcob.val uses: actions/cache@v4 @@ -88,38 +152,53 @@ jobs: save-always: true enableCrossOsArchive: true + - name: Run NIST85 testsuite + shell: msys2 {0} + run: | + make -C _build/tests test --jobs=$(($(nproc)+1)) + + - name: Upload NIST85 Test Suite results + if: ${{ ! cancelled() }} #-> always upload as build result documentation + uses: actions/upload-artifact@v4 + with: + name: NIST85 results on ${{matrix.sys}}-${{ matrix.target }} + path: | + _build/tests/cobol85/summary.* + _build/tests/cobol85/**/*.log + _build/tests/cobol85/**/*.out + _build/tests/cobol85/**/duration.txt + - name: Run testuite shell: msys2 {0} run: | - sed '/AT_SETUP(\[temporary path invalid\])/a \ - AT_SKIP_IF(\[true\])' \ - -i tests/testsuite.src/used_binaries.at - make -C _build/tests checkall \ - --jobs=$(($(nproc)+1)) \ - TESTSUITEFLAGS="--jobs=$(($(nproc)+1))" || \ - make -C _build/tests check \ - TESTSUITEFLAGS="--recheck --verbose" + # skip test as it sometimes works and sometimes not... + # instead of + # sed -i '/AT_SETUP(\[temporary path invalid\])/a AT_SKIP_IF(\[true\])' tests/testsuite.src/used_binaries.at + # use + sed -i '/used_binaries/{N;/temporary path invalid/{N;N;N;N;s/traceon/traceon; echo "workflow:1">"$at_check_line_file"; at_fn_check_skip 77/;}}' tests/testsuite + + # to work around regular hangs we run NIST first, then the internal + # and the later only with 2 jobs + # make -C _build/tests checkall TESTSUITEFLAGS="--jobs=$(($(nproc)+1))" || \ + make -C _build/tests check TESTSUITEFLAGS="--jobs=2" || \ + make -C _build/tests check TESTSUITEFLAGS="--recheck --verbose" - name: Upload testsuite-${{matrix.sys}}-${{matrix.target}}.log uses: actions/upload-artifact@v4 + if: ${{ ! cancelled() }} #-> always upload as build result documentation with: name: testsuite-${{matrix.sys}}-${{matrix.target}}.log - path: ${{ env.GITHUB_WORKSPACE }}/_build/tests/testsuite.log + path: _build/tests/testsuite.log - - name: Package GnuCOBOL + - name: Package GnuCOBOL MinGW nightly shell: msys2 {0} run: | make -C _build distmingw - - - name: Tar GnuCOBOL_mingw-${{matrix.sys}}-${{matrix.target}} - shell: msys2 {0} - run: | - cd _build - tar -cvf ../GnuCOBOL_mingw-${{matrix.sys}}-${{matrix.target}}.tar \ - "${{ env.DISTDIR }}" + tar -cvf GnuCOBOL_msys2-${{matrix.sys}}-${{matrix.target}}.tar \ + _build/"${{ env.DISTDIR }}" - name: Upload GnuCOBOL_mingw-${{matrix.sys}}-${{matrix.target}}.tar uses: actions/upload-artifact@v4 with: - name: GnuCOBOL_mingw-${{matrix.sys}}-${{matrix.target}}.tar - path: GnuCOBOL_mingw-${{matrix.sys}}-${{matrix.target}}.tar + name: GnuCOBOL_msys2-${{matrix.sys}}-${{matrix.target}}.tar + path: GnuCOBOL_msys2-${{matrix.sys}}-${{matrix.target}}.tar diff --git a/.gitpod.yml b/.gitpod.yml index ee365640a..21a39fabe 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -3,17 +3,17 @@ image: gitpod/workspace-c tasks: -- name: setup coding environment on Ubuntu 20.04 +- name: setup coding environment on Ubuntu 22.04 before: | # note: sadly we need this to be done every time as only /workspace is kept, but linked # against those dependencies; and also we do want to recompile after adjustments # this can all be dropped as soon as we would use a prepared docker sudo apt update && sudo apt upgrade -y sudo apt install -y build-essential libgmp-dev libdb-dev libjson-c-dev ncurses-dev libxml2-dev \ - automake libtool flex bison help2man texinfo \ + automake libtool flex bison help2man gettext texinfo \ lcov \ clangd bear - # sudo apt install gettext texlive-base # for make dist (po/*, doc/gnucobol.pdf) + # sudo apt install texlive-base # for make dist (doc/gnucobol.pdf) gp sync-done system-prepare - name: building GnuCOBOL diff --git a/ABOUT-NLS b/ABOUT-NLS index 186a3c65c..3cc828658 100644 --- a/ABOUT-NLS +++ b/ABOUT-NLS @@ -110,7 +110,7 @@ people who like their own language and write it well, and who are also able to synergize with other translators speaking the same language. Each translation team has its own mailing list. The up-to-date list of teams can be found at the Free Translation Project's homepage, -'https://translationproject.org/', in the "Teams" area. +'http://translationproject.org/', in the "Teams" area. If you'd like to volunteer to _work_ at translating messages, you should become a member of the translating team for your own language. @@ -1357,7 +1357,7 @@ mere existence a PO file and its wide availability in a distribution. If Jun 2014 seems to be old, you may fetch a more recent copy of this 'ABOUT-NLS' file on most GNU archive sites. The most up-to-date matrix with full percentage details can be found at -'https://translationproject.org/extra/matrix.html'. +'http://translationproject.org/extra/matrix.html'. 1.5 Using 'gettext' in new packages =================================== @@ -1376,4 +1376,4 @@ Free Translation Project is also available for packages which are not developed inside the GNU project. Therefore the information given above applies also for every other Free Software Project. Contact 'coordinator@translationproject.org' to make the '.pot' files available -to the translation teams. \ No newline at end of file +to the translation teams. diff --git a/ChangeLog b/ChangeLog index 398b4ef56..c5781dd89 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,31 @@ +2024-10-02 Simon Sobisch + + * configure.ac: new options --with-pkgversion=PKG and --with-bugurl=URL + see NEWS, currently only used in version and help output + +2024-09-29 Simon Sobisch + + * configure.ac: drop COB_LI_IS_LL in favor of existing COB_32_BIT_LONG + * configure.ac (cjson=local): use CJSON_CFLAGS and CJSON_LIBS also for + this case, fix include not to use quotes + +2024-09-27 Simon Sobisch + + * configure.ac: require autoconf 2.70 and drop check for lex-library with + noyywrap option for AC_PROG_LEX + * HACKING: document dependencies autoconf 2.70 and automake 1.16 and + several smaller text updates + * Makefile.am (checkmanual-code-coverage, checkall-code-coverage): new + targets removing the need to do that manually + * build_aux/ltmain.sh, m4/libtool.m4, m4/ltoptions.m4, m4/ltversion.m4: + update libtool from 2.46 to 2.53, dropping all manual patches + * DEPENDENCIES: added perl for running NIST85 + +2024-09-09 Simon Sobisch + + * README: add documentation for "make checkmanual" + 2024-08-10 Simon Sobisch * DEPENDENCIES, NEWS: document usage of libiconv diff --git a/DEPENDENCIES b/DEPENDENCIES index f0d54169b..1d2882ed5 100644 --- a/DEPENDENCIES +++ b/DEPENDENCIES @@ -137,7 +137,7 @@ The following libraries ARE required WHEN : JSON-C is distributed under Expat License. -5) charachter encoding support is needed and iconv is not provided +5) character encoding support is needed and iconv is not provided as part of libc BOTH runtime AND development components required. @@ -151,6 +151,14 @@ The following libraries ARE required WHEN : utf8 source encoding needs an implementation of the iconv API. +6) The NIST COBOL85 testsuite sould be used for verification; + the test runner "make test" REQUIRES: + + o Perl >= 5.0005 - https://www.perl.org + + Perl is licensed under its Artistic License, or the GNU General Public License (GPL). + + See HACKING if you wish to hack the GnuCOBOL source or build directly from version control as this includes the list of additional tools necessary for this task. diff --git a/DEPENDENCIES.md b/DEPENDENCIES.md index 289265bf5..2da3e8cc8 100644 --- a/DEPENDENCIES.md +++ b/DEPENDENCIES.md @@ -120,7 +120,7 @@ Support for GENERATE JSON is provided by *one* of the following: JSON-C is distributed under Expat License. -charachter encoding support +character encoding support ---------------------------- Support for partial character encoding is provided directly, @@ -131,3 +131,12 @@ If this is not provided by libc, it is provided by: * [libiconv](https://www.gnu.org/software/libiconv/) GNU libiconv is distributed under GNU Lesser General Public License. + + +NIST COBOL85 testsuite +---------------------------- +To be able to run `make test`: + +* [Perl](https://www.perl.org) >= 5.0005 + + Perl is licensed under its Artistic License, or the GNU General Public License (GPL). diff --git a/HACKING b/HACKING index 2d507ce4a..c9ad4cc49 100644 --- a/HACKING +++ b/HACKING @@ -16,18 +16,18 @@ following extra packages need to be installed with versions equal or greater. If you build from VCS the tools in the first 4 lists are always needed. For running "autogen.sh" (necessary after VCS checkout) / reconfigure: - o autoconf 2.64 - o automake 1.13 - o libtool 2.2.6 + o autoconf 2.70 + o automake 1.16 + o libtool 2.2.6 (2.5.3 highly+ suggested, can be easily installed locally) o m4 1.4.12 -If you modify top-level configure.ac or Makefile.am in any directory then -you will need to run "autoreconf -I m4" to regenerate the necessary files. +If you modify top-level configure.ac or Makefile.am in any directory and rerun +"make", the build system will regenerate the necessary files. -If you want to update to a newer automake/libtool version or get errors -about wrong version numbers in m4 run "autoreconf -vfi -I m4" instead. +If you want to update to a different automake/libtool version or get errors +about wrong version numbers in m4 run "autogen.sh install" instead. -For compiling (when changing flex/bison sources): +For compiling (when changing pparser/scanner sources): o Bison 2.3 (will be changed to 3.6 with GnuCOBOL 4) o Flex 2.5.35 @@ -108,4 +108,4 @@ OR # if you want to compare with an There should be no difference shown as long as the "old version" passed the same tests as the new version - given the example above: there was no support for REPORT WRITER in 2.2 so there would be an expected failure -of the RW tests). +of the RW tests. diff --git a/Makefile.am b/Makefile.am index 5e0001e75..266d6f889 100644 --- a/Makefile.am +++ b/Makefile.am @@ -166,9 +166,18 @@ vcs-update: distbin distbin-gzip distbin-bzip2 distbin-lzip distbin-xz test: all - cd tests && $(MAKE) $(AM_MAKEFLAGS) test + $(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C tests test checkmanual: all - cd tests && $(MAKE) $(AM_MAKEFLAGS) checkmanual + $(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C tests checkmanual checkall: check test - + +@CODE_COVERAGE_ENABLED_TRUE@checkmanual-code-coverage: +@CODE_COVERAGE_ENABLED_TRUE@ -$(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -k checkmanual +@CODE_COVERAGE_ENABLED_TRUE@ $(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) code-coverage-capture +@CODE_COVERAGE_ENABLED_FALSE@checkmanual-code-coverage: check-code-coverage + +@CODE_COVERAGE_ENABLED_TRUE@checkall-code-coverage: +@CODE_COVERAGE_ENABLED_TRUE@ -$(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -k checkall +@CODE_COVERAGE_ENABLED_TRUE@ $(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) code-coverage-capture +@CODE_COVERAGE_ENABLED_FALSE@checkall-code-coverage: check-code-coverage diff --git a/NEWS b/NEWS index 411ca2cc0..306f35115 100644 --- a/NEWS +++ b/NEWS @@ -25,6 +25,14 @@ NEWS - user visible changes -*- outline -*- more work in progress +* Changes that potentially effect recompilation of existing programs: + +** runtime checks for invalid numerical data in emitter fields of MOVE or SET + statements are now performed only when at least one receiver field + is of category numeric or numeric-edited. This enables programming + patterns where invalid numerical data (e.g, SPACES) encode "absent" + data + * Important Bugfixes ** #904: MOVE PACKED-DECIMAL unsigned to signed led to bad sign @@ -57,6 +65,9 @@ NEWS - user visible changes -*- outline -*- ** New option -fdefault-file-colseq to specify the default file collating sequence +** New options -M, -MP, -MG, -MD and -MQ to output COPY dependencies + to a file (see "Dependencies options" in the GnuCOBOL manual) + * More notable changes ** execution times were significantly reduced for the following: @@ -83,9 +94,20 @@ NEWS - user visible changes -*- outline -*- this is used for character encoding support, which otherwise is only provided partially +** configure now accepts --with-bugurl=URL which can be used to output a link + to an external or local URL (like file://) instead of the bug mailing list + +** configure now accepts --with-pkgversion=PKG which can be used to customize + the version output with a free-standing string (like revision number or + package manager version) + ** use the "default" -shared flag to build dynamic libraries on macOS so as to fix testuite issues with recent macOS versions +** "make checkmanual" was extended to be also usable with tmux and + allows to override the test runner and to attach for screen/tmux sessions, + see README for further details + * Known issues in 3.x ** testsuite: diff --git a/README b/README index 4b32ced96..6b5ce2ede 100644 --- a/README +++ b/README @@ -145,6 +145,23 @@ Tests make checkall + You may also optionally perform a series of semi-manual tests to + verify a working extended screenio. + make checkmanual + The test execution is automatic but the user needs to check for + the expected result. See tests/run_prog_manual.sh for tweaking the + test runner used (which is otherwise deduced from the environment), + either in that script or via TESTRUNNER environment variable. + +** NOTE ** + The semi-manual tests need either "xterm", GNU "screen" or "tmux" + installed and will run within a detached "cmd" on MSYS based + systems otherwise. + For running with screen or tmux execute the following from + a separate terminal, directly after running the testsuite: + tests/run_prog_manual.sh attach + ... and leave that using "exit" at the end of the tests + ============ The following is only interesting for advanced use. diff --git a/README.md b/README.md index 7106f6948..39890f5f7 100644 --- a/README.md +++ b/README.md @@ -88,13 +88,33 @@ If the the COBOL85 testsuite is not already in the build- or source-tree, `make test` will download it. For details see tests/cobol85/README. ** NOTE ** - The language interpreter "perl" is required to run COBOL85 tests. + The language interpreter `perl` is required to run COBOL85 tests. If you want to run both testsuites you can run * `make checkall` + + You may also optionally perform a series of semi-manual tests to + verify a working extended screenio. + + * `make checkmanual` + + The test execution is automatic but the user needs to check for + the expected result. See `tests/run_prog_manual.sh` for tweaking the + test runner used (which is otherwise deduced from the environment), + either in that script or via TESTRUNNER environment variable. + +** NOTE ** + The semi-manual tests need either `xterm`, GNU `screen` or `tmux` + installed and will run within a detached `cmd.exe` on MSYS based + systems otherwise. + For running with screen or tmux execute the following from + a separate terminal, directly after running the testsuite: + `tests/run_prog_manual.sh attach` + ... and leave that using `exit` at the end of the tests + Installation ============ diff --git a/bin/ChangeLog b/bin/ChangeLog index acf8a135a..8f456551a 100644 --- a/bin/ChangeLog +++ b/bin/ChangeLog @@ -1,4 +1,12 @@ +2024-10-02 Simon Sobisch + + * cobcrun.c (cobcrun_print_version): build and package data only + shown in verbose mode; + PACKAGE_NAME may now be overwritten by PKGVERSION (new configure option) + * cobcrun.c (cobcrun_print_usage): handle PACKAGE_BUGREPORT_URL as + alternative to mailing list, now resolved by PACKAGE_BUGREPORT + 2023-07-24 Simon Sobisch * cob-config.in: prevent warning to use datadir, but not datarootdir; @@ -9,6 +17,10 @@ * cob-config.in: echo in same order as arguments; add missing arguments (--bindir,--libdir,--datadir,--mandir,--includedir) +2023-01-02 Simon Sobisch + + * cobcrun.c: use libcob's cob_getenv_direct instead of getenv + 2022-10-18 Simon Sobisch * cobcrun.c: minor validation - check for empty parameters @@ -287,7 +299,7 @@ then you can switch easily. -Copyright 2004-2008,2010,2012,2014-2023 Free Software Foundation, Inc. +Copyright 2004-2008,2010,2012,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/bin/cobcrun.c b/bin/cobcrun.c index cf4992f57..386ffd800 100644 --- a/bin/cobcrun.c +++ b/bin/cobcrun.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2004-2012, 2014-2023 Free Software Foundation, Inc. + Copyright (C) 2004-2012, 2014-2024 Free Software Foundation, Inc. Written by Roger While, Simon Sobisch, Brian Tiffin This file is part of GnuCOBOL. @@ -70,43 +70,47 @@ static const struct option long_options[] = { /** - * Display cobcrun build and version date + * Display cobcrun version info, optional with build and version date */ static void cobcrun_print_version (void) { - char cob_build_stamp[COB_MINI_BUFF]; - char month[64]; - int status, day, year; - - /* Set up build time stamp */ - memset (cob_build_stamp, 0, (size_t)COB_MINI_BUFF); - memset (month, 0, sizeof(month)); - day = 0; - year = 0; - status = sscanf (__DATE__, "%63s %d %d", month, &day, &year); - /* LCOV_EXCL_START */ - if (status != 3) { - snprintf (cob_build_stamp, (size_t)COB_MINI_MAX, - "%s %s", __DATE__, __TIME__); - /* LCOV_EXCL_STOP */ - } else { - snprintf (cob_build_stamp, (size_t)COB_MINI_MAX, - "%s %2.2d %4.4d %s", month, day, year, __TIME__); - } - - printf ("cobcrun (%s) %s.%d\n", PACKAGE_NAME, PACKAGE_VERSION, PATCH_LEVEL); - puts ("Copyright (C) 2023 Free Software Foundation, Inc."); - printf (_("License GPLv3+: GNU GPL version 3 or later <%s>"), "https://gnu.org/licenses/gpl.html"); + printf ("cobcrun (%s) %s.%d\n", + PACKAGE_NAME, PACKAGE_VERSION, PATCH_LEVEL); + 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" "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.")); - printf (_("Written by %s"), "Roger While, Simon Sobisch, Brian Tiffin"); putchar ('\n'); - printf (_("Built %s"), cob_build_stamp); - putchar ('\n'); - printf (_("Packaged %s"), COB_TAR_DATE); + printf (_("Written by %s"), "Roger While, Simon Sobisch, Brian Tiffin"); putchar ('\n'); + if (verbose_output) { + char cob_build_stamp[COB_MINI_BUFF]; + char month[64]; + int status, day, year; + + /* Set up build time stamp */ + memset (cob_build_stamp, 0, (size_t)COB_MINI_BUFF); + memset (month, 0, sizeof(month)); + day = 0; + year = 0; + status = sscanf (__DATE__, "%63s %d %d", month, &day, &year); + /* LCOV_EXCL_START */ + if (status != 3) { + snprintf (cob_build_stamp, (size_t)COB_MINI_MAX, + "%s %s", __DATE__, __TIME__); + /* LCOV_EXCL_STOP */ + } else { + snprintf (cob_build_stamp, (size_t)COB_MINI_MAX, + "%s %2.2d %4.4d %s", month, day, year, __TIME__); + } + printf (_("Built %s"), cob_build_stamp); + putchar ('\n'); + printf (_("Packaged %s"), COB_TAR_DATE); + putchar ('\n'); + } } /** @@ -140,12 +144,20 @@ cobcrun_print_usage (char * prog) " and any basename to the module preload list\n" " (COB_LIBRARY_PATH and/or COB_PRELOAD)")); putchar ('\n'); - printf (_("Report bugs to: %s\n" - "or (preferably) use the issue tracker via the home page."), "bug-gnucobol@gnu.org"); +#ifndef PACKAGE_BUGREPORT_URL + printf (_("Report bugs to: %s\n" + "or (preferably) use the issue tracker via the home page."), + PACKAGE_BUGREPORT); putchar ('\n'); - printf (_("GnuCOBOL home page: <%s>"), "https://www.gnu.org/software/gnucobol/"); +#else + puts (_("For bug reporting instructions, please see:")); + printf ("%s.\n", PACKAGE_BUGREPORT_URL); +#endif + printf (_("GnuCOBOL home page: <%s>"), + "https://www.gnu.org/software/gnucobol/"); putchar ('\n'); - printf (_("General help using GNU software: <%s>"), "https://www.gnu.org/gethelp/"); + printf (_("General help using GNU software: <%s>"), + "https://www.gnu.org/gethelp/"); putchar ('\n'); } diff --git a/build_aux/ChangeLog b/build_aux/ChangeLog index 667d414b0..186b572eb 100644 --- a/build_aux/ChangeLog +++ b/build_aux/ChangeLog @@ -1,4 +1,10 @@ +2024-09-02 Simon Sobisch + + * ar-lib, config.guess, config.rpath, config.sub, texinfo.tex: updated + to recent versions from + https://git.savannah.gnu.org/cgit/gnulib.git/tree/build-aux/ + 2023-06-03 Simon Sobisch * config.sub, texinfo.tex: updated to recent versions from @@ -22,13 +28,13 @@ * bootstrap: drop tarstamp.h generation, done via make * config.guess, config.sub: updated to recent versions from - git.savannah.gnu.org/gitweb/?p=config.git + https://git.savannah.gnu.org/cgit/config.git 2022-06-30 Simon Sobisch * config.guess, config.rpath, install-sh, mkinstalldirs, texinfo.tex: updated to recent versions from - git.savannah.gnu.org/gitweb/?p=config.git + https://git.savannah.gnu.org/cgit/config.git 2022-05-30 Simon Sobisch @@ -43,7 +49,7 @@ 2022-01-07 Simon Sobisch * config.sub, config.guess: updated to recent versions from - git.savannah.gnu.org/gitweb/?p=config.git to solve build issues + https://git.savannah.gnu.org/cgit/config.git to solve build issues on different machines 2021-10-11 Simon Sobisch @@ -180,7 +186,7 @@ without uname(1) [removed 2014-01-25] from old version -Copyright 2015-2023 Free Software Foundation, Inc. +Copyright 2015-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/build_aux/ar-lib b/build_aux/ar-lib index be8806a2f..7fbce26f0 100755 --- a/build_aux/ar-lib +++ b/build_aux/ar-lib @@ -2,9 +2,9 @@ # Wrapper for Microsoft lib.exe me=ar-lib -scriptversion=2019-07-04.01; # UTC +scriptversion=2024-06-19.01; # UTC -# Copyright (C) 2010-2019 Free Software Foundation, Inc. +# Copyright (C) 2010-2019,2024 Free Software Foundation, Inc. # Written by Peter Rosin . # # This program is free software; you can redistribute it and/or modify @@ -105,11 +105,15 @@ case $1 in Usage: $me [--help] [--version] PROGRAM ACTION ARCHIVE [MEMBER...] Members may be specified in a file named with @FILE. + +Report bugs to . +GNU Automake home page: . +General help using GNU software: . EOF exit $? ;; -v | --v*) - echo "$me, version $scriptversion" + echo "$me (GNU Automake) $scriptversion" exit $? ;; esac @@ -135,6 +139,10 @@ do AR="$AR $1" shift ;; + -nologo | -NOLOGO) + # We always invoke AR with -nologo, so don't need to add it again. + shift + ;; *) action=$1 shift diff --git a/build_aux/config.guess b/build_aux/config.guess index 980b02083..48a684601 100755 --- a/build_aux/config.guess +++ b/build_aux/config.guess @@ -1,10 +1,10 @@ #! /bin/sh # Attempt to guess a canonical system name. -# Copyright 1992-2022 Free Software Foundation, Inc. +# Copyright 1992-2024 Free Software Foundation, Inc. # shellcheck disable=SC2006,SC2268 # see below for rationale -timestamp='2022-09-17' +timestamp='2024-07-27' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -47,7 +47,7 @@ me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] -Output the configuration name of the system \`$me' is run on. +Output the configuration name of the system '$me' is run on. Options: -h, --help print this help, then exit @@ -60,13 +60,13 @@ version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. -Copyright 1992-2022 Free Software Foundation, Inc. +Copyright 1992-2024 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" -Try \`$me --help' for more information." +Try '$me --help' for more information." # Parse command line while test $# -gt 0 ; do @@ -102,8 +102,8 @@ GUESS= # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. -# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still -# use `HOST_CC' if defined, but it is deprecated. +# Historically, 'CC_FOR_BUILD' used to be named 'HOST_CC'. We still +# use 'HOST_CC' if defined, but it is deprecated. # Portable tmp directory creation inspired by the Autoconf team. @@ -123,7 +123,7 @@ set_cc_for_build() { dummy=$tmp/dummy case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in ,,) echo "int x;" > "$dummy.c" - for driver in cc gcc c89 c99 ; do + for driver in cc gcc c17 c99 c89 ; do if ($driver -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then CC_FOR_BUILD=$driver break @@ -155,6 +155,9 @@ Linux|GNU|GNU/*) set_cc_for_build cat <<-EOF > "$dummy.c" + #if defined(__ANDROID__) + LIBC=android + #else #include #if defined(__UCLIBC__) LIBC=uclibc @@ -162,6 +165,8 @@ Linux|GNU|GNU/*) LIBC=dietlibc #elif defined(__GLIBC__) LIBC=gnu + #elif defined(__LLVM_LIBC__) + LIBC=llvm #else #include /* First heuristic to detect musl libc. */ @@ -169,6 +174,7 @@ Linux|GNU|GNU/*) LIBC=musl #endif #endif + #endif EOF cc_set_libc=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` eval "$cc_set_libc" @@ -459,7 +465,7 @@ case $UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION in UNAME_RELEASE=`uname -v` ;; esac - # Japanese Language versions have a version number like `4.1.3-JL'. + # Japanese Language versions have a version number like '4.1.3-JL'. SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/'` GUESS=sparc-sun-sunos$SUN_REL ;; @@ -628,7 +634,8 @@ EOF sed 's/^ //' << EOF > "$dummy.c" #include - main() + int + main () { if (!__power_pc()) exit(1); @@ -712,7 +719,8 @@ EOF #include #include - int main () + int + main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); @@ -904,7 +912,7 @@ EOF fi ;; *:FreeBSD:*:*) - UNAME_PROCESSOR=`/usr/bin/uname -p` + UNAME_PROCESSOR=`uname -p` case $UNAME_PROCESSOR in amd64) UNAME_PROCESSOR=x86_64 ;; @@ -976,7 +984,27 @@ EOF GUESS=$UNAME_MACHINE-unknown-minix ;; aarch64:Linux:*:*) - GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + set_cc_for_build + CPU=$UNAME_MACHINE + LIBCABI=$LIBC + if test "$CC_FOR_BUILD" != no_compiler_found; then + ABI=64 + sed 's/^ //' << EOF > "$dummy.c" + #ifdef __ARM_EABI__ + #ifdef __ARM_PCS_VFP + ABI=eabihf + #else + ABI=eabi + #endif + #endif +EOF + cc_set_abi=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^ABI' | sed 's, ,,g'` + eval "$cc_set_abi" + case $ABI in + eabi | eabihf) CPU=armv8l; LIBCABI=$LIBC$ABI ;; + esac + fi + GUESS=$CPU-unknown-linux-$LIBCABI ;; aarch64_be:Linux:*:*) UNAME_MACHINE=aarch64_be @@ -1042,6 +1070,15 @@ EOF k1om:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; + kvx:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + kvx:cos:*:*) + GUESS=$UNAME_MACHINE-unknown-cos + ;; + kvx:mbr:*:*) + GUESS=$UNAME_MACHINE-unknown-mbr + ;; loongarch32:Linux:*:* | loongarch64:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; @@ -1197,7 +1234,7 @@ EOF GUESS=$UNAME_MACHINE-pc-sysv4.2uw$UNAME_VERSION ;; i*86:OS/2:*:*) - # If we were able to find `uname', then EMX Unix compatibility + # If we were able to find 'uname', then EMX Unix compatibility # is probably installed. GUESS=$UNAME_MACHINE-pc-os2-emx ;; @@ -1338,7 +1375,7 @@ EOF GUESS=ns32k-sni-sysv fi ;; - PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + PENTIUM:*:4.0*:*) # Unisys 'ClearPath HMP IX 4000' SVR4/MP effort # says GUESS=i586-unisys-sysv4 ;; @@ -1560,6 +1597,9 @@ EOF *:Unleashed:*:*) GUESS=$UNAME_MACHINE-unknown-unleashed$UNAME_RELEASE ;; + *:Ironclad:*:*) + GUESS=$UNAME_MACHINE-unknown-ironclad + ;; esac # Do we have a guess based on uname results? @@ -1583,6 +1623,7 @@ cat > "$dummy.c" <, 1996 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. -# -# The first argument passed to this file is the canonical host specification, -# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM -# or -# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM -# The environment variables CC, GCC, LDFLAGS, LD, with_gnu_ld -# should be set by the caller. -# -# The set of defined variables is at the end of this script. # Known limitations: # - On IRIX 6.5 with CC="cc", the run time search patch must not be longer @@ -25,6 +17,81 @@ # known workaround is to choose shorter directory names for the build # directory and/or the installation directory. +# func_usage +# outputs to stdout the --help usage message. +func_usage () +{ + echo "\ +Usage: config.rpath [OPTION] HOST + +Prints shell variable assignments that describe how to hardcode a directory +for the lookup of shared libraries into a binary (executable or shared library). + +The first argument passed to this file is the canonical host specification, + CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +or + CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM + +The environment variables CC, GCC, LDFLAGS, LD, with_gnu_ld +should be set by the caller. + +The set of defined variables is at the end of this script. + +Options: + --help print this help and exit + --version print version information and exit + +Send patches and bug reports to ." +} + +# func_version +# outputs to stdout the --version message. +func_version () +{ + echo "config.rpath (GNU gnulib, module havelib)" + echo "Copyright (C) 2024 Free Software Foundation, Inc. +License: All-Permissive. +This is free software: you are free to change and redistribute it. +There is NO WARRANTY, to the extent permitted by law." + echo + printf 'Written by %s.\n' "Bruno Haible" +} + +# func_fatal_error message +# outputs to stderr a fatal error message, and terminates the program. +func_fatal_error () +{ + echo "config.rpath: *** $1" 1>&2 + echo "config.rpath: *** Stop." 1>&2 + exit 1 +} + +# Command-line option processing. +while test $# -gt 0; do + case "$1" in + --help | --hel | --he | --h ) + func_usage + exit 0 ;; + --version | --versio | --versi | --vers | --ver | --ve | --v ) + func_version + exit 0 ;; + -- ) # Stop option processing + shift; break ;; + -* ) + func_fatal_error "unrecognized option: $1" + ;; + * ) + break ;; + esac +done + +if test $# -gt 1; then + func_fatal_error "too many arguments" +fi +if test $# -lt 1; then + func_fatal_error "too few arguments" +fi + # All known linkers require a '.a' archive for static linking (except MSVC, # which needs '.lib'). libext=a diff --git a/build_aux/config.sub b/build_aux/config.sub index de4259e40..4aaae46f6 100755 --- a/build_aux/config.sub +++ b/build_aux/config.sub @@ -1,10 +1,10 @@ #! /bin/sh # Configuration validation subroutine script. -# Copyright 1992-2023 Free Software Foundation, Inc. +# Copyright 1992-2024 Free Software Foundation, Inc. -# shellcheck disable=SC2006,SC2268 # see below for rationale +# shellcheck disable=SC2006,SC2268,SC2162 # see below for rationale -timestamp='2023-01-21' +timestamp='2024-05-27' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -76,13 +76,13 @@ Report bugs and patches to ." version="\ GNU config.sub ($timestamp) -Copyright 1992-2023 Free Software Foundation, Inc. +Copyright 1992-2024 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" -Try \`$me --help' for more information." +Try '$me --help' for more information." # Parse command line while test $# -gt 0 ; do @@ -120,7 +120,6 @@ case $# in esac # Split fields of configuration type -# shellcheck disable=SC2162 saved_IFS=$IFS IFS="-" read field1 field2 field3 field4 <&2 + echo "Invalid configuration '$1': more than four components" >&2 exit 1 ;; *-*-*-*) @@ -142,10 +141,21 @@ case $1 in # parts maybe_os=$field2-$field3 case $maybe_os in - nto-qnx* | linux-* | uclinux-uclibc* \ - | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \ - | netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \ - | storm-chaos* | os2-emx* | rtmk-nova* | managarm-*) + cloudabi*-eabi* \ + | kfreebsd*-gnu* \ + | knetbsd*-gnu* \ + | kopensolaris*-gnu* \ + | linux-* \ + | managarm-* \ + | netbsd*-eabi* \ + | netbsd*-gnu* \ + | nto-qnx* \ + | os2-emx* \ + | rtmk-nova* \ + | storm-chaos* \ + | uclinux-gnu* \ + | uclinux-uclibc* \ + | windows-* ) basic_machine=$field1 basic_os=$maybe_os ;; @@ -160,8 +170,12 @@ case $1 in esac ;; *-*) - # A lone config we happen to match not fitting any pattern case $field1-$field2 in + # Shorthands that happen to contain a single dash + convex-c[12] | convex-c3[248]) + basic_machine=$field2-convex + basic_os= + ;; decstation-3100) basic_machine=mips-dec basic_os= @@ -169,28 +183,88 @@ case $1 in *-*) # Second component is usually, but not always the OS case $field2 in - # Prevent following clause from handling this valid os + # Do not treat sunos as a manufacturer sun*os*) basic_machine=$field1 basic_os=$field2 ;; - zephyr*) - basic_machine=$field1-unknown - basic_os=$field2 - ;; # Manufacturers - dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \ - | att* | 7300* | 3300* | delta* | motorola* | sun[234]* \ - | unicom* | ibm* | next | hp | isi* | apollo | altos* \ - | convergent* | ncr* | news | 32* | 3600* | 3100* \ - | hitachi* | c[123]* | convex* | sun | crds | omron* | dg \ - | ultra | tti* | harris | dolphin | highlevel | gould \ - | cbm | ns | masscomp | apple | axis | knuth | cray \ - | microblaze* | sim | cisco \ - | oki | wec | wrs | winbond) + 3100* \ + | 32* \ + | 3300* \ + | 3600* \ + | 7300* \ + | acorn \ + | altos* \ + | apollo \ + | apple \ + | atari \ + | att* \ + | axis \ + | be \ + | bull \ + | cbm \ + | ccur \ + | cisco \ + | commodore \ + | convergent* \ + | convex* \ + | cray \ + | crds \ + | dec* \ + | delta* \ + | dg \ + | digital \ + | dolphin \ + | encore* \ + | gould \ + | harris \ + | highlevel \ + | hitachi* \ + | hp \ + | ibm* \ + | intergraph \ + | isi* \ + | knuth \ + | masscomp \ + | microblaze* \ + | mips* \ + | motorola* \ + | ncr* \ + | news \ + | next \ + | ns \ + | oki \ + | omron* \ + | pc533* \ + | rebel \ + | rom68k \ + | rombug \ + | semi \ + | sequent* \ + | siemens \ + | sgi* \ + | siemens \ + | sim \ + | sni \ + | sony* \ + | stratus \ + | sun \ + | sun[234]* \ + | tektronix \ + | tti* \ + | ultra \ + | unicom* \ + | wec \ + | winbond \ + | wrs) basic_machine=$field1-$field2 basic_os= ;; + zephyr*) + basic_machine=$field1-unknown + basic_os=$field2 + ;; *) basic_machine=$field1 basic_os=$field2 @@ -271,26 +345,6 @@ case $1 in basic_machine=arm-unknown basic_os=cegcc ;; - convex-c1) - basic_machine=c1-convex - basic_os=bsd - ;; - convex-c2) - basic_machine=c2-convex - basic_os=bsd - ;; - convex-c32) - basic_machine=c32-convex - basic_os=bsd - ;; - convex-c34) - basic_machine=c34-convex - basic_os=bsd - ;; - convex-c38) - basic_machine=c38-convex - basic_os=bsd - ;; cray) basic_machine=j90-cray basic_os=unicos @@ -713,15 +767,26 @@ case $basic_machine in vendor=dec basic_os=tops20 ;; - delta | 3300 | motorola-3300 | motorola-delta \ - | 3300-motorola | delta-motorola) + delta | 3300 | delta-motorola | 3300-motorola | motorola-delta | motorola-3300) cpu=m68k vendor=motorola ;; - dpx2*) + # This used to be dpx2*, but that gets the RS6000-based + # DPX/20 and the x86-based DPX/2-100 wrong. See + # https://oldskool.silicium.org/stations/bull_dpx20.htm + # https://www.feb-patrimoine.com/english/bull_dpx2.htm + # https://www.feb-patrimoine.com/english/unix_and_bull.htm + dpx2 | dpx2[23]00 | dpx2[23]xx) cpu=m68k vendor=bull - basic_os=sysv3 + ;; + dpx2100 | dpx21xx) + cpu=i386 + vendor=bull + ;; + dpx20) + cpu=rs6000 + vendor=bull ;; encore | umax | mmax) cpu=ns32k @@ -836,18 +901,6 @@ case $basic_machine in next | m*-next) cpu=m68k vendor=next - case $basic_os in - openstep*) - ;; - nextstep*) - ;; - ns2*) - basic_os=nextstep2 - ;; - *) - basic_os=nextstep3 - ;; - esac ;; np1) cpu=np1 @@ -936,14 +989,13 @@ case $basic_machine in ;; *-*) - # shellcheck disable=SC2162 saved_IFS=$IFS IFS="-" read cpu vendor <&2 + echo "Invalid configuration '$1': machine '$cpu-$vendor' not recognized" 1>&2 exit 1 ;; esac @@ -1306,11 +1491,12 @@ esac # Decode manufacturer-specific aliases for certain operating systems. -if test x$basic_os != x +if test x"$basic_os" != x then # First recognize some ad-hoc cases, or perhaps split kernel-os, or else just # set os. +obj= case $basic_os in gnu/linux*) kernel=linux @@ -1325,7 +1511,6 @@ case $basic_os in os=`echo "$basic_os" | sed -e 's|nto-qnx|qnx|'` ;; *-*) - # shellcheck disable=SC2162 saved_IFS=$IFS IFS="-" read kernel os <&2 + fi + ;; *) - echo Invalid configuration \`"$1"\': OS \`"$os"\' not recognized 1>&2 + echo "Invalid configuration '$1': OS '$os' not recognized" 1>&2 + exit 1 + ;; +esac + +case $obj in + aout* | coff* | elf* | pe*) + ;; + '') + # empty is fine + ;; + *) + echo "Invalid configuration '$1': Machine code format '$obj' not recognized" 1>&2 + exit 1 + ;; +esac + +# Here we handle the constraint that a (synthetic) cpu and os are +# valid only in combination with each other and nowhere else. +case $cpu-$os in + # The "javascript-unknown-ghcjs" triple is used by GHC; we + # accept it here in order to tolerate that, but reject any + # variations. + javascript-ghcjs) + ;; + javascript-* | *-ghcjs) + echo "Invalid configuration '$1': cpu '$cpu' is not valid with os '$os$obj'" 1>&2 exit 1 ;; esac # As a final step for OS-related things, validate the OS-kernel combination # (given a valid OS), if there is a kernel. -case $kernel-$os in - linux-gnu* | linux-dietlibc* | linux-android* | linux-newlib* \ - | linux-musl* | linux-relibc* | linux-uclibc* | linux-mlibc* ) +case $kernel-$os-$obj in + linux-gnu*- | linux-android*- | linux-dietlibc*- | linux-llvm*- \ + | linux-mlibc*- | linux-musl*- | linux-newlib*- \ + | linux-relibc*- | linux-uclibc*- | linux-ohos*- ) + ;; + uclinux-uclibc*- | uclinux-gnu*- ) ;; - uclinux-uclibc* ) + managarm-mlibc*- | managarm-kernel*- ) ;; - managarm-mlibc* | managarm-kernel* ) + windows*-msvc*-) ;; - -dietlibc* | -newlib* | -musl* | -relibc* | -uclibc* | -mlibc* ) + -dietlibc*- | -llvm*- | -mlibc*- | -musl*- | -newlib*- | -relibc*- \ + | -uclibc*- ) # These are just libc implementations, not actual OSes, and thus # require a kernel. - echo "Invalid configuration \`$1': libc \`$os' needs explicit kernel." 1>&2 + echo "Invalid configuration '$1': libc '$os' needs explicit kernel." 1>&2 exit 1 ;; - -kernel* ) - echo "Invalid configuration \`$1': \`$os' needs explicit kernel." 1>&2 + -kernel*- ) + echo "Invalid configuration '$1': '$os' needs explicit kernel." 1>&2 exit 1 ;; - *-kernel* ) - echo "Invalid configuration \`$1': \`$kernel' does not support \`$os'." 1>&2 + *-kernel*- ) + echo "Invalid configuration '$1': '$kernel' does not support '$os'." 1>&2 exit 1 ;; - kfreebsd*-gnu* | kopensolaris*-gnu*) + *-msvc*- ) + echo "Invalid configuration '$1': '$os' needs 'windows'." 1>&2 + exit 1 ;; - vxworks-simlinux | vxworks-simwindows | vxworks-spe) + kfreebsd*-gnu*- | knetbsd*-gnu*- | netbsd*-gnu*- | kopensolaris*-gnu*-) ;; - nto-qnx*) + vxworks-simlinux- | vxworks-simwindows- | vxworks-spe-) ;; - os2-emx) + nto-qnx*-) ;; - *-eabi* | *-gnueabi*) + os2-emx-) ;; - -*) + rtmk-nova-) + ;; + *-eabi*- | *-gnueabi*-) + ;; + none--*) + # None (no kernel, i.e. freestanding / bare metal), + # can be paired with an machine code file format + ;; + -*-) # Blank kernel with real OS is always fine. ;; - *-*) - echo "Invalid configuration \`$1': Kernel \`$kernel' not known to work with OS \`$os'." 1>&2 + --*) + # Blank kernel and OS with real machine code file format is always fine. + ;; + *-*-*) + echo "Invalid configuration '$1': Kernel '$kernel' not known to work with OS '$os'." 1>&2 exit 1 ;; esac @@ -1826,7 +2273,7 @@ case $vendor in *-riscix*) vendor=acorn ;; - *-sunos*) + *-sunos* | *-solaris*) vendor=sun ;; *-cnk* | *-aix*) @@ -1896,7 +2343,7 @@ case $vendor in ;; esac -echo "$cpu-$vendor-${kernel:+$kernel-}$os" +echo "$cpu-$vendor${kernel:+-$kernel}${os:+-$os}${obj:+-$obj}" exit # Local variables: diff --git a/build_aux/ltmain.sh b/build_aux/ltmain.sh index 9c3dc576e..def0a431a 100755 --- a/build_aux/ltmain.sh +++ b/build_aux/ltmain.sh @@ -1,12 +1,12 @@ -#! /bin/sh +#! /usr/bin/env sh ## DO NOT EDIT - This file generated from ./build-aux/ltmain.in -## by inline-source v2014-01-03.01 +## by inline-source v2019-02-19.15 -# libtool (GNU libtool) 2.4.6 +# libtool (GNU libtool) 2.5.3 # Provide generalized library-building support services. # Written by Gordon Matzigkeit , 1996 -# Copyright (C) 1996-2015, 2018 Free Software Foundation, Inc. +# Copyright (C) 1996-2019, 2021-2024 Free Software Foundation, Inc. # This is free software; see the source for copying conditions. There is NO # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. @@ -26,13 +26,13 @@ # 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 . +# along with this program. If not, see . PROGRAM=libtool PACKAGE=libtool -VERSION=2.4.6 -package_revision=2.4.6 +VERSION=2.5.3 +package_revision=2.5.3 ## ------ ## @@ -64,34 +64,25 @@ package_revision=2.4.6 # libraries, which are installed to $pkgauxdir. # Set a version string for this script. -scriptversion=2015-01-20.17; # UTC +scriptversion=2019-02-19.15; # UTC # General shell script boiler plate, and helper functions. # Written by Gary V. Vaughan, 2004 -# Copyright (C) 2004-2015 Free Software Foundation, Inc. -# This is free software; see the source for copying conditions. There is NO -# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -# 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 3 of the License, or -# (at your option) any later version. - -# As a special exception to the GNU General Public License, if you distribute -# this file as part of a program or library that is built using GNU Libtool, -# you may include this file under the same distribution terms that you use -# for the rest of that program. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNES 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 . +# This is free software. There is NO warranty; not even for +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# +# Copyright (C) 2004-2019, 2021, 2023-2024 Bootstrap Authors +# +# This file is dual licensed under the terms of the MIT license +# , and GPL version 2 or later +# . You must apply one of +# these licenses when using or redistributing this software or any of +# the files within it. See the URLs above, or the file `LICENSE` +# included in the Bootstrap distribution for the full license texts. -# Please report bugs or propose patches to gary@gnu.org. +# Please report bugs or propose patches to: +# ## ------ ## @@ -139,9 +130,12 @@ do _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" fi" done - -# CDPATH. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH +# These NLS vars are set unconditionally (bootstrap issue #24). Unset those +# in case the environment reset is needed later and the $save_* variant is not +# defined (see the code above). +LC_ALL=C +LANGUAGE=C +export LANGUAGE LC_ALL # Make sure IFS has a sensible default sp=' ' @@ -149,7 +143,7 @@ nl=' ' IFS="$sp $nl" -# There are apparently some retarded systems that use ';' as a PATH separator! +# There are apparently some systems that use ';' as a PATH separator! if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { @@ -159,6 +153,26 @@ if test "${PATH_SEPARATOR+set}" != set; then fi +# func_unset VAR +# -------------- +# Portably unset VAR. +# In some shells, an 'unset VAR' statement leaves a non-zero return +# status if VAR is already unset, which might be problematic if the +# statement is used at the end of a function (thus poisoning its return +# value) or when 'set -e' is active (causing even a spurious abort of +# the script in this case). +func_unset () +{ + { eval $1=; (eval unset $1) >/dev/null 2>&1 && eval unset $1 || : ; } +} + + +# Make sure CDPATH doesn't cause `cd` commands to output the target dir. +func_unset CDPATH + +# Make sure ${,E,F}GREP behave sanely. +func_unset GREP_OPTIONS + ## ------------------------- ## ## Locate command utilities. ## @@ -259,7 +273,7 @@ test -z "$SED" && { rm -f conftest.in conftest.tmp conftest.nl conftest.out } - func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin + func_path_progs "sed gsed" func_check_prog_sed "$PATH:/usr/xpg4/bin" rm -f conftest.sed SED=$func_path_progs_result } @@ -295,7 +309,7 @@ test -z "$GREP" && { rm -f conftest.in conftest.tmp conftest.nl conftest.out } - func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin + func_path_progs "grep ggrep" func_check_prog_grep "$PATH:/usr/xpg4/bin" GREP=$func_path_progs_result } @@ -360,6 +374,35 @@ sed_double_backslash="\ s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g s/\n//g" +# require_check_ifs_backslash +# --------------------------- +# Check if we can use backslash as IFS='\' separator, and set +# $check_ifs_backshlash_broken to ':' or 'false'. +require_check_ifs_backslash=func_require_check_ifs_backslash +func_require_check_ifs_backslash () +{ + _G_save_IFS=$IFS + IFS='\' + _G_check_ifs_backshlash='a\\b' + for _G_i in $_G_check_ifs_backshlash + do + case $_G_i in + a) + check_ifs_backshlash_broken=false + ;; + '') + break + ;; + *) + check_ifs_backshlash_broken=: + break + ;; + esac + done + IFS=$_G_save_IFS + require_check_ifs_backslash=: +} + ## ----------------- ## ## Global variables. ## @@ -580,16 +623,16 @@ if test yes = "$_G_HAVE_PLUSEQ_OP"; then { $debug_cmd - func_quote_for_eval "$2" - eval "$1+=\\ \$func_quote_for_eval_result" + func_quote_arg pretty "$2" + eval "$1+=\\ \$func_quote_arg_result" }' else func_append_quoted () { $debug_cmd - func_quote_for_eval "$2" - eval "$1=\$$1\\ \$func_quote_for_eval_result" + func_quote_arg pretty "$2" + eval "$1=\$$1\\ \$func_quote_arg_result" } fi @@ -1091,85 +1134,203 @@ func_relative_path () } -# func_quote_for_eval ARG... -# -------------------------- -# Aesthetically quote ARGs to be evaled later. -# This function returns two values: -# i) func_quote_for_eval_result -# double-quoted, suitable for a subsequent eval -# ii) func_quote_for_eval_unquoted_result -# has all characters that are still active within double -# quotes backslashified. -func_quote_for_eval () +# func_quote_portable EVAL ARG +# ---------------------------- +# Internal function to portably implement func_quote_arg. Note that we still +# keep attention to performance here so we as much as possible try to avoid +# calling sed binary (so far O(N) complexity as long as func_append is O(1)). +func_quote_portable () { $debug_cmd - func_quote_for_eval_unquoted_result= - func_quote_for_eval_result= - while test 0 -lt $#; do - case $1 in - *[\\\`\"\$]*) - _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;; - *) - _G_unquoted_arg=$1 ;; - esac - if test -n "$func_quote_for_eval_unquoted_result"; then - func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg" - else - func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg" + $require_check_ifs_backslash + + func_quote_portable_result=$2 + + # one-time-loop (easy break) + while true + do + if $1; then + func_quote_portable_result=`$ECHO "$2" | $SED \ + -e "$sed_double_quote_subst" -e "$sed_double_backslash"` + break fi - case $_G_unquoted_arg in - # Double-quote args containing shell metacharacters to delay - # word splitting, command substitution and variable expansion - # for a subsequent eval. - # Many Bourne shells cannot handle close brackets correctly - # in scan sets, so we specify it separately. - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - _G_quoted_arg=\"$_G_unquoted_arg\" + # Quote for eval. + case $func_quote_portable_result in + *[\\\`\"\$]*) + # Fallback to sed for $func_check_bs_ifs_broken=:, or when the string + # contains the shell wildcard characters. + case $check_ifs_backshlash_broken$func_quote_portable_result in + :*|*[\[\*\?]*) + func_quote_portable_result=`$ECHO "$func_quote_portable_result" \ + | $SED "$sed_quote_subst"` + break + ;; + esac + + func_quote_portable_old_IFS=$IFS + for _G_char in '\' '`' '"' '$' + do + # STATE($1) PREV($2) SEPARATOR($3) + set start "" "" + func_quote_portable_result=dummy"$_G_char$func_quote_portable_result$_G_char"dummy + IFS=$_G_char + for _G_part in $func_quote_portable_result + do + case $1 in + quote) + func_append func_quote_portable_result "$3$2" + set quote "$_G_part" "\\$_G_char" + ;; + start) + set first "" "" + func_quote_portable_result= + ;; + first) + set quote "$_G_part" "" + ;; + esac + done + done + IFS=$func_quote_portable_old_IFS ;; - *) - _G_quoted_arg=$_G_unquoted_arg - ;; + *) ;; esac - - if test -n "$func_quote_for_eval_result"; then - func_append func_quote_for_eval_result " $_G_quoted_arg" - else - func_append func_quote_for_eval_result "$_G_quoted_arg" - fi - shift + break done + + func_quote_portable_unquoted_result=$func_quote_portable_result + case $func_quote_portable_result in + # double-quote args containing shell metacharacters to delay + # word splitting, command substitution and variable expansion + # for a subsequent eval. + # many bourne shells cannot handle close brackets correctly + # in scan sets, so we specify it separately. + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + func_quote_portable_result=\"$func_quote_portable_result\" + ;; + esac } -# func_quote_for_expand ARG -# ------------------------- -# Aesthetically quote ARG to be evaled later; same as above, -# but do not quote variable references. -func_quote_for_expand () -{ - $debug_cmd +# func_quotefast_eval ARG +# ----------------------- +# Quote one ARG (internal). This is equivalent to 'func_quote_arg eval ARG', +# but optimized for speed. Result is stored in $func_quotefast_eval. +if test xyes = `(x=; printf -v x %q yes; echo x"$x") 2>/dev/null`; then + printf -v _GL_test_printf_tilde %q '~' + if test '\~' = "$_GL_test_printf_tilde"; then + func_quotefast_eval () + { + printf -v func_quotefast_eval_result %q "$1" + } + else + # Broken older Bash implementations. Make those faster too if possible. + func_quotefast_eval () + { + case $1 in + '~'*) + func_quote_portable false "$1" + func_quotefast_eval_result=$func_quote_portable_result + ;; + *) + printf -v func_quotefast_eval_result %q "$1" + ;; + esac + } + fi +else + func_quotefast_eval () + { + func_quote_portable false "$1" + func_quotefast_eval_result=$func_quote_portable_result + } +fi - case $1 in - *[\\\`\"]*) - _G_arg=`$ECHO "$1" | $SED \ - -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;; - *) - _G_arg=$1 ;; + +# func_quote_arg MODEs ARG +# ------------------------ +# Quote one ARG to be evaled later. MODEs argument may contain zero or more +# specifiers listed below separated by ',' character. This function returns two +# values: +# i) func_quote_arg_result +# double-quoted (when needed), suitable for a subsequent eval +# ii) func_quote_arg_unquoted_result +# has all characters that are still active within double +# quotes backslashified. Available only if 'unquoted' is specified. +# +# Available modes: +# ---------------- +# 'eval' (default) +# - escape shell special characters +# 'expand' +# - the same as 'eval'; but do not quote variable references +# 'pretty' +# - request aesthetic output, i.e. '"a b"' instead of 'a\ b'. This might +# be used later in func_quote to get output like: 'echo "a b"' instead +# of 'echo a\ b'. This is slower than default on some shells. +# 'unquoted' +# - produce also $func_quote_arg_unquoted_result which does not contain +# wrapping double-quotes. +# +# Examples for 'func_quote_arg pretty,unquoted string': +# +# string | *_result | *_unquoted_result +# ------------+-----------------------+------------------- +# " | \" | \" +# a b | "a b" | a b +# "a b" | "\"a b\"" | \"a b\" +# * | "*" | * +# z="${x-$y}" | "z=\"\${x-\$y}\"" | z=\"\${x-\$y}\" +# +# Examples for 'func_quote_arg pretty,unquoted,expand string': +# +# string | *_result | *_unquoted_result +# --------------+---------------------+-------------------- +# z="${x-$y}" | "z=\"${x-$y}\"" | z=\"${x-$y}\" +func_quote_arg () +{ + _G_quote_expand=false + case ,$1, in + *,expand,*) + _G_quote_expand=: + ;; esac - case $_G_arg in - # Double-quote args containing shell metacharacters to delay - # word splitting and command substitution for a subsequent eval. - # Many Bourne shells cannot handle close brackets correctly - # in scan sets, so we specify it separately. - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - _G_arg=\"$_G_arg\" + case ,$1, in + *,pretty,*|*,expand,*|*,unquoted,*) + func_quote_portable $_G_quote_expand "$2" + func_quote_arg_result=$func_quote_portable_result + func_quote_arg_unquoted_result=$func_quote_portable_unquoted_result + ;; + *) + # Faster quote-for-eval for some shells. + func_quotefast_eval "$2" + func_quote_arg_result=$func_quotefast_eval_result ;; esac +} + - func_quote_for_expand_result=$_G_arg +# func_quote MODEs ARGs... +# ------------------------ +# Quote all ARGs to be evaled later and join them into single command. See +# func_quote_arg's description for more info. +func_quote () +{ + $debug_cmd + _G_func_quote_mode=$1 ; shift + func_quote_result= + while test 0 -lt $#; do + func_quote_arg "$_G_func_quote_mode" "$1" + if test -n "$func_quote_result"; then + func_append func_quote_result " $func_quote_arg_result" + else + func_append func_quote_result "$func_quote_arg_result" + fi + shift + done } @@ -1215,8 +1376,8 @@ func_show_eval () _G_cmd=$1 _G_fail_exp=${2-':'} - func_quote_for_expand "$_G_cmd" - eval "func_notquiet $func_quote_for_expand_result" + func_quote_arg pretty,expand "$_G_cmd" + eval "func_notquiet $func_quote_arg_result" $opt_dry_run || { eval "$_G_cmd" @@ -1241,8 +1402,8 @@ func_show_eval_locale () _G_fail_exp=${2-':'} $opt_quiet || { - func_quote_for_expand "$_G_cmd" - eval "func_echo $func_quote_for_expand_result" + func_quote_arg expand,pretty "$_G_cmd" + eval "func_echo $func_quote_arg_result" } $opt_dry_run || { @@ -1369,30 +1530,26 @@ func_lt_ver () # End: #! /bin/sh -# Set a version string for this script. -scriptversion=2014-01-07.03; # UTC - # A portable, pluggable option parser for Bourne shell. # Written by Gary V. Vaughan, 2010 -# Copyright (C) 2010-2015 Free Software Foundation, Inc. -# This is free software; see the source for copying conditions. There is NO -# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -# 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 3 of the License, 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. +# This is free software. There is NO warranty; not even for +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# +# Copyright (C) 2010-2019, 2021, 2023-2024 Bootstrap Authors +# +# This file is dual licensed under the terms of the MIT license +# , and GPL version 2 or later +# . You must apply one of +# these licenses when using or redistributing this software or any of +# the files within it. See the URLs above, or the file `LICENSE` +# included in the Bootstrap distribution for the full license texts. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . +# Please report bugs or propose patches to: +# -# Please report bugs or propose patches to gary@gnu.org. +# Set a version string for this script. +scriptversion=2019-02-19.15; # UTC ## ------ ## @@ -1415,7 +1572,7 @@ scriptversion=2014-01-07.03; # UTC # # In order for the '--version' option to work, you will need to have a # suitably formatted comment like the one at the top of this file -# starting with '# Written by ' and ending with '# warranty; '. +# starting with '# Written by ' and ending with '# Copyright'. # # For '-h' and '--help' to work, you will also need a one line # description of your script's purpose in a comment directly above the @@ -1427,7 +1584,7 @@ scriptversion=2014-01-07.03; # UTC # to display verbose messages only when your user has specified # '--verbose'. # -# After sourcing this file, you can plug processing for additional +# After sourcing this file, you can plug in processing for additional # options by amending the variables from the 'Configuration' section # below, and following the instructions in the 'Option parsing' # section further down. @@ -1476,8 +1633,8 @@ fatal_help="Try '\$progname --help' for more information." ## ------------------------- ## # This section contains functions for adding, removing, and running hooks -# to the main code. A hook is just a named list of of function, that can -# be run in order later on. +# in the main code. A hook is just a list of function names that can be +# run in order later on. # func_hookable FUNC_NAME # ----------------------- @@ -1510,7 +1667,8 @@ func_add_hook () # func_remove_hook FUNC_NAME HOOK_FUNC # ------------------------------------ -# Remove HOOK_FUNC from the list of functions called by FUNC_NAME. +# Remove HOOK_FUNC from the list of hook functions to be called by +# FUNC_NAME. func_remove_hook () { $debug_cmd @@ -1519,10 +1677,28 @@ func_remove_hook () } +# func_propagate_result FUNC_NAME_A FUNC_NAME_B +# --------------------------------------------- +# If the *_result variable of FUNC_NAME_A _is set_, assign its value to +# *_result variable of FUNC_NAME_B. +func_propagate_result () +{ + $debug_cmd + + func_propagate_result_result=: + if eval "test \"\${${1}_result+set}\" = set" + then + eval "${2}_result=\$${1}_result" + else + func_propagate_result_result=false + fi +} + + # func_run_hooks FUNC_NAME [ARG]... # --------------------------------- # Run all hook functions registered to FUNC_NAME. -# It is assumed that the list of hook functions contains nothing more +# It's assumed that the list of hook functions contains nothing more # than a whitespace-delimited list of legal shell function names, and # no effort is wasted trying to catch shell meta-characters or preserve # whitespace. @@ -1532,22 +1708,19 @@ func_run_hooks () case " $hookable_fns " in *" $1 "*) ;; - *) func_fatal_error "'$1' does not support hook funcions.n" ;; + *) func_fatal_error "'$1' does not support hook functions." ;; esac eval _G_hook_fns=\$$1_hooks; shift for _G_hook in $_G_hook_fns; do - eval $_G_hook '"$@"' - - # store returned options list back into positional - # parameters for next 'cmd' execution. - eval _G_hook_result=\$${_G_hook}_result - eval set dummy "$_G_hook_result"; shift + func_unset "${_G_hook}_result" + eval $_G_hook '${1+"$@"}' + func_propagate_result $_G_hook func_run_hooks + if $func_propagate_result_result; then + eval set dummy "$func_run_hooks_result"; shift + fi done - - func_quote_for_eval ${1+"$@"} - func_run_hooks_result=$func_quote_for_eval_result } @@ -1557,10 +1730,18 @@ func_run_hooks () ## --------------- ## # In order to add your own option parsing hooks, you must accept the -# full positional parameter list in your hook function, remove any -# options that you action, and then pass back the remaining unprocessed -# options in '_result', escaped suitably for -# 'eval'. Like this: +# full positional parameter list from your hook function. You may remove +# or edit any options that you action, and then pass back the remaining +# unprocessed options in '_result', escaped +# suitably for 'eval'. +# +# The '_result' variable is automatically unset +# before your hook gets called; for best performance, only set the +# *_result variable when necessary (i.e. don't call the 'func_quote' +# function unnecessarily because it can be an expensive operation on some +# machines). +# +# Like this: # # my_options_prep () # { @@ -1570,9 +1751,8 @@ func_run_hooks () # usage_message=$usage_message' # -s, --silent don'\''t print informational messages # ' -# -# func_quote_for_eval ${1+"$@"} -# my_options_prep_result=$func_quote_for_eval_result +# # No change in '$@' (ignored completely by this hook). Leave +# # my_options_prep_result variable intact. # } # func_add_hook func_options_prep my_options_prep # @@ -1581,25 +1761,36 @@ func_run_hooks () # { # $debug_cmd # -# # Note that for efficiency, we parse as many options as we can +# args_changed=false +# +# # Note that, for efficiency, we parse as many options as we can # # recognise in a loop before passing the remainder back to the # # caller on the first unrecognised argument we encounter. # while test $# -gt 0; do # opt=$1; shift # case $opt in -# --silent|-s) opt_silent=: ;; +# --silent|-s) opt_silent=: +# args_changed=: +# ;; # # Separate non-argument short options: # -s*) func_split_short_opt "$_G_opt" # set dummy "$func_split_short_opt_name" \ # "-$func_split_short_opt_arg" ${1+"$@"} # shift +# args_changed=: # ;; -# *) set dummy "$_G_opt" "$*"; shift; break ;; +# *) # Make sure the first unrecognised option "$_G_opt" +# # is added back to "$@" in case we need it later, +# # if $args_changed was set to 'true'. +# set dummy "$_G_opt" ${1+"$@"}; shift; break ;; # esac # done # -# func_quote_for_eval ${1+"$@"} -# my_silent_option_result=$func_quote_for_eval_result +# # Only call 'func_quote' here if we processed at least one argument. +# if $args_changed; then +# func_quote eval ${1+"$@"} +# my_silent_option_result=$func_quote_result +# fi # } # func_add_hook func_parse_options my_silent_option # @@ -1610,17 +1801,26 @@ func_run_hooks () # # $opt_silent && $opt_verbose && func_fatal_help "\ # '--silent' and '--verbose' options are mutually exclusive." -# -# func_quote_for_eval ${1+"$@"} -# my_option_validation_result=$func_quote_for_eval_result # } # func_add_hook func_validate_options my_option_validation # -# You'll alse need to manually amend $usage_message to reflect the extra +# You'll also need to manually amend $usage_message to reflect the extra # options you parse. It's preferable to append if you can, so that # multiple option parsing hooks can be added safely. +# func_options_finish [ARG]... +# ---------------------------- +# Finishing the option parse loop (call 'func_options' hooks ATM). +func_options_finish () +{ + $debug_cmd + + func_run_hooks func_options ${1+"$@"} + func_propagate_result func_run_hooks func_options_finish +} + + # func_options [ARG]... # --------------------- # All the functions called inside func_options are hookable. See the @@ -1630,17 +1830,27 @@ func_options () { $debug_cmd - func_options_prep ${1+"$@"} - eval func_parse_options \ - ${func_options_prep_result+"$func_options_prep_result"} - eval func_validate_options \ - ${func_parse_options_result+"$func_parse_options_result"} + _G_options_quoted=false - eval func_run_hooks func_options \ - ${func_validate_options_result+"$func_validate_options_result"} + for my_func in options_prep parse_options validate_options options_finish + do + func_unset func_${my_func}_result + func_unset func_run_hooks_result + eval func_$my_func '${1+"$@"}' + func_propagate_result func_$my_func func_options + if $func_propagate_result_result; then + eval set dummy "$func_options_result"; shift + _G_options_quoted=: + fi + done - # save modified positional parameters for caller - func_options_result=$func_run_hooks_result + $_G_options_quoted || { + # As we (func_options) are top-level options-parser function and + # nobody quoted "$@" for us yet, we need to do it explicitly for + # caller. + func_quote eval ${1+"$@"} + func_options_result=$func_quote_result + } } @@ -1649,9 +1859,8 @@ func_options () # All initialisations required before starting the option parse loop. # Note that when calling hook functions, we pass through the list of # positional parameters. If a hook function modifies that list, and -# needs to propogate that back to rest of this script, then the complete -# modified list must be put in 'func_run_hooks_result' before -# returning. +# needs to propagate that back to rest of this script, then the complete +# modified list must be put in 'func_run_hooks_result' before returning. func_hookable func_options_prep func_options_prep () { @@ -1662,9 +1871,7 @@ func_options_prep () opt_warning_types= func_run_hooks func_options_prep ${1+"$@"} - - # save modified positional parameters for caller - func_options_prep_result=$func_run_hooks_result + func_propagate_result func_run_hooks func_options_prep } @@ -1676,25 +1883,32 @@ func_parse_options () { $debug_cmd - func_parse_options_result= - + _G_parse_options_requote=false # this just eases exit handling while test $# -gt 0; do # Defer to hook functions for initial option parsing, so they # get priority in the event of reusing an option name. func_run_hooks func_parse_options ${1+"$@"} - - # Adjust func_parse_options positional parameters to match - eval set dummy "$func_run_hooks_result"; shift + func_propagate_result func_run_hooks func_parse_options + if $func_propagate_result_result; then + eval set dummy "$func_parse_options_result"; shift + # Even though we may have changed "$@", we passed the "$@" array + # down into the hook and it quoted it for us (because we are in + # this if-branch). No need to quote it again. + _G_parse_options_requote=false + fi # Break out of the loop if we already parsed every option. test $# -gt 0 || break + # We expect that one of the options parsed in this function matches + # and thus we remove _G_opt from "$@" and need to re-quote. + _G_match_parse_options=: _G_opt=$1 shift case $_G_opt in --debug|-x) debug_cmd='set -x' - func_echo "enabling shell trace mode" + func_echo "enabling shell trace mode" >&2 $debug_cmd ;; @@ -1704,7 +1918,10 @@ func_parse_options () ;; --warnings|--warning|-W) - test $# = 0 && func_missing_arg $_G_opt && break + if test $# = 0 && func_missing_arg $_G_opt; then + _G_parse_options_requote=: + break + fi case " $warning_categories $1" in *" $1 "*) # trailing space prevents matching last $1 above @@ -1757,15 +1974,24 @@ func_parse_options () shift ;; - --) break ;; + --) _G_parse_options_requote=: ; break ;; -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; - *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; + *) set dummy "$_G_opt" ${1+"$@"}; shift + _G_match_parse_options=false + break + ;; esac + + if $_G_match_parse_options; then + _G_parse_options_requote=: + fi done - # save modified positional parameters for caller - func_quote_for_eval ${1+"$@"} - func_parse_options_result=$func_quote_for_eval_result + if $_G_parse_options_requote; then + # save modified positional parameters for caller + func_quote eval ${1+"$@"} + func_parse_options_result=$func_quote_result + fi } @@ -1782,12 +2008,10 @@ func_validate_options () test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" func_run_hooks func_validate_options ${1+"$@"} + func_propagate_result func_run_hooks func_validate_options # Bail if the options were screwed! $exit_cmd $EXIT_FAILURE - - # save modified positional parameters for caller - func_validate_options_result=$func_run_hooks_result } @@ -1843,8 +2067,8 @@ func_missing_arg () # func_split_equals STRING # ------------------------ -# Set func_split_equals_lhs and func_split_equals_rhs shell variables after -# splitting STRING at the '=' sign. +# Set func_split_equals_lhs and func_split_equals_rhs shell variables +# after splitting STRING at the '=' sign. test -z "$_G_HAVE_XSI_OPS" \ && (eval 'x=a/b/c; test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ @@ -1859,8 +2083,9 @@ then func_split_equals_lhs=${1%%=*} func_split_equals_rhs=${1#*=} - test "x$func_split_equals_lhs" = "x$1" \ - && func_split_equals_rhs= + if test "x$func_split_equals_lhs" = "x$1"; then + func_split_equals_rhs= + fi }' else # ...otherwise fall back to using expr, which is often a shell builtin. @@ -1870,7 +2095,7 @@ else func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` func_split_equals_rhs= - test "x$func_split_equals_lhs" = "x$1" \ + test "x$func_split_equals_lhs=" = "x$1" \ || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` } fi #func_split_equals @@ -1896,7 +2121,7 @@ else { $debug_cmd - func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'` + func_split_short_opt_name=`expr "x$1" : 'x\(-.\)'` func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` } fi #func_split_short_opt @@ -1938,31 +2163,44 @@ func_usage_message () # func_version # ------------ # Echo version message to standard output and exit. +# The version message is extracted from the calling file's header +# comments, with leading '# ' stripped: +# 1. First display the progname and version +# 2. Followed by the header comment line matching /^# Written by / +# 3. Then a blank line followed by the first following line matching +# /^# Copyright / +# 4. Immediately followed by any lines between the previous matches, +# except lines preceding the intervening completely blank line. +# For example, see the header comments of this file. func_version () { $debug_cmd printf '%s\n' "$progname $scriptversion" $SED -n ' - /(C)/!b go - :more - /\./!{ - N - s|\n# | | - b more - } - :go - /^# Written by /,/# warranty; / { - s|^# || - s|^# *$|| - s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| - p + /^# Written by /!b + s|^# ||; p; n + + :fwd2blnk + /./ { + n + b fwd2blnk } - /^# Written by / { - s|^# || - p + p; n + + :holdwrnt + s|^# || + s|^# *$|| + /^Copyright /!{ + /./H + n + b holdwrnt } - /^warranty; /q' < "$progpath" + + s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| + G + s|\(\n\)\n*|\1|g + p; q' < "$progpath" exit $? } @@ -1972,12 +2210,12 @@ func_version () # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'before-save-hook 'time-stamp) -# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" +# time-stamp-pattern: "30/scriptversion=%:y-%02m-%02d.%02H; # UTC" # time-stamp-time-zone: "UTC" # End: # Set a version string. -scriptversion='(GNU libtool) 2.4.6' +scriptversion='(GNU libtool) 2.5.3' # func_echo ARG... @@ -2068,13 +2306,13 @@ include the following information: compiler: $LTCC compiler flags: $LTCFLAGS linker: $LD (gnu? $with_gnu_ld) - version: $progname (GNU libtool) 2.4.6 + version: $progname (GNU libtool) 2.5.3 automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` Report bugs to . -GNU libtool home page: . -General help using GNU software: ." +GNU libtool home page: . +General help using GNU software: ." exit 0 } @@ -2124,7 +2362,7 @@ fi # a configuration failure hint, and exit. func_fatal_configuration () { - func__fatal_error ${1+"$@"} \ + func_fatal_error ${1+"$@"} \ "See the $PACKAGE documentation for more information." \ "Fatal configuration error." } @@ -2270,6 +2508,8 @@ libtool_options_prep () nonopt= preserve_args= + _G_rc_lt_options_prep=: + # Shorthand for --mode=foo, only valid as the first argument case $1 in clean|clea|cle|cl) @@ -2293,11 +2533,16 @@ libtool_options_prep () uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) shift; set dummy --mode uninstall ${1+"$@"}; shift ;; + *) + _G_rc_lt_options_prep=false + ;; esac - # Pass back the list of options. - func_quote_for_eval ${1+"$@"} - libtool_options_prep_result=$func_quote_for_eval_result + if $_G_rc_lt_options_prep; then + # Pass back the list of options. + func_quote eval ${1+"$@"} + libtool_options_prep_result=$func_quote_result + fi } func_add_hook func_options_prep libtool_options_prep @@ -2309,9 +2554,12 @@ libtool_parse_options () { $debug_cmd + _G_rc_lt_parse_options=false + # Perform our own loop to consume as many options as possible in # each iteration. while test $# -gt 0; do + _G_match_lt_parse_options=: _G_opt=$1 shift case $_G_opt in @@ -2386,15 +2634,20 @@ libtool_parse_options () func_append preserve_args " $_G_opt" ;; - # An option not handled by this hook function: - *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; + # An option not handled by this hook function: + *) set dummy "$_G_opt" ${1+"$@"} ; shift + _G_match_lt_parse_options=false + break + ;; esac + $_G_match_lt_parse_options && _G_rc_lt_parse_options=: done - - # save modified positional parameters for caller - func_quote_for_eval ${1+"$@"} - libtool_parse_options_result=$func_quote_for_eval_result + if $_G_rc_lt_parse_options; then + # save modified positional parameters for caller + func_quote eval ${1+"$@"} + libtool_parse_options_result=$func_quote_result + fi } func_add_hook func_parse_options libtool_parse_options @@ -2415,10 +2668,10 @@ libtool_validate_options () # preserve --debug test : = "$debug_cmd" || func_append preserve_args " --debug" - case $host in + case $host_os in # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 - *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) + cygwin* | mingw* | windows* | pw32* | cegcc* | solaris2* | os2*) # don't eliminate duplications in $postdeps and $predeps opt_duplicate_compiler_generated_deps=: ;; @@ -2451,8 +2704,8 @@ libtool_validate_options () } # Pass back the unparsed argument list - func_quote_for_eval ${1+"$@"} - libtool_validate_options_result=$func_quote_for_eval_result + func_quote eval ${1+"$@"} + libtool_validate_options_result=$func_quote_result } func_add_hook func_validate_options libtool_validate_options @@ -2750,7 +3003,7 @@ EOF # func_convert_core_file_wine_to_w32 ARG # Helper function used by file name conversion functions when $build is *nix, -# and $host is mingw, cygwin, or some other w32 environment. Relies on a +# and $host is mingw, windows, cygwin, or some other w32 environment. Relies on a # correctly configured wine environment available, with the winepath program # in $build's $PATH. # @@ -2782,9 +3035,10 @@ func_convert_core_file_wine_to_w32 () # func_convert_core_path_wine_to_w32 ARG # Helper function used by path conversion functions when $build is *nix, and -# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly -# configured wine environment available, with the winepath program in $build's -# $PATH. Assumes ARG has no leading or trailing path separator characters. +# $host is mingw, windows, cygwin, or some other w32 environment. Relies on a +# correctly configured wine environment available, with the winepath program +# in $build's $PATH. Assumes ARG has no leading or trailing path separator +# characters. # # ARG is path to be converted from $build format to win32. # Result is available in $func_convert_core_path_wine_to_w32_result. @@ -3418,8 +3672,8 @@ func_mode_compile () esac done - func_quote_for_eval "$libobj" - test "X$libobj" != "X$func_quote_for_eval_result" \ + func_quote_arg pretty "$libobj" + test "X$libobj" != "X$func_quote_arg_result" \ && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ && func_warning "libobj name '$libobj' may not contain shell special characters." func_dirname_and_basename "$obj" "/" "" @@ -3439,7 +3693,7 @@ func_mode_compile () # On Cygwin there's no "real" PIC flag so we must build both object types case $host_os in - cygwin* | mingw* | pw32* | os2* | cegcc*) + cygwin* | mingw* | windows* | pw32* | os2* | cegcc*) pic_mode=default ;; esac @@ -3492,8 +3746,8 @@ compiler." func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 srcfile=$func_to_tool_file_result - func_quote_for_eval "$srcfile" - qsrcfile=$func_quote_for_eval_result + func_quote_arg pretty "$srcfile" + qsrcfile=$func_quote_arg_result # Only build a PIC object if we are building libtool libraries. if test yes = "$build_libtool_libs"; then @@ -3648,7 +3902,8 @@ This mode accepts the following additional options: -prefer-non-pic try to build non-PIC objects only -shared do not build a '.o' file suitable for static linking -static only build a '.o' file suitable for static linking - -Wc,FLAG pass FLAG directly to the compiler + -Wc,FLAG + -Xcompiler FLAG pass FLAG directly to the compiler COMPILE-COMMAND is a command to be used in creating a 'standard' object file from the given SOURCEFILE. @@ -3754,6 +4009,8 @@ The following components of LINK-COMMAND are treated specially: -weak LIBNAME declare that the target provides the LIBNAME interface -Wc,FLAG -Xcompiler FLAG pass linker-specific FLAG directly to the compiler + -Wa,FLAG + -Xassembler FLAG pass linker-specific FLAG directly to the assembler -Wl,FLAG -Xlinker FLAG pass linker-specific FLAG directly to the linker -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) @@ -4096,8 +4353,8 @@ func_mode_install () case $nonopt in *shtool*) :;; *) false;; esac then # Aesthetically quote it. - func_quote_for_eval "$nonopt" - install_prog="$func_quote_for_eval_result " + func_quote_arg pretty "$nonopt" + install_prog="$func_quote_arg_result " arg=$1 shift else @@ -4107,8 +4364,8 @@ func_mode_install () # The real first argument should be the name of the installation program. # Aesthetically quote it. - func_quote_for_eval "$arg" - func_append install_prog "$func_quote_for_eval_result" + func_quote_arg pretty "$arg" + func_append install_prog "$func_quote_arg_result" install_shared_prog=$install_prog case " $install_prog " in *[\\\ /]cp\ *) install_cp=: ;; @@ -4165,12 +4422,12 @@ func_mode_install () esac # Aesthetically quote the argument. - func_quote_for_eval "$arg" - func_append install_prog " $func_quote_for_eval_result" + func_quote_arg pretty "$arg" + func_append install_prog " $func_quote_arg_result" if test -n "$arg2"; then - func_quote_for_eval "$arg2" + func_quote_arg pretty "$arg2" fi - func_append install_shared_prog " $func_quote_for_eval_result" + func_append install_shared_prog " $func_quote_arg_result" done test -z "$install_prog" && \ @@ -4181,8 +4438,8 @@ func_mode_install () if test -n "$install_override_mode" && $no_mode; then if $install_cp; then :; else - func_quote_for_eval "$install_override_mode" - func_append install_shared_prog " -m $func_quote_for_eval_result" + func_quote_arg pretty "$install_override_mode" + func_append install_shared_prog " -m $func_quote_arg_result" fi fi @@ -4313,7 +4570,7 @@ func_mode_install () 'exit $?' tstripme=$stripme case $host_os in - cygwin* | mingw* | pw32* | cegcc*) + cygwin* | mingw* | windows* | pw32* | cegcc*) case $realname in *.dll.a) tstripme= @@ -4426,7 +4683,7 @@ func_mode_install () # Do a test to see if this is really a libtool program. case $host in - *cygwin* | *mingw*) + *cygwin* | *mingw* | *windows*) if func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" wrapper=$func_ltwrapper_scriptname_result @@ -4478,8 +4735,8 @@ func_mode_install () relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` $opt_quiet || { - func_quote_for_expand "$relink_command" - eval "func_echo $func_quote_for_expand_result" + func_quote_arg expand,pretty "$relink_command" + eval "func_echo $func_quote_arg_result" } if eval "$relink_command"; then : else @@ -4654,7 +4911,7 @@ extern \"C\" { $RM $export_symbols eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' case $host in - *cygwin* | *mingw* | *cegcc* ) + *cygwin* | *mingw* | *windows* | *cegcc* ) eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' ;; @@ -4666,7 +4923,7 @@ extern \"C\" { eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' case $host in - *cygwin* | *mingw* | *cegcc* ) + *cygwin* | *mingw* | *windows* | *cegcc* ) eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' ;; @@ -4680,7 +4937,7 @@ extern \"C\" { func_basename "$dlprefile" name=$func_basename_result case $host in - *cygwin* | *mingw* | *cegcc* ) + *cygwin* | *mingw* | *windows* | *cegcc* ) # if an import library, we need to obtain dlname if func_win32_import_lib_p "$dlprefile"; then func_tr_sh "$dlprefile" @@ -4706,8 +4963,16 @@ extern \"C\" { eval '$ECHO ": $name " >> "$nlist"' fi func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 - eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | - $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" + case $host in + i[3456]86-*-mingw32*) + eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | + $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" + ;; + *) + eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | + $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/__nm_//' >> '$nlist'" + ;; + esac } else # not an import lib $opt_dry_run || { @@ -4855,7 +5120,7 @@ static const void *lt_preloaded_setup() { # Transform the symbol file into the correct name. symfileobj=$output_objdir/${my_outputname}S.$objext case $host in - *cygwin* | *mingw* | *cegcc* ) + *cygwin* | *mingw* | *windows* | *cegcc* ) if test -f "$output_objdir/$my_outputname.def"; then compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` @@ -4931,7 +5196,7 @@ func_win32_libid () *ar\ archive*) # could be an import, or static # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | - $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then + $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64|pe-aarch64)' >/dev/null; then case $nm_interface in "MS dumpbin") if func_cygming_ms_implib_p "$1" || @@ -5198,7 +5463,7 @@ func_extract_archives () # # Emit a libtool wrapper script on stdout. # Don't directly open a file because we may want to -# incorporate the script contents within a cygwin/mingw +# incorporate the script contents within a cygwin/mingw/windows # wrapper executable. Must ONLY be called from within # func_mode_link because it depends on a number of variables # set therein. @@ -5206,7 +5471,7 @@ func_extract_archives () # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR # variable will take. If 'yes', then the emitted script # will assume that the directory where it is stored is -# the $objdir directory. This is a cygwin/mingw-specific +# the $objdir directory. This is a cygwin/mingw/windows-specific # behavior. func_emit_wrapper () { @@ -5258,7 +5523,8 @@ else if test \"\$libtool_execute_magic\" != \"$magic\"; then file=\"\$0\"" - qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` + func_quote_arg pretty "$ECHO" + qECHO=$func_quote_arg_result $ECHO "\ # A function that is used when there is no print builtin or printf. @@ -5268,7 +5534,7 @@ func_fallback_echo () \$1 _LTECHO_EOF' } - ECHO=\"$qECHO\" + ECHO=$qECHO fi # Very basic option parsing. These options are (a) specific to @@ -5330,7 +5596,7 @@ func_exec_program_core () " case $host in # Backslashes separate directories on plain windows - *-*-mingw | *-*-os2* | *-cegcc*) + *-*-mingw* | *-*-windows* | *-*-os2* | *-cegcc*) $ECHO "\ if test -n \"\$lt_option_debug\"; then \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 @@ -5398,7 +5664,7 @@ func_exec_program () file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` done - # Usually 'no', except on cygwin/mingw when embedded into + # Usually 'no', except on cygwin/mingw/windows when embedded into # the cwrapper. WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then @@ -5530,7 +5796,7 @@ EOF #endif #include #include -#if defined (_WIN32) && !defined (__GNUC__) +#if defined _WIN32 && !defined __GNUC__ # include # include # include @@ -5555,7 +5821,7 @@ EOF /* declarations of non-ANSI functions */ #if defined __MINGW32__ # ifdef __STRICT_ANSI__ -int _putenv (const char *); +_CRTIMP int __cdecl _putenv (const char *); # endif #elif defined __CYGWIN__ # ifdef __STRICT_ANSI__ @@ -5753,7 +6019,7 @@ main (int argc, char *argv[]) { EOF case $host in - *mingw* | *cygwin* ) + *mingw* | *windows* | *cygwin* ) # make stdout use "unix" line endings echo " setmode(1,_O_BINARY);" ;; @@ -5772,7 +6038,7 @@ EOF { /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX namespace, but it is not one of the ones we know about and - have already dealt with, above (inluding dump-script), then + have already dealt with, above (including dump-script), then report an error. Otherwise, targets might begin to believe they are allowed to use options in the LTWRAPPER_OPTION_PREFIX namespace. The first time any user complains about this, we'll @@ -5856,7 +6122,7 @@ EOF EOF case $host_os in - mingw*) + mingw* | windows*) cat <<"EOF" { char* p; @@ -5898,7 +6164,7 @@ EOF EOF case $host_os in - mingw*) + mingw* | windows*) cat <<"EOF" /* execv doesn't actually work on mingw as expected on unix */ newargz = prepare_spawn (newargz); @@ -6317,7 +6583,7 @@ lt_update_lib_path (const char *name, const char *value) EOF case $host_os in - mingw*) + mingw* | windows*) cat <<"EOF" /* Prepares an argument vector before calling spawn(). @@ -6492,7 +6758,7 @@ func_mode_link () $debug_cmd case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) + *-*-cygwin* | *-*-mingw* | *-*-windows* | *-*-pw32* | *-*-os2* | *-cegcc*) # It is impossible to link a dll without this setting, and # we shouldn't force the makefile maintainer to figure out # what system we are compiling for in order to pass an extra @@ -6556,10 +6822,12 @@ func_mode_link () xrpath= perm_rpath= temp_rpath= + temp_rpath_tail= thread_safe=no vinfo= vinfo_number=no weak_libs= + rpath_arg= single_module=$wl-single_module func_infer_tag $base_compile @@ -6611,9 +6879,9 @@ func_mode_link () while test "$#" -gt 0; do arg=$1 shift - func_quote_for_eval "$arg" - qarg=$func_quote_for_eval_unquoted_result - func_append libtool_args " $func_quote_for_eval_result" + func_quote_arg pretty,unquoted "$arg" + qarg=$func_quote_arg_unquoted_result + func_append libtool_args " $func_quote_arg_result" # If the previous option needs an argument, assign it. if test -n "$prev"; then @@ -6822,7 +7090,7 @@ func_mode_link () case $arg in [\\/]* | [A-Za-z]:[\\/]*) ;; *) - func_fatal_error "only absolute run-paths are allowed" + func_fatal_error "argument to -rpath is not absolute: $arg" ;; esac if test rpath = "$prev"; then @@ -6849,6 +7117,13 @@ func_mode_link () prev= continue ;; + xassembler) + func_append compiler_flags " -Xassembler $qarg" + prev= + func_append compile_command " -Xassembler $qarg" + func_append finalize_command " -Xassembler $qarg" + continue + ;; xcclinker) func_append linker_flags " $qarg" func_append compiler_flags " $qarg" @@ -6991,7 +7266,7 @@ func_mode_link () ;; esac case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) + *-*-cygwin* | *-*-mingw* | *-*-windows* | *-*-pw32* | *-*-os2* | *-cegcc*) testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` case :$dllsearchpath: in *":$dir:"*) ;; @@ -7011,7 +7286,7 @@ func_mode_link () -l*) if test X-lc = "X$arg" || test X-lm = "X$arg"; then case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) + *-*-cygwin* | *-*-mingw* | *-*-windows* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) # These systems don't actually have a C or math library (as such) continue ;; @@ -7019,7 +7294,7 @@ func_mode_link () # These systems don't actually have a C library (as such) test X-lc = "X$arg" && continue ;; - *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) + *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-midnightbsd*) # Do not include libc due to us having libc/libc_r. test X-lc = "X$arg" && continue ;; @@ -7039,7 +7314,7 @@ func_mode_link () esac elif test X-lc_r = "X$arg"; then case $host in - *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) + *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-midnightbsd*) # Do not include libc_r directly, use -pthread flag. continue ;; @@ -7069,9 +7344,21 @@ func_mode_link () prev=xcompiler continue ;; - - -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ - |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) + # Solaris ld rejects as of 11.4. Refer to Oracle bug 22985199. + -pthread) + case $host in + *solaris2*) ;; + *) + case "$new_inherited_linker_flags " in + *" $arg "*) ;; + * ) func_append new_inherited_linker_flags " $arg" ;; + esac + ;; + esac + continue + ;; + -mt|-mthreads|-kthread|-Kthread|-pthreads|--thread-safe \ + |-threads|-fopenmp|-fopenmp=*|-openmp|-mp|-xopenmp|-omp|-qsmp=*) func_append compiler_flags " $arg" func_append compile_command " $arg" func_append finalize_command " $arg" @@ -7094,7 +7381,7 @@ func_mode_link () -no-install) case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) + *-*-cygwin* | *-*-mingw* | *-*-windows* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) # The PATH hackery in wrapper scripts is required on Windows # and Darwin in order for the loader to find any dlls it needs. func_warning "'-no-install' is ignored for $host" @@ -7154,7 +7441,7 @@ func_mode_link () dir=$lt_sysroot$func_stripname_result ;; *) - func_fatal_error "only absolute run-paths are allowed" + func_fatal_error "argument ($arg) to '-R' is not an absolute path: $dir" ;; esac case "$xrpath " in @@ -7211,9 +7498,9 @@ func_mode_link () save_ifs=$IFS; IFS=, for flag in $args; do IFS=$save_ifs - func_quote_for_eval "$flag" - func_append arg " $func_quote_for_eval_result" - func_append compiler_flags " $func_quote_for_eval_result" + func_quote_arg pretty "$flag" + func_append arg " $func_quote_arg_result" + func_append compiler_flags " $func_quote_arg_result" done IFS=$save_ifs func_stripname ' ' '' "$arg" @@ -7227,16 +7514,21 @@ func_mode_link () save_ifs=$IFS; IFS=, for flag in $args; do IFS=$save_ifs - func_quote_for_eval "$flag" - func_append arg " $wl$func_quote_for_eval_result" - func_append compiler_flags " $wl$func_quote_for_eval_result" - func_append linker_flags " $func_quote_for_eval_result" + func_quote_arg pretty "$flag" + func_append arg " $wl$func_quote_arg_result" + func_append compiler_flags " $wl$func_quote_arg_result" + func_append linker_flags " $func_quote_arg_result" done IFS=$save_ifs func_stripname ' ' '' "$arg" arg=$func_stripname_result ;; + -Xassembler) + prev=xassembler + continue + ;; + -Xcompiler) prev=xcompiler continue @@ -7254,8 +7546,8 @@ func_mode_link () # -msg_* for osf cc -msg_*) - func_quote_for_eval "$arg" - arg=$func_quote_for_eval_result + func_quote_arg pretty "$arg" + arg=$func_quote_arg_result ;; # Flags to be passed through unchanged, with rationale: @@ -7272,12 +7564,33 @@ func_mode_link () # -tp=* Portland pgcc target processor selection # --sysroot=* for sysroot support # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization + # -specs=* GCC specs files # -stdlib=* select c++ std lib with clang + # -fdiagnostics-color* simply affects output + # -frecord-gcc-switches used to verify flags were respected + # -fsanitize=* Clang/GCC memory and address sanitizer + # -fno-sanitize* Clang/GCC memory and address sanitizer + # -shared-libsan Link with shared sanitizer runtimes (Clang) + # -static-libsan Link with static sanitizer runtimes (Clang) + # -no-canonical-prefixes Do not expand any symbolic links + # -fuse-ld=* Linker select flags for GCC + # -static-* direct GCC to link specific libraries statically + # -fcilkplus Cilk Plus language extension features for C/C++ + # -rtlib=* select c runtime lib with clang + # --unwindlib=* select unwinder library with clang + # -f{file|debug|macro|profile}-prefix-map=* needed for lto linking + # -Wa,* Pass flags directly to the assembler + # -Werror, -Werror=* Report (specified) warnings as errors -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ - -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*) - func_quote_for_eval "$arg" - arg=$func_quote_for_eval_result + -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-no-canonical-prefixes| \ + -stdlib=*|-rtlib=*|--unwindlib=*| \ + -specs=*|-fsanitize=*|-fno-sanitize*|-shared-libsan|-static-libsan| \ + -ffile-prefix-map=*|-fdebug-prefix-map=*|-fmacro-prefix-map=*|-fprofile-prefix-map=*| \ + -fdiagnostics-color*|-frecord-gcc-switches| \ + -fuse-ld=*|-static-*|-fcilkplus|-Wa,*|-Werror|-Werror=*) + func_quote_arg pretty "$arg" + arg=$func_quote_arg_result func_append compile_command " $arg" func_append finalize_command " $arg" func_append compiler_flags " $arg" @@ -7298,15 +7611,15 @@ func_mode_link () continue else # Otherwise treat like 'Some other compiler flag' below - func_quote_for_eval "$arg" - arg=$func_quote_for_eval_result + func_quote_arg pretty "$arg" + arg=$func_quote_arg_result fi ;; # Some other compiler flag. -* | +*) - func_quote_for_eval "$arg" - arg=$func_quote_for_eval_result + func_quote_arg pretty "$arg" + arg=$func_quote_arg_result ;; *.$objext) @@ -7426,15 +7739,27 @@ func_mode_link () *) # Unknown arguments in both finalize_command and compile_command need # to be aesthetically quoted because they are evaled later. - func_quote_for_eval "$arg" - arg=$func_quote_for_eval_result + func_quote_arg pretty "$arg" + arg=$func_quote_arg_result ;; esac # arg # Now actually substitute the argument into the commands. if test -n "$arg"; then - func_append compile_command " $arg" - func_append finalize_command " $arg" + if test -n "$rpath_arg"; then + func_append finalize_rpath " ${arg##*,}" + unset rpath_arg + else + case $arg in + -Wl,-rpath,*) + func_append finalize_rpath " ${arg##*,}";; + -Wl,-rpath) + rpath_arg=1;; + *) + func_append compile_command " $arg" + func_append finalize_command " $arg" + esac + fi fi done # argument parsing loop @@ -7605,7 +7930,7 @@ func_mode_link () found=false case $deplib in -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ - |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) + |-threads|-fopenmp|-fopenmp=*|-openmp|-mp|-xopenmp|-omp|-qsmp=*) if test prog,link = "$linkmode,$pass"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" @@ -7782,18 +8107,15 @@ func_mode_link () ;; esac if $valid_a_lib; then - echo - $ECHO "*** Warning: Linking the shared library $output against the" - $ECHO "*** static library $deplib is not portable!" + func_warning "Linking the shared library $output against the static library $deplib is not portable!" deplibs="$deplib $deplibs" else - echo - $ECHO "*** Warning: Trying to link with static lib archive $deplib." - echo "*** I have the capability to make that library automatically link in when" - echo "*** you link to this library. But I can only do this if you have a" - echo "*** shared version of the library, which you do not appear to have" - echo "*** because the file extensions .$libext of this argument makes me believe" - echo "*** that it is just a static archive that I should not use here." + func_warning "Trying to link with static lib archive $deplib." + func_warning "I have the capability to make that library automatically link in when" + func_warning "you link to this library. But I can only do this if you have a" + func_warning "shared version of the library, which you do not appear to have" + func_warning "because the file extensions .$libext of this argument makes me believe" + func_warning "that it is just a static archive that I should not use here." fi ;; esac @@ -7988,7 +8310,7 @@ func_mode_link () fi case $host in # special handling for platforms with PE-DLLs. - *cygwin* | *mingw* | *cegcc* ) + *cygwin* | *mingw* | *windows* | *cegcc* ) # Linker will automatically link against shared library if both # static and shared are present. Therefore, ensure we extract # symbols from the import library if a shared library is present @@ -8088,7 +8410,10 @@ func_mode_link () # Make sure the rpath contains only unique directories. case $temp_rpath: in *"$absdir:"*) ;; - *) func_append temp_rpath "$absdir:" ;; + *) case $absdir in + "$progdir/"*) func_append temp_rpath "$absdir:" ;; + *) func_append temp_rpath_tail "$absdir:" ;; + esac esac fi @@ -8100,7 +8425,9 @@ func_mode_link () *) case "$compile_rpath " in *" $absdir "*) ;; - *) func_append compile_rpath " $absdir" ;; + *) case $absdir in + "$progdir/"*) func_append compile_rpath " $absdir" ;; + esac esac ;; esac @@ -8131,8 +8458,8 @@ func_mode_link () fi if test -n "$library_names" && { test no = "$use_static_libs" || test -z "$old_library"; }; then - case $host in - *cygwin* | *mingw* | *cegcc* | *os2*) + case $host_os in + cygwin* | mingw* | windows* | cegcc* | os2*) # No point in relinking DLLs because paths are not encoded func_append notinst_deplibs " $lib" need_relink=no @@ -8158,11 +8485,11 @@ func_mode_link () if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then echo if test prog = "$linkmode"; then - $ECHO "*** Warning: Linking the executable $output against the loadable module" + func_warning "Linking the executable $output against the loadable module" else - $ECHO "*** Warning: Linking the shared library $output against the loadable module" + func_warning "Linking the shared library $output against the loadable module" fi - $ECHO "*** $linklib is not portable!" + func_warning "$linklib is not portable!" fi if test lib = "$linkmode" && test yes = "$hardcode_into_libs"; then @@ -8174,7 +8501,9 @@ func_mode_link () *) case "$compile_rpath " in *" $absdir "*) ;; - *) func_append compile_rpath " $absdir" ;; + *) case $absdir in + "$progdir/"*) func_append compile_rpath " $absdir" ;; + esac esac ;; esac @@ -8201,8 +8530,8 @@ func_mode_link () soname=$dlname elif test -n "$soname_spec"; then # bleh windows - case $host in - *cygwin* | mingw* | *cegcc* | *os2*) + case $host_os in + cygwin* | mingw* | windows* | cegcc* | os2*) func_arith $current - $age major=$func_arith_result versuffix=-$major @@ -8257,11 +8586,10 @@ func_mode_link () if /usr/bin/file -L $add 2> /dev/null | $GREP ": [^:]* bundle" >/dev/null; then if test "X$dlopenmodule" != "X$lib"; then - $ECHO "*** Warning: lib $linklib is a module, not a shared library" + func_warning "lib $linklib is a module, not a shared library" if test -z "$old_library"; then - echo - echo "*** And there doesn't seem to be a static archive available" - echo "*** The link will probably fail, sorry" + func_warning "And there doesn't seem to be a static archive available" + func_warning "The link will probably fail, sorry" else add=$dir/$old_library fi @@ -8344,7 +8672,7 @@ func_mode_link () test no = "$hardcode_direct_absolute"; then add=$libdir/$linklib elif test yes = "$hardcode_minus_L"; then - add_dir=-L$libdir + add_dir=-L$lt_sysroot$libdir add=-l$name elif test yes = "$hardcode_shlibpath_var"; then case :$finalize_shlibpath: in @@ -8361,7 +8689,7 @@ func_mode_link () fi else # We cannot seem to hardcode it, guess we'll fake it. - add_dir=-L$libdir + add_dir=-L$lt_sysroot$libdir # Try looking first in the location we're being installed to. if test -n "$inst_prefix_dir"; then case $libdir in @@ -8401,21 +8729,19 @@ func_mode_link () # Just print a warning and add the library to dependency_libs so # that the program can be linked against the static library. - echo - $ECHO "*** Warning: This system cannot link to static lib archive $lib." - echo "*** I have the capability to make that library automatically link in when" - echo "*** you link to this library. But I can only do this if you have a" - echo "*** shared version of the library, which you do not appear to have." + func_warning "This system cannot link to static lib archive $lib." + func_warning "I have the capability to make that library automatically link in when" + func_warning "you link to this library. But I can only do this if you have a" + func_warning "shared version of the library, which you do not appear to have." if test yes = "$module"; then - echo "*** But as you try to build a module library, libtool will still create " - echo "*** a static module, that should work as long as the dlopening application" - echo "*** is linked with the -dlopen flag to resolve symbols at runtime." + func_warning "But as you try to build a module library, libtool will still create " + func_warning "a static module, that should work as long as the dlopening application" + func_warning "is linked with the -dlopen flag to resolve symbols at runtime." if test -z "$global_symbol_pipe"; then - echo - echo "*** However, this would only work if libtool was able to extract symbol" - echo "*** lists from a program, using 'nm' or equivalent, but libtool could" - echo "*** not find such a program. So, this module is probably useless." - echo "*** 'nm' from GNU binutils and a full rebuild may help." + func_warning "However, this would only work if libtool was able to extract symbol" + func_warning "lists from a program, using 'nm' or equivalent, but libtool could" + func_warning "not find such a program. So, this module is probably useless." + func_warning "'nm' from GNU binutils and a full rebuild may help." fi if test no = "$build_old_libs"; then build_libtool_libs=module @@ -8538,6 +8864,8 @@ func_mode_link () fi # link_all_deplibs != no fi # linkmode = lib done # for deplib in $libs + + func_append temp_rpath "$temp_rpath_tail" if test link = "$pass"; then if test prog = "$linkmode"; then compile_deplibs="$new_inherited_linker_flags $compile_deplibs" @@ -8575,42 +8903,46 @@ func_mode_link () # Add libraries to $var in reverse order eval tmp_libs=\"\$$var\" new_libs= + # FIXME: Pedantically, this is the right thing to do, so + # that some nasty dependency loop isn't accidentally + # broken: new_libs="$deplib $new_libs" for deplib in $tmp_libs; do - # FIXME: Pedantically, this is the right thing to do, so - # that some nasty dependency loop isn't accidentally - # broken: - #new_libs="$deplib $new_libs" - # Pragmatically, this seems to cause very few problems in - # practice: - case $deplib in - -L*) new_libs="$deplib $new_libs" ;; - -R*) ;; - *) - # And here is the reason: when a library appears more - # than once as an explicit dependence of a library, or - # is implicitly linked in more than once by the - # compiler, it is considered special, and multiple - # occurrences thereof are not removed. Compare this - # with having the same library being listed as a - # dependency of multiple other libraries: in this case, - # we know (pedantically, we assume) the library does not - # need to be listed more than once, so we keep only the - # last copy. This is not always right, but it is rare - # enough that we require users that really mean to play - # such unportable linking tricks to link the library - # using -Wl,-lname, so that libtool does not consider it - # for duplicate removal. - case " $specialdeplibs " in - *" $deplib "*) new_libs="$deplib $new_libs" ;; + if $opt_preserve_dup_deps; then + new_libs="$deplib $new_libs" + else + # Pragmatically, this seems to cause very few problems in + # practice: + case $deplib in + -L*) new_libs="$deplib $new_libs" ;; + -R*) ;; *) - case " $new_libs " in - *" $deplib "*) ;; - *) new_libs="$deplib $new_libs" ;; - esac - ;; + # And here is the reason: when a library appears more + # than once as an explicit dependence of a library, or + # is implicitly linked in more than once by the + # compiler, it is considered special, and multiple + # occurrences thereof are not removed. Compare this + # with having the same library being listed as a + # dependency of multiple other libraries: in this case, + # we know (pedantically, we assume) the library does not + # need to be listed more than once, so we keep only the + # last copy. This is not always right, but it is rare + # enough that we require users that really mean to play + # such unportable linking tricks to link the library + # using -Wl,-lname, so that libtool does not consider it + # for duplicate removal. And if not possible for portability + # reasons, then --preserve-dup-deps should be used. + case " $specialdeplibs " in + *" $deplib "*) new_libs="$deplib $new_libs" ;; + *) + case " $new_libs " in + *" $deplib "*) ;; + *) new_libs="$deplib $new_libs" ;; + esac + ;; + esac + ;; esac - ;; - esac + fi done tmp_libs= for deplib in $new_libs; do @@ -8632,7 +8964,7 @@ func_mode_link () test CXX = "$tagname" && { case $host_os in linux*) - case `$CC -V 2>&1 | sed 5q` in + case `$CC -V 2>&1 | $SED 5q` in *Sun\ C*) # Sun C++ 5.9 func_suncc_cstd_abi @@ -8742,9 +9074,7 @@ func_mode_link () if test pass_all != "$deplibs_check_method"; then func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" else - echo - $ECHO "*** Warning: Linking the shared library $output against the non-libtool" - $ECHO "*** objects $objs is not portable!" + func_warning "Linking the shared library $output against the non-libtool objects $objs is not portable!" func_append libobjs " $objs" fi fi @@ -8805,13 +9135,13 @@ func_mode_link () # case $version_type in # correct linux to gnu/linux during the next big refactor - darwin|freebsd-elf|linux|osf|windows|none) + darwin|freebsd-elf|linux|midnightbsd-elf|osf|qnx|windows|none) func_arith $number_major + $number_minor current=$func_arith_result age=$number_minor revision=$number_revision ;; - freebsd-aout|qnx|sunos) + freebsd-aout|sco|sunos) current=$number_major revision=$number_minor age=0 @@ -8896,7 +9226,7 @@ func_mode_link () versuffix=.$current.$revision ;; - freebsd-elf) + freebsd-elf | midnightbsd-elf) func_arith $current - $age major=.$func_arith_result versuffix=$major.$age.$revision @@ -8958,8 +9288,9 @@ func_mode_link () ;; qnx) - major=.$current - versuffix=.$current + func_arith $current - $age + major=.$func_arith_result + versuffix=$major.$age.$revision ;; sco) @@ -9112,7 +9443,7 @@ func_mode_link () if test yes = "$build_libtool_libs"; then if test -n "$rpath"; then case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) + *-*-cygwin* | *-*-mingw* | *-*-windows* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) # these systems don't actually have a c library (as such)! ;; *-*-rhapsody* | *-*-darwin1.[012]) @@ -9122,7 +9453,7 @@ func_mode_link () *-*-netbsd*) # Don't link with libc until the a.out ld.so is fixed. ;; - *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) + *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-midnightbsd*) # Do not include libc due to us having libc/libc_r. ;; *-*-sco3.2v5* | *-*-sco5v6*) @@ -9163,108 +9494,6 @@ func_mode_link () # implementing what was already the behavior. newdeplibs=$deplibs ;; - test_compile) - # This code stresses the "libraries are programs" paradigm to its - # limits. Maybe even breaks it. We compile a program, linking it - # against the deplibs as a proxy for the library. Then we can check - # whether they linked in statically or dynamically with ldd. - $opt_dry_run || $RM conftest.c - cat > conftest.c <\^^M' is replaced by a single space. -% -% \argremovec might leave us with trailing space, e.g., +\def\argremovec#1\c#2\ArgTerm{\argremovespace#1$ $\ArgTerm} +% \argremovec might leave us with trailing space, though; e.g., % @end itemize @c foo -% This space token undergoes the same procedure and is eventually removed -% by \finishparsearg. -% -\def\argcheckspaces#1\^^M{\argcheckspacesX#1\^^M \^^M} -\def\argcheckspacesX#1 \^^M{\argcheckspacesY#1\^^M} -\def\argcheckspacesY#1\^^M#2\^^M#3\ArgTerm{% - \def\temp{#3}% - \ifx\temp\empty - % Do not use \next, perhaps the caller of \parsearg uses it; reuse \temp: - \let\temp\finishparsearg - \else - \let\temp\argcheckspaces - \fi - % Put the space token in: - \temp#1 #3\ArgTerm -} +% Note that the argument cannot contain the TeX $, as its catcode is +% changed to \other when Texinfo source is read. +\def\argremovespace#1 $#2\ArgTerm{\finishparsearg#1$\ArgTerm} % If a _delimited_ argument is enclosed in braces, they get stripped; so % to get _exactly_ the rest of the line, we had to prevent such situation. -% We prepended an \empty token at the very beginning and we expand it now, -% just before passing the control to \argtorun. -% (Similarly, we have to think about #3 of \argcheckspacesY above: it is -% either the null string, or it ends with \^^M---thus there is no danger -% that a pair of braces would be stripped. -% -% But first, we have to remove the trailing space token. -% -\def\finishparsearg#1 \ArgTerm{\expandafter\argtorun\expandafter{#1}} +% We prepended an \empty token at the very beginning and we expand it +% just before passing the control to \next. +% (But first, we have to remove the remaining $ or two.) +\def\finishparsearg#1$#2\ArgTerm{\expandafter\argtorun\expandafter{#1}} % \parseargdef - define a command taking an argument on the line @@ -4950,6 +4928,7 @@ \commondummyword\inforef {}% \commondummyword\kbd {}% \commondummyword\key {}% + \commondummyword\link {}% \commondummyword\math {}% \commondummyword\option {}% \commondummyword\pxref {}% @@ -5259,14 +5238,14 @@ % the current value of \escapechar. \def\escapeisbackslash{\escapechar=`\\} -% Use \ in index files by default. texi2dvi didn't support @ as the escape -% character (as it checked for "\entry" in the files, and not "@entry"). When -% the new version of texi2dvi has had a chance to become more prevalent, then -% the escape character can change back to @ again. This should be an easy -% change to make now because both @ and \ are only used as escape characters in -% index files, never standing for themselves. +% Uncomment to use \ in index files by default. Old texi2dvi (before 2019) +% didn't support @ as the escape character (as it checked for "\entry" in +% the files, and not "@entry"). +% In the future we can remove this flag and simplify the code for +% index files and backslashes, once the support is no longer likely to be +% useful. % -\set txiindexescapeisbackslash +% \set txiindexescapeisbackslash % Write the entry in \indextext to the index file. % @@ -5575,6 +5554,11 @@ \newdimen\entryrightmargin \entryrightmargin=0pt +% amount to indent subsequent lines in an entry when it spans more than +% one line. +\newdimen\entrycontskip +\entrycontskip=1em + % for PDF output, whether to make the text of the entry a link to the page % number. set for @contents and @shortcontents where there is only one % page number. @@ -5668,41 +5652,17 @@ \parfillskip=0pt plus -1fill % \advance\rightskip by \entryrightmargin - % Determine how far we can stretch into the margin. - % This allows, e.g., "Appendix H GNU Free Documentation License" to - % fit on one line in @letterpaper format. - \ifdim\entryrightmargin>2.1em - \dimen@i=2.1em - \else - \dimen@i=0em - \fi - \advance \parfillskip by 0pt minus 1\dimen@i % \dimen@ii = \hsize \advance\dimen@ii by -1\leftskip \advance\dimen@ii by -1\entryrightmargin - \advance\dimen@ii by 1\dimen@i \ifdim\wd\boxA > \dimen@ii % If the entry doesn't fit in one line \ifdim\dimen@ > 0.8\dimen@ii % due to long index text - % Try to split the text roughly evenly. \dimen@ will be the length of - % the first line. - \dimen@ = 0.7\dimen@ - \dimen@ii = \hsize - \ifnum\dimen@>\dimen@ii - % If the entry is too long (for example, if it needs more than - % two lines), use all the space in the first line. - \dimen@ = \dimen@ii - \fi \advance\leftskip by 0pt plus 1fill % ragged right - \advance \dimen@ by 1\rightskip - \parshape = 2 0pt \dimen@ 0em \dimen@ii - % Ideally we'd add a finite glue at the end of the first line only, - % instead of using \parshape with explicit line lengths, but TeX - % doesn't seem to provide a way to do such a thing. % % Indent all lines but the first one. - \advance\leftskip by 1em - \advance\parindent by -1em + \advance\leftskip by \entrycontskip + \advance\parindent by -\entrycontskip \fi\fi \indent % start paragraph \unhbox\boxA @@ -5725,12 +5685,11 @@ \newskip\thinshrinkable \skip\thinshrinkable=.15em minus .15em -% Like plain.tex's \dotfill, except uses up at least 1 em. +% Like plain.tex's \dotfill, except uses up at least 0.5 em. % The filll stretch here overpowers both the fil and fill stretch to push % the page number to the right. \def\indexdotfill{\cleaders - \hbox{$\mathsurround=0pt \mkern1.5mu.\mkern1.5mu$}\hskip 1em plus 1filll} - + \hbox{$\mathsurround=0pt \mkern1.5mu.\mkern1.5mu$}\hskip 0.5em plus 1filll} \def\primary #1{\line{#1\hfil}} @@ -5783,7 +5742,7 @@ % below is chosen so that the gutter has the same value (well, +-<1pt) % as it did when we hard-coded it. % - % We put the result in a separate register, \doublecolumhsize, so we + % We put the result in a separate register, \doublecolumnhsize, so we % can restore it in \pagesofar, after \hsize itself has (potentially) % been clobbered. % @@ -6178,8 +6137,7 @@ % normally unnmhead0 calls unnumberedzzz: \outer\parseargdef\unnumbered{\unnmhead0{#1}} \def\unnumberedzzz#1{% - \global\secno=0 \global\subsecno=0 \global\subsubsecno=0 - \global\advance\unnumberedno by 1 + \global\advance\unnumberedno by 1 % % Since an unnumbered has no number, no prefix for figures. \global\let\chaplevelprefix = \empty @@ -6235,8 +6193,8 @@ % normally calls unnumberedseczzz: \outer\parseargdef\unnumberedsec{\unnmhead1{#1}} \def\unnumberedseczzz#1{% - \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1 - \sectionheading{#1}{sec}{Ynothing}{\the\unnumberedno.\the\secno}% + \global\advance\unnumberedno by 1 + \sectionheading{#1}{sec}{Ynothing}{\the\unnumberedno}% } % Subsections. @@ -6259,9 +6217,8 @@ % normally calls unnumberedsubseczzz: \outer\parseargdef\unnumberedsubsec{\unnmhead2{#1}} \def\unnumberedsubseczzz#1{% - \global\subsubsecno=0 \global\advance\subsecno by 1 - \sectionheading{#1}{subsec}{Ynothing}% - {\the\unnumberedno.\the\secno.\the\subsecno}% + \global\advance\unnumberedno by 1 + \sectionheading{#1}{subsec}{Ynothing}{\the\unnumberedno}% } % Subsubsections. @@ -6285,9 +6242,8 @@ % normally unnumberedsubsubseczzz: \outer\parseargdef\unnumberedsubsubsec{\unnmhead3{#1}} \def\unnumberedsubsubseczzz#1{% - \global\advance\subsubsecno by 1 - \sectionheading{#1}{subsubsec}{Ynothing}% - {\the\unnumberedno.\the\secno.\the\subsecno.\the\subsubsecno}% + \global\advance\unnumberedno by 1 + \sectionheading{#1}{subsubsec}{Ynothing}{\the\unnumberedno}% } % These macros control what the section commands do, according @@ -6721,6 +6677,82 @@ \input \tocreadfilename } +% process toc file to find the maximum width of the section numbers for +% each chapter +\def\findsecnowidths{% + \begingroup + \setupdatafile + \activecatcodes + \secentryfonts + % Redefinitions + \def\numchapentry##1##2##3##4{% + \def\curchapname{secnowidth-##2}% + \curchapmax=0pt + }% + \let\appentry\numchapentry + % + \def\numsecentry##1##2##3##4{% + \def\cursecname{secnowidth-##2}% + \cursecmax=0pt + % + \setbox0=\hbox{##2}% + \ifdim\wd0>\curchapmax + \curchapmax=\wd0 + \expandafter\xdef\csname\curchapname\endcsname{\the\wd0}% + \fi + }% + \let\appsecentry\numsecentry + % + \def\numsubsecentry##1##2##3##4{% + \def\curssecname{secnowidth-##2}% + \curssecmax=0pt + % + \setbox0=\hbox{##2}% + \ifdim\wd0>\cursecmax + \cursecmax=\wd0 + \expandafter\xdef\csname\cursecname\endcsname{\the\wd0}% + \fi + }% + \let\appsubsecentry\numsubsecentry + % + \def\numsubsubsecentry##1##2##3##4{% + \setbox0=\hbox{##2}% + \ifdim\wd0>\curssecmax + \curssecmax=\wd0 + \expandafter\xdef\csname\curssecname\endcsname{\the\wd0}% + \fi + }% + \let\appsubsubsecentry\numsubsubsecentry + % + % Discard any output by outputting to dummy vbox, in case the toc file + % contains macros that we have not redefined above. + \setbox\dummybox\vbox\bgroup + \input \tocreadfilename\relax + \egroup + \endgroup +} +\newdimen\curchapmax +\newdimen\cursecmax +\newdimen\curssecmax + + +% set #1 to the maximum section width for #2 +\def\retrievesecnowidth#1#2{% + \expandafter\let\expandafter\savedsecnowidth \csname secnowidth-#2\endcsname + \ifx\savedsecnowidth\relax + #1=0pt + \else + #1=\savedsecnowidth + \fi +} +\newdimen\secnowidthchap +\secnowidthchap=0pt +\newdimen\secnowidthsec +\secnowidthsec=0pt +\newdimen\secnowidthssec +\secnowidthssec=0pt + + \newskip\contentsrightmargin \contentsrightmargin=1in \newcount\savepageno \newcount\lastnegativepageno \lastnegativepageno = -1 @@ -6766,6 +6798,7 @@ \startcontents{\putwordTOC}% \openin 1 \tocreadfilename\space \ifeof 1 \else + \findsecnowidths \readtocfile \fi \vfill \eject @@ -6793,6 +6826,7 @@ \rm \hyphenpenalty = 10000 \advance\baselineskip by 1pt % Open it up a little. + \extrasecnoskip=0.4pt \def\numsecentry##1##2##3##4{} \let\appsecentry = \numsecentry \let\unnsecentry = \numsecentry @@ -6828,8 +6862,6 @@ % This space should be enough, since a single number is .5em, and the % widest letter (M) is 1em, at least in the Computer Modern fonts. % But use \hss just in case. - % (This space doesn't include the extra space that gets added after - % the label; that gets put in by \shortchapentry above.) % % We'd like to right-justify chapter numbers, but that looks strange % with appendix letters. And right-justifying numbers and @@ -6839,10 +6871,15 @@ \hbox to 1em{#1\hss}% } -% These macros generate individual entries in the table of contents. -% The first argument is the chapter or section name. -% The last argument is the page number. -% The arguments in between are the chapter number, section number, ... +% These macros generate individual entries in the table of contents, +% and are read in from the *.toc file. +% +% The arguments are like: +% \def\numchapentry#1#2#3#4 +% #1 - the chapter or section name. +% #2 - section number +% #3 - level of section (e.g "chap", "sec") +% #4 - page number % Parts, in the main contents. Replace the part number, which doesn't % exist, with an empty box. Let's hope all the numbers have the same width. @@ -6855,7 +6892,7 @@ \vskip 0pt plus 5\baselineskip \penalty-300 \vskip 0pt plus -5\baselineskip - \dochapentry{\numeralbox\labelspace#1}{}% + \dochapentry{#1}{\numeralbox}{}% } % % Parts, in the short toc. @@ -6866,12 +6903,14 @@ } % Chapters, in the main contents. -\def\numchapentry#1#2#3#4{\dochapentry{#2\labelspace#1}{#4}} +\def\numchapentry#1#2#3#4{% + \retrievesecnowidth\secnowidthchap{#2}% + \dochapentry{#1}{#2}{#4}% +} % Chapters, in the short toc. -% See comments in \dochapentry re vbox and related settings. \def\shortchapentry#1#2#3#4{% - \tocentry{\shortchaplabel{#2}\labelspace #1}{#4}% + \tocentry{#1}{\shortchaplabel{#2}}{#4}% } % Appendices, in the main contents. @@ -6882,67 +6921,111 @@ \setbox0 = \hbox{\putwordAppendix{} M}% \hbox to \wd0{\putwordAppendix{} #1\hss}} % -\def\appentry#1#2#3#4{\dochapentry{\appendixbox{#2}\hskip.7em#1}{#4}} +\def\appentry#1#2#3#4{% + \retrievesecnowidth\secnowidthchap{#2}% + \dochapentry{\appendixbox{#2}\hskip.7em#1}{}{#4}% +} % Unnumbered chapters. -\def\unnchapentry#1#2#3#4{\dochapentry{#1}{#4}} -\def\shortunnchapentry#1#2#3#4{\tocentry{#1}{#4}} +\def\unnchapentry#1#2#3#4{\dochapentry{#1}{}{#4}} +\def\shortunnchapentry#1#2#3#4{\tocentry{#1}{}{#4}} % Sections. -\def\numsecentry#1#2#3#4{\dosecentry{#2\labelspace#1}{#4}} +\def\numsecentry#1#2#3#4{\dosecentry{#1}{#2}{#4}} + +\def\numsecentry#1#2#3#4{% + \retrievesecnowidth\secnowidthsec{#2}% + \dosecentry{#1}{#2}{#4}% +} \let\appsecentry=\numsecentry -\def\unnsecentry#1#2#3#4{\dosecentry{#1}{#4}} +\def\unnsecentry#1#2#3#4{% + \retrievesecnowidth\secnowidthsec{#2}% + \dosecentry{#1}{}{#4}% +} % Subsections. -\def\numsubsecentry#1#2#3#4{\dosubsecentry{#2\labelspace#1}{#4}} +\def\numsubsecentry#1#2#3#4{% + \retrievesecnowidth\secnowidthssec{#2}% + \dosubsecentry{#1}{#2}{#4}% +} \let\appsubsecentry=\numsubsecentry -\def\unnsubsecentry#1#2#3#4{\dosubsecentry{#1}{#4}} +\def\unnsubsecentry#1#2#3#4{% + \retrievesecnowidth\secnowidthssec{#2}% + \dosubsecentry{#1}{}{#4}% +} % And subsubsections. -\def\numsubsubsecentry#1#2#3#4{\dosubsubsecentry{#2\labelspace#1}{#4}} +\def\numsubsubsecentry#1#2#3#4{\dosubsubsecentry{#1}{#2}{#4}} \let\appsubsubsecentry=\numsubsubsecentry -\def\unnsubsubsecentry#1#2#3#4{\dosubsubsecentry{#1}{#4}} +\def\unnsubsubsecentry#1#2#3#4{\dosubsubsecentry{#1}{}{#4}} % This parameter controls the indentation of the various levels. % Same as \defaultparindent. \newdimen\tocindent \tocindent = 15pt -% Now for the actual typesetting. In all these, #1 is the text and #2 is the -% page number. +% Now for the actual typesetting. In all these, #1 is the text, #2 is +% a section number if present, and #3 is the page number. % % If the toc has to be broken over pages, we want it to be at chapters % if at all possible; hence the \penalty. -\def\dochapentry#1#2{% +\def\dochapentry#1#2#3{% \penalty-300 \vskip1\baselineskip plus.33\baselineskip minus.25\baselineskip \begingroup % Move the page numbers slightly to the right \advance\entryrightmargin by -0.05em \chapentryfonts - \tocentry{#1}{#2}% + \extrasecnoskip=0.4em % separate chapter number more + \tocentry{#1}{#2}{#3}% \endgroup \nobreak\vskip .25\baselineskip plus.1\baselineskip } -\def\dosecentry#1#2{\begingroup +\def\dosecentry#1#2#3{\begingroup + \secnowidth=\secnowidthchap \secentryfonts \leftskip=\tocindent - \tocentry{#1}{#2}% + \tocentry{#1}{#2}{#3}% \endgroup} -\def\dosubsecentry#1#2{\begingroup +\def\dosubsecentry#1#2#3{\begingroup + \secnowidth=\secnowidthsec \subsecentryfonts \leftskip=2\tocindent - \tocentry{#1}{#2}% + \tocentry{#1}{#2}{#3}% \endgroup} -\def\dosubsubsecentry#1#2{\begingroup +\def\dosubsubsecentry#1#2#3{\begingroup + \secnowidth=\secnowidthssec \subsubsecentryfonts \leftskip=3\tocindent - \tocentry{#1}{#2}% + \tocentry{#1}{#2}{#3}% \endgroup} -% We use the same \entry macro as for the index entries. -\let\tocentry = \entry +% Used for the maximum width of a section number so we can align +% section titles. +\newdimen\secnowidth +\secnowidth=0pt +\newdimen\extrasecnoskip +\extrasecnoskip=0pt -% Space between chapter (or whatever) number and the title. -\def\labelspace{\hskip1em \relax} +% \tocentry{TITLE}{SEC NO}{PAGE} +% +\def\tocentry#1#2#3{% + \def\secno{#2}% + \ifx\empty\secno + \entry{#1}{#3}% + \else + \ifdim 0pt=\secnowidth + \setbox0=\hbox{#2\hskip\labelspace\hskip\extrasecnoskip}% + \else + \advance\secnowidth by \labelspace + \advance\secnowidth by \extrasecnoskip + \setbox0=\hbox to \secnowidth{% + #2\hskip\labelspace\hskip\extrasecnoskip\hfill}% + \fi + \entrycontskip=\wd0 + \entry{\box0 #1}{#3}% + \fi +} +\newdimen\labelspace +\labelspace=0.6em \def\chapentryfonts{\secfonts \rm} \def\secentryfonts{\textfonts} @@ -7593,9 +7676,13 @@ \def\deflineheader#1 #2 #3\endheader{% \printdefname{#1}{}{#2}\magicamp\defunargs{#3\unskip}% } + \def\deftypeline{% \doingtypefntrue - \parseargusing\activeparens{\printdefunline\deflineheader}% + \parseargusing\activeparens{\printdefunline\deftypelineheader}% +} +\def\deftypelineheader#1 #2 #3 #4\endheader{% + \printdefname{#1}{#2}{#3}\magicamp\defunargs{#4\unskip}% } % \makedefun{deffoo} (\deffooheader parameters) { (\deffooheader expansion) } @@ -7787,6 +7874,8 @@ \tolerance=10000 \hbadness=10000 \exdentamount=\defbodyindent {% + \def\^^M{}% for line continuation + % % defun fonts. We use typewriter by default (used to be bold) because: % . we're printing identifiers, they should be in tt in principle. % . in languages with many accents, such as Czech or French, it's @@ -7819,6 +7908,7 @@ % Print arguments. Use slanted for @def*, typewriter for @deftype*. \def\defunargs#1{% \bgroup + \def\^^M{}% for line continuation \df \ifdoingtypefn \tt \else \sl \fi \ifflagclear{txicodevaristt}{}% {\def\var##1{{\setregularquotes \ttsl ##1}}}% @@ -8112,8 +8202,6 @@ \let\commondummyword\unmacrodo \xdef\macrolist{\macrolist}% \endgroup - \else - \errmessage{Macro #1 not defined}% \fi } @@ -8180,7 +8268,7 @@ % Read recursive and nonrecursive macro bodies. (They're different since % rec and nonrec macros end differently.) % -% We are in \macrobodyctxt, and the \xdef causes backslashshes in the macro +% We are in \macrobodyctxt, and the \xdef causes backslashes in the macro % body to be transformed. % Set \macrobody to the body of the macro, and call \macrodef. % @@ -8727,6 +8815,11 @@ \fi } +% @nodedescription, @nodedescriptionblock - do nothing for TeX +\parseargdef\nodedescription{} +\def\nodedescriptionblock{\doignore{nodedescriptionblock}} + + % @anchor{NAME} -- define xref target at arbitrary point. % \newcount\savesfregister @@ -8808,109 +8901,11 @@ \def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup \unsepspaces % - % Get args without leading/trailing spaces. - \def\printedrefname{\ignorespaces #3}% - \setbox\printedrefnamebox = \hbox{\printedrefname\unskip}% - % + \getprintedrefname{#1}{#3}{#5}% \def\infofilename{\ignorespaces #4}% \setbox\infofilenamebox = \hbox{\infofilename\unskip}% % - \def\printedmanual{\ignorespaces #5}% - \setbox\printedmanualbox = \hbox{\printedmanual\unskip}% - % - % If the printed reference name (arg #3) was not explicitly given in - % the @xref, figure out what we want to use. - \ifdim \wd\printedrefnamebox = 0pt - % No printed node name was explicitly given. - \expandafter\ifx\csname SETxref-automatic-section-title\endcsname \relax - % Not auto section-title: use node name inside the square brackets. - \def\printedrefname{\ignorespaces #1}% - \else - % Auto section-title: use chapter/section title inside - % the square brackets if we have it. - \ifdim \wd\printedmanualbox > 0pt - % It is in another manual, so we don't have it; use node name. - \def\printedrefname{\ignorespaces #1}% - \else - \ifhavexrefs - % We (should) know the real title if we have the xref values. - \def\printedrefname{\refx{#1-title}}% - \else - % Otherwise just copy the Info node name. - \def\printedrefname{\ignorespaces #1}% - \fi% - \fi - \fi - \fi - % - % Make link in pdf output. - \ifpdf - % For pdfTeX and LuaTeX - {\indexnofonts - \makevalueexpandable - \turnoffactive - % This expands tokens, so do it after making catcode changes, so _ - % etc. don't get their TeX definitions. This ignores all spaces in - % #4, including (wrongly) those in the middle of the filename. - \getfilename{#4}% - % - % This (wrongly) does not take account of leading or trailing - % spaces in #1, which should be ignored. - \setpdfdestname{#1}% - % - \ifx\pdfdestname\empty - \def\pdfdestname{Top}% no empty targets - \fi - % - \leavevmode - \startlink attr{/Border [0 0 0]}% - \ifnum\filenamelength>0 - goto file{\the\filename.pdf} name{\pdfdestname}% - \else - goto name{\pdfmkpgn{\pdfdestname}}% - \fi - }% - \setcolor{\linkcolor}% - \else - \ifx\XeTeXrevision\thisisundefined - \else - % For XeTeX - {\indexnofonts - \makevalueexpandable - \turnoffactive - % This expands tokens, so do it after making catcode changes, so _ - % etc. don't get their TeX definitions. This ignores all spaces in - % #4, including (wrongly) those in the middle of the filename. - \getfilename{#4}% - % - % This (wrongly) does not take account of leading or trailing - % spaces in #1, which should be ignored. - \setpdfdestname{#1}% - % - \ifx\pdfdestname\empty - \def\pdfdestname{Top}% no empty targets - \fi - % - \leavevmode - \ifnum\filenamelength>0 - % With default settings, - % XeTeX (xdvipdfmx) replaces link destination names with integers. - % In this case, the replaced destination names of - % remote PDFs are no longer known. In order to avoid a replacement, - % you can use xdvipdfmx's command line option `-C 0x0010'. - % If you use XeTeX 0.99996+ (TeX Live 2016+), - % this command line option is no longer necessary - % because we can use the `dvipdfmx:config' special. - \special{pdf:bann << /Border [0 0 0] /Type /Annot /Subtype /Link /A - << /S /GoToR /F (\the\filename.pdf) /D (\pdfdestname) >> >>}% - \else - \special{pdf:bann << /Border [0 0 0] /Type /Annot /Subtype /Link /A - << /S /GoTo /D (\pdfdestname) >> >>}% - \fi - }% - \setcolor{\linkcolor}% - \fi - \fi + \startxreflink{#1}{#4}% {% % Have to otherify everything special to allow the \csname to % include an _ in the xref name, etc. @@ -8991,6 +8986,93 @@ \endlink \endgroup} +% \getprintedrefname{NODE}{LABEL}{MANUAL} +% - set \printedrefname and \printedmanual +% +\def\getprintedrefname#1#2#3{% + % Get args without leading/trailing spaces. + \def\printedrefname{\ignorespaces #2}% + \setbox\printedrefnamebox = \hbox{\printedrefname\unskip}% + % + \def\printedmanual{\ignorespaces #3}% + \setbox\printedmanualbox = \hbox{\printedmanual\unskip}% + % + % If the printed reference name (arg #2) was not explicitly given in + % the @xref, figure out what we want to use. + \ifdim \wd\printedrefnamebox = 0pt + % No printed node name was explicitly given. + \expandafter\ifx\csname SETxref-automatic-section-title\endcsname \relax + % Not auto section-title: use node name inside the square brackets. + \def\printedrefname{\ignorespaces #1}% + \else + % Auto section-title: use chapter/section title inside + % the square brackets if we have it. + \ifdim \wd\printedmanualbox > 0pt + % It is in another manual, so we don't have it; use node name. + \def\printedrefname{\ignorespaces #1}% + \else + \ifhavexrefs + % We (should) know the real title if we have the xref values. + \def\printedrefname{\refx{#1-title}}% + \else + % Otherwise just copy the Info node name. + \def\printedrefname{\ignorespaces #1}% + \fi% + \fi + \fi + \fi +} + +% \startxreflink{NODE}{FILE} - start link in pdf output. +\def\startxreflink#1#2{% + \ifpdforxetex + % For pdfTeX and LuaTeX + {\indexnofonts + \makevalueexpandable + \turnoffactive + % This expands tokens, so do it after making catcode changes, so _ + % etc. don't get their TeX definitions. This ignores all spaces in + % #2, including (wrongly) those in the middle of the filename. + \getfilename{#2}% + % + % This (wrongly) does not take account of leading or trailing + % spaces in #1, which should be ignored. + \setpdfdestname{#1}% + % + \ifx\pdfdestname\empty + \def\pdfdestname{Top}% no empty targets + \fi + % + \leavevmode + \ifpdf + \startlink attr{/Border [0 0 0]}% + \ifnum\filenamelength>0 + goto file{\the\filename.pdf} name{\pdfdestname}% + \else + goto name{\pdfmkpgn{\pdfdestname}}% + \fi + \else % XeTeX + \ifnum\filenamelength>0 + % With default settings, + % XeTeX (xdvipdfmx) replaces link destination names with integers. + % In this case, the replaced destination names of + % remote PDFs are no longer known. In order to avoid a replacement, + % you can use xdvipdfmx's command line option `-C 0x0010'. + % If you use XeTeX 0.99996+ (TeX Live 2016+), + % this command line option is no longer necessary + % because we can use the `dvipdfmx:config' special. + \special{pdf:bann << /Border [0 0 0] /Type /Annot /Subtype /Link /A + << /S /GoToR /F (\the\filename.pdf) /D (\pdfdestname) >> >>}% + \else + \special{pdf:bann << /Border [0 0 0] /Type /Annot /Subtype /Link /A + << /S /GoTo /D (\pdfdestname) >> >>}% + \fi + \fi + }% + \setcolor{\linkcolor}% + \fi +} + % can be overridden in translation files \def\putpageref#1{% \space\putwordpage\tie\refx{#1-pg}} @@ -9028,6 +9110,21 @@ % \def\xrefprintnodename#1{[#1]} +% @link{NODENAME, LABEL, MANUAL} - create a "plain" link, with no +% page number. Not useful if printed on paper. +% +\def\link#1{\linkX[#1,,,]} +\def\linkX[#1,#2,#3,#4]{% + \begingroup + \unsepspaces + \getprintedrefname{#1}{#2}{#3}% + \startxreflink{#1}{#3}% + \printedrefname + \endlink + \endgroup +} + + % Things referred to by \setref. % \def\Ynothing{} @@ -11736,9 +11833,13 @@ \def\c{\loadconf\c}% % Definition for the first newline read in the file \def ^^M{\loadconf}% - % In case the first line has a whole-line command on it + % In case the first line has a whole-line or environment command on it \let\originalparsearg\parsearg% \def\parsearg{\loadconf\originalparsearg}% + % + % \startenvironment is in the expansion of commands defined with \envdef + \let\originalstartenvironment\startenvironment% + \def\startenvironment{\loadconf\startenvironment}% }} @@ -11766,6 +11867,7 @@ \enableemergencynewline \let\c=\comment \let\parsearg\originalparsearg + \let\startenvironment\originalstartenvironment % % Also turn back on active characters that might appear in the input % file name, in case not using a pre-dumped format. diff --git a/build_windows/ChangeLog.txt b/build_windows/ChangeLog.txt index a4b7b78dc..9eba7e07d 100644 --- a/build_windows/ChangeLog.txt +++ b/build_windows/ChangeLog.txt @@ -1,4 +1,8 @@ +2024-10-07 Simon Sobisch + + * set_env_vs_dist: supporting space-included paths (not recommended) + 2024-05-15 Simon Sobisch * makedist.cmd: cater for new different library names @@ -315,7 +319,7 @@ * update for subfolder vc10 -2014-07-07 Philipp Böhme +2014-07-07 Philipp B�hme * minor bugfix (tpyos) for subfolder vc12 @@ -326,7 +330,7 @@ * updated all project files * added subfolder vc11 -2014-06-20 Philipp Böhme +2014-06-20 Philipp B�hme * added project files - subfolders: vc7, vc8, vc9, vc10, vc12 (original project files and resource files version_cobc.rc, diff --git a/build_windows/config.h.in b/build_windows/config.h.in index e294ff951..44343b870 100644 --- a/build_windows/config.h.in +++ b/build_windows/config.h.in @@ -306,10 +306,6 @@ #define COB_LIBS "libcob.l" #endif - -/* long int is long long */ -/* #undef COB_LI_IS_LL */ - /* Module extension */ #define COB_MODULE_EXT "dll" @@ -772,6 +768,9 @@ /* Define to 1 if you have the header file. */ /* #undef HAVE_XCURSES_H */ +/* Define as const if the declaration of iconv() needs const. */ +/* #undef ICONV_CONST */ + /* Define to the sub-directory where libtool stores uninstalled libraries. */ /* #undef LT_OBJDIR */ @@ -784,6 +783,9 @@ /* Define to the address where bug reports for this package should be sent. */ #define PACKAGE_BUGREPORT "bug-gnucobol@gnu.org" +/* Bug URL instead of mailing list */ +/* #undef PACKAGE_BUGREPORT_URL */ + /* Define to the full name of this package. */ #define PACKAGE_NAME "GnuCOBOL" @@ -802,6 +804,9 @@ /* Define a patch level (numeric, max. 8 digits) */ #define PATCH_LEVEL COB_NUM_TAR_DATE +/* PKG version string */ +#define PKGVERSION "(" PACKAGE_NAME ") " + // Use \ to escape things, for example \\ for using in paths // Use \" for paths with spaces diff --git a/build_windows/set_env_vs_x64.cmd b/build_windows/set_env_vs_x64.cmd index 4fde7ca57..4c905c9f3 100644 --- a/build_windows/set_env_vs_x64.cmd +++ b/build_windows/set_env_vs_x64.cmd @@ -1,4 +1,4 @@ -:: Copyright (C) 2014-2020 Free Software Foundation, Inc. +:: Copyright (C) 2014-2020,2024 Free Software Foundation, Inc. :: Written by Simon Sobisch, Edward Hart :: :: This file is part of GnuCOBOL. @@ -36,4 +36,4 @@ if %errorlevel% equ 0 ( set "stay_open=x" ) -call %~dp0gcvsvars.cmd %* +call "%~dp0gcvsvars.cmd" %* diff --git a/build_windows/set_env_vs_x64.dist.tmpl.cmd b/build_windows/set_env_vs_x64.dist.tmpl.cmd index 6c5dd8e68..31afef62b 100644 --- a/build_windows/set_env_vs_x64.dist.tmpl.cmd +++ b/build_windows/set_env_vs_x64.dist.tmpl.cmd @@ -1,4 +1,4 @@ -:: Copyright (C) 2014-2020 Free Software Foundation, Inc. +:: Copyright (C) 2014-2020,2024 Free Software Foundation, Inc. :: Written by Simon Sobisch, Edward Hart :: :: This file is part of GnuCOBOL. @@ -36,4 +36,4 @@ if %errorlevel% equ 0 ( set "stay_open=x" ) -call %~dp0gcvsvars.cmd %* +call "%~dp0gcvsvars.cmd" %* diff --git a/build_windows/set_env_vs_x86.cmd b/build_windows/set_env_vs_x86.cmd index c80706ba6..8fc7e2007 100644 --- a/build_windows/set_env_vs_x86.cmd +++ b/build_windows/set_env_vs_x86.cmd @@ -1,4 +1,4 @@ -:: Copyright (C) 2014-2020 Free Software Foundation, Inc. +:: Copyright (C) 2014-2020,2024 Free Software Foundation, Inc. :: Written by Simon Sobisch, Edward Hart :: :: This file is part of GnuCOBOL. @@ -39,4 +39,4 @@ if %errorlevel% equ 0 ( set "stay_open=x" ) -call %~dp0gcvsvars.cmd %* +call "%~dp0gcvsvars.cmd" %* diff --git a/build_windows/set_env_vs_x86.dist.tmpl.cmd b/build_windows/set_env_vs_x86.dist.tmpl.cmd index e8e01d7f6..4a160b87d 100644 --- a/build_windows/set_env_vs_x86.dist.tmpl.cmd +++ b/build_windows/set_env_vs_x86.dist.tmpl.cmd @@ -36,4 +36,4 @@ if %errorlevel% equ 0 ( set "stay_open=x" ) -call %~dp0gcvsvars.cmd %* +call "%~dp0gcvsvars.cmd" %* diff --git a/cobc/ChangeLog b/cobc/ChangeLog index 3632de83d..03b6b65b0 100644 --- a/cobc/ChangeLog +++ b/cobc/ChangeLog @@ -1,4 +1,57 @@ +2024-10-02 Simon Sobisch + + * pplex.l (output_line_directive): extracted from other places and + extended to output compile from stdin as + * codegen.c (output_cobol_info): output compile from stdin as + * cobc.c (cobc_print_version, cobc_print_shortversion, + process_command_line): build and package data only shown in verbose mode + which does not output the verbose "process" calls by default; + PACKAGE_NAME may now be overwritten by PKGVERSION (new configure option) + * help.c (cobc_print_usage): handle PACKAGE_BUGREPORT_URL as + alternative to mailing list, now resolved by PACKAGE_BUGREPORT + * cobc.c (cobc_sig_handler): skip abort message for SIGPIPE + +2024-10-01 Nicolas Berthier + + * tree.c (validate_indexed_key_field): warn about ignored collating + sequence for non-alphanumeric keys (considers only primary keys and file + collating sequence for now) + * codegen.c (output_indexed_file_key_colseq): assign collating sequence + for any key of alphanumeric class, and preliminary handing of NATIONAL + collations + * parser.y: adjust position of messages about unfinished KEY or FILE + COLLATING SEQUENCE + +2024-09-29 Simon Sobisch + + * cobc.c (cobc_print_info): drop COB_LI_IS_LL + in favor of existing COB_32_BIT_LONG + +2024-09-27 Simon Sobisch + + * plex.l, scanner.l: use noyywrap option instead of manually + defining related code parts + * typeck.c (cb_tree_list_has_numeric_ref_or_field): cleanup + +2024-09-25 Nicolas Berthier + + * typeck.c (cb_tree_is_numeric_ref_or_field) + (cb_tree_list_has_numeric_ref_or_field): new helper functions to check + whether a given item is of category numeric (edited or not) + * typeck.c (cb_emit_incompat_data_checks): use new helper function + * typeck.c (cb_emit_move, cb_emit_set_to): do not check for incompatible + data if no receiver field is of category numeric or numeric edited + +2024-09-03 Simon Sobisch + + * typeck.c (cb_emit_accept): always check position + * cobc.c, flag.def: make scope optional for -fdump + +2024-09-23 David Declerck + + * pplex.l (cb_text_list): prevent duplicates + 2024-08-30 Ammar Almorsi BUG #961: Nested Elements Mishandled Despite 'with attributes' Specification @@ -124,6 +177,16 @@ * codegen.c: handle profiling code generation under the cb_flag_prof guard +2024-03-15 Fabrice Le Fessant + + * cobc.c, help.c, pplex.l: add new flags to output dependencies following + gcc: -M to output deps only, -MD to output deps while compiling (in + .d files), -MP to output phony targets, -MG to keep missing copybooks, + -MQ to Makefile-quote target ; add -fcopybook-deps to + output only copybook names instead of file paths. -fcopybook-deps + also forces -E, -foneline-deps, -MT=copybooks, disables errors on + missing copybooks and removes output on stdout + 2024-02-19 Boris Eng * parser.y (screen_value_clause): replaced basic literals by literals @@ -1290,7 +1353,7 @@ * codegen.c (output_perform_call): use statement reference to generate separate comment for PERFORM procedure or USE procedure * flag.def, codegen.c: new -fsection-exit-check - (cb_flag_section_exit_check) and -fimplicit-goback-check + (cb_flag_section_exit_check) and -fimplicit-goback-check (cb_flag_implicit_goback_check) * tree.h (cb_progam), parser.y (perform_procedure): add and set perform_thru_list for internal checks @@ -2339,7 +2402,7 @@ 2021-01-25 Simon Sobisch - * reserved.c: fixed context attribute of acu-extension POS + * reserved.c: fixed context attribute of acu-extension POS * parser.y, reserved.c, tree.h, cobc.h: added acu-extension MOVE WITH CONVERSION as PENDING @@ -2370,7 +2433,7 @@ * field.c, pplex.l, tree.c, typeck.c: fixed warning option querying enum instead of actual value via cb_warn_opt_val - + 2020-12-09 Ron Norman * cobc.c: now calls cob_get_sig_name from common.c to get signal name @@ -2386,7 +2449,7 @@ * typeck.c (syntax_check_ml_gen_name_list): additional parameter is_xml to distinguish between XML and JSON generation (messages, possible rules) * typeck.c (syntax_check_ml_gen_name_list): check of NAME ... IS OMITTED - + 2020-12-17 Simon Sobisch bug #571 revised: @@ -2615,7 +2678,7 @@ 2020-10-12 Ron Norman * typeck.c: Flag internal variables with 'flag_real_binary' - * codegen.c: Emit USAGE INDEX and internal binary variables + * codegen.c: Emit USAGE INDEX and internal binary variables as COB_TYPE_NUMERIC_COMP5 2020-10-06 Simon Sobisch @@ -3097,8 +3160,8 @@ 2020-02-10 Ron Norman - * cobc.c, cobc.h, codegen.c, help.c, warning.def: - Add new define CB_ERRWARNDEF + * cobc.c, cobc.h, codegen.c, help.c, warning.def: + Add new define CB_ERRWARNDEF 2020-02-05 Ron Norman @@ -3267,7 +3330,7 @@ 2019-09-15 Ron Norman * cobc.h: For HPUX set COB_ALLOW_UNALIGNED as undefined - * typeck.c: Emit ADD/SUBTRACT shortcut for COMP-5 only + * typeck.c: Emit ADD/SUBTRACT shortcut for COMP-5 only if COB_ALLOW_UNALIGNED defined * tree.h: Revert 'lock_mode' back to an 'int' * codegen.c: Changes for 'lock_mode' being an 'int' @@ -7289,7 +7352,7 @@ 2015-04-27 Ron Norman * config.c: don't store configuration values additional to the setting - + 2015-04-14 Ron Norman * cobc.c codegen.c common.h tree.h parser.y typeck.c: diff --git a/cobc/cobc.c b/cobc/cobc.c index f44c62f75..de9c1d6f1 100644 --- a/cobc/cobc.c +++ b/cobc/cobc.c @@ -109,7 +109,13 @@ enum compile_level { #define CB_FLAG_GETOPT_MEMORY_CHECK 17 #define CB_FLAG_GETOPT_COPY_FILE 18 #define CB_FLAG_GETOPT_INCLUDE_FILE 19 - +#define CB_FLAG_GETOPT_DEPEND_OUTPUT 20 +#define CB_FLAG_GETOPT_DEPEND_TARGET 21 +#define CB_FLAG_GETOPT_DEPEND_ESCAPE_TARGET 22 +#define CB_FLAG_GETOPT_DEPEND_OUTPUT_FILE 23 +#define CB_FLAG_GETOPT_DEPEND_ADD_PHONY 24 +#define CB_FLAG_GETOPT_DEPEND_KEEP_MISSING 25 +#define CB_FLAG_GETOPT_DEPEND_ON_THE_SIDE 26 /* Info display limits */ #define CB_IMSG_SIZE 24 @@ -249,6 +255,12 @@ FILE *cb_storage_file = NULL; FILE *cb_listing_file = NULL; FILE *cb_depend_file = NULL; const char *cb_ebcdic_table = NULL; +int cb_depend_output = 0; +int cb_depend_output_only = 0; +int cb_depend_add_phony = 0; +int cb_depend_keep_missing = 0; +int cb_depend_target_auto = 0; +int cb_flag_copybook_deps = 0; /* set by option -fttitle= */ char *cb_listing_with_title = NULL; @@ -386,7 +398,9 @@ static char *cobc_libs; /* -l... */ static char *cobc_lib_paths; /* -L... */ static char *cobc_include; /* -I... */ static char *cobc_ldflags; /* -Q / COB_LDFLAGS */ + static char *cb_depend_target; /* -MT <target>... */ +static const char *cb_depend_filename; /* -MF <file> */ static size_t cobc_cflags_size; static size_t cobc_libs_size; @@ -612,8 +626,14 @@ static const struct option long_options[] = { {"j", CB_OP_ARG, NULL, 'j'}, {"Q", CB_RQ_ARG, NULL, 'Q'}, {"A", CB_RQ_ARG, NULL, 'A'}, - {"MT", CB_RQ_ARG, NULL, '!'}, - {"MF", CB_RQ_ARG, NULL, '@'}, + {"M", CB_NO_ARG, NULL, CB_FLAG_GETOPT_DEPEND_OUTPUT }, + {"MT", CB_RQ_ARG, NULL, CB_FLAG_GETOPT_DEPEND_TARGET}, + {"MQ", CB_RQ_ARG, NULL, CB_FLAG_GETOPT_DEPEND_ESCAPE_TARGET}, + {"MF", CB_RQ_ARG, NULL, CB_FLAG_GETOPT_DEPEND_OUTPUT_FILE}, + {"MP", CB_NO_ARG, NULL, CB_FLAG_GETOPT_DEPEND_ADD_PHONY}, + {"MG", CB_NO_ARG, NULL, CB_FLAG_GETOPT_DEPEND_KEEP_MISSING}, + {"MD", CB_NO_ARG, NULL, CB_FLAG_GETOPT_DEPEND_ON_THE_SIDE}, + {"fcopybook-deps", CB_NO_ARG, &cb_flag_copybook_deps, 1}, {"coverage", CB_NO_ARG, &cb_coverage_enabled, 1}, {"P", CB_OP_ARG, NULL, 'P'}, {"Xref", CB_NO_ARG, NULL, 'X'}, @@ -2482,7 +2502,13 @@ cobc_sig_handler (int sig) int ret = 0; #endif - cobc_abort_msg (); +#ifdef SIGPIPE + if (sig == SIGPIPE) ret = 1; +#endif + + if (!ret) { + cobc_abort_msg (); + } #if defined (SIGINT) || defined (SIGQUIT) || defined (SIGTERM) || defined (SIGPIPE) #ifdef SIGINT if (sig == SIGINT) ret = 1; @@ -2493,9 +2519,6 @@ cobc_sig_handler (int sig) #ifdef SIGTERM if (sig == SIGTERM) ret = 1; #endif -#ifdef SIGPIPE - if (sig == SIGPIPE) ret = 1; -#endif /* LCOV_EXCL_START */ if (!ret) { @@ -2515,27 +2538,31 @@ cobc_sig_handler (int sig) static void cobc_print_version (void) { - printf ("cobc (%s) %s.%d\n", PACKAGE_NAME, PACKAGE_VERSION, PATCH_LEVEL); + printf ("cobc %s%s.%d\n", PKGVERSION, PACKAGE_VERSION, PATCH_LEVEL); 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" "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.")); - printf (_("Written by %s"), "Keisuke Nishida, Roger While, Ron Norman, Simon Sobisch, Edward Hart"); putchar ('\n'); - printf (_("Built %s"), cb_cobc_build_stamp); - putchar ('\n'); - printf (_("Packaged %s"), COB_TAR_DATE); - putchar ('\n'); - printf ("%s %s", _("C version"), GC_C_VERSION_PRF GC_C_VERSION); + printf (_("Written by %s"), "Keisuke Nishida, Roger While, Ron Norman, Simon Sobisch, Edward Hart"); putchar ('\n'); + if (verbose_output) { + putchar ('\n'); + printf (_("Built %s"), cb_cobc_build_stamp); + putchar ('\n'); + printf (_("Packaged %s"), COB_TAR_DATE); + putchar ('\n'); + printf ("%s %s", _("C version"), GC_C_VERSION_PRF GC_C_VERSION); + putchar ('\n'); + } } static void cobc_print_shortversion (void) { - printf ("cobc (%s) %s.%d\n", - PACKAGE_NAME, PACKAGE_VERSION, PATCH_LEVEL); + printf ("cobc %s%s.%d\n", + PKGVERSION, PACKAGE_VERSION, PATCH_LEVEL); printf (_("Built %s"), cb_cobc_build_stamp); putchar ('\t'); printf (_("Packaged %s"), COB_TAR_DATE); @@ -2704,7 +2731,7 @@ cobc_print_info (void) cobc_var_print ("64bit-mode", _("no"), 0); #endif -#ifdef COB_LI_IS_LL +#ifndef COB_32_BIT_LONG cobc_var_print ("BINARY-C-LONG", _("8 bytes"), 0); #else cobc_var_print ("BINARY-C-LONG", _("4 bytes"), 0); @@ -2797,7 +2824,7 @@ cobc_def_dump_opts (const char *opt, const int on) int dump_to_set; cb_old_trace = 0; /* Use new methods */ - if (!cb_strcasecmp (opt, "ALL")) { + if (!opt || !cb_strcasecmp (opt, "ALL")) { if (on) { cb_flag_dump = COB_DUMP_ALL; } else { @@ -3001,6 +3028,82 @@ remove_trailing_slash (char *data) } } +static COB_INLINE COB_A_INLINE int +string_is_dash (const char *s) +{ + return (strcmp (s, COB_DASH) == 0); +} + +static void +add_depend_target (const char *s) +{ + if (!cb_depend_target) { + cb_depend_target = cobc_strdup (s); + } else { + /* multiple invocations add to the list */ + const size_t orig_len = strlen (cb_depend_target); + const size_t new_len = strlen (s); + const size_t buff_len = orig_len + 1 + new_len + 1; + cb_depend_target = cobc_realloc (cb_depend_target, buff_len); + *(cb_depend_target + orig_len) = ' '; + memcpy (cb_depend_target + orig_len + 1, s, new_len); + *(cb_depend_target + orig_len + 1 + new_len) = '\0'; + } +} + +static void +add_depend_escape_target (const char *s) +{ + int i, nchars = 0; + const int len = strlen (s); + for (i=0; i<len; i++) { + const char c = s[i]; + if (c == '$' || c == '#' || c == '*') { + nchars++; + } + } + if (nchars) { + char *new_s = cobc_malloc (len+nchars+1); + char *cur_s = new_s ; + for (i=0; i<len; i++) { + const char c = s[i]; + if (c == '$') { + *cur_s++ = '$'; + } else if (c == '#' || c == '*'){ + *cur_s++ = '\\'; + } + *cur_s++ = c; + } + *cur_s = 0; + add_depend_target (new_s); + cobc_free (new_s); + } else { + add_depend_target (s); + } +} + +static const char * +file_replace_extension (const char *file, const char *ext) +{ + int i; + const int len = strlen (file); + const int extlen = strlen (ext); + for (i=len; i>0; i--) { + const char c = file[i]; + if (c == '.') { + const int newlen = i+extlen+1; + char *new_file = cobc_malloc(newlen); + memcpy (new_file, file, i); + memcpy (new_file+i, ext, extlen+1); + return new_file; + } + if (c == '/') { + break; + } + } + return cobc_main_stradd_dup (file, ext); +} + /* process command line options */ static int process_command_line (const int argc, char **argv) @@ -3093,7 +3196,10 @@ process_command_line (const int argc, char **argv) /* --version */ cobc_print_version (); if (verbose_output) { - puts ("\n"); + /* temporarily reduce verbosity for not necessarily showing the process */ + const int verbose_output_sav = verbose_output--; + + putchar ('\n'); fflush (stdout); #ifdef _MSC_VER process ("cl.exe"); @@ -3107,7 +3213,8 @@ process_command_line (const int argc, char **argv) snprintf (cobc_buffer, cobc_buffer_size, "%s --version", cobc_cc); #endif #if (defined(__GNUC__) && !defined(__INTEL_COMPILER)) - if (verbose_output > 2) { + if (verbose_output > 1) { + verbose_output--; snprintf (cobc_buffer, cobc_buffer_size, "%s -v", cobc_cc); } #endif @@ -3116,6 +3223,7 @@ process_command_line (const int argc, char **argv) cobc_free (cobc_buffer); cobc_buffer = NULL; #endif + verbose_output = verbose_output_sav; } cobc_early_exit (EXIT_SUCCESS); @@ -3287,7 +3395,7 @@ process_command_line (const int argc, char **argv) break; case CB_FLAG_GETOPT_DUMP: - /* -fdump=<scope> : Add sections for dump code generation */ + /* -fdump[=<scope>] : Add sections for dump code generation */ cobc_def_dump_opts (cob_optarg, 1); break; @@ -3642,28 +3750,29 @@ process_command_line (const int argc, char **argv) cb_define_list = p; break; - case '!': - /* -MT <target> */ - if (!cb_depend_target) { - cb_depend_target = cobc_strdup (cob_optarg); - } else { - /* multiple invocations add to the list */ - const size_t orig_len = strlen (cb_depend_target); - const size_t new_len = strlen (cob_optarg); - const size_t buff_len = orig_len + 1 + new_len + 1; - cb_depend_target = cobc_realloc (cb_depend_target, buff_len); - memset (cb_depend_target + orig_len, ' ', 1); - memcpy (cb_depend_target + orig_len + 1, cob_optarg, new_len); - memset (cb_depend_target + orig_len + 1 + new_len, 0, 1); - } + case CB_FLAG_GETOPT_DEPEND_OUTPUT: /* -M */ + cb_depend_output = 1; + cb_depend_output_only = 1; + cb_compile_level = CB_LEVEL_PREPROCESS; break; - - case '@': - /* -MF <file> */ - cb_depend_file = fopen (cob_optarg, "w"); - if (!cb_depend_file) { - cb_perror (0, "cobc: %s: %s", cob_optarg, cb_get_strerror ()); - } + case CB_FLAG_GETOPT_DEPEND_ON_THE_SIDE: /* -MD */ + cb_depend_output = 1; + cb_depend_target_auto = 1; + break; + case CB_FLAG_GETOPT_DEPEND_ADD_PHONY: /* -MP */ + cb_depend_add_phony = 1; + break; + case CB_FLAG_GETOPT_DEPEND_KEEP_MISSING: /* -MG */ + cb_depend_keep_missing = 1; + break; + case CB_FLAG_GETOPT_DEPEND_TARGET: /* -MT <target> */ + add_depend_target (cob_optarg); + break; + case CB_FLAG_GETOPT_DEPEND_ESCAPE_TARGET: /* -MQ <target> */ + add_depend_escape_target (cob_optarg); + break; + case CB_FLAG_GETOPT_DEPEND_OUTPUT_FILE: /* -MF <file> */ + cb_depend_filename = cobc_strdup(cob_optarg); break; case 'I': @@ -4057,6 +4166,23 @@ process_command_line (const int argc, char **argv) } } + if (cb_flag_copybook_deps) { + /* same as -M, but only COPYBOOK names */ + cb_depend_output = 1; + cb_depend_output_only = 1; + cb_depend_keep_missing = 1; + cb_depend_add_phony = 0; + cb_compile_level = CB_LEVEL_PREPROCESS; + } + if (!cb_depend_output && + (cb_depend_filename || cb_depend_add_phony || cb_depend_target + || cb_depend_keep_missing)) { + cobc_err_exit ("dependency options require -M or -MD"); + } + if (cb_depend_output_only && cb_compile_level != CB_LEVEL_PREPROCESS) { + cobc_err_exit ("-M is compatible only with -E. Use -MD instead."); + } + /* Load reserved words from fixed word-list if specified */ if (cb_reserved_words != NULL) { cb_load_words(); @@ -4111,7 +4237,29 @@ process_command_line (const int argc, char **argv) } #endif - if (output_name && strcmp (output_name, COB_DASH) == 0) { + if (cb_depend_target_auto) { + if (!cb_depend_filename) { + if (output_name) { + cb_depend_filename = + file_replace_extension (output_name, ".d"); + } + } + } + if (cb_depend_output_only) { + if (cb_depend_filename) { + if (output_name) { + cb_depend_output_only = 0; + } + } else { + if (output_name) { + cb_depend_filename = output_name; + output_name = NULL; + } else + cb_depend_filename = cobc_strdup(COB_DASH); + } + } + + if (output_name && string_is_dash (output_name)) { cb_src_list_file = stdout; if (cb_compile_level != CB_LEVEL_PREPROCESS) { cobc_err_exit (_("output to stdout only valid for preprocess")); @@ -4119,18 +4267,16 @@ process_command_line (const int argc, char **argv) cobc_main_free (output_name); cobc_main_free (output_name_buff); } - -#if 0 /* TODO: */ - if (cb_compile_level == CB_LEVEL_PREPROCESS - && output_name && strcmp (output_name, COB_DASH) != 0)) { - cb_depend_file = output_file; - } -#endif - /* TODO: add -M and -MD (breaking change "per GCC" already announced) */ - if (cb_depend_file && !cb_depend_target) { - fclose (cb_depend_file); - cb_depend_file = NULL; - cobc_err_exit (_("-MT must be given to specify target file")); + + if (cb_depend_filename) { + if (string_is_dash(cb_depend_filename)) { + cb_depend_file = stdout; + } else { + cb_depend_file = fopen (cb_depend_filename, "w"); + if (!cb_depend_file) { + cb_perror (0, "cobc: %s: %s", cb_depend_filename, cb_get_strerror ()); + } + } } /* debug: Turn on all exception conditions @@ -4355,7 +4501,7 @@ process_filename (const char *filename) char *full_path; #endif - if (strcmp (filename, COB_DASH) == 0) { + if (string_is_dash (filename)) { if (cobc_seen_stdin == 0) { cobc_seen_stdin = 1; file_is_stdin = 1; @@ -5196,7 +5342,8 @@ preprocess (struct filename *fn) #endif if (output_name - || cb_compile_level > CB_LEVEL_PREPROCESS) { + || cb_compile_level > CB_LEVEL_PREPROCESS + || cb_depend_output_only) { if (cb_unix_lf) { ppout = fopen(fn->preprocess, "wb"); } else { @@ -5300,7 +5447,7 @@ preprocess (struct filename *fn) fflush (stderr); } if (cb_listing_outputfile && verbose_output >= 0) { - if (strcmp (cb_listing_outputfile, COB_DASH) == 0) { + if (string_is_dash (cb_listing_outputfile)) { cb_src_list_file = stdout; } else { if (cb_unix_lf) { @@ -9156,6 +9303,50 @@ process_file (struct filename *fn, int status) cobc_set_listing_header_code (); } + if (cb_depend_output) { + struct cb_text_list *l; + const char *sep = " \\\n"; + FILE *file = NULL; + + if (cb_flag_copybook_deps) { + sep = ""; + } + if (cb_depend_file) { + file = cb_depend_file; + } else { + const char *basename = file_basename (fn->source, NULL); + const char *d_name = file_replace_extension (basename, ".d"); + file = fopen (d_name, "w"); + } + + if (cb_depend_target) { + fprintf (file, "%s:%s", cb_depend_target, sep); + } else { + const char *basename = file_basename (fn->source, NULL); + basename = file_replace_extension (basename, "." COB_OBJECT_EXT); + fprintf (file, "%s:%s", basename, sep); + } + + for (l = cb_depend_list; l; l = l->next) { + fprintf (file, " %s%s", l->text, l->next ? sep : "\n\n"); + } + /* These lines should only be added with -MP */ + if (cb_depend_add_phony) { + for (l = cb_depend_list; l; l = l->next) { + fprintf (file, "%s:\n", l->text); + } + } + if (!cb_depend_file) { + fclose (file); + } + + /* For now, we don't need to free this space as it is + allocated by cobc_plex_malloc() for which no + cobc_plex_free() exists. Everything is freed at the + end. */ + cb_depend_list = NULL; + } + if (cobc_list_file) { putc ('\n', cb_listing_file); } @@ -9319,7 +9510,7 @@ main (int argc, char **argv) memset (cb_listing_header, 0, sizeof (cb_listing_header)); /* If -P=file specified, all lists go to this file */ if (cobc_list_file) { - if (strcmp (cobc_list_file, COB_DASH) == 0) { + if (string_is_dash (cobc_list_file)) { cb_listing_file = stdout; } else if (cb_unix_lf) { @@ -9334,7 +9525,7 @@ main (int argc, char **argv) /* internal complete source listing file */ if (cb_listing_outputfile) { - if (strcmp (cb_listing_outputfile, COB_DASH) == 0) { + if (string_is_dash (cb_listing_outputfile)) { cb_src_list_file = stdout; } else { if (cb_unix_lf) { @@ -9427,15 +9618,7 @@ main (int argc, char **argv) } /* Output dependency list */ - if (cb_depend_file) { - struct cb_text_list *l; - fprintf (cb_depend_file, "%s: \\\n", cb_depend_target); - for (l = cb_depend_list; l; l = l->next) { - fprintf (cb_depend_file, " %s%s\n", l->text, l->next ? " \\" : "\n"); - } - for (l = cb_depend_list; l; l = l->next) { - fprintf (cb_depend_file, "%s:\n", l->text); - } + if (cb_depend_file && cb_depend_file != stdout) { fclose (cb_depend_file); } diff --git a/cobc/cobc.h b/cobc/cobc.h index 822f7381e..2c1bcf2ca 100644 --- a/cobc/cobc.h +++ b/cobc/cobc.h @@ -473,6 +473,9 @@ extern int cb_saveargc; extern FILE *cb_listing_file; extern FILE *cb_src_list_file; extern FILE *cb_depend_file; +extern int cb_depend_output; +extern int cb_depend_keep_missing; +extern int cb_flag_copybook_deps; extern struct cb_text_list *cb_depend_list; extern struct cb_text_list *cb_copy_list; extern struct cb_text_list *cb_include_file_list; diff --git a/cobc/codegen.c b/cobc/codegen.c index 29ef1c6fe..2710761f8 100644 --- a/cobc/codegen.c +++ b/cobc/codegen.c @@ -5352,7 +5352,11 @@ output_initialize_to_default (struct cb_field *f, cb_tree x) static void output_c_info (void) { - /* note: output name is already escaped for C string */ + /* note: output name is already escaped for C string; + output name cannot be COB_DASH as we generate the headers "on the fly" and + would have to place everything into temporary files (which would have a name) + and after we're finished cat those to stdout; or adjust to first generate the + headers (in memory) and output them instead of the #include */ output ("#line %d \"%s\"", output_line_number + 1, output_name); output_newline (); } @@ -5362,12 +5366,17 @@ output_cobol_info (cb_tree x) { const char *p = x->source_file; output ("#line %d \"", x->source_line); + + if (strcmp (p, COB_DASH)) { /* escape COBOL file name for C string */ - while (*p) { - if (*p == '\\') { - output ("%c",'\\'); + while (*p) { + if (*p == '\\') { + output ("%c", '\\'); + } + output ("%c", *p++); } - output ("%c",*p++); + } else { + output ("<stdin>"); } output ("\""); output_newline (); @@ -9339,16 +9348,14 @@ output_indexed_file_key_colseq (const struct cb_file *f, const struct cb_alt_key { const cb_tree key = ak ? ak->key : f->key; const cb_tree key_col = ak ? ak->collating_sequence_key : f->collating_sequence_key; - const int type = cb_tree_type (key, cb_code_field (key)); cb_tree col = NULL; - /* We only apply a collating sequence if the key is alphanumeric / display */ - if ((type & COB_TYPE_ALNUM) || (type == COB_TYPE_NUMERIC_DISPLAY)) { + /* We only apply a collating sequence if the key is of class alphanumeric; + Warned in `validate_indexed_key_field`. */ + if (CB_TREE_CLASS (key) == CB_CLASS_ALPHANUMERIC) { col = key_col ? key_col : f->collating_sequence; -#if 0 /* TODO: this should be done for national, when available */ - } else if (type & COB_TYPE_NATIONAL) { - col = key_col_n ? key_col_n : f->collating_sequence_n; -#endif + } else if (CB_TREE_CLASS (key) == CB_CLASS_NATIONAL) { + col = f->collating_sequence_n; } output_prefix (); diff --git a/cobc/flag.def b/cobc/flag.def index ad6f720c5..d487f3ab4 100644 --- a/cobc/flag.def +++ b/cobc/flag.def @@ -82,9 +82,10 @@ CB_FLAG_NQ (0, "ec", CB_FLAG_GETOPT_EC, CB_FLAG_NQ (0, "no-ec", CB_FLAG_GETOPT_NO_EC, " -fno-ec=<exception-name>\tdisable code generation for <exception-name>") -CB_FLAG_NQ (1, "dump", CB_FLAG_GETOPT_DUMP, +CB_FLAG_OP (1, "dump", CB_FLAG_GETOPT_DUMP, _(" -fdump=<scope> dump data fields on abort, <scope> may be\n" - " a combination of: ALL, WS, LS, RD, FD, SC, LO")) + " a combination of: ALL, WS, LS, RD, FD, SC, LO\n" + " default if no scope specified: ALL")) CB_FLAG_OP (0, "no-dump", CB_FLAG_GETOPT_NO_DUMP, _(" -fno-dump=<scope> exclude data fields from dumping on abort, <scope> may\n" " be a combination of: ALL, WS, LS, RD, FD, SC, LO\n" @@ -149,6 +150,8 @@ 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/cobc/help.c b/cobc/help.c index 3e95a2e19..bb1ee3127 100644 --- a/cobc/help.c +++ b/cobc/help.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, Ron Norman, Simon Sobisch, Brian Tiffin, Edward Hart, Dave Pitts @@ -44,14 +44,20 @@ cobc_print_usage (char * prog) cobc_print_usage_dialect (); - putchar ('\n'); +#ifndef PACKAGE_BUGREPORT_URL printf (_("Report bugs to: %s\n" "or (preferably) use the issue tracker via the home page."), - "bug-gnucobol@gnu.org"); + PACKAGE_BUGREPORT); putchar ('\n'); - printf (_("GnuCOBOL home page: <%s>"), "https://www.gnu.org/software/gnucobol/"); +#else + puts (_("For bug reporting instructions, please see:")); + printf ("%s.\n", PACKAGE_BUGREPORT_URL); +#endif + printf (_("GnuCOBOL home page: <%s>"), + "https://www.gnu.org/software/gnucobol/"); putchar ('\n'); - printf (_("General help using GNU software: <%s>"), "https://www.gnu.org/gethelp/"); + printf (_("General help using GNU software: <%s>"), + "https://www.gnu.org/gethelp/"); putchar ('\n'); } @@ -135,9 +141,15 @@ cobc_print_usage_common_options (void) puts (_(" --list-system display system routines")); puts (_(" --save-temps[=<dir>] save intermediate files\n" " * default: current directory")); + puts (_(" -M output dependency list in Makefile format")); puts (_(" -MT <target> set/add target file used in dependency list")); + puts (_(" -MQ <target> same as -MT but with Makefile-quoting of the target")); puts (_(" -MF <file> place dependency list into <file>")); + puts (_(" -MP create phony targets for all dependencies")); + puts (_(" -MG output missing dependencies without complaining")); + puts (_(" -MD output dependencies in .d files while compiling")); puts (_(" -ext <extension> add file extension for resolving COPY")); + puts (_(" -fcopybook-deps output copybook names as dependencies")); putchar ('\n'); } diff --git a/cobc/parser.y b/cobc/parser.y index 5f4eebe45..6293848c0 100644 --- a/cobc/parser.y +++ b/cobc/parser.y @@ -5784,7 +5784,7 @@ collating_sequence_clause: check_repeated ("COLLATING", SYN_CLAUSE_3, &check_duplicate); current_file->collating_sequence = alphanumeric_collation; current_file->collating_sequence_n = national_collation; - CB_UNFINISHED ("FILE COLLATING SEQUENCE"); /* only implemented for BDB */ + CB_UNFINISHED_X (alphanumeric_collation, "FILE COLLATING SEQUENCE"); /* only implemented for BDB */ } ; @@ -5836,7 +5836,7 @@ collating_sequence_clause_key: and also attached to the correct key later, so just store in a list here: */ current_file->collating_sequence_keys = cb_list_add(current_file->collating_sequence_keys, CB_BUILD_PAIR ($6, $4)); - CB_UNFINISHED ("KEY COLLATING SEQUENCE"); /* only implemented for BDB */ + CB_UNFINISHED_X ($6, "KEY COLLATING SEQUENCE"); /* only implemented for BDB */ } ; diff --git a/cobc/pplex.l b/cobc/pplex.l index 0b7105efb..303f34ec3 100644 --- a/cobc/pplex.l +++ b/cobc/pplex.l @@ -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, Dave Pitts This file is part of GnuCOBOL. @@ -25,6 +25,7 @@ %option prefix="pp" %option stack +%option noyywrap %option noyy_top_state %option noyy_scan_buffer @@ -54,11 +55,6 @@ #undef YY_BUF_SIZE #define YY_BUF_SIZE 32768 -#define YY_SKIP_YYWRAP -static int ppwrap (void) { - return 1; -} - static void insert_copy_arg (void); #define PPLEX_BUFF_LEN 512 @@ -85,6 +81,7 @@ static void insert_copy_arg (void); #include <ctype.h> #include <sys/stat.h> #include <sys/types.h> +#include <stdio.h> #include <string.h> #ifdef HAVE_STRINGS_H #include <strings.h> @@ -1287,7 +1284,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; } } @@ -1461,7 +1458,7 @@ ppopen (const char *name, struct cb_replace_list *replacing_list) } /* add opened file to dependency list */ - if (cb_depend_file) { + if (cb_depend_output && !cb_flag_copybook_deps) { cb_depend_list = pp_text_list_add (cb_depend_list, name, strlen (name)); } @@ -1619,6 +1616,16 @@ cb_copy_find_file (char *name, int has_ext) return NULL; } +static COB_INLINE COB_A_INLINE void +output_line_directive (FILE *stream) +{ + if (strcmp (cb_source_file, COB_DASH)) { + fprintf (yyout, "#line %d \"%s\"\n", cb_source_line, cb_source_file); + } else { + fprintf (yyout, "#line %d \"<stdin>\"\n", cb_source_line); + } +} + static COB_INLINE COB_A_INLINE void output_pending_newlines (FILE *stream) { @@ -1627,7 +1634,7 @@ output_pending_newlines (FILE *stream) long comment blocks, for example from EXEC SQL preparsers), so generate source directive from the already adjusted static vars instead of spitting out possibly hundreds of empty lines */ - fprintf (stream, "\n#line %d \"%s\"\n", cb_source_line, cb_source_file); + output_line_directive (stream); echo_newline = 0; } else { while (echo_newline > 1) { @@ -1654,6 +1661,20 @@ ppcopy (const char *name, const char *lib, struct cb_replace_list *replace_list) plexbuff1 = cobc_malloc ((size_t)COB_SMALL_BUFF); } + if (cb_depend_output && cb_flag_copybook_deps) { + + if (lib) { + snprintf (plexbuff1, (size_t)COB_SMALL_MAX, "%s%c%s", + lib, SLASH_CHAR, name); + plexbuff1[COB_SMALL_MAX] = 0; + } else { + strcpy (plexbuff1, name); + } + cb_depend_list = + pp_text_list_add (cb_depend_list, plexbuff1, + strlen (plexbuff1)); + } + /* TODO: open with path relative to the current file's path, if any (applies both to with and without "lib") */ @@ -1724,15 +1745,28 @@ ppcopy (const char *name, const char *lib, struct cb_replace_list *replace_list) } /* otherwise fall-trough to error handling */ } else { - /* ensure to have errno from name as specified, not from another file */ - (void)access (plexbuff1, R_OK); - /* pass file error as we have no more places to check */ - cb_error ("%s: %s", plexbuff1, cb_get_strerror ()); + /* do not output error if looking only for copybook deps */ + if (!cb_flag_copybook_deps){ + + /* add opened file to dependency list */ + if (cb_depend_output && cb_depend_keep_missing) { + const char *depname = cobc_plex_stradd (plexbuff1, cb_extension_list->text); + + cb_depend_list = pp_text_list_add (cb_depend_list, depname, strlen (depname)); + } else { + + /* ensure to have errno from name as specified, not from another file */ + (void)access (plexbuff1, R_OK); + /* pass file error as we have no more places to check */ + cb_error ("%s: %s", + plexbuff1, cb_get_strerror ()); + } + } } /* On COPY, open error restore old file */ cb_current_file = old_list_file; - fprintf (yyout, "#line %d \"%s\"\n", cb_source_line, cb_source_file); + output_line_directive (yyout); return -1; } @@ -2096,7 +2130,8 @@ switch_to_buffer (const int line, const char *file, const YY_BUFFER_STATE buffer /* Reset file/line */ cb_source_line = line; cb_source_file = file; - fprintf (yyout, "#line %d \"%s\"\n", line, file); + + output_line_directive (yyout); /* Switch buffer */ yy_switch_to_buffer (buffer); } @@ -2793,6 +2828,12 @@ pp_text_list_add (struct cb_text_list *list, const char *text, struct cb_text_list *p; void *tp; + for (p = list; p; p = p->next) { + if (!strcmp(text, p->text)) { + return list; + } + } + p = cobc_plex_malloc (sizeof (struct cb_text_list)); tp = cobc_plex_malloc (size + 1); memcpy (tp, text, size); diff --git a/cobc/scanner.l b/cobc/scanner.l index 15f3d1871..878e660e9 100644 --- a/cobc/scanner.l +++ b/cobc/scanner.l @@ -24,6 +24,7 @@ %option case-insensitive %option never-interactive %option nodefault +%option noyywrap %option noyy_scan_buffer %option noyy_scan_bytes @@ -52,11 +53,6 @@ #undef YY_BUF_SIZE #define YY_BUF_SIZE 32768 -#define YY_SKIP_YYWRAP -static int yywrap (void) { - return 1; -} - #define YY_INPUT(buf,result,max_size) \ { \ if (fgets (buf, (int)max_size, yyin) == NULL) { \ @@ -85,6 +81,7 @@ static int yywrap (void) { #include <ctype.h> #include <limits.h> +#include <stdio.h> #include <string.h> #ifdef HAVE_STRINGS_H #include <strings.h> @@ -1366,7 +1363,7 @@ scan_ebcdic_char (int c) buff, "(1..256)"); return '?'; } - c--; // in ordinal, i.e. 1..256 -> 0..255 + c--; /* in ordinal, i.e. 1..256 -> 0..255 */ #ifdef COB_EBCDIC_MACHINE return (cob_u8_t) c; #else diff --git a/cobc/tree.c b/cobc/tree.c index 72008a659..9ae64d219 100644 --- a/cobc/tree.c +++ b/cobc/tree.c @@ -4789,6 +4789,27 @@ validate_indexed_key_field (struct cb_file *f, struct cb_field *records, } } } + + /* check collating sequence is not ignored */ + if (get_warn_opt_value (cb_warn_filler) != COBC_WARN_DISABLED + && CB_TREE_CLASS (k) != CB_CLASS_ALPHANUMERIC) { + const char *source = "KEY"; + cb_tree colseq = (cbak == NULL) + ? f->collating_sequence_key + : cbak->collating_sequence_key; + cb_tree pos = colseq; + if (colseq == NULL) { + source = "FILE"; + colseq = f->collating_sequence; + pos = key_ref; + } + if (colseq != NULL) { + cb_warning_x (COBC_WARN_FILLER, CB_TREE (pos), + _("%s COLLATING SEQUENCE '%s' is ignored " + "for non-alphanumeric key '%s'"), + source, CB_NAME (colseq), k->name); + } + } } void diff --git a/cobc/typeck.c b/cobc/typeck.c index 1b2a5039a..3f87068dd 100644 --- a/cobc/typeck.c +++ b/cobc/typeck.c @@ -1055,16 +1055,33 @@ cb_emit_list (cb_tree l) return l; } +static COB_INLINE COB_A_INLINE int +cb_tree_is_numeric_ref_or_field (cb_tree x, int include_numeric_edited) +{ + int cat; + if (!x || !CB_REF_OR_FIELD_P (x)) { + return 0; + } + cat = CB_TREE_CATEGORY (x); + return (cat == CB_CATEGORY_NUMERIC + || (include_numeric_edited && cat == CB_CATEGORY_NUMERIC_EDITED)); +} + +static int +cb_tree_list_has_numeric_ref_or_field (cb_tree l) +{ + for (; + l && !cb_tree_is_numeric_ref_or_field (CB_VALUE (l), 1); + l = CB_CHAIN (l)); + return (l != NULL); +} + static void cb_emit_incompat_data_checks (cb_tree x) { struct cb_field *f; - if (!x || x == cb_error_node) { - return; - } - if (!CB_REF_OR_FIELD_P (x) - || CB_TREE_CATEGORY (x) != CB_CATEGORY_NUMERIC) { + if (!cb_tree_is_numeric_ref_or_field (x, 0)) { return; } f = CB_FIELD_PTR (x); @@ -3924,6 +3941,7 @@ validate_alphabet (cb_tree alphabet) ap->high_val_char = maxchar; alphabet_valid = 1; + n = 0; /* keep analyzer happy */ for (l = ap->custom_list; l; l = CB_CHAIN (l)) { x = CB_VALUE (l); @@ -8243,7 +8261,9 @@ cb_emit_accept (cb_tree var, cb_tree pos, struct cb_attr_struct *attr_ptr) if (cb_listing_xref) { cobc_xref_set_receiving (var); } - + if (cb_validate_one (pos)) { + return; + } if (attr_ptr) { fgc = attr_ptr->fgc; bgc = attr_ptr->bgc; @@ -8255,8 +8275,7 @@ cb_emit_accept (cb_tree var, cb_tree pos, struct cb_attr_struct *attr_ptr) cursor = attr_ptr->cursor; color = attr_ptr->color; disp_attrs = attr_ptr->dispattrs; - if (cb_validate_one (pos) - || cb_validate_one (fgc) + if (cb_validate_one (fgc) || cb_validate_one (bgc) || cb_validate_one (scroll) || cb_validate_one (timeout) @@ -12884,8 +12903,11 @@ cb_emit_move (cb_tree src, cb_tree dsts) return; } - /* validate / fix-up source, if requested */ - cb_emit_incompat_data_checks (src); + /* validate / fix-up source, if at least one receiver is of category + numeric */ + if (cb_tree_list_has_numeric_ref_or_field (dsts)) { + cb_emit_incompat_data_checks (src); + } /* FIXME: this is way to much to cater for sum field */ src = cb_check_sum_field (src); @@ -13725,8 +13747,11 @@ cb_emit_set_to (cb_tree vars, cb_tree src) return; } - /* validate / fix-up source, if requested */ - cb_emit_incompat_data_checks (src); + /* validate / fix-up source, if at least one receiver is of category + numeric */ + if (cb_tree_list_has_numeric_ref_or_field (vars)) { + cb_emit_incompat_data_checks (src); + } /* Emit statements. */ for (l = vars; l; l = CB_CHAIN (l)) { diff --git a/config/ChangeLog b/config/ChangeLog index cd1a4744f..a23c513bb 100644 --- a/config/ChangeLog +++ b/config/ChangeLog @@ -44,11 +44,19 @@ * rm-strict.conf: enable indirect-redefines as this was added with later RM-COBOL versions +2023-02-20 Nicolas Berthier <nicolas.berthier@ocamlpro.com> + + * general: add ebcdic-symbolic-characters + 2023-02-16 Fabrice Le Fessant <fabrice.le_fessant@ocamlpro.com> * gcos.words: remove alias VALUES=VALUE, to correctly parse "VALUES ARE" +2023-01-28 Fabrice Le Fessant <fabrice.le_fessant@ocamlpro.com> + + * default.conf: change default source reference-format to 'auto' + 2023-01-25 Simon Sobisch <simonsobisch@gnu.org> * ibm.words, mvs.words: re-add BINARY diff --git a/configure.ac b/configure.ac index d8719b571..703d359b2 100644 --- a/configure.ac +++ b/configure.ac @@ -22,7 +22,11 @@ dnl You should have received a copy of the GNU General Public License dnl along with GnuCOBOL. If not, see <https://www.gnu.org/licenses/>. dnl -AC_PREREQ([2.67]) # note: 2.67 is the one found in old msys, 2.69 is commonly available +# note: old environments only have autoconf 2.69 or even (old msys) 2.67 +# just do a "make dist" on a modern system and get the taball back +# to the ancient one... (which would likely also not have the necessary +# automake package either) +AC_PREREQ([2.70]) AC_INIT([GnuCOBOL], [3.3-dev], @@ -33,9 +37,11 @@ AC_REVISION([GnuCOBOL snapshot $Revision$]) AC_COPYRIGHT([This file is part of GnuCOBOL. Copyright (C) 2001-2012, 2014-2024 Free Software Foundation, Inc. + Written by Keisuke Nishida, Roger While, Ron Norman, Simon Sobisch, Edward Hart ]) + AC_CONFIG_SRCDIR([libcob.h]) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_TESTDIR([tests]) @@ -54,6 +60,50 @@ AC_CONFIG_FILES([tests/atlocal], [chmod +x tests/atlocal]) AC_CONFIG_FILES([tests/run_prog_manual.sh], [chmod +x tests/run_prog_manual.sh]) +dnl Support the --with-pkgversion configure option, +dnl inspired from GCC's ACX_PKGVERSION. +AC_ARG_WITH([pkgversion], + [AS_HELP_STRING([--with-pkgversion=PKG], + [Use PKG in the version string in place of "$PACKAGE_NAME"])], + [case "$withval" in + yes) AC_MSG_ERROR([package version not specified]) ;; + no) PKGVERSION= ;; + *) PKGVERSION="($withval) " ;; + esac], + [PKGVERSION="($PACKAGE_NAME) "]) + +# AC_SUBST(PKGVERSION) +AC_DEFINE_UNQUOTED([PKGVERSION], ["$PKGVERSION"], [PKG version string]) + + +dnl Support the --with-bugurl configure option, +dnl inspired from GCC's ACX_BUGURL. +AC_ARG_WITH([bugurl], + [AS_HELP_STRING([--with-bugurl=URL], + [Direct users to URL to report a bug, instead of mailing list])], + [case "$withval" in + yes) AC_MSG_ERROR([bug URL not specified]) ;; + no) BUGURL= ;; + *) BUGURL="$withval" ;; + esac], + [ # BUGURL="$PACKAGE_BUGREPORT" + ]) + + case ${BUGURL} in + "") + # REPORT_BUGS_TO= + # REPORT_BUGS_TEXI= + ;; + *) + AC_DEFINE_UNQUOTED([PACKAGE_BUGREPORT_URL], ["<$BUGURL>"], [Bug URL instead of mailing list]) + # REPORT_BUGS_TO="<$BUGURL>" + # REPORT_BUGS_TEXI=@uref{`echo "$BUGURL" | sed 's/@/@@/g'`} + ;; + esac; + # AC_SUBST(REPORT_BUGS_TO) + # AC_SUBST(REPORT_BUGS_TEXI) + + # In general: don't export/setenv but pass as option to configure # this has the benefit that re-runs will take the same and "sudo" # or later "make" (possibly as different user) will use the same @@ -170,7 +220,6 @@ AH_TEMPLATE([COB_EXE_EXT], [Executable extension]) AH_TEMPLATE([COB_KEYWORD_INLINE], [Keyword for inline]) AH_TEMPLATE([COB_NO_SELFOPEN], [Can not dlopen self]) AH_TEMPLATE([COB_COMPUTED_GOTO], [Compilation of computed gotos works]) -AH_TEMPLATE([COB_LI_IS_LL], [long int is long long]) AH_TEMPLATE([COB_32_BIT_LONG], [long int is 32 bits]) AH_TEMPLATE([COB_64_BIT_POINTER], [Pointers are longer than 32 bits]) AH_TEMPLATE([WITH_CURSES], [curses library for extended SCREEN I/O]) @@ -541,6 +590,9 @@ 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]) +dnl We declare %noyywrap in the lexer files so we use the noyywrap +dnl option here to skip the search for that function. +AC_PROG_LEX([noyywrap]) AX_PROG_FLEX AX_PROG_BISON @@ -908,6 +960,42 @@ AC_CHECK_LIB([$with_math], [__gmp_get_memory_functions], LIBS="$curr_libs" CPPFLAGS="$curr_cppflags" +# Checks for gettext. + +case $host_os in + darwin* | rhapsody*) + ;; + *) + gt_cv_func_CFPreferencesCopyAppValue=no + gt_cv_func_CFLocaleCopyCurrent=no + ;; +esac + +dnl Simon: removed, use --disable-nls instead +dnl # Disable for Cygwin +dnl AC_MSG_CHECKING([for __CYGWIN__]) +dnl AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ +dnl #ifndef __CYGWIN__ +dnl # error macro not defined +dnl #endif]])], +dnl [enable_nls=no +dnl AC_MSG_RESULT([yes])], +dnl [AC_MSG_RESULT([no])]) + +AM_GNU_GETTEXT([external]) +AM_GNU_GETTEXT_VERSION([0.19.8]) +if test "x$LTLIBINTL" != x; then + if test "x$PROGRAMS_LIBS" != x; then + PROGRAMS_LIBS="$PROGRAMS_LIBS $LTLIBINTL" + else + PROGRAMS_LIBS="$LTLIBINTL" + fi + LIBCOB_LIBS="$LIBCOB_LIBS $LTLIBINTL" +fi + +# Checks for internationalization stuff +AM_LANGINFO_CODESET + AC_ARG_WITH([iconv], [AS_HELP_STRING([--with-iconv], [(GnuCOBOL) Use iconv for character set conversion (default: check)])], @@ -956,7 +1044,7 @@ AS_IF([test "$with_xml2" = yes -o "$with_xml2" = check], [ XML2_LIBS="-lxml2" fi LIBS="$LIBS $LIBCOB_LIBS_extern $XML2_LIBS" - # note: PKG_CONFIG and xml2-config set -I /path/to/libxml2 which contains a "libxml" folder where + # 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 AC_CHECK_HEADER([libxml/$header.h], [], @@ -1037,8 +1125,8 @@ AS_IF([test "$USE_JSON" = "cjson" -o "$USE_JSON" = "local" -o "$USE_JSON" = chec with_cjson_local=no 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_extern" + CPPFLAGS="$curr_cppflags -I./libcob $CJSON_CFLAGS" + LIBS="$LIBS $LIBCOB_LIBS_extern $CJSON_LIBS" AC_LINK_IFELSE([ AC_LANG_PROGRAM([[#include "cJSON.c"]], [[#if (CJSON_VERSION_MAJOR * 100 + CJSON_VERSION_MINOR) < 103 @@ -1055,8 +1143,8 @@ AS_IF([test "$USE_JSON" = "cjson" -o "$USE_JSON" = "local" -o "$USE_JSON" = chec if test "$with_cjson_local" = no; then 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_extern" + CPPFLAGS="$curr_cppflags -I$srcdir/libcob $CJSON_CFLAGS" + LIBS="$LIBS $LIBCOB_LIBS_extern $CJSON_LIBS" AC_LINK_IFELSE([ AC_LANG_PROGRAM([[#include "cJSON.c"]], [[#if (CJSON_VERSION_MAJOR * 100 + CJSON_VERSION_MINOR) < 103 @@ -1065,7 +1153,7 @@ AS_IF([test "$USE_JSON" = "cjson" -o "$USE_JSON" = "local" -o "$USE_JSON" = chec cJSON_CreateNull ();]])], [AC_MSG_RESULT([yes]) AC_DEFINE([WITH_CJSON], [1]) - with_cjson_local="yes (in \"$srcdir/libcob\")"], + with_cjson_local="yes (in $srcdir/libcob)"], [AC_MSG_RESULT([no])] ) LIBS="$curr_libs"] @@ -1134,7 +1222,7 @@ AS_IF([test "$USE_JSON" = "json-c" -o "$USE_JSON" = check], [ JSON_C_LIBS="-ljson-c" fi LIBS="$LIBS $LIBCOB_LIBS_extern $JSON_C_LIBS" - AC_CHECK_HEADERS([json.h json-c/json.h], [break], + AC_CHECK_HEADERS([json-c/json.h 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]) else @@ -1275,17 +1363,6 @@ AC_CHECK_FUNCS([fdatasync sigaction fmemopen]) AC_CHECK_DECLS([fdatasync]) # also check for declaration, missing on MacOS... AC_CHECK_DECLS([fmemopen]) # also check for declaration, missing on AIX... -# Checks for gettext. - -case $host_os in - darwin* | rhapsody*) - ;; - *) - gt_cv_func_CFPreferencesCopyAppValue=no - gt_cv_func_CFLocaleCopyCurrent=no - ;; -esac - # Checks for ncurses/pdcurses/curses. AC_MSG_NOTICE([Checks for curses ...]) AC_ARG_VAR([CURSES_LIBS], [linker flags for curses lookup, overriding automatic lookup, to be used with explicit selection via --with-curses=arg]) @@ -1901,11 +1978,6 @@ AC_CHECK_SIZEOF(long long) AC_CHECK_SIZEOF(long) AC_CHECK_SIZEOF(void *) -AC_MSG_CHECKING([whether size of long int = size of long long]) -AS_IF([test "$ac_cv_sizeof_long_int" = "$ac_cv_sizeof_long_long"], - [AC_DEFINE([COB_LI_IS_LL], [1]) AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])]) - AC_MSG_CHECKING([whether long is 32 bits]) AS_IF([test "$ac_cv_sizeof_long" = 4], [AC_DEFINE([COB_32_BIT_LONG], [1]) AC_MSG_RESULT([yes])], @@ -1975,32 +2047,6 @@ if test "$gc_cv_attribute_constructor" = yes; then fi CFLAGS="$curr_cflags" -dnl Simon: removed, use --disable-nls instead -dnl # Disable for Cygwin -dnl AC_MSG_CHECKING([for __CYGWIN__]) -dnl AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ -dnl #ifndef __CYGWIN__ -dnl # error macro not defined -dnl #endif]])], -dnl [enable_nls=no -dnl AC_MSG_RESULT([yes])], -dnl [AC_MSG_RESULT([no])]) - -AM_GNU_GETTEXT([external]) -AM_GNU_GETTEXT_VERSION([0.19.8]) -if test "x$LTLIBINTL" != x; then - if test "x$PROGRAMS_LIBS" != x; then - PROGRAMS_LIBS="$PROGRAMS_LIBS $LTLIBINTL" - else - PROGRAMS_LIBS="$LTLIBINTL" - fi - LIBCOB_LIBS="$LIBCOB_LIBS $LTLIBINTL" -fi - -# Checks for internationalization stuff -dnl currently not directly used: AM_ICONV -AM_LANGINFO_CODESET - # Check for perl, used for "make test" #AM_MISSING_PROG(PERL, perl) --> only use for tools that generate something AC_CHECK_PROG(PERL, perl, perl) diff --git a/doc/ChangeLog b/doc/ChangeLog index 6934379cf..1f25414cd 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,4 +1,8 @@ +2024-03-15 Fabrice Le Fessant <fabrice.le_fessant@ocamlpro.com> + + * gnucobol.texi: document new dependencies options + 2023-09-07 Emilien Lemaire <emilien.lemaire@ocamlpro.com> * gnucobol.texi: document the profiling feature diff --git a/doc/gnucobol.texi b/doc/gnucobol.texi index af4eb9fd2..29fa893f4 100644 --- a/doc/gnucobol.texi +++ b/doc/gnucobol.texi @@ -121,6 +121,7 @@ Compiler options * Configuration options:: Configuration options * Listing options:: Listing options * Debug switches:: Debug switches +* Dependencies options:: Dependencies options * Miscellaneous:: Miscellaneous Multiple sources @@ -291,6 +292,7 @@ A complete list of options can be displayed by using the option @option{--help}. * Configuration options:: Configuration options * Listing options:: Listing options * Debug switches:: Debug switches +* Dependencies options:: Dependencies options * Miscellaneous:: Miscellaneous @end menu @@ -540,7 +542,8 @@ between paragraphs and sections. Warnings are diagnostic messages that report constructions that are not inherently erroneous but that are risky or suggest there may have been an error. -The following options do not enable specific warnings but control the kinds of diagnostics produced by @command{cobc}. +The following options do not enable specific warnings but control the kinds of +diagnostics produced by @command{cobc}. @table @code @item -fsyntax-only @@ -615,9 +618,10 @@ and that are easy to avoid (or modify to prevent the warning).@* The list of warning flags turned on by this option is shown in @option{--help}. @item -Wextra, -W -Enable every possible warning that is not dialect specific. This includes more information -than @option{-Wall} would normally provide.@* -(This option used to be called @option{-W}. The older name is still supported, but the newer name is more descriptive.) +Enable every possible warning that is not dialect specific. This includes more +information than @option{-Wall} would normally provide.@* +(This option used to be called @option{-W}. The older name is still supported, +but the newer name is more descriptive.) @item -W@var{warning} Enable single warning @var{warning}. @@ -629,7 +633,8 @@ Disable single warning @var{warning}. Warn if archaic features are used, such as continuation lines or the @code{NEXT SENTENCE} statement. @item -Wcall-params -Warn if non-01/77-level items are used as arguments in a @code{CALL} statement. This is @emph{not} set with @option{-Wall}. +Warn if non-01/77-level items are used as arguments in a @code{CALL} statement. +This is @emph{not} set with @option{-Wall}. @item -Wcolumn-overflow Warn if text after column 72 in FIXED format. This is @emph{not} set with @option{-Wall}. @@ -781,8 +786,9 @@ Compiler uses the given @var{dialect} to determine the reserved words. User-defined dialect configuration. @item -febcdic-table=@var{cconv-table}/@var{file} -EBCDIC/ASCII translation table to use; either read from @var{file}, or one of the existing @var{cconv-table} -from the configuration directory (see @code{cobc --info}) which have a .ttbl extension, for example @option{-febcdic-table=alternate}.@* +EBCDIC/ASCII translation table to use; either read from @var{file}, or one of +the existing @var{cconv-table} from the configuration directory (see @code{cobc --info}) +which have a .ttbl extension, for example @option{-febcdic-table=alternate}.@* See the @file{default.ttbl} file for detailed information about the format. @end table @@ -977,6 +983,43 @@ Do not truncate binary fields according to PICTURE. @end table +@node Dependencies options +@subsection Dependencies options + +Dependencies are files containing the content included by @code{COPY} +statements. These options are usually used by build systems to extract +dependencies from COBOL files. The dependencies can then be used to +decide when a file should be recompiled or not. + +@table @code + +@item -M +Output dependency list in Makefile format on stdout. Stop after +preprocessing the file and do not generate any other files. + +@item -MT <target> +Set/add target file used in dependency list + +@item -MQ <target> +Same as -MT but with Makefile-quoting of the target + +@item -MF <file> +Specify a filename <file> where to output dependencies + +@item -MP +Create phony targets for all dependencies + +@item -MG +Output missing dependencies without complaining + +@item -MD +Output dependencies in .d files while compiling + +@item -fcopybook-deps +Output dependencies as copybook names instead of file names + +@end table + @node Miscellaneous @subsection Miscellaneous @table @code diff --git a/libcob/ChangeLog b/libcob/ChangeLog index 31bc7a0db..8b440116e 100644 --- a/libcob/ChangeLog +++ b/libcob/ChangeLog @@ -1,4 +1,64 @@ +2024-10-04 Simon Sobisch <simonsobisch@gnu.org> + + * common.c (cob_sig_handler): moved call of cob_exit_screen_from_signal + from ss_terminate_routines here instead of calling cob_exit_screen + * common.c (cob_sig_handler, cob_stack_trace_internal, + cob_runtime_warning_ss): now using an internal buffer to output data + instead of potentially hundreds of small direct writes, output the + complete buffer when half-full oir at the end + * common.c (get_source_location): renamed from output_source_location, + now writing to a specified buffer, returning the length, instead of + direct write to stderr + * common.c (output_procedure_stack_entry): use buffer instead of direct + write to stderr, now returning the length + * common.c (write_until_fail, strcat_to_buf, intcat_to_buff): new helper + functions + * common.c (cob_sig_handler): moved call of cob_exit_screen_from_signal + from ss_terminate_routines here instead of calling cob_exit_screen + * common.c (cob_runtime_warning_ss), coblocal.h, + fileio.c (cob_exit_fileio_msg_only): changed signature, now returning + nonzero if write to stderr wasn't sucessfull + * common.c (cob_runtime_warning, cob_runtime_warning_external): + use all buffered io again + * common.c (cob_load_config_file): fix format truncation warning by + explicit checking for it + +2024-10-02 Simon Sobisch <simonsobisch@gnu.org> + + * common.c (print_version): PACKAGE_NAME may now be overwritten + by PKGVERSION (new configure option) + * common.c (cob_sig_handler): fixed early exit from signal handler + in case of errors during write to stderr, adjusted macros accordingly + * common.c (cob_sig_handler): flush stdout+stderr for fixed set of signals + where this is known to work + * common.c (cob_reg_sighnd): if signal handler is enabled from outside the + COBOL runtime (like via cobc), do the initialization of the internal signal + text table (was empty before) + * common.c (cob_sig_handler): early exit for SIGPIPE without output if + signal handler is used without any COBOL modules active (like via cobc) + * common.c (cob_sig_handler): fixed coding error that led to missing output + of catched signal name + +2024-09-29 Simon Sobisch <simonsobisch@gnu.org> + + * numeric.c, common.c (print_info_detailed): drop COB_LI_IS_LL + in favor of existing COB_32_BIT_LONG + +2024-07-27 Chuck Haatvedt <chuck.haatvedt+cobol@gmail.com> + + * screenio.c: In preparation for Multiple Window support + added static WINDOW pointer "mywin", all curses functions + which either implicitly or explicitly referenced the + stdscr WINDOW pointer were changed to use the window + specific functions using mywin except the getch function + remains unchanged. The wgetch function caused the mouse + not to be recognized. + +2024-09-20 Chuck Haatvedt <chuck.haatvedt+cobol@gmail.com> + + * screenio.c (cob_screen_get_all) fixed Bug #990 + 2024-08-28 David Declerck <david.declerck@ocamlpro.com> * intrinsics.c (cob_intr_random), move.c (cob_move_display_to_packed): @@ -17,6 +77,22 @@ * screenio.c (cob_settings_screenio): implemented runtime config to hide the cursor +2024-08-11 Simon Sobisch <simonsobisch@gnu.org> + + * fileio.c (cob_fd_file_open) [_WIN32]: workaround for MinGW bug in locking + +2024-08-09 Simon Sobisch <simonsobisch@gnu.org> + + * common.h, common.c (cob_cleanup_thread): fix declaration + * common.c: drop includes found in coblocal.h + * common.c (cob_alloc_module): changed type and name of cob_mod_ptr + * common.h, coblocal.h: added pragma once for better supporting clangd + in single-file mode + +2024-08-06 Simon Sobisch <simonsobisch@gnu.org> + + * intrinsic.c: speedup for NUMVAL related functions + 2024-07-29 Chuck Haatvedt <chuck.haatvedt+cobol@gmail.com> * move.c (optimized_move_display_to_edited): fixed small bug @@ -70,10 +146,10 @@ 2024-05-30 Chuck Haatvedt <chuck.haatvedt+cobol@gmail.com> - fix errors caught by the Sanitizer functionality of GCC. This - change did not resolve all of the issues found as some of them - were in Berkeley DB and some were intentional in the memory - corruption logic which has been implemented in the runtime. + fix errors caught by the Sanitizer functionality of GCC. This + change did not resolve all of the issues found as some of them + were in Berkeley DB and some were intentional in the memory + corruption logic which has been implemented in the runtime. * move.c (the cob_move_display_to_packed function was rewritten to fix the out of bounds memory addressing issues and also to make @@ -83,8 +159,8 @@ 2024-05-30 Chuck Haatvedt <chuck.haatvedt+cobol@gmail.com> - fix errors in filio.c when building with VISAM 2.2. This issue - occurred when using a partial key with a sequential read previous. + fix errors in filio.c when building with VISAM 2.2. This issue + occurred when using a partial key with a sequential read previous. * fileio.c (indexed_start_internal), (indexed_start) and (indexed_read_next): added a new field, partial_key_length, @@ -115,7 +191,7 @@ 2024-07-19 Simon Sobisch <simonsobisch@gnu.org> - * coblocal.h (COB_TLS): add a new attribute for thread local static. + * coblocal.h (COB_TLS): add a new attribute for thread local static * common.h, common.c (cob_cleanup_thread): add a cleanup function for threads 2024-05-15 Simon Sobisch <simonsobisch@gnu.org> @@ -153,8 +229,9 @@ * fileio.c (cob_path_to_absolute): extracted from insert and cob_set_main_argv0 -2024-03-10 Alfredo Tupone <tupone@gentoo.org> +2024-01-31 Gwyn Ciesla <gwync@protonmail.com> + Bug #941 build issue * common.c: add missing include libxml/parser.h 2024-02-26 Boris Eng <boris.eng@ocamlpro.com> @@ -762,7 +839,7 @@ after suggestions by Chuck Haatvedt <chuck.haatvedt+cobol@gmail.com> * termio.c (pretty_display_numeric): fix GCC warning with {{ 0 }} * termio.c (display_alnum_dump): slightly rewritten to fix compiler warnings - * cconv.c (cob_load_collation), common.c, intrinisic.c (cob_intr_random), + * cconv.c (cob_load_collation), common.c, intrinsic.c (cob_intr_random), termio.c: minor adjustments to fix compiler warnings * fileio.c (copy_fcd_to_file): fixed memory issues with writing to assign and select name @@ -822,7 +899,7 @@ after suggestions by Chuck Haatvedt <chuck.haatvedt+cobol@gmail.com> * common.c (cob_move_packed_to_display, cob_packed_get_int, cob_packed_get_long_long): minor performance improvements and similar code to numeric.c - * intrinisic.c (calculate_start_end_for_numval): only skip leading spaces + * intrinsic.c (calculate_start_end_for_numval): only skip leading spaces and zeros, but not leading low-values 2023-01-25 Simon Sobisch <simonsobisch@gnu.org> @@ -1122,8 +1199,8 @@ after suggestions by Chuck Haatvedt <chuck.haatvedt+cobol@gmail.com> 2022-10-17 Simon Sobisch <simonsobisch@gnu.org> * common.c (cob_debug_open, cob_trace_print), intrinsic.c - (cob_intr_hex_to_char): prefer extending switch over use of topupper - * call.c, common.c, intrinisic.c, screenio.c: directly call toupper/tolower + (cob_intr_hex_to_char): prefer extending switch over use of topupper + * call.c, common.c, intrinsic.c, screenio.c: directly call toupper/tolower without previous check of islower/isupper * system.def, common.c (cob_sys_runtime_error_proc): implement CBL_RUNTIME_ERROR diff --git a/libcob/coblocal.h b/libcob/coblocal.h index 5fa04d7f9..a8b8e2c6c 100644 --- a/libcob/coblocal.h +++ b/libcob/coblocal.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2007-2012, 2014-2023 Free Software Foundation, Inc. + Copyright (C) 2007-2012, 2014-2024 Free Software Foundation, Inc. Written by Roger While, Simon Sobisch, Ron Norman This file is part of GnuCOBOL. @@ -22,6 +22,8 @@ #ifndef COB_LOCAL_H #define COB_LOCAL_H +#pragma once + /* We use this file to define/prototype things that should not be exported to user space */ @@ -575,7 +577,7 @@ COB_HIDDEN char *cob_int_to_formatted_bytestring (int, char*); COB_HIDDEN char *cob_strcat (char*, char*, int); COB_HIDDEN char *cob_strjoin (char**, int, char*); -COB_HIDDEN void cob_runtime_warning_ss (const char *, const char *); +COB_HIDDEN int cob_runtime_warning_ss (const char *, const char *); DECLNORET COB_HIDDEN void cob_hard_failure (void) COB_A_NORETURN; diff --git a/libcob/common.c b/libcob/common.c index 7ecf0c926..00c5d9a40 100644 --- a/libcob/common.c +++ b/libcob/common.c @@ -29,14 +29,10 @@ #endif #endif -#include <stdio.h> #include <stdlib.h> #include <stddef.h> #include <stdarg.h> #include <string.h> -#ifdef HAVE_STRINGS_H -#include <strings.h> -#endif #include <ctype.h> #include <sys/types.h> #include <sys/stat.h> @@ -277,7 +273,7 @@ const int MAX_MODULE_ITERS = 10240; struct cob_alloc_module { struct cob_alloc_module *next; /* Pointer to next */ - void *cob_pointer; /* Pointer to malloced space */ + cob_module *cob_mod_ptr; /* Pointer to malloced module space */ }; /* EXTERNAL structure */ @@ -785,7 +781,7 @@ cob_exit_common_modules (void) - currently used for: decimals - and remove it from the internal module list */ for (ptr = cob_module_list; ptr; ptr = nxt) { - mod = ptr->cob_pointer; + mod = ptr->cob_mod_ptr; nxt = ptr->next; if (mod && mod->module_cancel.funcint) { mod->module_active = 0; @@ -804,7 +800,6 @@ ss_terminate_routines (void) return; } cob_exit_fileio_msg_only (); - cob_exit_screen_from_signal(1); if (COB_MODULE_PTR && abort_reason[0] != 0) { if (cobsetptr->cob_stacktrace) { @@ -828,7 +823,7 @@ cob_terminate_routines (void) } fflush (stderr); - cob_prof_end(); + cob_prof_end (); cob_exit_fileio_msg_only (); if (COB_MODULE_PTR && abort_reason[0] != 0) { @@ -1024,52 +1019,59 @@ set_source_location (const char **file, unsigned int *line) } } -/* write integer to stderr using fixed buffer */ -#define write_to_stderr_or_return_int(i) \ - if (write (STDERR_FILENO, ss_itoa_buf, ss_itoa_u10 (i)) == -1) return -/* write char array (constant C string) to stderr */ -#define write_to_stderr_or_return_arr(ch_arr) \ - if (write (STDERR_FILENO, ch_arr, sizeof (ch_arr) - 1) == -1) return -/* write string to stderr, byte count computed with strlen, - str is evaluated twice */ -#define write_to_stderr_or_return_str(str) \ - if (write (STDERR_FILENO, str, strlen (str)) == -1) return +/* writes data to fd, returns either the initial size or -1 in case of error */ +static COB_INLINE cob_s64_t +write_until_fail (int fd, const char *data, size_t size) +{ + register cob_s64_t size_to_write = size; + while (size_to_write > 0) { + long bytes_written = write (fd, data, (size_t)size_to_write); + if (bytes_written == -1) { + return 1; + } + data += bytes_written; + size_to_write -= bytes_written; -/* write integer to fileno using fixed buffer */ -#define write_or_return_int(fileno,i) \ - if (write (fileno, ss_itoa_buf, ss_itoa_u10 (i)) == -1) return -/* write char array (constant C string) to fileno */ -#define write_or_return_arr(fileno, ch_arr) \ - if (write (fileno, ch_arr, sizeof (ch_arr) - 1) == -1) return -/* write string to fileno, byte count computed with strlen, - str is evaluated twice */ -#define write_or_return_str(fileno,str) \ - if (write (fileno, str, strlen (str)) == -1) return + } + return size; +} -#if 0 /* unused */ -/* write buffer with given byte count to stderr */ -#define write_to_stderr_or_return_buf(buff,count) \ - if (write (STDERR_FILENO, buff, count) == -1) return -/* write buffer with given byte count to fileno */ -#define write_or_return_buf(fileno,buff,count) \ - if (write (fileno, buff, count) == -1) return -#endif +static COB_INLINE COB_A_INLINE size_t +strcat_to_buff (char *buff, const char *str) +{ + const size_t len = strlen (str); + memcpy (buff, str, len); + return len; +} -static void -output_source_location (void) +static COB_INLINE COB_A_INLINE size_t +intcat_to_buff (char *buff, const int num) +{ + ss_itoa_u10 (num); + return strcat_to_buff (buff, ss_itoa_buf); +} + +/* stores source location into buff, returns size written (without trailing NUL) */ +static size_t +get_source_location (char *buff) { const char *source_file; unsigned int source_line; + size_t pos = 0; + set_source_location (&source_file, &source_line); if (source_file) { - write_to_stderr_or_return_str (source_file); + pos += strcat_to_buff (buff, source_file); if (source_line) { - write_to_stderr_or_return_arr (":"); - write_to_stderr_or_return_int ((int)source_line); + buff[pos++] = ':'; + pos += intcat_to_buff (buff + pos, source_line); } - write_to_stderr_or_return_arr (": "); + buff[pos++] = ':'; + buff[pos++] = ' '; } + buff[pos] = 0; + return pos; } static int @@ -1114,10 +1116,11 @@ create_dumpfile (void) static void cob_sig_handler (int sig) { + char buff [COB_MEDIUM_BUFF]; + char signal_text[COB_MINI_BUFF]; const char *signal_name; const char *msg; - char signal_text[COB_MINI_BUFF] = { 0 }; - size_t str_len; + size_t pos = 0; #if defined (HAVE_SIGACTION) && !defined (SA_RESETHAND) struct sigaction sa; @@ -1135,21 +1138,48 @@ cob_sig_handler (int sig) sig_is_handled = 1; #endif -#if 0 /* We do not generally flush whatever we may have in our streams - as stdio is not signal-safe; - we _may_ do this if not SIGSEGV/SIGBUS/SIGABRT */ - fflush (stdout); - fflush (stderr); + + /* We do not generally flush whatever we may have in our streams + as stdio is not signal-safe; + we _may_ do this if not SIGSEGV/SIGBUS/SIGABRT (but as we don't know + if all of those are defined we only flush on a positive list)*/ + switch (sig) { + case -1: +#ifdef SIGPIPE + case SIGPIPE: +#endif +#ifdef SIGTERM + case SIGTERM: +#endif +#ifdef SIGINT + case SIGINT: +#endif +#ifdef SIGHUP + case SIGHUP: +#endif + fflush (stderr); + fflush (stdout); + break; + default: + break; + } + +#ifdef SIGPIPE + /* early exit for non-active COBOL runtime */ + if (sig == SIGPIPE + && !cob_initialized) { + goto exit_handler; + } #endif signal_name = cob_get_sig_name (sig); /* LCOV_EXCL_START */ if (signal_name == signals[NUM_SIGNALS].shortname) { /* not translated as it is a very unlikely error case */ + pos += strcat_to_buff (buff + pos, "\n" "cob_sig_handler caught not handled signal: "); + pos += intcat_to_buff (buff + pos, sig); + buff[pos++] = '\n'; signal_name = signals[NUM_SIGNALS].description; /* translated unknown */ - write_to_stderr_or_return_arr ("\ncob_sig_handler caught not handled signal: "); - write_to_stderr_or_return_int (sig); - write_to_stderr_or_return_arr ("\n"); } /* LCOV_EXCL_STOP */ @@ -1184,34 +1214,44 @@ cob_sig_handler (int sig) #else (void)signal (sig, SIG_DFL); #endif - cob_exit_screen (); + cob_exit_screen_from_signal (1); - write_to_stderr_or_return_arr ("\n"); - cob_get_source_line (); - output_source_location (); + buff[pos++] = '\n'; + /* buffer: "prog.cob:1: " */ + pos += get_source_location (buff + pos); + /* buffer: "signal desc" */ msg = cob_get_sig_description (sig); - write_to_stderr_or_return_str (msg); + pos += strcat_to_buff (buff + pos, msg); + /* setup "signal %s" (for output and abort reason) */ + { + + const size_t str_len = strlen (signal_msgid); + memcpy (signal_text, signal_msgid, str_len); + signal_text[str_len] = ' '; + strcpy (signal_text + str_len + 1, signal_name); + } + /* buffer: " (signal %s)" */ + buff[pos++] = ' '; + buff[pos++] = '('; + pos += strcat_to_buff (buff + pos, signal_text); + buff[pos++] = ')'; - /* setup "signal %s" */ - str_len = strlen (signal_msgid); - memcpy (signal_text, signal_msgid, str_len++); - signal_text[str_len] = ' '; - memcpy (signal_text + str_len, signal_name, strlen (signal_name)); + buff[pos++] = '\n'; + buff[pos++] = '\n'; - write_to_stderr_or_return_arr (" ("); - write_to_stderr_or_return_str (signal_text); - write_to_stderr_or_return_arr (")\n\n"); if (cob_initialized) { if (abort_reason[0] == 0) { memcpy (abort_reason, signal_text, COB_MINI_BUFF); #if 0 /* Is there a use in this message ?*/ - write_to_stderr_or_return_str (abnormal_termination_msgid); - write_to_stderr_or_return_arr ("\n"); + pos += strcat_to_buff (buff + pos, abnormal_termination_msgid); + buff[pos++] = '\n'; #endif } } + buff[pos] = 0; + write_until_fail (STDERR_FILENO, buff, pos); /* early coredump if requested would be nice, but that is not signal-safe so do SIGABRT later... */ @@ -1239,6 +1279,7 @@ cob_sig_handler (int sig) break; } +exit_handler: /* call external signal handler if registered */ if (cob_ext_sighdl != NULL) { (*cob_ext_sighdl) (sig); @@ -3247,7 +3288,7 @@ cob_module_global_enter (cob_module **module, cob_global **mglobal, *module = cob_cache_malloc (sizeof (cob_module)); /* Add to list of all modules activated */ mod_ptr = cob_malloc (sizeof (struct cob_alloc_module)); - mod_ptr->cob_pointer = *module; + mod_ptr->cob_mod_ptr = *module; mod_ptr->next = cob_module_list; cob_module_list = mod_ptr; #if 0 /* cob_call_name_hash and cob_call_from_c are rw-branch only features @@ -3329,7 +3370,7 @@ cob_module_free (cob_module **module) prv = NULL; /* Remove from list of all modules activated */ for (ptr = cob_module_list; ptr; ptr = ptr->next) { - if (ptr->cob_pointer == *module) { + if (ptr->cob_mod_ptr == *module) { if (prv == NULL) { cob_module_list = ptr->next; } else { @@ -3341,7 +3382,8 @@ cob_module_free (cob_module **module) prv = ptr; } -#if 0 /* cob_module->param_buf and cob_module->param_field are rw-branch only features +#if 0 /* cob_module->param_buf and cob_module->param_field are + trunk (previously rw-branch) only features for now - TODO: activate on merge of r1547 */ && !cobglobptr->cob_call_from_c if ((*module)->param_buf != NULL) @@ -3845,6 +3887,7 @@ cob_reg_sighnd (void (*sighnd) (int)) { if (!cob_initialized) { cob_set_signal (); + cob_init_sig_descriptions (); } cob_ext_sighdl = sighnd; } @@ -8653,8 +8696,8 @@ cob_load_config_file (const char *config_file, int isoptional) size = strlen (buff); if (size != 0 && buff[size] == SLASH_CHAR) buff[--size] = 0; if (size != 0) { - snprintf (filename, (size_t)COB_FILE_MAX, "%s%c%s", buff, SLASH_CHAR, - config_file); + snprintf (filename, (size_t)COB_FILE_MAX, "%s%c%s", + buff, SLASH_CHAR, config_file); if (access (filename, F_OK) == 0) { /* and prefixed file exist */ config_file = filename; /* Prefix last directory */ } else { @@ -8664,15 +8707,17 @@ cob_load_config_file (const char *config_file, int isoptional) } if (filename[0] == 0) { /* check for COB_CONFIG_DIR (use default if not in environment) */ + int size; penv = getenv ("COB_CONFIG_DIR"); if (penv != NULL) { - snprintf (filename, (size_t)COB_FILE_MAX, "%s%c%s", + size = snprintf (filename, (size_t)COB_FILE_MAX, "%s%c%s", penv, SLASH_CHAR, config_file); } else { - snprintf (filename, (size_t)COB_FILE_MAX, "%s%c%s", + size = snprintf (filename, (size_t)COB_FILE_MAX, "%s%c%s", COB_CONFIG_DIR, SLASH_CHAR, config_file); } - if (access (filename, F_OK) == 0) { /* and prefixed file exist */ + if (size > 0 && size < COB_FILE_MAX + && access (filename, F_OK) == 0) { /* and prefixed file exist */ config_file = filename; /* Prefix COB_CONFIG_DIR */ } } @@ -8835,18 +8880,18 @@ cob_runtime_warning_external (const char *caller_name, const int cob_reference, if (!cobsetptr->cob_display_warn) { return; } - if (!(caller_name && *caller_name)) caller_name = "unknown caller"; /* Prefix */ + fprintf (stderr, "libcob: "); if (cob_reference) { - fflush (stderr); /* necessary as we write afterwards */ - write_to_stderr_or_return_arr ("libcob: "); + char buff[COB_MINI_BUFF]; cob_get_source_line (); - output_source_location (); - } else { - fprintf (stderr, "libcob: "); - } + get_source_location (buff); + fprintf (stderr, "%s", buff); + } fprintf (stderr, _("warning: ")); + + if (!(caller_name && *caller_name)) caller_name = "unknown caller"; fprintf (stderr, "%s: ", caller_name); /* Body */ @@ -8859,26 +8904,34 @@ cob_runtime_warning_external (const char *caller_name, const int cob_reference, fflush (stderr); } -void +/* output non-buffered (signal-async-safe) runtime warning, + returning 1 if write to stderr was not sucessfull */ +int cob_runtime_warning_ss (const char *msg, const char *addition) { - if (cobsetptr && !cobsetptr->cob_display_warn) { - return; - } + if (!cobsetptr + || cobsetptr->cob_display_warn) { + char buff[COB_MEDIUM_BUFF]; + size_t pos = 0; - /* Prefix */ - write_to_stderr_or_return_arr ("libcob: "); - output_source_location (); - write_to_stderr_or_return_str (warning_msgid); + /* Prefix */ + pos += strcat_to_buff (buff, "libcob: "); + pos += get_source_location (buff + pos); + pos += strcat_to_buff (buff + pos, warning_msgid); - /* Body */ - write_to_stderr_or_return_str (msg); - if (addition) { - write_to_stderr_or_return_str (addition); - } + /* Body */ + pos += strcat_to_buff (buff + pos, msg); + if (addition) { + pos += strcat_to_buff (buff + pos, addition); + } - /* Postfix */ - write_to_stderr_or_return_arr ("\n"); + /* Postfix */ + buff[pos++] = '\n'; + buff[pos] = 0; + + return (write_until_fail (STDERR_FILENO, buff, pos) == -1); + } + return 0; } void @@ -8890,14 +8943,16 @@ cob_runtime_warning (const char *fmt, ...) return; } - fflush (stderr); /* necessary as we write afterwards */ /* Prefix */ - write_to_stderr_or_return_arr ("libcob: "); - cob_get_source_line (); - output_source_location (); - - fprintf (stderr, _("warning: ")); /* back to stdio */ + fprintf (stderr, "libcob: "); + { + char buff[COB_MINI_BUFF]; + cob_get_source_line (); + get_source_location (buff); + fprintf (stderr, "%s", buff); + } + fprintf (stderr, _("warning: ")); /* Body */ va_start (args, fmt); @@ -9684,14 +9739,17 @@ print_version (void) set_cob_build_stamp (cob_build_stamp); - printf ("libcob (%s) %s.%d\n", - PACKAGE_NAME, PACKAGE_VERSION, PATCH_LEVEL); - puts ("Copyright (C) 2023 Free Software Foundation, Inc."); - printf (_("License LGPLv3+: GNU LGPL version 3 or later <%s>"), "https://gnu.org/licenses/lgpl.html"); + printf ("libcob %s%s.%d\n", + PKGVERSION, PACKAGE_VERSION, PATCH_LEVEL); + puts ("Copyright (C) 2024 Free Software Foundation, Inc."); + printf (_("License LGPLv3+: GNU LGPL version 3 or later <%s>"), + "https://gnu.org/licenses/lgpl.html"); putchar ('\n'); puts (_("This is free software; see the source for copying conditions. There is NO\n" "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.")); - printf (_("Written by %s"), "Keisuke Nishida, Roger While, Ron Norman, Simon Sobisch, Edward Hart"); + putchar ('\n'); + printf (_("Written by %s"), "Keisuke Nishida, Roger While, " + "Ron Norman, Simon Sobisch, Edward Hart"); putchar ('\n'); /* TRANSLATORS: This msgid is intended as the "Packaged" msgid, %s expands to date and time */ @@ -9769,7 +9827,7 @@ print_info_detailed (const int verbose) var_print ("64bit-mode", _("no"), "", 0); #endif -#ifdef COB_LI_IS_LL +#ifndef COB_32_BIT_LONG var_print ("BINARY-C-LONG", _("8 bytes"), "", 0); #else var_print ("BINARY-C-LONG", _("4 bytes"), "", 0); @@ -10182,9 +10240,9 @@ void cob_set_main_argv0 (const int argc, char **argv) int i; #ifdef _WIN32 - s = cob_malloc ((size_t)COB_LARGE_BUFF); - i = GetModuleFileNameA (NULL, s, COB_LARGE_MAX); - if (i > 0 && i < COB_LARGE_BUFF) { + s = cob_malloc ((size_t)COB_MEDIUM_BUFF); + i = GetModuleFileNameA (NULL, s, COB_MEDIUM_MAX); + if (i > 0 && i < COB_MEDIUM_BUFF) { cobglobptr->cob_main_argv0 = cob_strdup (s); cob_free (s); return; @@ -10202,9 +10260,9 @@ void cob_set_main_argv0 (const int argc, char **argv) path = NULL; } if (path) { - s = cob_malloc ((size_t)COB_LARGE_BUFF); - i = (int)readlink (path, s, (size_t)COB_LARGE_MAX); - if (i > 0 && i < COB_LARGE_BUFF) { + s = cob_malloc ((size_t)COB_MEDIUM_BUFF); + i = (int)readlink (path, s, (size_t)COB_MEDIUM_MAX); + if (i > 0 && i < COB_MEDIUM_BUFF) { s[i] = 0; cobglobptr->cob_main_argv0 = cob_strdup (s); cob_free (s); @@ -10218,7 +10276,7 @@ void cob_set_main_argv0 (const int argc, char **argv) path = getexecname (); if (path) { #ifdef HAVE_REALPATH - s = cob_malloc ((size_t)COB_LARGE_BUFF); + s = cob_malloc ((size_t)COB_MEDIUM_BUFF); if (realpath (path, s) != NULL) { cobglobptr->cob_main_argv0 = cob_strdup (s); } else { @@ -10557,37 +10615,45 @@ cob_backtrace (void *target, int count) dump_trace_started ^= DUMP_TRACE_ACTIVE_TRACE; } -/* internal output the procedure stack entry to the given target */ -static void -output_procedure_stack_entry (const int file_no, +/* internal output the procedure stack entry to the given buffer, + returns the written length */ +static size_t +output_procedure_stack_entry (char *buff, const char *section, const char *paragraph, const char *source_file, const unsigned int source_line) { + size_t pos = 0; if (!section && !paragraph) { - return; + return 0; } - write_or_return_arr (file_no, "\n\t"); + + buff[pos++] = '\n'; + buff[pos++] = '\t'; if (section && paragraph) { - write_or_return_str (file_no, paragraph); - write_or_return_arr (file_no, " OF "); - write_or_return_str (file_no, section); + pos += strcat_to_buff (buff + pos, paragraph); + pos += strcat_to_buff (buff + pos, " OF "); + pos += strcat_to_buff (buff + pos, section); } else { if (section) { - write_or_return_str (file_no, section); + pos += strcat_to_buff (buff + pos, section); } else { - write_or_return_str (file_no, paragraph); + pos += strcat_to_buff (buff + pos, paragraph); } } - write_or_return_arr (file_no, " at "); - write_or_return_str (file_no, source_file); - write_or_return_arr (file_no, ":"); - write_or_return_int (file_no, (int)source_line); + pos += strcat_to_buff (buff + pos, " at "); + pos += strcat_to_buff (buff + pos, source_file); + buff[pos++] = ':'; + pos += intcat_to_buff (buff + pos, (int)source_line); + buff[pos] = '0'; + return pos; } /* internal output the COBOL-view of the stacktrace to the given target */ void cob_stack_trace_internal (FILE *target, int verbose, int count) { + char buff[COB_MEDIUM_BUFF]; + size_t pos = 0; cob_module *mod; int first_entry = 0; int i, k; @@ -10620,7 +10686,7 @@ cob_stack_trace_internal (FILE *target, int verbose, int count) } if (verbose) { - write_or_return_arr (file_no, "\n"); + buff[pos++] = '\n'; } k = 0; for (mod = COB_MODULE_PTR, i = 0; mod; mod = mod->next, i++) { @@ -10630,64 +10696,71 @@ cob_stack_trace_internal (FILE *target, int verbose, int count) if (count > 0 && count == i) { break; } - write_or_return_arr (file_no, " "); + buff[pos++] = ' '; if (mod->module_stmt != 0 && mod->module_sources) { const unsigned int source_file_num = COB_GET_FILE_NUM (mod->module_stmt); const unsigned int source_line = COB_GET_LINE_NUM (mod->module_stmt); const char *source_file = mod->module_sources[source_file_num]; if (!verbose) { - write_or_return_str (file_no, mod->module_name); - write_or_return_arr (file_no, " at "); - write_or_return_str (file_no, source_file); - write_or_return_arr (file_no, ":"); - write_or_return_int (file_no, (int)source_line); + pos += strcat_to_buff (buff + pos, mod->module_name); + pos += strcat_to_buff (buff + pos, " at "); + pos += strcat_to_buff (buff + pos, source_file); + buff[pos++] = ':'; + pos += intcat_to_buff (buff + pos, (int)source_line); } else if (mod->statement == STMT_UNKNOWN && !mod->section_name && !mod->paragraph_name) { /* GC 3.1 output, now used for "no source location / no trace" case */ - write_or_return_arr (file_no, "Last statement of "); + pos += strcat_to_buff (buff + pos, "Last statement of "); if (mod->module_type == COB_MODULE_TYPE_FUNCTION) { - write_or_return_arr (file_no, "FUNCTION "); + pos += strcat_to_buff (buff + pos, "FUNCTION "); } - write_or_return_arr (file_no, "\""); - write_or_return_str (file_no, mod->module_name); - write_or_return_arr (file_no, "\" was at line "); - write_or_return_int (file_no, (int)source_line); - write_or_return_arr (file_no, " of "); - write_or_return_str (file_no, source_file); + buff[pos++] = '"'; + pos += strcat_to_buff (buff + pos, mod->module_name); + pos += strcat_to_buff (buff + pos, "\" was at line "); + pos += intcat_to_buff (buff + pos, (int)source_line); + pos += strcat_to_buff (buff + pos, " of "); + pos += strcat_to_buff (buff + pos, source_file); } else if (!mod->section_name && !mod->paragraph_name) { /* special case: there _would_ be data, but there's no procedure defined in the program */ - write_or_return_arr (file_no, "Last statement of "); + pos += strcat_to_buff (buff + pos, "Last statement of "); if (mod->module_type == COB_MODULE_TYPE_FUNCTION) { - write_or_return_arr (file_no, "FUNCTION "); + pos += strcat_to_buff (buff + pos, "FUNCTION "); } - write_or_return_arr (file_no, "\""); - write_or_return_str (file_no, mod->module_name); - write_or_return_arr (file_no, "\" was "); - write_or_return_str (file_no, cob_statement_name[mod->statement]); - write_or_return_arr (file_no, " at line "); - write_or_return_int (file_no, (int)source_line); - write_or_return_arr (file_no, " of "); - write_or_return_str (file_no, source_file); + buff[pos++] = '"'; + pos += strcat_to_buff (buff + pos, mod->module_name); + pos += strcat_to_buff (buff + pos, "\" was "); + pos += strcat_to_buff (buff + pos, cob_statement_name[mod->statement]); + pos += strcat_to_buff (buff + pos, " at line "); + pos += intcat_to_buff (buff + pos, (int)source_line); + pos += strcat_to_buff (buff + pos, " of "); + pos += strcat_to_buff (buff + pos, source_file); } else { /* common case when compiled with runtime checks enabled: statement and procedure known - the later is printed from the stack entry with the source location by the following call */ - write_or_return_arr (file_no, "Last statement of "); + pos += strcat_to_buff (buff + pos, "Last statement of "); if (mod->module_type == COB_MODULE_TYPE_FUNCTION) { - write_or_return_arr (file_no, "FUNCTION "); + pos += strcat_to_buff (buff + pos, "FUNCTION "); } - write_or_return_arr (file_no, "\""); - write_or_return_str (file_no, mod->module_name); - write_or_return_arr (file_no, "\" was "); - write_or_return_str (file_no, cob_statement_name[mod->statement]); + buff[pos++] = '"'; + pos += strcat_to_buff (buff + pos, mod->module_name); + pos += strcat_to_buff (buff + pos, "\" was "); + pos += strcat_to_buff (buff + pos, cob_statement_name[mod->statement]); } - output_procedure_stack_entry (file_no, mod->section_name, mod->paragraph_name, + pos += output_procedure_stack_entry (buff + pos, + mod->section_name, mod->paragraph_name, source_file, source_line); + if (pos > COB_MEDIUM_MAX - COB_FILE_MAX) { + if (write_until_fail (file_no, buff, pos) == -1) { + return; + } + pos = 0; + } if (mod->frame_ptr) { struct cob_frame_ext *perform_ptr = mod->frame_ptr; int frame_max = 512; /* max from -fstack-size */ @@ -10698,71 +10771,92 @@ cob_stack_trace_internal (FILE *target, int verbose, int count) if (perform_ptr->section_name) { /* marker for "root frame" - at ENTRY */ if (perform_ptr->section_name[0] == 0) { - write_or_return_arr (file_no, "\n\tENTRY "); - write_or_return_str (file_no, perform_ptr->paragraph_name); - write_or_return_arr (file_no, " at "); - write_or_return_str (file_no, ffile); - write_or_return_arr (file_no, ":"); - write_or_return_int (file_no, (int)fline); + pos += strcat_to_buff (buff + pos, "\n\t" "ENTRY "); + pos += strcat_to_buff (buff + pos, perform_ptr->paragraph_name); + pos += strcat_to_buff (buff + pos, " at "); + pos += strcat_to_buff (buff + pos, ffile); + buff[pos++] = ':'; + pos += intcat_to_buff (buff + pos, (int)fline); break; } } - output_procedure_stack_entry (file_no, + pos += output_procedure_stack_entry (buff + pos, perform_ptr->section_name, perform_ptr->paragraph_name, ffile, fline); + if (pos > COB_MEDIUM_MAX - COB_FILE_MAX) { + if (write_until_fail (file_no, buff, pos) == -1) { + return; + } + pos = 0; + } perform_ptr--; } } } else { if (verbose) { - write_or_return_arr (file_no, "Last statement of "); + pos += strcat_to_buff (buff + pos, "Last statement of "); if (mod->module_type == COB_MODULE_TYPE_FUNCTION) { - write_or_return_arr (file_no, "FUNCTION "); + pos += strcat_to_buff (buff + pos, "FUNCTION "); } - write_or_return_arr (file_no, "\""); - write_or_return_str (file_no, mod->module_name); + buff[pos++] = '"'; + pos += strcat_to_buff (buff + pos, mod->module_name); if (mod->statement != STMT_UNKNOWN) { - write_or_return_arr (file_no, "\" was "); - write_or_return_str (file_no, cob_statement_name[mod->statement]); + pos += strcat_to_buff (buff + pos, "\" was "); + pos += strcat_to_buff (buff + pos, cob_statement_name[mod->statement]); } else { - write_or_return_arr (file_no, "\" unknown"); + pos += strcat_to_buff (buff + pos, "\" unknown"); } } else { - write_or_return_str (file_no, mod->module_name); - write_or_return_arr (file_no, " at unknown"); + pos += strcat_to_buff (buff + pos, mod->module_name); + pos += strcat_to_buff (buff + pos, " at unknown"); } } - write_or_return_arr (file_no, "\n"); + buff[pos++] = '\n'; if (mod->next == mod) { /* not translated as highly unexpected */ - write_or_return_arr (file_no, "FIXME: recursive mod (stack trace)\n"); + pos += strcat_to_buff (buff + pos, + "FIXME: recursive mod (stack trace)" "\n"); break; } if (k++ == MAX_MODULE_ITERS) { /* not translated as highly unexpected */ - write_or_return_arr (file_no, - "max module iterations exceeded, possible broken chain\n"); + pos += strcat_to_buff (buff + pos, + "max module iterations exceeded, possible broken chain" "\n"); break; } } if (mod) { - write_or_return_arr (file_no, " "); - write_or_return_str (file_no, more_stack_frames_msgid); - write_or_return_arr (file_no, "\n"); + buff[pos++] = ' '; + pos += strcat_to_buff (buff + pos, more_stack_frames_msgid); + buff[pos++] = '\n'; + } + if (pos > COB_MEDIUM_MAX - COB_FILE_MAX) { + if (write_until_fail (file_no, buff, pos) == -1) { + return; + } + pos = 0; } if (verbose && cob_argc != 0) { - size_t ia; - write_or_return_arr (file_no, " Started by "); - write_or_return_str (file_no, cob_argv[0]); - write_or_return_arr (file_no, "\n"); - for (ia = 1; ia < (size_t)cob_argc; ++ia) { - write_or_return_arr (file_no, "\t"); - write_or_return_str (file_no, cob_argv[ia]); - write_or_return_arr (file_no, "\n"); + const unsigned int ia_max = (unsigned int)cob_argc; + unsigned int ia; + pos += strcat_to_buff (buff + pos, " Started by "); + pos += strcat_to_buff (buff + pos, cob_argv[0]); + buff[pos++] = '\n'; + for (ia = 1; ia < ia_max; ++ia) { + buff[pos++] = '\t'; + pos += strcat_to_buff (buff + pos, cob_argv[ia]); + buff[pos++] = '\n'; + if (pos > COB_MEDIUM_MAX - COB_FILE_MAX) { + if (write_until_fail (file_no, buff, pos) == -1) { + return; + } + pos = 0; + } } } + write_until_fail (file_no, buff, pos); } FILE * @@ -10873,6 +10967,7 @@ cob_dump_module (char *reason) fputc ('\n', fp); fprintf (fp, _("Module dump due to %s"), reason); fputc ('\n', fp); + fflush (fp); } if (fp != stdout) { /* was already sent to stderr before this function was called, @@ -10883,7 +10978,6 @@ cob_dump_module (char *reason) dump_trace_started ^= DUMP_TRACE_ACTIVE_TRACE; } } - fflush (stdout); } else { fflush (stderr); } @@ -11221,7 +11315,8 @@ init_statement_list (void) } #endif -void cob_cleanup_thread () +void +cob_cleanup_thread (void) { cob_exit_strings (); } diff --git a/libcob/common.h b/libcob/common.h index cbdbadff6..c268eed79 100644 --- a/libcob/common.h +++ b/libcob/common.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2012, 2014-2023 Free Software Foundation, Inc. + Copyright (C) 2002-2012, 2014-2024 Free Software Foundation, Inc. Written by Keisuke Nishida, Roger While, Simon Sobisch, Ron Norman, Edward Hart @@ -22,6 +22,8 @@ #ifndef COB_COMMON_H #define COB_COMMON_H +#pragma once + #include <stddef.h> /* for size_t */ /* Only define cob_decimal if we have the necessary mpz_t from gmp.h/mpir.h @@ -1682,7 +1684,7 @@ COB_EXPIMP void cob_runtime_hint (const char *, ...) COB_A_FORMAT12; COB_EXPIMP void cob_runtime_error (const char *, ...) COB_A_FORMAT12; COB_EXPIMP void cob_runtime_warning (const char *, ...) COB_A_FORMAT12; -COB_EXPIMP void cob_cleanup_thread (); +COB_EXPIMP void cob_cleanup_thread (void); /* General functions */ diff --git a/libcob/fileio.c b/libcob/fileio.c index e3d8a51b0..509623452 100644 --- a/libcob/fileio.c +++ b/libcob/fileio.c @@ -1824,12 +1824,17 @@ cob_fd_file_open (cob_file *f, char *filename, HANDLE osHandle = (HANDLE)_get_osfhandle (fd); if (osHandle != INVALID_HANDLE_VALUE) { DWORD flags = LOCKFILE_FAIL_IMMEDIATELY; - OVERLAPPED fromStart = {0}; + OVERLAPPED fromStart = { 0 }; if (mode != COB_OPEN_INPUT) flags |= LOCKFILE_EXCLUSIVE_LOCK; if (!LockFileEx (osHandle, flags, 0, MAXDWORD, MAXDWORD, &fromStart)) { - f->open_mode = COB_OPEN_CLOSED; - close (fd); - return COB_STATUS_61_FILE_SHARING; + DWORD err = GetLastError (); + /* normally that return value would not happen, we use it to + work around call errors happening on MSYS */ + if (err != ERROR_INVALID_FUNCTION) { + f->open_mode = COB_OPEN_CLOSED; + close (fd); + return COB_STATUS_61_FILE_SHARING; + } } } } @@ -2087,10 +2092,15 @@ cob_file_open (cob_file *f, char *filename, OVERLAPPED fromStart = {0}; if (mode != COB_OPEN_INPUT) flags |= LOCKFILE_EXCLUSIVE_LOCK; if (!LockFileEx (osHandle, flags, 0, MAXDWORD, MAXDWORD, &fromStart)) { - f->open_mode = COB_OPEN_CLOSED; - f->fd = -1; - fclose (fp); - return COB_STATUS_61_FILE_SHARING; + DWORD err = GetLastError (); + /* normally that return value would not happen, we use it to + work around call errors happening on MSYS */ + if (err != ERROR_INVALID_FUNCTION) { + f->open_mode = COB_OPEN_CLOSED; + fclose (fp); + f->fd = -1; + return COB_STATUS_61_FILE_SHARING; + } } } } @@ -7074,7 +7084,7 @@ cob_savekey (cob_file *f, int idx, unsigned char *data) /* System routines */ /* stores the field's rtrimmed string content into a fresh allocated - string, which later needs to be passed to cob_free */ + string, which later needs to be passed to cob_free */ static void * cob_str_from_fld (const cob_field *f) { @@ -7104,7 +7114,7 @@ cob_str_from_fld (const cob_field *f) } while (data <= end) { -#if 0 /* Quotes in file */ +#if 0 /* Quotes in file, per MF, stopping at first space outside */ if (*data == '"') { quote_switch = !quote_switch; data++; @@ -8758,7 +8768,6 @@ cob_get_filename_print (cob_file* file, const int show_resolved_name) cobsetpr-values with type ENV_PATH or ENV_STR like bdb_home and cob_file_path are taken care in cob_exit_common()! */ - const char *implicit_close_of_msgid = NULL; void @@ -8767,7 +8776,8 @@ cob_exit_fileio_msg_only (void) struct file_list *l; static int output_done = 0; - if (output_done) { + if (output_done + || (cobsetptr && !cobsetptr->cob_display_warn)) { return; } output_done = 1; @@ -8778,8 +8788,10 @@ cob_exit_fileio_msg_only (void) && l->file->open_mode != COB_OPEN_LOCKED && !l->file->flag_nonexistent && !COB_FILE_SPECIAL (l->file)) { - cob_runtime_warning_ss (implicit_close_of_msgid, - cob_get_filename_print (l->file, 0)); + if (cob_runtime_warning_ss (implicit_close_of_msgid, + cob_get_filename_print (l->file, 0))) { + return; + } } } } diff --git a/libcob/intrinsic.c b/libcob/intrinsic.c index 785fa3b1b..727f7f6f6 100644 --- a/libcob/intrinsic.c +++ b/libcob/intrinsic.c @@ -716,6 +716,7 @@ int cob_check_numval_f (const cob_field *srcfield) { unsigned char *p = srcfield->data; + const unsigned int fsize = (unsigned int)srcfield->size; size_t plus_minus; size_t digits; size_t decimal_seen; @@ -724,10 +725,10 @@ cob_check_numval_f (const cob_field *srcfield) size_t break_needed; size_t exponent; size_t e_plus_minus; - int n; + unsigned int n; const unsigned char dec_pt = COB_MODULE_PTR->decimal_point; - if (!srcfield->size) { + if (!fsize) { return 1; } @@ -743,7 +744,7 @@ cob_check_numval_f (const cob_field *srcfield) e_plus_minus = 0; /* Check leading positions */ - for (n = 0; n < (int)srcfield->size; ++n, ++p) { + for (n = 0; n < fsize; ++n, ++p) { switch (*p) { case '0': case '1': @@ -781,11 +782,11 @@ cob_check_numval_f (const cob_field *srcfield) } } - if (n == (int)srcfield->size) { + if (n == fsize) { return n + 1; } - for (; n < (int)srcfield->size; ++n, ++p) { + for (; n < fsize; ++n, ++p) { switch (*p) { case '0': case '1': @@ -1445,7 +1446,7 @@ calculate_start_end_for_numval (cob_field *srcfield, unsigned char **pp, unsigned char **pp_end) { unsigned char *p = srcfield->data; - unsigned char *p_end; + register unsigned char *p_end; if (srcfield->size == 0 || p == NULL) { @@ -1479,7 +1480,7 @@ enum numval_type { static cob_field * numval (cob_field *srcfield, cob_field *currency, const enum numval_type type) { - unsigned char *final_buff = NULL; + unsigned char final_buff [COB_MAX_DIGITS + 1] = { 0 }; unsigned char *p, *p_end; unsigned char *currency_data = NULL; size_t datasize; @@ -1511,14 +1512,19 @@ numval (cob_field *srcfield, cob_field *currency, const enum numval_type type) cob_alloc_set_field_uint (0); return curr_field; } - /* not wasting buffer space (COBOL2022: 35/34 max)... */ + /* not wasting buffer space (COBOL2023: 35/34 max)... */ if (datasize > COB_MAX_DIGITS) { +#ifdef INVALID_NUMVAL_IS_ZERO + cob_set_exception (COB_EC_ARGUMENT_FUNCTION); + cob_alloc_set_field_uint (0); + return curr_field; +#else + /* Should this truncate or raise an exception? + What about COBOL2025 new max? */ datasize = COB_MAX_DIGITS; +#endif } - /* acquire temp buffer long enugh */ - final_buff = cob_malloc (datasize + 1U); - sign = 0; digits = 0; decimal_digits = 0; @@ -1648,8 +1654,6 @@ numval (cob_field *srcfield, cob_field *currency, const enum numval_type type) } } - cob_free (final_buff); - if (exception) { cob_set_exception (COB_EC_ARGUMENT_FUNCTION); } diff --git a/libcob/numeric.c b/libcob/numeric.c index fe1425429..bd76526bc 100644 --- a/libcob/numeric.c +++ b/libcob/numeric.c @@ -372,7 +372,7 @@ cob_decimal_clear (cob_decimal *d) void cob_decimal_set_ullint (cob_decimal *d, const cob_u64_t n) { -#ifdef COB_LI_IS_LL +#ifndef COB_32_BIT_LONG mpz_set_ui (d->value, (cob_uli_t)n); #else mpz_set_ui (d->value, (cob_uli_t)(n >> 32)); @@ -386,7 +386,7 @@ cob_decimal_set_ullint (cob_decimal *d, const cob_u64_t n) void cob_decimal_set_llint (cob_decimal *d, const cob_s64_t n) { -#ifdef COB_LI_IS_LL +#ifndef COB_32_BIT_LONG mpz_set_si (d->value, (cob_sli_t)n); #else cob_u64_t uval; @@ -455,7 +455,7 @@ cob_decimal_print (cob_decimal *d, FILE *fp) } #define MAX_LLI_DIGITS_PLUS_1 20 -#ifdef COB_LI_IS_LL +#ifndef COB_32_BIT_LONG #define MAX_LI_DIGITS_PLUS_1 20 #else #define MAX_LI_DIGITS_PLUS_1 10 @@ -497,7 +497,7 @@ const cob_uli_t cob_pow_10_uli_val[MAX_LI_DIGITS_PLUS_1] = { , 10000000 , 100000000 , 1000000000UL -#ifdef COB_LI_IS_LL +#ifndef COB_32_BIT_LONG , 10000000000 , 100000000000 , 1000000000000 @@ -701,7 +701,7 @@ cob_decimal_set_ieee64dec (cob_decimal *d, const cob_field *f) d->scale = 0; return; } -#ifdef COB_LI_IS_LL +#ifndef COB_32_BIT_LONG mpz_set_ui (d->value, data); #else mpz_set_ui (d->value, (cob_uli_t)(data >> 32)); @@ -810,7 +810,7 @@ cob_decimal_set_ieee128dec (cob_decimal *d, const cob_field *f) d->scale = 0; return; } -#ifdef COB_LI_IS_LL +#ifndef COB_32_BIT_LONG mpz_set_ui (d->value, COB_128_MSW(data)); mpz_mul_2exp (d->value, d->value, 64UL); mpz_add_ui (d->value, d->value, COB_128_LSW(data)); @@ -1187,7 +1187,7 @@ cob_decimal_set_packed (cob_decimal *d, cob_field *f) val = val * 10 + (*p >> 4); } -#ifdef COB_LI_IS_LL +#ifndef COB_32_BIT_LONG mpz_set_ui (d->value, (cob_uli_t)val); #else cob_decimal_set_ullint (d, val); @@ -1676,7 +1676,7 @@ cob_decimal_set_binary (cob_decimal *d, cob_field *f) } #endif -#elif defined(COB_LI_IS_LL) +#elif !defined (COB_32_BIT_LONG) if (COB_FIELD_HAVE_SIGN (f)) { mpz_set_si (d->value, cob_binary_get_sint64 (f)); } else { @@ -1779,7 +1779,7 @@ cob_decimal_get_binary (cob_decimal *d, cob_field *f, const int opt) } } } -#ifdef COB_LI_IS_LL +#ifndef COB_32_BIT_LONG if (!field_sign || (overflow && !(opt & COB_STORE_TRUNC_ON_OVERFLOW))) { cob_binary_set_uint64 (f, mpz_get_ui (d->value)); } else { @@ -3707,7 +3707,7 @@ cob_cmp_llint (cob_field *f1, const cob_s64_t n) } else { if (n >= 0) return -1; } -#ifdef COB_LI_IS_LL +#ifndef COB_32_BIT_LONG mpz_set_si (cob_d2.value, (cob_sli_t)n); #else { diff --git a/libcob/screenio.c b/libcob/screenio.c index 17a3c9df0..e0512cc19 100644 --- a/libcob/screenio.c +++ b/libcob/screenio.c @@ -161,6 +161,7 @@ static int accept_cursor_y; static int accept_cursor_x; static int pending_accept; static int got_sys_char; +static WINDOW *mywin; #ifdef HAVE_MOUSEMASK static unsigned int curr_setting_mouse_flags = UINT_MAX; #endif @@ -324,7 +325,7 @@ raise_ec_on_invalid_line_or_col (const int line, const int column) int max_y; int max_x; - getmaxyx (stdscr, max_y, max_x); + getmaxyx (mywin, max_y, max_x); if (line < 0 || line >= max_y) { cob_set_exception (COB_EC_SCREEN_LINE_NUMBER); } @@ -336,7 +337,7 @@ raise_ec_on_invalid_line_or_col (const int line, const int column) static int cob_move_cursor (const int line, const int column) { - int status = move (line, column); + int status = wmove (mywin, line, column); if (status == ERR) { raise_ec_on_invalid_line_or_col (line, column); @@ -348,7 +349,7 @@ void cob_set_cursor_pos (int line, int column) { init_cob_screen_if_needed (); - (void) move (line, column); + (void) wmove (mywin, line, column); } #if 0 /* currently unused */ @@ -358,9 +359,9 @@ cob_move_to_beg_of_last_line (void) int max_y; int max_x; - getmaxyx (stdscr, max_y, max_x); + getmaxyx (mywin, max_y, max_x); /* We don't need to check for exceptions here; it will always be fine */ - move (max_y, 0); + wmove (mywin, max_y, 0); COB_UNUSED (max_x); } @@ -413,11 +414,11 @@ cob_activate_color_pair (const short color_pair_number) int ret; #ifdef HAVE_COLOR_SET - ret = color_set (color_pair_number, NULL); + ret = wcolor_set (mywin, color_pair_number, NULL); #else - ret = attrset (COLOR_PAIR(color_pair_number)); + ret = wattrset (mywin, COLOR_PAIR(color_pair_number)); #endif - bkgdset (COLOR_PAIR(color_pair_number)); + wbkgdset (mywin, COLOR_PAIR(color_pair_number)); return ret; } @@ -842,7 +843,7 @@ adjust_attr_from_control_field (cob_flags_t *attr, cob_field *control, continue; } - /* normal attribute - apply and go on*/ + /* normal attribute - apply and go on */ if (control_attr->cobflag != 0) { if (no_indicator == 0) { *attr |= control_attr->cobflag; @@ -956,9 +957,9 @@ cob_screen_attr (cob_field *fgc, cob_field *bgc, cob_flags_t attr, #endif /* apply attributes */ - attrset (A_NORMAL); + wattrset (mywin, A_NORMAL); if (styles != A_NORMAL) { - attron (styles); + wattron (mywin, styles); } /* apply colors */ @@ -975,24 +976,24 @@ cob_screen_attr (cob_field *fgc, cob_field *bgc, cob_flags_t attr, } /* BLANK SCREEN colors the whole screen. */ if (attr & COB_SCREEN_BLANK_SCREEN) { - getyx (stdscr, line, column); - clear (); + getyx (mywin, line, column); + wclear (mywin); cob_move_cursor (line, column); } if (stmt == DISPLAY_STATEMENT) { /* BLANK LINE colors the whole line. */ if (attr & COB_SCREEN_BLANK_LINE) { - getyx (stdscr, line, column); + getyx (mywin, line, column); cob_move_cursor (line, 0); - clrtoeol (); + wclrtoeol (mywin); cob_move_cursor (line, column); } if (attr & COB_SCREEN_ERASE_EOL) { - clrtoeol (); + wclrtoeol (mywin); } if (attr & COB_SCREEN_ERASE_EOS) { - clrtobot (); + wclrtobot (mywin); } } if (attr & COB_SCREEN_BELL) { @@ -1054,6 +1055,14 @@ cob_screen_init (void) cob_runtime_error (_("failed to initialize curses")); return 1; } + + /* set mywin pointer to mywin pointer for future + implementation of panels functionality + Note that stdscr WINDOW pointer can not + be altered as the keyboard and mouse + still require this pointer */ + mywin = stdscr; + cobglobptr->cob_screen_initialized = 1; #ifdef HAVE_USE_LEGACY_CODING use_legacy_coding (2); @@ -1069,7 +1078,7 @@ cob_screen_init (void) #endif cbreak (); - keypad (stdscr, 1); + keypad (mywin, 1); nonl (); noecho (); if (has_colors ()) { @@ -1114,8 +1123,8 @@ cob_screen_init (void) #endif } } - attrset (A_NORMAL); - getmaxyx (stdscr, COB_MAX_Y_COORD, COB_MAX_X_COORD); + wattrset (mywin, A_NORMAL); + getmaxyx (mywin, COB_MAX_Y_COORD, COB_MAX_X_COORD); cob_settings_screenio (); @@ -1317,7 +1326,7 @@ pass_cursor_to_program (void) cob_field *cursor_field = COB_MODULE_PTR->cursor_pos; int sline; int scolumn; - getyx (stdscr, sline, scolumn); + getyx (mywin, sline, scolumn); sline++; scolumn++; /* zero-based in curses */ if (COB_FIELD_IS_NUMERIC (cursor_field) && COB_FIELD_TYPE (cursor_field) != COB_TYPE_NUMERIC_DISPLAY) { @@ -1415,8 +1424,8 @@ raise_ec_on_truncation (const int item_size) int max_y; int max_x; - getyx (stdscr, y, x); - getmaxyx (stdscr, max_y, max_x); + getyx (mywin, y, x); + getmaxyx (mywin, max_y, max_x); if (x + item_size - 1 > max_x) { cob_set_exception (COB_EC_SCREEN_ITEM_TRUNCATED); @@ -1430,7 +1439,7 @@ static void cob_addnstr (const char *data, const int size) { raise_ec_on_truncation (size); - addnstr (data, size); + waddnstr (mywin, data, size); } /* variant of cob_addnstr that outputs each character separately, @@ -1446,182 +1455,182 @@ cob_addnstr_graph (const char *data, const int size) switch (c) { case 'j': /* lower-right corner */ #if defined (WITH_WIDE_FUNCTIONS) - add_wch (WACS_LRCORNER); + wadd_wch (mywin, WACS_LRCORNER); #else - addch (ACS_LRCORNER); + waddch (mywin, ACS_LRCORNER); #endif break; case 'J': /* lower-right corner, double */ #if defined (WACS_D_LRCORNER) && defined (WITH_WIDE_FUNCTIONS) - add_wch (WACS_D_LRCORNER); + wadd_wch (mywin, WACS_D_LRCORNER); #elif defined (ACS_D_LRCORNER) - addch (ACS_D_LRCORNER); + waddch (mywin, ACS_D_LRCORNER); #else - addch ((const chtype)'+'); + waddch (mywin, (const chtype)'+'); #endif break; case 'k': /* upper-right corner */ #if defined (WITH_WIDE_FUNCTIONS) - add_wch (WACS_URCORNER); + wadd_wch (mywin, WACS_URCORNER); #else - addch (ACS_URCORNER); + waddch (mywin, ACS_URCORNER); #endif break; case 'K': /* upper-right corner, double */ #if defined (WACS_D_URCORNER) && defined (WITH_WIDE_FUNCTIONS) - add_wch (WACS_D_URCORNER); + wadd_wch (mywin, WACS_D_URCORNER); #elif defined (ACS_D_URCORNER) - addch (ACS_D_URCORNER); + waddch (mywin, ACS_D_URCORNER); #else - addch ((const chtype)'+'); + waddch (mywin, (const chtype)'+'); #endif break; case 'm': /* lower-left corner */ #if defined (WITH_WIDE_FUNCTIONS) - add_wch (WACS_LLCORNER); + wadd_wch (mywin, WACS_LLCORNER); #else - addch (ACS_LLCORNER); + waddch (mywin, ACS_LLCORNER); #endif break; case 'M': /* lower-left corner, double */ #if defined (WACS_D_LLCORNER) && defined (WITH_WIDE_FUNCTIONS) - add_wch (WACS_D_LLCORNER); + wadd_wch (mywin, WACS_D_LLCORNER); #elif defined (ACS_D_LLCORNER) - addch (ACS_D_LLCORNER); + waddch (mywin, ACS_D_LLCORNER); #else - addch ((const chtype)'+'); + waddch (mywin, (const chtype)'+'); #endif break; case 'l': /* upper-left corner */ #if defined (WITH_WIDE_FUNCTIONS) - add_wch (WACS_ULCORNER); + wadd_wch (mywin, WACS_ULCORNER); #else - addch (ACS_ULCORNER); + waddch (mywin, ACS_ULCORNER); #endif break; case 'L': /* upper-left corner, double */ #if defined (WACS_D_ULCORNER) && defined (WITH_WIDE_FUNCTIONS) - add_wch (WACS_D_ULCORNER); + wadd_wch (mywin, WACS_D_ULCORNER); #elif defined (ACS_D_ULCORNER) - addch (ACS_D_ULCORNER); + waddch (mywin, ACS_D_ULCORNER); #else - addch ((const chtype)'+'); + waddch (mywin, (const chtype)'+'); #endif break; case 'n': /* plus */ #if defined (WITH_WIDE_FUNCTIONS) - add_wch (WACS_PLUS); + wadd_wch (mywin, WACS_PLUS); #else - addch (ACS_PLUS); + waddch (mywin, ACS_PLUS); #endif break; case 'N': /* plus, double */ #if defined (WACS_D_PLUS) && defined (WITH_WIDE_FUNCTIONS) - add_wch (WACS_D_PLUS); + wadd_wch (mywin, WACS_D_PLUS); #elif defined (ACS_D_PLUS) - addch (ACS_D_PLUS); + waddch (mywin, ACS_D_PLUS); #else - addch ((const chtype)'+'); + waddch (mywin, (const chtype)'+'); #endif break; case 'q': /* horizontal line */ #if defined (WITH_WIDE_FUNCTIONS) - add_wch (WACS_HLINE); + wadd_wch (mywin, WACS_HLINE); #else - addch (ACS_HLINE); + waddch (mywin, ACS_HLINE); #endif break; case 'Q': /* horizontal line, double */ #if defined (WACS_D_HLINE) && defined (WITH_WIDE_FUNCTIONS) - add_wch (WACS_D_HLINE); + wadd_wch (mywin, WACS_D_HLINE); #elif defined (ACS_D_HLINE) - addch (ACS_D_HLINE); + waddch (mywin, ACS_D_HLINE); #else - addch ((const chtype)'-'); + waddch (mywin, (const chtype)'-'); #endif break; case 'x': /* vertical line */ #if defined (WITH_WIDE_FUNCTIONS) - add_wch (WACS_VLINE); + wadd_wch (mywin, WACS_VLINE); #else - addch (ACS_VLINE); + waddch (mywin, ACS_VLINE); #endif break; case 'X': /* vertical line, double */ #if defined (WACS_D_VLINE) && defined (WITH_WIDE_FUNCTIONS) - add_wch (WACS_D_VLINE); + wadd_wch (mywin, WACS_D_VLINE); #elif defined (ACS_D_VLINE) - addch (ACS_D_VLINE); + waddch (mywin, ACS_D_VLINE); #else - addch ((const chtype)'|'); + waddch (mywin, (const chtype)'|'); #endif break; case 't': /* left tee */ #if defined (WITH_WIDE_FUNCTIONS) - add_wch (WACS_LTEE); + wadd_wch (mywin, WACS_LTEE); #else - addch (ACS_LTEE); + waddch (mywin, ACS_LTEE); #endif break; case 'T': /* left tee , double */ #if defined (WACS_D_LTEE) && defined (WITH_WIDE_FUNCTIONS) - add_wch (WACS_D_LTEE); + wadd_wch (mywin, WACS_D_LTEE); #elif defined (ACS_D_LTEE) - addch (ACS_D_LTEE); + waddch (mywin, ACS_D_LTEE); #else - addch ((const chtype)'+'); + waddch (mywin, (const chtype)'+'); #endif break; case 'u': /* right tee */ #if defined (WITH_WIDE_FUNCTIONS) - add_wch (WACS_RTEE); + wadd_wch (mywin, WACS_RTEE); #else - addch (ACS_RTEE); + waddch (mywin, ACS_RTEE); #endif break; case 'U': /* right tee , double */ #if defined (WACS_D_RTEE) && defined (WITH_WIDE_FUNCTIONS) - add_wch (WACS_D_RTEE); + wadd_wch (mywin, WACS_D_RTEE); #elif defined (ACS_D_RTEE) - addch (ACS_D_RTEE); + waddch (mywin, ACS_D_RTEE); #else - addch ((const chtype)'+'); + waddch (mywin, (const chtype)'+'); #endif break; case 'v': /* bottom tee */ #if defined (WITH_WIDE_FUNCTIONS) - add_wch (WACS_BTEE); + wadd_wch (mywin, WACS_BTEE); #else - addch (ACS_BTEE); + waddch (mywin, ACS_BTEE); #endif break; case 'V': /* bottom tee , double */ #if defined (WACS_D_BTEE) && defined (WITH_WIDE_FUNCTIONS) - add_wch (WACS_D_BTEE); + wadd_wch (mywin, WACS_D_BTEE); #elif defined (ACS_D_BTEE) - addch (ACS_D_BTEE); + waddch (mywin, ACS_D_BTEE); #else - addch ((const chtype)'+'); + waddch (mywin, (const chtype)'+'); #endif break; case 'w': /* top tee */ #if defined (WITH_WIDE_FUNCTIONS) - add_wch (WACS_TTEE); + wadd_wch (mywin, WACS_TTEE); #else - addch (ACS_TTEE); + waddch (mywin, ACS_TTEE); #endif break; case 'W': /* top tee , double */ #if defined (WACS_D_TTEE) && defined (WITH_WIDE_FUNCTIONS) - add_wch (WACS_D_TTEE); + wadd_wch (mywin, WACS_D_TTEE); #elif defined (ACS_D_TTEE) - addch (ACS_D_TTEE); + waddch (mywin, ACS_D_TTEE); #else - addch ((const chtype)'+'); + waddch (mywin, (const chtype)'+'); #endif break; default: - addch ((const chtype)c); + waddch (mywin, (const chtype)c); } } } @@ -1630,14 +1639,14 @@ static void cob_addch (const chtype c) { raise_ec_on_truncation (1); - addch (c); + waddch (mywin, c); } /* Use only when raise_ec_on_truncation is called beforehand. */ static void cob_addch_no_trunc_check (const chtype c) { - addch (c); + waddch (mywin, c); } static void @@ -1838,7 +1847,7 @@ cob_screen_puts (cob_screen *s, cob_field *f, const cob_u32_t is_input, accept_cursor_x = column + f->size; } - refresh (); + wrefresh (mywin); } static COB_INLINE COB_A_INLINE int @@ -2025,7 +2034,7 @@ refresh_field (cob_screen *s) int y; int x; - getyx (stdscr, y, x); + getyx (mywin, y, x); cob_screen_puts (s, s->field, cobsetptr->cob_legacy, ACCEPT_STATEMENT); cob_move_cursor (y, x); } @@ -2411,7 +2420,7 @@ cob_screen_get_all (const int initial_curs, const int accept_timeout) int cursor_clause_line; int cursor_clause_col; get_cursor_from_program (&cursor_clause_line, &cursor_clause_col); - if (cursor_clause_line > 0) { + if (cursor_clause_line >= 0) { int fld_index = find_field_by_pos (initial_curs, cursor_clause_line, cursor_clause_col); if (fld_index >= 0) { curr_index = fld_index; @@ -2438,9 +2447,9 @@ cob_screen_get_all (const int initial_curs, const int accept_timeout) default_prompt_char = COB_CH_UL; } - refresh (); + wrefresh (mywin); errno = 0; - timeout (accept_timeout); + wtimeout (mywin, accept_timeout); keyp = getch (); /* FIXME: modularize (cob_screen_get_all, field_accept) and @@ -2476,7 +2485,7 @@ cob_screen_get_all (const int initial_curs, const int accept_timeout) continue; } - getyx (stdscr, cline, ccolumn); + getyx (mywin, cline, ccolumn); switch (keyp) { case KEY_ENTER: @@ -2899,7 +2908,7 @@ cob_screen_get_all (const int initial_curs, const int accept_timeout) cob_beep (); } screen_return: - refresh (); + wrefresh (mywin); } static int @@ -2936,7 +2945,7 @@ cob_screen_moveyx (cob_screen *s) if (s->line || s->column || s->attr & (COB_SCREEN_LINE_PLUS | COB_SCREEN_LINE_MINUS | COB_SCREEN_COLUMN_PLUS | COB_SCREEN_COLUMN_MINUS)) { - getyx (stdscr, y, x); + getyx (mywin, y, x); if (x < 0 || y < 0) { /* not translated as "testing only" (should not happen) */ cob_runtime_warning ("negative values from getyx"); @@ -2974,7 +2983,7 @@ cob_screen_moveyx (cob_screen *s) } cob_move_cursor (line, column); - refresh (); + wrefresh (mywin); cob_current_y = line; cob_current_x = column; } @@ -3178,7 +3187,7 @@ screen_display (cob_screen *s, const int line, const int column) pending_accept = 1; } cob_screen_iterate (s); - refresh (); + wrefresh (mywin); } static int @@ -3291,10 +3300,10 @@ field_display (cob_field *f, cob_flags_t fattr, const int line, const int column cob_field *fgc, cob_field *bgc, cob_field *fscroll, cob_field *size_is, cob_field *control, cob_field *color) { - int sline; - int scolumn; - int size_display, fsize; - int status; + int sline; + int scolumn; + int size_display, fsize; + int status; char fig_const; /* figurative constant character */ /* LCOV_EXCL_START */ @@ -3324,10 +3333,10 @@ field_display (cob_field *f, cob_flags_t fattr, const int line, const int column if (fattr & COB_SCREEN_SCROLL_DOWN) { sline = -sline; } - scrollok (stdscr, 1); - scrl (sline); - scrollok (stdscr, 0); - refresh (); + scrollok (mywin, 1); + wscrl (mywin, sline); + scrollok (mywin, 0); + wrefresh (mywin); } sline = line; @@ -3375,7 +3384,7 @@ field_display (cob_field *f, cob_flags_t fattr, const int line, const int column } cob_move_cursor (sline, 0); } - refresh (); + wrefresh (mywin); } static void @@ -3436,10 +3445,10 @@ field_accept (cob_field *f, cob_flags_t fattr, const int sline, const int scolum if (fattr & COB_SCREEN_SCROLL_DOWN) { keyp = -keyp; } - scrollok (stdscr, 1); - scrl (keyp); - scrollok (stdscr, 0); - refresh (); + scrollok (mywin, 1); + wscrl (mywin, keyp); + scrollok (mywin, 0); + wrefresh (mywin); } cobglobptr->cob_exception_code = 0; @@ -3494,7 +3503,7 @@ field_accept (cob_field *f, cob_flags_t fattr, const int sline, const int scolum } } /* SIZE IS greater than field, blank out trailing screen */ - if (size_accept > (int)f->size) { + if (size_accept > f->size) { cob_addnch (size_accept - f->size, COB_CH_SP); } /* start position within the field, if specified (all 1-based) */ @@ -3520,11 +3529,11 @@ field_accept (cob_field *f, cob_flags_t fattr, const int sline, const int scolum if (cursor_clause_line == sline && cursor_clause_col > scolumn - && cursor_clause_col < scolumn + disp_size) { + && cursor_clause_col < scolumn + (int)disp_size) { cursor_off = cursor_clause_col - scolumn + 1; } } - move (sline, scolumn + cursor_off - 1); + wmove (mywin, sline, scolumn + cursor_off - 1); } } #if 0 /* RXWRXW - Screen update */ @@ -3549,14 +3558,14 @@ field_accept (cob_field *f, cob_flags_t fattr, const int sline, const int scolum } count = 0; - timeout (get_accept_timeout (ftimeout)); + wtimeout (mywin, get_accept_timeout (ftimeout)); /* Get characters from keyboard, processing each one. */ for (; ;) { /* Show prompt characters. */ if (f) { /* Get current line, column. */ - getyx (stdscr, cline, ccolumn); + getyx (mywin, cline, ccolumn); /* Trailing prompts. */ if (fattr & COB_SCREEN_NO_ECHO) { prompt_char = COB_CH_SP; @@ -3607,7 +3616,7 @@ field_accept (cob_field *f, cob_flags_t fattr, const int sline, const int scolum /* Cursor to current column. */ cob_move_cursor (cline, ccolumn); /* Refresh screen. */ - refresh (); + wrefresh (mywin); } errno = 0; @@ -3723,6 +3732,10 @@ field_accept (cob_field *f, cob_flags_t fattr, const int sline, const int scolum { int mline = mevent.y; int mcolumn = mevent.x; + if (!wmouse_trafo (mywin, &mline, &mcolumn, 0)) { + cob_beep (); + continue; + } mevent.bstate &= cob_mask_accept; if (mevent.bstate != 0) { fret = mouse_to_exception_code (mevent.bstate); @@ -3950,6 +3963,10 @@ field_accept (cob_field *f, cob_flags_t fattr, const int sline, const int scolum { int mline = mevent.y; int mcolumn = mevent.x; + if (!wmouse_trafo (mywin, &mline, &mcolumn, 0)) { + cob_beep (); + continue; + } /* handle depending on state */ if (mevent.bstate & BUTTON1_PRESSED && COB_MOUSE_FLAGS & 1) { @@ -4080,7 +4097,7 @@ field_accept (cob_field *f, cob_flags_t fattr, const int sline, const int scolum if (cursor) { /* horizontal position stored in CURSOR clause */ if (!COB_FIELD_CONSTANT (cursor)) { - getyx (stdscr, cline, ccolumn); + getyx (mywin, cline, ccolumn); if (cline == sline) { cob_set_int (cursor, ccolumn + 1 - scolumn); } @@ -4097,7 +4114,7 @@ field_accept (cob_field *f, cob_flags_t fattr, const int sline, const int scolum memset (COB_TERM_BUFF, ' ', size_accept); #endif } - refresh (); + wrefresh (mywin); } static void @@ -4109,7 +4126,7 @@ field_accept_from_curpos (cob_field *f, cob_field *fgc, size_t ccolumn; /* Get current line, column. */ - getyx (stdscr, cline, ccolumn); + getyx (mywin, cline, ccolumn); /* accept field */ field_accept (f, (cob_flags_t)fattr, cline, ccolumn, fgc, bgc, @@ -4125,7 +4142,7 @@ field_display_at_curpos (cob_field *f, size_t ccolumn; /* Get current line, column. */ - getyx (stdscr, cline, ccolumn); + getyx (mywin, cline, ccolumn); field_display (f, (cob_flags_t)fattr, cline, ccolumn, fgc, bgc, fscroll, size_is, NULL, NULL); @@ -4360,8 +4377,8 @@ cob_sys_clear_screen (void) { init_cob_screen_if_needed (); - clear (); - refresh (); + wclear (mywin); + wrefresh (mywin); cob_current_y = 0; cob_current_x = 0; return 0; @@ -4377,14 +4394,14 @@ cob_screen_set_mode (const cob_u32_t smode) if (!smode) { if (cobglobptr->cob_screen_initialized) { - refresh (); + wrefresh (mywin); def_prog_mode (); endwin (); } } else { if (cobglobptr->cob_screen_initialized) { reset_prog_mode (); - refresh (); + wrefresh (mywin); } else { cob_screen_init (); } @@ -4522,11 +4539,11 @@ cob_exit_screen (void) } cobglobptr->cob_screen_initialized = 0; #if 0 /* CHECKME: Shouldn't be necessary */ - clear (); + wclear (mywin); cob_move_to_beg_of_last_line (); #endif endwin (); /* ends curses' terminal mode */ - delwin (stdscr); /* free storage related to screen not active */ + delwin (mywin); /* free storage related to screen not active */ #ifdef HAVE_CURSES_FREEALL /* cleanup storage that would otherwise be shown to be "still reachable" with valgrind */ @@ -4558,6 +4575,8 @@ cob_exit_screen_from_signal (int ss_only) #if (!defined (NCURSES_VERSION_MAJOR) || NCURSES_VERSION_MAJOR < 6) \ && (!defined (PDC_BUILD) || PDC_BUILD < 4305) if (ss_only) return; +#else + COB_UNUSED (ss_only); #endif if (cobglobptr->cob_screen_initialized) { @@ -4767,7 +4786,7 @@ cob_sys_get_csr_pos (unsigned char *fld) init_cob_screen_if_needed (); #ifdef WITH_EXTENDED_SCREENIO - getyx (stdscr, cline, ccol); + getyx (mywin, cline, ccol); if (f && f->size == 4) { /* group with sizes up to 64k (2 * 2 bytes) as used by Fujitsu (likely with a limit of @@ -4864,7 +4883,7 @@ cob_sys_set_csr_pos (unsigned char *fld) cline = fld[0]; ccol= fld[1]; } - return move (cline, ccol); + return wmove (mywin, cline, ccol); #else COB_UNUSED (fld); return 0; @@ -4916,9 +4935,9 @@ cob_sys_set_scr_size (unsigned char *line, unsigned char *col) #endif } - /* save the current stdscr screen to a file */ +/* save the current mywin screen to a file */ int -cob_sys_scr_dump(unsigned char *parm) +cob_sys_scr_dump (unsigned char *parm) { #ifdef WITH_EXTENDED_SCREENIO int result; @@ -4928,24 +4947,25 @@ cob_sys_scr_dump(unsigned char *parm) COB_CHK_PARMS (CBL_GC_SCR_DUMP, 1); init_cob_screen_if_needed (); - if (filename && (filep = fopen(filename, "wb")) != NULL) - { - refresh(); - result = putwin(stdscr, filep); - fclose(filep); + if (filename && (filep = fopen (filename, "wb")) != NULL) { + refresh (); + result = putwin (mywin, filep); + fclose (filep); return result; } + COB_UNUSED (parm); return ERR; #else + COB_UNUSED (parm); return -1; #endif } - /* restore the current stdscr screen from a file */ -int cob_sys_scr_restore(unsigned char *parm) +/* restore the current mywin screen from a file */ +int cob_sys_scr_restore (unsigned char *parm) { #ifdef WITH_EXTENDED_SCREENIO int result; @@ -4955,22 +4975,22 @@ int cob_sys_scr_restore(unsigned char *parm) COB_CHK_PARMS (CBL_GC_SCR_RESTORE, 1); init_cob_screen_if_needed (); - if (filename && (filep = fopen(filename, "rb")) != NULL) - { - WINDOW *replacement = getwin(filep); - fclose(filep); + if (filename && (filep = fopen (filename, "rb")) != NULL) { + WINDOW *replacement = getwin (filep); + fclose (filep); - if (replacement) - { - result = overwrite(replacement, stdscr); - refresh(); - delwin(replacement); + if (replacement) { + result = overwrite (replacement, mywin); + refresh (); + delwin (replacement); return result; } } + COB_UNUSED (parm); return ERR; #else + COB_UNUSED (parm); return -1; #endif diff --git a/m4/libtool.m4 b/m4/libtool.m4 index b6a7da5a8..e5ddacee9 100644 --- a/m4/libtool.m4 +++ b/m4/libtool.m4 @@ -1,6 +1,7 @@ # libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- # -# Copyright (C) 1996-2001, 2003-2019 Free Software Foundation, Inc. +# Copyright (C) 1996-2001, 2003-2019, 2021-2024 Free Software +# Foundation, Inc. # Written by Gordon Matzigkeit, 1996 # # This file is free software; the Free Software Foundation gives @@ -8,13 +9,13 @@ # modifications, as long as this notice is preserved. m4_define([_LT_COPYING], [dnl -# Copyright (C) 2014 Free Software Foundation, Inc. +# Copyright (C) 2024 Free Software Foundation, Inc. # This is free software; see the source for copying conditions. There is NO # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # GNU Libtool 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 of of the License, or +# the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # As a special exception to the GNU General Public License, if you @@ -28,10 +29,10 @@ m4_define([_LT_COPYING], [dnl # 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 <https://www.gnu.org/licenses/>. +# along with this program. If not, see <http://www.gnu.org/licenses/>. ]) -# serial 58 LT_INIT +# serial 62 LT_INIT # LT_PREREQ(VERSION) @@ -59,7 +60,7 @@ esac # LT_INIT([OPTIONS]) # ------------------ AC_DEFUN([LT_INIT], -[AC_PREREQ([2.62])dnl We use AC_PATH_PROGS_FEATURE_CHECK +[AC_PREREQ([2.64])dnl We use AC_PATH_PROGS_FEATURE_CHECK AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl AC_BEFORE([$0], [LT_LANG])dnl AC_BEFORE([$0], [LT_OUTPUT])dnl @@ -181,6 +182,7 @@ m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_CHECK_SHELL_FEATURES])dnl m4_require([_LT_PATH_CONVERSION_FUNCTIONS])dnl m4_require([_LT_CMD_RELOAD])dnl +m4_require([_LT_DECL_FILECMD])dnl m4_require([_LT_CHECK_MAGIC_METHOD])dnl m4_require([_LT_CHECK_SHAREDLIB_FROM_LINKLIB])dnl m4_require([_LT_CMD_OLD_ARCHIVE])dnl @@ -614,7 +616,7 @@ m4_popdef([AS_MESSAGE_LOG_FD])])])# _LT_GENERATED_FILE_INIT # LT_OUTPUT # --------- # This macro allows early generation of the libtool script (before -# AC_OUTPUT is called), incase it is used in configure for compilation +# AC_OUTPUT is called), in case it is used in configure for compilation # tests. AC_DEFUN([LT_OUTPUT], [: ${CONFIG_LT=./config.lt} @@ -649,9 +651,9 @@ m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION]) configured by $[0], generated by m4_PACKAGE_STRING. -Copyright (C) 2011 Free Software Foundation, Inc. +Copyright (C) 2024 Free Software Foundation, Inc. This config.lt script is free software; the Free Software Foundation -gives unlimited permision to copy, distribute and modify it." +gives unlimited permission to copy, distribute and modify it." while test 0 != $[#] do @@ -728,7 +730,6 @@ _LT_CONFIG_SAVE_COMMANDS([ cat <<_LT_EOF >> "$cfgfile" #! $SHELL # Generated automatically by $as_me ($PACKAGE) $VERSION -# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: # NOTE: Changes made to this file will be lost: look at ltmain.sh. # Provide generalized library-building support services. @@ -778,7 +779,7 @@ _LT_EOF # if finds mixed CR/LF and LF-only lines. Since sed operates in # text mode, it properly converts lines to CR/LF. This bash problem # is reportedly fixed, but why not run on old versions too? - sed '$q' "$ltmain" >> "$cfgfile" \ + $SED '$q' "$ltmain" >> "$cfgfile" \ || (rm -f "$cfgfile"; exit 1) mv -f "$cfgfile" "$ofile" || @@ -973,6 +974,7 @@ _lt_linker_boilerplate=`cat conftest.err` $RM -r conftest* ])# _LT_LINKER_BOILERPLATE + # _LT_REQUIRED_DARWIN_CHECKS # ------------------------- m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[ @@ -1023,6 +1025,21 @@ m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[ rm -f conftest.* fi]) + # Feature test to disable chained fixups since it is not + # compatible with '-undefined dynamic_lookup' + AC_CACHE_CHECK([for -no_fixup_chains linker flag], + [lt_cv_support_no_fixup_chains], + [ save_LDFLAGS=$LDFLAGS + LDFLAGS="$LDFLAGS -Wl,-no_fixup_chains" + AC_LINK_IFELSE( + [AC_LANG_PROGRAM([],[])], + lt_cv_support_no_fixup_chains=yes, + lt_cv_support_no_fixup_chains=no + ) + LDFLAGS=$save_LDFLAGS + ] + ) + AC_CACHE_CHECK([for -exported_symbols_list linker flag], [lt_cv_ld_exported_symbols_list], [lt_cv_ld_exported_symbols_list=no @@ -1047,7 +1064,7 @@ _LT_EOF echo "$RANLIB libconftest.a" >&AS_MESSAGE_LOG_FD $RANLIB libconftest.a 2>&AS_MESSAGE_LOG_FD cat > conftest.c << _LT_EOF -int main() { return 0;} +int main(void) { return 0;} _LT_EOF echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err @@ -1067,17 +1084,16 @@ _LT_EOF _lt_dar_allow_undefined='$wl-undefined ${wl}suppress' ;; darwin1.*) _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; - darwin*) # darwin 5.x on - # if running on 10.5 or later, the deployment target defaults - # to the OS version, if on x86, and 10.4, the deployment - # target defaults to 10.4. Don't you love it? - case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in - 10.0,*86*-darwin8*|10.0,*-darwin[[912]]*) - _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; - 10.[[012]][[,.]]*) - _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; - 10.*|11.*) - _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; + darwin*) + case $MACOSX_DEPLOYMENT_TARGET,$host in + 10.[[012]],*|,*powerpc*-darwin[[5-8]]*) + _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; + *) + _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' + if test yes = "$lt_cv_support_no_fixup_chains"; then + AS_VAR_APPEND([_lt_dar_allow_undefined], [' $wl-no_fixup_chains']) + fi + ;; esac ;; esac @@ -1126,12 +1142,12 @@ m4_defun([_LT_DARWIN_LINKER_FEATURES], output_verbose_link_cmd=func_echo_all _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dsymutil" _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dsymutil" - _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil" - _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil" + _LT_TAGVAR(archive_expsym_cmds, $1)="$SED 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil" + _LT_TAGVAR(module_expsym_cmds, $1)="$SED -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil" m4_if([$1], [CXX], [ if test yes != "$lt_cv_apple_cc_single_mod"; then _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dsymutil" - _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dar_export_syms$_lt_dsymutil" + _LT_TAGVAR(archive_expsym_cmds, $1)="$SED 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dar_export_syms$_lt_dsymutil" fi ],[]) else @@ -1245,7 +1261,8 @@ _LT_DECL([], [ECHO], [1], [An echo program that protects backslashes]) # _LT_WITH_SYSROOT # ---------------- AC_DEFUN([_LT_WITH_SYSROOT], -[AC_MSG_CHECKING([for sysroot]) +[m4_require([_LT_DECL_SED])dnl +AC_MSG_CHECKING([for sysroot]) AC_ARG_WITH([sysroot], [AS_HELP_STRING([--with-sysroot@<:@=DIR@:>@], [Search for dependent libraries within DIR (or the compiler's sysroot @@ -1258,11 +1275,13 @@ lt_sysroot= case $with_sysroot in #( yes) if test yes = "$GCC"; then - lt_sysroot=`$CC --print-sysroot 2>/dev/null` + # Trim trailing / since we'll always append absolute paths and we want + # to avoid //, if only for less confusing output for the user. + lt_sysroot=`$CC --print-sysroot 2>/dev/null | $SED 's:/\+$::'` fi ;; #( /*) - lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` + lt_sysroot=`echo "$with_sysroot" | $SED -e "$sed_quote_subst"` ;; #( no|'') ;; #( @@ -1292,7 +1311,7 @@ ia64-*-hpux*) # options accordingly. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then - case `/usr/bin/file conftest.$ac_objext` in + case `$FILECMD conftest.$ac_objext` in *ELF-32*) HPUX_IA64_MODE=32 ;; @@ -1309,7 +1328,7 @@ ia64-*-hpux*) echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then if test yes = "$lt_cv_prog_gnu_ld"; then - case `/usr/bin/file conftest.$ac_objext` in + case `$FILECMD conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -melf32bsmip" ;; @@ -1321,7 +1340,7 @@ ia64-*-hpux*) ;; esac else - case `/usr/bin/file conftest.$ac_objext` in + case `$FILECMD conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -32" ;; @@ -1343,7 +1362,7 @@ mips64*-*linux*) echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then emul=elf - case `/usr/bin/file conftest.$ac_objext` in + case `$FILECMD conftest.$ac_objext` in *32-bit*) emul="${emul}32" ;; @@ -1351,7 +1370,7 @@ mips64*-*linux*) emul="${emul}64" ;; esac - case `/usr/bin/file conftest.$ac_objext` in + case `$FILECMD conftest.$ac_objext` in *MSB*) emul="${emul}btsmip" ;; @@ -1359,7 +1378,7 @@ mips64*-*linux*) emul="${emul}ltsmip" ;; esac - case `/usr/bin/file conftest.$ac_objext` in + case `$FILECMD conftest.$ac_objext` in *N32*) emul="${emul}n32" ;; @@ -1370,7 +1389,7 @@ mips64*-*linux*) ;; x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \ -s390*-*linux*|s390*-*tpf*|sparc*-*linux*) +s390*-*linux*|s390*-*tpf*|sparc*-*linux*|x86_64-gnu*) # Find out what ABI is being produced by ac_compile, and set linker # options accordingly. Note that the listed cases only cover the # situations where additional linker options are needed (such as when @@ -1379,14 +1398,14 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) # not appear in the list. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then - case `/usr/bin/file conftest.o` in + case `$FILECMD conftest.o` in *32-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_i386_fbsd" ;; - x86_64-*linux*) - case `/usr/bin/file conftest.o` in + x86_64-*linux*|x86_64-gnu*) + case `$FILECMD conftest.o` in *x86-64*) LD="${LD-ld} -m elf32_x86_64" ;; @@ -1414,7 +1433,7 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_x86_64_fbsd" ;; - x86_64-*linux*) + x86_64-*linux*|x86_64-gnu*) LD="${LD-ld} -m elf_x86_64" ;; powerpcle-*linux*) @@ -1454,7 +1473,7 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) # options accordingly. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then - case `/usr/bin/file conftest.o` in + case `$FILECMD conftest.o` in *64-bit*) case $lt_cv_prog_gnu_ld in yes*) @@ -1497,7 +1516,7 @@ _LT_DECL([], [AR], [1], [The archiver]) # Use ARFLAGS variable as AR's operation code to sync the variable naming with # Automake. If both AR_FLAGS and ARFLAGS are specified, AR_FLAGS should have -# higher priority because thats what people were doing historically (setting +# higher priority because that's what people were doing historically (setting # ARFLAGS for automake and AR_FLAGS for libtool). FIXME: Make the AR_FLAGS # variable obsoleted/removed. @@ -1547,7 +1566,7 @@ AC_CHECK_TOOL(STRIP, strip, :) test -z "$STRIP" && STRIP=: _LT_DECL([], [STRIP], [1], [A symbol stripping program]) -AC_CHECK_TOOL(RANLIB, ranlib, :) +AC_REQUIRE([AC_PROG_RANLIB]) test -z "$RANLIB" && RANLIB=: _LT_DECL([], [RANLIB], [1], [Commands used to install an old-style archive]) @@ -1558,15 +1577,8 @@ old_postinstall_cmds='chmod 644 $oldlib' old_postuninstall_cmds= if test -n "$RANLIB"; then - case $host_os in - bitrig* | openbsd*) - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib" - ;; - *) - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" - ;; - esac old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" fi case $host_os in @@ -1705,7 +1717,7 @@ AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl lt_cv_sys_max_cmd_len=-1; ;; - cygwin* | mingw* | cegcc*) + cygwin* | mingw* | windows* | cegcc*) # On Win9x/ME, this test blows up -- it succeeds, but takes # about 5 minutes as the teststring grows exponentially. # Worse, since 9x/ME are not pre-emptively multitasking, @@ -1727,7 +1739,7 @@ AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl lt_cv_sys_max_cmd_len=8192; ;; - bitrig* | darwin* | dragonfly* | freebsd* | netbsd* | openbsd*) + darwin* | dragonfly* | freebsd* | midnightbsd* | netbsd* | openbsd*) # This has been around since 386BSD, at least. Likely further. if test -x /sbin/sysctl; then lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` @@ -1770,7 +1782,7 @@ AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl sysv5* | sco5v6* | sysv4.2uw2*) kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` if test -n "$kargmax"; then - lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'` + lt_cv_sys_max_cmd_len=`echo $kargmax | $SED 's/.*[[ ]]//'` else lt_cv_sys_max_cmd_len=32768 fi @@ -1887,11 +1899,11 @@ else /* When -fvisibility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) -int fnord () __attribute__((visibility("default"))); +int fnord (void) __attribute__((visibility("default"))); #endif -int fnord () { return 42; } -int main () +int fnord (void) { return 42; } +int main (void) { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; @@ -1948,7 +1960,7 @@ else lt_cv_dlopen_self=yes ;; - mingw* | pw32* | cegcc*) + mingw* | windows* | pw32* | cegcc*) lt_cv_dlopen=LoadLibrary lt_cv_dlopen_libs= ;; @@ -2316,7 +2328,7 @@ if test yes = "$GCC"; then *) lt_awk_arg='/^libraries:/' ;; esac case $host_os in - mingw* | cegcc*) lt_sed_strip_eq='s|=\([[A-Za-z]]:\)|\1|g' ;; + mingw* | windows* | cegcc*) lt_sed_strip_eq='s|=\([[A-Za-z]]:\)|\1|g' ;; *) lt_sed_strip_eq='s|=/|/|g' ;; esac lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` @@ -2374,7 +2386,7 @@ BEGIN {RS = " "; FS = "/|\n";} { # AWK program above erroneously prepends '/' to C:/dos/paths # for these hosts. case $host_os in - mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ + mingw* | windows* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ $SED 's|/\([[A-Za-z]]:\)|\1|g'` ;; esac sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` @@ -2449,7 +2461,7 @@ aix[[4-9]]*) # Unfortunately, runtime linking may impact performance, so we do # not want this to be the default eventually. Also, we use the # versioned .so libs for executables only if there is the -brtl - # linker flag in LDFLAGS as well, or --with-aix-soname=svr4 only. + # linker flag in LDFLAGS as well, or --enable-aix-soname=svr4 only. # To allow for filename-based versioning support, we need to create # libNAME.so.V as an archive file, containing: # *) an Import File, referring to the versioned filename of the @@ -2543,7 +2555,7 @@ bsdi[[45]]*) # libtool to hard-code these into programs ;; -cygwin* | mingw* | pw32* | cegcc*) +cygwin* | mingw* | windows* | pw32* | cegcc*) version_type=windows shrext_cmds=.dll need_version=no @@ -2554,6 +2566,19 @@ cygwin* | mingw* | pw32* | cegcc*) # gcc library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds + # If user builds GCC with mulitlibs enabled, + # it should just install on $(libdir) + # not on $(libdir)/../bin or 32 bits dlls would override 64 bit ones. + if test yes = $multilib; then + postinstall_cmds='base_file=`basename \$file`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + $install_prog $dir/$dlname $destdir/$dlname~ + chmod a+x $destdir/$dlname~ + if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then + eval '\''$striplib $destdir/$dlname'\'' || exit \$?; + fi' + else postinstall_cmds='base_file=`basename \$file`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ @@ -2563,6 +2588,7 @@ cygwin* | mingw* | pw32* | cegcc*) if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' + fi postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' @@ -2571,17 +2597,17 @@ cygwin* | mingw* | pw32* | cegcc*) case $host_os in cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' - soname_spec='`echo $libname | sed -e 's/^lib/cyg/'``echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' + soname_spec='`echo $libname | $SED -e 's/^lib/cyg/'``echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' m4_if([$1], [],[ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"]) ;; - mingw* | cegcc*) + mingw* | windows* | cegcc*) # MinGW DLLs use traditional 'lib' prefix soname_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' - library_names_spec='`echo $libname | sed -e 's/^lib/pw/'``echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' + library_names_spec='`echo $libname | $SED -e 's/^lib/pw/'``echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' ;; esac dynamic_linker='Win32 ld.exe' @@ -2594,7 +2620,7 @@ m4_if([$1], [],[ library_names_spec='$libname.dll.lib' case $build_os in - mingw*) + mingw* | windows*) sys_lib_search_path_spec= lt_save_ifs=$IFS IFS=';' @@ -2607,7 +2633,7 @@ m4_if([$1], [],[ done IFS=$lt_save_ifs # Convert to MSYS style. - sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([[a-zA-Z]]\\):| /\\1|g' -e 's|^ ||'` + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's|\\\\|/|g' -e 's| \\([[a-zA-Z]]\\):| /\\1|g' -e 's|^ ||'` ;; cygwin*) # Convert to unix form, then to dos form, then back to unix form @@ -2677,7 +2703,7 @@ dgux*) shlibpath_var=LD_LIBRARY_PATH ;; -freebsd* | dragonfly*) +freebsd* | dragonfly* | midnightbsd*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. if test -x /usr/bin/objformat; then @@ -2701,7 +2727,21 @@ freebsd* | dragonfly*) need_version=yes ;; esac - shlibpath_var=LD_LIBRARY_PATH + case $host_cpu in + powerpc64) + # On FreeBSD bi-arch platforms, a different variable is used for 32-bit + # binaries. See <https://man.freebsd.org/cgi/man.cgi?query=ld.so>. + AC_COMPILE_IFELSE( + [AC_LANG_SOURCE( + [[int test_pointer_size[sizeof (void *) - 5]; + ]])], + [shlibpath_var=LD_LIBRARY_PATH], + [shlibpath_var=LD_32_LIBRARY_PATH]) + ;; + *) + shlibpath_var=LD_LIBRARY_PATH + ;; + esac case $host_os in freebsd2.*) shlibpath_overrides_runpath=yes @@ -2842,7 +2882,7 @@ linux*android*) version_type=none # Android doesn't support versioned libraries. need_lib_prefix=no need_version=no - library_names_spec='$libname$release$shared_ext' + library_names_spec='$libname$release$shared_ext $libname$shared_ext' soname_spec='$libname$release$shared_ext' finish_cmds= shlibpath_var=LD_LIBRARY_PATH @@ -2854,8 +2894,9 @@ linux*android*) hardcode_into_libs=yes dynamic_linker='Android linker' - # Don't embed -rpath directories since the linker doesn't support them. - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + # -rpath works at least for libraries that are not overridden by + # libraries installed in system locations. + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' ;; # This must be glibc/ELF. @@ -2889,7 +2930,7 @@ linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) # before this can be enabled. hardcode_into_libs=yes - # Ideally, we could use ldconfig to report *all* directores which are + # Ideally, we could use ldconfig to report *all* directories which are # searched for libraries, however this is still not possible. Aside from not # being certain /sbin/ldconfig is available, command # 'ldconfig -N -X -v | grep ^/' on 64bit Fedora does not report /usr/lib64, @@ -2909,18 +2950,6 @@ linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) dynamic_linker='GNU/Linux ld.so' ;; -netbsdelf*-gnu) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - dynamic_linker='NetBSD ld.elf_so' - ;; - netbsd*) version_type=sunos need_lib_prefix=no @@ -2958,7 +2987,7 @@ newsos6) dynamic_linker='ldqnx.so' ;; -openbsd* | bitrig*) +openbsd*) version_type=sunos sys_lib_dlsearch_path_spec=/usr/lib need_lib_prefix=no @@ -3290,7 +3319,7 @@ if test yes = "$GCC"; then # Check if gcc -print-prog-name=ld gives a path. AC_MSG_CHECKING([for ld used by $CC]) case $host in - *-*-mingw*) + *-*-mingw* | *-*-windows*) # gcc leaves a trailing carriage return, which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) @@ -3399,7 +3428,7 @@ case $reload_flag in esac reload_cmds='$LD$reload_flag -o $output$reload_objs' case $host_os in - cygwin* | mingw* | pw32* | cegcc*) + cygwin* | mingw* | windows* | pw32* | cegcc*) if test yes != "$GCC"; then reload_cmds=false fi @@ -3471,7 +3500,6 @@ lt_cv_deplibs_check_method='unknown' # 'none' -- dependencies not supported. # 'unknown' -- same as none, but documents that we really don't know. # 'pass_all' -- all dependencies passed with no checks. -# 'test_compile' -- check by making test program. # 'file_magic [[regex]]' -- check by looking for files in library path # that responds to the $file_magic_cmd with a given extended regex. # If you have 'file' or equivalent on your system and you're not sure @@ -3488,7 +3516,7 @@ beos*) bsdi[[45]]*) lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib)' - lt_cv_file_magic_cmd='/usr/bin/file -L' + lt_cv_file_magic_cmd='$FILECMD -L' lt_cv_file_magic_test_file=/shlib/libc.so ;; @@ -3498,7 +3526,7 @@ cygwin*) lt_cv_file_magic_cmd='func_win32_libid' ;; -mingw* | pw32*) +mingw* | windows* | pw32*) # Base MSYS/MinGW do not provide the 'file' command needed by # func_win32_libid shell function, so use a weaker test based on 'objdump', # unless we find 'file', for example because we are cross-compiling. @@ -3507,7 +3535,7 @@ mingw* | pw32*) lt_cv_file_magic_cmd='func_win32_libid' else # Keep this pattern in sync with the one in func_win32_libid. - lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' + lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64|pe-aarch64)' lt_cv_file_magic_cmd='$OBJDUMP -f' fi ;; @@ -3522,14 +3550,14 @@ darwin* | rhapsody*) lt_cv_deplibs_check_method=pass_all ;; -freebsd* | dragonfly*) +freebsd* | dragonfly* | midnightbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then case $host_cpu in i*86 ) # Not sure whether the presence of OpenBSD here was a mistake. # Let's accept both of them until this is cleared up. lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library' - lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_cmd=$FILECMD lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` ;; esac @@ -3543,7 +3571,7 @@ haiku*) ;; hpux10.20* | hpux11*) - lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_cmd=$FILECMD case $host_cpu in ia64*) lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64' @@ -3580,7 +3608,7 @@ linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) lt_cv_deplibs_check_method=pass_all ;; -netbsd* | netbsdelf*-gnu) +netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' else @@ -3590,7 +3618,7 @@ netbsd* | netbsdelf*-gnu) newos6*) lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)' - lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_cmd=$FILECMD lt_cv_file_magic_test_file=/usr/lib/libnls.so ;; @@ -3598,7 +3626,7 @@ newos6*) lt_cv_deplibs_check_method=pass_all ;; -openbsd* | bitrig*) +openbsd*) if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$' else @@ -3662,7 +3690,7 @@ file_magic_glob= want_nocaseglob=no if test "$build" = "$host"; then case $host_os in - mingw* | pw32*) + mingw* | windows* | pw32*) if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then want_nocaseglob=yes else @@ -3714,16 +3742,16 @@ else # Tru64's nm complains that /dev/null is an invalid object file # MSYS converts /dev/null to NUL, MinGW nm treats NUL as empty case $build_os in - mingw*) lt_bad_file=conftest.nm/nofile ;; + mingw* | windows*) lt_bad_file=conftest.nm/nofile ;; *) lt_bad_file=/dev/null ;; esac - case `"$tmp_nm" -B $lt_bad_file 2>&1 | sed '1q'` in + case `"$tmp_nm" -B $lt_bad_file 2>&1 | $SED '1q'` in *$lt_bad_file* | *'Invalid file or object type'*) lt_cv_path_NM="$tmp_nm -B" break 2 ;; *) - case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in + case `"$tmp_nm" -p /dev/null 2>&1 | $SED '1q'` in */dev/null*) lt_cv_path_NM="$tmp_nm -p" break 2 @@ -3749,7 +3777,7 @@ else # Let the user override the test. else AC_CHECK_TOOLS(DUMPBIN, [dumpbin "link -dump"], :) - case `$DUMPBIN -symbols -headers /dev/null 2>&1 | sed '1q'` in + case `$DUMPBIN -symbols -headers /dev/null 2>&1 | $SED '1q'` in *COFF*) DUMPBIN="$DUMPBIN -symbols -headers" ;; @@ -3805,7 +3833,7 @@ lt_cv_sharedlib_from_linklib_cmd, [lt_cv_sharedlib_from_linklib_cmd='unknown' case $host_os in -cygwin* | mingw* | pw32* | cegcc*) +cygwin* | mingw* | windows* | pw32* | cegcc*) # two different shell functions defined in ltmain.sh; # decide which one to use based on capabilities of $DLLTOOL case `$DLLTOOL --help 2>&1` in @@ -3837,16 +3865,16 @@ _LT_DECL([], [sharedlib_from_linklib_cmd], [1], m4_defun([_LT_PATH_MANIFEST_TOOL], [AC_CHECK_TOOL(MANIFEST_TOOL, mt, :) test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt -AC_CACHE_CHECK([if $MANIFEST_TOOL is a manifest tool], [lt_cv_path_mainfest_tool], - [lt_cv_path_mainfest_tool=no +AC_CACHE_CHECK([if $MANIFEST_TOOL is a manifest tool], [lt_cv_path_manifest_tool], + [lt_cv_path_manifest_tool=no echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&AS_MESSAGE_LOG_FD $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out cat conftest.err >&AS_MESSAGE_LOG_FD if $GREP 'Manifest Tool' conftest.out > /dev/null; then - lt_cv_path_mainfest_tool=yes + lt_cv_path_manifest_tool=yes fi rm -f conftest*]) -if test yes != "$lt_cv_path_mainfest_tool"; then +if test yes != "$lt_cv_path_manifest_tool"; then MANIFEST_TOOL=: fi _LT_DECL([], [MANIFEST_TOOL], [1], [Manifest tool])dnl @@ -3875,7 +3903,7 @@ AC_DEFUN([LT_LIB_M], [AC_REQUIRE([AC_CANONICAL_HOST])dnl LIBM= case $host in -*-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-haiku* | *-*-pw32* | *-*-darwin*) +*-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-haiku* | *-*-mingw* | *-*-pw32* | *-*-darwin*) # These system don't have libm, or don't need it ;; *-ncr-sysv4.3*) @@ -3950,7 +3978,7 @@ case $host_os in aix*) symcode='[[BCDT]]' ;; -cygwin* | mingw* | pw32* | cegcc*) +cygwin* | mingw* | windows* | pw32* | cegcc*) symcode='[[ABCDGISTW]]' ;; hpux*) @@ -3965,7 +3993,7 @@ osf*) symcode='[[BCDEGQRST]]' ;; solaris*) - symcode='[[BDRT]]' + symcode='[[BCDRT]]' ;; sco3.2v5*) symcode='[[DT]]' @@ -3989,7 +4017,7 @@ esac if test "$lt_cv_nm_interface" = "MS dumpbin"; then # Gets list of data symbols to import. - lt_cv_sys_global_symbol_to_import="sed -n -e 's/^I .* \(.*\)$/\1/p'" + lt_cv_sys_global_symbol_to_import="$SED -n -e 's/^I .* \(.*\)$/\1/p'" # Adjust the below global symbol transforms to fixup imported variables. lt_cdecl_hook=" -e 's/^I .* \(.*\)$/extern __declspec(dllimport) char \1;/p'" lt_c_name_hook=" -e 's/^I .* \(.*\)$/ {\"\1\", (void *) 0},/p'" @@ -4007,20 +4035,20 @@ fi # Transform an extracted symbol line into a proper C declaration. # Some systems (esp. on ia64) link data and code symbols differently, # so use this general approach. -lt_cv_sys_global_symbol_to_cdecl="sed -n"\ +lt_cv_sys_global_symbol_to_cdecl="$SED -n"\ $lt_cdecl_hook\ " -e 's/^T .* \(.*\)$/extern int \1();/p'"\ " -e 's/^$symcode$symcode* .* \(.*\)$/extern char \1;/p'" # Transform an extracted symbol line into symbol name and symbol address -lt_cv_sys_global_symbol_to_c_name_address="sed -n"\ +lt_cv_sys_global_symbol_to_c_name_address="$SED -n"\ $lt_c_name_hook\ " -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\ " -e 's/^$symcode$symcode* .* \(.*\)$/ {\"\1\", (void *) \&\1},/p'" # Transform an extracted symbol line into symbol name with lib prefix and # symbol address. -lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n"\ +lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="$SED -n"\ $lt_c_name_lib_hook\ " -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\ " -e 's/^$symcode$symcode* .* \(lib.*\)$/ {\"\1\", (void *) \&\1},/p'"\ @@ -4029,7 +4057,7 @@ $lt_c_name_lib_hook\ # Handle CRLF in mingw tool chain opt_cr= case $build_os in -mingw*) +mingw* | windows*) opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp ;; esac @@ -4062,9 +4090,9 @@ for ac_symprfx in "" "_"; do " s[1]~prfx {split(s[1],t,\"@\"); print f,t[1],substr(t[1],length(prfx))}"\ " ' prfx=^$ac_symprfx]" else - lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" + lt_cv_sys_global_symbol_pipe="$SED -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" fi - lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" + lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | $SED '/ __gnu_lto/d'" # Check to see that the pipe works correctly. pipe_works=no @@ -4080,7 +4108,7 @@ void nm_test_func(void){} #ifdef __cplusplus } #endif -int main(){nm_test_var='a';nm_test_func();return(0);} +int main(void){nm_test_var='a';nm_test_func();return(0);} _LT_EOF if AC_TRY_EVAL(ac_compile); then @@ -4256,7 +4284,7 @@ m4_if([$1], [CXX], [ beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; - mingw* | cygwin* | os2* | pw32* | cegcc*) + mingw* | windows* | cygwin* | os2* | pw32* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style @@ -4332,7 +4360,7 @@ m4_if([$1], [CXX], [ ;; esac ;; - mingw* | cygwin* | os2* | pw32* | cegcc*) + mingw* | windows* | cygwin* | os2* | pw32* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). m4_if([$1], [GCJ], [], @@ -4351,7 +4379,7 @@ m4_if([$1], [CXX], [ ;; esac ;; - freebsd* | dragonfly*) + freebsd* | dragonfly* | midnightbsd*) # FreeBSD uses GNU C++ ;; hpux9* | hpux10* | hpux11*) @@ -4434,7 +4462,7 @@ m4_if([$1], [CXX], [ _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' ;; *) - case `$CC -V 2>&1 | sed 5q` in + case `$CC -V 2>&1 | $SED 5q` in *Sun\ C*) # Sun C++ 5.9 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' @@ -4458,7 +4486,7 @@ m4_if([$1], [CXX], [ ;; esac ;; - netbsd* | netbsdelf*-gnu) + netbsd*) ;; *qnx* | *nto*) # QNX uses GNU C++, but need to define -shared option too, otherwise @@ -4580,7 +4608,7 @@ m4_if([$1], [CXX], [ # PIC is the default for these OSes. ;; - mingw* | cygwin* | pw32* | os2* | cegcc*) + mingw* | windows* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style @@ -4684,7 +4712,7 @@ m4_if([$1], [CXX], [ esac ;; - mingw* | cygwin* | pw32* | os2* | cegcc*) + mingw* | windows* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). m4_if([$1], [GCJ], [], @@ -4726,6 +4754,12 @@ m4_if([$1], [CXX], [ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; + *flang* | ftn) + # Flang compiler. + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; # icc used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. icc* | ifort*) @@ -4770,7 +4804,7 @@ m4_if([$1], [CXX], [ _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' ;; *) - case `$CC -V 2>&1 | sed 5q` in + case `$CC -V 2>&1 | $SED 5q` in *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [[1-7]].* | *Sun*Fortran*\ 8.[[0-3]]*) # Sun Fortran 8.3 passes all unrecognized flags to the linker _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' @@ -4959,7 +4993,7 @@ m4_if([$1], [CXX], [ pw32*) _LT_TAGVAR(export_symbols_cmds, $1)=$ltdll_cmds ;; - cygwin* | mingw* | cegcc*) + cygwin* | mingw* | windows* | cegcc*) case $cc_basename in cl* | icl*) _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' @@ -5017,7 +5051,7 @@ dnl Note also adjust exclude_expsyms for C++ above. extract_expsyms_cmds= case $host_os in - cygwin* | mingw* | pw32* | cegcc*) + cygwin* | mingw* | windows* | pw32* | cegcc*) # FIXME: the MSVC++ and ICC port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using # Microsoft Visual C++ or Intel C++ Compiler. @@ -5029,7 +5063,7 @@ dnl Note also adjust exclude_expsyms for C++ above. # we just hope/assume this is gcc and not c89 (= MSVC++ or ICC) with_gnu_ld=yes ;; - openbsd* | bitrig*) + openbsd*) with_gnu_ld=no ;; esac @@ -5078,7 +5112,7 @@ dnl Note also adjust exclude_expsyms for C++ above. _LT_TAGVAR(whole_archive_flag_spec, $1)= fi supports_anon_versioning=no - case `$LD -v | $SED -e 's/([^)]\+)\s\+//' 2>&1` in + case `$LD -v | $SED -e 's/([[^)]]\+)\s\+//' 2>&1` in *GNU\ gold*) supports_anon_versioning=yes ;; *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11 *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... @@ -5132,7 +5166,7 @@ _LT_EOF fi ;; - cygwin* | mingw* | pw32* | cegcc*) + cygwin* | mingw* | windows* | pw32* | cegcc*) # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, # as there is no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' @@ -5188,7 +5222,7 @@ _LT_EOF cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ emximp -o $lib $output_objdir/$libname.def' - _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' + _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes _LT_TAGVAR(file_list_spec, $1)='@' ;; @@ -5205,7 +5239,7 @@ _LT_EOF # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$SED "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) @@ -5248,7 +5282,7 @@ _LT_EOF _LT_TAGVAR(compiler_needs_object, $1)=yes ;; esac - case `$CC -V 2>&1 | sed 5q` in + case `$CC -V 2>&1 | $SED 5q` in *Sun\ C*) # Sun C 5.9 _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes @@ -5260,7 +5294,7 @@ _LT_EOF if test yes = "$supports_anon_versioning"; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ - cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib' fi @@ -5276,7 +5310,7 @@ _LT_EOF _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' if test yes = "$supports_anon_versioning"; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ - cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' fi @@ -5287,7 +5321,7 @@ _LT_EOF fi ;; - netbsd* | netbsdelf*-gnu) + netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' wlarc= @@ -5589,7 +5623,7 @@ _LT_EOF _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic ;; - cygwin* | mingw* | pw32* | cegcc*) + cygwin* | mingw* | windows* | pw32* | cegcc*) # When not using gcc, we currently assume that we are using # Microsoft Visual C++ or Intel C++ Compiler. # hardcode_libdir_flag_spec is actually meaningless, as there is @@ -5606,14 +5640,14 @@ _LT_EOF # Tell ltmain to make .dll files, not .so files. shrext_cmds=.dll # FIXME: Setting linknames here is a bad hack. - _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames=' + _LT_TAGVAR(archive_cmds, $1)='$CC -Fe $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames=' _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then cp "$export_symbols" "$output_objdir/$soname.def"; echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp"; else $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp; fi~ - $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ + $CC -Fe $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' @@ -5685,7 +5719,7 @@ _LT_EOF ;; # FreeBSD 3 and greater uses gcc -shared to do shared libraries. - freebsd* | dragonfly*) + freebsd* | dragonfly* | midnightbsd*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes @@ -5829,7 +5863,7 @@ _LT_EOF esac ;; - netbsd* | netbsdelf*-gnu) + netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out else @@ -5851,7 +5885,7 @@ _LT_EOF *nto* | *qnx*) ;; - openbsd* | bitrig*) + openbsd*) if test -f /usr/libexec/ld.so; then _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no @@ -5894,7 +5928,7 @@ _LT_EOF cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ emximp -o $lib $output_objdir/$libname.def' - _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' + _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes _LT_TAGVAR(file_list_spec, $1)='@' ;; @@ -6188,7 +6222,7 @@ _LT_TAGDECL([], [hardcode_direct], [0], _LT_TAGDECL([], [hardcode_direct_absolute], [0], [Set to "yes" if using DIR/libNAME$shared_ext during linking hardcodes DIR into the resulting binary and the resulting library dependency is - "absolute", i.e impossible to change by setting $shlibpath_var if the + "absolute", i.e. impossible to change by setting $shlibpath_var if the library is relocated]) _LT_TAGDECL([], [hardcode_minus_L], [0], [Set to "yes" if using the -LDIR flag during linking hardcodes DIR @@ -6246,7 +6280,7 @@ _LT_TAGVAR(objext, $1)=$objext lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests -lt_simple_link_test_code='int main(){return(0);}' +lt_simple_link_test_code='int main(void){return(0);}' _LT_TAG_COMPILER # Save the default compiler, since it gets overwritten when the other @@ -6435,8 +6469,7 @@ if test yes != "$_lt_caught_CXX_error"; then wlarc='$wl' # ancient GNU ld didn't support --whole-archive et. al. - if eval "`$CC -print-prog-name=ld` --help 2>&1" | - $GREP 'no-whole-archive' > /dev/null; then + if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then _LT_TAGVAR(whole_archive_flag_spec, $1)=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive' else _LT_TAGVAR(whole_archive_flag_spec, $1)= @@ -6456,7 +6489,7 @@ if test yes != "$_lt_caught_CXX_error"; then # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "[[-]]L"' else GXX=no @@ -6665,7 +6698,7 @@ if test yes != "$_lt_caught_CXX_error"; then esac ;; - cygwin* | mingw* | pw32* | cegcc*) + cygwin* | mingw* | windows* | pw32* | cegcc*) case $GXX,$cc_basename in ,cl* | no,cl* | ,icl* | no,icl*) # Native MSVC or ICC @@ -6764,7 +6797,7 @@ if test yes != "$_lt_caught_CXX_error"; then cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ emximp -o $lib $output_objdir/$libname.def' - _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' + _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes _LT_TAGVAR(file_list_spec, $1)='@' ;; @@ -6797,7 +6830,7 @@ if test yes != "$_lt_caught_CXX_error"; then _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;; - freebsd* | dragonfly*) + freebsd* | dragonfly* | midnightbsd*) # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF # conventions _LT_TAGVAR(ld_shlibs, $1)=yes @@ -6832,7 +6865,7 @@ if test yes != "$_lt_caught_CXX_error"; then # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. - output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "[[-]]L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test yes = "$GXX"; then @@ -6897,7 +6930,7 @@ if test yes != "$_lt_caught_CXX_error"; then # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. - output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "[[-]]L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test yes = "$GXX"; then @@ -6934,7 +6967,7 @@ if test yes != "$_lt_caught_CXX_error"; then # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$SED "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; irix5* | irix6*) case $cc_basename in @@ -7074,13 +7107,13 @@ if test yes != "$_lt_caught_CXX_error"; then _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' if test yes = "$supports_anon_versioning"; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ - cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib' fi ;; *) - case `$CC -V 2>&1 | sed 5q` in + case `$CC -V 2>&1 | $SED 5q` in *Sun\ C*) # Sun C++ 5.9 _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' @@ -7145,7 +7178,7 @@ if test yes != "$_lt_caught_CXX_error"; then _LT_TAGVAR(ld_shlibs, $1)=yes ;; - openbsd* | bitrig*) + openbsd*) if test -f /usr/libexec/ld.so; then _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no @@ -7236,7 +7269,7 @@ if test yes != "$_lt_caught_CXX_error"; then # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "[[-]]L"' else # FIXME: insert proper C++ library support @@ -7320,7 +7353,7 @@ if test yes != "$_lt_caught_CXX_error"; then # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "[[-]]L"' else # g++ 2.7 appears to require '-G' NOT '-shared' on this # platform. @@ -7331,7 +7364,7 @@ if test yes != "$_lt_caught_CXX_error"; then # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. - output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' + output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "[[-]]L"' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $wl$libdir' @@ -7569,10 +7602,11 @@ if AC_TRY_EVAL(ac_compile); then case $prev$p in -L* | -R* | -l*) - # Some compilers place space between "-{L,R}" and the path. + # Some compilers place space between "-{L,R,l}" and the path. # Remove the space. - if test x-L = "$p" || - test x-R = "$p"; then + if test x-L = x"$p" || + test x-R = x"$p" || + test x-l = x"$p"; then prev=$p continue fi @@ -8226,6 +8260,14 @@ _LT_DECL([], [DLLTOOL], [1], [DLL creation program]) AC_SUBST([DLLTOOL]) ]) +# _LT_DECL_FILECMD +# ---------------- +# Check for a file(cmd) program that can be used to detect file type and magic +m4_defun([_LT_DECL_FILECMD], +[AC_CHECK_PROG([FILECMD], [file], [file], [:]) +_LT_DECL([], [FILECMD], [1], [A file(cmd) program that detects file types]) +])# _LD_DECL_FILECMD + # _LT_DECL_SED # ------------ # Check for a fully-functional sed program, that truncates @@ -8238,73 +8280,6 @@ _LT_DECL([], [SED], [1], [A sed program that does not truncate output]) _LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"], [Sed that helps us avoid accidentally triggering echo(1) options like -n]) ])# _LT_DECL_SED - -m4_ifndef([AC_PROG_SED], [ -############################################################ -# NOTE: This macro has been submitted for inclusion into # -# GNU Autoconf as AC_PROG_SED. When it is available in # -# a released version of Autoconf we should remove this # -# macro and use it instead. # -############################################################ - -m4_defun([AC_PROG_SED], -[AC_MSG_CHECKING([for a sed that does not truncate output]) -AC_CACHE_VAL(lt_cv_path_SED, -[# Loop through the user's path and test for sed and gsed. -# Then use that list of sed's as ones to test for truncation. -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for lt_ac_prog in sed gsed; do - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then - lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext" - fi - done - done -done -IFS=$as_save_IFS -lt_ac_max=0 -lt_ac_count=0 -# Add /usr/xpg4/bin/sed as it is typically found on Solaris -# along with /bin/sed that truncates output. -for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do - test ! -f "$lt_ac_sed" && continue - cat /dev/null > conftest.in - lt_ac_count=0 - echo $ECHO_N "0123456789$ECHO_C" >conftest.in - # Check for GNU sed and select it if it is found. - if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then - lt_cv_path_SED=$lt_ac_sed - break - fi - while true; do - cat conftest.in conftest.in >conftest.tmp - mv conftest.tmp conftest.in - cp conftest.in conftest.nl - echo >>conftest.nl - $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break - cmp -s conftest.out conftest.nl || break - # 10000 chars as input seems more than enough - test 10 -lt "$lt_ac_count" && break - lt_ac_count=`expr $lt_ac_count + 1` - if test "$lt_ac_count" -gt "$lt_ac_max"; then - lt_ac_max=$lt_ac_count - lt_cv_path_SED=$lt_ac_sed - fi - done -done -]) -SED=$lt_cv_path_SED -AC_SUBST([SED]) -AC_MSG_RESULT([$SED]) -])#AC_PROG_SED -])#m4_ifndef - -# Old name: -AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([LT_AC_PROG_SED], []) @@ -8351,7 +8326,7 @@ AC_CACHE_VAL(lt_cv_to_host_file_cmd, [case $host in *-*-mingw* ) case $build in - *-*-mingw* ) # actually msys + *-*-mingw* | *-*-windows* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 ;; *-*-cygwin* ) @@ -8364,7 +8339,7 @@ AC_CACHE_VAL(lt_cv_to_host_file_cmd, ;; *-*-cygwin* ) case $build in - *-*-mingw* ) # actually msys + *-*-mingw* | *-*-windows* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin ;; *-*-cygwin* ) @@ -8390,9 +8365,9 @@ AC_CACHE_VAL(lt_cv_to_tool_file_cmd, [#assume ordinary cross tools, or native build. lt_cv_to_tool_file_cmd=func_convert_file_noop case $host in - *-*-mingw* ) + *-*-mingw* | *-*-windows* ) case $build in - *-*-mingw* ) # actually msys + *-*-mingw* | *-*-windows* ) # actually msys lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 ;; esac diff --git a/m4/ltoptions.m4 b/m4/ltoptions.m4 index 94b082976..25caa8902 100644 --- a/m4/ltoptions.m4 +++ b/m4/ltoptions.m4 @@ -1,14 +1,14 @@ # Helper functions for option handling. -*- Autoconf -*- # -# Copyright (C) 2004-2005, 2007-2009, 2011-2015 Free Software -# Foundation, Inc. +# Copyright (C) 2004-2005, 2007-2009, 2011-2019, 2021-2024 Free +# Software Foundation, Inc. # Written by Gary V. Vaughan, 2004 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. -# serial 8 ltoptions.m4 +# serial 10 ltoptions.m4 # This is to help aclocal find these macros, as it can't see m4_define. AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])]) @@ -128,7 +128,7 @@ LT_OPTION_DEFINE([LT_INIT], [win32-dll], [enable_win32_dll=yes case $host in -*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*) +*-*-cygwin* | *-*-mingw* | *-*-windows* | *-*-pw32* | *-*-cegcc*) AC_CHECK_TOOL(AS, as, false) AC_CHECK_TOOL(DLLTOOL, dlltool, false) AC_CHECK_TOOL(OBJDUMP, objdump, false) @@ -323,29 +323,39 @@ dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], []) # _LT_WITH_AIX_SONAME([DEFAULT]) # ---------------------------------- -# implement the --with-aix-soname flag, and support the `aix-soname=aix' -# and `aix-soname=both' and `aix-soname=svr4' LT_INIT options. DEFAULT -# is either `aix', `both' or `svr4'. If omitted, it defaults to `aix'. +# implement the --enable-aix-soname configure option, and support the +# `aix-soname=aix' and `aix-soname=both' and `aix-soname=svr4' LT_INIT options. +# DEFAULT is either `aix', `both', or `svr4'. If omitted, it defaults to `aix'. m4_define([_LT_WITH_AIX_SONAME], [m4_define([_LT_WITH_AIX_SONAME_DEFAULT], [m4_if($1, svr4, svr4, m4_if($1, both, both, aix))])dnl shared_archive_member_spec= case $host,$enable_shared in power*-*-aix[[5-9]]*,yes) AC_MSG_CHECKING([which variant of shared library versioning to provide]) - AC_ARG_WITH([aix-soname], - [AS_HELP_STRING([--with-aix-soname=aix|svr4|both], + AC_ARG_ENABLE([aix-soname], + [AS_HELP_STRING([--enable-aix-soname=aix|svr4|both], [shared library versioning (aka "SONAME") variant to provide on AIX, @<:@default=]_LT_WITH_AIX_SONAME_DEFAULT[@:>@.])], - [case $withval in - aix|svr4|both) - ;; - *) - AC_MSG_ERROR([Unknown argument to --with-aix-soname]) - ;; - esac - lt_cv_with_aix_soname=$with_aix_soname], - [AC_CACHE_VAL([lt_cv_with_aix_soname], - [lt_cv_with_aix_soname=]_LT_WITH_AIX_SONAME_DEFAULT) - with_aix_soname=$lt_cv_with_aix_soname]) + [case $enableval in + aix|svr4|both) + ;; + *) + AC_MSG_ERROR([Unknown argument to --enable-aix-soname]) + ;; + esac + lt_cv_with_aix_soname=$enable_aix_soname], + [_AC_ENABLE_IF([with], [aix-soname], + [case $withval in + aix|svr4|both) + ;; + *) + AC_MSG_ERROR([Unknown argument to --with-aix-soname]) + ;; + esac + lt_cv_with_aix_soname=$with_aix_soname], + [AC_CACHE_VAL([lt_cv_with_aix_soname], + [lt_cv_with_aix_soname=]_LT_WITH_AIX_SONAME_DEFAULT)]) + enable_aix_soname=$lt_cv_with_aix_soname]) + with_aix_soname=$enable_aix_soname AC_MSG_RESULT([$with_aix_soname]) if test aix != "$with_aix_soname"; then # For the AIX way of multilib, we name the shared archive member @@ -376,30 +386,50 @@ LT_OPTION_DEFINE([LT_INIT], [aix-soname=svr4], [_LT_WITH_AIX_SONAME([svr4])]) # _LT_WITH_PIC([MODE]) # -------------------- -# implement the --with-pic flag, and support the 'pic-only' and 'no-pic' +# implement the --enable-pic flag, and support the 'pic-only' and 'no-pic' # LT_INIT options. # MODE is either 'yes' or 'no'. If omitted, it defaults to 'both'. m4_define([_LT_WITH_PIC], -[AC_ARG_WITH([pic], - [AS_HELP_STRING([--with-pic@<:@=PKGS@:>@], +[AC_ARG_ENABLE([pic], + [AS_HELP_STRING([--enable-pic@<:@=PKGS@:>@], [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], [lt_p=${PACKAGE-default} - case $withval in - yes|no) pic_mode=$withval ;; - *) - pic_mode=default - # Look at the argument we got. We use all the common list separators. - lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, - for lt_pkg in $withval; do - IFS=$lt_save_ifs - if test "X$lt_pkg" = "X$lt_p"; then - pic_mode=yes - fi - done - IFS=$lt_save_ifs - ;; - esac], - [pic_mode=m4_default([$1], [default])]) + case $enableval in + yes|no) pic_mode=$enableval ;; + *) + pic_mode=default + # Look at the argument we got. We use all the common list separators. + lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, + for lt_pkg in $enableval; do + IFS=$lt_save_ifs + if test "X$lt_pkg" = "X$lt_p"; then + pic_mode=yes + fi + done + IFS=$lt_save_ifs + ;; + esac], + [dnl Continue to support --with-pic and --without-pic, for backward + dnl compatibility. + _AC_ENABLE_IF([with], [pic], + [lt_p=${PACKAGE-default} + case $withval in + yes|no) pic_mode=$withval ;; + *) + pic_mode=default + # Look at the argument we got. We use all the common list separators. + lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, + for lt_pkg in $withval; do + IFS=$lt_save_ifs + if test "X$lt_pkg" = "X$lt_p"; then + pic_mode=yes + fi + done + IFS=$lt_save_ifs + ;; + esac], + [pic_mode=m4_default([$1], [default])])] + ) _LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl ])# _LT_WITH_PIC diff --git a/m4/ltversion.m4 b/m4/ltversion.m4 index fa04b52a3..149c9719f 100644 --- a/m4/ltversion.m4 +++ b/m4/ltversion.m4 @@ -1,6 +1,7 @@ # ltversion.m4 -- version numbers -*- Autoconf -*- # -# Copyright (C) 2004, 2011-2015 Free Software Foundation, Inc. +# Copyright (C) 2004, 2011-2019, 2021-2024 Free Software Foundation, +# Inc. # Written by Scott James Remnant, 2004 # # This file is free software; the Free Software Foundation gives @@ -9,15 +10,15 @@ # @configure_input@ -# serial 4179 ltversion.m4 +# serial 4392 ltversion.m4 # This file is part of GNU Libtool -m4_define([LT_PACKAGE_VERSION], [2.4.6]) -m4_define([LT_PACKAGE_REVISION], [2.4.6]) +m4_define([LT_PACKAGE_VERSION], [2.5.3]) +m4_define([LT_PACKAGE_REVISION], [2.5.3]) AC_DEFUN([LTVERSION_VERSION], -[macro_version='2.4.6' -macro_revision='2.4.6' +[macro_version='2.5.3' +macro_revision='2.5.3' _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) _LT_DECL(, macro_revision, 0) ]) diff --git a/tests/ChangeLog b/tests/ChangeLog index 6c28dd67f..29e095b7f 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,4 +1,31 @@ +2024-10-05 Simon Sobisch <simonsobisch@gnu.org> + + * atlocal.in, atlocal_win: export new definition COB_ON_WINDOWS + to allow the testsuite skipping/failing tests + * run_prog_manual.sh.in: fix extranous $COBCRUN for all test runners + * run_prog_manual.sh.in (xterm): use all parameters, not only the first + +2024-10-02 Simon Sobisch <simonsobisch@gnu.org> + + * atlocal.in, atlocal_win: allow overriding COB_CC during tests + +2024-09-09 Simon Sobisch <simonsobisch@gnu.org> + + * run_prog_manual.sh.in: adding testrunner tmux as alternative + to screen; allow to override the deduced test runner by environment + variable TESTRUNNER; new option to call with parameter "attach" and + "kill" for either attaching to or killing test runner sessions in + screen/tmux; enhance portability and use abs_builddir + * run_prog_manual.sh.in (_test_with_screen): use separate SCREENDIR + to ensure using system defaults and work around WSL regressions + * run_prog_manual.sh.in (_test_with_cmd): work around cmd quoting + by using a dynamically created sub command file + * atlocal.in (set_utf8_locale): new function for the testsuite + enabling tests to either run with UTF8 locale or skip + * atlocal.in: use configure-setup for the grep binary + * atlocal_win: updated to current atlocal.in + 2024-08-03 David Declerck <david.declerck@ocamlpro.com> * testsuite.src/run_file.at, testsuite.src/run_misc.at: diff --git a/tests/atlocal.in b/tests/atlocal.in index 3d49ec140..254e08e59 100644 --- a/tests/atlocal.in +++ b/tests/atlocal.in @@ -1,7 +1,7 @@ # # atlocal gnucobol/tests # -# 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 # # This file is part of GnuCOBOL. @@ -185,6 +185,7 @@ _unset_option () { -a "$1" != "COB_COPY_DIR" \ -a "$1" != "COB_RUNTIME_CONFIG" \ -a "$1" != "COB_LIBRARY_PATH" \ + -a "$1" != "COB_CC" \ -a "$1" != "COB_CFLAGS" \ -a "$1" != "COB_LIBS" \ -a "$1" != "COB_UNIX_LF" \ @@ -204,12 +205,39 @@ _return_path () { fi } +# as we run the testsuite in plain LC_ALL=C the system runs in a plain-as-possible environment; +# in the case that we need UTF8 encoding within tests, we try to find out if a working UTF-8 +# locale is available, if not then we return with 77 which will skip the spßecific test needing it +set_utf8_locale () { + # we need the locale binary to tell us how about the locales available + if [ -z "$(which locale)" ]; then + echo "Warning: no locale binary found." + exit 77 # return code for setting + fi + unset LC_ALL + if [ -z "$LC_ALL" ]; then export LC_ALL=$(locale -a | $GREP -i -E "C\.utf.*8" | head -n1); fi + if [ -z "$LC_ALL" ]; then export LC_ALL=$(locale -a | $GREP -i -E "en_US\.utf.*8" | head -n1); fi + if [ -z "$LC_ALL" ]; then export LC_ALL=$(locale -a | $GREP -i -E ".*\.utf.*8" | head -n1); fi + if [ -z "$LC_ALL" ]; then + echo "Warning: no UTF-8 locale found." + exit 77 + fi +} + # ensure we don't execute windows paths within programs generated by cygwin -# by passing a hint -if test "$OSTYPE" = "cygwin"; then - COB_ON_CYGWIN=1 - export COB_ON_CYGWIN -fi +# by passing a hint and to (not) skip some tests that are portable in all +# environments but Windows +case "$OSTYPE" in + msys*|win* ) + # Windows but not Cygwin + COB_ON_WINDOWS=yes + export COB_ON_WINDOWS + ;; + cygwin* ) + COB_ON_CYGWIN=yes + export COB_ON_CYGWIN + ;; +esac # Fix for testcases where cobc translates path to win32 equivalents if test "x$MSYSTEM" != "x"; then @@ -256,8 +284,8 @@ export COB_UNIX_LF COB_RUNTIME_CONFIG="${abs_top_srcdir}/config/runtime_empty.cfg" export COB_RUNTIME_CONFIG for cobenv in $(${LOCAL_ENV} ${ABS_COBCRUN} --runtime-conf \ - | grep " env:" | cut -d: -f2 | cut -d= -f1 \ - | grep -v "PATH" | grep -v "TERM"); \ + | $GREP " env:" | cut -d: -f2 | cut -d= -f1 \ + | $GREP -v "PATH" | $GREP -v "TERM"); \ do _unset_option $cobenv; \ done @@ -266,8 +294,8 @@ ${LOCAL_ENV} ${ABS_COBC} --verbose --info > info.out # ... and also unset for the compiler if test "$GNUCOBOL_TEST_LOCAL" != "1"; then - for cobenv in $(grep "env:" info.out | cut -d: -f2 | cut -d= -f1 \ - | grep -v "PATH"); \ + for cobenv in $($GREP "env:" info.out | cut -d: -f2 | cut -d= -f1 \ + | $GREP -v "PATH"); \ do _unset_option $cobenv; \ done fi @@ -276,8 +304,11 @@ COB_STACKTRACE=0 export COB_STACKTRACE -# different flags checked in the testsuite +# different variables used in the testsuite if test "$GNUCOBOL_TEST_LOCAL" != "1"; then + if test "$COB_CC" = ""; then + COB_CC="@COB_CC@" + fi COB_OBJECT_EXT="@COB_OBJECT_EXT@" COB_EXE_EXT="@COB_EXE_EXT@" COB_MODULE_EXT="@COB_MODULE_EXT@" @@ -289,20 +320,23 @@ if test "$GNUCOBOL_TEST_LOCAL" != "1"; then COB_HAS_CURSES="@COB_HAS_CURSES@" else - COB_OBJECT_EXT="$(grep COB_OBJECT_EXT info.out | cut -d: -f2 | cut -b2-)" - COB_EXE_EXT="$(grep COB_EXE_EXT info.out | cut -d: -f2 | cut -b2-)" - COB_MODULE_EXT="$(grep COB_MODULE_EXT info.out | cut -d: -f2 | cut -b2-)" + if test "$COB_CC" = ""; then + COB_CC="$($GREP COBC_CC info.out | cut -d: -f2 | cut -b2-)" + fi + COB_OBJECT_EXT="$($GREP COB_OBJECT_EXT info.out | cut -d: -f2 | cut -b2-)" + COB_EXE_EXT="$($GREP COB_EXE_EXT info.out | cut -d: -f2 | cut -b2-)" + COB_MODULE_EXT="$($GREP COB_MODULE_EXT info.out | cut -d: -f2 | cut -b2-)" - if test $(grep -i -c "little-endian" info.out) = 0; then + if test $($GREP -i -c "little-endian" info.out) = 0; then COB_BIGENDIAN="yes" else COB_BIGENDIAN="no" fi - COB_HAS_64_BIT_POINTER=$(grep "64bit-mode" info.out | cut -d: -f2 | cut -b2-) + COB_HAS_64_BIT_POINTER=$($GREP "64bit-mode" info.out | cut -d: -f2 | cut -b2-) - cob_indexed=$(grep -i "indexed file" info.out | cut -d: -f2) + cob_indexed=$($GREP -i "indexed file" info.out | cut -d: -f2) if test "x$cob_indexed" = "x"; then - cob_indexed=$(grep ISAM info.out | cut -d: -f2) + cob_indexed=$($GREP ISAM info.out | cut -d: -f2) fi case "$cob_indexed" in " disabled") COB_HAS_ISAM="no";; @@ -314,18 +348,18 @@ else *) echo "unknown entry for indexed handler: '"$cob_indexed"' please report" && exit 1;; esac - if test $(grep -i -c "XML library.*disabled" info.out) = 0; then + if test $($GREP -i -c "XML library.*disabled" info.out) = 0; then COB_HAS_XML2="yes" else COB_HAS_XML2="no" fi - if test $(grep -i -c "JSON library.*disabled" info.out) = 0; then + if test $($GREP -i -c "JSON library.*disabled" info.out) = 0; then COB_HAS_JSON="yes" else COB_HAS_JSON="no" fi # see note below - if test $(grep -i -c " screen .*disabled" info.out) = 0; then + if test $($GREP -i -c " screen .*disabled" info.out) = 0; then COB_HAS_CURSES="yes" else COB_HAS_CURSES="no" @@ -337,7 +371,7 @@ if test "x$MSYSTEM" != "x" -o "$OSTYPE" = "cygwin"; then # "Redirection is not supported" (at least with PDCurses "wincon" port) # --> disabling the tests for this feature # ncurses is known to work as long as TERM is appropriate - if test $(grep -i -c "ncurses" info.out) != 0; then + if test $($GREP -i -c "ncurses" info.out) != 0; then if test "x$MSYSTEM" != "x"; then TERM="" else @@ -348,7 +382,7 @@ if test "x$MSYSTEM" != "x" -o "$OSTYPE" = "cygwin"; then else # manual tests are executed in separate window # and are visible - so no need to handle it there - echo "$at_help_all" | grep -q "run_manual_screen" 2>/dev/null + echo "$at_help_all" | $GREP -q "run_manual_screen" 2>/dev/null if test $? -ne 0; then COB_HAS_CURSES="no" fi @@ -360,7 +394,7 @@ rm -rf info.out # NIST tests (tests/cobol85) are executed in a separate perl process with a new environment --> export needed export COB_HAS_ISAM COB_HAS_XML2 COB_HAS_JSON COB_HAS_CURSES COB_HAS_64_BIT_POINTER export COBC COBCRUN COBCRUN_DIRECT RUN_PROG_MANUAL -export COB_OBJECT_EXT COB_EXE_EXT COB_MODULE_EXT +export COB_CC COB_OBJECT_EXT COB_EXE_EXT COB_MODULE_EXT # to ensure that no external DB_HOME is polluted: unset DB_HOME="" && export DB_HOME diff --git a/tests/atlocal_win b/tests/atlocal_win index 910fc301f..b24ff2d7e 100644 --- a/tests/atlocal_win +++ b/tests/atlocal_win @@ -5,7 +5,7 @@ # a not POSIX build (OrangeC or Visual Studio build for example) # in a POSIX environment (like MinGW or Cygwin, possibly WSL). # -# 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 # # This file is part of GnuCOBOL. @@ -27,7 +27,10 @@ TEMPLATE="${abs_srcdir}/testsuite.src" COB_SRC_PATH="$(cd ${abs_srcdir}/.. ; pwd)" -COB_WIN_BUILDPATH="$COB_SRC_PATH/build_windows/x64/Debug" + +if test "${COB_WIN_BUILDPATH}" = ""; then + COB_WIN_BUILDPATH="$COB_SRC_PATH/build_windows/x64/Debug" +fi COBC="cobc.exe" COBCRUN="cobcrun.exe" @@ -48,8 +51,8 @@ export LC_ALL unset LANG # define for performance checks (running code several thousand times) -# comment manually if not needed -COBOL_FLAGS="-DCHECK-PERF ${COBOL_FLAGS}" +# uncomment manually if wanted, or set via environment +# COBOL_FLAGS="-DCHECK-PERF ${COBOL_FLAGS}" FLAGS="-debug -Wall ${COBOL_FLAGS} -fdiagnostics-plain-output" # workaround to adjust the testsuite later: @@ -74,6 +77,7 @@ _unset_option () { -a "$1" != "COB_COPY_DIR" \ -a "$1" != "COB_RUNTIME_CONFIG" \ -a "$1" != "COB_LIBRARY_PATH" \ + -a "$1" != "COB_CC" \ -a "$1" != "COB_CFLAGS" \ -a "$1" != "COB_LIBS" \ -a "$1" != "COB_UNIX_LF" \ @@ -92,7 +96,7 @@ _return_path () { cygpath -pm "$1" else # check for WSL / Bash on Windows; ignore error messages (file not available) - if $(grep -q "Microsoft" /proc/sys/kernel/osrelease 2>/dev/null); then + if $($GREP -q "Microsoft" /proc/sys/kernel/osrelease 2>/dev/null); then echo "$1" | sed -E 's+^/mnt/(.{1})+\1:+' | sed 's+:$+:/+1' else echo "$1" @@ -100,8 +104,30 @@ _return_path () { fi } +# as we run the testsuite in plain LC_ALL=C the system runs in a plain-as-possible environment; +# in the case that we need UTF8 encoding within tests, we try to find out if a working UTF-8 +# locale is available, if not then we return with 77 which will skip the spßecific test needing it +set_utf8_locale () { + # we need the locale binary to tell us how about the locales available + if [ -z "$(which locale)" ]; then + echo "Warning: no locale binary found." + exit 77 # return code for setting + fi + unset LC_ALL + if [ -z "$LC_ALL" ]; then export LC_ALL=$(locale -a | $GREP -i -E "C\.utf.*8" | head -n1); fi + if [ -z "$LC_ALL" ]; then export LC_ALL=$(locale -a | $GREP -i -E "en_US\.utf.*8" | head -n1); fi + if [ -z "$LC_ALL" ]; then export LC_ALL=$(locale -a | $GREP -i -E ".*\.utf.*8" | head -n1); fi + if [ -z "$LC_ALL" ]; then + echo "Warning: no UTF-8 locale found." + exit 77 + fi +} + # Note: we explicit do not set COB_ON_CYGWIN here, # as this is file is about running non-cygwin binaries + # Windows but not Cygwin + COB_ON_WINDOWS=yes + export COB_ON_WINDOWS # Fix for testcases where cobc uses win32 paths internally PATHSEP=";" @@ -123,8 +149,8 @@ export COB_UNIX_LF COB_RUNTIME_CONFIG="$(_return_path "${abs_top_srcdir}/config/runtime_empty.cfg")" export COB_RUNTIME_CONFIG for cobenv in $(${LOCAL_ENV} ${COBCRUN} --runtime-conf \ - | grep " env:" | cut -d: -f2 | cut -d= -f1 \ - | grep -v "PATH" | grep -v "TERM"); \ + | $GREP " env:" | cut -d: -f2 | cut -d= -f1 \ + | $GREP -v "PATH" | $GREP -v "TERM"); \ do _unset_option $cobenv; \ done @@ -133,8 +159,8 @@ ${LOCAL_ENV} ${COBC} --verbose --info > info.out # ... and also unset for the compiler if test "$GNUCOBOL_TEST_LOCAL" != "1"; then - for cobenv in $(grep "env:" info.out | cut -d: -f2 | cut -d= -f1 \ - | grep -v "PATH"); \ + for cobenv in $($GREP "env:" info.out | cut -d: -f2 | cut -d= -f1 \ + | $GREP -v "PATH"); \ do _unset_option $cobenv; \ done fi @@ -145,23 +171,25 @@ export COB_STACKTRACE COB_MSG_FORMAT=GCC export COB_MSG_FORMAT -# different flags checked in the testsuite +# different variables used in the testsuite # note: kept intended to ease merge from atlocal.in - - COB_OBJECT_EXT="$(grep COB_OBJECT_EXT info.out | cut -d: -f2 | cut -b2-)" + if test "$COB_CC" = ""; then + COB_CC="$($GREP COBC_CC info.out | cut -d: -f2 | cut -b2-)" + fi + COB_OBJECT_EXT="$($GREP COB_OBJECT_EXT info.out | cut -d: -f2 | cut -b2-)" COB_EXE_EXT=".exe" COB_MODULE_EXT="dll" - if test $(grep -i -c "little-endian" info.out) = 0; then + if test $($GREP -i -c "little-endian" info.out) = 0; then COB_BIGENDIAN="yes" else COB_BIGENDIAN="no" fi - COB_HAS_64_BIT_POINTER=$(grep "64bit-mode" info.out | cut -d: -f2 | cut -b2-) + COB_HAS_64_BIT_POINTER=$($GREP "64bit-mode" info.out | cut -d: -f2 | cut -b2-) - cob_indexed=$(grep -i "indexed file" info.out | cut -d: -f2) + cob_indexed=$($GREP -i "indexed file" info.out | cut -d: -f2) if test "x$cob_indexed" = "x"; then - cob_indexed=$(grep ISAM info.out | cut -d: -f2) + cob_indexed=$($GREP ISAM info.out | cut -d: -f2) fi case "$cob_indexed" in " disabled") COB_HAS_ISAM="no";; @@ -173,18 +201,18 @@ export COB_MSG_FORMAT *) echo "unknown entry for indexed handler: '"$cob_indexed"' please report" && exit 1;; esac - if test $(grep -i -c "XML library.*disabled" info.out) = 0; then + if test $($GREP -i -c "XML library.*disabled" info.out) = 0; then COB_HAS_XML2="yes" else COB_HAS_XML2="no" fi - if test $(grep -i -c "JSON library.*disabled" info.out) = 0; then + if test $($GREP -i -c "JSON library.*disabled" info.out) = 0; then COB_HAS_JSON="yes" else COB_HAS_JSON="no" fi # see note below - if test $(grep -i -c " screen .*disabled" info.out) = 0; then + if test $($GREP -i -c " screen .*disabled" info.out) = 0; then COB_HAS_CURSES="yes" else COB_HAS_CURSES="no" @@ -196,7 +224,7 @@ if test "x$MSYSTEM" != "x" -o "$OSTYPE" = "cygwin"; then # "Redirection is not supported" (at least with PDCurses "wincon" port) # --> disabling the tests for this feature # ncurses is known to work as long as TERM is appropriate - if test $(grep -i -c "ncurses" info.out) != 0; then + if test $($GREP -i -c "ncurses" info.out) != 0; then if test "x$MSYSTEM" != "x"; then TERM="" else @@ -207,7 +235,7 @@ if test "x$MSYSTEM" != "x" -o "$OSTYPE" = "cygwin"; then else # manual tests are executed in separate window # and are visible - so no need to handle it there - echo "$at_help_all" | grep -q "run_manual_screen" 2>/dev/null + echo "$at_help_all" | $GREP -q "run_manual_screen" 2>/dev/null if test $? -ne 0; then COB_HAS_CURSES="no" fi @@ -219,7 +247,7 @@ rm -rf info.out # NIST tests (tests/cobol85) are executed in a separate perl process with a new environment --> export needed export COB_HAS_ISAM COB_HAS_XML2 COB_HAS_JSON COB_HAS_CURSES COB_HAS_64_BIT_POINTER export COBC COBCRUN COBCRUN_DIRECT RUN_PROG_MANUAL -export COB_OBJECT_EXT COB_EXE_EXT COB_MODULE_EXT +export COB_CC COB_OBJECT_EXT COB_EXE_EXT COB_MODULE_EXT # to ensure that no external DB_HOME is polluted: unset DB_HOME="" && export DB_HOME diff --git a/tests/cobol85/ChangeLog b/tests/cobol85/ChangeLog index fa52b1d5f..9deb8f786 100644 --- a/tests/cobol85/ChangeLog +++ b/tests/cobol85/ChangeLog @@ -1,7 +1,12 @@ -2024-08-27 Nicolas Berthier <nicolas.berthier@ocamlpro.com> +2024-09-27 Simon Sobisch <simonsobisch@gnu.org> - * Makefile.am: stop downloading "newcob.val.Z" from out-dated URL + * summary.pl: compute total duration and modules executed, + output those to stderr at the end; close file handles + * Makefile.am (summary.out): new target depending on summary.log + * Makefile.am (summary.log): catch stderr of summary.pl into + summary.out file and output that on stdout + * Makefile.am (URL_NEWCOB_Z): replaced by web archive URL 2023-06-02 Simon Sobisch <simonsobisch@gnu.org> @@ -61,7 +66,7 @@ 2020-11-21 Simon Sobisch <simonsobisch@gnu.org> - * Makefil.module.in: don't pass additional params to atlocal + * Makefile.module.in: don't pass additional params to atlocal * report.pl: now exporting at_group for more useful valgrind log names 2020-10-16 Simon Sobisch <simonsobisch@gnu.org> @@ -400,7 +405,7 @@ * SQ.txt, summary.txt : We now pass the LINAGE tests -Copyright 2005-2010,2015-2020,2022-2023 Free Software Foundation, Inc. +Copyright 2005-2010,2015-2020,2022-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/tests/cobol85/Makefile.am b/tests/cobol85/Makefile.am index 1490ef85c..edc99d9be 100644 --- a/tests/cobol85/Makefile.am +++ b/tests/cobol85/Makefile.am @@ -1,7 +1,7 @@ # # Makefile gnucobol/tests/cobol85 # -# Copyright (C) 2002-2012, 2015-2023 Free Software Foundation, Inc. +# Copyright (C) 2002-2012, 2015-2024 Free Software Foundation, Inc. # Written by Keisuke Nishida, Roger While, Simon Sobisch # # This file is part of GnuCOBOL. @@ -24,22 +24,28 @@ RM = rm -rf -MODULES_ALL = NC SM IC SQ RL ST SG OB IF RW DB IX DBNOIX CM +MODULES_ALL = NC SQ IX IF ST IC RL SM SG OB DB DBNOIX RW CM # currently untested modules: CM +# note: MODULES should be kept in order to not change the order +# in the summary files; +# MODULES_RUN is kept in descending order of runtime duration +# to allow faster builds with multiple jobs if COB_MAKE_IX MODULES = NC SM IC SQ RL ST SG OB IF RW DB IX -MODULES_RUN = NC_RUN SM_RUN IC_RUN SQ_RUN RL_RUN \ - ST_RUN SG_RUN OB_RUN IF_RUN RW_RUN DB_RUN IX_RUN +MODULES_RUN = NC_RUN SQ_RUN IX_RUN IF_RUN ST_RUN \ + IC_RUN RL_RUN SM_RUN SG_RUN OB_RUN DB_RUN RW_RUN SUMMARY = summary.txt else MODULES = NC SM IC SQ RL ST SG OB IF RW DBNOIX -MODULES_RUN = NC_RUN SM_RUN IC_RUN SQ_RUN RL_RUN \ - ST_RUN SG_RUN OB_RUN IF_RUN RW_RUN DBNOIX_RUN +MODULES_RUN = NC_RUN SQ_RUN IX_RUN IF_RUN ST_RUN \ + IC_RUN RL_RUN SM_RUN SG_RUN OB_RUN DBNOIX_RUN RW_RUN SUMMARY = summarynoix.txt endif -URL_NEWCOB_Z = https://www.itl.nist.gov/div897/ctg/suites/newcob.val.Z +# currently down, leading to se<rver error with HTTPS, broken redirection on HTTP +#URL_NEWCOB_Z = https://www.itl.nist.gov/div897/ctg/suites/newcob.val.Z +URL_NEWCOB_Z = https://web.archive.org/web/20240322143655if_/https://www.itl.nist.gov/div897/ctg/suites/newcob.val.Z URL_NEWCOB_TAR_GZ = https://gnucobol.sourceforge.io/files/newcob.val.tar.gz EXTRA_DIST = EXEC85.conf.in expand.pl report.pl summary.pl summary.txt \ @@ -146,9 +152,12 @@ test-local-compat: # FIXME: as some make implementations don't support .PHONY (POSIX 2021) # and we don't need it: add all depdencies below (MODULES -> report.txt) # then remove the rm of the file below -summary.log: +summary.log: duration.log @echo "Computing total test results..." - @$(PERL) "$(srcdir)/summary.pl" $(MODULES) > $@ + @$(PERL) "$(srcdir)/summary.pl" $(MODULES) 1> $@ 2>summary.out + @cat summary.out + +summary.out: summary.log diff: @echo "Comparing test results for each module" @@ -169,13 +178,11 @@ diff-summary: @diff $(DIFF_FLAGS) "$(srcdir)/$(SUMMARY)" "summary.log" @echo Done -# Note: $(URL_NEWCOB_Z) is out-dated and simply grabs an HTML file -# without error. -# newcob.val.Z: -# @echo "Trying to download newcob.val.Z..." -# @(which curl 1>/dev/null && curl $(CURL_FLAGS) "$(URL_NEWCOB_Z)" -o $@) || \ -# wget $(WGET_FLAGS) "$(URL_NEWCOB_Z)" || \ -# ($(RM) $@; echo "Downloading $@ failed"; false) +newcob.val.Z: + @echo "Trying to download newcob.val.Z..." + @(which curl 1>/dev/null && curl $(CURL_FLAGS) "$(URL_NEWCOB_Z)" -o $@) || \ + wget $(WGET_FLAGS) "$(URL_NEWCOB_Z)" || \ + ($(RM) $@; echo "Downloading $@ failed"; false) newcob.val.tar.gz: @echo "Trying to download newcob.val.tar.gz..." diff --git a/tests/cobol85/summary.pl b/tests/cobol85/summary.pl index c51850b91..b3cbbe5c0 100755 --- a/tests/cobol85/summary.pl +++ b/tests/cobol85/summary.pl @@ -1,7 +1,7 @@ # # gnucobol/tests/cobol85/summary.pl # -# Copyright (C) 2002-2012, 2017, 2020 Free Software Foundation, Inc. +# Copyright (C) 2002-2012, 2017, 2020, 2024 Free Software Foundation, Inc. # Written by Keisuke Nishida, Roger While, Simon Sobisch # # This file is part of GnuCOBOL. @@ -35,23 +35,27 @@ my $total_insp = 0; my $total_total = 0; +my $duration = 0; +my $tested_modules = ""; + print ("------ Directory Information ------- --- Total Tests Information ---\n"); print ("Module Programs Executed Error Crash Pass Fail Deleted Inspect Total\n"); print ("------ -------- -------- ----- ----- ----- ---- ------- ------- -----\n"); my $module; while ($module = shift) { - open(IN, "$module/report.txt") or die; - my $test; - my $pass; - my $fail; - my $delete; - my $inspect; - my $progs; - my $executed; - my $error; - my $crash; + my $test; + my $pass; + my $fail; + my $delete; + my $inspect; + my $progs; + my $executed; + my $error; + my $crash; + + open(IN, "$module/report.txt") or die; while (<IN>) { if (/^Total *(\d+) *(\d+) *(\d+) *(\d+) *(\d+)/) { ($test, $pass, $fail, $delete, $inspect) = ($1, $2, $3, $4, $5); @@ -65,6 +69,8 @@ $crash = $1; } } + close(IN); + printf "%-6s %8d %8d %5d %5d %4d %4d %7d %7d %5d\n", $module, $progs, $executed, $error, $crash, $pass, $fail, $delete, $inspect, $test; @@ -77,10 +83,24 @@ $total_del += $delete; $total_insp += $inspect; $total_total += $test; + + $tested_modules = "$tested_modules$module "; + + open(IN, "$module/duration.txt") or die; + while (<IN>) { + if (/^Total *([\d.,]+)/) { + $duration += $1; + last; # Exit the loop once 'Total' is found + } + } + close(IN); } print ("------ -------- -------- ----- ----- ----- ---- ------- ------- -----\n"); printf "Total %8d %8d %5d %5d %5d %4d %7d %7d %5d\n", $total_progs, $total_executed, $total_error, $total_crash, $total_pass, $total_fail, $total_del, $total_insp, $total_total; -print STDERR "Total executed programs : $total_executed - Total performed tests : $total_total\n\n"; + +print STDERR "Total executed programs : $total_executed - Total performed tests : $total_total\n"; +print STDERR "Modules tested : $tested_modules\n"; +print STDERR "Total duration : $duration seconds\n\n"; diff --git a/tests/run_prog_manual.sh.in b/tests/run_prog_manual.sh.in index 982468ea1..dd063596e 100755 --- a/tests/run_prog_manual.sh.in +++ b/tests/run_prog_manual.sh.in @@ -2,7 +2,7 @@ # # run_prog_manual.sh gnucobol/tests # -# Copyright (C) 2014-2022 Free Software Foundation, Inc. +# Copyright (C) 2014-2022,2024 Free Software Foundation, Inc. # Written by Edward Hart, Simon Sobisch # # This file is part of GnuCOBOL. @@ -24,14 +24,40 @@ # code to the testsuite after the terminal ends. # You may change run_prog_manual.sh according to you needs, especially -# if you want to use a different terminal/terminal manager than xterm/screen -# or different options for these. - -abs_top_builddir="@abs_top_builddir@" - +# if you want to use a different test runner than the default ones. + +# test runner evaluation, you may want to override this in the +# generated file +case "$TESTRUNNER" in + xterm | screen | tmux | cmd) + # we do as instructed... + ;; + "") + if ( command -v xterm >/dev/null 2>&1) && test -n "$DISPLAY"; then + TESTRUNNER=xterm + elif command -v screen >/dev/null 2>&1; then + TESTRUNNER=screen + elif command -v tmux >/dev/null 2>&1; then + TESTRUNNER=tmux + elif test -n "$MSYSTEM"; then + TESTRUNNER=cmd + else + (>&2 echo "don't know which test runner to use, either install" + echo "one of the default supported ones (xterm, screen, tmux) or" + echo "adjust $0") + exit 1 + fi + ;; + *) + (>&2 echo "unknown test runner '""$TESTRUNNER""'") + exit 1 +esac + + +abs_builddir="@abs_builddir@" TIMEOUT=30 # timeout in seconds -if test ! -z "$MSYSTEM"; then +if test -n "$MSYSTEM"; then SLEEP_SCALE=1 # always possible, done in MSYS to reduce number of spawned processes else SLEEP_SCALE=0.1 # needs a "modern" sleep implementation @@ -43,33 +69,72 @@ TITLE="GnuCOBOL Manual Test Run - $DESC" _test_with_xterm () { xterm -T "$TITLE" \ -fa 'Liberation Mono' -fs 14 \ - -e "bash -c \"(\$COBCRUN_DIRECT $1 2>./syserr.log && echo \$? > ./result) || echo 1 > ./result\"" + -e "sh -c \"(\$* 2>./syserr.log && echo \$? > ./result) || echo 1 > ./result\"" } -# Note: when using screen manager you have to -# run `screen -r "GCTESTS"` in a separate terminal -# within 5 seconds after starting the tests +export SCREENDIR="${abs_builddir}/screen" + +# Note: when using the GNU screen manager you have to either call +# this script with the parameter "attach" or +# run `screen -r "GCTESTS"` with appropriate SCREENDIR +# in a separate terminal within 5 seconds after starting the tests _test_with_screen () { - # check if screen session already exists, setup if not - screen -S "GCTESTS" -X select . 2>/dev/null 1>&2 - if test $? -ne 0; then + test -d "$SCREENDIR" || mkdir -p -m 700 "$SCREENDIR" + # check if screen session already exists, setup if not + if ! screen -S "GCTESTS" -X select . 2>/dev/null 1>&2; then # Note: you may need to adjust screen's terminal to get an output matching the actual running code later - screen -dmS "GCTESTS" -t "$TITLE" + screen -dmS "GCTESTS" -t "GCTESTS" # we have a fresh environment there - source the test config once - screen -S "GCTESTS" -X stuff ". \"${abs_top_builddir}/tests/atconfig\" && . \"${abs_top_builddir}/tests/atlocal\" + screen -S "GCTESTS" -X stuff "cd \"${abs_builddir}\" && . atconfig && . atlocal; echo " sleep 5 fi # run actual test in screen session - screen -S "GCTESTS" -X title $"TITLE" - screen -S "GCTESTS" -X exec ... bash -c "cd \"$PWD\" && ($COBCRUN_DIRECT $* 2>./syserr.log && echo $? > ./result) || echo 1 > ./result" + screen -S "GCTESTS" -X title "$TITLE" + screen -S "GCTESTS" -X exec ... sh -c "cd \"$PWD\" && ($* 2>./syserr.log && echo $? > ./result) || echo 1 > ./result" +} +_attach_to_screen () { + test -d "$SCREENDIR" && (screen -r "GCTESTS" ; true) && exit + echo "no sessions with SCREENDIR='""$SCREENDIR""'" +} +_kill_screen () { + test -d "$SCREENDIR" && (screen -S "GCTESTS" -X kill ; rm -rf "$SCREENDIR") && exit + echo "no sessions with SCREENDIR='""$SCREENDIR""'" +} + + +# Note: when using the terminal multiplexer you have to either call +# this script with the parameter "attach" or +# run `tmux attach -t "=GCTESTS:0"` in a separate terminal +# within 5 seconds after starting the tests +_test_with_tmux () { + # check if tmux session already exists, setup if not + if ! tmux has-session -t "=GCTESTS" 2>/dev/null; then + # Note: you may need to adjust screen's terminal to get an output matching the actual running code later + tmux new-session -d -s "GCTESTS" + # we have a fresh environment there - source the test config once + tmux send-keys -t "=GCTESTS:0" "cd \"${abs_builddir}\" && . atconfig && . atlocal; echo" C-m + sleep 5 + fi + # run actual test in screen session + tmux rename-window -t "=GCTESTS:0" "$TITLE" + tmux send-keys -t "=GCTESTS:0" "sh -c \"cd \\\"$PWD\\\" && ($* 2>./syserr.log && echo $? > ./result) || echo 1 > ./result; echo\"" C-m +} +_attach_to_tmux () { + tmux attach -t "=GCTESTS:0" +} +_kill_tmux () { + tmux has-session -t "=GCTESTS" 2>/dev/null && (tmux kill-session -t "=GCTESTS:0") && exit + echo "no sessions named GCTESTS" } _test_with_cmd () { - # run cmd to start a detached cmd (via cmd's start), and execute the tests there - cmd.exe /c "start \"$TITLE\" /wait cmd /v:on /c \"$COBCRUN_DIRECT $(echo $* | tr '/' '\\') 2>syserr.log & echo !errorlevel! >result\"" + # run cmd to start a detached cmd (via cmd's start), and execute the tests there, + # to work around quoting issues we create a sub-cmd + echo "$(echo $* | tr '/' '\\') 2>syserr.log & echo !errorlevel! >result" > run_manual.cmd + cmd.exe /c "start \"$TITLE\" /wait cmd /v:on /c run_manual.cmd" #if test -f ./syserr.log; then # dos2unix -q ./syserr.log #fi @@ -89,22 +154,39 @@ _wait_result () { } -# actual test +# special run to attach / kill +if test "$1" = attach; then + case "$TESTRUNNER" in + screen) _attach_to_screen ;; + tmux) _attach_to_tmux ;; + *) echo "no need for external attach with test runner \"$TESTRUNNER\"" ;; + esac + exit +fi +if test "$1" = kill; then + case "$TESTRUNNER" in + screen) _kill_screen ;; + tmux) _kill_tmux ;; + *) echo "no need for external kill with test runner \"$TESTRUNNER\"" ;; + esac + exit +fi + +# actual test rm -f ./result ./syserr.log -if test ! -z "$DISPLAY"; then - _test_with_xterm $* || echo $? > ./result -elif test ! -z "$MSYSTEM"; then - _test_with_cmd $* || echo $? > ./result -else - _test_with_screen $* || echo $? > ./result -fi +case "$TESTRUNNER" in + xterm) _test_with_xterm $* || echo $? > ./result ;; + screen) _test_with_screen $* || echo $? > ./result ;; + tmux) _test_with_tmux $* || echo $? > ./result ;; + cmd) _test_with_cmd $* || echo $? > ./result ;; +esac _wait_result || { (>&2 echo "No result file after waiting for $TIMEOUT seconds!") - if test ! -z "$DISPLAY"; then - screen -S "GCTESTS" -X kill - fi + case "$TESTRUNNER" in + screen | tmux) $0 kill;; + esac echo 124 > ./result } if test -f ./syserr.log; then diff --git a/tests/testsuite.src/listings.at b/tests/testsuite.src/listings.at index 2a2fb68a6..26d90b67e 100644 --- a/tests/testsuite.src/listings.at +++ b/tests/testsuite.src/listings.at @@ -6913,7 +6913,8 @@ AT_CLEANUP AT_SETUP([Long concatenated literal]) AT_KEYWORDS([listing overflow]) -AT_DATA([prog.cob], [ +# extra quoting here as we received a bug report of something adding a leading ( +AT_DATA([prog.cob], [[ >>SOURCE FORMAT IS FREE ID DIVISION. PROGRAM-ID. ED000MAIN IS INITIAL. @@ -6935,10 +6936,11 @@ WORKING-STORAGE SECTION. "1234567890123456789012". PROCEDURE DIVISION. EXIT. -]) +]]) +# extra quoting here as we received a bug report of something adding a leading ( AT_CHECK([$COMPILE_LISTING0 -t- prog.cob], [0], -[GnuCOBOL V.R.P prog.cob +[[GnuCOBOL V.R.P prog.cob LINE PG/LN A...B............................................................ @@ -6980,7 +6982,7 @@ LINE PG/LN A...B............................................................ 0 warnings in compilation group 0 errors in compilation group -]) +]]) AT_CLEANUP diff --git a/tests/testsuite.src/run_file.at b/tests/testsuite.src/run_file.at index 11a491571..f7fbbfe8c 100644 --- a/tests/testsuite.src/run_file.at +++ b/tests/testsuite.src/run_file.at @@ -9102,7 +9102,6 @@ TSTFH (unsigned char *opCodep, FCD3 *fcd) static char * /* Return Text name of function */ txtOpCode(int opCode) { - static char tmp[32]; switch (opCode) { case OP_OPEN_INPUT: return "OPEN_IN"; case OP_OPEN_OUTPUT: return "OPEN_OUT"; @@ -9154,8 +9153,11 @@ txtOpCode(int opCode) case OP_WRITE_AFTER_TAB: return "WRITE_AFTER_TAB"; case OP_WRITE_AFTER_PAGE: return "WRITE_AFTER_PAGE"; } - sprintf(tmp, "Func 0x%02X:", opCode); - return tmp; + { + static char wrk[20]; + snprintf (wrk, sizeof(wrk), "Func 0x%02X", opCode); + return wrk; + } } ]]) @@ -12444,7 +12446,7 @@ AT_CLEANUP # This is, so far, only supported by the BDB backend -AT_SETUP([INDEXED files under ASCII/EBCDIC collation]) +AT_SETUP([INDEXED file under ASCII/EBCDIC collation]) AT_KEYWORDS([runfile WRITE DELETE READ EBCDIC]) AT_SKIP_IF([test "$COB_HAS_ISAM" != "db"]) @@ -12685,13 +12687,15 @@ CCC 888 +0000000043 1 DONE ]) +# Note: `-Wno-others` is for ignored COLLATIONS for non-alphanumeric keys + # Testing ASCII file collating sequence using clause AT_DATA([prog1.cob], [ COPY "prog.cpy" REPLACING ==FILE-COLSEQ== BY ==COLLATING SEQUENCE IS ASCII== ==KEY-COLSEQ== BY ====. ]) -AT_CHECK([$COMPILE -Wno-unfinished prog1.cob], [0], [], []) +AT_CHECK([$COMPILE -Wno-unfinished -Wno-others prog1.cob], [0], [], []) AT_CHECK([$COBCRUN_DIRECT ./prog1 1>prog1.out], [0], [], []) AT_CHECK([diff reference_ascii prog1.out], [0], [], []) @@ -12712,7 +12716,7 @@ AT_DATA([prog3.cob], [ ==FILE-COLSEQ== BY ==COLLATING SEQUENCE IS ASCII== ==KEY-COLSEQ== BY ==COLLATING SEQUENCE OF MY-AKEY1 IS EBCDIC==. ]) -AT_CHECK([$COMPILE -Wno-unfinished prog3.cob], [0], [], []) +AT_CHECK([$COMPILE -Wno-unfinished -Wno-others prog3.cob], [0], [], []) AT_CHECK([$COBCRUN_DIRECT ./prog3 1>prog3.out], [0], [], []) AT_CHECK([diff reference_ascii_ebcdic prog3.out], [0], [], []) @@ -12732,7 +12736,7 @@ AT_DATA([prog5.cob], [ ==FILE-COLSEQ== BY ==COLLATING SEQUENCE IS EBCDIC== ==KEY-COLSEQ== BY ==COLLATING SEQUENCE OF MY-AKEY1 IS EBCDIC==. ]) -AT_CHECK([$COMPILE -Wno-unfinished prog5.cob], [0], [], []) +AT_CHECK([$COMPILE -Wno-unfinished -Wno-others prog5.cob], [0], [], []) AT_CHECK([$COBCRUN_DIRECT ./prog5 1>prog5.out], [0], [], []) AT_CHECK([diff reference_ebcdic prog5.out], [0], [], []) @@ -12742,7 +12746,7 @@ AT_DATA([prog6.cob], [ ==FILE-COLSEQ== BY ==== ==KEY-COLSEQ== BY ====. ]) -AT_CHECK([$COMPILE -Wno-unfinished -fdefault-file-colseq=EBCDIC prog6.cob], [0], [], []) +AT_CHECK([$COMPILE -Wno-unfinished -Wno-others -fdefault-file-colseq=EBCDIC prog6.cob], [0], [], []) AT_CHECK([$COBCRUN_DIRECT ./prog6 1>prog6.out], [0], [], []) AT_CHECK([diff reference_ebcdic prog6.out], [0], [], []) @@ -12752,7 +12756,7 @@ AT_DATA([prog7.cob], [ ==FILE-COLSEQ== BY ==COLLATING SEQUENCE IS EBCDIC== ==KEY-COLSEQ== BY ==COLLATING SEQUENCE OF MY-AKEY1 IS ASCII==. ]) -AT_CHECK([$COMPILE -Wno-unfinished prog7.cob], [0], [], []) +AT_CHECK([$COMPILE -Wno-unfinished -Wno-others prog7.cob], [0], [], []) AT_CHECK([$COBCRUN_DIRECT ./prog7 1>prog7.out], [0], [], []) AT_CHECK([diff reference_ebcdic_ascii prog7.out], [0], [], []) @@ -12762,13 +12766,156 @@ AT_DATA([prog8.cob], [ ==FILE-COLSEQ== BY ==== ==KEY-COLSEQ== BY ==COLLATING SEQUENCE OF MY-AKEY1 IS ASCII==. ]) -AT_CHECK([$COMPILE -Wno-unfinished -fdefault-file-colseq=EBCDIC prog8.cob], [0], [], []) +AT_CHECK([$COMPILE -Wno-unfinished -Wno-others -fdefault-file-colseq=EBCDIC prog8.cob], [0], [], []) AT_CHECK([$COBCRUN_DIRECT ./prog8 1>prog8.out], [0], [], []) AT_CHECK([diff reference_ebcdic_ascii prog8.out], [0], [], []) AT_CLEANUP +AT_SETUP([INDEXED file with collation on group key]) +AT_KEYWORDS([runfile WRITE READ EBCDIC]) + +AT_SKIP_IF([test "$COB_HAS_ISAM" = "no"]) + +# This is, so far, only supported by the BDB backend +AT_XFAIL_IF([test "$COB_HAS_ISAM" != "db"]) + +AT_DATA([prog.cob], [ + IDENTIFICATION DIVISION. + PROGRAM-ID. prog. + ENVIRONMENT DIVISION. + INPUT-OUTPUT SECTION. + FILE-CONTROL. + SELECT MY-FILE ASSIGN TO "testfile" + ORGANIZATION IS INDEXED + ACCESS IS DYNAMIC + RECORD KEY IS MY-KEY. + DATA DIVISION. + FILE SECTION. + FD MY-FILE. + 01 MY-REC. + 05 MY-KEY. + 10 MY-KEY-1 PIC X. + 10 MY-KEY-2 PIC X. + 05 MY-DATA PIC 9. + PROCEDURE DIVISION. + + OPEN OUTPUT MY-FILE + MOVE "111" TO MY-REC WRITE MY-REC + MOVE "AA2" TO MY-REC WRITE MY-REC + MOVE "223" TO MY-REC WRITE MY-REC + MOVE "BB4" TO MY-REC WRITE MY-REC + MOVE "335" TO MY-REC WRITE MY-REC + MOVE "CC6" TO MY-REC WRITE MY-REC + MOVE "447" TO MY-REC WRITE MY-REC + MOVE "DD8" TO MY-REC WRITE MY-REC + CLOSE MY-FILE + + OPEN INPUT MY-FILE + MOVE LOW-VALUES TO MY-KEY + START MY-FILE KEY >= MY-KEY + INVALID KEY + DISPLAY "INVALID KEY" + NOT INVALID KEY + PERFORM UNTIL EXIT + READ MY-FILE NEXT + AT END + EXIT PERFORM + NOT AT END + DISPLAY MY-REC + END-READ + END-PERFORM + END-START. + CLOSE MY-FILE + + STOP RUN. +]) + +AT_DATA([expout], +[ASCII: +111 +223 +335 +447 +AA2 +BB4 +CC6 +DD8 +EBCDIC: +AA2 +BB4 +CC6 +DD8 +111 +223 +335 +447 +]) + +# Note: ignore any unfinished warning as the test is about the runtime behavior: +AT_CHECK([$COMPILE -Wno-unfinished -fdefault-file-colseq=ASCII prog.cob -o ascii], [0]) +AT_CHECK([$COMPILE -Wno-unfinished -fdefault-file-colseq=EBCDIC prog.cob -o ebcdic], [0]) + +AT_CHECK([ + echo "ASCII:" && $COBCRUN_DIRECT ./ascii && \ + echo "EBCDIC:" && $COBCRUN_DIRECT ./ebcdic +], [0], [expout]) # <- compare stdout with existing `expout` + +AT_CLEANUP + + +# Note: codegen only for now +AT_SETUP([INDEXED file with NATIONAL collation]) +AT_KEYWORDS([runfile]) + +AT_SKIP_IF([test "$COB_HAS_ISAM" = "no"]) + +AT_DATA([prog.cob], [ + IDENTIFICATION DIVISION. + PROGRAM-ID. prog. + ENVIRONMENT DIVISION. + INPUT-OUTPUT SECTION. + FILE-CONTROL. + SELECT MY-FILE ASSIGN TO "testfile" + ORGANIZATION IS INDEXED + ACCESS IS DYNAMIC + RECORD KEY IS MY-KEY + COLLATING SEQUENCE FOR NATIONAL IS ASCII. + DATA DIVISION. + FILE SECTION. + FD MY-FILE. + 01 MY-REC. + 05 MY-KEY PIC N. + 05 MY-DATA PIC 9. + PROCEDURE DIVISION. + + OPEN OUTPUT MY-FILE + MOVE "11" TO MY-REC WRITE MY-REC + MOVE "A2" TO MY-REC WRITE MY-REC + MOVE "23" TO MY-REC WRITE MY-REC + MOVE "B4" TO MY-REC WRITE MY-REC + MOVE "35" TO MY-REC WRITE MY-REC + MOVE "C6" TO MY-REC WRITE MY-REC + MOVE "47" TO MY-REC WRITE MY-REC + MOVE "D8" TO MY-REC WRITE MY-REC + CLOSE MY-FILE + + STOP RUN. +]) + +AT_DATA([expout], []) + +# Note: ignore any unfinished warning as the test is about the runtime behavior: +AT_CHECK([$COMPILE -Wno-unfinished prog.cob], [0], [], +[prog.cob:11: warning: NATIONAL COLLATING SEQUENCE is not implemented +]) + +AT_CHECK([$COBCRUN_DIRECT ./prog], [0], [expout]) + +AT_CLEANUP + + AT_SETUP([INDEXED file numeric keys ordering]) AT_KEYWORDS([runfile]) diff --git a/tests/testsuite.src/run_manual_screen.at b/tests/testsuite.src/run_manual_screen.at index 8d64a5e15..a5ed5cb19 100644 --- a/tests/testsuite.src/run_manual_screen.at +++ b/tests/testsuite.src/run_manual_screen.at @@ -1138,7 +1138,7 @@ AT_DATA([prog.cob], [ 77 CMAGENTA PIC 9(05) COMP-5 VALUE 6. 77 CYELLOW PIC 9(05) COMP-5 VALUE 7. 77 CWHITE PIC 9(05) COMP-5 VALUE 8. - + 77 LIN PIC 99 COMP-5. 01 scr1 PIC X(80) @@ -1248,7 +1248,7 @@ AT_DATA([prog.cob], [[ & "BCOLOR=BLACK,". 77 CWHITE PIC X(99) VALUE "FCOLOR=WHITE, " & "BCOLOR=BLACK, ". - + 77 LIN PIC 99 COMP-5. 01 scr1 PIC X(75) @@ -1300,7 +1300,7 @@ AT_DATA([prog.cob], [[ * ADD 2 TO LIN PERFORM dspcol - MOVE "REVERSE," TO + MOVE "REVERSE," TO CBLACK (40:), CBLUE (40:), CGREEN (40:), CCYAN (40:), CRED (40:), CMAGENTA (40:), CYELLOW (40:), CWHITE (40:) ADD 1 TO LIN @@ -1312,12 +1312,12 @@ AT_DATA([prog.cob], [[ ADD 1 TO LIN DISPLAY scr9 AT LINE LIN COL 2 * - MOVE "HIGHLIGHT,NO REVERSE" TO + MOVE "HIGHLIGHT,NO REVERSE" TO CBLACK (50:), CBLUE (50:), CGREEN (50:), CCYAN (50:), CRED (50:), CMAGENTA (50:), CYELLOW (50:), CWHITE (50:) ADD 1 TO LIN PERFORM dspcol - MOVE "NO HIGH, BLINK" TO + MOVE "NO HIGH, BLINK" TO CBLACK (60:), CBLUE (60:), CGREEN (60:), CCYAN (60:), CRED (60:), CMAGENTA (60:), CYELLOW (60:), CWHITE (60:) MOVE 12 TO LIN @@ -1359,7 +1359,7 @@ AT_DATA([prog.cob], [[ WORKING-STORAGE SECTION. 01 success-flag PIC X VALUE 'Y'. 88 success VALUE 'Y', 'y'. - + 77 LIN-START PIC 99 COMP-5. 77 LIN PIC 99 COMP-5. @@ -3600,3 +3600,70 @@ AT_CHECK([$COMPILE prog.cob], [0], [], []) MANUAL_CHECK([$COBCRUN_DIRECT ./prog], [0], [], []) AT_CLEANUP + + +AT_SETUP([CURSOR position in line 1]) +AT_KEYWORDS([screen]) + +AT_SKIP_IF([test "$COB_HAS_CURSES" != "yes"]) + +AT_DATA([prog.cob], [ + IDENTIFICATION DIVISION. + PROGRAM-ID. PROG. + ENVIRONMENT DIVISION. + CONFIGURATION SECTION. + SPECIAL-NAMES. + CURSOR IS CURSOR-POSITION. + + DATA DIVISION. + + WORKING-STORAGE SECTION. + + 01 CURSOR-POSITION. + 05 CSR-ROW-NUMBER PIC 9(03) VALUE 001. + 05 CSR-COL-NUMBER PIC 9(03) VALUE 005. + + 01 WORK-FIELDS. + 05 IN-ID PIC X(09) VALUE SPACES. + 05 TRAN-ID PIC X(03) VALUE 'ABC'. + + 01 SUCCESS-FLAG PIC X VALUE 'Y'. + 88 SUCCESS VALUE 'y', 'Y'. + + SCREEN SECTION. + + 01 EMPLOYEE-SCREEN + BACKGROUND-COLOR IS 0 + FOREGROUND-COLOR IS 7. + + 05 LINE 01 COL 01 AUTO PIC X(03) USING + TRAN-ID. + 05 LINE 01 COL 04 PIC X(01) VALUE + ','. + 05 LINE 01 COL 05 AUTO PIC X(09) USING + IN-ID. + + 05 LINE 5 VALUE 'cursor should be ' + & 'at line 1 and column 5'. + 05 LINE 6 VALUE 'go to line 10 ' + & 'and enter an "y" or "n" '. + 05 LINE 10 PIC X, REQUIRED USING success-flag. + + PROCEDURE DIVISION. + + DISPLAY EMPLOYEE-SCREEN. + ACCEPT EMPLOYEE-SCREEN. + + IF SUCCESS AND COB-CRT-STATUS = 0 + GOBACK RETURNING 0 + ELSE + GOBACK RETURNING 1 + END-IF. + +]) + +AT_CHECK([$COMPILE prog.cob], [0], [], []) +MANUAL_CHECK([$COBCRUN_DIRECT ./prog], [0], [], []) + +AT_CLEANUP + diff --git a/tests/testsuite.src/run_misc.at b/tests/testsuite.src/run_misc.at index 210a28758..cd7cf27e6 100644 --- a/tests/testsuite.src/run_misc.at +++ b/tests/testsuite.src/run_misc.at @@ -1172,6 +1172,40 @@ AT_CHECK([$COBCRUN_DIRECT ./prog2], [1], [], AT_CLEANUP +AT_SETUP([MOVE of invalid data from numeric to alphanumeric item]) +AT_KEYWORDS([runmisc]) + +AT_DATA([prog.cob], [ + PROGRAM-ID. prog. + DATA DIVISION. + WORKING-STORAGE SECTION. + 77 X-NUM PIC 9. + 77 X-ALN REDEFINES X-NUM PIC X. + 77 Y-ALN PIC X. + 77 Z-NUM PIC +9,9. + 77 Z-ALN REDEFINES Z-NUM PIC XX. + 77 T-ALN PIC XX. + PROCEDURE DIVISION. + MAIN. + MOVE SPACES TO X-ALN + MOVE X-NUM TO Y-ALN + IF Y-ALN NOT EQUAL " " THEN + DISPLAY "Y-ALN: '" Y-ALN "' (' ' EXPECTED)" + END-IF + MOVE SPACES TO Z-ALN + MOVE Z-NUM TO T-ALN + IF T-ALN NOT EQUAL " " THEN + DISPLAY "T-ALN: '" T-ALN "' (' ' EXPECTED)" + END-IF + STOP RUN. +]) + +AT_CHECK([$COMPILE prog.cob], [0], [], []) +AT_CHECK([$COBCRUN_DIRECT ./prog], [0], [], []) + +AT_CLEANUP + + ## CALL statement AT_SETUP([Dynamic call with static linking]) @@ -11832,7 +11866,6 @@ AT_DATA([cmod.c], [[ static char * getType (int type, int byvalue) { - static char wrk[24]; switch (type) { #if 1 case COB_TYPE_GROUP: return "Group"; @@ -11863,28 +11896,30 @@ getType (int type, int byvalue) case COB_TYPE_NATIONAL: return "N"; #endif } - sprintf (wrk,"Type %04X",type); - return wrk; + { + static char wrk[20]; + snprintf (wrk, sizeof(wrk), "Type 0x%04X", type); + return wrk; + } } COB_EXT_EXPORT int CAPI (void *p1, ...) { - int k,nargs,type,digits,scale,size,sign,byvalue; - cob_s64_t val = 0; - char *str; - char wrk[80],pic[30]; /* note: maximum _theoretical_ size */ + char wrk[80], pic[30]; /* note: maximum _theoretical_ size */ + const int nargs = cob_get_num_params(); + int k; + cob_s64_t val = 0; - nargs = cob_get_num_params(); printf ("CAPI called with %d parameters\n",nargs); - fflush(stdout); + fflush (stdout); for (k=1; k <= nargs; k++) { - type = cob_get_param_type (k); - digits = cob_get_param_digits (k); - scale = cob_get_param_scale (k); - size = cob_get_param_size (k); - sign = cob_get_param_sign (k); - byvalue = cob_get_param_constant(k); + int type = cob_get_param_type (k); + int digits = cob_get_param_digits (k); + int scale = cob_get_param_scale (k); + int size = cob_get_param_size (k); + int sign = cob_get_param_sign (k); + int byvalue = cob_get_param_constant(k); printf (" %d: %-8s ", k, getType (type, byvalue)); if (byvalue) { printf ("BY VALUE "); @@ -11892,27 +11927,31 @@ CAPI (void *p1, ...) printf ("BY REFERENCE "); } if (type == COB_TYPE_ALPHANUMERIC) { - sprintf (pic, "X(%d)", size); - str = cob_get_picx_param (k, NULL, 0); + char *str = cob_get_picx_param (k, NULL, 0); + snprintf (pic, sizeof(pic), "X(%d)", size); printf ("%-11s '%s'", pic, str); cob_free ((void*)str); cob_put_picx_param (k, "Bye!"); } else if (type == COB_TYPE_NATIONAL) { - sprintf (pic, "N(%d)", size); /* FIXME */ + snprintf (pic, sizeof(pic), "N(%d)", size); /* FIXME */ printf ("exchange of national data is not supported yet"); } else if (type == COB_TYPE_GROUP) { - sprintf (pic, "(%d)", size); - str = cob_get_grp_param (k, NULL, 0); + char *str = cob_get_grp_param (k, NULL, 0); + snprintf (pic, sizeof(pic), "(%d)", size); printf ("%-11s '%.*s'", pic, size, str); cob_free ((void*)str); - memset (wrk,' ',sizeof(wrk)); - memcpy (wrk,"Bye-Bye Birdie!",15); + memset (wrk, ' ',sizeof(wrk)); + memcpy (wrk, "Bye-Bye Birdie!", 15); cob_put_grp_param (k, wrk, sizeof(wrk)); } else if (type == COB_TYPE_NUMERIC_EDITED) { if (scale > 0) { - sprintf (pic,"%s9(%d)V9(%d)",sign?"S":"",digits-scale,scale); + snprintf (pic, sizeof(pic), "%s9(%d)V9(%d)", + sign ? "S":"", + digits - scale, scale); } else { - sprintf (pic,"%s9(%d)",sign?"S":"",digits-scale); + snprintf (pic, sizeof(pic), "%s9(%d)", + sign ? "S":"", + digits - scale); } val = cob_get_s64_param (k); printf ("%-11s %lld ",pic,val); @@ -11923,9 +11962,13 @@ CAPI (void *p1, ...) printf (" to %.*s",size,wrk); } else { if(scale > 0) { - sprintf (pic,"%s9(%d)V9(%d)",sign?"S":"",digits-scale,scale); + snprintf (pic, sizeof(pic), "%s9(%d)V9(%d)", + sign ? "S":"", + digits - scale, scale); } else { - sprintf (pic,"%s9(%d)",sign?"S":"",digits-scale); + snprintf (pic, sizeof(pic), "%s9(%d)", + sign ? "S":"", + digits - scale); } val = cob_get_s64_param (k); printf ("%-11s %lld", pic, val); @@ -12012,7 +12055,7 @@ AT_CLEANUP AT_SETUP([C-API (field based)]) -AT_KEYWORDS([runmisc CALL api]) +AT_KEYWORDS([runmisc CALL api field]) AT_DATA([prog.cob], [ IDENTIFICATION DIVISION. @@ -12068,7 +12111,6 @@ AT_DATA([cmod.c], [[ static char * getType (int type, int byvalue) { - static char wrk[24]; switch (type) { #if 1 case COB_TYPE_GROUP: return "Group"; @@ -12099,73 +12141,82 @@ getType (int type, int byvalue) case COB_TYPE_NATIONAL: return "N"; #endif } - sprintf (wrk,"Type %04X",type); - return wrk; + { + static char wrk[20]; + snprintf (wrk, sizeof(wrk), "Type 0x%04X", type); + return wrk; + } } COB_EXT_EXPORT int CAPI (void *p1, ...) { - int k,nargs,type,digits,scale,size,sign,byvalue; - cob_s64_t val; - char *str; - char wrk[80],pic[30]; /* note: maximum _theoretical_ size */ + char wrk[80],pic[30]; /* note: maximum _theoretical_ size */ + const int nargs = cob_get_num_params(); + int k; - nargs = cob_get_num_params(); printf ("CAPI called with %d parameters\n",nargs); - fflush(stdout); + fflush (stdout); for (k=1; k <= nargs; k++) { cob_field *fld = cob_get_param_field (k, "CAPI"); - type = cob_get_field_type (fld); - digits = cob_get_field_digits (fld); - scale = cob_get_field_scale (fld); - size = cob_get_field_size (fld); - sign = cob_get_field_sign (fld); - byvalue = cob_get_field_constant (fld); + char *str = (char *) cob_get_field_str_buffered (fld); + int type = cob_get_field_type (fld); + int digits = cob_get_field_digits (fld); + int scale = cob_get_field_scale (fld); + int size = cob_get_field_size (fld); + int sign = cob_get_field_sign (fld); + int byvalue = cob_get_field_constant (fld); printf (" %d: %-8s ", k, getType (type, byvalue)); if (byvalue) { printf ("BY VALUE "); } else { printf ("BY REFERENCE "); } - str = (char *) cob_get_field_str_buffered (fld); if (type == COB_TYPE_ALPHANUMERIC) { - sprintf (pic, "X(%d)", size); + snprintf (pic, sizeof(pic), "X(%d)", size); printf ("%-11s '%s'", pic, str); cob_put_field_str (fld, "Bye!"); } else if (type == COB_TYPE_NATIONAL) { - sprintf (pic,"N(%d)",size); /* FIXME */ + snprintf (pic, sizeof(pic), "N(%d)", size); /* FIXME */ printf ("exchange of national data is not supported yet"); } else if (type == COB_TYPE_GROUP) { - sprintf (pic,"(%d)",size); + snprintf (pic, sizeof(pic), "(%d)",size); printf ("%-11s '%.*s'",pic,size,str); cob_put_field_str (fld, "Bye-Bye Birdie!"); } else if (type == COB_TYPE_NUMERIC_EDITED) { + cob_s64_t val = cob_get_s64_param (k); if (scale > 0) { - sprintf (pic,"%s9(%d)V9(%d)",sign?"S":"",digits-scale,scale); + snprintf (pic, sizeof(pic), "%s9(%d)V9(%d)", + sign ? "S":"", + digits - scale, scale); } else { - sprintf (pic,"%s9(%d)",sign?"S":"",digits-scale); + snprintf (pic, sizeof(pic), "%s9(%d)", + sign ? "S":"", + digits - scale); } printf ("%-11s %s ",pic,str); - val = cob_get_s64_param (k); val = val + 130; val = -val; cob_put_s64_param (k, val); str = (char *) cob_get_field_str (fld, wrk, 78); printf (" to %.*s",size,wrk); } else { + cob_s64_t val = cob_get_s64_param (k); if(scale > 0) { - sprintf (pic,"%s9(%d)V9(%d)",sign?"S":"",digits-scale,scale); + snprintf (pic, sizeof(pic), "%s9(%d)V9(%d)", + sign ? "S":"", + digits - scale, scale); } else { - sprintf (pic,"%s9(%d)",sign?"S":"",digits-scale); + snprintf (pic, sizeof(pic), "%s9(%d)", + sign ? "S":"", + digits - scale); } printf ("%-11s %s", pic, str); - val = cob_get_s64_param (k); - sprintf (wrk, "%lld", val + 3); + snprintf (wrk, sizeof(wrk), "%lld", val + 3); cob_put_field_str (fld, wrk); } printf (";\n"); - fflush(stdout); + fflush (stdout); } return 0; } diff --git a/tests/testsuite.src/syn_definition.at b/tests/testsuite.src/syn_definition.at index 33889dd69..5f43cdc3e 100644 --- a/tests/testsuite.src/syn_definition.at +++ b/tests/testsuite.src/syn_definition.at @@ -2878,3 +2878,72 @@ prog.cob:6: error: 'DEPTHDR' is not defined AT_CLEANUP + +AT_SETUP([POINTER TO typedef-name]) +AT_KEYWORDS([POINTER TYPEDEF]) + +AT_DATA([prog.cob], [ + IDENTIFICATION DIVISION. + PROGRAM-ID. prog. + DATA DIVISION. + WORKING-STORAGE SECTION. + 01 data-type PIC X(10) USAGE DISPLAY IS TYPEDEF. + 01 data-ptr1 USAGE POINTER data-type. + 01 data-ptr2 USAGE POINTER TO data-type. + PROCEDURE DIVISION. + STOP RUN. + END PROGRAM prog. +]) + +AT_CHECK([$COMPILE_ONLY -Wno-pending prog.cob], [0], [], []) +AT_CLEANUP + + +AT_SETUP([FUNCTION-POINTER TO function-name]) +AT_KEYWORDS([FUNCTION-POINTER]) + +AT_DATA([prog.cob], [ + IDENTIFICATION DIVISION. + PROGRAM-ID. prog. + DATA DIVISION. + WORKING-STORAGE SECTION. + 01 fun-ptr1 USAGE FUNCTION-POINTER FUNCTION random. + 01 fun-ptr2 USAGE FUNCTION-POINTER TO FUNCTION random. + PROCEDURE DIVISION. + STOP RUN. + END PROGRAM prog. +]) + +AT_CHECK([$COMPILE_ONLY -Wno-pending prog.cob], [0], [], []) +AT_CLEANUP + + +AT_SETUP([PROGRAM-POINTER TO program-prototype]) +AT_KEYWORDS([PROGRAM-POINTER PROTOTYPE]) + +# currently fails -> investigate +AT_XFAIL_IF([true]) + +AT_DATA([prog.cob], [ + IDENTIFICATION DIVISION. + + PROGRAM-ID. prog-proto IS PROTOTYPE. + PROCEDURE DIVISION. + END PROGRAM prog-proto. + + PROGRAM-ID. prog. + ENVIRONMENT DIVISION. + CONFIGURATION SECTION. + REPOSITORY. + PROGRAM prog-proto. + DATA DIVISION. + WORKING-STORAGE SECTION. + 01 prog-ptr1 USAGE PROGRAM-POINTER prog-proto. + 01 prog-ptr2 USAGE PROGRAM-POINTER TO prog-proto. + PROCEDURE DIVISION. + STOP RUN. + END PROGRAM prog. +]) + +AT_CHECK([$COMPILE_ONLY -Wno-unfinished prog.cob], [0], [], []) +AT_CLEANUP diff --git a/tests/testsuite.src/syn_file.at b/tests/testsuite.src/syn_file.at index 24c1f835f..1f43f9025 100644 --- a/tests/testsuite.src/syn_file.at +++ b/tests/testsuite.src/syn_file.at @@ -631,7 +631,7 @@ AT_CLEANUP AT_SETUP([INDEXED file invalid key items]) -AT_KEYWORDS([record ALTERNATE split]) +AT_KEYWORDS([record ALTERNATE split collation]) AT_DATA([prog.cob], [ IDENTIFICATION DIVISION. @@ -658,6 +658,32 @@ AT_DATA([prog.cob], [ RECORD KEY IS NOT-HERE-KEY SOURCE IS NOT-IN-FILE1 NOT-IN-FILE2. + SELECT TEST-CSQ1 ASSIGN TO 'FILE-TEST-COSQ1' + ORGANIZATION IS INDEXED + ACCESS MODE IS DYNAMIC + RECORD KEY IS TEST-P5 + ALTERNATE KEY IS TEST-P6 + ALTERNATE KEY IS TEST-P7 + COLLATING SEQUENCE IS EBCDIC + COLLATING SEQUENCE OF TEST-P7 IS EBCDIC. + SELECT TEST-CSQ2 ASSIGN TO 'FILE-TEST-COSQ2' + ORGANIZATION IS INDEXED + ACCESS MODE IS DYNAMIC + RECORD KEY IS TEST-P8 + COLLATING SEQUENCE IS EBCDIC *> unused + COLLATING SEQUENCE OF TEST-P8 IS EBCDIC. + SELECT TEST-CSQ3 ASSIGN TO 'FILE-TEST-COSQ3' + ORGANIZATION IS INDEXED + ACCESS MODE IS DYNAMIC + RECORD KEY IS SPLIT-KEY1 = TEST-P9 TEST-P10 + ALTERNATE KEY IS SPLIT-KEY2 = TEST-P9 TEST-P11 + COLLATING SEQUENCE IS EBCDIC *> should not warn + COLLATING SEQUENCE OF SPLIT-KEY2 IS EBCDIC.*> should not warn + SELECT TEST-CSQ4 ASSIGN TO 'FILE-TEST-COSQ4' + ORGANIZATION IS INDEXED + ACCESS MODE IS DYNAMIC + RECORD KEY IS SPLIT-KEY3 = TEST-P12 + COLLATING SEQUENCE OF SPLIT-KEY1 IS EBCDIC. DATA DIVISION. FILE SECTION. FD TEST-SOME. @@ -670,6 +696,23 @@ AT_DATA([prog.cob], [ FD TEST-MORE. 01 MORE-REC. 05 MORE-DATA PIC X(4). + FD TEST-CSQ1. + 01 CSQ1-REC. + 05 TEST-P5 PIC 9(2) BINARY. + 05 TEST-P6 PIC 9(2) BINARY. + 05 TEST-P7 PIC X(2). + FD TEST-CSQ2. + 01 CSQ2-REC. + 05 TEST-P8 PIC 9(2) BINARY. + 05 TEST-P8X PIC X(2). + FD TEST-CSQ3. + 01 CSQ3-REC. + 05 TEST-P9 PIC 9(2) BINARY. + 05 TEST-P10 PIC 9(2) BINARY. + 05 TEST-P11 PIC X(2). + FD TEST-CSQ4. + 01 CSQ4-REC. + 05 TEST-P12 PIC 9(2) BINARY. WORKING-STORAGE SECTION. 77 TEST-P2 PIC S9(4) COMP. 77 TEST-P3 PIC S9(5) COMP-3. @@ -681,13 +724,23 @@ AT_DATA([prog.cob], [ # FIXME: "is not defined" should be changed in "is not defined in file ..." AT_CHECK([$COMPILE_ONLY prog.cob], [1], [], -[prog.cob:10: error: 'TEST-P2' is not defined +[prog.cob:32: warning: handling of FILE COLLATING SEQUENCE is unfinished; implementation is likely to be changed +prog.cob:33: warning: handling of KEY COLLATING SEQUENCE is unfinished; implementation is likely to be changed +prog.cob:38: warning: handling of FILE COLLATING SEQUENCE is unfinished; implementation is likely to be changed +prog.cob:39: warning: handling of KEY COLLATING SEQUENCE is unfinished; implementation is likely to be changed +prog.cob:45: warning: handling of FILE COLLATING SEQUENCE is unfinished; implementation is likely to be changed +prog.cob:46: warning: handling of KEY COLLATING SEQUENCE is unfinished; implementation is likely to be changed +prog.cob:51: warning: handling of KEY COLLATING SEQUENCE is unfinished; implementation is likely to be changed +prog.cob:10: error: 'TEST-P2' is not defined prog.cob:11: error: 'TEST-P1' is not defined prog.cob:12: error: 'TEST-P3' is not defined prog.cob:18: error: 'NOT-THERE' is not defined prog.cob:13: error: invalid KEY item 'SOME-REC', not in file 'TEST-FILE' prog.cob:24: error: 'NOT-IN-FILE1' is not defined prog.cob:20: error: invalid KEY item 'NOT-HERE-KEY', not in file 'TEST-MORE' +prog.cob:66: warning: FILE COLLATING SEQUENCE 'EBCDIC' is ignored for non-alphanumeric key 'TEST-P5' +prog.cob:67: warning: FILE COLLATING SEQUENCE 'EBCDIC' is ignored for non-alphanumeric key 'TEST-P6' +prog.cob:39: warning: KEY COLLATING SEQUENCE 'EBCDIC' is ignored for non-alphanumeric key 'TEST-P8' prog.cob:25: error: 'NOT-IN-FILE2' is not defined ]) diff --git a/tests/testsuite.src/syn_functions.at b/tests/testsuite.src/syn_functions.at index 53735c571..27f3e2773 100644 --- a/tests/testsuite.src/syn_functions.at +++ b/tests/testsuite.src/syn_functions.at @@ -582,10 +582,11 @@ AT_DATA([prog.cob], [ . ]) +# extra quoting here as we received a bug report of something adding a leading ( AT_CHECK([$COMPILE -Wno-pending prog.cob], [1], [], -[prog.cob:7: error: syntax error, unexpected Literal, expecting PHYSICAL or ) +[[prog.cob:7: error: syntax error, unexpected Literal, expecting PHYSICAL or ) prog.cob:8: error: a non-numeric literal is expected here prog.cob:9: error: a non-numeric literal is expected here -]) +]]) AT_CLEANUP diff --git a/tests/testsuite.src/syn_misc.at b/tests/testsuite.src/syn_misc.at index 6a4107e7d..06e8f75c0 100644 --- a/tests/testsuite.src/syn_misc.at +++ b/tests/testsuite.src/syn_misc.at @@ -7559,7 +7559,7 @@ AT_DATA([prog.cob], [ AT_CAPTURE_FILE([prog.c]) AT_CHECK([COBC_GEN_DUMP_COMMENTS=1 \ - $COMPILE -C -fdump=all -w prog.cob], [0], []) + $COMPILE -C -fdump -w prog.cob], [0], []) # TODO: only execute this piece when extended $GREP works AT_CHECK([($GREP -A 200 "P_dump:" prog.c | $GREP -B 200 "END OF DUMP") || exit 77], [0], [ P_dump: diff --git a/tests/testsuite.src/used_binaries.at b/tests/testsuite.src/used_binaries.at index 50d8a1867..405c48d0f 100644 --- a/tests/testsuite.src/used_binaries.at +++ b/tests/testsuite.src/used_binaries.at @@ -279,30 +279,6 @@ AT_CHECK([$GREP 'PARAGRAPH_00_l_4:' prog.c], [0], ignore, []) AT_CHECK([$GREP 'PARAGRAPH_EX_l_7:' prog.c], [0], ignore, []) AT_CHECK([$COBCRUN_DIRECT ./prog], [0], [bluBb END], []) -AT_CAPTURE_FILE([prog.d]) -AT_CHECK([$COBC -I sub/copy prog.cob -ext=cpy -o prog.i -MF prog.d -MT "prog.c prog.h" -MT prog$COB_EXE_EXT -MT prog.$COB_OBJECT_EXT -MT prog.i -fsyntax-only], [0], [], []) -AT_CHECK([$GREP 'prog.c prog.h ' prog.d], [0], ignore, []) -AT_CHECK([$GREP ' prog.i:' prog.d], [0], ignore, []) -AT_CHECK([$GREP 'sub/copy/PROC.cpy' prog.d], [0], ignore, [], [ - # Previous test "failed" --> no entry with slash available, check backslash for this and following tests - AT_CHECK([$GREP ' sub\\copy\\PROC.cpy \\' prog.d], [0], ignore, []) - AT_CHECK([$GREP ' sub\\PROCE.cpy' prog.d], [0], ignore, []) - AT_CHECK([$GREP 'sub\\copy\\PROC.cpy:' prog.d], [0], ignore, []) - AT_CHECK([$GREP 'sub\\PROCE.cpy:' prog.d], [0], ignore, []) -], [ - AT_CHECK([$GREP ' sub/copy/PROC.cpy \\' prog.d], [0], ignore, []) - AT_CHECK([$GREP ' sub/PROCE.cpy' prog.d], [0], ignore, []) - AT_CHECK([$GREP 'sub/copy/PROC.cpy:' prog.d], [0], ignore, []) - AT_CHECK([$GREP 'sub/PROCE.cpy:' prog.d], [0], ignore, []) -]) - -# test again with trailing slash which should not result in different files -AT_CHECK([$COBC -I sub/copy/ prog.cob -ext=cpy -o prog.i -MF prog.d -MT "prog.c prog.h" -MT prog$COB_EXE_EXT -MT prog.$COB_OBJECT_EXT -MT prog.i -fsyntax-only], [0], [], []) -AT_CHECK([$GREP 'sub/copy/PROC.cpy' prog.d], [0], ignore, [], [ - # Previous test "failed" --> no entry with slash available, check backslash for this test - AT_CHECK([$GREP 'sub\\copy\\PROC.cpy' prog.d], [0], ignore, []) -]) - AT_CLEANUP @@ -383,9 +359,8 @@ AT_CLEANUP AT_SETUP([temporary path invalid]) AT_KEYWORDS([cobc runmisc]) -# Note: may be either removed completely as there was a report about -# this test "failing" - or skipped as this very often fails for -# WIN32 builds +# Note: we skip this as it often fails for WIN32 builds but sometimes works +AT_SKIP_IF([test "$COB_ON_WINDOWS" = "yes"]) AT_DATA([prog.cob], [ IDENTIFICATION DIVISION. @@ -972,6 +947,10 @@ AT_CHECK([cat prog.cob | $COMPILE -], [0], [], [], ) AT_CHECK([$COBCRUN_DIRECT ./a.out], [0], [], []) +AT_CHECK([echo "program-id.test." | $COMPILE_MODULE -free -E -], [0], +[#line 1 "<stdin>" +program-id.test. +], []) AT_CLEANUP @@ -1172,3 +1151,298 @@ AT_CHECK([$COMPILE_MODULE -Wno-unfinished --copy "f.copy" -fstatic-call prog2.co ) AT_CLEANUP + + +AT_SETUP([output dependencies]) +# AT_KEYWORDS([]) + +AT_CAPTURE_FILE([compiler.output]) + +AT_DATA([prog.cob], [ + IDENTIFICATION DIVISION. + PROGRAM-ID. prog. + DATA DIVISION. + WORKING-STORAGE SECTION. + COPY COPY1. + PROCEDURE DIVISION. + MAIN-PROC SECTION. + 00. + COPY COPY3. + COPY COPY3.CPY. + END-PROC SECTION. + COPY COPY4 in "sub". + EX. + STOP RUN. +]) + +AT_DATA([prog2.cob], [ + IDENTIFICATION DIVISION. + PROGRAM-ID. prog2. + PROCEDURE DIVISION. + COPY COPY3. + STOP RUN. +]) + + +AT_CHECK([mkdir -p sub]) +AT_DATA([COPY1.CPY], [ COPY COPY2. +]) +AT_DATA([COPY2.CPY], []) +AT_DATA([COPY3.CPY], [ DISPLAY "Hello". +]) +AT_DATA([sub/COPY4.CPY], []) + +AT_CHECK([$COMPILE prog.cob]) + +AT_CHECK([$COMPILE -M prog.cob prog2.cob > compiler.output], [0]) +AT_CHECK([$SED "s/\.$COB_OBJECT_EXT:/.COB_OBJECT_EXT:/g;s/sub\\\\/sub\//g" compiler.output], [0], +[prog.COB_OBJECT_EXT: \ + prog.cob \ + COPY1.CPY \ + COPY2.CPY \ + COPY3.CPY \ + sub/COPY4.CPY + +prog2.COB_OBJECT_EXT: \ + prog2.cob \ + COPY3.CPY + +]) + +AT_CHECK([$COMPILE -M -MF prog.dep prog.cob]) +AT_CHECK([$SED "s/\.$COB_OBJECT_EXT/.COB_OBJECT_EXT/g;s/sub\\\\/sub\//g" prog.dep], [0], +[prog.COB_OBJECT_EXT: \ + prog.cob \ + COPY1.CPY \ + COPY2.CPY \ + COPY3.CPY \ + sub/COPY4.CPY + +]) + +AT_CHECK([$COMPILE -M -fcopybook-deps prog.cob > compiler.output], [0]) +AT_CHECK([$SED "s/\.$COB_OBJECT_EXT/.COB_OBJECT_EXT/g;s/sub\\\\/sub\//g" compiler.output], [0], +[prog.COB_OBJECT_EXT: COPY1 COPY2 COPY3 COPY3.CPY sub/COPY4 + +]) + +AT_CHECK([$COMPILE -g -M -MT prog.$COB_MODULE_EXT prog.cob > compiler.output], [0]) +AT_CHECK([$SED "s/\.$COB_MODULE_EXT/.COB_MODULE_EXT/g;s/sub\\\\/sub\//g" compiler.output], [0], +[prog.COB_MODULE_EXT: \ + prog.cob \ + COPY1.CPY \ + COPY2.CPY \ + COPY3.CPY \ + sub/COPY4.CPY + +]) + +AT_CHECK([test -f prog.c], [1]) +AT_CHECK([test -f prog.o], [1]) + +AT_CHECK([$COMPILE -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 \ + COPY2.CPY \ + COPY3.CPY \ + sub/COPY4.CPY + +]) + +AT_CHECK([rm -f prog.d]) +AT_CAPTURE_FILE([prog.d]) + +AT_CHECK([$COMPILE -MD prog.cob]) +AT_CHECK([$SED "s/\.$COB_OBJECT_EXT/.COB_OBJECT_EXT/g;s/sub\\\\/sub\//g" prog.d], [0], +[prog.COB_OBJECT_EXT: \ + prog.cob \ + COPY1.CPY \ + COPY2.CPY \ + COPY3.CPY \ + sub/COPY4.CPY + +]) + +AT_CHECK([$COMPILE -MD -o sub/prog.exe prog.cob]) +AT_CHECK([test -f sub/prog.exe]) +AT_CHECK([$SED "s/\.$COB_OBJECT_EXT/.COB_OBJECT_EXT/g;s/sub\\\\/sub\//g" sub/prog.d], [0], +[prog.COB_OBJECT_EXT: \ + prog.cob \ + COPY1.CPY \ + COPY2.CPY \ + COPY3.CPY \ + sub/COPY4.CPY + +]) + +AT_CHECK([rm sub/COPY4.CPY]) + +AT_CHECK([$COMPILE -M prog.cob > compiler.output 2> compiler.error], [1], [], []) +AT_CHECK([$SED "s/\.$COB_OBJECT_EXT/.COB_OBJECT_EXT/g" compiler.output], [0], +[prog.COB_OBJECT_EXT: \ + prog.cob \ + COPY1.CPY \ + COPY2.CPY \ + COPY3.CPY + +]) + +AT_CHECK([$SED "s/sub\\\\/sub\//g" compiler.error], [0], +[prog.cob:13: error: sub/COPY4: No such file or directory +]) + +AT_CHECK([$COMPILE_ONLY -M -MG prog.cob > compiler.output], [0]) +AT_CHECK([$SED "s/\.$COB_OBJECT_EXT/.COB_OBJECT_EXT/g;s/sub\\\\/sub\//g" compiler.output], [0], +[prog.COB_OBJECT_EXT: \ + prog.cob \ + COPY1.CPY \ + COPY2.CPY \ + COPY3.CPY \ + sub/COPY4.CPY + +]) + +AT_DATA([prog.cob], [ + IDENTIFICATION DIVISION. + PROGRAM-ID. prog. + DATA DIVISION. + WORKING-STORAGE SECTION. + 01 BLA PIC X(5) VALUE 'bluBb'. + PROCEDURE DIVISION. + MAIN-PROC SECTION. + 00. + COPY PROC. + END-PROC SECTION. + COPY PROCE in "sub". + EX. + STOP RUN. +]) + +AT_CHECK([mkdir -p sub/copy]) +AT_DATA([sub/copy/PROC.cpy], [ + DISPLAY BLA NO ADVANCING. +]) +AT_DATA([sub/PROCE.cpy], [ + DISPLAY ' END' NO ADVANCING. +]) + +AT_CAPTURE_FILE([prog.d]) +AT_CHECK([$COBC -I sub/copy prog.cob -ext=cpy -o prog.i -M -MP -MF prog.d -MT "prog.c prog.h" -MT prog$COB_EXE_EXT -MT prog.$COB_OBJECT_EXT -MT prog.i -fsyntax-only]) +AT_CHECK([$GREP 'prog.c prog.h ' prog.d], [0], [ignore]) +AT_CHECK([$GREP ' prog.i:' prog.d], [0], [ignore]) +AT_CHECK([$GREP 'sub/copy/PROC.cpy' prog.d], [0], [ignore], [], [ + # Previous test "failed" --> no entry with slash available, check backslash for this and following tests + AT_CHECK([$GREP ' sub\\copy\\PROC.cpy \\' prog.d], [0], [ignore]) + AT_CHECK([$GREP ' sub\\PROCE.cpy' prog.d], [0], [ignore]) + AT_CHECK([$GREP 'sub\\copy\\PROC.cpy:' prog.d], [0], [ignore]) + AT_CHECK([$GREP 'sub\\PROCE.cpy:' prog.d], [0], [ignore]) +], [ + AT_CHECK([$GREP ' sub/copy/PROC.cpy \\' prog.d], [0], [ignore]) + AT_CHECK([$GREP ' sub/PROCE.cpy' prog.d], [0], [ignore]) + AT_CHECK([$GREP 'sub/copy/PROC.cpy:' prog.d], [0], [ignore]) + AT_CHECK([$GREP 'sub/PROCE.cpy:' prog.d], [0], [ignore]) +]) + +# test again with trailing slash which should not result in different files +AT_CHECK([$COBC -I sub/copy/ prog.cob -ext=cpy -o prog.i -M -MP -MF prog.d -MT "prog.c prog.h" -MT prog$COB_EXE_EXT -MT prog.$COB_OBJECT_EXT -MT prog.i -fsyntax-only]) +AT_CHECK([$GREP 'sub/copy/PROC.cpy' prog.d], [0], [ignore], [], [ + # Previous test "failed" --> no entry with slash available, check backslash for this test + AT_CHECK([$GREP 'sub\\copy\\PROC.cpy' prog.d], [0], [ignore]) +]) + +AT_CLEANUP + + +AT_SETUP([signal handling SIGPIPE cobc]) +AT_KEYWORDS([runmisc]) + +# the runtime is not initialized, so we get out without any error message in libcob +# and we also don't raise anything in cobc either +AT_CHECK([$COBC --help | head], [0], [ignore], []) + +AT_CLEANUP + + +AT_SETUP([signal handling SIGPIPE in COBOL]) +AT_KEYWORDS([runmisc]) + +AT_DATA([prog.cob], [ + IDENTIFICATION DIVISION. + PROGRAM-ID. prog. + PROCEDURE DIVISION. + 00. DISPLAY '1'. DISPLAY '2'. DISPLAY '3'. DISPLAY '4'. + DISPLAY '5'. DISPLAY '6'. DISPLAY '7'. DISPLAY '8'. + EX. STOP RUN. +]) + +AT_CHECK([$COMPILE prog.cob], [0], [], []) +AT_CHECK([$COBCRUN_DIRECT ./prog | head -n 2], [0], +[1 +2 +], []) + +AT_CLEANUP + + +AT_SETUP([signal handling SIGTERM in COBOL]) +AT_KEYWORDS([runmisc stack stacktrace]) + +# this is portable in all posix environments, but not on Win32; +# note: cygwin-compiled programs handle cygwin-sent SIGTERM as expected +# CTRL+C does raise a SIGINT, but only when executed from "within" the program +AT_XFAIL_IF([test "$COB_ON_WINDOWS" = "yes"]) + +AT_DATA([prog.cob], [ + IDENTIFICATION DIVISION. + PROGRAM-ID. 'prog'. + PROCEDURE DIVISION. + 00. DISPLAY '1'. + CALL 'wait'. DISPLAY '2'. + EX. STOP RUN. + END PROGRAM 'prog'. + IDENTIFICATION DIVISION. + PROGRAM-ID. 'wait'. + PROCEDURE DIVISION. + 00. PERFORM DO-WAIT. + EX. GOBACK. + DO-WAIT. CONTINUE AFTER 10 SECONDS. + END PROGRAM 'wait'. +]) + +AT_CHECK([$COMPILE prog.cob], [0], [], []) + +# note: the stack trace, while enabled per default, is globally disabled in the testsuite +AT_CHECK([$COBCRUN_DIRECT ./prog & cobpid=$! +sleep 6 +kill -15 $cobpid], [0], +[1 +], +[ +prog.cob:14: termination (signal SIGTERM) + +]) +AT_CHECK([COB_STACKTRACE=1 $COBCRUN_DIRECT ./prog a "b c" & cobpid=$! +sleep 6 +kill -15 $cobpid], [0], +[1 +], +[ +prog.cob:14: termination (signal SIGTERM) + + + Last statement of "wait" was CONTINUE AFTER + DO-WAIT at prog.cob:14 + 00 at prog.cob:12 + ENTRY wait at prog.cob:12 + Last statement of "prog" was CALL + 00 at prog.cob:6 + ENTRY prog at prog.cob:5 + Started by ./prog + a + b c +]) + +AT_CLEANUP +