Commit Graph

166 Commits

Author SHA1 Message Date
lukem 8e5c6bed5f obsolete mkstr(1) and xstr(1)
These were only used on PDP-11 for two programs we don't ship,
and have been obsolete since the VAX days.

xstr never worked in the build.sh cross-build environment (22 years), or
parallel make environment (nearly 28 years), didn't work in the orignal 386bsd
import, and has never been needed in NetBSD as we don't have the older BSD
programs (pascal, pre-nvi ex) that needed mkstr/xstr on PDP-11.

PR toolchain/35964
2023-05-24 13:00:14 +00:00
gutteridge 550467b4c4 makemandb.c: spell "metadata" consistently 2023-01-01 21:27:14 +00:00
gutteridge 954d646f97 makemandb.c: fix grammar in a comment 2022-10-30 01:49:30 +00:00
andvar 49811c99f0 fix various typos in comments and makefs README file. 2022-10-26 21:56:19 +00:00
gutteridge 6f0eae4436 makemandb/*: fix spelling of database and consistency of SQLite 2022-09-11 20:32:37 +00:00
skrll 09be482eb3 Don't index outside the mdocs array of function pointers. Analysis and
suggested fixes from Tom Lane.  I played it safe and went with (my
variation of) the minimal fix.

port-hppa/56118: sporadic app crashes in HPPA -current
2022-06-06 07:41:23 +00:00
gutteridge 521bd3ea5d apropos(1): improve error handling in edge cases
Patch from RVP on NetBSD-Users, with an additional comment tweak by me.
Summary from RVP:

1. Ignore SIGPIPE so that we're not killed in the middle of some
   DB operation by a botched $PAGER:

$ env PAGER=/non-existent apropos -p ...

2. Return proper exit status in case of write errors:

$ apropos ... >/dev/full || echo fail
2022-05-19 04:08:03 +00:00
uwe 308d716787 apropos(1): Use the official spelling for "SQLite".
While here, use .Bx to refer to 3BSD.
2022-05-17 11:37:54 +00:00
uwe 806c657e56 apropos(1): Tweak the description of -1, ... -9, and -s
-s is not for compatibility only, because section names can be
anything.  E.g. we have 3lua and 9lua in base.  We have rudiments of
3f (for FORTRAN libs).  Some packages in pkgsrc also use suffixed 1
and 3 sections.
2022-05-17 11:31:14 +00:00
uwe 72ea3012f5 apropos(1): use proper -width for the list of options too 2022-05-17 08:39:58 +00:00
uwe 5123efc107 apropos(1): use proper -width 2022-05-17 08:35:46 +00:00
gutteridge ba4e9b2ab5 apropos.1: document the PAGER environment variable 2022-05-17 01:22:14 +00:00
gutteridge d2ce6e15e6 apropos.c: fix pager functionality
Issue reported by Rocky Hotas on NetBSD-Users, patch input from RVP on
same, adjustments by me.
2022-05-17 00:21:22 +00:00
gutteridge f2240c734a makemandb.c: fail sooner if man page dirs can't be found
There's no point initializing database state if we're then going to
fail to locate any man page sources. Make all the initial state checks
contiguous for simplicity and readability. Also, free the variable
"command" on the error path, and correct the error message.
2022-04-06 03:23:38 +00:00
msaitoh 813cf550c4 s/trival/trivial/ in comment. 2021-12-05 08:18:18 +00:00
wiz d07955d934 preceds -> precedes 2021-12-05 08:03:32 +00:00
msaitoh 79d22ebfb9 s/preceed/preced/ in comment. 2021-12-05 07:13:48 +00:00
rillig 6f4965e060 usr.sbin: remove unnecessary CONSTCOND, lint no longer needs it
Since 2021-01-31, lint no longer requires a CONSTCOND comment in a
do-while-0 statement since this is a common code pattern, especially in
statement-like macros.

sed -i -E 's,} while \(/\* ?CONSTCOND ?\*/ ?0\),} while (0),' */*.[ch]
2021-11-27 22:30:25 +00:00
msaitoh 882c1780be - Remove obsolete cltom(9) and mtocl(9).
- Add missing manual page's link of m_adj.
2021-04-16 07:45:41 +00:00
nia a42fc114cd Revert addition of pthread dependency on sqlite.
It is less trivial than expected and introduced some surprising breakage.
2020-11-12 17:53:43 +00:00
martin 312a1f515d Fix copy&pasto in previous 2020-11-09 10:19:41 +00:00
nia 70f54ff57b sqlite: do not build without multithreading support
at least a few pkgsrc packages avoid base sqlite because it fails
this check, and it's probably a surprising performance penalty for
unsuspecting users
2020-11-08 21:56:47 +00:00
kamil 16b0614b43 Register ppoll 2020-06-02 15:43:26 +00:00
maya 09ad70fb6c Remove uyurex(4).
This is a driver for a "nonsense machine" made by the art group Maywa-Denki
in 2008. It was disabled by default.

Unfortunately even so it draws development attention (flaws found in the
code, MP-ification needs) and it is best not to continue to maintain this
driver.

Proposed without objections on tech-kern.
2020-01-17 15:00:20 +00:00
maxv 87107185b5 Revert the removal of filemon. 2019-12-23 06:45:36 +00:00
maxv e67f51b8f7 Retire filemon, discussed on tech-kern@. 2019-12-18 07:37:17 +00:00
abhinav b0ca50fb4d PR bin/54343: We want the callback_args.machine to be NULL if it is not present in the DB.
The previous commit fixed the problem of allowing apropos to not crash and
produce output even if the database is missing values for certain mandatory
fields, such as name, section etc. Normally we don't expect those values
to be missing in the database but in case of parsing errors it can happen.

However, the machine architecture is an optional field since not all man pages
are hardware specific so that should be allowed to be set to NULL if not
present in the database.
2019-08-18 09:14:30 +00:00
christos 2d0aa66b2f PR/54343: Prevent NULL pointers in callback strings; use "*?*" for now to
identify them.
2019-08-15 10:29:07 +00:00
leot a5fb0c00f0 Properly free section_clause. 2019-06-07 16:43:58 +00:00
leot 2710d0dc9d Document name_desc attribute of mandb_links.
Discussed with <abhinav> via PR misc/54213, thanks!
2019-05-18 10:38:04 +00:00
leot 83d9007765 Reintroduce case insensitive comparison of name accidentally lost in last
revision.

Discussed with <abhinav> via PR misc/54213, thanks!
2019-05-18 10:28:57 +00:00
abhinav 933b5da267 PR misc/54213: Fix performance of whatis(1) when no matches are found
In revision 1.6 of whatis.c the query was modified to return matches for names found
in MLINKS of the man pages as well. However it was slow. The reason probably being that it
required a join. But more importantly the where condition on an FTS virtual table column
is very slow. To avoid the join and the expensive where condition on the virtual table,
add the name_desc column to the mandb_links table as well. This improves the performance
of whatis(1) to the original level at the expense of slight data duplication.

Bump the schema to force database rebuild to take account for the new column addition
2019-05-18 07:56:43 +00:00
kamil 0c003f5999 Add a C99 symbol to libm: nexttowardl
It's an alias for an already existing symbol nextafterl.

Patch obtained from <mgorny>

Detected by the LLVM buildbot breakage in tests.
2019-04-27 23:04:31 +00:00
abhinav 6947938705 Memory allocated by sqlite3_mprintf should be free'd by sqlite3_free
This was causing memory corruption thus making apropos(1) fail in some cases.
Specifically following options were broken and should be fixed with this commit:

-n option was causing a core dump
apropos was giving warning when using -l and any of the section numbers as options
as reported by paulg on current-users.
2019-04-19 20:35:13 +00:00
abhinav 496b8ce373 Set the snippet_length field of the callback_args
Because of this field not being set, apropos was failing to show snippet when piped to a pager
or when used with -p argument.
2019-04-14 07:59:56 +00:00
christos 7f6ee53058 remove unneeded header. 2019-03-11 00:31:36 +00:00
christos 059d37ece9 adjust to the new mandoc api 2019-03-11 00:14:44 +00:00
christos e6b2ce53d6 fix memory allocation problems detected by jemalloc... 2019-03-07 22:08:59 +00:00
abhinav 50d4d47f30 Adjust makemandb for the latest mandoc
ok christos@
2018-08-24 16:01:57 +00:00
kre 6a7c82e6b2 In the latest mandoc (mdocml) the signature (prototype) of
mparse_alloc() altered - update the call here to compensate.

This fixes the build (of makemandb), but I am not sure that
the changed version is what is desired - someone who knows
something about all of this should validate ... I just copied
the invocation from mandoc's demandoc.c (which seems likely
to be at least a similar kind of usage).
2018-08-16 05:07:22 +00:00
abhinav 357f7b44ef Encapsulate all the arguments required by the query callback function in a struct.
If we want to add or remove arguments from the callback functions, it requires
changing the callback interface all over the place. By letting the callback simply
expect a single struct argument, it would clean things up a bit.

ok christos
2017-11-25 14:29:38 +00:00
abhinav b0184879c2 Casting variable of type int * to size_t *, may cause
alignment issues on some platforms (e.g. Sparc64)
So, Use a temporary variable to avoid the cast.

Thanks to Martin@ for noticing the issue and also suggesting the issue.
Fixes PR bin/52678
2017-10-31 10:14:27 +00:00
jmcneill 1385e4296e Make the 'no results found' message sound less harsh.
Changes "try using better keywords" to "try using different keywords".
2017-08-02 12:52:18 +00:00
abhinav f56c37233e Don't use the custom tokenizer when compiled with debugging on
Using the custom tokenizer means one cannot interactively query the database
through the SQLite shell, thus thwarting the purpose of the debug build option.

Thanks to leot@ for reporting it.

(While there change the debug macro from DEBUG to APROPOS_DEBUG)
2017-08-01 16:16:32 +00:00
abhinav 188f922ddf Add a custom tokenizer which does not stem certain keywords.
Which keywords should not be stemmed is specified in the nostem.txt file.
(Right now I have taken all the man page names, split them if they had
underscores, removed common English words and converted everything to
lowercase.)

The tokenizer itself is based on the Porter stemming tokenizer shipped with
Sqlite. The code in custom_apropos_tokenizer.c is copy of that code with
some modifications to prevent stemming keywords specified in nostem.txt.

Additionally, it now uses underscore `_' also as a token delimiter. Therefore,
now it's possible to do query for `lwp' and all `_lwp_*' man page names
will be matched. Or the query can be `unconst' and `__UNCONST' will be matched.
This was not possible earlier, because underscore was not a delimiter and therefore
the index would have __UNCONST as a key rather than UNCONST.

The tokenizer needs fts3_tokenizer.h file, which is not shipped with the
amalgamation build of Sqlite, therefore it needs to be added here (unless
we decide there is a better place for it).

To enforce using the new tokenizer, a schema version bump is needed

Since the tokenization is done both at the indexing time (via makemandb) and
also while query time (via apropos or whatis), it will be needed to bump
the schema version everytime nostem.txt is modified. Otherwise the
index will consist of old tokens and desired changes will not be seen with
apropos.

This should also fix the issue reported in PR bin/46255. Similar suggestion was
also made on tech-userlevel@ recently:
<http://mail-index.netbsd.org/tech-userlevel/2017/06/08/msg010620.html>

Thanks to christos@ for multiple rounds of reviews of the tokenizer code.
2017-06-18 16:24:10 +00:00
abhinav 2f6fb75f1b Make the name comparison case insensitive.
(The old whatis(1) also used to do case insensitive string comparisons).
2017-05-23 15:27:54 +00:00
riastradh ef315f7931 Remove MKCRYPTO option.
Originally, MKCRYPTO was introduced because the United States
classified cryptography as a munition and restricted its export.  The
export controls were substantially relaxed fifteen years ago, and are
essentially irrelevant for software with published source code.

In the intervening time, nobody bothered to remove the option after
its motivation -- the US export restriction -- was eliminated.  I'm
not aware of any other operating system that has a similar option; I
expect it is mainly out of apathy for churn that we still have it.
Today, cryptography is an essential part of modern computing -- you
can't use the internet responsibly without cryptography.

The position of the TNF board of directors is that TNF makes no
representation that MKCRYPTO=no satisfies any country's cryptography
regulations.

My personal position is that the availability of cryptography is a
basic human right; that any local laws restricting it to a privileged
few are fundamentally immoral; and that it is wrong for developers to
spend effort crippling cryptography to work around such laws.

As proposed on tech-crypto, tech-security, and tech-userlevel to no
objections:

https://mail-index.netbsd.org/tech-crypto/2017/05/06/msg000719.html
https://mail-index.netbsd.org/tech-security/2017/05/06/msg000928.html
https://mail-index.netbsd.org/tech-userlevel/2017/05/06/msg010547.html

P.S.  Reviewing all the uses of MKCRYPTO in src revealed a lot of
*bad* crypto that was conditional on it, e.g. DES in telnet...  That
should probably be removed too, but on the grounds that it is bad,
not on the grounds that it is (nominally) crypto.
2017-05-21 15:28:36 +00:00
abhinav a46498cbc0 Get rid of unnecessary variable. 2017-05-10 12:09:52 +00:00
abhinav 0b6c27b077 We do need to copy the return value from dirname(3) since there it is a static
buffer and can be overwritten in between. I overzealously removed this in one
of my previous commits.
2017-05-02 13:54:08 +00:00
abhinav 520f86ec72 Avoid dereferencing pointer at multiple places, instead use a local variable. 2017-05-01 06:56:00 +00:00