www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Get original un-altered command line?

reply Robert Atkinson <Robert.Atkinson gmail.com> writes:
Is this possible with a standard D call?  I don't want the parsed char[][]
args value.

Or the 2nd part, how do people initialise GLUT with the char[][] instead of
argc and argv ?
Apr 23 2005
next sibling parent reply Robert Atkinson <Robert.Atkinson gmail.com> writes:
I've manually passed parameters to the glutInit call, but I'm still
interested in getting the original commandline, particularly as char[][]
strips spaces and does some rudimentary parsing of its own

Robert Atkinson wrote:

 Is this possible with a standard D call?  I don't want the parsed char[][]
 args value.
 
 Or the 2nd part, how do people initialise GLUT with the char[][] instead
 of argc and argv ?
Apr 23 2005
next sibling parent "TechnoZeus" <TechnoZeus PeoplePC.com> writes:
Hmmm.  An interesting question.

I would think it would be easy to make a simple function that would
convert an array of arrays to a single array,
inserting a specified separater, but that's not "quite" the same thing.

I wonder if the original string is tossed out, or if it is stored somewhere.

TZ

"Robert Atkinson" <Robert.Atkinson gmail.com> wrote in message
news:d4ee2s$2e64$1 digitaldaemon.com...
 I've manually passed parameters to the glutInit call, but I'm still
 interested in getting the original commandline, particularly as char[][]
 strips spaces and does some rudimentary parsing of its own

 Robert Atkinson wrote:

 Is this possible with a standard D call?  I don't want the parsed char[][]
 args value.

 Or the 2nd part, how do people initialise GLUT with the char[][] instead
 of argc and argv ?
Apr 23 2005
prev sibling next sibling parent Manfred Nowak <svv1999 hotmail.com> writes:
Robert Atkinson <Robert.Atkinson gmail.com> wrote:

[...]
 as char[][] strips spaces and does some rudimentary
 parsing of its own 
Dont you think that it is the shell, that interprets the command line and splits it into tokens, serving them to the D executable? If it is this way and the shell does not store the original command line in the environment, from where you can get it, there will be no chance to access the original command line. But if you know of a C program that can do such work, a port should be possible. By the way, have you seen the entry for the learn group? Thanks. -manfred
Apr 23 2005
prev sibling parent =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> writes:
Robert Atkinson wrote:

Is this possible with a standard D call?  I don't want the parsed char[][]
args value.
I've manually passed parameters to the glutInit call, but I'm still interested in getting the original commandline, particularly as char[][] strips spaces and does some rudimentary parsing of its own
The "D main" does not do any such space-stripping or parsing, it just converts the arguments from "int argc, char **argv" to "char[][] args". Like others pointed out, it is most likely the shell that globs/parses ? But that should be no different from C, which is what glutInit expects. If you want to you can fill out D args[] again, from the return values. Note that the contents of each argument is *not* changed, so if you run D in a non-Unicode shell (not supported), you get invalid UTF-8 input... To access the original strings, you can simply cast it back to ubyte[] ? Then you can use your own function, to translate from ubyte[] to char[]. But for simple ASCII strings, the char[] and "ubyte[]" are identical. Your post has a good point, though. Using GLUT with D is too complex. I think I'll add a "extern(D) void glutInit(inout char[][] args);" ... --anders PS. The real interesting one is libSDL, with the SDL_main hack... "glutInit" is pretty straight-forward, compared to that one.
Apr 24 2005
prev sibling parent =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> writes:
Robert Atkinson wrote:

 Or the 2nd part, how do people initialise GLUT with
 the char[][] instead of argc and argv ?
Here is a version of "glutInit", for D: /* GLUT initialization sub-API. */ extern(C) void glutInit(int *argcp, char **argv); import std.string; extern(D) void glutInit(inout char[][] args) { int argc = args.length; char **argv = new char*[argc]; for(int i = 0; i < argc; i++) argv[i] = toStringz(args[i]); glutInit(&argc, argv); args.length = argc; for(int i = 0; i < argc; i++) args[i] = toString(argv[i]); } Comes from opengl.glut module (tested). --anders
Apr 24 2005