tyalpha: don't call strlen()

This commit is contained in:
Jean Guyomarc'h 2016-01-30 22:34:43 +01:00 committed by Jean Guyomarc'h
parent f4e03704b1
commit a6d698a550
1 changed files with 5 additions and 3 deletions

View File

@ -11,6 +11,7 @@ int
main(int argc, char **argv) main(int argc, char **argv)
{ {
int i, perm = 0; int i, perm = 0;
int bytes;
ON_NOT_RUNNING_IN_TERMINOLOGY_EXIT_1(); ON_NOT_RUNNING_IN_TERMINOLOGY_EXIT_1();
@ -34,10 +35,11 @@ main(int argc, char **argv)
if (i >= argc) break; if (i >= argc) break;
} }
if (perm) if (perm)
snprintf(tbuf, sizeof(tbuf), "%c}ap%s", 0x1b, argv[i]); bytes = snprintf(tbuf, sizeof(tbuf), "%c}ap%s", 0x1b, argv[i]);
else else
snprintf(tbuf, sizeof(tbuf), "%c}at%s", 0x1b, argv[i]); bytes = 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++;
if (write(STDIN_FILENO, tbuf, bytes) != bytes) perror("write");
} }
return 0; return 0;
} }