[PATCH] makedocbook: Fix false report of unhandled texinfo command

Mike Frysinger vapier@gentoo.org
Mon Oct 31 12:28:13 GMT 2022


On 31 Oct 2022 09:59, Jon Turney wrote:

i guess the feedback below isn't exactly about new code even if it's relevant ...

> +    # fail if there are unhandled texinfo commands
> +    match = re.search('(?<!@)@[^@\s]+', s)

regexes should use raw strings (i.e., this is missing the r prefix)

> +    if match:
> +        print("texinfo command '%s' remains in output" % match.group(), file=sys.stderr)

this is a little dangerous in general as match.group() could return a tuple,
and this would fail.  if you want to use %, you should force a tuple.
  print("..." % (match.group(),), ...)

> +        exit(1)

scripts should never use exit(), only sys.exit().  although i see the current
script gets this wrong in a lot of places.

also you can simplify this -- sys.exit accepts a string that it'll print to
stderr and then exit non-zero.
  sys.exit(".....")
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/newlib/attachments/20221031/e545b398/attachment.sig>


More information about the Newlib mailing list