OK.
Thanks.

> The scanner builds a list of lines from the source code.  Then it
> iterates over the list concatenating the lines that end with
> backslashes with the following line.
>
> Instead of iterating over all lines skip a backslash if it preceeds a
> newline.
>
> gcc/algol68/ChangeLog:
>
>         * a68-parser-scanner.cc (concatenate_lines): Delete.
>         (read_source_file): Stop calling concatenate_lines.
>         (next_char): Skip backslash at the end of lines.
>         (include_files): Stop calling concatenate_lines.
>
> gcc/testsuite/ChangeLog:
>
>         * algol68/compile/backslash-1.a68: New test.
>
> Signed-off-by: Pietro Monteiro <[email protected]>
> ---
>  gcc/algol68/a68-parser-scanner.cc             | 43 +++----------------
>  gcc/testsuite/algol68/execute/backslash-1.a68 |  6 +++
>  2 files changed, 13 insertions(+), 36 deletions(-)
>  create mode 100644 gcc/testsuite/algol68/execute/backslash-1.a68
>
> diff --git a/gcc/algol68/a68-parser-scanner.cc 
> b/gcc/algol68/a68-parser-scanner.cc
> index 30c23996dcd..5ddf25894a2 100644
> --- a/gcc/algol68/a68-parser-scanner.cc
> +++ b/gcc/algol68/a68-parser-scanner.cc
> @@ -285,38 +285,6 @@ unworthy (LINE_T *u, char *v, char ch)
>    a68_scan_error (u, v, A68 (edit_line));
>  }
>  
> -/* Concatenate lines that terminate in '\' with next line.  */
> -
> -static void
> -concatenate_lines (LINE_T * top)
> -{
> -  LINE_T *q;
> -  /* Work from bottom backwards.  */
> -  for (q = top; q != NO_LINE && NEXT (q) != NO_LINE; FORWARD (q))
> -    ;
> -
> -  for (; q != NO_LINE; BACKWARD (q))
> -    {
> -      char *z = STRING (q);
> -      size_t len = strlen (z);
> -
> -      if (len >= 2
> -       && z[len - 2] == BACKSLASH_CHAR
> -       && z[len - 1] == NEWLINE_CHAR
> -       && NEXT (q) != NO_LINE
> -       && STRING (NEXT (q)) != NO_TEXT)
> -     {
> -       z[len - 2] = '\0';
> -       len += (int) strlen (STRING (NEXT (q)));
> -       z = (char *) xmalloc (len + 1);
> -       a68_bufcpy (z, STRING (q), len + 1);
> -       a68_bufcat (z, STRING (NEXT (q)), len + 1);
> -       STRING (NEXT (q))[0] = '\0';
> -       STRING (q) = z;
> -     }
> -    }
> -}
> -
>  /* Read source file FILENAME and make internal copy.  */
>  
>  static bool
> @@ -400,9 +368,6 @@ read_source_file (const char *filename)
>                 ? upper_postlude : supper_postlude,
>                 &ref_l, &line_num, "postlude");
>  
> -  /* Concatenate lines that end with \.  */
> -  concatenate_lines (TOP_LINE (&A68_JOB));
> -
>    /* Include files.  */
>    include_files (TOP_LINE (&A68_JOB));
>  
> @@ -439,6 +404,13 @@ next_char (LINE_T **ref_l, char **ref_s, bool allow_typo,
>    else
>      (*ref_s)++;
>  
> +  /* Skip backslash at the end of lines.  */
> +  if ((*ref_s)[0] == BACKSLASH_CHAR && (*ref_s)[1] == NEWLINE_CHAR)
> +    {
> +      (*ref_s)++;
> +      return next_char (ref_l, ref_s, allow_typo, allow_one_under, 
> found_under);
> +    }
> +
>    /* Deliver next char.  */
>    ch = (*ref_s)[0];
>    if ((allow_typo && (ISSPACE (ch) || ch == FORMFEED_CHAR))
> @@ -1133,7 +1105,6 @@ include_files (LINE_T *top)
>             /* Conclude and go find another include directive, if any.  */
>             NEXT (t) = s;
>             PREVIOUS (s) = t;
> -           concatenate_lines (top);
>             if (fclose (fp) != 0)
>               gcc_unreachable ();
>             make_pass = true;
> diff --git a/gcc/testsuite/algol68/execute/backslash-1.a68 
> b/gcc/testsuite/algol68/execute/backslash-1.a68
> new file mode 100644
> index 00000000000..120fc218890
> --- /dev/null
> +++ b/gcc/testsuite/algol68/execute/backslash-1.a68
> @@ -0,0 +1,6 @@
> +begin
> +    string foobar = "foo bar";
> +    string fubar = "foo \
> +bar";
> +    assert (foobar = fubar)
> +end

Reply via email to