aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2004-12-06 10:32:20 +0000
committerWerner Koch <[email protected]>2004-12-06 10:32:20 +0000
commit5bc5baf304939ff868de243c6be53a35d121e03c (patch)
tree4b2ac42c33cef0b84282ab77453d9688c1a94f1c /util
parent* http.c (send_request): Include the port if non-80 in the Host: header. (diff)
downloadgnupg-5bc5baf304939ff868de243c6be53a35d121e03c.tar.gz
gnupg-5bc5baf304939ff868de243c6be53a35d121e03c.zip
(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.
Diffstat (limited to 'util')
-rw-r--r--util/ChangeLog6
-rw-r--r--util/iobuf.c26
2 files changed, 29 insertions, 3 deletions
diff --git a/util/ChangeLog b/util/ChangeLog
index 483723754..51e99173f 100644
--- a/util/ChangeLog
+++ b/util/ChangeLog
@@ -1,3 +1,9 @@
+2004-12-06 Werner Koch <[email protected]>
+
+ * 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 <[email protected]>
* http.c (send_request): Include the port if non-80 in the Host:
diff --git a/util/iobuf.c b/util/iobuf.c
index 0731f3d00..5f0e84383 100644
--- a/util/iobuf.c
+++ b/util/iobuf.c
@@ -130,8 +130,28 @@ static int special_names_enabled;
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 @@ fd_cache_invalidate (const char *fname)
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 @@ fd_cache_close (const char *fname, FILEP_OR_FD fp)
}
/* 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 @@ fd_cache_open (const char *fname, const char *mode)
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 )