Skip to content

Commit

Permalink
Fix errors & reduce diff
Browse files Browse the repository at this point in the history
Signed-off-by: Tin Švagelj <tin.svagelj@live.com>
  • Loading branch information
Caellian committed May 4, 2024
1 parent 6f43619 commit 457ce1b
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ configure_file(${CMAKE_MODULE_PATH}/build.h.in ${CMAKE_BINARY_DIR}/build.h)
set(conky_sources ${CMAKE_BINARY_DIR}/config.h ${CMAKE_BINARY_DIR}/build.h)

# Finally, add some code
add_subdirectory(lua)
add_subdirectory(data)
add_subdirectory(doc)

Expand All @@ -67,8 +68,6 @@ endif()

add_subdirectory(src)

add_subdirectory(lua)

if(BUILD_TESTS)
add_subdirectory(tests)
enable_testing()
Expand Down
2 changes: 1 addition & 1 deletion lua/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ if(BUILD_LUA_IMLIB2)
add_library(conky-imlib2 MODULE ${luaimlib2_src})
set_target_properties(conky-imlib2 PROPERTIES OUTPUT_NAME "imlib2")

target_link_libraries(conky-imlib2 ${luaimlib2_libs} toluapp_lib_static )
target_link_libraries(conky-imlib2 ${luaimlib2_libs} toluapp_lib_static)
set(lua_libs ${lua_libs} conky-imlib2)

print_target_properties(conky-imlib2)
Expand Down
5 changes: 1 addition & 4 deletions src/darwin.mm
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,8 @@
#include <time.h>
#endif

/* debugging defines */
#undef NDEBUG

/* (E)nhanced printf */
#ifndef NDEBUG
#if true // ifdef NDEBUG
#include <cstdarg>
void eprintf(const char *fmt, ...) {
va_list args;
Expand Down
1 change: 1 addition & 0 deletions src/logger.hh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include <ctime>
#include <optional>
#include <stdexcept>
#include <string>
#include <tuple>
#include <type_traits>

Expand Down
12 changes: 9 additions & 3 deletions src/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@

#include "logger.hh"

#include <string>

class fork_throw : public std::runtime_error {
public:
fork_throw() : std::runtime_error("Fork happened") {}
Expand Down Expand Up @@ -92,9 +94,9 @@ namespace _priv_error_print {
template <typename... Args>
inline std::string alloc_printf(const char *format, Args &&...args) {
auto size = std::snprintf(nullptr, 0, format, args...);
std::string output(size + 1, '\0');
std::sprintf(&output[0], format, args...);
return output;
char output[size + 1];
std::snprintf(output, sizeof(output), format, args...);
return std::string(&output[0]);
}
inline std::string alloc_printf(const char *format) {
return std::string(format);
Expand All @@ -103,6 +105,10 @@ inline std::string alloc_printf(const char *format) {

class error : public std::runtime_error {
public:
/// @brief Construct a new error object.
///
/// @param Msg Already localized error message.
error(const std::string &msg) : std::runtime_error(msg) {}
error(const char *msg) : std::runtime_error(_(msg)) {}
template <typename... Args>
error(const char *format, Args &&...args)
Expand Down

0 comments on commit 457ce1b

Please sign in to comment.