Index: configure.in
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/configure.in,v
retrieving revision 1.200
diff -u -d -r1.200 configure.in
--- configure.in	22 Apr 2005 16:08:04 -0000	1.200
+++ configure.in	2 May 2005 06:24:16 -0000
@@ -482,6 +482,7 @@
 AC_CHECK_FUNCS(isnan isinf finite fmod strtod mmap munmap getpagesize)
 AC_CHECK_FUNCS(stat lstat vfprintf waitpid wait fork execv open)
 AC_CHECK_FUNCS(getpid qsort unlink remove getcwd getwd)
+AC_CHECK_FUNCS(mkstemp getenv)
 AC_CHECK_FUNCS(get_current_dir_name dlopen strerror fcntl ftruncate)
 AC_CHECK_FUNCS(acos asin atan atan2 ceil cos cosh exp floor remainder)
 AC_CHECK_FUNCS(log log10 pow rint sin sinh sqrt tan tanh)
Index: csant/csant_cscc.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/csant/csant_cscc.c,v
retrieving revision 1.29
diff -u -d -r1.29 csant_cscc.c
--- csant/csant_cscc.c	7 Aug 2004 00:14:24 -0000	1.29
+++ csant/csant_cscc.c	2 May 2005 06:24:16 -0000
@@ -227,7 +227,7 @@
 	int				numDefines;
 	char		  **args;
 	int				numArgs;
-
+	char		   *temp_source_file_name;
 } CSAntCompileArgs;
 
 /*
@@ -245,6 +245,11 @@
 	CSAntFileSetDestroy(args->modules);
 	FreeArgs(args->defines, args->numDefines);
 	FreeArgs(args->args, args->numArgs);
+	if(args->temp_source_file_name != 0)
+	{
+		ILDeleteFile(args->temp_source_file_name + 1);
+		ILFree(args->temp_source_file_name);
+	}
 }
 
 /*
@@ -281,6 +286,7 @@
 	args->numDefines = 0;
 	args->args = 0;
 	args->numArgs = 0;
+	args->temp_source_file_name = 0;
 
 	/* Validate "output" and "target" */
 	if(!(args->output))
@@ -487,6 +493,56 @@
 	return 1;
 }
 
+/* How many source files to go ahead and expand on the command line
+   before writing them to a response file instead. */
+#define MAX_SOURCE_INLINE_FILES 40
+/*
+ * Write a new temporary file with each of the filenames in FSET,
+ * returning the path to the file, so it can be deleted after it's no
+ * longer needed.
+ */
+static char *BuildResponseFile(CSAntFileSet *fset)
+{
+	ILSysIOHandle tmp_fd;
+	char *tmp_path;
+	unsigned long fset_size;
+	unsigned long file;
+	char *to_write;
+	if ((tmp_fd = ILSysIOOpenTempFile(&tmp_path)) == ILSysIOHandle_Invalid)
+	{
+#ifdef HAVE_STRERROR
+		fprintf(stderr, "csant: Can't create tempfile: %s\n", strerror(errno));
+#endif
+		return 0;
+	}
+	fset_size = CSAntFileSetSize(fset);
+	for (file = 0; file < fset_size; ++file)
+	{
+		to_write = CSAntFileSetFile(fset, file);
+		if (ILSysIOWrite(tmp_fd, (void *)to_write, strlen(to_write)) == -1
+			|| ILSysIOWrite(tmp_fd, (void *)"\n", strlen("\n")) == -1)
+		{
+			ILSysIOClose(tmp_fd);
+			ILDeleteFile(tmp_path);
+#ifdef HAVE_STRERROR
+			fprintf(stderr, "%s: %s\n", tmp_path, strerror(errno));
+#endif
+			ILFree(tmp_path);
+			return 0;
+		}
+	}
+	if (!ILSysIOClose(tmp_fd))	/* ensure all data written */
+	{
+		ILDeleteFile(tmp_path);
+#ifdef HAVE_STRERROR
+		fprintf(stderr, "%s: %s\n", tmp_path, strerror(errno));
+#endif
+		ILFree(tmp_path);
+		return 0;
+	}
+	return tmp_path;
+}
+
 /*
  * Build a command-line for "cscc".
  */
@@ -618,9 +674,27 @@
 
 	/* Add the source files to the command-line */
 	numFiles = CSAntFileSetSize(args->sources);
-	for(file = 0; file < numFiles; ++file)
+	if (numFiles <= MAX_SOURCE_INLINE_FILES)
 	{
-		AddArg(&argv, &argc, CSAntFileSetFile(args->sources, file));
+		for(file = 0; file < numFiles; ++file)
+		{
+			AddArg(&argv, &argc, CSAntFileSetFile(args->sources, file));
+		}
+	}
+	else
+	{
+		temp = BuildResponseFile(args->sources);
+		if (temp)
+		{
+			args->temp_source_file_name = (char *)ILMalloc(strlen(temp) + 2);
+			if (args->temp_source_file_name == 0)
+				CSAntOutOfMemory();
+			args->temp_source_file_name[0] = '@';
+			strcpy(args->temp_source_file_name + 1, temp);
+			ILFree(temp);
+			temp = 0;
+			AddArg(&argv, &argc, args->temp_source_file_name);
+		}
 	}
 
 	/* Add the library references to the command-line */
Index: include/il_sysio.h
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/include/il_sysio.h,v
retrieving revision 1.24
diff -u -d -r1.24 il_sysio.h
--- include/il_sysio.h	21 Feb 2005 12:17:06 -0000	1.24
+++ include/il_sysio.h	2 May 2005 06:24:16 -0000
@@ -468,6 +468,15 @@
  */
 int ILSysIOSetFileAttributes(const char *path, ILInt32 attributes);
 
+/*
+ * Securely open a new temporary file for writing, returning a file
+ * handle as with ILSysIOOpenFile.  Store the path to the filename in
+ * *out_path, suitable as an argument to ILDeleteFile when done with
+ * the temporary file.  *out_path must be freed if the operation
+ * succeeds.
+ */
+ILSysIOHandle ILSysIOOpenTempFile(char **out_path);
+
 #ifdef	__cplusplus 
 };
 #endif
Index: support/file.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/support/file.c,v
retrieving revision 1.23
diff -u -d -r1.23 file.c
--- support/file.c	26 May 2004 08:25:46 -0000	1.23
+++ support/file.c	2 May 2005 06:24:16 -0000
@@ -824,6 +824,69 @@
 #endif
 }
 
+ILSysIOHandle ILSysIOOpenTempFile(char **out_path)
+{
+#define DIE return ILSysIOHandle_Invalid
+	ILSysIOHandle result;
+#if defined(IL_WIN32_PLATFORM)
+	/* This code came from spawn.c (ILSpawnProcess), so I don't know
+	   whether it works here */
+	char temppath[MAX_PATH];
+	char tempname[MAX_PATH];
+	if (!GetTempPath(sizeof(temppath), temppath))
+	{
+		DIE;
+	}
+	if (!GetTempFileName(temppath, "ILS", 0, tempname))
+	{
+		DIE;
+	}
+	result = ILSysIOOpen(tempname, ILFileMode_CreateNew,
+						 ILFileAccess_Write, 2);
+	if (result != ILSysIOHandle_Invalid)
+	{
+		*out_path = ILDupString(tempname);
+		if (*out_path == 0)
+			result = -1;
+	}
+	return result;
+#elif defined(HAVE_MKSTEMP) && defined(HAVE_GETENV)
+	size_t strloc;
+	const char *tmpdir_env;
+	size_t idx;
+	static const char *tmpenvs[] = { "TMPDIR", "TEMP", "TMP", 0 };
+	/* take the first defined environment variable, falling back on
+	   "/tmp" if all are missing or empty (POSIX) */
+	tmpdir_env = 0;
+	for (idx = 0; tmpdir_env == 0 || tmpdir_env[0] == '\0'; ++idx)
+	{
+		if (tmpenvs[idx] == 0)
+			tmpdir_env = "/tmp";
+		else
+			tmpdir_env = getenv(tmpenvs[idx]);
+	}
+	strloc = strlen(tmpdir_env);
+	*out_path = (char *)ILMalloc(strloc + 11 + 1);
+	if (*out_path == 0)
+	{
+		DIE;
+	}
+	ILMemCpy((void *)*out_path, (void *)tmpdir_env, strloc);
+	ILMemCpy((void *)(*out_path + strloc), (void *)"/ilsuXXXXXX", 11 + 1);
+	result = (ILSysIOHandle)(ILNativeInt)(mkstemp(*out_path));
+	if (result == ILSysIOHandle_Invalid)
+	{
+		ILFree(*out_path);
+		*out_path = 0;
+	}
+	return result;
+#else
+	ILSysIOSetErrno(IL_ERRNO_ENOSYS);
+	DIE;
+#endif
+#undef DIE
+}
+
 #else /* IL_NO_FILE_ROUTINES */
 
 int ILDeleteFile(const char *filename)
@@ -964,6 +1027,12 @@
 	return IL_ERRNO_ENOENT;
 }
 
+ILSysIOHandle ILSysIOOpenTempFile(char **out_path)
+{
+	errno = ENOENT;				/* I dunno */
+	return (ILSysIOHandle)(ILNativeInt)(-1);
+}
+
 #endif /* IL_NO_FILE_ROUTINES */
 
 #ifdef	__cplusplus
