mirror of
https://git.savannah.gnu.org/git/gperf.git
synced 2025-12-02 13:09:22 +00:00
Rework the Read_Line class.
This commit is contained in:
@@ -29,8 +29,8 @@
|
||||
#include <limits.h> /* defines UCHAR_MAX etc. */
|
||||
#include "options.h"
|
||||
|
||||
Input::Input (Keyword_Factory *keyword_factory)
|
||||
: _factory (keyword_factory)
|
||||
Input::Input (FILE *stream, Keyword_Factory *keyword_factory)
|
||||
: Read_Line (stream), _factory (keyword_factory)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
class Input : private Read_Line
|
||||
{
|
||||
public:
|
||||
Input (Keyword_Factory *keyword_factory);
|
||||
Input (FILE *stream, Keyword_Factory *keyword_factory);
|
||||
void read_keys ();
|
||||
private:
|
||||
#ifndef strcspn
|
||||
|
||||
@@ -45,12 +45,12 @@ KeywordExt_Factory::create_keyword (const char *allchars, int allchars_length, c
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
/* Set the Options. */
|
||||
/* Set the Options. Open the input file and assign stdin to it. */
|
||||
option.parse_options (argc, argv);
|
||||
|
||||
/* Initialize the key word list. */
|
||||
KeywordExt_Factory factory;
|
||||
Input inputter (&factory);
|
||||
Input inputter (stdin, &factory);
|
||||
inputter.read_keys ();
|
||||
/* We can cast the keyword list to KeywordExt_List* because its list
|
||||
elements were created by KeywordExt_Factory. */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Correctly reads an arbitrarily size string.
|
||||
/* Correctly reads an arbitrarily long string.
|
||||
|
||||
Copyright (C) 1989-1998, 2002 Free Software Foundation, Inc.
|
||||
Written by Douglas C. Schmidt <schmidt@ics.uci.edu>
|
||||
|
||||
@@ -37,7 +37,7 @@ class Read_Line
|
||||
public:
|
||||
|
||||
/* Initializes the instance with a given input stream. */
|
||||
Read_Line (FILE *stream = stdin) : _fp (stream) {}
|
||||
Read_Line (FILE *stream);
|
||||
|
||||
/* Reads the next line and returns it, excluding the terminating newline,
|
||||
and ignoring lines starting with '#'. Returns NULL on error or EOF.
|
||||
@@ -46,7 +46,8 @@ public:
|
||||
char * read_next_line ();
|
||||
|
||||
private:
|
||||
FILE * const _fp; /* FILE pointer to the input stream. */
|
||||
/* FILE pointer to the input stream. */
|
||||
FILE * const _fp;
|
||||
};
|
||||
|
||||
#ifdef __OPTIMIZE__
|
||||
|
||||
@@ -25,6 +25,13 @@
|
||||
//#include <stdio.h>
|
||||
//#include "getline.h"
|
||||
|
||||
/* Initializes the instance with a given input stream. */
|
||||
INLINE
|
||||
Read_Line::Read_Line (FILE *stream)
|
||||
: _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
|
||||
|
||||
Reference in New Issue
Block a user