1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
/*
\funcref{delfromlist}{VAR\_ delfromlist (\params)}
{
{VAR\_} {v} {variable holding list to scratch from}
{char} {*s} {string to scratch from list}
}
{variable holding shrinked list}
{initvar(), xrealloc(), xstrdup()}
{inlist(), copylist()}
{delfroml.c}
{
This function deletes string {\em s} to the list of variable {\em v}.
The same variable is returned.
Variable {\em v} is initialized (if necessary) to accomodate an
intermediate memory allocation struct and the new element.
}
*/
#include "icm-exec.h"
VAR_ delfromlist (v, s)
VAR_ v;
char *s;
{
register unsigned
i,
j;
register char
*elem;
register LIST_
*list;
if (! v.vu.i || ! (list = &(v.vu.i->ls.list)) )
return (v);
for (i = 0; i < list->size; i++)
{
elem = list->element [i];
if (! strcmp (s, elem))
{
for (j = i + 1; j < list->size; j++)
list->element [j - 1] = list->element [j];
list->size--;
xrealloc (elem, 0);
i--;
}
}
return (v);
}
|