delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1997/03/17/07:30:09

Date: Mon, 17 Mar 1997 13:15:59 +0100 (MET)
From: Robert Hoehne <robert DOT hoehne AT mathematik DOT tu-chemnitz DOT de>
To: DJGPP workers <djgpp-workers AT delorie DOT com>
Subject: Patch fro lock.c and unlock.c
Message-Id: <Pine.HPP.3.95q.970317131321.21742E-100000@newton.mathematik.tu-chemnitz.de>
Mime-Version: 1.0

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019