From eef18664f9a161816a954ce032f44cae4e90ed81 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Sat, 29 Nov 2025 14:46:55 -0500 Subject: Stop defining u8 and u16 all over the place. --- src/Makefile | 4 ++-- src/alf.c | 16 +++++++++++----- src/sanity.c | 5 +---- src/u816.h | 4 ++++ src/unalf.h | 6 +----- 5 files changed, 19 insertions(+), 16 deletions(-) create mode 100644 src/u816.h diff --git a/src/Makefile b/src/Makefile index 716cf47..0d6d070 100644 --- a/src/Makefile +++ b/src/Makefile @@ -76,7 +76,7 @@ usage.c: mkusage.pl unalf.rst alfusage.c: mkusage.pl alf.rst perl mkusage.pl alf.rst > alfusage.c -unalf.o: unalf.c unalf.h ../f65/f65.h +unalf.o: unalf.c unalf.h ../f65/f65.h u816.h glob.o: glob.c unalf.h @@ -88,7 +88,7 @@ listalf.o: listalf.c addrs.h unalf.h ../f65/f65.h extract.o: extract.c addrs.h unalf.h ../f65/f65.h -sanity.o: sanity.c sanity.h +sanity.o: sanity.c sanity.h u816.h ver.rst: echo '.. |version| replace:: $(VERSION)' > ver.rst diff --git a/src/alf.c b/src/alf.c index a366a5c..1d634ab 100644 --- a/src/alf.c +++ b/src/alf.c @@ -7,14 +7,10 @@ #include #include +#include "u816.h" #include "sanity.h" #include "self.h" -#ifndef u8 -#define u8 unsigned char -#define u16 unsigned short -#endif - #define INITIAL_BITS 9 #define MAX_BITS 12 #define MAX_TOKENS (1 << MAX_BITS) @@ -35,6 +31,7 @@ int opt_zerotime = 0; int opt_alftime = 0; int opt_gmtime = 0; int opt_txtconv = 0; +int opt_verbose = 0; struct stat in_file_stat; @@ -260,6 +257,7 @@ int match_token(int pos) { } void make_token(int start, int end) { + int i; /* if the token table is full, reset it. basically start over like we would with a new file. */ if(curr_token == max_token) { @@ -276,6 +274,13 @@ void make_token(int start, int end) { tokentab[curr_token].start = &input_buf[start]; tokentab[curr_token].length = end - start + 1; curr_token++; + + if(opt_verbose) { + printf("%d -> %d (%d) = ", start, end, end - start + 1); + for(i = start; i < end; i++) + putchar(input_buf[i]); + putchar('\n'); + } } void crunch(void) { @@ -290,6 +295,7 @@ void crunch(void) { store_token(TOK_RESET); while(in_pos < input_len) { + if(opt_verbose) printf("in_pos==%d\n", in_pos); token = match_token(in_pos); store_token(token); new_pos = in_pos + tokentab[token].length; diff --git a/src/sanity.c b/src/sanity.c index ccbcae1..5b5c787 100644 --- a/src/sanity.c +++ b/src/sanity.c @@ -1,9 +1,6 @@ #include #include - -#ifndef u8 -#define u8 unsigned char -#endif +#include "u816.h" extern const char *self; diff --git a/src/u816.h b/src/u816.h new file mode 100644 index 0000000..829d8f5 --- /dev/null +++ b/src/u816.h @@ -0,0 +1,4 @@ +#ifndef u8 +#define u8 unsigned char +#define u16 unsigned short +#endif diff --git a/src/unalf.h b/src/unalf.h index 2d0072e..33a7760 100644 --- a/src/unalf.h +++ b/src/unalf.h @@ -7,17 +7,13 @@ #include #include #include "self.h" +#include "u816.h" #ifndef VERSION #define VERSION "???" #warning "VERSION not defined, defaulting to \"???\"" #endif -#ifndef u8 -#define u8 unsigned char -#define u16 unsigned short -#endif - /* asmcode.c (converted from asm) */ void uncrunch_file(void); void setup_io_bufs(void); -- cgit v1.2.3