wlist #3/3, whitespace
This commit is contained in:
parent
fe5ac28b92
commit
713091ea22
|
|
@ -19,6 +19,7 @@ wl_length(const wordlist *wl)
|
||||||
|
|
||||||
for (; wl; wl = wl->wl_next)
|
for (; wl; wl = wl->wl_next)
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
return (i);
|
return (i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -44,6 +45,7 @@ wl_copy(wordlist *wl)
|
||||||
|
|
||||||
for (; wl; wl = wl->wl_next)
|
for (; wl; wl = wl->wl_next)
|
||||||
wl_append_word(&first, &last, copy(wl->wl_word));
|
wl_append_word(&first, &last, copy(wl->wl_word));
|
||||||
|
|
||||||
return (first);
|
return (first);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -102,9 +104,11 @@ wl_build(char **v)
|
||||||
|
|
||||||
while (*v)
|
while (*v)
|
||||||
wl_append_word(&first, &last, copy(*v++));
|
wl_append_word(&first, &last, copy(*v++));
|
||||||
|
|
||||||
return (first);
|
return (first);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char **
|
char **
|
||||||
wl_mkvec(wordlist *wl)
|
wl_mkvec(wordlist *wl)
|
||||||
{
|
{
|
||||||
|
|
@ -118,6 +122,7 @@ wl_mkvec(wordlist *wl)
|
||||||
wl = wl->wl_next;
|
wl = wl->wl_next;
|
||||||
}
|
}
|
||||||
vec[i] = NULL;
|
vec[i] = NULL;
|
||||||
|
|
||||||
return (vec);
|
return (vec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -147,12 +152,12 @@ wl_reverse(wordlist *wl)
|
||||||
return (wl);
|
return (wl);
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
wordlist *t = wl->wl_next;
|
wordlist *t = wl->wl_next;
|
||||||
wl->wl_next = wl->wl_prev;
|
wl->wl_next = wl->wl_prev;
|
||||||
wl->wl_prev = t;
|
wl->wl_prev = t;
|
||||||
if (!t)
|
if (!t)
|
||||||
return (wl);
|
return (wl);
|
||||||
wl = t;
|
wl = t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -167,6 +172,7 @@ wl_flatten(wordlist *wlist)
|
||||||
|
|
||||||
for (wl = wlist; wl; wl = wl->wl_next)
|
for (wl = wlist; wl; wl = wl->wl_next)
|
||||||
len += strlen(wl->wl_word) + 1;
|
len += strlen(wl->wl_word) + 1;
|
||||||
|
|
||||||
buf = TMALLOC(char, len + 1);
|
buf = TMALLOC(char, len + 1);
|
||||||
*buf = '\0';
|
*buf = '\0';
|
||||||
|
|
||||||
|
|
@ -176,6 +182,7 @@ wl_flatten(wordlist *wlist)
|
||||||
(void) strcat(buf, " ");
|
(void) strcat(buf, " ");
|
||||||
}
|
}
|
||||||
return (buf);
|
return (buf);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -186,11 +193,11 @@ wl_nthelem(int i, wordlist *wl)
|
||||||
{
|
{
|
||||||
while ((i-- > 0) && wl->wl_next)
|
while ((i-- > 0) && wl->wl_next)
|
||||||
wl = wl->wl_next;
|
wl = wl->wl_next;
|
||||||
|
|
||||||
return (wl);
|
return (wl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
wlcomp(const void *a, const void *b)
|
wlcomp(const void *a, const void *b)
|
||||||
{
|
{
|
||||||
|
|
@ -245,11 +252,11 @@ wl_range(wordlist *wl, int low, int up)
|
||||||
wl->wl_prev = NULL;
|
wl->wl_prev = NULL;
|
||||||
low--;
|
low--;
|
||||||
}
|
}
|
||||||
tt = wl;
|
tt = wl;
|
||||||
while (tt && (up > 0)) {
|
while (tt && (up > 0)) {
|
||||||
tt = tt->wl_next;
|
tt = tt->wl_next;
|
||||||
up--;
|
up--;
|
||||||
}
|
}
|
||||||
if (tt && tt->wl_next) {
|
if (tt && tt->wl_next) {
|
||||||
wl_free(tt->wl_next);
|
wl_free(tt->wl_next);
|
||||||
tt->wl_next = NULL;
|
tt->wl_next = NULL;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue