ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/Iffy/Iffy.cpp
(Generate patch)

Comparing Iffy/Iffy.cpp (file contents):
Revision 278 by Douglas Thrift, 2004-11-13T14:04:03-08:00 vs.
Revision 284 by Douglas Thrift, 2004-11-18T16:37:13-08:00

# Line 4 | Line 4
4   //
5   // $Id$
6  
7 < #include "Tag.hpp"
7 > #include "Cleaner.hpp"
8   #include "Matcher.hpp"
9  
10   #include <menes-api/exename.hpp>
# Line 83 | Line 83 | bool Iffy::debug(false);
83   void Iffy::iffy(ios::Reader& in, ios::Writer& out)
84   {
85          ext::String segment;
86 <        bool text(true);
87 <        ios::FormatWriter fout(out);
88 <        ext::Stack<ext::String> opens;
86 >        bool text(false);
87 >        Cleaner cleaner;
88  
89 <        while (read(in, segment, text)) if (text)
89 >        while (read(in, segment, (text = !text))) if (text)
90          {
91 <                fout << segment;
93 <
94 <                text = false;
91 >                cleaner.insert(segment);
92          }
93          else
94          {
95 <                Tag tag(segment);
95 >                Matcher matcher;
96  
97 <                if (tag == "br") tag = STANDALONE;
101 <
102 <                switch (tag)
97 >                if (segment == matcher("^!--( \\(\\d{1,2}:\\d{2}:\\d{2} [AP]M\\))--$"))
98                  {
99 <                case OPEN:
105 <                        opens.Push(tag);
99 >                        cleaner.insert(matcher[1]);
100  
101 <                        break;
108 <                case CLOSE:
109 <                        if (tag != opens.Top()) tag = opens.Top();
110 <
111 <                        opens.Pop();
112 <
113 <                        break;
114 <                default:
115 <                        break;
101 >                        continue;
102                  }
103  
104 <                fout << tag;
104 >                Tag tag(segment);
105 >
106 >                if (tag == "br") tag = STANDALONE;
107  
108 <                text = true;
108 >                cleaner.insert(tag);
109          }
110 +
111 +        cleaner.clean();
112 +
113 +        ios::FormatWriter fout(out);
114 +
115 +        fout << cleaner;
116   }
117  
118   bool Iffy::read(ios::Reader& in, ext::String& segment, bool text)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines