aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHolden Rohrer <hr@hrhr.dev>2020-05-25 00:40:13 -0400
committerHolden Rohrer <hr@hrhr.dev>2020-05-25 00:40:13 -0400
commit4e7a7784a4847805077b97cfd1b09cb0595a2507 (patch)
tree34fec4df4496c0a8fdef2ccac120baae460ce130
parenta314652fd3d2c303d518dc1cad04f4ec396fd436 (diff)
changed strtok to a custom token()
-rw-r--r--badroff.c12
1 files 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);