1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxHtmlHelpData
4 // Notes: Based on htmlhelp.cpp, implementing a monolithic
5 // HTML Help controller class, by Vaclav Slavik
6 // Author: Harm van der Heijden and Vaclav Slavik
8 // Copyright: (c) Harm van der Heijden and Vaclav Slavik
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "helpdata.h"
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
25 #if wxUSE_HTML && wxUSE_STREAMS
34 #include "wx/html/helpdata.h"
35 #include "wx/tokenzr.h"
36 #include "wx/wfstream.h"
37 #include "wx/busyinfo.h"
38 #include "wx/encconv.h"
39 #include "wx/fontmap.h"
41 #include "wx/html/htmlpars.h"
42 #include "wx/html/htmldefs.h"
43 #include "wx/filename.h"
45 #include "wx/arrimpl.cpp"
46 WX_DEFINE_OBJARRAY(wxHtmlBookRecArray
)
48 //-----------------------------------------------------------------------------
49 // static helper functions
50 //-----------------------------------------------------------------------------
52 // Reads one line, stores it into buf and returns pointer to new line or NULL.
53 static const wxChar
* ReadLine(const wxChar
*line
, wxChar
*buf
, size_t bufsize
)
55 wxChar
*writeptr
= buf
;
56 wxChar
*endptr
= buf
+ bufsize
- 1;
57 const wxChar
*readptr
= line
;
59 while (*readptr
!= 0 && *readptr
!= _T('\r') && *readptr
!= _T('\n') &&
61 *(writeptr
++) = *(readptr
++);
63 while (*readptr
== _T('\r') || *readptr
== _T('\n'))
73 extern "C" int LINKAGEMODE
74 wxHtmlHelpIndexCompareFunc(const void *a
, const void *b
)
76 return wxStricmp(((wxHtmlContentsItem
*)a
)->m_Name
, ((wxHtmlContentsItem
*)b
)->m_Name
);
80 //-----------------------------------------------------------------------------
82 //-----------------------------------------------------------------------------
84 class HP_Parser
: public wxHtmlParser
87 wxObject
* GetProduct() { return NULL
; }
89 virtual void AddText(const wxChar
* WXUNUSED(txt
)) {}
93 //-----------------------------------------------------------------------------
95 //-----------------------------------------------------------------------------
97 class HP_TagHandler
: public wxHtmlTagHandler
100 wxString m_Name
, m_Page
;
104 wxHtmlContentsItem
*m_Items
;
106 wxHtmlBookRecord
*m_Book
;
109 HP_TagHandler(wxHtmlBookRecord
*b
) : wxHtmlTagHandler()
110 { m_Book
= b
; m_Items
= NULL
; m_ItemsCnt
= 0; m_Name
= m_Page
= wxEmptyString
;
111 m_Level
= 0; m_ID
= -1; }
112 wxString
GetSupportedTags() { return wxT("UL,OBJECT,PARAM"); }
113 bool HandleTag(const wxHtmlTag
& tag
);
114 void WriteOut(wxHtmlContentsItem
*& array
, int& size
);
115 void ReadIn(wxHtmlContentsItem
* array
, int size
);
119 bool HP_TagHandler::HandleTag(const wxHtmlTag
& tag
)
121 if (tag
.GetName() == wxT("UL"))
128 else if (tag
.GetName() == wxT("OBJECT"))
130 m_Name
= m_Page
= wxEmptyString
;
134 if (!m_Page
.IsEmpty())
135 /* Valid HHW's file may contain only two object tags:
137 <OBJECT type="text/site properties">
138 <param name="ImageType" value="Folder">
143 <OBJECT type="text/sitemap">
144 <param name="Name" value="main page">
145 <param name="Local" value="another.htm">
148 We're interested in the latter. !m_Page.IsEmpty() is valid
149 condition because text/site properties does not contain Local param
152 if (tag
.GetParam(wxT("TYPE")) == wxT("text/sitemap"))
154 if (m_ItemsCnt
% wxHTML_REALLOC_STEP
== 0)
155 m_Items
= (wxHtmlContentsItem
*) realloc(m_Items
,
156 (m_ItemsCnt
+ wxHTML_REALLOC_STEP
) *
157 sizeof(wxHtmlContentsItem
));
159 m_Items
[m_ItemsCnt
].m_Level
= m_Level
;
160 m_Items
[m_ItemsCnt
].m_ID
= m_ID
;
161 m_Items
[m_ItemsCnt
].m_Page
= new wxChar
[m_Page
.Length() + 1];
162 wxStrcpy(m_Items
[m_ItemsCnt
].m_Page
, m_Page
.c_str());
163 m_Items
[m_ItemsCnt
].m_Name
= new wxChar
[m_Name
.Length() + 1];
164 wxStrcpy(m_Items
[m_ItemsCnt
].m_Name
, m_Name
.c_str());
165 m_Items
[m_ItemsCnt
].m_Book
= m_Book
;
173 if (m_Name
== wxEmptyString
&& tag
.GetParam(wxT("NAME")) == wxT("Name"))
174 m_Name
= tag
.GetParam(wxT("VALUE"));
175 if (tag
.GetParam(wxT("NAME")) == wxT("Local"))
176 m_Page
= tag
.GetParam(wxT("VALUE"));
177 if (tag
.GetParam(wxT("NAME")) == wxT("ID"))
178 tag
.GetParamAsInt(wxT("VALUE"), &m_ID
);
185 void HP_TagHandler::WriteOut(wxHtmlContentsItem
*& array
, int& size
)
193 void HP_TagHandler::ReadIn(wxHtmlContentsItem
* array
, int size
)
202 //-----------------------------------------------------------------------------
204 //-----------------------------------------------------------------------------
206 wxString
wxHtmlBookRecord::GetFullPath(const wxString
&page
) const
208 if (wxIsAbsolutePath(page
))
211 return m_BasePath
+ page
;
216 IMPLEMENT_DYNAMIC_CLASS(wxHtmlHelpData
, wxObject
)
218 wxHtmlHelpData::wxHtmlHelpData()
220 m_TempPath
= wxEmptyString
;
228 wxHtmlHelpData::~wxHtmlHelpData()
232 m_BookRecords
.Empty();
235 for (i
= 0; i
< m_ContentsCnt
; i
++)
237 delete[] m_Contents
[i
].m_Page
;
238 delete[] m_Contents
[i
].m_Name
;
244 for (i
= 0; i
< m_IndexCnt
; i
++)
246 delete[] m_Index
[i
].m_Page
;
247 delete[] m_Index
[i
].m_Name
;
253 // defined in htmlfilt.cpp
254 void wxPrivate_ReadString(wxString
& str
, wxInputStream
* s
);
256 bool wxHtmlHelpData::LoadMSProject(wxHtmlBookRecord
*book
, wxFileSystem
& fsys
, const wxString
& indexfile
, const wxString
& contentsfile
)
263 HP_TagHandler
*handler
= new HP_TagHandler(book
);
264 parser
.AddTagHandler(handler
);
266 f
= ( contentsfile
.IsEmpty() ? (wxFSFile
*) NULL
: fsys
.OpenFile(contentsfile
) );
270 wxPrivate_ReadString(buf
, f
->GetStream());
272 handler
->ReadIn(m_Contents
, m_ContentsCnt
);
274 handler
->WriteOut(m_Contents
, m_ContentsCnt
);
277 wxLogError(_("Cannot open contents file: %s"), contentsfile
.c_str());
279 f
= ( indexfile
.IsEmpty() ? (wxFSFile
*) NULL
: fsys
.OpenFile(indexfile
) );
283 wxPrivate_ReadString(buf
, f
->GetStream());
285 handler
->ReadIn(m_Index
, m_IndexCnt
);
287 handler
->WriteOut(m_Index
, m_IndexCnt
);
289 else if (!indexfile
.IsEmpty())
290 wxLogError(_("Cannot open index file: %s"), indexfile
.c_str());
296 inline static void CacheWriteInt32(wxOutputStream
*f
, wxInt32 value
)
298 wxInt32 x
= wxINT32_SWAP_ON_BE(value
);
299 f
->Write(&x
, sizeof(x
));
302 inline static wxInt32
CacheReadInt32(wxInputStream
*f
)
305 f
->Read(&x
, sizeof(x
));
306 return wxINT32_SWAP_ON_BE(x
);
309 inline static void CacheWriteString(wxOutputStream
*f
, const wxChar
*str
)
311 size_t len
= wxStrlen(str
)+1;
312 CacheWriteInt32(f
, len
);
313 f
->Write(str
, len
* sizeof(wxChar
));
316 inline static wxChar
*CacheReadString(wxInputStream
*f
)
319 size_t len
= (size_t)CacheReadInt32(f
);
320 str
= new wxChar
[len
];
321 f
->Read(str
, len
* sizeof(wxChar
));
325 #define CURRENT_CACHED_BOOK_VERSION 2
327 bool wxHtmlHelpData::LoadCachedBook(wxHtmlBookRecord
*book
, wxInputStream
*f
)
332 /* load header - version info : */
333 version
= CacheReadInt32(f
);
335 if (version
!= CURRENT_CACHED_BOOK_VERSION
)
337 // NB: We can just silently return FALSE here and don't worry about
338 // it anymore, because AddBookParam will load the MS project in
339 // absence of (properly versioned) .cached file and automatically
340 // create new .cached file immediately afterward.
344 /* load contents : */
346 m_ContentsCnt
+= CacheReadInt32(f
);
347 m_Contents
= (wxHtmlContentsItem
*) realloc(m_Contents
,
348 (m_ContentsCnt
/ wxHTML_REALLOC_STEP
+ 1) *
349 wxHTML_REALLOC_STEP
* sizeof(wxHtmlContentsItem
));
350 for (i
= st
; i
< m_ContentsCnt
; i
++)
352 m_Contents
[i
].m_Level
= CacheReadInt32(f
);
353 m_Contents
[i
].m_ID
= CacheReadInt32(f
);
354 m_Contents
[i
].m_Name
= CacheReadString(f
);
355 m_Contents
[i
].m_Page
= CacheReadString(f
);
356 m_Contents
[i
].m_Book
= book
;
361 m_IndexCnt
+= CacheReadInt32(f
);
362 m_Index
= (wxHtmlContentsItem
*) realloc(m_Index
, (m_IndexCnt
/ wxHTML_REALLOC_STEP
+ 1) *
363 wxHTML_REALLOC_STEP
* sizeof(wxHtmlContentsItem
));
364 for (i
= st
; i
< m_IndexCnt
; i
++)
366 m_Index
[i
].m_Name
= CacheReadString(f
);
367 m_Index
[i
].m_Page
= CacheReadString(f
);
368 m_Index
[i
].m_Book
= book
;
374 bool wxHtmlHelpData::SaveCachedBook(wxHtmlBookRecord
*book
, wxOutputStream
*f
)
379 /* save header - version info : */
380 CacheWriteInt32(f
, CURRENT_CACHED_BOOK_VERSION
);
382 /* save contents : */
383 for (cnt
= 0, i
= 0; i
< m_ContentsCnt
; i
++)
384 if (m_Contents
[i
].m_Book
== book
&& m_Contents
[i
].m_Level
> 0)
386 CacheWriteInt32(f
, cnt
);
388 for (i
= 0; i
< m_ContentsCnt
; i
++)
390 if (m_Contents
[i
].m_Book
!= book
|| m_Contents
[i
].m_Level
== 0)
392 CacheWriteInt32(f
, m_Contents
[i
].m_Level
);
393 CacheWriteInt32(f
, m_Contents
[i
].m_ID
);
394 CacheWriteString(f
, m_Contents
[i
].m_Name
);
395 CacheWriteString(f
, m_Contents
[i
].m_Page
);
399 for (cnt
= 0, i
= 0; i
< m_IndexCnt
; i
++)
400 if (m_Index
[i
].m_Book
== book
&& m_Index
[i
].m_Level
> 0)
402 CacheWriteInt32(f
, cnt
);
404 for (i
= 0; i
< m_IndexCnt
; i
++)
406 if (m_Index
[i
].m_Book
!= book
|| m_Index
[i
].m_Level
== 0)
408 CacheWriteString(f
, m_Index
[i
].m_Name
);
409 CacheWriteString(f
, m_Index
[i
].m_Page
);
415 void wxHtmlHelpData::SetTempDir(const wxString
& path
)
417 if (path
== wxEmptyString
) m_TempPath
= path
;
420 if (wxIsAbsolutePath(path
)) m_TempPath
= path
;
421 else m_TempPath
= wxGetCwd() + _T("/") + path
;
423 if (m_TempPath
[m_TempPath
.Length() - 1] != _T('/'))
424 m_TempPath
<< _T('/');
430 static wxString
SafeFileName(const wxString
& s
)
433 res
.Replace(wxT("#"), wxT("_"));
434 res
.Replace(wxT(":"), wxT("_"));
435 res
.Replace(wxT("\\"), wxT("_"));
436 res
.Replace(wxT("/"), wxT("_"));
440 bool wxHtmlHelpData::AddBookParam(const wxFSFile
& bookfile
,
441 wxFontEncoding encoding
,
442 const wxString
& title
, const wxString
& contfile
,
443 const wxString
& indexfile
, const wxString
& deftopic
,
444 const wxString
& path
)
448 wxHtmlBookRecord
*bookr
;
450 int IndexOld
= m_IndexCnt
,
451 ContentsOld
= m_ContentsCnt
;
454 fsys
.ChangePathTo(path
, TRUE
);
456 size_t booksCnt
= m_BookRecords
.GetCount();
457 for (size_t i
= 0; i
< booksCnt
; i
++)
459 if ( m_BookRecords
[i
].GetBookFile() == bookfile
.GetLocation() )
460 return TRUE
; // book is (was) loaded
463 bookr
= new wxHtmlBookRecord(bookfile
.GetLocation(), fsys
.GetPath(), title
, deftopic
);
465 if (m_ContentsCnt
% wxHTML_REALLOC_STEP
== 0)
466 m_Contents
= (wxHtmlContentsItem
*) realloc(m_Contents
, (m_ContentsCnt
+ wxHTML_REALLOC_STEP
) * sizeof(wxHtmlContentsItem
));
467 m_Contents
[m_ContentsCnt
].m_Level
= 0;
468 m_Contents
[m_ContentsCnt
].m_ID
= 0;
469 m_Contents
[m_ContentsCnt
].m_Page
= new wxChar
[deftopic
.Length() + 1];
470 wxStrcpy(m_Contents
[m_ContentsCnt
].m_Page
, deftopic
.c_str());
471 m_Contents
[m_ContentsCnt
].m_Name
= new wxChar
[title
.Length() + 1];
472 wxStrcpy(m_Contents
[m_ContentsCnt
].m_Name
, title
.c_str());
473 m_Contents
[m_ContentsCnt
].m_Book
= bookr
;
475 // store the contents index for later
476 int cont_start
= m_ContentsCnt
++;
478 // Try to find cached binary versions:
479 // 1. save file as book, but with .hhp.cached extension
480 // 2. same as 1. but in temp path
481 // 3. otherwise or if cache load failed, load it from MS.
483 fi
= fsys
.OpenFile(bookfile
.GetLocation() + wxT(".cached"));
486 fi
->GetModificationTime() < bookfile
.GetModificationTime() ||
487 !LoadCachedBook(bookr
, fi
->GetStream()))
489 if (fi
!= NULL
) delete fi
;
490 fi
= fsys
.OpenFile(m_TempPath
+ wxFileNameFromPath(bookfile
.GetLocation()) + wxT(".cached"));
491 if (m_TempPath
== wxEmptyString
|| fi
== NULL
||
492 fi
->GetModificationTime() < bookfile
.GetModificationTime() ||
493 !LoadCachedBook(bookr
, fi
->GetStream()))
495 LoadMSProject(bookr
, fsys
, indexfile
, contfile
);
496 if (m_TempPath
!= wxEmptyString
)
498 wxFileOutputStream
*outs
= new wxFileOutputStream(m_TempPath
+
499 SafeFileName(wxFileNameFromPath(bookfile
.GetLocation())) + wxT(".cached"));
500 SaveCachedBook(bookr
, outs
);
506 if (fi
!= NULL
) delete fi
;
508 // Now store the contents range
509 bookr
->SetContentsRange(cont_start
, m_ContentsCnt
);
511 // Convert encoding, if neccessary:
512 if (encoding
!= wxFONTENCODING_SYSTEM
)
514 wxFontEncodingArray a
= wxEncodingConverter::GetPlatformEquivalents(encoding
);
515 if (a
.GetCount() != 0 && a
[0] != encoding
)
518 wxEncodingConverter conv
;
519 conv
.Init(encoding
, a
[0]);
521 for (i
= IndexOld
; i
< m_IndexCnt
; i
++)
522 conv
.Convert(m_Index
[i
].m_Name
);
523 for (i
= ContentsOld
; i
< m_ContentsCnt
; i
++)
524 conv
.Convert(m_Contents
[i
].m_Name
);
528 m_BookRecords
.Add(bookr
);
530 qsort(m_Index
, m_IndexCnt
, sizeof(wxHtmlContentsItem
), wxHtmlHelpIndexCompareFunc
);
536 bool wxHtmlHelpData::AddBook(const wxString
& book
)
538 if (book
.Right(4).Lower() == wxT(".zip") ||
539 book
.Right(4).Lower() == wxT(".htb") /*html book*/)
545 s
= fsys
.FindFirst(book
+ wxT("#zip:") + wxT("*.hhp"), wxFILE
);
548 if (AddBook(s
)) rt
= TRUE
;
561 wxString title
= _("noname"),
563 start
= wxEmptyString
,
564 contents
= wxEmptyString
,
565 index
= wxEmptyString
,
566 charset
= wxEmptyString
;
568 #if defined(__WXMAC__) && !defined(__DARWIN__)
569 if (wxIsAbsolutePath(book
)) bookFull
= book
;
570 else bookFull
= wxGetCwd() + book
; // no slash or dot
571 wxFileName
fn( bookFull
);
572 bookFull
= fn
.GetFullPath( wxPATH_UNIX
);
574 if (wxIsAbsolutePath(book
)) bookFull
= book
;
575 else bookFull
= wxGetCwd() + "/" + book
;
578 fi
= fsys
.OpenFile(bookFull
);
581 wxLogError(_("Cannot open HTML help book: %s"), bookFull
.c_str());
584 fsys
.ChangePathTo(bookFull
);
587 const wxChar
*lineptr
;
591 wxPrivate_ReadString(tmp
, s
);
592 lineptr
= tmp
.c_str();
596 lineptr
= ReadLine(lineptr
, linebuf
, 300);
598 for (wxChar
*ch
= linebuf
; *ch
!= '\0' && *ch
!= '='; ch
++)
601 if (wxStrstr(linebuf
, _T("title=")) == linebuf
)
602 title
= linebuf
+ wxStrlen(_T("title="));
603 if (wxStrstr(linebuf
, _T("default topic=")) == linebuf
)
604 start
= linebuf
+ wxStrlen(_T("default topic="));
605 if (wxStrstr(linebuf
, _T("index file=")) == linebuf
)
606 index
= linebuf
+ wxStrlen(_T("index file="));
607 if (wxStrstr(linebuf
, _T("contents file=")) == linebuf
)
608 contents
= linebuf
+ wxStrlen(_T("contents file="));
609 if (wxStrstr(linebuf
, _T("charset=")) == linebuf
)
610 charset
= linebuf
+ wxStrlen(_T("charset="));
611 } while (lineptr
!= NULL
);
614 if (charset
== wxEmptyString
) enc
= wxFONTENCODING_SYSTEM
;
615 else enc
= wxFontMapper::Get()->CharsetToEncoding(charset
);
616 bool rtval
= AddBookParam(*fi
, enc
,
617 title
, contents
, index
, start
, fsys
.GetPath());
623 wxString
wxHtmlHelpData::FindPageByName(const wxString
& x
)
629 wxString
url(wxEmptyString
);
631 /* 1. try to open given file: */
633 cnt
= m_BookRecords
.GetCount();
634 for (i
= 0; i
< cnt
; i
++)
636 f
= fsys
.OpenFile(m_BookRecords
[i
].GetFullPath(x
));
639 url
= m_BookRecords
[i
].GetFullPath(x
);
646 /* 2. try to find a book: */
648 for (i
= 0; i
< cnt
; i
++)
650 if (m_BookRecords
[i
].GetTitle() == x
)
652 url
= m_BookRecords
[i
].GetFullPath(m_BookRecords
[i
].GetStart());
657 /* 3. try to find in contents: */
660 for (i
= 0; i
< cnt
; i
++)
662 if (wxStrcmp(m_Contents
[i
].m_Name
, x
) == 0)
664 url
= m_Contents
[i
].GetFullPath();
670 /* 4. try to find in index: */
673 for (i
= 0; i
< cnt
; i
++)
675 if (wxStrcmp(m_Index
[i
].m_Name
, x
) == 0)
677 url
= m_Index
[i
].GetFullPath();
685 wxString
wxHtmlHelpData::FindPageById(int id
)
688 wxString
url(wxEmptyString
);
690 for (i
= 0; i
< m_ContentsCnt
; i
++)
692 if (m_Contents
[i
].m_ID
== id
)
694 url
= m_Contents
[i
].GetFullPath();
702 //----------------------------------------------------------------------------------
703 // wxHtmlSearchStatus functions
704 //----------------------------------------------------------------------------------
706 wxHtmlSearchStatus::wxHtmlSearchStatus(wxHtmlHelpData
* data
, const wxString
& keyword
,
707 bool case_sensitive
, bool whole_words_only
,
708 const wxString
& book
)
712 wxHtmlBookRecord
* bookr
= NULL
;
713 if (book
!= wxEmptyString
)
715 // we have to search in a specific book. Find it first
716 int i
, cnt
= data
->m_BookRecords
.GetCount();
717 for (i
= 0; i
< cnt
; i
++)
718 if (data
->m_BookRecords
[i
].GetTitle() == book
)
720 bookr
= &(data
->m_BookRecords
[i
]);
721 m_CurIndex
= bookr
->GetContentsStart();
722 m_MaxIndex
= bookr
->GetContentsEnd();
725 // check; we won't crash if the book doesn't exist, but it's Bad Anyway.
730 // no book specified; search all books
732 m_MaxIndex
= m_Data
->m_ContentsCnt
;
734 m_Engine
.LookFor(keyword
, case_sensitive
, whole_words_only
);
735 m_Active
= (m_CurIndex
< m_MaxIndex
);
739 bool wxHtmlSearchStatus::Search()
742 int i
= m_CurIndex
; // shortcut
748 // sanity check. Illegal use, but we'll try to prevent a crash anyway
753 m_Name
= wxEmptyString
;
754 m_ContentsItem
= NULL
;
755 thepage
= m_Data
->m_Contents
[i
].m_Page
;
757 m_Active
= (++m_CurIndex
< m_MaxIndex
);
758 // check if it is same page with different anchor:
759 if (m_LastPage
!= NULL
)
762 for (p1
= thepage
, p2
= m_LastPage
;
763 *p1
!= 0 && *p1
!= _T('#') && *p1
== *p2
; p1
++, p2
++) {}
765 m_LastPage
= thepage
;
767 if (*p1
== 0 || *p1
== _T('#'))
770 else m_LastPage
= thepage
;
773 file
= fsys
.OpenFile(m_Data
->m_Contents
[i
].m_Book
->GetFullPath(thepage
));
776 if (m_Engine
.Scan(file
->GetStream()))
778 m_Name
= m_Data
->m_Contents
[i
].m_Name
;
779 m_ContentsItem
= m_Data
->m_Contents
+ i
;
794 //--------------------------------------------------------------------------------
796 //--------------------------------------------------------------------------------
798 void wxSearchEngine::LookFor(const wxString
& keyword
, bool case_sensitive
, bool whole_words_only
)
800 m_CaseSensitive
= case_sensitive
;
801 m_WholeWords
= whole_words_only
;
802 if (m_Keyword
) delete[] m_Keyword
;
803 m_Keyword
= new wxChar
[keyword
.Length() + 1];
804 wxStrcpy(m_Keyword
, keyword
.c_str());
806 if (!m_CaseSensitive
)
808 for (int i
= wxStrlen(m_Keyword
) - 1; i
>= 0; i
--)
810 if ((m_Keyword
[i
] >= wxT('A')) && (m_Keyword
[i
] <= wxT('Z')))
811 m_Keyword
[i
] += wxT('a') - wxT('A');
817 static inline bool WHITESPACE(wxChar c
)
819 return c
== _T(' ') || c
== _T('\n') || c
== _T('\r') || c
== _T('\t');
822 bool wxSearchEngine::Scan(wxInputStream
*stream
)
824 wxASSERT_MSG(m_Keyword
!= NULL
, wxT("wxSearchEngine::LookFor must be called before scanning!"));
827 int wrd
= wxStrlen(m_Keyword
);
830 wxPrivate_ReadString(tmp
, stream
);
831 int lng
= tmp
.length();
832 const wxChar
*buf
= tmp
.c_str();
834 if (!m_CaseSensitive
)
835 for (i
= 0; i
< lng
; i
++)
836 tmp
[(size_t)i
] = (wxChar
)wxTolower(tmp
[(size_t)i
]);
840 for (i
= 0; i
< lng
- wrd
; i
++)
842 if (WHITESPACE(buf
[i
])) continue;
844 while ((j
< wrd
) && (buf
[i
+ j
] == m_Keyword
[j
])) j
++;
845 if (j
== wrd
&& WHITESPACE(buf
[i
+ j
])) { found
= TRUE
; break; }
851 for (i
= 0; i
< lng
- wrd
; i
++)
854 while ((j
< wrd
) && (buf
[i
+ j
] == m_Keyword
[j
])) j
++;
855 if (j
== wrd
) { found
= TRUE
; break; }