Skip to content

Commit

Permalink
not return 1 if input is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
takenori-y committed Dec 13, 2023
1 parent d837ec8 commit 27554d8
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/main/minmax.cc
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ int main(int argc, char* argv[]) {
}
} else if (kFindValueFromVectorSequenceForEachDimension ==
way_to_find_value) {
bool empty(true);
while (sptk::ReadStream(false, 0, 0, vector_length, &data, &input_stream,
NULL)) {
for (int vector_index(0); vector_index < vector_length; ++vector_index) {
Expand All @@ -353,14 +354,18 @@ int main(int argc, char* argv[]) {
sptk::PrintErrorMessage("minmax", error_message);
return 1;
}
if (empty) empty = false;
}
}
if (!WriteMinMaxValues(minmax_accumulation, buffer, num_best, output_format,
output_stream_pointer)) {
std::ostringstream error_message;
error_message << "Failed to write values";
sptk::PrintErrorMessage("minmax", error_message);
return 1;
// Write value if at least one data is given.
if (!empty) {
if (!WriteMinMaxValues(minmax_accumulation, buffer, num_best,
output_format, output_stream_pointer)) {
std::ostringstream error_message;
error_message << "Failed to write values";
sptk::PrintErrorMessage("minmax", error_message);
return 1;
}
}
}

Expand Down

0 comments on commit 27554d8

Please sign in to comment.