Переглянути джерело

* patch by "rs" to support lines longer than 255 chars in h2pas, resolves #15056

git-svn-id: trunk@29425 -
florian 10 роки тому
батько
коміт
15537361ee

+ 2 - 2
utils/h2pas/h2pas.pas

@@ -4,7 +4,7 @@
 (* global definitions: *)
 (* global definitions: *)
 
 
 program h2pas;
 program h2pas;
-
+{$H+}
 (*
 (*
     Copyright (c) 1998-2000 by Florian Klaempfl
     Copyright (c) 1998-2000 by Florian Klaempfl
 
 
@@ -9392,4 +9392,4 @@ begin
   PTypeList.Free;
   PTypeList.Free;
   freedynlibproc.free;
   freedynlibproc.free;
   loaddynlibproc.free;
   loaddynlibproc.free;
-end.
+end.

+ 1 - 1
utils/h2pas/h2pas.y

@@ -1,6 +1,6 @@
 %{
 %{
 program h2pas;
 program h2pas;
-
+{$H+}
 (*
 (*
     Copyright (c) 1998-2000 by Florian Klaempfl
     Copyright (c) 1998-2000 by Florian Klaempfl
 
 

+ 13 - 17
utils/h2pas/h2plexlib.pas

@@ -1,6 +1,5 @@
-
 unit h2pLexLib;
 unit h2pLexLib;
-
+{$H+}
 (* Standard Lex library unit for TP Lex Version 3.0.
 (* Standard Lex library unit for TP Lex Version 3.0.
    2-11-91 AG *)
    2-11-91 AG *)
 
 
@@ -25,7 +24,8 @@ interface
 
 
 (* Variables:
 (* Variables:
 
 
-   The variable yytext contains the current match, yyleng its length.
+   The variable yytext contains the current match, yyleng(was removed because of
+   $H+) its length.
    The variable yyline contains the current input line, and yylineno and
    The variable yyline contains the current input line, and yylineno and
    yycolno denote the current input position (line, column). These values
    yycolno denote the current input position (line, column). These values
    are often used in giving error diagnostics (however, they will only be
    are often used in giving error diagnostics (however, they will only be
@@ -43,8 +43,6 @@ yyinput, yyoutput : Text;        (* input and output file *)
 yyline,yyprevline : String;      (* current and previous input line *)
 yyline,yyprevline : String;      (* current and previous input line *)
 yylineno, yycolno : Integer;     (* current input position *)
 yylineno, yycolno : Integer;     (* current input position *)
 yytext            : String;      (* matched text (should be considered r/o) *)
 yytext            : String;      (* matched text (should be considered r/o) *)
-yyleng            : Byte         (* length of matched text *)
-  absolute yytext;
 
 
 (* I/O routines:
 (* I/O routines:
 
 
@@ -256,14 +254,14 @@ yysstate, yylstate : Integer;
 yymatches          : Integer;
 yymatches          : Integer;
 yystack            : array [1..max_matches] of Integer;
 yystack            : array [1..max_matches] of Integer;
 yypos              : array [1..max_rules] of Integer;
 yypos              : array [1..max_rules] of Integer;
-yysleng            : Byte;
+yysleng            : Integer;
 
 
 (* Utilities: *)
 (* Utilities: *)
 
 
 procedure echo;
 procedure echo;
   var i : Integer;
   var i : Integer;
   begin
   begin
-    for i := 1 to yyleng do
+    for i := 1 to Length(yytext) do
       put_char(yytext[i])
       put_char(yytext[i])
   end(*echo*);
   end(*echo*);
 
 
@@ -275,16 +273,16 @@ procedure yymore;
 procedure yyless ( n : Integer );
 procedure yyless ( n : Integer );
   var i : Integer;
   var i : Integer;
   begin
   begin
-    for i := yyleng downto n+1 do
+    for i := Length(yytext) downto n+1 do
       unget_char(yytext[i]);
       unget_char(yytext[i]);
-    yyleng := n;
+    SetLength(yytext,n);
   end(*yyless*);
   end(*yyless*);
 
 
 procedure reject;
 procedure reject;
   var i : Integer;
   var i : Integer;
   begin
   begin
     yyreject := true;
     yyreject := true;
-    for i := yyleng+1 to yysleng do
+    for i := Length(yytext)+1 to yysleng do
       yytext := yytext+get_char;
       yytext := yytext+get_char;
     dec(yymatches);
     dec(yymatches);
   end(*reject*);
   end(*reject*);
@@ -333,16 +331,14 @@ procedure yynew;
 
 
 procedure yyscan;
 procedure yyscan;
   begin
   begin
-    if yyleng=255 then fatal('yytext overflow');
     yyactchar := get_char;
     yyactchar := get_char;
-    inc(yyleng);
-    yytext[yyleng] := yyactchar;
+    yytext:=yytext+yyactchar;
   end(*yyscan*);
   end(*yyscan*);
 
 
 procedure yymark ( n : Integer );
 procedure yymark ( n : Integer );
   begin
   begin
     if n>max_rules then fatal('too many rules');
     if n>max_rules then fatal('too many rules');
-    yypos[n] := yyleng;
+    yypos[n] := Length(yytext);
   end(*yymark*);
   end(*yymark*);
 
 
 procedure yymatch ( n : Integer );
 procedure yymatch ( n : Integer );
@@ -359,12 +355,12 @@ function yyfind ( var n : Integer ) : Boolean;
       dec(yymatches);
       dec(yymatches);
     if yymatches>0 then
     if yymatches>0 then
       begin
       begin
-        yysleng := yyleng;
+        yysleng := Length(yytext);
         n       := yystack[yymatches];
         n       := yystack[yymatches];
         yyless(yypos[n]);
         yyless(yypos[n]);
         yypos[n] := 0;
         yypos[n] := 0;
-        if yyleng>0 then
-          yylastchar := yytext[yyleng]
+        if Length(yytext)>0 then
+          yylastchar := yytext[Length(yytext)]
         else
         else
           yylastchar := #0;
           yylastchar := #0;
         yyfind := true;
         yyfind := true;

+ 3 - 1
utils/h2pas/h2poptions.pas

@@ -16,7 +16,9 @@
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
 
  ****************************************************************************}
  ****************************************************************************}
+
 unit h2poptions;
 unit h2poptions;
+{$H+}
 interface
 interface
 
 
 const
 const
@@ -138,7 +140,7 @@ end;
 
 
 Procedure ProcessOptions;
 Procedure ProcessOptions;
 Var
 Var
-  cp : string;
+  cp : string[255];   {because of cp[3] indexing}
   I : longint;
   I : longint;
 
 
   Function GetNextParam (const Opt,Name : String) : string;
   Function GetNextParam (const Opt,Name : String) : string;

+ 1 - 1
utils/h2pas/h2pyacclib.pas

@@ -34,7 +34,7 @@ $History: YACCLIB.PAS $
 
 
 
 
 {$I-}
 {$I-}
-
+{$H+}
 unit h2pYaccLib;
 unit h2pYaccLib;
 
 
 (* Yacc Library Unit for TP Yacc Version 3.0, 6-17-91 AG *)
 (* Yacc Library Unit for TP Yacc Version 3.0, 6-17-91 AG *)

+ 1 - 0
utils/h2pas/scan.l

@@ -20,6 +20,7 @@
 
 
 
 
 unit scan;
 unit scan;
+{$H+}
 
 
   interface
   interface
 
 

+ 1 - 0
utils/h2pas/scan.pas

@@ -23,6 +23,7 @@
 
 
 
 
 unit scan;
 unit scan;
+{$H+}
 
 
   interface
   interface