delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1997/05/25/11:20:53

Date: Sun, 25 May 1997 18:20:14 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: djgpp-workers AT delorie DOT com
cc: DJ Delorie <dj AT delorie DOT com>
Subject: Re: Dynamic pathconf?
Message-ID: <Pine.SUN.3.91.970525181613.6865A-100000@is>
MIME-Version: 1.0

The previous patch to `pathconf' didn't look at $LFN in the environment, 
and so would cause a program that used its info to fail when LFN is set 
to N on Windows 95.  This patch (relative to original v2.01 sources) 
corrects that bug:

*** src/libc/posix/unistd/pathconf.c~0	Sun Apr  2 00:25:52 1995
--- src/libc/posix/unistd/pathconf.c	Sun May 25 17:37:36 1997
***************
*** 1,8 ****
--- 1,14 ----
+ /* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */
  /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
  #include <errno.h>
+ #include <stdlib.h>
+ #include <ctype.h>
  #include <unistd.h>
+ #include <fcntl.h>
  #include <limits.h>
  
+ #define TOLOWER(c) (isascii(c) && isupper(c) ? tolower (c) : (c))
+ 
  long
  pathconf(const char *path, int name)
  {
*************** pathconf(const char *path, int name)
*** 11,18 ****
    case _PC_LINK_MAX:		return LINK_MAX;
    case _PC_MAX_CANON:		return MAX_CANON;
    case _PC_MAX_INPUT:		return MAX_INPUT;
!   case _PC_NAME_MAX:		return NAME_MAX;
!   case _PC_PATH_MAX:		return PATH_MAX;
    case _PC_PIPE_BUF:		return PIPE_BUF;
    case _PC_CHOWN_RESTRICTED:	return _POSIX_CHOWN_RESTRICTED;
    case _PC_NO_TRUNC:		return _POSIX_NO_TRUNC;
--- 17,40 ----
    case _PC_LINK_MAX:		return LINK_MAX;
    case _PC_MAX_CANON:		return MAX_CANON;
    case _PC_MAX_INPUT:		return MAX_INPUT;
!   case _PC_NAME_MAX: case _PC_PATH_MAX:
!     {
!       int name_max, path_max;
!       int e = errno;
!       char *lfnenv = getenv ("LFN");
! 
!       if (!lfnenv || TOLOWER (*lfnenv) != 'n')
! 	{
! 	  errno = 0;
! 	  _get_volume_info (path, &name_max, &path_max, 0);
! 	  if (!errno)
! 	    {
! 	      errno = e;
! 	      return (name == _PC_NAME_MAX) ? name_max : path_max;
! 	    }
! 	}
!       return (name == _PC_NAME_MAX) ? NAME_MAX : PATH_MAX;
!     }
    case _PC_PIPE_BUF:		return PIPE_BUF;
    case _PC_CHOWN_RESTRICTED:	return _POSIX_CHOWN_RESTRICTED;
    case _PC_NO_TRUNC:		return _POSIX_NO_TRUNC;

- Raw text -


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