|
From: <ust...@us...> - 2009-03-29 10:36:06
|
Revision: 2962
http://clucene.svn.sourceforge.net/clucene/?rev=2962&view=rev
Author: ustramooner
Date: 2009-03-29 10:36:00 +0000 (Sun, 29 Mar 2009)
Log Message:
-----------
various demo code cleanup
Modified Paths:
--------------
branches/lucene2_3_2/src/demo/IndexFiles.cpp
branches/lucene2_3_2/src/demo/Main.cpp
branches/lucene2_3_2/src/demo/SearchFiles.cpp
Modified: branches/lucene2_3_2/src/demo/IndexFiles.cpp
===================================================================
--- branches/lucene2_3_2/src/demo/IndexFiles.cpp 2009-03-29 10:12:47 UTC (rev 2961)
+++ branches/lucene2_3_2/src/demo/IndexFiles.cpp 2009-03-29 10:36:00 UTC (rev 2962)
@@ -15,8 +15,7 @@
#include <fstream>
#include <sys/stat.h>
#include <cctype>
-#include <string>
-
+#include <string.h>
using namespace std;
using namespace lucene::index;
using namespace lucene::analysis;
@@ -137,5 +136,5 @@
writer->close();
_CLDELETE(writer);
- printf("Indexing took: %d ms.\n\n", Misc::currentTimeMillis() - str);
+ printf("Indexing took: %d ms.\n\n", (int32_t)(Misc::currentTimeMillis() - str));
}
Modified: branches/lucene2_3_2/src/demo/Main.cpp
===================================================================
--- branches/lucene2_3_2/src/demo/Main.cpp 2009-03-29 10:12:47 UTC (rev 2961)
+++ branches/lucene2_3_2/src/demo/Main.cpp 2009-03-29 10:36:00 UTC (rev 2962)
@@ -18,6 +18,7 @@
#endif
#include <iostream>
+#include <string.h>
using namespace std;
using namespace lucene::util;
@@ -40,12 +41,14 @@
printf("Location of text files to be indexed: ");
char files[250];
- fgets(files,250,stdin);
+ char* tmp = fgets(files,250,stdin);
+ if ( tmp == NULL ) return 1;
files[strlen(files)-1] = 0;
printf("Location to store the clucene index: ");
char ndx[250];
- fgets(ndx,250,stdin);
+ tmp = fgets(ndx,250,stdin);
+ if ( tmp == NULL ) return 1;
ndx[strlen(ndx)-1] = 0;
IndexFiles(files,ndx,true);
@@ -54,9 +57,9 @@
DeleteFiles(ndx);
}catch(CLuceneError& err){
- printf(err.what());
+ printf("Error: %s\n", err.what());
}catch(...){
- printf("Unknown error");
+ printf("Unknown error\n");
}
_lucene_shutdown(); //clears all static memory
@@ -68,6 +71,6 @@
// _crtBreakAlloc
//for linux, use valgrind
- printf ("\n\nTime taken: %d\n\n",Misc::currentTimeMillis() - str);
+ printf ("\n\nTime taken: %d\n\n", (int32_t)(Misc::currentTimeMillis() - str));
return 0;
}
Modified: branches/lucene2_3_2/src/demo/SearchFiles.cpp
===================================================================
--- branches/lucene2_3_2/src/demo/SearchFiles.cpp 2009-03-29 10:12:47 UTC (rev 2961)
+++ branches/lucene2_3_2/src/demo/SearchFiles.cpp 2009-03-29 10:36:00 UTC (rev 2962)
@@ -31,7 +31,8 @@
IndexSearcher s(index);
while (true) {
printf("Enter query string: ");
- fgets(line,80,stdin);
+ char* tmp = fgets(line,80,stdin);
+ if ( tmp == NULL ) continue;
line[strlen(line)-1]=0;
if ( strlen(line) == 0 )
@@ -45,7 +46,7 @@
uint64_t str = Misc::currentTimeMillis();
Hits* h = s.search(q);
- uint64_t srch = Misc::currentTimeMillis() - str;
+ uint32_t srch = (int32_t)(Misc::currentTimeMillis() - str);
str = Misc::currentTimeMillis();
for ( int32_t i=0;i<h->length();i++ ){
@@ -56,7 +57,7 @@
}
printf("\n\nSearch took: %d ms.\n", srch);
- printf("Screen dump took: %d ms.\n\n", Misc::currentTimeMillis() - str);
+ printf("Screen dump took: %d ms.\n\n", (int32_t)(Misc::currentTimeMillis() - str));
_CLDELETE(h);
_CLDELETE(q);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|