lpd ls lspci M m4 mail make MAKEDEV makewhatis man \
mdb mesg mined mkdep mkdir mkdist mkfifo mkfs mknod \
mkproto modem mount mt netconf newroot nice nm nohup \
- nonamed od packit packman passwd paste pax \
+ nonamed od packit packman passwd paste patch pax \
ping postinstall poweroff pr prep printf printroot \
profile progressbar proto pr_routes ps pwd pwdauth \
ramdisk rarpd rawspeed rcp rdate readall readclock \
PROG= patch
SRCS= patch.c pch.c inp.c util.c backupfile.c mkpath.c
-.include <bsd.prog.mk>
+.include <minix.prog.mk>
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: backupfile.c,v 1.14 2008/09/19 18:33:34 joerg Exp $");
#include <ctype.h>
#include <dirent.h>
file_name_length = strlen(file);
while ((dp = readdir(dirp)) != NULL) {
- if (dp->d_namlen <= file_name_length)
+ if (strlen(dp->d_name) <= file_name_length)
continue;
this_version = version_number(file, dp->d_name, file_name_length);
make_version_name(const char *file, int version)
{
char *backup_name;
+ int len = strlen(file)+20;
- if (asprintf(&backup_name, "%s.~%d~", file, version) == -1)
+ if(!(backup_name = malloc(len)))
return NULL;
+
+ if (snprintf(backup_name, len, "%s.~%d~", file, version) == -1)
+ return NULL;
+
return backup_name;
}
concat(const char *str1, const char *str2)
{
char *newstr;
+ int len = strlen(str1) + strlen(str2) + 1;
- if (asprintf(&newstr, "%s%s", str1, str2) == -1)
+ if(!(newstr = malloc(strlen(str1) + strlen(str2) + 1)))
return NULL;
+
+ if (snprintf(newstr, len, "%s%s", str1, str2) == -1)
+ return NULL;
+
return newstr;
}
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: inp.c,v 1.19 2008/09/19 18:33:34 joerg Exp $");
#include <sys/types.h>
#include <sys/file.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <fcntl.h>
#include "common.h"
#include "util.h"
static off_t i_size; /* size of the input file */
static char *i_womp; /* plan a buffer for entire file */
static char **i_ptr; /* pointers to lines in i_womp */
+#if 0
static char empty_line[] = { '\0' };
+#endif
static int tifd = -1; /* plan b virtual string array */
static char *tibuf[2]; /* plan b buffers */
static int tireclen; /* length of records in tmp file */
static bool rev_in_string(const char *);
+#if 0
static bool reallocate_lines(size_t *);
+#endif
/* returns false if insufficient memory */
static bool plan_a(const char *);
}
}
+#if 0
static bool
reallocate_lines(size_t *lines_allocated)
{
i_ptr = p;
return true;
}
+#endif
/* Try keeping everything in memory. */
static bool
plan_a(const char *filename)
{
+#ifdef __minix
+ return false;
+#else
int ifd, statfailed;
char *p, *s, lbuf[MAXLINELEN];
struct stat filestat;
revision);
}
return true; /* plan a will work */
+#endif
}
/* Keep (virtually) nothing in memory. */
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: mkpath.c,v 1.1 2008/09/19 18:33:34 joerg Exp $");
#include <sys/types.h>
#include <sys/stat.h>
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: patch.c,v 1.27 2008/09/19 18:33:34 joerg Exp $");
#include <sys/types.h>
#include <sys/stat.h>
LINENUM where = 0, newwhere, fuzz, mymaxfuzz;
const char *tmpdir;
char *v;
+ int alloclen;
setbuf(stderr, serrbuf);
for (i = 0; i < MAXFILEC; i++)
filearg[i] = NULL;
+
/* Cons up the names of the temporary files. */
if ((tmpdir = getenv("TMPDIR")) == NULL || *tmpdir == '\0')
tmpdir = _PATH_TMP;
for (i = strlen(tmpdir) - 1; i > 0 && tmpdir[i] == '/'; i--)
;
i++;
- if (asprintf(&TMPOUTNAME, "%.*s/patchoXXXXXXXXXX", i, tmpdir) == -1)
+
+ alloclen = i + 100;
+#define TMPALLOC(var) if(!(var = malloc(alloclen))) { fatal(#var); exit(1); }
+ TMPALLOC(TMPOUTNAME);
+ TMPALLOC(TMPINNAME);
+ TMPALLOC(TMPREJNAME);
+ TMPALLOC(TMPPATNAME);
+
+ if (snprintf(TMPOUTNAME, alloclen, "%.*s/patchoXXXXXXXXXX", i, tmpdir) == -1)
fatal("cannot allocate memory");
if ((fd = mkstemp(TMPOUTNAME)) < 0)
pfatal("can't create %s", TMPOUTNAME);
close(fd);
- if (asprintf(&TMPINNAME, "%.*s/patchiXXXXXXXXXX", i, tmpdir) == -1)
+ if (snprintf(TMPINNAME, alloclen, "%.*s/patchiXXXXXXXXXX", i, tmpdir) == -1)
fatal("cannot allocate memory");
if ((fd = mkstemp(TMPINNAME)) < 0)
pfatal("can't create %s", TMPINNAME);
close(fd);
- if (asprintf(&TMPREJNAME, "%.*s/patchrXXXXXXXXXX", i, tmpdir) == -1)
+ if (snprintf(TMPREJNAME, alloclen, "%.*s/patchrXXXXXXXXXX", i, tmpdir) == -1)
fatal("cannot allocate memory");
if ((fd = mkstemp(TMPREJNAME)) < 0)
pfatal("can't create %s", TMPREJNAME);
close(fd);
- if (asprintf(&TMPPATNAME, "%.*s/patchpXXXXXXXXXX", i, tmpdir) == -1)
+ if (snprintf(TMPPATNAME, alloclen, "%.*s/patchpXXXXXXXXXX", i, tmpdir) == -1)
fatal("cannot allocate memory");
if ((fd = mkstemp(TMPPATNAME)) < 0)
pfatal("can't create %s", TMPPATNAME);
* on July 29, 2003.
*/
-#include <paths.h>
+#include <minix/paths.h>
#define _PATH_ED "/bin/ed"
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: pch.c,v 1.23 2008/09/19 18:33:34 joerg Exp $");
#include <sys/types.h>
#include <sys/stat.h>
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: util.c,v 1.24 2008/09/19 18:33:34 joerg Exp $");
#include <sys/param.h>
#include <sys/stat.h>
#include <errno.h>
#include <fcntl.h>
#include <libgen.h>
-#include <paths.h>
+#include <minix/paths.h>
#include <signal.h>
#include <stdarg.h>
#include <stdlib.h>