From 93963f62c3b2c4a29b48767583b1319e92998edd Mon Sep 17 00:00:00 2001 From: Jesse Talavera Date: Tue, 18 Jun 2024 17:10:45 -0400 Subject: [PATCH] Fix some log entries not being output with a newline. --- CHANGELOG.md | 6 ++++++ src/libretro/environment.cpp | 9 ++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d4a55da..fe96a5ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0), and this project roughly adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Fixed + +- Fixed some log entries not being output with a newline. + ## [1.1.3] - 2024-06-14 ### Fixed diff --git a/src/libretro/environment.cpp b/src/libretro/environment.cpp index 0ea6e4ff..7101136f 100644 --- a/src/libretro/environment.cpp +++ b/src/libretro/environment.cpp @@ -300,13 +300,12 @@ constexpr uint32_t GetLogColor(retro_log_level level) noexcept { void retro::fmt_log(retro_log_level level, fmt::string_view fmt, fmt::format_args args) noexcept { fmt::basic_memory_buffer buffer; fmt::vformat_to(std::back_inserter(buffer), fmt, args); - // We can't pass the va_list directly to the libretro callback, - // so we have to construct the string and print that - if (buffer[buffer.size() - 1] == '\n') - buffer[buffer.size() - 1] = '\0'; + if (buffer[buffer.size() - 1] != '\n') + // If the string doesn't end with a newline... + buffer.push_back('\n'); - buffer.push_back('\n'); + // vformat_to doesn't append a null terminator, so we have to do it ourselves buffer.push_back('\0'); if (_log) {