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.

[snip]
@@ -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;
         }
[snip]
   
For 3.1.5, you can simply append the ".0" to 1000 as above, or if you've
already applied the dateRange.1 patch, here's the additional patch to
apply...

--- htsearch/Display.cc.patched	2001/06/19 22:07:58
+++ htsearch/Display.cc	2001/06/22 20:57:22
@@ -1100,6 +1100,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
@@ -1121,11 +1125,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;
@@ -1332,7 +1331,7 @@ Display::buildMatchList()
 	    if (thisRef)   // We better hope it's not null!
 	      {
 		score += date_factor * 
-		  ((thisRef->DocTime() * 1000 / (double)time(0)) - 900);
+		  ((thisRef->DocTime() * 1000.0 / (double)now) - 900);
 		int links = thisRef->DocLinks();
 		if (links == 0)
 		  links = 1; // It's a hack, but it helps...

-- 
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

