From 4e7a7784a4847805077b97cfd1b09cb0595a2507 Mon Sep 17 00:00:00 2001 From: Holden Rohrer Date: Mon, 25 May 2020 00:40:13 -0400 Subject: changed strtok to a custom token() --- badroff.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/badroff.c b/badroff.c index 7bdb3e7..e9346c3 100644 --- a/badroff.c +++ b/badroff.c @@ -90,11 +90,15 @@ char* fillline(char* txt){ memset(str, txt[0], width); return str; } +char* token(char* txt, char c) { + char* end = strchr(txt, c); + *end = 0; + return end+1; +} char* leader(char* txt){ - char* cnxt; - char* start = strtok_r(txt, "|", &cnxt); - char* repeat = strtok_r(NULL, "|", &cnxt); - char* end = strtok_r(NULL, "|", &cnxt); + char* start = txt; + char* repeat = token(start, '|'); + char* end = token(repeat, '|'); char* fin = malloc(sizeof(char)*(width+2)); fin[width] = '\n'; fin[width+1] = 0; strcpy(fin, start); -- cgit