--- Net2/ddb/db_output.c 2018/04/24 18:06:57 1.1 +++ Net2/ddb/db_output.c 2018/04/24 18:15:48 1.1.1.3 @@ -22,13 +22,29 @@ * * any improvements or extensions that they make and grant Carnegie the * rights to redistribute these changes. + * + * PATCHES MAGIC LEVEL PATCH THAT GOT US HERE + * -------------------- ----- ---------------------- + * CURRENT PATCH LEVEL: 4 00083 + * -------------------- ----- ---------------------- + * + * 14 Mar 93 Chris G. Demetriou Fixed so that tab is not output, + * use spaces instead. */ /* + * db_output.c,v 1.3 1993/05/20 03:39:21 cgd Exp + * * HISTORY - * $Log: db_output.c,v $ - * Revision 1.1 2018/04/24 18:06:57 root - * Initial revision + * db_output.c,v + * Revision 1.3 1993/05/20 03:39:21 cgd + * add explicit rcs id + * + * Revision 1.2 1993/03/21 18:08:08 cgd + * after 0.2.2 "stable" patches applied * + * Revision 1.1.1.1 93/03/21 09:46:26 cgd + * initial import of 386bsd-0.1 sources + * * Revision 1.1 1992/03/25 21:45:18 pace * Initial revision * @@ -69,12 +85,24 @@ * don't print trailing spaces. This avoids most * of the wraparounds. */ + +#ifndef DB_MAX_LINE +#define DB_MAX_LINE 24 /* maximum line */ +#define DB_MAX_WIDTH 80 /* maximum width */ +#endif DB_MAX_LINE + +#define DB_MIN_MAX_WIDTH 20 /* minimum max width */ +#define DB_MIN_MAX_LINE 3 /* minimum max line */ +#define CTRL(c) ((c) & 0xff) + int db_output_position = 0; /* output column */ +int db_output_line = 0; /* output line number */ int db_last_non_space = 0; /* last non-space character */ int db_tab_stop_width = 8; /* how wide are tab stops? */ #define NEXT_TAB(i) \ ((((i) + db_tab_stop_width) / db_tab_stop_width) * db_tab_stop_width) -int db_max_width = 80; /* output line width */ +int db_max_line = DB_MAX_LINE; /* output max lines */ +int db_max_width = DB_MAX_WIDTH; /* output line width */ extern void db_check_interrupt(); @@ -90,8 +118,10 @@ db_force_whitespace() while (last_print < db_output_position) { next_tab = NEXT_TAB(last_print); if (next_tab <= db_output_position) { - cnputc('\t'); - last_print = next_tab; + while (last_print < next_tab) { /* DON'T send a tab!!! */ + cnputc(' '); + last_print++; + } } else { cnputc(' '); @@ -101,12 +131,44 @@ db_force_whitespace() db_last_non_space = db_output_position; } +static void +db_more() +{ + register char *p; + int quit_output = 0; + + for (p = "--db_more--"; *p; p++) + cnputc(*p); + switch(cngetc()) { + case ' ': + db_output_line = 0; + break; + case 'q': + case CTRL('c'): + db_output_line = 0; + quit_output = 1; + break; + default: + db_output_line--; + break; + } + p = "\b\b\b\b\b\b\b\b\b\b\b \b\b\b\b\b\b\b\b\b\b\b"; + while (*p) + cnputc(*p++); + if (quit_output) { + db_error(0); + /* NOTREACHED */ + } +} + /* * Output character. Buffer whitespace. */ db_putchar(c) int c; /* character to output */ { + if (db_max_line >= DB_MIN_MAX_LINE && db_output_line >= db_max_line-1) + db_more(); if (c > ' ' && c <= '~') { /* * Printing character. @@ -116,6 +178,14 @@ db_putchar(c) db_force_whitespace(); cnputc(c); db_output_position++; + if (db_max_width >= DB_MIN_MAX_WIDTH + && db_output_position >= db_max_width-1) { + /* auto new line */ + cnputc('\n'); + db_output_position = 0; + db_last_non_space = 0; + db_output_line++; + } db_last_non_space = db_output_position; } else if (c == '\n') { @@ -123,6 +193,7 @@ db_putchar(c) cnputc(c); db_output_position = 0; db_last_non_space = 0; + db_output_line++; db_check_interrupt(); } else if (c == '\t') { @@ -150,16 +221,6 @@ db_print_position() } /* - * End line if too long. - */ -void -db_end_line() -{ - if (db_output_position >= db_max_width) - db_printf("\n"); -} - -/* * Printing */ extern int db_radix; @@ -185,6 +246,16 @@ kdbprintf(char *fmt, ...) } /* + * End line if too long. + */ +void +db_end_line() +{ + if (db_output_position >= db_max_width) + db_printf("\n"); +} + +/* * Put a number (base <= 16) in a buffer in reverse order; return an * optional length and a pointer to the NULL terminated (preceded?) * buffer.