Fix OpenBSD build
LLVM 19.1 doesn't have from_chars for double.
This commit is contained in:
+1
-1
@@ -5,7 +5,7 @@ project(asciicast2webp VERSION 0.1 DESCRIPTION "Render asciicast as WebP"
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(LIBRARIES REQUIRED
|
||||
vterm cairo libwebp libwebpmux libjq oniguruma)
|
||||
pkg_search_module(TERMINFO REQUIRED tinfo ncursesw)
|
||||
pkg_search_module(TERMINFO REQUIRED tinfo ncursesw ncurses)
|
||||
|
||||
add_executable(${PROJECT_NAME} ${PROJECT_NAME}.cpp)
|
||||
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_20)
|
||||
|
||||
+10
-10
@@ -23,7 +23,7 @@
|
||||
#include <clocale>
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
@@ -1369,22 +1369,22 @@ void usage(const char *program) {
|
||||
|
||||
int parse_integer_option(
|
||||
const char *name, const char *value, int minimum, int maximum) {
|
||||
int result = 0;
|
||||
const char *end = value + strlen(value);
|
||||
const auto [position, error] = from_chars(value, end, result);
|
||||
if (error != errc{} || position != end || result < minimum ||
|
||||
char *end = nullptr;
|
||||
errno = 0;
|
||||
const long result = strtol(value, &end, 10);
|
||||
if (errno == ERANGE || end == value || *end || result < minimum ||
|
||||
result > maximum) {
|
||||
fail(string(name) + " must be between " + to_string(minimum) + " and " +
|
||||
to_string(maximum));
|
||||
}
|
||||
return result;
|
||||
return int(result);
|
||||
}
|
||||
|
||||
double parse_real_option(const char *name, const char *value) {
|
||||
double result = 0.;
|
||||
const char *end = value + strlen(value);
|
||||
const auto [position, error] = from_chars(value, end, result);
|
||||
if (error != errc{} || position != end || !isfinite(result))
|
||||
char *end = nullptr;
|
||||
errno = 0;
|
||||
const double result = strtod(value, &end);
|
||||
if (errno == ERANGE || end == value || *end || !isfinite(result))
|
||||
fail(string(name) + " must be a finite number");
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user