Fix whitespace collapsing in !ai, !gitlog, !changelog responses. (0.39.1)
This commit is contained in:
parent
738323ebaf
commit
184d4c4000
2 changed files with 21 additions and 12 deletions
|
|
@ -1,3 +1,12 @@
|
|||
2026.07.22 - Fix whitespace collapsing in !ai, !gitlog, !changelog responses. (0.39.1)
|
||||
|
||||
- Fixed `collapse_spaces()` to treat tabs, newlines, and carriage returns as whitespace (not just spaces), collapsing any run of mixed whitespace into a single space.
|
||||
- `collapse_spaces()` now strips leading and trailing whitespace from output.
|
||||
- Added `collapse_spaces()` call to `!ai` responses (after `strip_ai_phrases()`).
|
||||
- Added `collapse_spaces()` call to `!changelog full` entries before sending.
|
||||
- Fixed `!gitlog full` output still containing multiple spaces from git's tab-delimited commit fields.
|
||||
- Version bumped to 0.39.1.
|
||||
|
||||
2026.07.21 - Hot reload preserves IRC session (nick, channels, voice). (0.39.0)
|
||||
|
||||
- `reload_do()` now accepts an `exec_new` parameter: when 0 (`!reload`/`!restart`), the child inherits the socket fd and SSL context directly and continues the event loop without reconnecting; when 1 (`!rebuild`/`!code`), the old fork+exec path is used.
|
||||
|
|
|
|||
24
zynk.c
24
zynk.c
|
|
@ -28,7 +28,7 @@ int asprintf(char **, const char *, ...);
|
|||
|
||||
/* ---- constants ---- */
|
||||
|
||||
#define VERSION "0.39.0"
|
||||
#define VERSION "0.39.1"
|
||||
#define DEFAULT_SERVER "irc.libera.chat"
|
||||
#define OPENCODE_BIN "/usr/bin/opencode"
|
||||
#define CLR_RESET "\033[0m"
|
||||
|
|
@ -1578,13 +1578,19 @@ static void normalize_city(const char *in, char *display, size_t dsz, char *url,
|
|||
*/
|
||||
static void collapse_spaces(char *s) {
|
||||
char *r = s, *w = s;
|
||||
int space = 0;
|
||||
int in_space = 1;
|
||||
while (*r) {
|
||||
if (*r == ' ') { if (!space) *w++ = ' '; space = 1; }
|
||||
else { *w++ = *r; space = 0; }
|
||||
if (*r == ' ' || *r == '\t' || *r == '\n' || *r == '\r') {
|
||||
if (!in_space) *w++ = ' ';
|
||||
in_space = 1;
|
||||
} else {
|
||||
*w++ = *r;
|
||||
in_space = 0;
|
||||
}
|
||||
r++;
|
||||
}
|
||||
*w = 0;
|
||||
while (w > s && *(w-1) == ' ') *--w = 0;
|
||||
}
|
||||
|
||||
/* ---- curl helper ---- */
|
||||
|
|
@ -1853,6 +1859,7 @@ static void ai_child_task(Session *s, long long id, const char *agent) {
|
|||
strip_formatting(out);
|
||||
strip_opencode_header(out);
|
||||
strip_ai_phrases(out);
|
||||
collapse_spaces(out);
|
||||
ai_set_answer(id, out);
|
||||
db_update_lasta(out);
|
||||
}
|
||||
|
|
@ -3099,14 +3106,6 @@ static int cmd_gitlog(Session *s, const char *msg, const char *reply_target, con
|
|||
while (elen > 0 && (p[elen-1] == '\n' || p[elen-1] == '\r')) elen--;
|
||||
if (elen > 0) {
|
||||
p[elen] = 0;
|
||||
char *out = p;
|
||||
char *src = p;
|
||||
while (*src) {
|
||||
while (*src == ' ') src++;
|
||||
while (*src && *src != '\n') *out++ = *src++;
|
||||
if (*src == '\n') *out++ = *src++;
|
||||
}
|
||||
*out = 0;
|
||||
collapse_spaces(p);
|
||||
irc_msg(s, reply_target, p);
|
||||
nanosleep(&ts_msg, NULL);
|
||||
|
|
@ -3234,6 +3233,7 @@ static int cmd_changelog(Session *s, const char *msg, const char *reply_target,
|
|||
if (total == 0) { irc_msg(s, reply_target, "changelog: no entries found"); return 1; }
|
||||
int showed_n = count < total ? count : total;
|
||||
for (int i = 0; i < showed_n; i++) {
|
||||
collapse_spaces(entries[i]);
|
||||
irc_msg(s, reply_target, entries[i]);
|
||||
showed++;
|
||||
free(entries[i]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue