ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/proj/trunk/Search/Processor.cpp
(Generate patch)

Comparing trunk/Search/Processor.cpp (file contents):
Revision 315 by douglas, 2004-02-20T18:58:09-08:00 vs.
Revision 316 by douglas, 2004-03-08T22:21:46-08:00

# Line 46 | Line 46
46   //
47   // Douglas Thrift
48   //
49 < // $Id: Processor.cpp,v 1.10 2004/02/21 02:58:09 douglas Exp $
49 > // $Id: Processor.cpp,v 1.11 2004/03/09 06:21:46 douglas Exp $
50  
51   #include "Processor.h"
52  
# Line 75 | Line 75 | bool Processor::process(HttpHandler& htt
75                  entities(title, "&gt;", '>');
76                  entities(title, "&quot;", '\"');
77                  entities(title, "&amp;", '&');
78
78                  entities(description, "&nbsp;", ' ');
79                  entities(description, "&lt;", '<');
80                  entities(description, "&gt;", '>');
81                  entities(description, "&quot;", '\"');
82                  entities(description, "&amp;", '&');
84
83                  entities(text, "&nbsp;", ' ');
84                  entities(text, "&lt;", '<');
85                  entities(text, "&gt;", '>');
# Line 100 | Line 98 | bool Processor::process(HttpHandler& htt
98                  normalize(title);
99                  normalize(description);
100                  normalize(text);
101 +
102                  for (int index0 = 0; index0 < headings.size(); index0++)
103                  {
104                          normalize(headings[index0]);
# Line 108 | Line 107 | bool Processor::process(HttpHandler& htt
107          else
108          {
109                  string line;
110 +
111                  while (http.good())
112                  {
113                          http.getline(line);
# Line 131 | Line 131 | bool Processor::process(HttpHandler& htt
131   void Processor::reset()
132   {
133          links.clear();
134 +
135          delete page;
136 +
137          page = new Page();
138   }
139  
# Line 140 | Line 142 | bool Processor::process(HttpHandler& htt
142   {
143          bool inHtml = false, inHead = false, inTitle = false, inBody = false,
144                  inHeading = false, inComment = false, follow = true, answer = true;
143        unsigned startComment = 0, finishComment = 0;
145          string line, heading;
146  
147          while (http.good())
148          {
149                  http.getline(line);
150  
151 <                unsigned begin = 0;
151 >                unsigned begin = 0, startComment = 0;
152 >
153                  while (begin < line.length())
154                  {
155                          unsigned open = line.find('<', begin);
156                          unsigned close = line.find('>', begin);
155
157                          string next;
158 +
159                          while (close == string::npos && http.good())
160                          {
161                                  http.getline(next);
# Line 189 | Line 191 | bool Processor::process(HttpHandler& htt
191                                  {
192                                          heading += between + "\n";
193                                  }
194 +
195                                  if (((lowerTag.find("meta ") == 0) || (lowerTag.find("meta\n")
196                                          == 0) || (lowerTag.find("meta   ") == 0)) && inHead)
197                                  {
# Line 301 | Line 304 | bool Processor::process(HttpHandler& htt
304  
305                          if (lowerTag.find("html") == 0) inHtml = true;
306                          if (lowerTag.find("/html") == 0) inHtml = false;
304
307                          if (lowerTag.find("head") == 0) inHead = true;
308                          if (lowerTag.find("/head") == 0) inHead = false;
307
309                          if (lowerTag.find("title") == 0) inTitle = true;
310                          if (lowerTag.find("/title") == 0) inTitle = false;
310
311                          if (lowerTag.find("body") == 0 || lowerTag.find("noframes") == 0)
312                                  inBody = true;
313                          if (lowerTag.find("/body") == 0 || lowerTag.find("/noframes") == 0)
# Line 320 | Line 320 | bool Processor::process(HttpHandler& htt
320                                  heading = "";
321                                  inHeading = true;
322                          }
323 +
324                          if (lowerTag.find("/h1") == 0 || lowerTag.find("/h2") == 0 ||
325                                  lowerTag.find("/h3") == 0 || lowerTag.find("/h4") == 0 ||
326                                  lowerTag.find("/h5") == 0 || lowerTag.find("/h6") == 0)
327                          {
328                                  if (heading != "") headings.push_back(heading);
329 +
330                                  inHeading = false;
331                          }
332  
# Line 333 | Line 335 | bool Processor::process(HttpHandler& htt
335                                  startComment = open;
336                                  inComment = true;
337                          }
338 +
339                          if (line.find("-->", begin) >= startComment && line.find("-->",
340                                  begin) != string::npos)
341                          {
342 <                                finishComment = line.find("-->", begin) + 3;
342 >                                close = line.find("-->", begin) + 3;
343                                  inComment = false;
344                          }
345  
# Line 349 | Line 352 | bool Processor::process(HttpHandler& htt
352                                  begin = close + 1;
353                          }
354                  }
352
353                startComment = 0;
354                finishComment = 0;
355          }
356  
357          return answer;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines