Update of /cvsroot/agd/server/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23318
Modified Files:
lang.y
Log Message:
Removed preallocation of arrays; fixed string concatenation.
Index: lang.y
===================================================================
RCS file: /cvsroot/agd/server/src/lang.y,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- lang.y 20 Mar 2004 19:29:19 -0000 1.8
+++ lang.y 20 Mar 2004 20:26:52 -0000 1.9
@@ -654,7 +654,7 @@
array_push(&$$.arr, (void *) F_ADD);
array_push(&$$.arr, (void *) F_ASSIGN);
}
-| expr L_MINUS expr
+ | expr L_MINUS expr
{
$$.lval = $$.direct_type = 0;
$$.side_effect = $1.side_effect || $3.side_effect;
@@ -1075,7 +1075,9 @@
init_array(&$$.arr);
if($1.length) {
- $$.type = (int) array_pop(&$1);
+ $1.length--;
+ $$.type = (int) $1.data[$1.length];
+ /*$1.data = realloc($1.data, $1.length);*/
array_concat(&$$.arr, &$1);
}
}
@@ -1190,9 +1192,14 @@
string_con2:
L_STRING
+ {
+ $$ = $1;
+ }
| string_con2 L_STRING
{
- $$ = strcat($1, $2);
+ $$ = malloc(strlen($1) + strlen($2) + 1);
+ strcpy($$, $1);
+ $$ = strcat($$, $2);
}
;
@@ -1333,20 +1340,6 @@
init_array(&$$);
#if 0
- if((index = nametable_find_cob(TYPE_FUN | SCOPE_LOCAL, $1)) != -1) {
- scope = SCOPE_LOCAL;
- if(index >= fun_been_called.allocated) {
- array_push(&fun_been_called, (void *) index);
- }
- fun_been_called.data[index] = (void *) 1;
- fun_been_called.length = index + 1;
- } else {
- index = nametable_find_cob(TYPE_FUN | SCOPE_GLOBAL, $1);
- scope = SCOPE_GLOBAL;
- }
-#endif
-
-#if 0
if($1->type == ID_FUN_PROT) {
char buf[256];
sprintf(buf, "Function '%s' is called, but not defined", $1->name);
@@ -1357,10 +1350,6 @@
if($1->type == ID_FUN_PROT)
$1->has_been_called = 1;
- /* Leave a place for F_CALL_*FUN to place it's return value. */
-/* array_push(&$$, (void *) F_PUSH);
- array_push(&$$, (void *) NULL);*/
-
realargs = type_xmalloc(array_t);
init_array(realargs);
for(i=0;i<$3.length;i++) {
@@ -1370,10 +1359,9 @@
array_concat(&$$, realargs);
xfree(realargs);
- /* First arguments, then call. So F_CALL won't have to do any pushing. */
- if($1->type == ID_DFUN)
+ if($1->type == ID_DFUN) {
array_push(&$$, (void *) F_CALL_DFUN);
- else /* ID_FUN */
+ } else /* ID_FUN */
array_push(&$$, (void *) F_CALL_LFUN);
array_push(&$$, (void *) $1->index);
array_push(&$$, (void *) $3.length); /* num_arg */
|