billiob pushed a commit to branch master.

http://git.enlightenment.org/apps/terminology.git/commit/?id=a925de13dc41eda673f0704f9b823089b8f169c3

commit a925de13dc41eda673f0704f9b823089b8f169c3
Author: Boris Faure <bill...@gmail.com>
Date:   Sat Nov 7 19:09:12 2015 +0100

    tyfuzz: read from stdin but write to /dev/null
---
 src/bin/termpty.c |  2 +-
 src/bin/termpty.h |  3 +++
 src/bin/tyfuzz.c  | 28 +++++++++++++++++++++-------
 3 files changed, 25 insertions(+), 8 deletions(-)

diff --git a/src/bin/termpty.c b/src/bin/termpty.c
index ae0046e..6535bcb 100644
--- a/src/bin/termpty.c
+++ b/src/bin/termpty.c
@@ -909,7 +909,7 @@ termpty_write(Termpty *ty, const char *input, int len)
    int fd = ty->fd;
 
 #ifdef ENABLE_FUZZING
-   fd = STDOUT_FILENO;
+   fd = ty->fd_dev_null;
 #endif
    if (fd < 0) return;
    if (write(fd, input, len) < 0)
diff --git a/src/bin/termpty.h b/src/bin/termpty.h
index 18a42d5..e841245 100644
--- a/src/bin/termpty.h
+++ b/src/bin/termpty.h
@@ -102,6 +102,9 @@ struct _Termpty
    } backlog_beacon;
    int w, h;
    int fd, slavefd;
+#ifdef ENABLE_FUZZING
+   int fd_dev_null;
+#endif
    struct {
       int curid;
       Eina_Hash *blocks;
diff --git a/src/bin/tyfuzz.c b/src/bin/tyfuzz.c
index 0742f7f..29c57db 100644
--- a/src/bin/tyfuzz.c
+++ b/src/bin/tyfuzz.c
@@ -3,12 +3,15 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <string.h>
-#include "string.h"
+#include <sys/stat.h>
+#include <fcntl.h>
 #include "private.h"
 #include <Elementary.h>
 #include "termpty.h"
+#include "termptyops.h"
 #include <assert.h>
 
+
 /* {{{ stub */
 int _log_domain = -1;
 static Config *_config = NULL;
@@ -20,7 +23,7 @@ theme_path_get(void)
 }
 
 void
-main_config_sync(const Config *config)
+main_config_sync(const Config *config EINA_UNUSED)
 {
 }
 
@@ -58,8 +61,9 @@ termio_textgrid_get(Evas_Object *obj EINA_UNUSED)
 
 
 static void
-_init_termpty(Termpty *ty)
+_termpty_init(Termpty *ty)
 {
+   memset(ty, '\0', sizeof(*ty));
    ty->w = 80;
    ty->h = 25;
    ty->backsize = 50;
@@ -70,15 +74,23 @@ _init_termpty(Termpty *ty)
    assert(ty->screen2);
    ty->circular_offset = 0;
    ty->fd = STDIN_FILENO;
+   ty->fd_dev_null = open("/dev/null", O_WRONLY|O_APPEND);
+   assert(ty->fd_dev_null >= 0);
+}
+
+static void
+_termpty_shutdown(Termpty *ty)
+{
+   close(ty->fd_dev_null);
 }
 
 int
-main(int argc, char **argv)
+main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
 {
-   Termpty ty = {};
+   Termpty ty;
    char buf[4097];
    Eina_Unicode codepoint[4097];
-   int len, i, j, k, reads;
+   int len, i, j, k;
 
    eina_init();
 
@@ -86,7 +98,7 @@ main(int argc, char **argv)
 
    _config = config_new();
 
-   _init_termpty(&ty);
+   _termpty_init(&ty);
 
    do
      {
@@ -155,6 +167,8 @@ main(int argc, char **argv)
      }
    while (1);
 
+   _termpty_shutdown(&ty);
+
    eina_shutdown();
    free(_config);
 

-- 


Reply via email to