From 28aeada5c757a5a997526f74a471cf0c56c6b473 Mon Sep 17 00:00:00 2001 From: dos-reis Date: Wed, 21 May 2008 11:30:55 +0000 Subject: * graph/Gdraws/Makefile.in (HEADERS): Don't include hash.H1. * include/halloc.h: Rename from include/halloc.H1. * include/lex.H1: Remove. * include/hterror.H1: Likewise. * hyper/halloc.c: Likewise. * hyper/hash.c: Likewise. * hyper/Makefile.in (hypertex_SOURCES): Don't include hash.c, halloc.c. --- src/ChangeLog | 11 ++ src/graph/Gdraws/Gfun.c | 1 - src/graph/Gdraws/Makefile.in | 2 +- src/hyper/Makefile.in | 4 +- src/hyper/addfile.c | 1 + src/hyper/halloc.c | 73 -------------- src/hyper/hash.c | 221 ----------------------------------------- src/hyper/htadd.c | 7 +- src/hyper/hterror.c | 6 ++ src/hyper/hterror.h | 17 ++-- src/hyper/lex.c | 11 +- src/hyper/lex.h | 20 ++++ src/hyper/macro.c | 1 + src/include/all_hyper_proto.H1 | 4 - src/include/halloc.H1 | 1 - src/include/halloc.h | 41 ++++++++ src/include/hash.H1 | 12 --- src/include/hash.h | 29 ++++-- src/include/hterror.H1 | 6 -- src/include/lex.H1 | 23 ----- src/lib/halloc.c | 4 +- src/lib/hash.c | 31 +++--- src/lib/pixmap.c | 2 +- 23 files changed, 143 insertions(+), 385 deletions(-) delete mode 100644 src/hyper/halloc.c delete mode 100644 src/hyper/hash.c delete mode 100644 src/include/halloc.H1 create mode 100644 src/include/halloc.h delete mode 100644 src/include/hash.H1 delete mode 100644 src/include/hterror.H1 delete mode 100644 src/include/lex.H1 (limited to 'src') diff --git a/src/ChangeLog b/src/ChangeLog index 8a793490..8a26d3a5 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,14 @@ +2008-05-21 Gabriel Dos Reis + + * graph/Gdraws/Makefile.in (HEADERS): Don't include hash.H1. + * include/halloc.h: Rename from include/halloc.H1. + * include/lex.H1: Remove. + * include/hterror.H1: Likewise. + * hyper/halloc.c: Likewise. + * hyper/hash.c: Likewise. + * hyper/Makefile.in (hypertex_SOURCES): Don't include hash.c, + halloc.c. + 2008-05-21 Igor Kahvkine Waldek Hebisch diff --git a/src/graph/Gdraws/Gfun.c b/src/graph/Gdraws/Gfun.c index ffb8275a..db2f4f7f 100644 --- a/src/graph/Gdraws/Gfun.c +++ b/src/graph/Gdraws/Gfun.c @@ -45,7 +45,6 @@ #include "G.h" #include "hash.h" -#include "hash.H1" #include "Gfun.H1" diff --git a/src/graph/Gdraws/Makefile.in b/src/graph/Gdraws/Makefile.in index 434b29bb..56d018df 100644 --- a/src/graph/Gdraws/Makefile.in +++ b/src/graph/Gdraws/Makefile.in @@ -64,7 +64,7 @@ subdir = src/graph/Gdraws/ pamphlets = psFiles.pamphlet HEADERS = ${IN}/Gdraws0.h ${LINC}/G.h ${LINC}/Gfun.H1 \ - ${GINC}/hash.h ${GINC}/hash.H1 $(axiom_c_macros_h) + ${GINC}/hash.h $(axiom_c_macros_h) PSFiles= ${PS}/colorpoly.ps ${PS}/colorwol.ps ${PS}/draw.ps \ ${PS}/drawIstr.ps ${PS}/drawarc.ps ${PS}/drawcolor.ps \ diff --git a/src/hyper/Makefile.in b/src/hyper/Makefile.in index 078d5bfe..e099fa56 100644 --- a/src/hyper/Makefile.in +++ b/src/hyper/Makefile.in @@ -62,7 +62,7 @@ HEADERS = display.h event.h extent.h \ build_libdir = $(top_builddir)/src/lib hypertex_SOURCES = addfile.c cond.c dialog.c display.c event.c extent1.c \ - extent2.c form-ext.c group.c halloc.c hash.c hterror.c \ + extent2.c form-ext.c group.c hterror.c \ htinp.c hyper.c initx.c input.c item.c keyin.c lex.c \ macro.c mem.c parse.c parse-aux.c parse-input.c \ parse-paste.c parse-types.c ReadBitmap.c scrollbar.c \ @@ -74,7 +74,7 @@ hypertex_objects = $(hypertex_SOURCES:.c=.lo) hypertex_LDADD = $(libspad_la) -L$(build_libdir) -lopen-axiom-core hypertex_DEPENDENCIES = -htadd_SOURCES = addfile.c halloc.c hash.c htadd.c hterror.c lex.c +htadd_SOURCES = addfile.c htadd.c hterror.c lex.c htadd_objects = $(htadd_SOURCES:.c=.lo) htadd_LDADD = $(libspad_la) -L$(build_libdir) -lopen-axiom-core htadd_DEPENDENCIES = diff --git a/src/hyper/addfile.c b/src/hyper/addfile.c index b1b97d49..32eddd95 100644 --- a/src/hyper/addfile.c +++ b/src/hyper/addfile.c @@ -45,6 +45,7 @@ #include #include +#include "halloc.h" #include "all_hyper_proto.H1" static int build_ht_filename(char*, char*, char*); diff --git a/src/hyper/halloc.c b/src/hyper/halloc.c deleted file mode 100644 index 1cccb324..00000000 --- a/src/hyper/halloc.c +++ /dev/null @@ -1,73 +0,0 @@ -/* - Copyright (C) 1991-2002, The Numerical Algorithms Group Ltd. - All rights reserved. - Copyright (C) 2007-2008, Gabriel Dos Reis. - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical Algorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER - OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#define _HALLOC_C -#include "openaxiom-c-macros.h" - -#include "debug.h" -#include -#include - -FILE *fp; - -#include "halloc.H1" - -/* allocate memory and bomb if none left (HyperDoc alloc) */ - -char * -halloc(int bytes, char *msg) -{ - static char buf[200]; - char *result; - -#ifdef DEBUG - static int first = 1; - - if (first) { - fp = fopen("/tmp/hallocs", "w"); - first = 0; - } -#endif - result = (char *) malloc(bytes); -#ifdef DEBUG - fprintf(fp, "%d\tAlocating %d Bytes for %s\n", result,bytes, msg); -#endif - if (result == NULL) { - sprintf(buf, "Ran out of memory allocating %s.\b", msg); - fprintf(stderr, "%s\n", buf); - exit(-1); - } - return result; -} diff --git a/src/hyper/hash.c b/src/hyper/hash.c deleted file mode 100644 index 170f7d15..00000000 --- a/src/hyper/hash.c +++ /dev/null @@ -1,221 +0,0 @@ -/* - Copyright (C) 1991-2002, The Numerical Algorithms Group Ltd. - All rights reserved. - Copyright (C) 2007-2008, Gabriel Dos Reis. - All rights resrved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical Algorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER - OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#define _HASH_C -#include "openaxiom-c-macros.h" - -#include "debug.h" - -#include -#include -#include -#include "hash.h" - -#include "hash.H1" -#include "halloc.H1" - -/* initialize a hash table */ - -void -hash_init(HashTable *table, int size, EqualFunction equal, - HashcodeFunction hash_code) -{ - int i; - - table->table = - (HashEntry **) halloc(size * sizeof(HashEntry *), "HashEntry"); - for (i = 0; i < size; i++) - table->table[i] = NULL; - table->size = size; - table->equal = equal; - table->hash_code = hash_code; - table->num_entries = 0; -} - -void -free_hash(HashTable *table, FreeFunction free_fun) -{ - if (table) { - int i; - - for (i = 0; i < table->size; i++) { - HashEntry *e, *next; - - for (e = table->table[i]; e != NULL;) { - next = e->next; - (*free_fun) (e->data); - (*e).data=0; - free(e); - e = next; - } - } - free(table->table); - } -} - -/* insert an entry into a hash table */ - -void -hash_insert(HashTable *table, char *data, char *key) -{ - HashEntry *entry = (HashEntry *) halloc(sizeof(HashEntry), "HashEntry"); - int code; - - entry->data = data; - entry->key = key; - code = (*table->hash_code) (key, table->size) % table->size; -#ifdef DEBUG - fprintf(stderr, "Hash value = %d\n", code); -#endif - entry->next = table->table[code]; - table->table[code] = entry; - table->num_entries++; -} - -char * -hash_find(HashTable *table, char *key) -{ - HashEntry *entry; - int code = table->hash_code(key, table->size) % table->size; - - for (entry = table->table[code]; entry != NULL; entry = entry->next) - if ((*table->equal) (entry->key, key)) - return entry->data; - return NULL; -} - -char * -hash_replace(HashTable *table, char *data, char *key) -{ - HashEntry *entry; - int code = table->hash_code(key, table->size) % table->size; - - for (entry = table->table[code]; entry != NULL; entry = entry->next) - if ((*table->equal) (entry->key, key)) { - entry->data = data; - return entry->data; - } - return NULL; -} - -void -hash_delete(HashTable *table, char *key) -{ - HashEntry **entry; - int code = table->hash_code(key, table->size) % table->size; - - for (entry = &table->table[code]; *entry != NULL; entry = &((*entry)->next)) - if ((*table->equal) ((*entry)->key, key)) { - *entry = (*entry)->next; - table->num_entries--; - return; - } -} - -void -hash_map(HashTable *table, MappableFunction func) -{ - int i; - HashEntry *e; - - if (table == NULL) - return; - for (i = 0; i < table->size; i++) - for (e = table->table[i]; e != NULL; e = e->next) - (*func) (e->data); -} - -HashEntry * -hash_copy_entry(HashEntry *e) -{ - HashEntry *ne; - - if (e == NULL) - return e; - ne = (HashEntry *) halloc(sizeof(HashEntry), "HashEntry"); - ne->data = e->data; - ne->key = e->key; - ne->next = hash_copy_entry(e->next); - return ne; -} - -/* copy a hash table */ -HashTable * -hash_copy_table(HashTable *table) -{ - HashTable *nt = (HashTable *) halloc(sizeof(HashTable), "copy hash table"); - int i; - - nt->size = table->size; - nt->num_entries = table->num_entries; - nt->equal = table->equal; - nt->hash_code = table->hash_code; - nt->table = (HashEntry **) halloc(nt->size * sizeof(HashEntry *), - "copy table"); - for (i = 0; i < table->size; i++) - nt->table[i] = hash_copy_entry(table->table[i]); - return nt; -} - -/* hash code function for strings */ -int -string_hash(char *s, int size) -{ - int c = 0; - char *p =s; - - - while (*p) - c += *p++; - return c % size; -} - -/* test strings for equality */ - -int -string_equal(char *s1, char *s2) -{ - return (strcmp(s1, s2) == 0); -} - -/* make a fresh copy of the given string */ -char * -alloc_string(char *str) -{ - char * result; - result = halloc(strlen(str)+1,"String"); - strcpy(result,str); - return (result); -} diff --git a/src/hyper/htadd.c b/src/hyper/htadd.c index 6eb71c5c..6caa50da 100644 --- a/src/hyper/htadd.c +++ b/src/hyper/htadd.c @@ -45,13 +45,10 @@ #include #include +#include "hash.h" +#include "hterror.h" #include "lex.h" - #include "addfile.h" -#include "halloc.H1" -#include "hash.H1" -#include "hterror.H1" -#include "lex.H1" static void add_file(char*, char*, int); diff --git a/src/hyper/hterror.c b/src/hyper/hterror.c index ec5f8123..b98830d5 100644 --- a/src/hyper/hterror.c +++ b/src/hyper/hterror.c @@ -49,6 +49,12 @@ char ebuffer[128]; jmp_buf jmpbuf; +char *errmess[] = { + "place holder", + "parsing condition node", + "unrecognized keyword" +}; + /* * This file is the error handling routine in AXIOM. The main routine is * called htperror(): arguments: msg - like perror it accepts an error diff --git a/src/hyper/hterror.h b/src/hyper/hterror.h index 1ecf63d1..6e2b0ae4 100644 --- a/src/hyper/hterror.h +++ b/src/hyper/hterror.h @@ -33,13 +33,18 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#ifndef OPENAXIOM_HTERROR +#define OPENAXIOM_HTERROR + #define HTCONDNODE 1 /* unrecognized condition node */ #define KEYTYPE 2 /* unrecognized keyword found in lex.c */ #define Numerrors 2 -#ifdef HTERROR -char *errmess[] = { - "place holder", - "parsing condition node", - "unrecognized keyword" }; -#endif +extern void print_page_and_filename(void); +extern void jump(void); +extern void print_token(void); +extern void token_name(int); +extern void print_next_ten_tokens(void); +extern void htperror(char* , int); + +#endif /* OPENAXIOM_HTERROR */ diff --git a/src/hyper/lex.c b/src/hyper/lex.c index aaff7b3a..80acb07e 100644 --- a/src/hyper/lex.c +++ b/src/hyper/lex.c @@ -71,12 +71,17 @@ int useAscii; #include "lex.h" #include "all_hyper_proto.H1" +#include "halloc.h" #include "sockio.h" #include #include +static int get_char1(void ); +static void spad_error_handler(void ); +static int keyword_type(void ); + extern int gTtFontIs850; @@ -535,7 +540,7 @@ BeStruct *top_be_stack; void -push_be_stack(int type,char * id) +push_be_stack(int type, const char* id) { BeStruct *be = (BeStruct *) halloc(sizeof(BeStruct), "BeginENd stack"); @@ -548,7 +553,7 @@ push_be_stack(int type,char * id) return; } void -check_and_pop_be_stack(int type,char * id) +check_and_pop_be_stack(int type, const char* id) { BeStruct *x; @@ -594,7 +599,7 @@ clear_be_stack(void) } int -be_type(char *which) +be_type(const char* which) { Token store; diff --git a/src/hyper/lex.h b/src/hyper/lex.h index 8cb3cf0a..ff3998fe 100644 --- a/src/hyper/lex.h +++ b/src/hyper/lex.h @@ -38,6 +38,26 @@ #include "hyper.h" +extern int connect_spad(void); +extern void get_expected_token(int); +extern void parser_init(void); +extern void init_scanner(void); +extern void save_scanner_state(void); +extern void restore_scanner_state(void); +extern void unget_char(int); +extern int get_char(void); +extern void unget_token(void); +extern int get_token(void); +extern void push_be_stack(int, const char*); +extern void check_and_pop_be_stack(int, const char*); +extern int clear_be_stack(void); +extern int be_type(const char*); +extern int begin_type(void); +extern int end_type(void); +extern void reset_connection(void); +extern int spad_busy(void); + + extern HyperDocPage *gPageBeingParsed; extern short int gInSpadsrc; diff --git a/src/hyper/macro.c b/src/hyper/macro.c index 917a6f83..63723153 100644 --- a/src/hyper/macro.c +++ b/src/hyper/macro.c @@ -40,6 +40,7 @@ #include "sockio.h" #include "parse.h" #include "hyper.h" +#include "lex.h" #include "all_hyper_proto.H1" diff --git a/src/include/all_hyper_proto.H1 b/src/include/all_hyper_proto.H1 index 320e1eb1..0218d96a 100644 --- a/src/include/all_hyper_proto.H1 +++ b/src/include/all_hyper_proto.H1 @@ -7,16 +7,13 @@ #include "form_ext.H1" #include "extent1.H1" #include "extent2.H1" -#include "halloc.H1" #include "group.H1" -#include "hterror.H1" #include "htinp.H1" #include "hyper.H1" #include "initx.H1" #include "input.H1" #include "keyin.H1" #include "item.H1" -#include "lex.H1" #include "parse.H1" #include "macro.H1" #include "parse_paste.H1" @@ -27,5 +24,4 @@ #include "scrollbar.H1" #include "titlebar.H1" #include "spadint.H1" -#include "hash.H1" #include "mem.H1" diff --git a/src/include/halloc.H1 b/src/include/halloc.H1 deleted file mode 100644 index 717a7d0f..00000000 --- a/src/include/halloc.H1 +++ /dev/null @@ -1 +0,0 @@ -extern char * halloc(int bytes , char * msg); diff --git a/src/include/halloc.h b/src/include/halloc.h new file mode 100644 index 00000000..9ecd3aa0 --- /dev/null +++ b/src/include/halloc.h @@ -0,0 +1,41 @@ +/* + Copyright (C) 1991-2002, The Numerical Algorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef OPENAXIOM_HALLOC +#define OPENAXIOM_HALLOC + +extern char * halloc(int, const char*); + +#endif /* OPENAXIOM_HALLOC */ diff --git a/src/include/hash.H1 b/src/include/hash.H1 deleted file mode 100644 index 2028b961..00000000 --- a/src/include/hash.H1 +++ /dev/null @@ -1,12 +0,0 @@ -extern char * alloc_string(char * str); -extern HashEntry * hash_copy_entry(HashEntry * e); -extern HashTable * hash_copy_table(HashTable * table); -extern void hash_delete(HashTable * table , char * key); -extern char * hash_find(HashTable * table , char * key); -extern void hash_init(HashTable * table , int size , EqualFunction equal ,HashcodeFunction hash_code); -extern void free_hash(HashTable * table , FreeFunction free_fun); -extern void hash_insert(HashTable * table , char * data , char * key); -extern void hash_map(HashTable * table , MappableFunction func); -extern char * hash_replace(HashTable * table , char * data , char * key); -extern int string_equal(char * s1 , char * s2); -extern int string_hash(char * s , int size); diff --git a/src/include/hash.h b/src/include/hash.h index 87b34610..5c63b315 100644 --- a/src/include/hash.h +++ b/src/include/hash.h @@ -36,17 +36,17 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -typedef struct hash_entry { - char *key; /* pointer to key data */ - char *data; /* Pointer to entry */ - struct hash_entry *next; /* Link to next entry */ +typedef struct HashEntry { + const char *key; /* pointer to key data */ + char *data; /* Pointer to entry */ + struct HashEntry *next; /* Link to next entry */ } HashEntry; -typedef int (*EqualFunction)(void *,void *); -typedef int (*HashcodeFunction)(void *,int); -typedef void (*MappableFunction) (void *); +typedef int (*EqualFunction)(const void*, const void*); +typedef int (*HashcodeFunction)(const void*,int); +typedef void (*MappableFunction) (const void*); typedef void (*FreeFunction) (void *); -typedef struct { +typedef struct HashTable { HashEntry **table; /* the actual table */ int size; /* size of table */ int num_entries; /* number of elements in a hash table */ @@ -54,4 +54,17 @@ typedef struct { HashcodeFunction hash_code; /* create hash code for a key */ } HashTable; +extern char* alloc_string(const char*); +extern HashEntry* hash_copy_entry(HashEntry*); +extern HashTable* hash_copy_table(HashTable*); +extern void hash_delete(HashTable*, const char*); +extern char* hash_find(HashTable*, const char*); +extern void hash_init(HashTable*, int, EqualFunction, HashcodeFunction); +extern void free_hash(HashTable*, FreeFunction); +extern void hash_insert(HashTable*, char*, const char*); +extern void hash_map(HashTable*, MappableFunction func); +extern char* hash_replace(HashTable*, char*, const char*); +extern int string_equal(const char*, const char*); +extern int string_hash(const char*, int size); + #endif diff --git a/src/include/hterror.H1 b/src/include/hterror.H1 deleted file mode 100644 index cf4f99d4..00000000 --- a/src/include/hterror.H1 +++ /dev/null @@ -1,6 +0,0 @@ -extern void print_page_and_filename(void ); -extern void jump(void ); -extern void print_token(void ); -extern void token_name(int type); -extern void print_next_ten_tokens(void ); -extern void htperror(char *, int); diff --git a/src/include/lex.H1 b/src/include/lex.H1 deleted file mode 100644 index 7f049204..00000000 --- a/src/include/lex.H1 +++ /dev/null @@ -1,23 +0,0 @@ -extern int connect_spad(void); -extern void get_expected_token(int type); -extern void parser_init(void); -extern void init_scanner(void); -extern void save_scanner_state(void); -extern void restore_scanner_state(void); -extern void unget_char(int c); -extern int get_char(void); -extern void unget_token(void); -extern int get_token(void); -extern void push_be_stack(int type , char * id); -extern void check_and_pop_be_stack(int type , char * id); -extern int clear_be_stack(void); -extern int be_type(char * which); -extern int begin_type(void); -extern int end_type(void); -extern void reset_connection(void); -extern int spad_busy(void); -#ifdef _LEX_C -static int get_char1(void ); -static void spad_error_handler(void ); -static int keyword_type(void ); -#endif diff --git a/src/lib/halloc.c b/src/lib/halloc.c index 776c0c43..4b19c60a 100644 --- a/src/lib/halloc.c +++ b/src/lib/halloc.c @@ -38,12 +38,12 @@ #include #include -#include "halloc.H1" +#include "halloc.h" /* allocate memory and bomb if none left (hyperTeX alloc) */ char * -halloc(int bytes,char * msg) +halloc(int bytes, const char* msg) { static char buf[200]; char *result; diff --git a/src/lib/hash.c b/src/lib/hash.c index f2935c1e..837eb8b1 100644 --- a/src/lib/hash.c +++ b/src/lib/hash.c @@ -39,10 +39,9 @@ #include #include #include -#include "hash.h" -#include "hash.H1" -#include "halloc.H1" +#include "halloc.h" +#include "hash.h" /* initialize a hash table */ @@ -63,7 +62,7 @@ hash_init(HashTable *table, int size, EqualFunction equal, } void -free_hash(HashTable *table, FreeFunction free_fun) +free_hash(HashTable* table, FreeFunction free_fun) { if (table) { int i; @@ -73,7 +72,7 @@ free_hash(HashTable *table, FreeFunction free_fun) for (e = table->table[i]; e != NULL;) { next = e->next; - (*free_fun) (e->data); + (*free_fun) ((char*) e->data); (*e).data=0; free(e); e = next; @@ -86,7 +85,7 @@ free_hash(HashTable *table, FreeFunction free_fun) /* insert an entry into a hash table */ void -hash_insert(HashTable *table, char *data, char *key) +hash_insert(HashTable* table, char* data, const char *key) { HashEntry *entry = (HashEntry *) halloc(sizeof(HashEntry), "HashEntry"); int code; @@ -103,7 +102,7 @@ hash_insert(HashTable *table, char *data, char *key) } char * -hash_find(HashTable *table, char *key) +hash_find(HashTable* table, const char *key) { HashEntry *entry; int code = table->hash_code(key, table->size) % table->size; @@ -115,7 +114,7 @@ hash_find(HashTable *table, char *key) } char * -hash_replace(HashTable *table, char *data, char *key) +hash_replace(HashTable* table, char* data, const char* key) { HashEntry *entry; int code = table->hash_code(key, table->size) % table->size; @@ -129,7 +128,7 @@ hash_replace(HashTable *table, char *data, char *key) } void -hash_delete(HashTable *table, char *key) +hash_delete(HashTable* table, const char* key) { HashEntry **entry; int code = table->hash_code(key, table->size) % table->size; @@ -143,7 +142,7 @@ hash_delete(HashTable *table, char *key) } void -hash_map(HashTable *table, MappableFunction func) +hash_map(HashTable* table, MappableFunction func) { int i; HashEntry *e; @@ -171,7 +170,7 @@ hash_copy_entry(HashEntry *e) /* copy a hash table */ HashTable * -hash_copy_table(HashTable *table) +hash_copy_table(HashTable* table) { HashTable *nt = (HashTable *) halloc(sizeof(HashTable), "copy hash table"); int i; @@ -189,10 +188,10 @@ hash_copy_table(HashTable *table) /* hash code function for strings */ int -string_hash(char *s, int size) +string_hash(const char* s, int size) { int c = 0; - char *p =s; + const char *p =s; while (*p) @@ -203,17 +202,17 @@ string_hash(char *s, int size) /* test strings for equality */ int -string_equal(char *s1, char *s2) +string_equal(const char* s1, const char* s2) { return (strcmp(s1, s2) == 0); } /* make a fresh copy of the given string */ char * -alloc_string(char *str) +alloc_string(const char* str) { char * result; - result = halloc(strlen(str)+1,"String"); + result = halloc(strlen(str)+1,"alloc_string"); strcpy(result,str); return (result); } diff --git a/src/lib/pixmap.c b/src/lib/pixmap.c index 57762e2f..de24d8e3 100644 --- a/src/lib/pixmap.c +++ b/src/lib/pixmap.c @@ -47,8 +47,8 @@ #include "spadcolors.h" +#include "halloc.h" #include "pixmap.H1" -#include "halloc.H1" #include "spadcolors.H1" -- cgit v1.2.3