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

Comparing FeepingCreaturism/Jargon.cpp (file contents):
Revision 254 by Douglas Thrift, 2004-09-14T17:42:21-07:00 vs.
Revision 352 by douglas, 2004-12-17T17:50:49-08:00

# Line 5 | Line 5
5   // $Id$
6  
7   #include "Jargon.hpp"
8 < #include "Matcher.hpp"
8 > #include "Matcher/Matcher.hpp"
9  
10 < Jargon::Jargon(const ext::String& path, const ext::String& jargon, bool include,
11 <        const ext::String& relative) : include(include),
12 <        args(1, FeepingCreaturism::program)
10 > Jargon::Jargon(const ext::String& path, const ext::String& jargon, bool include, const ext::String& relative) : include(include)
11   {
12 <        args.push_back("-m");
13 <        args.push_back("-p");
14 <        args.push_back("jargon");
15 <        args.push_back("\"" + jargon + "\"");
16 <        args.push_back("-p");
17 <        args.push_back("include");
20 <        args.push_back(lexical_cast<ext::String>(include) + "()");
12 >        args.InsertLast("--stringparam");
13 >        args.InsertLast("jargon");
14 >        args.InsertLast(jargon);
15 >        args.InsertLast("--param");
16 >        args.InsertLast("include");
17 >        args.InsertLast(ios::String() << include << "()");
18  
19          if (!relative.IsEmpty())
20          {
21 <                args.push_back("-p");
22 <                args.push_back("relative");
23 <                args.push_back("\"" + relative + "\"");
21 >                args.InsertLast("--stringparam");
22 >                args.InsertLast("relative");
23 >                args.InsertLast(relative);
24          }
25  
26 <        args.push_back(path + "/" + jargon);
27 <        args.push_back("jargon.xsl");
26 >        args.InsertLast("jargon.xsl");
27 >        args.InsertLast(ios::String() << path << "/" << jargon);
28   }
29  
30   ios::PrintWriter& operator<<(ios::PrintWriter& pout, const Jargon& jargon)
31   {
32 <        redi::ipstream pin("/usr/local/bin/Xalan", jargon.args);
32 >        _S<api::Process> xslt("/usr/local/bin/xsltproc", jargon.args);
33  
34 <        if (jargon.include)
38 <        {
39 <                std::string ignore;
40 <
41 <                std::getline(pin, ignore);
42 <        }
34 >        if (jargon.include) ios::ReadLine(*xslt.GetReader());
35  
36 <        do
36 >        if (jargon.include)
37          {
38 <                std::string line;
39 <
48 <                std::getline(pin, line);
38 >                ext::String line;
39 >                Matcher matcher("^(.*) xmlns=\"http://www.w3.org/1999/xhtml\"(.*)$");
40  
41 <                while (jargon.include && line.find(" xmlns=") != std::string::npos)
41 >                while (ios::ReadLine(*xslt.GetReader(), line))
42                  {
43 <                        std::string::size_type position(line.find(" xmlns="));
43 >                        while (line == matcher) line = matcher[1] + matcher[2];
44  
45 <                        line.replace(position, 37, "");
45 >                        pout << line << ios::NewLine;
46                  }
56
57                pout << line << "\n";
47          }
48 <        while (pin.good());
48 >        else ios::ReadToWrite(*xslt.GetReader(), pout);
49  
50          return pout;
51   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines