Date: Fri, 22 Jun 2001 16:20:06 -0500 (CDT)
From: Gilles Detillieux <grdetil@scrc.umanitoba.ca>
To: m.pohl@gmx.de
Cc: htdig-dev@lists.sourceforge.net
Subject: Re: [htdig-dev] 3 small patches for htdig-3.2.0b4

Hi, Marc.  Thank you, thank you, and thank you for your 3 patches.
A couple more thank yous as well for the 3rd patch, because 1) it also
points out a bug fix for the 3.1.5 code, and 2) it pointed me in the
direction of a bug I introduced in Mike Grommet's date range handling
code.  I ended up moving the localtime() call up above the gmtime() call,
to prevent it from potentially clobbering the data returned by gmtime()
(both return a pointer to a static structure) before it's used.

Here's what I ended up committing to CVS for 3.2.0b4:

Index: htsearch/Display.cc
===================================================================
RCS file: /cvsroot/htdig/htdig/htsearch/Display.cc,v
retrieving revision 1.100.2.37
retrieving revision 1.100.2.38
diff -u -p -r1.100.2.37 -r1.100.2.38
--- htsearch/Display.cc	2001/06/19 22:04:02	1.100.2.37
+++ htsearch/Display.cc	2001/06/22 20:51:50	1.100.2.38
@@ -9,7 +9,7 @@
 // or the GNU Public License version 2 or later
 // <http://www.gnu.org/copyleft/gpl.html>
 //
-// $Id: Display.cc,v 1.100.2.37 2001/06/19 22:04:02 grdetil Exp $
+// $Id: Display.cc,v 1.100.2.38 2001/06/22 20:51:50 grdetil Exp $
 //
 
 #ifdef HAVE_CONFIG_H
@@ -1174,6 +1174,10 @@ Display::buildMatchList()
 
     tm startdate;     // structure to hold the startdate specified by the user
     tm enddate;       // structure to hold the enddate specified by the user
+    time_t now = time((time_t *)0); 	// fill in all fields for mktime
+    tm *lt = localtime(&now); 		//  - Gilles's fix
+    startdate = *lt; 
+    enddate = *lt; 
 
     time_t eternity = ~(1<<(sizeof(time_t)*8-1));  // will be the largest value holdable by a time_t
     tm *endoftime;     // the time_t eternity will be converted into a tm, held by this variable
@@ -1195,11 +1199,6 @@ Display::buildMatchList()
 
     if(dategiven)    // user specified some sort of date information
       {
-	time_t now = time((time_t *)0); 	// fill in all fields for mktime
-	tm *lt = localtime(&now); 		//  - Gilles's fix
-	startdate = *lt; 
-	enddate = *lt; 
-
 	// set up the startdate structure
 	// see man mktime for details on the tm structure
 	startdate.tm_sec = 0;
@@ -1424,7 +1423,7 @@ Display::buildMatchList()
 	if (date_factor != 0.0)
 	{
 	    date_score =  date_factor * 
-	      ((thisRef->DocTime() * 1000 / (double)time(0)) - 900);
+	      ((thisRef->DocTime() * 1000.0 / (double)now) - 900);
 	    score += date_score;
         }
-- 
Gilles R. Detillieux              E-mail: <grdetil@scrc.umanitoba.ca>
Spinal Cord Research Centre       WWW:    http://www.scrc.umanitoba.ca/~grdetil
Dept. Physiology, U. of Manitoba  Phone:  (204)789-3766
Winnipeg, MB  R3E 3J7  (Canada)   Fax:    (204)789-3930

_______________________________________________
htdig-dev mailing list
htdig-dev@lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/htdig-dev
