mirror of
https://github.com/autc04/Retro68.git
synced 2024-11-24 23:32:06 +00:00
fix plain C pascal strings
This commit is contained in:
parent
281135ccfa
commit
4007b27d05
@ -7340,6 +7340,7 @@ c_parser_string_literal (c_parser *parser, bool translate, bool wide_ok)
|
|||||||
location_t loc, last_tok_loc;
|
location_t loc, last_tok_loc;
|
||||||
enum cpp_ttype type;
|
enum cpp_ttype type;
|
||||||
tree value, string_tree;
|
tree value, string_tree;
|
||||||
|
bool pascal_string = false;
|
||||||
|
|
||||||
tok = c_parser_peek_token (parser);
|
tok = c_parser_peek_token (parser);
|
||||||
loc = tok->location;
|
loc = tok->location;
|
||||||
@ -7420,11 +7421,23 @@ c_parser_string_literal (c_parser *parser, bool translate, bool wide_ok)
|
|||||||
warning (OPT_Wtraditional,
|
warning (OPT_Wtraditional,
|
||||||
"traditional C rejects string constant concatenation");
|
"traditional C rejects string constant concatenation");
|
||||||
|
|
||||||
|
if (!strncmp((const char*)strs[0].text, "\"\\p", 3))
|
||||||
|
{
|
||||||
|
pascal_string = true;
|
||||||
|
/* replace \p by a valid escape sequence */
|
||||||
|
((unsigned char*)strs[0].text)[2] = 'n';
|
||||||
|
}
|
||||||
|
|
||||||
if ((type == CPP_STRING || wide_ok)
|
if ((type == CPP_STRING || wide_ok)
|
||||||
&& ((translate
|
&& ((translate
|
||||||
? cpp_interpret_string : cpp_interpret_string_notranslate)
|
? cpp_interpret_string : cpp_interpret_string_notranslate)
|
||||||
(parse_in, strs, count, &istr, type)))
|
(parse_in, strs, count, &istr, type)))
|
||||||
{
|
{
|
||||||
|
if (pascal_string)
|
||||||
|
{
|
||||||
|
/* put the real string length in */
|
||||||
|
((unsigned char*)istr.text)[0] = (unsigned char) (istr.len - 2);
|
||||||
|
}
|
||||||
value = build_string (istr.len, (const char *) istr.text);
|
value = build_string (istr.len, (const char *) istr.text);
|
||||||
free (CONST_CAST (unsigned char *, istr.text));
|
free (CONST_CAST (unsigned char *, istr.text));
|
||||||
if (count > 1)
|
if (count > 1)
|
||||||
@ -7475,6 +7488,9 @@ c_parser_string_literal (c_parser *parser, bool translate, bool wide_ok)
|
|||||||
default:
|
default:
|
||||||
case CPP_STRING:
|
case CPP_STRING:
|
||||||
case CPP_UTF8STRING:
|
case CPP_UTF8STRING:
|
||||||
|
if (pascal_string)
|
||||||
|
TREE_TYPE (value) = uchar_array_type_node;
|
||||||
|
else
|
||||||
TREE_TYPE (value) = char_array_type_node;
|
TREE_TYPE (value) = char_array_type_node;
|
||||||
break;
|
break;
|
||||||
case CPP_STRING16:
|
case CPP_STRING16:
|
||||||
|
Loading…
Reference in New Issue
Block a user