mirror of https://github.com/OpenTTD/OpenTTD
Codechange: replace manual trim and std::from_chars with ParseInteger
parent
414f6a3067
commit
4109b6848b
|
@ -8,6 +8,7 @@
|
|||
/** @file fileio.cpp Standard In/Out file operations */
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "core/string_consumer.hpp"
|
||||
#include "fileio_func.h"
|
||||
#include "spriteloader/spriteloader.hpp"
|
||||
#include "debug.h"
|
||||
|
@ -23,7 +24,6 @@
|
|||
#include <unistd.h>
|
||||
#include <pwd.h>
|
||||
#endif
|
||||
#include <charconv>
|
||||
#include <sys/stat.h>
|
||||
#include <filesystem>
|
||||
|
||||
|
@ -514,13 +514,13 @@ bool TarScanner::AddFile(const std::string &filename, size_t, [[maybe_unused]] c
|
|||
std::string size = ExtractString(th.size);
|
||||
size_t skip = 0;
|
||||
if (!size.empty()) {
|
||||
StrTrimInPlace(size);
|
||||
auto [_, err] = std::from_chars(size.data(), size.data() + size.size(), skip, 8);
|
||||
if (err != std::errc()) {
|
||||
auto value = ParseInteger<size_t>(size, 8);
|
||||
if (!value.has_value()) {
|
||||
Debug(misc, 0, "The file '{}' has an invalid size for '{}'", filename, name);
|
||||
fclose(f);
|
||||
return false;
|
||||
}
|
||||
skip = *value;
|
||||
}
|
||||
|
||||
switch (th.typeflag) {
|
||||
|
|
Loading…
Reference in New Issue