[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    [BusyBox] [PATCH] for strings.c and deallocvt.c in bb_unstable
From:       Tito <farmatito () tiscali ! it>
Date:       2003-04-21 13:58:59
[Download RAW message or body]

Hi,
Attached is a little fix for strings.c and two patches (not sequential) that rework deallocvt.c
( deallocvt_extreme_patch.txt maybe is too extreme........just an idea ).
Please apply at least the one for strings.

Thanks in advance
Ciao
Tito



["deallocvt_extreme_patch.txt" (text/plain)]

--- console-tools/deallocvt.c	2003-03-19 09:11:28.000000000 +0000
+++ console-tools/deallocvt.c	2003-04-20 22:10:09.000000000 +0000
@@ -15,29 +15,18 @@
 
 int deallocvt_main(int argc, char *argv[])
 {
-	int fd, num, i;
+	/*  num=0  deallocates all unused consoles */
+	int fd, num=0;
 
-	//if ((argc > 2) || ((argv == 2) && (**(argv + 1) == '-')))
 	if (argc > 2)
 		bb_show_usage();
 
 	fd = get_console_fd();
 
-	if (argc == 1) {
-		/* deallocate all unused consoles */
-		if (ioctl(fd, VT_DISALLOCATE, 0))
-			bb_perror_msg_and_die("VT_DISALLOCATE");
-	} else {
-		for (i = 1; i < argc; i++) {
-			num = atoi(argv[i]);
-			if (num == 0)
-				bb_error_msg("0: illegal VT number");
-			else if (num == 1)
-				bb_error_msg("VT 1 cannot be deallocated");
-			else if (ioctl(fd, VT_DISALLOCATE, num))
-				bb_perror_msg_and_die("VT_DISALLOCATE");
-		}
-	}
+	if (argc == 2)
+		num=bb_xgetlarg(argv[1], 10, 2, INT_MAX);
 
+	if (ioctl(fd, VT_DISALLOCATE, num))
+		bb_perror_msg_and_die("VT_DISALLOCATE");
 	return EXIT_SUCCESS;
 }

["deallocvt_patch.txt" (text/plain)]

--- console-tools/deallocvt.c	2003-03-19 09:11:28.000000000 +0000
+++ console-tools/deallocvt.c	2003-04-20 21:40:29.000000000 +0000
@@ -15,29 +15,32 @@
 
 int deallocvt_main(int argc, char *argv[])
 {
-	int fd, num, i;
+	int fd, num=0;
 
-	//if ((argc > 2) || ((argv == 2) && (**(argv + 1) == '-')))
 	if (argc > 2)
 		bb_show_usage();
 
 	fd = get_console_fd();
+	
+	/*  num=0  deallocate all unused consoles */
+	if (argc == 1)
+		goto disallocate_all;
 
-	if (argc == 1) {
-		/* deallocate all unused consoles */
-		if (ioctl(fd, VT_DISALLOCATE, 0))
-			bb_perror_msg_and_die("VT_DISALLOCATE");
-	} else {
-		for (i = 1; i < argc; i++) {
-			num = atoi(argv[i]);
-			if (num == 0)
-				bb_error_msg("0: illegal VT number");
-			else if (num == 1)
-				bb_error_msg("VT 1 cannot be deallocated");
-			else if (ioctl(fd, VT_DISALLOCATE, num))
+	num=bb_xgetlarg(argv[1], 10, 0, INT_MAX);
+
+	switch(num)
+	{
+		case 0:
+			bb_error_msg("0: illegal VT number");
+			break;
+		case 1:
+			bb_error_msg("VT 1 cannot be deallocated");
+			break;
+		default:
+disallocate_all:
+			if (ioctl(fd, VT_DISALLOCATE, num))
 				bb_perror_msg_and_die("VT_DISALLOCATE");
-		}
+			return EXIT_SUCCESS;
 	}
-
-	return EXIT_SUCCESS;
+	return EXIT_FAILURE;
 }

["strings_patch.txt" (text/plain)]

--- miscutils/strings.c	2003-03-19 09:12:29.000000000 +0000
+++ miscutils/strings.c	2003-04-20 20:22:49.000000000 +0000
@@ -54,7 +54,7 @@
 				opt+=2;
 				break;
 			case 'n':
-				n = bb_xgetlarg(optarg, 10, 1, LONG_MAX);
+				n = bb_xgetlarg(optarg, 10, 1, INT_MAX);
 				break;
 			default:
 				bb_show_usage();


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic