From: Peep P. <so...@us...> - 2004-03-18 20:57:24
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1995 Modified Files: dfuns.c dfdecl.in Log Message: Added lower_case, capitalize, strlen, removed asctime Index: dfuns.c =================================================================== RCS file: /cvsroot/agd/server/src/dfuns.c,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- dfuns.c 16 Mar 2004 20:12:37 -0000 1.12 +++ dfuns.c 18 Mar 2004 20:47:36 -0000 1.13 @@ -137,15 +137,18 @@ void df_clone_object(void) { object_t *ret; - variable_t *saved_fp; +/* variable_t *saved_fp;*/ - saved_fp = fp; - fp++; - ret = clone_object(saved_fp->u.s); + push_control_stack(); +/* saved_fp = fp; + fp++;*/ + ret = clone_object(/*saved_*/fp->u.s); /* clone_object() might, or might not call create() and therefore decrease fp. * We have to decrement manually if needed. */ - if(fp > saved_fp) +/* if(fp > saved_fp) { fp--; + }*/ + pop_control_stack(1); pop_stack(); push_object(ret); @@ -192,44 +195,9 @@ void df_uptime(void) { time_t t; time(&t); -/* ret.u.i = total_hb * conf.heartbeat / 1000000;*/ push_int(t - startup_time); } -/* Should be done in the mudlib - much easier in LPC. */ -#define WRITE_BUFFER(plur, sing) if(plur) { if(bufptr > buf) bufptr[-1] = ' ';\ - bufptr += sprintf(bufptr, "%d "#sing"%c", plur, plur>1?'s':0) + (plur>1); } -void df_asctime(void) -{ - int secs, mins, hrs, days; - static char buf[256]; - char *bufptr; - - days = hrs = mins = 0; - secs = fp->u.i; - if(secs >= 60) { - secs %= 60; - mins = fp->u.i /= 60; - if(mins >= 60) { - mins %= 60; - hrs = fp->u.i /= 60; - if(hrs > 24) { - hrs %= 24; - days = fp->u.i / 24; - } - } - } - - memset(buf, 0, 256); - bufptr = buf; - WRITE_BUFFER(days, day) - WRITE_BUFFER(hrs, hour) - WRITE_BUFFER(mins, minute) - WRITE_BUFFER(secs, second) - pop_stack(); - push_string(&buf, ST_STATIC); -} - void df_query_idle(void) { int ret; @@ -250,6 +218,39 @@ push_int(j); } +/* Strings. */ +void df_strlen(void) +{ + int i; + i = strlen(fp->u.s); + pop_stack(); + push_int(i); +} + +void df_capitalize(void) +{ + char *s; + s = stringdup(fp->u.s); + s[0] = toupper(s[0]); + pop_stack(); + push_string(s, ST_MALLOC); +} + +void df_lower_case(void) +{ + char *s; + int i, len; + + len = strlen(fp->u.s); + s = xmalloc(len); + for(i=0;i<len;i++) { + s[i] = tolower(fp->u.s[i]); + } + pop_stack(); + push_string(s, ST_MALLOC); +} + +/* Debugging. */ void df_print_objs(void) { print_objs(); Index: dfdecl.in =================================================================== RCS file: /cvsroot/agd/server/src/dfdecl.in,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- dfdecl.in 16 Mar 2004 20:12:37 -0000 1.5 +++ dfdecl.in 18 Mar 2004 20:47:36 -0000 1.6 @@ -29,8 +29,14 @@ string version() string platform() int uptime() -string asctime(int) int random(int) +# Removed. +# string asctime(int) + +# strings +int strlen(string) +string capitalize(string) +string lower_case(string) # objects void destruct(object) |