octave-maintainers
[Top][All Lists]
Advanced

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

replace use of mkstemp in makeinfo.m with tmpnam/fopen ?


From: Benjamin Lindner
Subject: replace use of mkstemp in makeinfo.m with tmpnam/fopen ?
Date: Fri, 30 Jan 2009 18:52:59 +0100
User-agent: Thunderbird 2.0.0.18 (Windows/20081105)

Hello,

with the current develeopment sources, makeinfo.m utilizes the function mkstemp to create its temporary texinfo file. However, mkstemp is not available on mingw32, so its call returns a file descriptor of -1 and subsequently, makeinfo.m fails. This means that help() and pring_usage() also fail.

Is is acceptable to replace the call to mkstemp() with a call to tmpnam() and fopen() instead? This way, makeinfo.m does not use functions that may not be available on some OSes.

I have attached a proposal changeset.
This yields working makeinfo.m and thus also help() and print_usage() for a mingw32 platform

benjamin

# HG changeset patch
# User Benjamin Lindner <address@hidden>
# Date 1233223928 -3600
# Node ID 4b9c12517efd5f62de6a408a7e14b06c7be48e70
# Parent  89804c0060de2445b5af30ff41ea53bab09a456a
replace call to mkstemp() in makeinfo.m with tmpname()/fopen()

diff -r 89804c0060de -r 4b9c12517efd scripts/help/makeinfo.m
--- a/scripts/help/makeinfo.m   Thu Jan 29 11:10:28 2009 +0100
+++ b/scripts/help/makeinfo.m   Thu Jan 29 11:12:08 2009 +0100
@@ -123,7 +123,11 @@
   
   unwind_protect
     ## Write Texinfo to tmp file
-    [fid, name, msg] = mkstemp ("octave_help_XXXXXX", true);
+    name = tmpnam (P_tmpdir(), "octave_help_");
+    [fid, msg] = fopen( name, "wt" );
+    if ( fid == -1 )
+      error("Could not create a temporary file for makeinfo: %s", msg);
+    endif
     fwrite (fid, text);
     fclose (fid);
 

reply via email to

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