pike.git / src / mapping.c

version» Context lines:

pike.git/src/mapping.c:1:   /*\   ||| This file a part of Pike, and is copyright by Fredrik Hubinette   ||| Pike is distributed as GPL (General Public License)   ||| See the files COPYING and DISCLAIMER for more information.   \*/   /**/   #include "global.h" - RCSID("$Id: mapping.c,v 1.52 2000/01/28 22:06:42 hubbe Exp $"); + RCSID("$Id: mapping.c,v 1.53 2000/01/29 13:42:13 mirar Exp $");   #include "main.h"   #include "object.h"   #include "mapping.h"   #include "svalue.h"   #include "array.h"   #include "pike_macros.h"   #include "language.h"   #include "error.h"   #include "pike_memory.h"   #include "dynamic_buffer.h"
pike.git/src/mapping.c:1162:       free((char *)zipper);       m=mkmapping(ci, cv);    free_array(ci);    free_array(cv);       return m;   }    + struct mapping *merge_mapping_array_ordered(struct mapping *a, +  struct array *b, INT32 op) + { +  struct array *ai, *av; +  struct array *ci, *cv; +  INT32 *zipper; +  struct mapping *m; +  +  ai=mapping_indices(a); +  av=mapping_values(a); +  if(ai->size > 1) +  { +  zipper=get_set_order(ai); +  order_array(ai, zipper); +  order_array(av, zipper); +  free((char *)zipper); +  } +  +  switch (op) /* no elements from »b» may be selected */ +  { +  case PIKE_ARRAY_OP_AND: +  zipper=merge(b,ai,op); +  ci=array_zip(b,ai,zipper); /* b must not be used */ +  cv=array_zip(b,av,zipper); /* b must not be used */ +  break; +  case PIKE_ARRAY_OP_SUB: +  zipper=merge(ai,b,op); +  ci=array_zip(ai,b,zipper); /* b must not be used */ +  cv=array_zip(av,b,zipper); /* b must not be used */ +  break; +  default: +  fatal("merge_mapping_array on other then AND or SUB\n"); +  } +  +  free_array(ai); +  free_array(av); +  +  free((char *)zipper); +  +  m=mkmapping(ci, cv); +  free_array(ci); +  free_array(cv); +  +  return m; + } +  + struct mapping *merge_mapping_array_unordered(struct mapping *a, +  struct array *b, INT32 op) + { +  struct array *b_temp; +  INT32 *zipper; +  struct mapping *m; +  +  if (b->size>1) +  { +  zipper=get_set_order(b); +  b_temp=reorder_and_copy_array(b,zipper); +  m=merge_mapping_array_ordered(a,b_temp,op); +  free_array(b_temp); +  } +  else +  m=merge_mapping_array_ordered(a,b,op); +  +  return m; + } +    struct mapping *add_mappings(struct svalue *argp, INT32 args)   {    INT32 e,d;    struct mapping *ret;    struct keypair *k;       for(e=d=0;d<args;d++)    {   #ifdef PIKE_DEBUG    if(d_flag>1) check_mapping(argp[d].u.mapping);