Mercurial > hg > octave-nkf > gnulib-hg
annotate lib/linebuffer.h @ 17848:ab58d4870664
version-etc: new year
* doc/gnulib.texi:
* lib/version-etc.c (COPYRIGHT_YEAR): Update copyright date.
* all files: Run 'make update-copyright'.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Thu, 01 Jan 2015 01:38:23 +0000 |
parents | 344018b6e5d7 |
children |
rev | line source |
---|---|
14 | 1 /* linebuffer.h -- declarations for reading arbitrarily long lines |
4169
f3219f604940
(readlinebuffer): Renamed from readline.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4103
diff
changeset
|
2 |
17848 | 3 Copyright (C) 1986, 1991, 1998-1999, 2002-2003, 2007, 2009-2015 Free |
12559
c2cbabec01dd
update nearly all FSF copyright year lists to include 2010
Jim Meyering <meyering@redhat.com>
parents:
12518
diff
changeset
|
4 Software Foundation, Inc. |
14 | 5 |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8816
diff
changeset
|
6 This program is free software: you can redistribute it and/or modify |
14 | 7 it under the terms of the GNU General Public License as published by |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8816
diff
changeset
|
8 the Free Software Foundation; either version 3 of the License, or |
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8816
diff
changeset
|
9 (at your option) any later version. |
14 | 10 |
11 This program is distributed in the hope that it will be useful, | |
12 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 GNU General Public License for more details. | |
15 | |
16 You should have received a copy of the GNU General Public License | |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8816
diff
changeset
|
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
1216
cf3c93b52b9b
Make PARAMS-defining conditionals consistent.
Jim Meyering <jim@meyering.net>
parents:
756
diff
changeset
|
18 |
cf3c93b52b9b
Make PARAMS-defining conditionals consistent.
Jim Meyering <jim@meyering.net>
parents:
756
diff
changeset
|
19 #if !defined LINEBUFFER_H |
cf3c93b52b9b
Make PARAMS-defining conditionals consistent.
Jim Meyering <jim@meyering.net>
parents:
756
diff
changeset
|
20 # define LINEBUFFER_H |
cf3c93b52b9b
Make PARAMS-defining conditionals consistent.
Jim Meyering <jim@meyering.net>
parents:
756
diff
changeset
|
21 |
4347
df44e79ce676
.h files should stand alone, but we shouldn't include <sys/types.h>
Paul Eggert <eggert@cs.ucla.edu>
parents:
4169
diff
changeset
|
22 # include <stdio.h> |
df44e79ce676
.h files should stand alone, but we shouldn't include <sys/types.h>
Paul Eggert <eggert@cs.ucla.edu>
parents:
4169
diff
changeset
|
23 |
16235
18a38c9615f0
In commentary, do not use ` to quote.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16201
diff
changeset
|
24 /* A 'struct linebuffer' holds a line of text. */ |
14 | 25 |
26 struct linebuffer | |
27 { | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
28 size_t size; /* Allocated. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
29 size_t length; /* Used. */ |
14 | 30 char *buffer; |
31 }; | |
32 | |
33 /* Initialize linebuffer LINEBUFFER for use. */ | |
4397
c6450308f123
Assume C89, so PARAMS isn't needed.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4347
diff
changeset
|
34 void initbuffer (struct linebuffer *linebuffer); |
14 | 35 |
36 /* Read an arbitrarily long line of text from STREAM into LINEBUFFER. | |
8812
28d0ef9a0a36
* lib/linebuffer.c (readlinebuffer_delim): New function,
Jim Meyering <jim@meyering.net>
parents:
5848
diff
changeset
|
37 Consider lines to be terminated by DELIMITER. |
28d0ef9a0a36
* lib/linebuffer.c (readlinebuffer_delim): New function,
Jim Meyering <jim@meyering.net>
parents:
5848
diff
changeset
|
38 Keep the delimiter; append DELIMITER if we reach EOF and it wasn't |
8816 | 39 the last character in the file. Do not NUL-terminate. |
40 Return LINEBUFFER, except at end of file return NULL. */ | |
8812
28d0ef9a0a36
* lib/linebuffer.c (readlinebuffer_delim): New function,
Jim Meyering <jim@meyering.net>
parents:
5848
diff
changeset
|
41 struct linebuffer *readlinebuffer_delim (struct linebuffer *linebuffer, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
42 FILE *stream, char delimiter); |
8812
28d0ef9a0a36
* lib/linebuffer.c (readlinebuffer_delim): New function,
Jim Meyering <jim@meyering.net>
parents:
5848
diff
changeset
|
43 |
28d0ef9a0a36
* lib/linebuffer.c (readlinebuffer_delim): New function,
Jim Meyering <jim@meyering.net>
parents:
5848
diff
changeset
|
44 /* Read an arbitrarily long line of text from STREAM into LINEBUFFER. |
1867
8cac4427bbda
[struct linebuffer] (size): Declare to be of type size_t, not long.
Jim Meyering <jim@meyering.net>
parents:
1216
diff
changeset
|
45 Keep the newline; append a newline if it's the last line of a file |
8816 | 46 that ends in a non-newline character. Do not NUL-terminate. |
47 Return LINEBUFFER, except at end of file return NULL. */ | |
4397
c6450308f123
Assume C89, so PARAMS isn't needed.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4347
diff
changeset
|
48 struct linebuffer *readlinebuffer (struct linebuffer *linebuffer, FILE *stream); |
14 | 49 |
50 /* Free linebuffer LINEBUFFER and its data, all allocated with malloc. */ | |
4397
c6450308f123
Assume C89, so PARAMS isn't needed.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4347
diff
changeset
|
51 void freebuffer (struct linebuffer *); |
1216
cf3c93b52b9b
Make PARAMS-defining conditionals consistent.
Jim Meyering <jim@meyering.net>
parents:
756
diff
changeset
|
52 |
cf3c93b52b9b
Make PARAMS-defining conditionals consistent.
Jim Meyering <jim@meyering.net>
parents:
756
diff
changeset
|
53 #endif /* LINEBUFFER_H */ |