remove more old, unused files

This commit is contained in:
Chet Ramey
2023-03-28 15:54:06 -04:00
parent 57d4dc15ff
commit 1efe6d6b69
42 changed files with 0 additions and 61452 deletions
-31
View File
@@ -1,31 +0,0 @@
The version of bash in this directory has been compiled on the
following systems:
By chet:
SunOS 4.1.4
SunOS 5.5
BSDI BSD/OS 2.1
FreeBSD 2.2
NetBSD 1.2
AIX 4.2
AIX 4.1.4
HP/UX 9.05, 10.01, 10.10, 10.20
Linux 2.0.29 (libc 5.3.12)
Linux 2.0.4 (libc 5.3.12)
By other testers:
SCO ODT 2.0
SCO 3.2v5.0, 3.2v4.2
SunOS 5.3
SunOS 5.5
BSD/OS 2.1
FreeBSD 2.2
SunOS 4.1.3
Irix 5.3
Irix 6.2
Linux 2.0 (unknown distribution)
Digital OSF/1 3.2
GNU Hurd 0.1
SVR4.2
File diff suppressed because it is too large Load Diff
-14
View File
@@ -1,14 +0,0 @@
SRCS= main.c parse.y make.c copy.c aux.c
OBJS= main.o parse.o make.o copy.o aux.o
PROG= parse
AUX= ../../../sun4/error.o
CFLAGS= -g -I. -I../.. -I. -DTEST -Dalloca=__builtin_alloca
LDFLAGS= -g
$(PROG): $(OBJS)
$(CC) $(LDFLAGS) -o $@ $(OBJS) $(AUX) $(LIBS)
parse.o: parse.y
-231
View File
@@ -1,231 +0,0 @@
#include <stdio.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/param.h>
#include "filecntl.h"
#include "shell.h"
#include <strings.h>
char *
xmalloc (size)
int size;
{
register char *temp = (char *)malloc (size);
if (!temp)
fatal_error ("Out of virtual memory!");
return (temp);
}
char *
xrealloc (pointer, size)
register char *pointer;
int size;
{
char *temp;
if (!pointer)
temp = (char *)xmalloc (size);
else
temp = (char *)realloc (pointer, size);
if (!temp)
fatal_error ("Out of virtual memory!");
return (temp);
}
/* Reverse the chain of structures in LIST. Output the new head
of the chain. You should always assign the output value of this
function to something, or you will lose the chain. */
GENERIC_LIST *
reverse_list (list)
register GENERIC_LIST *list;
{
register GENERIC_LIST *next, *prev = (GENERIC_LIST *)NULL;
while (list) {
next = list->next;
list->next = prev;
prev = list;
list = next;
}
return (prev);
}
/* Return the number of elements in LIST, a generic list. */
int
list_length (list)
register GENERIC_LIST *list;
{
register int i;
for (i = 0; list; list = list->next, i++);
return (i);
}
/* Delete the element of LIST which satisfies the predicate function COMPARER.
Returns the element that was deleted, so you can dispose of it, or -1 if
the element wasn't found. COMPARER is called with the list element and
then ARG. Note that LIST contains the address of a variable which points
to the list. You might call this function like this:
SHELL_VAR *elt = delete_element (&variable_list, check_var_has_name, "foo");
dispose_variable (elt);
*/
GENERIC_LIST *
delete_element (list, comparer, arg)
GENERIC_LIST **list;
Function *comparer;
{
register GENERIC_LIST *prev = (GENERIC_LIST *)NULL;
register GENERIC_LIST *temp = *list;
while (temp) {
if ((*comparer) (temp, arg)) {
if (prev) prev->next = temp->next;
else *list = temp->next;
return (temp);
}
prev = temp;
temp = temp->next;
}
return ((GENERIC_LIST *)-1);
}
/* Find NAME in ARRAY. Return the index of NAME, or -1 if not present.
ARRAY shoudl be NULL terminated. */
int
find_name_in_list (name, array)
char *name, *array[];
{
int i;
for (i=0; array[i]; i++)
if (strcmp (name, array[i]) == 0)
return (i);
return (-1);
}
/* Return the length of ARRAY, a NULL terminated array of char *. */
int
array_len (array)
register char **array;
{
register int i;
for (i=0; array[i]; i++);
return (i);
}
/* Free the contents of ARRAY, a NULL terminated array of char *. */
void
free_array (array)
register char **array;
{
register int i = 0;
if (!array) return;
while (array[i])
free (array[i++]);
free (array);
}
/* Allocate and return a new copy of ARRAY and its contents. */
char **
copy_array (array)
register char **array;
{
register int i;
int len;
char **new_array;
len = array_len (array);
new_array = (char **)xmalloc ((len + 1) * sizeof (char *));
for (i = 0; array[i]; i++)
new_array[i] = savestring (array[i]);
new_array[i] = (char *)NULL;
return (new_array);
}
/* Append LIST2 to LIST1. Return the header of the list. */
GENERIC_LIST *
list_append (head, tail)
GENERIC_LIST *head, *tail;
{
register GENERIC_LIST *t_head = head;
if (!t_head)
return (tail);
while (t_head->next) t_head = t_head->next;
t_head->next = tail;
return (head);
}
#include <stdio.h>
#ifndef NULL
#define NULL 0x0
#endif
#if defined (ibm032)
/*
* Most vanilla 4.3 (not 4.3-tahoe) sites lack vfprintf.
* Here is the one from 4.3-tahoe (it is freely redistributable).
*
* Beware! Don't trust the value returned by either of these functions; it
* seems that pre-4.3-tahoe implementations of _doprnt () return the first
* argument, i.e. a char *. Besides, _doprnt () is incorrectly documented
* in the 4.3 BSD manuals, anyway (it's wrong in SunOS 3.5 also, but they
* have the v*printf functions (incorrectly documented (vprintf), but they
* are present)).
*/
#include <varargs.h>
int
vfprintf (iop, fmt, ap)
FILE *iop;
char *fmt;
va_list ap;
{
int len;
char localbuf[BUFSIZ];
if (iop->_flag & _IONBF)
{
iop->_flag &= ~_IONBF;
iop->_ptr = iop->_base = localbuf;
len = _doprnt (fmt, ap, iop);
(void) fflush (iop);
iop->_flag |= _IONBF;
iop->_base = NULL;
iop->_bufsiz = 0;
iop->_cnt = 0;
}
else
len = _doprnt (fmt, ap, iop);
return (ferror (iop) ? EOF : len);
}
/*
* Ditto for vsprintf
*/
int
vsprintf (str, fmt, ap)
char *str, *fmt;
va_list ap;
{
FILE f;
int len;
f._flag = _IOWRT+_IOSTRG;
f._ptr = str;
f._cnt = 32767;
len = _doprnt (fmt, ap, &f);
*f._ptr = 0;
return (len);
}
#endif /* ibm032 */
-179
View File
@@ -1,179 +0,0 @@
/* command.h -- The structures used internally to represent commands, and
the extern declarations of the functions used to create them. */
#if !defined (_COMMAND_H)
#define _COMMAND_H
/* Instructions describing what kind of thing to do for a redirection. */
enum r_instruction {
r_output_direction, r_input_direction, r_inputa_direction,
r_appending_to, r_reading_until, r_duplicating_input,
r_duplicating_output, r_deblank_reading_until, r_close_this,
r_err_and_out, r_input_output, r_output_force,
r_duplicating_input_word, r_duplicating_output_word
};
/* Command Types: */
enum command_type { cm_for, cm_case, cm_while, cm_if, cm_simple,
cm_connection, cm_function_def, cm_until, cm_group };
/* A structure which represents a word. */
typedef struct word_desc {
char *word; /* Zero terminated string. */
int dollar_present; /* Non-zero means dollar sign present. */
int quoted; /* Non-zero means single, double, or back quote
or backslash is present. */
int assignment; /* Non-zero means that this word contains an
assignment. */
} WORD_DESC;
/* A linked list of words. */
typedef struct word_list {
struct word_list *next;
WORD_DESC *word;
} WORD_LIST;
/* **************************************************************** */
/* */
/* Shell Command Structs */
/* */
/* **************************************************************** */
/* What a redirection descriptor looks like. If FLAGS is IS_DESCRIPTOR,
then we use REDIRECTEE.DEST, else we use the file specified. */
typedef struct redirect {
struct redirect *next; /* Next element, or NULL. */
int redirector; /* Descriptor to be redirected. */
int flags; /* Flag value for `open'. */
enum r_instruction instruction; /* What to do with the information. */
union {
int dest; /* Place to redirect REDIRECTOR to, or ... */
WORD_DESC *filename; /* filename to redirect to. */
} redirectee;
char *here_doc_eof; /* The word that appeared in <<foo. */
} REDIRECT;
/* An element used in parsing. A single word or a single redirection.
This is an ephemeral construct. */
typedef struct element {
WORD_DESC *word;
REDIRECT *redirect;
struct element *next;
} ELEMENT;
/* Possible values for command->flags. */
#define CMD_WANT_SUBSHELL 0x01 /* User wants a subshell: ( command ) */
#define CMD_FORCE_SUBSHELL 0x02 /* Shell needs to force a subshell. */
#define CMD_INVERT_RETURN 0x04 /* Invert the exit value. */
#define CMD_IGNORE_RETURN 0x08 /* Ignore the exit value. For set -e. */
#define CMD_NO_FUNCTIONS 0x10 /* Ignore functions during command lookup. */
#define CMD_INHIBIT_EXPANSION 0x20 /* Do not expand the command words. */
/* What a command looks like. */
typedef struct command {
enum command_type type; /* FOR CASE WHILE IF CONNECTION or SIMPLE. */
int flags; /* Flags controlling execution environment. */
REDIRECT *redirects; /* Special redirects for FOR CASE, etc. */
union {
struct for_com *For;
struct case_com *Case;
struct while_com *While;
struct if_com *If;
struct connection *Connection;
struct simple_com *Simple;
struct function_def *Function_def;
struct group_com *Group;
} value;
} COMMAND;
/* Structure used to represent the CONNECTION type. */
typedef struct connection {
int ignore; /* Unused; simplifies make_command (). */
COMMAND *first; /* Pointer to the first command. */
COMMAND *second; /* Pointer to the second command. */
int connector; /* What separates this command from others. */
} CONNECTION;
/* Structures used to represent the CASE command. */
/* Pattern/action structure for CASE_COM. */
typedef struct pattern_list {
struct pattern_list *next; /* Clause to try in case this one failed. */
WORD_LIST *patterns; /* Linked list of patterns to test. */
COMMAND *action; /* Thing to execute if a pattern matches. */
} PATTERN_LIST;
/* The CASE command. */
typedef struct case_com {
int flags; /* See description of CMD flags. */
WORD_DESC *word; /* The thing to test. */
PATTERN_LIST *clauses; /* The clauses to test against, or NULL. */
} CASE_COM;
/* FOR command. */
typedef struct for_com {
int flags; /* See description of CMD flags. */
WORD_DESC *name; /* The variable name to get mapped over. */
WORD_LIST *map_list; /* The things to map over. This is never NULL. */
COMMAND *action; /* The action to execute.
During execution, NAME is bound to successive
members of MAP_LIST. */
} FOR_COM;
/* IF command. */
typedef struct if_com {
int flags; /* See description of CMD flags. */
COMMAND *test; /* Thing to test. */
COMMAND *true_case; /* What to do if the test returned non-zero. */
COMMAND *false_case; /* What to do if the test returned zero. */
} IF_COM;
/* WHILE command. */
typedef struct while_com {
int flags; /* See description of CMD flags. */
COMMAND *test; /* Thing to test. */
COMMAND *action; /* Thing to do while test is non-zero. */
} WHILE_COM;
/* The "simple" command. Just a collection of words and redirects. */
typedef struct simple_com {
int flags; /* See description of CMD flags. */
WORD_LIST *words; /* The program name, the arguments,
variable assignments, etc. */
REDIRECT *redirects; /* Redirections to perform. */
} SIMPLE_COM;
/* The "function_def" command. This isn't really a command, but it is
represented as such for now. If the function def appears within
`(' `)' the parser tries to set the SUBSHELL bit of the command. That
means that FUNCTION_DEF has to be run through the executor. Maybe this
command should be defined in a subshell. Who knows or cares. */
typedef struct function_def {
int ignore; /* See description of CMD flags. */
WORD_DESC *name; /* The name of the function. */
COMMAND *command; /* The parsed execution tree. */
} FUNCTION_DEF;
/* A command that is `grouped' allows pipes to take effect over
the entire command structure. */
typedef struct group_com {
int ignore; /* See description of CMD flags. */
COMMAND *command;
} GROUP_COM;
/* Forward declarations of functions called by the grammer. */
extern REDIRECT *make_redirection ();
extern WORD_LIST *make_word_list ();
extern WORD_DESC *make_word ();
extern COMMAND
*make_for_command (), *make_case_command (), *make_if_command (),
*make_while_command (), *command_connect (), *make_simple_command (),
*make_function_def (), *clean_simple_command (), *make_until_command (),
*make_group_command ();
extern PATTERN_LIST *make_pattern_list ();
extern COMMAND *global_command, *copy_command ();
#endif /* _COMMAND_H */
-279
View File
@@ -1,279 +0,0 @@
/* copy_command.c -- copy a COMMAND structure. This is needed
primarily for making function definitions, but I'm not sure
that anyone else will need it. */
/* Copyright (C) 1987,1991 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 1, or (at your option)
any later version.
Bash is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
License for more details.
You should have received a copy of the GNU General Public License
along with Bash; see the file COPYING. If not, write to the Free
Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <stdio.h>
#include "shell.h"
/* Forward declaration. */
extern COMMAND *copy_command ();
WORD_DESC *
copy_word (word)
WORD_DESC *word;
{
WORD_DESC *new_word = (WORD_DESC *)xmalloc (sizeof (WORD_DESC));
bcopy (word, new_word, sizeof (WORD_DESC));
new_word->word = savestring (word->word);
return (new_word);
}
/* Copy the chain of words in LIST. Return a pointer to
the new chain. */
WORD_LIST *
copy_word_list (list)
WORD_LIST *list;
{
WORD_LIST *new_list = NULL;
while (list)
{
WORD_LIST *temp = (WORD_LIST *)xmalloc (sizeof (WORD_LIST));
temp->next = new_list;
new_list = temp;
new_list->word = copy_word (list->word);
list = list->next;
}
return ((WORD_LIST *)reverse_list (new_list));
}
PATTERN_LIST *
copy_case_clause (clause)
PATTERN_LIST *clause;
{
PATTERN_LIST *new_clause = (PATTERN_LIST *)xmalloc (sizeof (PATTERN_LIST));
new_clause->patterns = copy_word_list (clause->patterns);
new_clause->action = copy_command (clause->action);
return (new_clause);
}
PATTERN_LIST *
copy_case_clauses (clauses)
PATTERN_LIST *clauses;
{
PATTERN_LIST *new_list = (PATTERN_LIST *)NULL;
while (clauses)
{
PATTERN_LIST *new_clause = copy_case_clause (clauses);
new_clause->next = new_list;
new_list = new_clause;
clauses = clauses->next;
}
return ((PATTERN_LIST *)reverse_list (new_list));
}
/* Copy a single redirect. */
REDIRECT *
copy_redirect (redirect)
REDIRECT *redirect;
{
REDIRECT *new_redirect = (REDIRECT *)xmalloc (sizeof (REDIRECT));
bcopy (redirect, new_redirect, (sizeof (REDIRECT)));
switch (redirect->instruction)
{
case r_reading_until:
case r_deblank_reading_until:
new_redirect->here_doc_eof = savestring (redirect->here_doc_eof);
/* There is NO BREAK HERE ON PURPOSE!!!! */
case r_appending_to:
case r_output_direction:
case r_input_direction:
case r_inputa_direction:
case r_err_and_out:
case r_input_output:
case r_output_force:
case r_duplicating_input_word:
case r_duplicating_output_word:
new_redirect->redirectee.filename =
copy_word (redirect->redirectee.filename);
break;
}
return (new_redirect);
}
REDIRECT *
copy_redirects (list)
REDIRECT *list;
{
REDIRECT *new_list = NULL;
while (list)
{
REDIRECT *temp = copy_redirect (list);
temp->next = new_list;
new_list = temp;
list = list->next;
}
return ((REDIRECT *)reverse_list (new_list));
}
FOR_COM *
copy_for_command (com)
FOR_COM *com;
{
FOR_COM *new_for = (FOR_COM *)xmalloc (sizeof (FOR_COM));
new_for->flags = com->flags;
new_for->name = copy_word (com->name);
new_for->map_list = copy_word_list (com->map_list);
new_for->action = copy_command (com->action);
return (new_for);
}
GROUP_COM *
copy_group_command (com)
GROUP_COM *com;
{
GROUP_COM *new_group = (GROUP_COM *)xmalloc (sizeof (GROUP_COM));
new_group->command = copy_command (com->command);
return (new_group);
}
CASE_COM *
copy_case_command (com)
CASE_COM *com;
{
CASE_COM *new_case = (CASE_COM *)xmalloc (sizeof (CASE_COM));
new_case->flags = com->flags;
new_case->word = copy_word (com->word);
new_case->clauses = copy_case_clauses (com->clauses);
return (new_case);
}
WHILE_COM *
copy_while_command (com)
WHILE_COM *com;
{
WHILE_COM *new_while = (WHILE_COM *)xmalloc (sizeof (WHILE_COM));
new_while->flags = com->flags;
new_while->test = copy_command (com->test);
new_while->action = copy_command (com->action);
return (new_while);
}
IF_COM *
copy_if_command (com)
IF_COM *com;
{
IF_COM *new_if = (IF_COM *)xmalloc (sizeof (IF_COM));
new_if->flags = com->flags;
new_if->test = copy_command (com->test);
new_if->true_case = copy_command (com->true_case);
new_if->false_case = copy_command (com->false_case);
return (new_if);
}
SIMPLE_COM *
copy_simple_command (com)
SIMPLE_COM *com;
{
SIMPLE_COM *new_simple = (SIMPLE_COM *)xmalloc (sizeof (SIMPLE_COM));
new_simple->flags = com->flags;
new_simple->words = copy_word_list (com->words);
new_simple->redirects = copy_redirects (com->redirects);
return (new_simple);
}
FUNCTION_DEF *
copy_function_def (com)
FUNCTION_DEF *com;
{
FUNCTION_DEF *new_def = (FUNCTION_DEF *)xmalloc (sizeof (FUNCTION_DEF));
new_def->name = copy_word (com->name);
new_def->command = copy_command (com->command);
return (new_def);
}
/* Copy the command structure in COMMAND. Return a pointer to the
copy. Don't you forget to dispose_command () on this pointer
later! */
COMMAND *
copy_command (command)
COMMAND *command;
{
COMMAND *new_command = (COMMAND *)NULL;
if (command)
{
new_command = (COMMAND *)xmalloc (sizeof (COMMAND));
bcopy (command, new_command, sizeof (COMMAND));
new_command->flags = command->flags;
if (command->redirects)
new_command->redirects = copy_redirects (command->redirects);
switch (command->type)
{
case cm_for:
new_command->value.For = copy_for_command (command->value.For);
break;
case cm_group:
new_command->value.Group = copy_group_command (command->value.Group);
break;
case cm_case:
new_command->value.Case = copy_case_command (command->value.Case);
break;
case cm_until:
case cm_while:
new_command->value.While = copy_while_command (command->value.While);
break;
case cm_if:
new_command->value.If = copy_if_command (command->value.If);
break;
case cm_simple:
new_command->value.Simple = copy_simple_command (command->value.Simple);
break;
case cm_connection:
{
CONNECTION *new_connection;
new_connection = (CONNECTION *)xmalloc (sizeof (CONNECTION));
new_connection->connector = command->value.Connection->connector;
new_connection->first =
copy_command (command->value.Connection->first);
new_connection->second =
copy_command (command->value.Connection->second);
new_command->value.Connection = new_connection;
break;
}
/* Pathological case. I'm not even sure that you can have a
function definition as part of a function definition. */
case cm_function_def:
new_command->value.Function_def =
copy_function_def (command->value.Function_def);
break;
}
}
return (new_command);
}
-9
View File
@@ -1,9 +0,0 @@
/* endian.h - Define BIG or LITTLE endian. */
/* This file was automatically created by `endian.aux'. You shouldn't
edit this file, because your changes will be overwritten. Instead,
edit the source code file `endian.c'. */
#if !defined (BIG_ENDIAN)
# define BIG_ENDIAN
#endif /* BIG_ENDIAN */
-97
View File
@@ -1,97 +0,0 @@
#include <stdio.h>
#include "shell.h"
COMMAND *global_command;
int last_command_exit_value;
int interrupt_state;
int interactive = 1;
int eof_encountered = 0;
int exit_immediately_on_error = 1;
char *the_current_maintainer = "chet";
char *shell_name = "posix";
void
throw_to_top_level()
{
}
char *
base_pathname(s)
char *s;
{
return s;
}
char *
strerror(s)
int s;
{
return ("error");
}
parse_command ()
{
extern int need_here_doc, current_command_line_count;
extern REDIRECT *redirection_needing_here_doc;
int r;
need_here_doc = 0;
redirection_needing_here_doc = (REDIRECT *)NULL;
current_command_line_count = 0;
r = yyparse ();
if (need_here_doc)
make_here_document (redirection_needing_here_doc);
need_here_doc = 0;
return (r);
}
main(argc, argv)
int argc;
char **argv;
{
with_input_from_stdin();
if (parse_command () == 0) {
printf ("legal command in the Posix shell\n");
exit (0);
} else {
printf ("illegal\n");
exit (1);
}
}
char *
string_quote_removal (s)
{
return (savestring (s));
}
assignment (string)
char *string;
{
register int c, index = 0;
c = string[index];
if (!isletter (c) && c != '_')
return (0);
while (c = string[index])
{
/* The following is safe. Note that '=' at the start of a word
is not an assignment statement. */
if (c == '=')
return (index);
if (!isletter (c) && !digit (c) && c != '_')
return (0);
index++;
}
return (0);
}
-596
View File
@@ -1,596 +0,0 @@
/* make_cmd.c --
Functions for making instances of the various parser constructs. */
/* Copyright (C) 1989 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <stdio.h>
#include <sys/types.h>
#include <sys/file.h>
#include "config.h"
#include "general.h"
#include "error.h"
#include "command.h"
#include "flags.h"
#include "filecntl.h"
#if defined (JOB_CONTROL)
#include "jobs.h"
#endif
extern GENERIC_LIST *reverse_list ();
WORD_DESC *
make_word (string)
char *string;
{
WORD_DESC *temp;
temp = (WORD_DESC *)xmalloc (sizeof (WORD_DESC));
temp->word = savestring (string);
temp->quoted = temp->dollar_present = temp->assignment = 0;
while (*string)
{
if (*string == '$') temp->dollar_present = 1;
if (member (*string, "'`\\\""))
{
temp->quoted = 1;
if (*string == '\\')
string++;
}
if (*string)
(string++);
}
return (temp);
}
WORD_DESC *
make_word_from_token (token)
int token;
{
char tokenizer[2];
tokenizer[0] = token;
tokenizer[1] = '\0';
return (make_word (tokenizer));
}
WORD_LIST *
make_word_list (word, link)
WORD_DESC *word;
WORD_LIST *link;
{
WORD_LIST *temp;
temp = (WORD_LIST *)xmalloc (sizeof (WORD_LIST));
temp->word = word;
temp->next = link;
return (temp);
}
WORD_LIST *
add_string_to_list (string, list)
char *string;
WORD_LIST *list;
{
WORD_LIST *temp = (WORD_LIST *)xmalloc (sizeof (WORD_LIST));
temp->word = make_word (string);
temp->next = list;
return (temp);
}
WORD_DESC *
coerce_to_word (number)
int number;
{
char string[24];
sprintf (string, "%d", number);
return (make_word (string));
}
COMMAND *
make_command (type, pointer)
enum command_type type;
SIMPLE_COM *pointer;
{
COMMAND *temp;
temp = (COMMAND *)xmalloc (sizeof (COMMAND));
temp->type = type;
temp->value.Simple = pointer;
temp->value.Simple->flags = 0;
temp->flags = 0;
temp->redirects = (REDIRECT *)NULL;
return (temp);
}
COMMAND *
command_connect (com1, com2, connector)
COMMAND *com1, *com2;
int connector;
{
CONNECTION *temp;
temp = (CONNECTION *)xmalloc (sizeof (CONNECTION));
temp->connector = connector;
temp->first = com1;
temp->second = com2;
return (make_command (cm_connection, (SIMPLE_COM *)temp));
}
COMMAND *
make_for_command (name, map_list, action)
WORD_DESC *name;
WORD_LIST *map_list;
COMMAND *action;
{
FOR_COM *temp = (FOR_COM *)xmalloc (sizeof (FOR_COM));
temp->flags = 0;
temp->name = name;
temp->map_list = map_list;
temp->action = action;
return (make_command (cm_for, (SIMPLE_COM *)temp));
}
COMMAND *
make_group_command (command)
COMMAND *command;
{
GROUP_COM *temp = (GROUP_COM *)xmalloc (sizeof (GROUP_COM));
temp->command = command;
return (make_command (cm_group, (SIMPLE_COM *)temp));
}
COMMAND *
make_case_command (word, clauses)
WORD_DESC *word;
PATTERN_LIST *clauses;
{
CASE_COM *temp;
temp = (CASE_COM *)xmalloc (sizeof (CASE_COM));
temp->flags = 0;
temp->word = word;
temp->clauses = (PATTERN_LIST *)reverse_list (clauses);
return (make_command (cm_case, (SIMPLE_COM *)temp));
}
PATTERN_LIST *
make_pattern_list (patterns, action)
WORD_LIST *patterns;
COMMAND *action;
{
PATTERN_LIST *temp;
temp = (PATTERN_LIST *)xmalloc (sizeof (PATTERN_LIST));
temp->patterns = patterns;
temp->action = action;
temp->next = NULL;
return (temp);
}
COMMAND *
make_if_command (test, true_case, false_case)
COMMAND *test, *true_case, *false_case;
{
IF_COM *temp;
temp = (IF_COM *)xmalloc (sizeof (IF_COM));
temp->flags = 0;
temp->test = test;
temp->true_case = true_case;
temp->false_case = false_case;
return (make_command (cm_if, (SIMPLE_COM *)temp));
}
COMMAND *
make_until_or_while (test, action, which)
COMMAND *test, *action;
enum command_type which;
{
WHILE_COM *temp;
temp = (WHILE_COM *)xmalloc (sizeof (WHILE_COM));
temp->flags = 0;
temp->test = test;
temp->action = action;
return (make_command (which, (SIMPLE_COM *)temp));
}
COMMAND *
make_while_command (test, action)
COMMAND *test, *action;
{
return (make_until_or_while (test, action, cm_while));
}
COMMAND *
make_until_command (test, action)
COMMAND *test, *action;
{
return (make_until_or_while (test, action, cm_until));
}
COMMAND *
make_bare_simple_command ()
{
COMMAND *command;
SIMPLE_COM *temp = (SIMPLE_COM *)xmalloc (sizeof (SIMPLE_COM));
temp->flags = 0;
temp->words = (WORD_LIST *)NULL;
temp->redirects = (REDIRECT *)NULL;
command = (COMMAND *)xmalloc (sizeof (COMMAND));
command->type = cm_simple;
command->redirects = (REDIRECT *)NULL;
command->flags = 0;
command->value.Simple = temp;
return (command);
}
COMMAND *
new_make_simple_command (word, prefix, suffix)
WORD_DESC *word;
ELEMENT *prefix;
ELEMENT *suffix;
{
/* Make a list of words and redirects from WORD, PREFIX, and SUFFIX. */
WORD_LIST *w = (WORD_LIST *)NULL;
REDIRECT *r = (REDIRECT *)NULL;
COMMAND *ret;
SIMPLE_COM *sc;
register ELEMENT *te;
ret = make_bare_simple_command ();
sc = ret->value.Simple;
te = prefix;
while (te)
{
ELEMENT *t2;
if (te->redirect)
{
te->redirect->next = r;
r->next = te->redirect;
}
else if (te->word)
{
WORD_LIST *twl = make_word_list (te->word, (WORD_LIST *)NULL);
twl->next = w;
w = twl;
}
t2 = te;
te = te->next;
free (t2);
}
if (word)
{
WORD_LIST *twl = make_word_list (word, (WORD_LIST *)NULL);
twl->next = w;
w = twl;
}
te = suffix;
while (te)
{
ELEMENT *t2;
if (te->redirect)
{
te->redirect->next = r;
r->next = te->redirect;
}
else if (te->word)
{
WORD_LIST *twl = make_word_list (te->word, (WORD_LIST *)NULL);
twl->next = w;
w = twl;
}
t2 = te;
te = te->next;
free (t2);
}
sc->words = (WORD_LIST *)reverse_list (w);
sc->redirects = (REDIRECT *)reverse_list (r);
sc->flags = 0;
return (ret);
}
/* Return a command which is the connection of the word or redirection
in ELEMENT, and the command * or NULL in COMMAND. */
COMMAND *
make_simple_command (element, command)
ELEMENT element;
COMMAND *command;
{
/* If we are starting from scratch, then make the initial command
structure. Also note that we have to fill in all the slots, since
malloc doesn't return zeroed space. */
if (!command)
command = make_bare_simple_command ();
if (element.word)
{
WORD_LIST *tw = (WORD_LIST *)xmalloc (sizeof (WORD_LIST));
tw->word = element.word;
tw->next = command->value.Simple->words;
command->value.Simple->words = tw;
}
else
{
REDIRECT *r = element.redirect;
/* Due to the way <> is implemented, there may be more than a single
redirection in element.redirect. We just follow the chain as far
as it goes, and hook onto the end. */
while (r->next)
r = r->next;
r->next = command->value.Simple->redirects;
command->value.Simple->redirects = element.redirect;
}
return (command);
}
#define POSIX_HERE_DOCUMENTS
make_here_document (temp)
REDIRECT *temp;
{
int kill_leading = 0;
switch (temp->instruction)
{
/* Because we are Bourne compatible, we read the input for this
<< or <<- redirection now, from wherever input is coming from.
We store the input read into a WORD_DESC. Replace the text of
the redirectee.word with the new input text. If <<- is on,
then remove leading TABS from each line. */
case r_deblank_reading_until: /* <<-foo */
kill_leading++;
/* ... */
case r_reading_until: /* <<foo */
{
extern char *redirection_expand ();
extern char *string_quote_removal ();
char *redirectee_word;
int len;
char *document = (char *)NULL;
int document_index = 0, document_size = 0;
#if !defined (POSIX_HERE_DOCUMENTS)
/* Because of Bourne shell semantics, we turn off globbing, but
only for this style of redirection. I feel a little ill. */
{
extern int disallow_filename_globbing;
int old_value = disallow_filename_globbing;
disallow_filename_globbing = 1;
redirectee_word = redirection_expand (temp->redirectee.filename);
disallow_filename_globbing = old_value;
}
#else /* POSIX_HERE_DOCUMENTS */
/* Quote removal is the only expansion performed on the delimiter
for here documents, making it an extremely special case. I
still feel ill. */
redirectee_word =
string_quote_removal (temp->redirectee.filename->word, 0);
#endif /* POSIX_HERE_DOCUMENTS */
/* redirection_expand will return NULL if the expansion results in
multiple words or no words. Check for that here, and just abort
this here document if it does. */
if (redirectee_word)
len = strlen (redirectee_word);
else
{
temp->here_doc_eof = savestring ("");
goto document_done;
}
free (temp->redirectee.filename->word);
temp->here_doc_eof = redirectee_word;
/* Read lines from wherever lines are coming from.
For each line read, if kill_leading, then kill the
leading tab characters.
If the line matches redirectee_word exactly, then we have
manufactured the document. Otherwise, add the line to the
list of lines in the document. */
{
extern char *read_secondary_line ();
char *line;
int l;
while (line = read_secondary_line ())
{
if (!line)
goto document_done;
if (kill_leading)
{
register int i;
/* Hack: To be compatible with some Bourne shells, we
check the word before stripping the whitespace. This
is a hack, though. */
if ((strncmp (line, redirectee_word, len) == 0) &&
line[len] == '\n')
goto document_done;
for (i = 0; line[i] == '\t'; i++)
;
if (i)
strcpy (&line[0], &line[i]);
}
if ((strncmp (line, redirectee_word, len) == 0) &&
line[len] == '\n')
goto document_done;
l = strlen (line);
if (l + document_index >= document_size)
{
document = (char *)
xrealloc (document, (document_size += (10 * l)));
}
if (l != 0)
{
strcpy (&document[document_index], line);
free (line);
document_index += l;
}
}
document_done:
if (!document)
document = savestring ("");
temp->redirectee.filename->word = document;
}
}
}
}
/* Generate a REDIRECT from SOURCE, DEST, and INSTRUCTION.
INSTRUCTION is the instruction type, SOURCE is an INT,
and DEST is an INT or a WORD_DESC *. */
REDIRECT *
make_redirection (source, instruction, dest)
enum r_instruction instruction;
{
REDIRECT *temp = (REDIRECT *)xmalloc (sizeof (REDIRECT));
/* First do the common cases. */
temp->redirector = source;
temp->redirectee.dest = dest;
temp->instruction = instruction;
temp->next = (REDIRECT *)NULL;
switch (instruction)
{
case r_output_direction: /* >foo */
case r_output_force: /* >| foo */
temp->flags = O_TRUNC | O_WRONLY | O_CREAT;
break;
case r_input_direction: /* <foo */
case r_inputa_direction: /* foo & makes this. */
temp->flags = O_RDONLY;
break;
case r_appending_to: /* >>foo */
temp->flags = O_APPEND | O_WRONLY | O_CREAT;
break;
case r_deblank_reading_until: /* <<-foo */
case r_reading_until: /* << foo */
break;
case r_duplicating_input: /* 1<&2 */
case r_duplicating_output: /* 1>&2 */
case r_close_this: /* <&- */
case r_duplicating_input_word: /* 1<&$foo */
case r_duplicating_output_word: /* 1>&$foo */
break;
case r_err_and_out: /* command &>filename */
temp->flags = O_TRUNC | O_WRONLY | O_CREAT;
break;
case r_input_output:
temp->flags = O_RDWR;
break;
default:
programming_error ("Redirection instruction from yyparse () '%d' is\n\
out of range in make_redirection ().", instruction);
abort ();
break;
}
return (temp);
}
COMMAND *
make_function_def (name, command)
WORD_DESC *name;
COMMAND *command;
{
FUNCTION_DEF *temp;
temp = (FUNCTION_DEF *)xmalloc (sizeof (FUNCTION_DEF));
temp->command = command;
temp->name = name;
return (make_command (cm_function_def, (SIMPLE_COM *)temp));
}
/* Reverse the word list and redirection list in the simple command
has just been parsed. It seems simpler to do this here the one
time then by any other method that I can think of. */
COMMAND *
clean_simple_command (command)
COMMAND *command;
{
extern GENERIC_LIST *reverse_list ();
if (command->type != cm_simple)
{
programming_error
("clean_simple_command () got a command with type %d.", command->type);
}
else
{
command->value.Simple->words =
(WORD_LIST *)reverse_list (command->value.Simple->words);
command->value.Simple->redirects =
(REDIRECT *)reverse_list (command->value.Simple->redirects);
}
return (command);
}
/* Cons up a new array of words. The words are taken from LIST,
which is a WORD_LIST *. Absolutely everything is malloc'ed,
so you should free everything in this array when you are done.
The array is NULL terminated. */
char **
make_word_array (list)
WORD_LIST *list;
{
int count = list_length (list);
char **array = (char **)xmalloc ((1 + count) * sizeof (char *));
for (count = 0; list; count++)
{
array[count] = (char *)xmalloc (1 + strlen (list->word->word));
strcpy (array[count], list->word->word);
list = list->next;
}
array[count] = (char *)NULL;
return (array);
}
File diff suppressed because it is too large Load Diff
-71
View File
@@ -1,71 +0,0 @@
/* shell.h -- The data structures used by the shell */
#include "config.h"
#include "general.h"
#include "error.h"
#include "variables.h"
#include "quit.h"
#include "maxpath.h"
#include "unwind_prot.h"
#include "command.h"
extern int EOF_Reached;
#define NO_PIPE -1
#define REDIRECT_BOTH -2
#define IS_DESCRIPTOR -1
#define NO_VARIABLE -1
/* A bunch of stuff for flow of control using setjmp () and longjmp (). */
#include <setjmp.h>
extern jmp_buf top_level, catch;
#define NOT_JUMPED 0 /* Not returning from a longjmp. */
#define FORCE_EOF 1 /* We want to stop parsing. */
#define DISCARD 2 /* Discard current command. */
#define EXITPROG 3 /* Unconditionally exit the program now. */
/* Values that can be returned by execute_command (). */
#define EXECUTION_FAILURE 1
#define EXECUTION_SUCCESS 0
/* Special exit status used when the shell is asked to execute a
binary file as a shell script. */
#define EX_BINARY_FILE 126
/* The list of characters that are quoted in double-quotes with a
backslash. Other characters following a backslash cause nothing
special to happen. */
#define slashify_in_quotes "\\`$\""
#define slashify_in_here_document "\\`$"
/* Constants which specify how to handle backslashes and quoting in
expand_word_internal (). Q_DOUBLE_QUOTES means to use the function
slashify_in_quotes () to decide whether the backslash should be
retained. Q_HERE_DOCUMENT means slashify_in_here_document () to
decide whether to retain the backslash. Q_KEEP_BACKSLASH means
to unconditionally retain the backslash. */
#define Q_DOUBLE_QUOTES 0x1
#define Q_HERE_DOCUMENT 0x2
#define Q_KEEP_BACKSLASH 0x4
extern char **shell_environment;
extern WORD_LIST *rest_of_args;
/* Generalized global variables. */
extern int executing, login_shell;
/* Structure to pass around that holds a bitmap of file descriptors
to close, and the size of that structure. Used in execute_cmd.c. */
struct fd_bitmap {
long size;
char *bitmap;
};
#define FD_BITMAP_SIZE 32
#if defined (EIGHT_BIT)
# define CTLESC '\001'
# define CTLNUL '\002'
#endif /* EIGHT_BIT */
-294
View File
@@ -1,294 +0,0 @@
/* I can't stand it anymore! Please can't we just write the
whole Unix system in lisp or something? */
/* Copyright (C) 1987,1989 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
/* **************************************************************** */
/* */
/* Unwind Protection Scheme for Bash */
/* */
/* **************************************************************** */
#include <sys/types.h>
#include <signal.h>
#include "config.h"
#include "general.h"
#include "unwind_prot.h"
/* If CLEANUP is null, then ARG contains a tag to throw back to. */
typedef struct _uwp {
struct _uwp *next;
Function *cleanup;
char *arg;
} UNWIND_ELT;
static void
unwind_frame_discard_internal (), unwind_frame_run_internal (),
add_unwind_protect_internal (), remove_unwind_protect_internal (),
run_unwind_protects_internal ();
static UNWIND_ELT *unwind_protect_list = (UNWIND_ELT *)NULL;
/* Run a function without interrupts. */
void
without_interrupts (function, arg1, arg2)
VFunction *function;
char *arg1, *arg2;
{
#if defined (_POSIX_VERSION)
static int sets_done = 0;
static sigset_t set;
sigset_t oset;
/* SET needs to be initialized only once. */
if (sets_done == 0)
{
sigemptyset (&set);
sigaddset (&set, SIGINT);
sets_done = 1;
}
sigemptyset (&oset);
sigprocmask (SIG_BLOCK, &set, &oset);
#else
# if defined (USG)
SigHandler *old_int;
old_int = (SigHandler *)signal (SIGINT, SIG_IGN);
# else
int oldmask = sigblock (SIGINT);
# endif
#endif
(*function)(arg1, arg2);
#if defined (_POSIX_VERSION)
sigprocmask (SIG_SETMASK, &oset, (sigset_t *)NULL);
#else
# if defined (USG)
signal (SIGINT, old_int);
# else
sigsetmask (oldmask);
# endif
#endif
}
/* Start the beginning of a region. */
void
begin_unwind_frame (tag)
char *tag;
{
add_unwind_protect ((Function *)NULL, tag);
}
/* Discard the unwind protects back to TAG. */
void
discard_unwind_frame (tag)
char *tag;
{
if (unwind_protect_list)
without_interrupts (unwind_frame_discard_internal, tag, (char *)NULL);
}
/* Run the unwind protects back to TAG. */
void
run_unwind_frame (tag)
char *tag;
{
if (unwind_protect_list)
without_interrupts (unwind_frame_run_internal, tag, (char *)NULL);
}
/* Add the function CLEANUP with ARG to the list of unwindable things. */
void
add_unwind_protect (cleanup, arg)
Function *cleanup;
char *arg;
{
without_interrupts (add_unwind_protect_internal, (char *)cleanup, arg);
}
/* Remove the top unwind protect from the list. */
void
remove_unwind_protect ()
{
if (unwind_protect_list)
without_interrupts
(remove_unwind_protect_internal, (char *)NULL, (char *)NULL);
}
/* Run the list of cleanup functions in unwind_protect_list. */
void
run_unwind_protects ()
{
if (unwind_protect_list)
without_interrupts
(run_unwind_protects_internal, (char *)NULL, (char *)NULL);
}
/* **************************************************************** */
/* */
/* The Actual Functions */
/* */
/* **************************************************************** */
static void
add_unwind_protect_internal (cleanup, arg)
Function *cleanup;
char *arg;
{
UNWIND_ELT *elt;
elt = (UNWIND_ELT *)xmalloc (sizeof (UNWIND_ELT));
elt->cleanup = cleanup;
elt->arg = arg;
elt->next = unwind_protect_list;
unwind_protect_list = elt;
}
static void
remove_unwind_protect_internal ()
{
UNWIND_ELT *elt = unwind_protect_list;
if (elt)
{
unwind_protect_list = unwind_protect_list->next;
free (elt);
}
}
static void
run_unwind_protects_internal ()
{
UNWIND_ELT *t, *elt = unwind_protect_list;
while (elt)
{
/* This function can be run at strange times, like when unwinding
the entire world of unwind protects. Thus, we may come across
an element which is simply a label for a catch frame. Don't call
the non-existant function. */
if (elt->cleanup)
(*(elt->cleanup)) (elt->arg);
t = elt;
elt = elt->next;
free (t);
}
unwind_protect_list = elt;
}
static void
unwind_frame_discard_internal (tag)
char *tag;
{
UNWIND_ELT *elt;
while (elt = unwind_protect_list)
{
unwind_protect_list = unwind_protect_list->next;
if (!elt->cleanup && (STREQ (elt->arg, tag)))
{
free (elt);
break;
}
else
free (elt);
}
}
static void
unwind_frame_run_internal (tag)
char *tag;
{
UNWIND_ELT *elt;
while (elt = unwind_protect_list)
{
unwind_protect_list = elt->next;
/* If tag, then compare. */
if (!elt->cleanup)
{
if (STREQ (elt->arg, tag))
{
free (elt);
break;
}
free (elt);
continue;
}
else
{
(*(elt->cleanup)) (elt->arg);
free (elt);
}
}
}
/* Structure describing a saved variable and the value to restore it to. */
typedef struct {
int *variable;
char *desired_setting;
int size;
} SAVED_VAR;
/* Restore the value of a variable, based on the contents of SV. If
sv->size is greater than sizeof (int), sv->desired_setting points to
a block of memory SIZE bytes long holding the value, rather than the
value itself. This block of memory is copied back into the variable. */
static void
restore_variable (sv)
SAVED_VAR *sv;
{
if (sv->size > sizeof (int))
{
bcopy ((char *)sv->desired_setting, (char *)sv->variable, sv->size);
free (sv->desired_setting);
}
else
*(sv->variable) = (int)sv->desired_setting;
free (sv);
}
/* Save the value of a variable so it will be restored when unwind-protects
are run. VAR is a pointer to the variable. VALUE is the value to be
saved. SIZE is the size in bytes of VALUE. If SIZE is bigger than what
can be saved in an int, memory will be allocated and the value saved
into that using bcopy (). */
void
unwind_protect_var (var, value, size)
int *var;
char *value;
int size;
{
SAVED_VAR *s = (SAVED_VAR *)xmalloc (sizeof (SAVED_VAR));
s->variable = var;
if (size > sizeof (int))
{
s->desired_setting = (char *)xmalloc (size);
bcopy (value, (char *)s->desired_setting, size);
}
else
s->desired_setting = value;
s->size = size;
add_unwind_protect ((Function *)restore_variable, (char *)s);
}
-1331
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
Binary file not shown.
-191
View File
@@ -1,191 +0,0 @@
#include <stdio.h>
#include <limits.h>
#include <locale.h>
#include <unistd.h>
#include <errno.h>
#include <stdarg.h>
#include "bashansi.h"
#include "shell.h"
#include "builtins.h"
#include "stdc.h"
#include "common.h"
#include "bashgetopt.h"
char *this_command_name = (char *)NULL;
void
builtin_error (const char *format, ...)
{
va_list args;
char *name;
name = get_name_for_error ();
fprintf (stderr, "%s: ", name);
if (this_command_name && *this_command_name)
fprintf (stderr, "%s: ", this_command_name);
va_start (args, format);
vfprintf (stderr, format, args);
va_end (args);
fprintf (stderr, "\n");
}
int
no_options(list)
WORD_LIST *list;
{
reset_internal_getopt ();
if (internal_getopt (list, "") != -1)
{
builtin_usage ();
return (1);
}
return (0);
}
int
legal_number (string, result)
char *string;
long *result;
{
long value;
char *ep;
if (result)
*result = 0;
value = strtol (string, &ep, 10);
/* If *string is not '\0' but *ep is '\0' on return, the entire string
is valid. */
if (string && *string && *ep == '\0')
{
if (result)
*result = value;
/* The SunOS4 implementation of strtol() will happily ignore
overflow conditions, so this cannot do overflow correctly
on those systems. */
return 1;
}
return (0);
}
/* Return the number of elements in LIST, a generic list. */
int
list_length (list)
GENERIC_LIST *list;
{
register int i;
for (i = 0; list; list = list->next, i++);
return (i);
}
GENERIC_LIST *
reverse_list (list)
GENERIC_LIST *list;
{
register GENERIC_LIST *next, *prev;
for (prev = (GENERIC_LIST *)NULL; list; )
{
next = list->next;
list->next = prev;
prev = list;
list = next;
}
return (prev);
}
WORD_DESC *
make_bare_word (string)
char *string;
{
WORD_DESC *temp;
temp = (WORD_DESC *)xmalloc (sizeof (WORD_DESC));
if (*string)
temp->word = savestring (string);
else
{
temp->word = xmalloc (1);
temp->word[0] = '\0';
}
temp->flags = 0;
return (temp);
}
WORD_LIST *
make_word_list (word, link)
WORD_DESC *word;
WORD_LIST *link;
{
WORD_LIST *temp;
temp = (WORD_LIST *)xmalloc (sizeof (WORD_LIST));
temp->word = word;
temp->next = link;
return (temp);
}
void
builtin_usage()
{
if (this_command_name && *this_command_name)
fprintf (stderr, "%s: usage: %s args\n", this_command_name, this_command_name);
fflush (stderr);
}
char *
xmalloc(s)
size_t s;
{
return (malloc (s));
}
WORD_LIST *
argv_to_word_list (array, copy, starting_index)
char **array;
int copy, starting_index;
{
WORD_LIST *list;
WORD_DESC *w;
int i, count;
if (array == 0 || array[0] == 0)
return (WORD_LIST *)NULL;
for (count = 0; array[count]; count++)
;
for (i = starting_index, list = (WORD_LIST *)NULL; i < count; i++)
{
w = make_bare_word (copy ? "" : array[i]);
if (copy)
{
free (w->word);
w->word = array[i];
}
list = make_word_list (w, list);
}
return (REVERSE_LIST(list, WORD_LIST *));
}
/* Convert a WORD_LIST into a C-style argv. Return the number of elements
in the list in *IP, if IP is non-null. A convenience function for
loadable builtins; also used by `test'. */
char **
make_builtin_argv (list, ip)
WORD_LIST *list;
int *ip;
{
char **argv;
argv = strvec_from_word_list (list, 0, 1, ip);
argv[0] = this_command_name;
return argv;
}
-46
View File
@@ -1,46 +0,0 @@
/* strindex.c - Find if one string appears as a substring of another string,
without regard to case. */
/* Copyright (C) 2000 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Bash is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Bash. If not, see <http://www.gnu.org/licenses/>.
*/
#include <config.h>
#include <bashansi.h>
#include <chartypes.h>
#include <stdc.h>
/* Determine if s2 occurs in s1. If so, return a pointer to the
match in s1. The compare is case insensitive. This is a
case-insensitive strstr(3). */
char *
strindex (s1, s2)
const char *s1;
const char *s2;
{
register int i, l, len, c;
c = TOLOWER ((unsigned char)s2[0]);
len = strlen (s1);
l = strlen (s2);
for (i = 0; (len - i) >= l; i++)
if ((TOLOWER ((unsigned char)s1[i]) == c) && (strncasecmp (s1 + i, s2, l) == 0))
return ((char *)s1 + i);
return ((char *)0);
}
-78
View File
@@ -1,78 +0,0 @@
/* xstrchr.c - strchr(3) that handles multibyte characters. */
/* Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Bash is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Bash. If not, see <http://www.gnu.org/licenses/>.
*/
#include <config.h>
#ifdef HAVE_STDLIB_H
# include <stdlib.h>
#endif
#include "bashansi.h"
#include "shmbutil.h"
#undef xstrchr
/* In some locales, the non-first byte of some multibyte characters have
the same value as some ascii character. Faced with these strings, a
legacy strchr() might return the wrong value. */
char *
#if defined (PROTOTYPES)
xstrchr (const char *s, int c)
#else
xstrchr (s, c)
const char *s;
int c;
#endif
{
#if HANDLE_MULTIBYTE
char *pos;
mbstate_t state;
size_t strlength, mblength;
/* The locale encodings with said weird property are BIG5, BIG5-HKSCS,
GBK, GB18030, SHIFT_JIS, and JOHAB. They exhibit the problem only
when c >= 0x30. We can therefore use the faster bytewise search if
c <= 0x30. */
if ((unsigned char)c >= '0' && MB_CUR_MAX > 1)
{
pos = (char *)s;
memset (&state, '\0', sizeof(mbstate_t));
strlength = strlen (s);
while (strlength > 0)
{
mblength = mbrlen (pos, strlength, &state);
if (mblength == (size_t)-2 || mblength == (size_t)-1 || mblength == (size_t)0)
mblength = 1;
if (c == (unsigned char)*pos)
return pos;
strlength -= mblength;
pos += mblength;
}
return ((char *)NULL);
}
else
#endif
return (strchr (s, c));
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
-547
View File
@@ -1,547 +0,0 @@
#! /bin/sh
# Output a system dependent set of variables, describing how to set the
# run time search path of shared libraries in an executable.
#
# Copyright 1996-2003 Free Software Foundation, Inc.
# Taken from GNU libtool, 2001
# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
#
# The first argument passed to this file is the canonical host specification,
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
# or
# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
# The environment variables CC, GCC, LDFLAGS, LD, with_gnu_ld
# should be set by the caller.
#
# The set of defined variables is at the end of this script.
# Known limitations:
# - On IRIX 6.5 with CC="cc", the run time search patch must not be longer
# than 256 bytes, otherwise the compiler driver will dump core. The only
# known workaround is to choose shorter directory names for the build
# directory and/or the installation directory.
# All known linkers require a `.a' archive for static linking (except M$VC,
# which needs '.lib').
libext=a
shrext=.so
host="$1"
host_cpu=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
host_vendor=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
host_os=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
# Code taken from libtool.m4's AC_LIBTOOL_PROG_COMPILER_PIC.
wl=
if test "$GCC" = yes; then
wl='-Wl,'
else
case "$host_os" in
aix*)
wl='-Wl,'
;;
mingw* | pw32* | os2*)
;;
hpux9* | hpux10* | hpux11*)
wl='-Wl,'
;;
irix5* | irix6* | nonstopux*)
wl='-Wl,'
;;
newsos6)
;;
linux*)
case $CC in
icc|ecc)
wl='-Wl,'
;;
ccc)
wl='-Wl,'
;;
esac
;;
osf3* | osf4* | osf5*)
wl='-Wl,'
;;
sco3.2v5*)
;;
solaris*)
wl='-Wl,'
;;
sunos4*)
wl='-Qoption ld '
;;
sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
wl='-Wl,'
;;
sysv4*MP*)
;;
uts4*)
;;
esac
fi
# Code taken from libtool.m4's AC_LIBTOOL_PROG_LD_SHLIBS.
hardcode_libdir_flag_spec=
hardcode_libdir_separator=
hardcode_direct=no
hardcode_minus_L=no
case "$host_os" in
cygwin* | mingw* | pw32*)
# FIXME: the MSVC++ port hasn't been tested in a loooong time
# When not using gcc, we currently assume that we are using
# Microsoft Visual C++.
if test "$GCC" != yes; then
with_gnu_ld=no
fi
;;
openbsd*)
with_gnu_ld=no
;;
esac
ld_shlibs=yes
if test "$with_gnu_ld" = yes; then
case "$host_os" in
aix3* | aix4* | aix5*)
# On AIX/PPC, the GNU linker is very broken
if test "$host_cpu" != ia64; then
ld_shlibs=no
fi
;;
amigaos*)
hardcode_libdir_flag_spec='-L$libdir'
hardcode_minus_L=yes
# Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports
# that the semantics of dynamic libraries on AmigaOS, at least up
# to version 4, is to share data among multiple programs linked
# with the same dynamic library. Since this doesn't match the
# behavior of shared libraries on other platforms, we can use
# them.
ld_shlibs=no
;;
beos*)
if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
:
else
ld_shlibs=no
fi
;;
cygwin* | mingw* | pw32*)
# hardcode_libdir_flag_spec is actually meaningless, as there is
# no search path for DLLs.
hardcode_libdir_flag_spec='-L$libdir'
if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
:
else
ld_shlibs=no
fi
;;
netbsd*)
;;
solaris* | sysv5*)
if $LD -v 2>&1 | egrep 'BFD 2\.8' > /dev/null; then
ld_shlibs=no
elif $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
:
else
ld_shlibs=no
fi
;;
sunos4*)
hardcode_direct=yes
;;
*)
if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
:
else
ld_shlibs=no
fi
;;
esac
if test "$ld_shlibs" = yes; then
# Unlike libtool, we use -rpath here, not --rpath, since the documented
# option of GNU ld is called -rpath, not --rpath.
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
fi
else
case "$host_os" in
aix3*)
# Note: this linker hardcodes the directories in LIBPATH if there
# are no directories specified by -L.
hardcode_minus_L=yes
if test "$GCC" = yes; then
# Neither direct hardcoding nor static linking is supported with a
# broken collect2.
hardcode_direct=unsupported
fi
;;
aix4* | aix5*)
if test "$host_cpu" = ia64; then
# On IA64, the linker does run time linking by default, so we don't
# have to do anything special.
aix_use_runtimelinking=no
else
aix_use_runtimelinking=no
# Test if we are trying to use run time linking or normal
# AIX style linking. If -brtl is somewhere in LDFLAGS, we
# need to do runtime linking.
case $host_os in aix4.[23]|aix4.[23].*|aix5*)
for ld_flag in $LDFLAGS; do
if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
aix_use_runtimelinking=yes
break
fi
done
esac
fi
hardcode_direct=yes
hardcode_libdir_separator=':'
if test "$GCC" = yes; then
case $host_os in aix4.[012]|aix4.[012].*)
collect2name=`${CC} -print-prog-name=collect2`
if test -f "$collect2name" && \
strings "$collect2name" | grep resolve_lib_name >/dev/null
then
# We have reworked collect2
hardcode_direct=yes
else
# We have old collect2
hardcode_direct=unsupported
hardcode_minus_L=yes
hardcode_libdir_flag_spec='-L$libdir'
hardcode_libdir_separator=
fi
esac
fi
# Begin _LT_AC_SYS_LIBPATH_AIX.
echo 'int main () { return 0; }' > conftest.c
${CC} ${LDFLAGS} conftest.c -o conftest
aix_libpath=`dump -H conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
}'`
if test -z "$aix_libpath"; then
aix_libpath=`dump -HX64 conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
}'`
fi
if test -z "$aix_libpath"; then
aix_libpath="/usr/lib:/lib"
fi
rm -f conftest.c conftest
# End _LT_AC_SYS_LIBPATH_AIX.
if test "$aix_use_runtimelinking" = yes; then
hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
else
if test "$host_cpu" = ia64; then
hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib'
else
hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
fi
fi
;;
amigaos*)
hardcode_libdir_flag_spec='-L$libdir'
hardcode_minus_L=yes
# see comment about different semantics on the GNU ld section
ld_shlibs=no
;;
bsdi4*)
;;
cygwin* | mingw* | pw32*)
# When not using gcc, we currently assume that we are using
# Microsoft Visual C++.
# hardcode_libdir_flag_spec is actually meaningless, as there is
# no search path for DLLs.
hardcode_libdir_flag_spec=' '
libext=lib
;;
darwin* | rhapsody*)
if $CC -v 2>&1 | grep 'Apple' >/dev/null ; then
hardcode_direct=no
fi
;;
dgux*)
hardcode_libdir_flag_spec='-L$libdir'
;;
freebsd1*)
ld_shlibs=no
;;
freebsd2.2*)
hardcode_libdir_flag_spec='-R$libdir'
hardcode_direct=yes
;;
freebsd2*)
hardcode_direct=yes
hardcode_minus_L=yes
;;
freebsd*)
hardcode_libdir_flag_spec='-R$libdir'
hardcode_direct=yes
;;
hpux9*)
hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
hardcode_libdir_separator=:
hardcode_direct=yes
# hardcode_minus_L: Not really in the search PATH,
# but as the default location of the library.
hardcode_minus_L=yes
;;
hpux10* | hpux11*)
if test "$with_gnu_ld" = no; then
case "$host_cpu" in
hppa*64*)
hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
hardcode_libdir_separator=:
hardcode_direct=no
;;
ia64*)
hardcode_libdir_flag_spec='-L$libdir'
hardcode_direct=no
# hardcode_minus_L: Not really in the search PATH,
# but as the default location of the library.
hardcode_minus_L=yes
;;
*)
hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
hardcode_libdir_separator=:
hardcode_direct=yes
# hardcode_minus_L: Not really in the search PATH,
# but as the default location of the library.
hardcode_minus_L=yes
;;
esac
fi
;;
irix5* | irix6* | nonstopux*)
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
hardcode_libdir_separator=:
;;
netbsd*)
hardcode_libdir_flag_spec='-R$libdir'
hardcode_direct=yes
;;
newsos6)
hardcode_direct=yes
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
hardcode_libdir_separator=:
;;
openbsd*)
hardcode_direct=yes
if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
else
case "$host_os" in
openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
hardcode_libdir_flag_spec='-R$libdir'
;;
*)
hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
;;
esac
fi
;;
os2*)
hardcode_libdir_flag_spec='-L$libdir'
hardcode_minus_L=yes
;;
osf3*)
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
hardcode_libdir_separator=:
;;
osf4* | osf5*)
if test "$GCC" = yes; then
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
else
# Both cc and cxx compiler support -rpath directly
hardcode_libdir_flag_spec='-rpath $libdir'
fi
hardcode_libdir_separator=:
;;
sco3.2v5*)
;;
solaris*)
hardcode_libdir_flag_spec='-R$libdir'
;;
sunos4*)
hardcode_libdir_flag_spec='-L$libdir'
hardcode_direct=yes
hardcode_minus_L=yes
;;
sysv4)
case $host_vendor in
sni)
hardcode_direct=yes # is this really true???
;;
siemens)
hardcode_direct=no
;;
motorola)
hardcode_direct=no #Motorola manual says yes, but my tests say they lie
;;
esac
;;
sysv4.3*)
;;
sysv4*MP*)
if test -d /usr/nec; then
ld_shlibs=yes
fi
;;
sysv4.2uw2*)
hardcode_direct=yes
hardcode_minus_L=no
;;
sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[78]* | unixware7*)
;;
sysv5*)
hardcode_libdir_flag_spec=
;;
uts4*)
hardcode_libdir_flag_spec='-L$libdir'
;;
*)
ld_shlibs=no
;;
esac
fi
# Check dynamic linker characteristics
# Code taken from libtool.m4's AC_LIBTOOL_SYS_DYNAMIC_LINKER.
libname_spec='lib$name'
case "$host_os" in
aix3*)
;;
aix4* | aix5*)
;;
amigaos*)
;;
beos*)
;;
bsdi4*)
;;
cygwin* | mingw* | pw32*)
shrext=.dll
;;
darwin* | rhapsody*)
shrext=.dylib
;;
dgux*)
;;
freebsd1*)
;;
freebsd*)
;;
gnu*)
;;
hpux9* | hpux10* | hpux11*)
case "$host_cpu" in
ia64*)
shrext=.so
;;
hppa*64*)
shrext=.sl
;;
*)
shrext=.sl
;;
esac
;;
irix5* | irix6* | nonstopux*)
case "$host_os" in
irix5* | nonstopux*)
libsuff= shlibsuff=
;;
*)
case $LD in
*-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= ;;
*-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 ;;
*-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 ;;
*) libsuff= shlibsuff= ;;
esac
;;
esac
;;
linux*oldld* | linux*aout* | linux*coff*)
;;
linux*)
;;
netbsd*)
;;
newsos6)
;;
nto-qnx)
;;
openbsd*)
;;
os2*)
libname_spec='$name'
shrext=.dll
;;
osf3* | osf4* | osf5*)
;;
sco3.2v5*)
;;
solaris*)
;;
sunos4*)
;;
sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
;;
sysv4*MP*)
;;
uts4*)
;;
esac
sed_quote_subst='s/\(["`$\\]\)/\\\1/g'
escaped_wl=`echo "X$wl" | sed -e 's/^X//' -e "$sed_quote_subst"`
shlibext=`echo "$shrext" | sed -e 's,^\.,,'`
escaped_hardcode_libdir_flag_spec=`echo "X$hardcode_libdir_flag_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`
sed -e 's/^\([a-zA-Z0-9_]*\)=/acl_cv_\1=/' <<EOF
# How to pass a linker flag through the compiler.
wl="$escaped_wl"
# Static library suffix (normally "a").
libext="$libext"
# Shared library suffix (normally "so").
shlibext="$shlibext"
# Flag to hardcode \$libdir into a binary during linking.
# This must work even if \$libdir does not exist.
hardcode_libdir_flag_spec="$escaped_hardcode_libdir_flag_spec"
# Whether we need a single -rpath flag with a separated argument.
hardcode_libdir_separator="$hardcode_libdir_separator"
# Set to yes if using DIR/libNAME.so during linking hardcodes DIR into the
# resulting binary.
hardcode_direct="$hardcode_direct"
# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
# resulting binary.
hardcode_minus_L="$hardcode_minus_L"
EOF
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
-568
View File
@@ -1,568 +0,0 @@
#! /bin/sh
# texi2dvi --- produce DVI (or PDF) files from Texinfo (or LaTeX) sources.
# $Id: texi2dvi,v 0.43 1999/09/28 19:36:53 karl Exp $
#
# Copyright (C) 1992, 93, 94, 95, 96, 97, 98, 99 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, you can either send email to this
# program's maintainer or write to: The Free Software Foundation,
# Inc.; 59 Temple Place, Suite 330; Boston, MA 02111-1307, USA.
#
# Original author: Noah Friedman <friedman@gnu.org>.
#
# Please send bug reports, etc. to bug-texinfo@gnu.org.
# If possible, please send a copy of the output of the script called with
# the `--debug' option when making a bug report.
# This string is expanded by rcs automatically when this file is checked out.
rcs_revision='$Revision: 0.43 $'
rcs_version=`set - $rcs_revision; echo $2`
program=`echo $0 | sed -e 's!.*/!!'`
version="texi2dvi (GNU Texinfo 4.0) $rcs_version
Copyright (C) 1999 Free Software Foundation, Inc.
There is NO warranty. You may redistribute this software
under the terms of the GNU General Public License.
For more information about these matters, see the files named COPYING."
usage="Usage: $program [OPTION]... FILE...
Run each Texinfo or LaTeX FILE through TeX in turn until all
cross-references are resolved, building all indices. The directory
containing each FILE is searched for included files. The suffix of FILE
is used to determine its language (LaTeX or Texinfo).
Makeinfo is used to perform Texinfo macro expansion before running TeX
when needed.
Options:
-@ Use @input instead of \input; for preloaded Texinfo.
-b, --batch No interaction.
-c, --clean Remove all auxiliary files.
-D, --debug Turn on shell debugging (set -x).
-e, --expand Force macro expansion using makeinfo.
-I DIR Search DIR for Texinfo files.
-h, --help Display this help and exit successfully.
-l, --language=LANG Specify the LANG of FILE: LaTeX or Texinfo.
-p, --pdf Use pdftex or pdflatex for processing.
-q, --quiet No output unless errors (implies --batch).
-s, --silent Same as --quiet.
-t, --texinfo=CMD Insert CMD after @setfilename in copy of input file.
Multiple values accumulate.
-v, --version Display version information and exit successfully.
-V, --verbose Report on what is done.
The values of the BIBTEX, LATEX (or PDFLATEX), MAKEINDEX, MAKEINFO,
TEX (or PDFTEX), and TEXINDEX environment variables are used to run
those commands, if they are set.
Email bug reports to <bug-texinfo@gnu.org>,
general questions and discussion to <help-texinfo@gnu.org>."
# Initialize variables for option overriding and otherwise.
# Don't use `unset' since old bourne shells don't have this command.
# Instead, assign them an empty value.
escape='\'
batch=false # eval for batch mode
clean=
debug=
expand= # t for expansion via makeinfo
oformat=dvi
set_language=
miincludes= # makeinfo include path
textra=
tmpdir=${TMPDIR:-/tmp}/t2d$$ # avoid collisions on 8.3 filesystems.
txincludes= # TEXINPUTS extensions
txiprereq=19990129 # minimum texinfo.tex version to have macro expansion
quiet= # by default let the tools' message be displayed
verbose=false # echo for verbose mode
orig_pwd=`pwd`
# Systems which define $COMSPEC or $ComSpec use semicolons to separate
# directories in TEXINPUTS.
if test -n "$COMSPEC$ComSpec"; then
path_sep=";"
else
path_sep=":"
fi
# Save this so we can construct a new TEXINPUTS path for each file.
TEXINPUTS_orig="$TEXINPUTS"
# Unfortunately makeindex does not read TEXINPUTS.
INDEXSTYLE_orig="$INDEXSTYLE"
export TEXINPUTS INDEXSTYLE
# Push a token among the arguments that will be used to notice when we
# ended options/arguments parsing.
# Use "set dummy ...; shift" rather than 'set - ..." because on
# Solaris set - turns off set -x (but keeps set -e).
# Use ${1+"$@"} rather than "$@" because Digital Unix and Ultrix 4.3
# still expand "$@" to a single argument (the empty string) rather
# than nothing at all.
arg_sep="$$--$$"
set dummy ${1+"$@"} "$arg_sep"; shift
#
# Parse command line arguments.
while test x"$1" != x"$arg_sep"; do
# Handle --option=value by splitting apart and putting back on argv.
case "$1" in
--*=*)
opt=`echo "$1" | sed -e 's/=.*//'`
val=`echo "$1" | sed -e 's/[^=]*=//'`
shift
set dummy "$opt" "$val" ${1+"$@"}; shift
;;
esac
# This recognizes --quark as --quiet. So what.
case "$1" in
-@ ) escape=@;;
# Silently and without documentation accept -b and --b[atch] as synonyms.
-b | --b*) batch=eval;;
-q | -s | --q* | --s*) quiet=t; batch=eval;;
-c | --c*) clean=t;;
-D | --d*) debug=t;;
-e | --e*) expand=t;;
-h | --h*) echo "$usage"; exit 0;;
-I | --I*)
shift
miincludes="$miincludes -I $1"
txincludes="$txincludes$path_sep$1"
;;
-l | --l*) shift; set_language=$1;;
-p | --p*) oformat=pdf;;
-t | --t*) shift; textra="$textra\\
$1";;
-v | --vers*) echo "$version"; exit 0;;
-V | --verb*) verbose=echo;;
--) # What remains are not options.
shift
while test x"$1" != x"$arg_sep"; do
set dummy ${1+"$@"} "$1"; shift
shift
done
break;;
-*)
echo "$0: Unknown or ambiguous option \`$1'." >&2
echo "$0: Try \`--help' for more information." >&2
exit 1;;
*) set dummy ${1+"$@"} "$1"; shift;;
esac
shift
done
# Pop the token
shift
# Interpret remaining command line args as filenames.
if test $# = 0; then
echo "$0: Missing file arguments." >&2
echo "$0: Try \`--help' for more information." >&2
exit 2
fi
# Prepare the temporary directory. Remove it at exit, unless debugging.
if test -z "$debug"; then
trap "cd / && rm -rf $tmpdir" 0 1 2 15
fi
# Create the temporary directory with strict rights
(umask 077 && mkdir $tmpdir) || exit 1
# Prepare the tools we might need. This may be extra work in some
# cases, but improves the readibility of the script.
utildir=$tmpdir/utils
mkdir $utildir || exit 1
# A sed script that preprocesses Texinfo sources in order to keep the
# iftex sections only. We want to remove non TeX sections, and
# comment (with `@c texi2dvi') TeX sections so that makeinfo does not
# try to parse them. Nevertheless, while commenting TeX sections,
# don't comment @macro/@end macro so that makeinfo does propagate
# them. Unfortunately makeinfo --iftex --no-ifhtml --no-ifinfo
# doesn't work well enough (yet) to use that, so work around with sed.
comment_iftex_sed=$utildir/comment.sed
cat <<EOF >$comment_iftex_sed
/^@tex/,/^@end tex/{
s/^/@c texi2dvi/
}
/^@iftex/,/^@end iftex/{
s/^/@c texi2dvi/
/^@c texi2dvi@macro/,/^@c texi2dvi@end macro/{
s/^@c texi2dvi//
}
}
/^@html/,/^@end html/d
/^@ifhtml/,/^@end ifhtml/d
/^@ifnottex/,/^@end ifnottex/d
/^@ifinfo/,/^@end ifinfo/{
/^@node/p
/^@menu/,/^@end menu/p
d
}
EOF
# Uncommenting is simple: Remove any leading `@c texi2dvi'.
uncomment_iftex_sed=$utildir/uncomment.sed
cat <<EOF >$uncomment_iftex_sed
s/^@c texi2dvi//
EOF
# A shell script that computes the list of xref files.
# Takes the filename (without extension) of which we look for xref
# files as argument. The index files must be reported last.
get_xref_files=$utildir/get_xref.sh
cat <<\EOF >$get_xref_files
#! /bin/sh
# Get list of xref files (indexes, tables and lists).
# Find all files having root filename with a two-letter extension,
# saves the ones that are really Texinfo-related files. .?o? catches
# LaTeX tables and lists.
for this_file in "$1".?o? "$1".aux "$1".?? "$1".idx; do
# If file is empty, skip it.
test -s "$this_file" || continue
# If the file is not suitable to be an index or xref file, don't
# process it. The file can't be if its first character is not a
# backslash or single quote.
first_character=`sed -n '1s/^\(.\).*$/\1/p;q' $this_file`
if test "x$first_character" = "x\\" \
|| test "x$first_character" = "x'"; then
xref_files="$xref_files ./$this_file"
fi
done
echo "$xref_files"
EOF
chmod 500 $get_xref_files
# File descriptor usage:
# 0 standard input
# 1 standard output (--verbose messages)
# 2 standard error
# 3 some systems may open it to /dev/tty
# 4 used on the Kubota Titan
# 5 tools output (turned off by --quiet)
# Tools' output. If quiet, discard, else redirect to the message flow.
if test "$quiet" = t; then
exec 5>/dev/null
else
exec 5>&1
fi
# Enable tracing
test "$debug" = t && set -x
#
# TeXify files.
for command_line_filename in ${1+"$@"}; do
$verbose "Processing $command_line_filename ..."
# If the COMMAND_LINE_FILENAME is not absolute (e.g., --debug.tex),
# prepend `./' in order to avoid that the tools take it as an option.
echo "$command_line_filename" | egrep '^(/|[A-z]:/)' >/dev/null \
|| command_line_filename="./$command_line_filename"
# See if the file exists. If it doesn't we're in trouble since, even
# though the user may be able to reenter a valid filename at the tex
# prompt (assuming they're attending the terminal), this script won't
# be able to find the right xref files and so forth.
if test ! -r "$command_line_filename"; then
echo "$0: Could not read $command_line_filename, skipping." >&2
continue
fi
# Get the name of the current directory. We want the full path
# because in clean mode we are in tmp, in which case a relative
# path has no meaning.
filename_dir=`echo $command_line_filename | sed 's!/[^/]*$!!;s!^$!.!'`
filename_dir=`cd "$filename_dir" >/dev/null && pwd`
# Strip directory part but leave extension.
filename_ext=`basename "$command_line_filename"`
# Strip extension.
filename_noext=`echo "$filename_ext" | sed 's/\.[^.]*$//'`
ext=`echo "$filename_ext" | sed 's/^.*\.//'`
# _src. Use same basename since we want to generate aux files with
# the same basename as the manual. If --expand, then output the
# macro-expanded file to here, else copy the original file.
tmpdir_src=$tmpdir/src
filename_src=$tmpdir_src/$filename_noext.$ext
# _xtr. The file with the user's extra commands.
tmpdir_xtr=$tmpdir/xtr
filename_xtr=$tmpdir_xtr/$filename_noext.$ext
# _bak. Copies of the previous xref files (another round is run if
# they differ from the new one).
tmpdir_bak=$tmpdir/bak
# Make all those directories and give up if we can't succeed.
mkdir $tmpdir_src $tmpdir_xtr $tmpdir_bak || exit 1
# Source file might include additional sources. Put `.' and
# directory where source file(s) reside in TEXINPUTS before anything
# else. `.' goes first to ensure that any old .aux, .cps,
# etc. files in ${directory} don't get used in preference to fresher
# files in `.'. Include orig_pwd in case we are in clean mode, where
# we've cd'd to a temp directory.
common=".$path_sep$orig_pwd$path_sep$filename_dir$path_sep$txincludes$path_sep"
TEXINPUTS="$common$TEXINPUTS_orig"
INDEXSTYLE="$common$INDEXSTYLE_orig"
# If the user explicitly specified the language, use that.
# Otherwise, if the first line is \input texinfo, assume it's texinfo.
# Otherwise, guess from the file extension.
if test -n "$set_language"; then
language=$set_language
elif sed 1q "$command_line_filename" | fgrep 'input texinfo' >/dev/null; then
language=texinfo
else
language=
fi
# Get the type of the file (latex or texinfo) from the given language
# we just guessed, or from the file extension if not set yet.
case ${language:-$filename_ext} in
[lL]a[tT]e[xX] | *.ltx | *.tex)
# Assume a LaTeX file. LaTeX needs bibtex and uses latex for
# compilation. No makeinfo.
bibtex=${BIBTEX:-bibtex}
makeinfo= # no point in running makeinfo on latex source.
texindex=${MAKEINDEX:-makeindex}
if test $oformat = dvi; then
tex=${LATEX:-latex}
else
tex=${PDFLATEX:-pdflatex}
fi
;;
*)
# Assume a Texinfo file. Texinfo files need makeinfo, texindex and tex.
bibtex=
texindex=${TEXINDEX:-texindex}
if test $oformat = dvi; then
tex=${TEX:-tex}
else
tex=${PDFTEX:-pdftex}
fi
# Unless required by the user, makeinfo expansion is wanted only
# if texinfo.tex is too old.
if test "$expand" = t; then
makeinfo=${MAKEINFO:-makeinfo}
else
# Check if texinfo.tex performs macro expansion by looking for
# its version. The version is a date of the form YEAR-MO-DA.
# We don't need to use [0-9] to match the digits since anyway
# the comparison with $txiprereq, a number, will fail with non
# digits.
txiversion_tex=txiversion.tex
echo '\input texinfo.tex @bye' >$tmpdir/$txiversion_tex
# Run in the tmpdir to avoid leaving files.
eval `cd $tmpdir >/dev/null \
&& $tex $txiversion_tex 2>/dev/null \
| sed -n 's/^.*\[\(.*\)version \(....\)-\(..\)-\(..\).*$/txiformat=\1 txiversion="\2\3\4"/p'`
$verbose "texinfo.tex preloaded as \`$txiformat', version is \`$txiversion' ..."
if test "$txiprereq" -le "$txiversion" >/dev/null 2>&1; then
makeinfo=
else
makeinfo=${MAKEINFO:-makeinfo}
fi
# As long as we had to run TeX, offer the user this convenience
if test "$txiformat" = Texinfo; then
escape=@
fi
fi
;;
esac
# Expand macro commands in the original source file using Makeinfo.
# Always use `end' footnote style, since the `separate' style
# generates different output (arguably this is a bug in -E).
# Discard main info output, the user asked to run TeX, not makeinfo.
if test -n "$makeinfo"; then
$verbose "Macro-expanding $command_line_filename to $filename_src ..."
sed -f $comment_iftex_sed "$command_line_filename" \
| $makeinfo --footnote-style=end -I "$filename_dir" $miincludes \
-o /dev/null --macro-expand=- \
| sed -f $uncomment_iftex_sed >"$filename_src"
filename_input=$filename_src
fi
# If makeinfo failed (or was not even run), use the original file as input.
if test $? -ne 0 \
|| test ! -r "$filename_src"; then
$verbose "Reverting to $command_line_filename ..."
filename_input=$filename_dir/$filename_ext
fi
# Used most commonly for @finalout, @smallbook, etc.
if test -n "$textra"; then
$verbose "Inserting extra commands: $textra"
sed '/^@setfilename/a\
'"$textra" "$filename_input" >$filename_xtr
filename_input=$filename_xtr
fi
# If clean mode was specified, then move to the temporary directory.
if test "$clean" = t; then
$verbose "cd $tmpdir_src"
cd "$tmpdir_src" || exit 1
fi
while :; do # will break out of loop below
orig_xref_files=`$get_xref_files "$filename_noext"`
# Save copies of originals for later comparison.
if test -n "$orig_xref_files"; then
$verbose "Backing up xref files: `echo $orig_xref_files | sed 's|\./||g'`"
cp $orig_xref_files $tmpdir_bak
fi
# Run bibtex on current file.
# - If its input (AUX) exists.
# - If AUX contains both `\bibdata' and `\bibstyle'.
# - If some citations are missing (LOG contains `Citation').
# or the LOG complains of a missing .bbl
#
# We run bibtex first, because I can see reasons for the indexes
# to change after bibtex is run, but I see no reason for the
# converse.
#
# Don't try to be too smart. Running bibtex only if the bbl file
# exists and is older than the LaTeX file is wrong, since the
# document might include files that have changed. Because there
# can be several AUX (if there are \include's), but a single LOG,
# looking for missing citations in LOG is easier, though we take
# the risk to match false messages.
if test -n "$bibtex" \
&& test -r "$filename_noext.aux" \
&& test -r "$filename_noext.log" \
&& (grep '^\\bibdata[{]' "$filename_noext.aux" \
&& grep '^\\bibstyle[{]' "$filename_noext.aux" \
&& (grep 'Warning:.*Citation.*undefined' "$filename_noext.log" \
|| grep 'No file .*\.bbl\.' "$filename_noext.log")) \
>/dev/null 2>&1; \
then
$verbose "Running $bibtex $filename_noext ..."
if $bibtex "$filename_noext" >&5; then :; else
echo "$0: $bibtex exited with bad status, quitting." >&2
exit 1
fi
fi
# What we'll run texindex on -- exclude non-index files.
# Since we know index files are last, it is correct to remove everything
# before .aux and .?o?.
index_files=`echo "$orig_xref_files" \
| sed "s!.*\.aux!!g;
s!./$filename_noext\..o.!!g;
s/^[ ]*//;s/[ ]*$//"`
# Run texindex (or makeindex) on current index files. If they
# already exist, and after running TeX a first time the index
# files don't change, then there's no reason to run TeX again.
# But we won't know that if the index files are out of date or
# nonexistent.
if test -n "$texindex" && test -n "$index_files"; then
$verbose "Running $texindex $index_files ..."
if $texindex $index_files 2>&5 1>&2; then :; else
echo "$0: $texindex exited with bad status, quitting." >&2
exit 1
fi
fi
# Finally, run TeX.
# Prevent $ESCAPE from being interpreted by the shell if it happens
# to be `/'.
$batch tex_args="\\${escape}nonstopmode\ \\${escape}input"
$verbose "Running $cmd ..."
cmd="$tex $tex_args $filename_input"
if $cmd >&5; then :; else
echo "$0: $tex exited with bad status, quitting." >&2
echo "$0: see $filename_noext.log for errors." >&2
test "$clean" = t \
&& cp "$filename_noext.log" "$orig_pwd"
exit 1
fi
# Decide if looping again is needed.
finished=t
# LaTeX (and the package changebar) report in the LOG file if it
# should be rerun. This is needed for files included from
# subdirs, since texi2dvi does not try to compare xref files in
# subdirs. Performing xref files test is still good since LaTeX
# does not report changes in xref files.
if fgrep "Rerun to get" "$filename_noext.log" >/dev/null 2>&1; then
finished=
fi
# Check if xref files changed.
new_xref_files=`$get_xref_files "$filename_noext"`
$verbose "Original xref files = `echo $orig_xref_files | sed 's|\./||g'`"
$verbose "New xref files = `echo $new_xref_files | sed 's|\./||g'`"
# If old and new lists don't at least have the same file list,
# then one file or another has definitely changed.
test "x$orig_xref_files" != "x$new_xref_files" && finished=
# File list is the same. We must compare each file until we find
# a difference.
if test -n "$finished"; then
for this_file in $new_xref_files; do
$verbose "Comparing xref file `echo $this_file | sed 's|\./||g'` ..."
# cmp -s returns nonzero exit status if files differ.
if cmp -s "$this_file" "$tmpdir_bak/$this_file"; then :; else
# We only need to keep comparing until we find one that
# differs, because we'll have to run texindex & tex again no
# matter how many more there might be.
finished=
$verbose "xref file `echo $this_file | sed 's|\./||g'` differed ..."
test "$debug" = t && diff -c "$tmpdir_bak/$this_file" "$this_file"
break
fi
done
fi
# If finished, exit the loop, else rerun the loop.
test -n "$finished" && break
done
# If we were in clean mode, compilation was in a tmp directory.
# Copy the DVI (or PDF) file into the directory where the compilation
# has been done. (The temp dir is about to get removed anyway.)
# We also return to the original directory so that
# - the next file is processed in correct conditions
# - the temporary file can be removed
if test -n "$clean"; then
$verbose "Copying $oformat file from `pwd` to $orig_pwd"
cp -p "./$filename_noext.$oformat" "$orig_pwd"
cd / # in case $orig_pwd is on a different drive (for DOS)
cd $orig_pwd || exit 1
fi
# Remove temporary files.
if test "x$debug" = "x"; then
$verbose "Removing $tmpdir_src $tmpdir_xtr $tmpdir_bak ..."
cd /
rm -rf $tmpdir_src $tmpdir_xtr $tmpdir_bak
fi
done
$verbose "$0 done."
exit 0 # exit successfully, not however we ended the loop.
-604
View File
@@ -1,604 +0,0 @@
#! /bin/sh
# texi2dvi --- produce DVI (or PDF) files from Texinfo (or LaTeX) sources.
# $Id: texi2dvi,v 0.46 2001/06/07 18:43:25 karl Exp $
#
# Copyright (C) 1992, 93, 94, 95, 96, 97, 98, 99, 2001
# Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, you can either send email to this
# program's maintainer or write to: The Free Software Foundation,
# Inc.; 59 Temple Place, Suite 330; Boston, MA 02111-1307, USA.
#
# Original author: Noah Friedman <friedman@gnu.org>.
#
# Please send bug reports, etc. to bug-texinfo@gnu.org.
# If possible, please send a copy of the output of the script called with
# the `--debug' option when making a bug report.
# This string is expanded by rcs automatically when this file is checked out.
rcs_revision='$Revision: 0.46 $'
rcs_version=`set - $rcs_revision; echo $2`
program=`echo $0 | sed -e 's!.*/!!'`
version="texi2dvi (GNU Texinfo 4.0) $rcs_version
Copyright (C) 1999 Free Software Foundation, Inc.
There is NO warranty. You may redistribute this software
under the terms of the GNU General Public License.
For more information about these matters, see the files named COPYING."
usage="Usage: $program [OPTION]... FILE...
Run each Texinfo or LaTeX FILE through TeX in turn until all
cross-references are resolved, building all indices. The directory
containing each FILE is searched for included files. The suffix of FILE
is used to determine its language (LaTeX or Texinfo).
Makeinfo is used to perform Texinfo macro expansion before running TeX
when needed.
Operation modes:
-b, --batch no interaction
-c, --clean remove all auxiliary files
-D, --debug turn on shell debugging (set -x)
-h, --help display this help and exit successfully
-o, --output=OFILE leave output in OFILE (implies --clean);
Only one input FILE may be specified in this case
-q, --quiet no output unless errors (implies --batch)
-s, --silent same as --quiet
-v, --version display version information and exit successfully
-V, --verbose report on what is done
TeX tuning:
-@ use @input instead of \input; for preloaded Texinfo
-e, --expand force macro expansion using makeinfo
-I DIR search DIR for Texinfo files
-l, --language=LANG specify the LANG of FILE (LaTeX or Texinfo)
-p, --pdf use pdftex or pdflatex for processing
-t, --texinfo=CMD insert CMD after @setfilename in copy of input file
multiple values accumulate
The values of the BIBTEX, LATEX (or PDFLATEX), MAKEINDEX, MAKEINFO,
TEX (or PDFTEX), and TEXINDEX environment variables are used to run
those commands, if they are set.
Email bug reports to <bug-texinfo@gnu.org>,
general questions and discussion to <help-texinfo@gnu.org>."
# Initialize variables for option overriding and otherwise.
# Don't use `unset' since old bourne shells don't have this command.
# Instead, assign them an empty value.
batch=false # eval for batch mode
clean=
debug=
escape='\'
expand= # t for expansion via makeinfo
miincludes= # makeinfo include path
oformat=dvi
oname= # --output
quiet= # by default let the tools' message be displayed
set_language=
textra=
tmpdir=${TMPDIR:-/tmp}/t2d$$ # avoid collisions on 8.3 filesystems.
txincludes= # TEXINPUTS extensions
txiprereq=19990129 # minimum texinfo.tex version to have macro expansion
verbose=false # echo for verbose mode
orig_pwd=`pwd`
# Systems which define $COMSPEC or $ComSpec use semicolons to separate
# directories in TEXINPUTS.
if test -n "$COMSPEC$ComSpec"; then
path_sep=";"
else
path_sep=":"
fi
# Save this so we can construct a new TEXINPUTS path for each file.
TEXINPUTS_orig="$TEXINPUTS"
# Unfortunately makeindex does not read TEXINPUTS.
INDEXSTYLE_orig="$INDEXSTYLE"
export TEXINPUTS INDEXSTYLE
# Push a token among the arguments that will be used to notice when we
# ended options/arguments parsing.
# Use "set dummy ...; shift" rather than 'set - ..." because on
# Solaris set - turns off set -x (but keeps set -e).
# Use ${1+"$@"} rather than "$@" because Digital Unix and Ultrix 4.3
# still expand "$@" to a single argument (the empty string) rather
# than nothing at all.
arg_sep="$$--$$"
set dummy ${1+"$@"} "$arg_sep"; shift
#
# Parse command line arguments.
while test x"$1" != x"$arg_sep"; do
# Handle --option=value by splitting apart and putting back on argv.
case "$1" in
--*=*)
opt=`echo "$1" | sed -e 's/=.*//'`
val=`echo "$1" | sed -e 's/[^=]*=//'`
shift
set dummy "$opt" "$val" ${1+"$@"}; shift
;;
esac
# This recognizes --quark as --quiet. So what.
case "$1" in
-@ ) escape=@;;
# Silently and without documentation accept -b and --b[atch] as synonyms.
-b | --b*) batch=eval;;
-q | -s | --q* | --s*) quiet=t; batch=eval;;
-c | --c*) clean=t;;
-D | --d*) debug=t;;
-e | --e*) expand=t;;
-h | --h*) echo "$usage"; exit 0;;
-I | --I*)
shift
miincludes="$miincludes -I $1"
txincludes="$txincludes$path_sep$1"
;;
-l | --l*) shift; set_language=$1;;
-o | --o*)
shift
clean=t
case "$1" in
/* | ?:/*) oname=$1;;
*) oname="$orig_pwd/$1";;
esac;;
-p | --p*) oformat=pdf;;
-t | --t*) shift; textra="$textra\\
$1";;
-v | --vers*) echo "$version"; exit 0;;
-V | --verb*) verbose=echo;;
--) # What remains are not options.
shift
while test x"$1" != x"$arg_sep"; do
set dummy ${1+"$@"} "$1"; shift
shift
done
break;;
-*)
echo "$0: Unknown or ambiguous option \`$1'." >&2
echo "$0: Try \`--help' for more information." >&2
exit 1;;
*) set dummy ${1+"$@"} "$1"; shift;;
esac
shift
done
# Pop the token
shift
# Interpret remaining command line args as filenames.
case $# in
0)
echo "$0: Missing file arguments." >&2
echo "$0: Try \`--help' for more information." >&2
exit 2
;;
1) ;;
*)
if test -n "$oname"; then
echo "$0: Can't use option \`--output' with more than one argument." >&2
exit 2
fi
;;
esac
# Prepare the temporary directory. Remove it at exit, unless debugging.
if test -z "$debug"; then
trap "cd / && rm -rf $tmpdir" 0 1 2 15
fi
# Create the temporary directory with strict rights
(umask 077 && mkdir $tmpdir) || exit 1
# Prepare the tools we might need. This may be extra work in some
# cases, but improves the readibility of the script.
utildir=$tmpdir/utils
mkdir $utildir || exit 1
# A sed script that preprocesses Texinfo sources in order to keep the
# iftex sections only. We want to remove non TeX sections, and
# comment (with `@c texi2dvi') TeX sections so that makeinfo does not
# try to parse them. Nevertheless, while commenting TeX sections,
# don't comment @macro/@end macro so that makeinfo does propagate
# them. Unfortunately makeinfo --iftex --no-ifhtml --no-ifinfo
# doesn't work well enough (yet) to use that, so work around with sed.
comment_iftex_sed=$utildir/comment.sed
cat <<EOF >$comment_iftex_sed
/^@tex/,/^@end tex/{
s/^/@c texi2dvi/
}
/^@iftex/,/^@end iftex/{
s/^/@c texi2dvi/
/^@c texi2dvi@macro/,/^@c texi2dvi@end macro/{
s/^@c texi2dvi//
}
}
/^@html/,/^@end html/{
s/^/@c (texi2dvi)/
}
/^@ifhtml/,/^@end ifhtml/{
s/^/@c (texi2dvi)/
}
/^@ifnottex/,/^@end ifnottex/{
s/^/@c (texi2dvi)/
}
/^@ifinfo/,/^@end ifinfo/{
/^@node/p
/^@menu/,/^@end menu/p
t
s/^/@c (texi2dvi)/
}
s/^@ifnotinfo/@c texi2dvi@ifnotinfo/
s/^@end ifnotinfo/@c texi2dvi@end ifnotinfo/
EOF
# Uncommenting is simple: Remove any leading `@c texi2dvi'.
uncomment_iftex_sed=$utildir/uncomment.sed
cat <<EOF >$uncomment_iftex_sed
s/^@c texi2dvi//
EOF
# A shell script that computes the list of xref files.
# Takes the filename (without extension) of which we look for xref
# files as argument. The index files must be reported last.
get_xref_files=$utildir/get_xref.sh
cat <<\EOF >$get_xref_files
#! /bin/sh
# Get list of xref files (indexes, tables and lists).
# Find all files having root filename with a two-letter extension,
# saves the ones that are really Texinfo-related files. .?o? catches
# LaTeX tables and lists.
for this_file in "$1".?o? "$1".aux "$1".?? "$1".idx; do
# If file is empty, skip it.
test -s "$this_file" || continue
# If the file is not suitable to be an index or xref file, don't
# process it. The file can't be if its first character is not a
# backslash or single quote.
first_character=`sed -n '1s/^\(.\).*$/\1/p;q' $this_file`
if test "x$first_character" = "x\\" \
|| test "x$first_character" = "x'"; then
xref_files="$xref_files ./$this_file"
fi
done
echo "$xref_files"
EOF
chmod 500 $get_xref_files
# File descriptor usage:
# 0 standard input
# 1 standard output (--verbose messages)
# 2 standard error
# 3 some systems may open it to /dev/tty
# 4 used on the Kubota Titan
# 5 tools output (turned off by --quiet)
# Tools' output. If quiet, discard, else redirect to the message flow.
if test "$quiet" = t; then
exec 5>/dev/null
else
exec 5>&1
fi
# Enable tracing
test "$debug" = t && set -x
#
# TeXify files.
for command_line_filename in ${1+"$@"}; do
$verbose "Processing $command_line_filename ..."
# If the COMMAND_LINE_FILENAME is not absolute (e.g., --debug.tex),
# prepend `./' in order to avoid that the tools take it as an option.
echo "$command_line_filename" | egrep '^(/|[A-z]:/)' >/dev/null \
|| command_line_filename="./$command_line_filename"
# See if the file exists. If it doesn't we're in trouble since, even
# though the user may be able to reenter a valid filename at the tex
# prompt (assuming they're attending the terminal), this script won't
# be able to find the right xref files and so forth.
if test ! -r "$command_line_filename"; then
echo "$0: Could not read $command_line_filename, skipping." >&2
continue
fi
# Get the name of the current directory. We want the full path
# because in clean mode we are in tmp, in which case a relative
# path has no meaning.
filename_dir=`echo $command_line_filename | sed 's!/[^/]*$!!;s!^$!.!'`
filename_dir=`cd "$filename_dir" >/dev/null && pwd`
# Strip directory part but leave extension.
filename_ext=`basename "$command_line_filename"`
# Strip extension.
filename_noext=`echo "$filename_ext" | sed 's/\.[^.]*$//'`
ext=`echo "$filename_ext" | sed 's/^.*\.//'`
# _src. Use same basename since we want to generate aux files with
# the same basename as the manual. If --expand, then output the
# macro-expanded file to here, else copy the original file.
tmpdir_src=$tmpdir/src
filename_src=$tmpdir_src/$filename_noext.$ext
# _xtr. The file with the user's extra commands.
tmpdir_xtr=$tmpdir/xtr
filename_xtr=$tmpdir_xtr/$filename_noext.$ext
# _bak. Copies of the previous xref files (another round is run if
# they differ from the new one).
tmpdir_bak=$tmpdir/bak
# Make all those directories and give up if we can't succeed.
mkdir $tmpdir_src $tmpdir_xtr $tmpdir_bak || exit 1
# Source file might include additional sources. Put `.' and
# directory where source file(s) reside in TEXINPUTS before anything
# else. `.' goes first to ensure that any old .aux, .cps,
# etc. files in ${directory} don't get used in preference to fresher
# files in `.'. Include orig_pwd in case we are in clean mode, where
# we've cd'd to a temp directory.
common=".$path_sep$orig_pwd$path_sep$filename_dir$path_sep$txincludes$path_sep"
TEXINPUTS="$common$TEXINPUTS_orig"
INDEXSTYLE="$common$INDEXSTYLE_orig"
# If the user explicitly specified the language, use that.
# Otherwise, if the first line is \input texinfo, assume it's texinfo.
# Otherwise, guess from the file extension.
if test -n "$set_language"; then
language=$set_language
elif sed 1q "$command_line_filename" | fgrep 'input texinfo' >/dev/null; then
language=texinfo
else
language=
fi
# Get the type of the file (latex or texinfo) from the given language
# we just guessed, or from the file extension if not set yet.
case ${language:-$filename_ext} in
[lL]a[tT]e[xX] | *.ltx | *.tex)
# Assume a LaTeX file. LaTeX needs bibtex and uses latex for
# compilation. No makeinfo.
bibtex=${BIBTEX:-bibtex}
makeinfo= # no point in running makeinfo on latex source.
texindex=${MAKEINDEX:-makeindex}
if test $oformat = dvi; then
tex=${LATEX:-latex}
else
tex=${PDFLATEX:-pdflatex}
fi
;;
*)
# Assume a Texinfo file. Texinfo files need makeinfo, texindex and tex.
bibtex=
texindex=${TEXINDEX:-texindex}
if test $oformat = dvi; then
tex=${TEX:-tex}
else
tex=${PDFTEX:-pdftex}
fi
# Unless required by the user, makeinfo expansion is wanted only
# if texinfo.tex is too old.
if test "$expand" = t; then
makeinfo=${MAKEINFO:-makeinfo}
else
# Check if texinfo.tex performs macro expansion by looking for
# its version. The version is a date of the form YEAR-MO-DA.
# We don't need to use [0-9] to match the digits since anyway
# the comparison with $txiprereq, a number, will fail with non
# digits.
txiversion_tex=txiversion.tex
echo '\input texinfo.tex @bye' >$tmpdir/$txiversion_tex
# Run in the tmpdir to avoid leaving files.
eval `cd $tmpdir >/dev/null &&
$tex $txiversion_tex 2>/dev/null |
sed -n 's/^.*\[\(.*\)version \(....\)-\(..\)-\(..\).*$/txiformat=\1 txiversion="\2\3\4"/p'`
$verbose "texinfo.tex preloaded as \`$txiformat', version is \`$txiversion' ..."
if test "$txiprereq" -le "$txiversion" >/dev/null 2>&1; then
makeinfo=
else
makeinfo=${MAKEINFO:-makeinfo}
fi
# As long as we had to run TeX, offer the user this convenience
if test "$txiformat" = Texinfo; then
escape=@
fi
fi
;;
esac
# Expand macro commands in the original source file using Makeinfo.
# Always use `end' footnote style, since the `separate' style
# generates different output (arguably this is a bug in -E).
# Discard main info output, the user asked to run TeX, not makeinfo.
if test -n "$makeinfo"; then
$verbose "Macro-expanding $command_line_filename to $filename_src ..."
sed -f $comment_iftex_sed "$command_line_filename" \
| $makeinfo --footnote-style=end -I "$filename_dir" $miincludes \
-o /dev/null --macro-expand=- \
| sed -f $uncomment_iftex_sed >"$filename_src"
filename_input=$filename_src
fi
# If makeinfo failed (or was not even run), use the original file as input.
if test $? -ne 0 \
|| test ! -r "$filename_src"; then
$verbose "Reverting to $command_line_filename ..."
filename_input=$filename_dir/$filename_ext
fi
# Used most commonly for @finalout, @smallbook, etc.
if test -n "$textra"; then
$verbose "Inserting extra commands: $textra"
sed '/^@setfilename/a\
'"$textra" "$filename_input" >$filename_xtr
filename_input=$filename_xtr
fi
# If clean mode was specified, then move to the temporary directory.
if test "$clean" = t; then
$verbose "cd $tmpdir_src"
cd "$tmpdir_src" || exit 1
fi
while :; do # will break out of loop below
orig_xref_files=`$get_xref_files "$filename_noext"`
# Save copies of originals for later comparison.
if test -n "$orig_xref_files"; then
$verbose "Backing up xref files: `echo $orig_xref_files | sed 's|\./||g'`"
cp $orig_xref_files $tmpdir_bak
fi
# Run bibtex on current file.
# - If its input (AUX) exists.
# - If AUX contains both `\bibdata' and `\bibstyle'.
# - If some citations are missing (LOG contains `Citation').
# or the LOG complains of a missing .bbl
#
# We run bibtex first, because I can see reasons for the indexes
# to change after bibtex is run, but I see no reason for the
# converse.
#
# Don't try to be too smart. Running bibtex only if the bbl file
# exists and is older than the LaTeX file is wrong, since the
# document might include files that have changed. Because there
# can be several AUX (if there are \include's), but a single LOG,
# looking for missing citations in LOG is easier, though we take
# the risk to match false messages.
if test -n "$bibtex" \
&& test -r "$filename_noext.aux" \
&& test -r "$filename_noext.log" \
&& (grep '^\\bibdata[{]' "$filename_noext.aux" \
&& grep '^\\bibstyle[{]' "$filename_noext.aux" \
&& (grep 'Warning:.*Citation.*undefined' "$filename_noext.log" \
|| grep 'No file .*\.bbl\.' "$filename_noext.log")) \
>/dev/null 2>&1; \
then
$verbose "Running $bibtex $filename_noext ..."
if $bibtex "$filename_noext" >&5; then :; else
echo "$0: $bibtex exited with bad status, quitting." >&2
exit 1
fi
fi
# What we'll run texindex on -- exclude non-index files.
# Since we know index files are last, it is correct to remove everything
# before .aux and .?o?.
index_files=`echo "$orig_xref_files" \
| sed "s!.*\.aux!!g;
s!./$filename_noext\..o.!!g;
s/^[ ]*//;s/[ ]*$//"`
# Run texindex (or makeindex) on current index files. If they
# already exist, and after running TeX a first time the index
# files don't change, then there's no reason to run TeX again.
# But we won't know that if the index files are out of date or
# nonexistent.
if test -n "$texindex" && test -n "$index_files"; then
$verbose "Running $texindex $index_files ..."
if $texindex $index_files 2>&5 1>&2; then :; else
echo "$0: $texindex exited with bad status, quitting." >&2
exit 1
fi
fi
# Finally, run TeX.
# Prevent $ESCAPE from being interpreted by the shell if it happens
# to be `/'.
$batch tex_args="\\${escape}nonstopmode\ \\${escape}input"
$verbose "Running $cmd ..."
cmd="$tex $tex_args $filename_input"
if $cmd >&5; then :; else
echo "$0: $tex exited with bad status, quitting." >&2
echo "$0: see $filename_noext.log for errors." >&2
test "$clean" = t \
&& cp "$filename_noext.log" "$orig_pwd"
exit 1
fi
# Decide if looping again is needed.
finished=t
# LaTeX (and the package changebar) report in the LOG file if it
# should be rerun. This is needed for files included from
# subdirs, since texi2dvi does not try to compare xref files in
# subdirs. Performing xref files test is still good since LaTeX
# does not report changes in xref files.
if fgrep "Rerun to get" "$filename_noext.log" >/dev/null 2>&1; then
finished=
fi
# Check if xref files changed.
new_xref_files=`$get_xref_files "$filename_noext"`
$verbose "Original xref files = `echo $orig_xref_files | sed 's|\./||g'`"
$verbose "New xref files = `echo $new_xref_files | sed 's|\./||g'`"
# If old and new lists don't at least have the same file list,
# then one file or another has definitely changed.
test "x$orig_xref_files" != "x$new_xref_files" && finished=
# File list is the same. We must compare each file until we find
# a difference.
if test -n "$finished"; then
for this_file in $new_xref_files; do
$verbose "Comparing xref file `echo $this_file | sed 's|\./||g'` ..."
# cmp -s returns nonzero exit status if files differ.
if cmp -s "$this_file" "$tmpdir_bak/$this_file"; then :; else
# We only need to keep comparing until we find one that
# differs, because we'll have to run texindex & tex again no
# matter how many more there might be.
finished=
$verbose "xref file `echo $this_file | sed 's|\./||g'` differed ..."
test "$debug" = t && diff -c "$tmpdir_bak/$this_file" "$this_file"
break
fi
done
fi
# If finished, exit the loop, else rerun the loop.
test -n "$finished" && break
done
# If we were in clean mode, compilation was in a tmp directory.
# Copy the DVI (or PDF) file into the directory where the compilation
# has been done. (The temp dir is about to get removed anyway.)
# We also return to the original directory so that
# - the next file is processed in correct conditions
# - the temporary file can be removed
if test -n "$clean"; then
if test -n "$oname"; then
dest=$oname
else
dest=$orig_pwd
fi
$verbose "Copying $oformat file from `pwd` to $dest"
cp -p "./$filename_noext.$oformat" "$dest"
cd / # in case $orig_pwd is on a different drive (for DOS)
cd $orig_pwd || exit 1
fi
# Remove temporary files.
if test "x$debug" = "x"; then
$verbose "Removing $tmpdir_src $tmpdir_xtr $tmpdir_bak ..."
cd /
rm -rf $tmpdir_src $tmpdir_xtr $tmpdir_bak
fi
done
$verbose "$0 done."
exit 0 # exit successfully, not however we ended the loop.
-658
View File
@@ -1,658 +0,0 @@
#! /bin/sh
# texi2dvi --- produce DVI (or PDF) files from Texinfo (or LaTeX) sources.
# $Id: texi2dvi,v 1.14 2003/02/05 00:42:33 karl Exp $
#
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2001,
# 2002, 2003 Free Software Foundation, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Original author: Noah Friedman <friedman@gnu.org>.
#
# Please send bug reports, etc. to bug-texinfo@gnu.org.
# If possible, please send a copy of the output of the script called with
# the `--debug' option when making a bug report.
# This string is expanded by rcs automatically when this file is checked out.
rcs_revision='$Revision: 1.14 $'
rcs_version=`set - $rcs_revision; echo $2`
program=`echo $0 | sed -e 's!.*/!!'`
version="texi2dvi (GNU Texinfo 4.5) $rcs_version
Copyright (C) 2003 Free Software Foundation, Inc.
There is NO warranty. You may redistribute this software
under the terms of the GNU General Public License.
For more information about these matters, see the files named COPYING."
usage="Usage: $program [OPTION]... FILE...
Run each Texinfo or LaTeX FILE through TeX in turn until all
cross-references are resolved, building all indices. The directory
containing each FILE is searched for included files. The suffix of FILE
is used to determine its language (LaTeX or Texinfo).
Makeinfo is used to perform Texinfo macro expansion before running TeX
when needed.
Operation modes:
-b, --batch no interaction
-c, --clean remove all auxiliary files
-D, --debug turn on shell debugging (set -x)
-h, --help display this help and exit successfully
-o, --output=OFILE leave output in OFILE (implies --clean);
Only one input FILE may be specified in this case
-q, --quiet no output unless errors (implies --batch)
-s, --silent same as --quiet
-v, --version display version information and exit successfully
-V, --verbose report on what is done
TeX tuning:
-@ use @input instead of \input; for preloaded Texinfo
-e, -E, --expand force macro expansion using makeinfo
-I DIR search DIR for Texinfo files
-l, --language=LANG specify the LANG of FILE (LaTeX or Texinfo)
-p, --pdf use pdftex or pdflatex for processing
-t, --texinfo=CMD insert CMD after @setfilename in copy of input file
multiple values accumulate
The values of the BIBTEX, LATEX (or PDFLATEX), MAKEINDEX, MAKEINFO,
TEX (or PDFTEX), and TEXINDEX environment variables are used to run
those commands, if they are set.
Email bug reports to <bug-texinfo@gnu.org>,
general questions and discussion to <help-texinfo@gnu.org>.
Texinfo home page: http://www.gnu.org/software/texinfo/"
# Initialize variables for option overriding and otherwise.
# Don't use `unset' since old bourne shells don't have this command.
# Instead, assign them an empty value.
batch=false # eval for batch mode
clean=
debug=
escape='\'
expand= # t for expansion via makeinfo
miincludes= # makeinfo include path
oformat=dvi
oname= # --output
quiet= # by default let the tools' message be displayed
set_language=
textra=
tmpdir=${TMPDIR:-/tmp}/t2d$$ # avoid collisions on 8.3 filesystems.
txincludes= # TEXINPUTS extensions, with trailing colon
txiprereq=19990129 # minimum texinfo.tex version to have macro expansion
verbose=false # echo for verbose mode
orig_pwd=`pwd`
# Systems which define $COMSPEC or $ComSpec use semicolons to separate
# directories in TEXINPUTS.
if test -n "$COMSPEC$ComSpec"; then
path_sep=";"
else
path_sep=":"
fi
# Pacify verbose cds.
CDPATH=${ZSH_VERSION+.}$path_sep
# In case someone crazy insists on using grep -E.
: ${EGREP=egrep}
# Save this so we can construct a new TEXINPUTS path for each file.
TEXINPUTS_orig="$TEXINPUTS"
# Unfortunately makeindex does not read TEXINPUTS.
INDEXSTYLE_orig="$INDEXSTYLE"
export TEXINPUTS INDEXSTYLE
# Push a token among the arguments that will be used to notice when we
# ended options/arguments parsing.
# Use "set dummy ...; shift" rather than 'set - ..." because on
# Solaris set - turns off set -x (but keeps set -e).
# Use ${1+"$@"} rather than "$@" because Digital Unix and Ultrix 4.3
# still expand "$@" to a single argument (the empty string) rather
# than nothing at all.
arg_sep="$$--$$"
set dummy ${1+"$@"} "$arg_sep"; shift
#
# Parse command line arguments.
while test x"$1" != x"$arg_sep"; do
# Handle --option=value by splitting apart and putting back on argv.
case "$1" in
--*=*)
opt=`echo "$1" | sed -e 's/=.*//'`
val=`echo "$1" | sed -e 's/[^=]*=//'`
shift
set dummy "$opt" "$val" ${1+"$@"}; shift
;;
esac
# This recognizes --quark as --quiet. So what.
case "$1" in
-@ ) escape=@;;
# Silently and without documentation accept -b and --b[atch] as synonyms.
-b | --b*) batch=eval;;
-q | -s | --q* | --s*) quiet=t; batch=eval;;
-c | --c*) clean=t;;
-D | --d*) debug=t;;
-e | -E | --e*) expand=t;;
-h | --h*) echo "$usage"; exit 0;;
-I | --I*)
shift
miincludes="$miincludes -I $1"
txincludes="$txincludes$1$path_sep"
;;
-l | --l*) shift; set_language=$1;;
-o | --o*)
shift
clean=t
case "$1" in
/* | ?:/*) oname=$1;;
*) oname="$orig_pwd/$1";;
esac;;
-p | --p*) oformat=pdf;;
-t | --t*) shift; textra="$textra\\
$1";;
-v | --vers*) echo "$version"; exit 0;;
-V | --verb*) verbose=echo;;
--) # What remains are not options.
shift
while test x"$1" != x"$arg_sep"; do
set dummy ${1+"$@"} "$1"; shift
shift
done
break;;
-*)
echo "$0: Unknown or ambiguous option \`$1'." >&2
echo "$0: Try \`--help' for more information." >&2
exit 1;;
*) set dummy ${1+"$@"} "$1"; shift;;
esac
shift
done
# Pop the token
shift
# Interpret remaining command line args as filenames.
case $# in
0)
echo "$0: Missing file arguments." >&2
echo "$0: Try \`--help' for more information." >&2
exit 2
;;
1) ;;
*)
if test -n "$oname"; then
echo "$0: Can't use option \`--output' with more than one argument." >&2
exit 2
fi
;;
esac
# Prepare the temporary directory. Remove it at exit, unless debugging.
if test -z "$debug"; then
trap "cd / && rm -rf $tmpdir" 0 1 2 15
fi
# Create the temporary directory with strict rights
(umask 077 && mkdir $tmpdir) || exit 1
# Prepare the tools we might need. This may be extra work in some
# cases, but improves the readibility of the script.
utildir=$tmpdir/utils
mkdir $utildir || exit 1
# A sed script that preprocesses Texinfo sources in order to keep the
# iftex sections only. We want to remove non TeX sections, and
# comment (with `@c texi2dvi') TeX sections so that makeinfo does not
# try to parse them. Nevertheless, while commenting TeX sections,
# don't comment @macro/@end macro so that makeinfo does propagate
# them. Unfortunately makeinfo --iftex --no-ifhtml --no-ifinfo
# doesn't work well enough (yet) to use that, so work around with sed.
comment_iftex_sed=$utildir/comment.sed
cat <<EOF >$comment_iftex_sed
/^@tex/,/^@end tex/{
s/^/@c texi2dvi/
}
/^@iftex/,/^@end iftex/{
s/^/@c texi2dvi/
/^@c texi2dvi@macro/,/^@c texi2dvi@end macro/{
s/^@c texi2dvi//
}
}
/^@html/,/^@end html/{
s/^/@c (texi2dvi)/
}
/^@ifhtml/,/^@end ifhtml/{
s/^/@c (texi2dvi)/
}
/^@ifnottex/,/^@end ifnottex/{
s/^/@c (texi2dvi)/
}
/^@ifinfo/,/^@end ifinfo/{
/^@node/p
/^@menu/,/^@end menu/p
t
s/^/@c (texi2dvi)/
}
s/^@ifnotinfo/@c texi2dvi@ifnotinfo/
s/^@end ifnotinfo/@c texi2dvi@end ifnotinfo/
EOF
# Uncommenting is simple: Remove any leading `@c texi2dvi'.
uncomment_iftex_sed=$utildir/uncomment.sed
cat <<EOF >$uncomment_iftex_sed
s/^@c texi2dvi//
EOF
# A shell script that computes the list of xref files.
# Takes the filename (without extension) of which we look for xref
# files as argument. The index files must be reported last.
get_xref_files=$utildir/get_xref.sh
cat <<\EOF >$get_xref_files
#! /bin/sh
# Get list of xref files (indexes, tables and lists).
# Find all files having root filename with a two-letter extension,
# saves the ones that are really Texinfo-related files. .?o? catches
# many files: .toc, .log, LaTeX tables and lists, FiXme's .lox, maybe more.
for this_file in "$1".?o? "$1".aux "$1".?? "$1".idx; do
# If file is empty, skip it.
test -s "$this_file" || continue
# If the file is not suitable to be an index or xref file, don't
# process it. The file can't be if its first character is not a
# backslash or single quote.
first_character=`sed -n '1s/^\(.\).*$/\1/p;q' $this_file`
if test "x$first_character" = "x\\" \
|| test "x$first_character" = "x'"; then
xref_files="$xref_files ./$this_file"
fi
done
echo "$xref_files"
EOF
chmod 500 $get_xref_files
# File descriptor usage:
# 0 standard input
# 1 standard output (--verbose messages)
# 2 standard error
# 3 some systems may open it to /dev/tty
# 4 used on the Kubota Titan
# 5 tools output (turned off by --quiet)
# Tools' output. If quiet, discard, else redirect to the message flow.
if test "$quiet" = t; then
exec 5>/dev/null
else
exec 5>&1
fi
# Enable tracing
test "$debug" = t && set -x
#
# TeXify files.
for command_line_filename in ${1+"$@"}; do
$verbose "Processing $command_line_filename ..."
# If the COMMAND_LINE_FILENAME is not absolute (e.g., --debug.tex),
# prepend `./' in order to avoid that the tools take it as an option.
echo "$command_line_filename" | $EGREP '^(/|[A-z]:/)' >/dev/null \
|| command_line_filename="./$command_line_filename"
# See if the file exists. If it doesn't we're in trouble since, even
# though the user may be able to reenter a valid filename at the tex
# prompt (assuming they're attending the terminal), this script won't
# be able to find the right xref files and so forth.
if test ! -r "$command_line_filename"; then
echo "$0: Could not read $command_line_filename, skipping." >&2
continue
fi
# Get the name of the current directory. We want the full path
# because in clean mode we are in tmp, in which case a relative
# path has no meaning.
filename_dir=`echo $command_line_filename | sed 's!/[^/]*$!!;s!^$!.!'`
filename_dir=`cd "$filename_dir" >/dev/null && pwd`
# Strip directory part but leave extension.
filename_ext=`basename "$command_line_filename"`
# Strip extension.
filename_noext=`echo "$filename_ext" | sed 's/\.[^.]*$//'`
ext=`echo "$filename_ext" | sed 's/^.*\.//'`
# _src. Use same basename since we want to generate aux files with
# the same basename as the manual. If --expand, then output the
# macro-expanded file to here, else copy the original file.
tmpdir_src=$tmpdir/src
filename_src=$tmpdir_src/$filename_noext.$ext
# _xtr. The file with the user's extra commands.
tmpdir_xtr=$tmpdir/xtr
filename_xtr=$tmpdir_xtr/$filename_noext.$ext
# _bak. Copies of the previous xref files (another round is run if
# they differ from the new one).
tmpdir_bak=$tmpdir/bak
# Make all those directories and give up if we can't succeed.
mkdir $tmpdir_src $tmpdir_xtr $tmpdir_bak || exit 1
# Source file might include additional sources.
# We want `.:$orig_pwd' before anything else. (We'll add `.:' later
# after all other directories have been turned into absolute paths.)
# `.' goes first to ensure that any old .aux, .cps,
# etc. files in ${directory} don't get used in preference to fresher
# files in `.'. Include orig_pwd in case we are in clean mode, where
# we've cd'd to a temp directory.
common="$orig_pwd$path_sep$filename_dir$path_sep$txincludes"
TEXINPUTS="$common$TEXINPUTS_orig"
INDEXSTYLE="$common$INDEXSTYLE_orig"
# Convert relative paths to absolute paths, so we can run in another
# directory (e.g., in --clean mode, or during the macro-support
# detection.)
#
# Empty path components are meaningful to tex. We rewrite them
# as `EMPTY' so they don't get lost when we split on $path_sep.
TEXINPUTS=`echo $TEXINPUTS |sed 's/^:/EMPTY:/;s/:$/:EMPTY/;s/::/:EMPTY:/g'`
INDEXSTYLE=`echo $INDEXSTYLE |sed 's/^:/EMPTY:/;s/:$/:EMPTY/;s/::/:EMPTY:/g'`
save_IFS=$IFS
IFS=$path_sep
set x $TEXINPUTS; shift
TEXINPUTS=.
for dir
do
case $dir in
EMPTY)
TEXINPUTS=$TEXINPUTS$path_sep
;;
[\\/]* | ?:[\\/]*) # Absolute paths don't need to be expansed.
TEXINPUTS=$TEXINPUTS$path_sep$dir
;;
*)
abs=`cd "$dir" && pwd` && TEXINPUTS=$TEXINPUTS$path_sep$abs
;;
esac
done
set x $INDEXSTYLE; shift
INDEXSTYLE=.
for dir
do
case $dir in
EMPTY)
INDEXSTYLE=$INDEXSTYLE$path_sep
;;
[\\/]* | ?:[\\/]*) # Absolute paths don't need to be expansed.
INDEXSTYLE=$INDEXSTYLE$path_sep$dir
;;
*)
abs=`cd "$dir" && pwd` && INDEXSTYLE=$INDEXSTYLE$path_sep$abs
;;
esac
done
IFS=$save_IFS
# If the user explicitly specified the language, use that.
# Otherwise, if the first line is \input texinfo, assume it's texinfo.
# Otherwise, guess from the file extension.
if test -n "$set_language"; then
language=$set_language
elif sed 1q "$command_line_filename" | grep 'input texinfo' >/dev/null; then
language=texinfo
else
language=
fi
# Get the type of the file (latex or texinfo) from the given language
# we just guessed, or from the file extension if not set yet.
case ${language:-$filename_ext} in
[lL]a[tT]e[xX] | *.ltx | *.tex)
# Assume a LaTeX file. LaTeX needs bibtex and uses latex for
# compilation. No makeinfo.
bibtex=${BIBTEX:-bibtex}
makeinfo= # no point in running makeinfo on latex source.
texindex=${MAKEINDEX:-makeindex}
if test $oformat = dvi; then
tex=${LATEX:-latex}
else
tex=${PDFLATEX:-pdflatex}
fi
;;
*)
# Assume a Texinfo file. Texinfo files need makeinfo, texindex and tex.
bibtex=
texindex=${TEXINDEX:-texindex}
if test $oformat = dvi; then
tex=${TEX:-tex}
else
tex=${PDFTEX:-pdftex}
fi
# Unless required by the user, makeinfo expansion is wanted only
# if texinfo.tex is too old.
if test "$expand" = t; then
makeinfo=${MAKEINFO:-makeinfo}
else
# Check if texinfo.tex performs macro expansion by looking for
# its version. The version is a date of the form YEAR-MO-DA.
# We don't need to use [0-9] to match the digits since anyway
# the comparison with $txiprereq, a number, will fail with non
# digits.
txiversion_tex=txiversion.tex
echo '\input texinfo.tex @bye' >$tmpdir/$txiversion_tex
# Run in the tmpdir to avoid leaving files.
eval `cd $tmpdir >/dev/null &&
$tex $txiversion_tex 2>/dev/null |
sed -n 's/^.*\[\(.*\)version \(....\)-\(..\)-\(..\).*$/txiformat=\1 txiversion="\2\3\4"/p'`
$verbose "texinfo.tex preloaded as \`$txiformat', version is \`$txiversion' ..."
if test "$txiprereq" -le "$txiversion" >/dev/null 2>&1; then
makeinfo=
else
makeinfo=${MAKEINFO:-makeinfo}
fi
# As long as we had to run TeX, offer the user this convenience
if test "$txiformat" = Texinfo; then
escape=@
fi
fi
;;
esac
# Expand macro commands in the original source file using Makeinfo.
# Always use `end' footnote style, since the `separate' style
# generates different output (arguably this is a bug in -E).
# Discard main info output, the user asked to run TeX, not makeinfo.
if test -n "$makeinfo"; then
$verbose "Macro-expanding $command_line_filename to $filename_src ..."
sed -f $comment_iftex_sed "$command_line_filename" \
| $makeinfo --footnote-style=end -I "$filename_dir" $miincludes \
-o /dev/null --macro-expand=- \
| sed -f $uncomment_iftex_sed >"$filename_src"
filename_input=$filename_src
fi
# If makeinfo failed (or was not even run), use the original file as input.
if test $? -ne 0 \
|| test ! -r "$filename_src"; then
$verbose "Reverting to $command_line_filename ..."
filename_input=$filename_dir/$filename_ext
fi
# Used most commonly for @finalout, @smallbook, etc.
if test -n "$textra"; then
$verbose "Inserting extra commands: $textra"
sed '/^@setfilename/a\
'"$textra" "$filename_input" >$filename_xtr
filename_input=$filename_xtr
fi
# If clean mode was specified, then move to the temporary directory.
if test "$clean" = t; then
$verbose "cd $tmpdir_src"
cd "$tmpdir_src" || exit 1
fi
while :; do # will break out of loop below
orig_xref_files=`$get_xref_files "$filename_noext"`
# Save copies of originals for later comparison.
if test -n "$orig_xref_files"; then
$verbose "Backing up xref files: `echo $orig_xref_files | sed 's|\./||g'`"
cp $orig_xref_files $tmpdir_bak
fi
# Run bibtex on current file.
# - If its input (AUX) exists.
# - If AUX contains both `\bibdata' and `\bibstyle'.
# - If some citations are missing (LOG contains `Citation').
# or the LOG complains of a missing .bbl
#
# We run bibtex first, because I can see reasons for the indexes
# to change after bibtex is run, but I see no reason for the
# converse.
#
# Don't try to be too smart. Running bibtex only if the bbl file
# exists and is older than the LaTeX file is wrong, since the
# document might include files that have changed. Because there
# can be several AUX (if there are \include's), but a single LOG,
# looking for missing citations in LOG is easier, though we take
# the risk to match false messages.
if test -n "$bibtex" \
&& test -r "$filename_noext.aux" \
&& test -r "$filename_noext.log" \
&& (grep '^\\bibdata[{]' "$filename_noext.aux" \
&& grep '^\\bibstyle[{]' "$filename_noext.aux" \
&& (grep 'Warning:.*Citation.*undefined' "$filename_noext.log" \
|| grep 'No file .*\.bbl\.' "$filename_noext.log")) \
>/dev/null 2>&1; \
then
$verbose "Running $bibtex $filename_noext ..."
if $bibtex "$filename_noext" >&5; then :; else
echo "$0: $bibtex exited with bad status, quitting." >&2
exit 1
fi
fi
# What we'll run texindex on -- exclude non-index files.
# Since we know index files are last, it is correct to remove everything
# before .aux and .?o?. But don't really do <anything>o<anything>
# -- don't match whitespace as <anything>.
# Otherwise, if orig_xref_files contains something like
# foo.xo foo.whatever
# the space after the o will get matched.
index_files=`echo "$orig_xref_files" \
| sed "s!.*\.aux!!g;
s!./$filename_noext\.[^ ]o[^ ]!!g;
s/^[ ]*//;s/[ ]*$//"`
# Run texindex (or makeindex) on current index files. If they
# already exist, and after running TeX a first time the index
# files don't change, then there's no reason to run TeX again.
# But we won't know that if the index files are out of date or
# nonexistent.
if test -n "$texindex" && test -n "$index_files"; then
$verbose "Running $texindex $index_files ..."
if $texindex $index_files 2>&5 1>&2; then :; else
echo "$0: $texindex exited with bad status, quitting." >&2
exit 1
fi
fi
# Finally, run TeX.
# Prevent $ESCAPE from being interpreted by the shell if it happens
# to be `/'.
$batch tex_args="\\${escape}nonstopmode\ \\${escape}input"
cmd="$tex $tex_args $filename_input"
$verbose "Running $cmd ..."
if $cmd >&5; then :; else
echo "$0: $tex exited with bad status, quitting." >&2
echo "$0: see $filename_noext.log for errors." >&2
test "$clean" = t \
&& cp "$filename_noext.log" "$orig_pwd"
exit 1
fi
# Decide if looping again is needed.
finished=t
# LaTeX (and the package changebar) report in the LOG file if it
# should be rerun. This is needed for files included from
# subdirs, since texi2dvi does not try to compare xref files in
# subdirs. Performing xref files test is still good since LaTeX
# does not report changes in xref files.
if grep "Rerun to get" "$filename_noext.log" >/dev/null 2>&1; then
finished=
fi
# Check if xref files changed.
new_xref_files=`$get_xref_files "$filename_noext"`
$verbose "Original xref files = `echo $orig_xref_files | sed 's|\./||g'`"
$verbose "New xref files = `echo $new_xref_files | sed 's|\./||g'`"
# If old and new lists don't at least have the same file list,
# then one file or another has definitely changed.
test "x$orig_xref_files" != "x$new_xref_files" && finished=
# File list is the same. We must compare each file until we find
# a difference.
if test -n "$finished"; then
for this_file in $new_xref_files; do
$verbose "Comparing xref file `echo $this_file | sed 's|\./||g'` ..."
# cmp -s returns nonzero exit status if files differ.
if cmp -s "$this_file" "$tmpdir_bak/$this_file"; then :; else
# We only need to keep comparing until we find one that
# differs, because we'll have to run texindex & tex again no
# matter how many more there might be.
finished=
$verbose "xref file `echo $this_file | sed 's|\./||g'` differed ..."
test "$debug" = t && diff -c "$tmpdir_bak/$this_file" "$this_file"
break
fi
done
fi
# If finished, exit the loop, else rerun the loop.
test -n "$finished" && break
done
# If we were in clean mode, compilation was in a tmp directory.
# Copy the DVI (or PDF) file into the directory where the compilation
# has been done. (The temp dir is about to get removed anyway.)
# We also return to the original directory so that
# - the next file is processed in correct conditions
# - the temporary file can be removed
if test -n "$clean"; then
if test -n "$oname"; then
dest=$oname
else
dest=$orig_pwd
fi
$verbose "Copying $oformat file from `pwd` to $dest"
cp -p "./$filename_noext.$oformat" "$dest"
cd / # in case $orig_pwd is on a different drive (for DOS)
cd $orig_pwd || exit 1
fi
# Remove temporary files.
if test "x$debug" = "x"; then
$verbose "Removing $tmpdir_src $tmpdir_xtr $tmpdir_bak ..."
cd /
rm -rf $tmpdir_src $tmpdir_xtr $tmpdir_bak
fi
done
$verbose "$0 done."
exit 0 # exit successfully, not however we ended the loop.
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
-91
View File
@@ -1,91 +0,0 @@
/* version.c -- distribution and version numbers. */
/* Copyright (C) 1989-2009 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
Bash is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Bash. If not, see <http://www.gnu.org/licenses/>.
*/
#include <config.h>
#include <stdio.h>
#include "stdc.h"
#include "version.h"
#include "patchlevel.h"
#include "conftypes.h"
#include "bashintl.h"
extern char *shell_name;
/* Defines from version.h */
const char * const dist_version = DISTVERSION;
const int patch_level = PATCHLEVEL;
const int build_version = BUILDVERSION;
#ifdef RELSTATUS
const char * const release_status = RELSTATUS;
#else
const char * const release_status = (char *)0;
#endif
const char * const sccs_version = SCCSVERSION;
/* If == 31, shell compatible with bash-3.1, == 32 with bash-3.2, and so on */
int shell_compatibility_level = DEFAULT_COMPAT_LEVEL;
/* Functions for getting, setting, and displaying the shell version. */
/* Forward declarations so we don't have to include externs.h */
extern char *shell_version_string __P((void));
extern void show_shell_version __P((int));
/* Give version information about this shell. */
char *
shell_version_string ()
{
static char tt[32] = { '\0' };
if (tt[0] == '\0')
{
if (release_status)
#if defined (HAVE_SNPRINTF)
snprintf (tt, sizeof (tt), "%s.%d(%d)-%s", dist_version, patch_level, build_version, release_status);
#else
sprintf (tt, "%s.%d(%d)-%s", dist_version, patch_level, build_version, release_status);
#endif
else
#if defined (HAVE_SNPRINTF)
snprintf (tt, sizeof (tt), "%s.%d(%d)", dist_version, patch_level, build_version);
#else
sprintf (tt, "%s.%d(%d)", dist_version, patch_level, build_version);
#endif
}
return tt;
}
void
show_shell_version (extended)
int extended;
{
printf (_("GNU bash, version %s (%s)\n"), shell_version_string (), MACHTYPE);
if (extended)
{
printf (_("Copyright (C) 2009 Free Software Foundation, Inc.\n"));
printf (_("License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>\n"));
printf (_("This is free software; you are free to change and redistribute it.\n"));
printf (_("There is NO WARRANTY, to the extent permitted by law.\n"));
}
}
-84
View File
@@ -1,84 +0,0 @@
:
# link bash for Xenix under SCO Unix
#
# For xenix 2.2:
# CC="cc -xenix -lx" ./configure
# edit config.h:
# comment out the define for HAVE_DIRENT_H
# enable the define for HAVE_SYS_NDIR_H to 1
# make
# CC="cc -xenix -lx" ./link.sh
#
# For xenix 2.3:
# CC="cc -x2.3" ./configure
# make
# CC="cc -x2.3" ./link.sh
# Copyright (C) 1989-2002 Free Software Foundation, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
set -x
rm -f bash
if [ -z "$CC" ]
then
if [ -f /unix ] && [ ! -f /xenix ]
then
CC="cc -xenix"
else
CC=gcc
fi
fi
try_dir=no
try_23=no
try_x=yes
case "$CC" in
*-ldir*) try_dir=yes ;;
esac
case "$CC" in
*-lx*) try_23=no ; try_x=yes ;;
esac
case "$CC" in
*-x2.3*|*-l2.3*) try_23=yes ; try_dir=yes ;;
esac
libs=
try="socket"
if [ $try_dir = yes ] ; then try="$try dir" ; fi
if [ $try_23 = yes ] ; then try="$try 2.3" ; fi
if [ $try_x = yes ] ; then try="$try x" ; fi
for name in $try
do
if [ -r "/lib/386/Slib${name}.a" ] ; then libs="$libs -l$name" ; fi
done
$CC -o bash shell.o eval.o y.tab.o \
general.o make_cmd.o print_cmd.o dispose_cmd.o execute_cmd.o variables.o \
copy_cmd.o error.o expr.o flags.o nojobs.o subst.o hashcmd.o hashlib.o \
mailcheck.o trap.o input.o unwind_prot.o pathexp.o sig.o test.o \
version.o alias.o array.o braces.o bracecomp.o bashhist.o bashline.o \
getcwd.o siglist.o vprint.o oslib.o list.o stringlib.o locale.o \
xmalloc.o builtins/libbuiltins.a \
lib/readline/libreadline.a lib/readline/libhistory.a \
-ltermcap lib/glob/libglob.a lib/tilde/libtilde.a lib/malloc/libmalloc.a \
$libs
ls -l bash
View File