Skip to content

Commit

Permalink
Add case LINE SEQUENTIAL FILE
Browse files Browse the repository at this point in the history
  • Loading branch information
n-isaka committed May 9, 2024
1 parent 6536bc9 commit a8c7c4f
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions libcob/fileio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1909,9 +1909,17 @@ cob_file_open (cob_file *f, char *filename,
switch (mode) {
case COB_OPEN_INPUT:
if (!cobsetptr->cob_unix_lf) {
fmode = "r";
if (f->lock_mode & COB_LOCK_EXCLUSIVE) {
fmode = "r+";
} else {
fmode = "r";
}
} else {
fmode = "rb";
if (f->lock_mode & COB_LOCK_EXCLUSIVE) {
fmode = "rb+";
} else {
fmode = "rb";
}
}
break;
case COB_OPEN_OUTPUT:
Expand Down Expand Up @@ -2014,7 +2022,7 @@ cob_file_open (cob_file *f, char *filename,
if (fp && memcmp (filename, "/dev/", (size_t)5)) {
struct flock lock;
memset ((void *)&lock, 0, sizeof (struct flock));
if (mode != COB_OPEN_INPUT) {
if ((mode != COB_OPEN_INPUT) || (f->lock_mode & COB_LOCK_EXCLUSIVE)) {
lock.l_type = F_WRLCK;
} else {
lock.l_type = F_RDLCK;
Expand Down

0 comments on commit a8c7c4f

Please sign in to comment.