Commit 736fb87e authored by Jelte Jansen's avatar Jelte Jansen

[1741] Merge branch 'trac1093' into trac1741

parents 4cee65dd 5a8474bf
......@@ -491,22 +491,22 @@ writeProgramFile(const string& file, const vector<string>& ns_components,
}
/// \brief Warn of Duplicate Entries
/// \brief Error and exit if there are duplicate entries
///
/// If the input file contained duplicate message IDs, only the first will be
/// processed. However, we should warn about it.
/// If the input file contained duplicate message IDs, we print an
/// error for each of them, then exit the program with a non-0 value.
///
/// \param reader Message Reader used to read the file
void
warnDuplicates(MessageReader& reader) {
errorDuplicates(MessageReader& reader) {
// Get the duplicates (the overflow) and, if present, sort them into some
// order and remove those which occur more than once (which mean that they
// occur more than twice in the input file).
MessageReader::MessageIDCollection duplicates = reader.getNotAdded();
if (duplicates.size() > 0) {
cout << "Warning: the following duplicate IDs were found:\n";
if (!duplicates.empty()) {
cout << "Error: the following duplicate IDs were found:\n";
sort(duplicates.begin(), duplicates.end());
MessageReader::MessageIDCollection::iterator new_end =
......@@ -515,6 +515,7 @@ warnDuplicates(MessageReader& reader) {
i != new_end; ++i) {
cout << " " << *i << "\n";
}
exit(1);
}
}
......@@ -580,6 +581,9 @@ main(int argc, char* argv[]) {
MessageReader reader(&dictionary);
reader.readFile(message_file);
// Error (and quit) if there are of any duplicates encountered.
errorDuplicates(reader);
if (doPython) {
// Warn in case of ignored directives
if (!reader.getNamespace().empty()) {
......@@ -604,8 +608,6 @@ main(int argc, char* argv[]) {
output_directory);
}
// Finally, warn of any duplicates encountered.
warnDuplicates(reader);
}
catch (const MessageException& e) {
// Create an error message from the ID and the text
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment