prevent stupid Ambiquous Command error on null input line
[unix-history] / usr / src / usr.sbin / lpr / lpc / lpc.c
index 0f8a010..47b84e9 100644 (file)
@@ -22,7 +22,7 @@ char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)lpc.c      5.7 (Berkeley) %G%";
+static char sccsid[] = "@(#)lpc.c      5.9 (Berkeley) %G%";
 #endif /* not lint */
 
 /*
 #endif /* not lint */
 
 /*
@@ -107,7 +107,7 @@ cmdscanner(top)
                }
                if (fgets(cmdline, sizeof(cmdline), stdin) == 0)
                        quit();
                }
                if (fgets(cmdline, sizeof(cmdline), stdin) == 0)
                        quit();
-               if (cmdline[0] == 0)
+               if (cmdline[0] == 0 || cmdline[0] == '\n')
                        break;
                makeargv();
                c = getcmd(margv[0]);
                        break;
                makeargv();
                c = getcmd(margv[0]);
@@ -201,7 +201,7 @@ help(argc, argv)
                extern int NCMDS;
 
                printf("Commands may be abbreviated.  Commands are:\n\n");
                extern int NCMDS;
 
                printf("Commands may be abbreviated.  Commands are:\n\n");
-               for (c = cmdtab; c < &cmdtab[NCMDS - 1]; c++) {
+               for (c = cmdtab; c->c_name; c++) {
                        int len = strlen(c->c_name);
 
                        if (len > width)
                        int len = strlen(c->c_name);
 
                        if (len > width)
@@ -215,7 +215,8 @@ help(argc, argv)
                for (i = 0; i < lines; i++) {
                        for (j = 0; j < columns; j++) {
                                c = cmdtab + j * lines + i;
                for (i = 0; i < lines; i++) {
                        for (j = 0; j < columns; j++) {
                                c = cmdtab + j * lines + i;
-                               printf("%s", c->c_name);
+                               if (c->c_name)
+                                       printf("%s", c->c_name);
                                if (c + lines >= &cmdtab[NCMDS]) {
                                        printf("\n");
                                        break;
                                if (c + lines >= &cmdtab[NCMDS]) {
                                        printf("\n");
                                        break;