Skip to content

Commit 948e175

Browse files
committed
minor improve for xISAM error handling
* libcob/fileio.c (indexed_open) [WITH_ANY_ISAM]: slightly improve error handling, including partial hand-merge of changes from GC4
1 parent 0999419 commit 948e175

2 files changed

Lines changed: 37 additions & 12 deletions

File tree

libcob/ChangeLog

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11

2+
2025-05-10 Simon Sobisch <simonsobisch@gnu.org>
3+
4+
* fileio.c (indexed_open) [WITH_ANY_ISAM]: slightly improve error handling,
5+
including partial hand-merge of changes from GC4
6+
27
2024-12-31 Simon Sobisch <simonsobisch@gnu.org>
38

49
* common.c [WITH_EXTENDED_SCREENIO]: adjusted curses includes/defines
@@ -6592,7 +6597,7 @@ after suggestions by Chuck Haatvedt <chuck.haatvedt+cobol@gmail.com>
65926597
* call.c, common.c, move.c, Makefile.am: gettextized
65936598

65946599

6595-
Copyright 2002-2024 Free Software Foundation, Inc.
6600+
Copyright 2002-2025 Free Software Foundation, Inc.
65966601

65976602
Copying and distribution of this file, with or without modification, are
65986603
permitted provided the copyright notice and this notice are preserved.

libcob/fileio.c

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (C) 2002-2012, 2014-2024 Free Software Foundation, Inc.
2+
Copyright (C) 2002-2012, 2014-2025 Free Software Foundation, Inc.
33
Written by Keisuke Nishida, Roger While, Simon Sobisch, Ron Norman
44
55
This file is part of GnuCOBOL.
@@ -4393,19 +4393,39 @@ indexed_open (cob_file *f, char *filename,
43934393
}
43944394
isfd = isbuild ((void *)filename, (int)f->record_max, &fh->key[0],
43954395
vmode | ISINOUT | ISEXCLLOCK);
4396-
#if 0 /* activate on later merge of locking enhancements */
4397-
f->flag_file_lock = 1;
4398-
#endif
4399-
if (ISERRNO == EEXIST
4396+
4397+
if (isfd < 0) {
4398+
if (ISERRNO == EFLOCKED) {
4399+
return COB_STATUS_61_FILE_SHARING;
4400+
}
4401+
if ((ISERRNO == EEXIST || ISERRNO == EBADARG)
44004402
#if 1 /* CHECKME: guard added by Simon, needed ? */
4401-
&& omode == ISOUTPUT
4403+
&& omode == ISOUTPUT
44024404
#endif
4403-
&& isfd < 0) {
4404-
/* Erase file and redo the 'isbuild' */
4405-
iserase ((void *)filename);
4406-
isfd = isbuild ((void *)filename, (int)f->record_max, &fh->key[0],
4405+
) {
4406+
/* Erase file and redo the 'isbuild' */
4407+
#if 0 /* TODO: activate on later merge of delete refactoring */
4408+
isam_file_delete (a, f, filename);
4409+
#else
4410+
iserase ((void *)filename);
4411+
#endif
4412+
#ifdef ISVARLEN
4413+
if (f->record_min != f->record_max) {
4414+
ISRECLEN = f->record_min;
4415+
}
4416+
#endif
4417+
ISERRNO = 0;
4418+
isfd = isbuild ((void *)filename, (int)f->record_max, &fh->key[0],
44074419
vmode | ISINOUT | ISEXCLLOCK);
4408-
#if 0 /* activate on later merge of locking enhancements */
4420+
#if 0 /* TODO: activate on later merge of locking enhancements */
4421+
f->flag_file_lock = 1;
4422+
#endif
4423+
}
4424+
/* TODO: more checks in case isfd < 0,
4425+
allowing better io status than 30,
4426+
possibly setting extended error to ISERNO */
4427+
#if 0 /* TODO: activate on later merge of locking enhancements */
4428+
} else {
44094429
f->flag_file_lock = 1;
44104430
#endif
44114431
}

0 commit comments

Comments
 (0)