Browse Source

* bugfix for multiline string constants

olle 21 years ago
parent
commit
ea51b18d9b
2 changed files with 83 additions and 73 deletions
  1. 7 3
      compiler/i386/ag386int.pas
  2. 76 70
      compiler/powerpc/agppcmpw.pas

+ 7 - 3
compiler/i386/ag386int.pas

@@ -503,7 +503,7 @@ implementation
                            begin
                            begin
                              AsmWrite(#9#9'DB'#9);
                              AsmWrite(#9#9'DB'#9);
                              quoted:=false;
                              quoted:=false;
-                             for i:=counter to counter+line_length do
+                             for i:=counter to counter+line_length-1 do
                                 begin
                                 begin
                                   { it is an ascii character. }
                                   { it is an ascii character. }
                                   if (ord(tai_string(hp).str[i])>31) and
                                   if (ord(tai_string(hp).str[i])>31) and
@@ -534,7 +534,8 @@ implementation
                              counter := counter+line_length;
                              counter := counter+line_length;
                           end; { end for j:=0 ... }
                           end; { end for j:=0 ... }
                         { do last line of lines }
                         { do last line of lines }
-                        AsmWrite(#9#9'DB'#9);
+                        if counter<tai_string(hp).len then
+                          AsmWrite(#9#9'DB'#9);
                         quoted:=false;
                         quoted:=false;
                         for i:=counter to tai_string(hp).len-1 do
                         for i:=counter to tai_string(hp).len-1 do
                           begin
                           begin
@@ -882,7 +883,10 @@ initialization
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.46  2004-02-27 10:21:05  florian
+  Revision 1.47  2004-03-17 12:03:00  olle
+    * bugfix for multiline string constants
+
+  Revision 1.46  2004/02/27 10:21:05  florian
     * top_symbol killed
     * top_symbol killed
     + refaddr to treference added
     + refaddr to treference added
     + refsymbol to treference added
     + refsymbol to treference added

+ 76 - 70
compiler/powerpc/agppcmpw.pas

@@ -933,84 +933,87 @@ var
               AsmWriteLn(#9'dc.d'#9'"'+double2str(tai_real_64bit(hp).value)+'"');
               AsmWriteLn(#9'dc.d'#9'"'+double2str(tai_real_64bit(hp).value)+'"');
             ait_string:
             ait_string:
               begin
               begin
-                 {NOTE When a single quote char is encountered, it is
-                 replaced with a numeric ascii value. It could also
-                 have been replaced with the escape seq of double quotes.
-                 Backslash seems to be used as an escape char, although
-                 this is not mentioned in the PPCAsm documentation.}
-                 counter := 0;
-                 lines := tai_string(hp).len div line_length;
-                 { separate lines in different parts }
-                 if tai_string(hp).len > 0 then
-                  Begin
+                {NOTE When a single quote char is encountered, it is
+                replaced with a numeric ascii value. It could also
+                have been replaced with the escape seq of double quotes.
+                Backslash seems to be used as an escape char, although
+                this is not mentioned in the PPCAsm documentation.}
+                counter := 0;
+                lines := tai_string(hp).len div line_length;
+                { separate lines in different parts }
+                if tai_string(hp).len > 0 then
+                  begin
                     for j := 0 to lines-1 do
                     for j := 0 to lines-1 do
-                     begin
-                       AsmWrite(#9'dc.b'#9);
-                       quoted:=false;
-                       for i:=counter to counter+line_length do
+                      begin
+                        AsmWrite(#9'dc.b'#9);
+                        quoted:=false;
+                        for i:=counter to counter+line_length-1 do
                           begin
                           begin
                             { it is an ascii character. }
                             { it is an ascii character. }
                             if (ord(tai_string(hp).str[i])>31) and
                             if (ord(tai_string(hp).str[i])>31) and
                                (ord(tai_string(hp).str[i])<128) and
                                (ord(tai_string(hp).str[i])<128) and
                                (tai_string(hp).str[i]<>'''') and
                                (tai_string(hp).str[i]<>'''') and
                                (tai_string(hp).str[i]<>'\') then
                                (tai_string(hp).str[i]<>'\') then
-                                begin
-                                  if not(quoted) then
-                                      begin
-                                        if i>counter then
-                                          AsmWrite(',');
-                                        AsmWrite('''');
-                                      end;
-                                  AsmWrite(tai_string(hp).str[i]);
-                                  quoted:=true;
-                                end { if > 31 and < 128 and ord('"') }
-                            else
-                                begin
-                                    if quoted then
-                                        AsmWrite('''');
-                                    if i>counter then
+                              begin
+                                if not(quoted) then
+                                    begin
+                                      if i>counter then
                                         AsmWrite(',');
                                         AsmWrite(',');
-                                    quoted:=false;
-                                    AsmWrite(tostr(ord(tai_string(hp).str[i])));
-                                end;
-                         end; { end for i:=0 to... }
-                       if quoted then AsmWrite('''');
-                       AsmWrite(target_info.newline);
-                       counter := counter+line_length;
-                    end; { end for j:=0 ... }
-                  { do last line of lines }
-                  AsmWrite(#9'dc.b'#9);
-                  quoted:=false;
-                  for i:=counter to tai_string(hp).len-1 do
-                    begin
-                      { it is an ascii character. }
-                      if (ord(tai_string(hp).str[i])>31) and
-                         (ord(tai_string(hp).str[i])<128) and
-                         (tai_string(hp).str[i]<>'''') and
-                         (tai_string(hp).str[i]<>'\') then                          begin
-                            if not(quoted) then
-                                begin
+                                      AsmWrite('''');
+                                    end;
+                                AsmWrite(tai_string(hp).str[i]);
+                                quoted:=true;
+                              end { if > 31 and < 128 and ord('"') }
+                            else
+                              begin
+                                  if quoted then
+                                      AsmWrite('''');
                                   if i>counter then
                                   if i>counter then
-                                    AsmWrite(',');
-                                  AsmWrite('''');
-                                end;
-                            AsmWrite(tai_string(hp).str[i]);
-                            quoted:=true;
-                          end { if > 31 and < 128 and " }
-                      else
-                          begin
-                            if quoted then
-                              AsmWrite('''');
-                            if i>counter then
-                                AsmWrite(',');
-                            quoted:=false;
-                            AsmWrite(tostr(ord(tai_string(hp).str[i])));
-                          end;
-                    end; { end for i:=0 to... }
-                  if quoted then
-                    AsmWrite('''');
-                  end;
-                 AsmLn;
+                                      AsmWrite(',');
+                                  quoted:=false;
+                                  AsmWrite(tostr(ord(tai_string(hp).str[i])));
+                              end;
+                          end; { end for i:=0 to... }
+                        if quoted then AsmWrite('''');
+                        AsmLn;
+                        counter := counter+line_length;
+                      end; { end for j:=0 ... }
+
+                  { do last line of lines }
+									if counter < tai_string(hp).len then
+										AsmWrite(#9'dc.b'#9);
+									quoted:=false;
+									for i:=counter to tai_string(hp).len-1 do
+										begin
+											{ it is an ascii character. }
+											if (ord(tai_string(hp).str[i])>31) and
+												 (ord(tai_string(hp).str[i])<128) and
+												 (tai_string(hp).str[i]<>'''') and
+												 (tai_string(hp).str[i]<>'\') then
+												begin
+													if not(quoted) then
+														begin
+															if i>counter then
+																AsmWrite(',');
+															AsmWrite('''');
+														end;
+													AsmWrite(tai_string(hp).str[i]);
+													quoted:=true;
+												end { if > 31 and < 128 and " }
+											else
+												begin
+													if quoted then
+														AsmWrite('''');
+													if i>counter then
+														AsmWrite(',');
+													quoted:=false;
+													AsmWrite(tostr(ord(tai_string(hp).str[i])));
+												end;
+										end; { end for i:=0 to... }
+									if quoted then
+										AsmWrite('''');
+                end;
+								AsmLn;
               end;
               end;
             ait_label:
             ait_label:
               begin
               begin
@@ -1359,7 +1362,10 @@ initialization
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.33  2004-03-02 00:57:01  olle
+  Revision 1.34  2004-03-17 12:03:31  olle
+    * bugfix for multiline string constants
+
+  Revision 1.33  2004/03/02 00:57:01  olle
     + adding missing log msg: misc fixes
     + adding missing log msg: misc fixes
 
 
   Revision 1.32  2004/03/02 00:36:33  olle
   Revision 1.32  2004/03/02 00:36:33  olle