retry: patch for bogotune.c

David Relson relson at osagesoftware.com
Sun Mar 20 18:25:15 CET 2005


This new version of the patch uses variables ds_path and ds_file and
makes sure that ds_path is the _directory_ and ds_file is a full path,
i.e. directory _plus_ filename.

bogotune -v -d ~/.bogofilter -s spam.d -n ham.d
bogotune -v -d ~/.bogofilter/wordlist.db -s spam.d ham.d

HTH,

David

-------------- next part --------------
--- 0941/src/bogotune.c	2005-03-15 23:10:54.000000000 -0500
+++ cvs/src/bogotune.c	2005-03-20 12:20:09.660615944 -0500
@@ -1,4 +1,4 @@
-/* $Id: bogotune.c,v 1.204 2005/03/16 03:55:14 m-a Exp $ */
+/* $Id: bogotune.c,v 1.205 2005/03/20 15:35:44 relson Exp $ */
 
 /*****************************************************************************
 
@@ -137,7 +137,8 @@
 /* Global Variables */
 
 const char *progname = "bogotune";
-static char *ds_path;
+static char *ds_path;			/* directory */
+static char *ds_file;			/* directory/file */
 static ds_loc ds_flag = DS_NONE;
 static void *env = NULL;
 
@@ -625,11 +626,11 @@
 static void load_wordlist(ds_foreach_t *hook, void *userdata)
 {
     if (verbose) {
-	printf("Reading %s\n", ds_path);
+	printf("Reading %s\n", ds_file);
 	fflush(stdout);
     }
 
-    ds_oper(env, ds_path, DS_READ, hook, userdata);
+    ds_oper(env, ds_file, DS_READ, hook, userdata);
 
     return;
 }
@@ -930,7 +931,7 @@
 	    suppress_config_file = true;
 	    break;
 	case 'd':
-	    ds_path = optarg;
+	    ds_path = xstrdup(optarg);
 	    ds_flag = (ds_flag == DS_NONE) ? DS_DSK : DS_ERR;
 	    break;
 	case 'D':
@@ -1318,6 +1319,7 @@
     mime_cleanup();
 
     xfree(ds_path);
+    xfree(ds_file);
 
     return;
 }
@@ -1712,8 +1714,19 @@
 	set_bogohome(ds_path);
 	env = ds_init(bogohome, WORDLIST);
 
-	ds_path = mxcat(ds_path, DIRSEP_S, WORDLIST, NULL);
-	init_wordlist("word", ds_path, 0, WL_REGULAR);
+	/* ds_path is the directory and
+	** ds_file is directory/WORDLIST.
+	*/
+	if (strcmp(bogohome, ds_path) == 0) {
+	    ds_file = mxcat(ds_path, DIRSEP_S, WORDLIST, NULL);
+	}
+	else {
+	    ds_file = xstrdup(ds_path);
+	    xfree(ds_path);
+	    ds_path = xstrdup(bogohome);
+	}
+
+	init_wordlist("word", ds_file, 0, WL_REGULAR);
     }
 
     bogotune();
-------------- next part --------------
_______________________________________________
Bogofilter mailing list
Bogofilter at bogofilter.org
http://www.bogofilter.org/mailman/listinfo/bogofilter


More information about the bogofilter mailing list