diff options
author | Holden Rohrer <hr@hrhr.dev> | 2020-05-25 00:40:13 -0400 |
---|---|---|
committer | Holden Rohrer <hr@hrhr.dev> | 2020-05-25 00:40:13 -0400 |
commit | 4e7a7784a4847805077b97cfd1b09cb0595a2507 (patch) | |
tree | 34fec4df4496c0a8fdef2ccac120baae460ce130 | |
parent | a314652fd3d2c303d518dc1cad04f4ec396fd436 (diff) |
changed strtok to a custom token()
-rw-r--r-- | badroff.c | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -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); |