bug-groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: mkstemp


From: Gaius Mulley
Subject: Re: mkstemp
Date: Fri, 29 Jun 2001 12:29:12 +0100

Werner <address@hidden> writes:

> Indeed, both pre-html.cc and indxbib.cc should be changed to use
> xtmpfile() as defined in tmpfile.cc instead which has proper code if
> mkstemp() is missing.

> Gaius, can you fix this?  

pre-html.cc and indxbib.cc need to know the name of the temporary file.
So I've included a xmkstemp inside tmpfile.cc and modified indxbib.cc and
pre-html.cc accordingly, hope this is acceptable ?

Also included is a minor tmac.www improvement.

Gaius

--- groff-cvs/src/preproc/html/pre-html.cc      Thu Jun 21 08:56:00 2001
+++ groff-html/src/preproc/html/pre-html.cc     Fri Jun 29 11:48:30 2001
@@ -1326,13 +1326,13 @@
 #else
   int fd;
 
-  if ((fd = mkstemp(psFileName = xtmptemplate("-ps-"))) == -1) {
-    sys_fatal("mkstemp");
+  if ((fd = xmkstemp(psFileName = xtmptemplate("-ps-"))) == -1) {
+    sys_fatal("xmkstemp");
     return -1;
   }
   close(fd);
-  if ((fd = mkstemp(regionFileName = xtmptemplate("-regions-"))) == -1) {
-    sys_fatal("mkstemp");
+  if ((fd = xmkstemp(regionFileName = xtmptemplate("-regions-"))) == -1) {
+    sys_fatal("xmkstemp");
     unlink(psFileName);
     return -1;
   }
--- groff-cvs/src/include/lib.h Fri Apr 20 14:34:59 2001
+++ groff-html/src/include/lib.h        Fri Jun 29 11:46:20 2001
@@ -45,6 +45,7 @@
 
 FILE *xtmpfile(char **namep=0, char *postfix=0, int do_unlink=1);
 char *xtmptemplate(char *extension=0);
+int   xmkstemp(char *);
 
 #ifdef NEED_DECLARATION_POPEN
 
--- groff-cvs/src/libs/libgroff/tmpfile.cc      Sat Apr 21 00:53:49 2001
+++ groff-html/src/libs/libgroff/tmpfile.cc     Fri Jun 29 12:25:16 2001
@@ -50,6 +50,20 @@
 #define TMPFILE_PREFIX  "groff"
 
 /*
+ *  xmkstemp - create a unique temporary file, utilizing
+ *             mkstemp if available.
+ */
+
+int xmkstemp (char *f)
+{
+#ifdef HAVE_MKSTEMP
+  return mkstemp(f);
+#else
+  return creat(f, S_IRUSR|S_IRGRP|S_IROTH);
+#endif
+}
+
+/*
  *  Generate a temporary name template with a postfix
  *  immediately after the TMPFILE_PREFIX.
  *  It uses the groff preferences for a temporary directory.
--- groff-cvs/src/utils/indxbib/indxbib.cc      Sat Apr 21 00:53:49 2001
+++ groff-html/src/utils/indxbib/indxbib.cc     Fri Jun 29 11:44:42 2001
@@ -39,12 +39,6 @@
 
 extern "C" const char *Version_string;
 
-#ifndef HAVE_MKSTEMP_PROTO
-extern "C" {
-  extern int mkstemp(char *);
-}
-#endif
-
 #define DEFAULT_HASH_TABLE_SIZE 997
 #define TEMP_INDEX_TEMPLATE "indxbibXXXXXX"
 
@@ -249,11 +243,7 @@
     fatal("cannot create file name for temporary file");
 #endif
   catch_fatal_signals();
-#ifdef HAVE_MKSTEMP
-  int fd = mkstemp(temp_index_file);
-#else
-  int fd = creat(temp_index_file, S_IRUSR|S_IRGRP|S_IROTH);
-#endif
+  int fd = xmkstemp(temp_index_file);
   if (fd < 0)
     fatal("can't create temporary index file: %1", strerror(errno));
   indxfp = fdopen(fd, FOPEN_WB);
--- groff-cvs/tmac/www.tmac     Mon Jun 18 23:37:34 2001
+++ groff-html/tmac/www.tmac    Fri Jun 29 12:04:04 2001
@@ -103,20 +103,25 @@
 .\"
 .\" IMAGE - reference an image
 .\"         $1 is the image file
-.\"         $2 is the x width (default if absent 400 pixels)
-.\"         $3 is the y width (default if absent is the x value)
+.\"         $2 is the alignment r, l or c  (center by default)
+.\"         $3 is the x width (default if absent 400 pixels)
+.\"         $4 is the y width (default if absent is the x value)
 .\"
 .de IMAGE
 .  ie \\n[www-html] \{\
+.    ie '\\$2'r' .HTML-TAG ".right-image"
+.    el \{\
+.      ie '\\$2'l' .HTML-TAG ".left-image"
+.      el .HTML-TAG ".centered-image"
+.    \}
 .    nr HTMLWIDTH 400
-.    if !'\\$2'' \{\
-.      nr HTMLWIDTH \\$2
+.    if !'\\$3'' \{\
+.      nr HTMLWIDTH \\$3
 .    \}
 .    nr HTMLHEIGHT \\n[HTMLWIDTH]
-.    if !'\\$3'' \{\
-.      nr HTMLHEIGHT \\$3
+.    if !'\\$4'' \{\
+.      nr HTMLHEIGHT \\$4
 .    \}
-.    HTML-TAG ".centered-image"
 .    HTML <img src="\\$1" width=\\n[HTMLWIDTH] height=\\n[HTMLHEIGHT]>
 .  \}
 .  el \{\



reply via email to

[Prev in Thread] Current Thread [Next in Thread]