Thread overview | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
April 23, 2005 Get original un-altered command line? | ||||
---|---|---|---|---|
| ||||
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 ? |
April 23, 2005 Re: Get original un-altered command line? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Robert Atkinson | 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 ?
|
April 24, 2005 Re: Get original un-altered command line? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Robert Atkinson | 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 ? > |
April 24, 2005 Re: Get original un-altered command line? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Robert Atkinson | 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
|
April 24, 2005 Re: Get original un-altered command line? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Robert Atkinson | 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.
|
April 24, 2005 Re: Get original un-altered command line? (glutInit) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Robert Atkinson | 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
|
Copyright © 1999-2021 by the D Language Foundation