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 276 by Douglas Thrift, 2004-11-13T00:45:59-08:00 vs.
Revision 288 by douglas, 2004-12-09T22:47:17-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>
11   #include <menes-api/files.hpp>
12   #include <menes-app/application.hpp>
13 + #include <menes-ext/stack.hpp>
14  
15   struct IffyCommand : public app::Application
16   {
# Line 82 | 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);
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 << ios::Flush;
91 <
92 <                text = false;
91 >                cleaner.insert(segment);
92          }
93          else
94          {
95 +                Matcher matcher;
96 +
97 +                if (segment == matcher("^!--( \\(\\d{1,2}:\\d{2}:\\d{2} [AP]M\\))--$"))
98 +                {
99 +                        cleaner.insert(matcher[1]);
100 +
101 +                        continue;
102 +                }
103 +
104                  Tag tag(segment);
105  
106                  if (tag == "br") tag = STANDALONE;
107  
108 <                // XXX: automagically fix
108 >                cleaner.insert(tag);
109 >        }
110  
111 <                fout << tag << ios::Flush;
111 >        cleaner.clean();
112  
113 <                text = true;
114 <        }
113 >        ios::FormatWriter fout(out);
114 >
115 >        fout << cleaner;
116   }
117  
118   bool Iffy::read(ios::Reader& in, ext::String& segment, bool text)
119   {
120          segment.Clear();
121  
122 <        byte_t atom;
122 >        utf8_t atom;
123  
124          while (in.Get(atom))
125          {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines