summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/lib
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/texk/web2c/lib')
-rw-r--r--Build/source/texk/web2c/lib/ChangeLog61
-rw-r--r--Build/source/texk/web2c/lib/Makefile.am2
-rw-r--r--Build/source/texk/web2c/lib/Makefile.in4
-rw-r--r--Build/source/texk/web2c/lib/lib.h12
-rw-r--r--Build/source/texk/web2c/lib/openclose.c20
-rw-r--r--Build/source/texk/web2c/lib/printversion.c4
-rw-r--r--Build/source/texk/web2c/lib/texmfmp.c189
-rw-r--r--Build/source/texk/web2c/lib/version.c2
8 files changed, 129 insertions, 165 deletions
diff --git a/Build/source/texk/web2c/lib/ChangeLog b/Build/source/texk/web2c/lib/ChangeLog
index 7172b942789..f2662df6dda 100644
--- a/Build/source/texk/web2c/lib/ChangeLog
+++ b/Build/source/texk/web2c/lib/ChangeLog
@@ -1,3 +1,62 @@
+2009-10-24 Peter Breitenlohner <peb@mppmu.mpg.de>
+
+ * texmfmp.c (openinnameok, openoutnameok): Moved to Kpathsea
+ and renamed kpse_{in,out}_name_ok.
+
+2009-09-06 Peter Breitenlohner <peb@mppmu.mpg.de>
+
+ * texmfmp.c (last_lineno): MAYBE_STATIC for luaTeX.
+ (srcspecialsoption, parse_src_specials_option): static but not
+ used for luaTeX.
+
+2009-09-05 Peter Breitenlohner <peb@mppmu.mpg.de>
+
+ * texmfmp.c (runpopen): Used only for pdfTeX and luaTeX.
+ (last_source_name etc): Not used by MF.
+ (ipcpage): Avoid unconstifying cast.
+ (compare_paths): Declare as static.
+ (mfwin_sw): Constify member string.
+
+2009-09-04 Peter Breitenlohner <peb@mppmu.mpg.de>
+
+ * texmfmp.c (initscreen): Add explicit braces.
+ (getrandomseed, makefullnamestring): ANSI C definition.
+
+2009-08-27 Peter Breitenlohner <peb@mppmu.mpg.de>
+
+ * lib.h (NOT_WEB2C): New preprocessor macro, if defined prevents
+ declaration of argc, argv, cmdline, and mainbody (from main.c).
+
+2009-08-24 Peter Breitenlohner <peb@mppmu.mpg.de>
+
+ * openclose.c (open_output): Bugfix? local var 'fname' was
+ shadowed by a second one. Avoid memory leak.
+
+2009-08-22 Peter Breitenlohner <peb@mppmu.mpg.de>
+
+ * lib.h, texmfmp.c, version.c: Constify ptexbanner and
+ versionstring.
+
+2009-08-21 Peter Breitenlohner <peb@mppmu.mpg.de>
+
+ Avoid maximal compiler warnings.
+ * openclose.c (recorder_record_name): Constify string param1.
+ (recorder_record_{name,input,output}): Rename param
+ nameoffile=>name, not to shadow global var.
+
+2009-08-20 Peter Breitenlohner <peb@mppmu.mpg.de>
+
+ * lib.h (ptexbanner): Add decl for pdfTeX and luaTeX.
+ * texmfmp.c (ptexbanner): Drop decl but keep initializer.
+ * printversion.c (kpathsea_version_string):
+ #include <kpathsea/version.h> and drop extern declaration.
+
+2009-08-17 Peter Breitenlohner <peb@mppmu.mpg.de>
+
+ * texmfmp.c (shell_cmd_is_allowed): Change param1 from 'char **'
+ to 'const char *'.
+ (runsystem, runpopen): Constify string params.
+
2009-07-24 Martin Schröder <martin@oneiros.de>
* printversion.c: don't nest extern declarations
@@ -17,7 +76,7 @@
input2int.c, inputint.c, main.c, openclose.c, printversion.c,
zround.c: #include "lib.h" to declare function prototypes.
* openclose.c: declare internal function recorder_record_name as
- static; declare arg of recorder_record_input and
+ static; declare param of recorder_record_input and
recorder_record_output as const_string as from ../cpascal.h.
2009-06-01 Karl Berry <karl@tug.org>
diff --git a/Build/source/texk/web2c/lib/Makefile.am b/Build/source/texk/web2c/lib/Makefile.am
index a6b1e9aba12..f660f62e55d 100644
--- a/Build/source/texk/web2c/lib/Makefile.am
+++ b/Build/source/texk/web2c/lib/Makefile.am
@@ -12,7 +12,7 @@ AM_CFLAGS = $(WARNING_CFLAGS)
noinst_LIBRARIES = lib.a
## We don't compile `texmfmp.c'; this file is converted into 'texextra.c'
-## for TeX, 'mfextra.c' for Metafont, 'mfextra.c' for MetaPost, ...
+## for TeX, 'mfextra.c' for Metafont, ...
lib_a_SOURCES = \
basechsuffix.c \
chartostring.c \
diff --git a/Build/source/texk/web2c/lib/Makefile.in b/Build/source/texk/web2c/lib/Makefile.in
index d3bf99aaac8..f2dca167edc 100644
--- a/Build/source/texk/web2c/lib/Makefile.in
+++ b/Build/source/texk/web2c/lib/Makefile.in
@@ -38,7 +38,8 @@ subdir = lib
DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
ChangeLog
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/../../m4/kpse-asm.m4 \
+am__aclocal_m4_deps = $(top_srcdir)/m4/web2c-disable.m4 \
+ $(top_srcdir)/../../m4/kpse-asm.m4 \
$(top_srcdir)/../../m4/kpse-common.m4 \
$(top_srcdir)/../../m4/kpse-cross.m4 \
$(top_srcdir)/../../m4/kpse-cxx-hack.m4 \
@@ -186,6 +187,7 @@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PKG_CONFIG = @PKG_CONFIG@
diff --git a/Build/source/texk/web2c/lib/lib.h b/Build/source/texk/web2c/lib/lib.h
index 156e1350d15..4c8bab85a68 100644
--- a/Build/source/texk/web2c/lib/lib.h
+++ b/Build/source/texk/web2c/lib/lib.h
@@ -25,11 +25,14 @@ extern integer inputint (FILE *);
extern void zinput2ints (integer *, integer *);
extern void zinput3ints (integer *, integer *, integer *);
-/* main.c */
+/* main.c (or win32main.c or texmfmp.c) */
+#ifndef NOT_WEB2C
+/* Only used in Web2C programs and possibly harmful otherwise. */
extern int argc;
extern string *argv;
extern string cmdline (int);
extern TEXDLL void mainbody (void); /* generated by web2c */
+#endif
/* openclose.c */
extern boolean open_input (FILE **, int, const_string fopen_mode);
@@ -44,8 +47,13 @@ extern void recorder_record_output (const_string);
/* printversion.c */
extern void printversionandexit (const_string, const_string, const_string, char*);
+/* texmfmp.c (actually ../pdftexextra.c or ../luatexextra) */
+#if defined(pdfTeX) || defined(luaTeX)
+extern const char *ptexbanner;
+#endif
+
/* version.c */
-extern char *versionstring;
+extern const char *versionstring;
/* zround.c */
extern integer zround (double);
diff --git a/Build/source/texk/web2c/lib/openclose.c b/Build/source/texk/web2c/lib/openclose.c
index dab1b4ff43c..e82b3215d6c 100644
--- a/Build/source/texk/web2c/lib/openclose.c
+++ b/Build/source/texk/web2c/lib/openclose.c
@@ -72,28 +72,28 @@ recorder_change_filename (string new_name)
/* helper for recorder_record_* */
static void
-recorder_record_name (string prefix, const_string nameoffile)
+recorder_record_name (const_string prefix, const_string name)
{
if (recorder_enabled) {
if (!recorder_file)
recorder_start();
- fprintf(recorder_file, "%s %s\n", prefix, nameoffile);
+ fprintf(recorder_file, "%s %s\n", prefix, name);
fflush(recorder_file);
}
}
-/* record an input file */
+/* record an input file name */
void
-recorder_record_input (const_string nameoffile)
+recorder_record_input (const_string name)
{
- recorder_record_name ("INPUT", nameoffile);
+ recorder_record_name ("INPUT", name);
}
-/* record an output file */
+/* record an output file name */
void
-recorder_record_output (const_string nameoffile)
+recorder_record_output (const_string name)
{
- recorder_record_name ("OUTPUT", nameoffile);
+ recorder_record_name ("OUTPUT", name);
}
/* Open an input file F, using the kpathsea format FILEFMT and passing
@@ -241,7 +241,9 @@ open_output (FILE **f_ptr, const_string fopen_mode)
string texmfoutput = kpse_var_value("TEXMFOUTPUT");
if (texmfoutput && *texmfoutput && !absolute) {
- string fname = concat3(texmfoutput, DIR_SEP_STRING, nameoffile+1);
+ if (fname != nameoffile + 1)
+ free(fname);
+ fname = concat3(texmfoutput, DIR_SEP_STRING, nameoffile+1);
*f_ptr = fopen(fname, fopen_mode);
}
}
diff --git a/Build/source/texk/web2c/lib/printversion.c b/Build/source/texk/web2c/lib/printversion.c
index ed169331873..bb9874b5244 100644
--- a/Build/source/texk/web2c/lib/printversion.c
+++ b/Build/source/texk/web2c/lib/printversion.c
@@ -4,6 +4,7 @@
#include "config.h"
#include "lib.h"
+#include <kpathsea/version.h>
/* We're passed in the original WEB banner string, which has the form
This is PROGRAM, Version VERSION-NUMBER
@@ -16,9 +17,6 @@ This is PROGRAM, Version VERSION-NUMBER
Maybe I should have just done it all inline in each individual
program, but tangle doesn't allow multiline string constants ... */
-extern string versionstring; /* from web2c/lib/version.c */
-extern KPSEDLL string kpathsea_version_string;/* from kpathsea/version.c */
-
void
printversionandexit (const_string banner,
const_string copyright_holder,
diff --git a/Build/source/texk/web2c/lib/texmfmp.c b/Build/source/texk/web2c/lib/texmfmp.c
index e4b63c3090b..063cdfcc621 100644
--- a/Build/source/texk/web2c/lib/texmfmp.c
+++ b/Build/source/texk/web2c/lib/texmfmp.c
@@ -263,22 +263,23 @@ free_shellcmdlist (void)
what is checked against the shell_escape_commands list. */
int
-shell_cmd_is_allowed (char **cmd, char **safecmd, char **cmdname)
+shell_cmd_is_allowed (const char *cmd, char **safecmd, char **cmdname)
{
char **p;
char *buf;
- char *s, *d;
+ char *c, *d;
+ const char *s;
int pre, spaces;
int allow = 0;
/* pre == 1 means that the previous character is a white space
pre == 0 means that the previous character is not a white space */
- buf = (char *) xmalloc (strlen (*cmd) + 1);
- strcpy (buf, *cmd);
- s = buf;
- while (Isspace (*s))
- s++;
- d = s;
+ buf = (char *) xmalloc (strlen (cmd) + 1);
+ strcpy (buf, cmd);
+ c = buf;
+ while (Isspace (*c))
+ c++;
+ d = c;
while (!Isspace(*d) && *d)
d++;
*d = '\0';
@@ -287,7 +288,7 @@ shell_cmd_is_allowed (char **cmd, char **safecmd, char **cmdname)
*cmdname == "kpsewhich" for
\write18{kpsewhich --progname=dvipdfm --format="other text files" config}
*/
- *cmdname = xstrdup (s);
+ *cmdname = xstrdup (c);
free (buf);
/* Is *cmdname listed in a texmf.cnf vriable as
@@ -306,20 +307,20 @@ shell_cmd_is_allowed (char **cmd, char **safecmd, char **cmdname)
}
if (allow == 2) {
spaces = 0;
- for (s = *cmd; *s; s++) {
+ for (s = cmd; *s; s++) {
if (Isspace (*s))
spaces++;
}
/* allocate enough memory (too much?) */
#ifdef WIN32
- *safecmd = (char *) xmalloc (2 * strlen (*cmd) + 3 + 2 * spaces);
+ *safecmd = (char *) xmalloc (2 * strlen (cmd) + 3 + 2 * spaces);
#else
- *safecmd = (char *) xmalloc (strlen (*cmd) + 3 + 2 * spaces);
+ *safecmd = (char *) xmalloc (strlen (cmd) + 3 + 2 * spaces);
#endif
/* make a safe command line *safecmd */
- s = *cmd;
+ s = cmd;
while (Isspace (*s))
s++;
d = *safecmd;
@@ -389,7 +390,7 @@ shell_cmd_is_allowed (char **cmd, char **safecmd, char **cmdname)
*d++ = QUOTE;
*d++ = *s++;
} else {
- /* Copy a character from *cmd to *safecmd. */
+ /* Copy a character from cmd to *safecmd. */
#ifdef WIN32
if (char_needs_quote (*s))
*d++ = '^';
@@ -416,7 +417,7 @@ shell_cmd_is_allowed (char **cmd, char **safecmd, char **cmdname)
2 if shell escapes are restricted and CMD is allowed. */
int
-runsystem (char *cmd)
+runsystem (const char *cmd)
{
int allow = 0;
char *safecmd = NULL;
@@ -430,7 +431,7 @@ runsystem (char *cmd)
if (restrictedshell == 0)
allow = 1;
else
- allow = shell_cmd_is_allowed (&cmd, &safecmd, &cmdname);
+ allow = shell_cmd_is_allowed (cmd, &safecmd, &cmdname);
if (allow == 1)
(void) system (cmd);
@@ -445,13 +446,14 @@ runsystem (char *cmd)
return allow;
}
+#if defined(pdfTeX) || defined(luaTeX)
/* Like runsystem(), the runpopen() function is called only when
shellenabledp == 1. Unlike runsystem(), here we write errors to
stderr, since we have nowhere better to use; and of course we return
a file handle (or NULL) instead of a status indicator. */
static FILE *
-runpopen (char *cmd, char *mode)
+runpopen (const char *cmd, const char *mode)
{
FILE *f = NULL;
char *safecmd = NULL;
@@ -462,7 +464,7 @@ runpopen (char *cmd, char *mode)
if (restrictedshell == 0)
allow = 1;
else
- allow = shell_cmd_is_allowed (&cmd, &safecmd, &cmdname);
+ allow = shell_cmd_is_allowed (cmd, &safecmd, &cmdname);
if (allow == 1)
f = popen (cmd, mode);
@@ -480,7 +482,8 @@ runpopen (char *cmd, char *mode)
free (cmdname);
return f;
}
-#endif
+#endif /* pdfTeX || luaTeX */
+#endif /* TeX */
/* The main program, etc. */
@@ -516,11 +519,15 @@ extern string fullnameoffile;
string translate_filename;
string default_translate_filename;
+#if defined(TeX)
/* Needed for --src-specials option. */
MAYBE_STATIC char *last_source_name;
-static int last_lineno;
-MAYBE_STATIC boolean srcspecialsoption = false;
-MAYBE_STATIC void parse_src_specials_option (const_string);
+MAYBE_STATIC int last_lineno;
+#if !defined (luaTeX)
+static boolean srcspecialsoption = false;
+static void parse_src_specials_option (const_string);
+#endif
+#endif
/* The main body of the WEB is transformed into this procedure. */
extern TEXDLL void mainbody (void);
@@ -541,10 +548,6 @@ static string get_input_file_name (void);
static int eightbitp;
#endif /* Aleph */
-#if defined(pdfTeX) || defined(luaTeX)
-char *ptexbanner;
-#endif
-
/* Get a true/false value for a variable from texmf.cnf and the environment. */
static boolean
texmf_yesno(const_string var)
@@ -577,6 +580,10 @@ texmf_yesno(const_string var)
#define poolsize pool_size
#endif
+#if defined(pdfTeX) || defined(luaTeX)
+const char *ptexbanner = BANNER;
+#endif
+
/* The entry point: set up for reading the command line, which will
happen in `topenin', then call the main body. */
@@ -613,10 +620,6 @@ maininit (int ac, string *av)
# endif
#endif
-#if defined(pdfTeX) || defined(luaTeX)
- ptexbanner = BANNER;
-#endif
-
/* If the user says --help or --version, we need to notice early. And
since we want the --ini option, have to do it before getting into
the web (which would read the base file, etc.). */
@@ -1026,7 +1029,7 @@ ipcpage (int is_eof)
{
static boolean begun = false;
unsigned len = 0;
- string p = (string)"";
+ string p = NULL;
if (!begun) {
string name; /* Just the filename. */
@@ -1061,7 +1064,7 @@ ipcpage (int is_eof)
}
ipc_snd (len, is_eof, p);
- if (len > 0) {
+ if (p) {
free (p);
}
}
@@ -1662,115 +1665,6 @@ parse_first_line (const_string filename)
}
}
-/* Return true if FNAME is acceptable as a name for \openout, \openin, or
- \input. */
-
-typedef enum ok_type {
- ok_reading,
- ok_writing
-} ok_type;
-
-static const_string ok_type_name[] = {
- "reading",
- "writing"
-};
-
-static boolean
-opennameok (const_string fname, const_string check_var,
- const_string default_choice, ok_type action)
-{
- /* We distinguish three cases:
- 'a' (any) allows any file to be opened.
- 'r' (restricted) means disallowing special file names.
- 'p' (paranoid) means being really paranoid: disallowing special file
- names and restricting output files to be in or below
- the working directory or $TEXMFOUTPUT, while input files
- must be below the current directory, $TEXMFOUTPUT, or
- (implicitly) in the system areas.
- We default to "paranoid". The error messages from TeX will be somewhat
- puzzling...
- This function contains several return statements... */
-
- const_string open_choice = kpse_var_value (check_var);
-
- if (!open_choice) open_choice = default_choice;
-
- if (*open_choice == 'a' || *open_choice == 'y' || *open_choice == '1')
- return true;
-
-#if defined (unix) && !defined (MSDOS)
- {
- const_string base = xbasename (fname);
- /* Disallow .rhosts, .login, etc. Allow .tex (for LaTeX). */
- if (base[0] == 0 ||
- (base[0] == '.' && !IS_DIR_SEP(base[1]) && !STREQ (base, ".tex"))) {
- fprintf(stderr, "%s: Not %s to %s (%s = %s).\n",
- program_invocation_name, ok_type_name[action], fname,
- check_var, open_choice);
- return false;
- }
- }
-#else
- /* Other OSs don't have special names? */
-#endif
-
- if (*open_choice == 'r' || *open_choice == 'n' || *open_choice == '0')
- return true;
-
- /* Paranoia supplied by Charles Karney... */
- if (kpse_absolute_p (fname, false)) {
- const_string texmfoutput = kpse_var_value ("TEXMFOUTPUT");
- /* Absolute pathname is only OK if TEXMFOUTPUT is set, it's not empty,
- fname begins the TEXMFOUTPUT, and is followed by / */
- if (!texmfoutput || *texmfoutput == '\0'
- || fname != strstr (fname, texmfoutput)
- || !IS_DIR_SEP(fname[strlen(texmfoutput)])) {
- fprintf(stderr, "%s: Not %s to %s (%s = %s).\n",
- program_invocation_name, ok_type_name[action], fname,
- check_var, open_choice);
- return false;
- }
- }
- /* For all pathnames, we disallow "../" at the beginning or "/../"
- anywhere. */
- if (fname[0] == '.' && fname[1] == '.' && IS_DIR_SEP(fname[2])) {
- fprintf(stderr, "%s: Not %s to %s (%s = %s).\n",
- program_invocation_name, ok_type_name[action], fname,
- check_var, open_choice);
- return false;
- } else {
- /* Check for "/../". Since more than one characted can be matched
- by IS_DIR_SEP, we cannot use "/../" itself. */
- const_string dotpair = strstr(fname, "..");
- while (dotpair) {
- /* If dotpair[2] == DIR_SEP, then dotpair[-1] is well-defined,
- because the "../" case was handled above. */
- if (IS_DIR_SEP(dotpair[2]) && IS_DIR_SEP(dotpair[-1])) {
- fprintf(stderr, "%s: Not %s to %s (%s = %s).\n",
- program_invocation_name, ok_type_name[action], fname,
- check_var, open_choice);
- return false;
- }
- /* Continue after the dotpair. */
- dotpair = strstr(dotpair+2, "..");
- }
- }
-
- /* We passed all tests. */
- return true;
-}
-
-boolean openinnameok (const_string fname)
-{
- /* For input default to all. */
- return opennameok (fname, "openin_any", "a", ok_reading);
-}
-
-boolean openoutnameok (const_string fname)
-{
- /* For output, default to paranoid. */
- return opennameok (fname, "openout_any", "p", ok_writing);
-}
/*
piped I/O
*/
@@ -1996,7 +1890,7 @@ get_seconds_and_micros (integer *seconds, integer *micros)
Generating a better seed numbers
*/
integer
-getrandomseed()
+getrandomseed(void)
{
#if defined (HAVE_GETTIMEOFDAY)
struct timeval tv;
@@ -2350,7 +2244,7 @@ maketexstring(const_string s)
size_t len;
#ifdef XeTeX
UInt32 rval;
- unsigned char* cp = (unsigned char*)s;
+ const unsigned char* cp = (const unsigned char*)s;
#endif
assert (s != 0);
len = strlen(s);
@@ -2385,7 +2279,7 @@ maketexstring(const_string s)
#endif /* !pdfTeX */
strnumber
-makefullnamestring()
+makefullnamestring(void)
{
return maketexstring(fullnameoffile);
}
@@ -2403,7 +2297,7 @@ getjobname(strnumber name)
#endif
#if defined(TeX)
-int
+static int
compare_paths (const_string p1, const_string p2)
{
int ret;
@@ -2824,7 +2718,7 @@ extern void mf_trap_paintrow (screenrow, pixelcolor, transspec, screencol);
struct mfwin_sw
{
- char *mfwsw_type; /* Name of terminal a la TERMCAP. */
+ const char *mfwsw_type; /* Name of terminal a la TERMCAP. */
int (*mfwsw_initscreen) (void);
void (*mfwsw_updatescrn) (void);
void (*mfwsw_blankrect) (screencol, screencol, screenrow, screenrow);
@@ -2931,7 +2825,7 @@ initscreen (void)
under Emacs, the first one. */
for (mfwp = mfwsw; mfwp->mfwsw_type != NULL; mfwp++) {
if (!strncmp (mfwp->mfwsw_type, tty_type, strlen (mfwp->mfwsw_type))
- || STREQ (tty_type, "emacs"))
+ || STREQ (tty_type, "emacs")) {
if (mfwp->mfwsw_initscreen)
return ((*mfwp->mfwsw_initscreen) ());
else {
@@ -2939,6 +2833,7 @@ initscreen (void)
tty_type);
break;
}
+ }
}
/* We disable X support by default, since most sites don't use it, and
diff --git a/Build/source/texk/web2c/lib/version.c b/Build/source/texk/web2c/lib/version.c
index 8c7efb17cc9..40f8cf4db12 100644
--- a/Build/source/texk/web2c/lib/version.c
+++ b/Build/source/texk/web2c/lib/version.c
@@ -3,4 +3,4 @@
/* This string is appended to all the banners and used in --version. */
/* Public domain. */
-char *versionstring = WEB2CVERSION;
+const char *versionstring = WEB2CVERSION;