Update of /cvsroot/swishe/swish-e/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21969/src
Modified Files:
Makefile.am Makefile.in array.c bash.h config.h docprop.c
double_metaphone.c double_metaphone.h entities.c fhash.c
hash.c index.c parse_conffile.c parser.c ramdisk.c
result_output.c result_sort.c search.c soundex.c stemmer.c
swish-e.h swish.c swish.h worddata.c
Log Message:
Merged in changes from the rel-2-4-0-patches branch into main trunk
and set a tag for rel-2-4-2 for the patches branch.
Index: Makefile.am
===================================================================
RCS file: /cvsroot/swishe/swish-e/src/Makefile.am,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- Makefile.am 10 Sep 2003 18:57:39 -0000 1.11
+++ Makefile.am 9 Mar 2004 20:13:23 -0000 1.12
@@ -1,9 +1,18 @@
SUBDIRS = expat replace snowball
+# Using AM_CPPFLAGS instead of per-target flags means object names
+# don't get renamed. If using per-target _CPPFLAGS then would need
+# to update configure.in to use the prefix names on all optional objects
+# passed in. (e.g. $BTREE_OBJS).
+
AM_CPPFLAGS = -Dlibexecdir=\"${libexecdir}\" \
-DPATH_SEPARATOR=\"${PATH_SEPARATOR}\" \
$(Z_CFLAGS) $(PCRE_CFLAGS) $(LIBXML2_CFLAGS) -Ireplace
+# Until can figure out how to use AM_AUTOMAKE_INIT([-Wall])
+AM_CFLAGS = -Wall
+
+
bin_PROGRAMS = swish-e
swish_e_SOURCES = swish.c swish.h keychar_out.c keychar_out.h dump.c dump.h result_output.c result_output.h
swish_e_LDADD = libswishindex.la libswish-e.la
Index: Makefile.in
===================================================================
RCS file: /cvsroot/swishe/swish-e/src/Makefile.in,v
retrieving revision 1.76
retrieving revision 1.77
diff -u -r1.76 -r1.77
--- Makefile.in 18 Dec 2003 05:00:39 -0000 1.76
+++ Makefile.in 9 Mar 2004 20:13:23 -0000 1.77
@@ -151,11 +151,19 @@
target_alias = @target_alias@
SUBDIRS = expat replace snowball
+
+# Using AM_CPPFLAGS instead of per-target flags means object names
+# don't get renamed. If using per-target _CPPFLAGS then would need
+# to update configure.in to use the prefix names on all optional objects
+# passed in. (e.g. $BTREE_OBJS).
AM_CPPFLAGS = -Dlibexecdir=\"${libexecdir}\" \
-DPATH_SEPARATOR=\"${PATH_SEPARATOR}\" \
$(Z_CFLAGS) $(PCRE_CFLAGS) $(LIBXML2_CFLAGS) -Ireplace
+# Until can figure out how to use AM_AUTOMAKE_INIT([-Wall])
+AM_CFLAGS = -Wall
+
bin_PROGRAMS = swish-e
swish_e_SOURCES = swish.c swish.h keychar_out.c keychar_out.h dump.c dump.h result_output.c result_output.h
swish_e_LDADD = libswishindex.la libswish-e.la
Index: array.c
===================================================================
RCS file: /cvsroot/swishe/swish-e/src/array.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- array.c 4 Dec 2003 18:28:23 -0000 1.9
+++ array.c 9 Mar 2004 20:13:24 -0000 1.10
@@ -58,6 +58,7 @@
#include "mem.h"
#include "compress.h"
#include "array.h"
+#include "error.h"
/* A ARRAY page size */
Index: bash.h
===================================================================
RCS file: /cvsroot/swishe/swish-e/src/bash.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- bash.h 6 Sep 2003 05:16:22 -0000 1.2
+++ bash.h 9 Mar 2004 20:13:24 -0000 1.3
@@ -11,7 +11,7 @@
#endif
/* horrible Win32 hack */
-#ifdef _WIN32
+#if defined _WIN32 || defined(__VMS)
/* Fake group functions... */
#define GETGROUPS_T int
#define getegid() 0
Index: config.h
===================================================================
RCS file: /cvsroot/swishe/swish-e/src/config.h,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -r1.61 -r1.62
--- config.h 20 Nov 2003 16:24:44 -0000 1.61
+++ config.h 9 Mar 2004 20:13:24 -0000 1.62
@@ -129,6 +129,10 @@
/* DEFAULT_HTTP_DELAY is the default delay when using swishspider -S http */
+#define DATE_FORMAT_STRING "%Y-%m-%d %H:%M:%S %Z"
+/* default format string for dates */
+
+
#define INDEXPERMS 0644
/* After SWISH generates an index file, it changes the permissions
Index: docprop.c
===================================================================
RCS file: /cvsroot/swishe/swish-e/src/docprop.c,v
retrieving revision 1.117
retrieving revision 1.118
diff -u -r1.117 -r1.118
--- docprop.c 10 Aug 2003 14:49:29 -0000 1.117
+++ docprop.c 9 Mar 2004 20:13:24 -0000 1.118
@@ -69,7 +69,7 @@
{
if ( prop )
efree(prop);
-}
+}
@@ -82,17 +82,17 @@
void freeDocProperties(docProperties *docProperties)
{
- int i;
+ int i;
- for( i = 0; i < docProperties->n; i++ )
- {
- freeProperty( docProperties->propEntry[i] );
- docProperties->propEntry[i] = NULL;
- }
+ for( i = 0; i < docProperties->n; i++ )
+ {
+ freeProperty( docProperties->propEntry[i] );
+ docProperties->propEntry[i] = NULL;
+ }
+
+ efree(docProperties);
+ docProperties = NULL;
- efree(docProperties);
- docProperties = NULL;
-
}
@@ -143,27 +143,27 @@
if ( !meta_entry )
progerr("DecodeDocProperty passed NULL meta_entry");
-
+
if ( !prop )
return estrdup("");
-
-
+
+
if ( is_meta_string(meta_entry) ) /* check for ascii/string data */
return (char *)bin2string(prop->propValue,prop->propLen);
if ( is_meta_date(meta_entry) )
{
- s=emalloc(20);
+ s=emalloc(30);
i = *(unsigned long *) prop->propValue; /* read binary */
i = UNPACKLONG(i); /* Convert the portable number */
- strftime(s,20,"%Y-%m-%d %H:%M:%S",(struct tm *)localtime((time_t *)&i));
+ strftime(s,30, DATE_FORMAT_STRING, (struct tm *)localtime((time_t *)&i));
return s;
}
-
+
if ( is_meta_number(meta_entry) )
{
s=emalloc(14);
@@ -262,11 +262,11 @@
return CreateProperty( *meta_entry, (unsigned char *)&num, sizeof( num ), 1, &error_flag );
}
-
+
if ( is_meta_entry( *meta_entry, AUTOPROPERTY_INDEXFILE ) )
return CreateProperty( *meta_entry, (unsigned char *)result->db_results->indexf->line, strlen( result->db_results->indexf->line ), 0, &error_flag );
}
-
+
return ReadSingleDocPropertiesFromDisk(indexf, &result->fi, metaID, max_size );
}
@@ -285,7 +285,8 @@
*
* Bugs:
* Only returns first property in list (which is the last property)
-*
+* This function is called by dump.c and by result_output.c to
+* display the old -p style property listings.
*
********************************************************************/
@@ -295,9 +296,9 @@
propEntry *prop;
struct metaEntry *meta_entry = NULL;
-
- if( !result )
- return estrdup(""); // when would this happen?
+
+ if( !result )
+ return estrdup(""); // when would this happen?
@@ -314,7 +315,7 @@
/*******************************************************************
* SwishResultPropertyStr - Returns a string for the property *name* supplied
-* Numbers are zero filled
+* Numbers are zero filled (why??)
*
* ** Library interface call **
*
@@ -336,9 +337,9 @@
struct metaEntry *meta_entry = NULL;
IndexFILE *indexf;
DB_RESULTS *db_results;
-
- if( !result )
- return ""; // when would this happen?
+
+ if( !result )
+ progerr("SwishResultPropertyStr was called with a NULL result");
db_results = result->db_results;
@@ -353,11 +354,14 @@
return "(null)";
}
+ /* reset error level */
+ result->db_results->indexf->sw->lasterror = 0;
+
/* Does this results have this property? */
-
+
if ( !(prop = getDocProperty(result, &meta_entry, 0, 0 )) )
return "";
@@ -370,14 +374,11 @@
efree( s );
return "";
}
-
- /* create a place to store the strings */
-
- if ( ! db_results->prop_string_cache )
- {
- db_results->prop_string_cache = (char **)emalloc( indexf->header.metaCounter * sizeof( char *) );
- memset( db_results->prop_string_cache, 0, indexf->header.metaCounter * sizeof( char *) );
- }
+ if ( ! db_results->prop_string_cache )
+ {
+ db_results->prop_string_cache = (char **)emalloc( indexf->header.metaCounter * sizeof( char *) );
+ memset( db_results->prop_string_cache, 0, indexf->header.metaCounter * sizeof( char *) );
+ }
/* Free previous, if needed -- note the metaIDs start at one */
@@ -389,6 +390,8 @@
}
+
+
/*******************************************************************
* SwishResultPropertyULong - Returns an unsigned long for the property *name* supplied
*
@@ -407,42 +410,26 @@
unsigned long SwishResultPropertyULong(RESULT *result, char *pname)
{
- struct metaEntry *meta_entry = NULL;
- IndexFILE *indexf;
PropValue *pv;
- unsigned long value;
-
- if( !result )
- {
- result->db_results->indexf->sw->lasterror = SWISH_LISTRESULTS_EOF;
- return ULONG_MAX;
- }
-
-
- indexf = result->db_results->indexf;
+ unsigned long value = ULONG_MAX;
- /* Ok property name? */
-
- if ( !(meta_entry = getPropNameByName( &indexf->header, pname )) )
- {
- set_progerr(UNKNOWN_PROPERTY_NAME_IN_SEARCH_DISPLAY, result->db_results->indexf->sw, "Invalid property name '%s'", pname );
- return ULONG_MAX;
- }
+ /* Fetch the property */
+ pv = getResultPropValue (result, pname, 0 );
+ if ( !pv )
+ return ULONG_MAX; /* bad property name */
- /* make sure it's a numeric prop */
- if ( !is_meta_number(meta_entry) && !is_meta_date(meta_entry) )
+ /* Make sure it's of the correct type */
+ if ( (PROP_ULONG != pv->datatype) && (PROP_DATE != pv->datatype) )
{
- set_progerr(INVALID_PROPERTY_TYPE, result->db_results->indexf->sw, "Property '%s' is not numeric", pname );
- return ULONG_MAX;
- }
-
- pv = getResultPropValue (result, pname, 0 );
-
- value = pv->value.v_ulong;
+ if ( PROP_UNDEFINED != pv->datatype )
+ set_progerr(INVALID_PROPERTY_TYPE, result->db_results->indexf->sw,
+ "Property '%s' is not numeric", pname );
+ value = ULONG_MAX;
+ }
- efree( pv );
+ freeResultPropValue( pv );
return value;
}
@@ -459,9 +446,16 @@
* *metaName -- String name of meta entry
* metaID -- OR - meta ID number
*
+* Note that the ID is not really used anyplace, but
+* could be used to save the prop->id lookup.
+*
* Returns:
* pointer to a propValue structure if found -- caller MUST free
* Returns NULL if propertyName doesn't exist.
+* Jan 14, 2004:
+* Returns a PropValue PROP_UNDEFINED if result has not property
+* If returning NULL (i.e. bad property name) sets a swish-e error.
+* Caller is responsible for checking.
*
* Note:
* Feb 13, 2002 - now defined properties that just don't exist
@@ -479,11 +473,21 @@
struct metaEntry *meta_entry = NULL;
propEntry *prop;
+ /* Die on null result */
+ if( !r )
+ progerr("Called getResultPropValue with NULL result");
/* Lookup by property name, if supplied */
if ( pname )
if ( !(meta_entry = getPropNameByName( &r->db_results->indexf->header, pname )) )
+ {
+ set_progerr(UNKNOWN_PROPERTY_NAME_IN_SEARCH_DISPLAY, r->db_results->indexf->sw,
+ "Invalid property name '%s'", pname );
return NULL;
+ }
+
+ /* reset error level */
+ r->db_results->indexf->sw->lasterror = 0;
/* create a propvalue to return to caller */
@@ -493,15 +497,11 @@
- /* This may return false */
+ /* This will return false if the result does not have a value for this property */
prop = getDocProperty( r, &meta_entry, ID, 0 );
if ( !prop )
- {
- pv->datatype = PROP_STRING;
- pv->value.v_str = "";
- return pv;
- }
+ return pv; /* returning PROP_UNDEFINED */
if ( is_meta_string(meta_entry) ) /* check for ascii/string data */
@@ -514,19 +514,6 @@
}
- /* dates and numbers should return null to tell apart from zero */
- /* This is a slight problem with display, as blank properties show "(NULL)" */
- /* but is needed since other parts of swish (like sorting) need to see NULL. */
-
- /****************
- if ( !prop )
- {
- efree( pv );
- return NULL;
- }
- ****************/
-
-
if ( is_meta_number(meta_entry) )
{
unsigned long i;
@@ -538,7 +525,7 @@
return pv;
}
-
+
if ( is_meta_date(meta_entry) )
{
unsigned long i;
@@ -550,16 +537,12 @@
return pv;
}
- freeProperty( prop );
-
- if (pv->datatype == PROP_UNDEFINED) { /* nothing found */
- efree (pv);
- pv = NULL;
- }
+ /* If here, then it's an unknown property type and abort! */
+ progerr("Swish-e database error. Unknown property type '%d'", meta_entry->metaType );
+ return NULL; /* make compier happy */
- return pv;
}
/*******************************************************************
@@ -570,10 +553,10 @@
void freeResultPropValue(PropValue *pv)
{
if ( !pv ) return;
-
+
if ( pv->datatype == PROP_STRING && pv->destroy )
efree( pv->value.v_str );
-
+
efree(pv);
}
Index: double_metaphone.c
===================================================================
RCS file: /cvsroot/swishe/swish-e/src/double_metaphone.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- double_metaphone.c 30 Sep 2002 21:23:31 -0000 1.2
+++ double_metaphone.c 9 Mar 2004 20:13:24 -0000 1.3
@@ -224,7 +224,7 @@
void
-DoubleMetaphone(char *str, char **codes)
+DoubleMetaphone(const char *str, char **codes)
{
int length;
metastring *original;
@@ -237,7 +237,7 @@
/* we need the real length and last prior to padding */
length = strlen(str);
last = length - 1;
- original = NewMetaString(str);
+ original = NewMetaString((char *)str);
/* Pad original so we can index beyond end */
MetaphAdd(original, " ");
Index: double_metaphone.h
===================================================================
RCS file: /cvsroot/swishe/swish-e/src/double_metaphone.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- double_metaphone.h 5 Oct 2002 05:54:16 -0000 1.3
+++ double_metaphone.h 9 Mar 2004 20:13:24 -0000 1.4
@@ -18,7 +18,7 @@
void
-DoubleMetaphone(char *str,
+DoubleMetaphone(const char *str,
char **codes);
#ifdef __cplusplus
Index: entities.c
===================================================================
RCS file: /cvsroot/swishe/swish-e/src/entities.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- entities.c 28 Mar 2003 16:31:31 -0000 1.17
+++ entities.c 9 Mar 2004 20:13:24 -0000 1.18
@@ -634,7 +634,7 @@
{
unsigned char *s1,
*t;
- unsigned char *e_end;
+ char *e_end;
unsigned char s_cmp[MAX_ENTITY_LEN + 1];
int len;
int code;
Index: fhash.c
===================================================================
RCS file: /cvsroot/swishe/swish-e/src/fhash.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- fhash.c 24 Nov 2003 11:52:55 -0000 1.6
+++ fhash.c 9 Mar 2004 20:13:24 -0000 1.7
@@ -48,6 +48,7 @@
#include "compress.h"
#include "mem.h"
#include "fhash.h"
+#include "error.h"
FHASH *FHASH_Create(FILE *fp)
{
Index: hash.c
===================================================================
RCS file: /cvsroot/swishe/swish-e/src/hash.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- hash.c 18 Dec 2003 05:00:39 -0000 1.16
+++ hash.c 9 Mar 2004 20:13:24 -0000 1.17
@@ -120,8 +120,8 @@
table_ptr->count = 0;
}
else
- if ( is_word_in_hash_table( *table_ptr, word ) )
- return;
+ if ( (sp = is_word_in_hash_table( *table_ptr, word )) )
+ return sp;
hashval = string_hash(word,hash_size);
@@ -186,10 +186,6 @@
void free_word_hash_table( WORD_HASH_TABLE *table_ptr)
{
struct swline **hash_array = table_ptr->hash_array;
- int hash_size = table_ptr->hash_size;
- int i;
- struct swline *sp,
- *tmp;
if ( !hash_array )
return;
Index: index.c
===================================================================
RCS file: /cvsroot/swishe/swish-e/src/index.c,v
retrieving revision 1.226
retrieving revision 1.227
diff -u -r1.226 -r1.227
--- index.c 18 Dec 2003 05:00:39 -0000 1.226
+++ index.c 9 Mar 2004 20:13:24 -0000 1.227
@@ -141,8 +141,9 @@
static void index_path_parts( SWISH *sw, char *path, path_extract_list *list, INDEXDATAHEADER *header, docProperties **properties );
static void SwapLocData(SWISH *,ENTRY *,unsigned char *,int);
static void unSwapLocData(SWISH *,int, ENTRY *);
+#ifndef USE_BTREE
static void sortSwapLocData(ENTRY *);
-
+#endif
/*
-- init structures for this module
@@ -2894,6 +2895,7 @@
}
}
+#ifndef USE_BTREE
/* 2002-07 jmruiz - Sorts unswaped location data by metaname, filenum */
static void sortSwapLocData(ENTRY *e)
{
@@ -2972,5 +2974,6 @@
/* Free the memory of the sorting array */
efree(ptmp);
-
+
}
+#endif
Index: parse_conffile.c
===================================================================
RCS file: /cvsroot/swishe/swish-e/src/parse_conffile.c,v
retrieving revision 1.94
retrieving revision 1.95
diff -u -r1.94 -r1.95
--- parse_conffile.c 18 Dec 2003 05:00:39 -0000 1.94
+++ parse_conffile.c 9 Mar 2004 20:13:25 -0000 1.95
@@ -431,31 +431,9 @@
if (strcasecmp(w0, "UseStemming") == 0)
{
-#ifdef SNOWBALL
- char *stem_tmp;
- if (sl->n != 2)
- progerr("%s: requires one value", w0);
-
- /* Fix. "no" should default to norvegian
- if( strcasecmp(sl->word[1],"no") != 0 )
- {
- */
- /* Fix to make "UseStemming yes" -> "UseStemming en" */
- if( strcasecmp(sl->word[1],"yes") == 0 )
- strcpy(sl->word[1],"en");
-
- stem_tmp = (char *) emalloc(strlen("Stemming_") + strlen(sl->word[1]) + 1);
- sprintf(stem_tmp,"Stemming_%s",sl->word[1]);
- fuzzy_or_die( indexf, stem_tmp );
-
- efree(stem_tmp);
- /*
- }
- */
-#else
+ progwarn("UseStemming is deprecated. See FuzzyIndexingMode in the docs");
if ( getYesNoOrAbort(sl, 1, 1) )
fuzzy_or_die( indexf, "Stemming_en" );
-#endif
continue;
}
Index: parser.c
===================================================================
RCS file: /cvsroot/swishe/swish-e/src/parser.c,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -r1.49 -r1.50
--- parser.c 18 Dec 2003 05:00:39 -0000 1.49
+++ parser.c 9 Mar 2004 20:13:25 -0000 1.50
@@ -604,7 +604,7 @@
if(strlen(el) >= MAXSTRLEN) // easy way out
{
- warning("Warning: Tag found in %s is too long: '%s'\n", parse_data->fprop->real_path, el );
+ warning( (void *)data, "Warning: Tag found in %s is too long: '%s'\n", parse_data->fprop->real_path, el );
return;
}
@@ -704,7 +704,7 @@
if(strlen(el) > MAXSTRLEN)
{
- warning("Warning: Tag found in %s is too long: '%s'\n", parse_data->fprop->real_path, el );
+ warning( (void *)data, "Warning: Tag found in %s is too long: '%s'\n", parse_data->fprop->real_path, el );
return;
}
@@ -1008,8 +1008,15 @@
if ( (m = getPropNameByName( parse_data->header, tag)) )
{
- flush_buffer( parse_data, 7 ); // flush since it's a new meta tag
- push_stack( &parse_data->prop_stack, endtag, m, prop_append, 0 );
+ if ( is_meta_internal( m ) )
+ {
+ warning( (void *)parse_data, "Found Swish-e reserved property name '%s'\n", tag );
+ }
+ else
+ {
+ flush_buffer( parse_data, 7 ); // flush since it's a new meta tag
+ push_stack( &parse_data->prop_stack, endtag, m, prop_append, 0 );
+ }
}
@@ -1264,11 +1271,11 @@
if(strlen(tag) >= MAXSTRLEN) // easy way out
{
- warning("Warning: Tag found in %s is too long: '%s'\n", parse_data->fprop->real_path, tag );
+ warning( (void *)parse_data, "Warning: Tag found in %s is too long: '%s'\n", parse_data->fprop->real_path, tag );
return 0;
}
-
-
+
+
strcpy( tagbuf, tag );
t = tagbuf + taglen;
*t = '.'; /* hard coded! */
@@ -1284,14 +1291,14 @@
/* Is the tag going to be too long? */
if ( strlen( (char *)attr[i+1] ) + taglen + 2 > 256 )
{
- warning("ClassAttribute on tag '%s' too long\n", tag );
+ warning( (void *)parse_data, "ClassAttribute on tag '%s' too long\n", tag );
continue;
}
/* All metanames are currently lowercase -- would be better to force this in metanames.c */
strtolower( tagbuf );
-
+
strcpy( t, (char *)attr[i+1] ); /* create tag.attribute metaname */
start_metaTag( parse_data, tagbuf, tag, meta_append, prop_append, 0 );
found++;
@@ -1357,7 +1364,7 @@
if(strlen(tag) >= MAXSTRLEN) // easy way out
{
- warning("Warning: Tag found in %s is too long: '%s'\n", parse_data->fprop->real_path, tag );
+ warning( (void *)parse_data, "Warning: Tag found in %s is too long: '%s'\n", parse_data->fprop->real_path, tag );
return;
}
@@ -1379,7 +1386,7 @@
if ( strlen( (char *)attr[i] ) + taglen + 2 > 256 )
{
- warning("Attribute '%s' on tag '%s' too long to build metaname\n", (char *)attr[i], tag );
+ warning(" (void *)parse_data, Attribute '%s' on tag '%s' too long to build metaname\n", (char *)attr[i], tag );
continue;
}
@@ -1702,6 +1709,7 @@
PARSE_DATA *parse_data = (PARSE_DATA *)data;
char str[1000];
+ printf("8888\n");
va_start(args, msg);
vsnprintf(str, 1000, msg, args );
va_end(args);
Index: ramdisk.c
===================================================================
RCS file: /cvsroot/swishe/swish-e/src/ramdisk.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- ramdisk.c 4 Dec 2003 18:06:41 -0000 1.8
+++ ramdisk.c 9 Mar 2004 20:13:25 -0000 1.9
@@ -104,7 +104,7 @@
unsigned int lenbuf=(unsigned int)(sz1 *sz2);
struct ramdisk *rd = (struct ramdisk *)fp;
unsigned char *buf = (unsigned char *)buffer;
-unsigned int num_buffer,start_pos,tmplenbuf = lenbuf;
+unsigned int num_buffer,start_pos;
unsigned int avail;
num_buffer = (unsigned int)(rd->cur_pos / (sw_off_t)rd->buf_size);
Index: result_output.c
===================================================================
RCS file: /cvsroot/swishe/swish-e/src/result_output.c,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -r1.70 -r1.71
--- result_output.c 18 Jul 2003 22:51:22 -0000 1.70
+++ result_output.c 9 Mar 2004 20:13:25 -0000 1.71
@@ -136,7 +136,7 @@
struct MOD_ResultOutput *md = sw->ResultOutput;
struct ResultExtFmtStrList *l,
*ln;
-
+
if (md->stdResultFieldDelimiter)
efree(md->stdResultFieldDelimiter); /* -d :free swish 1.x delimiter */
@@ -161,14 +161,14 @@
if (md->propNameToDisplay)
{
int i;
-
+
for( i=0; i < md->numPropertiesToDisplay; i++ )
efree(md->propNameToDisplay[i]);
-
+
efree(md->propNameToDisplay);
}
md->propNameToDisplay=NULL;
-
+
if (md->propIDToDisplay)
{
int i;
@@ -326,16 +326,13 @@
SWISH *sw = results->sw;
struct MOD_ResultOutput *md = sw->ResultOutput;
RESULT *r = NULL;
- FileRec *fi;
- char *delimiter;
FILE *f_out;
f_out = stdout;
- delimiter = (md->stdResultFieldDelimiter) ? md->stdResultFieldDelimiter : " ";
-
+ /* -b is begin +1 */
if ( begin )
{
begin--;
@@ -345,57 +342,56 @@
/* Seek, and report errors if trying to seek past eof */
-
+
if ( SwishSeekResult(results, begin) < 0 )
SwishAbortLastError( results->sw );
-
+ /* If maxhits = 0 then display all */
if (maxhits <= 0)
maxhits = -1;
- /* -- resultmaxhits: >0 or -1 (all hits) */
-
- while ( (r = SwishNextResult(results)) && maxhits )
+ if ( md->extendedformat ) /* are we using -x for output? */
{
- fi = &r->fi; /* get address of FileRec to store properties and pointers */
-
+ while ( (r = SwishNextResult(results)) && maxhits )
+ {
+ printExtResultEntry(sw, f_out, md->extendedformat, r);
+ freefileinfo( &r->fi );
+ if ( maxhits > 0)
+ maxhits--;
+ }
+ }
- /* This may or may not be an optimization */
- // not really any more -- used to be able to read all the props, now this just reads them using ReadSingle...
- // ReadAllDocPropertiesFromDisk( r->indexf, r->filenum);
-
- if (md->extendedformat)
- printExtResultEntry(sw, f_out, md->extendedformat, r);
+ else /* not using -x and maybe -p (old style) */
+ {
+ char *format;
+ char *delimiter;
- else
+ if ((delimiter = (md->stdResultFieldDelimiter)) )
{
- char *format;
+ format = emalloc( (3* strlen( delimiter )) + 100 );
+ /* warning -- user data in a sprintf format string */
+ sprintf( format, "%%r%s%%p%s%%t%s%%l", delimiter, delimiter, delimiter );
+ }
+ else
+ format = estrdup( "%r %p \"%t\" %l" );
- if ((delimiter = (md->stdResultFieldDelimiter)) )
- {
- format = emalloc( (3* strlen( delimiter )) + 100 );
- sprintf( format, "%%r%s%%p%s%%t%s%%l", delimiter, delimiter, delimiter );
- }
- else
- format = estrdup( "%r %p \"%t\" %l" );
+ while ( (r = SwishNextResult(results)) && maxhits )
+ {
printExtResultEntry(sw, f_out, format, r);
- printStandardResultProperties(f_out, r);
-
+ printStandardResultProperties(f_out, r); /* print any -p properties */
+ freefileinfo( &r->fi );
fprintf(f_out, "\n");
- efree( format );
- }
-
- /* might as well free the memory as we go */
- freefileinfo( fi );
+ if ( maxhits > 0)
+ maxhits--;
+ }
- if (maxhits > 0)
- maxhits--;
+ efree( format );
}
}
@@ -658,30 +654,38 @@
pv = getResultPropValue(r, propname, 0);
+ /* If returning NULL then it's an invalid property name */
if (!pv)
{
- if (f)
- fprintf(f, "(NULL)"); /* Null value, no propname */
- return;
+ printf("(null)");
+ return;
+ /* or could just abort, but that's ugly in the middle of output */
+ /* it would be nice to check the format strings (and cache the meta name lookups) */
+ /* before generating resuls, but need to do that for each index */
+ printf("\n"); /* might be in the middle of some text */
+ SwishAbortLastError( r->db_results->indexf->sw );
}
+
#ifdef USE_DOCPATH_AS_TITLE
- if ( strcmp( AUTOPROPERTY_TITLE, propname ) == 0 && strcmp( "", pv->value.v_str ) == 0 )
+ if ( ( PROP_UNDEFINED == pv->datatype ) && strcmp( AUTOPROPERTY_TITLE, propname ) == 0 )
{
- char *c;
- efree( pv );
+ freeResultPropValue( pv );
+
pv = getResultPropValue(r, AUTOPROPERTY_DOCPATH, 0);
+ if ( !pv ) /* in this case, let it slide */
+ return;
+
/* Just display the base name */
- if ( pv )
+ if ( PROP_STRING == pv->datatype )
{
- c = estrdup( str_basename( pv->value.v_str ) );
+ char *c = estrdup( str_basename( pv->value.v_str ) );
efree( pv->value.v_str );
pv->value.v_str = c;
}
}
-#endif
-
+#endif
@@ -695,13 +699,13 @@
fprintf(f, fmt, pv->value.v_int);
break;
+
case PROP_ULONG:
fmt = (subfmt) ? subfmt : "%lu";
if (f)
fprintf(f, fmt, pv->value.v_ulong);
break;
-
case PROP_STRING:
fmt = (subfmt) ? subfmt : "%s";
@@ -723,7 +727,7 @@
case PROP_DATE:
- fmt = (subfmt) ? subfmt : "%Y-%m-%d %H:%M:%S %Z";
+ fmt = (subfmt) ? subfmt : DATE_FORMAT_STRING;
if (!strcmp(fmt, "%ld"))
{
/* special: Print date as serial int (for Bill) */
@@ -747,12 +751,16 @@
fprintf(f, fmt, (double) pv->value.v_float);
break;
+ case PROP_UNDEFINED:
+ break; /* Do nothing */
+
default:
- fprintf(stdout, "err:(unknown datatype <%s>)\n", propname);
+ progerr("Swish-e database error. Unknown property type accessing property '%s'", propname);
break;
-
}
+
+
freeResultPropValue(pv);
}
@@ -880,7 +888,8 @@
* *RESULT
*
* I think this could be done in result_output.c by creating a standard
-* -x format (plus properites) for use when there isn't one already.
+* -x format (plus properites) for use when there isn't one already,
+xxxx
*
*
********************************************************************/
Index: result_sort.c
===================================================================
RCS file: /cvsroot/swishe/swish-e/src/result_sort.c,v
retrieving revision 1.81
retrieving revision 1.82
diff -u -r1.81 -r1.82
--- result_sort.c 5 Sep 2003 05:07:58 -0000 1.81
+++ result_sort.c 9 Mar 2004 20:13:25 -0000 1.82
@@ -146,7 +146,6 @@
int num_fields = r1->db_results->num_sort_props;
SortData *sort_data1;
SortData *sort_data2;
- propEntry *prop_entry;
for (i = 0; i < num_fields; i++)
{
Index: search.c
===================================================================
RCS file: /cvsroot/swishe/swish-e/src/search.c,v
retrieving revision 1.130
retrieving revision 1.131
diff -u -r1.130 -r1.131
--- search.c 20 Nov 2003 17:01:12 -0000 1.130
+++ search.c 9 Mar 2004 20:13:26 -0000 1.131
@@ -2177,7 +2177,6 @@
/* funtion to free the memory of one result */
static void freeresult(RESULT * rp)
{
- int i;
DB_RESULTS *db_results;
if (!rp)
Index: soundex.c
===================================================================
RCS file: /cvsroot/swishe/swish-e/src/soundex.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- soundex.c 18 Dec 2003 05:00:40 -0000 1.5
+++ soundex.c 9 Mar 2004 20:13:26 -0000 1.6
@@ -50,7 +50,6 @@
{
FUZZY_WORD *fw = create_fuzzy_word( inword, 1 ); /* create place to store stemmed word */
char word[MAXWORDLEN+1];
- int length;
/* Misc Stuff */
char u, l ;
int i, j, n;
Index: stemmer.c
===================================================================
RCS file: /cvsroot/swishe/swish-e/src/stemmer.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- stemmer.c 18 Dec 2003 05:00:40 -0000 1.19
+++ stemmer.c 9 Mar 2004 20:13:26 -0000 1.20
@@ -77,6 +77,8 @@
#define FALSE 0
#define TRUE 1
+#include "double_metaphone.h"
+
/* Includes for using SNOWBALL stemmer */
#include "snowball/stem_es.h"
#include "snowball/stem_fr.h"
@@ -285,6 +287,7 @@
}
progerr("Invalid FuzzyIndexingMode '%d' in index file", fuzzy);
+ return NULL;
}
@@ -324,7 +327,7 @@
struct SN_env *snowball = fi->snowball_options;
FUZZY_WORD *fw = create_fuzzy_word( inword, 1 ); /* create place to store stemmed word */
- SN_set_current(snowball,strlen(inword),inword); /* Set Word to Stem */
+ SN_set_current(snowball,strlen(inword),(const symbol *)inword); /* Set Word to Stem */
fi->stemmer->lang_stem(snowball); /* Stem the word */
Index: swish-e.h
===================================================================
RCS file: /cvsroot/swishe/swish-e/src/swish-e.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- swish-e.h 18 Dec 2003 05:00:40 -0000 1.7
+++ swish-e.h 9 Mar 2004 20:13:26 -0000 1.8
@@ -143,12 +143,12 @@
typedef enum
{ /* Property Datatypes */
- PROP_UNDEFINED = -1,
- PROP_UNKNOWN = 0,
+ PROP_UNDEFINED = -1, /* a result does not have a value for that prop */
+ PROP_UNKNOWN = 0, /* invalid property requested (not really used anyplace) */
PROP_STRING,
PROP_INTEGER,
PROP_FLOAT,
- PROP_DATE,
+ PROP_DATE,
PROP_ULONG
}
PropType;
Index: swish.c
===================================================================
RCS file: /cvsroot/swishe/swish-e/src/swish.c,v
retrieving revision 1.117
retrieving revision 1.118
diff -u -r1.117 -r1.118
--- swish.c 18 Dec 2003 05:00:40 -0000 1.117
+++ swish.c 9 Mar 2004 20:13:26 -0000 1.118
@@ -298,6 +298,9 @@
printf(" The default value is: \"%s\"\n", defaultIndexingSystem);
printf(" -i : create an index from the specified files\n");
+#ifdef USE_BTREE
+ printf(" -u : update: adds files to existing index\n");
+#endif
printf(" -w : search for words \"word1 word2 ...\"\n");
printf(" -t : tags to search in - specify as a string\n");
printf(" \"HBthec\" - in Head|Body|title|header|emphasized|comments\n");
Index: swish.h
===================================================================
RCS file: /cvsroot/swishe/swish-e/src/swish.h,v
retrieving revision 1.194
retrieving revision 1.195
diff -u -r1.194 -r1.195
--- swish.h 18 Dec 2003 05:00:40 -0000 1.194
+++ swish.h 9 Mar 2004 20:13:26 -0000 1.195
@@ -138,7 +138,13 @@
#endif
+/* $$$ THESE NEED TO BE UPGRADED WHEN THE INDEX FORMAT CHANGES */
+
+#ifdef USE_BTREE
+#define SWISH_MAGIC 11076322L
+#else
#define SWISH_MAGIC 21076322L
+#endif
#define INDEXFILE "index.swish-e"
Index: worddata.c
===================================================================
RCS file: /cvsroot/swishe/swish-e/src/worddata.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- worddata.c 4 Dec 2003 18:06:41 -0000 1.8
+++ worddata.c 9 Mar 2004 20:13:26 -0000 1.9
@@ -10,6 +10,7 @@
#include "mem.h"
#include "compress.h"
#include "worddata.h"
+#include "error.h"
/* WORDDATA page size */
/* !!!! Must no be less than 4096 and not greater than 65536*/
|