perl 5.0 alpha 3
[perl.git] / do / chop
1 void
2 do_chop(astr,TARG)
3 register STR *astr;
4 register STR *TARG;
5 {
6     register char *tmps;
7     register int i;
8     ARRAY *ary;
9     HASH *hash;
10     HENT *entry;
11
12     if (!TARG)
13         return;
14     if (TARG->str_state == SS_ARY) {
15         ary = stab_array(TARG->str_u.str_stab);
16         for (i = 0; i <= ary->ary_fill; i++)
17             do_chop(astr,ary->ary_array[i]);
18         return;
19     }
20     if (TARG->str_state == SS_HASH) {
21         hash = stab_hash(TARG->str_u.str_stab);
22         (void)hiterinit(hash);
23         /*SUPPRESS 560*/
24         while (entry = hiternext(hash))
25             do_chop(astr,hiterval(hash,entry));
26         return;
27     }
28     tmps = str_get(TARG);
29     if (tmps && TARG->str_cur) {
30         tmps += TARG->str_cur - 1;
31         str_nset(astr,tmps,1);  /* remember last char */
32         *tmps = '\0';                           /* wipe it out */
33         TARG->str_cur = tmps - TARG->str_ptr;
34         TARG->str_nok = 0;
35         STABSET(TARG);
36     }
37     else
38         str_nset(astr,"",0);
39 }
40