Mail Archives: djgpp-workers/1997/03/17/07:30:09
During my work for a program, which should run even on
a network, I found a little bug in lock() and unlock().
The problem is the wrong error code in errno and I think
that the patch explains it enough.
*** src/libc/dos/io/lock.c~ Sat Apr 1 23:18:18 1995
--- src/libc/dos/io/lock.c Sun Mar 16 22:32:24 1997
***************
*** 1,17 ****
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#include <io.h>
#include <errno.h>
int
lock(int fd, long offset, long length)
{
int ret = _dos_lock(fd, offset, length);
/* change return code because Borland does it this way */
if (ret == 0x21)
ret = EACCES;
if (ret != 0)
{
! errno = ret;
return -1;
}
else
--- 1,20 ----
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#include <io.h>
#include <errno.h>
+ #include <libc/dosio.h>
int
lock(int fd, long offset, long length)
{
int ret = _dos_lock(fd, offset, length);
+ #if 0 /* __doserr_to_errno does the same */
/* change return code because Borland does it this way */
if (ret == 0x21)
ret = EACCES;
+ #endif
if (ret != 0)
{
! errno = __doserr_to_errno(ret);
return -1;
}
else
*** src/libc/dos/io/unlock.c~ Sat Apr 1 23:18:18 1995
--- src/libc/dos/io/unlock.c Sun Mar 16 22:32:08 1997
***************
*** 1,17 ****
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#include <io.h>
#include <errno.h>
int
unlock(int fd, long offset, long length)
{
int ret = _dos_unlock(fd, offset, length);
/* change return code because Borland does it this way */
if (ret == 0x21)
ret = EACCES;
if (ret != 0)
{
! errno = ret;
return -1;
}
else
--- 1,20 ----
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#include <io.h>
#include <errno.h>
+ #include <libc/dosio.h>
int
unlock(int fd, long offset, long length)
{
int ret = _dos_unlock(fd, offset, length);
+ #if 0 /* __doserr_to_errno does the same */
/* change return code because Borland does it this way */
if (ret == 0x21)
ret = EACCES;
+ #endif
if (ret != 0)
{
! errno = __doserr_to_errno(ret);
return -1;
}
else
Robert
- Raw text -