]> git.xolatile.top Git - emil-bake.git/commitdiff
fixed keeping first newline under strip function
authorEmil <emilwilliams@tuta.io>
Wed, 11 Oct 2023 11:58:58 +0000 (11:58 +0000)
committerEmil <emilwilliams@tuta.io>
Wed, 11 Oct 2023 11:58:58 +0000 (11:58 +0000)
baked.c

diff --git a/baked.c b/baked.c
index 912dc653977eeb650a3cbb90de653797ad7fc2b8..9c1c37946f45cb73c9449f43c4adb1ebdd429d48 100644 (file)
--- a/baked.c
+++ b/baked.c
@@ -292,7 +292,7 @@ strip(char * buf)
   { --i; }
   buf[i] = '\0';
   for (i = 0; isspace(buf[i]); ++i);
-  return i;
+  return i - (buf[i - 1] == '\n');
 }
 
 static int
@@ -341,7 +341,7 @@ main(int argc, char ** argv)
   buf = realloc(buf, expand_size(buf, argc, argv));
   local_assert(buf, 1);
   buf = expand(buf);
-  fprintf(stderr, "Exec: %s\n", buf + strip(buf) - (buf[0] == '\n'));
+  fprintf(stderr, "Exec: %s\n", buf + strip(buf));
   if ((ret = ret ? 0 : run(buf)))
   { fprintf(stderr, "Result: %d\n", ret); }