This mail list server will cut off the code line. 8...(

Keith Owens kaos at sgi.com
Wed Dec 4 19:23:05 PST 2002


On Thu, 5 Dec 2002 09:33:42 +0800 , 
"Zhang, Sonic" <sonic.zhang at intel.com> wrote:
>	Finally, I find why my code lines are always cut off.
>
>	Some of the code lines are longer than 80 characters. It seems this
>mail list server will cut off any line which is longer than 80. It is not
>the fault of my mailer.

I doubt it is this mailing list.  I will copy in your patch with its
long lines and see what happens.

==== test start ====
--- linux-kdb/kdb/kdbmain.c	Wed Dec  4 15:53:39 2002
+++ linux-kdb-cmdline/kdb/kdbmain.c	Wed Dec  4 10:28:36 2002
@@ -691,7 +691,7 @@
  */
 #define KDB_CMD_HISTORY_COUNT	32
 #define CMD_BUFLEN		200	/* kdb_printf: max printline size == 256 */
-static unsigned int cmd_head, cmd_tail;
+static unsigned int cmd_head=0, cmd_tail=0;
 static unsigned int cmdptr;
 static char cmd_hist[KDB_CMD_HISTORY_COUNT][CMD_BUFLEN];
 
@@ -887,22 +887,22 @@
 #define CTRL_N	14
 
 	/* initial situation */
-	if (cmd_head == cmd_tail) return 1;
+	if (cmd_head == cmd_tail) return 0;
 
 	switch(*cmd) {
-		case '\n':
 		case CTRL_P:
 			if (cmdptr != cmd_tail)
 				cmdptr = (cmdptr-1) % KDB_CMD_HISTORY_COUNT;
-			strcpy(cmd, cmd_hist[cmdptr]);
-			return 0;	
+			strncpy(cmd_hist[cmd_head], cmd_hist[cmdptr], CMD_BUFLEN);
+			return 1;
 		case CTRL_N:
+			if (cmdptr == cmd_head) return 0;
 			if (cmdptr != (cmd_head-1))
 				cmdptr = (cmdptr+1) % KDB_CMD_HISTORY_COUNT;
-			strcpy(cmd, cmd_hist[cmdptr]);
-			return 0;
+			strncpy(cmd_hist[cmd_head], cmd_hist[cmdptr], CMD_BUFLEN);
+			return 1;
 	}
-	return 1;
+	return 0;
 }
 
 
@@ -998,7 +998,7 @@
 			return KDB_CMD_GO;
 		}
 		break;
-	case KDB_REASON_CALL:	
+	case KDB_REASON_CALL:
 		if (!regs)
 			kdb_printf("kdb() called with no registers, restricted function\n");
 		break;
@@ -1059,6 +1059,10 @@
 			KDB_STATE_SET(LONGJMP);
 #endif	/* KDB_HAVE_LONGJMP */
 
+
+		cmdbuf = cmd_hist[cmd_head];
+		*cmdbuf = '\0';
+
 do_full_getstr:
 #if defined(CONFIG_SMP)
 		kdb_printf(kdbgetenv("PROMPT"), smp_processor_id());
@@ -1066,15 +1070,15 @@
 		kdb_printf(kdbgetenv("PROMPT"));
 #endif
 
-		cmdbuf = cmd_hist[cmd_head];
-		*cmdbuf = '\0';
 		/*
 		 * Fetch command from keyboard
 		 */
 		cmdbuf = kdb_getstr(cmdbuf, CMD_BUFLEN, defcmd_in_progress ? "[defcmd]" : "");
-		if (*cmdbuf < 32 && *cmdbuf != '\n')
-			if (handle_ctrl_cmd(cmdbuf))
-				goto do_full_getstr;
+		if (*cmdbuf < 32 && *cmdbuf != '\n') {
+			if (!handle_ctrl_cmd(cmdbuf)) *cmdbuf = '\0';
+			cmdbuf = cmd_hist[cmd_head];
+			goto do_full_getstr;
+		}

 		if (*cmdbuf != '\n') {
 			cmd_head = (cmd_head+1) % KDB_CMD_HISTORY_COUNT;


--- linux-kdb/kdb/kdb_io.c	Wed Dec  4 16:09:02 2002
+++ linux-kdb-cmdline/kdb/kdb_io.c	Wed Dec  4 16:18:42 2002
@@ -206,7 +206,7 @@

 	if (kdb_nextline == linecount) {
 #ifdef KDB_HAVE_LONGJMP
-		char buf1[16];
+		char buf1[16]="";
 #if defined(CONFIG_SMP)
 		char buf2[32];
 #endif
@@ -246,7 +246,7 @@
 		if (logging)
 			printk("%s", moreprompt);

-		kdb_read(buf1, sizeof(buf1));
+		kdb_read(buf1, 2); // '2' indicates to return immediately after getting one key.
 		kdb_nextline = 1;	/* Really set output line 1 */

 		if ((buf1[0] == 'q') || (buf1[0] == 'Q'))
==== test end ====




More information about the kdb mailing list