mirror of
https://github.com/ZoiteChat/zoitechat.git
synced 2026-10-17 10:37:12 +00:00
fix(xtext): move hexcolor_parse to its own file for the standalone xtext tests
master's new xtext_tests target compiles xtext.c on its own with only GTK linked, so hexcolor_parse cannot live in util.c. Keep it in a dependency-free hexcolor.c that both test targets compile, and register it in the Visual Studio project for the Windows build. Claude-Session: https://claude.ai/code/session_01Jxd4AknGzdAENADWAGHCzx
This commit is contained in:
+1
-36
@@ -47,6 +47,7 @@
|
||||
#include "zoitechatc.h"
|
||||
#include <ctype.h>
|
||||
#include "util.h"
|
||||
#include "hexcolor.h"
|
||||
|
||||
#if defined (__FreeBSD__) || defined (__APPLE__)
|
||||
#include <sys/sysctl.h>
|
||||
@@ -301,42 +302,6 @@ strip_color (const char *text, int len, int flags)
|
||||
return new_str;
|
||||
}
|
||||
|
||||
static int
|
||||
hexcolor_component (const char *s, int avail, guint32 *rgb)
|
||||
{
|
||||
int i;
|
||||
guint32 value = 0;
|
||||
|
||||
if (avail < 6)
|
||||
return FALSE;
|
||||
for (i = 0; i < 6; i++)
|
||||
{
|
||||
if (!g_ascii_isxdigit (s[i]))
|
||||
return FALSE;
|
||||
value = (value << 4) | g_ascii_xdigit_value (s[i]);
|
||||
}
|
||||
if (rgb)
|
||||
*rgb = value;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Parses the parameters of a \004 (hex color) code: RRGGBB[,RRGGBB].
|
||||
int
|
||||
hexcolor_parse (const char *s, int avail, guint32 *fg, guint32 *bg, int *has_bg)
|
||||
{
|
||||
if (has_bg)
|
||||
*has_bg = FALSE;
|
||||
if (!hexcolor_component (s, avail, fg))
|
||||
return 0;
|
||||
if (avail >= 7 && s[6] == ',' && hexcolor_component (s + 7, avail - 7, bg))
|
||||
{
|
||||
if (has_bg)
|
||||
*has_bg = TRUE;
|
||||
return 13;
|
||||
}
|
||||
return 6;
|
||||
}
|
||||
|
||||
/* CL: strip_color2 strips src and writes the output at dst; pass the same pointer
|
||||
in both arguments to strip in place. */
|
||||
int
|
||||
|
||||
Reference in New Issue
Block a user