1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-20 14:20:06 +02:00
Leland Lucius 15b9bb96cd Update nyquist to SVN r331 (r3.16+)
------------------------------------------------------------------------
   r331 | rbd | 2020-10-13 12:40:12 -0500 (Tue, 13 Oct 2020) | 2 lines

   Also forgot to install NyquistWords.txt

   ------------------------------------------------------------------------
   r330 | rbd | 2020-10-13 12:34:06 -0500 (Tue, 13 Oct 2020) | 2 lines

   Forgot to move nyquistman.pdf from docsrc/s2h to release

   ------------------------------------------------------------------------
   r329 | rbd | 2020-10-13 11:32:33 -0500 (Tue, 13 Oct 2020) | 2 lines

   Updated some version numbers for 3.16.

   ------------------------------------------------------------------------
   r328 | rbd | 2020-10-13 11:20:52 -0500 (Tue, 13 Oct 2020) | 2 lines

   Fixed NyquistIDE antialiasing for plot text, fix format of message.

   ------------------------------------------------------------------------
   r327 | rbd | 2020-10-12 21:01:53 -0500 (Mon, 12 Oct 2020) | 2 lines

   Fixed a couple of format problems in manual. This version of Nyquist has been tested wtih macOS, Linux, 32&64-bit Windows.

   ------------------------------------------------------------------------
   r326 | rbd | 2020-10-12 20:21:38 -0500 (Mon, 12 Oct 2020) | 1 line

   Modified WIN32 32-bit XLisp to use 64-bit FIXNUMs. This allows XLisp and Nyquist to handle big sounds even on 32-bit machines. Probably at some cost, but inner loops are mostly float and int32, and the Nyquist release is 64-bit anyway. Maybe we'll have to run some benchmarks on Audacity, which is still 32-bit on Windows.
   ------------------------------------------------------------------------
   r325 | rbd | 2020-10-12 13:16:57 -0500 (Mon, 12 Oct 2020) | 1 line

   Win64 passes bigfiletest.lsp now. This version should work on all 64-bit systems now. These changes untested on Linux and macOS.
   ------------------------------------------------------------------------
   r324 | rbd | 2020-10-11 21:31:53 -0500 (Sun, 11 Oct 2020) | 2 lines

   I couldn't free enough space on my linux box, so I adjusted the bigfiletest to write 8-bit ulaw. It's still >4GB and >4G samples. Works on Linux.

   ------------------------------------------------------------------------
   r323 | rbd | 2020-10-11 19:41:25 -0500 (Sun, 11 Oct 2020) | 2 lines

   Missing file from last commit.

   ------------------------------------------------------------------------
   r322 | rbd | 2020-10-11 19:36:08 -0500 (Sun, 11 Oct 2020) | 1 line

   Found another case where WIN64 needs int64_t instead of long for sample count.
   ------------------------------------------------------------------------
   r321 | rbd | 2020-10-11 19:33:25 -0500 (Sun, 11 Oct 2020) | 3 lines

   Fixed s-save to	handle optional	and keyword parameters (which should never have	been mixed in the first	place).	Documentation cleanup - should be final for this version.

   ------------------------------------------------------------------------
   r320 | rbd | 2020-10-11 14:44:37 -0500 (Sun, 11 Oct 2020) | 2 lines

   Fixes to handle IRCAM sound format and tests for big file io working on macOS.

   ------------------------------------------------------------------------
   r319 | rbd | 2020-10-10 21:31:58 -0500 (Sat, 10 Oct 2020) | 2 lines

   Changes for linux and to avoid compiler warnings on linux.

   ------------------------------------------------------------------------
   r318 | rbd | 2020-10-10 20:50:23 -0500 (Sat, 10 Oct 2020) | 1 line

   This is the test used for Win64 version.
   ------------------------------------------------------------------------
   r317 | rbd | 2020-10-10 20:34:34 -0500 (Sat, 10 Oct 2020) | 1 line

   This version works on Win64. Need to test changes on macOS and linux.
   ------------------------------------------------------------------------
   r316 | rbd | 2020-10-10 19:59:15 -0500 (Sat, 10 Oct 2020) | 2 lines

   PWL changes to avoid compiler warning.

   ------------------------------------------------------------------------
   r315 | rbd | 2020-10-10 19:34:04 -0500 (Sat, 10 Oct 2020) | 2 lines

   A few more changes for 64-bit sample counts on Win64

   ------------------------------------------------------------------------
   r314 | rbd | 2020-10-10 13:19:42 -0500 (Sat, 10 Oct 2020) | 2 lines

   Fixed int64_t declaration in gate.alg

   ------------------------------------------------------------------------
   r313 | rbd | 2020-10-10 12:07:40 -0500 (Sat, 10 Oct 2020) | 2 lines

   Fixes to gate for long sounds

   ------------------------------------------------------------------------
   r312 | rbd | 2020-10-10 11:47:29 -0500 (Sat, 10 Oct 2020) | 2 lines

   Fixed sound_save types for intgen

   ------------------------------------------------------------------------
   r311 | rbd | 2020-10-10 11:09:01 -0500 (Sat, 10 Oct 2020) | 2 lines

   Fixed a 64-bit sample count problem in siosc.alg

   ------------------------------------------------------------------------
   r310 | rbd | 2020-10-10 11:03:12 -0500 (Sat, 10 Oct 2020) | 2 lines

   Fixed sndmax to handle 64-bit sample counts.

   ------------------------------------------------------------------------
   r309 | rbd | 2020-10-10 10:57:04 -0500 (Sat, 10 Oct 2020) | 2 lines

   Forgot to re-translate all tran/*.alg files with fix for int64 cast to int32. This version compiles on macOS and ready for test on Win64.

   ------------------------------------------------------------------------
   r308 | rbd | 2020-10-10 10:16:05 -0500 (Sat, 10 Oct 2020) | 2 lines

   Everything seems to compile and run on macOS now. Moving changes to Windows for test.

   ------------------------------------------------------------------------
   r307 | rbd | 2020-10-10 09:23:45 -0500 (Sat, 10 Oct 2020) | 1 line

   Added casts to avoid compiler warnings and to review changes to support 64-bit sample counts on Windows. Still not complete, and waiting to regenerate and compile tran directory code after updates to translation code that will insert more casts.
   ------------------------------------------------------------------------
   r306 | rbd | 2020-10-09 21:55:15 -0500 (Fri, 09 Oct 2020) | 2 lines

   Rebuilt seqfnint.c from header files.

   ------------------------------------------------------------------------
   r305 | rbd | 2020-10-09 21:53:33 -0500 (Fri, 09 Oct 2020) | 1 line

   Changed some FIXNUMS to LONG to avoid compiler warnings in seqfnint.c
   ------------------------------------------------------------------------
   r304 | rbd | 2020-10-09 21:44:03 -0500 (Fri, 09 Oct 2020) | 2 lines

   I discovered forgotten regression-test.lsp and added test that requires 64-bit sample counts to pass. Fixed a few bugs revealed by running the type-checking regression tests.

   ------------------------------------------------------------------------
   r303 | rbd | 2020-10-09 12:28:58 -0500 (Fri, 09 Oct 2020) | 2 lines

   Changes for 64-bit sample counts broke mult-channel s-save. Fixed in the commit for macOS.

   ------------------------------------------------------------------------
   r302 | rbd | 2020-10-09 10:03:39 -0500 (Fri, 09 Oct 2020) | 2 lines

   Changed snd-play to return samples computed and used that to make a test for computing long sounds that would overflow 32-bit length counts.

   ------------------------------------------------------------------------
   r301 | rbd | 2020-10-09 09:11:26 -0500 (Fri, 09 Oct 2020) | 2 lines

   corrected mistake in delaycv.alg and re-translated

   ------------------------------------------------------------------------
   r300 | rbd | 2020-10-09 09:09:06 -0500 (Fri, 09 Oct 2020) | 2 lines

   Fix to delaycv.alg -- "s" changed to "input" to avoid matching "s" in "sample_type".

   ------------------------------------------------------------------------
   r299 | rbd | 2020-10-09 09:03:33 -0500 (Fri, 09 Oct 2020) | 4 lines

   To avoid compiler warnings, XLisp interfaces to C int and long are now
   specified as LONG rather than FIXNUM, and the stubs that call the C
   functions cast FIXNUMs from XLisp into longs before calling C functions.

   ------------------------------------------------------------------------
   r298 | rbd | 2020-10-08 22:20:26 -0500 (Thu, 08 Oct 2020) | 2 lines

   This commit has many more fixes to handle long (64-bit) sounds, including a lot of fixes for warnings by Visual Studio assigning int64_t to long (works on macOS, doesn't work on VS). This was compiled and tested on macOS, and even computed a 27.1-hour sound using OSC, LP, SUM and MULT (haven't tested I/O yet).

   ------------------------------------------------------------------------
   r297 | rbd | 2020-10-07 13:04:02 -0500 (Wed, 07 Oct 2020) | 2 lines

   This is a major cleanup. It started with the goal of changing long to int64_t for sample counts so that on 64-bit windows, where long is only 32-bits, the sample counts would nevertheless be 64-bit allowing long sounds, which was a limitation for long recordings in Audacity. Since I was using compiler warnings to track possible loss-of-precision conversions from 64-bit sample counts, and there were *many* warnings, I started cleaning up *all* the warnings and ended up with a very large set of changes, including "modernizing" C declarations that date back to XLisp and CMU MIDI Toolkit code and were never changed. This version runs all the examples.sal code on macOS, but will surely have problems on Windows and Linux given the number of changes.

   ------------------------------------------------------------------------
   r296 | rbd | 2020-10-06 13:34:20 -0500 (Tue, 06 Oct 2020) | 2 lines

   More changes from long to int64_t for sample counts.

   ------------------------------------------------------------------------
   r295 | rbd | 2020-10-06 11:53:49 -0500 (Tue, 06 Oct 2020) | 2 lines

   More work on using 64-bit sample counts. Changed MAX_STOP from 32-bit to 64-bit limit.

   ------------------------------------------------------------------------
   r294 | rbd | 2020-10-06 11:48:05 -0500 (Tue, 06 Oct 2020) | 2 lines

   Made some changes so that sample counts are int64_t (for windows) instead of long to support sample counts above 31 bits.

   ------------------------------------------------------------------------
   r293 | rbd | 2020-10-04 21:30:55 -0500 (Sun, 04 Oct 2020) | 2 lines

   Fixed a few minor things for Linux and tested on Linux.

   ------------------------------------------------------------------------
   r292 | rbd | 2020-10-04 21:00:28 -0500 (Sun, 04 Oct 2020) | 2 lines

   Update extensions: all are minor changes.

   ------------------------------------------------------------------------
   r291 | rbd | 2020-09-24 13:59:31 -0500 (Thu, 24 Sep 2020) | 2 lines

   New implementation of seq and seqrep, added get-real-time, documented get-real-time, fixed examples.sal and examples.lsp which are now in lib rather than extensions (so they are now back in the basic installation), other cleanup.

   ------------------------------------------------------------------------
   r290 | rbd | 2020-08-16 16:24:52 -0500 (Sun, 16 Aug 2020) | 2 lines

   Fixed bug in snd-gate, revised GATE and NOISE-GATE to handle multi-channel sound. RMS now handles multi-channel input. S-AVG added to take multichannel input (but not used, because RMS could not be written without making SND-SRATE convert multichannel sound to vector of floats. That seems to be going toward a fully vectorized model. Not going there for now.

   ------------------------------------------------------------------------
   r289 | rbd | 2020-07-09 16:27:45 -0500 (Thu, 09 Jul 2020) | 2 lines

   Added GET-REAL-TIME function to XLISP. May not work yet on Windows. Various fixes for compiler warnings. I noticed FLAC doesn't work (I guess it never did) and I cannot figure out how this even links because flac_min seems to be undefined. Something to look at later.
2021-01-27 23:45:25 -06:00

478 lines
16 KiB
C
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/* cmdline.c -- command line parsing routines */
/* Copyright 1989 Carnegie Mellon University */
/*
* This module is designed to allow various modules to scan (and rescan)
* the command line for applicable arguments. The goal is to hide as
* much information about switches and their names as possible so that
* switches become more consistent across applications and so that the
* author of an application need not do a lot of work to provide numerous
* options. Instead, each module scans the command line for its own
* arguments.
*
* Command lines are of the following form:
* command -s1 -s2 opt2 -s3 arg1 arg2 -s4 opt4 arg3
* Note that there are three kinds of command line parameters:
* (1) A Switch is a "-" followed by a name, e.g. "-s1"
* (2) An Option is a Switch followed by a space and name, e.g. "-s2 opt2"
* (3) An Argument is a name by itself, e.g. "arg1"
* Note also that a switch followed by an argument looks just like an
* option, so a list of valid option names is necessary to disambiguate.
*
* Long names are good for readability, but single character abbreviations
* are nice for experienced users. cmdline.c allows single character
* abbreviations provided that they are unambiguous. These are
* recognized with no extra work by the programmer. If an
* isolated '?' is encountered in the command line, then all of
* the options and switches are printed as help and for debugging.
*
* Given that we must tell this module about option names and switch
* names, how should we do it? We can't wait until modules are
* initialized, since often modules want to read the command line
* at initialization time. In the original implementation, the
* main program was supposed to provide names for the whole program,
* but this violates modularity: when an option is added to a module,
* the main program has to be modified too. This is a real pain when
* different machines support different options and you want to have
* a single machine-independent main program. The solution is to
* have the main program import strings describing the options and
* switches used by each module. These are passed into cmdline.c
* before initialization of other modules is begun.
*
* A main program that uses cmdline.c should do the following:
* call cl_syntax(s) for each module's option/switch string.
* The string s should have the following format:
* "opt1<o>description;opt2<o>description;...;switch1<s>description;..."
* where opt1 and opt2 are option names (without the preceding "-"), and
* switch1 is a switch name. The <o> and <s> indicate whether the
* name is an option or a switch. The descriptions are arbitrary strings
* (without semicolons) that are printed out for the user when "?"
* is typed on the command line.
*
* After calling cl_syntax, main() should call
* cl_init(argv, argc)
* cl_init will report an error (to STDERR) if it finds any illegal
* switch or option names in argv, and help will be printed if "?"
* is found in argv. If cl_init returns false, then the user has been
* given an error message or help, and main should probably exit.
*
* Afterward, switches, options, and arguments can be accessed by
* calling cl_switch, cl_option, and cl_arg. If cl_switch or cl_option
* is called with a switch name that was not mentioned in the call to
* cl_init, an error will result. This indicates that the application
* author omitted a valid switch or option name when calling cl_init.
* This is an error because the full set of names is needed for error
* checking and to distinguish arguments from options.
*
*/
/*****************************************************************************
* Change Log
* Date | Change
*-----------+-----------------------------------------------------------------
* 13-Jun-86 | Created Change Log
* 6-Aug-86 | Modified for Lattice 3.0 -- use "void" to type some routines
* 20-Sep-89 | Redesigned the interface, adding cl_syntax call.
* 2-Apr-91 | JDW : further changes
* 27-Dec-93 | "@file" as first arg reads command line args from file
* 11-Mar-94 | PLu: Add private to cl_search() definition.
* 28-Apr-03 | DM: true->TRUE, false->FALSE
*****************************************************************************/
/* stdlib.h not on PMAX */
#ifndef mips
#include "stdlib.h"
#endif
#include "stdio.h"
#include "cext.h"
#include "userio.h"
#include "cmdline.h"
#include "ctype.h"
#include "string.h"
/* this should really be defined in security.h, but it is in xlisp.h.
* I don't want to add an xlisp dependency here, nor do I want to
* create security.h since that's not how xlisp does things.
* The C++ linker will type check so this is at least type safe.
*/
int ok_to_open(const char *filename, const char *mode);
#define syntax_max 10 /* allow for 10 syntax strings */
private char *syntax[syntax_max];
private int n_syntax = 0; /* number of strings so far */
private char **argv; /* command line argument vector */
private int argc; /* length of argv */
private boolean cl_rdy = FALSE; /* set to TRUE when initialized */
#define cl_OPT 1
#define cl_SW 2
#define cl_INIT 3
#define cl_ARG 4
/*****************************************************************************
* Routines local to this module
*****************************************************************************/
private char *cl_search(char *name, int opt_sw, int n);
private int find_string(char *s, boolean *abbr);
private void indirect_command(char *filename, char *oldarg0);
private void ready_check(void);
/****************************************************************
* cl_arg
* Inputs:
* n: the index of the arg needed
* Results:
* pointer to the nth arg, or NULL if none exists
* arg 0 is the command name
*****************************************************************/
char *cl_arg(n)
int n;
{
return (n <= 0 ? argv[0] :
cl_search((char *)NULL, cl_ARG, n));
}
/* cl_help -- print help from syntax strings */
/**/
void cl_help()
{
register int i, j;
int count = 0; /* see if there are any switches or flags */
for (i = 0; i < n_syntax; i++) {
register char *ptr = syntax[i];
register char c = *ptr++;
while (c != EOS) {
while (c != EOS && !(isalnum(c))) c = *ptr++;
if (c != EOS) {
count++;
gprintf(TRANS, "-");
j = 1;
while (c != EOS && c != '<') {
gprintf(TRANS, "%c", c);
c = *ptr++;
j++;
}
if (c != EOS) {
c = *ptr++;
if (c == 'o') {
gprintf(TRANS, " xxx");
j += 4;
}
}
/* attempt to tab */
do {
gprintf(TRANS, " ");
} while (j++ < 16);
while (c != EOS && c != '>') c = *ptr++;
if (c != EOS) c = *ptr++;
while (c != EOS && c != ';') {
gprintf(TRANS, "%c", c);
c = *ptr++;
}
gprintf(TRANS, "\n");
}
}
}
if (!count) gprintf(TRANS, "No switches or options exist.\n");
}
/*****************************************************************************
* cl_init
* Inputs:
* char *switches[]: array of switch names
* int nsw: number of switch names
* char *options[]: array of option names
* int nopt: number of option names
* char *av: array of command line fields (argv)
* int ac: number of command line fields (argc)
* Effect:
* Checks that all command line entries are valid.
* Saves info for use by other routines.
* Returns:
* TRUE if syntax checks OK, otherwise false
*****************************************************************************/
boolean cl_init(char *av[], int ac)
{
argv = av;
argc = ac;
/* check for help request */
if (argc == 2 && strcmp(argv[1], "?") == 0) {
cl_help();
return FALSE; /* avoid cl_search which would complain about "?" */
}
/* check for indirection */
if (argc == 2 && *(argv[1]) == '@') {
/* read new args from file */
indirect_command(av[1] + 1, av[0]);
}
/* check command line syntax: */
cl_rdy = TRUE;
return (cl_rdy = (cl_search("true", cl_INIT, 0) != NULL));
}
/****************************************************************
* cl_int_option
* Inputs:
* char *name: name of option
* long default: default value for option
* Result:
* returns long encoding of the option, deflt if none
* Implementation:
* call cl_option and sscanf result
*****************************************************************/
long cl_int_option(name, deflt)
char *name;
long deflt;
{
char *opt = cl_option(name);
if (opt) {
if (sscanf(opt, "%ld", &deflt) != 1) {
gprintf(TRANS, "Warning: option %s %s not an integer, ignored\n",
name, opt);
}
}
return deflt;
}
/****************************************************************
* cl_search
* Inputs:
* char *name: name of field, must be non-null if opt_sw == cl_INIT
* int opt_sw: option, switch, init, or arg
* int n: argument number (if opt_sw is cl_ARG)
* Result:
* returns pointer to option value/switch if one exists, otherwise null
* Implementation:
* parse the command line until name or arg is found
* see if the option is followed by a string that does
* not start with "-"
*****************************************************************/
private char *cl_search(char *name, int opt_sw, int n)
{
register int i = 1; /* index into command line */
boolean abbr;
boolean result = TRUE;
ready_check();
/* parse command line: */
while (i < argc) {
register char *arg = argv[i];
/* arguments that start with '-' should be quoted and quotes must
be removed by the application
*/
if (*arg == '-') {
int arg_type = find_string(arg + 1, &abbr);
if (arg_type == cl_OPT) {
i += 1; /* skip name and option */
/* don't look for '-' because the option might be a
* negative number
*/
if (i >= argc /* || *arg == '-' */) {
if (opt_sw == cl_INIT) {
gprintf(ERROR, "missing argument after %s\n", arg);
result = FALSE;
}
} else if (opt_sw == cl_OPT &&
(strcmp(arg + 1, name) == 0 ||
(abbr && *(arg + 1) == name[0]))) {
return argv[i];
}
} else if (arg_type == cl_SW) {
if (opt_sw == cl_SW &&
(strcmp(arg + 1, name) == 0 ||
(abbr && *(arg + 1) == name[0])))
return arg;
} else if (opt_sw == cl_INIT) {
gprintf(ERROR, "invalid switch: %s\n", arg);
result = FALSE;
}
} else if (opt_sw == cl_ARG) {
if (n == 1) return arg;
n--;
}
i++; /* skip to next field */
}
if (opt_sw == cl_INIT) {
/* return name or NULL to represent TRUE or FALSE */
return (result ? name : NULL);
}
return NULL;
}
/****************************************************************
* cl_option
* Inputs:
* char *name: option name
* Outputs:
* returns char *: the option string if found, otherwise null
****************************************************************/
char *cl_option(name)
char *name;
{
return cl_search(name, cl_OPT, 0);
}
/****************************************************************
* cl_switch
* Inputs:
* char *name: switch name
* Outputs:
* boolean: TRUE if switch found
****************************************************************/
boolean cl_switch(name)
char *name;
{
return (boolean)(cl_search(name, cl_SW, 0) != NULL);
}
/* cl_syntax -- install a string specifying options and switches */
/**/
boolean cl_syntax(char *s)
{
if (n_syntax < syntax_max) {
syntax[n_syntax++] = s;
return TRUE;
} else {
gprintf(ERROR, "cl_syntax: out of room\n");
return FALSE;
}
}
/****************************************************************
* find_string
* Inputs:
* char *s: string to find, terminated by any non-alphanumeric
* boolean *abbr: set TRUE if s is an abbreviation, otherwise false
* Effect:
* Looks for s in syntax strings
* Returns:
* 0 = FALSE = not found, 1 = cl_OPT = option, 2 = cl_SW = switch
*****************************************************************/
private int find_string(char *s, boolean *abbr)
{
int found_it = FALSE;
int i;
*abbr = FALSE;
for (i = 0; i < n_syntax; i++) { /* loop through strings */
register char *syntax_ptr = syntax[i];
while (*syntax_ptr != EOS) {
register char *s_ptr = s;
while (*syntax_ptr != EOS &&
!(isalnum(*syntax_ptr))) syntax_ptr++;
while (*s_ptr != EOS && (*s_ptr++ == *syntax_ptr))
syntax_ptr++; /* only increment if there's a match */
if (!(isalnum(*s_ptr)) && *syntax_ptr == '<') {
syntax_ptr++; /* advance to the type field */
if (*syntax_ptr == 's') return cl_SW;
if (*syntax_ptr != 'o')
gprintf(ERROR,
"(internal error) bad cl_syntax string: %s\n",
syntax[i]);
return cl_OPT;
}
/* no match, so go to next */
while (*syntax_ptr != ';' && *syntax_ptr != EOS) syntax_ptr++;
if (*syntax_ptr == ';') syntax_ptr++;
}
}
/* no match, maybe there is a single character match */
if (s[0] == EOS || s[1] != EOS) return FALSE;
for (i = 0; i < n_syntax; i++) { /* loop through strings */
char *syntax_ptr = syntax[i];
while (*syntax_ptr != EOS) {
while (*syntax_ptr != EOS &&
!(isalnum(*syntax_ptr))) syntax_ptr++;
if (s[0] == *syntax_ptr) {
if (found_it) return FALSE; /* ambiguous */
/* else, find the type */
while (*syntax_ptr != '<' && *syntax_ptr != EOS)
syntax_ptr++;
syntax_ptr++;
if (*syntax_ptr == 's') found_it = cl_SW;
else if (*syntax_ptr == 'o') found_it = cl_OPT;
else return FALSE; /* error in string syntax */
}
/* no match, so go to next */
while (*syntax_ptr != ';' && *syntax_ptr != EOS) syntax_ptr++;
if (*syntax_ptr == ';') syntax_ptr++;
}
}
if (found_it) *abbr = TRUE;
return found_it;
}
/* get_arg -- get an argument from a file */
/**/
boolean get_arg(FILE *file, char *arg)
{
int c;
while ((c = getc(file)) != EOF && isspace(c)) ;
if (c == EOF) return FALSE;
ungetc(c, file);
while ((c = getc(file)) != EOF && !isspace(c)) {
*arg++ = c;
}
*arg = 0;
return TRUE;
}
/* indirect_command -- get argv, argc from a file */
/**/
private void indirect_command(char *filename, char *oldarg0)
{
FILE *argfile = NULL;
if (ok_to_open(filename, "r"))
argfile = fopen(filename, "r");
if (!argfile) {
argv = (char **) malloc(sizeof(char *));
argv[0] = oldarg0;
argc = 1;
} else {
int i = 1;
char arg[100];
while (get_arg(argfile, arg)) i++;
fclose(argfile);
argfile = fopen(filename, "r");
argv = (char **) malloc(sizeof(char *) * i);
argv[0] = oldarg0;
argc = i;
i = 1;
while (get_arg(argfile, arg)) {
argv[i] = (char *) malloc(strlen(arg) + 1);
strcpy(argv[i], arg);
i++;
}
fclose(argfile);
}
}
/****************************************************************
* ready_check
* Effect:
* Halt program if cl_rdy is not true.
*****************************************************************/
private void ready_check(void)
{
if (!cl_rdy) {
gprintf(ERROR,
"Internal error: cl_init was not called, see cmdline.c\n");
EXIT(1);
}
}