Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package ibis for openSUSE:Factory checked in at 2025-03-31 11:44:03 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/ibis (Old) and /work/SRC/openSUSE:Factory/.ibis.new.2696 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ibis" Mon Mar 31 11:44:03 2025 rev:4 rq:1265608 version:0.13.0 Changes: -------- --- /work/SRC/openSUSE:Factory/ibis/ibis.changes 2025-03-17 22:21:44.904893392 +0100 +++ /work/SRC/openSUSE:Factory/.ibis.new.2696/ibis.changes 2025-03-31 11:45:07.268991900 +0200 @@ -1,0 +2,7 @@ +Sun Mar 30 20:39:11 UTC 2025 - Richard Rahl <rra...@opensuse.org> + +- update to 0.13.0: + * Fix the parameter order of an error in Ibis.Client.parse_mode_string + * Implement Ibis.formatting_parse + +------------------------------------------------------------------- Old: ---- ibis-0.12.0.tar.xz ibis-0.12.0.tar.xz.asc New: ---- ibis-0.13.0.tar.xz ibis-0.13.0.tar.xz.asc ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ ibis.spec ++++++ --- /var/tmp/diff_new_pack.IC7LdW/_old 2025-03-31 11:45:09.097067757 +0200 +++ /var/tmp/diff_new_pack.IC7LdW/_new 2025-03-31 11:45:09.117068587 +0200 @@ -18,7 +18,7 @@ %define sover 0 Name: ibis -Version: 0.12.0 +Version: 0.13.0 Release: 0 Summary: Gobject based library License: GPL-2.0-or-later @@ -35,6 +35,7 @@ BuildRequires: pkgconfig(gobject-2.0) >= 2.76 BuildRequires: pkgconfig(gobject-introspection-1.0) BuildRequires: pkgconfig(hasl) >= 0.4.0 +BuildRequires: pkgconfig(pango) >= 1.54.0 %description This parser originated out of an early version of purple-spasm. The library was ++++++ ibis-0.12.0.tar.xz -> ibis-0.13.0.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ibis-0.12.0/.hg_archival.txt new/ibis-0.13.0/.hg_archival.txt --- old/ibis-0.12.0/.hg_archival.txt 2025-03-14 07:02:09.000000000 +0100 +++ new/ibis-0.13.0/.hg_archival.txt 2025-03-30 21:42:39.000000000 +0200 @@ -1,4 +1,4 @@ repo: ee571f6e8e7556786ca8029199b9a669e850c8cb -node: ecd0828aeada054828934156fc0ecca0826bc8ff +node: 9be6cce745b3a29f47749ca8511cfe64c0c2919e branch: default -tag: v0.12.0 +tag: v0.13.0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ibis-0.12.0/ChangeLog new/ibis-0.13.0/ChangeLog --- old/ibis-0.12.0/ChangeLog 2025-03-14 07:02:09.000000000 +0100 +++ new/ibis-0.13.0/ChangeLog 2025-03-30 21:42:39.000000000 +0200 @@ -1,3 +1,8 @@ +0.13.0: 2025-03-30 + * Fix the parameter order of an error in Ibis.Client.parse_mode_string + (RR 3906) (Gary Kramlich) + * Implement Ibis.formatting_parse (IBIR-53) (RR 3940) (Gary Kramlich) + 0.12.0: 2025-03-14 * Add Ibis.ModeChange to represent mode changes (IBIS-44) (RR 3874) (Gary Kramlich) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ibis-0.12.0/ibis/ibisclient.c new/ibis-0.13.0/ibis/ibisclient.c --- old/ibis-0.12.0/ibis/ibisclient.c 2025-03-14 07:02:09.000000000 +0100 +++ new/ibis-0.13.0/ibis/ibisclient.c 2025-03-30 21:42:39.000000000 +0200 @@ -1563,8 +1563,8 @@ IBIS_CLIENT_ERROR, IBIS_CLIENT_ERROR_PARSE_MODE_STRING_TOO_MANY_PARAMETERS, "got %u parameters, expected %u", - param_index, - n_params); + n_params, + param_index); g_array_remove_range(mode_changes, 0, mode_changes->len); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ibis-0.12.0/ibis/ibisformatting.c new/ibis-0.13.0/ibis/ibisformatting.c --- old/ibis-0.12.0/ibis/ibisformatting.c 2025-03-14 07:02:09.000000000 +0100 +++ new/ibis-0.13.0/ibis/ibisformatting.c 2025-03-30 21:42:39.000000000 +0200 @@ -32,11 +32,206 @@ #define IBIS_FORMAT_STRIKETHROUGH (0x1e) #define IBIS_FORMAT_UNDERLINE (0x1f) +#define IBIS_FORMATTING_DEFAULT_COLORS (99) + +/* These colors are copied from https://modern.ircdocs.horse/formatting#colors + * and https://modern.ircdocs.horse/formatting#colors-16-98. + */ +static PangoColor ibis_formatting_palette[] = { + { 0xffff, 0xffff, 0xffff }, /* 00 white */ + { 0x0000, 0x0000, 0x0000 }, /* 01 black */ + { 0x0000, 0x0000, 0x7f7f }, /* 02 blue */ + { 0x0000, 0x9393, 0x0000 }, /* 03 green */ + { 0xffff, 0x0000, 0x0000 }, /* 04 red */ + { 0x7f7f, 0x0000, 0x0000 }, /* 05 brown? */ + { 0x9c9c, 0x0000, 0x9c9c }, /* 06 magenta */ + { 0xfcfc, 0x7f7f, 0x0000 }, /* 07 orange */ + { 0xffff, 0xffff, 0x0000 }, /* 08 yellow */ + { 0x0000, 0xfcfc, 0x0000 }, /* 09 light green */ + { 0x0000, 0x9393, 0x9393 }, /* 10 cyan */ + { 0x0000, 0xffff, 0xffff }, /* 11 light cyan */ + { 0x0000, 0x0000, 0xfcfc }, /* 12 light blue */ + { 0xffff, 0x0000, 0xffff }, /* 13 pink */ + { 0x7f7f, 0x7f7f, 0x7f7f }, /* 14 grey */ + { 0xd2d2, 0xd2d2, 0xd2d2 }, /* 15 light grey */ + { 0x4747, 0x0000, 0x0000 }, /* 16 */ + { 0x4747, 0x2121, 0x0000 }, /* 17 */ + { 0x4747, 0x4747, 0x0000 }, /* 18 */ + { 0x3232, 0x4747, 0x0000 }, /* 19 */ + { 0x0000, 0x4747, 0x0000 }, /* 20 */ + { 0x0000, 0x4747, 0x2c2c }, /* 21 */ + { 0x0000, 0x4747, 0x4747 }, /* 22 */ + { 0x0000, 0x2727, 0x4747 }, /* 23 */ + { 0x0000, 0x0000, 0x4747 }, /* 24 */ + { 0x2e2e, 0x0000, 0x4747 }, /* 25 */ + { 0x4747, 0x0000, 0x4747 }, /* 26 */ + { 0x4747, 0x0000, 0x2a2a }, /* 27 */ + { 0x7474, 0x0000, 0x0000 }, /* 28 */ + { 0x7474, 0x3a3a, 0x0000 }, /* 29 */ + { 0x7474, 0x7474, 0x0000 }, /* 30 */ + { 0x5151, 0x7474, 0x0000 }, /* 31 */ + { 0x0000, 0x7474, 0x0000 }, /* 32 */ + { 0x0000, 0x7474, 0x4949 }, /* 33 */ + { 0x0000, 0x7474, 0x7474 }, /* 34 */ + { 0x0000, 0x4040, 0x7474 }, /* 35 */ + { 0x0000, 0x0000, 0x7474 }, /* 36 */ + { 0x4b4b, 0x0000, 0x7474 }, /* 37 */ + { 0x7474, 0x0000, 0x7474 }, /* 38 */ + { 0x7474, 0x0000, 0x4545 }, /* 39 */ + { 0xb5b5, 0x0000, 0x0000 }, /* 40 */ + { 0xb5b5, 0x6363, 0x0000 }, /* 41 */ + { 0xb5b5, 0xb5b5, 0x0000 }, /* 42 */ + { 0x7d7d, 0xb5b5, 0x0000 }, /* 43 */ + { 0x0000, 0xb5b5, 0x0000 }, /* 44 */ + { 0x0000, 0xb5b5, 0x7171 }, /* 45 */ + { 0x0000, 0xb5b5, 0xb5b5 }, /* 46 */ + { 0x0000, 0x6363, 0xb5b5 }, /* 47 */ + { 0x0000, 0x0000, 0xb5b5 }, /* 48 */ + { 0x7575, 0x0000, 0xb5b5 }, /* 49 */ + { 0xb5b5, 0x0000, 0xb5b5 }, /* 50 */ + { 0xb5b5, 0x0000, 0x6b6b }, /* 51 */ + { 0xffff, 0x0000, 0x0000 }, /* 52 */ + { 0xffff, 0x8c8c, 0x0000 }, /* 53 */ + { 0xffff, 0xffff, 0x0000 }, /* 54 */ + { 0xb2b2, 0xffff, 0x0000 }, /* 55 */ + { 0x0000, 0xffff, 0x0000 }, /* 56 */ + { 0x0000, 0xffff, 0xa0a0 }, /* 57 */ + { 0x0000, 0xffff, 0xffff }, /* 58 */ + { 0x0000, 0x8c8c, 0xffff }, /* 59 */ + { 0x0000, 0x0000, 0xffff }, /* 60 */ + { 0xa5a5, 0x0000, 0xffff }, /* 61 */ + { 0xffff, 0x0000, 0xffff }, /* 62 */ + { 0xffff, 0x0000, 0x9898 }, /* 63 */ + { 0xffff, 0x5959, 0x5959 }, /* 64 */ + { 0xffff, 0xb4b4, 0x5959 }, /* 65 */ + { 0xffff, 0xffff, 0x7171 }, /* 66 */ + { 0xcfcf, 0xffff, 0x6060 }, /* 67 */ + { 0x6f6f, 0xffff, 0x6f6f }, /* 68 */ + { 0x6565, 0xffff, 0xc9c9 }, /* 69 */ + { 0x6d6d, 0xffff, 0xffff }, /* 70 */ + { 0x5959, 0xb4b4, 0xffff }, /* 71 */ + { 0x5959, 0x5959, 0xffff }, /* 72 */ + { 0xc4c4, 0x5959, 0xffff }, /* 73 */ + { 0xffff, 0x6666, 0xffff }, /* 74 */ + { 0xffff, 0x5959, 0xbcbc }, /* 75 */ + { 0xffff, 0x9c9c, 0x9c9c }, /* 76 */ + { 0xffff, 0xd3d3, 0x9c9c }, /* 77 */ + { 0xffff, 0xffff, 0x9c9c }, /* 78 */ + { 0xe2e2, 0xffff, 0x9c9c }, /* 79 */ + { 0x9c9c, 0xffff, 0x9c9c }, /* 80 */ + { 0x9c9c, 0xffff, 0xdbdb }, /* 81 */ + { 0x9c9c, 0xffff, 0xffff }, /* 82 */ + { 0x9c9c, 0xd3d3, 0xffff }, /* 83 */ + { 0x9c9c, 0x9c9c, 0xffff }, /* 84 */ + { 0xdcdc, 0x9c9c, 0xffff }, /* 85 */ + { 0xffff, 0x9c9c, 0xffff }, /* 86 */ + { 0xffff, 0x9494, 0xd3d3 }, /* 87 */ + { 0x0000, 0x0000, 0x0000 }, /* 88 */ + { 0x1313, 0x1313, 0x1313 }, /* 89 */ + { 0x2828, 0x2828, 0x2828 }, /* 90 */ + { 0x3636, 0x3636, 0x3636 }, /* 91 */ + { 0x4d4d, 0x4d4d, 0x4d4d }, /* 92 */ + { 0x6565, 0x6565, 0x6565 }, /* 93 */ + { 0x8181, 0x8181, 0x8181 }, /* 94 */ + { 0x9f9f, 0x9f9f, 0x9f9f }, /* 95 */ + { 0xbcbc, 0xbcbc, 0xbcbc }, /* 96 */ + { 0xe2e2, 0xe2e2, 0xe2e2 }, /* 97 */ + { 0xffff, 0xffff, 0xffff }, /* 98 */ +}; + /****************************************************************************** * Helpers *****************************************************************************/ static inline gboolean -ibis_formatting_is_hex_color(const char *text) { +ibis_formatting_get_color(PangoColor *color, guint index) { + if(index > G_N_ELEMENTS(ibis_formatting_palette)) { + return FALSE; + } + + *color = ibis_formatting_palette[index]; + + return TRUE; +} + +static inline gboolean +ibis_formatting_is_color(const char *text, guint *bytes, PangoColor *color) { + char buffer[3]; + guint length = 0; + + if(text == NULL || text[0] == '\0') { + return FALSE; + } + + /* If the first byte is not a digit we can exit early. */ + if(!g_ascii_isdigit(text[0])) { + return FALSE; + } + + /* Check if the second byte is a digit as well. */ + if(g_ascii_isdigit(text[1])) { + length = 2; + } else { + length = 1; + } + + /* If the user gave us a place to put the value, do it. */ + if(color != NULL) { + int index = 0; + + memset(buffer, 0, sizeof(buffer)); + strncpy(buffer, text, length); + index = atoi(buffer); + *color = ibis_formatting_palette[index]; + } + + /* Set bytes to the length of the color. */ + if(bytes != NULL) { + *bytes = length; + } + + return TRUE; +} + +static inline void +ibis_formatting_parse_color(const char *text, guint *offset, + gboolean *fg_set, PangoColor *fg, + gboolean *bg_set, PangoColor *bg) +{ + guint bytes = 0; + + /* If we're at the end of the string then we are ending a previous color + * format. + */ + if(text == NULL || text[0] == '\0') { + return; + } + + if(ibis_formatting_is_color(text, &bytes, fg)) { + if(fg_set != NULL) { + *fg_set = TRUE; + } + + if(text[bytes] == ',') { + guint bg_bytes = 0; + + if(ibis_formatting_is_color(&text[bytes + 1], &bg_bytes, bg)) { + if(bg_set != NULL) { + *bg_set = TRUE; + } + + /* Increment bytes for the length of bg_bytes and the comma. */ + bytes += bg_bytes + 1; + } + } + } + + if(offset != NULL) { + *offset = bytes; + } +} + +static inline gboolean +ibis_formatting_is_hex_color(const char *text, PangoColor *color) { for(int i = 0; i < 6; i++) { if(text[i] == '\0') { return FALSE; @@ -47,15 +242,97 @@ } } + if(color != NULL) { + char buffer[8]; + + memset(buffer, 0, sizeof(buffer)); + buffer[0] = '#'; + strncpy(buffer + 1, text, 6); + if(!pango_color_parse(color, buffer)) { + return FALSE; + } + } + return TRUE; } +static inline gboolean +ibis_formatting_parse_hex_color(const char *text, guint *offset, + gboolean *fg_set, PangoColor *fg, + gboolean *bg_set, PangoColor *bg) +{ + guint bytes = 0; + + if(text == NULL || text[0] == '\0') { + return FALSE; + } + + if(ibis_formatting_is_hex_color(text, fg)) { + if(fg_set != NULL) { + *fg_set = TRUE; + } + + bytes = 6; + + if(text[bytes] == ',' && + ibis_formatting_is_hex_color(&text[bytes + 1], bg)) + { + if(bg_set != NULL) { + *bg_set = TRUE; + } + + bytes += 7; + } + } + + if(offset != NULL) { + *offset = bytes; + } + + return TRUE; +} + +/* The following macros have been created to make the format parser easier to + * read. There's not much to them, but they help avoid a lot of duplicated + * code in the parsing function. + */ +#define IBIS_FORMATTING_START_ATTRIBUTE(tag, ctor) G_STMT_START { \ + tag = ctor; \ + tag->start_index = position; \ + pango_attr_list_insert(real_attrs, tag); \ +} G_STMT_END + +#define IBIS_FORMATTING_END_ATTRIBUTE(tag) G_STMT_START { \ + if(tag != NULL) { \ + tag->end_index = position; \ + tag = NULL; \ + } \ +} G_STMT_END + +#define IBIS_FORMATTING_TOGGLE_ATTRIBUTE(tag, ctor) G_STMT_START { \ + if(tag == NULL) { \ + IBIS_FORMATTING_START_ATTRIBUTE(tag, ctor); \ + } else { \ + IBIS_FORMATTING_END_ATTRIBUTE(tag); \ + } \ +} G_STMT_END + /****************************************************************************** * Public API *****************************************************************************/ char * -ibis_formatting_strip(const char *text) { +ibis_formatting_parse(const char *text, PangoAttrList **attrs) { GString *str = NULL; + PangoAttrList *real_attrs = NULL; + PangoAttribute *background = NULL; + PangoAttribute *bold = NULL; + PangoAttribute *foreground = NULL; + PangoAttribute *italic = NULL; + PangoAttribute *monospace = NULL; + PangoAttribute *strikethrough = NULL; + PangoAttribute *underline = NULL; + guint offset = 0; + guint position = 0; /* We don't use ibis_str_is_empty here because if we're passed an empty * string, we should return a newly allocated empty string. @@ -65,54 +342,142 @@ } str = g_string_new(""); + real_attrs = pango_attr_list_new(); - for(int i = 0; text[i] != '\0'; i++) { + for(guint i = 0; text[i] != '\0'; i++) { switch(text[i]) { case IBIS_FORMAT_BOLD: + IBIS_FORMATTING_TOGGLE_ATTRIBUTE(bold, pango_attr_weight_new(PANGO_WEIGHT_BOLD)); + break; case IBIS_FORMAT_ITALIC: + IBIS_FORMATTING_TOGGLE_ATTRIBUTE(italic, pango_attr_style_new(PANGO_STYLE_ITALIC)); + break; case IBIS_FORMAT_MONOSPACE: + IBIS_FORMATTING_TOGGLE_ATTRIBUTE(monospace, pango_attr_family_new("monospace")); + break; case IBIS_FORMAT_RESET: + IBIS_FORMATTING_END_ATTRIBUTE(background); + IBIS_FORMATTING_END_ATTRIBUTE(bold); + IBIS_FORMATTING_END_ATTRIBUTE(foreground); + IBIS_FORMATTING_END_ATTRIBUTE(italic); + IBIS_FORMATTING_END_ATTRIBUTE(monospace); + IBIS_FORMATTING_END_ATTRIBUTE(strikethrough); + IBIS_FORMATTING_END_ATTRIBUTE(underline); + break; case IBIS_FORMAT_REVERSE: + break; case IBIS_FORMAT_STRIKETHROUGH: + IBIS_FORMATTING_TOGGLE_ATTRIBUTE(strikethrough, pango_attr_strikethrough_new(TRUE)); + break; case IBIS_FORMAT_UNDERLINE: - continue; + IBIS_FORMATTING_TOGGLE_ATTRIBUTE(underline, + pango_attr_underline_new(PANGO_UNDERLINE_SINGLE)); break; - case IBIS_FORMAT_COLOR: - if(g_ascii_isdigit(text[i + 1])) { - i += 1; - - if(g_ascii_isdigit(text[i + 1])) { - i += 1; - } + case IBIS_FORMAT_COLOR: { + PangoColor bg; + PangoColor fg; + gboolean bg_set = FALSE; + gboolean fg_set = FALSE; + + ibis_formatting_parse_color(&text[i + 1], &offset, + &fg_set, &fg, + &bg_set, &bg); + + if(fg_set) { + /* If we had an existing foreground, we need to end it. */ + IBIS_FORMATTING_END_ATTRIBUTE(foreground); + + IBIS_FORMATTING_START_ATTRIBUTE(foreground, + pango_attr_foreground_new(fg.red, + fg.green, + fg.blue)); + } else { + IBIS_FORMATTING_END_ATTRIBUTE(foreground); + } - if(text[i + 1] == ',' && g_ascii_isdigit(text[i + 2])) { - i += 2; + if(bg_set) { + IBIS_FORMATTING_END_ATTRIBUTE(background); - if(g_ascii_isdigit(text[i + 1])) { - i += 1; - } - } + IBIS_FORMATTING_START_ATTRIBUTE(background, + pango_attr_background_new(bg.red, + bg.green, + bg.blue)); + } else { + IBIS_FORMATTING_END_ATTRIBUTE(background); } + i += offset; + break; + } case IBIS_FORMAT_HEX_COLOR: - if(ibis_formatting_is_hex_color(&text[i + 1])) { - i += 6; + PangoColor bg; + PangoColor fg; + gboolean bg_set = FALSE; + gboolean fg_set = FALSE; + + ibis_formatting_parse_hex_color(&text[i + 1], &offset, + &fg_set, &fg, + &bg_set, &bg); + + if(fg_set) { + /* If we had an existing foreground, we need to end it. */ + IBIS_FORMATTING_END_ATTRIBUTE(foreground); + + IBIS_FORMATTING_START_ATTRIBUTE(foreground, + pango_attr_foreground_new(fg.red, + fg.green, + fg.blue)); + } else { + IBIS_FORMATTING_END_ATTRIBUTE(foreground); } - if(text[i + 1] == ',' && - ibis_formatting_is_hex_color(&text[i + 2])) - { - i += 7; + if(bg_set) { + IBIS_FORMATTING_END_ATTRIBUTE(background); + + IBIS_FORMATTING_START_ATTRIBUTE(background, + pango_attr_background_new(bg.red, + bg.green, + bg.blue)); + } else { + IBIS_FORMATTING_END_ATTRIBUTE(background); } + i += offset; + break; default: g_string_append_c(str, text[i]); + position += 1; break; } + } + IBIS_FORMATTING_END_ATTRIBUTE(background); + IBIS_FORMATTING_END_ATTRIBUTE(bold); + IBIS_FORMATTING_END_ATTRIBUTE(foreground); + IBIS_FORMATTING_END_ATTRIBUTE(italic); + IBIS_FORMATTING_END_ATTRIBUTE(monospace); + IBIS_FORMATTING_END_ATTRIBUTE(strikethrough); + IBIS_FORMATTING_END_ATTRIBUTE(underline); + + if(attrs != NULL) { + *attrs = real_attrs; + } else { + pango_attr_list_unref(real_attrs); } return g_string_free_and_steal(str); } + +char * +ibis_formatting_strip(const char *text) { + /* We don't use ibis_str_is_empty here because if we're passed an empty + * string, we should return a newly allocated empty string. + */ + if(text == NULL) { + return NULL; + } + + return ibis_formatting_parse(text, NULL); +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ibis-0.12.0/ibis/ibisformatting.h new/ibis-0.13.0/ibis/ibisformatting.h --- old/ibis-0.12.0/ibis/ibisformatting.h 2025-03-14 07:02:09.000000000 +0100 +++ new/ibis-0.13.0/ibis/ibisformatting.h 2025-03-30 21:42:39.000000000 +0200 @@ -29,11 +29,27 @@ #include <glib.h> +#include <pango/pango.h> + #include "ibisversion.h" G_BEGIN_DECLS /** + * ibis_formatting_parse: + * @text: (nullable): the text to parse + * @attrs: (out) (optional): a return address for the formatting attributes + * + * Separates the raw text and its formatting. + * + * Returns: (nullable): The raw text. + * + * Since: 0.13 + */ +IBIS_AVAILABLE_IN_0_13 +char *ibis_formatting_parse(const char *text, PangoAttrList **attrs); + +/** * ibis_formatting_strip: * @text: (nullable): the text to strip * diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ibis-0.12.0/ibis/ibisversion.h new/ibis-0.13.0/ibis/ibisversion.h --- old/ibis-0.12.0/ibis/ibisversion.h 2025-03-14 07:02:09.000000000 +0100 +++ new/ibis-0.13.0/ibis/ibisversion.h 2025-03-30 21:42:39.000000000 +0200 @@ -413,6 +413,30 @@ #define IBIS_AVAILABLE_TYPE_IN_0_12 #endif +/** + * IBIS_VERSION_0_13: + * + * A macro that evaluates to the 0.13 version of ibis, in a format that can be + * used by the C pre-processor. + * + * Since: 0.13 + */ +#define IBIS_VERSION_0_13 (G_ENCODE_VERSION(0, 13)) + +#if IBIS_VERSION_MAX_ALLOWED < IBIS_VERSION_0_13 +#define IBIS_AVAILABLE_IN_0_13 IBIS_UNAVAILABLE(0, 13) +#define IBIS_AVAILABLE_STATIC_INLINE_IN_0_13 IBIS_UNAVAILABLE_STATIC_INLINE(0, 13) +#define IBIS_AVAILABLE_MACRO_IN_0_13 IBIS_UNAVAILABLE_MACRO(0, 13) +#define IBIS_AVAILABLE_ENUMERATOR_IN_0_13 IBIS_UNAVAILABLE_ENUMERATOR(0, 13) +#define IBIS_AVAILABLE_TYPE_IN_0_13 IBIS_UNAVAILABLE_TYPE(0, 13) +#else +#define IBIS_AVAILABLE_IN_0_13 _IBIS_EXTERN +#define IBIS_AVAILABLE_STATIC_INLINE_IN_0_13 +#define IBIS_AVAILABLE_MACRO_IN_0_13 +#define IBIS_AVAILABLE_ENUMERATOR_IN_0_13 +#define IBIS_AVAILABLE_TYPE_IN_0_13 +#endif + G_BEGIN_DECLS /** diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ibis-0.12.0/ibis/meson.build new/ibis-0.13.0/ibis/meson.build --- old/ibis-0.12.0/ibis/meson.build 2025-03-14 07:02:09.000000000 +0100 +++ new/ibis-0.13.0/ibis/meson.build 2025-03-30 21:42:39.000000000 +0200 @@ -97,12 +97,13 @@ # Library Target ############################################################################### ibis_inc = include_directories('.') +ibis_dependencies = [birb_dep, gio_dep, glib_dep, gobject_dep, hasl_dep, pango_dep] ibis_lib = library('ibis', IBIS_SOURCES + IBIS_HEADERS + IBIS_BUILT_SOURCES + IBIS_BUILT_HEADERS, c_args : ['-DIBIS_COMPILATION', '-DG_LOG_USE_STRUCTURED', '-DG_LOG_DOMAIN="Ibis"'], gnu_symbol_visibility : 'hidden', - dependencies : [birb_dep, gio_dep, glib_dep, gobject_dep, hasl_dep], + dependencies : ibis_dependencies, include_directories : [toplevel_inc, ibis_inc], version : IBIS_LIB_VERSION, install : true) @@ -117,7 +118,7 @@ description : 'Ibis IRCv3 Parsing Library', filebase : 'ibis', subdirs : 'ibis-1.0', - libraries : [birb_dep, gio_dep, glib_dep, gobject_dep, hasl_dep], + libraries : ibis_dependencies, ) ############################################################################### @@ -126,7 +127,7 @@ if get_option('introspection') ibis_gir = gnome.generate_gir(ibis_lib, sources : IBIS_SOURCES + IBIS_HEADERS + IBIS_BUILT_HEADERS, - includes : ['Gio-2.0', 'GObject-2.0', 'Hasl-1.0'], + includes : ['Gio-2.0', 'GObject-2.0', 'Hasl-1.0', 'Pango-1.0'], header : 'ibis.h', namespace : 'Ibis', symbol_prefix : 'ibis', @@ -142,7 +143,7 @@ # Library Dependency Object ############################################################################### ibis_dep = declare_dependency( - dependencies : [birb_dep, gio_dep, glib_dep, gobject_dep, hasl_dep], + dependencies : ibis_dependencies, include_directories : [toplevel_inc, ibis_inc], link_with : ibis_lib, sources : IBIS_BUILT_HEADERS + IBIS_GENERATED_TARGETS) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ibis-0.12.0/ibis/reference/ibis.toml.in new/ibis-0.13.0/ibis/reference/ibis.toml.in --- old/ibis-0.12.0/ibis/reference/ibis.toml.in 2025-03-14 07:02:09.000000000 +0100 +++ new/ibis-0.13.0/ibis/reference/ibis.toml.in 2025-03-30 21:42:39.000000000 +0200 @@ -36,6 +36,11 @@ description = "Hassle-free Authentication and Security Layer client library." docs_url = "https://docs.imfreedom.org/hasl/" + [dependencies."Pango-1.0"] + name = "Pango" + description = "Internationalized text layout and rendering" + docs_url = "https://docs.gtk.org/Pango/" + [theme] name = "basic" show_index_summary = true diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ibis-0.12.0/ibis/tests/test_formatting.c new/ibis-0.13.0/ibis/tests/test_formatting.c --- old/ibis-0.12.0/ibis/tests/test_formatting.c 2025-03-14 07:02:09.000000000 +0100 +++ new/ibis-0.13.0/ibis/tests/test_formatting.c 2025-03-30 21:42:39.000000000 +0200 @@ -27,14 +27,12 @@ /****************************************************************************** * Strip Tests *****************************************************************************/ -static void -test_ibis_formatting_strip(const char *input, const char *expected) { - char *actual = NULL; - - actual = ibis_formatting_strip(input); - g_assert_cmpstr(actual, ==, expected); - g_clear_pointer(&actual, g_free); -} +#define test_ibis_formatting_strip(input, expected) G_STMT_START { \ + char *actual = NULL; \ + actual = ibis_formatting_strip(input); \ + g_assert_cmpstr(actual, ==, expected); \ + g_clear_pointer(&actual, g_free); \ +} G_STMT_END static void test_ibis_formatting_strip_null(void) { @@ -109,7 +107,7 @@ static void test_ibis_formatting_strip_italic(void) { test_ibis_formatting_strip("what do you \035mean\035?!", - "what do you mean?!"); + "what do you mean?!"); } static void @@ -130,13 +128,13 @@ static void test_ibis_formatting_strip_strikethrough(void) { test_ibis_formatting_strip("\036I could be wrong\036", - "I could be wrong"); + "I could be wrong"); } static void test_ibis_formatting_strip_underline(void) { test_ibis_formatting_strip("You can't handle the \037truth\037!", - "You can't handle the truth!"); + "You can't handle the truth!"); } static void @@ -168,12 +166,384 @@ } /****************************************************************************** + * Parse Tests + *****************************************************************************/ +#define test_ibis_formatting_parse(raw, expected, expected_attrs) G_STMT_START { \ + PangoAttrList *actual_attrs = NULL; \ + char *actual_text = NULL; \ + actual_text = ibis_formatting_parse(raw, &actual_attrs); \ + g_assert_cmpstr(actual_text, ==, expected); \ + g_clear_pointer(&actual_text, g_free); \ + if(expected_attrs != NULL) { \ + g_assert_true(pango_attr_list_equal(actual_attrs, expected_attrs)); \ + pango_attr_list_unref(expected_attrs); \ + pango_attr_list_unref(actual_attrs); \ + } else { \ + g_assert_null(actual_attrs); \ + } \ +} G_STMT_END + +static void +test_ibis_formatting_parse_null(void) { + test_ibis_formatting_parse(NULL, NULL, NULL); +} + +static void +test_ibis_formatting_parse_empty(void) { + PangoAttrList *attrs = pango_attr_list_new(); + + test_ibis_formatting_parse("", "", attrs); +} + +static void +test_ibis_formatting_parse_color_comma(void) { + PangoAttrList *attrs = pango_attr_list_new(); + + test_ibis_formatting_parse("\003,", ",", attrs); +} + +static void +test_ibis_formatting_parse_color_foreground_comma(void) { + PangoAttrList *attrs = pango_attr_list_new(); + PangoAttribute *attr = NULL; + + attr = pango_attr_foreground_new(0x0000, 0x9393, 0x0000); + attr->start_index = 0; + attr->end_index = 1; + pango_attr_list_insert(attrs, attr); + + test_ibis_formatting_parse("\0033,", ",", attrs); +} + +static void +test_ibis_formatting_parse_color_full(void) { + PangoAttrList *attrs = pango_attr_list_new(); + PangoAttribute *attr = NULL; + + attr = pango_attr_foreground_new(0x0000, 0x9393, 0x0000); + attr->start_index = 0; + attr->end_index = 3; + pango_attr_list_insert(attrs, attr); + + attr = pango_attr_background_new(0x0000, 0xfcfc, 0x0000); + attr->start_index = 0; + attr->end_index = 3; + pango_attr_list_insert(attrs, attr); + + test_ibis_formatting_parse("\0033,9wee", "wee", attrs); +} + +static void +test_ibis_formatting_parse_color_foreground_3_digit(void) { + PangoAttrList *attrs = pango_attr_list_new(); + PangoAttribute *attr = NULL; + + attr = pango_attr_foreground_new(0x5151, 0x7474, 0x0000); + attr->start_index = 0; + attr->end_index = 1; + pango_attr_list_insert(attrs, attr); + + test_ibis_formatting_parse("\003314", "4", attrs); +} + +static void +test_ibis_formatting_parse_color_background_3_digit(void) { + PangoAttrList *attrs = pango_attr_list_new(); + PangoAttribute *attr = NULL; + + attr = pango_attr_foreground_new(0x0000, 0x0000, 0x0000); + attr->start_index = 0; + attr->end_index = 1; + pango_attr_list_insert(attrs, attr); + + attr = pango_attr_background_new(0x0000, 0x2727, 0x4747); + attr->start_index = 0; + attr->end_index = 1; + pango_attr_list_insert(attrs, attr); + + test_ibis_formatting_parse("\0031,234", "4", attrs); +} + +static void +test_ibis_formatting_parse_hex_color(void) { + PangoAttrList *attrs = pango_attr_list_new(); + PangoAttribute *attr = NULL; + + attr = pango_attr_foreground_new(0xffff, 0x0000, 0xffff); + attr->start_index = 0; + attr->end_index = 4; + pango_attr_list_insert(attrs, attr); + + test_ibis_formatting_parse("\004FF00FFwoo!", "woo!", attrs); +} + +static void +test_ibis_formatting_parse_hex_color_full(void) { + PangoAttrList *attrs = pango_attr_list_new(); + PangoAttribute *attr = NULL; + + attr = pango_attr_foreground_new(0xffff, 0x0000, 0xffff); + attr->start_index = 0; + attr->end_index = 4; + pango_attr_list_insert(attrs, attr); + + attr = pango_attr_background_new(0x0000, 0xffff, 0x0000); + attr->start_index = 0; + attr->end_index = 4; + pango_attr_list_insert(attrs, attr); + + test_ibis_formatting_parse("\004FF00FF,00FF00woo!", "woo!", attrs); +} + +static void +test_ibis_formatting_parse_hex_color_comma(void) { + PangoAttrList *attrs = pango_attr_list_new(); + + test_ibis_formatting_parse("\004,", ",", attrs); +} + +static void +test_ibis_formatting_parse_hex_color_foreground_comma(void) { + PangoAttrList *attrs = pango_attr_list_new(); + PangoAttribute *attr = NULL; + + attr = pango_attr_foreground_new(0xfefe, 0xfefe, 0xfefe); + attr->start_index = 0; + attr->end_index = 1; + pango_attr_list_insert(attrs, attr); + + test_ibis_formatting_parse("\004FEFEFE,", ",", attrs); +} + +static void +test_ibis_formatting_parse_hex_color_foreground_7_characters(void) { + PangoAttrList *attrs = pango_attr_list_new(); + PangoAttribute *attr = NULL; + + attr = pango_attr_foreground_new(0xfefe, 0xfefe, 0xfefe); + attr->start_index = 0; + attr->end_index = 1; + pango_attr_list_insert(attrs, attr); + + test_ibis_formatting_parse("\004FEFEFEF", "F", attrs); +} + +static void +test_ibis_formatting_parse_hex_color_background_7_characters(void) { + PangoAttrList *attrs = pango_attr_list_new(); + PangoAttribute *attr = NULL; + + attr = pango_attr_foreground_new(0xfefe, 0xfefe, 0xfefe); + attr->start_index = 0; + attr->end_index = 1; + pango_attr_list_insert(attrs, attr); + + attr = pango_attr_background_new(0x2222, 0x2222, 0x2222); + attr->start_index = 0; + attr->end_index = 1; + pango_attr_list_insert(attrs, attr); + + test_ibis_formatting_parse("\004FEFEFE,2222223", "3", attrs); +} + +static void +test_ibis_formatting_parse_bold(void) { + PangoAttrList *attrs = pango_attr_list_new(); + PangoAttribute *attr = NULL; + + attr = pango_attr_weight_new(PANGO_WEIGHT_BOLD); + attr->start_index = 8; + attr->end_index = 12; + pango_attr_list_insert(attrs, attr); + + test_ibis_formatting_parse("this is \002bold\002!", + "this is bold!", + attrs); +} + +static void +test_ibis_formatting_parse_italic(void) { + PangoAttrList *attrs = pango_attr_list_new(); + PangoAttribute *attr = NULL; + + attr = pango_attr_style_new(PANGO_STYLE_ITALIC); + attr->start_index = 12; + attr->end_index = 16; + pango_attr_list_insert(attrs, attr); + + test_ibis_formatting_parse("what do you \035mean\035?!", + "what do you mean?!", + attrs); +} + +static void +test_ibis_formatting_parse_monospace(void) { + PangoAttrList *attrs = pango_attr_list_new(); + PangoAttribute *attr = NULL; + + attr = pango_attr_family_new("monospace"); + attr->start_index = 0; + attr->end_index = 4; + pango_attr_list_insert(attrs, attr); + + test_ibis_formatting_parse("\021i++;\021", "i++;", attrs); +} + +static void +test_ibis_formatting_parse_reset(void) { + PangoAttrList *attrs = pango_attr_list_new(); + + test_ibis_formatting_parse("end of formatting\017", + "end of formatting", + attrs); +} + +static void +test_ibis_formatting_parse_reverse(void) { + PangoAttrList *attrs = pango_attr_list_new(); + + /* reverse is ignored right now as we don't know how to handle it. */ + test_ibis_formatting_parse("re\026ver\026se", "reverse", attrs); +} + +static void +test_ibis_formatting_parse_strikethrough(void) { + PangoAttrList *attrs = pango_attr_list_new(); + PangoAttribute *attr = NULL; + + attr = pango_attr_strikethrough_new(TRUE); + attr->start_index = 0; + attr->end_index = 16; + pango_attr_list_insert(attrs, attr); + + test_ibis_formatting_parse("\036I could be wrong\036", + "I could be wrong", + attrs); +} + +static void +test_ibis_formatting_parse_underline(void) { + PangoAttrList *attrs = pango_attr_list_new(); + PangoAttribute *attr = NULL; + + attr = pango_attr_underline_new(PANGO_UNDERLINE_SINGLE); + attr->start_index = 21; + attr->end_index = 26; + pango_attr_list_insert(attrs, attr); + + test_ibis_formatting_parse("You can't handle the \037truth\037!", + "You can't handle the truth!", + attrs); +} + +static void +test_ibis_formatting_parse_spec_example1(void) { + PangoAttrList *attrs = pango_attr_list_new(); + PangoAttribute *attr = NULL; + + attr = pango_attr_foreground_new(0x0, 0x9393, 0x0); + attr->start_index = 7; + attr->end_index = 12; + pango_attr_list_insert(attrs, attr); + + attr = pango_attr_foreground_new(0xfcfc, 0x7f7f, 0x0); + attr->start_index = 22; + attr->end_index = 41; + pango_attr_list_insert(attrs, attr); + + test_ibis_formatting_parse("I love \0033IRC! \003It is the \0037best protocol ever!", + "I love IRC! It is the best protocol ever!", + attrs); +} + +static void +test_ibis_formatting_parse_spec_example2(void) { + PangoAttrList *attrs = pango_attr_list_new(); + PangoAttribute *attr = NULL; + + attr = pango_attr_style_new(PANGO_STYLE_ITALIC); + attr->start_index = 10; + attr->end_index = 22; + pango_attr_list_insert(attrs, attr); + + attr = pango_attr_foreground_new(0xffff, 0x0, 0xffff); + attr->start_index = 10; + attr->end_index = 15; + pango_attr_list_insert(attrs, attr); + + attr = pango_attr_background_new(0x0, 0xfcfc, 0x0); + attr->start_index = 10; + attr->end_index = 15; + pango_attr_list_insert(attrs, attr); + + test_ibis_formatting_parse("This is a \035\00313,9cool \003message", + "This is a cool message", + attrs); +} + +static void +test_ibis_formatting_parse_spec_example3(void) { + PangoAttrList *attrs = pango_attr_list_new(); + PangoAttribute *attr = NULL; + + attr = pango_attr_weight_new(PANGO_WEIGHT_BOLD); + attr->start_index = 4; + attr->end_index = 15; + pango_attr_list_insert(attrs, attr); + + attr = pango_attr_foreground_new(0xffff, 0x0, 0x0); + attr->start_index = 7; + attr->end_index = 10; + pango_attr_list_insert(attrs, attr); + + attr = pango_attr_background_new(0x0, 0x0, 0xfcfc); + attr->start_index = 7; + attr->end_index = 10; + pango_attr_list_insert(attrs, attr); + + test_ibis_formatting_parse("IRC \002is \0034,12so \003great\017!", + "IRC is so great!", + attrs); +} + +static void +test_ibis_formatting_parse_spec_example4(void) { + PangoAttrList *attrs = pango_attr_list_new(); + PangoAttribute *attr = NULL; + + attr = pango_attr_foreground_new(0xffff, 0x0000, 0xffff); + attr->start_index = 19; + attr->end_index = 21; + pango_attr_list_insert(attrs, attr); + + attr = pango_attr_background_new(0xffff, 0xffff, 0x0000); + attr->start_index = 19; + attr->end_index = 21; + pango_attr_list_insert(attrs, attr); + + attr = pango_attr_weight_new(PANGO_WEIGHT_BOLD); + attr->start_index = 46; + attr->end_index = 47; + pango_attr_list_insert(attrs, attr); + + attr = pango_attr_style_new(PANGO_STYLE_ITALIC); + attr->start_index = 47; + attr->end_index = 48; + pango_attr_list_insert(attrs, attr); + + test_ibis_formatting_parse("Rules: Don't spam 5\00313,8,6\003,7,8, and especially not \0029\002\035!", + "Rules: Don't spam 5,6,7,8, and especially not 9!", + attrs); +} + +/****************************************************************************** * Main *****************************************************************************/ int main(int argc, char *argv[]) { g_test_init(&argc, &argv, NULL); + /* Strip tests */ g_test_add_func("/ibis/formatting/strip/null", test_ibis_formatting_strip_null); g_test_add_func("/ibis/formatting/strip/empty", @@ -230,5 +600,59 @@ g_test_add_func("/ibis/formatting/strip/spec-example4", test_ibis_formatting_strip_spec_example4); + /* Parsing tests */ + g_test_add_func("/ibis/formatting/parse/null", + test_ibis_formatting_parse_null); + g_test_add_func("/ibis/formatting/parse/empty", + test_ibis_formatting_parse_empty); + + g_test_add_func("/ibis/formatting/parse/color-comma", + test_ibis_formatting_parse_color_comma); + g_test_add_func("/ibis/formatting/parse/color-full", + test_ibis_formatting_parse_color_full); + g_test_add_func("/ibis/formatting/parse/color-foreground-comma", + test_ibis_formatting_parse_color_foreground_comma); + g_test_add_func("/ibis/formatting/parse/color-foreground-3-digit", + test_ibis_formatting_parse_color_foreground_3_digit); + g_test_add_func("/ibis/formatting/parse/color-background-3-digit", + test_ibis_formatting_parse_color_background_3_digit); + + g_test_add_func("/ibis/formatting/parse/hex-color", + test_ibis_formatting_parse_hex_color); + g_test_add_func("/ibis/formatting/parse/hex-color-full", + test_ibis_formatting_parse_hex_color_full); + g_test_add_func("/ibis/formatting/parse/hex-color-comma", + test_ibis_formatting_parse_hex_color_comma); + g_test_add_func("/ibis/formatting/parse/hex-color-foreground-comma", + test_ibis_formatting_parse_hex_color_foreground_comma); + g_test_add_func("/ibis/formatting/parse/hex-color-foreground-7-characters", + test_ibis_formatting_parse_hex_color_foreground_7_characters); + g_test_add_func("/ibis/formatting/parse/hex-color-background-7-characters", + test_ibis_formatting_parse_hex_color_background_7_characters); + + g_test_add_func("/ibis/formatting/parse/bold", + test_ibis_formatting_parse_bold); + g_test_add_func("/ibis/formatting/parse/italic", + test_ibis_formatting_parse_italic); + g_test_add_func("/ibis/formatting/parse/monospace", + test_ibis_formatting_parse_monospace); + g_test_add_func("/ibis/formatting/parse/reset", + test_ibis_formatting_parse_reset); + g_test_add_func("/ibis/formatting/parse/reverse", + test_ibis_formatting_parse_reverse); + g_test_add_func("/ibis/formatting/parse/strikethrough", + test_ibis_formatting_parse_strikethrough); + g_test_add_func("/ibis/formatting/parse/underline", + test_ibis_formatting_parse_underline); + + g_test_add_func("/ibis/formatting/parse/spec-example1", + test_ibis_formatting_parse_spec_example1); + g_test_add_func("/ibis/formatting/parse/spec-example2", + test_ibis_formatting_parse_spec_example2); + g_test_add_func("/ibis/formatting/parse/spec-example3", + test_ibis_formatting_parse_spec_example3); + g_test_add_func("/ibis/formatting/parse/spec-example4", + test_ibis_formatting_parse_spec_example4); + return g_test_run(); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ibis-0.12.0/meson.build new/ibis-0.13.0/meson.build --- old/ibis-0.12.0/meson.build 2025-03-14 07:02:09.000000000 +0100 +++ new/ibis-0.13.0/meson.build 2025-03-30 21:42:39.000000000 +0200 @@ -2,7 +2,7 @@ default_options : ['c_std=c17', 'warning_level=2'], license : 'LGPL-2.1-or-later', meson_version : '>=1.0.0', - version : '0.12.0') + version : '0.13.0') toplevel_inc = include_directories('.') @@ -53,16 +53,18 @@ # Dependencies ############################################################################### glib_dep = dependency('glib-2.0', version : '>=2.76.0') -gio_dep = dependency('gio-2.0') -gobject_dep = dependency('gobject-2.0') -birb_dep = dependency('birb', version: '>=0.3.1') -hasl_dep = dependency('hasl', version : '>=0.4.0') - add_project_arguments( '-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_76', '-DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_76', language : 'c') +gio_dep = dependency('gio-2.0') +gobject_dep = dependency('gobject-2.0') + +birb_dep = dependency('birb', version: '>=0.3.1') +hasl_dep = dependency('hasl', version : '>=0.4.0') +pango_dep = dependency('pango', version : '>=1.54.0') + ############################################################################### # Internationalization ############################################################################### ++++++ ibis.keyring ++++++ --- /var/tmp/diff_new_pack.IC7LdW/_old 2025-03-31 11:45:10.117110085 +0200 +++ /var/tmp/diff_new_pack.IC7LdW/_new 2025-03-31 11:45:10.153111579 +0200 @@ -1,6 +1,6 @@ -----BEGIN PGP PUBLIC KEY BLOCK----- -Comment: Hostname: Version: Hockeypuck 2.2 +Comment: Hostname: xsFNBF05DzkBEADFEFM1ZALjngGoeIalaW9aXCA5Gr505LDK8WIVVeQD/Izggx9z Y0wi2UJR97eIXllL8FPZIe8DywJqXKhuafL+E/TI9UqRH/WtmNxZTFW6ZAvYlaHu