diff -rc Genesis-1.0p4/README Genesis-1.0p6/README *** Genesis-1.0p4/README Sat Apr 20 15:03:42 1996 --- Genesis-1.0p6/README Wed May 22 14:51:18 1996 *************** *** 9,49 **** world directory (wherever it may be). ------------------------------------------------------------------------ ! 1.0-1 RELEASE INFORMATION ! If you are using a 0.4-0 database, you can upgrade easilly. Dump your ! database to text (coldcc -d), edit it and search for the following ! functions, replacing them with their native counterparts. Make sure ! you have the objects in your database for those counterparts, and that ! the methods they are using are not already defined: ! ! hostname() => $network.hostname() ! ip() => $network.ip() ! status() => $sys.status() ! next_objnum() => $sys.next_objnum() ! version() => $sys.version() ! strftime() => $time.format() ! encode() => $http.encode() ! decode() => $http.decode() ! ! The following function has also changed, in leiu of using the function name ! 'log()' for the logarithmic float function. ! ! log() => dblog() ! ! You will also have to update any calls to strfmt(), two changes to the ! function have been made: ! ! 1 - Data arguments are no longer specified in a list, instead ! they simply follow the format. ! 2 - Formatting has changed, read the documentation at: ! ! http://www.cold.org/ColdC/Functions/strfmt.html ! ! If you want coldcc to force override regular method definitions, when they ! conflict with away native method definitions, use the '-f' (force override) ! flag when you compile the binary database. You can list the compiled native ! methods and their default objects with the '-n' flag in coldcc. ------------------------------------------------------------------------ FURTHER INFORMATION --- 9,17 ---- world directory (wherever it may be). ------------------------------------------------------------------------ ! RELEASE INFORMATION ! Read doc/CHANGES for information on release changes. ------------------------------------------------------------------------ FURTHER INFORMATION *************** *** 131,137 **** arg 'string cmd, 'integer num, [more]; var 'integer i, some, other, that; ! When the type is set, it is always that. * Declare the default value of a variable when starting, such as: --- 99,105 ---- arg 'string cmd, 'integer num, [more]; var 'integer i, some, other, that; ! When the type is set, it is always that type (allowing optimizations). * Declare the default value of a variable when starting, such as: *************** *** 141,143 **** --- 109,112 ---- var i = .default_value(); + * with this allow multiple 'var' declarations. diff -rc Genesis-1.0p4/doc/CHANGES Genesis-1.0p6/doc/CHANGES *** Genesis-1.0p4/doc/CHANGES Fri Apr 26 13:33:07 1996 --- Genesis-1.0p6/doc/CHANGES Wed May 22 14:36:49 1996 *************** *** 6,11 **** --- 6,26 ---- contributors to that version. ------------------------------------------------------------------------- + 1.0-[56] [26-Apr-96] Brandon Gillespie + * I regressed from patch five back to patch four, due to some changes + which ended up being incorrect. The updated source became patch 6. + * changed how natives are handled (again), they now _MUST_ call + pop_native_stack() (Macro'd to CLEAN_STACK()) before native_pushing + a value and returning. This cleans up the args list and cleans + up the method call info (handled in methods with frame_return()). + * -s option added for cache WIDTHxDEPTH definition at execution time + * prepare_to_modify() in each data type should now be [data]_prep(), + and is globally available (some natives need these). + * destroy() should not take args, I forgot to change it earlier + * Forgot to #include for gettimeofday() in genesis.c + * Added '*' characters to pad and precision in strfmt(), like in + standard printf()'s. + * Fixed strfmt(), it was dying on '%%' => '%' escapes. 1.0-4 [26-Apr-96] Brandon Gillespie * Maintenance * 'compile()' now is a clone of 'add_method()', when the full diff -rc Genesis-1.0p4/etc/version Genesis-1.0p6/etc/version *** Genesis-1.0p4/etc/version Mon Apr 22 19:56:43 1996 --- Genesis-1.0p6/etc/version Tue May 21 09:38:05 1996 *************** *** 1 **** ! 1.0p3 --- 1 ---- ! 1.0p6 diff -rc Genesis-1.0p4/src/cache.c Genesis-1.0p6/src/cache.c *** Genesis-1.0p4/src/cache.c Thu Apr 18 16:27:36 1996 --- Genesis-1.0p6/src/cache.c Tue May 21 09:27:29 1996 *************** *** 13,18 **** --- 13,20 ---- // all rights reserved. */ + #define _cache_ + #include "config.h" #include "defs.h" *************** *** 55,70 **** object_t *obj; int i, j; ! active = EMALLOC(object_t, CACHE_WIDTH); ! inactive = EMALLOC(object_t, CACHE_WIDTH); ! for (i = 0; i < CACHE_WIDTH; i++) { /* Active list starts out empty. */ active[i].next = active[i].prev = &active[i]; /* Inactive list begins as a chain of empty objects. */ inactive[i].next = inactive[i].prev = &inactive[i]; ! for (j = 0; j < CACHE_DEPTH; j++) { obj = EMALLOC(object_t, 1); obj->objnum = INV_OBJNUM; obj->ucounter=0; --- 57,72 ---- object_t *obj; int i, j; ! active = EMALLOC(object_t, cache_width); ! inactive = EMALLOC(object_t, cache_width); ! for (i = 0; i < cache_width; i++) { /* Active list starts out empty. */ active[i].next = active[i].prev = &active[i]; /* Inactive list begins as a chain of empty objects. */ inactive[i].next = inactive[i].prev = &inactive[i]; ! for (j = 0; j < cache_depth; j++) { obj = EMALLOC(object_t, 1); obj->objnum = INV_OBJNUM; obj->ucounter=0; *************** *** 88,94 **** */ object_t * cache_get_holder(long objnum) { ! int ind = objnum % CACHE_WIDTH; object_t *obj; if (inactive[ind].next != &inactive[ind]) { --- 90,96 ---- */ object_t * cache_get_holder(long objnum) { ! int ind = objnum % cache_width; object_t *obj; if (inactive[ind].next != &inactive[ind]) { *************** *** 147,153 **** // */ object_t *cache_retrieve(long objnum) { ! int ind = objnum % CACHE_WIDTH; object_t *obj; if (objnum < 0) --- 149,155 ---- // */ object_t *cache_retrieve(long objnum) { ! int ind = objnum % cache_width; object_t *obj; if (objnum < 0) *************** *** 243,249 **** #if DEBUG_CACHE _acounter--; #endif ! ind = obj->objnum % CACHE_WIDTH; /* Reference count hit 0; remove from active chain. */ obj->prev->next = obj->next; --- 245,251 ---- #if DEBUG_CACHE _acounter--; #endif ! ind = obj->objnum % cache_width; /* Reference count hit 0; remove from active chain. */ obj->prev->next = obj->next; *************** *** 280,286 **** */ int cache_check(long objnum) { ! int ind = objnum % CACHE_WIDTH; object_t *obj; if (objnum < 0) --- 282,288 ---- */ int cache_check(long objnum) { ! int ind = objnum % cache_width; object_t *obj; if (objnum < 0) *************** *** 316,322 **** object_t *obj; /* Traverse all the active and inactive chains. */ ! for (i = 0; i < CACHE_WIDTH; i++) { /* Check active chain. */ for (obj = active[i].next; obj != &active[i]; obj = obj->next) { if (obj->dirty) { --- 318,324 ---- object_t *obj; /* Traverse all the active and inactive chains. */ ! for (i = 0; i < cache_width; i++) { /* Check active chain. */ for (obj = active[i].next; obj != &active[i]; obj = obj->next) { if (obj->dirty) { *************** *** 381,387 **** VMState * task; /* using labels was the best way I could come up with, I'm sorry... */ ! for (i = 0; i < CACHE_WIDTH; i++) { for (obj = active[i].next; obj != &active[i]; obj = obj->next) { /* check suspended tasks */ --- 383,389 ---- VMState * task; /* using labels was the best way I could come up with, I'm sorry... */ ! for (i = 0; i < cache_width; i++) { for (obj = active[i].next; obj != &active[i]; obj = obj->next) { /* check suspended tasks */ *************** *** 421,427 **** object_t * obj; int i; ! for (i = 0; i < CACHE_WIDTH; i++) { for (obj = inactive[i].next; obj != &inactive[i]; obj = obj->next) { obj->ucounter >>= 1; if(obj->ucounter > 0) { --- 423,429 ---- object_t * obj; int i; ! for (i = 0; i < cache_width; i++) { for (obj = inactive[i].next; obj != &inactive[i]; obj = obj->next) { obj->ucounter >>= 1; if(obj->ucounter > 0) { *************** *** 458,460 **** --- 460,464 ---- } } } + + #undef _cache_ diff -rc Genesis-1.0p4/src/coldcc.c Genesis-1.0p6/src/coldcc.c *** Genesis-1.0p4/src/coldcc.c Sat Apr 20 16:23:13 1996 --- Genesis-1.0p6/src/coldcc.c Wed May 22 11:06:11 1996 *************** *** 17,22 **** --- 17,23 ---- #include #include #include + #include #include "cdc_string.h" /* strccmp() */ #include "codegen.h" #include "cdc_types.h" *************** *** 229,253 **** name = *argv; - init_defs(); - - init_sig(); - init_codegen(); - init_ident(); - init_op_table(); - init_match(); - init_util(); - init_execute(); - init_scratch_file(); - init_token(); - init_modules(argc, argv); - init_cache(); - use_natives = 0; argv++; argc--; while (argc) { if (**argv == '-') { opt = *argv; --- 230,243 ---- name = *argv; use_natives = 0; argv++; argc--; + init_util(); + init_defs(); + while (argc) { if (**argv == '-') { opt = *argv; *************** *** 275,280 **** --- 265,293 ---- case 'p': c_opt = OPT_PARTIAL; break; + case 's': { + char * p; + + argv += getarg(name, &buf, opt, argv, &argc, usage); + p = buf; + cache_width = atoi(p); + while (*p && isdigit(*p)) + p++; + if (LCASE(*p) == 'x') { + p++; + cache_depth = atoi(p); + } else { + usage(name); + printf("\n** Invalid WIDTHxDEPTH: '%s'\n", buf); + exit(0); + } + if (cache_width == 0 && cache_depth == 0) { + usage(name); + puts("\n** The WIDTH and DEPTH cannot both be zero\n"); + exit(0); + } + break; + } case 'w': fputs("\n** Unsupported option: -w\n", stderr); c_nowrite = 0; *************** *** 301,306 **** --- 314,330 ---- argv++; argc--; } + + init_sig(); + init_codegen(); + init_ident(); + init_op_table(); + init_match(); + init_execute(); + init_scratch_file(); + init_token(); + init_modules(argc, argv); + init_cache(); } /* *************** *** 324,329 **** --- 348,354 ---- -p Partial compile, compile object(s) and insert\n\ into database accordingly. Can be used with -w\n\ for a ColdC code verification program.\n\ + -s WIDTHxDEPTH Cache size, default 10x30\n\n\ Anticipated Options:\n\n\ -w Compile for parse only, do not write output.\n\ This option can only be used with partial compile.\n\ diff -rc Genesis-1.0p4/src/data/buffer.c Genesis-1.0p6/src/data/buffer.c *** Genesis-1.0p4/src/data/buffer.c Sat Mar 9 20:09:17 1996 --- Genesis-1.0p6/src/data/buffer.c Tue May 21 17:28:56 1996 *************** *** 16,28 **** #include "memory.h" #include "util.h" ! #define BUFALLOC(len) (Buffer *)emalloc(sizeof(Buffer) + (len) - 1) ! #define BUFREALLOC(buf, len) (Buffer *)erealloc(buf, sizeof(Buffer) + (len) - 1) ! INTERNAL Buffer *prepare_to_modify(Buffer *buf); ! ! Buffer *buffer_new(int len) { ! Buffer *buf; buf = BUFALLOC(len); buf->len = len; --- 16,26 ---- #include "memory.h" #include "util.h" ! #define BUFALLOC(len) (buffer_t *)emalloc(sizeof(buffer_t) + (len) - 1) ! #define BUFREALLOC(buf, len) (buffer_t *)erealloc(buf, sizeof(buffer_t) + (len) - 1) ! buffer_t *buffer_new(int len) { ! buffer_t *buf; buf = BUFALLOC(len); buf->len = len; *************** *** 30,99 **** return buf; } ! Buffer *buffer_dup(Buffer *buf) { buf->refs++; return buf; } ! void buffer_discard(Buffer *buf) { buf->refs--; if (!buf->refs) efree(buf); } ! Buffer *buffer_append(Buffer *buf1, Buffer *buf2) { if (!buf2->len) return buf1; ! buf1 = prepare_to_modify(buf1); buf1 = BUFREALLOC(buf1, buf1->len + buf2->len); MEMCPY(buf1->s + buf1->len, buf2->s, buf2->len); buf1->len += buf2->len; return buf1; } ! int buffer_retrieve(Buffer *buf, int pos) { return buf->s[pos]; } ! Buffer *buffer_replace(Buffer *buf, int pos, unsigned int c) { if (buf->s[pos] == c) return buf; ! buf = prepare_to_modify(buf); buf->s[pos] = OCTET_VALUE(c); return buf; } ! Buffer *buffer_add(Buffer *buf, unsigned int c) { ! buf = prepare_to_modify(buf); buf = BUFREALLOC(buf, buf->len + 1); buf->s[buf->len] = OCTET_VALUE(c); buf->len++; return buf; } ! Buffer *buffer_resize(Buffer *buf, int len) { if (len == buf->len) return buf; ! buf = prepare_to_modify(buf); buf = BUFREALLOC(buf, len); buf->len = len; return buf; } ! Buffer *buffer_tail(Buffer *buf, int pos) { ! Buffer *outbuf; if (pos == 1) return buf; ! outbuf = prepare_to_modify(buf); outbuf->len = buf->len - (pos-1); MEMCPY(outbuf->s, buf->s+(pos-1), outbuf->len); outbuf = BUFREALLOC(outbuf,outbuf->len); return(outbuf); } ! string_t * buffer_to_string(Buffer * buf) { string_t * str, * out; unsigned char * string_start, *p, *q; char * s; --- 28,97 ---- return buf; } ! buffer_t *buffer_dup(buffer_t *buf) { buf->refs++; return buf; } ! void buffer_discard(buffer_t *buf) { buf->refs--; if (!buf->refs) efree(buf); } ! buffer_t *buffer_append(buffer_t *buf1, buffer_t *buf2) { if (!buf2->len) return buf1; ! buf1 = buffer_prep(buf1); buf1 = BUFREALLOC(buf1, buf1->len + buf2->len); MEMCPY(buf1->s + buf1->len, buf2->s, buf2->len); buf1->len += buf2->len; return buf1; } ! int buffer_retrieve(buffer_t *buf, int pos) { return buf->s[pos]; } ! buffer_t *buffer_replace(buffer_t *buf, int pos, unsigned int c) { if (buf->s[pos] == c) return buf; ! buf = buffer_prep(buf); buf->s[pos] = OCTET_VALUE(c); return buf; } ! buffer_t *buffer_add(buffer_t *buf, unsigned int c) { ! buf = buffer_prep(buf); buf = BUFREALLOC(buf, buf->len + 1); buf->s[buf->len] = OCTET_VALUE(c); buf->len++; return buf; } ! buffer_t *buffer_resize(buffer_t *buf, int len) { if (len == buf->len) return buf; ! buf = buffer_prep(buf); buf = BUFREALLOC(buf, len); buf->len = len; return buf; } ! buffer_t *buffer_tail(buffer_t *buf, int pos) { ! buffer_t *outbuf; if (pos == 1) return buf; ! outbuf = buffer_prep(buf); outbuf->len = buf->len - (pos-1); MEMCPY(outbuf->s, buf->s+(pos-1), outbuf->len); outbuf = BUFREALLOC(outbuf,outbuf->len); return(outbuf); } ! string_t * buffer_to_string(buffer_t * buf) { string_t * str, * out; unsigned char * string_start, *p, *q; char * s; *************** *** 135,141 **** } /* If sep (separator buffer) is NULL, separate by newlines. */ ! list_t *buffer_to_strings(Buffer *buf, Buffer *sep) { data_t d; string_t *str; --- 133,139 ---- } /* If sep (separator buffer) is NULL, separate by newlines. */ ! list_t *buffer_to_strings(buffer_t *buf, buffer_t *sep) { data_t d; string_t *str; *************** *** 143,149 **** unsigned char sepchar, *string_start, *p, *q; char *s; int seplen; ! Buffer *end; sepchar = (sep) ? *sep->s : '\n'; seplen = (sep) ? sep->len : 1; --- 141,147 ---- unsigned char sepchar, *string_start, *p, *q; char *s; int seplen; ! buffer_t *end; sepchar = (sep) ? *sep->s : '\n'; seplen = (sep) ? sep->len : 1; *************** *** 192,199 **** return result; } ! Buffer *buffer_from_string(string_t * string) { ! Buffer * buf; int new; buf = buffer_new(string_length(string)); --- 190,197 ---- return result; } ! buffer_t *buffer_from_string(string_t * string) { ! buffer_t * buf; int new; buf = buffer_new(string_length(string)); *************** *** 207,215 **** return buf; } ! Buffer *buffer_from_strings(list_t * string_list, Buffer * sep) { data_t * string_data; ! Buffer *buf; int num_strings, i, len, pos; unsigned char *s; --- 205,213 ---- return buf; } ! buffer_t *buffer_from_strings(list_t * string_list, buffer_t * sep) { data_t * string_data; ! buffer_t *buf; int num_strings, i, len, pos; unsigned char *s; *************** *** 241,248 **** return buf; } ! Buffer * buffer_subrange(Buffer * buf, int start, int len) { ! Buffer * cnew = buffer_new(len); MEMCPY(cnew->s, buf->s + start, (len > buf->len ? buf->len : len)); cnew->len = len; --- 239,246 ---- return buf; } ! buffer_t * buffer_subrange(buffer_t * buf, int start, int len) { ! buffer_t * cnew = buffer_new(len); MEMCPY(cnew->s, buf->s + start, (len > buf->len ? buf->len : len)); cnew->len = len; *************** *** 251,259 **** return cnew; } ! INTERNAL Buffer *prepare_to_modify(Buffer *buf) ! { ! Buffer *cnew; if (buf->refs == 1) return buf; --- 249,256 ---- return cnew; } ! buffer_t *buffer_prep(buffer_t *buf) { ! buffer_t *cnew; if (buf->refs == 1) return buf; diff -rc Genesis-1.0p4/src/data/data.c Genesis-1.0p6/src/data/data.c *** Genesis-1.0p4/src/data/data.c Sat Apr 20 13:48:54 1996 --- Genesis-1.0p6/src/data/data.c Tue May 21 17:35:08 1996 *************** *** 213,219 **** break; case FROB: ! dest->u.frob = TMALLOC(Frob, 1); dest->u.frob->cclass = src->u.frob->cclass; data_dup(&dest->u.frob->rep, &src->u.frob->rep); break; --- 213,219 ---- break; case FROB: ! dest->u.frob = TMALLOC(frob_t, 1); dest->u.frob->cclass = src->u.frob->cclass; data_dup(&dest->u.frob->rep, &src->u.frob->rep); break; diff -rc Genesis-1.0p4/src/data/dict.c Genesis-1.0p6/src/data/dict.c *** Genesis-1.0p4/src/data/dict.c Sat Mar 9 20:07:28 1996 --- Genesis-1.0p6/src/data/dict.c Tue May 21 17:33:39 1996 *************** *** 19,36 **** #define MALLOC_DELTA 5 #define HASHTAB_STARTING_SIZE (32 - MALLOC_DELTA) ! static Dict *prepare_to_modify(Dict *dict); ! static void insert_key(Dict *dict, int i); ! static int search(Dict *dict, data_t *key); ! static void double_hashtab_size(Dict *dict); ! Dict *dict_new(list_t *keys, list_t *values) { ! Dict *cnew; int i, j; /* Construct a new dictionary. */ ! cnew = EMALLOC(Dict, 1); cnew->keys = list_dup(keys); cnew->values = list_dup(values); --- 19,35 ---- #define MALLOC_DELTA 5 #define HASHTAB_STARTING_SIZE (32 - MALLOC_DELTA) ! static void insert_key(dict_t *dict, int i); ! static int search(dict_t *dict, data_t *key); ! static void double_hashtab_size(dict_t *dict); ! dict_t *dict_new(list_t *keys, list_t *values) { ! dict_t *cnew; int i, j; /* Construct a new dictionary. */ ! cnew = EMALLOC(dict_t, 1); cnew->keys = list_dup(keys); cnew->values = list_dup(values); *************** *** 68,77 **** return cnew; } ! Dict *dict_new_empty(void) { list_t *l1, *l2; ! Dict *dict; l1 = list_new(0); l2 = list_new(0); --- 67,76 ---- return cnew; } ! dict_t *dict_new_empty(void) { list_t *l1, *l2; ! dict_t *dict; l1 = list_new(0); l2 = list_new(0); *************** *** 81,90 **** return dict; } ! Dict *dict_from_slices(list_t *slices) { list_t *keys, *values; ! Dict *dict; data_t *d; /* Make lists for keys and values. */ --- 80,89 ---- return dict; } ! dict_t *dict_from_slices(list_t *slices) { list_t *keys, *values; ! dict_t *dict; data_t *d; /* Make lists for keys and values. */ *************** *** 109,121 **** return dict; } ! Dict *dict_dup(Dict *dict) { dict->refs++; return dict; } ! void dict_discard(Dict *dict) { dict->refs--; if (!dict->refs) { --- 108,120 ---- return dict; } ! dict_t *dict_dup(dict_t *dict) { dict->refs++; return dict; } ! void dict_discard(dict_t *dict) { dict->refs--; if (!dict->refs) { *************** *** 127,133 **** } } ! int dict_cmp(Dict *dict1, Dict *dict2) { if (list_cmp(dict1->keys, dict2->keys) == 0 && list_cmp(dict1->values, dict2->values) == 0) --- 126,132 ---- } } ! int dict_cmp(dict_t *dict1, dict_t *dict2) { if (list_cmp(dict1->keys, dict2->keys) == 0 && list_cmp(dict1->values, dict2->values) == 0) *************** *** 136,146 **** return 1; } ! Dict *dict_add(Dict *dict, data_t *key, data_t *value) { int pos; ! dict = prepare_to_modify(dict); /* Just replace the value for the key if it already exists. */ pos = search(dict, key); --- 135,145 ---- return 1; } ! dict_t *dict_add(dict_t *dict, data_t *key, data_t *value) { int pos; ! dict = dict_prep(dict); /* Just replace the value for the key if it already exists. */ pos = search(dict, key); *************** *** 163,173 **** /* Error-checking is the caller's responsibility; this routine assumes that it * will find the key in the dictionary. */ ! Dict *dict_del(Dict *dict, data_t *key) { int ind, *ip, i = -1, j; ! dict = prepare_to_modify(dict); /* Search for a pointer to the key, either in the hash table entry or in * the chain links. */ --- 162,172 ---- /* Error-checking is the caller's responsibility; this routine assumes that it * will find the key in the dictionary. */ ! dict_t *dict_del(dict_t *dict, data_t *key) { int ind, *ip, i = -1, j; ! dict = dict_prep(dict); /* Search for a pointer to the key, either in the hash table entry or in * the chain links. */ *************** *** 207,213 **** return dict; } ! long dict_find(Dict *dict, data_t *key, data_t *ret) { int pos; --- 206,212 ---- return dict; } ! long dict_find(dict_t *dict, data_t *key, data_t *ret) { int pos; *************** *** 219,225 **** return NOT_AN_IDENT; } ! int dict_contains(Dict *dict, data_t *key) { int pos; --- 218,224 ---- return NOT_AN_IDENT; } ! int dict_contains(dict_t *dict, data_t *key) { int pos; *************** *** 227,238 **** return (pos != -1); } ! list_t *dict_keys(Dict *dict) { return list_dup(dict->keys); } ! list_t *dict_key_value_pair(Dict *dict, int i) { list_t *l; --- 226,237 ---- return (pos != -1); } ! list_t *dict_keys(dict_t *dict) { return list_dup(dict->keys); } ! list_t *dict_key_value_pair(dict_t *dict, int i) { list_t *l; *************** *** 245,251 **** return l; } ! string_t *dict_add_literal_to_str(string_t *str, Dict *dict) { int i; --- 244,250 ---- return l; } ! string_t *dict_add_literal_to_str(string_t *str, dict_t *dict) { int i; *************** *** 262,276 **** return string_addc(str, ']'); } ! static Dict *prepare_to_modify(Dict *dict) ! { ! Dict *cnew; if (dict->refs == 1) return dict; /* Duplicate the old dictionary. */ ! cnew = EMALLOC(Dict, 1); cnew->keys = list_dup(dict->keys); cnew->values = list_dup(dict->values); cnew->hashtab_size = dict->hashtab_size; --- 261,274 ---- return string_addc(str, ']'); } ! dict_t *dict_prep(dict_t *dict) { ! dict_t *cnew; if (dict->refs == 1) return dict; /* Duplicate the old dictionary. */ ! cnew = EMALLOC(dict_t, 1); cnew->keys = list_dup(dict->keys); cnew->values = list_dup(dict->values); cnew->hashtab_size = dict->hashtab_size; *************** *** 283,289 **** return cnew; } ! static void insert_key(Dict *dict, int i) { int ind; --- 281,287 ---- return cnew; } ! static void insert_key(dict_t *dict, int i) { int ind; *************** *** 292,298 **** dict->hashtab[ind] = i; } ! static int search(Dict *dict, data_t *key) { int ind, i; --- 290,296 ---- dict->hashtab[ind] = i; } ! static int search(dict_t *dict, data_t *key) { int ind, i; *************** *** 305,316 **** return -1; } ! int dict_size(Dict *dict) { return list_length(dict->keys); } ! static void double_hashtab_size(Dict *dict) { int i; --- 303,314 ---- return -1; } ! int dict_size(dict_t *dict) { return list_length(dict->keys); } ! static void double_hashtab_size(dict_t *dict) { int i; diff -rc Genesis-1.0p4/src/data/list.c Genesis-1.0p6/src/data/list.c *** Genesis-1.0p4/src/data/list.c Thu Apr 25 22:46:49 1996 --- Genesis-1.0p6/src/data/list.c Tue May 21 09:31:35 1996 *************** *** 46,52 **** * In general, modifying start and len is the responsibility of this routine; * modifying the contents is the responsibility of the calling routine. */ ! static list_t *prepare_to_modify(list_t *list, int start, int len) { list_t * cnew; int i, resize, --- 46,52 ---- * In general, modifying start and len is the responsibility of this routine; * modifying the contents is the responsibility of the calling routine. */ ! list_t * list_prep(list_t *list, int start, int len) { list_t * cnew; int i, resize, *************** *** 176,182 **** /* Error-checking on pos is the job of the calling function. */ list_t *list_insert(list_t *list, int pos, data_t *elem) { ! list = prepare_to_modify(list, list->start, list->len + 1); pos += list->start; MEMMOVE(list->el + pos + 1, list->el + pos, list->len - 1 - pos); data_dup(&list->el[pos], elem); --- 176,182 ---- /* Error-checking on pos is the job of the calling function. */ list_t *list_insert(list_t *list, int pos, data_t *elem) { ! list = list_prep(list, list->start, list->len + 1); pos += list->start; MEMMOVE(list->el + pos + 1, list->el + pos, list->len - 1 - pos); data_dup(&list->el[pos], elem); *************** *** 184,199 **** } list_t *list_add(list_t *list, data_t *elem) { ! list = prepare_to_modify(list, list->start, list->len + 1); data_dup(&list->el[list->start + list->len - 1], elem); return list; } /* Error-checking on pos is the job of the calling function. */ list_t *list_replace(list_t *list, int pos, data_t *elem) { ! /* prepare_to_modify needed here only for multiply referenced lists */ if (list->refs > 1) ! list = prepare_to_modify(list, list->start, list->len); pos += list->start; data_discard(&list->el[pos]); data_dup(&list->el[pos], elem); --- 184,199 ---- } list_t *list_add(list_t *list, data_t *elem) { ! list = list_prep(list, list->start, list->len + 1); data_dup(&list->el[list->start + list->len - 1], elem); return list; } /* Error-checking on pos is the job of the calling function. */ list_t *list_replace(list_t *list, int pos, data_t *elem) { ! /* list_prep needed here only for multiply referenced lists */ if (list->refs > 1) ! list = list_prep(list, list->start, list->len); pos += list->start; data_discard(&list->el[pos]); data_dup(&list->el[pos], elem); *************** *** 204,224 **** list_t *list_delete(list_t *list, int pos) { /* Special-case deletion of last element. */ if (pos == list->len - 1) ! return prepare_to_modify(list, list->start, list->len - 1); ! /* prepare_to_modify needed here only for multiply referenced lists */ if (list->refs > 1) ! list = prepare_to_modify(list, list->start, list->len); pos += list->start; data_discard(&list->el[pos]); MEMMOVE(list->el + pos, list->el + pos + 1, list->len - pos); list->len--; ! /* prepare_to_modify needed here only if list has shrunk */ if (((list->len - list->start) * 4 < list->size) && (list->size > STARTING_SIZE)) ! list = prepare_to_modify(list, list->start, list->len); return list; } --- 204,224 ---- list_t *list_delete(list_t *list, int pos) { /* Special-case deletion of last element. */ if (pos == list->len - 1) ! return list_prep(list, list->start, list->len - 1); ! /* list_prep needed here only for multiply referenced lists */ if (list->refs > 1) ! list = list_prep(list, list->start, list->len); pos += list->start; data_discard(&list->el[pos]); MEMMOVE(list->el + pos, list->el + pos + 1, list->len - pos); list->len--; ! /* list_prep needed here only if list has shrunk */ if (((list->len - list->start) * 4 < list->size) && (list->size > STARTING_SIZE)) ! list = list_prep(list, list->start, list->len); return list; } *************** *** 232,238 **** int i; data_t *p, *q; ! list1 = prepare_to_modify(list1, list1->start, list1->len + list2->len); p = list1->el + list1->start + list1->len - list2->len; q = list2->el + list2->start; for (i = 0; i < list2->len; i++) --- 232,238 ---- int i; data_t *p, *q; ! list1 = list_prep(list1, list1->start, list1->len + list2->len); p = list1->el + list1->start + list1->len - list2->len; q = list2->el + list2->start; for (i = 0; i < list2->len; i++) *************** *** 244,252 **** data_t *d, tmp; int i; ! /* prepare_to_modify needed here only for multiply referenced lists */ if (list->refs > 1) ! list = prepare_to_modify(list, list->start, list->len); d = list->el + list->start; for (i = 0; i < list->len / 2; i++) { --- 244,252 ---- data_t *d, tmp; int i; ! /* list_prep needed here only for multiply referenced lists */ if (list->refs > 1) ! list = list_prep(list, list->start, list->len); d = list->el + list->start; for (i = 0; i < list->len / 2; i++) { *************** *** 285,291 **** } list_t *list_sublist(list_t *list, int start, int len) { ! return prepare_to_modify(list, list->start + start, len); } /* Warning: do not discard a list before initializing its data elements. */ --- 285,291 ---- } list_t *list_sublist(list_t *list, int start, int len) { ! return list_prep(list, list->start + start, len); } /* Warning: do not discard a list before initializing its data elements. */ diff -rc Genesis-1.0p4/src/data/string.c Genesis-1.0p6/src/data/string.c *** Genesis-1.0p4/src/data/string.c Sat Apr 20 14:12:44 1996 --- Genesis-1.0p6/src/data/string.c Tue May 21 09:34:03 1996 *************** *** 34,41 **** #define MALLOC_DELTA (sizeof(string_t) + 32) #define STARTING_SIZE (128 - MALLOC_DELTA) - string_t * prepare_to_modify_str(string_t *str, int start, int len); - string_t *string_new(int size_needed) { string_t *cnew; int size; --- 34,39 ---- *************** *** 118,130 **** } string_t *string_fread(string_t *str, int len, FILE *fp) { ! str = prepare_to_modify_str(str, str->start, str->len + len); fread(str->s + str->start + str->len - len, sizeof(char), len, fp); return str; } string_t *string_add(string_t *str1, string_t *str2) { ! str1 = prepare_to_modify_str(str1, str1->start, str1->len + str2->len); MEMCPY(str1->s + str1->start + str1->len - str2->len, str2->s + str2->start, str2->len); str1->s[str1->start + str1->len] = 0; --- 116,128 ---- } string_t *string_fread(string_t *str, int len, FILE *fp) { ! str = string_prep(str, str->start, str->len + len); fread(str->s + str->start + str->len - len, sizeof(char), len, fp); return str; } string_t *string_add(string_t *str1, string_t *str2) { ! str1 = string_prep(str1, str1->start, str1->len + str2->len); MEMCPY(str1->s + str1->start + str1->len - str2->len, str2->s + str2->start, str2->len); str1->s[str1->start + str1->len] = 0; *************** *** 133,139 **** /* calling this with len == 0 can be a problem */ string_t *string_add_chars(string_t *str, char *s, int len) { ! str = prepare_to_modify_str(str, str->start, str->len + len); MEMCPY(str->s + str->start + str->len - len, s, len); /*str->s[str->len + str->start + len] = 0;*/ str->s[str->start + str->len] = 0; --- 131,137 ---- /* calling this with len == 0 can be a problem */ string_t *string_add_chars(string_t *str, char *s, int len) { ! str = string_prep(str, str->start, str->len + len); MEMCPY(str->s + str->start + str->len - len, s, len); /*str->s[str->len + str->start + len] = 0;*/ str->s[str->start + str->len] = 0; *************** *** 141,154 **** } string_t *string_addc(string_t *str, int c) { ! str = prepare_to_modify_str(str, str->start, str->len + 1); str->s[str->start + str->len - 1] = c; str->s[str->start + str->len] = 0; return str; } string_t *string_add_padding(string_t *str, char *filler, int len, int padding) { ! str = prepare_to_modify_str(str, str->start, str->len + padding); if (len == 1) { /* Optimize this case using memset(). */ --- 139,152 ---- } string_t *string_addc(string_t *str, int c) { ! str = string_prep(str, str->start, str->len + 1); str->s[str->start + str->len - 1] = c; str->s[str->start + str->len] = 0; return str; } string_t *string_add_padding(string_t *str, char *filler, int len, int padding) { ! str = string_prep(str, str->start, str->len + padding); if (len == 1) { /* Optimize this case using memset(). */ *************** *** 165,209 **** } string_t *string_truncate(string_t *str, int len) { ! str = prepare_to_modify_str(str, str->start, len); str->s[str->start + len] = 0; return str; } string_t *string_substring(string_t *str, int start, int len) { ! str = prepare_to_modify_str(str, str->start + start, len); str->s[str->start + str->len] = 0; return str; } - string_t * string_dup_or_copy(string_t * str) { - if (str->refs > 1) { - string_t * cnew = string_new(str->len); - MEMCPY(cnew->s, string_chars(str), string_length(str)); - cnew->len = string_length(str); - return cnew; - } else { - return string_dup(str); - } - } - string_t * string_uppercase(string_t *str) { char *s, *start, *end; ! start = str->s + str->start; end = start + str->len; for (s = start; s < end; s++) ! *s = UCASE(*s); return str; } string_t * string_lowercase(string_t *str) { char *s, *start, *end; start = str->s + str->start; end = start + str->len; for (s = start; s < end; s++) ! *s = LCASE(*s); return str; } --- 163,198 ---- } string_t *string_truncate(string_t *str, int len) { ! str = string_prep(str, str->start, len); str->s[str->start + len] = 0; return str; } string_t *string_substring(string_t *str, int start, int len) { ! str = string_prep(str, str->start + start, len); str->s[str->start + str->len] = 0; return str; } string_t * string_uppercase(string_t *str) { char *s, *start, *end; ! ! str = string_prep(str, str->start, str->len); start = str->s + str->start; end = start + str->len; for (s = start; s < end; s++) ! *s = UCASE(*s); return str; } string_t * string_lowercase(string_t *str) { char *s, *start, *end; + str = string_prep(str, str->start, str->len); start = str->s + str->start; end = start + str->len; for (s = start; s < end; s++) ! *s = LCASE(*s); return str; } *************** *** 293,299 **** // In general, modifying start and len is the responsibility of this routine; // modifying the contents is the responsibility of the calling routine. */ ! string_t * prepare_to_modify_str(string_t *str, int start, int len) { string_t *cnew; int need_to_move, need_to_resize, size; --- 282,288 ---- // In general, modifying start and len is the responsibility of this routine; // modifying the contents is the responsibility of the calling routine. */ ! string_t * string_prep(string_t *str, int start, int len) { string_t *cnew; int need_to_move, need_to_resize, size; diff -rc Genesis-1.0p4/src/dbpack.c Genesis-1.0p6/src/dbpack.c *** Genesis-1.0p4/src/dbpack.c Sun Mar 10 19:56:40 1996 --- Genesis-1.0p6/src/dbpack.c Tue May 21 17:32:37 1996 *************** *** 182,188 **** return size; } ! INTERNAL void pack_dict(Dict *dict, FILE *fp) { int i; --- 182,188 ---- return size; } ! INTERNAL void pack_dict(dict_t *dict, FILE *fp) { int i; *************** *** 195,206 **** } } ! INTERNAL Dict *unpack_dict(FILE *fp) { ! Dict *dict; int i; ! dict = EMALLOC(Dict, 1); dict->keys = unpack_list(fp); dict->values = unpack_list(fp); dict->hashtab_size = read_long(fp); --- 195,206 ---- } } ! INTERNAL dict_t *unpack_dict(FILE *fp) { ! dict_t *dict; int i; ! dict = EMALLOC(dict_t, 1); dict->keys = unpack_list(fp); dict->values = unpack_list(fp); dict->hashtab_size = read_long(fp); *************** *** 214,220 **** return dict; } ! INTERNAL int size_dict(Dict *dict) { int size = 0, i; --- 214,220 ---- return dict; } ! INTERNAL int size_dict(dict_t *dict) { int size = 0, i; *************** *** 645,651 **** break; case FROB: ! data->u.frob = TMALLOC(Frob, 1); data->u.frob->cclass = read_long(fp); unpack_data(&data->u.frob->rep, fp); break; --- 645,651 ---- break; case FROB: ! data->u.frob = TMALLOC(frob_t, 1); data->u.frob->cclass = read_long(fp); unpack_data(&data->u.frob->rep, fp); break; diff -rc Genesis-1.0p4/src/execute.c Genesis-1.0p6/src/execute.c *** Genesis-1.0p4/src/execute.c Thu Apr 25 22:43:18 1996 --- Genesis-1.0p6/src/execute.c Wed May 22 14:45:28 1996 *************** *** 565,580 **** while (cur_frame) { tick++; - if ((--(cur_frame->ticks)) == 0) { out_of_ticks_error(); ! return; } - - opcode = cur_frame->opcodes[cur_frame->pc]; - cur_frame->last_opcode = opcode; - cur_frame->pc++; - (*op_table[opcode].func)(); } } --- 565,578 ---- while (cur_frame) { tick++; if ((--(cur_frame->ticks)) == 0) { out_of_ticks_error(); ! } else { ! opcode = cur_frame->opcodes[cur_frame->pc]; ! cur_frame->last_opcode = opcode; ! cur_frame->pc++; ! (*op_table[opcode].func)(); } } } *************** *** 615,635 **** /* // --------------------------------------------------------------- */ ! INTERNAL void call_native_method(method_t * method, int stack_start, int arg_start, objnum_t objnum) { data_t rval; register int i; - rval.type = OBJNUM; - rval.u.objnum = objnum; if ((*natives[method->native].func)(arg_start, &rval)) { ! for (i = stack_start + 1; i < stack_pos; i++) data_discard(&stack[i]); stack_pos = stack_start; stack[stack_pos] = rval; stack_pos++; } } /* // --------------------------------------------------------------- --- 613,667 ---- /* // --------------------------------------------------------------- + // + // Ok, our stack looks like: + // + // [ ... | target | arg1 | arg2 | ... ] + // ^^^^^^-- stack_start + // + // make SURE that native methods are clearly duping their data */ ! ! #if DISABLED ! INTERNAL void ! call_native_method(method_t * method, ! int stack_start, ! int arg_start, ! objnum_t objnum) ! { data_t rval; register int i; if ((*natives[method->native].func)(arg_start, &rval)) { ! /* push ALL of the old stack off, including the target and name */ ! for (i = stack_start; i < stack_pos; i++) data_discard(&stack[i]); + + /* 'pop' the return value back on the stack */ stack_pos = stack_start; stack[stack_pos] = rval; stack_pos++; } } + #else + #define call_native_method(method, sstart, astart) \ + (*natives[method->native].func)(sstart, astart) + #endif + + /* + // because we want to keep references straight, one oft may want to + // grab the data they want off the stack, dup it for their own copy, + // then pop everything off the stack so references would still be + // one (in the cases that matter) + */ + + void pop_native_stack(int start) { + register int i; + + for (i = start; i < stack_pos; i++) + data_discard(&stack[i]); + stack_pos = start; + } /* // --------------------------------------------------------------- *************** *** 667,674 **** cur_frame->caller, cur_frame->user, stack_start, arg_start); } else { call_native_method(method, stack_start, arg_start, method->object->objnum); ! /* method_discard(method); */ result = CALL_NATIVE; } cache_discard(method->object); --- 699,709 ---- cur_frame->caller, cur_frame->user, stack_start, arg_start); } else { + #if 0 call_native_method(method, stack_start, arg_start, method->object->objnum); ! #else ! call_native_method(method, stack_start, arg_start); ! #endif result = CALL_NATIVE; } cache_discard(method->object); *************** *** 740,747 **** result = frame_start(obj,method,sender, caller,user,stack_start,arg_start); } else { ! call_native_method(method, stack_start, arg_start, objnum); ! /* method_discard(method); */ result = CALL_NATIVE; } --- 775,781 ---- result = frame_start(obj,method,sender, caller,user,stack_start,arg_start); } else { ! call_native_method(method, stack_start, arg_start); result = CALL_NATIVE; } *************** *** 777,920 **** /* // --------------------------------------------------------------- */ ! void push_int(long n) { ! ! #ifdef DEBUG ! write_err("push(%d)", n); ! #endif ! ! check_stack(1); ! stack[stack_pos].type = INTEGER; ! stack[stack_pos].u.val = n; ! stack_pos++; ! } ! ! /* ! // --------------------------------------------------------------- ! */ ! void push_float(float f) { ! ! #ifdef DEBUG ! write_err("push(%f)", f); ! #endif ! ! check_stack(1); ! stack[stack_pos].type = FLOAT; ! stack[stack_pos].u.fval = f; ! stack_pos++; ! } ! ! /* ! // --------------------------------------------------------------- ! */ ! void push_string(string_t *str) { ! ! #ifdef DEBUG ! write_err("push(\"%S\")", str); ! #endif ! ! check_stack(1); ! stack[stack_pos].type = STRING; ! stack[stack_pos].u.str = string_dup(str); ! stack_pos++; ! } /* // --------------------------------------------------------------- */ - void push_objnum(objnum_t objnum) { - - #ifdef DEBUG - write_err("push($%d)", objnum); - #endif - - check_stack(1); - stack[stack_pos].type = OBJNUM; - stack[stack_pos].u.objnum = objnum; - stack_pos++; - } - - /* - // --------------------------------------------------------------- - */ - void push_list(list_t * list) { - #ifdef DEBUG - string_t *str = string_new(0); - - write_err("push(%S)", data_add_list_literal_to_str(str, list)); - - string_discard(str); - #endif - - check_stack(1); - stack[stack_pos].type = LIST; - stack[stack_pos].u.list = list_dup(list); - stack_pos++; - } - - /* - // --------------------------------------------------------------- - */ - void push_dict(Dict *dict) { - #ifdef DEBUG - string_t *str = string_new(0); - - write_err("push(%S)", dict_add_literal_to_str(str, dict)); - - string_discard(str); - #endif - - check_stack(1); - stack[stack_pos].type = DICT; - stack[stack_pos].u.dict = dict_dup(dict); - stack_pos++; - } - - /* - // --------------------------------------------------------------- - */ - void push_symbol(Ident id) { - - #ifdef DEBUG - write_err("push(\'%s)", ident_name(id)); - #endif - - check_stack(1); - stack[stack_pos].type = SYMBOL; - stack[stack_pos].u.symbol = ident_dup(id); - stack_pos++; - } - - /* - // --------------------------------------------------------------- - */ - void push_error(Ident id) { - - #ifdef DEBUG - write_err("push(\'%s)", ident_name(id)); - #endif - - check_stack(1); - stack[stack_pos].type = ERROR; - stack[stack_pos].u.error = ident_dup(id); - stack_pos++; - } - - /* - // --------------------------------------------------------------- - */ - void push_buffer(Buffer *buf) { - - #ifdef DEBUG - write_err("push() buffer"); - #endif - - check_stack(1); - stack[stack_pos].type = BUFFER; - stack[stack_pos].u.buffer = buffer_dup(buf); - stack_pos++; - } - int func_init_0(void) { int arg_start = arg_starts[--arg_pos]; int num_args = stack_pos - arg_start; --- 811,852 ---- /* // --------------------------------------------------------------- */ ! #define PUSH_DATA(_x_, _name_, _cold_type_, _c_type_, _member_, _what_) \ ! void CAT(_x_, _name_) (_c_type_ var) { \ ! check_stack(1); \ ! stack[stack_pos].type = _cold_type_; \ ! stack[stack_pos].u._member_ = _what_; \ ! stack_pos++; \ ! } ! ! #define PUSH_FUNC(_name_, _cold_type_, _c_type_, _member_, _what_) \ ! PUSH_DATA(push_, _name_, _cold_type_, _c_type_, _member_, _what_) ! #define PUSH_NATIVE(_name_, _cold_type_, _c_type_, _member_) \ ! PUSH_DATA(native_push_, _name_, _cold_type_, _c_type_, _member_, var) ! ! PUSH_FUNC(int, INTEGER, long, val, var) ! PUSH_FUNC(float, FLOAT, float, fval, var) ! PUSH_FUNC(string, STRING, string_t *, str, string_dup(var)) ! PUSH_FUNC(objnum, OBJNUM, objnum_t, objnum, var) ! PUSH_FUNC(list, LIST, list_t *, list, list_dup(var)) ! PUSH_FUNC(dict, DICT, dict_t *, dict, dict_dup(var)) ! PUSH_FUNC(symbol, SYMBOL, Ident, symbol, ident_dup(var)) ! PUSH_FUNC(error, ERROR, Ident, error, ident_dup(var)) ! PUSH_FUNC(buffer, BUFFER, buffer_t *, buffer, buffer_dup(var)) ! ! PUSH_NATIVE(int, INTEGER, long, val) ! PUSH_NATIVE(float, FLOAT, float, fval) ! PUSH_NATIVE(string, STRING, string_t *, str) ! PUSH_NATIVE(objnum, OBJNUM, objnum_t, objnum) ! PUSH_NATIVE(list, LIST, list_t *, list) ! PUSH_NATIVE(dict, DICT, dict_t *, dict) ! PUSH_NATIVE(symbol, SYMBOL, Ident, symbol) ! PUSH_NATIVE(error, ERROR, Ident, error) ! PUSH_NATIVE(buffer, BUFFER, buffer_t *, buffer) /* // --------------------------------------------------------------- */ int func_init_0(void) { int arg_start = arg_starts[--arg_pos]; int num_args = stack_pos - arg_start; *************** *** 928,935 **** return 0; } ! int func_init_1(data_t **args, int type1) ! { int arg_start = arg_starts[--arg_pos]; int num_args = stack_pos - arg_start; --- 860,866 ---- return 0; } ! int func_init_1(data_t **args, int type1) { int arg_start = arg_starts[--arg_pos]; int num_args = stack_pos - arg_start; diff -rc Genesis-1.0p4/src/file.c Genesis-1.0p6/src/file.c *** Genesis-1.0p4/src/file.c Sat Mar 9 20:07:41 1996 --- Genesis-1.0p6/src/file.c Tue May 21 17:27:23 1996 *************** *** 162,169 **** return F_FAILURE; } ! Buffer * read_binary_file(filec_t * file, int block) { ! Buffer * buf = buffer_new(block); if (feof(file->fp)) { cthrow(eof_id, "End of file."); --- 162,169 ---- return F_FAILURE; } ! buffer_t * read_binary_file(filec_t * file, int block) { ! buffer_t * buf = buffer_new(block); if (feof(file->fp)) { cthrow(eof_id, "End of file."); *************** *** 371,378 **** // -------------------------------------------------------------------- // called by fread() */ ! Buffer * read_from_file(object_t * obj) { ! Buffer * buf; filec_t * file = find_file_controller(obj); if (file == NULL) --- 371,378 ---- // -------------------------------------------------------------------- // called by fread() */ ! buffer_t * read_from_file(object_t * obj) { ! buffer_t * buf; filec_t * file = find_file_controller(obj); if (file == NULL) *************** *** 394,400 **** // -------------------------------------------------------------------- // called by fwrite() */ ! int write_to_file(object_t * obj, Buffer * buf) { filec_t * file = find_file_controller(obj); if (file == NULL || !file->f.writable) --- 394,400 ---- // -------------------------------------------------------------------- // called by fwrite() */ ! int write_to_file(object_t * obj, buffer_t * buf) { filec_t * file = find_file_controller(obj); if (file == NULL || !file->f.writable) diff -rc Genesis-1.0p4/src/genesis.c Genesis-1.0p6/src/genesis.c *** Genesis-1.0p4/src/genesis.c Thu Apr 25 16:04:01 1996 --- Genesis-1.0p6/src/genesis.c Tue May 21 09:27:09 1996 *************** *** 14,22 **** #include "config.h" #include "defs.h" - #include #include #include #include #include #include "codegen.h" --- 14,24 ---- #include "config.h" #include "defs.h" #include #include + #include + #include + #include #include #include #include "codegen.h" *************** *** 105,123 **** /* Ditch stdin, so we can reuse the file descriptor */ fclose(stdin); init_defs(); - - /* Initialize internal tables and variables. */ - init_codegen(); - init_ident(); - init_op_table(); init_match(); - init_util(); - init_sig(); - init_execute(); - init_scratch_file(); - init_token(); - init_modules(argc, argv); /* db argument list */ args = list_new(0); --- 107,115 ---- /* Ditch stdin, so we can reuse the file descriptor */ fclose(stdin); + /* basic initialization */ init_defs(); init_match(); /* db argument list */ args = list_new(0); *************** *** 155,160 **** --- 147,175 ---- argv += getarg(name,&buf,opt,argv,&argc,usage); NEWFILE(c_pidfile, buf); break; + case 's': { + char * p; + + argv += getarg(name, &buf, opt, argv, &argc, usage); + p = buf; + cache_width = atoi(p); + while (*p && isdigit(*p)) + p++; + if (LCASE(*p) == 'x') { + p++; + cache_depth = atoi(p); + } else { + usage(name); + printf("\n** Invalid WIDTHxDEPTH: '%s'\n", buf); + exit(0); + } + if (cache_width == 0 && cache_depth == 0) { + usage(name); + puts("\n** The WIDTH and DEPTH cannot both be zero\n"); + exit(0); + } + break; + } case 'f': dofork = 0; break; *************** *** 185,190 **** --- 200,217 ---- argc--; } + /* Initialize internal tables and variables. */ + init_codegen(); + init_ident(); + init_op_table(); + init_util(); + init_sig(); + init_execute(); + init_scratch_file(); + init_token(); + init_modules(argc, argv); + + /* where is the base db directory ? */ if (basedir == NULL) basedir = "."; *************** *** 335,348 **** Note: specifying \"stdin\" or \"stderr\" for either of the logs will\n\ direct them appropriately.\n\n\ Options:\n\n\ ! -v version.\n\ ! -b binary binary database directory name, default: \"%s\"\n\ ! -r root root file directory name, default: \"%s\"\n\ ! -x bindir db executables directory, default: \"%s\"\n\ ! -d log alternate database logfile, default: \"%s\"\n\ ! -e log alternate error (driver) file, default: \"%s\"\n\ ! -p pidfile alternate pid file, default: \"%s\"\n\ ! -f do not fork on startup\n\ \n", VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH, name, c_dir_binary, c_dir_root, c_dir_bin, c_logfile, c_errfile, c_pidfile); } --- 362,376 ---- Note: specifying \"stdin\" or \"stderr\" for either of the logs will\n\ direct them appropriately.\n\n\ Options:\n\n\ ! -v version.\n\ ! -b binary binary database directory name, default: \"%s\"\n\ ! -r root root file directory name, default: \"%s\"\n\ ! -x bindir db executables directory, default: \"%s\"\n\ ! -d log alternate database logfile, default: \"%s\"\n\ ! -e log alternate error (driver) file, default: \"%s\"\n\ ! -p pidfile alternate pid file, default: \"%s\"\n\ ! -f do not fork on startup\n\ ! -s WIDTHxDEPTH Cache size, default 10x30\n\ \n", VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH, name, c_dir_binary, c_dir_root, c_dir_bin, c_logfile, c_errfile, c_pidfile); } diff -rc Genesis-1.0p4/src/include/buffer.h Genesis-1.0p6/src/include/buffer.h *** Genesis-1.0p4/src/include/buffer.h Mon Mar 4 15:47:21 1996 --- Genesis-1.0p6/src/include/buffer.h Tue May 21 17:29:35 1996 *************** *** 14,36 **** #include "cdc_types.h" ! Buffer * buffer_new(int len); ! Buffer * buffer_dup(Buffer *buf); ! void buffer_discard(Buffer *buf); ! Buffer * buffer_append(Buffer *buf1, Buffer *buf2); ! int buffer_retrieve(Buffer *buf, int pos); ! Buffer * buffer_replace(Buffer *buf, int pos, unsigned int c); ! Buffer * buffer_add(Buffer *buf, unsigned int c); ! Buffer * buffer_resize(Buffer *buf, int len); ! Buffer * buffer_tail(Buffer *buf, int pos); ! string_t * buffer_to_string(Buffer *buf); ! Buffer * buffer_from_string(string_t * string); ! list_t * buffer_to_strings(Buffer *buf, Buffer *sep); ! Buffer * buffer_from_strings(list_t *string_list, Buffer *sep); ! Buffer * buffer_subrange(Buffer *buf, int start, int len); #define buffer_len(__b) (__b->len) - /* int buffer_len(Buffer *buf); */ #endif --- 14,36 ---- #include "cdc_types.h" ! buffer_t * buffer_new(int len); ! buffer_t * buffer_dup(buffer_t *buf); ! void buffer_discard(buffer_t *buf); ! buffer_t * buffer_append(buffer_t *buf1, buffer_t *buf2); ! int buffer_retrieve(buffer_t *buf, int pos); ! buffer_t * buffer_replace(buffer_t *buf, int pos, unsigned int c); ! buffer_t * buffer_add(buffer_t *buf, unsigned int c); ! buffer_t * buffer_resize(buffer_t *buf, int len); ! buffer_t * buffer_tail(buffer_t *buf, int pos); ! string_t * buffer_to_string(buffer_t *buf); ! buffer_t * buffer_from_string(string_t * string); ! list_t * buffer_to_strings(buffer_t *buf, buffer_t *sep); ! buffer_t * buffer_from_strings(list_t *string_list, buffer_t *sep); ! buffer_t * buffer_subrange(buffer_t *buf, int start, int len); ! buffer_t * buffer_prep(buffer_t *buf); #define buffer_len(__b) (__b->len) #endif diff -rc Genesis-1.0p4/src/include/cache.h Genesis-1.0p6/src/include/cache.h *** Genesis-1.0p4/src/include/cache.h Fri Dec 15 02:54:10 1995 --- Genesis-1.0p6/src/include/cache.h Tue May 21 09:27:56 1996 *************** *** 14,19 **** --- 14,27 ---- #include "object.h" + #ifndef _cache_ + extern int cache_width; + extern int cache_depth; + #else + int cache_width = 10; + int cache_depth = 30; + #endif + void init_cache(void); object_t *cache_get_holder(long objnum); object_t *cache_retrieve(long objnum); diff -rc Genesis-1.0p4/src/include/cdc_string.h Genesis-1.0p6/src/include/cdc_string.h *** Genesis-1.0p4/src/include/cdc_string.h Sat Apr 20 14:13:00 1996 --- Genesis-1.0p6/src/include/cdc_string.h Tue May 21 09:33:18 1996 *************** *** 45,52 **** string_t * string_parse(char * *sptr); string_t * string_add_unparsed(string_t * str, char * s, int len); char * regerror(char * msg); ! string_t * prepare_to_modify_str(string_t *str, int start, int len); ! string_t * string_dup_or_copy(string_t * str); #define string_length(__s) ((int) __s->len) #define string_chars(__s) ((char *) __s->s + __s->start) --- 45,51 ---- string_t * string_parse(char * *sptr); string_t * string_add_unparsed(string_t * str, char * s, int len); char * regerror(char * msg); ! string_t * string_prep(string_t *str, int start, int len); #define string_length(__s) ((int) __s->len) #define string_chars(__s) ((char *) __s->s + __s->start) diff -rc Genesis-1.0p4/src/include/cdc_types.h Genesis-1.0p6/src/include/cdc_types.h *** Genesis-1.0p4/src/include/cdc_types.h Thu Apr 4 18:02:40 1996 --- Genesis-1.0p6/src/include/cdc_types.h Tue May 21 17:34:00 1996 *************** *** 14,23 **** typedef struct string string_t; typedef struct list list_t; ! typedef struct buffer Buffer; ! typedef struct frob Frob; typedef struct data data_t; ! typedef struct dict Dict; typedef long Ident; typedef long objnum_t; typedef struct ident_entry Ident_entry; --- 14,23 ---- typedef struct string string_t; typedef struct list list_t; ! typedef struct buffer buffer_t; ! typedef struct frob frob_t; typedef struct data data_t; ! typedef struct dict dict_t; typedef long Ident; typedef long objnum_t; typedef struct ident_entry Ident_entry; *************** *** 56,64 **** Ident error; string_t * str; list_t * list; ! Frob * frob; ! Dict * dict; ! Buffer * buffer; } u; }; --- 56,64 ---- Ident error; string_t * str; list_t * list; ! frob_t * frob; ! dict_t * dict; ! buffer_t * buffer; } u; }; diff -rc Genesis-1.0p4/src/include/dict.h Genesis-1.0p6/src/include/dict.h *** Genesis-1.0p4/src/include/dict.h Wed Oct 11 23:17:40 1995 --- Genesis-1.0p6/src/include/dict.h Tue May 21 17:34:11 1996 *************** *** 18,37 **** #include "data.h" #endif ! Dict * dict_new(list_t * keys, list_t * values); ! Dict * dict_new_empty(void); ! Dict * dict_from_slices(list_t * slices); ! Dict * dict_dup(Dict * dict); ! void dict_discard(Dict * dict); ! int dict_cmp(Dict * dict1, Dict * dict2); ! Dict * dict_add(Dict * dict, data_t * key, data_t * value); ! Dict * dict_del(Dict * dict, data_t * key); ! long dict_find(Dict * dict, data_t * key, data_t * ret); ! int dict_contains(Dict * dict, data_t * key); ! list_t * dict_keys(Dict * dict); ! list_t * dict_key_value_pair(Dict * mapping, int i); ! int dict_size(Dict * dict); ! string_t * dict_add_literal_to_str(string_t * str, Dict * dict); #endif --- 18,38 ---- #include "data.h" #endif ! dict_t * dict_new(list_t * keys, list_t * values); ! dict_t * dict_new_empty(void); ! dict_t * dict_from_slices(list_t * slices); ! dict_t * dict_dup(dict_t * dict); ! void dict_discard(dict_t * dict); ! int dict_cmp(dict_t * dict1, dict_t * dict2); ! dict_t * dict_add(dict_t * dict, data_t * key, data_t * value); ! dict_t * dict_del(dict_t * dict, data_t * key); ! dict_t * dict_prep(dict_t *); ! long dict_find(dict_t * dict, data_t * key, data_t * ret); ! int dict_contains(dict_t * dict, data_t * key); ! list_t * dict_keys(dict_t * dict); ! list_t * dict_key_value_pair(dict_t * mapping, int i); ! int dict_size(dict_t * dict); ! string_t * dict_add_literal_to_str(string_t * str, dict_t * dict); #endif diff -rc Genesis-1.0p4/src/include/execute.h Genesis-1.0p6/src/include/execute.h *** Genesis-1.0p4/src/include/execute.h Thu Apr 25 14:12:05 1996 --- Genesis-1.0p6/src/include/execute.h Wed May 22 14:40:35 1996 *************** *** 133,153 **** objnum_t user, int stack_start, int arg_start); void frame_return(void); void anticipate_assignment(void); int pass_method(int stack_start, int arg_start); int call_method(objnum_t objnum, Ident message, int stack_start, int arg_start); void pop(int n); void check_stack(int n); ! void push_int(long n); ! void push_float(float f); ! void push_string(string_t *str); ! void push_objnum(objnum_t objnum); ! void push_list(list_t *list); ! void push_symbol(Ident id); ! void push_error(Ident id); ! void push_dict(Dict *dict); ! void push_buffer(Buffer *buffer); int func_init_0(void); int func_init_1(data_t **args, int type1); int func_init_2(data_t **args, int type1, int type2); --- 133,174 ---- objnum_t user, int stack_start, int arg_start); + void pop_native_stack(int start); void frame_return(void); void anticipate_assignment(void); int pass_method(int stack_start, int arg_start); int call_method(objnum_t objnum, Ident message, int stack_start, int arg_start); void pop(int n); void check_stack(int n); ! ! #define F_PUSH(_name_, _c_type_) \ ! void CAT(push_, _name_) (_c_type_ var) ! #define N_PUSH(_name_, _c_type_) \ ! void CAT(native_push_, _name_) (_c_type_ var) ! ! F_PUSH(int, long); ! F_PUSH(float, float); ! F_PUSH(string, string_t *); ! F_PUSH(objnum, objnum_t); ! F_PUSH(list, list_t *); ! F_PUSH(dict, dict_t *); ! F_PUSH(symbol, Ident); ! F_PUSH(error, Ident); ! F_PUSH(buffer, buffer_t *); ! ! N_PUSH(int, long); ! N_PUSH(float, float); ! N_PUSH(string, string_t *); ! N_PUSH(objnum, objnum_t); ! N_PUSH(list, list_t *); ! N_PUSH(dict, dict_t *); ! N_PUSH(symbol, Ident); ! N_PUSH(error, Ident); ! N_PUSH(buffer, buffer_t *); ! ! #undef F_PUSH ! #undef N_PUSH ! int func_init_0(void); int func_init_1(data_t **args, int type1); int func_init_2(data_t **args, int type1, int type2); diff -rc Genesis-1.0p4/src/include/file.h Genesis-1.0p6/src/include/file.h *** Genesis-1.0p4/src/include/file.h Sat Mar 2 16:58:51 1996 --- Genesis-1.0p6/src/include/file.h Tue May 21 17:31:58 1996 *************** *** 44,50 **** filec_t * find_file_controller(object_t * obj); int close_file(filec_t * file); int flush_file(filec_t * file); ! Buffer * read_binary_file(filec_t * file, int block); string_t * read_file(filec_t * file); int abort_file(filec_t * file); int stat_file(filec_t * file, struct stat * sbuf); --- 44,50 ---- filec_t * find_file_controller(object_t * obj); int close_file(filec_t * file); int flush_file(filec_t * file); ! buffer_t * read_binary_file(filec_t * file, int block); string_t * read_file(filec_t * file); int abort_file(filec_t * file); int stat_file(filec_t * file, struct stat * sbuf); diff -rc Genesis-1.0p4/src/include/io.h Genesis-1.0p6/src/include/io.h *** Genesis-1.0p4/src/include/io.h Sun Dec 17 06:47:51 1995 --- Genesis-1.0p6/src/include/io.h Tue May 21 17:31:37 1996 *************** *** 20,27 **** struct connection_s { int fd; /* File descriptor for input and output. */ ! Buffer * write_buf; /* Buffer for network output. */ ! objnum_t objnum; /* Object connection is associated with. */ struct { char readable; /* Connection has new data pending. */ char writable; /* Connection can be written to. */ --- 20,27 ---- struct connection_s { int fd; /* File descriptor for input and output. */ ! buffer_t * write_buf; /* Buffer for network output. */ ! objnum_t objnum; /* Object connection is associated with. */ struct { char readable; /* Connection has new data pending. */ char writable; /* Connection can be written to. */ *************** *** 56,62 **** void handle_connection_input(void); void handle_connection_output(void); connection_t * find_connection(object_t * obj); ! connection_t * tell(object_t * obj, Buffer *buf); int boot(object_t * obj); int add_server(int port, long objnum); int remove_server(int port); --- 56,62 ---- void handle_connection_input(void); void handle_connection_output(void); connection_t * find_connection(object_t * obj); ! connection_t * tell(object_t * obj, buffer_t *buf); int boot(object_t * obj); int add_server(int port, long objnum); int remove_server(int port); diff -rc Genesis-1.0p4/src/include/list.h Genesis-1.0p6/src/include/list.h *** Genesis-1.0p4/src/include/list.h Wed Oct 11 23:17:44 1995 --- Genesis-1.0p6/src/include/list.h Tue May 21 09:32:21 1996 *************** *** 41,46 **** --- 41,47 ---- list_t * list_union(list_t * list1, list_t * list2); list_t * list_sublist(list_t * list, int start, int len); void list_discard(list_t * list); + list_t * list_prep(list_t * list, int start, int len); #endif diff -rc Genesis-1.0p4/src/include/macros.h Genesis-1.0p6/src/include/macros.h *** Genesis-1.0p4/src/include/macros.h Mon Apr 15 21:01:07 1996 --- Genesis-1.0p6/src/include/macros.h Wed May 22 14:33:58 1996 *************** *** 71,77 **** /* this macro is mainly handy when you want to parse the args yourself */ #define INIT_ARGC(_argc_, _expected_, _str_) \ if (_argc_ != _expected_) \ ! THROW_NUM_ERROR(_argc_, _str_); #define CHECK_TYPE(_pos_, _type_, _str_) \ if (args[_pos_].type != _type_) \ --- 71,77 ---- /* this macro is mainly handy when you want to parse the args yourself */ #define INIT_ARGC(_argc_, _expected_, _str_) \ if (_argc_ != _expected_) \ ! THROW_NUM_ERROR(_argc_, _str_) #define CHECK_TYPE(_pos_, _type_, _str_) \ if (args[_pos_].type != _type_) \ *************** *** 161,167 **** #define COLDC_FUNC(_name_) void CAT(func_, _name_) (void) #define NATIVE_METHOD(_name_) \ ! int CAT(native_, _name_) (int arg_start, data_t * rval) /* // ----------------------------------------------------------------------- --- 161,167 ---- #define COLDC_FUNC(_name_) void CAT(func_, _name_) (void) #define NATIVE_METHOD(_name_) \ ! int CAT(native_, _name_) (int stack_start, int arg_start) /* // ----------------------------------------------------------------------- *************** *** 174,191 **** #define FIXED 0 #define ANY_DATA 0 ! #define RETURN_INTEGER(d){rval->type = INTEGER; rval->u.val = d; RETURN_TRUE;} ! #define RETURN_FLOAT(d) {rval->type = FLOAT; rval->u.fval = d; RETURN_TRUE;} ! #define RETURN_OBJNUM(d) {rval->type = OBJNUM; rval->u.objnum = d; RETURN_TRUE;} ! #define RETURN_SYMBOL(d) {rval->type = SYMBOL; rval->u.symbol = d; RETURN_TRUE;} ! #define RETURN_ERROR(d) {rval->type = ERROR; rval->u.error = d; RETURN_TRUE;} ! #define RETURN_STRING(d) {rval->type = STRING; rval->u.str = d; RETURN_TRUE;} ! #define RETURN_BUFFER(d) {rval->type = BUFFER; rval->u.buffer = d; RETURN_TRUE;} ! #define RETURN_FROB(d) {rval->type = FROB; rval->u.frob = d; RETURN_TRUE;} ! #define RETURN_DICT(d) {rval->type = DICT; rval->u.dict = d; RETURN_TRUE;} ! #define RETURN_LIST(d) {rval->type = LIST; rval->u.list = d; RETURN_TRUE;} #else /* NATIVE_MODULE */ /* // ----------------------------------------------------------------------- // function-specific defines --- 174,207 ---- #define FIXED 0 #define ANY_DATA 0 ! #include "execute.h" ! ! #define CLEAN_STACK() pop_native_stack(stack_start) ! ! #define RETURN_INTEGER(d) native_push_int(d); RETURN_TRUE ! #define RETURN_FLOAT(d) native_push_float(d); RETURN_TRUE ! #define RETURN_OBJNUM(d) native_push_objnum(d); RETURN_TRUE ! #define RETURN_SYMBOL(d) native_push_symbol(d); RETURN_TRUE ! #define RETURN_ERROR(d) native_push_error(d); RETURN_TRUE ! #define RETURN_STRING(d) native_push_string(d); RETURN_TRUE ! #define RETURN_BUFFER(d) native_push_buffer(d); RETURN_TRUE ! #define RETURN_FROB(d) native_push_frob(d); RETURN_TRUE ! #define RETURN_DICT(d) native_push_dict(d); RETURN_TRUE ! #define RETURN_LIST(d) native_push_list(d); RETURN_TRUE ! ! #define CLEAN_RETURN_INTEGER(d) CLEAN_STACK(); RETURN_INTEGER(d) ! #define CLEAN_RETURN_FLOAT(d) CLEAN_STACK(); RETURN_FLOAT(d) ! #define CLEAN_RETURN_OBJNUM(d) CLEAN_STACK(); RETURN_OBJNUM(d) ! #define CLEAN_RETURN_SYMBOL(d) CLEAN_STACK(); RETURN_SYMBOL(d) ! #define CLEAN_RETURN_ERROR(d) CLEAN_STACK(); RETURN_ERROR(d) ! #define CLEAN_RETURN_STRING(d) CLEAN_STACK(); RETURN_STRING(d) ! #define CLEAN_RETURN_BUFFER(d) CLEAN_STACK(); RETURN_BUFFER(d) ! #define CLEAN_RETURN_FROB(d) CLEAN_STACK(); RETURN_FROB(d) ! #define CLEAN_RETURN_DICT(d) CLEAN_STACK(); RETURN_DICT(d) ! #define CLEAN_RETURN_LIST(d) CLEAN_STACK(); RETURN_LIST(d) #else /* NATIVE_MODULE */ + /* // ----------------------------------------------------------------------- // function-specific defines *************** *** 233,236 **** --- 249,283 ---- #define _BUF(_pos_) args[_pos_].u.buffer #define _FROB(_pos_) args[_pos_].u.frob #define _DICT(_pos_) args[_pos_].u.dict + + #define INT1 args[0].u.val + #define INT2 args[1].u.val + #define INT3 args[2].u.val + #define FLOAT1 args[0].u.fval + #define FLOAT2 args[1].u.fval + #define FLOAT3 args[2].u.fval + #define OBJNUM1 args[0].u.objnum + #define OBJNUM2 args[1].u.objnum + #define OBJNUM3 args[2].u.objnum + #define SYM1 args[0].u.symbol + #define SYM2 args[1].u.symbol + #define SYM3 args[2].u.symbol + #define ERR1 args[0].u.error + #define ERR2 args[1].u.error + #define ERR3 args[2].u.error + #define STR1 args[0].u.str + #define STR2 args[1].u.str + #define STR3 args[2].u.str + #define LIST1 args[0].u.list + #define LIST2 args[1].u.list + #define LIST3 args[2].u.list + #define BUF1 args[0].u.buffer + #define BUF2 args[1].u.buffer + #define BUF3 args[2].u.buffer + #define FROB1 args[0].u.frob + #define FROB2 args[1].u.frob + #define FROB3 args[2].u.frob + #define DICT1 args[0].u.dict + #define DICT2 args[1].u.dict + #define DICT3 args[2].u.dict diff -rc Genesis-1.0p4/src/include/native.h Genesis-1.0p6/src/include/native.h *** Genesis-1.0p4/src/include/native.h Wed Apr 3 14:53:34 1996 --- Genesis-1.0p6/src/include/native.h Wed May 22 10:52:22 1996 *************** *** 23,29 **** typedef struct native_s { char * bindobj; char * name; ! int (*func)(int stack_pos, data_t * rval); #if 0 int args; int rest; --- 23,29 ---- typedef struct native_s { char * bindobj; char * name; ! int (*func)(int stack_start, int arg_start); #if 0 int args; int rest; diff -rc Genesis-1.0p4/src/io.c Genesis-1.0p6/src/io.c *** Genesis-1.0p4/src/io.c Thu Mar 21 14:19:51 1996 --- Genesis-1.0p6/src/io.c Tue May 21 17:27:48 1996 *************** *** 234,240 **** // there is no connection, it will be NULL, and we will know. */ ! connection_t * tell(object_t * obj, Buffer * buf) { connection_t * conn = find_connection(obj); if (conn != NULL) --- 234,240 ---- // there is no connection, it will be NULL, and we will know. */ ! connection_t * tell(object_t * obj, buffer_t * buf) { connection_t * conn = find_connection(obj); if (conn != NULL) *************** *** 314,320 **** INTERNAL void connection_read(connection_t *conn) { unsigned char temp[BIGBUF]; int len; ! Buffer *buf; data_t d; len = read(conn->fd, (char *) temp, BIGBUF); --- 314,320 ---- INTERNAL void connection_read(connection_t *conn) { unsigned char temp[BIGBUF]; int len; ! buffer_t *buf; data_t d; len = read(conn->fd, (char *) temp, BIGBUF); *************** *** 343,349 **** // -------------------------------------------------------------------- */ INTERNAL void connection_write(connection_t *conn) { ! Buffer *buf = conn->write_buf; int r; r = write(conn->fd, buf->s, buf->len); --- 343,349 ---- // -------------------------------------------------------------------- */ INTERNAL void connection_write(connection_t *conn) { ! buffer_t *buf = conn->write_buf; int r; r = write(conn->fd, buf->s, buf->len); diff -rc Genesis-1.0p4/src/match.c Genesis-1.0p6/src/match.c *** Genesis-1.0p4/src/match.c Thu Apr 18 18:43:33 1996 --- Genesis-1.0p6/src/match.c Tue May 21 09:26:48 1996 *************** *** 705,731 **** break;\ } ! #define x_THROW(_what_) \ ! cthrow _what_; return NULL; string_t * strfmt(string_t * str, data_t * args, int argc) { string_t * out, * value; char * fmt, - * s, * tmp, buf[LINE], fill[LINE]; ! int len, pad, prec, trunc; int cur = -1; fmt = string_chars(str); ! len = string_length(str); ! out = string_new(len * 2); /* better more than less and having to resize */ for (;;) { s = strchr(fmt, '%'); ! if (s == (char) NULL || s[1] == (char) NULL) { out = string_add_chars(out, fmt, strlen(fmt)); break; } --- 705,735 ---- break;\ } ! #define x_THROW(_what_) { \ ! cthrow _what_; \ ! return NULL; \ ! } string_t * strfmt(string_t * str, data_t * args, int argc) { string_t * out, * value; + register char * s; char * fmt, * tmp, buf[LINE], fill[LINE]; ! register int pad, prec, trunc; int cur = -1; fmt = string_chars(str); ! ! /* better more than less and having to resize */ ! out = string_new(string_length(str) * 2); for (;;) { s = strchr(fmt, '%'); ! ! if (s == (char) NULL || *s == (char) NULL) { out = string_add_chars(out, fmt, strlen(fmt)); break; } *************** *** 733,779 **** out = string_add_chars(out, fmt, s - fmt); s++; - len -= (s - fmt); - if (*s == '%') { out = string_addc(out, '%'); continue; } ! if (++cur > argc) { string_discard(out); ! x_THROW((type_id, "No argument for format.")) } pad = prec = trunc = 0; ! while (isdigit(*s) && len--) ! pad = pad * 10 + *s++ - '0'; if (*s == '.') { s++; ! while (isdigit(*s) && len--) ! prec = prec * 10 + *s++ - '0'; } /* get the pad char */ if (*s == '{') { int x = 0; ! s++, len--; ! for (; *s != '}' && len; s++, len--) { if (s[0] == '\\' && (s[1] == '\\' || s[1] == '}')) ! s++, len--; fill[x++] = *s; } fill[x] = (char) NULL; ! s++, len--; } else { fill[0] = ' '; fill[1] = (char) NULL; } /* invalid format, just abort, they need to know when it is wrong */ ! if (len <= 0) { string_discard(out); x_THROW((type_id, "Invalid format")) } --- 737,804 ---- out = string_add_chars(out, fmt, s - fmt); s++; if (*s == '%') { out = string_addc(out, '%'); + fmt = ++s; continue; } ! if (++cur >= argc) { string_discard(out); ! x_THROW((type_id, "Not enough arguments for format.")) } pad = prec = trunc = 0; ! if (*s == '*') { ! if (args[cur].type != INTEGER) ! x_THROW((type_id, "Argument for '*' is not an integer.")) ! pad = args[cur].u.val; ! s++; ! if (++cur >= argc) { ! string_discard(out); ! x_THROW((type_id, "Not enough arguments for format.")) ! } ! } else { ! while (isdigit(*s)) ! pad = pad * 10 + *s++ - '0'; ! } if (*s == '.') { s++; ! if (*s == '*') { ! if (args[cur].type != INTEGER) ! x_THROW((type_id, "Argument for '*' is not an integer.")) ! prec = args[cur].u.val; ! s++; ! if (++cur >= argc) { ! string_discard(out); ! x_THROW((type_id, "Not enough arguments for format.")) ! } ! } else { ! while (isdigit(*s)) ! prec = prec * 10 + *s++ - '0'; ! } } /* get the pad char */ if (*s == '{') { int x = 0; ! s++; ! for (; *s && *s != '}'; s++) { if (s[0] == '\\' && (s[1] == '\\' || s[1] == '}')) ! s++; fill[x++] = *s; } fill[x] = (char) NULL; ! s++; } else { fill[0] = ' '; fill[1] = (char) NULL; } /* invalid format, just abort, they need to know when it is wrong */ ! if (*s == (char) NULL) { string_discard(out); x_THROW((type_id, "Invalid format")) } *************** *** 869,875 **** string_discard(value); fmt = ++s; - len--; } return out; --- 894,899 ---- diff -rc Genesis-1.0p4/src/modules/cdc_buffer.c Genesis-1.0p6/src/modules/cdc_buffer.c *** Genesis-1.0p4/src/modules/cdc_buffer.c Mon Apr 15 21:26:45 1996 --- Genesis-1.0p6/src/modules/cdc_buffer.c Tue May 21 17:41:20 1996 *************** *** 18,61 **** #include "execute.h" NATIVE_METHOD(bufgraft) { ! INIT_NO_ARGS() ! RETURN_INTEGER(0) } NATIVE_METHOD(buflen) { ! INIT_1_ARG(BUFFER) ! RETURN_INTEGER(buffer_len(_BUF(ARG1))) } NATIVE_METHOD(buf_replace) { ! int pos; ! INIT_3_ARGS(BUFFER, INTEGER, INTEGER) ! pos = _INT(ARG2) - 1; if (pos < 0) THROW((range_id, "Position (%d) is less than one.", pos + 1)) ! else if (pos >= buffer_len(_BUF(ARG1))) THROW((range_id, "Position (%d) is greater than buffer length (%d).", ! pos + 1, buffer_len(_BUF(ARG1)))) ! RETURN_BUFFER(buffer_replace(_BUF(ARG1), pos, _INT(ARG3))); } NATIVE_METHOD(subbuf) { int start, len, blen; INIT_2_OR_3_ARGS(BUFFER, INTEGER, INTEGER); ! blen = _BUF(ARG1)->len; ! start = _INT(ARG2) - 1; ! len = (argc == 3) ? _INT(ARG3) : blen - start; if (start < 0) THROW((range_id, "Start (%d) is less than one.", start + 1)) --- 18,72 ---- #include "execute.h" NATIVE_METHOD(bufgraft) { ! INIT_NO_ARGS(); ! CLEAN_RETURN_INTEGER(0); } NATIVE_METHOD(buflen) { ! int val; ! INIT_1_ARG(BUFFER); ! ! val = buffer_len(BUF1); ! ! CLEAN_RETURN_INTEGER(val); } NATIVE_METHOD(buf_replace) { ! buffer_t * buf; ! int pos, ch; ! INIT_3_ARGS(BUFFER, INTEGER, INTEGER); ! pos = INT2 - 1; if (pos < 0) THROW((range_id, "Position (%d) is less than one.", pos + 1)) ! else if (pos >= buffer_len(BUF1)) THROW((range_id, "Position (%d) is greater than buffer length (%d).", ! pos + 1, buffer_len(BUF1))) ! ! ch = INT3; ! buf = buffer_dup(BUF1); ! anticipate_assignment(); ! ! CLEAN_RETURN_BUFFER(buffer_replace(buf, pos, ch)); } NATIVE_METHOD(subbuf) { int start, len, blen; + buffer_t * buf; INIT_2_OR_3_ARGS(BUFFER, INTEGER, INTEGER); ! blen = BUF1->len; ! start = INT2 - 1; ! len = (argc == 3) ? INT3 : blen - start; if (start < 0) THROW((range_id, "Start (%d) is less than one.", start + 1)) *************** *** 66,115 **** "The subrange extends to %d, past the end of the buffer (%d).", start + len, blen)) ! RETURN_BUFFER(buffer_subrange(_BUF(ARG1), start, len)); } NATIVE_METHOD(buf_to_str) { INIT_1_ARG(BUFFER); ! RETURN_STRING(buffer_to_string(_BUF(ARG1))); } NATIVE_METHOD(buf_to_strings) { ! list_t *list; ! Buffer *sep; INIT_1_OR_2_ARGS(BUFFER, BUFFER); ! sep = (argc == 2) ? _BUF(ARG2) : NULL; ! list = buffer_to_strings(_BUF(ARG1), sep); ! RETURN_LIST(list); } NATIVE_METHOD(str_to_buf) { INIT_1_ARG(STRING); ! RETURN_BUFFER(buffer_from_string(_STR(ARG1))); } NATIVE_METHOD(strings_to_buf) { data_t * d; int i; ! Buffer * sep; list_t * list; INIT_1_OR_2_ARGS(LIST, BUFFER); ! list = args[0].u.list; ! sep = (argc == 2) ? args[1].u.buffer : NULL; for (d = list_first(list), i=0; d; d = list_next(list, d),i++) { if (d->type != STRING) ! THROW((type_id, "List element %d (%D) not a string.", i + 1, d)); } ! RETURN_BUFFER(buffer_from_strings(list, sep)); } --- 77,142 ---- "The subrange extends to %d, past the end of the buffer (%d).", start + len, blen)) ! buf = buffer_dup(BUF1); ! ! anticipate_assignment(); ! ! CLEAN_RETURN_BUFFER(buffer_subrange(buf, start, len)); } NATIVE_METHOD(buf_to_str) { + buffer_t * buf; + INIT_1_ARG(BUFFER); ! buf = buffer_dup(BUF1); ! ! CLEAN_RETURN_STRING(buffer_to_string(buf)); } NATIVE_METHOD(buf_to_strings) { ! list_t * list; ! buffer_t * sep; INIT_1_OR_2_ARGS(BUFFER, BUFFER); ! sep = (argc == 2) ? BUF2 : NULL; ! list = buffer_to_strings(BUF1, sep); ! CLEAN_RETURN_LIST(list); } NATIVE_METHOD(str_to_buf) { + buffer_t * buf; + INIT_1_ARG(STRING); ! anticipate_assignment(); ! buf = buffer_from_string(STR1); ! ! CLEAN_RETURN_BUFFER(buf); } NATIVE_METHOD(strings_to_buf) { data_t * d; int i; ! buffer_t * sep, ! * buf; list_t * list; INIT_1_OR_2_ARGS(LIST, BUFFER); ! list = LIST1; ! sep = (argc == 2) ? BUF2 : NULL; for (d = list_first(list), i=0; d; d = list_next(list, d),i++) { if (d->type != STRING) ! THROW((type_id, "List element %d (%D) not a string.", i + 1, d)) } ! buf = buffer_from_strings(list, sep); ! ! CLEAN_RETURN_BUFFER(buf); } diff -rc Genesis-1.0p4/src/modules/cdc_dict.c Genesis-1.0p6/src/modules/cdc_dict.c *** Genesis-1.0p4/src/modules/cdc_dict.c Mon Apr 15 21:03:37 1996 --- Genesis-1.0p6/src/modules/cdc_dict.c Wed May 22 10:32:32 1996 *************** *** 19,56 **** #include "memory.h" NATIVE_METHOD(dict_keys) { INIT_1_ARG(DICT); ! RETURN_LIST(dict_keys(args[0].u.dict)); } NATIVE_METHOD(dict_add) { DEF_args; INIT_ARGC(ARG_COUNT, 3, "three"); INIT_ARG1(DICT); ! RETURN_DICT(dict_add(args[0].u.dict, &args[1], &args[2])); } NATIVE_METHOD(dict_del) { DEF_args; INIT_ARGC(ARG_COUNT, 2, "two"); INIT_ARG1(DICT); ! if (!dict_contains(args[0].u.dict, &args[1])) THROW((keynf_id, "Key (%D) is not in the dictionary.", &args[1])); ! RETURN_DICT(dict_del(args[0].u.dict, &args[1])); } NATIVE_METHOD(dict_contains) { DEF_args; INIT_ARGC(ARG_COUNT, 2, "two"); INIT_ARG1(DICT); ! RETURN_INTEGER(dict_contains(args[0].u.dict, &args[1])); } --- 19,88 ---- #include "memory.h" NATIVE_METHOD(dict_keys) { + list_t * list; + INIT_1_ARG(DICT); ! list = dict_keys(DICT1); ! ! CLEAN_RETURN_LIST(list); } + /* ugh; what we do to keep from copying */ NATIVE_METHOD(dict_add) { + dict_t * dict; + data_t arg1, arg2; DEF_args; INIT_ARGC(ARG_COUNT, 3, "three"); INIT_ARG1(DICT); ! dict = dict_dup(DICT1); ! data_dup(&arg1, &args[1]); ! data_dup(&arg2, &args[2]); ! ! CLEAN_STACK(); ! ! anticipate_assignment(); ! dict = dict_add(dict, &arg1, &arg2); ! data_discard(&arg1); ! data_discard(&arg2); ! ! RETURN_DICT(dict); } NATIVE_METHOD(dict_del) { + data_t arg1; + dict_t * dict; DEF_args; INIT_ARGC(ARG_COUNT, 2, "two"); INIT_ARG1(DICT); ! if (!dict_contains(DICT1, &args[1])) THROW((keynf_id, "Key (%D) is not in the dictionary.", &args[1])); ! dict = dict_dup(DICT1); ! data_dup(&arg1, &args[1]); ! ! CLEAN_STACK(); ! anticipate_assignment(); ! ! dict = dict_del(dict, &arg1); ! data_discard(&arg1); ! ! RETURN_DICT(dict); } NATIVE_METHOD(dict_contains) { + int val; DEF_args; INIT_ARGC(ARG_COUNT, 2, "two"); INIT_ARG1(DICT); ! val = dict_contains(DICT1, &args[1]); ! ! CLEAN_RETURN_INTEGER(val); } diff -rc Genesis-1.0p4/src/modules/cdc_list.c Genesis-1.0p6/src/modules/cdc_list.c *** Genesis-1.0p4/src/modules/cdc_list.c Thu Apr 18 17:56:31 1996 --- Genesis-1.0p6/src/modules/cdc_list.c Wed May 22 11:11:01 1996 *************** *** 19,128 **** #include "memory.h" NATIVE_METHOD(listlen) { ! INIT_1_ARG(LIST) ! RETURN_INTEGER(list_length(_LIST(ARG1))); } NATIVE_METHOD(sublist) { ! int start, span, list_len; INIT_2_OR_3_ARGS(LIST, INTEGER, INTEGER) ! list_len = list_length(_LIST(ARG1)); ! start = _INT(ARG2) - 1; ! span = (argc == 3) ? _INT(ARG3) : list_len - start; /* Make sure range is in bounds. */ if (start < 0) THROW((range_id, "Start (%d) less than one", start + 1)) else if (span < 0) THROW((range_id, "Sublist length (%d) less than zero", span)) ! else if (start + span > list_len) THROW((range_id, "Sublist extends to %d, past end of list (length %d)", ! start + span, list_len)) ! RETURN_LIST(list_sublist(_LIST(ARG1), start, span)) } NATIVE_METHOD(insert) { ! int pos, list_len; DEF_args; INIT_ARGC(ARG_COUNT, 3, "three"); INIT_ARG1(LIST) INIT_ARG2(INTEGER) ! pos = _INT(ARG2) - 1; ! list_len = list_length(_LIST(ARG1)); if (pos < 0) THROW((range_id, "Position (%d) less than one", pos + 1)) ! else if (pos > list_len) THROW((range_id, "Position (%d) beyond end of list (length %d)", ! pos + 1, list_len)) ! RETURN_LIST(list_insert(_LIST(ARG1), pos, &args[2])) } NATIVE_METHOD(replace) { ! int pos, list_len; DEF_args; INIT_ARGC(ARG_COUNT, 3, "three"); INIT_ARG1(LIST) INIT_ARG2(INTEGER) ! list_len = list_length(args[0].u.list); ! pos = args[1].u.val - 1; if (pos < 0) THROW((range_id, "Position (%d) less than one", pos + 1)) ! else if (pos > list_len - 1) THROW((range_id, "Position (%d) greater than length of list (%d)", ! pos + 1, list_len)) ! RETURN_LIST(list_replace(args[0].u.list, pos, &args[2])) } NATIVE_METHOD(delete) { ! int pos, list_len; INIT_2_ARGS(LIST, INTEGER) ! list_len = list_length(args[0].u.list); ! pos = args[1].u.val - 1; if (pos < 0) THROW((range_id, "Position (%d) less than one", pos + 1)) ! else if (pos > list_len - 1) THROW((range_id, "Position (%d) greater than length of list (%d)", ! pos + 1, list_len)) ! RETURN_LIST(list_delete(args[0].u.list, pos)) } NATIVE_METHOD(setadd) { DEF_args; INIT_ARGC(ARG_COUNT, 2, "two") INIT_ARG1(LIST) ! RETURN_LIST(list_setadd(args[0].u.list, &args[1])) } NATIVE_METHOD(setremove) { DEF_args; INIT_ARGC(ARG_COUNT, 2, "two") INIT_ARG1(LIST) ! RETURN_LIST(list_setremove(args[0].u.list, &args[1])) } NATIVE_METHOD(union) { INIT_2_ARGS(LIST, LIST) ! RETURN_LIST(list_union(args[0].u.list, args[1].u.list)) } --- 19,206 ---- #include "memory.h" NATIVE_METHOD(listlen) { ! int len; ! INIT_1_ARG(LIST); ! ! len = list_length(LIST1); ! ! CLEAN_RETURN_INTEGER(len); } NATIVE_METHOD(sublist) { ! int start, ! span, ! len; ! list_t * list; INIT_2_OR_3_ARGS(LIST, INTEGER, INTEGER) ! len = list_length(LIST1); ! start = INT2 - 1; ! span = (argc == 3) ? INT3 : len - start; /* Make sure range is in bounds. */ if (start < 0) THROW((range_id, "Start (%d) less than one", start + 1)) else if (span < 0) THROW((range_id, "Sublist length (%d) less than zero", span)) ! else if (start + span > len) THROW((range_id, "Sublist extends to %d, past end of list (length %d)", ! start + span, len)) ! ! list = list_dup(LIST1); ! CLEAN_STACK(); ! anticipate_assignment(); ! ! list = list_sublist(list, start, span); ! ! RETURN_LIST(list); } NATIVE_METHOD(insert) { ! int pos, ! len; ! list_t * list; ! data_t data; DEF_args; INIT_ARGC(ARG_COUNT, 3, "three"); INIT_ARG1(LIST) INIT_ARG2(INTEGER) ! pos = INT2 - 1; ! len = list_length(LIST1); if (pos < 0) THROW((range_id, "Position (%d) less than one", pos + 1)) ! else if (pos > len) THROW((range_id, "Position (%d) beyond end of list (length %d)", ! pos + 1, len)) ! ! data_dup(&data, &args[2]); ! list = list_dup(LIST1); ! CLEAN_STACK(); ! anticipate_assignment(); ! ! list = list_insert(list, pos, &data); ! data_discard(&data); ! ! RETURN_LIST(list); } NATIVE_METHOD(replace) { ! int pos, ! len; ! list_t * list; ! data_t data; DEF_args; INIT_ARGC(ARG_COUNT, 3, "three"); INIT_ARG1(LIST) INIT_ARG2(INTEGER) ! len = list_length(LIST1); ! pos = INT2 - 1; if (pos < 0) THROW((range_id, "Position (%d) less than one", pos + 1)) ! else if (pos > len - 1) THROW((range_id, "Position (%d) greater than length of list (%d)", ! pos + 1, len)) ! ! data_dup(&data, &args[2]); ! list = list_dup(LIST1); ! CLEAN_STACK(); ! anticipate_assignment(); ! list = list_replace(list, pos, &data); ! data_discard(&data); ! ! RETURN_LIST(list); } NATIVE_METHOD(delete) { ! int pos, ! len; ! list_t * list; INIT_2_ARGS(LIST, INTEGER) ! len = list_length(LIST1); ! pos = INT2 - 1; if (pos < 0) THROW((range_id, "Position (%d) less than one", pos + 1)) ! else if (pos > len - 1) THROW((range_id, "Position (%d) greater than length of list (%d)", ! pos + 1, len)) ! ! list = list_dup(LIST1); ! ! CLEAN_STACK(); ! anticipate_assignment(); ! RETURN_LIST(list_delete(list, pos)); } NATIVE_METHOD(setadd) { + list_t * list; + data_t data; DEF_args; INIT_ARGC(ARG_COUNT, 2, "two") INIT_ARG1(LIST) ! data_dup(&data, &args[1]); ! list = list_dup(LIST1); ! ! CLEAN_STACK(); ! anticipate_assignment(); ! ! list = list_setadd(list, &data); ! data_discard(&data); ! ! RETURN_LIST(list); } NATIVE_METHOD(setremove) { + list_t * list; + data_t data; DEF_args; INIT_ARGC(ARG_COUNT, 2, "two") INIT_ARG1(LIST) ! data_dup(&data, &args[1]); ! list = list_dup(LIST1); ! ! CLEAN_STACK(); ! anticipate_assignment(); ! ! list = list_setremove(list, &data); ! data_discard(&data); ! ! RETURN_LIST(list); } NATIVE_METHOD(union) { + list_t * list, * list2; + INIT_2_ARGS(LIST, LIST) ! list = list_dup(LIST1); ! list2 = list_dup(LIST2); ! ! CLEAN_STACK(); ! anticipate_assignment(); ! ! list = list_union(list, list2); ! ! list_discard(list2); ! ! RETURN_LIST(list); } diff -rc Genesis-1.0p4/src/modules/cdc_misc.c Genesis-1.0p6/src/modules/cdc_misc.c *** Genesis-1.0p4/src/modules/cdc_misc.c Sun Apr 21 14:51:36 1996 --- Genesis-1.0p6/src/modules/cdc_misc.c Wed May 22 14:34:40 1996 *************** *** 29,40 **** time_t tt; struct tm * t; ! INIT_1_OR_2_ARGS(STRING, INTEGER) ! tt = ((argc == 2) ? (time_t) _INT(ARG2) : time(NULL)); t = localtime(&tt); ! fmt = string_chars(_STR(ARG1)); /* some OS's are weird and do odd things when you end in % (accidentally or no) */ --- 29,40 ---- time_t tt; struct tm * t; ! INIT_1_OR_2_ARGS(STRING, INTEGER); ! tt = ((argc == 2) ? (time_t) INT2 : time(NULL)); t = localtime(&tt); ! fmt = string_chars(STR1); /* some OS's are weird and do odd things when you end in % (accidentally or no) */ *************** *** 44,56 **** if (strftime(s, LINE, fmt, t) == (size_t) 0) THROW((range_id,"Format results in a string longer than 80 characters.")) ! RETURN_STRING(string_from_chars(s, strlen(s))) } NATIVE_METHOD(next_objnum) { ! INIT_NO_ARGS() ! RETURN_OBJNUM(db_top) } #ifdef HAVE_GETRUSAGE --- 44,56 ---- if (strftime(s, LINE, fmt, t) == (size_t) 0) THROW((range_id,"Format results in a string longer than 80 characters.")) ! CLEAN_RETURN_STRING(string_from_chars(s, strlen(s))); } NATIVE_METHOD(next_objnum) { ! INIT_NO_ARGS(); ! CLEAN_RETURN_OBJNUM(db_top); } #ifdef HAVE_GETRUSAGE *************** *** 67,73 **** data_t *d; int x; ! INIT_NO_ARGS() #define __LLENGTH__ 19 --- 67,73 ---- data_t *d; int x; ! INIT_NO_ARGS(); #define __LLENGTH__ 19 *************** *** 106,119 **** d[18].u.val = (int) atomic; #undef __LLENGTH__ ! RETURN_LIST(status) } NATIVE_METHOD(version) { list_t *version; data_t *d; ! INIT_NO_ARGS() /* Construct a list of the version numbers and push it. */ version = list_new(3); --- 106,119 ---- d[18].u.val = (int) atomic; #undef __LLENGTH__ ! CLEAN_RETURN_LIST(status); } NATIVE_METHOD(version) { list_t *version; data_t *d; ! INIT_NO_ARGS(); /* Construct a list of the version numbers and push it. */ version = list_new(3); *************** *** 123,146 **** d[1].u.val = VERSION_MINOR; d[2].u.val = VERSION_PATCH; ! RETURN_LIST(version); } /* // ----------------------------------------------------------------- */ NATIVE_METHOD(hostname) { ! INIT_1_ARG(STRING) ! RETURN_STRING(hostname(string_chars(_STR(ARG1)))) } /* // ----------------------------------------------------------------- */ NATIVE_METHOD(ip) { ! INIT_1_ARG(STRING) ! RETURN_STRING(ip(string_chars(_STR(ARG1)))) } --- 123,154 ---- d[1].u.val = VERSION_MINOR; d[2].u.val = VERSION_PATCH; ! CLEAN_RETURN_LIST(version); } /* // ----------------------------------------------------------------- */ NATIVE_METHOD(hostname) { ! string_t * name; ! INIT_1_ARG(STRING); ! ! name = hostname(string_chars(STR1)); ! ! CLEAN_RETURN_STRING(name); } /* // ----------------------------------------------------------------- */ NATIVE_METHOD(ip) { ! string_t * sip; ! ! INIT_1_ARG(STRING); ! ! sip = ip(string_chars(STR1)); ! CLEAN_RETURN_STRING(sip); } diff -rc Genesis-1.0p4/src/modules/cdc_string.c Genesis-1.0p6/src/modules/cdc_string.c *** Genesis-1.0p4/src/modules/cdc_string.c Sat Apr 20 14:14:27 1996 --- Genesis-1.0p6/src/modules/cdc_string.c Wed May 22 14:41:49 1996 *************** *** 24,56 **** #include "memory.h" NATIVE_METHOD(strlen) { INIT_1_ARG(STRING) ! RETURN_INTEGER(string_length(_STR(ARG1))) } NATIVE_METHOD(substr) { ! int start, ! len, ! string_len; INIT_2_OR_3_ARGS(STRING, INTEGER, INTEGER) ! string_len = string_length(_STR(ARG1)); ! start = _INT(ARG2) - 1; ! len = (argc == 3) ? _INT(ARG3) : string_len - start; /* Make sure range is in bounds. */ if (start < 0) THROW((range_id, "Start (%d) is less than one.", start + 1)) else if (len < 0) THROW((range_id, "Length (%d) is less than zero.", len)) ! else if (start + len > string_len) THROW((range_id, "The substring extends to %d, past the end of the string (%d).", ! start + len, string_len)) ! RETURN_STRING(string_substring(_STR(ARG1), start, len)); } NATIVE_METHOD(explode) { --- 24,64 ---- #include "memory.h" NATIVE_METHOD(strlen) { + int len; INIT_1_ARG(STRING) ! len = string_length(STR1); ! CLEAN_RETURN_INTEGER(len); } NATIVE_METHOD(substr) { ! int start, ! len, ! slen; ! string_t * str; INIT_2_OR_3_ARGS(STRING, INTEGER, INTEGER) ! slen = string_length(STR1); ! start = INT2 - 1; ! len = (argc == 3) ? INT3 : slen - start; /* Make sure range is in bounds. */ if (start < 0) THROW((range_id, "Start (%d) is less than one.", start + 1)) else if (len < 0) THROW((range_id, "Length (%d) is less than zero.", len)) ! else if (start + len > slen) THROW((range_id, "The substring extends to %d, past the end of the string (%d).", ! start + len, slen)) ! ! str = string_dup(STR1); ! CLEAN_STACK(); ! anticipate_assignment(); ! ! RETURN_STRING(string_substring(str, start, len)); } NATIVE_METHOD(explode) { *************** *** 69,76 **** switch(ARG_COUNT) { case 3: want_blanks = data_true(&args[2]); case 2: INIT_ARG2(STRING) ! sep = string_chars(_STR(ARG2)); ! sep_len = string_length(_STR(ARG2)); case 1: INIT_ARG1(STRING) break; default: THROW_NUM_ERROR(ARG_COUNT, "one to three") --- 77,84 ---- switch(ARG_COUNT) { case 3: want_blanks = data_true(&args[2]); case 2: INIT_ARG2(STRING) ! sep = string_chars(STR2); ! sep_len = string_length(STR2); case 1: INIT_ARG1(STRING) break; default: THROW_NUM_ERROR(ARG_COUNT, "one to three") *************** *** 79,86 **** if (!*sep) THROW((range_id, "Null string as separator.")) ! s = string_chars(_STR(ARG1)); ! len = string_length(_STR(ARG1)); exploded = list_new(0); p = s; --- 87,94 ---- if (!*sep) THROW((range_id, "Null string as separator.")) ! s = string_chars(STR1); ! len = string_length(STR1); exploded = list_new(0); p = s; *************** *** 106,112 **** } /* Pop the arguments and push the list onto the stack. */ ! RETURN_LIST(exploded) } NATIVE_METHOD(strsub) { --- 114,120 ---- } /* Pop the arguments and push the list onto the stack. */ ! CLEAN_RETURN_LIST(exploded); } NATIVE_METHOD(strsub) { *************** *** 116,130 **** INIT_3_ARGS(STRING, STRING, STRING) ! s = string_chars(_STR(ARG1)); ! len = string_length(_STR(ARG1)); ! search = string_chars(_STR(ARG2)); ! search_len = string_length(_STR(ARG2)); ! replace = string_chars(_STR(ARG3)); ! replace_len = string_length(_STR(ARG3)); if (*s == NULL || *search == NULL) { ! subbed = string_dup(_STR(ARG1)); } else { subbed = string_new(search_len); p = s; --- 124,138 ---- INIT_3_ARGS(STRING, STRING, STRING) ! s = string_chars(STR1); ! len = string_length(STR1); ! search = string_chars(STR2); ! search_len = string_length(STR2); ! replace = string_chars(STR3); ! replace_len = string_length(STR3); if (*s == NULL || *search == NULL) { ! subbed = string_dup(STR1); } else { subbed = string_new(search_len); p = s; *************** *** 137,143 **** subbed = string_add_chars(subbed, p, len - (p - s)); } ! RETURN_STRING(subbed) } /* Pad a string on the left (positive length) or on the right (negative --- 145,151 ---- subbed = string_add_chars(subbed, p, len - (p - s)); } ! CLEAN_RETURN_STRING(subbed); } /* Pad a string on the left (positive length) or on the right (negative *************** *** 145,190 **** NATIVE_METHOD(pad) { int len, padding, filler_len = 1; char * filler = " "; ! string_t * padded; DEF_args; switch (ARG_COUNT) { case 3: INIT_ARG3(STRING) ! filler = string_chars(_STR(ARG3)); ! filler_len = string_length(_STR(ARG3)); case 2: INIT_ARG2(INTEGER) INIT_ARG1(STRING) break; default: THROW_NUM_ERROR(ARG_COUNT, "two or three") } ! len = (_INT(ARG2) > 0) ? _INT(ARG2) : -_INT(ARG2); ! padding = len - string_length(_STR(ARG1)); /* Construct the padded string. */ - padded = _STR(ARG1); if (padding == 0) { /* Do nothing. Easiest case. */ } else if (padding < 0) { /* We're shortening the string. Almost as easy. */ ! padded = string_truncate(padded, len); } else if (args[1].u.val > 0) { /* We're lengthening the string on the right. */ ! padded = string_add_padding(padded, filler, filler_len, padding); } else { /* We're lengthening the string on the left. */ ! padded = string_new(padding + _STR(ARG1)->len); padded = string_add_padding(padded, filler, filler_len, padding); ! padded = string_add(padded, _STR(ARG1)); ! string_discard(_STR(ARG1)); } ! RETURN_STRING(padded); } NATIVE_METHOD(match_begin) { int sep_len = 1, ! search_len; char * sep = " ", * search, * s, --- 153,209 ---- NATIVE_METHOD(pad) { int len, padding, filler_len = 1; char * filler = " "; ! string_t * padded, ! * sfill = NULL, ! * str; DEF_args; switch (ARG_COUNT) { case 3: INIT_ARG3(STRING) ! sfill = string_dup(STR3); ! filler = string_chars(sfill); ! filler_len = string_length(sfill); case 2: INIT_ARG2(INTEGER) INIT_ARG1(STRING) break; default: THROW_NUM_ERROR(ARG_COUNT, "two or three") } ! str = string_dup(STR1); ! len = (INT2 > 0) ? INT2 : -INT2; ! padding = len - string_length(str); ! ! CLEAN_STACK(); ! anticipate_assignment(); /* Construct the padded string. */ if (padding == 0) { /* Do nothing. Easiest case. */ } else if (padding < 0) { /* We're shortening the string. Almost as easy. */ ! str = string_truncate(str, len); } else if (args[1].u.val > 0) { /* We're lengthening the string on the right. */ ! str = string_add_padding(str, filler, filler_len, padding); } else { /* We're lengthening the string on the left. */ ! padded = string_new(padding + str->len); padded = string_add_padding(padded, filler, filler_len, padding); ! padded = string_add(padded, str); ! string_discard(str); ! str = padded; } ! if (sfill != NULL) ! string_discard(sfill); ! ! RETURN_STRING(str); } NATIVE_METHOD(match_begin) { int sep_len = 1, ! search_len, ! bool = 0; char * sep = " ", * search, * s, *************** *** 193,217 **** switch (ARG_COUNT) { case 3: INIT_ARG3(STRING) ! sep = string_chars(_STR(ARG3)); ! sep_len = string_length(_STR(ARG3)); case 2: INIT_ARG2(STRING) INIT_ARG1(STRING) break; default: THROW_NUM_ERROR(ARG_COUNT, "two or three") } ! s = string_chars(_STR(ARG1)); ! search = string_chars(_STR(ARG2)); ! search_len = string_length(_STR(ARG2)); for (p = s - sep_len; p; p = strcstr(p + 1, sep)) { ! if (strnccmp(p + sep_len, search, search_len) == 0) ! RETURN_INTEGER(1) } ! RETURN_INTEGER(0) } /* Match against a command template. */ --- 212,238 ---- switch (ARG_COUNT) { case 3: INIT_ARG3(STRING) ! sep = string_chars(STR3); ! sep_len = string_length(STR3); case 2: INIT_ARG2(STRING) INIT_ARG1(STRING) break; default: THROW_NUM_ERROR(ARG_COUNT, "two or three") } ! s = string_chars(STR1); ! search = string_chars(STR2); ! search_len = string_length(STR2); for (p = s - sep_len; p; p = strcstr(p + 1, sep)) { ! if (strnccmp(p + sep_len, search, search_len) == 0) { ! bool = 1; ! break; ! } } ! CLEAN_RETURN_INTEGER(bool); } /* Match against a command template. */ *************** *** 220,234 **** char * ctemplate, * str; ! INIT_2_ARGS(STRING, STRING) ! ctemplate = string_chars(_STR(ARG1)); ! str = string_chars(_STR(ARG2)); ! if ((fields = match_template(ctemplate, str))) ! RETURN_LIST(fields) ! else ! RETURN_INTEGER(0) } /* Match against a command template. */ --- 241,256 ---- char * ctemplate, * str; ! INIT_2_ARGS(STRING, STRING); ! ctemplate = string_chars(STR1); ! str = string_chars(STR2); ! if ((fields = match_template(ctemplate, str))) { ! CLEAN_RETURN_LIST(fields); ! } else { ! CLEAN_RETURN_INTEGER(0); ! } } /* Match against a command template. */ *************** *** 239,251 **** INIT_2_ARGS(STRING, STRING) ! pattern = string_chars(_STR(ARG1)); ! str = string_chars(_STR(ARG2)); ! if ((fields = match_pattern(pattern, str))) ! RETURN_LIST(list_reverse(fields)) ! else ! RETURN_INTEGER(0) } NATIVE_METHOD(match_regexp) { --- 261,274 ---- INIT_2_ARGS(STRING, STRING) ! pattern = string_chars(STR1); ! str = string_chars(STR2); ! if ((fields = match_pattern(pattern, str))) { ! CLEAN_RETURN_LIST(list_reverse(fields)); ! } else { ! CLEAN_RETURN_INTEGER(0); ! } } NATIVE_METHOD(match_regexp) { *************** *** 261,272 **** default: THROW_NUM_ERROR(ARG_COUNT, "two or three") } ! fields = match_regexp(_STR(ARG1), string_chars(_STR(ARG2)), sensitive); ! if (fields) ! RETURN_LIST(fields) ! else ! RETURN_INTEGER(0) } NATIVE_METHOD(regexp) { --- 284,296 ---- default: THROW_NUM_ERROR(ARG_COUNT, "two or three") } ! fields = match_regexp(STR1, string_chars(STR2), sensitive); ! if (fields) { ! CLEAN_RETURN_LIST(fields); ! } else { ! CLEAN_RETURN_INTEGER(0); ! } } NATIVE_METHOD(regexp) { *************** *** 282,297 **** default: THROW_NUM_ERROR(ARG_COUNT, "two or three") } ! fields = regexp_matches(_STR(ARG1), string_chars(_STR(ARG2)), sensitive); ! if (fields) ! RETURN_LIST(fields) ! else ! RETURN_INTEGER(0) } - #define S(_x_) args[_x_].u.str - NATIVE_METHOD(strsed) { string_t * out; int sensitive=0, --- 306,320 ---- default: THROW_NUM_ERROR(ARG_COUNT, "two or three") } ! fields = regexp_matches(STR1, string_chars(STR2), sensitive); ! if (fields) { ! CLEAN_RETURN_LIST(fields); ! } else { ! CLEAN_RETURN_INTEGER(0); ! } } NATIVE_METHOD(strsed) { string_t * out; int sensitive=0, *************** *** 320,389 **** break; default: THROW_NUM_ERROR(ARG_COUNT, "three to five") } /* regexp *//* string *//* replace */ ! out = strsed(S(ARG1), S(ARG2), S(ARG3), global, sensitive, mult, &err); if (!out) { if (err) return 0; ! RETURN_INTEGER(0) ! } else ! RETURN_STRING(out) } /* Encrypt a string. */ NATIVE_METHOD(crypt) { char * s, * str; INIT_1_OR_2_ARGS(STRING, STRING) ! s = string_chars(_STR(ARG1)); if (argc == 2) { ! if (string_length(_STR(ARG2)) != 2) THROW((salt_id, "Salt (%S) is not two characters.", args[1].u.str)) str = crypt_string(s, string_chars(args[1].u.str)); } else { str = crypt_string(s, NULL); } ! RETURN_STRING(string_from_chars(str, strlen(str))) } NATIVE_METHOD(uppercase) { string_t * str; INIT_1_ARG(STRING) ! str = string_dup_or_copy(args[0].u.str); ! RETURN_STRING(string_uppercase(str)) } NATIVE_METHOD(lowercase) { string_t * str; INIT_1_ARG(STRING) ! str = string_dup_or_copy(args[0].u.str); ! RETURN_STRING(string_lowercase(str)) } NATIVE_METHOD(capitalize) { char * s; string_t * str; ! INIT_1_ARG(STRING) ! str = string_dup_or_copy(args[0].u.str); s = string_chars(str); *s = UCASE(*s); ! RETURN_STRING(str) } NATIVE_METHOD(strcmp) { INIT_2_ARGS(STRING, STRING) ! RETURN_INTEGER(strcmp(string_chars(_STR(ARG1)), string_chars(_STR(ARG2)))) } NATIVE_METHOD(strfmt) { --- 343,436 ---- break; default: THROW_NUM_ERROR(ARG_COUNT, "three to five") } + /* regexp *//* string *//* replace */ ! out = strsed(STR1, STR2, STR3, global, sensitive, mult, &err); if (!out) { if (err) return 0; ! CLEAN_RETURN_INTEGER(0); ! } ! ! CLEAN_RETURN_STRING(out); } /* Encrypt a string. */ NATIVE_METHOD(crypt) { char * s, * str; + string_t * crypt; INIT_1_OR_2_ARGS(STRING, STRING) ! s = string_chars(STR1); if (argc == 2) { ! if (string_length(STR2) != 2) THROW((salt_id, "Salt (%S) is not two characters.", args[1].u.str)) str = crypt_string(s, string_chars(args[1].u.str)); } else { str = crypt_string(s, NULL); } ! crypt = string_from_chars(str, strlen(str)); ! ! CLEAN_RETURN_STRING(crypt); } NATIVE_METHOD(uppercase) { string_t * str; + INIT_1_ARG(STRING) ! str = string_dup(STR1); ! ! CLEAN_STACK(); ! anticipate_assignment(); ! ! RETURN_STRING(string_uppercase(str)); } NATIVE_METHOD(lowercase) { string_t * str; + INIT_1_ARG(STRING) ! str = string_dup(STR1); ! ! CLEAN_STACK(); ! anticipate_assignment(); ! ! RETURN_STRING(string_lowercase(str)); } NATIVE_METHOD(capitalize) { char * s; string_t * str; ! INIT_1_ARG(STRING); ! ! str = string_dup(ARG1); ! ! CLEAN_STACK(); ! anticipate_assignment(); ! str = string_prep(str, str->start, str->len); s = string_chars(str); *s = UCASE(*s); ! RETURN_STRING(str); } NATIVE_METHOD(strcmp) { + int lex; + INIT_2_ARGS(STRING, STRING) ! lex = strcmp(string_chars(STR1), string_chars(STR2)); ! ! CLEAN_RETURN_INTEGER(lex); } NATIVE_METHOD(strfmt) { *************** *** 399,413 **** THROW((type_id, "First argument (%D) not a string.", &stack[arg_start])) fmt = stack[arg_start].u.str; - - if (argc == 1) - RETURN_STRING(string_dup(fmt)); - args = &stack[arg_start + 1]; if ((out = strfmt(fmt, args, argc - 1)) == (string_t *) NULL) ! return 0; ! RETURN_STRING(out); } --- 446,457 ---- THROW((type_id, "First argument (%D) not a string.", &stack[arg_start])) fmt = stack[arg_start].u.str; args = &stack[arg_start + 1]; + /* if out is NULL, strfmt() threw an error */ if ((out = strfmt(fmt, args, argc - 1)) == (string_t *) NULL) ! RETURN_FALSE; ! CLEAN_RETURN_STRING(out); } diff -rc Genesis-1.0p4/src/modules/moddef.h Genesis-1.0p6/src/modules/moddef.h *** Genesis-1.0p4/src/modules/moddef.h Tue Apr 16 14:53:15 1996 --- Genesis-1.0p6/src/modules/moddef.h Wed May 22 10:44:13 1996 *************** *** 78,84 **** #define NATIVE_HTTP_ENCODE 46 #define NATIVE_LAST 47 ! #define MAGIC_MODNUMBER 829687995 #ifdef _native_ --- 78,84 ---- #define NATIVE_HTTP_ENCODE 46 #define NATIVE_LAST 47 ! #define MAGIC_MODNUMBER 832783452 #ifdef _native_ Only in Genesis-1.0p6/src/modules: out diff -rc Genesis-1.0p4/src/modules/veil.c Genesis-1.0p6/src/modules/veil.c *** Genesis-1.0p4/src/modules/veil.c Mon Apr 15 21:11:37 1996 --- Genesis-1.0p6/src/modules/veil.c Wed May 22 10:25:47 1996 *************** *** 80,91 **** // ------------------------------------------------------------------- // internal function for buffer -> VEIL packet */ ! list_t * buffer_to_veil_packets(Buffer * buf) { int flags, session, length, blen; ! Buffer * databuf, * incomplete; data_t d, * list; --- 80,91 ---- // ------------------------------------------------------------------- // internal function for buffer -> VEIL packet */ ! list_t * buffer_to_veil_packets(buffer_t * buf) { int flags, session, length, blen; ! buffer_t * databuf, * incomplete; data_t d, * list; *************** *** 171,177 **** // Convert from a buffer to the standard 'VEIL packet' format */ NATIVE_METHOD(to_veil_pkts) { ! Buffer * buf; list_t * packets; INIT_1_OR_2_ARGS(BUFFER, BUFFER); --- 171,177 ---- // Convert from a buffer to the standard 'VEIL packet' format */ NATIVE_METHOD(to_veil_pkts) { ! buffer_t * buf; list_t * packets; INIT_1_OR_2_ARGS(BUFFER, BUFFER); *************** *** 187,193 **** buffer_discard(buf); ! RETURN_LIST(packets); } /* --- 187,193 ---- buffer_discard(buf); ! CLEAN_RETURN_LIST(packets); } /* *************** *** 200,206 **** NATIVE_METHOD(from_veil_pkts) { data_t * d, * pa; ! Buffer * out, * header; list_t * p, * packets; int len; --- 200,206 ---- NATIVE_METHOD(from_veil_pkts) { data_t * d, * pa; ! buffer_t * out, * header; list_t * p, * packets; int len; *************** *** 213,219 **** header->s[5] = (unsigned char) 0; out = buffer_new(0); ! packets = _LIST(ARG1); for (d = list_first(packets); d; d = list_next(packets, d)) { if (d->type != LIST) --- 213,219 ---- header->s[5] = (unsigned char) 0; out = buffer_new(0); ! packets = LIST1; for (d = list_first(packets); d; d = list_next(packets, d)) { if (d->type != LIST) *************** *** 254,266 **** header->s[7] = (unsigned char) pa->u.buffer->len%256; len = out->len + header->len + pa->u.buffer->len - 2; ! out = (Buffer *) erealloc(out, sizeof(Buffer) + len); MEMCPY(out->s + out->len, header->s, header->len); out->len += header->len; MEMCPY(out->s + out->len, pa->u.buffer->s, pa->u.buffer->len); out->len += pa->u.buffer->len; } ! RETURN_BUFFER(out); } --- 254,266 ---- header->s[7] = (unsigned char) pa->u.buffer->len%256; len = out->len + header->len + pa->u.buffer->len - 2; ! out = (buffer_t *) erealloc(out, sizeof(buffer_t) + len); MEMCPY(out->s + out->len, header->s, header->len); out->len += header->len; MEMCPY(out->s + out->len, pa->u.buffer->s, pa->u.buffer->len); out->len += pa->u.buffer->len; } ! CLEAN_RETURN_BUFFER(out); } diff -rc Genesis-1.0p4/src/modules/web.c Genesis-1.0p6/src/modules/web.c *** Genesis-1.0p4/src/modules/web.c Thu Apr 25 15:34:34 1996 --- Genesis-1.0p6/src/modules/web.c Wed May 22 10:35:09 1996 *************** *** 142,152 **** /* Accept a string to take the length of. */ INIT_1_ARG(STRING); ! /* decode directly munches the string, so force duplicate it, we should ! actually just have prepare_to_modify here, but its a string only func */ ! str = decode(string_from_chars(args[0].u.str->s, args[0].u.str->len)); ! RETURN_STRING(str); } NATIVE_METHOD(encode) { --- 142,154 ---- /* Accept a string to take the length of. */ INIT_1_ARG(STRING); ! str = string_dup(STR1); ! CLEAN_STACK(); ! anticipate_assignment(); ! ! /* decode should prep it, but its easier for us to do it */ ! RETURN_STRING(decode(string_prep(str, str->start, str->len))); } NATIVE_METHOD(encode) { *************** *** 154,161 **** INIT_1_ARG(STRING); ! str = encode(string_chars(args[0].u.str)); ! RETURN_STRING(str); } --- 156,163 ---- INIT_1_ARG(STRING); ! str = encode(string_chars(STR1)); ! CLEAN_RETURN_STRING(str); } diff -rc Genesis-1.0p4/src/ops/buffer.c Genesis-1.0p6/src/ops/buffer.c *** Genesis-1.0p4/src/ops/buffer.c Mon Apr 15 19:29:41 1996 --- Genesis-1.0p6/src/ops/buffer.c Tue May 21 17:30:18 1996 *************** *** 96,102 **** data_t *args; int num_args; list_t *list; ! Buffer *sep; if (!func_init_1_or_2(&args, &num_args, BUFFER, BUFFER)) return; --- 96,102 ---- data_t *args; int num_args; list_t *list; ! buffer_t *sep; if (!func_init_1_or_2(&args, &num_args, BUFFER, BUFFER)) return; *************** *** 111,117 **** COLDC_FUNC(str_to_buf) { data_t *args; ! Buffer *buf; if (!func_init_1(&args, STRING)) return; --- 111,117 ---- COLDC_FUNC(str_to_buf) { data_t *args; ! buffer_t *buf; if (!func_init_1(&args, STRING)) return; *************** *** 125,131 **** COLDC_FUNC(strings_to_buf) { data_t *args, *d; int num_args, i; ! Buffer *buf, *sep; list_t *list; if (!func_init_1_or_2(&args, &num_args, LIST, BUFFER)) --- 125,131 ---- COLDC_FUNC(strings_to_buf) { data_t *args, *d; int num_args, i; ! buffer_t *buf, *sep; list_t *list; if (!func_init_1_or_2(&args, &num_args, LIST, BUFFER)) diff -rc Genesis-1.0p4/src/ops/file.c Genesis-1.0p6/src/ops/file.c *** Genesis-1.0p4/src/ops/file.c Sun Mar 10 00:09:48 1996 --- Genesis-1.0p6/src/ops/file.c Tue May 21 17:30:25 1996 *************** *** 502,508 **** } if (file->f.binary) { ! Buffer * buf = NULL; int block = DEF_BLOCKSIZE; if (nargs) { --- 502,508 ---- } if (file->f.binary) { ! buffer_t * buf = NULL; int block = DEF_BLOCKSIZE; if (nargs) { diff -rc Genesis-1.0p4/src/ops/network.c Genesis-1.0p6/src/ops/network.c *** Genesis-1.0p4/src/ops/network.c Sat Mar 9 22:59:01 1996 --- Genesis-1.0p6/src/ops/network.c Tue May 21 17:30:34 1996 *************** *** 149,155 **** size_t block, r; data_t * args; FILE * fp; ! Buffer * buf; string_t * str; struct stat statbuf; int nargs; --- 149,155 ---- size_t block, r; data_t * args; FILE * fp; ! buffer_t * buf; string_t * str; struct stat statbuf; int nargs; diff -rc Genesis-1.0p4/src/ops/object.c Genesis-1.0p6/src/ops/object.c *** Genesis-1.0p4/src/ops/object.c Mon Apr 22 20:06:58 1996 --- Genesis-1.0p6/src/ops/object.c Tue May 21 17:34:28 1996 *************** *** 28,34 **** #include "grammar.h" #include "cache.h" ! void func_add_var(void) { data_t * args; long result; --- 28,34 ---- #include "grammar.h" #include "cache.h" ! COLDC_FUNC(add_var) { data_t * args; long result; *************** *** 45,51 **** push_int(1); } ! void func_del_var(void) { data_t * args; long result; --- 45,51 ---- push_int(1); } ! COLDC_FUNC(del_var) { data_t * args; long result; *************** *** 62,68 **** } } ! void func_variables(void) { list_t * vars; object_t * obj; int i; --- 62,68 ---- } } ! COLDC_FUNC(variables) { list_t * vars; object_t * obj; int i; *************** *** 90,96 **** list_discard(vars); } ! void func_set_var(void) { data_t * args, d; long result; --- 90,96 ---- list_discard(vars); } ! COLDC_FUNC(set_var) { data_t * args, d; long result; *************** *** 112,118 **** } } ! void func_get_var(void) { data_t * args, d; long result; --- 112,118 ---- } } ! COLDC_FUNC(get_var) { data_t * args, d; long result; *************** *** 132,138 **** } } ! void func_clear_var(void) { data_t * args; long result = 0; --- 132,138 ---- } } ! COLDC_FUNC(clear_var) { data_t * args; long result = 0; *************** *** 156,162 **** } } ! void func_add_method(void) { data_t * args, * d; method_t * method; --- 156,162 ---- } } ! COLDC_FUNC(add_method) { data_t * args, * d; method_t * method; *************** *** 205,211 **** list_discard(errors); } ! void func_rename_method(void) { data_t * args; method_t * method; --- 205,211 ---- list_discard(errors); } ! COLDC_FUNC(rename_method) { data_t * args; method_t * method; *************** *** 257,263 **** #undef LADD ! void func_method_flags(void) { data_t * args; list_t * list; --- 257,263 ---- #undef LADD ! COLDC_FUNC(method_flags) { data_t * args; list_t * list; *************** *** 271,277 **** list_discard(list); } ! void func_set_method_flags(void) { data_t * args, * d; list_t * list; --- 271,277 ---- list_discard(list); } ! COLDC_FUNC(set_method_flags) { data_t * args, * d; list_t * list; *************** *** 311,317 **** push_int(new_flags); } ! void func_method_access(void) { int access; data_t * args; --- 311,317 ---- push_int(new_flags); } ! COLDC_FUNC(method_access) { int access; data_t * args; *************** *** 332,338 **** } } ! void func_set_method_access(void) { int access = 0; data_t * args; Ident sym; --- 332,338 ---- } } ! COLDC_FUNC(set_method_access) { int access = 0; data_t * args; Ident sym; *************** *** 363,369 **** push_int(access); } ! void func_method_info(void) { data_t * args, * list; list_t * output; --- 363,369 ---- push_int(access); } ! COLDC_FUNC(method_info) { data_t * args, * list; list_t * output; *************** *** 430,436 **** list_discard(output); } ! void func_methods(void) { list_t * methods; data_t d; object_t * obj; --- 430,436 ---- list_discard(output); } ! COLDC_FUNC(methods) { list_t * methods; data_t d; object_t * obj; *************** *** 457,463 **** list_discard(methods); } ! void func_find_method(void) { data_t * args; method_t * method; --- 457,463 ---- list_discard(methods); } ! COLDC_FUNC(find_method) { data_t * args; method_t * method; *************** *** 476,482 **** } } ! void func_find_next_method(void) { data_t * args; method_t * method; --- 476,482 ---- } } ! COLDC_FUNC(find_next_method) { data_t * args; method_t * method; *************** *** 496,502 **** } } ! void func_decompile(void) { int num_args, indent, parens; --- 496,502 ---- } } ! COLDC_FUNC(decompile) { int num_args, indent, parens; *************** *** 524,530 **** } } ! void func_del_method(void) { data_t * args; int status; --- 524,530 ---- } } ! COLDC_FUNC(del_method) { data_t * args; int status; *************** *** 543,549 **** } } ! void func_parents(void) { /* Accept no arguments. */ if (!func_init_0()) return; --- 543,549 ---- } } ! COLDC_FUNC(parents) { /* Accept no arguments. */ if (!func_init_0()) return; *************** *** 552,558 **** push_list(cur_frame->object->parents); } ! void func_children(void) { /* Accept no arguments. */ if (!func_init_0()) return; --- 552,558 ---- push_list(cur_frame->object->parents); } ! COLDC_FUNC(children) { /* Accept no arguments. */ if (!func_init_0()) return; *************** *** 561,567 **** push_list(cur_frame->object->children); } ! void func_descendants(void) { list_t * desc; if (!func_init_0()) --- 561,567 ---- push_list(cur_frame->object->children); } ! COLDC_FUNC(descendants) { list_t * desc; if (!func_init_0()) *************** *** 573,579 **** list_discard(desc); } ! void func_ancestors(void) { list_t * ancestors; /* Accept no arguments. */ --- 573,579 ---- list_discard(desc); } ! COLDC_FUNC(ancestors) { list_t * ancestors; /* Accept no arguments. */ *************** *** 586,592 **** list_discard(ancestors); } ! void func_has_ancestor(void) { data_t * args; int resul