From 27fdc2f5b55fa1849d1b51fa866a4c2a4e83a3cd Mon Sep 17 00:00:00 2001 From: Kevin McCarthy Date: Tue, 24 Dec 2019 19:04:07 -0800 Subject: [PATCH] Convert makedoc.c to makedoc.pl. This removes the build-time dependency on a compiled program, which doesn't work for cross-compilation. My perl is pretty rusty, and the result isn't super pretty. However, since perl is already a build dependency, it made the most sense to use that. The output of Muttrc, muttrc.man, and manual.xml match. There might be a few bugs, so I'm going to leave makedoc.c in for now as a reference. Signed-off-by: Fabrice Fontaine [Retrieved from: https://gitlab.com/muttmua/mutt/commit/27fdc2f5b55fa1849d1b51fa866a4c2a4e83a3cd] --- doc/Makefile.am | 16 +- doc/devel-notes.txt | 2 +- doc/makedoc.pl | 952 ++++++++++++++++++++++++++++++++++++++++++++ init.h | 2 +- sort.h | 2 +- 5 files changed, 962 insertions(+), 12 deletions(-) create mode 100644 doc/makedoc.pl diff --git a/doc/Makefile.am b/doc/Makefile.am index 8f94a09b..1cb21b64 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -17,8 +17,6 @@ AM_CPPFLAGS = -I. -I.. -I$(includedir) -I$(top_srcdir) MAKEDOC_CPP = $(CPP) $(AM_CPPFLAGS) $(DEFS) $(CPPFLAGS) -D_MAKEDOC -C -noinst_PROGRAMS = makedoc - EXTRA_DIST = dotlock.man \ smime_keys.man \ mutt.man \ @@ -38,7 +36,7 @@ EXTRA_DIST = dotlock.man \ patch-notes.txt \ smime-notes.txt \ Muttrc Muttrc.head stamp-doc-rc \ - makedoc.c makedoc-defs.h \ + makedoc.pl makedoc-defs.h \ mutt.css mutt.xsl html.xsl chunk.xsl $(BUILT_DISTFILES) CHUNKED_DOCFILES = index.html intro.html gettingstarted.html \ @@ -136,11 +134,11 @@ manual.txt: manual.html Muttrc: stamp-doc-rc -stamp-doc-rc: $(top_srcdir)/init.h makedoc$(EXEEXT) $(srcdir)/Muttrc.head +stamp-doc-rc: $(top_srcdir)/init.h makedoc.pl $(srcdir)/Muttrc.head -rm -f Muttrc stamp-doc-rc sed -e 's,[@]docdir[@],$(docdir),' $(srcdir)/Muttrc.head > Muttrc $(CPP) $(AM_CPPFLAGS) $(DEFS) $(CPPFLAGS) -D_MAKEDOC -C \ - $(top_srcdir)/init.h | ./makedoc$(EXEEXT) -c >> Muttrc + $(top_srcdir)/init.h | perl $(srcdir)/makedoc.pl -c >> Muttrc touch stamp-doc-rc manual.html: $(srcdir)/html.xsl $(srcdir)/mutt.xsl stamp-doc-xml $(srcdir)/mutt.css @@ -211,8 +209,8 @@ instdoc: instdoc.sh update-doc: stamp-doc-rc $(BUILD_DOC_TARGETS) -muttrc.man: makedoc$(EXEEXT) $(top_srcdir)/init.h muttrc.man.head muttrc.man.tail - $(MAKEDOC_CPP) $(top_srcdir)/init.h | ./makedoc$(EXEEXT) -m | \ +muttrc.man: makedoc.pl $(top_srcdir)/init.h muttrc.man.head muttrc.man.tail + $(MAKEDOC_CPP) $(top_srcdir)/init.h | perl $(srcdir)/makedoc.pl -m | \ cat $(srcdir)/muttrc.man.head - $(srcdir)/muttrc.man.tail\ > muttrc.man @@ -232,13 +230,13 @@ mutt_pgpring.1: $(srcdir)/pgpring.man smime_keys.1: $(srcdir)/smime_keys.man $(EDIT) $(srcdir)/smime_keys.man > $@ -stamp-doc-xml: makedoc$(EXEEXT) $(top_srcdir)/init.h \ +stamp-doc-xml: makedoc.pl $(top_srcdir)/init.h \ manual.xml.head $(top_srcdir)/functions.h $(top_srcdir)/OPS* manual.xml.tail \ $(srcdir)/gen-map-doc $(top_srcdir)/VERSION $(top_srcdir)/ChangeLog ( date=`(cd $(top_srcdir) && ./mkreldate.sh)` && \ version=`(cd $(top_srcdir) && env sh ./version.sh)` && \ sed -e "s/@VERSION\@/$$version ($$date)/" $(srcdir)/manual.xml.head && \ - $(MAKEDOC_CPP) $(top_srcdir)/init.h | ./makedoc$(EXEEXT) -s && \ + $(MAKEDOC_CPP) $(top_srcdir)/init.h | perl $(srcdir)/makedoc.pl -s && \ $(MAKEDOC_CPP) $(top_srcdir)/functions.h | \ perl $(srcdir)/gen-map-doc $(srcdir)/manual.xml.tail $(top_srcdir)/OPS* \ ) > manual.xml diff --git a/doc/devel-notes.txt b/doc/devel-notes.txt index 99bc0fa0..bde077ab 100644 --- a/doc/devel-notes.txt +++ b/doc/devel-notes.txt @@ -225,7 +225,7 @@ these variables, and the global Muttrc, are generated automatically from that documentation. To start this process, type "make update-doc" in the top-level source directory. -Note that you may have to update the makedoc utility (makedoc.c) +Note that you may have to update the makedoc utility (makedoc.pl) when adding new data types to init.h. More precisely, variable name, type, and default value are directly diff --git a/doc/makedoc.pl b/doc/makedoc.pl new file mode 100644 index 00000000..e64d3c50 --- /dev/null +++ b/doc/makedoc.pl @@ -0,0 +1,952 @@ +#! /usr/bin/perl -w +# +# Copyright (C) 1999-2000 Thomas Roessler +# Copyright (C) 2019 Kevin J. McCarthy +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +# This program was translated from the C version (makedoc.c). +# So it looks like "c'ish perl" because it is, plus my perl is rusty ;-) + + +# Documentation line parser notes: +# +# The format is very remotely inspired by nroff. Most important, it's +# easy to parse and convert, and it was easy to generate from the SGML +# source of mutt's original manual. +# +# - \fI switches to italics +# - \fB switches to boldface +# - \fC swtiches to a literal string +# - \fP switches to normal display +# - .dl on a line starts a definition list (name taken taken from HTML). +# - .dt starts a term in a definition list. +# - .dd starts a definition in a definition list. +# - .de on a line finishes a definition list. +# - .il on a line starts an itemized list +# - .dd starts an item in an itemized list +# - .ie on a line finishes an itemized list +# - .ts on a line starts a "tscreen" environment (name taken from SGML). +# - .te on a line finishes this environment. +# - .pp on a line starts a paragraph. +# - \$word will be converted to a reference to word, where appropriate. +# Note that \$$word is possible as well. +# - '. ' in the beginning of a line expands to two space characters. +# This is used to protect indentations in tables. +# + +use strict; +use warnings; +use Getopt::Std; + +# Output formats +my $F_CONF = 1; +my $F_MAN = 2; +my $F_SGML = 3; + +my $OutputFormat; + +# docstatus flags, used by print_it() +my $D_INIT = (1 << 0); # init +my $D_NL = (1 << 1); # (usually) on a new line +my $D_NP = (1 << 2); # new paragraph ".pp" +my $D_PA = (1 << 3); # inside paragraph ".pp" + +my $D_EM = (1 << 4); # emphasis "\fI" .. "\fP" +my $D_BF = (1 << 5); # boldface "\fB" .. "\fP" +my $D_TT = (1 << 6); # literal string "\fC" .. "\fP" + +my $D_TAB = (1 << 7); # "tscreen" screen shot ".ts" .. ".te" +my $D_DL = (1 << 8); # start defn list ".dl" .. ".de" +my $D_DT = (1 << 9); # dlist term ".dt" +my $D_DD = (1 << 10); # dlist defn ".dd" +my $D_IL = (1 << 11); # itemized list ".il" .. ".ie" + +# Commands sent to print_it() in response to various input strings +my $SP_START_EM = 1; +my $SP_START_BF = 2; +my $SP_START_TT = 3; +my $SP_END_FT = 4; +my $SP_NEWLINE = 5; +my $SP_NEWPAR = 6; +my $SP_END_PAR = 7; +my $SP_STR = 8; +my $SP_START_TAB = 9; +my $SP_END_TAB = 10; +my $SP_START_DL = 11; +my $SP_DT = 12; +my $SP_DD = 13; +my $SP_END_DD = 14; +my $SP_END_DL = 15; +my $SP_START_IL = 16; +my $SP_END_IL = 17; +my $SP_END_SECT = 18; +my $SP_REFER = 19; + +# Types to documentation readable strings: +my %type2human = ("DT_NONE" => "-none-", + "DT_BOOL" => "boolean", + "DT_NUM" => "number", + "DT_LNUM" => "number (long)", + "DT_STR" => "string", + "DT_PATH" => "path", + "DT_QUAD" => "quadoption", + "DT_SORT" => "sort order", + "DT_RX" => "regular expression", + "DT_MAGIC" => "folder magic", + "DT_ADDR" => "e-mail address", + "DT_MBCHARTBL"=> "string"); + +my %string_types = ("DT_STR" => 1, + "DT_RX" => 1, + "DT_ADDR" => 1, + "DT_PATH" => 1, + "DT_MBCHARTBL" => 1); + +my %quad2human = ("MUTT_YES" => "yes", + "MUTT_NO" => "no", + "MUTT_ASKYES" => "ask-yes", + "MUTT_ASKNO" => "ask-no"); + +my %bool2human = ("1" => "yes", + "0" => "no"); + + +# prototypes +# to update: +# M-1 M-! grep '^sub' makedoc.pl +sub makedoc(); +sub flush_doc($); +sub handle_confline($); +sub pretty_default($$); +sub string_unescape($); +sub string_escape($); +sub print_confline($$$); +sub print_confline_conf($$$); +sub print_conf_strval($); +sub print_confline_man($$$); +sub man_string_escape($); +sub print_man_strval($); +sub print_confline_sgml($$$); +sub print_sgml_id($); +sub print_sgml($); +sub print_sgml_strval($); +sub handle_docline($$); +sub commit_buff($$); +sub print_docline($$$); +sub print_ref($$); +sub print_docline_conf($$$$); +sub print_docline_man($$$$); +sub print_docline_sgml($$$$); + + +our($opt_c, $opt_m, $opt_s); +getopts('cms'); +if ($opt_c) { + $OutputFormat = $F_CONF; +} +elsif ($opt_m) { + $OutputFormat = $F_MAN; +} +elsif ($opt_s) { + $OutputFormat = $F_SGML; +} +else { + die "$0: no output format specified" +} + +makedoc(); + + +sub makedoc() { + my $line; + my $lineno = 0; + my $active = 0; + my $docstat = $D_INIT; + + while ($line = ) { + chomp($line); + $line =~ s/^\s+//; + if ($line eq '/*++*/') { + $active = 1; + } + elsif ($line eq '/*--*/') { + $docstat = flush_doc($docstat); + $active = 0; + } + elsif ($active) { + if (($line =~ /^\/\*\*/) || ($line =~ /^\*\*/)) { + $line =~ s/^[\/*]+\s*//; + $docstat = handle_docline($line, $docstat); + } + elsif ($line =~ /^{/) { + $line =~ s/^{\s*//; + $docstat = flush_doc($docstat); + handle_confline($line); + } + } + } + flush_doc($docstat); + print("\n"); +} + +sub flush_doc($) { + my ($docstat) = @_; + + if ($docstat & $D_INIT) { + return $D_INIT; + } + + if ($docstat & ($D_PA)) { + $docstat = print_docline($SP_END_PAR, undef, $docstat); + } + + if ($docstat & ($D_TAB)) { + $docstat = print_docline($SP_END_TAB, undef, $docstat); + } + + if ($docstat & ($D_DL)) { + $docstat = print_docline($SP_END_DL, undef, $docstat); + } + + if ($docstat & ($D_EM | $D_BF | $D_TT)) { + $docstat = print_docline($SP_END_FT, undef, $docstat); + } + + $docstat = print_docline($SP_END_SECT, undef, $docstat); + + $docstat = print_docline($SP_NEWLINE, undef, 0); + + return $D_INIT; +} + +#################### +# Confline handling +#################### + +sub handle_confline($) { + my ($line) = @_; + + my ($name, $type, $flags, $data, $val) = split(/\s*,\s*/, $line, 5); + $name =~ s/"//g; + + $type =~ s/\|.*//; + + $val =~ s/^{\s*\.[lp]\s*=\s*"?//; + $val =~ s/"?\s*}\s*},\s*$//; + # This is a hack to concatenate compile-time constants. + # (?\n"; + print_sgml($name); + print "\nType: ${type2human{$type}}"; + + if (exists $string_types{$type}) { + if ($val ne "") { + print "\nDefault: "; + print_sgml_strval($val); + print ""; + } + else { + print "\nDefault: (empty)"; + } + } + else { + print "\nDefault: ${val}" + } + + print "\n"; +} + +sub print_sgml_id($) { + my ($id) = @_; + + $id =~ s/^$//; + $id =~ s/_/-/g; + + print $id; +} + +sub print_sgml($) { + my ($val) = @_; + + $val =~ s/&/&/g; + $val =~ s//>/g; + + print $val; +} + +sub print_sgml_strval($) { + my ($val) = @_; + + $val = string_escape($val); + print_sgml($val); +} + + +################### +# Docline handling +################### + +sub handle_docline($$) { + my ($line, $docstat) = @_; + my $buff = ""; + + if ($line =~ /^\.pp/) { + return print_docline($SP_NEWPAR, undef, $docstat); + } + elsif ($line =~ /^\.ts/) { + return print_docline($SP_START_TAB, undef, $docstat); + } + elsif ($line =~ /^\.te/) { + return print_docline($SP_END_TAB, undef, $docstat); + } + elsif ($line =~ /^\.dl/) { + return print_docline($SP_START_DL, undef, $docstat); + } + elsif ($line =~ /^\.de/) { + return print_docline($SP_END_DL, undef, $docstat); + } + elsif ($line =~ /^\.il/) { + return print_docline($SP_START_IL, undef, $docstat); + } + elsif ($line =~ /^\.ie/) { + return print_docline($SP_END_IL, undef, $docstat); + } + + $line =~ s/^\. / /; + + while ($line ne "") { + if ($line =~ /^\\\(as/) { + $buff .= "*"; + substr($line, 0, 4) = ""; + } + elsif ($line =~ /^\\\(rs/) { + $buff .= "\\"; + substr($line, 0, 4) = ""; + } + elsif ($line =~ /^\\fI/) { + $docstat = commit_buff(\$buff, $docstat); + $docstat = print_docline($SP_START_EM, undef, $docstat); + substr($line, 0, 3) = ""; + } + elsif ($line =~ /^\\fB/) { + $docstat = commit_buff(\$buff, $docstat); + $docstat = print_docline($SP_START_BF, undef, $docstat); + substr($line, 0, 3) = ""; + } + elsif ($line =~ /^\\fC/) { + $docstat = commit_buff(\$buff, $docstat); + $docstat = print_docline($SP_START_TT, undef, $docstat); + substr($line, 0, 3) = ""; + } + elsif ($line =~ /^\\fP/) { + $docstat = commit_buff(\$buff, $docstat); + $docstat = print_docline($SP_END_FT, undef, $docstat); + substr($line, 0, 3) = ""; + } + elsif ($line =~ /^\.dt/) { + if ($docstat & $D_DD) { + $docstat = commit_buff(\$buff, $docstat); + $docstat = print_docline($SP_END_DD, undef, $docstat); + } + $docstat = commit_buff(\$buff, $docstat); + $docstat = print_docline($SP_DT, undef, $docstat); + substr($line, 0, 4) = ""; + } + elsif ($line =~ /^\.dd/) { + if (($docstat & $D_IL) && ($docstat & $D_DD)) { + $docstat = commit_buff(\$buff, $docstat); + $docstat = print_docline($SP_END_DD, undef, $docstat); + } + $docstat = commit_buff(\$buff, $docstat); + $docstat = print_docline($SP_DD, undef, $docstat); + substr($line, 0, 4) = ""; + } + elsif ($line =~ /^\$\$\$/) { + print "\$"; + substr($line, 0, 3) = ""; + } + elsif ($line =~ /^(\$(\$?)([\w\-_<>]*))/) { + my $whole_ref; + my $ref; + my $output_dollar = 0; + + $whole_ref = $1; + if ($2) { + $output_dollar = 1; + } + $ref = $3; + + $docstat = commit_buff(\$buff, $docstat); + print_ref($output_dollar, $ref); + substr($line, 0, length($whole_ref)) = ""; + } + else { + $buff .= substr($line, 0, 1); + substr($line, 0, 1) = ""; + } + } + + $docstat = commit_buff(\$buff, $docstat); + return print_docline($SP_NEWLINE, undef, $docstat); +} + +sub commit_buff($$) { + my ($ref_buf, $docstat) = @_; + + if ($$ref_buf ne "") { + $docstat = print_docline($SP_STR, $$ref_buf, $docstat); + $$ref_buf = ""; + } + + return $docstat; +} + +sub print_docline($$$) { + my ($special, $str, $docstat) = @_; + my $onl; + + $onl = ($docstat & ($D_NL | $D_NP)); + $docstat &= ~($D_NL | $D_NP | $D_INIT); + + if ($OutputFormat == $F_CONF) { + return print_docline_conf($special, $str, $docstat, $onl); + } + elsif ($OutputFormat == $F_MAN) { + return print_docline_man($special, $str, $docstat, $onl); + } + elsif ($OutputFormat == $F_SGML) { + return print_docline_sgml($special, $str, $docstat, $onl); + } + + return $docstat; +} + +sub print_ref($$) { + my ($output_dollar, $ref) = @_; + + if (($OutputFormat == $F_CONF) || ($OutputFormat == $F_MAN)) { + if ($output_dollar) { + print "\$"; + } + print $ref; + } + elsif ($OutputFormat == $F_SGML) { + print ""; + if ($output_dollar) { + print "\$"; + } + print_sgml($ref); + print ""; + } +} + +my $Continuation = 0; + +sub print_docline_conf($$$$) { + my ($special, $str, $docstat, $onl) = @_; + + if ($special == $SP_END_FT) { + $docstat &= ~($D_EM|$D_BF|$D_TT); + } + elsif ($special == $SP_START_BF) { + $docstat |= $D_BF; + } + elsif ($special == $SP_START_EM) { + $docstat |= $D_EM; + } + elsif ($special == $SP_START_TT) { + $docstat |= $D_TT; + } + elsif ($special == $SP_NEWLINE) { + if ($onl) { + $docstat |= $onl; + } + else { + print "\n# "; + $docstat |= $D_NL; + } + if ($docstat & $D_DL) { + $Continuation++; + } + } + elsif ($special == $SP_NEWPAR) { + if ($onl & $D_NP) { + $docstat |= $onl; + } + else { + if (!($onl & $D_NL)) { + print "\n# "; + } + print "\n# "; + $docstat |= $D_NP; + } + } + elsif ($special == $SP_START_TAB) { + if (!$onl) { + print "\n# "; + } + $docstat |= $D_TAB; + } + elsif ($special == $SP_END_TAB) { + $docstat &= ~$D_TAB; + $docstat |= $D_NL; + } + elsif ($special == $SP_START_DL) { + $docstat |= $D_DL; + } + elsif ($special == $SP_DT) { + $Continuation = 0; + $docstat |= $D_DT; + } + elsif ($special == $SP_DD) { + if ($docstat & $D_IL) { + print "- "; + } + $Continuation = 0; + } + elsif ($special == $SP_END_DL) { + $Continuation = 0; + $docstat &= ~$D_DL; + } + elsif ($special == $SP_START_IL) { + $docstat |= $D_IL; + } + elsif ($special == $SP_END_IL) { + $Continuation = 0; + $docstat &= ~$D_IL; + } + elsif ($special == $SP_STR) { + if ($Continuation) { + $Continuation = 0; + print " "; + } + print $str; + if ($docstat & $D_DT) { + if (length($str) < 8) { + print " " x (8 - length($str)); + } + $docstat &= ~$D_DT; + $docstat |= $D_NL; + } + } + + return $docstat; +} + +sub print_docline_man($$$$) { + my ($special, $str, $docstat, $onl) = @_; + + if ($special == $SP_END_FT) { + print "\\fP"; + $docstat &= ~($D_EM|$D_BF|$D_TT); + } + elsif ($special == $SP_START_BF) { + print "\\fB"; + $docstat |= $D_BF; + $docstat &= ~($D_EM|$D_TT); + } + elsif ($special == $SP_START_EM) { + print "\\fI"; + $docstat |= $D_EM; + $docstat &= ~($D_BF|$D_TT); + } + elsif ($special == $SP_START_TT) { + print "\\fC"; + $docstat |= $D_TT; + $docstat &= ~($D_BF|$D_EM); + } + elsif ($special == $SP_NEWLINE) { + if ($onl) { + $docstat |= $onl; + } + else { + print "\n"; + $docstat |= $D_NL; + } + } + elsif ($special == $SP_NEWPAR) { + if ($onl & $D_NP) { + $docstat |= $onl; + } + else { + if (!($onl & $D_NL)) { + print "\n"; + } + print ".IP\n"; + $docstat |= $D_NP; + } + } + elsif ($special == $SP_START_TAB) { + print "\n.IP\n.EX\n"; + $docstat |= $D_TAB | $D_NL; + } + elsif ($special == $SP_END_TAB) { + print "\n.EE\n"; + $docstat &= ~$D_TAB; + $docstat |= $D_NL; + } + elsif ($special == $SP_START_DL) { + print ".RS\n.PD 0\n"; + $docstat |= $D_DL; + } + elsif ($special == $SP_DT) { + print ".TP\n"; + } + elsif ($special == $SP_DD) { + if ($docstat & $D_IL) { + print ".TP\n\\(hy "; + } + else { + print "\n"; + } + } + elsif ($special == $SP_END_DL) { + print ".RE\n.PD 1"; + $docstat &= ~$D_DL; + } + elsif ($special == $SP_START_IL) { + print ".RS\n.PD 0\n"; + $docstat |= $D_IL; + } + elsif ($special == $SP_END_IL) { + print ".RE\n.PD 1"; + $docstat &= ~$D_DL; + } + elsif ($special == $SP_STR) { + $str =~ s/\\/\\\\/g; + $str =~ s/"/\\(rq/g; + $str =~ s/-/\\-/g; + $str =~ s/``/\\(lq/g; + $str =~ s/''/\\(rq/g; + print $str; + } + + return $docstat; +} + +sub print_docline_sgml($$$$) { + my ($special, $str, $docstat, $onl) = @_; + + if ($special == $SP_END_FT) { + if ($docstat & $D_EM) { + print ""; + } + if ($docstat & $D_BF) { + print ""; + } + if ($docstat & $D_TT) { + print ""; + } + $docstat &= ~($D_EM|$D_BF|$D_TT); + } + elsif ($special == $SP_START_BF) { + print ""; + $docstat |= $D_BF; + $docstat &= ~($D_EM|$D_TT); + } + elsif ($special == $SP_START_EM) { + print ""; + $docstat |= $D_EM; + $docstat &= ~($D_BF|$D_TT); + } + elsif ($special == $SP_START_TT) { + print ""; + $docstat |= $D_TT; + $docstat &= ~($D_BF|$D_EM); + } + elsif ($special == $SP_NEWLINE) { + if ($onl) { + $docstat |= $onl; + } + else { + print "\n"; + $docstat |= $D_NL; + } + } + elsif ($special == $SP_NEWPAR) { + if ($onl & $D_NP) { + $docstat |= $onl; + } + else { + if (!($onl & $D_NL)) { + print "\n"; + } + if ($docstat & $D_PA) { + print "\n"; + } + print "\n"; + $docstat |= $D_NP; + $docstat |= $D_PA; + } + } + elsif ($special == $SP_END_PAR) { + print "\n"; + $docstat &= ~$D_PA; + } + elsif ($special == $SP_START_TAB) { + if ($docstat & $D_PA) { + print "\n\n"; + $docstat &= ~$D_PA; + } + print "\n\n"; + $docstat |= $D_TAB | $D_NL; + } + elsif ($special == $SP_END_TAB) { + print ""; + $docstat &= ~$D_TAB; + $docstat |= $D_NL; + } + elsif ($special == $SP_START_DL) { + if ($docstat & $D_PA) { + print "\n\n"; + $docstat &= ~$D_PA; + } + print "\n\n\n\n"; + $docstat |= $D_DL; + } + elsif ($special == $SP_DT) { + print ""; + } + elsif ($special == $SP_DD) { + $docstat |= $D_DD; + if ($docstat & $D_DL) { + print ""; + } + else { + print ""; + } + } + elsif ($special == $SP_END_DD) { + if ($docstat & $D_DL) { + print "\n"; + } + else { + print ""; + } + $docstat &= ~$D_DD; + } + elsif ($special == $SP_END_DL) { + print "\n"; + $docstat &= ~($D_DD|$D_DL); + } + elsif ($special == $SP_START_IL) { + if ($docstat & $D_PA) { + print "\n\n"; + $docstat &= ~$D_PA; + } + print "\n\n"; + $docstat |= $D_IL; + } + elsif ($special == $SP_END_IL) { + print "\n"; + $docstat &= ~($D_DD|$D_DL); + } + elsif ($special == $SP_END_SECT) { + print ""; + } + elsif ($special == $SP_STR) { + if ($docstat & $D_TAB) { + print_sgml($str); + } + else { + $str =~ s/&/&/g; + $str =~ s//>/g; + $str =~ s/``//g; + $str =~ s/''/<\/quote>/g; + print $str; + } + } + + return $docstat; +} diff --git a/init.h b/init.h index a237cb80..b797dd1c 100644 --- a/init.h +++ b/init.h @@ -27,7 +27,7 @@ #include "buffy.h" #ifndef _MAKEDOC -/* If you add a data type, be sure to update doc/makedoc.c */ +/* If you add a data type, be sure to update doc/makedoc.pl */ #define DT_MASK 0x0f #define DT_BOOL 1 /* boolean option */ #define DT_NUM 2 /* a number (short) */ diff --git a/sort.h b/sort.h index 0a6450e9..340ad18b 100644 --- a/sort.h +++ b/sort.h @@ -19,7 +19,7 @@ #define SORT_DATE 1 /* the date the mail was sent. */ #define SORT_SIZE 2 #define SORT_SUBJECT 3 -#define SORT_ALPHA 3 /* makedoc.c requires this */ +#define SORT_ALPHA 3 /* makedoc.pl requires this */ #define SORT_FROM 4 #define SORT_ORDER 5 /* the order the messages appear in the mailbox. */ #define SORT_THREADS 6 -- 2.24.1