#define _(msgid) gettext (msgid)
#define N_(msgid) msgid
+#ifndef FALLTHROUGH
+# if __GNUC__ < 7
+# define FALLTHROUGH ((void) 0)
+# else
+# define FALLTHROUGH __attribute__ ((__fallthrough__))
+# endif
+#endif
+
#include <wordsplit.h>
#define ISWS(c) ((c)==' '||(c)=='\t'||(c)=='\n')
static int wordsplit_run (const char *command, size_t length,
struct wordsplit *wsp,
- int flags, int lvl);
+ unsigned flags, int lvl);
static int wordsplit_init (struct wordsplit *wsp, const char *input, size_t len,
- int flags);
+ unsigned flags);
static int wordsplit_process_list (struct wordsplit *wsp, size_t start);
static int wordsplit_finish (struct wordsplit *wsp);
static int
_wsplt_subsplit (struct wordsplit *wsp, struct wordsplit *wss,
char const *str, int len,
- int flags, int finalize)
+ unsigned flags, int finalize)
{
int rc;
static int
wordsplit_init (struct wordsplit *wsp, const char *input, size_t len,
- int flags)
+ unsigned flags)
{
wsp->ws_flags = flags;
{
struct wordsplit_node *prev; /* Previous element */
struct wordsplit_node *next; /* Next element */
- int flags; /* Node flags */
+ unsigned flags; /* Node flags */
union
{
struct
};
static const char *
-wsnode_flagstr (int flags)
+wsnode_flagstr (unsigned flags)
{
static char retbuf[7];
char *p = retbuf;
static int
expvar (struct wordsplit *wsp, const char *str, size_t len,
- struct wordsplit_node **ptail, const char **pend, int flg)
+ struct wordsplit_node **ptail, const char **pend, unsigned flg)
{
size_t i = 0;
const char *defstr = NULL;
if (wsp->ws_errno == WRDSE_USERERR)
free (wsp->ws_usererr);
wsp->ws_usererr = value;
- /* fall through */
+ FALLTHROUGH;
default:
_wsplt_seterr (wsp, rc);
return 1;
const char *str, size_t len,
struct wordsplit_node **ptail,
const char **pend,
- int flg))
+ unsigned flg))
{
const char *str = wsnode_ptr (wsp, node);
size_t slen = wsnode_len (node);
static int
expcmd (struct wordsplit *wsp, const char *str, size_t len,
- struct wordsplit_node **ptail, const char **pend, int flg)
+ struct wordsplit_node **ptail, const char **pend, unsigned flg)
{
int rc;
size_t j;
j++;
if (j < len && command[j] == q)
{
- int flags = _WSNF_QUOTE | _WSNF_EMPTYOK;
+ unsigned flags = _WSNF_QUOTE | _WSNF_EMPTYOK;
if (q == '\'')
flags |= _WSNF_NOEXPAND;
if (wordsplit_add_segm (wsp, start + 1, j, flags))
const char *command = wsp->ws_input;
const char *comment = wsp->ws_comment;
int join = 0;
- int flags = 0;
+ unsigned flags = 0;
struct wordsplit_node *np = wsp->ws_tail;
size_t i = start;
static int
wordsplit_run (const char *command, size_t length, struct wordsplit *wsp,
- int flags, int lvl)
+ unsigned flags, int lvl)
{
int rc;
size_t start;
int
wordsplit_len (const char *command, size_t length, struct wordsplit *wsp,
- int flags)
+ unsigned flags)
{
return wordsplit_run (command, length, wsp, flags, 0);
}
int
-wordsplit (const char *command, struct wordsplit *ws, int flags)
+wordsplit (const char *command, struct wordsplit *ws, unsigned flags)
{
return wordsplit_len (command, command ? strlen (command) : 0, ws, flags);
}
size_t ws_offs; /* [Input] (WRDSF_DOOFFS) Number of initial
elements in ws_wordv to fill with NULLs. */
size_t ws_wordn; /* Number of elements ws_wordv can accomodate. */
- int ws_flags; /* [Input] Flags passed to wordsplit. */
- int ws_options; /* [Input] (WRDSF_OPTIONS)
+ unsigned ws_flags; /* [Input] Flags passed to wordsplit. */
+ unsigned ws_options; /* [Input] (WRDSF_OPTIONS)
Additional options. */
size_t ws_maxwords; /* [Input] (WRDSO_MAXWORDS) Return at most that
many words */
#define WRDSE_GLOBERR 8
#define WRDSE_USERERR 9
-int wordsplit (const char *s, wordsplit_t *ws, int flags);
-int wordsplit_len (const char *s, size_t len, wordsplit_t *ws, int flags);
+int wordsplit (const char *s, wordsplit_t *ws, unsigned flags);
+int wordsplit_len (const char *s, size_t len, wordsplit_t *ws, unsigned flags);
void wordsplit_free (wordsplit_t *ws);
void wordsplit_free_words (wordsplit_t *ws);
void wordsplit_free_envbuf (wordsplit_t *ws);