#include <error.h>
#include "attribute.h"
#include "message.h"
+#include "sf-istream.h"
#include "rc-str-list.h"
#include "string-desc.h"
#include "xgettext.h"
/* Accumulator for the output. */
message_list_ty *mlp;
- /* The input file stream, when reading from a file. */
- FILE *fp;
- /* The input area, when reading from a string. */
- const char *input;
- const char *input_end;
+ /* The input. */
+ sf_istream_t input;
int line_number;
if (xp->end_of_file)
return EOF;
- if (xp->fp != NULL)
+ if (xp->input.fp != NULL)
{
if (xp->linepos >= xp->linesize)
{
- xp->linesize = getline (&xp->linebuf, &xp->linebuf_size, xp->fp);
+ xp->linesize =
+ getline (&xp->linebuf, &xp->linebuf_size, xp->input.fp);
if (xp->linesize < 0)
{
- if (ferror (xp->fp))
+ if (ferror (xp->input.fp))
error (EXIT_FAILURE, errno, _("error while reading \"%s\""),
real_file_name);
xp->end_of_file = true;
{
if (xp->linebuf == NULL)
{
- xp->linebuf = xp->input;
- xp->linesize = xp->input_end - xp->input;
+ xp->linebuf = (char *) xp->input.input;
+ xp->linesize = xp->input.input_end - xp->input.input;
xp->linepos = 0;
}
if (xp->linepos >= xp->linesize)
for (;;)
{
- int read_bytes = getline (&my_linebuf, &my_linebuf_size, xp->fp);
+ int read_bytes = getline (&my_linebuf, &my_linebuf_size, xp->input.fp);
char *my_line_utf8;
bool chomp;
if (read_bytes < 0)
{
- if (ferror (xp->fp))
+ if (ferror (xp->input.fp))
{
error (EXIT_FAILURE, errno, _("error while reading \"%s\""),
real_file_name);
for (;;)
{
- xp->linesize = getline (&xp->linebuf, &xp->linebuf_size, xp->fp);
+ xp->linesize = getline (&xp->linebuf, &xp->linebuf_size, xp->input.fp);
if (xp->linesize < 0)
{
- if (ferror (xp->fp))
+ if (ferror (xp->input.fp))
error (EXIT_FAILURE, errno, _("error while reading \"%s\""),
real_file_name);
return;
struct perl_extractor *rxp = XMALLOC (struct perl_extractor);
rxp->mlp = xp->mlp;
- rxp->fp = NULL;
- rxp->input = substring;
- rxp->input_end = substring + bufpos;
+ sf_istream_init_from_string_desc (
+ &rxp->input,
+ string_desc_new_addr (bufpos, substring));
rxp->line_number = xp->line_number;
perl_extractor_init_rest (rxp);
struct perl_extractor *xp = XMALLOC (struct perl_extractor);
xp->mlp = mdlp->item[0]->messages;
- xp->fp = f;
- xp->input = NULL;
- xp->input_end = NULL;
+ sf_istream_init_from_file (&xp->input, f);
real_file_name = real_filename;
logical_file_name = xstrdup (logical_filename);
perl_extractor_init_rest (xp);
#include <error.h>
#include "attribute.h"
#include "message.h"
+#include "sf-istream.h"
#include "rc-str-list.h"
#include "xgettext.h"
#include "xg-pos.h"
/* Accumulator for the output. */
message_list_ty *mlp;
- /* The input file stream, when reading from a file. */
- FILE *fp;
- /* The input area, when reading from a string. */
- const char *input;
- const char *input_end;
+ /* The input. */
+ sf_istream_t input;
int line_number;
if (xp->phase1_pushback_length)
c = xp->phase1_pushback[--(xp->phase1_pushback_length)];
- else if (xp->fp != NULL)
+ else
{
- c = getc (xp->fp);
+ c = sf_getc (&xp->input);
if (c == EOF)
{
- if (ferror (xp->fp))
+ if (sf_ferror (&xp->input))
error (EXIT_FAILURE, errno, _("error while reading \"%s\""),
real_file_name);
return EOF;
}
}
- else
- {
- if (xp->input == xp->input_end)
- return EOF;
- c = *(xp->input++);
- }
- if (xp->fp != NULL && c == '\n')
+ if (xp->input.fp != NULL && c == '\n')
xp->line_number++;
return c;
struct php_extractor *rxp = XMALLOC (struct php_extractor);
rxp->mlp = xp->mlp;
- rxp->fp = NULL;
- rxp->input = substring;
- rxp->input_end = substring + bufpos;
+ sf_istream_init_from_string_desc (&rxp->input,
+ string_desc_new_addr (bufpos, substring));
rxp->line_number = xp->line_number;
php_extractor_init_rest (rxp);
struct php_extractor *rxp = XMALLOC (struct php_extractor);
rxp->mlp = xp->mlp;
- rxp->fp = NULL;
- rxp->input = substring;
- rxp->input_end = substring + bufpos;
+ sf_istream_init_from_string_desc (
+ &rxp->input,
+ string_desc_new_addr (bufpos, substring));
rxp->line_number = xp->line_number;
php_extractor_init_rest (rxp);
struct php_extractor *xp = XMALLOC (struct php_extractor);
xp->mlp = mdlp->item[0]->messages;
- xp->fp = f;
- xp->input = NULL;
- xp->input_end = NULL;
+ sf_istream_init_from_file (&xp->input, f);
real_file_name = real_filename;
logical_file_name = xstrdup (logical_filename);
xp->line_number = 1;