Compare commits

...

8 Commits

Author SHA1 Message Date
75fc6f1c37 const-qualify configuration schema items
All checks were successful
Alpine 3.20 Success
2024-08-08 08:53:49 +02:00
8a8437634a MPD client: fix argument quoting
All checks were successful
Alpine 3.20 Success
2024-08-07 22:04:00 +02:00
e78b410a6a MPD client: save the protocol version 2024-08-07 22:03:08 +02:00
bf44e827e8 liberty-xui: mention libgrapheme 2024-07-10 17:38:39 +02:00
8386af0420 Silence an OpenBSD linker warning
All checks were successful
Alpine 3.19 Success
2024-04-10 17:54:34 +02:00
f04cc2c61e Add MinGW-w64 CMake toolchain files
All checks were successful
Alpine 3.19 Success
2024-04-09 17:01:07 +02:00
969a4cfc3e liberty-xui: clip terminal drawing 2024-02-27 00:27:54 +01:00
ad5b2fb8cd asciiman: mildly improve compatibility
git manual pages render a little bit more sensibly now.
2024-02-12 10:57:23 +01:00
6 changed files with 75 additions and 28 deletions

View File

@@ -0,0 +1,15 @@
set (CMAKE_SYSTEM_NAME "Windows")
set (CMAKE_SYSTEM_PROCESSOR "x86_64")
set (CMAKE_C_COMPILER "x86_64-w64-mingw32-gcc")
set (CMAKE_CXX_COMPILER "x86_64-w64-mingw32-g++")
set (CMAKE_RC_COMPILER "x86_64-w64-mingw32-windres")
# Remember to set WINEPATH for library dependencies
set (CMAKE_CROSSCOMPILING_EMULATOR "wine64")
set (CMAKE_FIND_ROOT_PATH "/usr/x86_64-w64-mingw32")
set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

View File

@@ -0,0 +1,15 @@
set (CMAKE_SYSTEM_NAME "Windows")
set (CMAKE_SYSTEM_PROCESSOR "x86")
set (CMAKE_C_COMPILER "i686-w64-mingw32-gcc")
set (CMAKE_CXX_COMPILER "i686-w64-mingw32-g++")
set (CMAKE_RC_COMPILER "i686-w64-mingw32-windres")
# Remember to set WINEPATH for library dependencies
set (CMAKE_CROSSCOMPILING_EMULATOR "wine")
set (CMAKE_FIND_ROOT_PATH "/usr/i686-w64-mingw32")
set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

View File

@@ -1381,7 +1381,7 @@ struct mpd_client
// Protocol:
bool got_hello; ///< Got the OK MPD hello message
char *got_hello; ///< Version from OK MPD hello message
bool idling; ///< Sent idle as the last command
unsigned idling_subsystems; ///< Subsystems we're idling for
@@ -1482,7 +1482,7 @@ mpd_client_reset (struct mpd_client *self)
str_reset (&self->read_buffer);
str_reset (&self->write_buffer);
self->got_hello = false;
cstr_set (&self->got_hello, NULL);
self->idling = false;
self->idling_subsystems = 0;
self->in_list = false;
@@ -1549,7 +1549,8 @@ mpd_client_parse_hello (struct mpd_client *self, const char *line)
// TODO: call "on_connected" now. We should however also set up a timer
// so that we don't wait on this message forever.
return self->got_hello = true;
cstr_set (&self->got_hello, xstrdup (line + sizeof hello - 1));
return true;
}
static bool
@@ -1634,30 +1635,30 @@ mpd_client_on_ready (const struct pollfd *pfd, void *user_data)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
static bool
mpd_client_must_quote_char (char c)
{
return (unsigned char) c <= ' ' || c == '"' || c == '\'';
}
static bool
mpd_client_must_quote (const char *s)
{
if (!*s)
return true;
for (; *s; s++)
if (mpd_client_must_quote_char (*s))
if ((unsigned char) *s <= ' ' || *s == '"' || *s == '\'')
return true;
return false;
}
static bool
mpd_client_must_escape_in_quote (char c)
{
return c == '"' || c == '\'' || c == '\\';
}
static void
mpd_client_quote (const char *s, struct str *output)
{
str_append_c (output, '"');
for (; *s; s++)
{
if (mpd_client_must_quote_char (*s))
if (mpd_client_must_escape_in_quote (*s))
str_append_c (output, '\\');
str_append_c (output, *s);
}

View File

@@ -24,12 +24,12 @@
// It is surprisingly hard to find a good library to handle Unicode shenanigans,
// and there's enough of those for it to be impractical to reimplement them.
//
// GLib ICU libunistring utf8proc
// Decently sized . . x x
// Grapheme breaks . x . x
// Character width x . x x
// Locale handling . . x .
// Liberal license . x . x
// GLib ICU libunistring utf8proc libgrapheme
// Decently sized . . x x x
// Grapheme breaks . x . x x
// Character width x . x x .
// Locale handling . . x . .
// Liberal license . x . x x
//
// Also note that the ICU API is icky and uses UTF-16 for its primary encoding.
//
@@ -728,9 +728,12 @@ tui_flush_buffer (struct widget *self, struct row_buffer *buf)
{
move (self->y, self->x);
int space = MIN (self->width, g_xui.width - self->x);
row_buffer_align (buf, space, self->attrs);
row_buffer_flush (buf);
if (self->y >= 0 && self->y < g_xui.height)
{
int space = MIN (self->width, g_xui.width - self->x);
row_buffer_align (buf, space, self->attrs);
row_buffer_flush (buf);
}
row_buffer_free (buf);
}

View File

@@ -292,7 +292,8 @@ xreallocarray (void *o, size_t n, size_t m)
static char *
xstrdup (const char *s)
{
return strcpy (xmalloc (strlen (s) + 1), s);
size_t len = strlen (s) + 1;
return memcpy (xmalloc (len), s, len);
}
static char *
@@ -4500,7 +4501,7 @@ struct config_item
}
value; ///< The value of this item
struct config_schema *schema; ///< Schema describing this value
const struct config_schema *schema; ///< Schema describing this value
void *user_data; ///< User value attached by schema owner
};
@@ -4652,7 +4653,7 @@ config_item_object (void)
static bool
config_schema_accepts_type
(struct config_schema *self, enum config_item_type type)
(const struct config_schema *self, enum config_item_type type)
{
if (self->type == type)
return true;
@@ -4665,7 +4666,7 @@ config_schema_accepts_type
static bool
config_item_validate_by_schema (struct config_item *self,
struct config_schema *schema, struct error **e)
const struct config_schema *schema, struct error **e)
{
struct error *error = NULL;
if (!config_schema_accepts_type (schema, self->type))
@@ -4686,7 +4687,7 @@ static bool
config_item_set_from (struct config_item *self, struct config_item *source,
struct error **e)
{
struct config_schema *schema = self->schema;
const struct config_schema *schema = self->schema;
if (!schema)
{
// Easy, we don't know what this item is
@@ -5482,7 +5483,7 @@ end:
/// "user_data" is passed to allow its immediate use in validation callbacks
static struct config_item *
config_schema_initialize_item (struct config_schema *schema,
config_schema_initialize_item (const struct config_schema *schema,
struct config_item *parent, void *user_data, struct error **warning,
struct error **e)
{
@@ -5539,7 +5540,7 @@ keep_current:
/// Assign schemas and user_data to multiple items at once;
/// feel free to copy over and modify to suit your particular needs
static void
config_schema_apply_to_object (struct config_schema *schema_array,
config_schema_apply_to_object (const struct config_schema *schema_array,
struct config_item *object, void *user_data)
{
while (schema_array->name)

View File

@@ -1,6 +1,6 @@
# asciiman.awk: simplified AsciiDoc to manual page converter
#
# Copyright (c) 2022 - 2023, Přemysl Eric Janouch <p@janouch.name>
# Copyright (c) 2022 - 2024, Přemysl Eric Janouch <p@janouch.name>
# SPDX-License-Identifier: 0BSD
#
# This is not intended to produce great output, merely useful output.
@@ -149,6 +149,11 @@ function format(line, v) {
} else if (match(line, /^[*][^*]+[*]/) &&
substr(line, RSTART + RLENGTH) !~ /^[[:alnum:]]/) {
v = v "\\fB" substr(line, RSTART + 1, RLENGTH - 2) "\\fP"
} else if (match(line, /^`[^`]+`/) &&
substr(line, RSTART + RLENGTH) !~ /^[[:alnum:]]/) {
# Manual pages are usually already rendered in monospace;
# follow others, and render this in boldface.
v = v "\\fB" substr(line, RSTART + 1, RLENGTH - 2) "\\fP"
} else {
v = v substr(line, 1, 1)
line = substr(line, 2)
@@ -226,6 +231,13 @@ function process(firstline, posattrs, namedattrs) {
return 0
}
if (firstline ~ /^--$/) {
flushspace()
# For now, recognize, but do not process open block delimiters.
InOpenBlock = !InOpenBlock
return 1
}
if (firstline ~ /^(-{4,}|[.]{4,})$/) {
flushspace()