Branch: Tag:

1995-08-09

1995-08-09 10:21:55 by Fredrik Hübinette (Hubbe) <hubbe@hubbe.net>

ulpc dist

Rev: bin/create_testsuite:1.1.1.1
Rev: bin/hilfe.lpc:1.1.1.1
Rev: bin/rsif:1.1.1.1
Rev: bin/uhttpd.lpc:1.1.1.1
Rev: doc/README:1.1.1.1
Rev: doc/builtin/aggregate:1.1.1.1
Rev: doc/builtin/aggregate_list:1.1.1.1
Rev: doc/builtin/aggregate_mapping:1.1.1.1
Rev: doc/builtin/all_efuns:1.1.1.1
Rev: doc/builtin/allocate:1.1.1.1
Rev: doc/builtin/arrayp:1.1.1.1
Rev: doc/builtin/backtrace:1.1.1.1
Rev: doc/builtin/call_function:1.1.1.1
Rev: doc/builtin/call_out:1.1.1.1
Rev: doc/builtin/call_out_info:1.1.1.1
Rev: doc/builtin/catch:1.1.1.1
Rev: doc/builtin/clone:1.1.1.1
Rev: doc/builtin/combine_path:1.1.1.1
Rev: doc/builtin/compile_file:1.1.1.1
Rev: doc/builtin/compile_string:1.1.1.1
Rev: doc/builtin/copy_value:1.1.1.1
Rev: doc/builtin/crypt:1.1.1.1
Rev: doc/builtin/ctime:1.1.1.1
Rev: doc/builtin/destruct:1.1.1.1
Rev: doc/builtin/equal:1.1.1.1
Rev: doc/builtin/exit:1.1.1.1
Rev: doc/builtin/explode:1.1.1.1
Rev: doc/builtin/find_call_out:1.1.1.1
Rev: doc/builtin/floatp:1.1.1.1
Rev: doc/builtin/function_name:1.1.1.1
Rev: doc/builtin/function_object:1.1.1.1
Rev: doc/builtin/functionp:1.1.1.1
Rev: doc/builtin/hash:1.1.1.1
Rev: doc/builtin/implode:1.1.1.1
Rev: doc/builtin/indices:1.1.1.1
Rev: doc/builtin/intp:1.1.1.1
Rev: doc/builtin/listp:1.1.1.1
Rev: doc/builtin/lower_case:1.1.1.1
Rev: doc/builtin/m_delete:1.1.1.1
Rev: doc/builtin/mappingp:1.1.1.1
Rev: doc/builtin/mkmapping:1.1.1.1
Rev: doc/builtin/next_object:1.1.1.1
Rev: doc/builtin/object_program:1.1.1.1
Rev: doc/builtin/objectp:1.1.1.1
Rev: doc/builtin/programp:1.1.1.1
Rev: doc/builtin/query_host_name:1.1.1.1
Rev: doc/builtin/query_num_arg:1.1.1.1
Rev: doc/builtin/random:1.1.1.1
Rev: doc/builtin/regexpp:1.1.1.1
Rev: doc/builtin/remove_call_out:1.1.1.1
Rev: doc/builtin/replace:1.1.1.1
Rev: doc/builtin/reverse:1.1.1.1
Rev: doc/builtin/rusage:1.1.1.1
Rev: doc/builtin/search:1.1.1.1
Rev: doc/builtin/sizeof:1.1.1.1
Rev: doc/builtin/sscanf:1.1.1.1
Rev: doc/builtin/stringp:1.1.1.1
Rev: doc/builtin/sum:1.1.1.1
Rev: doc/builtin/this_object:1.1.1.1
Rev: doc/builtin/throw:1.1.1.1
Rev: doc/builtin/time:1.1.1.1
Rev: doc/builtin/trace:1.1.1.1
Rev: doc/builtin/upper_case:1.1.1.1
Rev: doc/builtin/values:1.1.1.1
Rev: doc/builtin/zero_type:1.1.1.1
Rev: doc/files/cd:1.1.1.1
Rev: doc/files/exec:1.1.1.1
Rev: doc/files/file:1.1.1.1
Rev: doc/files/file_stat:1.1.1.1
Rev: doc/files/fork:1.1.1.1
Rev: doc/files/get_dir:1.1.1.1
Rev: doc/files/getcwd:1.1.1.1
Rev: doc/files/mkdir:1.1.1.1
Rev: doc/files/mv:1.1.1.1
Rev: doc/files/perror:1.1.1.1
Rev: doc/files/port:1.1.1.1
Rev: doc/files/rm:1.1.1.1
Rev: doc/lpc/command_line_options:1.1.1.1
Rev: doc/lpc/control_structures:1.1.1.1
Rev: doc/lpc/hilfe.hilfe:1.1.1.1
Rev: doc/lpc/how_to_make_modules:1.1.1.1
Rev: doc/manual/i-overview.html:1.1.1.1
Rev: doc/manual/index.html:1.1.1.1
Rev: doc/manual/t-hello.html:1.1.1.1
Rev: doc/manual/ulpc-inside3.gif:1.1.1.1
Rev: doc/math/acos:1.1.1.1
Rev: doc/math/asin:1.1.1.1
Rev: doc/math/atan:1.1.1.1
Rev: doc/math/ceil:1.1.1.1
Rev: doc/math/cos:1.1.1.1
Rev: doc/math/exp:1.1.1.1
Rev: doc/math/floor:1.1.1.1
Rev: doc/math/log:1.1.1.1
Rev: doc/math/pow:1.1.1.1
Rev: doc/math/sin:1.1.1.1
Rev: doc/math/sqrt:1.1.1.1
Rev: doc/math/tan:1.1.1.1
Rev: doc/operators/addition:1.1.1.1
Rev: doc/regexp/regexp:1.1.1.1
Rev: doc/simulated/PI:1.1.1.1
Rev: doc/simulated/capitalize:1.1.1.1
Rev: doc/simulated/code_value:1.1.1.1
Rev: doc/simulated/describe_backtrace:1.1.1.1
Rev: doc/simulated/file_size:1.1.1.1
Rev: doc/simulated/filter_array:1.1.1.1
Rev: doc/simulated/get_function:1.1.1.1
Rev: doc/simulated/getenv:1.1.1.1
Rev: doc/simulated/l_sizeof:1.1.1.1
Rev: doc/simulated/m_indices:1.1.1.1
Rev: doc/simulated/m_sizeof:1.1.1.1
Rev: doc/simulated/m_values:1.1.1.1
Rev: doc/simulated/map_array:1.1.1.1
Rev: doc/simulated/master:1.1.1.1
Rev: doc/simulated/member_array:1.1.1.1
Rev: doc/simulated/popen:1.1.1.1
Rev: doc/simulated/previous_object:1.1.1.1
Rev: doc/simulated/read_bytes:1.1.1.1
Rev: doc/simulated/regexp:1.1.1.1
Rev: doc/simulated/search_array:1.1.1.1
Rev: doc/simulated/sort_array:1.1.1.1
Rev: doc/simulated/spawn:1.1.1.1
Rev: doc/simulated/strlen:1.1.1.1
Rev: doc/simulated/strstr:1.1.1.1
Rev: doc/simulated/sum_arrays:1.1.1.1
Rev: doc/simulated/this_function:1.1.1.1
Rev: doc/simulated/write:1.1.1.1
Rev: doc/simulated/write_file:1.1.1.1
Rev: doc/sprintf/sprintf:1.1.1.1
Rev: doc/types/array:1.1.1.1
Rev: doc/types/float:1.1.1.1
Rev: doc/types/function:1.1.1.1
Rev: doc/types/int:1.1.1.1
Rev: doc/types/list:1.1.1.1
Rev: doc/types/mapping:1.1.1.1
Rev: doc/types/object:1.1.1.1
Rev: doc/types/program:1.1.1.1
Rev: doc/types/string:1.1.1.1
Rev: lib/conftest.h:1.1.1.1
Rev: lib/master.lpc:1.1.1.1
Rev: lib/simulate.lpc:1.1.1.1
Rev: lib/testsuite.lpc:1.1.1.1
Rev: src/BUGS:1.1.1.1
Rev: src/COPYING:1.1.1.1
Rev: src/COPYRIGHT:1.1.1.1
Rev: src/DISCLAIMER:1.1.1.1
Rev: src/Makefile.in:1.1.1.1
Rev: src/README:1.1.1.1
Rev: src/add_efun.c:1.1.1.1
Rev: src/add_efun.h:1.1.1.1
Rev: src/alloca.c:1.1.1.1
Rev: src/array.c:1.1.1.1
Rev: src/array.h:1.1.1.1
Rev: src/backend.c:1.1.1.1
Rev: src/backend.h:1.1.1.1
Rev: src/builtin_efuns.c:1.1.1.1
Rev: src/builtin_efuns.h:1.1.1.1
Rev: src/call_out.c:1.1.1.1
Rev: src/call_out.h:1.1.1.1
Rev: src/callback.c:1.1.1.1
Rev: src/callback.h:1.1.1.1
Rev: src/config.h:1.1.1.1
Rev: src/configure.in:1.1.1.1
Rev: src/debug.c:1.1.1.1
Rev: src/debug.h:1.1.1.1
Rev: src/docode.c:1.1.1.1
Rev: src/docode.h:1.1.1.1
Rev: src/dynamic_buffer.c:1.1.1.1
Rev: src/dynamic_buffer.h:1.1.1.1
Rev: src/efun.h:1.1.1.1
Rev: src/error.c:1.1.1.1
Rev: src/error.h:1.1.1.1
Rev: src/fd_control.c:1.1.1.1
Rev: src/fd_control.h:1.1.1.1
Rev: src/fsort.c:1.1.1.1
Rev: src/fsort.h:1.1.1.1
Rev: src/global.h:1.1.1.1
Rev: src/hashtable.c:1.1.1.1
Rev: src/hashtable.h:1.1.1.1
Rev: src/install-sh:1.1.1.1
Rev: src/interpret.c:1.1.1.1
Rev: src/interpret.h:1.1.1.1
Rev: src/language.y:1.1.1.1
Rev: src/las.c:1.1.1.1
Rev: src/las.h:1.1.1.1
Rev: src/lex.c:1.1.1.1
Rev: src/lex.h:1.1.1.1
Rev: src/list.c:1.1.1.1
Rev: src/list.h:1.1.1.1
Rev: src/lpc_types.c:1.1.1.1
Rev: src/lpc_types.h:1.1.1.1
Rev: src/machine.h.in:1.1.1.1
Rev: src/macros.h:1.1.1.1
Rev: src/main.c:1.1.1.1
Rev: src/main.h:1.1.1.1
Rev: src/mapping.c:1.1.1.1
Rev: src/mapping.h:1.1.1.1
Rev: src/memory.c:1.1.1.1
Rev: src/memory.h:1.1.1.1
Rev: src/module.c:1.1.1.1
Rev: src/module.h:1.1.1.1
Rev: src/modules/efuns.c:1.1.1.1
Rev: src/modules/files/Makefile.in:1.1.1.1
Rev: src/modules/files/configure.in:1.1.1.1
Rev: src/modules/files/datagram.c:1.1.1.1
Rev: src/modules/files/efuns.c:1.1.1.1
Rev: src/modules/files/file.c:1.1.1.1
Rev: src/modules/files/file.h:1.1.1.1
Rev: src/modules/files/file_machine.h.in:1.1.1.1
Rev: src/modules/files/socket.c:1.1.1.1
Rev: src/modules/math/Makefile.in:1.1.1.1
Rev: src/modules/math/configure.in:1.1.1.1
Rev: src/modules/math/math.c:1.1.1.1
Rev: src/modules/regexp/Makefile.in:1.1.1.1
Rev: src/modules/regexp/configure.in:1.1.1.1
Rev: src/modules/regexp/glue.c:1.1.1.1
Rev: src/modules/regexp/regexp.c:1.1.1.1
Rev: src/modules/regexp/regexp.h:1.1.1.1
Rev: src/modules/sprintf/Makefile.in:1.1.1.1
Rev: src/modules/sprintf/configure.in:1.1.1.1
Rev: src/modules/sprintf/sprintf.c:1.1.1.1
Rev: src/object.c:1.1.1.1
Rev: src/object.h:1.1.1.1
Rev: src/opcodes.c:1.1.1.1
Rev: src/opcodes.h:1.1.1.1
Rev: src/operators.c:1.1.1.1
Rev: src/operators.h:1.1.1.1
Rev: src/otable.h:1.1.1.1
Rev: src/port.c:1.1.1.1
Rev: src/port.h:1.1.1.1
Rev: src/program.c:1.1.1.1
Rev: src/program.h:1.1.1.1
Rev: src/rusage.c:1.1.1.1
Rev: src/rusage.h:1.1.1.1
Rev: src/stralloc.c:1.1.1.1
Rev: src/stralloc.h:1.1.1.1
Rev: src/stuff.c:1.1.1.1
Rev: src/stuff.h:1.1.1.1
Rev: src/svalue.c:1.1.1.1
Rev: src/svalue.h:1.1.1.1
Rev: src/todo:1.1.1.1
Rev: src/types.h:1.1.1.1
Rev: src/ualarm.c:1.1.1.1

1: + #include <stdlib.h> + #include "global.h" + #include "array.h" + #include "types.h" + #include "list.h" + #include "svalue.h" + #include "macros.h" + #include "memory.h" + #include "error.h" + #include "dynamic_buffer.h" + #include "interpret.h" + #include "builtin_efuns.h"    -  + struct list *first_list; +  + int list_member(struct list *l, struct svalue *ind) + { +  return set_lookup(l->ind, ind) >= 0; + } +  + /* +  * allocate and init a new list +  */ + static struct list *allocate_list(struct array *ind) + { +  struct list *l; +  l=ALLOC_STRUCT(list); +  l->next = first_list; +  l->prev = 0; +  l->refs = 1; +  l->ind=ind; +  if(first_list) first_list->prev = l; +  first_list=l; +  +  return l; + } +  + /* +  * free a list +  */ + void really_free_list(struct list *l) + { + #ifdef DEBUG +  if(l->refs) +  fatal("really free list on list with nonzero refs.\n"); + #endif +  +  free_array(l->ind); +  +  if(l->prev) l->prev->next = l->next; +  if(l->next) l->next->prev = l->prev; +  if(first_list == l) first_list = 0; +  +  free((char *)l); + } +  + static void order_list(struct list *l) + { +  INT32 *order; +  order = get_set_order(l->ind); +  l->ind = order_array(l->ind, order); +  free((char *)order); + } +  + struct list *mklist(struct array *ind) + { +  struct list *l; +  l=allocate_list(copy_array(ind)); +  order_list(l); +  return l; + } +  + void list_insert(struct list *l, +  struct svalue *ind) + { +  INT32 i; +  i=set_lookup(l->ind, ind); +  if(i < 0) +  { +  l->ind=array_insert(l->ind, ind, ~i); +  } + } +  + #if 0 + struct array *list_indices(struct list *l) + { +  return l->ind; + } + #endif +  + void list_delete(struct list *l,struct svalue *ind) + { +  INT32 i; +  i=set_lookup(l->ind, ind); +  +  if(i >= 0) l->ind=array_remove(l->ind, i); + } +  + void check_list_for_destruct(struct list *l) + { + /* Horrifiying worst case!!!!! */ +  INT32 i; +  while( (i=array_find_destructed_object(l->ind)) >= 0) +  l->ind=array_remove(l->ind, i); + } +  + struct list *copy_list(struct list *tmp) + { +  check_list_for_destruct(tmp); +  return allocate_list(copy_array(tmp->ind)); + } +  + struct list *merge_lists(struct list *a, +  struct list *b, +  INT32 operator) + { +  struct list *ret; +  INT32 *zipper; +  +  check_list_for_destruct(a); +  check_list_for_destruct(b); +  +  zipper=merge(a->ind,b->ind,operator); +  ret=allocate_list(array_zip(a->ind,b->ind,zipper)); +  free((char *)zipper); +  return ret; + } +  + struct list *add_lists(struct svalue *argp,INT32 args) + { +  struct list *ret,*a,*b; +  switch(args) +  { +  case 0: +  ret=allocate_list(allocate_array_no_init(0,0,T_MIXED)); +  break; +  +  case 1: +  ret=copy_list(argp->u.list); +  break; +  +  case 2: +  ret=merge_lists(argp[0].u.list,argp[1].u.list,OP_ADD); +  break; +  +  case 3: +  a=merge_lists(argp[0].u.list, argp[1].u.list, OP_ADD); +  ret=merge_lists(a, argp[2].u.list, OP_ADD); +  free_list(a); +  break; +  +  default: +  a=add_lists(argp,args/2); +  b=add_lists(argp+args/2,args-args/2); +  ret=merge_lists(a,b,OP_ADD); +  free_list(a); +  free_list(b); +  break; +  } +  +  return ret; + } +  + int list_equal_p(struct list *a, struct list *b, struct processing *p) + { +  if(a == b) return 1; +  check_list_for_destruct(a); +  +  return array_equal_p(a->ind, b->ind, p); + } +  + void describe_list(struct list *l,struct processing *p,int indent) + { +  struct processing doing; +  int e; +  char buf[40]; +  if(!l->ind->size) +  { +  my_strcat("(< >)"); +  return; +  } +  +  doing.next=p; +  doing.pointer_a=(void *)l; +  for(e=0;p;e++,p=p->next) +  { +  if(p->pointer_a == (void *)l) +  { +  sprintf(buf,"@%d",e); +  my_strcat(buf); +  return; +  } +  } +  +  sprintf(buf,"(< /* %ld elements */\n",l->ind->size); +  my_strcat(buf); +  describe_array_low(l->ind,&doing,indent); +  my_putchar('\n'); +  for(e=2; e<indent; e++) my_putchar(' '); +  my_strcat(">)"); + } +  + node * make_node_from_list(struct list *l) + { +  if(check_that_array_is_constant(l->ind)) +  { +  struct svalue s; +  s.type=T_LIST; +  s.subtype=0; +  s.u.list=l; +  return mkconstantsvaluenode(&s); +  }else{ +  return mkefuncallnode("mklist",make_node_from_array(l->ind)); +  } + } +  + void f_aggregate_list(INT32 args) + { +  struct list *l; +  f_aggregate(args); +  l=allocate_list(sp[-1].u.array); +  order_list(l); +  sp[-1].type=T_LIST; +  sp[-1].u.list=l; + } +  +  + struct list *copy_list_recursively(struct list *l, +  struct processing *p) + { +  struct processing doing; +  struct list *ret; +  +  doing.next=p; +  doing.pointer_a=(void *)l; +  for(;p;p=p->next) +  { +  if(p->pointer_a == (void *)l) +  { +  ret=(struct list *)p->pointer_b; +  ret->refs++; +  return ret; +  } +  } +  +  ret=allocate_list(0); +  doing.pointer_b=(void *)ret; +  +  ret->ind=copy_array_recursively(l->ind,&doing); +  +  order_list(ret); +  +  return ret; + }   Newline at end of file added.