aboutsummaryrefslogtreecommitdiffstats
path: root/src/misc.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/misc.h')
-rw-r--r--src/misc.h25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/misc.h b/src/misc.h
index 07c0472..9d4eede 100644
--- a/src/misc.h
+++ b/src/misc.h
@@ -35,6 +35,8 @@ int count_substrs(const char *s, const char *sub);
an end character is reached. */
char *strdup_until(const char *s, const char *endchars);
+char *strdup_or_die(const char *s);
+
/* Like sprintf but writes to an automatically malloc'ed buffer. */
char *sprintf_new(const char *format, ...);
@@ -57,16 +59,19 @@ const char *my_dirname(char *path);
Assumes 'strlen(prefix) == prefix_len'. */
bool path_starts_with(const char *path, const char* prefix, size_t prefix_len);
-/* Filters arguments in comma-separated lists prefixed by '-o'.
- * Allocates 'new_argv' and its strings, as well as some temporary data, into 'arena'. */
-void filter_o_opts(
- bool (*keep)(const char* opt),
- int argc,
- const char * const *argv,
- int *new_argc,
- char ***new_argv,
- struct arena *arena
-);
+char *strtok_escape_r(char *str, const char *delim, char escape, char **saveptr);
+char *strtok_escape(char *str, const char *delim, char escape);
+
+/* NEW: like above, but preserves the backslash in the token ("\," stays two chars) */
+char *strtok_escape_preserve_r(char *str, const char *delim, char escape, char **saveptr);
+char *strtok_escape_preserve(char *str, const char *delim, char escape);
+
+void filter_o_opts(bool (*keep_option)(const char *opt),
+ int argc_in,
+ const char * const *argv_in,
+ int *argc_out,
+ char ***argv_out,
+ struct arena *arena);
/* Reallocs `*array` (may be NULL) to be at least one larger
than `*capacity` (may be 0) and stores the new capacity