Procházet zdrojové kódy

* fixed some bugs in the camelCase conversion performed on the JVM target by
-CTlowercaseprocstart
o convert all consecutive uppercase characters at the start to lowercase
instead of only the first one. Exception: if there is more than one
such character and the last one is followed by a lowercase character,
assume the last uppercase character belongs to the second word (like
in FPCIsGreat) and don't lowercase that one
+ test

git-svn-id: trunk@25845 -

Jonas Maebe před 11 roky
rodič
revize
b70e64dc67

+ 21 - 1
compiler/symsym.pas

@@ -616,12 +616,32 @@ implementation
 ****************************************************************************}
 
     constructor tprocsym.create(const n : string);
+      var
+        i: longint;
       begin
          if not(ts_lowercase_proc_start in current_settings.targetswitches) or
             (n='') then
            inherited create(procsym,n)
          else
-           inherited create(procsym,lowercase(n[1])+copy(n,2,length(n)-1));
+           begin
+             { YToX -> yToX
+               RC64Encode -> rc64Encode
+               Test -> test
+             }
+             i:=2;
+             while i<=length(n) do
+               begin
+                 if not(n[i] in ['A'..'Z']) then
+                   begin
+                     if (i>2) and
+                        (n[i] in ['a'..'z']) then
+                       dec(i);
+                     break;
+                   end;
+                 inc(i);
+               end;
+             inherited create(procsym,lower(copy(n,1,i-1))+copy(n,i,length(n)));
+           end;
          FProcdefList:=TFPObjectList.Create(false);
          FProcdefderefList:=nil;
          { the tprocdef have their own symoptions, make the procsym

+ 3 - 0
tests/test/jvm/tjavalowercaseproc.java

@@ -9,6 +9,9 @@ public static void main(String[] args)
   c = new org.freepascal.test.lcproc.tc();
   c.methodName();
   org.freepascal.test.lcproc.tc.classMethodName();
+  c.xToY();
+  c.prefixThingToTest();
+  c.rc64Encode();
 }
 
 }

+ 15 - 0
tests/test/jvm/tlowercaseproc.pp

@@ -13,6 +13,9 @@ type
   tc = class
    procedure MethodName;
    class procedure ClassMethodName; static;
+   procedure XToY; // should become xToY
+   procedure PREFIXThingToTest; // should become prefixThingToTest
+   procedure RC64Encode; // should become rc64Encode;
   end;
 
 implementation
@@ -37,4 +40,16 @@ begin
   doit;
 end;
 
+procedure tc.xtoy;
+begin
+end;
+
+procedure tc.PREFIXThingToTest;
+begin
+end;
+
+procedure tc.RC64Encode;
+begin
+end;
+
 end.