| 125 | } |
| 126 | |
| 127 | bool ParseDictionaryFile(const std::string &Text, std::vector<Unit> *Units) { |
| 128 | if (Text.empty()) { |
| 129 | Printf("ParseDictionaryFile: file does not exist or is empty\n"); |
| 130 | return false; |
| 131 | } |
| 132 | std::istringstream ISS(Text); |
| 133 | Units->clear(); |
| 134 | Unit U; |
| 135 | int LineNo = 0; |
| 136 | std::string S; |
| 137 | while (std::getline(ISS, S, '\n')) { |
| 138 | LineNo++; |
| 139 | size_t Pos = 0; |
| 140 | while (Pos < S.size() && isspace(S[Pos])) Pos++; // Skip spaces. |
| 141 | if (Pos == S.size()) continue; // Empty line. |
| 142 | if (S[Pos] == '#') continue; // Comment line. |
| 143 | if (ParseOneDictionaryEntry(S, &U)) { |
| 144 | Units->push_back(U); |
| 145 | } else { |
| 146 | Printf("ParseDictionaryFile: error in line %d\n\t\t%s\n", LineNo, |
| 147 | S.c_str()); |
| 148 | return false; |
| 149 | } |
| 150 | } |
| 151 | return true; |
| 152 | } |
| 153 | |
| 154 | // Code duplicated (and tested) in llvm/include/llvm/Support/Base64.h |
| 155 | std::string Base64(const Unit &U) { |