typop: don't use strlen() and use STDIN_FILENO

This commit is contained in:
Jean Guyomarc'h 2016-01-30 22:26:26 +01:00 committed by Jean Guyomarc'h
parent 36a7166b7a
commit e97de30ec6
1 changed files with 4 additions and 3 deletions

View File

@ -10,7 +10,7 @@
int int
main(int argc, char **argv) main(int argc, char **argv)
{ {
int i; int i, bytes;
ON_NOT_RUNNING_IN_TERMINOLOGY_EXIT_1(); ON_NOT_RUNNING_IN_TERMINOLOGY_EXIT_1();
@ -28,8 +28,9 @@ main(int argc, char **argv)
path = argv[i]; path = argv[i];
if (realpath(path, buf)) path = buf; if (realpath(path, buf)) path = buf;
snprintf(tbuf, sizeof(tbuf), "%c}pn%s", 0x1b, path); bytes = snprintf(tbuf, sizeof(tbuf), "%c}pn%s", 0x1b, path);
if (write(0, tbuf, strlen(tbuf) + 1) != (signed)(strlen(tbuf) + 1)) perror("write"); bytes++;
if (write(STDIN_FILENO, tbuf, bytes) != bytes) perror("write");
} }
return 0; return 0;
} }