mirror of
https://git.savannah.gnu.org/git/gperf.git
synced 2025-12-02 13:09:22 +00:00
New option --output-file.
This commit is contained in:
13
ChangeLog
13
ChangeLog
@@ -1,3 +1,16 @@
|
||||
2002-11-12 Bruno Haible <bruno@clisp.org>
|
||||
|
||||
* src/options.h (Output::get_output_file_name): New method.
|
||||
(Output::_output_file_name): New field.
|
||||
* src/options.icc (Options::get_output_file_name): New method.
|
||||
* src/options.cc (Options::long_usage): Document option --output-file.
|
||||
(Options::Options): Initialize _output_file_name.
|
||||
(long_options): Add --output-file.
|
||||
(Options::parse_options): Handle it.
|
||||
* src/main.cc (main): Open the output file if given by name.
|
||||
* doc/gperf.texi (Output File): New section.
|
||||
* tests/test-6.exp: Update.
|
||||
|
||||
2002-11-10 Bruno Haible <bruno@clisp.org>
|
||||
|
||||
* src/input.cc (pretty_input_file_name): New function.
|
||||
|
||||
1
NEWS
1
NEWS
@@ -2,6 +2,7 @@ New in 2.8:
|
||||
|
||||
* Added option -m/--multiple-iterations that reduces the size of the
|
||||
generated table.
|
||||
* Added option --output that allows to specify the output file name.
|
||||
* If the input file is given by name, the output file will now contain
|
||||
#line directives referring to the input file.
|
||||
* Bug fixes.
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
@c some day we should @include version.texi instead of defining
|
||||
@c these values at hand.
|
||||
@set UPDATED 9 November 2002
|
||||
@set UPDATED 12 November 2002
|
||||
@set EDITION 2.7.2
|
||||
@set VERSION 2.7.2
|
||||
@c ---------------------
|
||||
@@ -550,6 +550,7 @@ help is readily available via the @samp{--help} option. Here is the
|
||||
complete list of options.
|
||||
|
||||
@menu
|
||||
* Output File:: Specifying the Location of the Output File
|
||||
* Input Details:: Options that affect Interpretation of the Input File
|
||||
* Output Language:: Specifying the Language for the Output Code
|
||||
* Output Details:: Fine tuning Details in the Output Code
|
||||
@@ -557,7 +558,18 @@ complete list of options.
|
||||
* Verbosity:: Informative Output
|
||||
@end menu
|
||||
|
||||
@node Input Details, Output Language, Options, Options
|
||||
@node Output File, Input Details, Options, Options
|
||||
@section Specifying the Location of the Output File
|
||||
|
||||
@table @samp
|
||||
@item --output-file=@var{file}
|
||||
Allows you to specify the name of the file to which the output is written to.
|
||||
@end table
|
||||
|
||||
The results are written to standard output if no output file is specified
|
||||
or if it is @samp{-}.
|
||||
|
||||
@node Input Details, Output Language, Output File, Options
|
||||
@section Options that affect Interpretation of the Input File
|
||||
|
||||
@table @samp
|
||||
|
||||
11
src/main.cc
11
src/main.cc
@@ -22,6 +22,7 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "options.h"
|
||||
#include "input.h"
|
||||
#include "search.h"
|
||||
@@ -78,6 +79,16 @@ main (int argc, char *argv[])
|
||||
searcher.optimize ();
|
||||
list = searcher._head;
|
||||
|
||||
/* Open the output file. */
|
||||
if (option.get_output_file_name ())
|
||||
if (strcmp (option.get_output_file_name (), "-") != 0)
|
||||
if (!freopen (option.get_output_file_name (), "w", stdout))
|
||||
{
|
||||
fprintf (stderr, "Cannot open output file '%s'\n",
|
||||
option.get_output_file_name ());
|
||||
exit (1);
|
||||
}
|
||||
|
||||
{
|
||||
/* Output the hash function code. */
|
||||
Output outputter (searcher._head,
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <stdlib.h> /* declares atoi(), abs(), exit() */
|
||||
#include <string.h> /* declares strcmp() */
|
||||
#include <ctype.h> /* declares isdigit() */
|
||||
#include <limits.h> /* defines CHAR_MAX */
|
||||
#include "getopt.h"
|
||||
#include "version.h"
|
||||
|
||||
@@ -84,6 +85,14 @@ Options::long_usage (FILE * stream) const
|
||||
"If a long option shows an argument as mandatory, then it is mandatory\n"
|
||||
"for the equivalent short option also.\n");
|
||||
fprintf (stream, "\n");
|
||||
fprintf (stream,
|
||||
"Output file location:\n");
|
||||
fprintf (stream,
|
||||
" --output-file=FILE Write output to specified file.\n");
|
||||
fprintf (stream,
|
||||
"The results are written to standard output if no output file is specified\n"
|
||||
"or if it is -.\n");
|
||||
fprintf (stream, "\n");
|
||||
fprintf (stream,
|
||||
"Input file interpretation:\n");
|
||||
fprintf (stream,
|
||||
@@ -417,6 +426,7 @@ PositionStringParser::nextPosition ()
|
||||
Options::Options ()
|
||||
: _option_word (C),
|
||||
_input_file_name (NULL),
|
||||
_output_file_name (NULL),
|
||||
_iterations (0),
|
||||
_jump (DEFAULT_JUMP_VALUE),
|
||||
_initial_asso_value (0),
|
||||
@@ -521,6 +531,7 @@ Options::~Options ()
|
||||
|
||||
static const struct option long_options[] =
|
||||
{
|
||||
{ "output-file", required_argument, NULL, CHAR_MAX + 1 },
|
||||
{ "delimiters", required_argument, NULL, 'e' },
|
||||
{ "struct-type", no_argument, NULL, 't' },
|
||||
{ "language", required_argument, NULL, 'L' },
|
||||
@@ -826,6 +837,11 @@ Options::parse_options (int argc, char *argv[])
|
||||
_option_word |= SEVENBIT;
|
||||
break;
|
||||
}
|
||||
case CHAR_MAX + 1: /* Set the output file name. */
|
||||
{
|
||||
_output_file_name = /*getopt*/optarg;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
short_usage (stderr);
|
||||
exit (1);
|
||||
|
||||
@@ -184,6 +184,9 @@ public:
|
||||
/* Returns the input file name. */
|
||||
const char * get_input_file_name () const;
|
||||
|
||||
/* Returns the output file name. */
|
||||
const char * get_output_file_name () const;
|
||||
|
||||
/* Returns the iterations value. */
|
||||
int get_iterations () const;
|
||||
|
||||
@@ -250,6 +253,9 @@ private:
|
||||
/* Name of input file. */
|
||||
char * _input_file_name;
|
||||
|
||||
/* Name of output file. */
|
||||
char * _output_file_name;
|
||||
|
||||
/* Amount to iterate when a collision occurs. */
|
||||
int _iterations;
|
||||
|
||||
|
||||
@@ -132,6 +132,13 @@ Options::get_input_file_name () const
|
||||
return _input_file_name;
|
||||
}
|
||||
|
||||
/* Returns the output file name. */
|
||||
INLINE const char *
|
||||
Options::get_output_file_name () const
|
||||
{
|
||||
return _output_file_name;
|
||||
}
|
||||
|
||||
/* Returns the iterations value. */
|
||||
INLINE int
|
||||
Options::get_iterations () const
|
||||
|
||||
@@ -5,6 +5,11 @@ Usage: ../src/gperf [OPTION]... [INPUT-FILE]
|
||||
If a long option shows an argument as mandatory, then it is mandatory
|
||||
for the equivalent short option also.
|
||||
|
||||
Output file location:
|
||||
--output-file=FILE Write output to specified file.
|
||||
The results are written to standard output if no output file is specified
|
||||
or if it is -.
|
||||
|
||||
Input file interpretation:
|
||||
-e, --delimiters=DELIMITER-LIST
|
||||
Allow user to provide a string containing delimiters
|
||||
|
||||
Reference in New Issue
Block a user