Explorar o código

applied yet another proposal of Manuel

arg@mig29 %!s(int64=19) %!d(string=hai) anos
pai
achega
2210ea7e3b
Modificáronse 1 ficheiros con 2 adicións e 2 borrados
  1. 2 2
      main.c

+ 2 - 2
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);
 			}