aboutsummaryrefslogtreecommitdiff
path: root/src/hyper
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2008-05-21 11:30:55 +0000
committerdos-reis <gdr@axiomatics.org>2008-05-21 11:30:55 +0000
commit28aeada5c757a5a997526f74a471cf0c56c6b473 (patch)
treecd153e60571f07568a7e96a802d56100ed60a5c3 /src/hyper
parent7efb5764ecb6e7141c207bd906d9ac7f49342126 (diff)
downloadopen-axiom-28aeada5c757a5a997526f74a471cf0c56c6b473.tar.gz
* 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.
Diffstat (limited to 'src/hyper')
-rw-r--r--src/hyper/Makefile.in4
-rw-r--r--src/hyper/addfile.c1
-rw-r--r--src/hyper/halloc.c73
-rw-r--r--src/hyper/hash.c221
-rw-r--r--src/hyper/htadd.c7
-rw-r--r--src/hyper/hterror.c6
-rw-r--r--src/hyper/hterror.h17
-rw-r--r--src/hyper/lex.c11
-rw-r--r--src/hyper/lex.h20
-rw-r--r--src/hyper/macro.c1
10 files changed, 51 insertions, 310 deletions
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 <sys/stat.h>
#include <errno.h>
+#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 <stdio.h>
-#include <stdlib.h>
-
-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 <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#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 <errno.h>
#include <setjmp.h>
+#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 <ctype.h>
#include <setjmp.h>
+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"