aboutsummaryrefslogtreecommitdiff
path: root/gfsm/gfsm/src/programs/gfsmarith_cmdparser.c
diff options
context:
space:
mode:
Diffstat (limited to 'gfsm/gfsm/src/programs/gfsmarith_cmdparser.c')
-rw-r--r--gfsm/gfsm/src/programs/gfsmarith_cmdparser.c773
1 files changed, 0 insertions, 773 deletions
diff --git a/gfsm/gfsm/src/programs/gfsmarith_cmdparser.c b/gfsm/gfsm/src/programs/gfsmarith_cmdparser.c
deleted file mode 100644
index 7aade2f..0000000
--- a/gfsm/gfsm/src/programs/gfsmarith_cmdparser.c
+++ /dev/null
@@ -1,773 +0,0 @@
-/* -*- Mode: C -*-
- *
- * File: gfsmarith_cmdparser.c
- * Description: Code for command-line parser struct gengetopt_args_info.
- *
- * File autogenerated by optgen.perl version 0.05
- * generated with the following command:
- * /usr/local/bin/optgen.perl -u -l --no-handle-rcfile --nopod -F gfsmarith_cmdparser gfsmarith.gog
- *
- * The developers of optgen.perl consider the fixed text that goes in all
- * optgen.perl output files to be in the public domain:
- * we make no copyright claims on it.
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <string.h>
-#include <unistd.h>
-#include <ctype.h>
-
-/* If we use autoconf/autoheader. */
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#ifdef HAVE_PWD_H
-# include <pwd.h>
-#endif
-
-/* Allow user-overrides for PACKAGE and VERSION */
-#ifndef PACKAGE
-# define PACKAGE "PACKAGE"
-#endif
-
-#ifndef VERSION
-# define VERSION "VERSION"
-#endif
-
-
-#ifndef PROGRAM
-# define PROGRAM "gfsmarith"
-#endif
-
-/* #define cmdline_parser_DEBUG */
-
-/* Check for "configure's" getopt check result. */
-#ifndef HAVE_GETOPT_LONG
-# include "getopt.h"
-#else
-# include <getopt.h>
-#endif
-
-#if !defined(HAVE_STRDUP) && !defined(strdup)
-# define strdup gengetopt_strdup
-#endif /* HAVE_STRDUP */
-
-#include "gfsmarith_cmdparser.h"
-
-
-/* user code section */
-
-/* end user code section */
-
-
-void
-cmdline_parser_print_version (void)
-{
- printf("gfsmarith (%s %s) by Bryan Jurish <moocow@ling.uni-potsdam.de>\n", PACKAGE, VERSION);
-}
-
-void
-cmdline_parser_print_help (void)
-{
- cmdline_parser_print_version ();
- printf("\n");
- printf("Purpose:\n");
- printf(" Perform an elementary arithmetic operation on automaton weights\n");
- printf("\n");
-
- printf("Usage: %s [OPTIONS]... FSMFILE\n", "gfsmarith");
-
- printf("\n");
- printf(" Arguments:\n");
- printf(" FSMFILE Stored binary gfsm file\n");
-
- printf("\n");
- printf(" Options:\n");
- printf(" -h --help Print help and exit.\n");
- printf(" -V --version Print version and exit.\n");
- printf(" -zLEVEL --compress=LEVEL Specify compression level of output file.\n");
- printf(" -FFILE --output=FILE Specifiy output file (default=stdout).\n");
- printf("\n");
- printf(" Operator Selection:\n");
- printf(" -E --exp Real exponentiation\n");
- printf(" -L --log Real logarithm\n");
- printf(" -mFLOAT --multiply=FLOAT Real multiplication by WEIGHT\n");
- printf(" -aFLOAT --add=FLOAT Real addition of WEIGHT\n");
- printf(" -p --positive Set real negative weights to zero\n");
- printf(" --times=FLOAT Semiring multiplication by WEIGHT\n");
- printf(" --plus=FLOAT Semiring addition of WEIGHT\n");
- printf(" --sr-positive Set semiring-negative weights to semiring-zero\n");
- printf("\n");
- printf(" Weight Selection:\n");
- printf(" -A --no-arcs Exclude arc weights (default: include)\n");
- printf(" -f --no-finals Exclude final weights (default: include)\n");
- printf(" -Z --zero Include semiring-zero weights (default: exclude)\n");
- printf("\n");
- printf(" State & Label Selection:\n");
- printf(" -i --initial Select only initial state and its arcs/finality\n");
- printf(" -sID --state=ID Select only state ID and its arcs/finality (default=all)\n");
- printf(" -lLO --lower=LO Select only arcs with lower-label LO (default=any)\n");
- printf(" -uHI --upper=HI Select only arcs with upper-label HI (defualt=any)\n");
-}
-
-#if !defined(HAVE_STRDUP) && !defined(strdup)
-/* gengetopt_strdup(): automatically generated from strdup.c. */
-/* strdup.c replacement of strdup, which is not standard */
-static char *
-gengetopt_strdup (const char *s)
-{
- char *result = (char*)malloc(strlen(s) + 1);
- if (result == (char*)0)
- return (char*)0;
- strcpy(result, s);
- return result;
-}
-#endif /* HAVE_STRDUP */
-
-/* clear_args(args_info): clears all args & resets to defaults */
-static void
-clear_args(struct gengetopt_args_info *args_info)
-{
- args_info->compress_arg = -1;
- args_info->output_arg = strdup("-");
- args_info->exp_flag = 0;
- args_info->log_flag = 0;
- args_info->multiply_arg = 0;
- args_info->add_arg = 0;
- args_info->positive_flag = 0;
- args_info->times_arg = 0;
- args_info->plus_arg = 0;
- args_info->sr_positive_flag = 0;
- args_info->no_arcs_flag = 0;
- args_info->no_finals_flag = 0;
- args_info->zero_flag = 0;
- args_info->initial_flag = 0;
- args_info->state_arg = -1;
- args_info->lower_arg = -1;
- args_info->upper_arg = -1;
-}
-
-
-int
-cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info)
-{
- int c; /* Character of the parsed option. */
- int missing_required_options = 0;
-
- args_info->help_given = 0;
- args_info->version_given = 0;
- args_info->compress_given = 0;
- args_info->output_given = 0;
- args_info->exp_given = 0;
- args_info->log_given = 0;
- args_info->multiply_given = 0;
- args_info->add_given = 0;
- args_info->positive_given = 0;
- args_info->times_given = 0;
- args_info->plus_given = 0;
- args_info->sr_positive_given = 0;
- args_info->no_arcs_given = 0;
- args_info->no_finals_given = 0;
- args_info->zero_given = 0;
- args_info->initial_given = 0;
- args_info->state_given = 0;
- args_info->lower_given = 0;
- args_info->upper_given = 0;
-
- clear_args(args_info);
-
- /* rcfile handling */
-
- /* end rcfile handling */
-
- optarg = 0;
- optind = 1;
- opterr = 1;
- optopt = '?';
-
- while (1)
- {
- int option_index = 0;
- static struct option long_options[] = {
- { "help", 0, NULL, 'h' },
- { "version", 0, NULL, 'V' },
- { "compress", 1, NULL, 'z' },
- { "output", 1, NULL, 'F' },
- { "exp", 0, NULL, 'E' },
- { "log", 0, NULL, 'L' },
- { "multiply", 1, NULL, 'm' },
- { "add", 1, NULL, 'a' },
- { "positive", 0, NULL, 'p' },
- { "times", 1, NULL, 0 },
- { "plus", 1, NULL, 0 },
- { "sr-positive", 0, NULL, 0 },
- { "no-arcs", 0, NULL, 'A' },
- { "no-finals", 0, NULL, 'f' },
- { "zero", 0, NULL, 'Z' },
- { "initial", 0, NULL, 'i' },
- { "state", 1, NULL, 's' },
- { "lower", 1, NULL, 'l' },
- { "upper", 1, NULL, 'u' },
- { NULL, 0, NULL, 0 }
- };
- static char short_options[] = {
- 'h',
- 'V',
- 'z', ':',
- 'F', ':',
- 'E',
- 'L',
- 'm', ':',
- 'a', ':',
- 'p',
- 'A',
- 'f',
- 'Z',
- 'i',
- 's', ':',
- 'l', ':',
- 'u', ':',
- '\0'
- };
-
- c = getopt_long (argc, argv, short_options, long_options, &option_index);
-
- if (c == -1) break; /* Exit from 'while (1)' loop. */
-
- if (cmdline_parser_parse_option(c, long_options[option_index].name, optarg, args_info) != 0) {
- exit (EXIT_FAILURE);
- }
- } /* while */
-
-
-
- if ( missing_required_options )
- exit (EXIT_FAILURE);
-
-
- if (optind < argc) {
- int i = 0 ;
- args_info->inputs_num = argc - optind ;
- args_info->inputs = (char **)(malloc ((args_info->inputs_num)*sizeof(char *))) ;
- while (optind < argc)
- args_info->inputs[ i++ ] = strdup (argv[optind++]) ;
- }
-
- return 0;
-}
-
-
-/* Parse a single option */
-int
-cmdline_parser_parse_option(char oshort, const char *olong, const char *val,
- struct gengetopt_args_info *args_info)
-{
- if (!oshort && !(olong && *olong)) return 1; /* ignore null options */
-
-#ifdef cmdline_parser_DEBUG
- fprintf(stderr, "parse_option(): oshort='%c', olong='%s', val='%s'\n", oshort, olong, val);*/
-#endif
-
- switch (oshort)
- {
- case 'h': /* Print help and exit. */
- if (args_info->help_given) {
- fprintf(stderr, "%s: `--help' (`-h') option given more than once\n", PROGRAM);
- }
- clear_args(args_info);
- cmdline_parser_print_help();
- exit(EXIT_SUCCESS);
-
- break;
-
- case 'V': /* Print version and exit. */
- if (args_info->version_given) {
- fprintf(stderr, "%s: `--version' (`-V') option given more than once\n", PROGRAM);
- }
- clear_args(args_info);
- cmdline_parser_print_version();
- exit(EXIT_SUCCESS);
-
- break;
-
- case 'z': /* Specify compression level of output file. */
- if (args_info->compress_given) {
- fprintf(stderr, "%s: `--compress' (`-z') option given more than once\n", PROGRAM);
- }
- args_info->compress_given++;
- args_info->compress_arg = (int)atoi(val);
- break;
-
- case 'F': /* Specifiy output file (default=stdout). */
- if (args_info->output_given) {
- fprintf(stderr, "%s: `--output' (`-F') option given more than once\n", PROGRAM);
- }
- args_info->output_given++;
- if (args_info->output_arg) free(args_info->output_arg);
- args_info->output_arg = strdup(val);
- break;
-
- case 'E': /* Real exponentiation */
- if (args_info->exp_given) {
- fprintf(stderr, "%s: `--exp' (`-E') option given more than once\n", PROGRAM);
- }
- args_info->exp_given++;
- if (args_info->exp_given <= 1)
- args_info->exp_flag = !(args_info->exp_flag);
- break;
-
- case 'L': /* Real logarithm */
- if (args_info->log_given) {
- fprintf(stderr, "%s: `--log' (`-L') option given more than once\n", PROGRAM);
- }
- args_info->log_given++;
- if (args_info->log_given <= 1)
- args_info->log_flag = !(args_info->log_flag);
- break;
-
- case 'm': /* Real multiplication by WEIGHT */
- if (args_info->multiply_given) {
- fprintf(stderr, "%s: `--multiply' (`-m') option given more than once\n", PROGRAM);
- }
- args_info->multiply_given++;
- args_info->multiply_arg = (float)strtod(val, NULL);
- break;
-
- case 'a': /* Real addition of WEIGHT */
- if (args_info->add_given) {
- fprintf(stderr, "%s: `--add' (`-a') option given more than once\n", PROGRAM);
- }
- args_info->add_given++;
- args_info->add_arg = (float)strtod(val, NULL);
- break;
-
- case 'p': /* Set real negative weights to zero */
- if (args_info->positive_given) {
- fprintf(stderr, "%s: `--positive' (`-p') option given more than once\n", PROGRAM);
- }
- args_info->positive_given++;
- if (args_info->positive_given <= 1)
- args_info->positive_flag = !(args_info->positive_flag);
- break;
-
- case 'A': /* Exclude arc weights (default: include) */
- if (args_info->no_arcs_given) {
- fprintf(stderr, "%s: `--no-arcs' (`-A') option given more than once\n", PROGRAM);
- }
- args_info->no_arcs_given++;
- if (args_info->no_arcs_given <= 1)
- args_info->no_arcs_flag = !(args_info->no_arcs_flag);
- break;
-
- case 'f': /* Exclude final weights (default: include) */
- if (args_info->no_finals_given) {
- fprintf(stderr, "%s: `--no-finals' (`-f') option given more than once\n", PROGRAM);
- }
- args_info->no_finals_given++;
- if (args_info->no_finals_given <= 1)
- args_info->no_finals_flag = !(args_info->no_finals_flag);
- break;
-
- case 'Z': /* Include semiring-zero weights (default: exclude) */
- if (args_info->zero_given) {
- fprintf(stderr, "%s: `--zero' (`-Z') option given more than once\n", PROGRAM);
- }
- args_info->zero_given++;
- if (args_info->zero_given <= 1)
- args_info->zero_flag = !(args_info->zero_flag);
- break;
-
- case 'i': /* Select only initial state and its arcs/finality */
- if (args_info->initial_given) {
- fprintf(stderr, "%s: `--initial' (`-i') option given more than once\n", PROGRAM);
- }
- args_info->initial_given++;
- if (args_info->initial_given <= 1)
- args_info->initial_flag = !(args_info->initial_flag);
- break;
-
- case 's': /* Select only state ID and its arcs/finality (default=all) */
- if (args_info->state_given) {
- fprintf(stderr, "%s: `--state' (`-s') option given more than once\n", PROGRAM);
- }
- args_info->state_given++;
- args_info->state_arg = (int)atoi(val);
- break;
-
- case 'l': /* Select only arcs with lower-label LO (default=any) */
- if (args_info->lower_given) {
- fprintf(stderr, "%s: `--lower' (`-l') option given more than once\n", PROGRAM);
- }
- args_info->lower_given++;
- args_info->lower_arg = (int)atoi(val);
- break;
-
- case 'u': /* Select only arcs with upper-label HI (defualt=any) */
- if (args_info->upper_given) {
- fprintf(stderr, "%s: `--upper' (`-u') option given more than once\n", PROGRAM);
- }
- args_info->upper_given++;
- args_info->upper_arg = (int)atoi(val);
- break;
-
- case 0: /* Long option(s) with no short form */
- /* Print help and exit. */
- if (strcmp(olong, "help") == 0) {
- if (args_info->help_given) {
- fprintf(stderr, "%s: `--help' (`-h') option given more than once\n", PROGRAM);
- }
- clear_args(args_info);
- cmdline_parser_print_help();
- exit(EXIT_SUCCESS);
-
- }
-
- /* Print version and exit. */
- else if (strcmp(olong, "version") == 0) {
- if (args_info->version_given) {
- fprintf(stderr, "%s: `--version' (`-V') option given more than once\n", PROGRAM);
- }
- clear_args(args_info);
- cmdline_parser_print_version();
- exit(EXIT_SUCCESS);
-
- }
-
- /* Specify compression level of output file. */
- else if (strcmp(olong, "compress") == 0) {
- if (args_info->compress_given) {
- fprintf(stderr, "%s: `--compress' (`-z') option given more than once\n", PROGRAM);
- }
- args_info->compress_given++;
- args_info->compress_arg = (int)atoi(val);
- }
-
- /* Specifiy output file (default=stdout). */
- else if (strcmp(olong, "output") == 0) {
- if (args_info->output_given) {
- fprintf(stderr, "%s: `--output' (`-F') option given more than once\n", PROGRAM);
- }
- args_info->output_given++;
- if (args_info->output_arg) free(args_info->output_arg);
- args_info->output_arg = strdup(val);
- }
-
- /* Real exponentiation */
- else if (strcmp(olong, "exp") == 0) {
- if (args_info->exp_given) {
- fprintf(stderr, "%s: `--exp' (`-E') option given more than once\n", PROGRAM);
- }
- args_info->exp_given++;
- if (args_info->exp_given <= 1)
- args_info->exp_flag = !(args_info->exp_flag);
- }
-
- /* Real logarithm */
- else if (strcmp(olong, "log") == 0) {
- if (args_info->log_given) {
- fprintf(stderr, "%s: `--log' (`-L') option given more than once\n", PROGRAM);
- }
- args_info->log_given++;
- if (args_info->log_given <= 1)
- args_info->log_flag = !(args_info->log_flag);
- }
-
- /* Real multiplication by WEIGHT */
- else if (strcmp(olong, "multiply") == 0) {
- if (args_info->multiply_given) {
- fprintf(stderr, "%s: `--multiply' (`-m') option given more than once\n", PROGRAM);
- }
- args_info->multiply_given++;
- args_info->multiply_arg = (float)strtod(val, NULL);
- }
-
- /* Real addition of WEIGHT */
- else if (strcmp(olong, "add") == 0) {
- if (args_info->add_given) {
- fprintf(stderr, "%s: `--add' (`-a') option given more than once\n", PROGRAM);
- }
- args_info->add_given++;
- args_info->add_arg = (float)strtod(val, NULL);
- }
-
- /* Set real negative weights to zero */
- else if (strcmp(olong, "positive") == 0) {
- if (args_info->positive_given) {
- fprintf(stderr, "%s: `--positive' (`-p') option given more than once\n", PROGRAM);
- }
- args_info->positive_given++;
- if (args_info->positive_given <= 1)
- args_info->positive_flag = !(args_info->positive_flag);
- }
-
- /* Semiring multiplication by WEIGHT */
- else if (strcmp(olong, "times") == 0) {
- if (args_info->times_given) {
- fprintf(stderr, "%s: `--times' option given more than once\n", PROGRAM);
- }
- args_info->times_given++;
- args_info->times_arg = (float)strtod(val, NULL);
- }
-
- /* Semiring addition of WEIGHT */
- else if (strcmp(olong, "plus") == 0) {
- if (args_info->plus_given) {
- fprintf(stderr, "%s: `--plus' option given more than once\n", PROGRAM);
- }
- args_info->plus_given++;
- args_info->plus_arg = (float)strtod(val, NULL);
- }
-
- /* Set semiring-negative weights to semiring-zero */
- else if (strcmp(olong, "sr-positive") == 0) {
- if (args_info->sr_positive_given) {
- fprintf(stderr, "%s: `--sr-positive' option given more than once\n", PROGRAM);
- }
- args_info->sr_positive_given++;
- if (args_info->sr_positive_given <= 1)
- args_info->sr_positive_flag = !(args_info->sr_positive_flag);
- }
-
- /* Exclude arc weights (default: include) */
- else if (strcmp(olong, "no-arcs") == 0) {
- if (args_info->no_arcs_given) {
- fprintf(stderr, "%s: `--no-arcs' (`-A') option given more than once\n", PROGRAM);
- }
- args_info->no_arcs_given++;
- if (args_info->no_arcs_given <= 1)
- args_info->no_arcs_flag = !(args_info->no_arcs_flag);
- }
-
- /* Exclude final weights (default: include) */
- else if (strcmp(olong, "no-finals") == 0) {
- if (args_info->no_finals_given) {
- fprintf(stderr, "%s: `--no-finals' (`-f') option given more than once\n", PROGRAM);
- }
- args_info->no_finals_given++;
- if (args_info->no_finals_given <= 1)
- args_info->no_finals_flag = !(args_info->no_finals_flag);
- }
-
- /* Include semiring-zero weights (default: exclude) */
- else if (strcmp(olong, "zero") == 0) {
- if (args_info->zero_given) {
- fprintf(stderr, "%s: `--zero' (`-Z') option given more than once\n", PROGRAM);
- }
- args_info->zero_given++;
- if (args_info->zero_given <= 1)
- args_info->zero_flag = !(args_info->zero_flag);
- }
-
- /* Select only initial state and its arcs/finality */
- else if (strcmp(olong, "initial") == 0) {
- if (args_info->initial_given) {
- fprintf(stderr, "%s: `--initial' (`-i') option given more than once\n", PROGRAM);
- }
- args_info->initial_given++;
- if (args_info->initial_given <= 1)
- args_info->initial_flag = !(args_info->initial_flag);
- }
-
- /* Select only state ID and its arcs/finality (default=all) */
- else if (strcmp(olong, "state") == 0) {
- if (args_info->state_given) {
- fprintf(stderr, "%s: `--state' (`-s') option given more than once\n", PROGRAM);
- }
- args_info->state_given++;
- args_info->state_arg = (int)atoi(val);
- }
-
- /* Select only arcs with lower-label LO (default=any) */
- else if (strcmp(olong, "lower") == 0) {
- if (args_info->lower_given) {
- fprintf(stderr, "%s: `--lower' (`-l') option given more than once\n", PROGRAM);
- }
- args_info->lower_given++;
- args_info->lower_arg = (int)atoi(val);
- }
-
- /* Select only arcs with upper-label HI (defualt=any) */
- else if (strcmp(olong, "upper") == 0) {
- if (args_info->upper_given) {
- fprintf(stderr, "%s: `--upper' (`-u') option given more than once\n", PROGRAM);
- }
- args_info->upper_given++;
- args_info->upper_arg = (int)atoi(val);
- }
-
- else {
- fprintf(stderr, "%s: unknown long option '%s'.\n", PROGRAM, olong);
- return (EXIT_FAILURE);
- }
- break;
-
- case '?': /* Invalid Option */
- fprintf(stderr, "%s: unknown option '%s'.\n", PROGRAM, olong);
- return (EXIT_FAILURE);
-
-
- default: /* bug: options not considered. */
- fprintf (stderr, "%s: option unknown: %c\n", PROGRAM, oshort);
- abort ();
- } /* switch */
- return 0;
-}
-
-
-/* Initialize options not yet given from environmental defaults */
-void
-cmdline_parser_envdefaults(struct gengetopt_args_info *args_info)
-{
-
-
- return;
-}
-
-
-/* Load option values from an .rc file */
-void
-cmdline_parser_read_rcfile(const char *filename,
- struct gengetopt_args_info *args_info,
- int user_specified)
-{
- char *fullname;
- FILE *rcfile;
-
- if (!filename) return; /* ignore NULL filenames */
-
-#if defined(HAVE_GETUID) && defined(HAVE_GETPWUID)
- if (*filename == '~') {
- /* tilde-expansion hack */
- struct passwd *pwent = getpwuid(getuid());
- if (!pwent) {
- fprintf(stderr, "%s: user-id %d not found!\n", PROGRAM, getuid());
- return;
- }
- if (!pwent->pw_dir) {
- fprintf(stderr, "%s: home directory for user-id %d not found!\n", PROGRAM, getuid());
- return;
- }
- fullname = (char *)malloc(strlen(pwent->pw_dir)+strlen(filename));
- strcpy(fullname, pwent->pw_dir);
- strcat(fullname, filename+1);
- } else {
- fullname = strdup(filename);
- }
-#else /* !(defined(HAVE_GETUID) && defined(HAVE_GETPWUID)) */
- fullname = strdup(filename);
-#endif /* defined(HAVE_GETUID) && defined(HAVE_GETPWUID) */
-
- /* try to open */
- rcfile = fopen(fullname,"r");
- if (!rcfile) {
- if (user_specified) {
- fprintf(stderr, "%s: warning: open failed for rc-file '%s': %s\n",
- PROGRAM, fullname, strerror(errno));
- }
- }
- else {
- cmdline_parser_read_rc_stream(rcfile, fullname, args_info);
- }
-
- /* cleanup */
- if (fullname != filename) free(fullname);
- if (rcfile) fclose(rcfile);
-
- return;
-}
-
-
-/* Parse option values from an .rc file : guts */
-#define OPTPARSE_GET 32
-void
-cmdline_parser_read_rc_stream(FILE *rcfile,
- const char *filename,
- struct gengetopt_args_info *args_info)
-{
- char *optname = (char *)malloc(OPTPARSE_GET);
- char *optval = (char *)malloc(OPTPARSE_GET);
- size_t onsize = OPTPARSE_GET;
- size_t ovsize = OPTPARSE_GET;
- size_t onlen = 0;
- size_t ovlen = 0;
- int lineno = 0;
- char c;
-
-#ifdef cmdline_parser_DEBUG
- fprintf(stderr, "cmdline_parser_read_rc_stream('%s'):\n", filename);
-#endif
-
- while ((c = fgetc(rcfile)) != EOF) {
- onlen = 0;
- ovlen = 0;
- lineno++;
-
- /* -- get next option-name */
- /* skip leading space and comments */
- if (isspace(c)) continue;
- if (c == '#') {
- while ((c = fgetc(rcfile)) != EOF) {
- if (c == '\n') break;
- }
- continue;
- }
-
- /* parse option-name */
- while (c != EOF && c != '=' && !isspace(c)) {
- /* re-allocate if necessary */
- if (onlen >= onsize-1) {
- char *tmp = (char *)malloc(onsize+OPTPARSE_GET);
- strcpy(tmp,optname);
- free(optname);
-
- onsize += OPTPARSE_GET;
- optname = tmp;
- }
- optname[onlen++] = c;
- c = fgetc(rcfile);
- }
- optname[onlen++] = '\0';
-
-#ifdef cmdline_parser_DEBUG
- fprintf(stderr, "cmdline_parser_read_rc_stream('%s'): line %d: optname='%s'\n",
- filename, lineno, optname);
-#endif
-
- /* -- get next option-value */
- /* skip leading space */
- while ((c = fgetc(rcfile)) != EOF && isspace(c)) {
- ;
- }
-
- /* parse option-value */
- while (c != EOF && c != '\n') {
- /* re-allocate if necessary */
- if (ovlen >= ovsize-1) {
- char *tmp = (char *)malloc(ovsize+OPTPARSE_GET);
- strcpy(tmp,optval);
- free(optval);
- ovsize += OPTPARSE_GET;
- optval = tmp;
- }
- optval[ovlen++] = c;
- c = fgetc(rcfile);
- }
- optval[ovlen++] = '\0';
-
- /* now do the action for the option */
- if (cmdline_parser_parse_option('\0',optname,optval,args_info) != 0) {
- fprintf(stderr, "%s: error in file '%s' at line %d.\n", PROGRAM, filename, lineno);
-
- }
- }
-
- /* cleanup */
- free(optname);
- free(optval);
-
- return;
-}