Browse Source

Merged revisions 594 via svnmerge from
/trunk

git-svn-id: branches/fixes_2_0@680 -

peter 20 years ago
parent
commit
f61ed941c6
3 changed files with 29 additions and 5 deletions
  1. 1 0
      .gitattributes
  2. 16 5
      compiler/defcmp.pas
  3. 12 0
      tests/webtbs/tw4162.pp

+ 1 - 0
.gitattributes

@@ -5969,6 +5969,7 @@ tests/webtbs/tw4150.pp svneol=native#text/plain
 tests/webtbs/tw4151.pp svneol=native#text/plain
 tests/webtbs/tw4152.pp svneol=native#text/plain
 tests/webtbs/tw4155.pp svneol=native#text/plain
+tests/webtbs/tw4162.pp svneol=native#text/plain
 tests/webtbs/tw4188.pp svneol=native#text/plain
 tests/webtbs/ub1873.pp svneol=native#text/plain
 tests/webtbs/ub1883.pp svneol=native#text/plain

+ 16 - 5
compiler/defcmp.pas

@@ -304,12 +304,23 @@ implementation
                      else
                        begin
                          doconv:=tc_string_2_string;
-                         { Prefer conversions to shortstring over other
-                           conversions. This is compatible with Delphi (PFV) }
-                         if tstringdef(def_to).string_typ=st_shortstring then
-                           eq:=te_convert_l2
+                         if tstringdef(def_from).string_typ=st_widestring then
+                           begin
+                             { Prefer conversions to shortstring over other
+                               conversions. This is compatible with Delphi (PFV) }
+                             if tstringdef(def_to).string_typ=st_shortstring then
+                               eq:=te_convert_l3
+                             else
+                               eq:=te_convert_l2;
+                           end
+                         else
+                           { Prefer shortstrings of different length or conversions
+                             from shortstring to ansistring }
+                           if (tstringdef(def_from).string_typ=st_shortstring) and
+                              (tstringdef(def_to).string_typ in [st_shortstring,st_ansistring]) then
+                           eq:=te_convert_l1
                          else
-                           eq:=te_convert_l3;
+                           eq:=te_convert_l2;
                        end;
                    end;
                  orddef :

+ 12 - 0
tests/webtbs/tw4162.pp

@@ -0,0 +1,12 @@
+
+Var
+  S: ansistring;
+  SS: shortstring;
+Begin
+  SS := 'find';
+  SetLength(S, 300);
+  S := S + SS;
+  Writeln(Pos(SS, S)); // This will not find the occurance of 'find'
+  if pos(ss,s)<>301 then
+    halt(1);
+End.