]> git.tdb.fi Git - libs/datafile.git/commitdiff
Style update: add spaces around assignments
authorMikko Rasa <tdb@tdb.fi>
Wed, 3 Feb 2010 11:54:06 +0000 (11:54 +0000)
committerMikko Rasa <tdb@tdb.fi>
Wed, 3 Feb 2010 11:54:06 +0000 (11:54 +0000)
12 files changed:
source/binaryparser.cpp
source/binarywriter.cpp
source/collection.cpp
source/input.cpp
source/loader.cpp
source/parser.cpp
source/statement.cpp
source/textparser.cpp
source/textwriter.cpp
source/writer.cpp
tool/compiler.cpp
tool/tool.cpp

index 40736896c01bf13aaa789b2033050cbda5b338fc..ed1d71c8b197db64366e5e858b35ff032bc9b8df 100644 (file)
@@ -19,32 +19,32 @@ BinaryParser::BinaryParser(Input &i, const string &s):
        ParserMode(i, s),
        first(true)
 {
-       dict[1]=DictEntry("__kwd", "iss");
-       dict[2]=DictEntry("__str", "is");
+       dict[1] = DictEntry("__kwd", "iss");
+       dict[2] = DictEntry("__str", "is");
 }
 
 Statement BinaryParser::parse()
 {
        while(1)
        {
-               Statement st=parse_statement();
+               Statement st = parse_statement();
                if(st.keyword=="__kwd")
                {
                        if(st.args.size()!=3)
                                throw_at(TypeError("Keyword definition must have three arguments"), src);
 
-                       const unsigned id=st.args[0].get<unsigned>();
-                       const string &kw=st.args[1].get<const string &>();
-                       const string &args=st.args[2].get<const string &>();
-                       dict[id]=DictEntry(kw, args);
+                       const unsigned id = st.args[0].get<unsigned>();
+                       const string &kw = st.args[1].get<const string &>();
+                       const string &args = st.args[2].get<const string &>();
+                       dict[id] = DictEntry(kw, args);
                }
                else if(st.keyword=="__str")
                {
                        if(st.args.size()!=2)
                                throw_at(TypeError("String definition must have two arguments"), src);
 
-                       const unsigned id=st.args[0].get<unsigned>();
-                       strings[id]=st.args[1].get<const string &>();
+                       const unsigned id = st.args[0].get<unsigned>();
+                       strings[id] = st.args[1].get<const string &>();
                }
                else
                        return st;
@@ -55,22 +55,22 @@ Statement BinaryParser::parse_statement()
 {
        while(first && in.peek()=='\n')
                in.get();
-       first=false;
+       first = false;
 
-       unsigned id=parse_int();
+       unsigned id = parse_int();
        if(!in)
                return Statement();
 
-       Dictionary::const_iterator i=dict.find(id);
+       Dictionary::const_iterator i = dict.find(id);
        if(i==dict.end())
                throw_at(KeyError("Unknown statement ID", lexical_cast(id)), src);
-       const DictEntry &de=i->second;
+       const DictEntry &de = i->second;
 
        Statement result;
-       result.keyword=de.keyword;
-       result.source=src;
+       result.keyword = de.keyword;
+       result.source = src;
 
-       for(unsigned j=0; j<de.args.size(); ++j)
+       for(unsigned j = 0; j<de.args.size(); ++j)
        {
                switch(de.args[j])
                {
@@ -92,33 +92,33 @@ Statement BinaryParser::parse_statement()
                }
        }
 
-       unsigned nsub=parse_int();
-       for(unsigned j=0; j<nsub; ++j)
+       unsigned nsub = parse_int();
+       for(unsigned j = 0; j<nsub; ++j)
                result.sub.push_back(parse());
 
-       result.valid=true;
+       result.valid = true;
 
        return result;
 }
 
 long long BinaryParser::parse_int()
 {
-       long long result=0;
-       unsigned bits=0;
+       long long result = 0;
+       unsigned bits = 0;
 
        while(in)
        {
-               int c=in.get();
+               int c = in.get();
 
-               result=(result<<7) | (c&0x7F);
-               bits+=7;
+               result = (result<<7) | (c&0x7F);
+               bits += 7;
 
                if(!(c&0x80))
                        break;
        }
 
-       const long long mask=1LL<<(bits-1);
-       result=(result^mask)-mask;
+       const long long mask = 1LL<<(bits-1);
+       result = (result^mask)-mask;
 
        return result;
 }
@@ -132,11 +132,11 @@ float BinaryParser::parse_float()
        };
 
 #if BYTE_ORDER == LITTLE_ENDIAN
-       for(unsigned i=sizeof(float); i--;)
-               d[i]=in.get();
+       for(unsigned i = sizeof(float); i--;)
+               d[i] = in.get();
 #else
-       for(unsigned i=0; i<sizeof(float); ++i)
-               d[i]=in.get();
+       for(unsigned i = 0; i<sizeof(float); ++i)
+               d[i] = in.get();
 #endif
 
        return f;
@@ -149,13 +149,13 @@ bool BinaryParser::parse_bool()
 
 string BinaryParser::parse_string()
 {
-       int len=parse_int();
+       int len = parse_int();
        if(len>=0)
        {
                string result;
                result.reserve(len);
-               for(int i=0; i<len; ++i)
-                       result+=in.get();
+               for(int i = 0; i<len; ++i)
+                       result += in.get();
                return result;
        }
        else
@@ -169,7 +169,7 @@ string BinaryParser::parse_enum()
 
 const string &BinaryParser::lookup_string(unsigned id) const
 {
-       StringMap::const_iterator i=strings.find(id);
+       StringMap::const_iterator i = strings.find(id);
        if(i==strings.end())
                throw_at(KeyError("Unknown string", lexical_cast(id)), src);
        return i->second;
index 98dd2a9635317d56986ebff812867c263e25d5b9..0e118c9eb0ceb4542eda97752633e8f95848f9ef 100644 (file)
@@ -18,8 +18,8 @@ BinaryWriter::BinaryWriter(IO::Base &o):
        next_kwd_id(3),
        next_str_id(1)
 {
-       dict[DictEntry("__kwd", "iss")]=1;
-       dict[DictEntry("__str", "is")]=2;
+       dict[DictEntry("__kwd", "iss")] = 1;
+       dict[DictEntry("__str", "is")] = 2;
 }
 
 void BinaryWriter::write(const Statement &st)
@@ -30,12 +30,12 @@ void BinaryWriter::write(const Statement &st)
 
 void BinaryWriter::write_(const Statement &st)
 {
-       Dictionary::iterator i=dict.find(create_entry(st));
+       Dictionary::iterator i = dict.find(create_entry(st));
        if(i==dict.end())
                throw InvalidParameterValue("Unknown statement");
 
        write_int(i->second);
-       for(ValueArray::const_iterator j=st.args.begin(); j!=st.args.end(); ++j)
+       for(ValueArray::const_iterator j = st.args.begin(); j!=st.args.end(); ++j)
                switch(j->get_type())
                {
                case INTEGER: write_int   (j->get<long long>()); break;
@@ -46,20 +46,20 @@ void BinaryWriter::write_(const Statement &st)
                }
 
        write_int(st.sub.size());
-       for(list<Statement>::const_iterator j=st.sub.begin(); j!=st.sub.end(); ++j)
+       for(list<Statement>::const_iterator j = st.sub.begin(); j!=st.sub.end(); ++j)
                write(*j);
 }
 
 DictEntry BinaryWriter::create_entry(const Statement &st)
 {
-       static const char types[]="ifsbe";
+       static const char types[] = "ifsbe";
 
        string args;
-       for(ValueArray::const_iterator i=st.args.begin(); i!=st.args.end(); ++i)
+       for(ValueArray::const_iterator i = st.args.begin(); i!=st.args.end(); ++i)
        {
                if(i->get_type()>=5)
                        throw InvalidParameterValue("Invalid argument type");
-               args+=types[i->get_type()];
+               args += types[i->get_type()];
        }
 
        return DictEntry(st.keyword, args);
@@ -67,43 +67,43 @@ DictEntry BinaryWriter::create_entry(const Statement &st)
 
 void BinaryWriter::collect_keywords(const Statement &st)
 {
-       DictEntry de=create_entry(st);
+       DictEntry de = create_entry(st);
 
        if(!dict.count(de))
        {
                Statement kst;
-               kst.keyword="__kwd";
+               kst.keyword = "__kwd";
                kst.args.push_back(next_kwd_id);
                kst.args.push_back(de.keyword);
                kst.args.push_back(de.args);
                write_(kst);
 
-               dict[de]=next_kwd_id++;
+               dict[de] = next_kwd_id++;
        }
 
-       for(ValueArray::const_iterator i=st.args.begin(); i!=st.args.end(); ++i)
+       for(ValueArray::const_iterator i = st.args.begin(); i!=st.args.end(); ++i)
        {
-               const Type t=i->get_type();
-               const string &r=i->get_raw();
+               const Type t = i->get_type();
+               const string &r = i->get_raw();
                if((t==ENUM || (t==STRING && r.size()<32)) && !strings.count(r))
                {
                        Statement sst;
-                       sst.keyword="__str";
+                       sst.keyword = "__str";
                        sst.args.push_back(next_str_id);
                        sst.args.push_back(r);
                        write_(sst);
 
-                       strings[r]=next_str_id++;
+                       strings[r] = next_str_id++;
                }
        }
 
-       for(list<Statement>::const_iterator i=st.sub.begin(); i!=st.sub.end(); ++i)
+       for(list<Statement>::const_iterator i = st.sub.begin(); i!=st.sub.end(); ++i)
                collect_keywords(*i);
 }
 
 void BinaryWriter::write_int(long long n)
 {
-       unsigned i=sizeof(long long)-1;
+       unsigned i = sizeof(long long)-1;
 
        if(n>=0)
                for(; (i>0 && (n>>(i*7-1))==0); --i) ;
@@ -116,7 +116,7 @@ void BinaryWriter::write_int(long long n)
 
 void BinaryWriter::write_string(const string &s)
 {
-       StringMap::const_iterator i=strings.find(s);
+       StringMap::const_iterator i = strings.find(s);
        if(i!=strings.end())
                write_int(-static_cast<int>(i->second));
        else
@@ -134,19 +134,19 @@ void BinaryWriter::write_float(float f)
                char d[sizeof(float)];
        };
 
-       v=f;
+       v = f;
 #if BYTE_ORDER == LITTLE_ENDIAN
-       for(unsigned i=sizeof(float); i--;)
+       for(unsigned i = sizeof(float); i--;)
                out.put(d[i]);
 #else
-       for(unsigned i=0; i<sizeof(float); ++i)
+       for(unsigned i = 0; i<sizeof(float); ++i)
                out.put(d[i]);
 #endif
 }
 
 void BinaryWriter::write_enum(const string &e)
 {
-       StringMap::const_iterator i=strings.find(e);
+       StringMap::const_iterator i = strings.find(e);
        if(i==strings.end())
                throw InvalidParameterValue("Unknown enum");
        write_int(i->second);
index ea1095b39a93f61e0a14930b8e8edf039da9089e..2a567b58ce4af5271f553b58611ee8a43e29dd5c 100644 (file)
@@ -12,11 +12,11 @@ namespace DataFile {
 
 Collection::~Collection()
 {
-       for(ItemMap::iterator i=items.begin(); i!=items.end(); ++i)
+       for(ItemMap::iterator i = items.begin(); i!=items.end(); ++i)
                delete i->second;
-       for(ItemKeywordSeq::iterator i=keywords.begin(); i!=keywords.end(); ++i)
+       for(ItemKeywordSeq::iterator i = keywords.begin(); i!=keywords.end(); ++i)
                delete *i;
-       for(ItemCreatorSeq::iterator i=creators.begin(); i!=creators.end(); ++i)
+       for(ItemCreatorSeq::iterator i = creators.begin(); i!=creators.end(); ++i)
                delete *i;
 }
 
@@ -29,7 +29,7 @@ bool Collection::contains(const std::string &n) const
 Collection::Loader::Loader(Collection &c):
        coll(c)
 {      
-       for(ItemKeywordSeq::const_iterator i=coll.keywords.begin(); i!=coll.keywords.end(); ++i)
+       for(ItemKeywordSeq::const_iterator i = coll.keywords.begin(); i!=coll.keywords.end(); ++i)
                (*i)->add_to_loader(*this);
 }
 
index f3f8f23f3343fa9352a618c82f8c151f2811573e..d74c8efde0a943fb8cdb11f8f4f3281f88d21d9a 100644 (file)
@@ -17,9 +17,9 @@ Input::Input(IO::Base &i):
 
 int Input::get()
 {
-       int c=next;
-       next=-1;
-       if(c<0) c=in.get();
+       int c = next;
+       next = -1;
+       if(c<0) c = in.get();
        
        if(c=='\n')
                ++line;
@@ -30,7 +30,7 @@ int Input::get()
 int Input::peek()
 {
        if(next<0)
-               next=in.get();
+               next = in.get();
        return next;
 }
 
index 8d4f2bea35b07f0cf485cbc50a8d22fe146b5cd1..6b0557fc0b568f7a62eeeda60547697d137232b7 100644 (file)
@@ -14,7 +14,7 @@ namespace DataFile {
 
 void Loader::load(const Statement &st)
 {
-       for(list<Statement>::const_iterator i=st.sub.begin(); i!=st.sub.end(); ++i)
+       for(list<Statement>::const_iterator i = st.sub.begin(); i!=st.sub.end(); ++i)
                load_statement(*i);
        finish();
 }
@@ -23,7 +23,7 @@ void Loader::load(Parser &p)
 {
        while(p)
        {
-               Statement st=p.parse();
+               Statement st = p.parse();
                if(st.valid)
                        load_statement(st);
        }
@@ -32,7 +32,7 @@ void Loader::load(Parser &p)
 
 Loader::~Loader()
 {
-       for(ActionMap::iterator i=actions.begin(); i!=actions.end(); ++i)
+       for(ActionMap::iterator i = actions.begin(); i!=actions.end(); ++i)
                delete i->second;
 }
 
@@ -46,20 +46,20 @@ void Loader::load_sub_with(Loader &ldr)
 
 void Loader::add(const string &k, LoaderAction *a)
 {
-       ActionMap::iterator i=actions.find(k);
+       ActionMap::iterator i = actions.find(k);
        if(i!=actions.end())
        {
                delete i->second;
-               i->second=a;
+               i->second = a;
        }
        else
-               actions[k]=a;
+               actions[k] = a;
 }
 
 void Loader::load_statement(const Statement &st)
 {
-       cur_st=&st;
-       ActionMap::iterator j=actions.find(st.keyword);
+       cur_st = &st;
+       ActionMap::iterator j = actions.find(st.keyword);
        if(j==actions.end())
                throw_at(KeyError("Unknown keyword", st.keyword), st.get_location());
        if(j->second)
@@ -75,7 +75,7 @@ void Loader::load_statement(const Statement &st)
                        throw;
                }
        }
-       cur_st=0;
+       cur_st = 0;
 }
 
 } // namespace DataFile
index ade1dd98e40904412e842a91666b6670e6a124aa..1d225cb21d243c670dec03b29e5a4724cc47bd00 100644 (file)
@@ -37,24 +37,24 @@ Statement Parser::parse()
        {
                while(1)
                {
-                       Statement st=mode->parse();
+                       Statement st = mode->parse();
                        if(st.keyword=="__bin")
                        {
                                delete mode;
-                               mode=new BinaryParser(in, src);
+                               mode = new BinaryParser(in, src);
                        }
                        else if(st.keyword=="__text")
                        {
                                delete mode;
-                               mode=new TextParser(in, src);
+                               mode = new TextParser(in, src);
                        }
                        else if(st.keyword=="__src")
                        {
-                               string s=st.args[0].get<string>();
+                               string s = st.args[0].get<string>();
                                if(s.empty())
-                                       src=main_src;
+                                       src = main_src;
                                else
-                                       src=format("%s[%s]", main_src, s);
+                                       src = format("%s[%s]", main_src, s);
                        }
                        else
                                return st;
@@ -62,7 +62,7 @@ Statement Parser::parse()
        }
        catch(const Exception &e)
        {
-               good=false;
+               good = false;
                throw;
        }
 }
index 2df8b4cdde28e9019164977aa32b6771fbcd249f..d485a20a80f27f1f082c1cc3e400fdb03c46023a 100644 (file)
@@ -13,9 +13,9 @@ namespace DataFile {
 
 std::string Statement::get_location() const
 {
-       std::string result=source;
+       std::string result = source;
        if(line)
-               result+=format(":%d", line);
+               result += format(":%d", line);
        return result;
 }
 
index 0f17d3f3cc79808a7659e291e406f6b7bb814137..d8e422ee7ff4d4d710a764a62383955f377305f5 100644 (file)
@@ -28,19 +28,19 @@ Statement TextParser::parse()
 Statement TextParser::parse_statement(const Token *t)
 {
        Statement result;
-       bool      sub=false;
-       bool      finish=false;
+       bool      sub = false;
+       bool      finish = false;
 
        while(in)
        {
                Token token;
                if(t)
                {
-                       token=*t;
-                       t=0;
+                       token = *t;
+                       t = 0;
                }
                else
-                       token=parse_token();
+                       token = parse_token();
 
                if(result.keyword.empty())
                {
@@ -48,21 +48,21 @@ Statement TextParser::parse_statement(const Token *t)
                                break;
                        else if(token.type!=Token::IDENTIFIER)
                                throw_at(ParseError(format("Syntax error at token '%s' (expected an identifier)", token.str)), get_location());
-                       result.keyword=token.str;
-                       result.valid=true;
-                       result.source=src;
-                       result.line=in.get_line_number();
+                       result.keyword = token.str;
+                       result.valid = true;
+                       result.source = src;
+                       result.line = in.get_line_number();
                }
                else if(sub)
                {
                        if(token.str=="}")
                        {
-                               sub=false;
-                               finish=true;
+                               sub = false;
+                               finish = true;
                        }
                        else
                        {
-                               Statement ss=parse_statement(&token);
+                               Statement ss = parse_statement(&token);
                                result.sub.push_back(ss);
                        }
                }
@@ -73,7 +73,7 @@ Statement TextParser::parse_statement(const Token *t)
                        break;
                }
                else if(token.str=="{")
-                       sub=true;
+                       sub = true;
                else if(token.str==";")
                        break;
                else if(token.type==Token::INTEGER)
@@ -103,27 +103,27 @@ Statement TextParser::parse_statement(const Token *t)
 
 Token TextParser::parse_token()
 {
-       int c=0;
-       int comment=0;
+       int c = 0;
+       int comment = 0;
 
        // Skip over comments and whitespace
        while(in && comment>=0)
        {
-               c=in.get();
-               int next=in.peek();
+               c = in.get();
+               int next = in.peek();
 
                if(c=='/' && next=='/')
-                       comment=1;
+                       comment = 1;
                else if(c=='/' && next=='*')
-                       comment=2;
+                       comment = 2;
                else if(c=='\n' && comment==1)
-                       comment=0;
+                       comment = 0;
                else if(c=='*' && next=='/' && comment==2)
-                       comment=3;
+                       comment = 3;
                else if(comment==3)   // Skip the second character of block comment end
-                       comment=0;
+                       comment = 0;
                else if(!isspace(c) && !comment)
-                       comment=-1;
+                       comment = -1;
        }
 
        if(comment>0)  // EOF while in comment
@@ -165,64 +165,64 @@ Token TextParser::parse_token()
                Token::IDENTIFIER
        };
 
-       ParseState state=INIT;
+       ParseState state = INIT;
        string     buf;
-       bool       escape=false;
+       bool       escape = false;
 
        while(in || state==INIT)
        {
                if(state!=INIT)
-                       c=in.get();
-               int next=in.peek();
+                       c = in.get();
+               int next = in.peek();
 
-               buf+=c;
+               buf += c;
 
                switch(state)
                {
                case INIT:
                        if(c=='0')
-                               state=ZERO;
+                               state = ZERO;
                        else if(c=='-' || c=='+')
-                               state=SIGN;
+                               state = SIGN;
                        else if(c=='.')
-                               state=FLOAT;
+                               state = FLOAT;
                        else if(c=='"')
-                               state=STRING;
+                               state = STRING;
                        else if(c=='{' || c=='}' || c==';')
                                return Token(Token::SPECIAL, string(1, c));
                        else if(isdigit(c))
-                               state=DECIMAL;
+                               state = DECIMAL;
                        else if(isalpha(c) || c=='_')
-                               state=IDENTIFIER;
+                               state = IDENTIFIER;
                        else
                                parse_error(c, "0-9A-Za-z_.\"{};+-");
                        break;
 
                case SIGN:
                        if(c=='0')
-                               state=ZERO;
+                               state = ZERO;
                        else if(isdigit(c))
-                               state=DECIMAL;
+                               state = DECIMAL;
                        else if(c=='.')
-                               state=FLOAT;
+                               state = FLOAT;
                        else
                                parse_error(c, "0-9.");
                        break;
 
                case ZERO:
                        if(c=='x')
-                               state=HEXADECIMAL;
+                               state = HEXADECIMAL;
                        else if(isdigit(c))
-                               state=OCTAL;
+                               state = OCTAL;
                        else if(c=='.')
-                               state=FLOAT;
+                               state = FLOAT;
                        else
                                parse_error(c, "0-9A-Fa-f.");
                        break;
 
                case DECIMAL:
                        if(c=='.')
-                               state=FLOAT;
+                               state = FLOAT;
                        else if(!isdigit(c))
                                parse_error(c, "0-9.");
                        break;
@@ -239,23 +239,23 @@ Token TextParser::parse_token()
 
                case FLOAT:
                        if(c=='e' || c=='E')
-                               state=FLOATEXPINIT;
+                               state = FLOATEXPINIT;
                        else if(!isdigit(c))
                                parse_error(c, "0-9Ee");
                        break;
 
                case FLOATEXPINIT:
                        if(c=='+' || c=='-')
-                               state=FLOATEXPSIGN;
+                               state = FLOATEXPSIGN;
                        else if(isdigit(c))
-                               state=FLOATEXP;
+                               state = FLOATEXP;
                        else
                                parse_error(c, "0-9+-");
                        break;
 
                case FLOATEXPSIGN:
                        if(isdigit(c))
-                               state=FLOATEXP;
+                               state = FLOATEXP;
                        else
                                parse_error(c, "0-9");
                        break;
@@ -267,7 +267,7 @@ Token TextParser::parse_token()
 
                case STRING:
                        if(c=='\\')
-                               escape=!escape;
+                               escape = !escape;
                        else if(c=='"' && !escape)
                        {
                                try
@@ -281,7 +281,7 @@ Token TextParser::parse_token()
                                }
                        }
                        else
-                               escape=false;
+                               escape = false;
                        break;
 
                case IDENTIFIER:
index 890c4172162ea17631d8bc69fad7be8ce3a28788..2768462297e6fed397e31b8a7ae58e96b3110113 100644 (file)
@@ -29,7 +29,7 @@ void TextWriter::write_(const Statement &st, unsigned level)
        string indent(level, '\t');
 
        IO::print(out, "%s%s", indent, st.keyword);
-       for(ValueArray::const_iterator i=st.args.begin(); i!=st.args.end(); ++i)
+       for(ValueArray::const_iterator i = st.args.begin(); i!=st.args.end(); ++i)
        {
                out.put(' ');
                if(i->get_type()==STRING)
@@ -42,7 +42,7 @@ void TextWriter::write_(const Statement &st, unsigned level)
        if(!st.sub.empty())
        {
                IO::print(out, "\n%s{\n", indent);
-               for(list<Statement>::const_iterator i=st.sub.begin(); i!=st.sub.end(); ++i)
+               for(list<Statement>::const_iterator i = st.sub.begin(); i!=st.sub.end(); ++i)
                        write_(*i, level+1);
                IO::print(out, "%s}", indent);
        }
index bfd0edac784227efa21b8f30b7dd72e5bcdc3325..bcbccc240300a065ce01454409cb80049da32b1d 100644 (file)
@@ -36,21 +36,21 @@ void Writer::set_binary(bool b)
        if(b==binary)
                return;
 
-       binary=b;
+       binary = b;
 
        Statement st;
        if(binary)
-               st.keyword="__bin";
+               st.keyword = "__bin";
        else
-               st.keyword="__text";
+               st.keyword = "__text";
 
        mode->write(st);
 
        delete mode;
        if(binary)
-               mode=new BinaryWriter(out);
+               mode = new BinaryWriter(out);
        else
-               mode=new TextWriter(out);
+               mode = new TextWriter(out);
 }
 
 } // namespace DataFile
index ed5710b97d3bd8d3ffac53d88f4c41855b2866fd..8c280c4a2ec2a3d0ec3ed07fd72235d15a8bc92c 100644 (file)
@@ -40,10 +40,10 @@ void Compiler::write(const DataFile::Statement &st)
        if(reset_src)
        {
                writer.write((DataFile::Statement("__src"), string()));
-               reset_src=false;
+               reset_src = false;
        }
 
-       for(list<DataFile::Statement>::const_iterator i=st.sub.begin(); i!=st.sub.end(); ++i)
+       for(list<DataFile::Statement>::const_iterator i = st.sub.begin(); i!=st.sub.end(); ++i)
                writer.write(*i);
 }
 
@@ -52,11 +52,11 @@ bool Compiler::process_statement(const FS::Path &fn, DataFile::Statement &st)
        if(st.keyword=="_content")
                return true;
 
-       for(vector<DataFile::Value>::iterator i=st.args.begin(); i!=st.args.end(); ++i)
+       for(vector<DataFile::Value>::iterator i = st.args.begin(); i!=st.args.end(); ++i)
                if(i->get_type()==DataFile::STRING)
                {
                        if(i->get_raw()=="$filename")
-                               *i=DataFile::Value(FS::basename(fn.str()));
+                               *i = DataFile::Value(FS::basename(fn.str()));
                        else if(i->get_raw()=="$content")
                        {
                                IO::File in(fn.str());
@@ -64,14 +64,14 @@ bool Compiler::process_statement(const FS::Path &fn, DataFile::Statement &st)
                                while(!in.eof())
                                {
                                        char buf[4096];
-                                       unsigned len=in.read(buf, sizeof(buf));
+                                       unsigned len = in.read(buf, sizeof(buf));
                                        data.append(buf, len);
                                }
-                               *i=DataFile::Value(data);
+                               *i = DataFile::Value(data);
                        }
                }
 
-       for(list<DataFile::Statement>::iterator i=st.sub.begin(); i!=st.sub.end();)
+       for(list<DataFile::Statement>::iterator i = st.sub.begin(); i!=st.sub.end();)
        {
                if(process_statement(fn, *i))
                {
@@ -81,11 +81,11 @@ bool Compiler::process_statement(const FS::Path &fn, DataFile::Statement &st)
                        DataFile::Parser parser(in, fn.str());
                        while(parser)
                        {
-                               DataFile::Statement ss=parser.parse();
+                               DataFile::Statement ss = parser.parse();
                                if(ss.valid)
                                        st.sub.insert(i, ss);
                        }
-                       i=st.sub.erase(i);
+                       i = st.sub.erase(i);
                }
                else
                        ++i;
@@ -97,19 +97,19 @@ bool Compiler::process_statement(const FS::Path &fn, DataFile::Statement &st)
 void Compiler::process_file(const FS::Path &fn, const list<DataFile::Statement> &st)
 {
        writer.write((DataFile::Statement("__src"), FS::basename(fn.str())));
-       reset_src=true;
+       reset_src = true;
 
        if(st.empty())
                process_file(fn);
        else
        {
-               for(list<DataFile::Statement>::const_iterator i=st.begin(); i!=st.end(); ++i)
+               for(list<DataFile::Statement>::const_iterator i = st.begin(); i!=st.end(); ++i)
                {
                        if(i->keyword=="_content")
                                process_file(fn);
                        else
                        {
-                               DataFile::Statement s=*i;
+                               DataFile::Statement s = *i;
                                process_statement(fn, s);
                                writer.write(s);
                        }
@@ -125,7 +125,7 @@ void Compiler::process_file(const FS::Path &fn)
        DataFile::Parser parser(in, fn.str());
        while(parser)
        {
-               DataFile::Statement st=parser.parse();
+               DataFile::Statement st = parser.parse();
                if(st.valid)
                        writer.write(st);
        }
@@ -162,14 +162,14 @@ ForEach::ForEach(Compiler &c, const FS::Path &b, const list<string> &p):
 
 void ForEach::finish()
 {
-       list<string> files=FS::list_files(base);
-       for(list<string>::iterator i=files.begin(); i!=files.end(); ++i)
+       list<string> files = FS::list_files(base);
+       for(list<string>::iterator i = files.begin(); i!=files.end(); ++i)
        {
-               bool match=false;
-               for(list<string>::const_iterator j=patterns.begin(); (j!=patterns.end() && !match); ++j)
-                       match=Regex(*j).match(*i);
-               for(list<string>::const_iterator j=excludes.begin(); (j!=excludes.end() && match); ++j)
-                       match=!Regex(*j).match(*i);
+               bool match = false;
+               for(list<string>::const_iterator j = patterns.begin(); (j!=patterns.end() && !match); ++j)
+                       match = Regex(*j).match(*i);
+               for(list<string>::const_iterator j = excludes.begin(); (j!=excludes.end() && match); ++j)
+                       match = !Regex(*j).match(*i);
                if(match)
                        compiler.process_file(base / *i, write_st);
        }
index 36ee5c4abd6e760162934417a8d8ae4b1f355333..02fba07fa022cd758722fa81e4e4ec78caf50d1c 100644 (file)
@@ -30,24 +30,24 @@ DataTool::DataTool(int argc, char **argv):
        getopt.add_option('o', "output", out_fn, GetOpt::REQUIRED_ARG);
        getopt(argc, argv);
 
-       const vector<string> &args=getopt.get_args();
+       const vector<string> &args = getopt.get_args();
        if(!args.empty())
-               in_fn=args[0];
+               in_fn = args[0];
 }
 
 int DataTool::main()
 {
        IO::Base *in;
        if(in_fn=="-")
-               in=&IO::cin;
+               in = &IO::cin;
        else
-               in=new IO::File(in_fn);
+               in = new IO::File(in_fn);
 
        IO::Base *out;
        if(out_fn=="-")
-               out=&IO::cout;
+               out = &IO::cout;
        else
-               out=new IO::File(out_fn, IO::M_WRITE);
+               out = new IO::File(out_fn, IO::M_WRITE);
 
        {
                IO::Buffered in_buf(*in);
@@ -66,7 +66,7 @@ int DataTool::main()
                {
                        while(parser)
                        {
-                               DataFile::Statement st=parser.parse();
+                               DataFile::Statement st = parser.parse();
                                if(st.valid)
                                {
                                        writer.write(st);