SCP: Added expansion of special built-in environment variable DATE_YC which is the century of the current date.

This commit is contained in:
Mark Pizzolato 2014-12-03 10:39:19 -08:00
parent cd9a499c94
commit 1f20041b58
2 changed files with 5 additions and 1 deletions

View file

@ -237,7 +237,7 @@ The EXPECT command now exists to provide a means of reacting to simulator output
#### Command Processing Enhancements #### Command Processing Enhancements
##### Environment variable insertion ##### Environment variable insertion
Built In variables %DATE%, %TIME%, %DATETIME%, %LDATE%, %LTIME%, %CTIME%, %DATE_YYYY%, %DATE_YY%, %DATE_MM%, %DATE_DD%, %DATE_D%, %DATE_WYYYY%, %DATE_WW%, %TIME_HH%, %TIME_MM%, %TIME_SS%, %STATUS%, %TSTATUS%, %SIM_VERIFY%, %SIM_QUIET%, %SIM_MESSAGE% Built In variables %DATE%, %TIME%, %DATETIME%, %LDATE%, %LTIME%, %CTIME%, %DATE_YYYY%, %DATE_YY%, %DATE_YC%, %DATE_MM%, %DATE_DD%, %DATE_D%, %DATE_WYYYY%, %DATE_WW%, %TIME_HH%, %TIME_MM%, %TIME_SS%, %STATUS%, %TSTATUS%, %SIM_VERIFY%, %SIM_QUIET%, %SIM_MESSAGE%
Command Aliases Command Aliases
Token "%0" expands to the command file name. Token "%0" expands to the command file name.

4
scp.c
View file

@ -2933,6 +2933,10 @@ for (; *ip && (op < oend); ) {
strftime (rbuf, sizeof(rbuf), "%y", tmnow); strftime (rbuf, sizeof(rbuf), "%y", tmnow);
ap = rbuf; ap = rbuf;
} }
else if (!strcmp ("DATE_YC", gbuf)) {/* Century (year/100) */
sprintf (rbuf, "%d", (tmnow->tm_year + 1900)/100);
ap = rbuf;
}
else if (!strcmp ("DATE_MM", gbuf)) {/* Month number (01-12) */ else if (!strcmp ("DATE_MM", gbuf)) {/* Month number (01-12) */
strftime (rbuf, sizeof(rbuf), "%m", tmnow); strftime (rbuf, sizeof(rbuf), "%m", tmnow);
ap = rbuf; ap = rbuf;