diff --git a/src/lex.c b/src/lex.c
index 3b12fc6515d68f0e7d0248b5d644971008ac4d32..89192ec198efb81aa7ab627fc2ebde22caa26bac 100644
--- a/src/lex.c
+++ b/src/lex.c
@@ -2,7 +2,7 @@
 || This file is part of Pike. For copyright information see COPYRIGHT.
 || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
 || for more information.
-|| $Id: lex.c,v 1.122 2008/06/29 21:14:00 marcus Exp $
+|| $Id: lex.c,v 1.123 2008/06/29 21:33:25 marcus Exp $
 */
 
 #include "global.h"
@@ -18,7 +18,7 @@
 
 /* Must do like this since at least gcc is a little too keen on
  * optimizing INT_TYPE_MUL_OVERFLOW otherwise. */
-static p_wchar2 eight = 8, sixteen = 16, ten = 10;
+static unsigned INT32 eight = 8, sixteen = 16, ten = 10;
 
 /* Make lexers for shifts 0, 1 and 2. */
 
diff --git a/src/lexer.h b/src/lexer.h
index 50decc26b5241fbfd956b969abfafeba8d21fa51..7a9e7438a3cc0eb8b3ea4f40c225073aa0c04304 100644
--- a/src/lexer.h
+++ b/src/lexer.h
@@ -2,7 +2,7 @@
 || This file is part of Pike. For copyright information see COPYRIGHT.
 || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
 || for more information.
-|| $Id: lexer.h,v 1.83 2008/06/29 21:14:00 marcus Exp $
+|| $Id: lexer.h,v 1.84 2008/06/29 21:33:25 marcus Exp $
 */
 
 /*
@@ -214,54 +214,57 @@ int parse_esc_seq (WCHAR *buf, p_wchar2 *chr, ptrdiff_t *len)
     case '0': case '1': case '2': case '3':
     case '4': case '5': case '6': case '7': {
       unsigned of = 0;
-      c-='0';
+      unsigned INT32 n = c-'0';
       for (l = 1; buf[l] >= '0' && buf[l] <= '8'; l++) {
-	if (!of) of = UNSIGNED_INT_TYPE_MUL_OVERFLOW (c, eight);
-	c = 8 * c + buf[l] - '0';
+	if (!of) of = UNSIGNED_INT_TYPE_MUL_OVERFLOW (n, eight);
+	n = 8 * n + buf[l] - '0';
       }
       if (of) {*len = l; return 4;}
+      c = (p_wchar2)n;
       break;
     }
       
     case 'x': {
       unsigned of = 0;
-      c=0;
+      unsigned INT32 n=0;
       for (l = 1;; l++) {
 	switch (buf[l]) {
 	  case '0': case '1': case '2': case '3': case '4':
 	  case '5': case '6': case '7': case '8': case '9':
-	    if (!of) of = UNSIGNED_INT_TYPE_MUL_OVERFLOW (c, sixteen);
-	    c = 16 * c + buf[l] - '0';
+	    if (!of) of = UNSIGNED_INT_TYPE_MUL_OVERFLOW (n, sixteen);
+	    n = 16 * n + buf[l] - '0';
 	    continue;
 	  case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
-	    if (!of) of = UNSIGNED_INT_TYPE_MUL_OVERFLOW (c, sixteen);
-	    c = 16 * c + buf[l] - 'a' + 10;
+	    if (!of) of = UNSIGNED_INT_TYPE_MUL_OVERFLOW (n, sixteen);
+	    n = 16 * n + buf[l] - 'a' + 10;
 	    continue;
 	  case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
-	    if (!of) of = UNSIGNED_INT_TYPE_MUL_OVERFLOW (c, sixteen);
-	    c = 16 * c + buf[l] - 'A' + 10;
+	    if (!of) of = UNSIGNED_INT_TYPE_MUL_OVERFLOW (n, sixteen);
+	    n = 16 * n + buf[l] - 'A' + 10;
 	    continue;
 	}
 	break;
       }
       if (of) {*len = l; return 5;}
+      c = (p_wchar2)n;
       break;
     }
 
     case 'd': {
       unsigned of = 0;
-      c=0;
+      unsigned INT32 n=0;
       for (l = 1;; l++) {
 	switch (buf[l]) {
 	  case '0': case '1': case '2': case '3': case '4':
 	  case '5': case '6': case '7': case '8': case '9':
-	    if (!of) of = UNSIGNED_INT_TYPE_MUL_OVERFLOW (c, ten);
-	    c = 10 * c + buf[l] - '0';
+	    if (!of) of = UNSIGNED_INT_TYPE_MUL_OVERFLOW (n, ten);
+	    n = 10 * n + buf[l] - '0';
 	    continue;
 	}
 	break;
       }
       if (of) {*len = l; return 6;}
+      c = (p_wchar2)n;
       break;
     }