Deleted Added
full compact
getttyent.c (203068) getttyent.c (229403)
1/*
2 * Copyright (c) 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 17 unchanged lines hidden (view full) ---

26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#if defined(LIBC_SCCS) && !defined(lint)
31static char sccsid[] = "@(#)getttyent.c 8.1 (Berkeley) 6/4/93";
32#endif /* LIBC_SCCS and not lint */
33#include <sys/cdefs.h>
1/*
2 * Copyright (c) 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 17 unchanged lines hidden (view full) ---

26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#if defined(LIBC_SCCS) && !defined(lint)
31static char sccsid[] = "@(#)getttyent.c 8.1 (Berkeley) 6/4/93";
32#endif /* LIBC_SCCS and not lint */
33#include <sys/cdefs.h>
34__FBSDID("$FreeBSD: head/lib/libc/gen/getttyent.c 203068 2010-01-27 11:54:42Z ed $");
34__FBSDID("$FreeBSD: head/lib/libc/gen/getttyent.c 229403 2012-01-03 18:51:58Z ed $");
35
36#include <ttyent.h>
37#include <stdio.h>
38#include <stdlib.h>
39#include <ctype.h>
40#include <string.h>
41
42static char zapchar;

--- 30 unchanged lines hidden (view full) ---

73 size_t i;
74
75 if (!tf && !setttyent())
76 return (NULL);
77 for (;;) {
78 if (!fgets(p = line, lbsize, tf))
79 return (NULL);
80 /* extend buffer if line was too big, and retry */
35
36#include <ttyent.h>
37#include <stdio.h>
38#include <stdlib.h>
39#include <ctype.h>
40#include <string.h>
41
42static char zapchar;

--- 30 unchanged lines hidden (view full) ---

73 size_t i;
74
75 if (!tf && !setttyent())
76 return (NULL);
77 for (;;) {
78 if (!fgets(p = line, lbsize, tf))
79 return (NULL);
80 /* extend buffer if line was too big, and retry */
81 while (!index(p, '\n') && !feof(tf)) {
81 while (!strchr(p, '\n') && !feof(tf)) {
82 i = strlen(p);
83 lbsize += MALLOCCHUNK;
84 if ((p = realloc(line, lbsize)) == NULL) {
85 (void)endttyent();
86 return (NULL);
87 }
88 line = p;
89 if (!fgets(&line[i], lbsize - i, tf))

--- 53 unchanged lines hidden (view full) ---

143 }
144
145 if (zapchar == '#' || *p == '#')
146 while ((c = *++p) == ' ' || c == '\t')
147 ;
148 tty.ty_comment = p;
149 if (*p == 0)
150 tty.ty_comment = 0;
82 i = strlen(p);
83 lbsize += MALLOCCHUNK;
84 if ((p = realloc(line, lbsize)) == NULL) {
85 (void)endttyent();
86 return (NULL);
87 }
88 line = p;
89 if (!fgets(&line[i], lbsize - i, tf))

--- 53 unchanged lines hidden (view full) ---

143 }
144
145 if (zapchar == '#' || *p == '#')
146 while ((c = *++p) == ' ' || c == '\t')
147 ;
148 tty.ty_comment = p;
149 if (*p == 0)
150 tty.ty_comment = 0;
151 if ( (p = index(p, '\n')) )
151 if ((p = strchr(p, '\n')))
152 *p = '\0';
153 return (&tty);
154}
155
156#define QUOTED 1
157
158/*
159 * Skip over the current field, removing quotes, and return a pointer to

--- 31 unchanged lines hidden (view full) ---

191 *--t = '\0';
192 return (p);
193}
194
195static char *
196value(char *p)
197{
198
152 *p = '\0';
153 return (&tty);
154}
155
156#define QUOTED 1
157
158/*
159 * Skip over the current field, removing quotes, and return a pointer to

--- 31 unchanged lines hidden (view full) ---

191 *--t = '\0';
192 return (p);
193}
194
195static char *
196value(char *p)
197{
198
199 return ((p = index(p, '=')) ? ++p : NULL);
199 return ((p = strchr(p, '=')) ? ++p : NULL);
200}
201
202int
203setttyent(void)
204{
205
206 if (line == NULL) {
207 if ((line = malloc(MALLOCCHUNK)) == NULL)

--- 50 unchanged lines hidden ---
200}
201
202int
203setttyent(void)
204{
205
206 if (line == NULL) {
207 if ((line = malloc(MALLOCCHUNK)) == NULL)

--- 50 unchanged lines hidden ---