* src/system.h (getenv_quoting_style): Move here from ls.c and stat.c.
* src/ls.c (getenv_quoting_style): Remove.
* src/stat.c (getenv_quoting_style): Remove. Ensure ARGMATCH is
defined for system.h.
static void sort_files (void);
static void parse_ls_color (void);
-static int getenv_quoting_style (void);
-
static size_t quote_name_width (char const *name,
struct quoting_options const *options,
int needs_general_quoting);
color_symlink_as_referent = true;
}
-/* Return the quoting style specified by the environment variable
- QUOTING_STYLE if set and valid, -1 otherwise. */
-
-static int
-getenv_quoting_style (void)
-{
- char const *q_style = getenv ("QUOTING_STYLE");
- if (!q_style)
- return -1;
- int i = ARGMATCH (q_style, quoting_style_args, quoting_style_vals);
- if (i < 0)
- {
- error (0, 0,
- _("ignoring invalid value"
- " of environment variable QUOTING_STYLE: %s"),
- quote (q_style));
- return -1;
- }
- return quoting_style_vals[i];
-}
-
/* Set the exit status to report a failure. If SERIOUS, it is a
serious failure; otherwise, it is merely a minor problem. */
#include <selinux/selinux.h>
#include <getopt.h>
+#include "argmatch.h" /* argmatch($QUOTING_STYLE). */
#include "system.h"
#include "areadlink.h"
-#include "argmatch.h"
#include "c-ctype.h"
#include "file-type.h"
#include "filemode.h"
return fail;
}
-/* Return the quoting style specified by the environment variable
- QUOTING_STYLE if set and valid, -1 otherwise. */
-
-static int
-getenv_quoting_style (void)
-{
- char const *q_style = getenv ("QUOTING_STYLE");
- if (!q_style)
- return -1;
-
- int i = ARGMATCH (q_style, quoting_style_args, quoting_style_vals);
- if (i < 0)
- {
- error (0, 0, _("ignoring invalid value of environment "
- "variable QUOTING_STYLE: %s"), quote (q_style));
- return -1;
- }
- return quoting_style_vals[i];
-}
-
/* Set the quoting style once it is needed. */
static void
initialize_quoting_style (void)
}
}
-/* Equivalent to quotearg(), but explicit to avoid syntax checks. */
-#define quoteN(x) quotearg_style (get_quoting_style (NULL), x)
-
/* Print statfs info. Return zero upon success, nonzero upon failure. */
NODISCARD
static bool
#define quoteaf_n(n, arg) \
quotearg_n_style (n, shell_escape_always_quoting_style, arg)
+/* Equivalent to quotearg(), but explicit to avoid syntax checks. */
+#define quoteN(x) quotearg_style (get_quoting_style (NULL), x)
+
+#ifdef ARGMATCH
+/* Return the quoting style specified by the environment variable
+ QUOTING_STYLE if set and valid, -1 otherwise. */
+static inline int
+getenv_quoting_style (void)
+{
+ char const *q_style = getenv ("QUOTING_STYLE");
+ if (!q_style)
+ return -1;
+
+ int i = ARGMATCH (q_style, quoting_style_args, quoting_style_vals);
+ if (i < 0)
+ {
+ error (0, 0, _("ignoring invalid value of environment "
+ "variable QUOTING_STYLE: %s"), quote (q_style));
+ return -1;
+ }
+ return quoting_style_vals[i];
+}
+
/* Used instead of XARGMATCH() to provide a custom error message. */
-#ifdef XARGMATCH
static inline ptrdiff_t
x_timestyle_match (char const * style, bool allow_posix,
char const *const * timestyle_args,