Skip to content

Update fileio.c #228

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: gcos4gnucobol-3.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 69 additions & 1 deletion .gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,20 @@ tasks:
# sudo apt install texlive-base # for make dist (doc/gnucobol.pdf)
gp sync-done system-prepare

- name: building GnuCOBOL
- name: preparing GnuCOBOL
init: |
mkdir -p $GITPOD_REPO_ROOTS/build
cd $GITPOD_REPO_ROOTS/build
gp sync-await system-prepare
../autogen.sh
command: |
cd $GITPOD_REPO_ROOTS/build
gp sync-done prepare-finish

- name: building GnuCOBOL
init: |
cd $GITPOD_REPO_ROOTS/build
gp sync-await prepare-finish
../configure --enable-cobc-internal-checks --enable-debug --enable-code-coverage \
CC="gcc -std=c89" CPPFLAGS="-Werror=declaration-after-statement"
bear -- make --jobs=$(nproc)
Expand All @@ -35,13 +43,16 @@ tasks:
cd $GITPOD_REPO_ROOTS/build
half_jobs=$(( $(nproc) / 2 ))
nice make --jobs=${half_jobs} check-code-coverage TESTSUITEFLAGS="--jobs=${half_jobs}"
gp sync-done test-finish

- name: running NIST85 tests
command: |
gp sync-await build-finish
cd $GITPOD_REPO_ROOTS/build
half_jobs=$(( $(nproc) / 2 ))
nice make -C tests/cobol85 --jobs=${half_jobs} test
gp sync-done test85-finish


# disabled as running that is really onbly useful after several adjustments
#- name: running GnuCOBOL distribution tests with testuite
Expand All @@ -51,6 +62,63 @@ tasks:
# half_jobs=$(( $(nproc) / 2 ))
# nice make --jobs=${half_jobs} distcheck TESTSUITEFLAGS="--jobs=${half_jobs}"


- name: building VISAM
init: |
mkdir -p $GITPOD_REPO_ROOTS/../isam
cd $GITPOD_REPO_ROOTS/..
curl -LO http://inglenet.ca/Products/GnuCOBOL/vbisam-2.2.tar.Z
tar -xvzf vbisam-2.2.tar.Z -C isam --strip-components=1

# curl -L https://sourceforge.net/projects/vbisam/files/vbisam2/vbisam-2.0.tar.gz/download -o vbisam-2.0.tar.gz
# tar -xvzf vbisam-2.0.tar.gz -C isam --strip-components=1
# sed -i s'/long long/off_t/' isam/vbisam.h

cd isam
gp sync-await system-prepare
./configure CFLAGS="-fstack-protector-strong -fstack-clash-protection -ggdb3 -fasynchronous-unwind-tables" \
LDFLAGS="-fstack-protector-strong -fstack-clash-protection" \
CPPFLAGS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2" --enable-debug
bear -- make --jobs=$(nproc)
sudo make install
command: |
gp sync-await prepare-finish
cd $GITPOD_REPO_ROOTS/../isam
gp sync-done build-finish-isam

- name: building GnuCOBOL (ISAM)
init: |
mkdir -p $GITPOD_REPO_ROOTS/build-isam
cd $GITPOD_REPO_ROOTS/build-isam
gp sync-await build-finish-isam
../configure --enable-cobc-internal-checks --enable-debug --with-vbisam \
CC="gcc -std=c89" CPPFLAGS="-Werror=declaration-after-statement" \
LIBCOB_LIBS=-Wl,-rpath,/usr/local/lib
bear -- make --jobs=$(nproc)
command: |
gp sync-await build-finish-isam
cd $GITPOD_REPO_ROOTS/build-isam
gp sync-done build-finish-isam

- name: running GnuCOBOL tests (ISAM)
command: |
gp sync-await build-finish-isam
cd $GITPOD_REPO_ROOTS/build-isam
gp sync-await test-finish
half_jobs=$(( $(nproc) / 2 ))
nice make --jobs=${half_jobs} check TESTSUITEFLAGS="--jobs=${half_jobs}"
echo expected result in GnuCOBOL 3.x on GNU/Linux x86_64 with both RJN's VBISAM 2.2
echo and with RWs VBISAM 2.0 (+ patch to set vbisam_off_t to off_t):
echo 894 971 972 failed, 953 954 955 956 957 passed unexpectedly

- name: running NIST85 tests (ISAM)
command: |
gp sync-await build-finish-isam
cd $GITPOD_REPO_ROOTS/build-isam
gp sync-await test85-finish
half_jobs=$(( $(nproc) / 2 ))
nice make -C tests/cobol85 --jobs=${half_jobs} test

vscode:
extensions:
- llvm-vs-code-extensions.vscode-clangd
Expand Down
7 changes: 6 additions & 1 deletion libcob/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@

2025-05-10 Simon Sobisch <[email protected]>

* fileio.c (indexed_open) [WITH_ANY_ISAM]: slightly improve error handling,
including partial hand-merge of changes from GC4

2024-12-31 Simon Sobisch <[email protected]>

* common.c [WITH_EXTENDED_SCREENIO]: adjusted curses includes/defines
Expand Down Expand Up @@ -6592,7 +6597,7 @@ after suggestions by Chuck Haatvedt <[email protected]>
* call.c, common.c, move.c, Makefile.am: gettextized


Copyright 2002-2024 Free Software Foundation, Inc.
Copyright 2002-2025 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.
42 changes: 31 additions & 11 deletions libcob/fileio.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (C) 2002-2012, 2014-2024 Free Software Foundation, Inc.
Copyright (C) 2002-2012, 2014-2025 Free Software Foundation, Inc.
Written by Keisuke Nishida, Roger While, Simon Sobisch, Ron Norman

This file is part of GnuCOBOL.
Expand Down Expand Up @@ -4393,19 +4393,39 @@ indexed_open (cob_file *f, char *filename,
}
isfd = isbuild ((void *)filename, (int)f->record_max, &fh->key[0],
vmode | ISINOUT | ISEXCLLOCK);
#if 0 /* activate on later merge of locking enhancements */
f->flag_file_lock = 1;
#endif
if (ISERRNO == EEXIST

if (isfd < 0) {
if (ISERRNO == EFLOCKED) {
return COB_STATUS_61_FILE_SHARING;
}
if ((ISERRNO == EEXIST || ISERRNO == EBADARG)
#if 1 /* CHECKME: guard added by Simon, needed ? */
&& omode == ISOUTPUT
&& omode == ISOUTPUT
#endif
&& isfd < 0) {
/* Erase file and redo the 'isbuild' */
iserase ((void *)filename);
isfd = isbuild ((void *)filename, (int)f->record_max, &fh->key[0],
) {
/* Erase file and redo the 'isbuild' */
#if 0 /* TODO: activate on later merge of delete refactoring */
isam_file_delete (a, f, filename);
#else
iserase ((void *)filename);
#endif
#ifdef ISVARLEN
if (f->record_min != f->record_max) {
ISRECLEN = f->record_min;
}
#endif
ISERRNO = 0;
isfd = isbuild ((void *)filename, (int)f->record_max, &fh->key[0],
vmode | ISINOUT | ISEXCLLOCK);
#if 0 /* activate on later merge of locking enhancements */
#if 0 /* TODO: activate on later merge of locking enhancements */
f->flag_file_lock = 1;
#endif
}
/* TODO: more checks in case isfd < 0,
allowing better io status than 30,
possibly setting extended error to ISERNO */
#if 0 /* TODO: activate on later merge of locking enhancements */
} else {
f->flag_file_lock = 1;
#endif
}
Expand Down
Loading