/* @(#)mystrcpy.c 2.1 93/05/18 */ /******************************************************************************/ /* function : mystrcpy.c */ /* */ /* subsystem : chgen */ /* */ /* input : t (source string) , n (pad width) , unpad (trim trailers ?) */ /* */ /* output : s (modified string) */ /* */ /* returns : void */ /* */ /* author : Steve Smith / Craig Smith */ /* */ /* created : July, 1991 */ /* */ /* revisions : */ /* */ /* description : This routine is similar to strcpy, except that it pads the */ /* result string (s) with blanks (if the unpad flag is 0) out */ /* to the length specified by n. If the unpad flag is 1, then */ /* trailing blanks are removed (even any that were in the */ /* original string). Like hcg_parse.c, this handy routine */ /* is portable to other applications. */ /* */ /******************************************************************************/ #include "chgen_externs.h" void mystrcpy(s,t,n,unpad) char *s, *t; int n,unpad; { static char rcsid[] = "$Id: mystrcpy.c,v 1.3.4.1 1999/05/04 17:00:14 jkarner Exp $"; int i; char *s2; s2 = s; while ((*t != '\0') && (n>0)) { *s++ = *t++; n--; } for (s; n>0; n--) *s++ = ' '; *s = '\0'; s = s2; if (unpad) for (i=strlen(s)-1; (i>=0) && ((s[i] == ' ') || (s[i] == 9)); i--) s[i] = '\0'; return; }