Index: c/src/lib/libbsp/i386/pc386/ChangeLog
===================================================================
--- c/src/lib/libbsp/i386/pc386/ChangeLog	(revision 891a8254905246f9b645faff8f80109955841570)
+++ c/src/lib/libbsp/i386/pc386/ChangeLog	(revision 1235164645bb0b1810a05a5868a128d16abd1440)
@@ -1,2 +1,6 @@
+2007-09-10	Joel Sherrill <joel.sherrill@OARcorp.com>
+
+	* console/keyboard.c: Replaced tabs with spaces.
+
 2007-09-07	Joel Sherrill <joel.sherrill@oarcorp.com>
 
Index: c/src/lib/libbsp/i386/pc386/console/keyboard.c
===================================================================
--- c/src/lib/libbsp/i386/pc386/console/keyboard.c	(revision 891a8254905246f9b645faff8f80109955841570)
+++ c/src/lib/libbsp/i386/pc386/console/keyboard.c	(revision 1235164645bb0b1810a05a5868a128d16abd1440)
@@ -35,35 +35,35 @@
 int set_bit(int nr, unsigned long * addr)
 {
-	int	mask, retval,level;
-
-	addr += nr >> 5;
-	mask = 1 << (nr & 0x1f);
-	_CPU_ISR_Disable(level)
-	retval = (mask & *addr) != 0;
-	*addr |= mask;
-	_CPU_ISR_Enable (level);
-	return retval;
+  int  mask, retval,level;
+
+  addr += nr >> 5;
+  mask = 1 << (nr & 0x1f);
+  _CPU_ISR_Disable(level)
+  retval = (mask & *addr) != 0;
+  *addr |= mask;
+  _CPU_ISR_Enable (level);
+  return retval;
 }
 
 int clear_bit(int nr, unsigned long * addr)
 {
-	int	mask, retval,level;
-
-	addr += nr >> 5;
-	mask = 1 << (nr & 0x1f);
-	_CPU_ISR_Disable(level)
-	retval = (mask & *addr) != 0;
-	*addr &= ~mask;
-	_CPU_ISR_Enable (level);
-	return retval;
+  int  mask, retval,level;
+
+  addr += nr >> 5;
+  mask = 1 << (nr & 0x1f);
+  _CPU_ISR_Disable(level)
+  retval = (mask & *addr) != 0;
+  *addr &= ~mask;
+  _CPU_ISR_Enable (level);
+  return retval;
 }
 
 int test_bit(int nr, unsigned long * addr)
 {
-	int	mask;
-
-	addr += nr >> 5;
-	mask = 1 << (nr & 0x1f);
-	return ((mask & *addr) != 0);
+  int  mask;
+
+  addr += nr >> 5;
+  mask = 1 << (nr & 0x1f);
+  return ((mask & *addr) != 0);
 }
 
@@ -90,7 +90,7 @@
  */
 int shift_state = 0;
-static int npadch = -1;			/* -1 or number assembled on pad */
+static int npadch = -1;      /* -1 or number assembled on pad */
 static unsigned char diacr = 0;
-static char rep = 0;			/* flag telling character repeat */
+static char rep = 0;      /* flag telling character repeat */
 
 /* default console for RTEMS */
@@ -106,12 +106,12 @@
 
 static k_handfn
-	do_self, do_fn, do_spec, do_pad, do_dead, do_cons, do_cur, do_shift,
-	do_meta, do_ascii, do_lock, do_lowercase, do_slock, do_dead2,
-	do_ignore;
+  do_self, do_fn, do_spec, do_pad, do_dead, do_cons, do_cur, do_shift,
+  do_meta, do_ascii, do_lock, do_lowercase, do_slock, do_dead2,
+  do_ignore;
 
 static k_hand key_handler[16] = {
-	do_self, do_fn, do_spec, do_pad, do_dead, do_cons, do_cur, do_shift,
-	do_meta, do_ascii, do_lock, do_lowercase, do_slock, do_dead2,
-	do_ignore, do_ignore
+  do_self, do_fn, do_spec, do_pad, do_dead, do_cons, do_cur, do_shift,
+  do_meta, do_ascii, do_lock, do_lowercase, do_slock, do_dead2,
+  do_ignore, do_ignore
 };
 
@@ -131,13 +131,13 @@
 
 static void_fn do_null, enter, show_ptregs, send_intr, lastcons, caps_toggle,
-	num, hold, scroll_forw, scroll_back, boot_it, caps_on, compose,
-	SAK, decr_console, incr_console, spawn_console, bare_num;
+  num, hold, scroll_forw, scroll_back, boot_it, caps_on, compose,
+  SAK, decr_console, incr_console, spawn_console, bare_num;
 
 static void_fnp spec_fn_table[] = {
-	do_null,	enter,		show_ptregs,	show_mem,
-	show_state,	send_intr,	lastcons,	caps_toggle,
-	num,		hold,		scroll_forw,	scroll_back,
-	boot_it,	caps_on,	compose,	SAK,
-	decr_console,	incr_console,	spawn_console,	bare_num
+  do_null,  enter,    show_ptregs,  show_mem,
+  show_state,  send_intr,  lastcons,  caps_toggle,
+  num,    hold,    scroll_forw,  scroll_back,
+  boot_it,  caps_on,  compose,  SAK,
+  decr_console,  incr_console,  spawn_console,  bare_num
 };
 
@@ -146,8 +146,8 @@
 /* maximum values each key_handler can handle */
 const int max_vals[] = {
-	255, SIZE(func_table) - 1, SIZE(spec_fn_table) - 1, NR_PAD - 1,
-	NR_DEAD - 1, 255, 3, NR_SHIFT - 1,
-	255, NR_ASCII - 1, NR_LOCK - 1, 255,
-	NR_LOCK - 1, 255
+  255, SIZE(func_table) - 1, SIZE(spec_fn_table) - 1, NR_PAD - 1,
+  NR_DEAD - 1, 255, 3, NR_SHIFT - 1,
+  255, NR_ASCII - 1, NR_LOCK - 1, 255,
+  NR_LOCK - 1, 255
 };
 
@@ -170,12 +170,12 @@
 void to_utf8(ushort c) {
     if (c < 0x80)
-	put_queue(c);			/*  0*******  */
+  put_queue(c);      /*  0*******  */
     else if (c < 0x800) {
-	put_queue(0xc0 | (c >> 6)); 	/*  110***** 10******  */
-	put_queue(0x80 | (c & 0x3f));
+  put_queue(0xc0 | (c >> 6));   /*  110***** 10******  */
+  put_queue(0x80 | (c & 0x3f));
     } else {
-	put_queue(0xe0 | (c >> 12)); 	/*  1110**** 10****** 10******  */
-	put_queue(0x80 | ((c >> 6) & 0x3f));
-	put_queue(0x80 | (c & 0x3f));
+  put_queue(0xe0 | (c >> 12));   /*  1110**** 10****** 10******  */
+  put_queue(0x80 | ((c >> 6) & 0x3f));
+  put_queue(0x80 | (c & 0x3f));
     }
     /* UTF-8 is defined for words of up to 31 bits,
@@ -200,133 +200,133 @@
 void handle_scancode(unsigned char scancode, int down)
 {
-	unsigned char keycode;
-	char up_flag = down ? 0 : 0200;
-	char raw_mode;
-
-	mark_bh(CONSOLE_BH);
+  unsigned char keycode;
+  char up_flag = down ? 0 : 0200;
+  char raw_mode;
+
+  mark_bh(CONSOLE_BH);
 
 #if 0
-	tty = ttytab? ttytab[fg_console]: NULL;
-	if (tty && (!tty->driver_data)) {
-		/*
-		 * We touch the tty structure via the the ttytab array
-		 * without knowing whether or not tty is open, which
-		 * is inherently dangerous.  We currently rely on that
-		 * fact that console_open sets tty->driver_data when
-		 * it opens it, and clears it when it closes it.
-		 */
-		tty = NULL;
-	}
+  tty = ttytab? ttytab[fg_console]: NULL;
+  if (tty && (!tty->driver_data)) {
+    /*
+     * We touch the tty structure via the the ttytab array
+     * without knowing whether or not tty is open, which
+     * is inherently dangerous.  We currently rely on that
+     * fact that console_open sets tty->driver_data when
+     * it opens it, and clears it when it closes it.
+     */
+    tty = NULL;
+  }
 #endif
 
-	kbd = kbd_table + fg_console;
-	if ((raw_mode = (kbd->kbdmode == VC_RAW))) {
-		put_queue(scancode | up_flag);
-		/* we do not return yet, because we want to maintain
-		   the key_down array, so that we have the correct
-		   values when finishing RAW mode or when changing VT's */
-	}
-
-	/*
-	 *  Convert scancode to keycode
-	 */
-	if (!kbd_translate(scancode, &keycode, raw_mode))
-	    return;
-
-	/*
-	 * At this point the variable `keycode' contains the keycode.
-	 * Note: the keycode must not be 0 (++Geert: on m68k 0 is valid).
-	 * We keep track of the up/down status of the key, and
-	 * return the keycode if in MEDIUMRAW mode.
-	 */
-
-	if (up_flag) {
-		rep = 0;
-		if(!test_and_clear_bit(keycode, key_down))
-		    up_flag = kbd_unexpected_up(keycode);
-	} else
-		rep = test_and_set_bit(keycode, key_down);
-
-#ifdef CONFIG_MAGIC_SYSRQ		/* Handle the SysRq Hack */
-	if (keycode == SYSRQ_KEY) {
-		sysrq_pressed = !up_flag;
-		return;
-	} else if (sysrq_pressed) {
-		if (!up_flag && sysrq_enabled)
-			handle_sysrq(kbd_sysrq_xlate[keycode], kbd_pt_regs, kbd, tty);
-		return;
-	}
+  kbd = kbd_table + fg_console;
+  if ((raw_mode = (kbd->kbdmode == VC_RAW))) {
+    put_queue(scancode | up_flag);
+    /* we do not return yet, because we want to maintain
+       the key_down array, so that we have the correct
+       values when finishing RAW mode or when changing VT's */
+  }
+
+  /*
+   *  Convert scancode to keycode
+   */
+  if (!kbd_translate(scancode, &keycode, raw_mode))
+      return;
+
+  /*
+   * At this point the variable `keycode' contains the keycode.
+   * Note: the keycode must not be 0 (++Geert: on m68k 0 is valid).
+   * We keep track of the up/down status of the key, and
+   * return the keycode if in MEDIUMRAW mode.
+   */
+
+  if (up_flag) {
+    rep = 0;
+    if(!test_and_clear_bit(keycode, key_down))
+        up_flag = kbd_unexpected_up(keycode);
+  } else
+    rep = test_and_set_bit(keycode, key_down);
+
+#ifdef CONFIG_MAGIC_SYSRQ    /* Handle the SysRq Hack */
+  if (keycode == SYSRQ_KEY) {
+    sysrq_pressed = !up_flag;
+    return;
+  } else if (sysrq_pressed) {
+    if (!up_flag && sysrq_enabled)
+      handle_sysrq(kbd_sysrq_xlate[keycode], kbd_pt_regs, kbd, tty);
+    return;
+  }
 #endif
 
-	if (kbd->kbdmode == VC_MEDIUMRAW) {
-		/* soon keycodes will require more than one byte */
-		put_queue(keycode + up_flag);
-		raw_mode = 1;	/* Most key classes will be ignored */
-	}
-	/*
-	 * Small change in philosophy: earlier we defined repetition by
-	 *	 rep = keycode == prev_keycode;
-	 *	 prev_keycode = keycode;
-	 * but now by the fact that the depressed key was down already.
-	 * Does this ever make a difference? Yes.
-	 */
-
-	/*
-	 *  Repeat a key only if the input buffers are empty or the
-	 *  characters get echoed locally. This makes key repeat usable
-	 *  with slow applications and under heavy loads.
-	 */
-	if (!rep || vc_kbd_mode(kbd,VC_REPEAT) ) {
-/*
-	||  (vc_kbd_mode(kbd,VC_REPEAT) && tty &&
-	     (L_ECHO(tty) || (tty->driver.chars_in_buffer(tty) == 0)))) {
+  if (kbd->kbdmode == VC_MEDIUMRAW) {
+    /* soon keycodes will require more than one byte */
+    put_queue(keycode + up_flag);
+    raw_mode = 1;  /* Most key classes will be ignored */
+  }
+  /*
+   * Small change in philosophy: earlier we defined repetition by
+   *   rep = keycode == prev_keycode;
+   *   prev_keycode = keycode;
+   * but now by the fact that the depressed key was down already.
+   * Does this ever make a difference? Yes.
+   */
+
+  /*
+   *  Repeat a key only if the input buffers are empty or the
+   *  characters get echoed locally. This makes key repeat usable
+   *  with slow applications and under heavy loads.
+   */
+  if (!rep || vc_kbd_mode(kbd,VC_REPEAT) ) {
+/*
+  ||  (vc_kbd_mode(kbd,VC_REPEAT) && tty &&
+       (L_ECHO(tty) || (tty->driver.chars_in_buffer(tty) == 0)))) {
 */
-		u_short keysym;
-		u_char type;
-
-		/* the XOR below used to be an OR */
-		int shift_final = shift_state ^ kbd->lockstate ^ kbd->slockstate;
-		ushort *key_map = key_maps[shift_final];
-
-		if (key_map != NULL) {
-			keysym = key_map[keycode];
-			type = KTYP(keysym);
-
-			if (type >= 0xf0) {
-			    type -= 0xf0;
-			    if (raw_mode && ! (TYPES_ALLOWED_IN_RAW_MODE & (1 << type)))
-				return;
- 		    if (type == KT_LETTER) {
-				type = KT_LATIN;
-				if (vc_kbd_led(kbd, VC_CAPSLOCK)) {
-				    key_map = key_maps[shift_final ^ (1<<KG_SHIFT)];
-				    if (key_map)
-				      keysym = key_map[keycode];
-				}
-			    }
-
-			    (*key_handler[type])(keysym & 0xff, up_flag);
-
-			    if (type != KT_SLOCK)
-			      kbd->slockstate = 0;
-
-			} else {
-			    /* maybe only if (kbd->kbdmode == VC_UNICODE) ? */
-			    if (!up_flag && !raw_mode)
-			      to_utf8(keysym);
-			}
-		} else {
-			/* maybe beep? */
-			/* we have at least to update shift_state */
-#if 1			/* how? two almost equivalent choices follow */
-			compute_shiftstate();
+    u_short keysym;
+    u_char type;
+
+    /* the XOR below used to be an OR */
+    int shift_final = shift_state ^ kbd->lockstate ^ kbd->slockstate;
+    ushort *key_map = key_maps[shift_final];
+
+    if (key_map != NULL) {
+      keysym = key_map[keycode];
+      type = KTYP(keysym);
+
+      if (type >= 0xf0) {
+          type -= 0xf0;
+          if (raw_mode && ! (TYPES_ALLOWED_IN_RAW_MODE & (1 << type)))
+        return;
+         if (type == KT_LETTER) {
+        type = KT_LATIN;
+        if (vc_kbd_led(kbd, VC_CAPSLOCK)) {
+            key_map = key_maps[shift_final ^ (1<<KG_SHIFT)];
+            if (key_map)
+              keysym = key_map[keycode];
+        }
+          }
+
+          (*key_handler[type])(keysym & 0xff, up_flag);
+
+          if (type != KT_SLOCK)
+            kbd->slockstate = 0;
+
+      } else {
+          /* maybe only if (kbd->kbdmode == VC_UNICODE) ? */
+          if (!up_flag && !raw_mode)
+            to_utf8(keysym);
+      }
+    } else {
+      /* maybe beep? */
+      /* we have at least to update shift_state */
+#if 1      /* how? two almost equivalent choices follow */
+      compute_shiftstate();
 #else
-			keysym = U(plain_map[keycode]);
-			type = KTYP(keysym);
-			if (type == KT_SHIFT)
-			  (*key_handler[type])(keysym & 0xff, up_flag);
+      keysym = U(plain_map[keycode]);
+      type = KTYP(keysym);
+      if (type == KT_SHIFT)
+        (*key_handler[type])(keysym & 0xff, up_flag);
 #endif
-		}
-	}
+    }
+  }
 }
 
@@ -353,29 +353,29 @@
 static void puts_queue(char *cp)
 {
-	while (*cp) {
+  while (*cp) {
      put_queue( *cp );
-		cp++;
-	}
+    cp++;
+  }
 }
 
 static void applkey(int key, char mode)
 {
-	static char buf[] = { 0x1b, 'O', 0x00, 0x00 };
-
-	buf[1] = (mode ? 'O' : '[');
-	buf[2] = key;
-	puts_queue(buf);
+  static char buf[] = { 0x1b, 'O', 0x00, 0x00 };
+
+  buf[1] = (mode ? 'O' : '[');
+  buf[2] = key;
+  puts_queue(buf);
 }
 
 static void enter(void)
 {
-	if (diacr) {
-		put_queue(diacr);
-		diacr = 0;
-	}
-	put_queue(13);
-
-	if (vc_kbd_mode(kbd,VC_CRLF))
-		put_queue(10);
+  if (diacr) {
+    put_queue(diacr);
+    diacr = 0;
+  }
+  put_queue(13);
+
+  if (vc_kbd_mode(kbd,VC_CRLF))
+    put_queue(10);
 
 }
@@ -383,14 +383,14 @@
 static void caps_toggle(void)
 {
-	if (rep)
-		return;
-	chg_vc_kbd_led(kbd, VC_CAPSLOCK);
+  if (rep)
+    return;
+  chg_vc_kbd_led(kbd, VC_CAPSLOCK);
 }
 
 static void caps_on(void)
 {
-	if (rep)
-		return;
-	set_vc_kbd_led(kbd, VC_CAPSLOCK);
+  if (rep)
+    return;
+  set_vc_kbd_led(kbd, VC_CAPSLOCK);
 }
 
@@ -401,6 +401,6 @@
 static void hold(void)
 {
-	if (rep )
-		return;
+  if (rep )
+    return;
    chg_vc_kbd_led(kbd, VC_SCROLLOCK );
 
@@ -410,8 +410,8 @@
 {
 
-	if (vc_kbd_mode(kbd,VC_APPLIC))
-		applkey('P', 1);
-	else
-		bare_num();
+  if (vc_kbd_mode(kbd,VC_APPLIC))
+    applkey('P', 1);
+  else
+    bare_num();
 }
 
@@ -424,6 +424,6 @@
 static void bare_num(void)
 {
-	if (!rep)
-		chg_vc_kbd_led(kbd,VC_NUMLOCK);
+  if (!rep)
+    chg_vc_kbd_led(kbd,VC_NUMLOCK);
 }
 
@@ -460,5 +460,5 @@
 static void compose(void)
 {
-	dead_key_next = 1;
+  dead_key_next = 1;
 }
 
@@ -479,19 +479,19 @@
 static void do_null()
 {
-	compute_shiftstate();
+  compute_shiftstate();
 }
 
 static void do_spec(unsigned char value, char up_flag)
 {
-	if (up_flag)
-		return;
-	if (value >= SIZE(spec_fn_table))
-		return;
-
-	if ((kbd->kbdmode == VC_RAW || kbd->kbdmode == VC_MEDIUMRAW) &&
-	    !(SPECIALS_ALLOWED_IN_RAW_MODE & (1 << value)))
-		return;
-
-	spec_fn_table[value]();
+  if (up_flag)
+    return;
+  if (value >= SIZE(spec_fn_table))
+    return;
+
+  if ((kbd->kbdmode == VC_RAW || kbd->kbdmode == VC_MEDIUMRAW) &&
+      !(SPECIALS_ALLOWED_IN_RAW_MODE & (1 << value)))
+    return;
+
+  spec_fn_table[value]();
 }
 
@@ -502,16 +502,16 @@
 static void do_self(unsigned char value, char up_flag)
 {
-	if (up_flag)
-		return;		/* no action, if this is a key release */
-
-	if (diacr)
-		value = handle_diacr(value);
-
-	if (dead_key_next) {
-		dead_key_next = 0;
-		diacr = value;
-		return;
-	}
-	put_queue(value);
+  if (up_flag)
+    return;    /* no action, if this is a key release */
+
+  if (diacr)
+    value = handle_diacr(value);
+
+  if (dead_key_next) {
+    dead_key_next = 0;
+    diacr = value;
+    return;
+  }
+  put_queue(value);
 }
 
@@ -523,12 +523,12 @@
 #define A_CEDIL  ','
 static unsigned char ret_diacr[NR_DEAD] =
-	{A_GRAVE, A_ACUTE, A_CFLEX, A_TILDE, A_DIAER, A_CEDIL };
+  {A_GRAVE, A_ACUTE, A_CFLEX, A_TILDE, A_DIAER, A_CEDIL };
 
 /* Obsolete - for backwards compatibility only */
 static void do_dead(unsigned char value, char up_flag)
 {
-	value = ret_diacr[value];
+  value = ret_diacr[value];
    printk( " do_dead( %X ) ", value );
-	do_dead2(value,up_flag);
+  do_dead2(value,up_flag);
 }
 
@@ -540,7 +540,7 @@
 static void do_dead2(unsigned char value, char up_flag)
 {
-	if (up_flag)
-		return;
-	diacr = (diacr ? handle_diacr(value) : value);
+  if (up_flag)
+    return;
+  diacr = (diacr ? handle_diacr(value) : value);
 }
 
@@ -554,93 +554,93 @@
 unsigned char handle_diacr(unsigned char ch)
 {
-	int d = diacr;
-	int i;
-
-	diacr = 0;
-
-	for (i = 0; i < accent_table_size; i++) {
-		if (accent_table[i].diacr == d && accent_table[i].base == ch)
-			return accent_table[i].result;
-	}
-	if (ch == ' ' || ch == d)
-		return d;
-
-	put_queue(d);
-	return ch;
+  int d = diacr;
+  int i;
+
+  diacr = 0;
+
+  for (i = 0; i < accent_table_size; i++) {
+    if (accent_table[i].diacr == d && accent_table[i].base == ch)
+      return accent_table[i].result;
+  }
+  if (ch == ' ' || ch == d)
+    return d;
+
+  put_queue(d);
+  return ch;
 }
 
 static void do_cons(unsigned char value, char up_flag)
 {
-	if (up_flag)
-		return;
+  if (up_flag)
+    return;
 }
 
 static void do_fn(unsigned char value, char up_flag)
 {
-	if (up_flag)
-		return;
-
-	if (value < SIZE(func_table)) {
-		if (func_table[value])
-			puts_queue(func_table[value]);
-	} else
-		printk( "do_fn called with value=%d\n", value);
+  if (up_flag)
+    return;
+
+  if (value < SIZE(func_table)) {
+    if (func_table[value])
+      puts_queue(func_table[value]);
+  } else
+    printk( "do_fn called with value=%d\n", value);
 }
 
 static void do_pad(unsigned char value, char up_flag)
 {
-	static const char *pad_chars = "0123456789+-*/\015,.?()";
-	static const char *app_map = "pqrstuvwxylSRQMnnmPQ";
-
-	if (up_flag)
-		return;		/* no action, if this is a key release */
-
-	/* kludge... shift forces cursor/number keys */
-	if (vc_kbd_mode(kbd,VC_APPLIC) && !k_down[KG_SHIFT]) {
-		applkey(app_map[value], 1);
-		return;
-	}
-	if (!vc_kbd_led(kbd,VC_NUMLOCK))
-		switch (value) {
-			case KVAL(K_PCOMMA):
-			case KVAL(K_PDOT):
-				do_fn(KVAL(K_REMOVE), 0);
-				return;
-			case KVAL(K_P0):
-				do_fn(KVAL(K_INSERT), 0);
-				return;
-			case KVAL(K_P1):
-				do_fn(KVAL(K_SELECT), 0);
-				return;
-			case KVAL(K_P2):
-				do_cur(KVAL(K_DOWN), 0);
-				return;
-			case KVAL(K_P3):
-				do_fn(KVAL(K_PGDN), 0);
-				return;
-			case KVAL(K_P4):
-				do_cur(KVAL(K_LEFT), 0);
-				return;
-			case KVAL(K_P6):
-				do_cur(KVAL(K_RIGHT), 0);
-				return;
-			case KVAL(K_P7):
-				do_fn(KVAL(K_FIND), 0);
-				return;
-			case KVAL(K_P8):
-				do_cur(KVAL(K_UP), 0);
-				return;
-			case KVAL(K_P9):
-				do_fn(KVAL(K_PGUP), 0);
-				return;
-			case KVAL(K_P5):
-				applkey('G', vc_kbd_mode(kbd, VC_APPLIC));
-				return;
-		}
-
-	put_queue(pad_chars[value]);
-
-	if (value == KVAL(K_PENTER) && vc_kbd_mode(kbd, VC_CRLF))
-		put_queue(10);
+  static const char *pad_chars = "0123456789+-*/\015,.?()";
+  static const char *app_map = "pqrstuvwxylSRQMnnmPQ";
+
+  if (up_flag)
+    return;    /* no action, if this is a key release */
+
+  /* kludge... shift forces cursor/number keys */
+  if (vc_kbd_mode(kbd,VC_APPLIC) && !k_down[KG_SHIFT]) {
+    applkey(app_map[value], 1);
+    return;
+  }
+  if (!vc_kbd_led(kbd,VC_NUMLOCK))
+    switch (value) {
+      case KVAL(K_PCOMMA):
+      case KVAL(K_PDOT):
+        do_fn(KVAL(K_REMOVE), 0);
+        return;
+      case KVAL(K_P0):
+        do_fn(KVAL(K_INSERT), 0);
+        return;
+      case KVAL(K_P1):
+        do_fn(KVAL(K_SELECT), 0);
+        return;
+      case KVAL(K_P2):
+        do_cur(KVAL(K_DOWN), 0);
+        return;
+      case KVAL(K_P3):
+        do_fn(KVAL(K_PGDN), 0);
+        return;
+      case KVAL(K_P4):
+        do_cur(KVAL(K_LEFT), 0);
+        return;
+      case KVAL(K_P6):
+        do_cur(KVAL(K_RIGHT), 0);
+        return;
+      case KVAL(K_P7):
+        do_fn(KVAL(K_FIND), 0);
+        return;
+      case KVAL(K_P8):
+        do_cur(KVAL(K_UP), 0);
+        return;
+      case KVAL(K_P9):
+        do_fn(KVAL(K_PGUP), 0);
+        return;
+      case KVAL(K_P5):
+        applkey('G', vc_kbd_mode(kbd, VC_APPLIC));
+        return;
+    }
+
+  put_queue(pad_chars[value]);
+
+  if (value == KVAL(K_PENTER) && vc_kbd_mode(kbd, VC_CRLF))
+    put_queue(10);
 
 }
@@ -648,7 +648,7 @@
 static void do_cur(unsigned char value, char up_flag)
 {
-	static const char *cur_chars = "BDCA";
-	if (up_flag)
-		return;
+  static const char *cur_chars = "BDCA";
+  if (up_flag)
+    return;
 
   applkey(cur_chars[value], vc_kbd_mode(kbd,VC_CKMODE));
@@ -657,38 +657,38 @@
 static void do_shift(unsigned char value, char up_flag)
 {
-	int old_state = shift_state;
-
-	if (rep)
-		return;
-
-	/* Mimic typewriter:
-	   a CapsShift key acts like Shift but undoes CapsLock */
-	if (value == KVAL(K_CAPSSHIFT)) {
-		value = KVAL(K_SHIFT);
-		if (!up_flag)
-			clr_vc_kbd_led(kbd, VC_CAPSLOCK);
-	}
-
-	if (up_flag) {
-		/* handle the case that two shift or control
-		   keys are depressed simultaneously */
-		if (k_down[value])
-			k_down[value]--;
-	} else
-		k_down[value]++;
-
-	if (k_down[value])
-		shift_state |= (1 << value);
-	else
-		shift_state &= ~ (1 << value);
-
-	/* kludge */
-	if (up_flag && shift_state != old_state && npadch != -1) {
-		if (kbd->kbdmode == VC_UNICODE)
-		  to_utf8(npadch & 0xffff);
-		else
-	   put_queue(npadch & 0xff);
-		npadch = -1;
-	}
+  int old_state = shift_state;
+
+  if (rep)
+    return;
+
+  /* Mimic typewriter:
+     a CapsShift key acts like Shift but undoes CapsLock */
+  if (value == KVAL(K_CAPSSHIFT)) {
+    value = KVAL(K_SHIFT);
+    if (!up_flag)
+      clr_vc_kbd_led(kbd, VC_CAPSLOCK);
+  }
+
+  if (up_flag) {
+    /* handle the case that two shift or control
+       keys are depressed simultaneously */
+    if (k_down[value])
+      k_down[value]--;
+  } else
+    k_down[value]++;
+
+  if (k_down[value])
+    shift_state |= (1 << value);
+  else
+    shift_state &= ~ (1 << value);
+
+  /* kludge */
+  if (up_flag && shift_state != old_state && npadch != -1) {
+    if (kbd->kbdmode == VC_UNICODE)
+      to_utf8(npadch & 0xffff);
+    else
+     put_queue(npadch & 0xff);
+    npadch = -1;
+  }
 }
 
@@ -698,70 +698,70 @@
 void compute_shiftstate(void)
 {
-	int i, j, k, sym, val;
-
-	shift_state = 0;
-	for(i=0; i < SIZE(k_down); i++)
-	  k_down[i] = 0;
-
-	for(i=0; i < SIZE(key_down); i++)
-	  if(key_down[i]) {	/* skip this word if not a single bit on */
-	    k = i*BITS_PER_LONG;
-	    for(j=0; j<BITS_PER_LONG; j++,k++)
-	      if(test_bit(k, key_down)) {
-		sym = U(plain_map[k]);
-		if(KTYP(sym) == KT_SHIFT) {
-		  val = KVAL(sym);
-		  if (val == KVAL(K_CAPSSHIFT))
-		    val = KVAL(K_SHIFT);
-		  k_down[val]++;
-		  shift_state |= (1<<val);
-		}
-	      }
-	  }
+  int i, j, k, sym, val;
+
+  shift_state = 0;
+  for(i=0; i < SIZE(k_down); i++)
+    k_down[i] = 0;
+
+  for(i=0; i < SIZE(key_down); i++)
+    if(key_down[i]) {  /* skip this word if not a single bit on */
+      k = i*BITS_PER_LONG;
+      for(j=0; j<BITS_PER_LONG; j++,k++)
+        if(test_bit(k, key_down)) {
+    sym = U(plain_map[k]);
+    if(KTYP(sym) == KT_SHIFT) {
+      val = KVAL(sym);
+      if (val == KVAL(K_CAPSSHIFT))
+        val = KVAL(K_SHIFT);
+      k_down[val]++;
+      shift_state |= (1<<val);
+    }
+        }
+    }
 }
 
 static void do_meta(unsigned char value, char up_flag)
 {
-	if (up_flag)
-		return;
-
-	if (vc_kbd_mode(kbd, VC_META)) {
-		put_queue('\033');
-		put_queue(value);
-	} else
-		put_queue(value | 0x80);
+  if (up_flag)
+    return;
+
+  if (vc_kbd_mode(kbd, VC_META)) {
+    put_queue('\033');
+    put_queue(value);
+  } else
+    put_queue(value | 0x80);
 }
 
 static void do_ascii(unsigned char value, char up_flag)
 {
-	int base;
-
-	if (up_flag)
-		return;
-
-	if (value < 10)    /* decimal input of code, while Alt depressed */
-	    base = 10;
-	else {       /* hexadecimal input of code, while AltGr depressed */
-	    value -= 10;
-	    base = 16;
-	}
-
-	if (npadch == -1)
-	  npadch = value;
-	else
-	  npadch = npadch * base + value;
+  int base;
+
+  if (up_flag)
+    return;
+
+  if (value < 10)    /* decimal input of code, while Alt depressed */
+      base = 10;
+  else {       /* hexadecimal input of code, while AltGr depressed */
+      value -= 10;
+      base = 16;
+  }
+
+  if (npadch == -1)
+    npadch = value;
+  else
+    npadch = npadch * base + value;
 }
 
 static void do_lock(unsigned char value, char up_flag)
 {
-	if (up_flag || rep)
-		return;
-	chg_vc_kbd_lock(kbd, value);
+  if (up_flag || rep)
+    return;
+  chg_vc_kbd_lock(kbd, value);
 }
 
 static void do_slock(unsigned char value, char up_flag)
 {
-	if (up_flag || rep)
-		return;
+  if (up_flag || rep)
+    return;
 
   chg_vc_kbd_slock(kbd, value);
@@ -783,9 +783,9 @@
 void setledstate(struct kbd_struct *kbd, unsigned int led) {
     if (!(led & ~7)) {
-	ledioctl = led;
-	 kbd->ledmode = LED_SHOW_IOCTL;
+  ledioctl = led;
+   kbd->ledmode = LED_SHOW_IOCTL;
     } else
     ;
-	 kbd->ledmode = LED_SHOW_FLAGS;
+   kbd->ledmode = LED_SHOW_FLAGS;
     set_leds();
 }
@@ -798,14 +798,14 @@
 
 void register_leds(int console, unsigned int led,
-		   unsigned int *addr, unsigned int mask) {
+       unsigned int *addr, unsigned int mask) {
     struct kbd_struct *kbd = kbd_table + console;
 
    if (led < 3) {
-	ledptrs[led].addr = addr;
-	ledptrs[led].mask = mask;
-	ledptrs[led].valid = 1;
-	kbd->ledmode = LED_SHOW_MEM;
+  ledptrs[led].addr = addr;
+  ledptrs[led].mask = mask;
+  ledptrs[led].valid = 1;
+  kbd->ledmode = LED_SHOW_MEM;
     } else
-	kbd->ledmode = LED_SHOW_FLAGS;
+  kbd->ledmode = LED_SHOW_FLAGS;
 }
 
@@ -820,22 +820,22 @@
     leds = kbd->ledflagstate;
     if (kbd->ledmode == LED_SHOW_MEM) {
-	if (ledptrs[0].valid) {
-	    if (*ledptrs[0].addr & ledptrs[0].mask)
-	      leds |= 1;
-	    else
-	      leds &= ~1;
-	}
-	if (ledptrs[1].valid) {
-	    if (*ledptrs[1].addr & ledptrs[1].mask)
-	      leds |= 2;
-	    else
-	      leds &= ~2;
-	}
-	if (ledptrs[2].valid) {
-	    if (*ledptrs[2].addr & ledptrs[2].mask)
-	      leds |= 4;
-	    else
-	      leds &= ~4;
-	}
+  if (ledptrs[0].valid) {
+      if (*ledptrs[0].addr & ledptrs[0].mask)
+        leds |= 1;
+      else
+        leds &= ~1;
+  }
+  if (ledptrs[1].valid) {
+      if (*ledptrs[1].addr & ledptrs[1].mask)
+        leds |= 2;
+      else
+        leds &= ~2;
+  }
+  if (ledptrs[2].valid) {
+      if (*ledptrs[2].addr & ledptrs[2].mask)
+        leds |= 4;
+      else
+        leds &= ~4;
+  }
     }
    return leds;
@@ -857,9 +857,9 @@
 static void kbd_bh(void)
 {
-	unsigned char leds = getleds();
-	if (leds != ledstate) {
-		ledstate = leds;
-		kbd_leds(leds);
-	}
+  unsigned char leds = getleds();
+  if (leds != ledstate) {
+    ledstate = leds;
+    kbd_leds(leds);
+  }
 }
 
@@ -872,18 +872,18 @@
 {
 
-	int i;
-	struct kbd_struct kbd0;
-	kbd0.ledflagstate = kbd0.default_ledflagstate = KBD_DEFLEDS;
+  int i;
+  struct kbd_struct kbd0;
+  kbd0.ledflagstate = kbd0.default_ledflagstate = KBD_DEFLEDS;
    kbd0.ledmode = LED_SHOW_MEM;
-	kbd0.lockstate = KBD_DEFLOCK;
-	kbd0.slockstate = 0;
-	kbd0.modeflags = KBD_DEFMODE;
-	kbd0.kbdmode = VC_XLATE;
-
-	for (i = 0 ; i < MAX_NR_CONSOLES ; i++)
-		kbd_table[i] = kbd0;
-
-	kbd_init_hw();
-	mark_bh(KEYBOARD_BH);
-	return 0;
-}
+  kbd0.lockstate = KBD_DEFLOCK;
+  kbd0.slockstate = 0;
+  kbd0.modeflags = KBD_DEFMODE;
+  kbd0.kbdmode = VC_XLATE;
+
+  for (i = 0 ; i < MAX_NR_CONSOLES ; i++)
+    kbd_table[i] = kbd0;
+
+  kbd_init_hw();
+  mark_bh(KEYBOARD_BH);
+  return 0;
+}
