diff options
author | Pixel <Pixel> | 2002-08-17 01:48:34 +0000 |
---|---|---|
committer | Pixel <Pixel> | 2002-08-17 01:48:34 +0000 |
commit | 11bf45f50739afb923829b3cc32efb9c8c009613 (patch) | |
tree | 1a9a691cdd3a466d55259aa31fff1bfc0fcd8e7a /lib/dteutils.cpp | |
parent | 08ecf5aae1c7276bb1e78a288cba3a731604758e (diff) |
Working with Baltisot now....
Diffstat (limited to 'lib/dteutils.cpp')
-rw-r--r-- | lib/dteutils.cpp | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/lib/dteutils.cpp b/lib/dteutils.cpp index 4ae8668..6c8dcc4 100644 --- a/lib/dteutils.cpp +++ b/lib/dteutils.cpp @@ -21,13 +21,13 @@ #include <unistd.h> #include <stdlib.h> #include <string.h> -#include "fileutils.h" #include "generic.h" +#include "Handle.h" class thingtree { public: - static void addstring(const char *, long); - static long look(const char *); + static void addstring(const String, long); + static long look(const String); static void destroy(); private: thingtree(); @@ -57,21 +57,21 @@ thingtree::thingtree(char gchar, bool gterm, thingtree * gfather, long gthingent thingtree::thingtree() : thischar(0), terminal(false), father(0), child(0), brother(0) { } -long thingtree::look(const char * s) { - const char * p; +long thingtree::look(const String s) { long currentthing = -1; thingtree * ptr = root; + int i; if (!ptr) { printm(M_ERROR, "Error: thingtree not initialised\n"); exit(-1); } - for (p = s; *p; p++) { + for (i = 0; s[i]; i++) { // printm(M_INFO, "Looking for '%c'\n", *p); for (ptr = ptr->child; ptr; ptr = ptr->brother) { // printm(M_INFO, "Looking in %p: %c\n", ptr, ptr->thischar); - if (ptr->thischar == *p) { + if (ptr->thischar == s[i]) { if (ptr->terminal) { currentthing = ptr->thingentry; } @@ -85,15 +85,15 @@ long thingtree::look(const char * s) { } if (currentthing == -1) { - printm(M_ERROR, "Error, can't find any entry for string '%s'\n", s); + printm(M_ERROR, "Error, can't find any entry for string '" + s + "'\n"); } return currentthing; } -void thingtree::addstring(const char * s, long thingentry) { - const char * p; +void thingtree::addstring(const String s, long thingentry) { thingtree * ptr, * fptr; + int i; if (!root) { root = new thingtree(); @@ -102,21 +102,21 @@ void thingtree::addstring(const char * s, long thingentry) { // printm(M_INFO, "Creating new thingtree entry: %li='%s'\n", thingentry, s); ptr = root; - for (p = s; *p; p++) { + for (i = 0; s[i]; i++) { fptr = ptr; // printm(M_INFO, "Finding entry for '%c'\n", *p); for (ptr = ptr->child; ptr; ptr = ptr->brother) { // printm(M_INFO, "Browsing childs: %p = %c\n", ptr, ptr->thischar); - if (ptr->thischar == *p) + if (ptr->thischar == s[i]) break; } if (!ptr) { // printm(M_INFO, "Creating new branch for %c\n", *p); - ptr = new thingtree(*p, *(p + 1) == 0, fptr, thingentry); + ptr = new thingtree(s[i], s[i + 1] == 0, fptr, thingentry); // printm(M_INFO, "Created branch %p\n", ptr); } else { - if (*(p + 1) == 0) { + if (s[i + 1] == 0) { ptr->terminal = true; ptr->thingentry = thingentry; } @@ -137,7 +137,7 @@ thingtree::~thingtree() { delete child; } -char * things[256]; +String things[256]; char * dte_text; char dte_flags[256 * 256]; @@ -162,12 +162,12 @@ void dte_reset(void) { void build_dte(void) { int i; - unsigned short t, t2; + Uint16 t, t2; unsigned short p = 0; for (i = 0; i < dte_text_size; i++) { - t = *((unsigned short *) (dte_text + i)); - t2 = *((unsigned short *) (dte_text + i + 1)); + t = *((Uint16 *) (dte_text + i)); + t2 = *((Uint16 *) (dte_text + i + 1)); if (t == p) { p = 0; continue; @@ -208,7 +208,7 @@ void push_entry(long entry) { } } -char * read_line(FILE * f, char * b) { +String read_line(Handle * f, String b) { int r, pos = 0; while (!feof(f)) { @@ -261,7 +261,7 @@ void dte_compress() { printm(M_STATUS, "Estimated gain: %li bytes, new file size = %li\n", gain, dte_text_size - gain); } -void read_thingy(FILE * f) { +void read_thingy(Handle * f) { char line[256], * st, * thing; long code; int i; @@ -296,7 +296,7 @@ void read_thingy(FILE * f) { } } -void read_thingy_file(FILE * f) { +void read_thingy_file(Handle * f) { char line[10240], * p, * c, trans[5]; long code; int ptr = 0, i; |