X-Git-Url: https://feistymeow.org/gitweb/?a=blobdiff_plain;f=nucleus%2Flibrary%2Fapplication%2Fcommand_line.cpp;h=f132867f8e500d9005b539fe564c5f575fd706e0;hb=694e3381a805d240bd355886088d90cb25e1bb25;hp=19f61810ce130f4151a510659b85243a950c6af0;hpb=457b128b77b5b4a0b7dd3094de543de2ce1477ad;p=feisty_meow.git diff --git a/nucleus/library/application/command_line.cpp b/nucleus/library/application/command_line.cpp index 19f61810..f132867f 100644 --- a/nucleus/library/application/command_line.cpp +++ b/nucleus/library/application/command_line.cpp @@ -25,6 +25,9 @@ #include #include +#include +//temp + #undef LOG #define LOG(s) CLASS_EMERGENCY_LOG(program_wide_logger::get(), s) @@ -71,7 +74,7 @@ command_parameter &command_parameter::operator = // the default is a dash (-), while for DOS most programs use forward-slash // (/). Adding more characters is trivial; just add a character to the list // before the sentinel of '\0'. -#if defined(_MSC_VER) || defined(__MINGW32__) +#if defined(_MSC_VER) || defined(__MINGW32__) || defined(__WIN32__) static char option_prefixes[] = { '-', '/', '\0' }; #elif defined(__UNIX__) static char option_prefixes[] = { '-', '\0' }; @@ -236,12 +239,12 @@ bool command_line::zap(int field) string_array command_line::get_command_line() { -// FUNCDEF("get_command_line"); + FUNCDEF("get_command_line"); string_array listo_cmds; // the temporary string below can be given a flat formatting of the commands // and it will be popped out into a list of arguments. astring temporary; -#ifdef __UNIX__ +#if defined(__UNIX__) || defined(__GNU_WINDOWS__) if (!_global_argc || !_global_argv) { // our global parameters have not been set, so we must calculate them. temporary = application_configuration::get_cmdline_from_proc(); @@ -254,7 +257,7 @@ string_array command_line::get_command_line() // we don't need a long string to be parsed; the list is ready. return listo_cmds; } -#elif defined(__WIN32__) +#elif defined(_MSC_VER) // we have easy access to the original list of commands. for (int i = 0; i < _global_argc; i++) { // add a string entry for each argument. @@ -367,6 +370,7 @@ LOG(astring("found option string with dash! string is: ") + option_string); bool command_line::get_value(char option_character, astring &value, bool case_sense) const { + FUNCDEF("get_value"); value = ""; int posn = 0; // where we find the flag. if (!find(option_character, posn, case_sense)) return false; @@ -394,17 +398,21 @@ LOG(astring("found option string with dash! string is: ") + option_string); value = ""; int posn = 0; // where we find the flag. if (!find(option_string, posn, case_sense)) return false; +//printf("found the flag! at %d\n", posn); // get the value after the flag, if there is such. posn++; // this is where we think our flag's value lives. if (posn >= entries()) return false; +//printf("next posn is still okay at %d\n", posn); // there's still an entry after where we found our flag; grab it. command_parameter cp = get(posn); +//printf("comm parm has text %s\n", cp.text().s()); if (cp.type() != command_parameter::VALUE) return false; // finally; we've found an appropriate text value. value = cp.text(); +//printf("assigning value %s\n", value.s()); return true; }