On Thu, 28 Apr 2016 17:34:36 -0700, Tom Brennan wrote:
>
>Don't people usually use the argc (parm count) value also passed in unix
>main()?  If so they would never go past the end of argv[].
> 
I'm lazy; I might avoid declaring one variable with such as:
    for ( ; argv; ++argv ) {
        /* do something with *argv */
        }
( Utterly untested.  )

On Thu, 28 Apr 2016 17:33:21 -0700, retired mainframer wrote:
>
>In C, any address that is not point to part of an object or exactly one byte 
>past the end of an object is invalid and any attempt to evaluate it, whether 
>it is dereferenced or not, causes undefined behavior.  On a Z system it will 
>probably work as intended since operands are only treated as addresses when 
>they cause a memory reference.  At other times they are just regular numeric 
>values.
>  
(I didn't check the Standard for this lately.  IIRC, one may meaningfully 
compare
two addresses iff they reference members of the same object or the fictional
member immediately after an array.  So, yes.)

>> And the UNIX argv[] vector is terminated by a NULL (0) pointer, not -1.
>This is standard for all C, not just Unix.
>
Yes.  I did check the Standard for this; it has to do with Hosted Environments.
But the implementer seems to be given broad discretion as to how argv[] is
generated.  Many try to emulate the behavior of the POSIX Shell.  z/OS, in
contrast but probably still conforming, will treat:
    EXEC PGM=BPXBATCH,PARM='PGM whatever wombat foo\tbar xyzzy'
will pass 3 arguments, tokenizing at the blanks but not at the tab, and it
provides no way of escaping any of the blanks.

-- gil

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to