diff options
author | Simon Ser <contact@emersion.fr> | 2023-02-28 16:00:28 +0100 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2023-04-14 18:34:54 +0200 |
commit | aab4c9da5fb4138ca5f07df8bd8b698d02242a62 (patch) | |
tree | 4f26a160ebce948ca29855da4f05fa42e3c5e815 /include/stringop.h | |
parent | Use output_match_name_or_id() in workspace functions (diff) | |
download | sway-aab4c9da5fb4138ca5f07df8bd8b698d02242a62.tar.gz sway-aab4c9da5fb4138ca5f07df8bd8b698d02242a62.tar.zst sway-aab4c9da5fb4138ca5f07df8bd8b698d02242a62.zip |
Add format_str() and vformat_str()
Simple helpers to allocate and format a string.
Diffstat (limited to 'include/stringop.h')
-rw-r--r-- | include/stringop.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/include/stringop.h b/include/stringop.h index b29f59b2..19a50f23 100644 --- a/include/stringop.h +++ b/include/stringop.h | |||
@@ -5,6 +5,12 @@ | |||
5 | #include <stddef.h> | 5 | #include <stddef.h> |
6 | #include "list.h" | 6 | #include "list.h" |
7 | 7 | ||
8 | #ifdef __GNUC__ | ||
9 | #define _SWAY_ATTRIB_PRINTF(start, end) __attribute__((format(printf, start, end))) | ||
10 | #else | ||
11 | #define _SWAY_ATTRIB_PRINTF(start, end) | ||
12 | #endif | ||
13 | |||
8 | void strip_whitespace(char *str); | 14 | void strip_whitespace(char *str); |
9 | void strip_quotes(char *str); | 15 | void strip_quotes(char *str); |
10 | 16 | ||
@@ -31,4 +37,7 @@ char *argsep(char **stringp, const char *delim, char *matched_delim); | |||
31 | // Expand a path using shell replacements such as $HOME and ~ | 37 | // Expand a path using shell replacements such as $HOME and ~ |
32 | bool expand_path(char **path); | 38 | bool expand_path(char **path); |
33 | 39 | ||
40 | char *vformat_str(const char *fmt, va_list args) _SWAY_ATTRIB_PRINTF(1, 0); | ||
41 | char *format_str(const char *fmt, ...) _SWAY_ATTRIB_PRINTF(1, 2); | ||
42 | |||
34 | #endif | 43 | #endif |