Merge branch 'master' into jgrpp

# Conflicts:
#	src/cargotype.h
#	src/core/CMakeLists.txt
#	src/core/span_type.hpp
#	src/fileio.cpp
#	src/fios.cpp
#	src/misc/endian_buffer.hpp
#	src/misc_gui.cpp
#	src/saveload/saveload.h
#	src/saveload/vehicle_sl.cpp
#	src/screenshot.cpp
#	src/settings.cpp
#	src/settings_internal.h
#	src/stdafx.h
#	src/string_func.h
#	src/strings.cpp
#	src/strings_func.h
#	src/strings_internal.h
This commit is contained in:
Jonathan G Rennison
2024-01-25 18:37:23 +00:00
49 changed files with 127 additions and 472 deletions

View File

@@ -179,14 +179,14 @@ enum class HyperlinkType {
static HyperlinkType ClassifyHyperlink(const std::string &destination, bool trusted)
{
if (destination.empty()) return HyperlinkType::Unknown;
if (StrStartsWith(destination, "#")) return HyperlinkType::Internal;
if (destination.starts_with("#")) return HyperlinkType::Internal;
/* Only allow external / internal links for sources we trust. */
if (!trusted) return HyperlinkType::Unknown;
if (StrStartsWith(destination, "http://")) return HyperlinkType::Web;
if (StrStartsWith(destination, "https://")) return HyperlinkType::Web;
if (StrStartsWith(destination, "./")) return HyperlinkType::File;
if (destination.starts_with("http://")) return HyperlinkType::Web;
if (destination.starts_with("https://")) return HyperlinkType::Web;
if (destination.starts_with("./")) return HyperlinkType::File;
return HyperlinkType::Unknown;
}
@@ -430,7 +430,7 @@ void TextfileWindow::NavigateHistory(int delta)
void TextfileWindow::NavigateToFile(std::string newfile, size_t line)
{
/* Double-check that the file link begins with ./ as a relative path. */
if (!StrStartsWith(newfile, "./")) return;
if (!newfile.starts_with("./")) return;
/* Get the path portion of the current file path. */
std::string newpath = this->filepath;
@@ -790,12 +790,12 @@ static void Xunzip(byte **bufp, size_t *sizep)
#if defined(WITH_ZLIB)
/* In-place gunzip */
if (StrEndsWith(textfile, ".gz")) Gunzip((byte**)&buf, &filesize);
if (std::string_view(textfile).ends_with(".gz")) Gunzip((byte**)&buf, &filesize);
#endif
#if defined(WITH_LIBLZMA)
/* In-place xunzip */
if (StrEndsWith(textfile, ".xz")) Xunzip((byte**)&buf, &filesize);
if (std::string_view(textfile).ends_with(".xz")) Xunzip((byte**)&buf, &filesize);
#endif
if (buf == nullptr) return;
@@ -803,7 +803,7 @@ static void Xunzip(byte **bufp, size_t *sizep)
std::string_view sv_buf(buf, filesize);
/* Check for the byte-order-mark, and skip it if needed. */
if (StrStartsWith(sv_buf, "\ufeff")) sv_buf.remove_prefix(3);
if (sv_buf.starts_with("\ufeff")) sv_buf.remove_prefix(3);
/* Update the filename. */
this->filepath = textfile;