Date: Mon, 19 Feb 2001 21:06:18 -0500 (EST)
From: Geoff Hutchison <ghutchis@wso.williams.edu>
To: Gilles Detillieux <grdetil@scrc.umanitoba.ca>
Cc: htdig-dev@lists.sourceforge.net
Subject: [htdig-dev] Re: [htdig] 3.2.0b3 on Red Hat 6.2 - strange errors


I'm taking this to the htdig-dev list to avoid clutter. We may have to
enforce this more...

On Mon, 19 Feb 2001, Gilles Detillieux wrote:

> I had some old databases lying around from 3.2.0b2.  As Emily Latilla
> would say, "never mind!"  Actually, shouldn't an htdig -i remove the
> old databases?  I think an htfuzzy synonyms should as well.  It wasn't
> an issue for endings, because it builds them in TMPDIR and moves them to
> common afterward.  These issues may cause a lot of similar questions if
> we don't address these errors before b3 goes out.  Certainly the -s option
> would be a problem even for those who didn't previously install b2 or b1.

Were all bugs so easy to address...
-Geoff

Mon Feb 19 18:24:42 2001  Geoff Hutchison  <ghutchis@wso.williams.edu>

	* htfuzzy/Synonym.cc (createDB): Create database in a temporary
	directory before we move it into place, much like the endings
	code. This should prevent problems when we just append to the DB
	instead of making a new one.

	* htdig/htdig.cc (main): Fix bug discovered by Gilles--htword
	should be initialized *after* we are finished modifying config
	attributes based on flags and unlink with -i.

	* installdir/rundig: Fix bug with calling htpurge with -s option.

Index: htdig/htdig.cc
===================================================================
RCS file: /cvsroot/htdig/htdig/htdig/htdig.cc,v
retrieving revision 1.26.2.17
diff -c -3 -p -r1.26.2.17 htdig.cc
*** htdig/htdig.cc	2001/02/11 23:08:29	1.26.2.17
--- htdig/htdig.cc	2001/02/20 00:50:09
*************** int main(int ac, char **av)
*** 130,138 ****
      }
      config.Read(configFile);
  
-     // Initialize htword
-     WordContext::Initialize(config);
- 
      if (config["locale"].empty() && debug > 0)
        cout << "Warning: unknown locale!\n";
  
--- 130,135 ----
*************** int main(int ac, char **av)
*** 261,266 ****
--- 258,266 ----
      const String		word_filename = config["word_db"];
      if (initial)
         unlink(word_filename);
+ 
+     // Initialize htword
+     WordContext::Initialize(config);
  
      // Create the Retriever object which we will use to parse all the
      // HTML files.
Index: htfuzzy/Synonym.cc
===================================================================
RCS file: /cvsroot/htdig/htdig/htfuzzy/Synonym.cc,v
retrieving revision 1.8.2.7
diff -c -3 -p -r1.8.2.7 Synonym.cc
*** htfuzzy/Synonym.cc	2000/10/20 03:40:56	1.8.2.7
--- htfuzzy/Synonym.cc	2001/02/20 00:50:10
***************
*** 28,35 ****
  #include <stdio.h>
  #include <fstream.h>
  #include <stdlib.h>
  
- 
  //*****************************************************************************
  Synonym::Synonym(const HtConfiguration& config_arg) :
    Fuzzy(config_arg)
--- 28,35 ----
  #include <stdio.h>
  #include <fstream.h>
  #include <stdlib.h>
+ #include <sys/stat.h>
  
  //*****************************************************************************
  Synonym::Synonym(const HtConfiguration& config_arg) :
    Fuzzy(config_arg)
*************** Synonym::~Synonym()
*** 55,65 ****
  int
  Synonym::createDB(const HtConfiguration &config)
  {
      char	input[1000];
      FILE	*fl;
  	
      const String sourceFile = config["synonym_dictionary"];
-     const String dbFile = config["synonym_db"];
  
      fl = fopen(sourceFile, "r");
      if (fl == NULL)
--- 55,74 ----
  int
  Synonym::createDB(const HtConfiguration &config)
  {
+     String      tmpdir = getenv("TMPDIR");
+     String 	dbFile;
+ 
+     if (tmpdir.length())
+       dbFile = tmpdir;
+     else
+       dbFile = "/tmp";
+ 
+     dbFile << "/synonyms.db";
+ 
      char	input[1000];
      FILE	*fl;
  	
      const String sourceFile = config["synonym_dictionary"];
  
      fl = fopen(sourceFile, "r");
      if (fl == NULL)
*************** Synonym::createDB(const HtConfiguration 
*** 108,113 ****
--- 117,130 ----
      fclose(fl);
      db->Close();
      delete db;
+ 
+     struct stat stat_buf;
+     String mv("mv");	// assume it's in the PATH if predefined setting fails
+     if ((stat(MV, &stat_buf) != -1) && S_ISREG(stat_buf.st_mode))
+ 	mv = MV;
+     system(form("%s %s %s",
+ 		mv.get(), dbFile.get(), config["synonym_db"].get()));
+ 
      if (debug)
      {
          cout << "htfuzzy/synonyms: " << count << ' ' << word << "\n";
Index: installdir/rundig
===================================================================
RCS file: /cvsroot/htdig/htdig/installdir/rundig,v
retrieving revision 1.7.4.2
diff -c -3 -p -r1.7.4.2 rundig
*** installdir/rundig	2001/01/12 15:00:39	1.7.4.2
--- installdir/rundig	2001/02/20 00:50:10
*************** TMPDIR=$DBDIR
*** 34,40 ****
  export TMPDIR
  
  $BINDIR/htdig -i $opts $stats $alt
! $BINDIR/htpurge $opts $stats $alt
  case "$alt" in
  -a)
    ( cd $DBDIR && test -f db.docdb.work &&
--- 34,40 ----
  export TMPDIR
  
  $BINDIR/htdig -i $opts $stats $alt
! $BINDIR/htpurge $opts $alt
  case "$alt" in
  -a)
    ( cd $DBDIR && test -f db.docdb.work &&



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