On Sun, Nov 26, 2017 at 07:43:22PM +0000, kshe wrote:

> Hi,
> 
> This assignment is useless.
> 
> Index: bcode.c
> ===================================================================
> RCS file: /cvs/src/usr.bin/dc/bcode.c,v
> retrieving revision 1.51
> diff -u -p -r1.51 bcode.c
> --- bcode.c   26 Feb 2017 11:29:55 -0000      1.51
> +++ bcode.c   26 Oct 2017 04:44:01 -0000
> @@ -1630,7 +1611,7 @@ skip_until_mark(void)
>                       free(read_string(&bmachine.readstack[bmachine.readsp]));
>                       break;
>               case '!':
> -                     switch (ch = readch()) {
> +                     switch (readch()) {
>                               case '<':
>                               case '>':
>                               case '=':
> 
> The above diff does not cause any change in the optimised executable
> output, because such removal was obviously already performed by the
> compiler.

I just committed a diff that just eliminates the 'int ch' altogether.

        -Otto

> 
> Alternatively, while here, this function could be slightly shortened as
> follows.
> 
> Index: bcode.c
> ===================================================================
> RCS file: /cvs/src/usr.bin/dc/bcode.c,v
> retrieving revision 1.51
> diff -u -p -r1.51 bcode.c
> --- bcode.c   26 Feb 2017 11:29:55 -0000      1.51
> +++ bcode.c   17 Nov 2017 02:38:12 -0000
> @@ -1610,7 +1590,13 @@ skip_until_mark(void)
>                       return;
>               case EOF:
>                       errx(1, "mark not found");
> -                     return;
> +             case '!':
> +                     ch = readch();
> +                     if (ch != '<' && ch != '>' && ch != '=') {
> +                             free(readline());
> +                             break;
> +                     }
> +                     /* fall through */
>               case 'l':
>               case 'L':
>               case 's':
> @@ -1629,22 +1615,6 @@ skip_until_mark(void)
>               case '[':
>                       free(read_string(&bmachine.readstack[bmachine.readsp]));
>                       break;
> -             case '!':
> -                     switch (ch = readch()) {
> -                             case '<':
> -                             case '>':
> -                             case '=':
> -                                     (void)readreg();
> -                                     if (readch() == 'e')
> -                                             (void)readreg();
> -                                     else
> -                                             unreadch();
> -                                     break;
> -                             default:
> -                                     free(readline());
> -                                     break;
> -                     }
> -                     break;
>               default:
>                       break;
>               }
> 
> Regards,
> 
> kshe

Reply via email to