From: ant@mks.com (Anthony Howe)
Subject: Re: Problems with ARGV
Organization: Mortice Kern Systems, Waterloo, Ontario, CANADA
Date: Fri, 31 Jul 1992 14:31:22 GMT

dltest@castle.ed.ac.uk (Kevin Davidson) writes:
>ant@mks.com (Anthony Howe), babbling inanely in article <1992Jul29.130755.27902@mks.com>, claimed:

			     ^^^^^^^^^^^^^^^^
			     Uncalled for and impolite.
If you don't agree then say so, but there is no need to be uncivil about it.


>>Julian F. Reschke writes:
>>>In article <9130026@hpbbrd.bbn.hp.com>, jensk@hpbbrd.bbn.hp.com (Jens Kilian)
>>>says:
>>>>	[Problem with NULL parameters to programs

>>>>	[suggested fix was using another env.var. to record empty
>>>>	[string positions.

> So where does this environment variable go ? Before ARGV ? Then programs
>that don't understand will pass it onto their children, so we need *another*
>flag to say the information is valid. Yeeuch!

I'd forgotten about that.

>After ARGV ? How do we tell we are after ARGV, if the double null is possibly
>just a null parameter ? The information we need is somewhere else...
>(Think about this:
>
>prog.ttp arg1 "" ARGV_EMPTY=foo bar bletch
>
>(yeah it's unlikely, but *possible*)
>
>It looks like there should have been a length flag somewhere or maybe
>some other terminator than \0\0.
>The other solutions I've seen have problems too:
>1) escape characters (\001 etc) will really confuse older programs.
>2) adding spaces doesn't seem too bad, but there has to be a tidier fix
>   than this.
>
>I'd say put a length flag or the value of argc somewhere. I'd suggest
>breaking MWC programs and putting "ARGV=argc\0arg1\0arg2\0\0arg4\0\0"

This sounds pretty good too.  Having never used MWC, could someone
explain what MWC startup code uses the first ARGV parameter for?. 

Idea 1
------
Since most C startup just scan the environment for string "ARGV", why
not encode argc in the ARGV name:

	ARGV6=<MWC stuff>\0arg1\0\0arg3\0\0argv5\0\0

	    ^^ Place argc here in the name.  It is then left to the
C startup to correctly parse the env. for /ARGV[0-9]+=/.  This is by no
means perfect solution for old programs, especially if their C startup
looks for the string "ARGV=" instead.

Idea 2
------
An alternative would be to place the encoded string of empty positions 
_after_ the double NULL.

	ARGV=\0arg1\0arg3\0arg4\0\0EMPTY=2,5\0\0

would represent

	argc = 6;
	argv[] = { "", "arg1", "", "arg3", "argv4", "", NULL };

The ARGV could be left and parsed as it always has by older programs.
Newer ones could check immediately following the double NULL for the
EMPTY string list.


>if MiNT can pass open file descriptors to processes' children. I think
>something somewhere will be broken by whatever method we choose, and
>this one at least is aesthetically more pleasing.
>
> As an aside, who else is still using Sozobon 1.2 ? Can anyone tell me
>why I should move to Sozobon 2.0 or 1.33i ? What's the difference anyway ?
>...

The only reason I still use 1.2 is because I have the source.  The other
versions seemed too unstable at the time and without source.  I decided to
wait till a stable version with source was released.  I'm still waiting.
It would be nice to have longer names, handle ANSI prototypes, be able
to switch between int == short and int == long, allow structures and
arrays to be greater than 32K, and use long for array indexes.

-ant
-- 
ant@mks.com                                                   Anthony C Howe 
Mortice Kern Systems Inc. 35 King St. N., Waterloo, Ontario, Canada, N2J 6W9
"Nice legs.  For a human that is." - Worf (Q-pid)
Newsgroups: comp.sys.atari.st.tech