about summary refs log tree commit diff stats
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main.c')
-rw-r--r--main.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/main.c b/main.c
index f196df7..934bea4 100644
--- a/main.c
+++ b/main.c
@@ -284,8 +284,8 @@ main(int argc, char *argv[]) {
 				readin = False;
 				break;
 			default:
-				stext[r - (stext[r - 1] == '\n' ? 1 : 0)] = '\0';
-				for(p = stext + strlen(stext) - 1; p > stext && *p != '\n'; --p);
+				for(stext[r] = '\0', p = stext + strlen(stext) - 1; p >= stext && *p == '\n'; *p-- = '\0');
+				for(p = stext + strlen(stext) - 1; p >= stext && *p != '\n'; --p);
 				if(p > stext)
 					strncpy(stext, p + 1, sizeof stext);
 			}
f='#n100'>100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115