|
@@ -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
|
|
/// \param reader Message Reader used to read the file
|
|
|
|
|
|
void
|
|
void
|
|
-warnDuplicates(MessageReader& reader) {
|
|
|
|
|
|
+errorDuplicates(MessageReader& reader) {
|
|
|
|
|
|
// Get the duplicates (the overflow) and, if present, sort them into some
|
|
// 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
|
|
// order and remove those which occur more than once (which mean that they
|
|
// occur more than twice in the input file).
|
|
// occur more than twice in the input file).
|
|
MessageReader::MessageIDCollection duplicates = reader.getNotAdded();
|
|
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());
|
|
sort(duplicates.begin(), duplicates.end());
|
|
MessageReader::MessageIDCollection::iterator new_end =
|
|
MessageReader::MessageIDCollection::iterator new_end =
|
|
@@ -515,6 +515,7 @@ warnDuplicates(MessageReader& reader) {
|
|
i != new_end; ++i) {
|
|
i != new_end; ++i) {
|
|
cout << " " << *i << "\n";
|
|
cout << " " << *i << "\n";
|
|
}
|
|
}
|
|
|
|
+ exit(1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -580,6 +581,9 @@ main(int argc, char* argv[]) {
|
|
MessageReader reader(&dictionary);
|
|
MessageReader reader(&dictionary);
|
|
reader.readFile(message_file);
|
|
reader.readFile(message_file);
|
|
|
|
|
|
|
|
+ // Error (and quit) if there are of any duplicates encountered.
|
|
|
|
+ errorDuplicates(reader);
|
|
|
|
+
|
|
if (doPython) {
|
|
if (doPython) {
|
|
// Warn in case of ignored directives
|
|
// Warn in case of ignored directives
|
|
if (!reader.getNamespace().empty()) {
|
|
if (!reader.getNamespace().empty()) {
|
|
@@ -604,8 +608,6 @@ main(int argc, char* argv[]) {
|
|
output_directory);
|
|
output_directory);
|
|
}
|
|
}
|
|
|
|
|
|
- // Finally, warn of any duplicates encountered.
|
|
|
|
- warnDuplicates(reader);
|
|
|
|
}
|
|
}
|
|
catch (const MessageException& e) {
|
|
catch (const MessageException& e) {
|
|
// Create an error message from the ID and the text
|
|
// Create an error message from the ID and the text
|