From 5bc5baf304939ff868de243c6be53a35d121e03c Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Mon, 6 Dec 2004 10:32:20 +0000 Subject: [PATCH] (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(-) diff --git a/THANKS b/THANKS index e809b4de4..5713ffe84 100644 --- a/THANKS +++ b/THANKS @@ -197,6 +197,7 @@ Thijmen Klok thijmen@xs4all.nl Thomas Roessler roessler@guug.de Tim Mooney mooney@dogbert.cc.ndsu.nodak.edu Timo Schulz twoaday@freakmail.de +Tobias Winkler tobias.winkler@s1998.tu-chemnitz.de Todd Vierling tv@pobox.com TOGAWA Satoshi Satoshi.Togawa@jp.yokogawa.com Tom Spindler dogcow@home.merit.edu 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 + + * 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 * 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 )