From ebe76b73a95178dcb97c6311155d0b037ca21784 Mon Sep 17 00:00:00 2001 From: Marcel Baur Date: Wed, 10 Mar 1999 15:11:01 +0000 Subject: [PATCH] Added Boyer-Moore text search. --- programs/notepad/ChangeLog | 19 +++++++----- programs/notepad/Makefile.in | 3 +- programs/notepad/search.c | 56 ++++++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+), 8 deletions(-) create mode 100644 programs/notepad/search.c diff --git a/programs/notepad/ChangeLog b/programs/notepad/ChangeLog index b2db9b0f7a8..17960852ffd 100644 --- a/programs/notepad/ChangeLog +++ b/programs/notepad/ChangeLog @@ -1,3 +1,7 @@ +Fri Mar 5 22:14:13 1999 Marcel Baur + * NEW [search.c] + - Added Boyer-Moore text search + Sat Feb 6 20:25:25 1999 Marcel Baur - Added new IDS_NOTSAVED ressource (needs translation in *.rc) - Improved printing support (not yet complete) @@ -6,20 +10,20 @@ Sat Feb 6 20:25:25 1999 Marcel Baur Thu Jan 28 18:17:08 1999 Jukka Iivonen - * [Fi.rc] [main.c] [Makefile.in] - Added Finnish language support. - + * [Fi.rc] [main.c] [Makefile.in] + - Added Finnish language support. + Sun Oct 18 14:11:42 1998 Marcel Baur * [??.rc], [TODO], [dialog.c], [dialog.h], [language.c], [language.h], [license.c], [license.h], [main.c], [main.h], [notepad.rc]: - - Fixed GetOpenFileName and GetSaveFileName dialogs. - - Fixed Print dialog and introduced PrinterSetup dialog. - - Fixed PageSetup dialog: values are now correctly initialized + - Fixed GetOpenFileName and GetSaveFileName dialogs. + - Fixed Print dialog and introduced PrinterSetup dialog. + - Fixed PageSetup dialog: values are now correctly initialized (had to change all *.rc files) - - Preliminary file drag and drop support. + - Preliminary file drag and drop support. Fri Jun 12 23:29:44 1998 Marcel Baur - Fixed GetDateFormat()->GetTimeFormat() for locale time. @@ -73,3 +77,4 @@ Fri Dec 05 20:51:55 1997 Marcel Baur [README] [TODO] [ChangeLog] - Originals by Marcel Baur + diff --git a/programs/notepad/Makefile.in b/programs/notepad/Makefile.in index 3d0cbad211b..581f40aa9da 100644 --- a/programs/notepad/Makefile.in +++ b/programs/notepad/Makefile.in @@ -16,7 +16,8 @@ MOSTSRCS = \ license.c \ main.c \ dialog.c \ - language.c + language.c \ + search.c # Some strings need addresses >= 0x10000 STRINGSRCS = \ diff --git a/programs/notepad/search.c b/programs/notepad/search.c new file mode 100644 index 00000000000..c6218dae54a --- /dev/null +++ b/programs/notepad/search.c @@ -0,0 +1,56 @@ +/* + * Notepad (search.c) + * Copyright (C) 1999 by Marcel Baur + * To be distributed under the Wine license + * + * This file features Heuristic Boyer-Moore Text Search + * + * Always: - Buf is the Buffer containing the whole text + * ======= - SP is the Search Pattern, which has to be found in Buf. + * + */ + + #include + + #define CHARSETSIZE 255 + + int delta[CHARSETSIZE]; + + /* rightmostpos: return rightmost position of ch in szSP (or -1) */ + int rightmostpos(char ch, LPSTR szSP, int nSPLen) { + int i = nSPLen; + while ((i>0) & (szSP[i]!=ch)) i--; + return(i); + } + + /* setup_delta: setup delta1 cache */ + void setup_delta(LPSTR szSP, int nSPLen) { + int i; + + for (i=0; i delta[szBuf[i]]) { + i+= (nSPLen-j+1); + } else { + i+= delta[szBuf[i]]; + } + } + } while (j>0 && i<=nBufLen); + return(i+1); + } +