replace sasprintf with g_* equivalent
This commit is contained in:
parent
78ed4d77c5
commit
e2dc1872a7
15
dunst.c
15
dunst.c
@ -567,7 +567,7 @@ void add_notification_to_line_cache(notification *n, int max_width)
|
|||||||
|
|
||||||
/* print dup_count and msg*/
|
/* print dup_count and msg*/
|
||||||
if (n->dup_count > 0) {
|
if (n->dup_count > 0) {
|
||||||
sasprintf(&buf, "(%d) %s", n->dup_count, msg);
|
buf = g_strdup_printf("(%d) %s", n->dup_count, msg);
|
||||||
} else {
|
} else {
|
||||||
buf = strdup(msg);
|
buf = strdup(msg);
|
||||||
}
|
}
|
||||||
@ -583,13 +583,13 @@ void add_notification_to_line_cache(notification *n, int max_width)
|
|||||||
|
|
||||||
char *new_buf;
|
char *new_buf;
|
||||||
if (hours > 0) {
|
if (hours > 0) {
|
||||||
sasprintf(&new_buf, "%s (%dh %dm %ds old)", buf, hours,
|
new_buf = g_strdup_printf("%s (%dh %dm %ds old)", buf, hours,
|
||||||
minutes, seconds);
|
minutes, seconds);
|
||||||
} else if (minutes > 0) {
|
} else if (minutes > 0) {
|
||||||
sasprintf(&new_buf, "%s (%dm %ds old)", buf, minutes,
|
new_buf = g_strdup_printf("%s (%dm %ds old)", buf, minutes,
|
||||||
seconds);
|
seconds);
|
||||||
} else {
|
} else {
|
||||||
sasprintf(&new_buf, "%s (%ds old)", buf, seconds);
|
new_buf = g_strdup_printf("%s (%ds old)", buf, seconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(buf);
|
free(buf);
|
||||||
@ -747,7 +747,7 @@ void fill_line_cache(int width)
|
|||||||
if (indicate_hidden && queue_cnt > 0) {
|
if (indicate_hidden && queue_cnt > 0) {
|
||||||
if (geometry.h != 1) {
|
if (geometry.h != 1) {
|
||||||
char *tmp;
|
char *tmp;
|
||||||
sasprintf(&tmp, "(%d more)", queue_cnt);
|
tmp = g_strdup_printf("(%d more)", queue_cnt);
|
||||||
ColorSet *last_colors =
|
ColorSet *last_colors =
|
||||||
line_cache.lines[line_cache.count-1].colors;
|
line_cache.lines[line_cache.count-1].colors;
|
||||||
r_line_cache_append(&line_cache, tmp, last_colors, true, true);
|
r_line_cache_append(&line_cache, tmp, last_colors, true, true);
|
||||||
@ -755,7 +755,7 @@ void fill_line_cache(int width)
|
|||||||
} else {
|
} else {
|
||||||
char *old = line_cache.lines[0].str;
|
char *old = line_cache.lines[0].str;
|
||||||
char *new;
|
char *new;
|
||||||
sasprintf(&new, "%s (%d more)", old, queue_cnt);
|
new = g_strdup_printf("%s (%d more)", old, queue_cnt);
|
||||||
free(old);
|
free(old);
|
||||||
line_cache.lines[0].str = new;
|
line_cache.lines[0].str = new;
|
||||||
}
|
}
|
||||||
@ -1147,8 +1147,7 @@ int init_notification(notification * n, int id)
|
|||||||
n_queue_enqueue(&queue, n);
|
n_queue_enqueue(&queue, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *tmp;
|
char *tmp = g_strconcat(n->summary, " ", n->body, NULL);
|
||||||
sasprintf(&tmp, "%s %s", n->summary, n->body);
|
|
||||||
|
|
||||||
n->urls = extract_urls(tmp);
|
n->urls = extract_urls(tmp);
|
||||||
|
|
||||||
|
@ -439,18 +439,18 @@ void cmdline_usage_append(char *key, char *type, char *description)
|
|||||||
{
|
{
|
||||||
char *key_type;
|
char *key_type;
|
||||||
if (type && strlen(type) > 0)
|
if (type && strlen(type) > 0)
|
||||||
sasprintf(&key_type, "%s (%s)", key, type);
|
key_type = g_strdup_printf("%s (%s)", key, type);
|
||||||
else
|
else
|
||||||
sasprintf(&key_type, "%s", key);
|
key_type = g_strdup(key);
|
||||||
|
|
||||||
if (!usage_str) {
|
if (!usage_str) {
|
||||||
sasprintf(&usage_str, "%-40s - %s\n", key_type, description);
|
usage_str = g_strdup_printf("%-40s - %s\n", key_type, description);
|
||||||
free(key_type);
|
free(key_type);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *tmp;
|
char *tmp;
|
||||||
sasprintf(&tmp, "%s%-40s - %s\n", usage_str, key_type, description);
|
tmp = g_strdup_printf("%s%-40s - %s\n", usage_str, key_type, description);
|
||||||
free(key_type);
|
free(key_type);
|
||||||
|
|
||||||
free(usage_str);
|
free(usage_str);
|
||||||
|
17
utils.c
17
utils.c
@ -4,6 +4,7 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "dunst.h"
|
#include "dunst.h"
|
||||||
@ -50,9 +51,9 @@ char *string_append(char *a, const char *b, const char *sep)
|
|||||||
|
|
||||||
char *new;
|
char *new;
|
||||||
if (!sep)
|
if (!sep)
|
||||||
sasprintf(&new, "%s%s", a, b);
|
new = g_strconcat(a,b, NULL);
|
||||||
else
|
else
|
||||||
sasprintf(&new, "%s%s%s", a, sep, b);
|
new = g_strconcat(a, sep, b, NULL);
|
||||||
free(a);
|
free(a);
|
||||||
|
|
||||||
return new;
|
return new;
|
||||||
@ -103,16 +104,4 @@ void die(char *text, int exit_value)
|
|||||||
exit(exit_value);
|
exit(exit_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
int sasprintf(char **strp, const char *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list args;
|
|
||||||
int result;
|
|
||||||
|
|
||||||
va_start(args, fmt);
|
|
||||||
if ((result = vasprintf(strp, fmt, args)) == -1)
|
|
||||||
die("asprintf failed", EXIT_FAILURE);
|
|
||||||
va_end(args);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* vim: set ts=8 sw=8 tw=0: */
|
/* vim: set ts=8 sw=8 tw=0: */
|
||||||
|
2
utils.h
2
utils.h
@ -16,8 +16,6 @@ char **string_to_argv(const char *s);
|
|||||||
void die(char *msg, int exit_value);
|
void die(char *msg, int exit_value);
|
||||||
|
|
||||||
int digit_count(int i);
|
int digit_count(int i);
|
||||||
|
|
||||||
int sasprintf(char **strp, const char *fmt, ...);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* vim: set ts=8 sw=8 tw=0: */
|
/* vim: set ts=8 sw=8 tw=0: */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user