For "filecopy", it's absurd to do IO char by char.

For "|waitForViewport|", this is left over of the previous
"obey" -> "|run_shell_command|" change.  Also avoid spawning
lot's of threads.

- Qian


diff --git a/src/graph/Gdraws/Gfun.c b/src/graph/Gdraws/Gfun.c
index 292f8b3b..2ec625c3 100644
--- a/src/graph/Gdraws/Gfun.c
+++ b/src/graph/Gdraws/Gfun.c
@@ -52,14 +52,16 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  * Given 2 file pointers, this function copies file ifp to file ofp
  */

+#define BUFFER_SIZE 4096
+
 static void
 filecopy(FILE * ifp, FILE * ofp)
 {
-
-  int c;
-
-  while ((c = getc(ifp)) != EOF)
-    putc(c, ofp);
+  size_t bytesRead;
+  char buffer[BUFFER_SIZE];
+  while ((bytesRead = fread(buffer, 1, BUFFER_SIZE, ifp)) > 0) {
+      fwrite(buffer, 1, bytesRead, ofp);
+  }
 }

 /*
diff --git a/src/interp/util.lisp b/src/interp/util.lisp
index 939ddd19..faced223 100644
--- a/src/interp/util.lisp
+++ b/src/interp/util.lisp
@@ -273,11 +273,11 @@ After this function is called the image is clean and can be saved.
 (defun |waitForViewport| ()
   (progn
    (do ()
-       ((not (zerop (obey
+       ((not (zerop (|run_shell_command|
         (concat
          "ps "
          |$ViewportProcessToWatch|
-         " > /dev/null")))))
+         " > /dev/null && sleep 0.1")))))
        ())
    (|sockSendInt| |$MenuServer| 1)
    (|setIOindex| (- |$IOindex| 3))

--
You received this message because you are subscribed to the Google Groups "FriCAS - 
computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to fricas-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/fricas-devel/33b71d79-3bc2-4149-b0cb-f60df00b7938%40gmail.com.

Reply via email to