Whitespace cleanup

This commit is contained in:
Sergey Poznyakoff 2019-05-14 19:59:07 +03:00
parent a2c81cc5fa
commit a19f8397ed
2 changed files with 92 additions and 93 deletions

View file

@ -53,15 +53,15 @@ struct wordsplit
const char *ws_escape[2]; /* [Input] (WRDSF_ESCAPE) Characters to be escaped
with backslash. */
void (*ws_alloc_die) (wordsplit_t *wsp);
/* [Input] (WRDSF_ALLOC_DIE) Function called when
/* [Input] (WRDSF_ALLOC_DIE) Function called when
out of memory. Must not return. */
void (*ws_error) (const char *, ...)
__attribute__ ((__format__ (__printf__, 1, 2)));
/* [Input] (WRDSF_ERROR) Function used for error
__attribute__ ((__format__ (__printf__, 1, 2)));
/* [Input] (WRDSF_ERROR) Function used for error
reporting */
void (*ws_debug) (const char *, ...)
__attribute__ ((__format__ (__printf__, 1, 2)));
/* [Input] (WRDSF_DEBUG) Function used for debug
__attribute__ ((__format__ (__printf__, 1, 2)));
/* [Input] (WRDSF_DEBUG) Function used for debug
output. */
const char **ws_env; /* [Input] (WRDSF_ENV, !WRDSF_NOVAR) Array of
environment variables. */
@ -80,14 +80,14 @@ struct wordsplit
parameters */
size_t ws_paramc; /* Number of positional parameters */
/* Temporary storage for parameters. Works similarly to ws_enbuf.
/* Temporary storage for parameters. Works similarly to ws_enbuf.
*/
char **ws_parambuf;
size_t ws_paramidx;
size_t ws_paramsiz;
int (*ws_getvar) (char **ret, const char *var, size_t len, void *clos);
/* [Input] (WRDSF_GETVAR, !WRDSF_NOVAR) Looks up
/* [Input] (WRDSF_GETVAR, !WRDSF_NOVAR) Looks up
the name VAR (LEN bytes long) in the table of
variables and if found returns in memory
location pointed to by RET the value of that
@ -96,13 +96,13 @@ struct wordsplit
on error. User-specific errors can be returned
by storing the error diagnostic string in RET
and returning WRDSE_USERERR.
Whatever is stored in RET, it must be allocated
Whatever is stored in RET, it must be allocated
using malloc(3). */
void *ws_closure; /* [Input] (WRDSF_CLOSURE) Passed as the CLOS
argument to ws_getvar and ws_command. */
int (*ws_command) (char **ret, const char *cmd, size_t len, char **argv,
void *clos);
/* [Input] (!WRDSF_NOCMD) Returns in the memory
void *clos);
/* [Input] (!WRDSF_NOCMD) Returns in the memory
location pointed to by RET the expansion of
the command CMD (LEN bytes long). On input,
ARGV contains CMD split out to words.
@ -119,7 +119,7 @@ struct wordsplit
the error, if ws_errno is WRDSE_USERERR. Must
be allocated with malloc(3). */
struct wordsplit_node *ws_head, *ws_tail;
/* Doubly-linked list of parsed out nodes. */
/* Doubly-linked list of parsed out nodes. */
int ws_lvl; /* Invocation nesting level. */
};

View file

@ -148,10 +148,10 @@ _wsplt_subsplit (struct wordsplit *wsp, struct wordsplit *wss,
wss->ws_options = wsp->ws_options;
flags |= WRDSF_DELIM
| WRDSF_ALLOC_DIE
| WRDSF_ERROR
| WRDSF_DEBUG
| (wsp->ws_flags & (WRDSF_SHOWDBG | WRDSF_SHOWERR | WRDSF_OPTIONS));
| WRDSF_ALLOC_DIE
| WRDSF_ERROR
| WRDSF_DEBUG
| (wsp->ws_flags & (WRDSF_SHOWDBG | WRDSF_SHOWERR | WRDSF_OPTIONS));
rc = wordsplit_init (wss, str, len, flags);
if (rc)
@ -279,7 +279,7 @@ wordsplit_init (struct wordsplit *wsp, const char *input, size_t len,
wsp->ws_escape[WRDSX_WORD] = wordsplit_c_escape_tab;
wsp->ws_escape[WRDSX_QUOTE] = wordsplit_c_escape_tab;
wsp->ws_options |= WRDSO_OESC_QUOTE | WRDSO_OESC_WORD
| WRDSO_XESC_QUOTE | WRDSO_XESC_WORD;
| WRDSO_XESC_QUOTE | WRDSO_XESC_WORD;
}
else
{
@ -725,7 +725,7 @@ wordsplit_finish (struct wordsplit *wsp)
The following cases should be distinguished:
1. If both WRDSF_SQUEEZE_DELIMS and WRDSF_RETURN_DELIMS are set, compress
any runs of similar delimiter nodes to a single node. The nodes are
any runs of similar delimiter nodes to a single node. The nodes are
'similar' if they point to the same delimiter character.
If WRDSO_MAXWORDS option is set, stop compressing when
@ -733,12 +733,12 @@ wordsplit_finish (struct wordsplit *wsp)
a single last node.
2. If WRDSO_MAXWORDS option is set, but WRDSF_RETURN_DELIMS is not,
remove any delimiter nodes. Stop operation when
remove any delimiter nodes. Stop operation when
ws_wordi + 1 == ws_maxwords, and coalesce the rest of nodes into
a single last node.
3. If incremental operation is in progress, restart the loop any time
a delimiter node is about to be returned, unless WRDSF_RETURN_DELIMS
a delimiter node is about to be returned, unless WRDSF_RETURN_DELIMS
is set.
*/
again:
@ -858,8 +858,8 @@ wordsplit_finish (struct wordsplit *wsp)
char *newstr = malloc (slen + 1);
/* Assign newstr first, even if it is NULL. This way
wordsplit_free will work even if we return
nomem later. */
wordsplit_free will work even if we return
nomem later. */
wsp->ws_wordv[wsp->ws_offs + wsp->ws_wordc] = newstr;
if (!newstr)
return _wsplt_nomem (wsp);
@ -1247,8 +1247,8 @@ expand_paramv (struct wordsplit *wsp, struct wordsplit_node **ptail, int flg,
{
struct wordsplit ws;
int wsflags = WRDSF_NOVAR | WRDSF_NOCMD | WRDSF_QUOTE
| (WSP_RETURN_DELIMS (wsp) ? WRDSF_RETURN_DELIMS : 0)
| (q ? WRDSF_NOSPLIT : 0);
| (WSP_RETURN_DELIMS (wsp) ? WRDSF_RETURN_DELIMS : 0)
| (q ? WRDSF_NOSPLIT : 0);
size_t i;
for (i = 0; i < wsp->ws_paramc; i++)
@ -2623,7 +2623,7 @@ wordsplit_process_list (struct wordsplit *wsp, size_t start)
static int
wordsplit_run (const char *command, size_t length, struct wordsplit *wsp,
int flags, int lvl)
int flags, int lvl)
{
int rc;
size_t start;
@ -2660,7 +2660,7 @@ wordsplit_run (const char *command, size_t length, struct wordsplit *wsp,
int
wordsplit_len (const char *command, size_t length, struct wordsplit *wsp,
int flags)
int flags)
{
return wordsplit_run (command, length, wsp, flags, 0);
}
@ -2800,4 +2800,3 @@ wordsplit_perror (struct wordsplit *wsp)
wsp->ws_error ("%s", wordsplit_strerror (wsp));
}
}