forked from ports/contrib
170 lines
4.9 KiB
Diff
170 lines
4.9 KiB
Diff
|
#! /bin/sh /usr/share/dpatch/dpatch-run
|
|||
|
## 20_warn_missing_tex.dpatch by <norbert@gandalf.localdomain>
|
|||
|
##
|
|||
|
## All lines beginning with `## DP:' are a description of the patch.
|
|||
|
## DP: No description.
|
|||
|
|
|||
|
@DPATCH@
|
|||
|
diff -urNad --exclude=CVS --exclude=.svn ./util/texi2dvi /tmp/dpep-work.19TjB7/texinfo-4.8/util/texi2dvi
|
|||
|
--- ./util/texi2dvi 2005-08-19 13:04:27.000000000 +0200
|
|||
|
+++ /tmp/dpep-work.19TjB7/texinfo-4.8/util/texi2dvi 2005-08-19 13:05:17.000000000 +0200
|
|||
|
@@ -26,6 +26,17 @@
|
|||
|
# If possible, please send a copy of the output of the script called with
|
|||
|
# the `--debug' option when making a bug report.
|
|||
|
|
|||
|
+if ! command -v tex >/dev/null 2>&1; then
|
|||
|
+ cat <<%EOM%
|
|||
|
+You don't have a working TeX binary installed, but the texi2dvi script
|
|||
|
+can't proceed without it. If you want to use this script, you have to
|
|||
|
+install some kind of TeX, for example teTeX Debian packages. You can do
|
|||
|
+that with this command:
|
|||
|
+ prt-get install tetex
|
|||
|
+%EOM%
|
|||
|
+ exit 1
|
|||
|
+fi
|
|||
|
+
|
|||
|
# This string is expanded by rcs automatically when this file is checked out.
|
|||
|
rcs_revision='$Revision: 1.34 $'
|
|||
|
rcs_version=`set - $rcs_revision; echo $2`
|
|||
|
#! /bin/sh /usr/share/dpatch/dpatch-run
|
|||
|
## 30_texindex_racecondition.dpatch by Henry Jensen <jensen@scan-plus.de>
|
|||
|
## and Norbert Preining <preining@logic.at>
|
|||
|
## backport of cvs fixes
|
|||
|
##
|
|||
|
## All lines beginning with `## DP:' are a description of the patch.
|
|||
|
## DP: No description.
|
|||
|
|
|||
|
@DPATCH@
|
|||
|
--- branches/upstream/current/util/texindex.c 2005-09-30 11:28:05.000000000 +0200
|
|||
|
+++ texinfo-cvs/util/texindex.c 2005-10-06 08:35:26.000000000 +0200
|
|||
|
@@ -99,6 +99,9 @@
|
|||
|
/* Directory to use for temporary files. On Unix, it ends with a slash. */
|
|||
|
char *tempdir;
|
|||
|
|
|||
|
+/* Start of filename to use for temporary files. */
|
|||
|
+char *tempbase;
|
|||
|
+
|
|||
|
/* Number of last temporary file. */
|
|||
|
int tempcount;
|
|||
|
|
|||
|
@@ -144,7 +147,7 @@
|
|||
|
void fatal (const char *format, const char *arg);
|
|||
|
void error (const char *format, const char *arg);
|
|||
|
void *xmalloc (), *xrealloc ();
|
|||
|
-char *concat (char *s1, char *s2);
|
|||
|
+static char *concat3 (const char *, const char *, const char *);
|
|||
|
void flush_tempfiles (int to_count);
|
|||
|
|
|||
|
#define MAX_IN_CORE_SORT 500000
|
|||
|
@@ -190,6 +193,11 @@
|
|||
|
|
|||
|
decode_command (argc, argv);
|
|||
|
|
|||
|
+ /* XXX mkstemp not appropriate, as we need to have somewhat predictable
|
|||
|
+ * names. But race condition was fixed, see maketempname.
|
|||
|
+ */
|
|||
|
+ tempbase = mktemp (concat3 ("txiXXXXXX", "", ""));
|
|||
|
+
|
|||
|
/* Process input files completely, one by one. */
|
|||
|
|
|||
|
for (i = 0; i < num_infiles; i++)
|
|||
|
@@ -220,7 +228,7 @@
|
|||
|
|
|||
|
outfile = outfiles[i];
|
|||
|
if (!outfile)
|
|||
|
- outfile = concat (infiles[i], "s");
|
|||
|
+ outfile = concat3 (infiles[i], "s", "");
|
|||
|
|
|||
|
need_initials = 0;
|
|||
|
first_initial = '\0';
|
|||
|
@@ -318,7 +326,7 @@
|
|||
|
if (tempdir == NULL)
|
|||
|
tempdir = DEFAULT_TMPDIR;
|
|||
|
else
|
|||
|
- tempdir = concat (tempdir, "/");
|
|||
|
+ tempdir = concat3 (tempdir, "/", "");
|
|||
|
|
|||
|
keep_tempfiles = 0;
|
|||
|
|
|||
|
@@ -384,26 +395,25 @@
|
|||
|
usage (1);
|
|||
|
}
|
|||
|
|
|||
|
-/* Return a name for temporary file COUNT. */
|
|||
|
+/* Return a name for temporary file COUNT, or NULL if failure. */
|
|||
|
|
|||
|
static char *
|
|||
|
maketempname (int count)
|
|||
|
{
|
|||
|
- static char *tempbase = NULL;
|
|||
|
char tempsuffix[10];
|
|||
|
+ char *name;
|
|||
|
+ int fd;
|
|||
|
|
|||
|
- if (!tempbase)
|
|||
|
+ sprintf (tempsuffix, ".%d", count);
|
|||
|
+ name = concat3 (tempdir, tempbase, tempsuffix);
|
|||
|
+ fd = open (name, O_CREAT|O_EXCL|O_WRONLY, 0600);
|
|||
|
+ if (fd == -1)
|
|||
|
+ return NULL;
|
|||
|
+ else
|
|||
|
{
|
|||
|
- int fd;
|
|||
|
- tempbase = concat (tempdir, "txidxXXXXXX");
|
|||
|
-
|
|||
|
- fd = mkstemp (tempbase);
|
|||
|
- if (fd == -1)
|
|||
|
- pfatal_with_name (tempbase);
|
|||
|
+ close(fd);
|
|||
|
+ return(name);
|
|||
|
}
|
|||
|
-
|
|||
|
- sprintf (tempsuffix, ".%d", count);
|
|||
|
- return concat (tempbase, tempsuffix);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
@@ -931,6 +941,8 @@
|
|||
|
for (i = 0; i < ntemps; i++)
|
|||
|
{
|
|||
|
char *newtemp = maketempname (++tempcount);
|
|||
|
+ if (!newtemp)
|
|||
|
+ pfatal_with_name("temp file");
|
|||
|
sort_in_core (tempfiles[i], MAX_IN_CORE_SORT, newtemp);
|
|||
|
if (!keep_tempfiles)
|
|||
|
unlink (tempfiles[i]);
|
|||
|
@@ -1401,6 +1413,8 @@
|
|||
|
if (i + 1 == ntemps)
|
|||
|
nf = nfiles - i * MAX_DIRECT_MERGE;
|
|||
|
tempfiles[i] = maketempname (++tempcount);
|
|||
|
+ if (!tempfiles[i])
|
|||
|
+ pfatal_with_name("temp file");
|
|||
|
value |= merge_direct (&infiles[i * MAX_DIRECT_MERGE], nf, tempfiles[i]);
|
|||
|
}
|
|||
|
|
|||
|
@@ -1612,17 +1626,18 @@
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
-/* Return a newly-allocated string concatenating S1 and S2. */
|
|||
|
+/* Return a newly-allocated string concatenating S1, S2, and S3. */
|
|||
|
|
|||
|
-char *
|
|||
|
-concat (char *s1, char *s2)
|
|||
|
+static char *
|
|||
|
+concat3 (const char *s1, const char *s2, const char *s3)
|
|||
|
{
|
|||
|
- int len1 = strlen (s1), len2 = strlen (s2);
|
|||
|
- char *result = (char *) xmalloc (len1 + len2 + 1);
|
|||
|
+ int len1 = strlen (s1), len2 = strlen (s2), len3 = strlen (s3);
|
|||
|
+ char *result = (char *) xmalloc (len1 + len2 + len3 + 1);
|
|||
|
|
|||
|
strcpy (result, s1);
|
|||
|
strcpy (result + len1, s2);
|
|||
|
- *(result + len1 + len2) = 0;
|
|||
|
+ strcpy (result + len1 + len2, s3);
|
|||
|
+ *(result + len1 + len2 + len3) = 0;
|
|||
|
|
|||
|
return result;
|
|||
|
}
|