]> diplodocus.org Git - nmh/blob - docs/historical/mh-jun-1982/subs/trimcpy.c
Create new mh-format function %(ordinal)
[nmh] / docs / historical / mh-jun-1982 / subs / trimcpy.c
1 #ifdef COMMENT
2 Proprietary Rand Corporation, 1981.
3 Further distribution of this software
4 subject to the terms of the Rand
5 license agreement.
6 #endif
7
8 char *malloc();
9 extern char *strcpy();
10
11
12 char *trimcpy(cp)
13 register char *cp;
14 {
15 register char *sp;
16
17 while(*cp == ' ' || *cp == '\t')
18 cp++;
19
20 /* Zap trailing NL */
21 cp[strlen(cp) - 1] = '\0';
22
23 /* Replace embedded NL's with blanks */
24 for(sp = cp; *sp; sp++)
25 if(*sp == '\n')
26 *sp = ' ';
27 sp = malloc((unsigned)(sp - cp + 1));
28 strcpy(sp, cp);
29 return(sp);
30 }