patch for vinum to use libedit

Peter Avalos pavalos at theshell.com
Sun May 6 11:37:55 PDT 2007


Here's a patch that switches vinum to libedit.  I don't use vinum, so
this is untested, and I'd appreciate anyone that uses vinum to give
some feedback.

--Peter

also available at http://www.theshell.com/~pavalos/wip/vinum.patch

Switch from readline to libedit.

v.c:  Change history to hist to prevent symbol collision from libedit.
Index: Makefile
===================================================================
RCS file: /home/dcvs/src/sbin/vinum/Makefile,v
retrieving revision 1.8
diff -u -r1.8 Makefile
--- Makefile	17 Oct 2006 00:55:44 -0000	1.8
+++ Makefile	29 Apr 2007 16:05:21 -0000
@@ -6,8 +6,8 @@
 MAN=	vinum.8
 WARNS?=	2
 
-CFLAGS+=	-I${.CURDIR}/../../sys
-DPADD=	${LIBUTIL} ${LIBREADLINE} ${LIBTERMCAP}
-LDADD=	-lreadline -ltermcap -ldevstat
+CFLAGS+=	-I${.CURDIR}/../../lib/libedit -I${.CURDIR}/../../sys
+DPADD=	${LIBEDIT} ${LIBTERMCAP} ${LIBDEVSTAT}
+LDADD=	-ledit -ltermcap -ldevstat
 
 .include <bsd.prog.mk>
Index: commands.c
===================================================================
RCS file: /home/dcvs/src/sbin/vinum/commands.c,v
retrieving revision 1.7
diff -u -r1.7 commands.c
--- commands.c	20 Jan 2007 19:20:39 -0000	1.7
+++ commands.c	6 May 2007 18:31:39 -0000
@@ -59,7 +59,6 @@
 #include <sys/linker.h>
 #include <sys/module.h>
 #include <sys/wait.h>
-#include <readline/history.h>
 #include <readline/readline.h>
 #include <devstat.h>
 
Index: v.c
===================================================================
RCS file: /home/dcvs/src/sbin/vinum/v.c,v
retrieving revision 1.5
diff -u -r1.5 v.c
--- v.c	20 Jan 2007 19:20:39 -0000	1.5
+++ v.c	6 May 2007 18:31:31 -0000
@@ -54,14 +54,13 @@
 #include "vext.h"
 #include <sys/types.h>
 #include <sys/wait.h>
-#include <readline/history.h>
 #include <readline/readline.h>
 #include <sys/linker.h>
 #include <sys/module.h>
 #include <sys/resource.h>
 
 FILE *cf;						    /* config file handle */
-FILE *history;						    /* history file */
+FILE *hist;						    /* history file */
 char *historyfile;					    /* and its name */
 
 char *dateformat;					    /* format in which to store date */
@@ -139,11 +138,11 @@
 	    errno);
 	exit(1);
     }
-    history = fopen(historyfile, "a+");
-    if (history != NULL) {
+    hist = fopen(historyfile, "a+");
+    if (hist != NULL) {
 	timestamp();
-	fprintf(history, "*** " VINUMMOD " started ***\n");
-	fflush(history);				    /* before we start the daemon */
+	fprintf(hist, "*** " VINUMMOD " started ***\n");
+	fflush(hist);				    /* before we start the daemon */
     }
     superdev = open(VINUM_SUPERDEV_NAME, O_RDWR);	    /* open vinum superdevice */
     if (superdev < 0) {					    /* no go */
@@ -224,8 +223,8 @@
 		if (tokens)
 		    parseline(tokens, token);		    /* and do what he says */
 	    }
-	    if (history)
-		fflush(history);
+	    if (hist)
+		fflush(hist);
 	}
     }
     return 0;						    /* normal completion */
@@ -316,11 +315,11 @@
     int j;
     enum keyword command;				    /* command to execute */
 
-    if (history != NULL) {				    /* save the command to history file */
+    if (hist != NULL) {				    /* save the command to history file */
 	timestamp();
 	for (i = 0; i < args; i++)			    /* all args */
-	    fprintf(history, "%s ", argv[i]);
-	fputs("\n", history);
+	    fprintf(hist, "%s ", argv[i]);
+	fputs("\n", hist);
     }
     if ((args == 0)					    /* empty line */
     ||(*argv[0] == '#'))				    /* or a comment, */
@@ -525,9 +524,9 @@
 	    perror(VINUMMOD ": Can't write to /dev");
 	return;
     }
-    if (history) {
+    if (hist) {
 	timestamp();
-	fprintf(history, "*** Created devices ***\n");
+	fprintf(hist, "*** Created devices ***\n");
     }
     if (superdev >= 0)					    /* super device open */
 	close(superdev);
@@ -849,7 +848,7 @@
     char datetext[MAXDATETEXT];
     time_t sec;
 
-    if (history != NULL) {
+    if (hist != NULL) {
 	if (gettimeofday(&now, NULL) != 0) {
 	    fprintf(stderr, "Can't get time: %s\n", strerror(errno));
 	    return;
@@ -857,7 +856,7 @@
 	sec = now.tv_sec;
 	date = localtime(&sec);
 	strftime(datetext, MAXDATETEXT, dateformat, date),
-	    fprintf(history,
+	    fprintf(hist,
 	    "%s.%06ld ",
 	    datetext,
 	    now.tv_usec);
Attachment:
pgp00000.pgp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pgp00000.pgp
Type: application/octet-stream
Size: 189 bytes
Desc: "Description: PGP signature"
URL: <http://lists.dragonflybsd.org/pipermail/submit/attachments/20070506/7e5cc5a7/attachment-0018.obj>


More information about the Submit mailing list