Date: Wed, 12 Mar 1997 09:37:30 +0100 (MET) From: Robert Hoehne To: DJGPP workers Cc: Eli Zaretskii Subject: Again a patch for _use_lfn.c Message-Id: Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII I made now again a patch for '_use_lfn.c' because even the last patch from Eli (sorry that I said at first it was OK) is buggy. To proof this, link the test program (-DTEST) and run it in a W95 DOS-box with LFN=n and it will report ever 0 but it should report 1 after 'putenv("LFN=y");'. If you can't run under W95, think about the situation, that LFN=n and analize the program and you will see also that result. The reason for this is in my opinion the invalid modification of 'filesystem_flags'. I think (as the name it says), this variable should represent the filesystem status and NOT the setting of $(LFN). I have added now a static variable '_lfnenv', which remembers the last setting of $(LFN) and is updated when the environment has been changed. The 'filesystem_flags' are computed now only, if they are '==_FILESYS_UNKNOWN' or '_use_lfn()' is called for a different drive. '_use_lfn()' returns now 1 when the filesystem supports LFN and $(LFN) is not set to 'n'. BTW: If $(LFN) is not set, I assume it (in '_lfnenv') as it was set to 'y'. Is that correct? And the patch fixes of course also the unneccessary calls to 'getenv()' which was the goal with the first patch from me and Eli. OK. Here is now the patch against the '_use_lfn.c' from djlsr201.zip: *** src/libc/dos/lfn/_use_lfn.c~ Sat Aug 31 21:09:32 1996 --- src/libc/dos/lfn/_use_lfn.c Mon Mar 10 19:01:12 1997 *************** *** 17,22 **** --- 17,23 ---- static int use_lfn_bss_count = -1; /* if we are restarted (emacs) */ static unsigned filesystem_flags = _FILESYS_UNKNOWN; + static char _lfnenv = 'y'; /* remember here $(LFN) */ static unsigned last_env_changed = 0; static int last_drive; /* drive *letter*, not *number*! */ *************** *** 138,150 **** } } ! if (same_drive_as_last_time ! && last_env_changed == __environ_changed ! && use_lfn_bss_count == __bss_count ! && filesystem_flags != _FILESYS_UNKNOWN) /* paranoia */ ! return (filesystem_flags & _FILESYS_LFN_SUPPORTED) != 0; ! else { char *lfnenv; use_lfn_bss_count = __bss_count; --- 139,150 ---- } } ! if (!same_drive_as_last_time ! || last_env_changed != __environ_changed ! || use_lfn_bss_count != __bss_count ! || filesystem_flags == _FILESYS_UNKNOWN) { + /* check now the environment for $(LFN) */ char *lfnenv; use_lfn_bss_count = __bss_count; *************** *** 153,168 **** lfnenv = getenv ("LFN"); if(lfnenv && (tolower (lfnenv[0]) == 'n')) { ! filesystem_flags &= ~_FILESYS_LFN_SUPPORTED; last_drive = 0; ! return 0; } } if (!same_drive_as_last_time || filesystem_flags == _FILESYS_UNKNOWN) filesystem_flags = _get_volume_info (path, 0, 0, 0); ! return (filesystem_flags & _FILESYS_LFN_SUPPORTED) != 0; } #ifdef TEST --- 153,175 ---- lfnenv = getenv ("LFN"); if(lfnenv && (tolower (lfnenv[0]) == 'n')) { ! _lfnenv = 'n'; last_drive = 0; ! } ! else ! { ! /* if $(LFN) was not set or != 'n' assume it as 'y' */ ! _lfnenv = 'y'; } } if (!same_drive_as_last_time || filesystem_flags == _FILESYS_UNKNOWN) filesystem_flags = _get_volume_info (path, 0, 0, 0); ! /* Does the filesystem LFN support ? */ ! return ((filesystem_flags & _FILESYS_LFN_SUPPORTED) != 0 && ! /* Is it not disabled by the user ? */ ! _lfnenv != 'n'); } #ifdef TEST