mirror of
https://github.com/privacore/open-source-search-engine.git
synced 2025-06-09 21:39:34 -04:00
Use lang_t enum more than just plain uint8_t
This commit is contained in:
parent
ba5c30d7e1
commit
128790084b
4
Lang.cpp
4
Lang.cpp
@ -149,10 +149,10 @@ static const char * const s_langAbbr[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
uint8_t getLangIdFromAbbr ( const char *abbr ) {
|
||||
lang_t getLangIdFromAbbr ( const char *abbr ) {
|
||||
for (int x = 0; x < langLast && s_langAbbr[x]; ++x) {
|
||||
if (!strcasecmp((char*)abbr, s_langAbbr[x])) {
|
||||
return x;
|
||||
return (lang_t)x;
|
||||
}
|
||||
}
|
||||
|
||||
|
2
Lang.h
2
Lang.h
@ -84,7 +84,7 @@ enum lang_t {
|
||||
langLast
|
||||
};
|
||||
|
||||
uint8_t getLangIdFromAbbr ( const char *abbr ) ;
|
||||
lang_t getLangIdFromAbbr ( const char *abbr ) ;
|
||||
lang_t getLangIdFromCharset(uint16_t charset);
|
||||
|
||||
void languageToString ( unsigned char lang , char *buf );
|
||||
|
@ -348,7 +348,7 @@ void Msg39::getDocIds2() {
|
||||
|
||||
// . set our m_query instance
|
||||
if ( ! m_query.set2 ( m_msg39req->ptr_query,
|
||||
m_msg39req->m_language ,
|
||||
(lang_t)m_msg39req->m_language ,
|
||||
m_msg39req->m_queryExpansion ,
|
||||
m_msg39req->m_useQueryStopWords ,
|
||||
m_msg39req->m_allowHighFrequencyTermCache,
|
||||
|
@ -28,7 +28,7 @@ public:
|
||||
char m_format;
|
||||
int32_t m_niceness;
|
||||
XmlDoc m_xd;
|
||||
uint8_t m_langId;
|
||||
lang_t m_langId;
|
||||
//Msg8a m_msg8a;
|
||||
//SiteRec m_sr;
|
||||
//TagRec m_tagRec;
|
||||
@ -134,7 +134,7 @@ bool sendPageGet ( TcpSocket *s , HttpRequest *r ) {
|
||||
const char *langAbbr = r->getString("qlang",NULL);
|
||||
st->m_langId = langUnknown;
|
||||
if ( langAbbr ) {
|
||||
uint8_t langId = getLangIdFromAbbr ( langAbbr );
|
||||
lang_t langId = getLangIdFromAbbr ( langAbbr );
|
||||
st->m_langId = langId;
|
||||
}
|
||||
strncpy ( st->m_coll , coll , MAX_COLL_LEN+1 );
|
||||
|
@ -97,7 +97,7 @@ bool sendPageReindex ( TcpSocket *s , HttpRequest *r ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
int32_t langId = getLangIdFromAbbr ( gr->m_qlang );
|
||||
lang_t langId = getLangIdFromAbbr ( gr->m_qlang );
|
||||
|
||||
// let msg1d do all the work now
|
||||
if ( ! st->m_msg1c.reindexQuery ( gr->m_query ,
|
||||
@ -248,7 +248,7 @@ bool Msg1c::reindexQuery ( const char *query,
|
||||
int32_t startNum ,
|
||||
int32_t endNum ,
|
||||
bool forceDel ,
|
||||
int32_t langId,
|
||||
lang_t langId,
|
||||
void *state ,
|
||||
void (* callback) (void *state ) ) {
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#include "Msg4Out.h"
|
||||
#include "SafeBuf.h"
|
||||
#include "Lang.h"
|
||||
|
||||
// . for adding docid-based spider requests to spiderdb
|
||||
// . this is the original method, for queuing up docid-based spider requests
|
||||
@ -17,7 +18,7 @@ public:
|
||||
int32_t startNum ,
|
||||
int32_t endNum ,
|
||||
bool forceDel ,
|
||||
int32_t langId,
|
||||
lang_t langId,
|
||||
void *state ,
|
||||
void (* callback) (void *state ) ) ;
|
||||
|
||||
|
@ -38,7 +38,7 @@ Query::Query()
|
||||
m_numTerms = 0;
|
||||
|
||||
// Coverity
|
||||
m_langId = 0;
|
||||
m_langId = langUnknown;
|
||||
m_useQueryStopWords = false;
|
||||
m_allowHighFreqTermCache = false;
|
||||
m_numTermsUntruncated = 0;
|
||||
@ -96,13 +96,13 @@ void Query::reset ( ) {
|
||||
// This is used for term highlighting (Highlight.cpp and Summary.cpp)
|
||||
bool Query::set2 ( const char *query ,
|
||||
// need language for doing synonyms
|
||||
uint8_t langId ,
|
||||
lang_t langId ,
|
||||
bool queryExpansion ,
|
||||
bool useQueryStopWords ,
|
||||
bool allowHighFreqTermCache,
|
||||
int32_t maxQueryTerms ) {
|
||||
log(LOG_DEBUG,"query: set2(query='%s', langId=%d, queryExpansion=%s, useQueryStopWords=%s maxQueryTerms=%d)",
|
||||
query, langId, queryExpansion?"true":"false", useQueryStopWords?"true":"false", maxQueryTerms);
|
||||
query, (int)langId, queryExpansion?"true":"false", useQueryStopWords?"true":"false", maxQueryTerms);
|
||||
|
||||
reset();
|
||||
|
||||
|
5
Query.h
5
Query.h
@ -6,6 +6,7 @@
|
||||
#define GB_QUERY_H
|
||||
|
||||
#include "SafeBuf.h"
|
||||
#include "Lang.h"
|
||||
class CollectionRec;
|
||||
|
||||
|
||||
@ -412,7 +413,7 @@ class Query {
|
||||
// . returns false and sets g_errno on error
|
||||
// . after calling this you can call functions below
|
||||
bool set2 ( const char *query ,
|
||||
uint8_t langId ,
|
||||
lang_t langId ,
|
||||
bool queryExpansion ,
|
||||
bool useQueryStopWords,
|
||||
bool allowHighFreqTermCache,
|
||||
@ -467,7 +468,7 @@ public:
|
||||
|
||||
public:
|
||||
// language of the query
|
||||
uint8_t m_langId;
|
||||
lang_t m_langId;
|
||||
|
||||
bool m_useQueryStopWords;
|
||||
|
||||
|
@ -19,7 +19,7 @@ SearchInput::SearchInput() {
|
||||
m_cr = NULL;
|
||||
m_isMasterAdmin = false;
|
||||
m_isCollAdmin = false;
|
||||
m_queryLangId = 0;
|
||||
m_queryLangId = langUnknown;
|
||||
m_format = 0;
|
||||
m_START = 0;
|
||||
m_coll = NULL;
|
||||
|
@ -73,7 +73,7 @@ public:
|
||||
|
||||
// we convert m_defaultSortLang to this number, like langEnglish
|
||||
// or langFrench or langUnknown...
|
||||
int32_t m_queryLangId;
|
||||
lang_t m_queryLangId;
|
||||
|
||||
// can be 1 for FORMAT_HTML, 2 = FORMAT_XML, 3=FORMAT_JSON, 4=csv
|
||||
int32_t m_format;
|
||||
|
@ -16062,7 +16062,7 @@ Query *XmlDoc::getQuery() {
|
||||
int64_t start = logQueryTimingStart();
|
||||
|
||||
// return NULL with g_errno set on error
|
||||
if (!m_query.set2(m_req->ptr_qbuf, m_req->m_langId, m_req->m_queryExpansion, m_req->m_useQueryStopWords, m_req->m_allowHighFrequencyTermCache)) {
|
||||
if (!m_query.set2(m_req->ptr_qbuf, (lang_t)m_req->m_langId, m_req->m_queryExpansion, m_req->m_useQueryStopWords, m_req->m_allowHighFrequencyTermCache)) {
|
||||
if(!g_errno)
|
||||
g_errno = EBADENGINEER; //can fail due to a multitude of problems
|
||||
return NULL;
|
||||
|
Loading…
x
Reference in New Issue
Block a user