aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Guyomarc'h <jean.guyomarch@gmail.com>2016-01-30 22:32:56 +0100
committerJean Guyomarc'h <jean@guyomarch.bzh>2016-09-09 19:58:36 +0200
commitf4e03704b1edf9205d5f42b6a7fbcd5637d22814 (patch)
tree42ddf57ef232b5d22446e228d51dd26614bc19a5
parenttycat: avoid calls to strlen() when possible (diff)
downloadterminology-f4e03704b1edf9205d5f42b6a7fbcd5637d22814.tar.gz
ty*: use STDIN_FILENO
-rw-r--r--src/bin/tyalpha.c2
-rw-r--r--src/bin/tybg.c4
-rw-r--r--src/bin/tycat.c6
-rw-r--r--src/bin/tyls.c2
-rw-r--r--src/bin/tyq.c2
5 files changed, 8 insertions, 8 deletions
diff --git a/src/bin/tyalpha.c b/src/bin/tyalpha.c
index 7b55b7a..9bcaae7 100644
--- a/src/bin/tyalpha.c
+++ b/src/bin/tyalpha.c
@@ -37,7 +37,7 @@ main(int argc, char **argv)
snprintf(tbuf, sizeof(tbuf), "%c}ap%s", 0x1b, argv[i]);
else
snprintf(tbuf, sizeof(tbuf), "%c}at%s", 0x1b, argv[i]);
- if (write(0, tbuf, strlen(tbuf) + 1) != (signed)(strlen(tbuf) + 1)) perror("write");
+ if (write(STDIN_FILENO, tbuf, strlen(tbuf) + 1) != (signed)(strlen(tbuf) + 1)) perror("write");
}
return 0;
}
diff --git a/src/bin/tybg.c b/src/bin/tybg.c
index cc3df43..98924a4 100644
--- a/src/bin/tybg.c
+++ b/src/bin/tybg.c
@@ -29,7 +29,7 @@ main(int argc, char **argv)
{
char tbuf[32];
snprintf(tbuf, sizeof(tbuf), "%c}bt", 0x1b);
- if (write(0, tbuf, strlen(tbuf) + 1) != (signed)(strlen(tbuf) + 1)) perror("write");
+ if (write(STDIN_FILENO, tbuf, strlen(tbuf) + 1) != (signed)(strlen(tbuf) + 1)) perror("write");
return 0;
}
for (i = 1; i < argc; i++)
@@ -48,7 +48,7 @@ main(int argc, char **argv)
snprintf(tbuf, sizeof(tbuf), "%c}bp%s", 0x1b, path);
else
snprintf(tbuf, sizeof(tbuf), "%c}bt%s", 0x1b, path);
- if (write(0, tbuf, strlen(tbuf) + 1) != (signed)(strlen(tbuf) + 1)) perror("write");
+ if (write(STDIN_FILENO, tbuf, strlen(tbuf) + 1) != (signed)(strlen(tbuf) + 1)) perror("write");
}
return 0;
}
diff --git a/src/bin/tycat.c b/src/bin/tycat.c
index 982e072..8de9804 100644
--- a/src/bin/tycat.c
+++ b/src/bin/tycat.c
@@ -97,7 +97,7 @@ prnt(const char *path, int w, int h, int mode)
bytes = snprintf(buf, sizeof(buf), "%c}if#%i;%i;%s", 0x1b, w, h, path);
else
bytes = snprintf(buf, sizeof(buf), "%c}is#%i;%i;%s", 0x1b, w, h, path);
- if (write(0, buf, bytes + 1) < 0) perror("write");
+ if (write(STDIN_FILENO, buf, bytes + 1) < 0) perror("write");
i = 0;
line[i++] = 0x1b;
line[i++] = '}';
@@ -113,7 +113,7 @@ prnt(const char *path, int w, int h, int mode)
line[i++] = '\n';
for (y = 0; y < h; y++)
{
- if (write(0, line, i) < 0) perror("write");
+ if (write(STDIN_FILENO, line, i) < 0) perror("write");
}
free(line);
}
@@ -336,7 +336,7 @@ main(int argc, char **argv)
evas = ecore_evas_get(ee);
echo_off();
bytes = snprintf(buf, sizeof(buf), "%c}qs", 0x1b);
- if (write(0, buf, bytes + 1) < 0) perror("write");
+ if (write(STDIN_FILENO, buf, bytes + 1) < 0) perror("write");
if (scanf("%i;%i;%i;%i", &tw, &th, &cw, &ch) != 4 ||
((tw <= 0) || (th <= 0) || (cw <= 1) || (ch <= 1)))
{
diff --git a/src/bin/tyls.c b/src/bin/tyls.c
index 9bdd305..9b5ef08 100644
--- a/src/bin/tyls.c
+++ b/src/bin/tyls.c
@@ -761,7 +761,7 @@ main(int argc, char **argv)
echo_off();
snprintf(buf, sizeof(buf), "%c}qs", 0x1b);
len = strlen(buf);
- if (write(0, buf, len + 1) < (signed)len + 1) perror("write");
+ if (write(STDIN_FILENO, buf, len + 1) < (signed)len + 1) perror("write");
if ((scanf("%i;%i;%i;%i", &tw, &th, &cw, &ch) != 4)
|| (tw <= 0) || (th <= 0) || (cw <= 1) || (ch <= 1))
{
diff --git a/src/bin/tyq.c b/src/bin/tyq.c
index f78fcc0..52d485d 100644
--- a/src/bin/tyq.c
+++ b/src/bin/tyq.c
@@ -29,7 +29,7 @@ main(int argc, char **argv)
path = argv[i];
if (realpath(path, buf)) path = buf;
snprintf(tbuf, sizeof(tbuf), "%c}pq%s", 0x1b, path);
- if (write(0, tbuf, strlen(tbuf) + 1) != (signed)(strlen(tbuf) + 1)) perror("write");
+ if (write(STDIN_FILENO, tbuf, strlen(tbuf) + 1) != (signed)(strlen(tbuf) + 1)) perror("write");
}
return 0;
}