aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Guyomarc'h <jean.guyomarch@gmail.com>2016-01-30 22:34:43 +0100
committerJean Guyomarc'h <jean@guyomarch.bzh>2016-09-09 19:58:36 +0200
commita6d698a550d28d83ae69d6b54dd91955708dfcb2 (patch)
treefdb952aa690a12c82ac97ded0d7d351f1d5d011a
parentty*: use STDIN_FILENO (diff)
downloadterminology-a6d698a550d28d83ae69d6b54dd91955708dfcb2.tar.gz
tyalpha: don't call strlen()
-rw-r--r--src/bin/tyalpha.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/bin/tyalpha.c b/src/bin/tyalpha.c
index 9bcaae7..7c9a48a 100644
--- a/src/bin/tyalpha.c
+++ b/src/bin/tyalpha.c
@@ -11,6 +11,7 @@ int
main(int argc, char **argv)
{
int i, perm = 0;
+ int bytes;
ON_NOT_RUNNING_IN_TERMINOLOGY_EXIT_1();
@@ -34,10 +35,11 @@ main(int argc, char **argv)
if (i >= argc) break;
}
if (perm)
- snprintf(tbuf, sizeof(tbuf), "%c}ap%s", 0x1b, argv[i]);
+ bytes = snprintf(tbuf, sizeof(tbuf), "%c}ap%s", 0x1b, argv[i]);
else
- snprintf(tbuf, sizeof(tbuf), "%c}at%s", 0x1b, argv[i]);
- if (write(STDIN_FILENO, tbuf, strlen(tbuf) + 1) != (signed)(strlen(tbuf) + 1)) perror("write");
+ bytes = snprintf(tbuf, sizeof(tbuf), "%c}at%s", 0x1b, argv[i]);
+ bytes++;
+ if (write(STDIN_FILENO, tbuf, bytes) != bytes) perror("write");
}
return 0;
}