/********************************************************************** * Copyright (c) Digital Equipment Corporation 1984, 1985, 1986. * * All Rights Reserved. * * Reference "/usr/src/COPYRIGHT" for applicable restrictions. * **********************************************************************/ static char Sccsid[]="@(#)substr.c 3.0 4/22/86"; /* Place the `len' length substring of `as' starting at `as[origin]' in `aresult'. Return `aresult'. Note: The copying of as to aresult stops if either the specified number (len) characters have been copied, or if the end of as is found. A negative len generally guarantees that everything gets copied. */ char *substr(as, aresult, origin, len) char *as, *aresult; int origin; register unsigned len; { register char *s, *result; s = as + origin; result = aresult; ++len; while (--len && (*result++ = *s++)) ; if (len == 0) *result = 0; return(aresult); }