pkgsrc/graphics/urt/patches/patch-ah
dholland e76757474f Don't use sys_errlist; among other things it apparently fails on
Solaris 11. While here, patch the same small offending program to
not use mktemp (probably unsafely) and to not exhibit void main.
PKGREVISION++.
2014-01-02 07:34:11 +00:00

83 lines
1.7 KiB
Text

$NetBSD: patch-ah,v 1.5 2014/01/02 07:34:11 dholland Exp $
- use standard headers
- don't declare own errno
- don't use sys_errlist
- don't use mktemp
- avoid void main
- use c89
--- tools/into.c.orig 1992-04-30 14:10:15.000000000 +0000
+++ tools/into.c
@@ -27,6 +27,7 @@
#include "rle_config.h"
#include <stdio.h>
+#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/param.h> /* for MAXPATHLEN */
@@ -40,19 +41,14 @@ static char temp[] = "intoXXXXXXXX";
static char buf[MAXPATHLEN+1];
short forceflg; /* overwrite an unwritable file? */
-extern int errno;
-extern char *sys_errlist[];
-
-void
-main(argc, argv)
-int argc;
-char **argv;
+int
+main(int argc, char **argv)
{
char *cp;
int c;
FILE * outf;
char iobuf[BUFSIZ];
- int size;
+ int size, fd;
/* Don't allow files named "-f" in order to catch common error */
if (argc >= 2 && !strcmp(argv[1], "-f"))
@@ -72,7 +68,7 @@ char **argv;
exit(1);
}
- if ( (cp = rindex( argv[1], '/' )) != NULL )
+ if ( (cp = rle_rindex( argv[1], '/' )) != NULL )
{
c = *++cp;
*cp = 0;
@@ -82,9 +78,9 @@ char **argv;
}
else
strcpy( buf, temp );
- mktemp( buf );
+ fd = mkstemp( buf );
- if ( (outf = fopen( buf, "w" )) == NULL )
+ if ( fd < 0 || (outf = fdopen( fd, "w" )) == NULL )
{
perror(buf);
exit(1);
@@ -103,7 +99,7 @@ char **argv;
if (ferror(outf))
{
fprintf(stderr, "into: %s, \"%s\" not modified\n",
- sys_errlist[errno], argv[1]);
+ strerror(errno), argv[1]);
unlink(buf);
exit(1);
}
@@ -118,8 +114,8 @@ char **argv;
}
#ifdef NEED_RENAME
-rename( file1, file2 )
-char *file1, *file2;
+int
+rename( char *file1, char *file2 )
{
struct stat st;