1 static char Sccsid[] = "@(#)substr.c 1.2 02/15/87"; 2 /* 3 Place the `len' length substring of `as' starting at `as[origin]' 4 in `aresult'. 5 Return `aresult'. 6 7 Note: The copying of as to aresult stops if either the 8 specified number (len) characters have been copied, 9 or if the end of as is found. 10 A negative len generally guarantees that everything gets copied. 11 */ 12 13 char *substr(as, aresult, origin, len) 14 char *as, *aresult; 15 int origin; 16 register unsigned len; 17 { 18 register char *s, *result; 19 20 s = as + origin; 21 result = aresult; 22 ++len; 23 while (--len && (*result++ = *s++)) ; 24 if (len == 0) 25 *result = 0; 26 return(aresult); 27 } 28