From 23a84e9144fbff6ddba6810ffb215abaaf2459d4 Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Thu, 24 Aug 2017 22:05:45 -0400 Subject: [PATCH] removed hl-cpp.c source --- Makefile | 5 ++- hl-cpp.c | 95 -------------------------------------------------------- 2 files changed, 2 insertions(+), 98 deletions(-) delete mode 100644 hl-cpp.c diff --git a/Makefile b/Makefile index cee8450..f8a8281 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ INCS = -Iinc/ -BINS = tide tfetch tctl pick xcpd hl-cpp +BINS = tide tfetch tctl pick xcpd MAN1 = docs/tide.1 docs/pick.1 docs/picktag.1 docs/pickfile.1 LIBEDIT_OBJS = \ @@ -36,7 +36,7 @@ clean: find . \( -name '*.gcno' -o -name '*.gcda' \) -delete $(RM) $(BINS) $(TEST_BINS) -install: +install: mkdir -p $(PREFIX)/bin cp -f tcmd $(PREFIX)/bin cp -f tfetch $(PREFIX)/bin @@ -68,7 +68,6 @@ libedit.a: $(LIBEDIT_OBJS) tide: tide.o libedit.a pick: pick.o libedit.a xcpd: xcpd.o libedit.a -hl-cpp: hl-cpp.o libedit.a tfetch: tfetch.o tctl: tctl.o libedit.a tests/libedit: tests/libedit.o tests/lib/buf.o tests/lib/utf8.o libedit.a diff --git a/hl-cpp.c b/hl-cpp.c deleted file mode 100644 index 365ce51..0000000 --- a/hl-cpp.c +++ /dev/null @@ -1,95 +0,0 @@ -#include -#include -#include -#include -#include - -Buf GapBuffer; -char RawBuffer[32768]; -char* CurrBeg = RawBuffer; -char* CurrEnd = RawBuffer; -size_t Pos; -size_t End; - -int fetch_byte(void) { - if (CurrBeg >= CurrEnd) { - CurrBeg = CurrEnd = RawBuffer; - long nread = read(STDIN_FILENO, RawBuffer, sizeof(RawBuffer)); - if (nread <= 0) exit( -nread ); - CurrEnd += nread; - } - return *(CurrBeg++); -} - -void recv_chunk(void) { - int chunksz = 0, bufpos = 0, byte; - while (!bufpos) { - /* read the size of the chunk first */ - while (isdigit(byte = fetch_byte())) - chunksz = (chunksz * 10) + (byte - '0'); - if (!chunksz) continue; - /* now read out the actual chunk and stuff it in the gap buffer */ - for (; chunksz; chunksz--, bufpos++) { - size_t len = 0; - Rune r; - while (!utf8decode(&r, &len, fetch_byte())); - buf_insert(&GapBuffer, false, bufpos, r); - } - } - Pos = 0; - End = buf_end(&GapBuffer); -} - -extern void init(void); -extern void scan(void); - -int main(int argc, char** argv) { - init(); - while (true) { - buf_init(&GapBuffer, NULL); - recv_chunk(); - scan(); - printf("0,0,0\n"); - fflush(stdout); - } - return 0; -} - -/******************************************************************************/ - -#include - -static int isalnum_(int c) { return (isalnum(c) || c == '_'); } -static int isalpha_(int c) { return (isalpha(c) || c == '_'); } - -static int peekc(int i) { - if (Pos >= End) return '\n'; - Rune r = buf_get(&GapBuffer, Pos+i); - return (r == RUNE_CRLF ? '\n' : (int)r); -} - -static int takec(void) { - int c = peekc(0); - Pos++; - return c; -} - -/******************************************************************************/ - -void init(void) { - -} - -void scan(void) { - while (Pos < End) { - if (isalpha_(peekc(0))) { - size_t beg = Pos, end = Pos; - while (isalnum_(takec())) - end++; - printf("%d,%d,%d\n", (int)beg, (int)end, 0); - } else { - Pos++; - } - } -} - -- 2.49.0