CVS log for mandoc/tag.c

[BACK] Up to [cvsweb.bsd.lv] / mandoc

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.38 / (download) - annotate - [select for diffs], Fri Nov 24 05:02:18 2023 UTC (4 months ago) by schwarze
Branch: MAIN
CVS Tags: HEAD
Changes since 1.37: +46 -13 lines
Diff to previous 1.37 (colored)

1. Do not put ASCII_HYPH (0x1c) into the tag file.
That happened when tagging a string containing '-' on an input text line,
most commonly in man(7) .TP next line scope.
2. Do not let "\-" end the tag.
In both cases, translate ASCII_HYPH and "\-" to plain '-' for output.
For example, this improves handling of unbound.conf(5).

These two bugs were found thanks to a posting by weerd@.

Revision 1.37 / (download) - annotate - [select for diffs], Tue Apr 26 11:38:38 2022 UTC (23 months ago) by schwarze
Branch: MAIN
Changes since 1.36: +17 -4 lines
Diff to previous 1.36 (colored)

If a node is tagged explicitly, skip implicit tagging for that node.
Apart from making sense in the first place, this fixes an assertion
failure that happened when the calculated implicit tag did not match
the string value of the first child of the node,

Bug found by tb@ using afl(1).

Revision 1.36 / (download) - annotate - [select for diffs], Sun Apr 19 16:36:16 2020 UTC (3 years, 11 months ago) by schwarze
Branch: MAIN
CVS Tags: VERSION_1_14_6
Changes since 1.35: +41 -24 lines
Diff to previous 1.35 (colored)

When .Bd, .D1, or .Dl is tagged, attach the permalink
to the first few letters, similar to what was earlier done for .Pp.

Revision 1.35 / (download) - annotate - [select for diffs], Sat Apr 18 20:40:10 2020 UTC (3 years, 11 months ago) by schwarze
Branch: MAIN
Changes since 1.34: +29 -4 lines
Diff to previous 1.34 (colored)

When a .Tg is attached to a paragraph, attach the permalink
to the first word, or the first few words if they are short.

Revision 1.34 / (download) - annotate - [select for diffs], Wed Apr 8 11:56:04 2020 UTC (3 years, 11 months ago) by schwarze
Branch: MAIN
Changes since 1.33: +17 -10 lines
Diff to previous 1.33 (colored)

Use a separate node->tag attribute rather than abusing the node->string
attribute for the purpose.  No functional change intended.
The purpose is to make it possible to later attach tags to text nodes.

Revision 1.33 / (download) - annotate - [select for diffs], Tue Apr 7 22:56:02 2020 UTC (3 years, 11 months ago) by schwarze
Branch: MAIN
Changes since 1.32: +95 -1 lines
Diff to previous 1.32 (colored)

Separate the place to put the <a href> permalink (now marked
with NODE_HREF) from the target element of the link (still marked
with NODE_ID).  In many cases, use this to move the target to the
beginning of the paragraph, such that readers don't get dropped
into the middle of a sentence.

Revision 1.32 / (download) - annotate - [select for diffs], Fri Apr 3 10:30:09 2020 UTC (3 years, 11 months ago) by schwarze
Branch: MAIN
Changes since 1.31: +2 -1 lines
Diff to previous 1.31 (colored)

#include <stdint.h> because that is needed before #include <ohash.h>;
fixing a build failure of mandoc-portable on Arch Linux
reported by Stephen Gregoratto <dev at sgregoratto dot me>.

Revision 1.31 / (download) - annotate - [select for diffs], Thu Apr 2 22:12:55 2020 UTC (3 years, 11 months ago) by schwarze
Branch: MAIN
Changes since 1.30: +4 -12 lines
Diff to previous 1.30 (colored)

When the last file formatted yielded no tags, the tags file got
deleted before starting the pager, even when earlier input files
had written to it; thanks to weerd@ for reporting that bug.

Since we now generate tags for section headers, we almost always
generate at least some.  Consequently, while fixing the above bug,
simplify the code by never deleting the tags file before the pager
exits, not even in the rare case that the file happens to be empty.
Hence, this patch is -75 +63 LOC even though it fixes two bugs.

While deleting the output files belongs after exit from the pager,
closing them should be done before it is started.  Collect the
related code, which was scattered in various places, to where
it belongs, in a dedicated function in the term_tag.c module.
As a side benefit, never fclose(2) stdout, only dup2(2) to it.

Similarly, when the -O tag argument wasn't found in the last file
formatted, there was a complaint about "no such tag" even when the
argument did occur in earlier files.  Fix that by looking for a
matching tag after every formatted file rather than just once at
the very end.  Given that command line arguments aren't properties
of the file(s) being formatted, that check is a job for the main
program, not for the formatters, so while fixing the check, move
it from term_tag.c to main.c.

Revision 1.30 / (download) - annotate - [select for diffs], Sat Mar 21 00:17:31 2020 UTC (4 years ago) by schwarze
Branch: MAIN
Changes since 1.29: +19 -3 lines
Diff to previous 1.29 (colored)

When setting automatic tags, skip initial hyphens and minus signs,
bringing the behaviour for mdoc(7) closer to what is already done
for man(7).
Triggered by the observation of kn@ that automatic tagging didn't
work very well for find(1) primaries.
OK kn@

Revision 1.29 / (download) - annotate - [select for diffs], Fri Mar 13 16:16:58 2020 UTC (4 years ago) by schwarze
Branch: MAIN
Changes since 1.28: +4 -1 lines
Diff to previous 1.28 (colored)

Properly reset the validation part of the tagging module between files.
This fixes a crash in makewhatis(8) encountered by naddy@.

Revision 1.28 / (download) - annotate - [select for diffs], Fri Mar 13 15:32:29 2020 UTC (4 years ago) by schwarze
Branch: MAIN
Changes since 1.27: +76 -204 lines
Diff to previous 1.27 (colored)

Split tagging into a validation part including prioritization
in tag.{h,c} and {mdoc,man}_validate.c
and into a formatting part including command line argument checking
in term_tag.{h,c}, html.c, and {mdoc|man}_{term|html}.c.

Immediate functional benefits include:
* Improved prioritization of automatic tags for .Em and .Sy.
* Avoiding bogus automatic tags when .Em, .Fn, or .Sy are explicitly tagged.
* Explicit tagging of .Er and .Fl now works in HTML output.
* Automatic tagging of .IP and .TP now works in HTML output.
But mainly, this patch provides clean earth to build further improvements on.

Technical changes:
* Main program: Write a tag file for ASCII and UTF-8 output only.
* All formatters: There is no more need to delay writing the tags.
* mdoc(7)+man(7) formatters: No more need for elaborate syntax tree inspection.
* HTML formatter: If available, use the "string" attribute as the tag.
* HTML formatter: New function to write permalinks, to reduce code duplication.

Style cleanup in the vicinity while here:
* mdoc(7) terminal formatter: To set up bold font for children,
defer to termp_bold_pre() rather than calling term_fontpush() manually.
* mdoc(7) terminal formatter: Garbage collect some duplicate functions.
* mdoc(7) HTML formatter: Unify <code> handling, delete redundant functions.
* Where possible, use switch statements rather than if cascades.
* Get rid of some more Yoda notation.

The necessity for such changes was first discussed with kn@, but i didn't
bother him with a request to review the resulting -673/+782 line patch.

Revision 1.27 / (download) - annotate - [select for diffs], Mon Jan 20 10:37:15 2020 UTC (4 years, 2 months ago) by schwarze
Branch: MAIN
Changes since 1.26: +13 -12 lines
Diff to previous 1.26 (colored)

Make the code more readable by introducing
symbolic constants for tagging priorities.
This review also made me find a minor bug: do not upgrade
TAG_FALLBACK to TAG_WEAK when there is trailing whitespace.

Revision 1.26 / (download) - annotate - [select for diffs], Sun Jan 19 18:02:00 2020 UTC (4 years, 2 months ago) by schwarze
Branch: MAIN
Changes since 1.25: +6 -5 lines
Diff to previous 1.25 (colored)

Introduce a new mdoc(7) macro .Tg ("tag") to explicitly mark a place
as defining a term.  Please only use it when automatic tagging does
not work.  Manual page authors will not be required to add the new
macro; using it remains optional.  HTML output is still rudimentary
in this version and will be polished later.

Thanks to kn@ for reminding me that i have been considering since
BSDCan 2014 whether something like this might be useful.  Given
that possibilities of making automatic tagging better are running
out and there are still several situations where automatic tagging
cannot do the job, i think the time is now ripe.

Feedback and no objection from millert@; OK espie@ inoguchi@ kn@.

Revision 1.25 / (download) - annotate - [select for diffs], Sat Jul 27 13:40:57 2019 UTC (4 years, 8 months ago) by schwarze
Branch: MAIN
Changes since 1.24: +4 -2 lines
Diff to previous 1.24 (colored)

Move two more output state variables into the new struct outstate.
Also, move setting of tag_files.tagname into tag_init().
No functional change.

Revision 1.24 / (download) - annotate - [select for diffs], Mon Jul 22 03:21:50 2019 UTC (4 years, 8 months ago) by schwarze
Branch: MAIN
Changes since 1.23: +3 -3 lines
Diff to previous 1.23 (colored)

Slowly start implementing tagging support for man(7) pages, even
though it is obvious that this can never become as good as for
mdoc(7) pages.  As a first step, tag alphabetic arguments of .IP
macros, which are often used for lists of options and keywords.

Try "man -O tag=g as" to get the point.

Thanks to Leah Neukirchen for recently reminding me that exploring
how much can be done in this respect may be worthwhile: it is likely
to slightly improve usability while adding only small amounts of
relatively straightforward code.

Revision 1.23 / (download) - annotate - [select for diffs], Fri Jul 19 20:27:25 2019 UTC (4 years, 8 months ago) by schwarze
Branch: MAIN
Changes since 1.22: +12 -3 lines
Diff to previous 1.22 (colored)

If no tags were generated at all, unlink(2) the empty tags file as
soon as the condition can be detected and do not pass it to less(1).
This may happen for man(7) pages, for preformatted pages, and for
very simple pages like true(1).  The main benefit is that :t inside
less(1) yields the clearer diagnostic message "No tags file" rather
than the mildly confusing "No such tag in tags file": the latter
might encourage further, futile attempts to jump to other tags.

Improvement suggested by Leah Neukirchen <leah at vuxu dot org>
from The Void.

Revision 1.22 / (download) - annotate - [select for diffs], Wed Jul 10 19:39:01 2019 UTC (4 years, 8 months ago) by schwarze
Branch: MAIN
Changes since 1.21: +21 -11 lines
Diff to previous 1.21 (colored)

Some time ago, i simplified mandoc_msg() such that it can be used
everywhere and not only in the parsers.
For more uniform messages, use it at more places instead of err(3),
in particular in the main program.
While here, integrate a few trivial functions called at exactly one
place into the main option parser, and let a few more functions use
the normal convention of returning 0 for success and -1 for error.

Revision 1.21 / (download) - annotate - [select for diffs], Thu Nov 22 11:30:23 2018 UTC (5 years, 4 months ago) by schwarze
Branch: MAIN
CVS Tags: VERSION_1_14_5
Changes since 1.20: +9 -1 lines
Diff to previous 1.20 (colored)

In -T locale (the default), -T ascii, and -T utf8 mode, provide a new
output option -O tag[=term] to move right to the definition of "term" when
opening the manual page in a pager, effectively porting the -T html
fragment name feature - https://man.openbsd.org/ksh#ulimit - to the
terminal.  Try:

$ man -O tag uvm_sysctl
$ man -O tag=ulimit ksh
$ man -O tag 3 compress

Feature development triggered by a question from kn@.  Klemens also
tested, provided feedback that resulted in improvements, and provided
an OK.

Revision 1.20 / (download) - annotate - [select for diffs], Tue Oct 23 20:42:37 2018 UTC (5 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.19: +27 -10 lines
Diff to previous 1.19 (colored)

The ctags(1) file format uses whitespace as a field delimiter, and
there is no escaping mechanism, so tags cannot contain whitespace.
Consequently, we used to simply not tag macro arguments containing
space characters.  Instead, let's tag the first word, unless there
is a proper match for that word somewhere else.  For example, this
makes ":tquery" work in ntpd.conf(5).

Feature suggested by kn@, who also thinks the implementation looks
reasonable and works in his testing.

Revision 1.19 / (download) - annotate - [select for diffs], Fri Feb 23 16:47:10 2018 UTC (6 years, 1 month ago) by schwarze
Branch: MAIN
CVS Tags: VERSION_1_14_4
Changes since 1.18: +4 -1 lines
Diff to previous 1.18 (colored)

Invalidate the tag_files.tfd after fclose(3)ing the stram associated
with it.  In main() assert that the tfd was actually invalidated.
This avoids closing an invalid fd.
From tb@; OK deraadt@ on an earlier version.

Revision 1.18 / (download) - annotate - [select for diffs], Fri Feb 17 14:31:52 2017 UTC (7 years, 1 month ago) by schwarze
Branch: MAIN
CVS Tags: VERSION_1_14_3, VERSION_1_14_2, VERSION_1_14_1, VERSION_1_13
Changes since 1.17: +2 -2 lines
Diff to previous 1.17 (colored)

Be consistent in protecting __attribute__ attributes with __;
from Christos Zoulas <christos @ NetBSD>.

Revision 1.17 / (download) - annotate - [select for diffs], Mon Jan 9 17:49:58 2017 UTC (7 years, 2 months ago) by schwarze
Branch: MAIN
Changes since 1.16: +3 -3 lines
Diff to previous 1.16 (colored)

Use stdout rather than stdin for controlling the terminal
such that "cat foo.mdoc | man -l" works.
Issue reported by Christian Neukirchen <chneukirchen at gmail dot com>
and also tested by him on Void Linux with both glibc and musl.
The patch makes sense to millert@.

Revision 1.16 / (download) - annotate - [select for diffs], Tue Nov 8 16:23:58 2016 UTC (7 years, 4 months ago) by schwarze
Branch: MAIN
Changes since 1.15: +12 -4 lines
Diff to previous 1.15 (colored)

implement tag priority 0, which will tag only keys that appear as
tag candidates exactly once, and use it for .Em and .Sy;
written on the TGV Toulouse-Paris

Revision 1.15 / (download) - annotate - [select for diffs], Tue Nov 8 15:57:28 2016 UTC (7 years, 4 months ago) by schwarze
Branch: MAIN
Changes since 1.14: +8 -2 lines
Diff to previous 1.14 (colored)

skip leading \& and \e in tags

Revision 1.14 / (download) - annotate - [select for diffs], Tue Nov 8 15:28:17 2016 UTC (7 years, 4 months ago) by schwarze
Branch: MAIN
Changes since 1.13: +39 -8 lines
Diff to previous 1.13 (colored)

support more than one tag entry for the same search term;
general idea discussed with bcook@ during l2k16

Revision 1.13 / (download) - annotate - [select for diffs], Wed Jul 20 13:03:24 2016 UTC (7 years, 8 months ago) by schwarze
Branch: MAIN
Changes since 1.12: +2 -2 lines
Diff to previous 1.12 (colored)

tag_signal() is dead; from LLVM via Christos Zoulas

Revision 1.12 / (download) - annotate - [select for diffs], Fri Jul 8 20:42:15 2016 UTC (7 years, 8 months ago) by schwarze
Branch: MAIN
CVS Tags: VERSION_1_13_4
Changes since 1.11: +19 -7 lines
Diff to previous 1.11 (colored)

POSIX requires that a process calling tcsetpgrp(3) from the background
gets a SIGTTOU signal.  In that case, do not stop.
Portability issue found while testing on commercial Solaris 9/10/11.
Thanks to opencsw.org for providing me with a testing environment.

Revision 1.11 / (download) - annotate - [select for diffs], Fri Nov 20 21:59:54 2015 UTC (8 years, 4 months ago) by schwarze
Branch: MAIN
Changes since 1.10: +22 -5 lines
Diff to previous 1.10 (colored)

Fix multiple issues regarding process group and signal mask handling
found by tb@ and millert@; parts of the code, in particular in tag.c,
by millert@; OK millert@.

Revision 1.10 / (download) - annotate - [select for diffs], Tue Oct 13 15:53:05 2015 UTC (8 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.9: +3 -41 lines
Diff to previous 1.9 (colored)

Reduce the amount of code by moving the three copies of the ohash
callback functions into one common place, preparing for the use of
ohash for some additional purposes.  No functional change.

Revision 1.9 / (download) - annotate - [select for diffs], Sun Oct 11 22:00:52 2015 UTC (8 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.8: +2 -2 lines
Diff to previous 1.8 (colored)

Drop tags containing a blank character:
They don't work, they break other tags in weird ways, and even
if they could be made to work, they would be mostly useless.
Issue reported by naddy@, thanks.

Revision 1.8 / (download) - annotate - [select for diffs], Tue Oct 6 18:32:20 2015 UTC (8 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.7: +5 -5 lines
Diff to previous 1.7 (colored)

modernize style: "return" is not a function

Revision 1.7 / (download) - annotate - [select for diffs], Sat Aug 29 15:28:13 2015 UTC (8 years, 7 months ago) by schwarze
Branch: MAIN
Changes since 1.6: +4 -1 lines
Diff to previous 1.6 (colored)

Including <ohash.h> requires including <stdint.h> before,
and "config.h" was missing as well.
Patch from Svyatoslav Mishyn <juef and openmailbox dot org>, Crux Linux.

Revision 1.6 / (download) - annotate - [select for diffs], Tue Jul 28 18:38:55 2015 UTC (8 years, 8 months ago) by schwarze
Branch: MAIN
Changes since 1.5: +57 -20 lines
Diff to previous 1.5 (colored)

Remove the hack of scrolling forward and backward with +G1G that
many (jmc@, millert@, espie@, deraadt@) considered revolting.
Instead, when using a pager, since we are using a temporary file
for tags anyway, use another temporary file for the formatted
page(s), as suggested by millert@ and similar to what the traditional
BSD man(1) did, except that we use only one single temporary output
file rather than one for each formatted manual page, such that
searching (both with / and :t) works across all the displayed files.

Revision 1.5 / (download) - annotate - [select for diffs], Sat Jul 25 14:28:59 2015 UTC (8 years, 8 months ago) by schwarze
Branch: MAIN
Changes since 1.4: +10 -32 lines
Diff to previous 1.4 (colored)

Simplify and make tag_put() more efficient by integrating tag_get()
into it and by only handling NUL-terminated strings.
Minus 25 lines of code, no functional change.

Revision 1.4 / (download) - annotate - [select for diffs], Sat Jul 25 14:02:06 2015 UTC (8 years, 8 months ago) by schwarze
Branch: MAIN
Changes since 1.3: +6 -4 lines
Diff to previous 1.3 (colored)

basic support for tag priorities; written at YYC

Revision 1.3 / (download) - annotate - [select for diffs], Tue Jul 21 03:26:22 2015 UTC (8 years, 8 months ago) by schwarze
Branch: MAIN
Changes since 1.2: +3 -9 lines
Diff to previous 1.2 (colored)

When creation of the temporary tags file fails, call the pager
without the -T option, because otherwise the pager won't even start.
Fixing a bug reported by jca@.

While here, shorten the code by two lines
and delete one internal interface function.

Revision 1.2 / (download) - annotate - [select for diffs], Sat Jul 18 03:41:37 2015 UTC (8 years, 8 months ago) by schwarze
Branch: MAIN
Changes since 1.1: +17 -1 lines
Diff to previous 1.1 (colored)

clean up the temporary file when the process dies from a signal

Revision 1.1 / (download) - annotate - [select for diffs], Fri Jul 17 22:38:29 2015 UTC (8 years, 8 months ago) by schwarze
Branch: MAIN

Initial, still somewhat experimental implementation to leverage
less(1) -T and :t ctags(1)-like functionality to jump to the
definitions of various terms inside manual pages.
To be polished in the tree, so bear with me and report issues.

Technically, if less(1) is used as a pager, information is collected
by the mdoc(7) terminal formatter, first stored using the ohash
library, then ultimately written to a temporary file which is passed
to less via -T.  No change intended for other output formatters or
when running without a pager.

Based on an idea from Kristaps using feedback from many, in particular
phessler@ nicm@ millert@ halex@ doug@ kspillner@ deraadt@.

This form allows you to request diff's between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.




CVSweb