bc: Fix comment parsing - sbase - suckless unix tools
 (HTM) git clone git://git.suckless.org/sbase
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit bda3c885596c445a3f181c3935eabd953b455486
 (DIR) parent 4e3d54e231f17d851ee58031d8e2becf75b81302
 (HTM) Author: Roberto E. Vargas Caballero <k0ga@shike2.net>
       Date:   Sun, 23 Nov 2025 12:31:30 +0100
       
       bc: Fix comment parsing
       
       The function comment was misparsing comments, because it ate always
       the character after a *, invalidating sequences like **/. Also, as it
       didn't count new line characters error messages were misleading.
       
       Diffstat:
         M bc.y                                |      15 +++++++++++----
       
       1 file changed, 11 insertions(+), 4 deletions(-)
       ---
 (DIR) diff --git a/bc.y b/bc.y
       @@ -587,10 +587,17 @@ operand(int ch)
        static void
        comment(void)
        {
       -        do {
       -                while (getchar() != '*')
       -                        ;
       -        } while (getchar() != '/');
       +        int c;
       +
       +        for (;;) {
       +                while ((c = getchar()) != '*') {
       +                        if (c == '\n')
       +                                lineno++;
       +                }
       +                if ((c = getchar()) == '/')
       +                        break;
       +                ungetc(c, stdin);
       +        }
        }
        
        static int