the auto build, 20111127 release I am having problems with. this gets stuck in
a forever loop with lwi==0 and it shouldn't.
this is not by any means a complete program. but I am almost sure this is a
bug in the compiler (code generator?).
what I end up with is it has a forever loop and lwi the for loop index NEVER
increments beyond 0.
you can zap out all the debug ifdefs if you want. what I get is a zillion of
these, start to forever:
[FFMWPIL:OFF-word:lwi=0:wi=0:lwi+wi=0:lwsize=7:lineword=1:word=timothy]
Jim Michaels
Fri 02/03/2012
16:17:14.90|C:\prj\find-in-lines-in-files\find-in-lines-in-files-1.1|>%cpp32%
--version
i686-w64-mingw32-g++.exe (GCC) 4.7.0 20111127 (experimental)
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Fri 02/03/2012
16:26:08.81|C:\prj\find-in-lines-in-files\find-in-lines-in-files-1.1|>
#include <vector>
#include <string>
#include <iterator>
#include <tr1/stdint.h>
#include <algorithm>
#include <iostream>
using namespace std;
typedef struct {
string word;
size_t pos;
} SWord;
//use the list of words like a phrase to match corresponding words in linewords.
bool FindMultiWordPhraseInLinewords(vector<SWord>& linewords, vector<SWord>&
words, bool isCaseInsensitive) {
//the idea is to try to continue finding matching sets of
// words phrases within linewords until then end of linewords is reached.
size_t lwi=0, newlwi;
size_t wi=0, i, lwsize=linewords.size(), wsize=words.size();
bool isFirstWordFound=false, isOffWordFound=false, found=false;
if (0==wsize || 0==lwsize) {
#if defined(DEBUGFMWPIL)
cout<<"\n[FMWPIL:!empty!]"<<endl;
#endif
return false;
}
if (wsize > lwsize) {
#if defined(DEBUGFMWPIL)
cout<<"\n[FMWPIL:!toobig!]"<<endl;
#endif
return false; //no point in continuing if there are too many words to
search for
}
for (lwi=0; lwi < lwsize; lwi++) {
if (lwi <= lwsize-wsize) {
// && 0==findstr(linewords[lwi].word, words[0].word, string::npos,
isCaseInsensitive)) {
//find match
isOffWordFound=false;
for (wi=0; wi < wsize; wi++) {
if (0!=findstr(linewords[lwi+wi].word, words[wi].word,
string::npos, isCaseInsensitive)) {
#if defined(DEBUGFMWPIL)
cout<<"\n[FMWPIL:OFF-word:lwi="<<lwi<<":wi="<<wi<<":lwi+wi="<<(lwi+wi)<<":lwsize="<<lwsize<<":lineword="<<linewords[lwi+wi].word<<":word="<<words[wi].word<<"]"<<endl;
#endif
isOffWordFound=true;
break;
} else {
#if defined(DEBUGFMWPIL)
cout<<"\n[FMWPIL:MATCH-word:lwi="<<lwi<<":wi="<<wi<<":lwi+wi="<<(lwi+wi)<<":lwsize="<<lwsize<<":lineword="<<linewords[lwi+wi].word<<":word="<<words[wi].word<<"]"<<endl;
#endif
}
}
//at this point, wi==wsize or isOffWord==true.
if (isOffWordFound) {
isOffWordFound=false;
//zap the almost-phrase
for (i=0; i < wi; i++) {
#if defined(DEBUGFMWPIL)
cout<<"\n[FMWPIL:zap-almost-phrase-leftovers:lwi="<<lwi<<":i="<<i<<":lwi+i="<<(lwi+i)<<":word="<<linewords[lwi+i].word<<"]"<<endl;
#endif
linewords[lwi+i].pos=string::npos;
}
lwi+=wi-1;
wi=0;
} else {
//wi==wsize, reached past end of
#if defined(DEBUGFMWPIL)
cout<<"\n[FMWPIL:!found!]"<<endl;
#endif
found=true;
lwi+=wsize-1;
wi=0;
}
} else {
//didn't find a match
#if defined(DEBUGFMWPIL)
cout<<"\n[FMWPIL:zap-no-match:lwi="<<lwi<<":word="<<linewords[lwi].word<<"]"<<endl;
#endif
linewords[lwi].pos=string::npos;
}
}
return found;
}
-------------
Jim Michaels
[email protected]
[email protected]
http://JimsComputerRepairandWebDesign.com
http://JesusnJim.com (my personal site, has software)
---
Computer memory measurements, SSD measurements, microsoft disk size
measurements (note: they will say GB or MB or KB or TB when it is not!):
[KiB] [MiB] [GiB] [TiB]
[2^10B=1,024B=1KiB]
[2^20B=1,048,576B=1MiB]
[2^30B=1,073,741,824B=1GiB]
[2^40B=1,099,511,627,776B=1TiB]
hard disk industry disk size measurements:
[KB] [MB] [GB] [TB]
[10^3B=1,000B=1KB]
[10^6B=1,000,000B=1MB]
[10^9B=1,000,000,000B=1GB]
[10^12B=1,000,000,000,000B=1TB]------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public