Subject: RE: Asterisk expansion...
From: [email-masked] (Earnie Boyd)

31 Jul 1998 17:05:25 -0700
Message-ID: <[email-masked]>
Reply-To: [email-masked]
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
To: Andrew Dalgleish <[email-masked]>
Cc: gw32 <[email-masked]>

---Andrew Dalgleish <[email-masked]> wrote:
>
> 
> 
> > -----Original Message-----
> > From:	Earnie Boyd [SMTP:[email-masked]]
> > Sent:	1998 July 30, Thursday 21:37
> > To:	[email-masked]; Andrew Dalgleish
> > Subject:	RE: Asterisk expansion...
> > 
> > ---Andrew Dalgleish <[email-masked]> wrote:
> > >
> > > 
> > > 
> > <snip>
> > > 
> > > When linked with SETARGV.OBJ, the arguments are globbed.
> > > When linked without SETARGV.OBJ, the arguments are NOT globbed.
> > > 
> > > Hence cmd/command do NOT do globbing for external commands
> > > 
> > > (Actually it is possible that globbing is done by the shell.
> > > E.g. the shell could peek into the .EXE to detect which version of
> > > SETARGV.OBJ was included.
> > > I don't think this is very likely, but then it is Microsoft... :-)
> > > 
> > 
> > It is also possible that cmd.exe/command.com does do the globbing
and
> > that the default _setargv reads the command line and resets the argv
> > array.  I would do this if I had the MS compiler; but, try with this
> > sample code creating your own _setargv which simply does nothing
> > (maybe output a message so that you know that your _setargv was
> > called).
> [Andrew Dalgleish]  
> I've waded through Microsoft's run-time source.
> 
> SETARGV.OBJ contains a single function "_setargv".
> The default version does nothing.
> The globbing version sets a flag "_dowildcard" to one.
> 
> Later in the startup "__getmainargs" calls "__setargv".
> (It took me a while to realize this one has two leading underscores
:-)
> 
> If the flag is set "__setargv" then calls "_cwild".
> "_cwild" does some simple checks for quoted arguments (which are not
> expanded), and passes args which may be wildcards on to "tmatch".
> "tmatch" looks for the wildcard characters, then uses
> FindFirstFile/FindNextFile to build the list of files.
> 
> Most of these functions have two versions, one for char and one for
> wchar_t
> They use a single source with lots of #if's sprinkled around.
> For example "tmatch" is #defined to either "match" or "wmatch"
> 
> The bottom line - cmd/command do not glob.
> 
> 
> 

I found the following code from the init.c code for mingw32.  Note
that it has nothing to do with _setargv but it does confirm that
cmd/command _DO_NOT_GLOB_.

/* NOTE: Thanks to Pedro A. Aranda Gutiirrez <[email-masked]> for pointing
 * this out to me. GetMainArgs (used below) takes a fourth argument
 * which is an int that controls the globbing of the command line. If
 * _CRT_glob is non-zero the command line will be globbed (e.g. *.*
 * expanded to be all files in the startup directory). In the mingw32
 * library a _CRT_glob variable is defined as being -1, enabling
 * this command line globbing by default. To turn it off and do all
 * command line processing yourself (and possibly escape bogons in
 * MS's globbing code) include a line in one of your source modules
 * defining _CRT_glob and setting it to zero, like this:
 *  int _CRT_glob = 0;
 */
extern int  _CRT_glob;

/*
 * Initialize the __argc, __argv and _environ variables.
 */
static void
_mingw32_init_mainargs ()
{
    /*
     * CRTDLL provides a nice little function for doing just that.
     * Convenient isn't it?
     * NOTE: The last
     */
    (void) __GetMainArgs(&__argc, &__argv, &_environ, _CRT_glob);
}

==
-        \\||//
---o0O0--Earnie--0O0o----
[email-masked]
------ooo0O--O0ooo-------

_________________________________________________________
DO YOU YAHOO!?
Get your free @yahoo.com address at http://mail.yahoo.com

-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".