/* * Parse the command string contained in the current context. */ void CmdStringParse( OPT_STORAGE *cmdOpts, int *itemsParsed ) /***********************************************************/ { int ch; char * filename; for( ;; ) { /*** Find the start of the next item ***/ CmdScanWhitespace(); ch = GetCharContext(); if( ch == '\0' ) break; MarkPosContext(); /* mark start of switch */ /*** Handle switches, command files, and input files ***/ if( ch == '-' || ch == '/' ) { /* switch */ if( OPT_PROCESS( cmdOpts ) != 0 ) { cmd_line_error(); } } else if( ch == '@' ) { /* command file */ filename = CmdScanFileNameWithoutQuotes(); PushContext(); if( OpenFileContext( filename ) ) { FatalError( "Cannot open '%s'.", filename ); } FreeMem( filename ); CmdStringParse( cmdOpts, itemsParsed ); PopContext(); } else if( ch == '"' ) { /* quoted option or file name */ ch = GetCharContext(); if( ch == '-' ) { Quoted = 1; if( OPT_PROCESS( cmdOpts ) != 0 ) { cmd_line_error(); } } else { UngetCharContext(); UngetCharContext(); filename = CmdScanFileName(); AddFile( TYPE_DEFAULT_FILE, filename ); FreeMem( filename ); } } else { /* input file */ UngetCharContext(); filename = CmdScanFileName(); AddFile( TYPE_DEFAULT_FILE, filename ); FreeMem( filename ); } (*itemsParsed)++; } CloseContext(); }
/* * Parse the command string contained in the current context. */ void CmdStringParse( OPT_STORAGE *cmdOpts, int *itemsParsed ) /***********************************************************/ { char ch; char * filename; char * str; for( ;; ) { /*** Find the start of the next item ***/ CmdScanWhitespace(); ch = GetCharContext(); if( ch == '\0' ) break; MarkPosContext(); /* mark start of switch */ /*** Handle switches, command files, and input files ***/ if( ch == '-' || ch == '/' ) { /* switch */ if( OPT_PROCESS( cmdOpts ) ) { /* * Switch didn't match, if user entered empty switch, * just be silent like MS's nmake does. */ ch = GetCharContext(); if( ch != '\0' && !isspace( ch ) ) { cmd_line_error(); } } } else if( ch == '@' ) { /* command file */ filename = CmdScanFileNameWithoutQuotes(); PushContext(); if( OpenFileContext( filename ) ) { FatalError( "Cannot open '%s'.", filename ); } FreeMem( filename ); CmdStringParse( cmdOpts, itemsParsed ); PopContext(); } else { /* targets and macros */ UngetCharContext(); str = CmdScanString(); add_string( &(cmdOpts->t010101010101_value), str, '\0' ); cmdOpts->t010101010101 = 1; } (*itemsParsed)++; } CloseContext(); }