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