Skip to content

Commit

Permalink
merge from 4.02 (rev. 14929): add configure detection of mkstemp, rem…
Browse files Browse the repository at this point in the history
…ove old HAVE_MKSTEMP conditional, rename HAVE_MKSTEMP -> HAS_MKSTEMP

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14930 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
  • Loading branch information
mshinwell committed May 30, 2014
1 parent 60d0af5 commit ec96727
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
5 changes: 5 additions & 0 deletions configure
Expand Up @@ -1300,6 +1300,11 @@ if test $nargs != "none"; then
echo "#define HAS_GETHOSTBYADDR_R $nargs" >> s.h echo "#define HAS_GETHOSTBYADDR_R $nargs" >> s.h
fi fi


if sh ./hasgot mkstemp; then
inf "mkstemp() found"
echo "#define HAS_MKSTEMP" >> s.h
fi

# Determine if the debugger is supported # Determine if the debugger is supported


if test -n "$with_debugger"; then if test -n "$with_debugger"; then
Expand Down
20 changes: 8 additions & 12 deletions yacc/main.c
Expand Up @@ -55,11 +55,7 @@ char *text_file_name;
char *union_file_name; char *union_file_name;
char *verbose_file_name; char *verbose_file_name;


#if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) || (__APPLE__) #ifdef HAS_MKSTEMP
#define HAVE_MKSTEMP
#endif

#ifdef HAVE_MKSTEMP
int action_fd = -1, entry_fd = -1, text_fd = -1, union_fd = -1; int action_fd = -1, entry_fd = -1, text_fd = -1, union_fd = -1;
#endif #endif


Expand Down Expand Up @@ -101,7 +97,7 @@ char *rassoc;
short **derives; short **derives;
char *nullable; char *nullable;


#if !defined(HAVE_MKSTEMP) #if !defined(HAS_MKSTEMP)
extern char *mktemp(char *); extern char *mktemp(char *);
#endif #endif
#ifndef NO_UNIX #ifndef NO_UNIX
Expand All @@ -111,7 +107,7 @@ extern char *getenv(const char *);


void done(int k) void done(int k)
{ {
#ifdef HAVE_MKSTEMP #ifdef HAS_MKSTEMP
if (action_fd != -1) if (action_fd != -1)
unlink(action_file_name); unlink(action_file_name);
if (entry_fd != -1) if (entry_fd != -1)
Expand Down Expand Up @@ -325,7 +321,7 @@ void create_file_names(void)
text_file_name[len + 5] = 't'; text_file_name[len + 5] = 't';
union_file_name[len + 5] = 'u'; union_file_name[len + 5] = 'u';


#ifdef HAVE_MKSTEMP #ifdef HAS_MKSTEMP
action_fd = mkstemp(action_file_name); action_fd = mkstemp(action_file_name);
if (action_fd == -1) if (action_fd == -1)
open_error(action_file_name); open_error(action_file_name);
Expand Down Expand Up @@ -384,23 +380,23 @@ void open_files(void)
open_error(input_file_name); open_error(input_file_name);
} }


#ifdef HAVE_MKSTEMP #ifdef HAS_MKSTEMP
action_file = fdopen(action_fd, "w"); action_file = fdopen(action_fd, "w");
#else #else
action_file = fopen(action_file_name, "w"); action_file = fopen(action_file_name, "w");
#endif #endif
if (action_file == 0) if (action_file == 0)
open_error(action_file_name); open_error(action_file_name);


#ifdef HAVE_MKSTEMP #ifdef HAS_MKSTEMP
entry_file = fdopen(entry_fd, "w"); entry_file = fdopen(entry_fd, "w");
#else #else
entry_file = fopen(entry_file_name, "w"); entry_file = fopen(entry_file_name, "w");
#endif #endif
if (entry_file == 0) if (entry_file == 0)
open_error(entry_file_name); open_error(entry_file_name);


#ifdef HAVE_MKSTEMP #ifdef HAS_MKSTEMP
text_file = fdopen(text_fd, "w"); text_file = fdopen(text_fd, "w");
#else #else
text_file = fopen(text_file_name, "w"); text_file = fopen(text_file_name, "w");
Expand All @@ -420,7 +416,7 @@ void open_files(void)
defines_file = fopen(defines_file_name, "w"); defines_file = fopen(defines_file_name, "w");
if (defines_file == 0) if (defines_file == 0)
open_error(defines_file_name); open_error(defines_file_name);
#ifdef HAVE_MKSTEMP #ifdef HAS_MKSTEMP
union_file = fdopen(union_fd, "w"); union_file = fdopen(union_fd, "w");
#else #else
union_file = fopen(union_file_name, "w"); union_file = fopen(union_file_name, "w");
Expand Down

0 comments on commit ec96727

Please sign in to comment.