diff options
-rw-r--r-- | README | 5 | ||||
-rw-r--r-- | badroff.c | 14 | ||||
-rw-r--r-- | phrase-circuit.src | 2 |
3 files changed, 15 insertions, 6 deletions
@@ -43,9 +43,8 @@ mainloop. # Bugs -It mostly segfaults on line overfill (i.e. trying to center oversized -text or unfoldable lines are completely unhandled). Error handling -should probably be used, but that is a nontrivial addition. +Graceful folding of over-long lines isn't implemented. It is just left +as-is. # Return Value @@ -123,12 +123,22 @@ static char* leader(char* txt){ end = repeat; repeat = " . "; } + int startlen = strlen(start); + int endlen = strlen(end); + int rptln = strlen(repeat); + if (startlen + endlen > width) { + fin = malloc(sizeof(char)*(startlen+endlen+2)); + memcpy(fin, start, startlen); + fin[startlen] = ' '; + memcpy(fin+startlen+1, end, endlen+1); + return fin; + } fin = malloc(sizeof(char)*(width+2)); fin[width] = '\n'; fin[width+1] = 0; strcpy(fin, start); - size_t max = width-strlen(end); size_t rptln = strlen(repeat); + size_t max = width-endlen+1; strcpy(fin+max, end); - for (int i=strlen(start); i<width-strlen(end); i++) + for (int i=startlen; i<max; i++) fin[i] = repeat[i % rptln]; return fin; } diff --git a/phrase-circuit.src b/phrase-circuit.src index 020c97f..8e90cf2 100644 --- a/phrase-circuit.src +++ b/phrase-circuit.src @@ -1,4 +1,4 @@ -.W 34 +.W 40 .V 10 .CT Holden Rohrer .V 2 |