Skip to content

Commit

Permalink
Added ArgRecognize
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed May 23, 2003
1 parent 956e51a commit 5a4003f
Showing 1 changed file with 24 additions and 10 deletions.
34 changes: 24 additions & 10 deletions doomsday/Src/m_args.c
Expand Up @@ -253,27 +253,41 @@ char * ArgNext(void)
return args[++last_match];
}

//===========================================================================
// ArgRecognize
// Returns true if the two parameters are equivalent according to the
// abbreviations.
//===========================================================================
int ArgRecognize(char *first, char *second)
{
int k;

// A simple match?
if(!stricmp(first, second)) return true;

for(k = 0; k < num_names; k++)
{
if(stricmp(first, names[k]->long_name)) continue;
// names[k] now matches the first string.
if(!stricmp(names[k]->short_name, second)) return true;
}
return false;
}

//==========================================================================
// ArgCheck
// Checks for the given parameter in the program's command line arguments.
// Returns the argument number (1 to argc-1) or 0 if not present.
//==========================================================================
int ArgCheck(char *check)
{
int i, k;
int i;

for(i = 1; i < num_args; i++)
{
if(!stricmp(check, args[i]))
// Check the short names for this arg, too.
if(ArgRecognize(check, args[i]))
return last_match = i;

// Check the short names for this arg.
for(k = 0; k < num_names; k++)
{
if(stricmp(check, names[k]->long_name)) continue;
if(!stricmp(names[k]->short_name, args[i]))
return last_match = i;
}
}
return last_match = 0;
}
Expand Down

0 comments on commit 5a4003f

Please sign in to comment.