You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
(180) |
Apr
(20) |
May
|
Jun
(91) |
Jul
(78) |
Aug
(18) |
Sep
|
Oct
|
Nov
|
Dec
|
---|
From: Peep P. <so...@us...> - 2004-03-28 18:09:09
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31561 Modified Files: lang.y Log Message: Changed make_lvalue into a function; added string ranges. Index: lang.y =================================================================== RCS file: /cvsroot/agd/server/src/lang.y,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- lang.y 21 Mar 2004 14:06:36 -0000 1.13 +++ lang.y 28 Mar 2004 17:57:49 -0000 1.14 @@ -3,9 +3,13 @@ #include "lpc_incl.h" #include "lex.h" -/* Used during compilation, replaced with F_JMP. */ -#define F_BREAK -5 -#define F_CONTINUE -6 +/* Used during compilation, replaced with F_JMP. + Need to use two separate numbers for both, because one + could easily appear on it's own in code. */ +#define F_BREAK_MAGIC1 -1 +#define F_BREAK_MAGIC2 -2 +#define F_CONTINUE_MAGIC1 -3 +#define F_CONTINUE_MAGIC2 -4 YYLTYPE yylloc; @@ -19,13 +23,8 @@ void add_function(def_id_t *idp, int lineno, array_t *code); void redeclaration_error(def_id_t *id, int new_type); int compare_args(array_t *arg1, array_t *arg2); +void make_lvalue(expr_t *e); -#define MAKE_LVALUE(x) if((int)x.arr.data[0] == F_PUSH_LVAR)\ - x.arr.data[0] = (void *)F_PUSH_LVAR_LVALUE;\ - else if((int)x.arr.data[0] == F_PUSH_GVAR)\ - x.arr.data[0] = (void*)F_PUSH_GVAR_LVALUE;\ - else if((int)x.arr.data[x.arr.length-1] == F_RANGE)\ - x.arr.data[x.arr.length-1] = (void*)F_RANGE_LVALUE %} %expect 1 @@ -55,6 +54,7 @@ %token L_OPEN_FUNP L_CLOSE_FUNP /* operators */ +%nonassoc L_RANGE %right L_ASSIGN %left L_PE /* Pluq-equals */ L_ME /* Minus-equals */ %left L_MUE /* Multiply-equals */ L_MOE /* Modulo-equals */ L_DE /* Divide-equals */ @@ -73,7 +73,7 @@ %right '[' ']' %nonassoc L_NEG L_NOT L_INC L_DEC /*%left L_COMM*/ -%nonassoc L_TYPECAST +/*%nonassoc L_TYPECAST*/ %type <str> string string_con2 %type <id> defined_name @@ -84,7 +84,8 @@ %type <var> var_def %type <arr> call_args call_arg_list -%type <expr> expr optional_expr range_expr +%type <expr> expr optional_expr +%type <arr> slice_expr %type <arr> return if else do_while while for break continue %type <arr> fun_call call_other %type <arr> statements statement @@ -161,9 +162,10 @@ if($9.length) { def_id_t *idp = $<id>4; if(idp->lpc_type != $1 || compare_args(idp->args, &$6)) { - char buf[256]; + char *buf = xmalloc(strlen($2) + 41); sprintf(buf, "definition doesn't match declaration for %s", $2); comp_error(buf); + xfree(buf); } idp->type = ID_FUN; @@ -202,9 +204,10 @@ } else { def_id_t *idp = $<id>4; if(idp->type == ID_FUN_PROT && !$<i>3) { - char buf[256]; + char *buf = xmalloc(strlen($2) + 59); sprintf(buf, "warning: repeated prototype for %s; using existing prototype", $2); display_error(buf); + xfree(buf); compile_warnings++; } else { add_function(idp, $<i>8, NULL); @@ -273,9 +276,10 @@ if($8.length) { def_id_t *idp = $<id>3; if(idp->lpc_type != DEFAULT_FUNCTION_TYPE || compare_args(idp->args, &$5)) { - char buf[256]; + char *buf = xmalloc(strlen($1) + 42); sprintf(buf, "definition doesn't match declaration for %s", $1); comp_error(buf); + xfree(buf); } idp->type = ID_FUN; @@ -315,9 +319,10 @@ } else { def_id_t *idp = $<id>3; if(idp->type == ID_FUN_PROT && !$<i>2) { - char buf[256]; + char *buf = xmalloc(strlen($1) + 59); sprintf(buf, "warning: repeated prototype for %s; using existing prototype", $1); display_error(buf); + xfree(buf); compile_warnings++; } else { add_function(idp, $<i>8, NULL); @@ -398,9 +403,11 @@ { $$ = find_id($1); if(!$$) { - char buf[256]; + char *buf; + buf = xmalloc(strlen($1) + 25); sprintf(buf, "undeclared identifier '%s'", $1); comp_error(buf); + xfree(buf); xfree($1); /* WATCH OUT */ } } @@ -535,7 +542,7 @@ comp_error("improper use of void type"); } $$.type = $1; - init_var(&$$); + /*init_var(&$$);*/ $$.name = $2; } | L_IDENTIFIER @@ -551,9 +558,11 @@ id = find_id($1); if(id) { if(id->type == ID_ARG) { - char buf[256]; + char *buf; + buf = xmalloc(strlen($1) + 51); sprintf(buf, "warning: declaration of %s shadows function argument", $1); display_error(buf); + xfree(buf); compile_warnings++; } else if(id->type == ID_DFUN || id->base_scope >= scope_level) { redeclaration_error(id, ID_LVAR); @@ -570,15 +579,21 @@ id = find_id($1); if(id) { if(id->type == ID_ARG) { - char buf[256]; + char *buf; + buf = xmalloc(strlen($1) + 51); sprintf(buf, "warning: declaration of %s shadows function argument", $1); display_error(buf); + xfree(buf); compile_warnings++; } else if(id->base_scope >= scope_level) { redeclaration_error(id, ID_LVAR); } } + if($3.type && $3.type != global_type) { + comp_error("type mismatch"); + } + lval = type_xmalloc(variable_t); lval->name = $1; lval->type = global_type; @@ -684,7 +699,7 @@ init_array(&$$.arr); /* Once for F_ADD, once for F_ASSIGN. */ array_concat(&$$.arr, &$1.arr); - MAKE_LVALUE($$); + make_lvalue(&$$); array_concat(&$$.arr, &$1.arr); array_concat(&$$.arr, &$3.arr); array_push(&$$.arr, (void *) F_ADD); @@ -695,12 +710,8 @@ $$.lval = $$.direct_type = 0; $$.side_effect = $1.side_effect || $3.side_effect; - if(check_operand(F_SUB, $1.type, $3.type)) { - if($1.type != $3.type) { - comp_error("type mismatch"); - } - } - + check_operand(F_SUB, $1.type, $3.type); + $$.type = $1.type; init_array(&$$.arr); @@ -729,7 +740,7 @@ init_array(&$$.arr); /* Once for F_SUB, once for F_ASSIGN. */ array_concat(&$$.arr, &$1.arr); - MAKE_LVALUE($$); + make_lvalue(&$$); array_concat(&$$.arr, &$1.arr); array_concat(&$$.arr, &$3.arr); array_push(&$$.arr, (void *) F_SUB); @@ -769,7 +780,7 @@ init_array(&$$.arr); /* Once for F_MUL, once for F_ASSIGN. */ array_concat(&$$.arr, &$1.arr); - MAKE_LVALUE($$); + make_lvalue(&$$); array_concat(&$$.arr, &$1.arr); array_concat(&$$.arr, &$3.arr); array_push(&$$.arr, (void *) F_MUL); @@ -810,7 +821,7 @@ init_array(&$$.arr); /* Once for F_DIV, once for F_ASSIGN. */ array_concat(&$$.arr, &$1.arr); - MAKE_LVALUE($$); + make_lvalue(&$$); array_concat(&$$.arr, &$1.arr); array_concat(&$$.arr, &$3.arr); array_push(&$$.arr, (void *) F_DIV); @@ -850,7 +861,7 @@ init_array(&$$.arr); /* Once for F_MOD, once for F_ASSIGN. */ array_concat(&$$.arr, &$1.arr); - MAKE_LVALUE($$); + make_lvalue(&$$); array_concat(&$$.arr, &$1.arr); array_concat(&$$.arr, &$3.arr); array_push(&$$.arr, (void *) F_MOD); @@ -913,7 +924,7 @@ $$.lval = $$.direct_type = 0; $$.type = $1.type; init_array(&$$.arr); - MAKE_LVALUE($1); + make_lvalue(&$1); array_concat(&$$.arr, &$1.arr); array_push(&$$.arr, (void *) F_POSTINC); } @@ -927,7 +938,7 @@ $$.lval = $$.direct_type = 0; $$.type = $2.type; init_array(&$$.arr); - MAKE_LVALUE($2); + make_lvalue(&$2); array_concat(&$$.arr, &$2.arr); array_push(&$$.arr, (void *) F_PREINC); } @@ -941,7 +952,7 @@ $$.lval = $$.direct_type = 0; $$.type = $1.type; init_array(&$$.arr); - MAKE_LVALUE($1); + make_lvalue(&$1); array_concat(&$$.arr, &$1.arr); array_push(&$$.arr, (void *) F_POSTDEC); } @@ -956,7 +967,7 @@ $$.type = $2.type; init_array(&$$.arr); - MAKE_LVALUE($2); + make_lvalue(&$2); array_concat(&$$.arr, &$2.arr); array_push(&$$.arr, (void *) F_PREDEC); } @@ -1048,6 +1059,7 @@ init_array(&$$.arr); array_concat(&$$.arr, &$1.arr); + array_concat(&$$.arr, &$3.arr); array_push(&$$.arr, (void *) F_NE); } @@ -1055,11 +1067,13 @@ { check_operand(F_EQ, $1.type, $3.type); - $$.lval = $$.side_effect = $$.direct_type = 0; + $$.lval = $$.direct_type = 0; + $$.side_effect = $1.side_effect || $3.side_effect; $$.type = T_INT; - + init_array(&$$.arr); array_concat(&$$.arr, &$1.arr); + array_concat(&$$.arr, &$3.arr); array_push(&$$.arr, (void *) F_EQ); } @@ -1112,7 +1126,7 @@ array_push(&$$.arr, (void *) F_PUSH_INT); array_push(&$$.arr, (void *) 0); } - | expr '?' expr ':' expr + | expr '?' expr L_RANGE expr { $$.lval = $3.lval && $5.lval; $$.side_effect = $3.side_effect || $5.side_effect; @@ -1134,15 +1148,27 @@ { $$ = $2; /* Could cause problems. */ } - | '(' type ')' expr %prec L_TYPECAST +/* | '(' type ')' expr %prec L_TYPECAST { $$.side_effect = $4.side_effect; $$.lval = $4.lval; $$.direct_type = $4.direct_type; $$.type = $2; + + switch($2.type) { + case T_INT: + if($4.type != T_INT) { + comp_error("invalid cast to int"); + } + break; + case T_OBJECT: + comp_error("invalid cast to object"); + break; + } + init_array(&$$.arr); array_concat(&$$.arr, &$4.arr); - } + }*/ | call_other { $$.side_effect = 1; @@ -1185,18 +1211,20 @@ $$.type = $1->lpc_type; } } - | expr '[' range_expr ']' + | expr '[' slice_expr ']' { $$.lval = 1; - $$.direct_type = 0; - $$.side_effect = 0; - $$.type = T_INT; - check_operand(F_RANGE, $1.type, 0); + $$.direct_type = $$.side_effect = 0; + if((int)$3.data[$3.length-1] == F_INDEX) + $$.type = T_INT; + else + $$.type = T_STRING; + + check_operand(F_INDEX, $1.type, 0); init_array(&$$.arr); array_concat(&$$.arr, &$1.arr); - array_concat(&$$.arr, &$3.arr); - array_push(&$$.arr, (void *) F_RANGE); + array_concat(&$$.arr, &$3); } | expr L_ASSIGN expr { @@ -1207,12 +1235,20 @@ if($1.type && $3.type && $1.type != $3.type) { comp_error("type mismatch"); } + + if((int)$1.arr.data[$1.arr.length-1] == F_SLICE_LVALUE) { + comp_error("assigning to string slices unimplemented"); + } + + /* Check if we are assigning to a slice, then check + the resulting string's length. If bigger, error. + Else allows for some nasty buffer overflows. */ $$.side_effect = 1; $$.type = $1.type; $$.lval = $$.direct_type = 0; init_array(&$$.arr); - MAKE_LVALUE($1); + make_lvalue(&$1); array_concat(&$$.arr, &$1.arr); array_concat(&$$.arr, &$3.arr); array_push(&$$.arr, (void *) F_ASSIGN); @@ -1240,25 +1276,38 @@ } ; -range_expr: +slice_expr: expr { if($1.type != T_INT) { comp_error("index must be integer"); } - $$ = $1; + init_array(&$$); + array_concat(&$$, &$1.arr); + array_push(&$$, (void *) F_INDEX); +/* $$ = $1;*/ } -/* | L_INTEGER '..' L_INTEGER + | expr L_RANGE expr { - if($3 > $1) { - comp_error("range second element should be bigger than first"); + if($1.type != T_INT || $3.type != T_INT) { + + } else { + if($1.direct_type && $3.direct_type) { + int i1, i2; + i1 = (int) $1.arr.data[1]; + i2 = (int) $3.arr.data[1]; + if(i1 > i2) { + comp_error("slice second element should be bigger than first"); + } + } } - array_push(&$$, (void *) F_BEGIN); - array_push(&$$, (void *) $1); - array_push(&$$, (void *) F_END); - array_push(&$$, (void *) $3); + + init_array(&$$); + array_concat(&$$, &$1.arr); + array_concat(&$$, &$3.arr); + array_push(&$$, (void *) F_SLICE); } -*/ + ; string: @@ -1379,11 +1428,13 @@ { int i; for(i=0;i<$6.length;i++) { - if((int)$6.data[i] == F_BREAK) { + if((int)$6.data[i] == F_BREAK_MAGIC1 + && (int)$6.data[i+1] == F_BREAK_MAGIC2) { $6.data[i] = (void *) F_JMP; i++; $6.data[i] = (void *) $6.length - i + 2; - } else if((int)$6.data[i] == F_CONTINUE) { + } else if((int)$6.data[i] == F_CONTINUE_MAGIC1 + && (int)$6.data[i+1] == F_CONTINUE_MAGIC2) { $6.data[i] = (void *) F_JMP; i++; $6.data[i] = (void *) -(i + $4.arr.length + 2); @@ -1410,11 +1461,13 @@ { int i; for(i=0;i<$10.length;i++) { - if((int)$10.data[i] == F_BREAK) { + if((int)$10.data[i] == F_BREAK_MAGIC1 + && (int)$10.data[i+1] == F_BREAK_MAGIC2) { $10.data[i] = (void *) F_JMP; i++; $10.data[i] = (void *) $10.length + $7.arr.length - i - 1; - } else if((int)$10.data[i] == F_CONTINUE) { + } else if((int)$10.data[i] == F_CONTINUE_MAGIC1 && + (int)$10.data[i+1] == F_CONTINUE_MAGIC2) { $10.data[i] = (void *) F_JMP; i++; $10.data[i] = (void *) -(i + $5.arr.length + 5); @@ -1444,8 +1497,8 @@ L_BREAK { init_array(&$$); - array_push(&$$, (void *) F_BREAK); - array_push(&$$, (void *) 0); + array_push(&$$, (void *) F_BREAK_MAGIC1); + array_push(&$$, (void *) F_BREAK_MAGIC2); } ; @@ -1453,8 +1506,8 @@ L_CONTINUE { init_array(&$$); - array_push(&$$, (void *) F_CONTINUE); - array_push(&$$, (void *) 0); + array_push(&$$, (void *) F_CONTINUE_MAGIC1); + array_push(&$$, (void *) F_CONTINUE_MAGIC2); } ; @@ -1477,38 +1530,45 @@ i = compare_args($1->args, &tempargs); switch(i) { - char buf[256]; - case -2: - sprintf(buf, "Too many arguments to %s", $1->name); - comp_error(buf); - break; - case -1: - sprintf(buf, "Too few arguments to %s", $1->name); - comp_error(buf); - break; - case 0: - /* went okay */ - break; - default: /* > 0 */ - sprintf(buf, "Argument %d type mismatch for %s - expected %s, got %s", - i, $1->name, type2str($1->args->data[i]), - type2str(tempargs.data[i])); - comp_error(buf); - break; + char *buf; + case -2: + buf = xmalloc(strlen($1->name) + 23); + sprintf(buf, "Too many arguments to %s", + $1->name); + comp_error(buf); + xfree(buf); + break; + case -1: + buf = xmalloc(strlen($1->name) + 22); + sprintf(buf, "Too few arguments to %s", + $1->name); + comp_error(buf); + xfree(buf); + break; + case 0: + /* went okay */ + break; + default: /* > 0 */ + { + variable_t *v; + char *ts1, *ts2; + + v = tempargs.data[i]; + ts1 = type2str((int)$1->args->data[i]); + ts2 = type2str((int)tempargs.data[i]); + buf = xmalloc(strlen($1->name) + strlen(ts1) + strlen(ts2) + 64); + sprintf(buf, "Argument %d type mismatch for %s " + "- expected %s, got %s", i, $1->name, ts1, ts2); + comp_error(buf); + xfree(buf); + } + break; } if(tempargs.data) xfree(tempargs.data); init_array(&$$); -#if 0 - if($1->type == ID_FUN_PROT) { - char buf[256]; - sprintf(buf, "Function '%s' is called, but not defined", $1->name); - comp_error(buf); - /*goto out;*/ - } -#endif if($1->type == ID_FUN_PROT) $1->has_been_called = 1; @@ -1597,7 +1657,6 @@ e = type_xmalloc(expr_t); *e = $1; array_push(&$$, e); - } | call_arg_list ',' expr { @@ -1645,3 +1704,31 @@ } } ; +%% + +void make_lvalue(expr_t *e) +{ + int len, *begin, *end; + len = e->arr.length-1; + begin = (int *) e->arr.data; + end = (int *) e->arr.data + len; + switch(*end) { + case F_SLICE: + *end = F_SLICE_LVALUE; + goto out; + return; + case F_INDEX: + *end = F_INDEX_LVALUE; + return; + } + +out: + switch(*begin) { + case F_PUSH_LVAR: + *begin = F_PUSH_LVAR_LVALUE; + break; + case F_PUSH_GVAR: + *begin = F_PUSH_GVAR_LVALUE; + } +} + |
From: Peep P. <so...@us...> - 2004-03-28 18:08:48
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31487 Modified Files: lex.l Log Message: Added .. and : operators. Index: lex.l =================================================================== RCS file: /cvsroot/agd/server/src/lex.l,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- lex.l 21 Mar 2004 14:06:36 -0000 1.11 +++ lex.l 28 Mar 2004 17:57:19 -0000 1.12 @@ -244,6 +244,8 @@ "*=" RET(s, "*=", L_MUE); "/=" RET(s, "/=", L_DE); "%=" RET(s, "%=", L_MOE); +".." RET(s, "..", L_RANGE); +":" RET(s, ":", L_RANGE); "({" RET(s, "({", L_OPEN_ARRAY); "([" RET(s, "([", L_OPEN_MAPPING); |
From: Peep P. <so...@us...> - 2004-03-28 18:08:30
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31446 Modified Files: main.c net.c lpc_incl.h lpc.h Log Message: Small, subtle changes. Index: net.c =================================================================== RCS file: /cvsroot/agd/server/src/net.c,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- net.c 21 Mar 2004 16:37:06 -0000 1.12 +++ net.c 28 Mar 2004 17:57:04 -0000 1.13 @@ -2,6 +2,7 @@ net.c - network communication started in summer 2003 */ + #include <stdio.h> #include <string.h> #include "sys.h" @@ -11,8 +12,8 @@ #include "array.h" #include "lpc.h" #include "object.h" -#include "interpret.h" #include "net.h" +#include "interpret.h" #include <errno.h> @@ -117,7 +118,7 @@ if(!login_ob->u.ob) { fprintf(stderr, "Warning: master::connect() didn't return an object.\n"); - do_write("Oops, glitch in world fabric - you didn't get an object.\n"); + do_write("Oops, glitch in world fabric - you didn't get a login object.\n"); xfree(player_ob); net_disconnect(p); return; Index: lpc_incl.h =================================================================== RCS file: /cvsroot/agd/server/src/lpc_incl.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- lpc_incl.h 21 Mar 2004 08:56:52 -0000 1.5 +++ lpc_incl.h 28 Mar 2004 17:57:10 -0000 1.6 @@ -6,8 +6,8 @@ #include "lpc.h" #include "object.h" #include "compile.h" -#include "interpret.h" #include "net.h" +#include "interpret.h" #include "dfuns.h" #include "vars.h" Index: lpc.h =================================================================== RCS file: /cvsroot/agd/server/src/lpc.h,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- lpc.h 15 Mar 2004 18:49:30 -0000 1.6 +++ lpc.h 28 Mar 2004 17:57:10 -0000 1.7 @@ -21,9 +21,9 @@ #define ST_STATIC 2 typedef struct variable_t { - int type; + unsigned char type; char *name; - int string_type; + char string_type; union { long int i; #if 0 Index: main.c =================================================================== RCS file: /cvsroot/agd/server/src/main.c,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- main.c 21 Mar 2004 14:06:23 -0000 1.16 +++ main.c 28 Mar 2004 17:57:04 -0000 1.17 @@ -1,7 +1,7 @@ /* Adventure Game Driver - a graphical MUD driver with AGI-like graphics, using LPC for scripting - Copyright (C) 2003, 2004 Peep Pullerits (so...@es...) + Copyright (C) 2003, 2004 Peep Pullerits <so...@es...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -32,6 +32,9 @@ #include "object.h" #include "compile.h" +#include "net.h" +#include "interpret.h" + extern object_t *master; static char *conf_file; @@ -52,7 +55,7 @@ /* We generally do not want to debug the crash function. Causes unnecessary spam. */ dont_debug_interpreter = 1; #endif - + if(master) { if(!apply(master, "crash", "i", sig)) fprintf(stderr, "master::crash() failed.\n"); |
From: Peep P. <so...@us...> - 2004-03-28 18:07:35
|
Update of /cvsroot/agd/server/doc/dfuns In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31326 Added Files: asctime atoi query_hostname query_ip read_file strftime Log Message: Documentation for new dfuns. --- NEW FILE: query_ip --- --- NEW FILE: atoi --- --- NEW FILE: read_file --- --- NEW FILE: strftime --- string strftime(int, string) Turns the time given by the integer into a string, specified by a format string. If the resulting string is over 512 characters long, strftime will return an empty string. --- NEW FILE: asctime --- --- NEW FILE: query_hostname --- |
From: Peep P. <so...@us...> - 2004-03-28 18:05:51
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31077 Modified Files: compile.c Log Message: Separated object loading and program compilation into load_object() and compile_prog() - allows for recompilation in situ; changed static string buffers to strings on the heap Index: compile.c =================================================================== RCS file: /cvsroot/agd/server/src/compile.c,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- compile.c 21 Mar 2004 13:02:37 -0000 1.17 +++ compile.c 28 Mar 2004 17:54:29 -0000 1.18 @@ -3,9 +3,9 @@ #include "lex.h" /* for yylloc */ #include "lpc_incl.h" -static object_t *cob; -static function_t *curr_f; -static char *curr_fn; +static program_t *this_prog; +static function_t *curr_f; /* TODO: rename to curr_fun. */ +static char *this_file; int compile_errors, compile_warnings; @@ -15,7 +15,6 @@ numdfuns, numlfuns; array_t local_ids, global_ids; -/*static int locals_level;*/ static array_t *curr_block; static array_t block_history; @@ -221,7 +220,7 @@ case F_OR: SET_OPERATOR("||", 2, 0, 1, 1, 1); break; - case F_RANGE: + case F_INDEX: SET_OPERATOR("[]", 1, 0, 0, 1, 0); break; case F_POW: @@ -240,7 +239,8 @@ int check_operand(int operator, int opr1, int opr2) { int ret; - char buf[128]; + char buf[256]; /* Safe, since operator names + are set in the code. */ operator_t *op; if(opr1 == T_VOID) { @@ -251,6 +251,7 @@ if(!opr1) return; + /* Really necessary? */ memset(buf, 0, sizeof buf); op = &operator_table[operator-F_ADD]; @@ -258,15 +259,15 @@ (op->num_operand == 2 && opr2 && op->both_same_type && opr1 != opr2)) { switch(op->num_operand) { - case 1: - sprintf(buf, "wrong type argument to unary "); - break; - case 2: - sprintf(buf, "invalid operands to binary "); - break; - case 3: - sprintf(buf, "invalid operands to trinary "); - break; + case 1: + sprintf(buf, "wrong type argument to unary "); + break; + case 2: + sprintf(buf, "invalid operands to binary "); + break; + case 3: + sprintf(buf, "invalid operands to trinary "); + break; } sprintf(buf, "%s%s", buf, op->name); comp_error(buf); @@ -322,10 +323,10 @@ void add_function(def_id_t *idp, int lineno, array_t *code) { - if(idp->index < cob->prog->functions.length) { + if(idp->index < this_prog->functions.length) { function_t *f; /* Adding definition for a prototype. */ - f = cob->prog->functions.data[idp->index]; + f = this_prog->functions.data[idp->index]; f->type = idp->lpc_type; if(idp->args) f->args = *idp->args; @@ -340,23 +341,9 @@ if(code) curr_f->code = *code; curr_f->lineno = lineno; -#if 0 - if(idp->index == cob->prog->functions.length) { -#endif - array_push(&cob->prog->functions, curr_f); - /* This removes the need to generate a fun_table. */ - array_push(&cob->prog->fun_table, idp->name); -#if 0 - } else { /* index > length */ - cob->prog->functions.length = idp->index + 1; - alloc_array(&cob->prog->functions); - cob->prog->functions.data[idp->index] = curr_f; - - cob->prog->fun_table.length = idp->index + 1; - alloc_array(&cob->prog->fun_table); - cob->prog->fun_table.data[idp->index] = idp->name; - } -#endif + array_push(&this_prog->functions, curr_f); + /* This removes the need to generate a fun_table. */ + array_push(&this_prog->fun_table, idp->name); curr_f = NULL; } @@ -382,17 +369,25 @@ var = var->u.a->data[0]; } - init_var(var); + /*init_var(var);*/ if(type == ID_GVAR) { - array_push(&cob->variables, var); + /*array_push(&cob->variables, var);*/ + /* this_ob is set to the compiled object during compilation. */ + array_push(&this_ob->variables, var); } else /* LVAR */{ switch(var->type) { case T_INT: array_push(curr_block, (void *) F_PUSH_INT); + if(var->u.i) { + printf("add_varible(): var->u.i is not 0!\n"); + } array_push(curr_block, (void *) var->u.i); break; case T_STRING: array_push(curr_block, (void *) F_PUSH_STRING); + if(var->u.s) { + printf("add_variable(): var->u.s is not null!\n"); + } array_push(curr_block, (void *) var->u.s); break; case T_OBJECT: @@ -426,10 +421,6 @@ array_push(&block_history, curr_block); curr_block = type_xmalloc(array_t); init_array(curr_block); -/* if(!locals_level) { - free_array(&temp_variables, (void (*)(void*))free_var); - } - locals_level++;*/ } array_t add_block(array_t *stmt) @@ -448,11 +439,6 @@ curr_block = block_history.data[block_history.length]; /*block_history.data = realloc(block_history.data, block_history.length);*/ -/* if(locals_level > 0) - locals_level--; - if(!locals_level) { - free_array(&temp_nametable, (void (*)(void*))free_ntentry NULL); - }*/ } int compare_args(array_t *arg1, array_t *arg2) @@ -463,35 +449,38 @@ if(arg2->length < arg1->length) return -1; for(i=0;i<arg1->length;i++) { - if((int)arg1->data[i] != (int)arg2->data[i]) { +/* if(arg != (int)arg2->data[i] && (arg->type == T_INT && arg->u.i)) { return i; - } + }*/ } return 0; } void redeclaration_error(def_id_t *id, int new_type) { - char buf[256]; + char *buf, *buf2; + buf = xmalloc(strlen(id->name) + 16); sprintf(buf, "%s redeclared as ", id->name); switch(new_type) { case ID_ARG: - sprintf(buf, "%sfunction argument", buf); + buf2 = "function argument"; break; case ID_FUN: - sprintf(buf, "%slocal function", buf); + buf2 = "local function"; break; case ID_LVAR: - sprintf(buf, "%slocal variable", buf); + buf2 = "local variable"; break; case ID_GVAR: - sprintf(buf, "%sglobal variable", buf); + buf2 = "global variable"; break; default: - sprintf(buf, "%sidontknowwhat!", buf); + buf2 = "idontknowwhat!"; break; } + buf = strcat(buf, buf2); comp_error(buf); + xfree(buf); } /* This does the actual formatting. */ @@ -505,7 +494,7 @@ } /* buf = xmalloc(strlen(s) + 256); - s*/printf(/*buf, */"%s:%d:%d: %s\n", curr_fn, yylloc.line, yylloc.pos, s); + s*/printf(/*buf, */"%s:%d:%d: %s\n", this_file, yylloc.line, yylloc.pos, s); /* do_write(buf); xfree(buf);*/ } @@ -526,20 +515,16 @@ { compile_errors = 0; - init_array(&cob->prog->functions); - init_array(&cob->prog->fun_table); - init_array(&cob->variables); + init_array(&this_prog->functions); + init_array(&this_prog->fun_table); + init_array(&this_ob->variables); numlvars = numgvars = 0; numdfuns = numlfuns = 0; /*curr_f_check();*/ -/* init_array(&defined_names); - init_array(&temp_nametable); - init_array(&temp_variables);*/ free_array(&local_ids, free_id); - init_array(&block_history); yylloc.pos = 0; @@ -556,73 +541,54 @@ for(i=0;i<local_ids.length;i++) { def_id_t *id = local_ids.data[i]; if(id->type == ID_FUN_PROT && id->has_been_called) { - char buf[256]; - sprintf(buf, "Function %s has been called, but not defined", id->name); + char *buf; + buf = xmalloc(strlen(id->name) + 43); + sprintf(buf, "Function %s has been called, " + "but not defined", id->name); comp_error(buf); + xfree(buf); return 1; } } return 0; } -#define END_COMPILE() cob = NULL; start_with_newline = 0; actual_destruct(ob); xfree(file_name); return NULL -object_t *load_object(char *fn) +program_t *compile_prog(char *path) { - char *file_name, *our_fn; - object_t *ob; + char *real_path; + program_t *prog; + #ifdef DEBUG struct timeval tm, tm2; #endif - if(!legal_path(fn)) { - printf("load_object(): illegal path name \"%s\"!\n", fn); - return NULL; - } - - if(fn[strlen(fn)-2] != '.' && fn[strlen(fn)-1] != 'c') { - our_fn = xmalloc((strlen(fn) + 3)); - sprintf(our_fn, "%s.c", fn); - } else { - our_fn = stringdup(fn); - } + path = add_extension(path); #ifdef DEBUG if(conf.debuglevel > 1) gettimeofday(&tm, NULL); #endif - file_name = xmalloc(strlen(conf.lib_root) + strlen(our_fn) + 1); - sprintf(file_name, "%s%s", conf.lib_root, our_fn); - - ob = type_xmalloc(object_t); - memset(ob, 0, sizeof(object_t)); - ob->name = our_fn; - cob = ob; - - printf("compiling %s", ob->name); - if(conf.debuglevel) - printf(" (absolute path %s)", file_name); - printf("... "); - + real_path = absolute_path(path); + printf("compiling %s...", path); start_with_newline = 1; - if(access(file_name, R_OK)) { - printf("failed (file not accessable)\n"); - END_COMPILE(); - } - - yyin = fopen(file_name, "r"); + yyin = fopen(real_path, "r"); if(!yyin) { - printf("failed (can't open %s: %s)\n", file_name, strerror(errno)); - END_COMPILE(); + printf("failed (can't open %s: %s)\n", real_path, strerror(errno)); + this_prog = 0; + goto out; } - ob->prog = type_xmalloc(program_t); - memset(ob->prog, 0, sizeof(program_t)); + prog = type_xmalloc(program_t); + memset(prog, 0, sizeof(program_t)); + this_prog = prog; + parse_init(); - curr_fn = ob->name; + this_file = path; +/* curr_fn = ob->name;*/ -#if defined(DEBUG) && defined(YYDEBUG) +#if defined(DEBUG) && YYDEBUG if(conf.debuglevel > 4) { yydebug = 1; } @@ -637,37 +603,45 @@ compile_warnings == 1 ? "": "s"); } printf(" - failed\n"); - END_COMPILE(); + xfree(this_prog); + prog = NULL; + goto out; } if(check_fun_definitions()) { - END_COMPILE(); + xfree(this_prog); + prog = NULL; + goto out; } - ref_prog(ob->prog); - list_push(&all_objects, ob); + ref_prog(prog); #ifdef DEBUG printf("done"); if(conf.debuglevel > 1) { gettimeofday(&tm2, NULL); - printf(" in %d microseconds\n", tm2.tv_usec - tm.tv_usec); + printf(" in %d microseconds\n", abs(tm2.tv_usec - tm.tv_usec)); } else { putchar('\n'); } #else printf("done\n"); #endif - - if(conf.debuglevel > 1) - print_code(ob); - - apply(ob, "create", NULL); +#ifdef DEBUG + if(conf.debuglevel > 1) { + printf("Printing code for program %s:\n", path); + printf("Globals: \n"); + print_var_arr(&this_ob->variables); + printf("\n"); + print_code(prog); + } +#endif - curr_fn = NULL; - cob = NULL; - xfree(file_name); +out: + this_prog = NULL; + this_file = NULL; + xfree(real_path); start_with_newline = 0; - return ob; + return prog; } |
From: Peep P. <so...@us...> - 2004-03-28 18:04:46
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30840 Modified Files: object.c object.h Log Message: Separated object loading and program compilation into load_object() and compile_prog() - allows for recompilation in situ Index: object.c =================================================================== RCS file: /cvsroot/agd/server/src/object.c,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- object.c 21 Mar 2004 10:34:47 -0000 1.11 +++ object.c 28 Mar 2004 17:53:27 -0000 1.12 @@ -9,33 +9,27 @@ player_t *this_player; object_t *this_ob, *previous_ob; -/* this for clone_object() */ -void *copy_fun(void *voidf) -{ - function_t *f = voidf, *p; - p = type_xmalloc(function_t); - *p = *f; - return p; -} - void free_fun(void *p) { int i; function_t *f = p; -#if 0 + for(i=0;i<f->args.length;i++) free_var(f->args.data[i]); if(f->args.data) xfree(f->args.data); + + /* Can't do this. Need string tables. */ +#if 0 for(i=0;i<f->code.length;i++) { - int vmt = (int) f->code.data[i]; - /* Inefficient and risky, yes. */ - if((vmt == F_VAR_T || vmt == F_LOCAL) && vmt > F_HIGHEST) { - free_var(f->code.data[i]); - } + if((int) f->code.data[i] == F_PUSH_STRING) { + i++; + if(f->code.data[i]) + xfree(f->code.data[i]); + } } - xfree(f->code.data); #endif + xfree(f->code.data); } void destruct(object_t *ob) @@ -47,7 +41,8 @@ ob->flags |= O_DESTRUCTED; - unref_ob(ob->parent, NULL); + /*unref_ob(ob->parent, NULL);*/ + if(ob->iaob) { net_disconnect(ob->iaob); ob->iaob->ob = NULL; @@ -66,18 +61,13 @@ void actual_destruct(object_t *ob) { list_remove(&all_objects, ob); - if(unref_prog(ob->prog)) { - ob->prog = NULL; - } - /* - free_array(&ob->prog->fun_table, NULL); - free_array(&ob->prog->functions, free_fun); - xfree(ob->prog); - */ + unref_prog(&ob->prog); + free_array(&ob->variables, (void (*)(void*))free_var); if(ob->name) xfree(ob->name); + xfree(ob); } @@ -102,50 +92,98 @@ prog->ref++; } -/* Returns 1 if program was freed. */ -int unref_prog(program_t *prog) +void unref_prog(program_t **prog) { - if(!prog) - return 0; + program_t *p = *prog; + + if(!p) + return; - prog->ref--; - if(prog->ref <= 0) { - free_array(&prog->functions, free_fun); - free_array(&prog->fun_table, NULL); - xfree(prog); - return 1; + p->ref--; + if(p->ref <= 0) { + free_array(&p->functions, free_fun); + free_array(&p->fun_table, NULL); + xfree(p); + *prog = NULL; } - return 0; } object_t *find_object(char *s) { list_t *p; - char *name; - - if(s[strlen(s)-2] != '.') { - char *p = xmalloc(strlen(s) + 3); - strcpy(p, s); - strcat(p, ".c"); - name = p; - } else { - name = s; - } + if(!all_objects.data) + return NULL; + for(p = &all_objects; p; p = p->next) { object_t *ob = p->data; - if(ob->name && strcmp(name, ob->name) == 0) { - if(name != s) - xfree(name); + /* I'd rather not have the check for ob->name here. */ + if(ob->name && strcmp(s, ob->name) == 0) { return ob; } } - if(name != s) - xfree(name); return NULL; } +object_t *load_object(char *path) +{ + object_t *ob, + *saved_this_ob, + *saved_prev_ob; + + if(!legal_path(path)) { + printf("load_object(): illegal path name \"%s\"!\n", path); + return NULL; + } + + saved_this_ob = this_ob; + saved_prev_ob = previous_ob; + previous_ob = saved_this_ob; + + ob = find_object(path); + this_ob = ob; + if(ob) { + /* Try to recompile the object's + * code. */ + program_t *new_prog; + new_prog = compile_prog(path); + if(!new_prog) { + /* Runtime? */ + ob = NULL; + goto out; + } else { + unref_prog(&ob->prog); + /* new_prog is already referenced by compile_prog() */ + ob->prog = new_prog; + apply(ob, "create", NULL); + goto out; + } + } + + /* path = remove_extension(path); ? */ + ob = type_xmalloc(object_t); + memset(ob, 0, sizeof(object_t)); + ob->name = path; + + this_ob = ob; + + ob->prog = compile_prog(path); + if(!ob->prog) { + xfree(ob); + ob = NULL; + goto out; + } + + list_push(&all_objects, ob); + apply(ob, "create", NULL); + +out: + this_ob = saved_this_ob; + previous_ob = saved_prev_ob; + return ob; +} + object_t *clone_object(char *name) { object_t *base_ob, *new_ob; @@ -156,15 +194,17 @@ if(!base_ob) return NULL; } - + +#ifdef DEBUG debug("dfun", "cloning object %s\n", name); +#endif - ref_ob(base_ob, NULL); +/* ref_ob(base_ob, NULL);*/ new_ob = type_xmalloc(object_t); memset(new_ob, 0, sizeof(object_t)); new_ob->parent = base_ob; new_ob->name = xmalloc(strlen(base_ob->name) + 10); - sprintf(new_ob->name, "%s#%d", base_ob->name, base_ob->ref); + sprintf(new_ob->name, "%s#%d", base_ob->name, base_ob->prog->ref); new_ob->prog = base_ob->prog; ref_prog(new_ob->prog); @@ -178,16 +218,10 @@ return new_ob; } -/* This is pointless. */ -int interactivep(object_t *ob) -{ - return ob && ob->iaob; -} - void tell_object(object_t *ob, char *s) { player_t *p; - if(!interactivep(ob)) { + if(!ob || !ob->iaob) { return; } p = ob->iaob; @@ -195,7 +229,6 @@ } -#ifdef DEBUG void report_obs(void) { printf("this_ob: %p ", this_ob); @@ -236,4 +269,3 @@ } printf("-----------------------------------------\n"); } -#endif Index: object.h =================================================================== RCS file: /cvsroot/agd/server/src/object.h,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- object.h 18 Mar 2004 20:45:20 -0000 1.6 +++ object.h 28 Mar 2004 17:53:27 -0000 1.7 @@ -36,14 +36,10 @@ void ref_ob(object_t *ob, variable_t *v); void unref_ob(object_t *ob, variable_t *v); void ref_prog(program_t *prog); -int unref_prog(program_t *prog); +void unref_prog(program_t **prog); object_t *find_object(char *name); +object_t *load_object(char *path); object_t *clone_object(char *name); -int interactivep(object_t *ob); -/* -object_t *this_object(void); -object_t *previous_object(void); -*/ void tell_object(object_t *ob, char *s); void do_exec(object_t *ob); char *file_name(object_t *ob); |
From: Peep P. <so...@us...> - 2004-03-28 18:02:06
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30467 Modified Files: sys.c sys.h Log Message: Added add_extension(), absolute_path() Index: sys.h =================================================================== RCS file: /cvsroot/agd/server/src/sys.h,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- sys.h 21 Mar 2004 10:34:47 -0000 1.6 +++ sys.h 28 Mar 2004 17:50:47 -0000 1.7 @@ -36,4 +36,7 @@ int check_logfile(void); void debug(char *prefix, char *fmt, ...); +char *add_extension(char *str); +char *absolute_path(char *path); + #endif Index: sys.c =================================================================== RCS file: /cvsroot/agd/server/src/sys.c,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- sys.c 21 Mar 2004 13:43:50 -0000 1.11 +++ sys.c 28 Mar 2004 17:50:47 -0000 1.12 @@ -144,7 +144,7 @@ if(!p) { fprintf(stderr, "Out of memory!\n"); - exit(1); + /* Call crash() ? */ } mstats.total_alloced += bytes; @@ -185,3 +185,27 @@ return p; } +/* This makes a copy of str, and adds ".c" to the end. */ +char *add_extension(char *str) +{ + char *buf; + int len = strlen(str); + + if(str[len-2] != '.' && str[len-1] != 'c') { + buf = xmalloc(len + 3); + sprintf(buf, "%s.c", str); + } else { + buf = stringdup(str); + } + return buf; +} + +char *absolute_path(char *path) +{ + char *s; + s = xmalloc(strlen(conf.lib_root) + strlen(path) + 1); + strcpy(s, conf.lib_root); + s = strcat(s, path); + return s; +} + |
From: Peep P. <so...@us...> - 2004-03-28 18:00:52
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30211 Modified Files: vars.h vars.c Log Message: Changed type2str to take an integer instead of a variable_t as argument. Index: vars.c =================================================================== RCS file: /cvsroot/agd/server/src/vars.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- vars.c 21 Mar 2004 10:34:15 -0000 1.9 +++ vars.c 28 Mar 2004 17:49:33 -0000 1.10 @@ -95,7 +95,7 @@ switch(var->type) { case T_INT: var->u.i = 0; break; case T_STRING: - var->u.s = "0"; + var->u.s = ""; var->string_type = ST_STATIC; break; case T_OBJECT: var->u.ob = NULL; break; @@ -234,9 +234,9 @@ } /* lang.y uses this. */ -char *type2str(variable_t *v) +char *type2str(int t) { - switch(v->type) { + switch(t) { case T_INT: return "int"; case T_STRING: Index: vars.h =================================================================== RCS file: /cvsroot/agd/server/src/vars.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- vars.h 21 Mar 2004 10:34:15 -0000 1.5 +++ vars.h 28 Mar 2004 17:49:32 -0000 1.6 @@ -12,6 +12,6 @@ void assign_var(variable_t *dest, variable_t *src); void assign_var_value(variable_t *var, void *val); -char *type2str(variable_t *v); +char *type2str(int t); #endif |
From: Peep P. <so...@us...> - 2004-03-21 19:53:32
|
Update of /cvsroot/agd/server In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25538 Modified Files: ChangeLog NEWS TODO Log Message: New dfun: strftime() Index: NEWS =================================================================== RCS file: /cvsroot/agd/server/NEWS,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- NEWS 21 Mar 2004 14:06:35 -0000 1.8 +++ NEWS 21 Mar 2004 18:32:33 -0000 1.9 @@ -3,7 +3,7 @@ * break; and continue; statements * New operators: **, **= * New dfuns: query_ip, query_hostname (use with caution, may block for quite a while), - asctime. + asctime, strftime. time() was changed to return seconds since Epoch. * k, m, K and M integer constants 1k = 1000, 1m = 1000000, 1K = 1024, 1M = 1048576 (1024*1024) Index: TODO =================================================================== RCS file: /cvsroot/agd/server/TODO,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- TODO 21 Mar 2004 16:37:06 -0000 1.15 +++ TODO 21 Mar 2004 18:32:33 -0000 1.16 @@ -50,8 +50,6 @@ - octal: \0onnn - hexadecimal: \0xnn - binary: \0bnnnnnnnn - - dfuns: - - strftime() - mudlib: /update command - better logging system Index: ChangeLog =================================================================== RCS file: /cvsroot/agd/server/ChangeLog,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- ChangeLog 21 Mar 2004 14:06:35 -0000 1.14 +++ ChangeLog 21 Mar 2004 18:32:33 -0000 1.15 @@ -10,7 +10,7 @@ * fixed the functionality of time() - works as expected. time() now returns seconds since the Epoch, asctime() returns its argument as a string. - * dfuns: query_ip(), query_hostname() + * dfuns: query_ip(), query_hostname(), strftime() * k, m, K, M (the latter two suggested by elver) integer constants 1k = 1000 1m = 1000000 |
From: Peep P. <so...@us...> - 2004-03-21 19:53:22
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25538/src Modified Files: dfdecl.in dfuns.c Log Message: New dfun: strftime() Index: dfuns.c =================================================================== RCS file: /cvsroot/agd/server/src/dfuns.c,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- dfuns.c 21 Mar 2004 10:35:53 -0000 1.15 +++ dfuns.c 21 Mar 2004 18:32:35 -0000 1.16 @@ -128,23 +128,6 @@ push_string(s, ST_STATIC); } -void df_time(void) -{ - push_int(time(NULL)); -} - -void df_asctime(void) -{ - time_t t; - char *s; - - t = fp->u.i; - s = ctime(&t); - s[strlen(s)-1] = '\0'; /* Remove the newline. */ - pop_stack(); - push_string(s, ST_STATIC); -} - void df_shout(void) { shout(fp[0].u.s, fp[1].u.ob); @@ -249,13 +232,6 @@ push_string(ret, ST_STATIC); } -void df_uptime(void) -{ - time_t t; - time(&t); - push_int(t - startup_time); -} - void df_query_idle(void) { int ret; @@ -276,6 +252,45 @@ push_int(j); } +/* Time. */ +void df_uptime(void) +{ + time_t t; + time(&t); + push_int(t - startup_time); +} + +void df_time(void) +{ + push_int(time(NULL)); +} + +void df_asctime(void) +{ + time_t t; + char *s; + + t = fp->u.i; + s = ctime(&t); + s[strlen(s)-1] = '\0'; /* Remove the newline. */ + pop_stack(); + push_string(s, ST_STATIC); +} + +void df_strftime(void) +{ + struct tm *tm; + time_t t; + static char buf[512]; + + t = fp[0].u.i; + tm = localtime(&t); + strftime(buf, 512, fp[1].u.s, tm); + pop_stack(); pop_stack(); + + push_string(buf, ST_STATIC); +} + /* Strings. */ void df_strlen(void) { Index: dfdecl.in =================================================================== RCS file: /cvsroot/agd/server/src/dfdecl.in,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- dfdecl.in 21 Mar 2004 10:36:28 -0000 1.8 +++ dfdecl.in 21 Mar 2004 18:32:35 -0000 1.9 @@ -26,9 +26,12 @@ string query_ip(object) string query_hostname(object) -# misc +# Time. int time() string asctime(int) +string strftime(int, string) + +# misc string version() string platform() int uptime() |
From: Peep P. <so...@us...> - 2004-03-21 19:53:17
|
Update of /cvsroot/agd/server/lib/sys In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25538/lib/sys Modified Files: login.c player.c Log Message: New dfun: strftime() Index: player.c =================================================================== RCS file: /cvsroot/agd/server/lib/sys/player.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- player.c 21 Mar 2004 10:36:28 -0000 1.10 +++ player.c 21 Mar 2004 18:32:35 -0000 1.11 @@ -75,7 +75,8 @@ break; }*/ if(cmd == "/quit") { - shout(asctime(time()) + ": " + capitalize(_name) + " has quit the game\n", this_object()); + shout(strftime(time(), "[%H:%M] ") + capitalize(_name) + + " has quit the game\n", this_object()); destruct(this_object()); } else if(cmd == "/uptime") { write("AGD " + version() + " has been running for " + ctime(uptime()) + ".\n"); @@ -85,8 +86,7 @@ write_help(); } else if(cmd == "/time") { int t = time(); - write("The current time is: " + asctime(t) - + ".\n"); + write("The current time is: " + asctime(t) + ".\n"); } else if(cmd == "/report") { report_obs(); } else if(cmd == "/.") { @@ -98,10 +98,10 @@ write("Unknown command.\n"); } } else { - string t = asctime(time()); - shout(t + ": " + capitalize(_name) + " says: " + + string t = strftime(time(), "[%H:%M] "); + shout(t + capitalize(_name) + " says: " + cmd + "\n", this_object()); - write(t + ": You say: " + cmd + "\n"); + write(t + "You say: " + cmd + "\n"); } if(cmd != "/.") { last_cmd = cmd; Index: login.c =================================================================== RCS file: /cvsroot/agd/server/lib/sys/login.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- login.c 21 Mar 2004 08:54:12 -0000 1.5 +++ login.c 21 Mar 2004 18:32:35 -0000 1.6 @@ -23,9 +23,9 @@ } ob->set_name(name); - t = asctime(time()); - shout(t + ": " + name + " has joined the game\n", this_object()); - write(t + ": You have joined the game.\n"); + t = strftime(time(), "[%H:%M] "); + shout(t + name + " has joined the game\n", this_object()); + write(t + "You have joined the game.\n"); write("Use '/help' to get a list of commands.\n"); exec(ob); destruct(this_object()); |
From: Peep P. <so...@us...> - 2004-03-21 19:50:02
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25476 Modified Files: Makefile.in Log Message: Regenerated. Index: Makefile.in =================================================================== RCS file: /cvsroot/agd/server/src/Makefile.in,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- Makefile.in 20 Mar 2004 19:15:54 -0000 1.8 +++ Makefile.in 21 Mar 2004 18:32:09 -0000 1.9 @@ -119,7 +119,7 @@ dist_pkgdata_DATA = options noinst_PROGRAMS = dfparse -dfparse_SOURCES = dfparse.y dflex.l dflex.h +dfparse_SOURCES = dfparse.y dflex.l dfparse_LDADD = sys.o array.o log.o @LEXLIB@ BUILT_SOURCES = dfdecl.h |
From: Peep P. <so...@us...> - 2004-03-21 16:47:15
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32444/src Modified Files: Makefile.am arch.h net.c Log Message: Some minor changes, compilation fixes. Index: net.c =================================================================== RCS file: /cvsroot/agd/server/src/net.c,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- net.c 21 Mar 2004 13:43:05 -0000 1.11 +++ net.c 21 Mar 2004 16:37:06 -0000 1.12 @@ -3,6 +3,7 @@ started in summer 2003 */ #include <stdio.h> +#include <string.h> #include "sys.h" #include "compile_options.h" Index: Makefile.am =================================================================== RCS file: /cvsroot/agd/server/src/Makefile.am,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- Makefile.am 18 Mar 2004 20:49:10 -0000 1.8 +++ Makefile.am 21 Mar 2004 16:37:06 -0000 1.9 @@ -11,7 +11,7 @@ dist_pkgdata_DATA = options noinst_PROGRAMS = dfparse -dfparse_SOURCES = dfparse.y dflex.l dflex.h +dfparse_SOURCES = dfparse.y dflex.l dfparse_LDADD = sys.o array.o log.o @LEXLIB@ dflex.c: dfparse.c Index: arch.h =================================================================== RCS file: /cvsroot/agd/server/src/arch.h,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- arch.h 21 Mar 2004 08:56:42 -0000 1.6 +++ arch.h 21 Mar 2004 16:37:06 -0000 1.7 @@ -1,6 +1,6 @@ #ifndef _ARCH_H #define _ARCH_H -/* OpenBSD, QNX, OpenVMS/VAX, Cygwin, OS/2? */ +/* OpenBSD, QNX, OpenVMS/VAX, Cygwin, OS/2, BeOS? */ /* Operating system checks */ #ifdef __linux |
From: Peep P. <so...@us...> - 2004-03-21 16:47:15
|
Update of /cvsroot/agd/server In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32444 Modified Files: BUGS TODO configure.ac Log Message: Some minor changes, compilation fixes. Index: configure.ac =================================================================== RCS file: /cvsroot/agd/server/configure.ac,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- configure.ac 21 Mar 2004 08:56:42 -0000 1.5 +++ configure.ac 21 Mar 2004 16:37:06 -0000 1.6 @@ -22,7 +22,7 @@ # Checks for libraries. AC_CHECK_LIB(m, floor) #AC_CHECK_LIB(resolv, accept) -#AC_CHECK_LIB(nsl, gethostbyaddr) +AC_CHECK_LIB(nsl, gethostbyaddr) AC_CHECK_LIB(socket, socket) # Checks for header files. Index: TODO =================================================================== RCS file: /cvsroot/agd/server/TODO,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- TODO 21 Mar 2004 14:06:35 -0000 1.14 +++ TODO 21 Mar 2004 16:37:06 -0000 1.15 @@ -86,3 +86,4 @@ - make maintainer-clean shouldn't delete src/dfparse.h and src/lang.h - some terminals don't support \t, find out if it is possible to check for it, and then print out 8 spaces instead. + - on 64-bit, increase cp as a void* type. Index: BUGS =================================================================== RCS file: /cvsroot/agd/server/BUGS,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- BUGS 21 Mar 2004 14:06:35 -0000 1.8 +++ BUGS 21 Mar 2004 16:37:06 -0000 1.9 @@ -32,5 +32,8 @@ string s; s = s + "abc"; will result in "0abc" + - crashes on Solaris/SPARC with a SIGSEGV somewhere + between lines 190 and 199 in net.c (don't have gdb + on that host). - continue from here.. |
From: Peep P. <so...@us...> - 2004-03-21 14:17:05
|
Update of /cvsroot/agd/server In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4008 Modified Files: BUGS ChangeLog NEWS TODO Log Message: Added for(). Index: NEWS =================================================================== RCS file: /cvsroot/agd/server/NEWS,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- NEWS 21 Mar 2004 13:26:17 -0000 1.7 +++ NEWS 21 Mar 2004 14:06:35 -0000 1.8 @@ -1,4 +1,5 @@ New things in this version (0.0.2-3) that you might find useful: + * for() * break; and continue; statements * New operators: **, **= * New dfuns: query_ip, query_hostname (use with caution, may block for quite a while), Index: TODO =================================================================== RCS file: /cvsroot/agd/server/TODO,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- TODO 21 Mar 2004 13:43:23 -0000 1.13 +++ TODO 21 Mar 2004 14:06:35 -0000 1.14 @@ -13,7 +13,7 @@ - inheritance - better error recovery for lpc.y ! arrays (T_ARRAY) - ! for(), foreach(), switch() + ! foreach(), switch() ! all of the operators (/doc/lpc/operators) - ',' - this takes some serious grammar-hacking - mixed type Index: BUGS =================================================================== RCS file: /cvsroot/agd/server/BUGS,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- BUGS 21 Mar 2004 13:26:17 -0000 1.7 +++ BUGS 21 Mar 2004 14:06:35 -0000 1.8 @@ -32,9 +32,5 @@ string s; s = s + "abc"; will result in "0abc" - - lexical tie-ins stay activated on errors: - while(abcdef) { } - break; continue; - Only gives errors for "undeclared identifier 'abcdef'", but not for the break and continue. - continue from here.. Index: ChangeLog =================================================================== RCS file: /cvsroot/agd/server/ChangeLog,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- ChangeLog 21 Mar 2004 13:26:17 -0000 1.13 +++ ChangeLog 21 Mar 2004 14:06:35 -0000 1.14 @@ -1,6 +1,7 @@ 0.0.2-3: ---------------------------------------------------------------------------- 2004-03-21 + * for() statement * added break; and continue; * new operators: ** (power), **= (x = x ** y) * debuglevel can now be set with option "-d=x", where x is a number. |
From: Peep P. <so...@us...> - 2004-03-21 14:16:55
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4008/src Modified Files: lang.h lang.y lex.l Log Message: Added for(). Index: lang.h =================================================================== RCS file: /cvsroot/agd/server/src/lang.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- lang.h 21 Mar 2004 13:26:17 -0000 1.5 +++ lang.h 21 Mar 2004 14:06:36 -0000 1.6 @@ -34,45 +34,46 @@ L_ELSE = 260, L_DO = 261, L_WHILE = 262, - L_CONTINUE = 263, - L_BREAK = 264, - L_DATA_TYPE = 265, - L_IDENTIFIER = 266, - L_STRING = 267, - L_INTEGER = 268, - L_OPEN_MAPPING = 269, - L_CLOSE_MAPPING = 270, - L_OPEN_ARRAY = 271, - L_CLOSE_ARRAY = 272, - L_OPEN_FUNP = 273, - L_CLOSE_FUNP = 274, - L_ASSIGN = 275, - L_ME = 276, - L_PE = 277, - L_DE = 278, - L_MOE = 279, - L_MUE = 280, - L_POWE = 281, - L_AND = 282, - L_OR = 283, - L_NE = 284, - L_EQ = 285, - L_MINUS = 286, - L_PLUS = 287, - L_GE = 288, - L_LE = 289, - L_GT = 290, - L_LT = 291, - L_MOD = 292, - L_DIV = 293, - L_MUL = 294, - L_POW = 295, - L_DEREF = 296, - L_DEC = 297, - L_INC = 298, - L_NOT = 299, - L_NEG = 300, - L_TYPECAST = 301 + L_FOR = 263, + L_CONTINUE = 264, + L_BREAK = 265, + L_DATA_TYPE = 266, + L_IDENTIFIER = 267, + L_STRING = 268, + L_INTEGER = 269, + L_OPEN_MAPPING = 270, + L_CLOSE_MAPPING = 271, + L_OPEN_ARRAY = 272, + L_CLOSE_ARRAY = 273, + L_OPEN_FUNP = 274, + L_CLOSE_FUNP = 275, + L_ASSIGN = 276, + L_ME = 277, + L_PE = 278, + L_DE = 279, + L_MOE = 280, + L_MUE = 281, + L_POWE = 282, + L_AND = 283, + L_OR = 284, + L_NE = 285, + L_EQ = 286, + L_MINUS = 287, + L_PLUS = 288, + L_GE = 289, + L_LE = 290, + L_GT = 291, + L_LT = 292, + L_MOD = 293, + L_DIV = 294, + L_MUL = 295, + L_POW = 296, + L_DEREF = 297, + L_DEC = 298, + L_INC = 299, + L_NOT = 300, + L_NEG = 301, + L_TYPECAST = 302 }; #endif #define L_RETURN 258 @@ -80,45 +81,46 @@ #define L_ELSE 260 #define L_DO 261 #define L_WHILE 262 -#define L_CONTINUE 263 -#define L_BREAK 264 -#define L_DATA_TYPE 265 -#define L_IDENTIFIER 266 -#define L_STRING 267 -#define L_INTEGER 268 -#define L_OPEN_MAPPING 269 -#define L_CLOSE_MAPPING 270 -#define L_OPEN_ARRAY 271 -#define L_CLOSE_ARRAY 272 -#define L_OPEN_FUNP 273 -#define L_CLOSE_FUNP 274 -#define L_ASSIGN 275 -#define L_ME 276 -#define L_PE 277 -#define L_DE 278 -#define L_MOE 279 -#define L_MUE 280 -#define L_POWE 281 -#define L_AND 282 -#define L_OR 283 -#define L_NE 284 -#define L_EQ 285 -#define L_MINUS 286 -#define L_PLUS 287 -#define L_GE 288 -#define L_LE 289 -#define L_GT 290 -#define L_LT 291 -#define L_MOD 292 -#define L_DIV 293 -#define L_MUL 294 -#define L_POW 295 -#define L_DEREF 296 -#define L_DEC 297 -#define L_INC 298 -#define L_NOT 299 -#define L_NEG 300 -#define L_TYPECAST 301 +#define L_FOR 263 +#define L_CONTINUE 264 +#define L_BREAK 265 +#define L_DATA_TYPE 266 +#define L_IDENTIFIER 267 +#define L_STRING 268 +#define L_INTEGER 269 +#define L_OPEN_MAPPING 270 +#define L_CLOSE_MAPPING 271 +#define L_OPEN_ARRAY 272 +#define L_CLOSE_ARRAY 273 +#define L_OPEN_FUNP 274 +#define L_CLOSE_FUNP 275 +#define L_ASSIGN 276 +#define L_ME 277 +#define L_PE 278 +#define L_DE 279 +#define L_MOE 280 +#define L_MUE 281 +#define L_POWE 282 +#define L_AND 283 +#define L_OR 284 +#define L_NE 285 +#define L_EQ 286 +#define L_MINUS 287 +#define L_PLUS 288 +#define L_GE 289 +#define L_LE 290 +#define L_GT 291 +#define L_LT 292 +#define L_MOD 293 +#define L_DIV 294 +#define L_MUL 295 +#define L_POW 296 +#define L_DEREF 297 +#define L_DEC 298 +#define L_INC 299 +#define L_NOT 300 +#define L_NEG 301 +#define L_TYPECAST 302 @@ -135,7 +137,7 @@ def_id_t *id; } YYSTYPE; /* Line 1240 of yacc.c. */ -#line 139 "lang.h" +#line 141 "lang.h" # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_TRIVIAL 1 Index: lang.y =================================================================== RCS file: /cvsroot/agd/server/src/lang.y,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- lang.y 21 Mar 2004 13:26:17 -0000 1.12 +++ lang.y 21 Mar 2004 14:06:36 -0000 1.13 @@ -42,7 +42,7 @@ } /* keywords */ -%token L_RETURN L_IF L_ELSE L_DO L_WHILE +%token L_RETURN L_IF L_ELSE L_DO L_WHILE L_FOR %token L_CONTINUE L_BREAK /* operands */ @@ -85,7 +85,7 @@ %type <arr> call_args call_arg_list %type <expr> expr optional_expr range_expr -%type <arr> return if else do_while while break continue +%type <arr> return if else do_while while for break continue %type <arr> fun_call call_other %type <arr> statements statement %type <arr> block block_or_semi @@ -433,6 +433,11 @@ init_array(&$$); array_concat(&$$, &$1); } + | for + { + init_array(&$$); + array_concat(&$$, &$1); + } | break ';' { if(!break_allowed) { @@ -1392,10 +1397,49 @@ array_concat(&$$, &$6); array_push(&$$, (void *) F_JMP); array_push(&$$, (void *) -($6.length + $4.arr.length + 3)); - break_allowed = continue_allowed = 1; + break_allowed = continue_allowed = 0; } ; +for: + L_FOR '(' expr ';' expr ';' expr ')' + { + break_allowed = continue_allowed = 1; + } + statement + { + int i; + for(i=0;i<$10.length;i++) { + if((int)$10.data[i] == F_BREAK) { + $10.data[i] = (void *) F_JMP; + i++; + $10.data[i] = (void *) $10.length + $7.arr.length - i - 1; + } else if((int)$10.data[i] == F_CONTINUE) { + $10.data[i] = (void *) F_JMP; + i++; + $10.data[i] = (void *) -(i + $5.arr.length + 5); + } + } + + init_array(&$$); + /* first expr. */ + array_concat(&$$, &$3.arr); + /* condition expr. */ + array_concat(&$$, &$5.arr); + array_push(&$$, (void *) F_JMPF); + array_push(&$$, (void *) ($7.arr.length + $10.length + 3)); + + /* Third expression - after every loop. */ + array_concat(&$$, &$7.arr); + /* Statements. */ + array_concat(&$$, &$10); + array_push(&$$, (void *) F_JMP); + array_push(&$$, (void *) -($10.length + $7.arr.length + + $5.arr.length + 3)); + break_allowed = continue_allowed = 0; + + } + ; + break: L_BREAK { Index: lex.l =================================================================== RCS file: /cvsroot/agd/server/src/lex.l,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- lex.l 21 Mar 2004 13:26:17 -0000 1.10 +++ lex.l 21 Mar 2004 14:06:36 -0000 1.11 @@ -257,6 +257,7 @@ [0-9]+K yylval.i = atoi(yytext) * 1024; RET(d, yylval.i, L_INTEGER); [0-9]+M yylval.i = atoi(yytext) * 1048576; RET(d, yylval.i, L_INTEGER); [0-9]+ yylval.i = atoi(yytext); RET(d, yylval.i, L_INTEGER); + return RET(s, "return", L_RETURN); if RET(s, "if", L_IF); else RET(s, "else", L_ELSE); @@ -264,6 +265,8 @@ while RET(s, "while", L_WHILE); break RET(s, "break", L_BREAK); continue RET(s, "continue", L_CONTINUE); +for RET(s, "for", L_FOR); + void yylval.i = T_VOID; RET(s, "void", L_DATA_TYPE); int yylval.i = T_INT; RET(s, "int", L_DATA_TYPE); string yylval.i = T_STRING; RET(s, "string", L_DATA_TYPE); |
From: Peep P. <so...@us...> - 2004-03-21 14:16:42
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3964 Modified Files: main.c Log Message: Pretty please with sugar. Index: main.c =================================================================== RCS file: /cvsroot/agd/server/src/main.c,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- main.c 21 Mar 2004 13:43:50 -0000 1.15 +++ main.c 21 Mar 2004 14:06:23 -0000 1.16 @@ -161,7 +161,7 @@ #ifndef ALLOW_ROOT if(getuid() == 0) { - printf("Don't run AGD as root - this is a security risk at this point.\n"); + printf("Please don't run AGD as root - this is a security risk at this point.\n"); printf("Create a user for it or run it under your own account.\n"); exit(5); } |
From: Peep P. <so...@us...> - 2004-03-21 13:54:06
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31932/src Modified Files: compile_options.h main.c sys.c Log Message: Disallowed running AGD as root; Added exit value 5 as configuration error Index: sys.c =================================================================== RCS file: /cvsroot/agd/server/src/sys.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- sys.c 21 Mar 2004 10:34:47 -0000 1.10 +++ sys.c 21 Mar 2004 13:43:50 -0000 1.11 @@ -34,7 +34,7 @@ if(!f) { fprintf(stderr, "Can't open configuration file! (%s)\n", strerror(errno)); - exit(0); + exit(5); } conf.exit_stats = 0; Index: main.c =================================================================== RCS file: /cvsroot/agd/server/src/main.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- main.c 21 Mar 2004 12:24:59 -0000 1.14 +++ main.c 21 Mar 2004 13:43:50 -0000 1.15 @@ -84,7 +84,7 @@ printf("Usage: %s [options] [configuration file]\n", s); printf("\tOptions:\n\t\t-d:\n\t\t Increase debug level\n" "\t\t-?\n\t\t-v:\n\t\t Show version and quit\n"); - exit(0); + exit(5); } void print_version(void) @@ -159,6 +159,14 @@ parse_args(argc, argv); print_version(); +#ifndef ALLOW_ROOT + if(getuid() == 0) { + printf("Don't run AGD as root - this is a security risk at this point.\n"); + printf("Create a user for it or run it under your own account.\n"); + exit(5); + } +#endif + if(!conf_file) { #ifdef DEFAULT_CONFIG_FILE printf("No config file provided - using default file (\"%s\")\n", DEFAULT_CONFIG_FILE); Index: compile_options.h =================================================================== RCS file: /cvsroot/agd/server/src/compile_options.h,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- compile_options.h 20 Mar 2004 20:26:36 -0000 1.11 +++ compile_options.h 21 Mar 2004 13:43:50 -0000 1.12 @@ -41,4 +41,9 @@ * Must be one of T_VOID, T_STRING, T_OBJECT or T_INT. */ #define DEFAULT_FUNCTION_TYPE T_VOID +/* Define this if you want to allow root to run AGD, + * BUT ONLY IF YOU REALLY KNOW WHAT YOU ARE DOING! + * AGD is probably not very secure at this point. */ +#undef ALLOW_ROOT + #endif |
From: Peep P. <so...@us...> - 2004-03-21 13:54:05
|
Update of /cvsroot/agd/server In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31932 Modified Files: ExitValues Log Message: Disallowed running AGD as root; Added exit value 5 as configuration error Index: ExitValues =================================================================== RCS file: /cvsroot/agd/server/ExitValues,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- ExitValues 12 Mar 2004 08:32:10 -0000 1.1 +++ ExitValues 21 Mar 2004 13:43:50 -0000 1.2 @@ -3,3 +3,5 @@ 2: Network error 3: Script problems (for example, master doesn't load) 4: Exit due to a signal (this indicates a crash) +5: Configuration error (syntax error in the configuration file, + incorrect arguments, running AGD as root, etc.) |
From: Peep P. <so...@us...> - 2004-03-21 13:53:31
|
Update of /cvsroot/agd/server In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31883 Modified Files: TODO Log Message: Something about tabs. Index: TODO =================================================================== RCS file: /cvsroot/agd/server/TODO,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- TODO 21 Mar 2004 13:26:17 -0000 1.12 +++ TODO 21 Mar 2004 13:43:23 -0000 1.13 @@ -84,3 +84,5 @@ - IPv6 support? - realloc wrapper - make maintainer-clean shouldn't delete src/dfparse.h and src/lang.h + - some terminals don't support \t, find out if it is possible to check for it, and then + print out 8 spaces instead. |
From: Peep P. <so...@us...> - 2004-03-21 13:53:23
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31833 Modified Files: net.c Log Message: Input lines with \n and no \r are now stripped correctly (again). Index: net.c =================================================================== RCS file: /cvsroot/agd/server/src/net.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- net.c 21 Mar 2004 10:35:02 -0000 1.10 +++ net.c 21 Mar 2004 13:43:05 -0000 1.11 @@ -181,12 +181,10 @@ } c = strchr(p->conn.recvbuf, '\r'); - if(c) *c = '\0'; -/* if(c) { - if(++c) - *c = '\0'; + if(c) { + *c = '\0'; } else if(c = strchr(p->conn.recvbuf, '\n')) - *c = '\0';*/ + *c = '\0'; p->input_to_called = 1; apply(p->ob, p->input_to, "s", p->conn.recvbuf); if(p->input_to_called) { /* input_to wasn't called again */ |
From: Peep P. <so...@us...> - 2004-03-21 13:36:26
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29000/src Modified Files: lang.h lang.y lex.l Log Message: Added break; and continue; Index: lex.l =================================================================== RCS file: /cvsroot/agd/server/src/lex.l,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- lex.l 21 Mar 2004 13:02:37 -0000 1.9 +++ lex.l 21 Mar 2004 13:26:17 -0000 1.10 @@ -262,6 +262,8 @@ else RET(s, "else", L_ELSE); do RET(s, "do", L_DO); while RET(s, "while", L_WHILE); +break RET(s, "break", L_BREAK); +continue RET(s, "continue", L_CONTINUE); void yylval.i = T_VOID; RET(s, "void", L_DATA_TYPE); int yylval.i = T_INT; RET(s, "int", L_DATA_TYPE); string yylval.i = T_STRING; RET(s, "string", L_DATA_TYPE); Index: lang.h =================================================================== RCS file: /cvsroot/agd/server/src/lang.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- lang.h 21 Mar 2004 13:02:37 -0000 1.4 +++ lang.h 21 Mar 2004 13:26:17 -0000 1.5 @@ -34,43 +34,45 @@ L_ELSE = 260, L_DO = 261, L_WHILE = 262, - L_DATA_TYPE = 263, - L_IDENTIFIER = 264, - L_STRING = 265, - L_INTEGER = 266, - L_OPEN_MAPPING = 267, - L_CLOSE_MAPPING = 268, - L_OPEN_ARRAY = 269, - L_CLOSE_ARRAY = 270, - L_OPEN_FUNP = 271, - L_CLOSE_FUNP = 272, - L_ASSIGN = 273, - L_ME = 274, - L_PE = 275, - L_DE = 276, - L_MOE = 277, - L_MUE = 278, - L_POWE = 279, - L_AND = 280, - L_OR = 281, - L_NE = 282, - L_EQ = 283, - L_MINUS = 284, - L_PLUS = 285, - L_GE = 286, - L_LE = 287, - L_GT = 288, - L_LT = 289, - L_MOD = 290, - L_DIV = 291, - L_MUL = 292, - L_POW = 293, - L_DEREF = 294, - L_DEC = 295, - L_INC = 296, - L_NOT = 297, - L_NEG = 298, - L_TYPECAST = 299 + L_CONTINUE = 263, + L_BREAK = 264, + L_DATA_TYPE = 265, + L_IDENTIFIER = 266, + L_STRING = 267, + L_INTEGER = 268, + L_OPEN_MAPPING = 269, + L_CLOSE_MAPPING = 270, + L_OPEN_ARRAY = 271, + L_CLOSE_ARRAY = 272, + L_OPEN_FUNP = 273, + L_CLOSE_FUNP = 274, + L_ASSIGN = 275, + L_ME = 276, + L_PE = 277, + L_DE = 278, + L_MOE = 279, + L_MUE = 280, + L_POWE = 281, + L_AND = 282, + L_OR = 283, + L_NE = 284, + L_EQ = 285, + L_MINUS = 286, + L_PLUS = 287, + L_GE = 288, + L_LE = 289, + L_GT = 290, + L_LT = 291, + L_MOD = 292, + L_DIV = 293, + L_MUL = 294, + L_POW = 295, + L_DEREF = 296, + L_DEC = 297, + L_INC = 298, + L_NOT = 299, + L_NEG = 300, + L_TYPECAST = 301 }; #endif #define L_RETURN 258 @@ -78,49 +80,51 @@ #define L_ELSE 260 #define L_DO 261 #define L_WHILE 262 -#define L_DATA_TYPE 263 -#define L_IDENTIFIER 264 -#define L_STRING 265 -#define L_INTEGER 266 -#define L_OPEN_MAPPING 267 -#define L_CLOSE_MAPPING 268 -#define L_OPEN_ARRAY 269 -#define L_CLOSE_ARRAY 270 -#define L_OPEN_FUNP 271 -#define L_CLOSE_FUNP 272 -#define L_ASSIGN 273 -#define L_ME 274 -#define L_PE 275 -#define L_DE 276 -#define L_MOE 277 -#define L_MUE 278 -#define L_POWE 279 -#define L_AND 280 -#define L_OR 281 -#define L_NE 282 -#define L_EQ 283 -#define L_MINUS 284 -#define L_PLUS 285 -#define L_GE 286 -#define L_LE 287 -#define L_GT 288 -#define L_LT 289 -#define L_MOD 290 -#define L_DIV 291 -#define L_MUL 292 -#define L_POW 293 -#define L_DEREF 294 -#define L_DEC 295 -#define L_INC 296 -#define L_NOT 297 -#define L_NEG 298 -#define L_TYPECAST 299 +#define L_CONTINUE 263 +#define L_BREAK 264 +#define L_DATA_TYPE 265 +#define L_IDENTIFIER 266 +#define L_STRING 267 +#define L_INTEGER 268 +#define L_OPEN_MAPPING 269 +#define L_CLOSE_MAPPING 270 +#define L_OPEN_ARRAY 271 +#define L_CLOSE_ARRAY 272 +#define L_OPEN_FUNP 273 +#define L_CLOSE_FUNP 274 +#define L_ASSIGN 275 +#define L_ME 276 +#define L_PE 277 +#define L_DE 278 +#define L_MOE 279 +#define L_MUE 280 +#define L_POWE 281 +#define L_AND 282 +#define L_OR 283 +#define L_NE 284 +#define L_EQ 285 +#define L_MINUS 286 +#define L_PLUS 287 +#define L_GE 288 +#define L_LE 289 +#define L_GT 290 +#define L_LT 291 +#define L_MOD 292 +#define L_DIV 293 +#define L_MUL 294 +#define L_POW 295 +#define L_DEREF 296 +#define L_DEC 297 +#define L_INC 298 +#define L_NOT 299 +#define L_NEG 300 +#define L_TYPECAST 301 #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) -#line 28 "lang.y" +#line 34 "lang.y" typedef union YYSTYPE { char *str; int i; @@ -131,7 +135,7 @@ def_id_t *id; } YYSTYPE; /* Line 1240 of yacc.c. */ -#line 135 "lang.h" +#line 139 "lang.h" # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_TRIVIAL 1 Index: lang.y =================================================================== RCS file: /cvsroot/agd/server/src/lang.y,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- lang.y 21 Mar 2004 13:02:37 -0000 1.11 +++ lang.y 21 Mar 2004 13:26:17 -0000 1.12 @@ -3,11 +3,17 @@ #include "lpc_incl.h" #include "lex.h" +/* Used during compilation, replaced with F_JMP. */ +#define F_BREAK -5 +#define F_CONTINUE -6 + YYLTYPE yylloc; /* Lexical tie-ins. */ static int global_type, - curr_f_type; + curr_f_type, + break_allowed, + continue_allowed; extern int scope_level; void add_function(def_id_t *idp, int lineno, array_t *code); @@ -37,6 +43,7 @@ /* keywords */ %token L_RETURN L_IF L_ELSE L_DO L_WHILE +%token L_CONTINUE L_BREAK /* operands */ %token <i> L_DATA_TYPE @@ -78,7 +85,7 @@ %type <arr> call_args call_arg_list %type <expr> expr optional_expr range_expr -%type <arr> return if else do_while while +%type <arr> return if else do_while while break continue %type <arr> fun_call call_other %type <arr> statements statement %type <arr> block block_or_semi @@ -426,6 +433,24 @@ init_array(&$$); array_concat(&$$, &$1); } + | break ';' + { + if(!break_allowed) { + comp_error("illegal break"); + } + + init_array(&$$); + array_concat(&$$, &$1); + } + | continue ';' + { + if(!continue_allowed) { + comp_error("illegal continue"); + } + + init_array(&$$); + array_concat(&$$, &$1); + } | expr ';' { init_array(&$$); @@ -1323,31 +1348,72 @@ ; do_while: - L_DO statement L_WHILE '(' expr ')' + L_DO + { + break_allowed = continue_allowed = 1; + } + statement L_WHILE '(' expr ')' { init_array(&$$); array_push(&$$, (void *) F_JMP); - array_push(&$$, (void *) ($5.arr.length + 3)); - array_concat(&$$, &$5.arr); + array_push(&$$, (void *) ($6.arr.length + 3)); + array_concat(&$$, &$6.arr); array_push(&$$, (void *) F_JMPF); - array_push(&$$, (void *) ($2.length + 3)); - array_concat(&$$, &$2); + array_push(&$$, (void *) ($3.length + 3)); + array_concat(&$$, &$3); array_push(&$$, (void *) F_JMP); - array_push(&$$, (void *) -($2.length + $5.arr.length + 3)); + array_push(&$$, (void *) -($3.length + $6.arr.length + 3)); + break_allowed = continue_allowed = 0; } while: - L_WHILE '(' expr ')' statement + L_WHILE + { + break_allowed = continue_allowed = 1; + } + '(' expr ')' statement { + int i; + for(i=0;i<$6.length;i++) { + if((int)$6.data[i] == F_BREAK) { + $6.data[i] = (void *) F_JMP; + i++; + $6.data[i] = (void *) $6.length - i + 2; + } else if((int)$6.data[i] == F_CONTINUE) { + $6.data[i] = (void *) F_JMP; + i++; + $6.data[i] = (void *) -(i + $4.arr.length + 2); + } + } + init_array(&$$); - array_concat(&$$, &$3.arr); + array_concat(&$$, &$4.arr); array_push(&$$, (void *) F_JMPF); - array_push(&$$, (void *) ($5.length + 3)); - array_concat(&$$, &$5); + array_push(&$$, (void *) ($6.length + 3)); + array_concat(&$$, &$6); array_push(&$$, (void *) F_JMP); - array_push(&$$, (void *) -($5.length + $3.arr.length + 3)); + array_push(&$$, (void *) -($6.length + $4.arr.length + 3)); + break_allowed = continue_allowed = 1; } ; +break: + L_BREAK + { + init_array(&$$); + array_push(&$$, (void *) F_BREAK); + array_push(&$$, (void *) 0); + } + ; + +continue: + L_CONTINUE + { + init_array(&$$); + array_push(&$$, (void *) F_CONTINUE); + array_push(&$$, (void *) 0); + } + ; + fun_call: defined_name '(' call_args ')' { |
From: Peep P. <so...@us...> - 2004-03-21 13:36:25
|
Update of /cvsroot/agd/server In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29000 Modified Files: BUGS ChangeLog NEWS TODO Log Message: Added break; and continue; Index: NEWS =================================================================== RCS file: /cvsroot/agd/server/NEWS,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- NEWS 21 Mar 2004 13:02:37 -0000 1.6 +++ NEWS 21 Mar 2004 13:26:17 -0000 1.7 @@ -1,4 +1,5 @@ New things in this version (0.0.2-3) that you might find useful: + * break; and continue; statements * New operators: **, **= * New dfuns: query_ip, query_hostname (use with caution, may block for quite a while), asctime. Index: TODO =================================================================== RCS file: /cvsroot/agd/server/TODO,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- TODO 21 Mar 2004 13:02:37 -0000 1.11 +++ TODO 21 Mar 2004 13:26:17 -0000 1.12 @@ -24,7 +24,6 @@ * !n Need an intelligent parser for this. - ! continue; and break; - allow to define locals inside statements like: create() { write("\n"); int i; i = 1; int j; j = 2; } And maybe disable this with #pragma traditional-lpc ? @@ -56,6 +55,7 @@ - mudlib: /update command - better logging system + - print time using strftime() - log using lib's facilities (master::log()?) - different prefixes have different debuglevels - save to different files Index: BUGS =================================================================== RCS file: /cvsroot/agd/server/BUGS,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- BUGS 21 Mar 2004 10:37:02 -0000 1.6 +++ BUGS 21 Mar 2004 13:26:17 -0000 1.7 @@ -32,5 +32,9 @@ string s; s = s + "abc"; will result in "0abc" + - lexical tie-ins stay activated on errors: + while(abcdef) { } + break; continue; + Only gives errors for "undeclared identifier 'abcdef'", but not for the break and continue. - continue from here.. Index: ChangeLog =================================================================== RCS file: /cvsroot/agd/server/ChangeLog,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- ChangeLog 21 Mar 2004 13:02:37 -0000 1.12 +++ ChangeLog 21 Mar 2004 13:26:17 -0000 1.13 @@ -1,6 +1,7 @@ 0.0.2-3: ---------------------------------------------------------------------------- 2004-03-21 + * added break; and continue; * new operators: ** (power), **= (x = x ** y) * debuglevel can now be set with option "-d=x", where x is a number. * fixed net_send(), was a stupid bug - always sent to this_player. |
From: Peep P. <so...@us...> - 2004-03-21 13:36:08
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28946 Modified Files: log.c Log Message: Removed time functions. Index: log.c =================================================================== RCS file: /cvsroot/agd/server/src/log.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- log.c 21 Mar 2004 12:24:36 -0000 1.6 +++ log.c 21 Mar 2004 13:26:00 -0000 1.7 @@ -56,7 +56,7 @@ #endif #endif -#define WRITELOG(x) time(&t); fprintf(x, "%s [%s] %s", ctime(&t), prefix, str) +#define WRITELOG(x) fprintf(x, "[%s] %s", prefix, str) /* this currently writes the errors into a generic error log, maybe we should write them into separate files */ @@ -65,7 +65,6 @@ { char str[512]; va_list va; - time_t t; va_start(va, fmt); vsprintf(str, fmt, va); |
From: Peep P. <so...@us...> - 2004-03-21 13:12:48
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25264/src Modified Files: compile.c interpret.h lang.h lang.y lex.l Log Message: New operators - ** and **=. Index: lex.l =================================================================== RCS file: /cvsroot/agd/server/src/lex.l,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- lex.l 21 Mar 2004 08:51:36 -0000 1.8 +++ lex.l 21 Mar 2004 13:02:37 -0000 1.9 @@ -234,6 +234,8 @@ "=" RET(c, '=', L_ASSIGN); "++" RET(s, "++", L_INC); "+" RET(c, '+', L_PLUS); +"**" RET(s, "**", L_POW); +"**=" RET(s, "**=", L_POWE); "*" RET(c, '*', L_MUL); "/" RET(c, '/', L_DIV); "%" RET(c, '%', L_MOD); @@ -243,7 +245,6 @@ "/=" RET(s, "/=", L_DE); "%=" RET(s, "%=", L_MOE); - "({" RET(s, "({", L_OPEN_ARRAY); "([" RET(s, "([", L_OPEN_MAPPING); "(:" RET(s, "(:", L_OPEN_FUNP); Index: lang.h =================================================================== RCS file: /cvsroot/agd/server/src/lang.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- lang.h 21 Mar 2004 09:00:57 -0000 1.3 +++ lang.h 21 Mar 2004 13:02:37 -0000 1.4 @@ -50,25 +50,27 @@ L_DE = 276, L_MOE = 277, L_MUE = 278, - L_AND = 279, - L_OR = 280, - L_NE = 281, - L_EQ = 282, - L_MINUS = 283, - L_PLUS = 284, - L_GE = 285, - L_LE = 286, - L_GT = 287, - L_LT = 288, - L_MOD = 289, - L_DIV = 290, - L_MUL = 291, - L_DEREF = 292, - L_DEC = 293, - L_INC = 294, - L_NOT = 295, - L_NEG = 296, - L_TYPECAST = 297 + L_POWE = 279, + L_AND = 280, + L_OR = 281, + L_NE = 282, + L_EQ = 283, + L_MINUS = 284, + L_PLUS = 285, + L_GE = 286, + L_LE = 287, + L_GT = 288, + L_LT = 289, + L_MOD = 290, + L_DIV = 291, + L_MUL = 292, + L_POW = 293, + L_DEREF = 294, + L_DEC = 295, + L_INC = 296, + L_NOT = 297, + L_NEG = 298, + L_TYPECAST = 299 }; #endif #define L_RETURN 258 @@ -92,25 +94,27 @@ #define L_DE 276 #define L_MOE 277 #define L_MUE 278 -#define L_AND 279 -#define L_OR 280 -#define L_NE 281 -#define L_EQ 282 -#define L_MINUS 283 -#define L_PLUS 284 -#define L_GE 285 -#define L_LE 286 -#define L_GT 287 -#define L_LT 288 -#define L_MOD 289 -#define L_DIV 290 -#define L_MUL 291 -#define L_DEREF 292 -#define L_DEC 293 -#define L_INC 294 -#define L_NOT 295 -#define L_NEG 296 -#define L_TYPECAST 297 +#define L_POWE 279 +#define L_AND 280 +#define L_OR 281 +#define L_NE 282 +#define L_EQ 283 +#define L_MINUS 284 +#define L_PLUS 285 +#define L_GE 286 +#define L_LE 287 +#define L_GT 288 +#define L_LT 289 +#define L_MOD 290 +#define L_DIV 291 +#define L_MUL 292 +#define L_POW 293 +#define L_DEREF 294 +#define L_DEC 295 +#define L_INC 296 +#define L_NOT 297 +#define L_NEG 298 +#define L_TYPECAST 299 @@ -127,7 +131,7 @@ def_id_t *id; } YYSTYPE; /* Line 1240 of yacc.c. */ -#line 131 "lang.h" +#line 135 "lang.h" # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_TRIVIAL 1 Index: lang.y =================================================================== RCS file: /cvsroot/agd/server/src/lang.y,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- lang.y 21 Mar 2004 10:35:53 -0000 1.10 +++ lang.y 21 Mar 2004 13:02:37 -0000 1.11 @@ -51,6 +51,7 @@ %right L_ASSIGN %left L_PE /* Pluq-equals */ L_ME /* Minus-equals */ %left L_MUE /* Multiply-equals */ L_MOE /* Modulo-equals */ L_DE /* Divide-equals */ +%left L_POWE /* Power-equals */ %left L_OR L_AND %left L_EQ L_NE %left L_PLUS L_MINUS @@ -58,11 +59,13 @@ %left '?' %left L_LT L_GT L_LE L_GE %left L_MUL L_DIV L_MOD +%left L_POW %left L_DEREF /* L_DEREF _is_ a valid lval for call_other. i.e: ob->get_another_ob()->call(), as long as ob->get_another_ob() returns T_OBJECT. */ %right '[' ']' %nonassoc L_NEG L_NOT L_INC L_DEC +/*%left L_COMM*/ %nonassoc L_TYPECAST %type <str> string string_con2 @@ -823,6 +826,53 @@ array_push(&$$.arr, (void *) F_MOD); array_push(&$$.arr, (void *) F_ASSIGN); } +/* + | expr L_COMM expr + { + $$.side_effect = $1.side_effect || $3.side_effect; + $$.lval = $$.direct_type = 0; + $$.type = $1.type; + + array_concat(&$$.arr, &$1.arr); + array_concat(&$$.arr, &$3.arr); + array_push(&$$.arr, (void *) F_POP); + } +*/ + | expr L_POW expr + { + $$.side_effect = $1.side_effect || $3.side_effect; + $$.lval = $$.direct_type = 0; + $$.type = $1.type; + + check_operand(F_POW, $1.type, $3.type); + + init_array(&$$.arr); + if($1.direct_type && $3.direct_type) { + int i1, i2, res; + i1 = (int) $1.arr.data[1]; + i2 = (int) $3.arr.data[1]; + array_push(&$$.arr, (void *) F_PUSH_INT); + array_push(&$$.arr, (void *) pow(i1, i2)); + } else { + array_concat(&$$.arr, &$1.arr); + array_concat(&$$.arr, &$3.arr); + array_push(&$$.arr, (void *) F_POW); + } + } + | expr L_POWE expr + { + $$.side_effect = 1; + $$.lval = $$.direct_type = 0; + $$.type = $1.type; + + check_operand(F_POWE, $1.type, $3.type); + /* Once for F_POW, once for F_ASSIGN. */ + array_concat(&$$.arr, &$1.arr); + array_concat(&$$.arr, &$1.arr); + array_concat(&$$.arr, &$3.arr); + array_push(&$$.arr, (void *) F_POW); + array_push(&$$.arr, (void *) F_ASSIGN); + } | expr L_INC { check_operand(F_POSTINC, $1.type, 0); Index: compile.c =================================================================== RCS file: /cvsroot/agd/server/src/compile.c,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- compile.c 20 Mar 2004 20:26:36 -0000 1.16 +++ compile.c 21 Mar 2004 13:02:37 -0000 1.17 @@ -224,6 +224,12 @@ case F_RANGE: SET_OPERATOR("[]", 1, 0, 0, 1, 0); break; + case F_POW: + SET_OPERATOR("**", 2, 1, 1, 0, 0); + break; + case F_POWE: + SET_OPERATOR("**=", 2, 1, 1, 0, 0); + break; } } } Index: interpret.h =================================================================== RCS file: /cvsroot/agd/server/src/interpret.h,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- interpret.h 20 Mar 2004 19:18:42 -0000 1.8 +++ interpret.h 21 Mar 2004 13:02:37 -0000 1.9 @@ -50,6 +50,9 @@ #define F_PREDEC 43 #define F_RANGE 44 #define F_RANGE_LVALUE 45 +#define F_COMM 46 +#define F_POW 47 +#define F_POWE 48 #define F_HIGHEST F_RANGE_LVALUE |