diff -Nu linux/kernel/Makefile linux.bork/kernel/Makefile --- linux/kernel/Makefile Fri Dec 29 17:07:24 2000 +++ linux.bork/kernel/Makefile Tue Dec 11 16:39:22 2001 @@ -14,12 +14,30 @@ obj-y = sched.o dma.o fork.o exec_domain.o panic.o printk.o \ module.o exit.o itimer.o info.o time.o softirq.o resource.o \ sysctl.o acct.o capability.o ptrace.o timer.o user.o \ - signal.o sys.o kmod.o context.o + signal.o sys.o kmod.o context.o kchef.o obj-$(CONFIG_UID16) += uid16.o obj-$(CONFIG_MODULES) += ksyms.o obj-$(CONFIG_PM) += pm.o +kernel.o: kchef.o + +kchef.c: kchef.x + ( \ + echo "typedef struct FILE_BAD FILE;"; \ + echo "static FILE * stdout = 0;"; \ + echo "static FILE * stdin = 0;"; \ + echo "static FILE * stderr = 0;"; \ + echo "#define fileno(x) 0"; \ + echo "#include "; \ + echo "#include "; \ + echo "#include "; \ + echo "#include "; \ + echo "#define fileno(x) 0"; \ + echo ""; \ + flex -t kchef.x | \ + grep -v "^#include" ) > kchef.c + ifneq ($(CONFIG_IA64),y) # According to Alan Modra , the -fno-omit-frame-pointer is # needed for x86 only. Why this used to be enabled for all architectures is beyond @@ -28,5 +46,7 @@ # to get a correct value for the wait-channel (WCHAN in ps). --davidm CFLAGS_sched.o := $(PROFILING) -fno-omit-frame-pointer endif + +CFLAGS_kchef.o := -I. include $(TOPDIR)/Rules.make diff -Nu linux/kernel/kchef.x linux.bork/kernel/kchef.x --- linux/kernel/kchef.x Wed Dec 31 19:00:00 1969 +++ linux.bork/kernel/kchef.x Mon Dec 17 16:17:05 2001 @@ -0,0 +1,229 @@ +%{ +/* kchef.x - convert English to Mock Swedish on stdout + * + * The WC definition matches any word character, and the NW definition matches + * any non-word character. Two start conditions are maintained: INW (in word) + * and NIW (not in word). The first rule passes TeX commands without change. + * + * HISTORY + * + * Dec 17, 2001; David T. McWherter: Integration with Linux printk. + * + * Apr 26, 1993; John Hagerman: Added ! and ? to the Bork Bork Bork rule. + * + * Apr 15, 1992; John Hagerman: Created. + */ + +#define NULL 0 +#define EOF (-1) + +#define ECHO bork_write(yytext) + +/** + * Printk does some magic, to insert a message-loglevel into + * the buffer that it gets. It will potentially write + * characters before the beginning of the buffer. This is + * how much space to give to it. + */ +static const int bork_prefix = 3; +/** + * Buffer for holding translated message. + */ +static char bork_buf[2048]; +static int bork_pos = 0; +/** + * Indicate whether buffer-overflow was encountered in translation. + */ +static int bork_overflow = 0; +/** + * Pointer to current data being translated - input stream for Lex. + * Length of input stream for Lex. + */ +static const char * bork_datasource = 0; +static int bork_length = 0; + +#define YY_INPUT(buf,result,max_size) \ + { \ + if ( bork_datasource && bork_length > 0 ) { \ + if ( *bork_datasource ) { \ + buf[0] = *bork_datasource; \ + bork_datasource++; \ + bork_length--; \ + result = 1; \ + } else \ + result = YY_NULL; \ + } else { \ + result = YY_NULL; \ + } \ + } + +static char * realloc ( const char * s, int size ); +static char * malloc ( int size ); +static void free ( const char * s ); +static int fprintf( FILE * f, const char * s, ... ); +static int bork_write( const char * msg ); +static int isatty( int n ); + +#define exit(x) do { } while(0) + +static int i_seen = 0; +%} + +WC [A-Za-z'] +NW [^A-Za-z'] + +%start INW NIW + +%% + +\\[^ \n]+ { char buff[2] = { 0, 0 }; buff[0] = yytext[0]; + bork_write(buff); } + +{NW} { BEGIN NIW; i_seen = 0; ECHO; } +[.!?]$ { BEGIN NIW; i_seen = 0; + { char buff[2] = {0,0}; buff[0] = yytext[0]; + bork_write(buff); } + bork_write(" Bork Bork Bork!"); + } + + +"bork"/{NW} ECHO; +"Bork"/{NW} ECHO; + +"an" { BEGIN INW; bork_write("un"); } +"An" { BEGIN INW; bork_write("Un"); } +"au" { BEGIN INW; bork_write("oo"); } +"Au" { BEGIN INW; bork_write("Oo"); } +"a"/{WC} { BEGIN INW; bork_write("e"); } +"A"/{WC} { BEGIN INW; bork_write("E"); } +"en"/{NW} { BEGIN INW; bork_write("ee"); } +"ew" { BEGIN INW; bork_write("oo"); } +"e"/{NW} { BEGIN INW; bork_write("e-a"); } +"e" { BEGIN INW; bork_write("i"); } +"E" { BEGIN INW; bork_write("I"); } +"f" { BEGIN INW; bork_write("ff"); } +"ir" { BEGIN INW; bork_write("ur"); } +"i" { BEGIN INW; bork_write(i_seen++ ? "i" : "ee"); } +"ow" { BEGIN INW; bork_write("oo"); } +"o" { BEGIN INW; bork_write("oo"); } +"O" { BEGIN INW; bork_write("Oo"); } +"o" { BEGIN INW; bork_write("u"); } +"the" { BEGIN INW; bork_write("zee"); } +"The" { BEGIN INW; bork_write("Zee"); } +"th"/{NW} { BEGIN INW; bork_write("t"); } +"tion" { BEGIN INW; bork_write("shun"); } +"u" { BEGIN INW; bork_write("oo"); } +"U" { BEGIN INW; bork_write("Oo"); } +"v" { BEGIN INW; bork_write("f"); } +"V" { BEGIN INW; bork_write("F"); } +"w" { BEGIN INW; bork_write("v"); } +"W" { BEGIN INW; bork_write("V"); } + +. { BEGIN INW; ECHO; } + +%% + +#undef NULL +#undef EOF + + +static int bork_initialized = 0; +static struct yy_buffer_state bbs; +static char borking_buffer[1024]; + +/** + * Translate + */ +int bork_translate ( const char * msg, int len, const char ** out ) { + if ( !bork_initialized ) { + borking_buffer[sizeof(borking_buffer)-1] = YY_END_OF_BUFFER_CHAR; + borking_buffer[sizeof(borking_buffer)-2] = YY_END_OF_BUFFER_CHAR; + bbs.yy_input_file = 0; + bbs.yy_ch_buf = borking_buffer; + bbs.yy_buf_pos = borking_buffer; + bbs.yy_buf_size = sizeof(borking_buffer)-2; + bbs.yy_n_chars = sizeof(borking_buffer)-2; + bbs.yy_is_our_buffer = 0; + bbs.yy_is_interactive = 0; + bbs.yy_at_bol = 1; + bbs.yy_fill_buffer = 1; + bbs.yy_buffer_status = YY_BUFFER_NEW; + yy_switch_to_buffer( &bbs ); + bork_initialized = 1; + } + + /** + * Do the translation + */ + + bork_overflow = 0; + bork_pos = bork_prefix; + + bork_datasource = msg; + bork_length = len; + + yylex(); + + /** + * Check the translation for success. + */ + if ( !bork_overflow ) { + if ( out ) *out = bork_buf + bork_prefix; + return bork_pos - bork_prefix; + } else { + if ( out ) *out = msg; + return len; + } +} + +static int bork_write( const char * msg ) { +#if 0 + extern struct console *console_drivers; + struct console * c = console_drivers; + while ( c ) { + if ((c->flags & CON_ENABLED) && c->write) + c->write( c, msg, strlen(msg) ); + c = c->next; + } +#else + /** + * Copy the data into the bork_buf. + */ + const char * s; + for ( s = msg; *s && bork_pos < sizeof(bork_buf)-1; ++s, ++bork_pos ) + bork_buf[ bork_pos ] = *s; + if ( *s ) { + bork_overflow = 1; + bork_buf[ sizeof(bork_buf)-1 ] = 0; + } else { + bork_buf[ bork_pos ] = 0; + } +#endif + return 0; +} + +static char * realloc ( const char * s, int size ) { + panic("bork_realloc: Yuoo reelly dun't vunt tu du thees. Bork Bork Bork!"); + return 0; +} +static int fprintf( FILE * f, const char * s, ... ) { + return 0; +} + + +static void free ( const char * s ) { + panic("bork_free: Yuoo reelly dun't vunt tu du thees. Bork Bork Bork!"); +} +static char * malloc ( int size ) { + panic("bork_malloc: Yuoo reelly dun't vunt tu du thees. Bork Bork Bork!"); + return 0; +} + +static int isatty( int n ) { + return 0; +} + +int yywrap() { + return 1; +} + diff -Nu linux/kernel/printk.c linux.bork/kernel/printk.c --- linux/kernel/printk.c Fri Jun 29 22:30:36 2001 +++ linux.bork/kernel/printk.c Mon Dec 17 15:10:05 2001 @@ -260,12 +260,27 @@ static signed char msg_level = -1; long flags; +/** DTM */ + char * tbuf = 0; + int bork_translate ( const char * msg, int len, const char ** out ); +/** DTM */ + spin_lock_irqsave(&console_lock, flags); va_start(args, fmt); i = vsprintf(buf + 3, fmt, args); /* hopefully i < sizeof(buf)-4 */ buf_end = buf + 3 + i; va_end(args); + +#if 1 +/* DTM */ + + i = bork_translate( buf + 3, i, &tbuf ); + buf_end = tbuf + i; + + for (p = tbuf; p < buf_end; p++) { +#else for (p = buf + 3; p < buf_end; p++) { +#endif msg = p; if (msg_level < 0) { if (