ソースを参照

* UpdateTargetSwitchStr moved to a new unit dirparse.pas. This avoids the dependence of unit scandir on unit options

git-svn-id: trunk@25629 -
nickysn 12 年 前
コミット
119cf760eb
4 ファイル変更134 行追加90 行削除
  1. 1 0
      .gitattributes
  2. 130 0
      compiler/dirparse.pas
  3. 1 89
      compiler/options.pas
  4. 2 1
      compiler/scandir.pas

+ 1 - 0
.gitattributes

@@ -164,6 +164,7 @@ compiler/dbgstabs.pas svneol=native#text/plain
 compiler/dbgstabx.pas svneol=native#text/plain
 compiler/defcmp.pas svneol=native#text/plain
 compiler/defutil.pas svneol=native#text/plain
+compiler/dirparse.pas svneol=native#text/plain
 compiler/elfbase.pas svneol=native#text/plain
 compiler/export.pas svneol=native#text/plain
 compiler/expunix.pas svneol=native#text/plain

+ 130 - 0
compiler/dirparse.pas

@@ -0,0 +1,130 @@
+{
+    Copyright (c) 1998-2002 by Florian Klaempfl
+
+    This unit implements some support functions for the parsing of directives
+    and option strings
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ ****************************************************************************
+}
+
+unit dirparse;
+
+{$i fpcdefs.inc}
+
+interface
+
+    uses
+      globtype;
+
+    function UpdateTargetSwitchStr(s: string; var a: ttargetswitches; global: boolean): boolean;
+
+implementation
+
+    uses
+      globals,
+      cutils,
+      symtable;
+
+    function UpdateTargetSwitchStr(s: string; var a: ttargetswitches; global: boolean): boolean;
+      var
+        tok,
+        value : string;
+        setstr: string[2];
+        equalspos: longint;
+        doset,
+        gotvalue,
+        found : boolean;
+        opt   : ttargetswitch;
+      begin
+        result:=true;
+        repeat
+          tok:=GetToken(s,',');
+          if tok='' then
+           break;
+          setstr:=upper(copy(tok,length(tok),1));
+          if setstr='-' then
+            begin
+              setlength(tok,length(tok)-1);
+              doset:=false;
+            end
+          else
+            doset:=true;
+          { value specified? }
+          gotvalue:=false;
+          equalspos:=pos('=',tok);
+          if equalspos<>0 then
+            begin
+              value:=copy(tok,equalspos+1,length(tok));
+              delete(tok,equalspos,length(tok));
+              gotvalue:=true;
+            end;
+          found:=false;
+          uppervar(tok);
+          for opt:=low(ttargetswitch) to high(ttargetswitch) do
+            begin
+              if TargetSwitchStr[opt].name=tok then
+                begin
+                  found:=true;
+                  break;
+                end;
+            end;
+          if found then
+            begin
+              if not global and
+                 TargetSwitchStr[opt].isglobal then
+                result:=false
+              else if not TargetSwitchStr[opt].hasvalue then
+                begin
+                  if gotvalue then
+                    result:=false;
+                  if (TargetSwitchStr[opt].define<>'') and (doset xor (opt in a)) then
+                    if doset then
+                      def_system_macro(TargetSwitchStr[opt].define)
+                    else
+                      undef_system_macro(TargetSwitchStr[opt].define);
+                  if doset then
+                    include(a,opt)
+                  else
+                    exclude(a,opt)
+                end
+              else
+                begin
+                  if not gotvalue or
+                     not doset then
+                    result:=false
+                  else
+                    begin
+                      case opt of
+                        ts_auto_getter_prefix:
+                          prop_auto_getter_prefix:=value;
+                        ts_auto_setter_predix:
+                          prop_auto_setter_prefix:=value;
+                        else
+                          begin
+                            writeln('Internalerror 2012053001');
+                            halt(1);
+                          end;
+                      end;
+                    end;
+                end;
+            end
+          else
+            result:=false;
+        until false;
+      end;
+
+end.

+ 1 - 89
compiler/options.pas

@@ -78,7 +78,6 @@ Type
 var
   coption : TOptionClass;
 
-function UpdateTargetSwitchStr(s: string; var a: ttargetswitches; global: boolean): boolean;
 procedure read_arguments(cmd:TCmdStr);
 
 implementation
@@ -92,6 +91,7 @@ uses
   comphook,
   symtable,scanner,rabase,
   symconst,
+  dirparse,
   i_bsd;
 
 const
@@ -150,94 +150,6 @@ begin
 end;
 
 
-function UpdateTargetSwitchStr(s: string; var a: ttargetswitches; global: boolean): boolean;
-var
-  tok,
-  value : string;
-  setstr: string[2];
-  equalspos: longint;
-  doset,
-  gotvalue,
-  found : boolean;
-  opt   : ttargetswitch;
-begin
-  result:=true;
-  repeat
-    tok:=GetToken(s,',');
-    if tok='' then
-     break;
-    setstr:=upper(copy(tok,length(tok),1));
-    if setstr='-' then
-      begin
-        setlength(tok,length(tok)-1);
-        doset:=false;
-      end
-    else
-      doset:=true;
-    { value specified? }
-    gotvalue:=false;
-    equalspos:=pos('=',tok);
-    if equalspos<>0 then
-      begin
-        value:=copy(tok,equalspos+1,length(tok));
-        delete(tok,equalspos,length(tok));
-        gotvalue:=true;
-      end;
-    found:=false;
-    uppervar(tok);
-    for opt:=low(ttargetswitch) to high(ttargetswitch) do
-      begin
-        if TargetSwitchStr[opt].name=tok then
-          begin
-            found:=true;
-            break;
-          end;
-      end;
-    if found then
-      begin
-        if not global and
-           TargetSwitchStr[opt].isglobal then
-          result:=false
-        else if not TargetSwitchStr[opt].hasvalue then
-          begin
-            if gotvalue then
-              result:=false;
-            if (TargetSwitchStr[opt].define<>'') and (doset xor (opt in a)) then
-              if doset then
-                def_system_macro(TargetSwitchStr[opt].define)
-              else
-                undef_system_macro(TargetSwitchStr[opt].define);
-            if doset then
-              include(a,opt)
-            else
-              exclude(a,opt)
-          end
-        else
-          begin
-            if not gotvalue or
-               not doset then
-              result:=false
-            else
-              begin
-                case opt of
-                  ts_auto_getter_prefix:
-                    prop_auto_getter_prefix:=value;
-                  ts_auto_setter_predix:
-                    prop_auto_setter_prefix:=value;
-                  else
-                    begin
-                      writeln('Internalerror 2012053001');
-                      halt(1);
-                    end;
-                end;
-              end;
-          end;
-      end
-    else
-      result:=false;
-  until false;
-end;
-
 {****************************************************************************
                                  Toption
 ****************************************************************************}

+ 2 - 1
compiler/scandir.pas

@@ -52,11 +52,12 @@ unit scandir;
     uses
       SysUtils,
       cutils,cfileutl,
-      globals,systems,options,widestr,cpuinfo,
+      globals,systems,widestr,cpuinfo,
       verbose,comphook,ppu,
       scanner,switches,
       fmodule,
       defutil,
+      dirparse,
       symconst,symtable,symbase,symtype,symsym,
       rabase;