[Midnightbsd-cvs] CVS Commit: bin/pax: Our pax and cpio implementations do not support

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Sun Aug 12 03:53:21 EDT 2007


Log Message:
-----------
Our pax and cpio implementations do not support GNU style long options.  This is causing me hell in the transition off GNU cpio.  This adds some of the GNU longopts for cpio.  

>From NetBSD.

Modified Files:
--------------
    src/bin/pax:
        ar_io.c (r1.2 -> r1.3)
        options.c (r1.2 -> r1.3)

-------------- next part --------------
Index: options.c
===================================================================
RCS file: /home/cvs/src/bin/pax/options.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -Lbin/pax/options.c -Lbin/pax/options.c -u -r1.2 -r1.3
--- bin/pax/options.c
+++ bin/pax/options.c
@@ -51,6 +51,7 @@
 #include <stdlib.h>
 #include <limits.h>
 #include <paths.h>
+#include <getopt.h>
 #include "pax.h"
 #include "options.h"
 #include "cpio.h"
@@ -1004,6 +1005,29 @@
 
 	return (0);
 }
+
+struct option cpio_longopts[] = {
+	{ "reset-access-time",	no_argument,		0,	'a' },
+	{ "make-directories",	no_argument,		0, 	'd' },
+	{ "nonmatching",	no_argument,		0,	'f' },
+	{ "extract",		no_argument,		0,	'i' },
+	{ "link",		no_argument,		0,	'l' },
+	{ "preserve-modification-time", no_argument,	0,	'm' },
+	{ "create",		no_argument,		0,	'o' },
+	{ "pass-through",	no_argument,		0,	'p' },
+	{ "rename",		no_argument,		0,	'r' },
+	{ "list",		no_argument,		0,	't' },
+	{ "unconditional",	no_argument,		0,	'u' },
+	{ "verbose",		no_argument,		0,	'v' },
+	{ "append",		no_argument,		0,	'A' },
+	{ "pattern-file",	required_argument,	0,	'E' },
+	{ "file",		required_argument,	0,	'F' },
+	{ "format",		required_argument,	0,	'H' },
+	{ "dereference",	no_argument,		0,	'L' },
+	{ "swap-halfwords",	no_argument,		0,	'S' },
+	{ NULL,			0,			NULL,	0 }
+};
+
 /*
  * cpio_options()
  *	look at the user specified flags. set globals as required and check if
@@ -1027,7 +1051,9 @@
 	dflag = 1;
 	act = -1;
 	nodirs = 1;
-	while ((c=getopt(argc,argv,"abcdfiklmoprstuvzABC:E:F:H:I:LO:SZ6")) != -1)
+	while ((c = getopt_long(argc, argv,
+		"+abcdfiklmoprstuvzABC:E:F:H:I:LO:SZ6",
+		cpio_longopts, NULL)) != -1)
 		switch (c) {
 			case 'a':
 				/*
Index: ar_io.c
===================================================================
RCS file: /home/cvs/src/bin/pax/ar_io.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -Lbin/pax/ar_io.c -Lbin/pax/ar_io.c -u -r1.2 -r1.3
--- bin/pax/ar_io.c
+++ bin/pax/ar_io.c
@@ -1230,7 +1230,7 @@
 		 */
 		if (ar_open(buf) >= 0) {
 			if (freeit) {
-				(void)free((char *)(uintptr_t)arcname);
+				free((char *)(uintptr_t)arcname);
 				freeit = 0;
 			}
 			if ((arcname = strdup(buf)) == NULL) {


More information about the Midnightbsd-cvs mailing list