Branch: Tag:

1999-08-17

1999-08-17 01:04:20 by Martin Stjernholm <mast@lysator.liu.se>

Handle aggregate assignment in simple_set_index().

Rev: src/array.c:1.50

21:   #include "main.h"   #include "security.h"    - RCSID("$Id: array.c,v 1.49 1999/04/17 14:03:05 grubba Exp $"); + RCSID("$Id: array.c,v 1.50 1999/08/17 01:04:20 mast Exp $");      struct array empty_array=   {
235:   void simple_set_index(struct array *a,struct svalue *ind,struct svalue *s)   {    INT32 i; +  switch (ind->type) { +  case T_INT:    if(ind->type != T_INT)    error("Index is not an integer.\n");    i=ind->u.integer;
247:    }    }    array_set_index(a,i,s); +  break; +  +  case T_STRING: +  if (ind->subtype == 1) { +  INT32 i, n; +  sp++->type = T_VOID; +  push_svalue(ind); +  for (i = 0, n = a->size; i < n; i++) { +  assign_svalue(sp-2, &a->item[i]); +  assign_lvalue(sp-2, s);    } -  +  pop_n_elems(2); +  break; +  }    -  +  default: +  error("Index is not an integer.\n"); +  } + } +    /*    * Insert an svalue into an array, grow the array if nessesary    */