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 270 by Douglas Thrift, 2004-10-27T23:44:48-07:00

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines