Hi! On Fri, Apr 21, 2023 at 03:42:48AM +0200, Alejandro Colomar wrote: > On 4/21/23 02:39, наб wrote: > > Explicitly spell out the ranges involved. The original wording always > > confused me, but it's actually very sane. > > > > Remove "this doesn't change R_NOTBOL & R_NEWLINE" ‒ so does it change > > R_NOTEOL? No. That's weird and confusing. > > > > String largeness doesn't matter, known-lengthness does. > > > > Explicitly spell out the influence on returned matches > > (relative to string, not start of range). > > > > Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@xxxxxxxxxxxxxxxxxx> > > Patch applied. > > > --- > > Range-diff against v6: > > 1: 4b7971a5e < -: --------- regex.3: Desoupify regfree() description > > 2: 5fb4cc16f ! 1: ed050649b regex.3: Improve REG_STARTEND > > @@ man3/regex.3: .SS Matching > > -and ending before byte > > -.IR pmatch[0].rm_eo . > > +Match > > -+.RI [ string " + " pmatch[0].rm_so ", " string " + " pmatch[0].rm_eo ) > > ++.RI [ "string + pmatch[0].rm_so" , " string + pmatch[0].rm_eo" ) > > +instead of > > -+.RI [ string ", " string " + \fBstrlen\fP(" string )). > > ++.RI [ string , " string + strlen(string)" ). > > This allows matching embedded NUL bytes > > and avoids a > > .BR strlen (3) > > @@ man3/regex.3: .SS Matching > > +as usual, and the match offsets remain relative to > > +.IR string > > +(not > > -+.IR string " + " pmatch[0].rm_so ). > > ++.IR "string + pmatch[0].rm_so" ). > > This flag is a BSD extension, not present in POSIX. > > .SS Match offsets > > Unless > > > > man3/regex.3 | 29 ++++++++++++++++------------- > > 1 file changed, 16 insertions(+), 13 deletions(-) > > > > diff --git a/man3/regex.3 b/man3/regex.3 > > index 46a4a12b9..099c2c17f 100644 > > --- a/man3/regex.3 > > +++ b/man3/regex.3 > > @@ -131,23 +131,26 @@ .SS Matching > > above). > > .TP > > .B REG_STARTEND > > -Use > > -.I pmatch[0] > > -on the input string, starting at byte > > -.I pmatch[0].rm_so > > -and ending before byte > > -.IR pmatch[0].rm_eo . > > +Match > > +.RI [ "string + pmatch[0].rm_so" , " string + pmatch[0].rm_eo" ) > > +instead of > > +.RI [ string , " string + strlen(string)" ). > > This allows matching embedded NUL bytes > > and avoids a > > .BR strlen (3) > > -on large strings. > > -It does not use > > +on known-length strings. > > +If any matches are returned > > +.RB ( REG_NOSUB > > +wasn't passed to > > +.BR regcomp (), > > +the match succeeded, and > > .I nmatch > > -on input, and does not change > > -.B REG_NOTBOL > > -or > > -.B REG_NEWLINE > > -processing. > > +> 0), they overwrite > > +.I pmatch > > +as usual, and the match offsets remain relative to > > +.IR string > > Minor glitch: s/IR/I/ > > I fixed it. BTW, don't know if you knew, but you can run some linters > to check these accidents by yourself. $ make check # ... GREP .tmp/man/man1/memusage.1.check-catman.touch .tmp/man/man1/memusage.1.cat.grep:132: Memory usage summary: heap total: 45200, heap peak: 6440, stack peak: 224 .tmp/man/man1/memusage.1.cat.grep:135: realloc| 40 44800 0 (nomove:40, dec:19, free:0) make: *** [share/mk/check/catman.mk:36: .tmp/man/man1/memusage.1.check-catman.touch] Error 1 $ make lint SED .tmp/man/man2/add_key.2.d/add_key.c LINT (checkpatch) .tmp/man/man2/add_key.2.d/add_key.lint-c.checkpatch.touch bash: line 1: checkpatch: command not found make: *** [share/mk/lint/c.mk:64: .tmp/man/man2/add_key.2.d/add_key.lint-c.checkpatch.touch] Error 127 git grep checkpatch first says I want checkpatch(1). No such manual exists, at least in Debian. Then it reveals I actually want checkpatch.pl from a linux checkout. Probably call it [scripts/]checkpatch.pl then? Then it reveals CHECKPATCH := checkpatch which means that just export CHECKPATCH=~/store/code/linux/scripts/checkpatch.pl doesn't work, and I need to pass it as an argument (should be ?=). The same for all the other linters. $ make -j25 CHECKPATCH=~/store/code/linux/scripts/checkpatch.pl lint # ... LINT (mandoc) .tmp/man/man1/pldd.1.lint-man.mandoc.touch mandoc: man1/getent.1:6:14: WARNING: cannot parse date, using it verbatim: (date) # (same what feels like every page; bullseye mandoc 1.14.5-1) If I pass MANDOC=~/code/voreutils/mandoc (recent(ish, it was recent last year) CVS, + some patches I forgot that fixed some egregious formatting errors): LINT (mandoc) .tmp/man/man5/ftpusers.5.lint-man.mandoc.touch LINT (mandoc) .tmp/man/man5/gai.conf.5.lint-man.mandoc.touch LINT (mandoc) .tmp/man/man5/group.5.lint-man.mandoc.touch LINT (mandoc) .tmp/man/man5/host.conf.5.lint-man.mandoc.touch mandoc: man5/erofs.5:78:2: ERROR: skipping end of block that is not open: RE mandoc: man5/erofs.5:79:2: WARNING: skipping paragraph macro: IP empty mandoc: man5/erofs.5:78:2: WARNING: skipping paragraph macro: br at the end of SS And it passes! Those are the only errors I saw, even on the version with IR\ string$ When I ran with 2>&1 | less to make sure, I got /etc/bash.bashrc: line 7: PS1: unbound variable /etc/bash.bashrc: line 7: PS1: unbound variable /etc/bash.bashrc: line 7: PS1: unbound variable /etc/bash.bashrc: line 7: PS1: unbound variable /etc/bash.bashrc: line 7: PS1: unbound variable /etc/bash.bashrc: line 7: PS1: unbound variable /etc/bash.bashrc: line 7: PS1: unbound variable /etc/bash.bashrc: line 7: PS1: unbound variable /etc/bash.bashrc: line 7: PS1: unbound variable /etc/bash.bashrc: line 7: PS1: unbound variable /etc/bash.bashrc: line 7: PS1: unbound variable /etc/bash.bashrc: line 7: PS1: unbound variable /etc/bash.bashrc: line 7: PS1: unbound variable /etc/bash.bashrc: line 7: PS1: unbound variable SED .tmp/man/man2/add_key.2.d/add_key.c SED .tmp/man/man2/bind.2.d/bind.c SED .tmp/man/man2/chown.2.d/chown.c SED .tmp/man/man2/clock_getres.2.d/clock_getres.c SED .tmp/man/man2/clone.2.d/clone.c SED .tmp/man/man2/close_range.2.d/close_range.c SED .tmp/man/man2/copy_file_range.2.d/copy_file_range.c SED .tmp/man/man2/eventfd.2.d/eventfd.c and indeed Makefile:SHELL := /usr/bin/env bash -Eeuo pipefail and $ sed -n 6,7p /etc/bash.bashrc # If not running interactively, don't do anything [ -z "$PS1" ] && return (That should be ${PS1-}. What's even funnier is that $ sed -n 14p /etc/bash.bashrc if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then) $ make -j25 CHECKPATCH=~/store/code/linux/scripts/checkpatch.pl lint MANDOC=: CLANG-TIDY=: LINT (checkpatch) .tmp/man/man3/_Generic.3.d/_Generic.lint-c.checkpatch.touch ERROR:ASSIGN_IN_IF: do not use assignment in if condition #17: FILE: .tmp/man/man3const/EXIT_SUCCESS.3const.d/EXIT_SUCCESS.c:17: + if ((fp = fopen(argv[1], "r")) == NULL) { Do not use assignments in if condition. Example:: if ((foo = bar(...)) < BAZ) { should be written as:: foo = bar(...); if (foo < BAZ) { total: 1 errors, 0 warnings, 0 checks, 29 lines checked make: *** [share/mk/lint/c.mk:64: .tmp/man/man3const/EXIT_SUCCESS.3const.d/EXIT_SUCCESS.lint-c.checkpatch.touch] Error 1 make: *** Waiting for unfinished jobs.... CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #17: FILE: .tmp/man/man3/dl_iterate_phdr.3.d/dl_iterate_phdr.c:17: + printf("Name: \"%s\" (%d segments)\n", info->dlpi_name, + info->dlpi_phnum); CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #33: FILE: .tmp/man/man3/dl_iterate_phdr.3.d/dl_iterate_phdr.c:33: + printf(" %2zu: [%14p; memsz:%7jx] flags: %#jx; ", j, + (void *) (info->dlpi_addr + info->dlpi_phdr[j].p_vaddr), total: 0 errors, 0 warnings, 2 checks, 54 lines checked make: *** [share/mk/lint/c.mk:63: .tmp/man/man3/dl_iterate_phdr.3.d/dl_iterate_phdr.lint-c.checkpatch.touch] Error 1 WARNING:EMBEDDED_FUNCTION_NAME: Prefer using '"%s...", __func__' to using 'closeSocketPair', this function's name, in a string #230: FILE: .tmp/man/man2/seccomp_unotify.2.d/seccomp_unotify.c:230: + err(EXIT_FAILURE, "closeSocketPair-close-0"); Embedded function names are less appropriate to use as refactoring can cause function renaming. Prefer the use of "%s", __func__ to embedded function names. Note that this does not work with -f (--file) checkpatch option as it depends on patch context providing the function name. WARNING:EMBEDDED_FUNCTION_NAME: Prefer using '"%s...", __func__' to using 'closeSocketPair', this function's name, in a string #232: FILE: .tmp/man/man2/seccomp_unotify.2.d/seccomp_unotify.c:232: + err(EXIT_FAILURE, "closeSocketPair-close-1"); total: 0 errors, 2 warnings, 0 checks, 612 lines checked make: *** [share/mk/lint/c.mk:63: .tmp/man/man2/seccomp_unotify.2.d/seccomp_unotify.lint-c.checkpatch.touch] Error 1 (more pages) I'm not sure I agree with the ASSIGN_IN_IF case, but I'm assuming there's a mechanism to kill the lints you don't are about; linux cdc9718d5e590d6905361800b938b93f2b66818e. This continues until I've disabled every linter. I'm assuming you have specific versions that work for you, but, well. Best, наб
Attachment:
signature.asc
Description: PGP signature