aboutsummaryrefslogtreecommitdiff
path: root/gdb/c-exp.y
diff options
context:
space:
mode:
authorKevin Buettner <kevinb@redhat.com>2002-09-20 00:24:01 +0000
committerKevin Buettner <kevinb@redhat.com>2002-09-20 00:24:01 +0000
commit234b45d446cc127c7cbb5bfb39151b86795ffe3d (patch)
tree6a83f0d391193971249cf36509e216aae3e86a91 /gdb/c-exp.y
parentbb7eb0390bd1fe1972169391683eeb79cbd986fd (diff)
downloadgdb-234b45d446cc127c7cbb5bfb39151b86795ffe3d.zip
gdb-234b45d446cc127c7cbb5bfb39151b86795ffe3d.tar.gz
gdb-234b45d446cc127c7cbb5bfb39151b86795ffe3d.tar.bz2
Add support for distinct host and target character sets.
Diffstat (limited to 'gdb/c-exp.y')
-rw-r--r--gdb/c-exp.y26
1 files changed, 25 insertions, 1 deletions
diff --git a/gdb/c-exp.y b/gdb/c-exp.y
index c6fc52c..376f6d5 100644
--- a/gdb/c-exp.y
+++ b/gdb/c-exp.y
@@ -49,6 +49,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "bfd.h" /* Required by objfiles.h. */
#include "symfile.h" /* Required by objfiles.h. */
#include "objfiles.h" /* For have_full_symbols and have_partial_symbols */
+#include "charset.h"
/* Flag indicating we're dealing with HP-compiled objects */
extern int hp_som_som_object_present;
@@ -1314,6 +1315,15 @@ yylex ()
c = parse_escape (&lexptr);
else if (c == '\'')
error ("Empty character constant.");
+ else if (! host_char_to_target (c, &c))
+ {
+ int toklen = lexptr - tokstart + 1;
+ char *tok = alloca (toklen + 1);
+ memcpy (tok, tokstart, toklen);
+ tok[toklen] = '\0';
+ error ("There is no character corresponding to %s in the target "
+ "character set `%s'.", tok, target_charset ());
+ }
yylval.typed_val_int.val = c;
yylval.typed_val_int.type = builtin_type_char;
@@ -1464,6 +1474,8 @@ yylex ()
tempbufindex = 0;
do {
+ char *char_start_pos = tokptr;
+
/* Grow the static temp buffer if necessary, including allocating
the first one on demand. */
if (tempbufindex + 1 >= tempbufsize)
@@ -1486,7 +1498,19 @@ yylex ()
tempbuf[tempbufindex++] = c;
break;
default:
- tempbuf[tempbufindex++] = *tokptr++;
+ c = *tokptr++;
+ if (! host_char_to_target (c, &c))
+ {
+ int len = tokptr - char_start_pos;
+ char *copy = alloca (len + 1);
+ memcpy (copy, char_start_pos, len);
+ copy[len] = '\0';
+
+ error ("There is no character corresponding to `%s' "
+ "in the target character set `%s'.",
+ copy, target_charset ());
+ }
+ tempbuf[tempbufindex++] = c;
break;
}
} while ((*tokptr != '"') && (*tokptr != '\0'));