From cb36f073844d5ebbd05ca30507acc17222ec8357 Mon Sep 17 00:00:00 2001 From: Aleteoryx Date: Thu, 28 Aug 2025 20:34:53 -0400 Subject: [PATCH] cleanup debug statements --- .gitignore | 1 + README.md | 1 + gloss.py | 13 ++++--------- markup.c | 8 +++++--- 4 files changed, 11 insertions(+), 12 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..534afa61597090d20ee208113498936dbeedf7e9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/markup diff --git a/README.md b/README.md index e1b59890a756d0f30935efc2aa148e689ed6a105..8b6b5207b751416e1d0898a2c6b1ebafafca6b6a 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ it is designed to maximize nonlinear browsing. *** the central gloss.py script translates each .gls file in its input directory to a .html in its output. +to run it, you will need a python runtime and a C compiler. make sure to download the entire repo. .gls files are composed of a names section, a set of blocks, and an optional "see also" section. diff --git a/gloss.py b/gloss.py index 5a17559c4fec193086a1f71f5762cb7b217802bb..bf534cb39a50a6e96bc31493152c7d53bb9e97af 100755 --- a/gloss.py +++ b/gloss.py @@ -105,7 +105,7 @@ def first_pass(slug, fp): elif block_type == 'quote': if line.startswith('>'): line = line[1:].strip() - block_text += "\n" + line + block_text += ' ' + line elif block_type == 'para': block_text += ' ' + line @@ -124,25 +124,21 @@ class Markup: if stat(self.cfile).st_mtime > stat(self.bfile).st_mtime: print("recompiling markup subsystem...") - runcmd(['cc', self.cfile, '-DDEBUG', '-o', self.bfile, '-Wall'], check=True) + runcmd(['cc', self.cfile, '-o', self.bfile, '-Wall'], check=True) print("recompiled!") self.proc = Popen([self.bfile, 'convert'], stdin=PIPE, stdout=PIPE, text=True) def process(self, text): - print(f'{text=}') self.proc.stdin.write(text+"\n") self.proc.stdin.flush() segments = [] - while (line := self.proc.stdout.readline()) != '': + while (line := self.proc.stdout.readline()) not in ('NEXT\n', ''): ty = line[0:4] - if ty == 'NEXT': - break length = int(line[5:9]) ltext = line[12:12+length] - print(f'{ltext=}') if ty == 'HTML': segments.append((ltext,)) @@ -152,8 +148,7 @@ class Markup: segments.append(ltext) else: print(f'read in unknown type "{ty}" from markup subprocess', file=stderr) - - print(segments) + return segments diff --git a/markup.c b/markup.c index 5501850e8255b133e06f0e92ac348a57812e2439..1d5765780b35398ddf2cc23f73f6c08e2fa06d46 100644 --- a/markup.c +++ b/markup.c @@ -74,7 +74,8 @@ new_segment(int type, size_t length, const char *text) new->text = text; new->next = NULL; - fprintf(stderr, "new_segment @ %p: %d / %zu / %.*s\n", new, type, length, (int)length, text); + if (DEBUG) + fprintf(stderr, "new_segment @ %p: %d / %zu / %.*s\n", new, type, length, (int)length, text); return new; } @@ -152,7 +153,7 @@ segmentize(size_t length, const char *source) { // p is the start of the most recent text segment const char *p = source, *i, *newi, *end = source + length; - int in_italic = 0, in_escape = 0; + int in_italic = 0; struct segment *head = new_segment(SEG_HEAD, 0, NULL), *ret; struct segment *tail = head; struct segment *italic_head, *italic_tail; @@ -286,7 +287,8 @@ convert() struct segment *seg; while((s = nextline()) != NULL){ - fprintf(stderr, "processing line: %s\n", s); + if(DEBUG) + fprintf(stderr, "processing line: %s\n", s); length = strlen(s); seg = segmentize(length, s); for(; seg != NULL; seg = seg->next)