www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1993/06/24/21:09:40

Date: Thu, 24 Jun 93 18:45:19 -0600
From: Bob Proulx <rwp AT hprwp DOT fc DOT hp DOT com>
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: getcwd -- to drive: or not to drive:

>>> 1. If you call getcwd(buf,255) you will get the current working
>>>    directory but without the DOS drive.
>> How many unix programs will break when you change this?  It sounds
>> like an easy change.
> 
> I will comment that this behavior broke some of my DOS code when ported
> to djgcc.  I would vote for including the drive letter in the output of
> getcwd.

It really depends on your view of the world.  If GCC is a way to
compile UNIX programs on a PC then your would want to preserve UNIX
semantics.  If GCC is a way to compile PC programs then you would want
to preserve PC semantics.  (Being from the UNIX camp I would preserve
UNIX semantics by right that it was there first. ;-)

> If this turns out to be a controversial issue, a possible solution
> would be to make getcwd a macro, defined as something like

Something like this sounds like the best long term solution.  Then you
could in a UNIX module define it UNIX like and in a MS-DOS module you
could define it MS-DOS like.  Since you almost always have to add code
in #ifdef's to make things work on MS-DOS this would most easily allow
people to select a semantic.

#undef __GNUC_UNIX_GETCWD
#undef __GNUC_DOS_GETCWD
#define __GNUC_DOS_GETCWD
#include <unistd.h>		/* :-) UNIX standard definition of getcwd */

I almost favor putting things in a different library.  Then you select
it by putting -ldos on the command line before -lc.  But that makes it
difficult to have more routines with the same problem.  You would want
to be able to select on a routine by routine basis.  So you would want
a scheme that can handle more of this class of problem.

> The advantage of this definition is that it beats you over the head
> and says "here's a subtle difference between DOS and Unix, which
> one do you want"

This is true.  There are always going to be emotion filled debates
over which way it should be done, UNIX-like or MS-DOS-like.  And in
reality neither would work in all cases on the other's platform.
Eventually you have to make decisions on a program basis.  Something
along these lines would allow that.

Bob Proulx

- Raw text -


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