summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorflorian <florian@3ad0048d-3df7-0310-abae-a5850022a9f2>2009-07-30 19:28:55 +0000
committerflorian <florian@3ad0048d-3df7-0310-abae-a5850022a9f2>2009-07-30 19:28:55 +0000
commit158b6296a4c4cfb38ad39638176159036a31ce01 (patch)
treef2973aac981716cc883a1e9ec96121f9c6611bbe
parentfc8b1e3e72597ad80807eea5121c58c1c80bbc0f (diff)
downloadfpc-cpstr.tar.gz
* uncommited stuff for code page aware stringscpstr
git-svn-id: http://svn.freepascal.org/svn/fpc/branches/cpstr@13478 3ad0048d-3df7-0310-abae-a5850022a9f2
-rw-r--r--compiler/defcmp.pas8
-rw-r--r--compiler/pexpr.pas78
2 files changed, 47 insertions, 39 deletions
diff --git a/compiler/defcmp.pas b/compiler/defcmp.pas
index 068354da60..bfc445c5a9 100644
--- a/compiler/defcmp.pas
+++ b/compiler/defcmp.pas
@@ -340,10 +340,14 @@ implementation
end;
end
else
- { Same string type, for shortstrings also the length must match }
+ { same string type ? }
if (tstringdef(def_from).stringtype=tstringdef(def_to).stringtype) and
+ { for shortstrings also the length must match }
((tstringdef(def_from).stringtype<>st_shortstring) or
- (tstringdef(def_from).len=tstringdef(def_to).len)) then
+ (tstringdef(def_from).len=tstringdef(def_to).len)) and
+ { for ansi- and unicodestrings also the encoding must match }
+ (not(tstringdef(def_from).stringtype in [st_ansistring,st_unicodestring]) or
+ (tstringdef(def_from).stringencoding=tstringdef(def_to).stringencoding))then
eq:=te_equal
else
begin
diff --git a/compiler/pexpr.pas b/compiler/pexpr.pas
index 7176a4ea80..b78288921f 100644
--- a/compiler/pexpr.pas
+++ b/compiler/pexpr.pas
@@ -92,48 +92,52 @@ implementation
{ and returns a pointer to the string }
{ definition }
var
- p : tnode;
+ p : tnode;
begin
- def:=cshortstringtype;
- consume(_STRING);
- if try_to_consume(_LECKKLAMMER) then
- begin
- p:=comp_expr(true);
- if not is_constintnode(p) then
- begin
- Message(parser_e_illegal_expression);
- { error recovery }
- consume(_RECKKLAMMER);
- end
- else
- begin
- if (tordconstnode(p).value<=0) then
- begin
- Message(parser_e_invalid_string_size);
- tordconstnode(p).value:=255;
- end;
+ def:=cshortstringtype;
+ consume(_STRING);
+ if try_to_consume(_LECKKLAMMER) then
+ begin
+ p:=comp_expr(true);
+ if not is_constintnode(p) then
+ begin
+ Message(parser_e_illegal_expression);
+ { error recovery }
consume(_RECKKLAMMER);
- if tordconstnode(p).value>255 then
+ end
+ else
+ begin
+ if (tordconstnode(p).value<=0) then
begin
- { longstring is currently unsupported (CEC)! }
-{ t:=tstringdef.createlong(tordconstnode(p).value))}
Message(parser_e_invalid_string_size);
tordconstnode(p).value:=255;
- def:=tstringdef.createshort(int64(tordconstnode(p).value));
- end
- else
- if tordconstnode(p).value<>255 then
- def:=tstringdef.createshort(int64(tordconstnode(p).value));
- end;
- p.free;
- end
- else
- begin
- if cs_ansistrings in current_settings.localswitches then
- def:=cansistringtype
- else
- def:=cshortstringtype;
- end;
+ end;
+ consume(_RECKKLAMMER);
+ if tordconstnode(p).value>255 then
+ begin
+ { longstring is currently unsupported (CEC)! }
+{ t:=tstringdef.createlong(tordconstnode(p).value))}
+ Message(parser_e_invalid_string_size);
+ tordconstnode(p).value:=255;
+ def:=tstringdef.createshort(int64(tordconstnode(p).value));
+ end
+ else
+ if tordconstnode(p).value<>255 then
+ def:=tstringdef.createshort(int64(tordconstnode(p).value));
+ end;
+ p.free;
+ end
+ else if try_to_consume(_GT) then
+ begin
+ consume(_LT);
+ end
+ else
+ begin
+ if cs_ansistrings in current_settings.localswitches then
+ def:=cansistringtype
+ else
+ def:=cshortstringtype;
+ end;
end;