gnupg (THANKS util/ChangeLog util/iobuf.c)

cvs user wk cvs at cvs.gnupg.org
Mon Dec 6 11:24:26 CET 2004


    Date: Monday, December 6, 2004 @ 11:32:20
  Author: wk
    Path: /cvs/gnupg/gnupg

Modified: THANKS util/ChangeLog util/iobuf.c

(fd_cache_strcmp): New. Use whenever we compare
filenames for the fd_cache. This is needed because the backslash
is an alias for a slash under W32. Reported by Tobias Winkler.


----------------+
 THANKS         |    1 +
 util/ChangeLog |    6 ++++++
 util/iobuf.c   |   26 +++++++++++++++++++++++---
 3 files changed, 30 insertions(+), 3 deletions(-)


Index: gnupg/THANKS
diff -u gnupg/THANKS:1.76 gnupg/THANKS:1.77
--- gnupg/THANKS:1.76	Wed Nov  3 21:03:46 2004
+++ gnupg/THANKS	Mon Dec  6 11:32:20 2004
@@ -197,6 +197,7 @@
 Thomas Roessler 	   roessler at guug.de
 Tim Mooney		   mooney at dogbert.cc.ndsu.nodak.edu
 Timo Schulz                twoaday at freakmail.de
+Tobias Winkler             tobias.winkler at s1998.tu-chemnitz.de
 Todd Vierling              tv at pobox.com
 TOGAWA Satoshi             Satoshi.Togawa at jp.yokogawa.com
 Tom Spindler		   dogcow at home.merit.edu
Index: gnupg/util/ChangeLog
diff -u gnupg/util/ChangeLog:1.168 gnupg/util/ChangeLog:1.169
--- gnupg/util/ChangeLog:1.168	Fri Dec  3 21:23:12 2004
+++ gnupg/util/ChangeLog	Mon Dec  6 11:32:20 2004
@@ -1,3 +1,9 @@
+2004-12-06  Werner Koch  <wk at g10code.com>
+
+	* iobuf.c (fd_cache_strcmp): New. Use whenever we compare
+	filenames for the fd_cache. This is needed because the backslash
+	is an alias for a slash under W32. Reported by Tobias Winkler.
+
 2004-12-03  David Shaw  <dshaw at jabberwocky.com>
 
 	* http.c (send_request): Include the port if non-80 in the Host:
Index: gnupg/util/iobuf.c
diff -u gnupg/util/iobuf.c:1.70 gnupg/util/iobuf.c:1.71
--- gnupg/util/iobuf.c:1.70	Wed Nov  3 21:03:46 2004
+++ gnupg/util/iobuf.c	Mon Dec  6 11:32:20 2004
@@ -130,8 +130,28 @@
 static int underflow(IOBUF a);
 static int translate_file_handle ( int fd, int for_write );
 
+
+
 #ifndef FILE_FILTER_USES_STDIO
 
+/* This is a replacement for strcmp.  Under W32 it does not
+   distinguish between backslash and slash.  */
+static int
+fd_cache_strcmp (const char *a, const char *b)
+{
+#ifdef HAVE_DOSISH_SYSTEM
+  for (; *a && *b; a++, b++)
+    {
+      if (*a != *b && !((*a == '/' && *b == '\\') 
+                        || (*a == '\\' && *b == '/')) )
+        break;
+    }
+  return *(const unsigned *)a - *(const unsigned *)b;
+#else
+  return strcmp (a, b);
+#endif
+}
+
 /*
  * Invalidate (i.e. close) a cached iobuf
  */
@@ -145,7 +165,7 @@
         log_debug ("fd_cache_invalidate (%s)\n", fname);
 
     for (cc=close_cache; cc; cc = cc->next ) {
-        if ( cc->fp != INVALID_FP && !strcmp (cc->fname, fname) ) {
+        if ( cc->fp != INVALID_FP && !fd_cache_strcmp (cc->fname, fname) ) {
             if( DBG_IOBUF )
                 log_debug ("                did (%s)\n", cc->fname);
 #ifdef HAVE_DOSISH_SYSTEM
@@ -253,7 +273,7 @@
     }
     /* try to reuse a slot */
     for (cc=close_cache; cc; cc = cc->next ) {
-        if ( cc->fp == INVALID_FP && !strcmp (cc->fname, fname) ) {
+        if ( cc->fp == INVALID_FP && !fd_cache_strcmp (cc->fname, fname) ) {
             cc->fp = fp;
             if( DBG_IOBUF )
                 log_debug ("fd_cache_close (%s) used existing slot\n", fname);
@@ -280,7 +300,7 @@
 
     assert (fname);
     for (cc=close_cache; cc; cc = cc->next ) {
-        if ( cc->fp != INVALID_FP && !strcmp (cc->fname, fname) ) {
+        if ( cc->fp != INVALID_FP && !fd_cache_strcmp (cc->fname, fname) ) {
             FILEP_OR_FD fp = cc->fp;
             cc->fp = INVALID_FP;
             if( DBG_IOBUF )




More information about the Gnupg-commits mailing list