diff options
author | Gerald Combs <gerald@wireshark.org> | 2022-06-23 13:09:30 -0700 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2022-06-24 18:32:50 +0000 |
commit | d3e2f1053bebd9550b1c4befe83c540a4a349796 (patch) | |
tree | 9783e64e3c9611e949f861fd90c919a345e500fd /doc | |
parent | 602e87d6c5e251a2fb758bb10dea9aa75b08cc34 (diff) |
Doc: Port make-authors-short to Python3.
Port the script that creates AUTHORS-SHORT to Python3.
Ping #18152.
Diffstat (limited to 'doc')
-rw-r--r-- | doc/CMakeLists.txt | 6 | ||||
-rwxr-xr-x | doc/make-authors-short.pl | 39 | ||||
-rwxr-xr-x | doc/make-authors-short.py | 49 |
3 files changed, 52 insertions, 42 deletions
diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index 156ef650a8..0626c24dcb 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -11,12 +11,12 @@ find_package( Asciidoctor 1.5 ) add_custom_command( OUTPUT AUTHORS-SHORT - COMMAND ${PERL_EXECUTABLE} - ${CMAKE_CURRENT_SOURCE_DIR}/make-authors-short.pl + COMMAND ${PYTHON_EXECUTABLE} + ${CMAKE_CURRENT_SOURCE_DIR}/make-authors-short.py < ${CMAKE_SOURCE_DIR}/AUTHORS > ${CMAKE_CURRENT_BINARY_DIR}/AUTHORS-SHORT DEPENDS - ${CMAKE_CURRENT_SOURCE_DIR}/make-authors-short.pl + ${CMAKE_CURRENT_SOURCE_DIR}/make-authors-short.py ${CMAKE_SOURCE_DIR}/AUTHORS ) diff --git a/doc/make-authors-short.pl b/doc/make-authors-short.pl deleted file mode 100755 index 1b8286e904..0000000000 --- a/doc/make-authors-short.pl +++ /dev/null @@ -1,39 +0,0 @@ -# Remove tasks from individual author entries from AUTHORS file -# for use in the about dialog. -# -# Copyright 2004 Ulf Lamping <ulf.lamping@web.de> -# -# Wireshark - Network traffic analyzer -# By Gerald Combs <gerald@wireshark.org> -# Copyright 1998 Gerald Combs -# -# SPDX-License-Identifier: GPL-2.0-or-later -# - -use strict; -use open qw(:std :utf8); - -my $subinfo=0; -my $nextline; - -$_ = <>; -s/\xef\xbb\xbf//; # Skip UTF-8 byte order mark -print unless /^\n/; - -while (<>) { - if (/(.*?)\s*\{/) { - $subinfo = 1; - print "$1\n"; - } elsif (/\}/) { - $subinfo = 0; - if (($nextline = <>) !~ /^[\s]*$/) { - print STDERR "No blank line after '}', found: $nextline" - if $nextline =~ m/\{/; - print $nextline; - } - } elsif ($subinfo == 1) { - next; - } else { - print; - } -} diff --git a/doc/make-authors-short.py b/doc/make-authors-short.py new file mode 100755 index 0000000000..08b56e98d3 --- /dev/null +++ b/doc/make-authors-short.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python3 +# +# Generate the AUTHORS-SHORT file. +# Ported from make-authors-short.pl, copyright 2004 Ulf Lamping <ulf.lamping@web.de> +# +# By Gerald Combs <gerald@wireshark.org +# +# SPDX-License-Identifier: GPL-2.0-or-later +# +'''\ +Remove tasks from individual author entries from the AUTHORS file +for use in the "About" dialog. +''' + +import io +import re +import sys + +def main(): + stdinu8 = io.TextIOWrapper(sys.stdin.buffer, encoding='utf8') + stdoutu8 = io.TextIOWrapper(sys.stdout.buffer, encoding='utf8') + stderru8 = io.TextIOWrapper(sys.stderr.buffer, encoding='utf8') + in_subinfo = False + + # Assume the first line is blank and skip it. make-authors-short.pl + # skipped over the UTF-8 BOM as well. Do we need to do that here? + + stdinu8.readline() + + for line in stdinu8: + + sub_m = re.search(r'(.*?)\s*\{', line) + if sub_m: + in_subinfo = True + stdoutu8.write(sub_m.group(1) + '\n') + elif '}' in line: + in_subinfo = False + nextline = next(stdinu8) + if not re.match('^\s*$', nextline): + if '{' in nextline: + stderru8.write("No blank line after '}', found " + nextline) + stdoutu8.write(nextline) + elif in_subinfo: + continue + else: + stdoutu8.write(line) + +if __name__ == '__main__': + main() |