delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/05/25/08:16:11

Date: Mon, 25 May 1998 15:11:10 +0200
From: Alexander Bokovoy <bokovoy AT bspu DOT ac DOT by>
Reply-To: Alexander Bokovoy <bokovoy AT bspu DOT ac DOT by>
Organization: BSPU named after Maxim Tank
Message-ID: <9632.980525@bspu.unibel.by>
To: djgpp AT delorie DOT com
Subject: Bug in GCC 2.8.0? MAXFILE is equal 9 while LFN are supported
Mime-Version: 1.0

I  found that constant MAXFILE defined in dir.h is equal 9 which means
that  buffer  for  file name generated by fnsplit() must be at least 8
symbols  length.  But DJGPP's libc support long file names (LFN) up to
260  symbols  length  and  in  such case buffer must be greater than 8
symbols  to  proper  file name handling. It means that every time when
fnsplit() proceed with file name longer than 8 symbols the result will
be undefined. Of course, it needs switch options LFN in DJGPP.ENV to y
(+LFN=y).


So, the following example will crash when the file name (i.e. its NAME
part  without  DRIVE,  DIRECTORY and EXTENSION) longer than 8 symbols:
(code taken from libc.info)


  char d[MAXDRIVE], p[MAXDIR], f[MAXFILE], e[MAXEXT];
  int which = fnsplit("d:/Program Files/foo/Long file Name BAR.extention", d, p, f, e);
  d = "d:"
  p = "/Program Files/foo/"
  f = "Long fil"    <<<<- fnsplit() with LFN=y must have another behavior, isn't it?
  e = ".exe"

There  is  a  correction  for  this  "bug":  simply  don't use MAXFILE
constant and declare buffer for extracted file name large, for example
like MAXDIR.

Sincerely,
Alexander Bokovoy, <bokovoy AT bspu DOT unibel DOT by>
--=== The Soft Age coming soon ===--


- Raw text -


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