Files
amxmodx
compiler
configs
editor
gamedata
installer
modules
plugins
public
support
third_party
tools
docgen
pcre
cmake
doc
m4
sljit
testdata
132html
AUTHORS
CMakeLists.txt
COPYING
ChangeLog
CheckMan
CleanTxt
Detrail
HACKING
INSTALL
LICENCE
Makefile.am
Makefile.in
NEWS
NON-AUTOTOOLS-BUILD
NON-UNIX-USE
PrepareRelease
README
RunGrepTest
RunTest
RunTest.bat
aclocal.m4
ar-lib
compile
config-cmake.h.in
config.guess
config.h.generic
config.h.in
config.sub
configure
configure.ac
depcomp
dftables.c
install-sh
libpcre.pc.in
libpcre16.pc.in
libpcre32.pc.in
libpcrecpp.pc.in
libpcreposix.pc.in
ltmain.sh
makevp.bat
makevp_c.txt
makevp_l.txt
missing
pcre-config.in
pcre.h.generic
pcre.h.in
pcre16_byte_order.c
pcre16_chartables.c
pcre16_compile.c
pcre16_config.c
pcre16_dfa_exec.c
pcre16_exec.c
pcre16_fullinfo.c
pcre16_get.c
pcre16_globals.c
pcre16_jit_compile.c
pcre16_maketables.c
pcre16_newline.c
pcre16_ord2utf16.c
pcre16_printint.c
pcre16_refcount.c
pcre16_string_utils.c
pcre16_study.c
pcre16_tables.c
pcre16_ucd.c
pcre16_utf16_utils.c
pcre16_valid_utf16.c
pcre16_version.c
pcre16_xclass.c
pcre32_byte_order.c
pcre32_chartables.c
pcre32_compile.c
pcre32_config.c
pcre32_dfa_exec.c
pcre32_exec.c
pcre32_fullinfo.c
pcre32_get.c
pcre32_globals.c
pcre32_jit_compile.c
pcre32_maketables.c
pcre32_newline.c
pcre32_ord2utf32.c
pcre32_printint.c
pcre32_refcount.c
pcre32_string_utils.c
pcre32_study.c
pcre32_tables.c
pcre32_ucd.c
pcre32_utf32_utils.c
pcre32_valid_utf32.c
pcre32_version.c
pcre32_xclass.c
pcre_byte_order.c
pcre_chartables.c.dist
pcre_compile.c
pcre_config.c
pcre_dfa_exec.c
pcre_exec.c
pcre_fullinfo.c
pcre_get.c
pcre_globals.c
pcre_internal.h
pcre_jit_compile.c
pcre_jit_test.c
pcre_maketables.c
pcre_newline.c
pcre_ord2utf8.c
pcre_printint.c
pcre_refcount.c
pcre_scanner.cc
pcre_scanner.h
pcre_scanner_unittest.cc
pcre_string_utils.c
pcre_stringpiece.cc
pcre_stringpiece.h.in
pcre_stringpiece_unittest.cc
pcre_study.c
pcre_tables.c
pcre_ucd.c
pcre_valid_utf8.c
pcre_version.c
pcre_xclass.c
pcrecpp.cc
pcrecpp.h
pcrecpp_internal.h
pcrecpp_unittest.cc
pcrecpparg.h.in
pcredemo.c
pcregexp.pas
pcregrep.c
pcreposix.c
pcreposix.h
pcretest.c
perltest.pl
test-driver
ucp.h
.gitattributes
.gitignore
.gitmodules
.travis.yml
AMBuildScript
README.md
appveyor.yml
configure.py
product.version
pushbuild.txt
amxmodx/tools/pcre/CleanTxt
2014-07-05 00:28:24 +02:00

114 lines
2.9 KiB
Perl

#! /usr/bin/perl -w
# Script to take the output of nroff -man and remove all the backspacing and
# the page footers and the screen commands etc so that it is more usefully
# readable online. In fact, in the latest nroff, intermediate footers don't
# seem to be generated any more.
$blankcount = 0;
$lastwascut = 0;
$firstheader = 1;
# Input on STDIN; output to STDOUT.
while (<STDIN>)
{
s/\x1b\[\d+m//g; # Remove screen controls "ESC [ number m"
s/.\x8//g; # Remove "char, backspace"
# Handle header lines. Retain only the first one we encounter, but remove
# the blank line that follows. Any others (e.g. at end of document) and the
# following blank line are dropped.
if (/^PCRE(\w*)\(([13])\)\s+PCRE\1\(\2\)$/)
{
if ($firstheader)
{
$firstheader = 0;
print;
$lastprinted = $_;
$lastwascut = 0;
}
$_=<STDIN>; # Remove a blank that follows
next;
}
# Count runs of empty lines
if (/^\s*$/)
{
$blankcount++;
$lastwascut = 0;
next;
}
# If a chunk of lines has been cut out (page footer) and the next line
# has a different indentation, put back one blank line.
if ($lastwascut && $blankcount < 1 && defined($lastprinted))
{
($a) = $lastprinted =~ /^(\s*)/;
($b) = $_ =~ /^(\s*)/;
$blankcount++ if ($a ne $b);
}
# We get here only when we have a non-blank line in hand. If it was preceded
# by 3 or more blank lines, read the next 3 lines and see if they are blank.
# If so, remove all 7 lines, and remember that we have just done a cut.
if ($blankcount >= 3)
{
for ($i = 0; $i < 3; $i++)
{
$next[$i] = <STDIN>;
$next[$i] = "" if !defined $next[$i];
$next[$i] =~ s/\x1b\[\d+m//g; # Remove screen controls "ESC [ number m"
$next[$i] =~ s/.\x8//g; # Remove "char, backspace"
}
# Cut out chunks of the form <3 blanks><non-blank><3 blanks>
if ($next[0] =~ /^\s*$/ &&
$next[1] =~ /^\s*$/ &&
$next[2] =~ /^\s*$/)
{
$blankcount -= 3;
$lastwascut = 1;
}
# Otherwise output the saved blanks, the current, and the next three
# lines. Remember the last printed line.
else
{
for ($i = 0; $i < $blankcount; $i++) { print "\n"; }
print;
for ($i = 0; $i < 3; $i++)
{
$next[$i] =~ s/.\x8//g;
print $next[$i];
$lastprinted = $_;
}
$lastwascut = 0;
$blankcount = 0;
}
}
# This non-blank line is not preceded by 3 or more blank lines. Output
# any blanks there are, and the line. Remember it. Force two blank lines
# before headings.
else
{
$blankcount = 2 if /^\S/ && !/^Last updated/ && !/^Copyright/ &&
defined($lastprinted);
for ($i = 0; $i < $blankcount; $i++) { print "\n"; }
print;
$lastprinted = $_;
$lastwascut = 0;
$blankcount = 0;
}
}
# End