summaryrefslogtreecommitdiff
path: root/do/chop
blob: 377d694bef6cfeda2a87c0de548b08ef61f09b51 (plain)
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
void
do_chop(astr,TARG)
register STR *astr;
register STR *TARG;
{
    register char *tmps;
    register int i;
    ARRAY *ary;
    HASH *hash;
    HENT *entry;

    if (!TARG)
	return;
    if (TARG->str_state == SS_ARY) {
	ary = stab_array(TARG->str_u.str_stab);
	for (i = 0; i <= ary->ary_fill; i++)
	    do_chop(astr,ary->ary_array[i]);
	return;
    }
    if (TARG->str_state == SS_HASH) {
	hash = stab_hash(TARG->str_u.str_stab);
	(void)hiterinit(hash);
	/*SUPPRESS 560*/
	while (entry = hiternext(hash))
	    do_chop(astr,hiterval(hash,entry));
	return;
    }
    tmps = str_get(TARG);
    if (tmps && TARG->str_cur) {
	tmps += TARG->str_cur - 1;
	str_nset(astr,tmps,1);	/* remember last char */
	*tmps = '\0';				/* wipe it out */
	TARG->str_cur = tmps - TARG->str_ptr;
	TARG->str_nok = 0;
	STABSET(TARG);
    }
    else
	str_nset(astr,"",0);
}