Unescaped left brace in regex

Create issue
Issue #2 resolved
Former user created an issue

With version 1.8 2018-03-25 (updated this morning on MikTeX, Win 10) I still get unescaped left braces with the -s option.

The call texdef -t latex -f section -s produces the error message

Unescaped left brace in regex is illegal here in regex; marked by <-- HERE in m/
        ^                                                        # Begin of line (no whitespaces!)
        (
        (?:(?:\\global|\\long|\\protected|\\outer)\s*)*       # Prefixes (maybe with whitespace between them)
        )
        \\(
              (?:[gex]?def) \s* \\                               # TeX definitions
            | (?:new|renew|provide)command\s* \*? \s* {? \s* \\  # LaTeX definitions
            | (?:new|renew|provide)robustcmd\s* \*? \s* {? \s* \\  # etoolbox definitions
            | (?:new(?:box|count|dimen|if|insert|read|skip|muskip|toks|write)) \s* \\ # TeX registers etc.
            | (?:char|count|dimen|mathchar|skip|toks)def \s* \\  # TeX chardefs etc.
            | \@namedef{ <-- HERE ?                                        # Definition by name only
            | Declare[a-zA-z]+ \s* \*? \s* {? \s* \\             # Declare... definitions
            | declare[a-zA-z]+ \s* \*? \s* {? \s* \\             # declare... definitions
        )
        section                                              # Macro name without backslash
        [^a-zA-Z@]
        / at C:\Program Files\MiKTeX 2.9\scripts\texdef\texdef.pl line 679, <$texpipe> line 13.

for me. texdef -t latex -f section works just fine.

I'm no Perl expert, but the code block sub print_orig_def still seems to contain several problematic braces.

Regarding sub remove_invalid_braces I think that braces within [] need not be escaped, but I'm not sure.

Comments (2)

  1. Martin Scharrer repo owner

    Ok, I fixed these regexes as well. The multi-line regexes were not found by my last search for braces in regexes. It was also difficult to trigger the warning as it doesn't pop up under my Linux Installation. I installed a virtual Win7 under VirtualBox with MikTeX 2.9 and ActiveState Perl 5.22.4.2205 and could test it now that the issue got fixed. Thanks for the report.

  2. Log in to comment