1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
3*0Sstevel@tonic-gate * Use is subject to license terms.
4*0Sstevel@tonic-gate */
5*0Sstevel@tonic-gate
6*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI"
7*0Sstevel@tonic-gate
8*0Sstevel@tonic-gate /*
9*0Sstevel@tonic-gate * This program is copyright Alec Muffett 1993. The author disclaims all
10*0Sstevel@tonic-gate * responsibility or liability with respect to it's usage or its effect
11*0Sstevel@tonic-gate * upon hardware or computer systems, and maintains copyright as set out
12*0Sstevel@tonic-gate * in the "LICENCE" document which accompanies distributions of Crack v4.0
13*0Sstevel@tonic-gate * and upwards.
14*0Sstevel@tonic-gate */
15*0Sstevel@tonic-gate
16*0Sstevel@tonic-gate #include "packer.h"
17*0Sstevel@tonic-gate
18*0Sstevel@tonic-gate
19*0Sstevel@tonic-gate char
Chop(register char * string)20*0Sstevel@tonic-gate Chop(register char *string)
21*0Sstevel@tonic-gate {
22*0Sstevel@tonic-gate register char c;
23*0Sstevel@tonic-gate register char *ptr;
24*0Sstevel@tonic-gate
25*0Sstevel@tonic-gate c = '\0';
26*0Sstevel@tonic-gate
27*0Sstevel@tonic-gate for (ptr = string; *ptr; ptr++);
28*0Sstevel@tonic-gate if (ptr != string) {
29*0Sstevel@tonic-gate c = *(--ptr);
30*0Sstevel@tonic-gate *ptr = '\0';
31*0Sstevel@tonic-gate }
32*0Sstevel@tonic-gate return (c);
33*0Sstevel@tonic-gate }
34*0Sstevel@tonic-gate
35*0Sstevel@tonic-gate char
Chomp(register char * string)36*0Sstevel@tonic-gate Chomp(register char *string)
37*0Sstevel@tonic-gate {
38*0Sstevel@tonic-gate register char c;
39*0Sstevel@tonic-gate register char *ptr;
40*0Sstevel@tonic-gate
41*0Sstevel@tonic-gate c = '\0';
42*0Sstevel@tonic-gate
43*0Sstevel@tonic-gate for (ptr = string; *ptr; ptr++)
44*0Sstevel@tonic-gate ;
45*0Sstevel@tonic-gate if (ptr != string && isspace(*(--ptr))) {
46*0Sstevel@tonic-gate c = *ptr;
47*0Sstevel@tonic-gate *ptr = '\0';
48*0Sstevel@tonic-gate }
49*0Sstevel@tonic-gate return (c);
50*0Sstevel@tonic-gate }
51*0Sstevel@tonic-gate
52*0Sstevel@tonic-gate
53*0Sstevel@tonic-gate char *
Trim(register char * string)54*0Sstevel@tonic-gate Trim(register char *string)
55*0Sstevel@tonic-gate {
56*0Sstevel@tonic-gate register char *ptr;
57*0Sstevel@tonic-gate
58*0Sstevel@tonic-gate for (ptr = string; *ptr; ptr++);
59*0Sstevel@tonic-gate
60*0Sstevel@tonic-gate while ((--ptr >= string) && isspace(*ptr));
61*0Sstevel@tonic-gate
62*0Sstevel@tonic-gate *(++ptr) = '\0';
63*0Sstevel@tonic-gate
64*0Sstevel@tonic-gate return (ptr);
65*0Sstevel@tonic-gate }
66