瀏覽代碼

Use Length function instead of S[0].

Margers 1 月之前
父節點
當前提交
1ebf3c1615
共有 2 個文件被更改,包括 15 次插入14 次删除
  1. 7 7
      packages/fv/src/editors.pas
  2. 8 7
      packages/fv/src/stddlg.pas

+ 7 - 7
packages/fv/src/editors.pas

@@ -466,6 +466,7 @@ resourcestring  sClipboard='Clipboard';
                 sUntitled='Untitled';
                 sWordWrapNotPossible='Wordwrap on:  Wordwrap not possible in current margins with continuous line.';
                 sWordWrapOff='You must turn on wordwrap before you can reformat.';
+                sSaveFileAs='Save file as';
 
                 slCaseSensitive='~C~ase sensitive';
                 slCurrentLine='~C~urrent line';
@@ -941,7 +942,7 @@ begin
       StdEditorDialog := MessageBox(sFileUntitled, nil, mfInformation + mfYesNoCancel);
     edSaveAs:
       StdEditorDialog := Application^.ExecuteDialog(New(PFileDialog, Init('*.*',
-        slSaveFileAs, slName, fdOkButton, 101)), Info);
+        sSaveFileAs, slName, fdOkButton, 101)), Info);
     edFind:
       StdEditorDialog := Application^.ExecuteDialog(CreateFindDialog, Info);
     edSearchFailed:
@@ -1097,7 +1098,7 @@ Var
 begin
   BMMakeTable(str,bt);
   len:=length(str);
-  s2[0]:=chr(len);       { sets the length to that of the search String }
+  SetLength(s2,len);       { sets the length to that of the search String }
   found:=False;
   numb:=pred(len);
   While (not found) and (numb<(size-len)) do
@@ -1146,7 +1147,7 @@ begin
     exit;
   end;
   { create uppercased string }
-  s[0]:=chr(len);
+  SetLength(s,len);
   for x:=1 to len do
    begin
      if str[x] in ['a'..'z'] then
@@ -3197,7 +3198,6 @@ begin
           if Length (Tab_String) = 0 then
             begin
               FillChar (Tab_Settings, SizeOf (Tab_Settings), #0);
-              Tab_Settings[0] := #0;
               Exit;
             end
           else
@@ -3254,7 +3254,7 @@ begin
   Position := CurPos.X + 1;
   repeat
     Inc (Position);
-  until (Tab_Settings[Position] <> #32) or (Position >= Ord (Tab_Settings[0]));
+  until (Tab_Settings[Position] <> #32) or (Position >= Length (Tab_Settings));
   E := CurPos.X;
   Index := 1;
   { Now we enter a loop to go to the next tab position.  }
@@ -3267,7 +3267,7 @@ begin
       if Overwrite then
         begin
           if (Position > LineEnd (CurPtr) - LineStart (CurPtr))
-              or (Position > Ord (Tab_Settings[0])) then
+              or (Position > Length (Tab_Settings)) then
             begin
               SetCurPtr (LineStart (LineMove (CurPtr, 1)), Select_Mode);
               Exit;
@@ -3278,7 +3278,7 @@ begin
         end
       else
         begin
-          if (Position > Right_Margin) or (Position > Ord (Tab_Settings[0])) then
+          if (Position > Right_Margin) or (Position > Length (Tab_Settings)) then
             begin
               SetCurPtr (LineStart (LineMove (CurPtr, 1)), Select_Mode);
               Exit;

+ 8 - 7
packages/fv/src/stddlg.pas

@@ -680,7 +680,7 @@ begin
   begin
     { do not change '/' into '' }
     if (Length(ExpPath)>1) and (ExpPath[Length(ExpPath)] = DirSeparator) then
-      Dec(ExpPath[0]);
+      SetLength(ExpPath,Length(ExpPath)-1);
     // This function is called on current directories.
     // If the current dir starts with a . on Linux it is is hidden.
     // That's why we allow hidden dirs below (bug 6173)
@@ -1320,7 +1320,7 @@ end;
   begin
     I := 1;
     while (I < Length(S)) and (S[I] = ' ') do Inc(I);
-    LTrim := Copy(S, I, 255);
+    LTrim := Copy(S, I, length(S));
   end;
 
   function RTrim(const S: String): String;
@@ -1328,6 +1328,7 @@ end;
     I: Sw_Integer;
   begin
     I := Length(S);
+    if I = 0 then begin RTrim:=''; exit; end;
     while S[I] = ' ' do Dec(I);
     RTrim := Copy(S, 1, I);
   end;
@@ -2341,7 +2342,7 @@ begin
    Dec(SearchPos);
           if SearchPos = 0 then
             HandleDir:= ((GetShiftState and $3) <> 0) or (Event.CharCode in ['A'..'Z']);
-   CurString[0] := AnsiChar(SearchPos);
+          SetLength(CurString,SearchPos);
       end
       else if (Event.CharCode = '.') then
         SearchPos := Pos('.',CurString)
@@ -2350,7 +2351,7 @@ begin
    Inc(SearchPos);
           if SearchPos = 1 then
             HandleDir := ((GetShiftState and 3) <> 0) or (Event.CharCode in ['A'..'Z']);
-   CurString[0] := AnsiChar(SearchPos);
+          SetLength(CurString,SearchPos);
    CurString[SearchPos] := Event.CharCode;
       end;
       K := GetKey(CurString);
@@ -2490,9 +2491,9 @@ begin
     ExtractDir := '';
     Exit;
   end;
-  if (D[Byte(D[0])] <> DirSeparator)
+  if (D[Length(D)] <> DirSeparator)
   {$ifdef HASAMIGA}
-    and (D[Byte(D[0])] <> DriveSeparator)
+    and (D[Length(D)] <> DriveSeparator)
   {$endif}
   then
     D := D + DirSeparator;
@@ -2530,7 +2531,7 @@ begin
   GetDir(0, CurDir);
   if (Length(CurDir) > 3) then
   begin
-    Inc(CurDir[0]);
+    SetLength(CurDir,Length(CurDir)+1);
     CurDir[Length(CurDir)] := DirSeparator;
   end;
   GetCurDir := CurDir;