diff options
author | rathnor <rathnor> | 2002-12-01 13:42:15 (GMT) |
---|---|---|
committer | rathnor <rathnor> | 2002-12-01 13:42:15 (GMT) |
commit | 28b5c604490094e187494dcc566bd3d7a05a2c25 (patch) | |
tree | 8f78f5714a5cd055c10b067a2656fe7b2338e71a /src/tests/main.cc | |
parent | b9134162f9633784d9097df18769a699a62650fe (diff) | |
download | fluxbox-28b5c604490094e187494dcc566bd3d7a05a2c25.zip fluxbox-28b5c604490094e187494dcc566bd3d7a05a2c25.tar.bz2 |
Indenting from tabs to emacs 4-space
Diffstat (limited to 'src/tests/main.cc')
-rw-r--r-- | src/tests/main.cc | 166 |
1 files changed, 83 insertions, 83 deletions
diff --git a/src/tests/main.cc b/src/tests/main.cc index f0ff759..2505e65 100644 --- a/src/tests/main.cc +++ b/src/tests/main.cc | |||
@@ -33,110 +33,110 @@ bool loadMenu2(string filename); | |||
33 | 33 | ||
34 | void showError(int line, int pos, string& instr) { | 34 | void showError(int line, int pos, string& instr) { |
35 | 35 | ||
36 | cerr<<"Error on line: "<<line<<endl; | 36 | cerr<<"Error on line: "<<line<<endl; |
37 | cerr<<instr<<endl; | 37 | cerr<<instr<<endl; |
38 | for (int c=0; c<pos; c++) { | 38 | for (int c=0; c<pos; c++) { |
39 | if (instr[c]=='\t') | 39 | if (instr[c]=='\t') |
40 | cerr<<'\t'; | 40 | cerr<<'\t'; |
41 | else | 41 | else |
42 | cerr<<" "; | 42 | cerr<<" "; |
43 | } | 43 | } |
44 | cerr<<"^ here"<<endl; | 44 | cerr<<"^ here"<<endl; |
45 | 45 | ||
46 | } | 46 | } |
47 | 47 | ||
48 | int main(int argc, char **argv) { | 48 | int main(int argc, char **argv) { |
49 | string filename = "menu"; | 49 | string filename = "menu"; |
50 | if (argc>1) | 50 | if (argc>1) |
51 | filename = argv[1]; | 51 | filename = argv[1]; |
52 | if (loadMenu2(filename)) | 52 | if (loadMenu2(filename)) |
53 | cout<<"Load successfull"<<endl; | 53 | cout<<"Load successfull"<<endl; |
54 | else | 54 | else |
55 | cout<<"Load failed"<<endl; | 55 | cout<<"Load failed"<<endl; |
56 | 56 | ||
57 | /* | 57 | /* |
58 | string out; | 58 | string out; |
59 | vector<string> stringlist; | 59 | vector<string> stringlist; |
60 | stringlist.push_back(" \t\t\t \t[(in \\)\t haha )] \t\t "); | 60 | stringlist.push_back(" \t\t\t \t[(in \\)\t haha )] \t\t "); |
61 | stringlist.push_back("(in\\)) {_ _ my_ _}"); | 61 | stringlist.push_back("(in\\)) {_ _ my_ _}"); |
62 | stringlist.push_back("(in) {_ _ my_ _}"); | 62 | stringlist.push_back("(in) {_ _ my_ _}"); |
63 | stringlist.push_back("(in){_ _ my_ _}"); | 63 | stringlist.push_back("(in){_ _ my_ _}"); |
64 | stringlist.push_back("\t \t \t ( in ) {haha}"); | 64 | stringlist.push_back("\t \t \t ( in ) {haha}"); |
65 | stringlist.push_back("\t \t \t (( in \\) ) {haha}"); | 65 | stringlist.push_back("\t \t \t (( in \\) ) {haha}"); |
66 | stringlist.push_back("\t \t \t (( in \\) ){hihi}"); | 66 | stringlist.push_back("\t \t \t (( in \\) ){hihi}"); |
67 | stringlist.push_back("\t \t \t (( in \\) )|{hihi}"); | 67 | stringlist.push_back("\t \t \t (( in \\) )|{hihi}"); |
68 | for (unsigned int i=0; i<stringlist.size(); i++) { | 68 | for (unsigned int i=0; i<stringlist.size(); i++) { |
69 | int pos = StringUtil::getStringBetween(out, stringlist[i].c_str(), '(', ')'); | 69 | int pos = StringUtil::getStringBetween(out, stringlist[i].c_str(), '(', ')'); |
70 | int total_pos = 0; | 70 | int total_pos = 0; |
71 | if (pos<0) { | 71 | if (pos<0) { |
72 | showError(i+1, -pos, stringlist[i]); | 72 | showError(i+1, -pos, stringlist[i]); |
73 | continue; | 73 | continue; |
74 | } | 74 | } |
75 | cerr<<"string="<<stringlist[i]<<endl; | 75 | cerr<<"string="<<stringlist[i]<<endl; |
76 | cerr<<"pos="<<pos<<" ::"<<out; | 76 | cerr<<"pos="<<pos<<" ::"<<out; |
77 | total_pos += pos; | 77 | total_pos += pos; |
78 | pos = StringUtil::getStringBetween(out, stringlist[i].c_str()+total_pos, '{', '}'); | 78 | pos = StringUtil::getStringBetween(out, stringlist[i].c_str()+total_pos, '{', '}'); |
79 | if (pos<=0) { | 79 | if (pos<=0) { |
80 | pos=-pos; | 80 | pos=-pos; |
81 | showError(i+1, total_pos+pos, stringlist[i]); | 81 | showError(i+1, total_pos+pos, stringlist[i]); |
82 | continue; | 82 | continue; |
83 | } | 83 | } |
84 | cerr<<"::"<<out<<"::"<<endl; | 84 | cerr<<"::"<<out<<"::"<<endl; |
85 | total_pos += pos; | 85 | total_pos += pos; |
86 | } | 86 | } |
87 | */ | 87 | */ |
88 | return 0; | 88 | return 0; |
89 | } | 89 | } |
90 | 90 | ||
91 | 91 | ||
92 | 92 | ||
93 | bool loadMenu2(string filename) { | 93 | bool loadMenu2(string filename) { |
94 | 94 | ||
95 | if (!filename.size()) | 95 | if (!filename.size()) |
96 | return false; | 96 | return false; |
97 | 97 | ||
98 | ifstream menufile(filename.c_str()); | 98 | ifstream menufile(filename.c_str()); |
99 | 99 | ||
100 | 100 | ||
101 | if (menufile) { | 101 | if (menufile) { |
102 | string instr; | 102 | string instr; |
103 | vector<string> args; | 103 | vector<string> args; |
104 | int line=0; | 104 | int line=0; |
105 | while (!menufile.eof()) { | 105 | while (!menufile.eof()) { |
106 | //read a line | 106 | //read a line |
107 | getline(menufile, instr); | 107 | getline(menufile, instr); |
108 | line++; | 108 | line++; |
109 | string arg; | 109 | string arg; |
110 | int pos = StringUtil::getStringBetween(arg, instr.c_str(), '[', ']'); | 110 | int pos = StringUtil::getStringBetween(arg, instr.c_str(), '[', ']'); |
111 | if (pos<=0) { | 111 | if (pos<=0) { |
112 | showError(line, -pos, instr); | 112 | showError(line, -pos, instr); |
113 | continue; | 113 | continue; |
114 | } | 114 | } |
115 | 115 | ||
116 | cerr<<"("<<line<<"):"<<arg<<"::"; | 116 | cerr<<"("<<line<<"):"<<arg<<"::"; |
117 | int total_pos = pos; | 117 | int total_pos = pos; |
118 | pos = StringUtil::getStringBetween(arg, instr.c_str()+pos, '(', ')'); | 118 | pos = StringUtil::getStringBetween(arg, instr.c_str()+pos, '(', ')'); |
119 | if (pos<=0) { | 119 | if (pos<=0) { |
120 | showError(line, total_pos+(-pos), instr); | 120 | showError(line, total_pos+(-pos), instr); |
121 | continue; | 121 | continue; |
122 | } | 122 | } |
123 | cerr<<arg<<"::"; | 123 | cerr<<arg<<"::"; |
124 | 124 | ||
125 | total_pos +=pos; | 125 | total_pos +=pos; |
126 | pos = StringUtil::getStringBetween(arg, instr.c_str()+total_pos, '{', '}'); | 126 | pos = StringUtil::getStringBetween(arg, instr.c_str()+total_pos, '{', '}'); |
127 | if (pos<=0) { | 127 | if (pos<=0) { |
128 | total_pos = total_pos+(-pos); | 128 | total_pos = total_pos+(-pos); |
129 | showError(line, total_pos, instr); | 129 | showError(line, total_pos, instr); |
130 | continue; | 130 | continue; |
131 | } | 131 | } |
132 | cerr<<arg<<":"<<endl; | 132 | cerr<<arg<<":"<<endl; |
133 | 133 | ||
134 | } | 134 | } |
135 | 135 | ||
136 | 136 | ||
137 | } else | 137 | } else |
138 | return false; | 138 | return false; |
139 | 139 | ||
140 | return true; | 140 | return true; |
141 | } | 141 | } |
142 | 142 | ||