1
0
mirror of https://github.com/Tha14/toxic.git synced 2025-07-04 20:06:45 +02:00

Compare commits

..

3 Commits

Author SHA1 Message Date
310cf464d0 Fix bug causing messages containing newline byte to disappear
The wcswidth() function was silently failing when trying to convert
messages containing a newline to a widechar buffer which resulted
in the message showing up as an empty line. we now fall back
to using strlen to get the width of the string, which might still
cause minor display bugs when the message contains unicode, but is
still better than losing messages entirely.
2022-03-02 15:58:21 -05:00
0c11b3121a Update static musl build script
Bump toxcore to v0.2.16 and add new msgpack dependency
2022-02-20 13:12:23 -05:00
1bdf0041bc Bump toxic and curl versions in static build script 2022-02-12 21:17:19 -05:00
4 changed files with 18 additions and 14 deletions

View File

@ -18,6 +18,7 @@ jobs:
libalut-dev libalut-dev
libconfig-dev libconfig-dev
libcurl4-gnutls-dev libcurl4-gnutls-dev
libmsgpack-dev
libnotify-dev libnotify-dev
libopenal-dev libopenal-dev
libopus-dev libopus-dev
@ -72,6 +73,7 @@ jobs:
libalut-dev libalut-dev
libconfig-dev libconfig-dev
libcurl4-gnutls-dev libcurl4-gnutls-dev
libmsgpack-dev
libncurses-dev libncurses-dev
libnotify-dev libnotify-dev
libopenal-dev libopenal-dev
@ -103,6 +105,7 @@ jobs:
libnotify libnotify
libpng libpng
libqrencode libqrencode
msgpack
ncurses ncurses
openal openal
python3 python3

View File

@ -64,7 +64,6 @@ set -eu
ARTIFACT_DIR="/artifact" ARTIFACT_DIR="/artifact"
TOXIC_SRC_DIR="/toxic" TOXIC_SRC_DIR="/toxic"
if [ ! -f /etc/os-release ] || ! grep -qi 'Alpine Linux' /etc/os-release if [ ! -f /etc/os-release ] || ! grep -qi 'Alpine Linux' /etc/os-release
then then
echo "Error: This script expects to be run on Alpine Linux." echo "Error: This script expects to be run on Alpine Linux."
@ -115,6 +114,7 @@ apk add \
libsodium-dev \ libsodium-dev \
libsodium-static \ libsodium-static \
linux-headers \ linux-headers \
msgpack-c-dev \
ncurses-dev \ ncurses-dev \
ncurses-static \ ncurses-static \
ncurses-terminfo \ ncurses-terminfo \
@ -137,10 +137,10 @@ mkdir -p "$BUILD_DIR"
cd "$BUILD_DIR" cd "$BUILD_DIR"
# The git hash of the c-toxcore version we're using # The git hash of the c-toxcore version we're using
TOXCORE_VERSION="v0.2.13" TOXCORE_VERSION="v0.2.16"
# The sha256sum of the c-toxcore tarball for TOXCORE_VERSION # The sha256sum of the c-toxcore tarball for TOXCORE_VERSION
TOXCORE_HASH="67114fa57504c58b695f5dce8ef85124d555f2c3c353d0d2615e6d4845114ab8" TOXCORE_HASH="653aa42654b607f0940cecfac873e9ce55605119a90d1dc454d1090ff6ca29c0"
TOXCORE_FILENAME="c-toxcore-$TOXCORE_VERSION.tar.gz" TOXCORE_FILENAME="c-toxcore-$TOXCORE_VERSION.tar.gz"
@ -169,8 +169,8 @@ cmake --build _build --target install
# location with SSL_CERT_FILE env variable. # location with SSL_CERT_FILE env variable.
cd "$BUILD_DIR" cd "$BUILD_DIR"
CURL_VERSION="7.80.0" CURL_VERSION="7.81.0"
CURL_HASH="dab997c9b08cb4a636a03f2f7f985eaba33279c1c52692430018fae4a4878dc7" CURL_HASH="ac8e1087711084548d788ef18b9b732c8de887457b81f616fc681d1044b32f98"
CURL_FILENAME="curl-$CURL_VERSION.tar.gz" CURL_FILENAME="curl-$CURL_VERSION.tar.gz"
wget --timeout=10 -O "$CURL_FILENAME" "https://curl.haxx.se/download/$CURL_FILENAME" wget --timeout=10 -O "$CURL_FILENAME" "https://curl.haxx.se/download/$CURL_FILENAME"
@ -307,4 +307,3 @@ mv "$PREPARE_ARTIFACT_DIR" "$PREPARE_ARTIFACT_DIR/../$ARTIFACT_NAME"
tar -cJf "$ARTIFACT_NAME.tar.xz" "$ARTIFACT_NAME" tar -cJf "$ARTIFACT_NAME.tar.xz" "$ARTIFACT_NAME"
mv "$ARTIFACT_NAME.tar.xz" "$ARTIFACT_DIR" mv "$ARTIFACT_NAME.tar.xz" "$ARTIFACT_DIR"
chmod 777 -R "$ARTIFACT_DIR" chmod 777 -R "$ARTIFACT_DIR"

View File

@ -345,22 +345,25 @@ static uint16_t line_info_add_msg(wchar_t *buf, size_t buf_size, const char *msg
return 0; return 0;
} }
uint16_t width = 0;
const wint_t wc_msg_len = mbs_to_wcs_buf(buf, msg, buf_size); const wint_t wc_msg_len = mbs_to_wcs_buf(buf, msg, buf_size);
if (wc_msg_len > 0 && wc_msg_len < buf_size) { if (wc_msg_len > 0 && wc_msg_len < buf_size) {
buf[wc_msg_len] = L'\0'; buf[wc_msg_len] = L'\0';
width = (uint16_t) wcswidth(buf, wc_msg_len); int width = wcswidth(buf, wc_msg_len);
if (width == -1) { // the best we can do on failure is to fall back to strlen
width = strlen(msg);
}
return (uint16_t)width;
} else { } else {
fprintf(stderr, "Failed to convert string '%s' to widechar\n", msg); fprintf(stderr, "Failed to convert string '%s' to widechar\n", msg);
const wchar_t *err = L"Failed to parse message"; const wchar_t *err = L"Failed to parse message";
width = wcslen(err); uint16_t width = (uint16_t)wcslen(err);
wmemcpy(buf, err, width); wmemcpy(buf, err, width);
buf[width] = L'\0'; buf[width] = L'\0';
return width;
} }
return width;
} }
static void line_info_init_line(ToxWindow *self, struct line_info *line) static void line_info_init_line(ToxWindow *self, struct line_info *line)

View File

@ -477,10 +477,9 @@ on_error:
returns length of msg, which will be no larger than size-1 */ returns length of msg, which will be no larger than size-1 */
size_t copy_tox_str(char *msg, size_t size, const char *data, size_t length) size_t copy_tox_str(char *msg, size_t size, const char *data, size_t length)
{ {
size_t i;
size_t j = 0; size_t j = 0;
for (i = 0; (i < length) && (j < size - 1); ++i) { for (size_t i = 0; (i < length) && (j < size - 1); ++i) {
if (data[i] != '\r') { if (data[i] != '\r') {
msg[j++] = data[i]; msg[j++] = data[i];
} }