aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Guyomarc'h <jean.guyomarch@gmail.com>2016-01-30 22:26:26 +0100
committerJean Guyomarc'h <jean@guyomarch.bzh>2016-09-09 19:58:36 +0200
commite97de30ec6aa1141cf7a5810f1fb9e60d81b4f3c (patch)
tree58b5be88d96cff860a67dcc81602cecc76684ae5
parentconfig: change default to only scroll down on keypress (diff)
downloadterminology-e97de30ec6aa1141cf7a5810f1fb9e60d81b4f3c.tar.gz
typop: don't use strlen() and use STDIN_FILENO
-rw-r--r--src/bin/typop.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/bin/typop.c b/src/bin/typop.c
index 569ade5..af4aee6 100644
--- a/src/bin/typop.c
+++ b/src/bin/typop.c
@@ -10,7 +10,7 @@
int
main(int argc, char **argv)
{
- int i;
+ int i, bytes;
ON_NOT_RUNNING_IN_TERMINOLOGY_EXIT_1();
@@ -28,8 +28,9 @@ main(int argc, char **argv)
path = argv[i];
if (realpath(path, buf)) path = buf;
- snprintf(tbuf, sizeof(tbuf), "%c}pn%s", 0x1b, path);
- if (write(0, tbuf, strlen(tbuf) + 1) != (signed)(strlen(tbuf) + 1)) perror("write");
+ bytes = snprintf(tbuf, sizeof(tbuf), "%c}pn%s", 0x1b, path);
+ bytes++;
+ if (write(STDIN_FILENO, tbuf, bytes) != bytes) perror("write");
}
return 0;
}