Added fix for __DATE__, added __TIME__

Added tag table crap for new autoloading feature
Version bump
This commit is contained in:
David Anderson 2006-05-10 03:44:35 +00:00
parent a29f8d0651
commit 58209dfb37
2 changed files with 74 additions and 6 deletions

View File

@ -61,6 +61,8 @@
#include <windows.h>
#endif
#include <time.h>
#include "sc.h"
#define VERSION_STR "3.0.3367-amxx"
#define VERSION_INT 0x300
@ -125,6 +127,7 @@ static void dostate(void);
static void addwhile(int *ptr);
static void delwhile(void);
static int *readwhile(void);
static void inst_datetime_defines(void);
static int lastst = 0; /* last executed statement type */
static int nestlevel = 0; /* number of active (open) compound statements */
@ -382,6 +385,23 @@ long pc_lengthbin(void *handle)
#endif /* !defined NO_MAIN */
void inst_datetime_defines()
{
char date[64];
char ltime[64];
time_t td;
struct tm *curtime;
time(&td);
curtime = localtime(&td);
strftime(date, 31, "\"%m/%d/%Y\"", curtime);
strftime(ltime, 31, "\"%H:%M:%S\"", curtime);
insert_subst("__DATE__", date, 8);
insert_subst("__TIME__", ltime, 8);
}
/* "main" of the compiler
*/
@ -531,7 +551,7 @@ int pc_compile(int argc, char *argv[])
delete_symbols(&glbtab,0,TRUE,FALSE);
#if !defined NO_DEFINE
delete_substtable();
insert_subst("__DATE__", "\"" __DATE__ "\"", 8);
inst_datetime_defines();
#endif
resetglobals();
sc_ctrlchar=sc_ctrlchar_org;
@ -595,7 +615,7 @@ int pc_compile(int argc, char *argv[])
delete_symbols(&glbtab,0,TRUE,FALSE);
#if !defined NO_DEFINE
delete_substtable();
insert_subst("__DATE__", "\"" __DATE__ "\"", 8);
inst_datetime_defines();
#endif
resetglobals();
sc_ctrlchar=sc_ctrlchar_org;

View File

@ -1016,8 +1016,28 @@ static int command(void)
} /* if */
} else if (strcmp(str,"dynamic")==0) {
preproc_expr(&sc_stksize,NULL);
} else if (strcmp(str,"library")==0) {
char name[sNAMEMAX+1];
} else if ( !strcmp(str,"library") ||
!strcmp(str, "reqlib") ||
!strcmp(str, "reqclass") ||
!strcmp(str, "loadlib") ||
!strcmp(str, "explib") ||
!strcmp(str, "expclass") ||
!strcmp(str, "defclasslib") ) {
char name[sNAMEMAX+1],sname[sNAMEMAX+1];
const char *prefix = "";
sname[0] = '\0';
if (!strcmp(str, "reqlib"))
prefix = "?rl_";
else if (!strcmp(str, "reqclass"))
prefix = "?rc_";
else if (!strcmp(str, "loadlib"))
prefix = "?f_";
else if (!strcmp(str, "explib"))
prefix = "?el_";
else if (!strcmp(str, "expclass"))
prefix = "?ec_";
else if (!strcmp(str, "defclasslib"))
prefix = "?d_";
while (*lptr<=' ' && *lptr!='\0')
lptr++;
if (*lptr=='"') {
@ -1027,6 +1047,20 @@ static int command(void)
for (i=0; i<sizeof name && (alphanum(*lptr) || *lptr=='-'); i++,lptr++)
name[i]=*lptr;
name[i]='\0';
if (!strncmp(str, "exp", 3) || !strncmp(str, "def", 3))
{
while (*lptr && isalpha(*lptr))
lptr++;
for (i=1; i<sizeof sname && alphanum(*lptr); i++,lptr++)
sname[i]=*lptr;
sname[i] = '\0';
if (!sname[1])
{
error(28);
} else {
sname[0] = '_';
}
}
} /* if */
if (strlen(name)==0) {
curlibrary=NULL;
@ -1034,8 +1068,22 @@ static int command(void)
pc_addlibtable=FALSE;
} else {
/* add the name if it does not yet exist in the table */
if (find_constval(&libname_tab,name,0)==NULL)
curlibrary=append_constval(&libname_tab,name,0,0);
char newname[sNAMEMAX+1];
if (strlen(name) + strlen(prefix) + strlen(sname) <= sNAMEMAX)
{
strcpy(newname, prefix);
strcat(newname, name);
strcat(newname, sname);
if (newname[0] != '?')
{
if (find_constval(&libname_tab,newname,0)==NULL)
{
curlibrary=append_constval(&libname_tab,newname,0,0);
}
} else {
exporttag(pc_addtag(newname));
}
}
} /* if */
} else if (strcmp(str,"pack")==0) {
cell val;