Skip to main content.
home | support | download

Back to List Archive

Re: IndexDir using Windows

From: David L Norris <dave(at)not-real.webaugur.com>
Date: Fri Mar 01 2002 - 16:49:26 GMT
On Fri, 2002-03-01 at 10:10, Bill Moseley wrote:
> On Thursday 28 February 2002 10:00 pm, David L Norris wrote:
> 
> I forgot to ask Klaus-Peter Schulze the obvious question: are you sure you 
> are using the correct version?  As I seem to remember that it was WinME and 
> Win98SE that had the problems and Win98, Win NT, and Win2K worked.

Either way, it's still not totally fixed.  We still have the appended
'\\' problem.  I'm burning a lot of CPU time removing those in stat().

> It would be nice to use the correct path separator for the running OS.

I would prefer using the Unix-style seperator since Windows supports
it.  Double or quadruple escaping names is confusing.

> It's also ugly to end up with paths that have slashes both ways.  When 
> recursing through the directory tree swish has to stick a path separator 
> between names.  Currently it uses \ for windows and / for everthing else.
> But there's no check to see what people used in their IndexDir or -i setting 
> so you end up with paths like /home/manual\hardware\video\driver.txt.  It 
> would be nice to clean those up.

I wrote two functions and macros to convert back and forth.  My thought
is that we could clean up those file names once as they are read from
the config file and command line rather than dozens of times in stat().

But, converting the command line from / to \\ for popen is one place we
have to be careful.  Because we don't want to convert DOS/Win32 command
line "switches" by accident

> Still, filters pass the path name, so the filters will probably expect (or 
> need) path names with correct path separators.

Yep, that's true...

> And also, Windows users would probably like search results to show to correct
> path separator.

IMO, there is only one correct directory seperator.  ;-)  Maybe an issue
with copy and paste.  But, I'd not get too worried about asthetics.

> Dave, are there any system calls (other than popen() ) that require the back 
> slash, or will they all work either way?  (Or is that something that's fixed 
> up in dirent.c?)

Internally Windows doesn't care which seperator you use.  The only
problem with '/' comes from interacting with DOS/NT programs through the
shell.  I believe the shell itself interprets '/' as the beginning of an
argument which gets pushed onto argv[].  It's more of a "do what I mean"
instead of a "do what I say" type of shell.

For example: "dir..\winnt/p" means the same thing as "dir ..\winnt /p" 
The shells really foster bad habits on the command line.  And, it causes
POSIX applications to explode.  ;-)

> Maybe it would be smart to use the forward slash everywhere internally.

What I keep thinking is that we convert '\\' to '/' as we read them in
from the config file or command line.  Then translate '/' to '\\'
wherever we must.

> Then convert the slash when running a filter or generating output.

I'm not real thrilled with the idea of printing file names using '\\'. 
Why?  Because then we have to start this whole translation process all
over inside the parsing scripts.  PHP has all these same problems
internally, and, I'd imagine PERL does too.

> What happenes with VMS?

What does it use for a directory seperator?  If it uses '/' then it
shouldn't matter.

> > stat() is causing the most obvious errors, though.  stat() fails on a
> > directory name with a trailing '\' or '/'.
> 
> And it that dependent on the *version* of Windows, too?

Yes but we shouldn't have to worry about it.  Systems newer than NT 3.x
appear to have a stat() which functions consistently.  I've not verified
this on NT 4.0, though.

According to dirent.c, stat() on a NT version dating around 1993
REQUIRED a UNC path to have a trailing '\\'.  This is why stat() was
failing with the UNC paths a few weeks ago.  The current behavior of the
Win32 API is that stat() FAILS on ANY directory with a trailing '\\'.

So, it seems they have changed stat() to be consistently broken across
all filesystem types.  In their mind, they probably would say they have
fixed it.

-- 
 David Norris
  Dave's Web - http://www.webaugur.com/dave/
  Augury Net - http://augur.homeip.net/
  ICQ Universal Internet Number - 412039
  E-Mail - dave@webaugur.com

  "If you stare into an abyss long enough
   it begins to stare back into you."  --Nietzsche
Received on Fri Mar 1 16:50:23 2002