From cf90b09e5c0b0d5a91dd2d789842369b44b8b900 Mon Sep 17 00:00:00 2001 From: Curtis McEnroe Date: Sun, 10 Feb 2019 23:51:13 -0500 Subject: Avoid excessive tags in ttpre --- bin/ttpre.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/bin/ttpre.c b/bin/ttpre.c index 52e30f54..79006ca9 100644 --- a/bin/ttpre.c +++ b/bin/ttpre.c @@ -19,27 +19,36 @@ #include #include -static void put(const char *tag, wchar_t ch) { - if (tag) printf("<%s>", tag); +static void put(wchar_t ch) { switch (ch) { break; case L'&': printf("&"); break; case L'<': printf("<"); break; case L'>': printf(">"); break; default: printf("%lc", ch); } - if (tag) printf("", tag); +} + +static void tag(const char *open) { + static const char *close = NULL; + if (close == open) return; + if (close) printf("", close); + if (open) printf("<%s>", open); + close = open; } static void push(wchar_t ch) { static wchar_t q[3]; if (q[1] == L'\b' && q[0] == L'_') { - put("i", q[2]); + tag("i"); + put(q[2]); q[0] = q[1] = q[2] = 0; } else if (q[1] == L'\b' && q[0] == q[2]) { - put("b", q[2]); + tag("b"); + put(q[2]); q[0] = q[1] = q[2] = 0; } else if (q[0]) { - put(NULL, q[0]); + tag(NULL); + put(q[0]); } q[0] = q[1]; q[1] = q[2]; -- cgit 1.4.1 xt?id=9c03cb50c386189dcbbc438a09c618aa7fd4555c&follow=1'>commit diff homepage
Commit message (Collapse)Author
2020-11-22Day 10, part 2June McEnroe
2020-11-22Day 10June McEnroe
2020-11-22Day 9, part 2June McEnroe
2020-11-22Day 9June McEnroe
I was really sick at the start of the week, okay?
2020-11-22Day 8, part 2June McEnroe
2020-11-22Day 8June McEnroe
2020-11-22Day 7, part 2June McEnroe
I don't even know what this is. Don't look at it.
2020-11-22Day 7June McEnroe
2020-11-22Day 6, part 2June McEnroe
2020-11-22Day 6June McEnroe
2020-11-22Day 5, part 2June McEnroe
2020-11-22Day 5June McEnroe
2020-11-22Day 4, part 2June McEnroe
That ugly sort map though.
2020-11-22Day 4June McEnroe
2020-11-22Day 3, part 2June McEnroe
I am super surprised that worked on the first try.
2020-11-22Day 3, clean upJune McEnroe
2020-11-22Day 3June McEnroe
This is fucking awful and I'm angry.
2020-11-22Day 2, part 2June McEnroe
2020-11-22Day 2June McEnroe
2020-11-22Day 1, part 2June McEnroe
2020-11-22Day 1June McEnroe
2020-11-22Move to 2016 directoryJune McEnroe