]> diplodocus.org Git - nmh/blob - docs/historical/mh-jun-1982/Extras/libh/getline.c
Replaced use of snprintf() with memcpy()/memmove().
[nmh] / docs / historical / mh-jun-1982 / Extras / libh / getline.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 /* return one line using getchar, caller must supply line buf and max. cnt */
9 /* return actual char cnt */
10
11 getline(line,cnt)
12 char line[];
13 int cnt;
14 {
15 register char *lp;
16 register c, cc;
17
18 lp = line;
19 cc = cnt;
20 while ((c = getchar()) > 0) {
21 *lp++ = c;
22 if (--cc <= 0 || c == '\n') break;
23 }
24 return(cnt-cc);
25 }