mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-27 18:51:41 +02:00
Use the nicer stpcpy function
This commit is contained in:
7
glfw/linux_notify.c
vendored
7
glfw/linux_notify.c
vendored
@@ -5,9 +5,11 @@
|
|||||||
* Distributed under terms of the GPL3 license.
|
* Distributed under terms of the GPL3 license.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define _POSIX_C_SOURCE 200809L
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
#include "linux_notify.h"
|
#include "linux_notify.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#define NOTIFICATIONS_SERVICE "org.freedesktop.Notifications"
|
#define NOTIFICATIONS_SERVICE "org.freedesktop.Notifications"
|
||||||
#define NOTIFICATIONS_PATH "/org/freedesktop/Notifications"
|
#define NOTIFICATIONS_PATH "/org/freedesktop/Notifications"
|
||||||
@@ -106,11 +108,12 @@ got_capabilities(DBusMessage *msg, const char* err, void* data UNUSED) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dbus_message_iter_recurse(&iter, &array_iter);
|
dbus_message_iter_recurse(&iter, &array_iter);
|
||||||
char buf[2048] = {0}, *p = buf;
|
char buf[2048] = {0}, *p = buf, *end = buf + sizeof(buf);
|
||||||
while (dbus_message_iter_get_arg_type(&array_iter) == DBUS_TYPE_STRING) {
|
while (dbus_message_iter_get_arg_type(&array_iter) == DBUS_TYPE_STRING) {
|
||||||
const char *str;
|
const char *str;
|
||||||
dbus_message_iter_get_basic(&array_iter, &str);
|
dbus_message_iter_get_basic(&array_iter, &str);
|
||||||
if (sizeof(buf) > (size_t)(p-buf) + 1u) p += snprintf(p, sizeof(buf) - (p-buf) - 1, "%s\n", str);
|
size_t len = strlen(str);
|
||||||
|
if (len && p + len + 2 < end) { p = stpcpy(p, str); *(p++) = '\n'; }
|
||||||
dbus_message_iter_next(&array_iter);
|
dbus_message_iter_next(&array_iter);
|
||||||
}
|
}
|
||||||
if (activated_handler) activated_handler(0, -1, buf);
|
if (activated_handler) activated_handler(0, -1, buf);
|
||||||
|
|||||||
Reference in New Issue
Block a user