aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2025-11-29 14:46:55 -0500
committerB. Watson <urchlay@slackware.uk>2025-11-29 14:46:55 -0500
commiteef18664f9a161816a954ce032f44cae4e90ed81 (patch)
treece1d4bd8c00c7e946b111bc96c3509961b11278e
parent671fd9c6e7806229e06424f12b27fa2ad28afa05 (diff)
downloadalftools-eef18664f9a161816a954ce032f44cae4e90ed81.tar.gz
Stop defining u8 and u16 all over the place.
-rw-r--r--src/Makefile4
-rw-r--r--src/alf.c16
-rw-r--r--src/sanity.c5
-rw-r--r--src/u816.h4
-rw-r--r--src/unalf.h6
5 files changed, 19 insertions, 16 deletions
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 <sys/stat.h>
#include <time.h>
+#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 <stdio.h>
#include <string.h>
-
-#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 <sys/stat.h>
#include <f65.h>
#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);