Group :: System/Configuration/Printing
RPM: mpage
Main Changelog Spec Patches Sources Download Gear Bugs and FR Repocop
Patch: mpage-2.5.4-alt-tmpfile.patch
Download
Download
diff -Naur mpage-2.5.4/file.c mpage-2.5.4.new/file.c
--- mpage-2.5.4/file.c 2004-05-30 23:34:15 +0400
+++ mpage-2.5.4.new/file.c 2005-04-14 16:07:23 +0400
@@ -17,6 +17,8 @@
*
*/
+#include <error.h>
+extern const char *__progname;
#include "mpage.h"
@@ -156,9 +158,19 @@
#if 1
FILE *fd;
char buffer[LINESIZE];
- char tmpfile[LINESIZE];
int incnt, outcnt;
int tmpfd;
+ /*nomal tmpdir support*/
+ const char suffix[] = ".XXXXXX";
+ const char *tmp_dir = getenv("TMPDIR")?:"/tmp";
+ unsigned tmp_len = strlen( tmp_dir );
+ unsigned prog_len = strlen( __progname );
+ char tmpfile[ tmp_len + prog_len + sizeof(suffix) + 1 ];
+
+ memcpy( tmpfile, tmp_dir, tmp_len );
+ tmpfile[ tmp_len ] = '/';
+ memcpy( tmpfile + tmp_len + 1, __progname, prog_len );
+ memcpy( tmpfile + tmp_len + prog_len + 1, suffix, sizeof(suffix) );
/*
* Now the utf8 patch is in we always create a temporary file.
@@ -168,7 +180,6 @@
* but the tmpfilename
*/
- (void) strcpy(tmpfile, "/usr/tmp/mpage-stdin-XXXXXX");
if ( (tmpfd = mkstemp(tmpfile)) == -1) {
fprintf(stderr, "%s: cannot create temporary file", MPAGE);
perror(MPAGE);