[or-cvs] Clean windows a little

Nick Mathewson nickm at seul.org
Tue Nov 9 19:30:52 UTC 2004


Update of /home/or/cvsroot/src/common
In directory moria.mit.edu:/tmp/cvs-serv26784/src/common

Modified Files:
	compat.c util.c 
Log Message:
Clean windows a little

Index: compat.c
===================================================================
RCS file: /home/or/cvsroot/src/common/compat.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- compat.c	9 Nov 2004 01:24:10 -0000	1.6
+++ compat.c	9 Nov 2004 19:30:50 -0000	1.7
@@ -11,10 +11,7 @@
 #include "compat.h"
 
 #ifdef MS_WINDOWS
-#include <io.h>
 #include <process.h>
-#include <direct.h>
-#include <windows.h>
 #endif
 #ifdef HAVE_UNAME
 #include <sys/utsname.h>

Index: util.c
===================================================================
RCS file: /home/or/cvsroot/src/common/util.c,v
retrieving revision 1.174
retrieving revision 1.175
diff -u -d -r1.174 -r1.175
--- util.c	9 Nov 2004 19:13:08 -0000	1.174
+++ util.c	9 Nov 2004 19:30:50 -0000	1.175
@@ -18,12 +18,9 @@
 #include "log.h"
 #include "crypto.h"
 
-/* XXXX probably some of these are unneeded. find out which. */
 #ifdef MS_WINDOWS
 #include <io.h>
-#include <process.h>
 #include <direct.h>
-#include <windows.h>
 #endif
 
 #ifdef HAVE_CTYPE_H
@@ -90,6 +87,9 @@
 #ifndef O_BINARY
 #define O_BINARY 0
 #endif
+#ifndef O_TEXT
+#define O_TEXT 0
+#endif
 
 /* =====
  * Memory management
@@ -809,12 +809,12 @@
     log(LOG_WARN, "Filename %s.tmp too long (>1024 chars)", fname);
     return -1;
   }
-  if ((fd = open(tempname, O_WRONLY|O_CREAT|O_TRUNC|(bin?O_BINARY:0), 0600))
+  if ((fd = open(tempname, O_WRONLY|O_CREAT|O_TRUNC|(bin?O_BINARY:O_TEXT), 0600))
       < 0) {
     log(LOG_WARN, "Couldn't open %s for writing: %s", tempname,
         strerror(errno));
     return -1;
-  }
+  }
   result = write_all(fd, str, len, 0);
   if(result < 0 || (size_t)result != len) {
     log(LOG_WARN, "Error writing to %s: %s", tempname, strerror(errno));
@@ -848,7 +848,7 @@
     return NULL;
   }
 
-  fd = open(filename,O_RDONLY|(bin?O_BINARY:0),0);
+  fd = open(filename,O_RDONLY|(bin?O_BINARY:O_TEXT),0);
   if (fd<0) {
     log_fn(LOG_WARN,"Could not open %s.",filename);
     return NULL;
@@ -877,11 +877,9 @@
   }
 #ifdef MS_WINDOWS
   if (!bin && strchr(string, '\r')) {
-    if (strchr(string, '\r')) {
-      log_fn(LOG_DEBUG, "We didn't convert CRLF to LF as well as we hoped when reading %s. Coping.",
-             filename);  
-      tor_strstrip(string, "\r");
-    }
+    log_fn(LOG_DEBUG, "We didn't convert CRLF to LF as well as we hoped when reading %s. Coping.",
+           filename);  
+    tor_strstrip(string, "\r");
   }
 #endif
   close(fd);



More information about the tor-commits mailing list