]> granicus.if.org Git - graphviz/commitdiff
Try to fix bug 2256. Remove file descriptor polling from gvdevice_xlib.c
authorEmden Gansner <erg@research.att.com>
Wed, 13 Feb 2013 19:40:05 +0000 (14:40 -0500)
committerEmden Gansner <erg@research.att.com>
Wed, 13 Feb 2013 19:40:05 +0000 (14:40 -0500)
and have cgraph use FILE* for reading.

lib/cgraph/io.c
plugin/xlib/gvdevice_xlib.c

index efaef6b2cebcc80af736adf5ff03a8588a819fea..cb44e6c7f815b0bf28b92c563a3f056ad90204dd 100644 (file)
@@ -68,7 +68,11 @@ static int iofreadiconv(void *chan, char *buf, int bufsize)
 
 static int iofread(void *chan, char *buf, int bufsize)
 {
-    return read(fileno((FILE *) chan), buf, bufsize);
+    if (fgets(buf, bufsize, (FILE*)chan))
+       return strlen(buf);
+    else
+       return 0;
+    /* return read(fileno((FILE *) chan), buf, bufsize); */
     /* return fread(buf, 1, bufsize, (FILE*)chan); */
 }
 
index 417f3e128a615fb3f65bae58a66d4cc7f7118549..a73e648cd3dfe4f770fe171d84dba8751255b209 100644 (file)
 #include <fcntl.h>
 #endif
 
+#if 0
 #ifdef WITH_CGRAPH
 #include <poll.h>
 #endif
+#endif
 
 #include "gvplugin_device.h"
 
@@ -380,19 +382,8 @@ static int handle_stdin_events(GVJ_t *job, int stdin_fd)
 {
     int rc=0;
 
-#ifndef WITH_CGRAPH
     if (feof(stdin))
        return -1;
-#else
-    struct pollfd ufds[2];
-       int r;
-    ufds[0].fd = stdin_fd;
-    ufds[0].events = POLLIN;
-       ufds[0].revents = 0;
-    r = poll(ufds,1,0);
-       if (ufds[0].revents & POLLIN) return -1;
-       /* Beware of bugs in the above code; I have only proved it correct, not tried it. */
-#endif
     (job->callbacks->read)(job, job->input_filename, job->layout_type);
     
     rc++;