Deleted Added
full compact
fparseln.c (92917) fparseln.c (121193)
1/* $NetBSD: fparseln.c,v 1.9 1999/09/20 04:48:06 lukem Exp $ */
2
3/*
4 * Copyright (c) 1997 Christos Zoulas. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

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

25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32#include <sys/cdefs.h>
1/* $NetBSD: fparseln.c,v 1.9 1999/09/20 04:48:06 lukem Exp $ */
2
3/*
4 * Copyright (c) 1997 Christos Zoulas. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

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

25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32#include <sys/cdefs.h>
33__FBSDID("$FreeBSD: head/lib/libutil/fparseln.c 92917 2002-03-21 23:54:04Z obrien $");
33__FBSDID("$FreeBSD: head/lib/libutil/fparseln.c 121193 2003-10-18 10:04:16Z markm $");
34
35#include <sys/types.h>
36#include <assert.h>
37#include <errno.h>
38#include <stdio.h>
39#include <string.h>
40#include <stdlib.h>
41#include <libutil.h>
42
43static int isescaped(const char *, const char *, int);
44
45/* isescaped():
46 * Return true if the character in *p that belongs to a string
47 * that starts in *sp, is escaped by the escape character esc.
48 */
49static int
34
35#include <sys/types.h>
36#include <assert.h>
37#include <errno.h>
38#include <stdio.h>
39#include <string.h>
40#include <stdlib.h>
41#include <libutil.h>
42
43static int isescaped(const char *, const char *, int);
44
45/* isescaped():
46 * Return true if the character in *p that belongs to a string
47 * that starts in *sp, is escaped by the escape character esc.
48 */
49static int
50isescaped(sp, p, esc)
51 const char *sp, *p;
52 int esc;
50isescaped(const char *sp, const char *p, int esc)
53{
54 const char *cp;
55 size_t ne;
56
57#if 0
58 _DIAGASSERT(sp != NULL);
59 _DIAGASSERT(p != NULL);
60#endif

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

73
74
75/* fparseln():
76 * Read a line from a file parsing continuations ending in \
77 * and eliminating trailing newlines, or comments starting with
78 * the comment char.
79 */
80char *
51{
52 const char *cp;
53 size_t ne;
54
55#if 0
56 _DIAGASSERT(sp != NULL);
57 _DIAGASSERT(p != NULL);
58#endif

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

71
72
73/* fparseln():
74 * Read a line from a file parsing continuations ending in \
75 * and eliminating trailing newlines, or comments starting with
76 * the comment char.
77 */
78char *
81fparseln(fp, size, lineno, str, flags)
82 FILE *fp;
83 size_t *size;
84 size_t *lineno;
85 const char str[3];
86 int flags;
79fparseln(FILE *fp, size_t *size, size_t *lineno, const char str[3], int flags)
87{
88 static const char dstr[3] = { '\\', '\\', '#' };
89
90 size_t s, len;
91 char *buf;
92 char *ptr, *cp;
93 int cnt;
94 char esc, con, nl, com;

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

194
195 if (size)
196 *size = len;
197 return buf;
198}
199
200#ifdef TEST
201
80{
81 static const char dstr[3] = { '\\', '\\', '#' };
82
83 size_t s, len;
84 char *buf;
85 char *ptr, *cp;
86 int cnt;
87 char esc, con, nl, com;

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

187
188 if (size)
189 *size = len;
190 return buf;
191}
192
193#ifdef TEST
194
202int main(int, char **);
203
204int
195int
205main(argc, argv)
206 int argc;
207 char **argv;
196main(int argc, char *argv[])
208{
209 char *ptr;
210 size_t size, line;
211
212 line = 0;
213 while ((ptr = fparseln(stdin, &size, &line, NULL,
214 FPARSELN_UNESCALL)) != NULL)
215 printf("line %d (%d) |%s|\n", line, size, ptr);

--- 18 unchanged lines hidden ---
197{
198 char *ptr;
199 size_t size, line;
200
201 line = 0;
202 while ((ptr = fparseln(stdin, &size, &line, NULL,
203 FPARSELN_UNESCALL)) != NULL)
204 printf("line %d (%d) |%s|\n", line, size, ptr);

--- 18 unchanged lines hidden ---