mirror of
https://git.savannah.gnu.org/git/gperf.git
synced 2025-12-02 13:09:22 +00:00
Rename Read_Line method.
This commit is contained in:
@@ -354,7 +354,7 @@ Key_List::read_keys (void)
|
||||
set_output_types ();
|
||||
|
||||
/* Oops, problem with the input file. */
|
||||
if (! (ptr = Read_Line::get_line ()))
|
||||
if (! (ptr = Read_Line::read_next_line ()))
|
||||
{
|
||||
fprintf (stderr, "No words in input file, did you forget to prepend %s or use -t accidentally?\n", "%%");
|
||||
exit (1);
|
||||
@@ -369,7 +369,7 @@ Key_List::read_keys (void)
|
||||
head = parse_line (ptr, delimiter);
|
||||
|
||||
for (temp = head;
|
||||
(ptr = Read_Line::get_line ()) && strcmp (ptr, "%%");
|
||||
(ptr = Read_Line::read_next_line ()) && strcmp (ptr, "%%");
|
||||
temp = temp->next)
|
||||
{
|
||||
temp->next = parse_line (ptr, delimiter);
|
||||
|
||||
@@ -21,9 +21,6 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
|
||||
|
||||
#include "read-line.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h> /* declares memcpy() */
|
||||
|
||||
#ifndef __OPTIMIZE__
|
||||
|
||||
#define INLINE /* not inline */
|
||||
|
||||
@@ -22,23 +22,29 @@ You should have received a copy of the GNU General Public License
|
||||
along with GNU GPERF; see the file COPYING. If not, write to the Free
|
||||
Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
|
||||
|
||||
/* Returns a pointer to an arbitrary length string. Returns NULL on error or EOF
|
||||
The storage for the string is dynamically allocated by new. */
|
||||
|
||||
#ifndef read_line_h
|
||||
#define read_line_h 1
|
||||
|
||||
#include <stdio.h>
|
||||
#include "getline.h"
|
||||
|
||||
/* An instance of this class is used for repeatedly reading lines of text
|
||||
from an input stream. */
|
||||
class Read_Line
|
||||
{
|
||||
public:
|
||||
|
||||
/* Initializes the instance with a given input stream. */
|
||||
Read_Line (FILE *stream = stdin) : fp (stream) {}
|
||||
|
||||
/* Reads the next line and returns it, excluding the terminating newline,
|
||||
and ignoring lines starting with '#'. Returns NULL on error or EOF.
|
||||
The storage for the string is dynamically allocated and must be freed
|
||||
through delete[]. */
|
||||
char *read_next_line (void);
|
||||
|
||||
private:
|
||||
FILE *fp; /* FILE pointer to the input stream. */
|
||||
|
||||
public:
|
||||
Read_Line (FILE *stream = stdin) : fp (stream) {}
|
||||
char *get_line (void);
|
||||
};
|
||||
|
||||
#ifdef __OPTIMIZE__
|
||||
|
||||
@@ -23,9 +23,12 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
|
||||
//#include <stdio.h>
|
||||
//#include "getline.h"
|
||||
|
||||
/* Returns the "next" line, ignoring comments beginning with '#'. */
|
||||
/* Reads the next line and returns it, excluding the terminating newline,
|
||||
and ignoring lines starting with '#'. Returns NULL on error or EOF.
|
||||
The storage for the string is dynamically allocated and must be freed
|
||||
through delete[]. */
|
||||
INLINE char *
|
||||
Read_Line::get_line (void)
|
||||
Read_Line::read_next_line (void)
|
||||
{
|
||||
int c;
|
||||
|
||||
@@ -45,7 +48,7 @@ Read_Line::get_line (void)
|
||||
|
||||
char *line = (char *)0;
|
||||
size_t linesize = 0;
|
||||
int length = ::get_line (&line, &linesize, fp);
|
||||
int length = get_line (&line, &linesize, fp);
|
||||
if (length < 0)
|
||||
{
|
||||
delete[] line;
|
||||
|
||||
Reference in New Issue
Block a user