Index: ChangeLog
===================================================================
--- ChangeLog	(revision 1683)
+++ ChangeLog	(working copy)
@@ -8,6 +8,51 @@
 gcalctool change history.
 =========================
 
+2007-09-17 Rich Burridge <rich.burridge@sun.com>
+
+    * help/C/gcalctool.xml:
+      gcalctool/calctool.c:
+      gcalctool/calctool.h:
+      gcalctool/lr_tokeniser.l:
+      gcalctool/gcalctool.1:
+      gcalctool/gtk.c:
+      gcalctool/ce_parser.y:
+      gcalctool/ce_tokeniser.l
+      With help from Sami Pietila <sampie@ariana-dsl.utu.fi>
+      Fixed bug #469245 – Hexadecimal input is not intuitive and
+      bug #455889 – Copy/paste of lower case hex letter does not work.
+      The hexadecimal digits have been changed back to their pre Sept
+      2003 (bug #118826) values of "a" - "f".
+
+      The following functions have also had their keyboard shortcuts
+      reverted back to their pre Sept 2003 upper-case values:
+
+      [A] - Set accuracy
+      [C] - Change sign
+      [D] - Double-declining depreciation
+      [E] - Enter an exponential number
+      [F] - User-defined functions
+
+      With copy/paste operations, where the user is pasting a string into
+      gcalctool, the copy buffer is now iterated over. If an "A", "B", "C",
+      "D" or "F" character is encountered, it will be converted to its
+      lowercase equivalent. If an "E" is found,  and the next character is a
+      "-" or a "+", then it remains as an upper case "E" (it's assumed to be
+      a possible exponential number), otherwise its converted to a lower
+      case "e".
+
+      Displaying of hex digits in the gcalctool display will still be
+      in uppercase. Displaying of the "e" in an exponential number will
+      still be in lower-case.
+
+      In both left-to-right precedence and arithmetic precedence modes, if
+      the user enters a numeric digit that is incorrect for the current
+      numeric base, this shouldn't be allowed and should not be entered
+      in the display.
+
+      The gcalctool documentation (and tooltips) have been updated to
+      reflect these changes.
+
 2007-09-24 Rich Burridge <rich.burridge@sun.com>
 
     * From Christian Persch <chpe@gnome.org>
Index: help/C/gcalctool.xml
===================================================================
--- help/C/gcalctool.xml	(revision 1682)
+++ help/C/gcalctool.xml	(working copy)
@@ -2170,71 +2170,71 @@
                            </row>
                            <row valign="top">
                              <entry><para><keycap>A</keycap> </para></entry>
-                             <entry><para><guibutton>A</guibutton> </para></entry>
-                             <entry><para>Hexadecimal numerals</para> </entry>
-                             <entry><para><xref linkend="gcalctool-TBL-misc-calc"/></para> </entry>
-                           </row>
-                           <row valign="top">
-                             <entry><para><keycap>a</keycap> </para></entry>
                              <entry><para><guibutton>Acc</guibutton> </para></entry>
                              <entry><para>Accuracy</para> </entry>
                              <entry><para><xref linkend="gcalctool-set-acc"/></para> </entry>
                            </row>
                            <row valign="top">
-                             <entry><para><keycap>B</keycap> </para></entry>
-                             <entry><para><guibutton>B</guibutton> </para></entry>
+                             <entry><para><keycap>a</keycap> </para></entry>
+                             <entry><para><guibutton>A</guibutton> </para></entry>
                              <entry><para>Hexadecimal numerals</para> </entry>
                              <entry><para><xref linkend="gcalctool-TBL-misc-calc"/></para> </entry>
                            </row>
                            <row valign="top">
-                             <entry><para><keycap>C</keycap> </para></entry>
-                             <entry><para><guibutton>C</guibutton> </para></entry>
+                             <entry><para><keycap>b</keycap> </para></entry>
+                             <entry><para><guibutton>B</guibutton> </para></entry>
                              <entry><para>Hexadecimal numerals</para> </entry>
                              <entry><para><xref linkend="gcalctool-TBL-misc-calc"/></para> </entry>
                            </row>
                            <row valign="top">
-                             <entry><para><keycap>c</keycap></para></entry>
+                             <entry><para><keycap>C</keycap></para></entry>
                              <entry><para><guibutton>+/-</guibutton></para></entry>
                              <entry><para>Change the arithmetic sign</para> </entry>
                              <entry><para><xref linkend="gcalctool-TBL-adv-calc"/></para> </entry>
                            </row>
                            <row valign="top">
-                             <entry><para><keycap>D</keycap> </para></entry>
-                             <entry><para><guibutton>D</guibutton> </para></entry>
+                             <entry><para><keycap>c</keycap> </para></entry>
+                             <entry><para><guibutton>C</guibutton> </para></entry>
                              <entry><para>Hexadecimal numerals</para> </entry>
                              <entry><para><xref linkend="gcalctool-TBL-misc-calc"/></para> </entry>
                            </row>
                            <row valign="top">
-                             <entry><para><keycap>d</keycap></para></entry>
+                             <entry><para><keycap>D</keycap></para></entry>
                              <entry><para><guibutton>Ddb</guibutton></para></entry>
                              <entry><para>Double-declining depreciation</para> </entry>
                              <entry><para><xref linkend="gcalctool-TBL-financial-calc"/></para> </entry>
                            </row>
                            <row valign="top">
-                             <entry><para><keycap>E</keycap> </para></entry>
-                             <entry><para><guibutton>E</guibutton> </para></entry>
+                             <entry><para><keycap>d</keycap> </para></entry>
+                             <entry><para><guibutton>D</guibutton> </para></entry>
                              <entry><para>Hexadecimal numerals</para> </entry>
                              <entry><para><xref linkend="gcalctool-TBL-misc-calc"/></para> </entry>
                            </row>
                            <row valign="top">
-                             <entry><para><keycap>e</keycap> </para></entry>
+                             <entry><para><keycap>E</keycap> </para></entry>
                              <entry><para><guibutton>Exp</guibutton> </para></entry>
                              <entry><para>Exponential</para> </entry>
                              <entry><para><xref linkend="gcalctool-enter-exp"/></para> </entry>
                            </row>
                            <row valign="top">
-                             <entry><para><keycap>F</keycap> </para></entry>
-                             <entry><para><guibutton>F</guibutton> </para></entry>
+                             <entry><para><keycap>e</keycap> </para></entry>
+                             <entry><para><guibutton>E</guibutton> </para></entry>
                              <entry><para>Hexadecimal numerals</para> </entry>
                              <entry><para><xref linkend="gcalctool-TBL-misc-calc"/></para> </entry>
                            </row>
                            <row valign="top">
-                             <entry><para><keycap>f</keycap> </para></entry>
+                             <entry><para><keycap>F</keycap> </para></entry>
                              <entry><para><guibutton>Fun</guibutton> </para></entry>
                              <entry><para>Function</para> </entry>
                              <entry><para><xref linkend="gcalctool-edit-func"/></para> </entry>
                            </row>
                            <row valign="top">
+                             <entry><para><keycap>f</keycap> </para></entry>
+                             <entry><para><guibutton>F</guibutton> </para></entry>
+                             <entry><para>Hexadecimal numerals</para> </entry>
+                             <entry><para><xref linkend="gcalctool-TBL-misc-calc"/></para> </entry>
+                           </row>
+                           <row valign="top">
                              <entry><para><keycap>G</keycap></para></entry>
                              <entry><para><guibutton>Log</guibutton></para></entry>
                              <entry><para>Common logarithm</para> </entry>
Index: gcalctool/calctool.c
===================================================================
--- gcalctool/calctool.c	(revision 1682)
+++ gcalctool/calctool.c	(working copy)
@@ -141,7 +141,7 @@
     M_NONE,
     do_number,
     NULL,
-    number
+    number | oct_set
 },
 {
     N_("8"),
@@ -242,7 +242,7 @@
     M_NONE,
     do_number,
     NULL,
-    number
+    number | oct_set
 },
 {
     N_("5"),
@@ -254,7 +254,7 @@
     M_NONE,
     do_number,
     NULL,
-    number
+    number | oct_set
 },
 {
     N_("6"),
@@ -266,7 +266,7 @@
     M_NONE,
     do_number,
     NULL,
-    number
+    number | oct_set
 },
 {
     /* Note to translators: this is a multiplication sign (*) */
@@ -296,11 +296,11 @@
 {
     /* Note to translators: this is a plus-minus sign (+/-) */
     N_("\302\261"),
-    N_("Change sign [c]"),
+    N_("Change sign [C]"),
     NULL,
-    { 0,     0 },
-    { GDK_c, 0 },
-    'c',
+    { GDK_SHIFT_MASK, 0 },
+    { GDK_C,          0 },
+    'C',
     M_NONE,
     do_immed, 
     N_("Chs"),
@@ -328,7 +328,7 @@
     M_STO,
     do_pending,
     NULL,
-    none
+    pending
 },
 
 /* Row 3. */
@@ -342,7 +342,7 @@
     M_NONE,
     do_number,
     NULL,
-    number
+    number | bin_set | oct_set
 },
 {
     N_("2"),
@@ -354,7 +354,7 @@
     M_NONE,
     do_number,
     NULL,
-    number
+    number | oct_set
 },    
 {     
     N_("3"),
@@ -366,7 +366,7 @@
     M_NONE,
     do_number,
     NULL,
-    number
+    number | oct_set
 },
 {
     /* Note to translators: this is a minus sign (-) */
@@ -428,7 +428,7 @@
     M_RCL,
     do_pending,
     NULL,
-    none
+    pending
 },
 
 /* Row 4. */
@@ -442,7 +442,7 @@
     M_NONE,
     do_number,
     NULL,
-    number
+    number | bin_set | oct_set
 },
 {    
     N_("."),
@@ -527,7 +527,7 @@
     M_EXCH,
     do_pending,
     NULL,
-    none
+    pending
 },
 };
 
@@ -559,11 +559,11 @@
 },
 {
     N_("Ddb"),
-    N_("Double-declining depreciation [d]"),
+    N_("Double-declining depreciation [D]"),
     NULL,
-    { 0,     0 },
-    { GDK_d, 0 },
-    'd',
+    { GDK_SHIFT_MASK, 0 },
+    { GDK_D,          0 },
+    'D',
     M_NONE,
     do_business,
     NULL,
@@ -765,7 +765,7 @@
     M_LSHF,
     do_pending,
     NULL,
-    none
+    pending
 },
 {
     N_(">"),
@@ -777,7 +777,7 @@
     M_RSHF,   
     do_pending,
     NULL,
-    none
+    pending
 },            
 {             
     N_("&amp;16"),
@@ -841,15 +841,15 @@
 },
 {
     N_("Acc"),
-    N_("Set accuracy from 0 to 9 numeric places [a]"),
+    N_("Set accuracy from 0 to 9 numeric places [A]"),
     N_("Accuracy"),
-    { 0,     0 },
-    { GDK_a, 0 },
-    'a',
+    { GDK_SHIFT_MASK, 0 },
+    { GDK_A,          0 },
+    'A',
     M_ACC,
     do_pending,
     NULL,
-    none
+    pending
 },
 
 /* Row 2. */
@@ -863,27 +863,27 @@
     M_CON,            
     do_pending,
     NULL,
-    none
+    pending
 },
 {
     N_("Fun"),
-    N_("User-defined functions [f]"),
+    N_("User-defined functions [F]"),
     NULL,
-    { 0,     0 },
-    { GDK_f, 0 },
-    'f',
+    { GDK_SHIFT_MASK, 0 },
+    { GDK_F,          0 },
+    'F',
     M_FUN,
     do_pending,
     NULL,
-    none
+    pending
 },
 {
     N_("Exp"),
-    N_("Enter an exponential number [e]"),
+    N_("Enter an exponential number [E]"),
     N_("Exponential"),
-    { 0,     0 },
-    { GDK_e, 0 },
-    'e',
+    { GDK_SHIFT_MASK, 0 },
+    { GDK_E,          0 },
+    'E',
     M_NONE,
     do_expno,
     N_("e"),
@@ -953,39 +953,39 @@
 /* Row 3. */
 {
     N_("D"),
-    N_("Hexadecimal digit D"),
+    N_("Hexadecimal digit D [d]"),
     NULL,
-    { GDK_SHIFT_MASK, 0 },
-    { GDK_D,          0 },
-    'D',
+    { 0,     0 },
+    { GDK_d, 0 },
+    'd',
     M_NONE,
     do_number,
     NULL,
-    number
+    number | hex
 },
 {
     N_("E"),
-    N_("Hexadecimal digit E"),
+    N_("Hexadecimal digit E [e]"),
     NULL,
-    { GDK_SHIFT_MASK, 0 },
-    { GDK_E,          0 },
-    'E',
+    { 0,     0 },
+    { GDK_e, 0 },
+    'e',
     M_NONE,
     do_number,
     NULL,
-    number
+    number | hex
 },
 {
     N_("F"),
-    N_("Hexadecimal digit F"),
+    N_("Hexadecimal digit F [f]"),
     NULL,
-    { GDK_SHIFT_MASK, 0 },
-    { GDK_F,          0 },
-    'F',
+    { 0,     0 },
+    { GDK_f, 0 },
+    'f',
     M_NONE,
     do_number,
     NULL,
-    number
+    number | hex
 },
 {
     N_("Cos"),
@@ -1051,39 +1051,39 @@
 /* Row 4. */
 {
     N_("A"),
-    N_("Hexadecimal digit A"),
+    N_("Hexadecimal digit A [a]"),
     NULL,
-    { GDK_SHIFT_MASK, 0 },
-    { GDK_A,          0 },
-    'A',
+    { 0,     0 },
+    { GDK_a, 0 },
+    'a',
     M_NONE,
     do_number,
     NULL,
-    number
+    number | hex
 },
 {
     N_("B"),
-    N_("Hexadecimal digit B"),
+    N_("Hexadecimal digit B [b]"),
     NULL,
-    { GDK_SHIFT_MASK, 0 },
-    { GDK_B,          0 },
-    'B',
+    { 0,     0 },
+    { GDK_b, 0 },
+    'b',
     M_NONE,
     do_number,
     NULL,
-    number
+    number | hex
 },    
 {     
     N_("C"),
-    N_("Hexadecimal digit C"),
+    N_("Hexadecimal digit C [c]"),
     NULL,
-    { GDK_SHIFT_MASK, 0 },
-    { GDK_C,          0 },
-    'C',
+    { 0,     0 },
+    { GDK_c, 0 },
+    'c',
     M_NONE,
     do_number,
     NULL,
-    number
+    number | hex
 },
 {
     N_("Or"),
Index: gcalctool/calctool.h
===================================================================
--- gcalctool/calctool.h	(revision 1682)
+++ gcalctool/calctool.h	(working copy)
@@ -254,7 +254,11 @@
     expnum       = (1 << 13),  /* Exponential number */
     postfixop    = (1 << 14),  /* Unary postfix operation */
     prefixop     = (1 << 15),  /* Unary prefix operation */
-    dpoint       = (1 << 16)   /* Decimal point */
+    dpoint       = (1 << 16),  /* Decimal point */
+    pending      = (1 << 17),  /* Is a pending button */
+    hex          = (1 << 18),  /* Is a hex button A..F */
+    oct_set      = (1 << 19),  /* Is a oct button 0..7 */
+    bin_set      = (1 << 20)   /* Is a bin button 0..1 */
 };
 
 enum shiftd {
Index: gcalctool/lr_tokeniser.l
===================================================================
--- gcalctool/lr_tokeniser.l	(revision 1682)
+++ gcalctool/lr_tokeniser.l	(working copy)
@@ -41,6 +41,7 @@
 OCT     [0-7]
 NUMBER  [DIGIT}*{DECIMAL}{DIGIT}+|{DIGIT}
 SEPARATOR "e+"|"e-"
+HEXS [0-9]|[A-F]|" "
 
 %%
 
@@ -87,19 +88,19 @@
 "Sto" {return tSTO;}
 "Clr" {return tCLR;}
 
-{DIGIT}+ {
+{HEXS}+ {
   if (strlen(yytext) > 40) parser_state.error = EINVAL;
   MPstr_to_num(yytext, v->base, lrlval.int_t);
   return tINUMBER;
 }
 
-{DIGIT}*{DECIMAL}{DIGIT}+ {
+{HEXS}*{DECIMAL}{HEXS}+ {
   if (strlen(yytext) > 40) parser_state.error = EINVAL;
   MPstr_to_num(yytext, v->base, lrlval.int_t);
   return tDNUMBER;
 }
 
-{DIGIT}+{SEPARATOR}{DIGIT}+ {
+{HEXS}+{SEPARATOR}{HEXS}+ {
   MPstr_to_num(yytext, v->base, lrlval.int_t);
   return tDNUMBER;
 }
Index: gcalctool/ce_tokeniser.l
===================================================================
--- gcalctool/ce_tokeniser.l	(revision 1682)
+++ gcalctool/ce_tokeniser.l	(working copy)
@@ -28,19 +28,24 @@
 #include <sys/types.h>
 #include "calctool.h"
 #include "extern.h"
+#include "mpmath.h"
 #include "ce_parser.h"
 #include "ce_parser.tab.h"
 %}
 
-DIGIT	[0-9]
 DECIMAL	"."|","
 SIGN	"+"|"-" 
 CHARACTER [a-z]|[A-Z]
-HEX     [0-9]|[A-F]
-BIN     "0"|"1"
+BIN     [0-1]
 OCT     [0-7]
-NUMBER  [DIGIT}*{DECIMAL}{DIGIT}+|{DIGIT}
-SEPARATOR "e+"|"e-"
+DEC	[0-9]
+HEX     [0-9]|[A-F]|[a-f]
+EXP     "e+"|"e-"|"E+"|"E-"
+NEP     "e"
+HEX_NUM {HEX}+|{HEX}*{DECIMAL}{HEX}+
+DEC_NUM{DEC}+|{DEC}*{DECIMAL}{DEC}+
+OCT_NUM{OCT}+|{OCT}*{DECIMAL}{OCT}+
+BIN_NUM{BIN}+|{BIN}*{DECIMAL}{BIN}+
 
 %%
 
@@ -89,27 +94,49 @@
 "Xnor" {return tXNOR;}
 "Xor" {return tXOR;}
 
-"R"{DIGIT}+ {
+"R"{DEC}+ {
 celval.integer = atoi(yytext+1);  
 return tREG;
 }
 
 
-{DIGIT}+|{HEX}+ {
+{DEC_NUM}{EXP}{DEC_NUM} {
+if (v->base == HEX) REJECT;
+printf("EXP: Found: %s\n", yytext);
 if (strlen(yytext) > 40) parser_state.error = -PARSER_ERR_TOO_LONG_NUMBER;
-check_numbase(yytext);
 MPstr_to_num(yytext, v->base, celval.int_t);
-return tINUMBER;
+return tNUMBER;
 }
 
-{HEX}*{DECIMAL}{HEX}+ {
+{BIN_NUM} {
+if (v->base != BIN) REJECT;
 if (strlen(yytext) > 40) parser_state.error = -PARSER_ERR_TOO_LONG_NUMBER;
-check_numbase(yytext);
 MPstr_to_num(yytext, v->base, celval.int_t);
-return tDNUMBER;
+return tNUMBER;
 }
 
+{OCT_NUM} {
+if (v->base != OCT) REJECT;
+if (strlen(yytext) > 40) parser_state.error = -PARSER_ERR_TOO_LONG_NUMBER;
+MPstr_to_num(yytext, v->base, celval.int_t);
+return tNUMBER;
+}
 
+{DEC_NUM} {
+if (v->base != DEC) REJECT;
+if (strlen(yytext) > 40) parser_state.error = -PARSER_ERR_TOO_LONG_NUMBER;
+MPstr_to_num(yytext, v->base, celval.int_t);
+return tNUMBER;
+}
+
+{HEX_NUM} {
+if (v->base != HEX) REJECT;
+if (strlen(yytext) > 40) parser_state.error = -PARSER_ERR_TOO_LONG_NUMBER;
+MPstr_to_num(yytext, v->base, celval.int_t);
+return tNUMBER;
+}
+
+
 [ \t\n]
 .        {return *yytext; }
 
@@ -123,48 +150,8 @@
 }
 
 #if 0
-// TO BE USED LATER
+// EMPTY BLOCK
 
-{DIGIT}*{DECIMAL}*{DIGIT}+{SEPARATOR}{DIGIT}+ {
-check_numbase(yytext);
-MPstr_to_num(yytext, v->base, celval.int_t);
-return tDNUMBER;
-}
 
-{HEX}+"h" {
-// TODO: fix memory leak (look also following sections)
-char *number = ce_strndup(yytext, strlen(yytext)-1);
-MPstr_to_num(number, HEX, celval.int_t);
-free(number);
-return tINUMBER;
-}
 
-{BIN}+"b" {
-char *number = ce_strndup(yytext, strlen(yytext)-1);
-MPstr_to_num(number, BIN, celval.int_t);
-free(number);
-return tINUMBER;
-}
-
-{OCT}+"o" {
-char *number = ce_strndup(yytext, strlen(yytext)-1);
-MPstr_to_num(number, OCT, celval.int_t);
-free(number);
-return tINUMBER;
-}
-
-{DIGIT}+"d" {
-char *number = ce_strndup(yytext, strlen(yytext)-1);
-MPstr_to_num(number, DEC, celval.int_t);
-free(number);
-return tINUMBER;
-}
-
-{DIGIT}*{DECIMAL}{DIGIT}+"d" {
-char *number = ce_strndup(yytext, strlen(yytext)-1);
-MPstr_to_num(number, DEC, celval.int_t);
-free(number);
-return tDNUMBER;
-}
-
 #endif
Index: gcalctool/gcalctool.1
===================================================================
--- gcalctool/gcalctool.1	(revision 1682)
+++ gcalctool/gcalctool.1	(working copy)
@@ -257,7 +257,7 @@
 Return the fractional portion of the current entry.
 .IP "\fBAbs	[ u ]\fP" 18
 Return the absolute value of the current entry.
-.IP "\fB+/-	[ c ]\fP" 18
+.IP "\fB+/-	[ C ]\fP" 18
 Change the arithmetic sign of the current entry.
 .IP "\fB1/x	[ r ]\fP" 18
 Return the value of 1 divided by the current entry.
@@ -277,7 +277,7 @@
 available with the mouse, there is no visual feedback on what choices are
 available to you, so the user has to know what item they wish to select.
 .PD 0
-.IP "\fBAcc	[ a ]\fP" 18
+.IP "\fBAcc	[ A ]\fP" 18
 Set the display accuracy. Between 0 and 9 [ 0-9 ] significant digits can be
 displayed.
 .IP "\fBRcl	[ R ]\fP" 18
@@ -320,7 +320,7 @@
 Register 1	fv	(future value).
 .br
 Register 2	pv	(present value).
-.IP "\fBDdb	[ d ]\fP" 18
+.IP "\fBDdb	[ D ]\fP" 18
 Double-declining depreciation. Computes the depreciation allowance on an
 asset for a specified period of time, using the double-declining balance
 method.
@@ -477,7 +477,7 @@
 8	0.948		kilojoules or British thermals
 .br
 9	0.0610		cubic centimeters or cubic inches
-.IP "\fBFun	[ f ]\fP" 18
+.IP "\fBFun	[ F ]\fP" 18
 Retrieve and execute a function expression. There can be upto ten functions
 expression defined by the user [0 - 9]. There are no default function values.
 .PD
@@ -501,7 +501,7 @@
 provides a visual feedback of what is being typed in, in the calculator
 display. The calculation doesn't take place until the last parenthesis is
 matched, then the display is updated with the new result.
-.IP "\fBExp	[ e ]\fP" 18
+.IP "\fBExp	[ E ]\fP" 18
 This is used to allow numbers to be entered in scientific notation. The
 mantissa should be initially entered, then the Exp key selected. The exponent
 is then entered. If no numerical input had occurred when the Exp key was
@@ -517,9 +517,10 @@
 is only valid for positive integers.
 .IP "\fBRand	[ ? ]\fP" 18
 Return a random number between 0.0 and 1.0.
-.IP "\fBHexadecimal Keys [ A-F ]\fP" 18
+.IP "\fBHexadecimal Keys [ a-f ]\fP" 18
 The hexadecimal numerical digits A-F. These buttons will be insensitive 
-unless the calculator is currently in the hexadecimal mode.
+unless the calculator is currently in the hexadecimal mode. They will be
+shown in upper-case in the calculator display.
 .IP "\fBCos	[ J ]\fP" 18
 Return the trigonometric cosine, arc cosine, hyperbolic cosine or inverse
 hyperbolic cosine of the current display, depending upon the current
Index: gcalctool/gtk.c
===================================================================
--- gcalctool/gtk.c	(revision 1683)
+++ gcalctool/gtk.c	(working copy)
@@ -661,12 +661,26 @@
             break;
 
         case exprs:
-		  {
+		  { 
+                      if ((n->flags) & pending) {
+                          if (v->current != NULL) {
+                              free(v->current);
+                          }
+                          v->current = copy_button_info(n);
+                          do_pending();
+                      } else if (((n->flags) & hex) &&  (v->base != HEX)) {
+                          // Do nothing
+                      } else if (((n->flags) & number) && 
+                                 (((v->base == BIN) && !(n->flags & bin_set))
+                                  || ((v->base == OCT) && !(n->flags & oct_set)))) {
+                          // Do nothing
+                      } else {
 			struct exprm_state *e = get_state();
 			memcpy(&(e->button), n, sizeof(struct button));
 			new_state();
 			do_expression();
 			set_bit_panel();
+                      }
 		  }
 		  break;
 
@@ -1974,13 +1988,13 @@
     end_buffer = (gchar *) (buffer + strlen(buffer));
     text = malloc(strlen(buffer)+1);
 
-    /* If the clipboard buffer contains any occurances of the "thousands
-     * separator", remove them.
-     */
-
     srcp = (gchar *) buffer;
     dstp = text;
     while (srcp < end_buffer) {
+
+        /* If the clipboard buffer contains any occurances of the "thousands
+         * separator", remove them.
+         */
         if (*srcp == v->tsep[0]) {
             if (strstr(srcp, v->tsep) == srcp) {
                 srcp += strlen(v->tsep);
@@ -1988,7 +2002,35 @@
                 *dstp++ = *srcp++;
             }
         } else {
-            *dstp++ = *srcp++;
+
+            /* If an "A", "B", "C", "D" or "F" character is encountered, it 
+             * will be converted to its lowercase equivalent. If an "E" is 
+             * found,  and the next character is a "-" or a "+", then it 
+             * remains as an upper case "E" (it's assumed to be a possible 
+             * exponential number), otherwise its converted to a lower case 
+             * "e". See bugs #455889 and #469245 for more details.
+             */
+            switch (*srcp) {
+                case 'A':
+                case 'B':
+                case 'C':
+                case 'D':
+                case 'F': *dstp++ = tolower(*srcp);
+                          srcp++;
+                          break;
+
+                case 'E': if (srcp < (end_buffer-1)) {
+                              if (*(srcp+1) != '-' &&
+                                  *(srcp+1) != '+') {
+                                  *dstp++ = tolower(*srcp);
+                                  srcp++;
+                                  break;
+                              }
+                          }
+                          /*FALLTHROUGH*/
+
+                default:  *dstp++ = *srcp++;
+            }
         }
     }
     *dstp++ = '\0';
Index: gcalctool/ce_parser.y
===================================================================
--- gcalctool/ce_parser.y	(revision 1682)
+++ gcalctool/ce_parser.y	(working copy)
@@ -85,13 +85,12 @@
 %token tXNOR
 %token tXOR
 
-%token <int_t> tINUMBER
-%token <int_t> tDNUMBER
+%token <int_t> tNUMBER
 %token <integer> tREG
 
 %token NEG
 
-%type  <int_t> exp rcl value term reg func constant number parenthesis
+%type  <int_t> exp rcl value term reg func number parenthesis
 
 %start statement
 %left '+' '-'
@@ -125,12 +124,12 @@
   cp($1, v->MPdisp_val);
   show_display(v->MPdisp_val);
   }
-| value '=' tSTO '(' tINUMBER ')' {
+| value '=' tSTO '(' tNUMBER ')' {
   int val;
   mpcmi($5, &val);
   do_sto_reg(val, $1);
 }
-| value tSTO '(' tINUMBER ')' {
+| value tSTO '(' tNUMBER ')' {
   int val;
   mpcmi($4, &val);
   do_sto_reg(val, $1);
@@ -204,7 +203,6 @@
 | term '^' term {calc_xpowy($1, $3, $$);}
 | 'e' '^' term {calc_epowy($3, $$);} 
 | term '!' {do_factorial($1 ,$$);}
-| term 'e' term %prec MED {calc_xtimestenpowx($1, $3, $$);}
 | term '%' {calc_percent($1, $$);}
 | '-' term %prec NEG {mpneg($2, $$);}
 | '+' term %prec POS {cp($2, $$);}
@@ -213,7 +211,6 @@
 | reg {cp($1, $$);}
 
 | parenthesis {cp($1, $$);}
-| constant {cp($1, $$);}
 ;
 
 parenthesis:
@@ -221,10 +218,7 @@
   ;
 
 reg: 
-  tREG {do_rcl_reg($1, $$);};
-
-constant:
-  'e' {do_e($$);}
+  tREG {do_rcl_reg($1, $$);}
   ;
 
 func:
@@ -265,7 +259,7 @@
 ;
 
 rcl:
-  tRCL '(' tINUMBER ')' {
+  tRCL '(' tNUMBER ')' {
     int val;
     mpcmi($3, &val);
     do_rcl_reg(val, $$);
@@ -273,8 +267,7 @@
   ;
 
 number:
-  tINUMBER {cp($1, $$);}
-| tDNUMBER {cp($1, $$);}
+  tNUMBER {cp($1, $$);}
 | tANS {
   struct exprm_state *e = get_state();
   cp(e->ans, $$);
