A couple of patches from Tito <farmatito@tiscali.it>
authorEric Andersen <andersen@codepoet.org>
Sun, 27 Apr 2003 10:42:31 +0000 (10:42 -0000)
committerEric Andersen <andersen@codepoet.org>
Sun, 27 Apr 2003 10:42:31 +0000 (10:42 -0000)
console-tools/deallocvt.c
miscutils/strings.c

index a4ba851c8428a87d723a556f514094ece9d8b13e..f641be8d76a34101f16b4ed15f74aa528db17506 100644 (file)
@@ -15,29 +15,32 @@ static const int VT_DISALLOCATE = 0x5608;  /* free memory associated to vt */
 
 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;
 }
index 2413c3f2db33e94aefb112212b2180e6a086e32c..c0d4a3f7445294ca804d7da41b4795c172a682b8 100644 (file)
@@ -54,7 +54,7 @@ int strings_main(int argc, char **argv)
                                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();