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 281 by Douglas Thrift, 2004-11-14T14:41:47-08:00

# Line 10 | Line 10
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 81 | Line 82 | bool Iffy::debug(false);
82  
83   void Iffy::iffy(ios::Reader& in, ios::Writer& out)
84   {
84        ext::String segment;
85        bool text(true);
85          ios::FormatWriter fout(out);
86  
87 <        while (read(in, segment, text)) if (text)
88 <        {
89 <                fout << segment << ios::Flush;
87 >        fout << "<html>";
88 >
89 >        ext::String segment;
90 >        bool text(false);
91 >        ext::Stack<ext::String> opens;
92  
93 <                text = false;
93 >        while (read(in, segment, (text = !text))) if (text)
94 >        {
95 >                fout << segment;
96          }
97          else
98          {
99 +                Matcher matcher;
100 +
101 +                if (segment == matcher("^!--( \\(\\d{1,2}:\\d{2}:\\d{2} [AP]M\\))--$"))
102 +                {
103 +                        fout << matcher[1];
104 +
105 +                        continue;
106 +                }
107 +
108                  Tag tag(segment);
109  
110                  if (tag == "br") tag = STANDALONE;
111  
112 <                // XXX: automagically fix
112 >                switch (tag)
113 >                {
114 >                case OPEN:
115 >                        opens.Push(tag);
116  
117 <                fout << tag << ios::Flush;
117 >                        break;
118 >                case CLOSE:
119 >                        if (tag != opens.Top()) tag = opens.Top();
120 >
121 >                        opens.Pop();
122 >
123 >                        break;
124 >                default:
125 >                        break;
126 >                }
127  
128 <                text = true;
128 >                fout << tag;
129          }
130 +
131 +        fout << "</html>\n";
132   }
133  
134   bool Iffy::read(ios::Reader& in, ext::String& segment, bool text)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines