Revision: 76545
          http://sourceforge.net/p/brlcad/code/76545
Author:   brlcad
Date:     2020-07-28 05:47:55 +0000 (Tue, 28 Jul 2020)
Log Message:
-----------
needs binary mode for windows

Modified Paths:
--------------
    brlcad/trunk/src/util/lowp.c

Modified: brlcad/trunk/src/util/lowp.c
===================================================================
--- brlcad/trunk/src/util/lowp.c        2020-07-28 05:43:26 UTC (rev 76544)
+++ brlcad/trunk/src/util/lowp.c        2020-07-28 05:47:55 UTC (rev 76545)
@@ -33,6 +33,7 @@
 #include "bu/file.h"
 #include "bu/malloc.h"
 #include "bu/exit.h"
+#include "bu/log.h"
 
 
 #define MAX_LINE 10000         /* Max pixels/line */
@@ -76,8 +77,14 @@
        bu_exit (1, NULL);
     }
 
+    if (isatty(fileno(stdout))) {
+       bu_log("%s: Will not write to a TTY\n", argv[0]);
+       fprintf(stderr, "%s", usage);
+       bu_exit (1, NULL);
+    }
+
     ifname = bu_file_realpath(argv[1], NULL);
-    if ((infd1 = open(ifname, 0)) < 0) {
+    if ((infd1 = open(ifname, O_RDONLY|O_BINARY)) < 0) {
        perror(ifname);
        bu_free(ifname, "ifname alloc from bu_file_realpath");
        bu_exit (3, NULL);
@@ -85,7 +92,7 @@
     bu_free(ifname, "ifname alloc from bu_file_realpath");
 
     ifname = bu_file_realpath(argv[2], NULL);
-    if ((infd2 = open(ifname, 0)) < 0) {
+    if ((infd2 = open(ifname, O_RDONLY|O_BINARY)) < 0) {
        perror(ifname);
        bu_free(ifname, "ifname alloc from bu_file_realpath");
        bu_exit (3, NULL);
@@ -93,7 +100,7 @@
     bu_free(ifname, "ifname alloc from bu_file_realpath");
 
     ifname = bu_file_realpath(argv[3], NULL);
-    if ((infd3 = open(ifname, 0)) < 0) {
+    if ((infd3 = open(ifname, O_RDONLY|O_BINARY)) < 0) {
        perror(ifname);
        bu_free(ifname, "ifname alloc from bu_file_realpath");
        bu_exit (3, NULL);
@@ -116,7 +123,7 @@
 
     /* First and last are black */
     memset(out1, 0, pix_line*3);
-    ret = write(1, out1, pix_line*3);
+    ret = write(fileno(stdout), out1, pix_line*3);
     if (ret < 0)
        perror("write");
 
@@ -149,7 +156,7 @@
                     c[ i-3]    + c[ i  ]*3  + c[ i+3]
                ) / 84;
        }
-       ret = write(1, out1, pix_line*3);
+       ret = write(fileno(stdout), out1, pix_line*3);
        if (ret < 0)
            perror("write");
     }
@@ -156,7 +163,7 @@
 
     /* First and last are black */
     memset(out1, 0, pix_line*3);
-    ret = write(1, out1, pix_line*3);
+    ret = write(fileno(stdout), out1, pix_line*3);
     if (ret < 0)
        perror("write");
 

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to