diff --git a/doc/src/input-structure.md b/doc/src/input-structure.md index c78ce1ac8..93aa3e2ea 100644 --- a/doc/src/input-structure.md +++ b/doc/src/input-structure.md @@ -921,9 +921,8 @@ For *floats* and *ints*, the CSE input language recognizes a set of operators ba *Dates* are stored as *ints* (the value being the Julian day of the year), so all numeric operators could be used. The month abbreviations are implemented as operators that add the first day of the month to the following *int* value; CSE does not disallow their use in other numeric contexts. -For *strings*, *object names*, and *choices*, the CSE input language currently has no operators except the ?: conditional operator. A concatenation operator is being considered. Note, though, that the choose, choose1, select, and hourval functions described below work with strings, object names, and choice values as well as numbers. +For *strings*, *object names*, and *choices*, the CSE input language currently has no operators except the ?: conditional operator and the concat() function. Note, though, that the choose, choose1, select, and hourval functions described below work with strings, object names, and choice values as well as numbers. - ### System Variables *System Variables* are built-in operands with useful values. To avoid confusion with other words, they begin with a \$. Descriptions of the CSE system variables follow. Capitalization shown need not be matched. Most system variables change during a simulation run, resulting in the *variations* shown; they cannot be used where the context will not accept variation at least this fast. (The [Input Data Section](#input-data) gives the *variability*, or maximum acceptable variation, for each object member.) @@ -947,10 +946,10 @@ For *strings*, *object names*, and *choices*, the CSE input language currently h **Variation**: subhourly. \$dayOfWeek Day of week, 1 - 7; 1 corresponds to Sunday, 2 to - Monday, etc. **Variation:** daily. + Monday, etc. Note that \$dayOfWeek is 4 (Wed) during autosizing. **Variation:** daily. \$DOWH Day of week 1-7 except 8 on every observed holiday. - **Variation**: daily. + Note that \$DOWH is 4 (Wed) during autosizing **Variation**: daily. \$isHoliday 1 on days that a holiday is observed (regardless of the true date of the holiday); 0 on other days. diff --git a/src/cse.cpp b/src/cse.cpp index cf0e10420..df7732827 100644 --- a/src/cse.cpp +++ b/src/cse.cpp @@ -534,7 +534,7 @@ LOCAL int cse1( int argc, const char* argv[]) if (IsBlank( a)) continue; // ignore blank or NULL (unexpected) arguments argvx[argcx++] = a; // use this arg in this run - if (*a != '-' && *a != '/') // if it was not a flag (not - nor / first), assume it is an input filename + if (!IsCmdLineSwitch( *a)) // if it was not a switch (not '-' first), assume it is an input filename { BOO moreFilesFollow = FALSE; for (int argcj = argci; argcj < argc; ) // scan remaining args to see if more filenames follow @@ -542,8 +542,8 @@ LOCAL int cse1( int argc, const char* argv[]) const char* b = argv[argcj++]; // get one additional arg pointer if (IsBlank( b)) continue; // ignore blank or NULL (unexpected) arguments - if (*b != '-' && *b != '/') // if not a flag - moreFilesFollow++; // assume it is a file name + if (!IsCmdLineSwitch( *b)) // if not a switch + moreFilesFollow++; // assume it is a file name } if (moreFilesFollow) // if additional file args follow break; // terminate arg list for run with file name @@ -741,12 +741,12 @@ LOCAL int cse3( int argc, const char* argv[]) { char c0; const char* arg = argv[i]; - RC trc; - if (ppClargIf( arg, &trc) ) // test if a preprocessor cmd line arg such as a define or include path. + RC trc = RCOK; + if (ppClargIf( arg, trc) ) // test if a preprocessor cmd line arg such as a define or include path. // If so, do it, set trc, return true. pp.cpp. // uses -d, -D, -i, -I as of 2-95 rc |= trc; // merge cmd line arg error codes - else if ((c0 = *arg) != 0 && strchr("-/", *arg)) // test for switch + else if ((c0 = *arg) != 0 && IsCmdLineSwitch( *arg)) // test for switch { // warning for switch after file name, cuz confusing: apply to preceding file only if last file 2-95. Use switch anyway. if (InputFileName) diff --git a/src/cse.h b/src/cse.h index af41d3ab9..128ef2458 100644 --- a/src/cse.h +++ b/src/cse.h @@ -42,6 +42,8 @@ extern int TestOptions; // test option bits, set via -t command line argument #endif #endif + + // re sending DLL screen msgs to calling EXE // defined but not used per LOGCALLBACK void LogMsgViaCallBack( const char* msg, int level=0); diff --git a/src/pp.cpp b/src/pp.cpp index f612c71f3..743a0be3c 100644 --- a/src/pp.cpp +++ b/src/pp.cpp @@ -305,60 +305,57 @@ LOCAL void FC lisBufInsert( int* pPlace, char *p, int n=-1); /*=================== COMMAND LINE INTERFACE department ===================*/ /* interfaces to process preprocessor command line arguments: -Dsym define symbol (as null text) - -Dsym=value define symbol + -Dsym=value define symbol (no whitespace allowed) others may be added note does NOT pick out input file name -- caller must pass that to ppOpen.*/ //========================================================================== -SI FC ppClargIf( +bool ppClargIf( -// if text is a preprocessor command line argument, execute it and return nz +// if text is a preprocessor command line argument, execute it and return true const char* s, // one element of c's argv[] (if we are breaking up // command line in program, change to stop at (nonquoted?) // blanks and perhaps to decomment.) - RC* prc ) // NULL or receives RCOK or errCode (msg issued) from executing pp argument - // if a pp arg. + RC& rc ) // receives RCOK or errCode (msg issued) from executing pp argument + // iff a pp arg. -// if NOT a pp switch, fcn returns 0 (false) and *prc is unchanged. +// if NOT a pp switch, fcn returns false and rc is unchanged. { - SI retVal = 0; - RC rcSink; + bool bRet = false; ppctIni( s, true); // init to scan text, and make errMsgs say "in command line arg" not "at line n". SI c = ppCNdc(); // get char, not decommented - if (c=='-' || c=='/') // switches begin with - or / -- else not a command line arg for us, go return 0 + if (IsCmdLineSwitch( c)) // switch? else not a command line arg for us, go return false { - c = ppCNdc(); // get char after - or / - if (prc==NULL) - prc = &rcSink; + c = ppCNdc(); // get char after '-' switch (tolower(c)) { case 'd': // define - *prc = ppClDefine(); // do -D command (local, next) - retVal++; // say WAS a preprocessor command + rc = ppClDefine(); // do -D command (local, next) + bRet=true; // say WAS a preprocessor command break; case 'u': // undefine, 2-95 - *prc = ppClUndefine(); // do -U command (local, below) - retVal++; // say was a preprocessor command + rc = ppClUndefine(); // do -U command (local, below) + bRet=true; // say was a preprocessor command break; case 'i': /* -Ipath;path;path... sets directory search paths for input and #include files. May be given more than once; paths searched in order given. */ ppAddPath(s+2); // function below in pp.cpp. arg: all of s after "-i". - *prc = RCOK; // say no error - retVal++; // say a pp cmd line switch + rc = RCOK; // say no error + bRet=true; // say a pp cmd line switch break; default: - break; // not for us. fall thru to return 0. + // bRet=false; + break; // not for us. fall thru to return false. } } ppctIni( nullptr); // terminate cmd line arg scan - return retVal; // 0 or 1 + return bRet; } // ppClargIf - //========================================================================== LOCAL RC FC ppClDefine() @@ -369,18 +366,18 @@ LOCAL RC FC ppClDefine() // fcn value: RCOK if ok, else error message has been issued. { - char *id, *p, val[255+2+1]; - SI c; - RC rc /*=RCOK*/; + + RC rc=RCOK; // parse identifier CSE_E( ppcId(WRN) ) // get identifier to ppIdtx or issue errMsg; decomments. - id = strsave(ppIdtx); // save in dm for symbol table + char* id = strsave(ppIdtx); // save in dm for symbol table // parse optional "=value". // No blanks accepted around '=': blanks SEPARATE cmd line args. - c = ppCDc(); // next char (Decomment because ppcId decomments then ungets) - p = val; + SI c = ppCDc(); // next char (Decomment because ppcId decomments then ungets) + char val[255+2+1]; + char* p = val; if (c=='=') // if "=" after identifier { *p++ = ' '; // lead & trail spaces to prevent accidental token concat. Coord changes w/ doDefine(). @@ -410,7 +407,7 @@ LOCAL RC FC ppClUndefine() // fcn value: RCOK if ok, else error message has been issued. { - RC rc /*=RCOK*/; // (redundant init removed 12-94 when BCC 32 4.5 warned) + RC rc=RCOK; // parse identifier CSE_E( ppcId(WRN) ) // get identifier to ppIdtx or issue errMsg, decomments. diff --git a/src/pp.h b/src/pp.h index c3f8cdb65..5cf979d15 100644 --- a/src/pp.h +++ b/src/pp.h @@ -11,10 +11,11 @@ extern int VrInp; // 0 or virtual report handle (vrpak.cpp) for open INPut listi /*--------------- FUNCTIONS called outside of pp.cpp files --------------*/ -// pp.cpp: command line interface for pp switches -SI FC ppClargIf( const char* s, RC *prc /*,era?*/ ); +// command line interface for pp switches +inline bool IsCmdLineSwitch( int c) { return c == '-'; } +bool ppClargIf( const char* s, RC& rc); -// pp.cpp...: re getting preprocessed text (see pp.cpp for local fcns) +// re getting preprocessed text (see pp.cpp for local fcns) void FC ppClean( CLEANCASE cs); // init/cleanup void ppAddPath( const char* paths); // add path(s) to search for input/include files bool ppFindFile( const char *fname, char *fullPath); // search pp paths, return full file path @@ -26,7 +27,7 @@ RC FC ppOpen( const char* fname, char *defex); // open file void FC ppClose(); // close file(s) USI FC ppGet( char *p, USI n); // get preprocessed text -// pp.cpp...: input listing +// input listing SI FC openInpVr(); void FC closeInpVr(); void FC lisFlushThruLine( int line); @@ -35,6 +36,4 @@ void FC lisMsg( char *p, int dashB4, int dashAf); int FC lisFind( int fileIx, int line, const char* p, int *pPlace); void FC lisInsertMsg( int place, char *p, int dashB4, int dashAf); -void FC dumpDefines(); // debug aid - // end of pp.h