X-Loop: help-debbugs@HIDDEN Subject: [bug#77387] [PATCH 0/2] man-db: Better parsing of man macros. Resent-From: Sergey Trofimov <sarg@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: guix@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN Resent-Date: Sun, 30 Mar 2025 14:27:02 +0000 Resent-Message-ID: <handler.77387.B.174334479113013 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: report 77387 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77387 <at> debbugs.gnu.org Cc: Sergey Trofimov <sarg@HIDDEN>, Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN> X-Debbugs-Original-To: guix-patches@HIDDEN X-Debbugs-Original-Xcc: Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN> Received: via spool by submit <at> debbugs.gnu.org id=B.174334479113013 (code B ref -1); Sun, 30 Mar 2025 14:27:02 +0000 Received: (at submit) by debbugs.gnu.org; 30 Mar 2025 14:26:31 +0000 Received: from localhost ([127.0.0.1]:37659 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tytcM-0003Np-Mb for submit <at> debbugs.gnu.org; Sun, 30 Mar 2025 10:26:31 -0400 Received: from lists.gnu.org ([2001:470:142::17]:55086) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <sarg@HIDDEN>) id 1tytcJ-0003ND-Le for submit <at> debbugs.gnu.org; Sun, 30 Mar 2025 10:26:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <sarg@HIDDEN>) id 1tytbq-0005aH-D1 for guix-patches@HIDDEN; Sun, 30 Mar 2025 10:25:58 -0400 Received: from mail-ed1-x531.google.com ([2a00:1450:4864:20::531]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <sarg@HIDDEN>) id 1tytbo-0006nb-DE for guix-patches@HIDDEN; Sun, 30 Mar 2025 10:25:58 -0400 Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-5e5e63162a0so2051086a12.3 for <guix-patches@HIDDEN>; Sun, 30 Mar 2025 07:25:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sarg.org.ru; s=google; t=1743344751; x=1743949551; darn=gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=lqTqnWUoFSHwpuGES5pQSahBA12+x1BLK5szO+pAQwM=; b=eA33w2oyRj3QC/RrZukHahFegWK1ANNq13DQk6SkTP9K/9Mp6dpIt/DbyxbmjluYpq dbeG6XR1TNcY0MgWyzPpnQloZJ+F1Ow9SVKTdbngxP2KnYgFyYaeBIuNfC5MxyLEBDiv /4Pwbo9l6J0TQ5449TMka5kVJx3tK6dDeDi+A7OcxxcdyinoOJ9pmhF+42bn/SEKz/Aa 1xRSLiC531bWJ99GnyGSHN0XH2Z0dS2vcv3mtqvjsmGm6n0csgY0AQdo1gkF+2dwSr3d LQRWzsPu3L+/K76B6wzsT8A5VjSAtQEGB0C4FdnZ3dE5oUq/4cGDPLpKPIhInzsw5AaU NWfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743344751; x=1743949551; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=lqTqnWUoFSHwpuGES5pQSahBA12+x1BLK5szO+pAQwM=; b=HSP9dX3yXHKzse0MkVlzjwkJ6GvW+K06EsEE22l3ZKeUek02XXBXVnqHXe+szhFsHo oTZFQYiMl5WYKGKli3wm9h7w/oUJKXTxSKZ1yE7jVGUjO2VgOIOY6sLj6s9xGBdBJ1qy UEVzf2d3Ts/qaXjG16hGdlRy1CbOAoMDSx1umwpz2vpsY3G4sHqLQKA7F6BqXVcZQx8T ZZ9eREx/9auhpAGJJOjXzrrnC+bPw8TwaeH21c+tqkMu+W9wg+iCXYYVHEGY13eCmYXv 9faBMo0zObGk8cPG0e7j6qtPuQK2/F7jvv7FO0WYrck52PAZ+YfhzlrhmYM9G8Rju0Iy kNkA== X-Gm-Message-State: AOJu0Yw+kTk71gwYuHLO1ZcOpk1+GkvyJOHzT5Lz7wTNqbnTyY4qo0tI 3jhnCvOB+sco90mlwRz4TauLV1j7u6nip9K4cKGau8x+YynnxLk3U+NaKxuGuFDHwRzD81F1yZJ 6rX4= X-Gm-Gg: ASbGnctNMEGys/2vM4bhS1YGeKN7s73g3O0uDdYpN2cZDL1CP/l7yY1RtSdocunBqxs /RBCb2GI/fkArI3xy40UMhRSqJH+qB9lCE0RjEsV/sTndi2BPi1EoN78SvOeoF9+Of7et3Rdfpe m9zV21da/9zmPmapAvD0biwcohh1hcM/ywcw2zipYqApdMEYRfkVlSURfHDfBrj2Fvf30NeloZ+ UcjPAD+wW6kITw1OW2QdhJ7z15K9s3yn2xfVF8ZexLFIubnkEssxuBmawWZVJx+6h7NcsEAhIMy 2apfGRBVy60PCBGo9FQr8wsMWGMvdRakPhOwJEfimQ== X-Google-Smtp-Source: AGHT+IHtj9PU0I8V2K2+oBV1G/hM9eO77M5kNvH+svq9TnE71sHR/QqJeJ/Oja+Jwb5fx4Gg2Gda1A== X-Received: by 2002:a05:6402:51c6:b0:5e4:cd5c:50f6 with SMTP id 4fb4d7f45d1cf-5edfd157900mr4971295a12.18.1743344751412; Sun, 30 Mar 2025 07:25:51 -0700 (PDT) Received: from localhost ([2a02:2454:a095:5600:a64e:31ff:fe38:fd6c]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5edc16d4752sm4349139a12.27.2025.03.30.07.25.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Mar 2025 07:25:50 -0700 (PDT) From: Sergey Trofimov <sarg@HIDDEN> Date: Sun, 30 Mar 2025 16:25:46 +0200 Message-ID: <cover.1743343624.git.sarg@HIDDEN> X-Mailer: git-send-email 2.49.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2a00:1450:4864:20::531; envelope-from=sarg@HIDDEN; helo=mail-ed1-x531.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 1.0 (+) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -0.0 (/) Hey guix, I've noticed that quite a lot man pages are reported to belong to a wrong section by `man -k`: --8<---------------cut here---------------start------------->8--- $ man -k "" | grep "(0)" ... ssh-pkcs11-helper (0) - (unknown subject) ssh-sk-helper (0) - (unknown subject) ssh_config (0) - (unknown subject) sshd (0) - (unknown subject) sshd_config (0) - (unknown subject) sudo (0) - (unknown subject) sudo.conf (0) - (unknown subject) tc-cgroup (0) - control group based traffic control filter tc-connmark (0) - (unknown subject) ... --8<---------------cut here---------------end--------------->8--- A side-effect of it is that `M-x man` doesn't list such pages in auto-completion. I've attempted to fix that, see the following patch. With the patch `man -k` and `M-x man` work properly: --8<---------------cut here---------------start------------->8--- $ man -k sudo cvtsudoers (1) - (unknown subject) sudo (8) - (unknown subject) sudo.conf (5) - (unknown subject) sudo_logsrv.proto (5) - (unknown subject) sudo_logsrvd (8) - (unknown subject) ... --8<---------------cut here---------------end--------------->8--- Note, that synopsis extraction also needs improvement, however it turns out to be more complicated as proper formatting requires cleaning up / expanding macros. Sergey Trofimov (2): man-db: Parse man macro arguments better. man-db: Support mdoc-formatted man pages. guix/man-db.scm | 52 ++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 43 insertions(+), 9 deletions(-) base-commit: 2ed28b5c24c599b2f9bc60dfc93151cf489ca477 -- 2.49.0
Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) Content-Type: text/plain; charset=utf-8 X-Loop: help-debbugs@HIDDEN From: help-debbugs@HIDDEN (GNU bug Tracking System) To: Sergey Trofimov <sarg@HIDDEN> Subject: bug#77387: Acknowledgement ([PATCH 0/2] man-db: Better parsing of man macros.) Message-ID: <handler.77387.B.174334479113013.ack <at> debbugs.gnu.org> References: <cover.1743343624.git.sarg@HIDDEN> X-Gnu-PR-Message: ack 77387 X-Gnu-PR-Package: guix-patches X-Gnu-PR-Keywords: patch Reply-To: 77387 <at> debbugs.gnu.org Date: Sun, 30 Mar 2025 14:27:02 +0000 Thank you for filing a new bug report with debbugs.gnu.org. This is an automatically generated reply to let you know your message has been received. Your message is being forwarded to the package maintainers and other interested parties for their attention; they will reply in due course. As you requested using X-Debbugs-CC, your message was also forwarded to Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>,= Ludovic Court=C3=A8s <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, = Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@tobias= .gr> (after having been given a bug report number, if it did not have one). Your message has been sent to the package maintainer(s): guix-patches@HIDDEN If you wish to submit further information on this problem, please send it to 77387 <at> debbugs.gnu.org. Please do not send mail to help-debbugs@HIDDEN unless you wish to report a problem with the Bug-tracking system. --=20 77387: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D77387 GNU Bug Tracking System Contact help-debbugs@HIDDEN with problems
X-Loop: help-debbugs@HIDDEN Subject: [bug#77387] [PATCH 1/2] man-db: Parse man macro arguments better. Resent-From: Sergey Trofimov <sarg@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: guix@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN Resent-Date: Sun, 30 Mar 2025 15:51:01 +0000 Resent-Message-ID: <handler.77387.B77387.174334983728401 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 77387 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77387 <at> debbugs.gnu.org Cc: Sergey Trofimov <sarg@HIDDEN>, Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN> X-Debbugs-Original-Xcc: Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN> Received: via spool by 77387-submit <at> debbugs.gnu.org id=B77387.174334983728401 (code B ref 77387); Sun, 30 Mar 2025 15:51:01 +0000 Received: (at 77387) by debbugs.gnu.org; 30 Mar 2025 15:50:37 +0000 Received: from localhost ([127.0.0.1]:37819 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tyuvk-0007O1-E8 for submit <at> debbugs.gnu.org; Sun, 30 Mar 2025 11:50:36 -0400 Received: from mail-ej1-x630.google.com ([2a00:1450:4864:20::630]:56421) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from <sarg@HIDDEN>) id 1tyuvh-0007Ng-BW for 77387 <at> debbugs.gnu.org; Sun, 30 Mar 2025 11:50:34 -0400 Received: by mail-ej1-x630.google.com with SMTP id a640c23a62f3a-ac2bdea5a38so612505366b.0 for <77387 <at> debbugs.gnu.org>; Sun, 30 Mar 2025 08:50:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sarg.org.ru; s=google; t=1743349826; x=1743954626; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=t96MmNdEdMDhyCwll8S1Y4AAwglQBlqeJl7Mq5jnfOE=; b=sIBKmVhJzVJHLVkS4hLla2lnst4nwt54e6oD6H54s70IexaMu3xomoDtFsoJ5ocFT8 xf/dFwyhNMbq2P2GEoQWdYehP27ZoPgacIBEgAvPTlsiQiw2t3RctXmQBnmlvXBC4Kc5 YorHYHR1+7mP6CpHu8tlDdBcifOw0BsoFLK116PF8Nbg5TecmUogg3JvHb9C+GN3ag/m /VFyoZDRxZPaInlOtEORaEoG5sMXjNdGV1GjF16V1t1CP9YOC+ZNF7GkxiGVEXjDQD8k L+0XGcHoSCdloZxUGUo3weohoSOwB3d55M+1l2vlDLbrg5upSokKgoMOr6fjmyxghvL0 AorA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743349826; x=1743954626; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=t96MmNdEdMDhyCwll8S1Y4AAwglQBlqeJl7Mq5jnfOE=; b=k7jmT/6AM3f/uBx92JwaEGNA/fW1RaiAEkVUJc5ND5pJnuuXkUEThEQPBdi47r61tt vDhIxddJsGut7cv9umLL1vx9m8rGJ/GghmvD/Kfl01M/Nry2lQ50Orj1moeEqFvu281y t5bVXy1cFFGyWyk2h86ATlbGhihf5YpdHLw97WQJmVJhH6utLta0jbuBGUz9KPPUaCE5 JT692A+Ve/teA6pg68pfYDY7yU3wJFCCyr/0pdEA7erYKv2MNdHY7IBGwLBYspi55ixb u4qjGfattc9hCw5EfIknvisSLf/KTyzu8yGtXC98ykaLqZB0eFeCSG3BmXZGKz+ORJM8 16Vg== X-Gm-Message-State: AOJu0YyqZru8yuQAY5IrcaAyoOwNXvhVF+xjnJ5dL6K1bzInb6UoDImr xcPHOaA2spw+iQtcxtbIsSE8pxwGH4ARO1/CLxnn59JypfvNMu0LdwwP5XiJDsm3muKK1EVKV7W pwB0= X-Gm-Gg: ASbGnctaoOlN4yetAkIL6NpfbVfpVDUksEZp/oBkTYMdRNCJQFEbRvZfLvnuDOVzrws zq5fZzjeXpp6JlmExiiGY22eXLvzPD6C3fpWhgOty+y7hAwXiJMP/9h52azuY9aQbh4kK+cWosp xE3CVZsG2uKex7URCsZOUPPopPmUKKRr8oDqmxKLvHNnl6W3ITeq3e1F087zApMGWR13Mn72F1s cBI5/yHVwssPMYGZeWFA8dbOaXpVarjo1TvV3MJa187vBQYrGREntEt9l8iA8CR0U9CgWE0kLzm 675eX//TGrz2L/5qiU9abc7cPU+zIh9bdVbI7bMlFQ== X-Google-Smtp-Source: AGHT+IHvNbYf7df6BsEix2t5VBrZtoNQSXlrk0ifDr2L6MfeUhdYaosxNMsV/iYXTIcWFlf/9KMaZA== X-Received: by 2002:a17:907:948b:b0:abf:6db5:c9a9 with SMTP id a640c23a62f3a-ac738bbe871mr479144566b.39.1743349825836; Sun, 30 Mar 2025 08:50:25 -0700 (PDT) Received: from localhost ([2a02:2454:a095:5600:a64e:31ff:fe38:fd6c]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5edc16d4f4bsm4419215a12.30.2025.03.30.08.50.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Mar 2025 08:50:25 -0700 (PDT) From: Sergey Trofimov <sarg@HIDDEN> Date: Sun, 30 Mar 2025 16:32:54 +0200 Message-ID: <7068d5eb173f3d0c7cb69ae9592cb61b2dd84281.1743343624.git.sarg@HIDDEN> X-Mailer: git-send-email 2.49.0 In-Reply-To: <cover.1743343624.git.sarg@HIDDEN> References: <cover.1743343624.git.sarg@HIDDEN> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) * guix/man-db.scm (man-macro-tokenize): New procedure to parse man macros. (man-page->entry): Parse macro line using man-macro-tokenize. Change-Id: Iea0ffbc65290757df746138e0a6174646b5a3eb8 --- guix/man-db.scm | 52 ++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 43 insertions(+), 9 deletions(-) diff --git a/guix/man-db.scm b/guix/man-db.scm index bba90ed473..44c01ac298 100644 --- a/guix/man-db.scm +++ b/guix/man-db.scm @@ -161,16 +161,50 @@ (define (read-synopsis port) (line (loop (cons line lines)))))) +(define (man-macro-tokenize input) + (let loop ((pos 0) + (tokens '()) + (current '()) + (in-string? #f)) + (if (>= pos (string-length input)) + ;; End of input + (unless in-string? + (reverse (if (null? current) + tokens + (cons (list->string (reverse current)) tokens)))) + (let ((c (string-ref input pos))) + (cond + ;; Inside a string + (in-string? + (if (char=? c #\") + (if (and (< (+ pos 1) (string-length input)) + (char=? (string-ref input (+ pos 1)) #\")) + ;; Double quote inside string + (loop (+ pos 2) tokens (cons #\" current) #t) + ;; End of string + (loop (+ pos 1) (cons (list->string (reverse current)) tokens) '() #f)) + ;; Regular character in string + (loop (+ pos 1) tokens (cons c current) #t))) + + ;; Whitespace outside string + ((char-whitespace? c) + (if (null? current) + (loop (+ pos 1) tokens '() #f) + (loop (+ pos 1) (cons (list->string (reverse current)) tokens) '() #f))) + + ;; Start of string + ((char=? c #\") + (if (null? current) + (loop (+ pos 1) tokens '() #t) + (loop pos (cons (list->string (reverse current)) tokens) '() #f))) + + ;; Symbol character + (else + (loop (+ pos 1) tokens (cons c current) #f))))))) + (define* (man-page->entry file #:optional (resolve identity)) "Parse FILE, a gzip or zstd compressed man page, and return a <mandb-entry> for it." - (define (string->number* str) - (if (and (string-prefix? "\"" str) - (> (string-length str) 1) - (string-suffix? "\"" str)) - (string->number (string-drop (string-drop-right str 1) 1)) - (string->number str))) - (define call-with-input-port* (cond ((gzip-compressed? file) call-with-gzip-input-port) @@ -189,8 +223,8 @@ (define* (man-page->entry file #:optional (resolve identity)) (if (eof-object? line) (mandb-entry file name (or section 0) (or synopsis "") kind) - (match (string-tokenize line) - ((".TH" name (= string->number* section) _ ...) + (match (if (string-prefix? "." line) (man-macro-tokenize line) #f) + ((".TH" name (= string->number section) _ ...) (loop name section synopsis kind)) ((".SH" (or "NAME" "\"NAME\"")) (loop name section (read-synopsis port) kind)) -- 2.49.0
X-Loop: help-debbugs@HIDDEN Subject: [bug#77387] [PATCH 2/2] man-db: Support mdoc-formatted man pages. Resent-From: Sergey Trofimov <sarg@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: guix@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN Resent-Date: Sun, 30 Mar 2025 15:51:02 +0000 Resent-Message-ID: <handler.77387.B77387.174334983728409 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 77387 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77387 <at> debbugs.gnu.org Cc: Sergey Trofimov <sarg@HIDDEN>, Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN> X-Debbugs-Original-Xcc: Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN> Received: via spool by 77387-submit <at> debbugs.gnu.org id=B77387.174334983728409 (code B ref 77387); Sun, 30 Mar 2025 15:51:02 +0000 Received: (at 77387) by debbugs.gnu.org; 30 Mar 2025 15:50:37 +0000 Received: from localhost ([127.0.0.1]:37821 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tyuvl-0007O8-2o for submit <at> debbugs.gnu.org; Sun, 30 Mar 2025 11:50:37 -0400 Received: from mail-ej1-x629.google.com ([2a00:1450:4864:20::629]:50646) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from <sarg@HIDDEN>) id 1tyuvi-0007Ni-RB for 77387 <at> debbugs.gnu.org; Sun, 30 Mar 2025 11:50:35 -0400 Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-ac339f53df9so674377066b.1 for <77387 <at> debbugs.gnu.org>; Sun, 30 Mar 2025 08:50:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sarg.org.ru; s=google; t=1743349828; x=1743954628; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+v61YczsJiy0hyAaMtUpc1cPgjb+r21CvSHSPhJsarw=; b=cAAVIsqmUtQs8iNK9R3tgx3BagcAB9twET1rXhrYXK+brlPzWCTn2LQMoIu2ulI/0M vOa0mhynTONTcUImZ6YQeettcdx5c2iYeme+a3QCiOYDTyKE5MQbimd/x2mcwSOE03Az R2Yk/V11TpxNMK7m8Y4tfs3Z1zKOUBszUqfomEGHkDg2qd5GlP+oA9hSMPY/hlnbAdJx 0K381TS/Kr5csLauq5a8Qibtls62OSKg0vDh+mQRZ0cL56weZxN/f2vA0+cNfMowLOmt dsaMAdnCdHHPr4zcq4gOXWv8zhbZbNcYLE0PGRTaepVeKiKOSYbtlj5ZbIv64yFzSIEV ik9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743349828; x=1743954628; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+v61YczsJiy0hyAaMtUpc1cPgjb+r21CvSHSPhJsarw=; b=j9YCuz8AliNHO7vD0f11iKlbYjrw41C4wkRSjq0BtLupzL4MEOE13lYO9g43t0yLUI QRAWdu+hKHqxEzcwSMDvHKvBi8HAe7rDxxAsz0YgxXA+jIG1Suq+l4iR39zmOahY7nkn +AjD33OVVT8+PeYAqmx8HN5AXdRVaDmg4Mjb62vtc2alyMLf5BbeF3sKQwosSN5+SbOU a+i6GfHSoAu62pVPuBtGK/v1FTYVS01I8weTB3TyqzJDcMTN+U0tWTyD1YWMtTII5BKn KOrIFLo4BMX2dzTtZFpQEhsxE5v9xBepd6uBGZY144412oBwvtOBb+H94YD71P2EKA7S B2dA== X-Gm-Message-State: AOJu0Yxmp1EmxcOSHYjv2aL+STOE/5HvTX/Y+1fPeLJQouLI76ywg9rz 0WexUyVRhwGYwCp5vkdqaNVC8DFTlO1CVt7KjseIwCjAXzgO1agbcZlucH0U6xmL5aY8d+j2/Jc aBEw= X-Gm-Gg: ASbGncs7qcMIuHYDSkWgkm+DEZuaL+VpNTZgtmHbF2thQRNO05/tMcV/OhHxuhJVrxS haIwrvvUJQA6phsPOdvdaM9l87qcPdOdaaXQ5mHFJ3i3W811hXEdjX/0Oq/6lEb2UQKR8kOfpsh YWqgXI5LuQdNCbzRtNFwJYJej0Sd1oh3u/86kLRWhvyGWheWJWKKfn2rvVTYg8wXCUUFDriojLy QbTQ0fSOPqEQlU1f71KIgC+MYoBDFZkDuhcH+9jAPzFd73VK6d+wYXZjxJFAlqF2QWXtnS9uw9x XxjR9vVAeFDV5/M7xGTCZJQH5WpkaqexqWyGeqMqvg== X-Google-Smtp-Source: AGHT+IEwY8isAsHwZNFvlpcPk+BjZlptC5xsEBDAlvvrRV+sMl9YBAWnRXVLKLXwavH7VXYo793qGA== X-Received: by 2002:a17:907:d14:b0:ac3:9587:f2ac with SMTP id a640c23a62f3a-ac738a8db2bmr559568866b.33.1743349827462; Sun, 30 Mar 2025 08:50:27 -0700 (PDT) Received: from localhost ([2a02:2454:a095:5600:a64e:31ff:fe38:fd6c]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ac71922ba02sm500642166b.10.2025.03.30.08.50.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Mar 2025 08:50:27 -0700 (PDT) From: Sergey Trofimov <sarg@HIDDEN> Date: Sun, 30 Mar 2025 16:32:55 +0200 Message-ID: <43b006e62f2034b3acdd611e72029c9664922618.1743349817.git.sarg@HIDDEN> X-Mailer: git-send-email 2.49.0 In-Reply-To: <7068d5eb173f3d0c7cb69ae9592cb61b2dd84281.1743349817.git.sarg@HIDDEN> References: <7068d5eb173f3d0c7cb69ae9592cb61b2dd84281.1743349817.git.sarg@HIDDEN> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) * guix/man-db.scm (man-page->entry): Extract man name and section from .Dt macro. Change-Id: I02dc99d73dceecdb077315805025efad9a650e91 --- guix/man-db.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guix/man-db.scm b/guix/man-db.scm index 44c01ac298..44668a3ebf 100644 --- a/guix/man-db.scm +++ b/guix/man-db.scm @@ -224,7 +224,7 @@ (define* (man-page->entry file #:optional (resolve identity)) (mandb-entry file name (or section 0) (or synopsis "") kind) (match (if (string-prefix? "." line) (man-macro-tokenize line) #f) - ((".TH" name (= string->number section) _ ...) + (((or ".TH" ".Dt") name (= string->number section) _ ...) (loop name section synopsis kind)) ((".SH" (or "NAME" "\"NAME\"")) (loop name section (read-synopsis port) kind)) -- 2.49.0
X-Loop: help-debbugs@HIDDEN Subject: [bug#77387] [PATCH 1/2] man-db: Parse man macro arguments better. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: guix-patches@HIDDEN Resent-Date: Tue, 01 Apr 2025 12:09:04 +0000 Resent-Message-ID: <handler.77387.B77387.174350929328773 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 77387 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Sergey Trofimov <sarg@HIDDEN> Cc: Josselin Poiret <dev@HIDDEN>, 77387 <at> debbugs.gnu.org, Simon Tournier <zimon.toutoune@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>, Christopher Baines <guix@HIDDEN> Received: via spool by 77387-submit <at> debbugs.gnu.org id=B77387.174350929328773 (code B ref 77387); Tue, 01 Apr 2025 12:09:04 +0000 Received: (at 77387) by debbugs.gnu.org; 1 Apr 2025 12:08:13 +0000 Received: from localhost ([127.0.0.1]:46850 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tzaPc-0007Tv-2O for submit <at> debbugs.gnu.org; Tue, 01 Apr 2025 08:08:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58648) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <ludo@HIDDEN>) id 1tzaPa-0007Ss-40 for 77387 <at> debbugs.gnu.org; Tue, 01 Apr 2025 08:08:10 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <ludo@HIDDEN>) id 1tzaPQ-000739-BT; Tue, 01 Apr 2025 08:08:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=9ew0dvI46yQTSjiysMx/VlPtOnfXcAWbqBSoRiLa43I=; b=r89ZkvXjRo/OCWKK+OQJ vjqxGt15UpDXCBcH55PAkUQItqNA5ALZpyhAabpb/0vMAQCS0AzysnkkzU7rgYjbXK8KF32qFzT3u FjDgtE07zDhRTuhZAJKaQTfqzHp4BLKshtwLR/GfyRpXlklKdPKaNQgX5gYY0a4yqsv+PuPT7i/1b JKvHR/gFkUxO1rGsDAErB91B8yq6PLS7KVfkv7lj1SHkCMgR9kXMc9aaxsNoxsGEz/W6ohAzxc2hs DC2PNA5E4wTLQsg22E6PKqmMJoCnNnqpf9P0z01ttsQ1f24W7tlj+pj9UsqWWJaC9TjX8kPR36Xk/ mt1SAdhwxsKo4g==; From: Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN> In-Reply-To: <7068d5eb173f3d0c7cb69ae9592cb61b2dd84281.1743343624.git.sarg@HIDDEN> (Sergey Trofimov's message of "Sun, 30 Mar 2025 16:32:54 +0200") References: <cover.1743343624.git.sarg@HIDDEN> <7068d5eb173f3d0c7cb69ae9592cb61b2dd84281.1743343624.git.sarg@HIDDEN> Date: Tue, 01 Apr 2025 14:07:35 +0200 Message-ID: <87r02cdr08.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) Hi! Glad you fixed this problem. :-) Sergey Trofimov <sarg@HIDDEN> skribis: > * guix/man-db.scm (man-macro-tokenize): New procedure to parse man > macros. > (man-page->entry): Parse macro line using man-macro-tokenize. > > Change-Id: Iea0ffbc65290757df746138e0a6174646b5a3eb8 [...] > +(define (man-macro-tokenize input) Could you add a docstring explaining what it takes and what it returns? > + (let loop ((pos 0) > + (tokens '()) > + (current '()) Maybe s/current/characters/ ? > + (in-string? #f)) > + (if (>=3D pos (string-length input)) > + ;; End of input > + (unless in-string? > + (reverse (if (null? current) > + tokens > + (cons (list->string (reverse current)) tokens)))) So this procedure can return *unspecified*, right? Sounds fishy. > @@ -189,8 +223,8 @@ (define* (man-page->entry file #:optional (resolve id= entity)) > (if (eof-object? line) > (mandb-entry file name (or section 0) (or synopsis "") > kind) > - (match (string-tokenize line) > - ((".TH" name (=3D string->number* section) _ ...) > + (match (if (string-prefix? "." line) (man-macro-tokeni= ze line) #f) > + ((".TH" name (=3D string->number section) _ ...) Please add a comment above =E2=80=98match=E2=80=99 explaining what=E2=80=99= s happening (why we call =E2=80=98man-macro-tokenize=E2=80=99 etc.). Also: (and (string-prefix? "." line) (man-macro-tokenize line)) Ludo=E2=80=99.
X-Loop: help-debbugs@HIDDEN Subject: [bug#77387] [PATCH 2/2] man-db: Support mdoc-formatted man pages. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: guix-patches@HIDDEN Resent-Date: Tue, 01 Apr 2025 12:09:05 +0000 Resent-Message-ID: <handler.77387.B77387.174350932829152 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 77387 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Sergey Trofimov <sarg@HIDDEN> Cc: Josselin Poiret <dev@HIDDEN>, 77387 <at> debbugs.gnu.org, Simon Tournier <zimon.toutoune@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>, Christopher Baines <guix@HIDDEN> Received: via spool by 77387-submit <at> debbugs.gnu.org id=B77387.174350932829152 (code B ref 77387); Tue, 01 Apr 2025 12:09:05 +0000 Received: (at 77387) by debbugs.gnu.org; 1 Apr 2025 12:08:48 +0000 Received: from localhost ([127.0.0.1]:46855 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tzaQA-0007Zx-VV for submit <at> debbugs.gnu.org; Tue, 01 Apr 2025 08:08:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45998) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <ludo@HIDDEN>) id 1tzaQ8-0007YU-5K for 77387 <at> debbugs.gnu.org; Tue, 01 Apr 2025 08:08:44 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <ludo@HIDDEN>) id 1tzaQ1-0007Ac-NA; Tue, 01 Apr 2025 08:08:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=c4ZJ/WQJhBLo5uQFJnexOX9sIuoXsmMT9ivg6+k4gPo=; b=jixOHmAIzf33tMIQrfIr 6YvaNIdYCnZrtGiJIcN0qW2nJ9Ex8r78ucpp78oCLAihlM/yIeAiqTPEHn5nBUuuGd2LGtV67MXLl 8LyEBJZ59VMbHgLrq0Zmw8FMyoVZj+rSEiuTJoMYDUd2o2KW6bSjKJHJv+mf2JbaIxDRixkzuAjVg QY9+L8HRgHejyN/hWsEfm55DX/jcbPqP8gPnV8MsTKju6fSLtXSAsFaHp9QfDwzBBluz8B7c3vzcM +3CSc9uOf2iHSY56cyP5ttJpxShnKgj6MlXDEatcX+syPRp/ii2Mg+bjuLF2+MDxwKMvtj4x/36r5 98JHXrSPXMsMmA==; From: Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN> In-Reply-To: <43b006e62f2034b3acdd611e72029c9664922618.1743349817.git.sarg@HIDDEN> (Sergey Trofimov's message of "Sun, 30 Mar 2025 16:32:55 +0200") References: <7068d5eb173f3d0c7cb69ae9592cb61b2dd84281.1743349817.git.sarg@HIDDEN> <43b006e62f2034b3acdd611e72029c9664922618.1743349817.git.sarg@HIDDEN> Date: Tue, 01 Apr 2025 14:08:31 +0200 Message-ID: <87msd0dqyo.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) Sergey Trofimov <sarg@HIDDEN> skribis: > * guix/man-db.scm (man-page->entry): Extract man name and section from > .Dt macro. > > Change-Id: I02dc99d73dceecdb077315805025efad9a650e91 [...] > (match (if (string-prefix? "." line) (man-macro-tokeni= ze line) #f) > - ((".TH" name (=3D string->number section) _ ...) > + (((or ".TH" ".Dt") name (=3D string->number section)= _ ...) Likewise, please add a short comment above the clause explaining that =E2=80=98.Dt=E2=80=99 is produced by =E2=80=98mandoc=E2=80=99 (did I get th= at right?). Ludo=E2=80=99.
X-Loop: help-debbugs@HIDDEN Subject: [bug#77387] [PATCH v1 1/2] man-db: Parse man macro arguments better. References: <cover.1743343624.git.sarg@HIDDEN> In-Reply-To: <cover.1743343624.git.sarg@HIDDEN> Resent-From: Sergey Trofimov <sarg@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: sarg@HIDDEN, ludo@HIDDEN, guix@HIDDEN, dev@HIDDEN, othacehe@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN Resent-Date: Tue, 01 Apr 2025 19:33:02 +0000 Resent-Message-ID: <handler.77387.B77387.174353594713063 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 77387 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77387 <at> debbugs.gnu.org Cc: Sergey Trofimov <sarg@HIDDEN>, Sergey Trofimov <sarg@HIDDEN>, Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>, Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN> X-Debbugs-Original-Xcc: Sergey Trofimov <sarg@HIDDEN>, Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>, Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN> Received: via spool by 77387-submit <at> debbugs.gnu.org id=B77387.174353594713063 (code B ref 77387); Tue, 01 Apr 2025 19:33:02 +0000 Received: (at 77387) by debbugs.gnu.org; 1 Apr 2025 19:32:27 +0000 Received: from localhost ([127.0.0.1]:51387 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tzhLW-0003OU-42 for submit <at> debbugs.gnu.org; Tue, 01 Apr 2025 15:32:26 -0400 Received: from mail-ej1-x634.google.com ([2a00:1450:4864:20::634]:50442) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from <sarg@HIDDEN>) id 1tzhLT-0003NM-Lq for 77387 <at> debbugs.gnu.org; Tue, 01 Apr 2025 15:32:25 -0400 Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-ac339f53df9so1047733566b.1 for <77387 <at> debbugs.gnu.org>; Tue, 01 Apr 2025 12:32:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sarg.org.ru; s=google; t=1743535937; x=1744140737; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=84B+HaKIkCtXiSnzduMypItwc6yngjgrkSnqfB23XGQ=; b=idEBLc69R1J5wDfKuHB8QGeYXmUQTAj7f52mEf6d7BOYweOurbhnpWaWyCp+z5NTXw /BHdZdLdofoZ+95Tvto9ShrlbRoyj0iYzLZjOgZb1VxDeGfE/AHKnR3wNao9HOT3IAYZ CyAZZWNQ0HzRmDBSkbQvgl2L69FS5aLKIwpuxNxX8vSGdeXzKXkmdchlFNsVM8NMQMUR UJn+rmjJiuPQDH94QFxcMqvnqoV0pgtDiAtPkuH2ZZyMDukNjHfkNm0BOCyXYrUBYGfk 1DGcvFPPfXYFfm3j1FyGZ3g48iYY7t/WmBwyhLMQbkry4JEXan59iI3mBIZMaJbg+gYf Yfyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743535937; x=1744140737; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=84B+HaKIkCtXiSnzduMypItwc6yngjgrkSnqfB23XGQ=; b=l8bH10go+CfBw5vWMCyfXOKUuKXAgUMtv1IENRWEIwj0gvPNZR1rzDc/kXDkVi5OZG yU7cB6aUxj0nGcJDZYDSOUQkdkdh1TopQmJG3n5I2ux74fpmrnBQvRZRBJCcQZl1FKXn ZxpfGHXHwye4CV0wXC2uIWo9AvgdaVYBS0WqeRmTdRnJTfj42IHTBlKMRfYKeU6Z/j/0 Eejck9XN58K2oPICXS/q4g0IKV1dt4atePDukInQT5MjDmjwYuqG+O2jXnfdT2RtflJo av1sFOAoMDyL0dzA7HnyzKblUpjmRL8PkVFFwIyjZTiRQ4vJ+YhbecV3rFhEml/fBj4t KKzA== X-Gm-Message-State: AOJu0Yygs0BgoCbSrZeKptLElUYusodn92ER+JYF9Lrbp5dVHpYJPFXN SSwyKKhUKWUar6pqeEaE4EXyOWtosUJuFEk24OhPI+x3wCyb3GkuKp5ZUmBWAWHM8dUEZyWvNok JYJk= X-Gm-Gg: ASbGncs5tHW9jK8qi+5y9KhcXaV2F8wlbx9DSF05mDr1Oh2MlncEynyx8OK7Mc2fcq1 lm0HgmV+syVCDggVnymbUEBnnVTr7vN/gndJkN+q0CBzzHacQ4Fd7vbNhe2waARw+1qswyVXrXK w62nZUl6qCRPtEe0PFZTKArrScNPnsbeUUHW7jvvTqwZsWal6U59TNkRC93vhgCtCZdAGJhGMDD 6kVrvErj2xVosd6u8DfaB2dp7PO4XvRHjsZXoVqQL+8BciJfZlYhrxEjLCqSvITC7stIX18jEBX yD8cz1ecd4DKCZMGYvJ9Zfuo4HU4/DTXhOW8Yo2jLQ== X-Google-Smtp-Source: AGHT+IEqMwPmDSPU8HHmcL9LMU/JzTkgRFHo1CXTSWqQ+/F26XMBvTzUwqO+Dh0vu2TtBaKWgT/JyA== X-Received: by 2002:a17:906:c144:b0:ac1:def4:ce20 with SMTP id a640c23a62f3a-ac7389e6c75mr1343218166b.18.1743535936743; Tue, 01 Apr 2025 12:32:16 -0700 (PDT) Received: from localhost ([2a02:2454:a095:5600:a64e:31ff:fe38:fd6c]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ac71967fcf4sm796746366b.129.2025.04.01.12.32.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Apr 2025 12:32:16 -0700 (PDT) From: Sergey Trofimov <sarg@HIDDEN> Date: Tue, 1 Apr 2025 21:31:59 +0200 Message-ID: <109f10a155f45adf26420b11787153cf96bbdc8b.1743535900.git.sarg@HIDDEN> X-Mailer: git-send-email 2.49.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) * guix/man-db.scm (man-macro-tokenize): New procedure to parse man macros. (man-page->entry): Parse macro line using man-macro-tokenize. Change-Id: Iea0ffbc65290757df746138e0a6174646b5a3eb8 --- guix/man-db.scm | 56 +++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 47 insertions(+), 9 deletions(-) diff --git a/guix/man-db.scm b/guix/man-db.scm index bba90ed473..94231264f0 100644 --- a/guix/man-db.scm +++ b/guix/man-db.scm @@ -161,16 +161,52 @@ (define (read-synopsis port) (line (loop (cons line lines)))))) +(define (man-macro-tokenize input) + "Split INPUT string, a man macro invocation, into a list containing the macro's +name followed by its arguments." + (let loop ((pos 0) + (tokens '()) + (characters '()) + (in-string? #f)) + (if (>= pos (string-length input)) + ;; End of input + (unless in-string? + (reverse (if (null? characters) + tokens + (cons (list->string (reverse characters)) tokens)))) + (let ((c (string-ref input pos))) + (cond + ;; Inside a string + (in-string? + (if (char=? c #\") + (if (and (< (+ pos 1) (string-length input)) + (char=? (string-ref input (+ pos 1)) #\")) + ;; Double quote inside string + (loop (+ pos 2) tokens (cons #\" characters) #t) + ;; End of string + (loop (+ pos 1) (cons (list->string (reverse characters)) tokens) '() #f)) + ;; Regular character in string + (loop (+ pos 1) tokens (cons c characters) #t))) + + ;; Whitespace outside string + ((char-whitespace? c) + (if (null? characters) + (loop (+ pos 1) tokens '() #f) + (loop (+ pos 1) (cons (list->string (reverse characters)) tokens) '() #f))) + + ;; Start of string + ((char=? c #\") + (if (null? characters) + (loop (+ pos 1) tokens '() #t) + (loop pos (cons (list->string (reverse characters)) tokens) '() #f))) + + ;; Symbol character + (else + (loop (+ pos 1) tokens (cons c characters) #f))))))) + (define* (man-page->entry file #:optional (resolve identity)) "Parse FILE, a gzip or zstd compressed man page, and return a <mandb-entry> for it." - (define (string->number* str) - (if (and (string-prefix? "\"" str) - (> (string-length str) 1) - (string-suffix? "\"" str)) - (string->number (string-drop (string-drop-right str 1) 1)) - (string->number str))) - (define call-with-input-port* (cond ((gzip-compressed? file) call-with-gzip-input-port) @@ -189,8 +225,10 @@ (define* (man-page->entry file #:optional (resolve identity)) (if (eof-object? line) (mandb-entry file name (or section 0) (or synopsis "") kind) - (match (string-tokenize line) - ((".TH" name (= string->number* section) _ ...) + ;; man 7 groff groff_mdoc groff_man + ;; look for metadata in macro invocations (lines starting with .) + (match (and (string-prefix? "." line) (man-macro-tokenize line)) + ((".TH" name (= string->number section) _ ...) (loop name section synopsis kind)) ((".SH" (or "NAME" "\"NAME\"")) (loop name section (read-synopsis port) kind)) base-commit: 5735c278e16517d9be5e26235fe68dea9bae3527 prerequisite-patch-id: f9cc903b8048c8c6fde576fbf38ab110263020e3 prerequisite-patch-id: 220ddf11addf3a6c7ab3b349077bca6849241556 prerequisite-patch-id: fc7d254c8dc198bc2f083e1c8aea18960c73b165 prerequisite-patch-id: b6d30068ce4971d4d8e67517229916df4e76c529 -- 2.49.0
X-Loop: help-debbugs@HIDDEN Subject: [bug#77387] [PATCH v1 2/2] man-db: Support mdoc-formatted man pages. Resent-From: Sergey Trofimov <sarg@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: sarg@HIDDEN, ludo@HIDDEN, guix@HIDDEN, dev@HIDDEN, othacehe@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN Resent-Date: Tue, 01 Apr 2025 19:33:02 +0000 Resent-Message-ID: <handler.77387.B77387.174353594813082 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 77387 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77387 <at> debbugs.gnu.org Cc: Sergey Trofimov <sarg@HIDDEN>, Sergey Trofimov <sarg@HIDDEN>, Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>, Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN> X-Debbugs-Original-Xcc: Sergey Trofimov <sarg@HIDDEN>, Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>, Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN> Received: via spool by 77387-submit <at> debbugs.gnu.org id=B77387.174353594813082 (code B ref 77387); Tue, 01 Apr 2025 19:33:02 +0000 Received: (at 77387) by debbugs.gnu.org; 1 Apr 2025 19:32:28 +0000 Received: from localhost ([127.0.0.1]:51389 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tzhLX-0003Oq-Sn for submit <at> debbugs.gnu.org; Tue, 01 Apr 2025 15:32:28 -0400 Received: from mail-ej1-x62f.google.com ([2a00:1450:4864:20::62f]:60621) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from <sarg@HIDDEN>) id 1tzhLV-0003Nc-Fb for 77387 <at> debbugs.gnu.org; Tue, 01 Apr 2025 15:32:25 -0400 Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-ac28e66c0e1so892010866b.0 for <77387 <at> debbugs.gnu.org>; Tue, 01 Apr 2025 12:32:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sarg.org.ru; s=google; t=1743535939; x=1744140739; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9N5M1Capkss/5bpF6QdtNcZTD5SLCSMNQoltOh7SGcI=; b=KnyyEi+jeqvMoJ0fzcLHgXFOqEaIKHnwzkVObyn4S7Wt1RmsbEAdiuDMAhF21rXcXG W16cCO5X8DGevXQPafAhx+MC4bUcVmrshaKB+Dz//q3E17jBiqUJxwVfDz65Nxow3MKN sK+MIjmIcg2DhMKUdzC8FEAg0855oJlOAhouYfXeypnk001x8jPhwZcwgK9Ma1FO4qOA +Bm+ORO3uTSsZQLYfmMGvu5dvlOw+yMS7q9wgwKzdjtaJIAffs1VmSecSzofn6bfXzYX xE/D3mUSrOItdj5obFQGgL9WrJAM3YOoJeygC6N5ywlSEmay9k3+sgFesQ44OydujCRQ 8xlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743535939; x=1744140739; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9N5M1Capkss/5bpF6QdtNcZTD5SLCSMNQoltOh7SGcI=; b=h/ohToiMigkW0FNJ0TBiRpSYMT490sKkWmz8qFr5zCQDWL0SFhJyForZdIP6bCH+D3 ASKI18G3sv1GS8FsOgHOEuwMgTLuNe8WB9wt0TRwqsu1h7XNqq9IlNpFeySiFZeGMpOh s3O9p9a8V+fH2rKZR+mMDJfrTzz81D1il0LMJ2zLGn08mf/pl56WAwbiqrG5EhfBJq80 +lmbZV/aFZHHzYW27JMmyDIgmj7Ap33TPKcVr+ycrVAWupii1acXaAaKztUiFVM24IWB U6dWJLGpX+AvKcpRM3msxxTeEWVg0oexTovUEUrzcwDiIOq/p7zPIpBbZVEySDydwszy i+rg== X-Gm-Message-State: AOJu0YwO1tuTpHGzlUr2NFcTGdKxhF+tH30JRNKnUQEC3bgZpkNezTFQ C7bFlLVRLh7qeYv2eO6x2m8T6RY9MEPOUNksUmr4tFJivpxJeeqYAVtLsHIHxfLJGsXYENGfhtO KirY= X-Gm-Gg: ASbGnctfFS0KCAyzFnNsa90mLHxc8fa+Mt4a+iYe185US4tOH9DtOoruLKTRLLO5kAH 6Gi5tyiwaajew9be3p/ZaYINhc12bDKv43oY+iq74W6c7yIZqBIShhse0CRbrpzC/YTfwUaQD6Z t+f4sPrYXZm+PxXBwfRgH3+ev34hPaH3l5QabEPaiP8Kwq+FjhiOKGIZPbht2eYex+C53HpduF6 LiWOqai0y7r5VqV+hoc5diwuJcqva9iSF9R5TGb8xmPCv13NGgj2t5nk3rH18a9GkbDU7Zx4dpT gG2KiZS1xDENCZSBeAQipmLE6M3iPdu1WhrqMH1Pdw== X-Google-Smtp-Source: AGHT+IFAn7WfTVeqFMdZ0c3YRrFl+WXuGg+SHOGfIkMD5hI+a76Pxx8NZzUkc/bU5BSmCC0PKM3B2A== X-Received: by 2002:a17:907:97c9:b0:ac6:e42b:7556 with SMTP id a640c23a62f3a-ac7389e6743mr1398638466b.11.1743535938917; Tue, 01 Apr 2025 12:32:18 -0700 (PDT) Received: from localhost ([2a02:2454:a095:5600:a64e:31ff:fe38:fd6c]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ac71922c0c5sm805005666b.9.2025.04.01.12.32.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Apr 2025 12:32:18 -0700 (PDT) From: Sergey Trofimov <sarg@HIDDEN> Date: Tue, 1 Apr 2025 21:32:00 +0200 Message-ID: <b861158e0e55b40d58b24ebfec2b80bb2591645b.1743535900.git.sarg@HIDDEN> X-Mailer: git-send-email 2.49.0 In-Reply-To: <109f10a155f45adf26420b11787153cf96bbdc8b.1743535900.git.sarg@HIDDEN> References: <109f10a155f45adf26420b11787153cf96bbdc8b.1743535900.git.sarg@HIDDEN> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) * guix/man-db.scm (man-page->entry): Extract man name and section from .Dt macro. Change-Id: I02dc99d73dceecdb077315805025efad9a650e91 --- guix/man-db.scm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/guix/man-db.scm b/guix/man-db.scm index 94231264f0..7601580c40 100644 --- a/guix/man-db.scm +++ b/guix/man-db.scm @@ -228,10 +228,13 @@ (define* (man-page->entry file #:optional (resolve identity)) ;; man 7 groff groff_mdoc groff_man ;; look for metadata in macro invocations (lines starting with .) (match (and (string-prefix? "." line) (man-macro-tokenize line)) - ((".TH" name (= string->number section) _ ...) + ;; "Title Header" or "Document title" + (((or ".TH" ".Dt") name (= string->number section) _ ...) (loop name section synopsis kind)) + ;; "Section Header" ((".SH" (or "NAME" "\"NAME\"")) (loop name section (read-synopsis port) kind)) + ;; include source ((".so" link) (match (and=> (resolve link) (cut man-page->entry <> resolve)) -- 2.49.0
X-Loop: help-debbugs@HIDDEN Subject: [bug#77387] [PATCH 1/2] man-db: Parse man macro arguments better. Resent-From: Sergey Trofimov <sarg@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: guix-patches@HIDDEN Resent-Date: Tue, 01 Apr 2025 19:43:02 +0000 Resent-Message-ID: <handler.77387.B77387.174353653218095 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 77387 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN> Cc: Josselin Poiret <dev@HIDDEN>, 77387 <at> debbugs.gnu.org, Simon Tournier <zimon.toutoune@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>, Christopher Baines <guix@HIDDEN> Received: via spool by 77387-submit <at> debbugs.gnu.org id=B77387.174353653218095 (code B ref 77387); Tue, 01 Apr 2025 19:43:02 +0000 Received: (at 77387) by debbugs.gnu.org; 1 Apr 2025 19:42:12 +0000 Received: from localhost ([127.0.0.1]:51437 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tzhUy-0004hn-5l for submit <at> debbugs.gnu.org; Tue, 01 Apr 2025 15:42:12 -0400 Received: from mail-ej1-x62a.google.com ([2a00:1450:4864:20::62a]:54769) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from <sarg@HIDDEN>) id 1tzhUw-0004gn-4M for 77387 <at> debbugs.gnu.org; Tue, 01 Apr 2025 15:42:10 -0400 Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-ac6ed4ab410so942899066b.1 for <77387 <at> debbugs.gnu.org>; Tue, 01 Apr 2025 12:42:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sarg.org.ru; s=google; t=1743536524; x=1744141324; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:user-agent :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=IhMum3XPUKVPoAeYgvCpdMIzqcTUC2qwx0tMYQAoPXs=; b=RA0LTmzVCjA/Jf6QyGa0TyQSR/m5RMR3fGdD6hM5i+EJvyc84OlKEGlCznnlqmgeJZ Erse02qgn0YGcbO6JkCuVyKCTxbVmx0NoXwikbpN7iqrx47EfY/9F46VRNyiij4u2EJd 8FJHcN+S7dCTm/IFfwGl9LdSpJikPBVZt23g37K4U276IGEjCU/YygnwIKM0Hdg4ubzt GXSJVCfOaZpBqQsRwrsUrzEMZNHu/62yXxEEPYTrNkNV3dczhCI5U9/AdJR66T1OXHyQ nC0wDYhTsj9H5wVzukCGQPBXkvXcGw5rhGF87wO1hKcG/4cb0+QLraof9Tr6nVNhzUMG gIwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743536524; x=1744141324; h=content-transfer-encoding:mime-version:message-id:date:user-agent :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=IhMum3XPUKVPoAeYgvCpdMIzqcTUC2qwx0tMYQAoPXs=; b=l827uG7SVwrIMgh0l22t3PrEJ/sZpG0MPMpLeE0sKg7/+E3GRtchqhABfymlMn/VaB /yHVU4tZqJMgFG2c/7dRe/M5kCLaE9LTTzixieLr+xzW6P/Yy7qmHBChJS+GmukpSNDe D+1uht1CVJDoq5VZwLu84pD4GuCRDzU0Cll2UV/ZNuaP7rdXPFj+RU/GL2rH2DsngGWw XR+gT2Y0WfhhploejUdZM8D6f7EuzfzsgTwt3rh1utATjSxKS3uSeuV+85x19R6IoHok mXG1+3S5uQrUrXTQdVqPOEsAzplzjW8/iG+8JGSqfo2zWLY4ctXyOniQ8qLmyLWR9spR 5R8g== X-Gm-Message-State: AOJu0Yx3QATp6uyEvM7otcNwRMOIIE4rtJBsyvbP+9oWFblucxg+/U+V xsHTD47UUFDGyIiWFRZnk7WmewmSfttZ1RdROsEld88/kK5cdi8RlSXux9emOshESKAqd647FiA CQBTa7Q== X-Gm-Gg: ASbGncuDYgO7hJV7R4SA43/lFVGvYRkY77It92v8nLD6PyfwAM2x4sWfPgkk0iuBraz 9l8ozLPwXGWXk760XA199vPd44Dbc6V7USkI/snc3vObWm9j10tOdx0HIYaf8OLDA/o3dzeAOFO MFGKZvyivqwKZKIQxH212chS8YuECV5JQdaGmyou2COv0sr817LpwbYSvpYnU4korjGpp9aHGCQ 8FXSR+gaQ7fZOyiGSbmfpxcRji3ssQ9XG+GzNTU92P0x/obm0sh7Mx1oE+z6fCvILW3q/XYsuQH +yKYKSPJt8wQF+TThUcHKp4DaMbd7JRvJXREXNc/Dw== X-Google-Smtp-Source: AGHT+IG7gREhNZYypzpyB+ZoT0O77jnVQrPqfIlTjkGCVhDaSD1Ly+ffV6Rvqt9gIkjtqNotn5CuHQ== X-Received: by 2002:a17:906:cec7:b0:ac7:391a:e157 with SMTP id a640c23a62f3a-ac7391ae294mr1151823666b.58.1743536523944; Tue, 01 Apr 2025 12:42:03 -0700 (PDT) Received: from localhost ([2a02:2454:a095:5600:a64e:31ff:fe38:fd6c]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ac719220358sm801473066b.36.2025.04.01.12.42.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Apr 2025 12:42:03 -0700 (PDT) From: Sergey Trofimov <sarg@HIDDEN> In-Reply-To: <87r02cdr08.fsf@HIDDEN> ("Ludovic =?UTF-8?Q?Court=C3=A8s?="'s message of "Tue, 01 Apr 2025 14:07:35 +0200") References: <cover.1743343624.git.sarg@HIDDEN> <7068d5eb173f3d0c7cb69ae9592cb61b2dd84281.1743343624.git.sarg@HIDDEN> <87r02cdr08.fsf@HIDDEN> User-Agent: mu4e 1.12.9; emacs 30.0.92 Date: Tue, 01 Apr 2025 21:42:02 +0200 Message-ID: <87h637ekj9.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Hi Ludovic, I've sent an amended series. Ludovic Courtès <ludo@HIDDEN> writes: >> + (in-string? #f)) >> + (if (>= pos (string-length input)) >> + ;; End of input >> + (unless in-string? >> + (reverse (if (null? current) >> + tokens >> + (cons (list->string (reverse current)) tokens)))) > > So this procedure can return *unspecified*, right? Sounds fishy. > Why is it fishy? Is it unconventional? Such return value is handled correctly by the calling code (`match`).
X-Loop: help-debbugs@HIDDEN Subject: [bug#77387] [PATCH 1/2] man-db: Parse man macro arguments better. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: guix-patches@HIDDEN Resent-Date: Tue, 08 Apr 2025 15:31:01 +0000 Resent-Message-ID: <handler.77387.B77387.174412624832640 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 77387 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Sergey Trofimov <sarg@HIDDEN> Cc: Josselin Poiret <dev@HIDDEN>, 77387 <at> debbugs.gnu.org, Simon Tournier <zimon.toutoune@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>, Christopher Baines <guix@HIDDEN> Received: via spool by 77387-submit <at> debbugs.gnu.org id=B77387.174412624832640 (code B ref 77387); Tue, 08 Apr 2025 15:31:01 +0000 Received: (at 77387) by debbugs.gnu.org; 8 Apr 2025 15:30:48 +0000 Received: from localhost ([127.0.0.1]:34782 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1u2AuV-0008UJ-8N for submit <at> debbugs.gnu.org; Tue, 08 Apr 2025 11:30:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35648) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <ludo@HIDDEN>) id 1u2AuS-0008Ta-Tg for 77387 <at> debbugs.gnu.org; Tue, 08 Apr 2025 11:30:45 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <ludo@HIDDEN>) id 1u2AuM-0002B9-1K; Tue, 08 Apr 2025 11:30:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=ymbHgPg+YChB9K95Ehsax65vEypB1Uz+EQWNr0hvTRk=; b=E8v+6khzx13jcjiz6Wjk JI9/a4xL85sJrSdK+w9oOtK32RHcBPQ+tIKNKpVaGU/A6VgfWBooRNjO8a7jWxgNOdN303za1vZSv IpnL9PJxBOOx+Van2lCJsLdgxiw0SbcM6c0c9K2xuORcdl/zLgVyqcB207SOKIJENPvGl4jK1JYvP 8+7OJpwpY+Drf8brMN7k0ToH8FCSufCTnelvH7Cdg9gky2tIYo4EwcRKMOj04ITa4GiXC5zu2+/2O uGF441+mwKjBRvWzy2js68ar9tEsdFX0T0UsJBS9HHnpYGcedJWC32qvYRzy+DwSOTUdtfMpBZfKs BsQec3e5paJRBA==; From: Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN> In-Reply-To: <87h637ekj9.fsf@HIDDEN> (Sergey Trofimov's message of "Tue, 01 Apr 2025 21:42:02 +0200") References: <cover.1743343624.git.sarg@HIDDEN> <7068d5eb173f3d0c7cb69ae9592cb61b2dd84281.1743343624.git.sarg@HIDDEN> <87r02cdr08.fsf@HIDDEN> <87h637ekj9.fsf@HIDDEN> Date: Tue, 08 Apr 2025 17:11:55 +0200 Message-ID: <87ikne4ric.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) Hi, Sergey Trofimov <sarg@HIDDEN> skribis: > Ludovic Court=C3=A8s <ludo@HIDDEN> writes: > >>> + (in-string? #f)) >>> + (if (>=3D pos (string-length input)) >>> + ;; End of input >>> + (unless in-string? >>> + (reverse (if (null? current) >>> + tokens >>> + (cons (list->string (reverse current)) tokens))= )) >> >> So this procedure can return *unspecified*, right? Sounds fishy. >> > Why is it fishy? Is it unconventional? Such return value is handled > correctly by the calling code (`match`). It=E2=80=99s unconventional; usually, procedures are monomorphic and in this case, the expectation is that it always returns a list of tokens. I would either return the empty list in the =E2=80=98in-string?=E2=80=99 ca= se or throw an exception (because that means we failed to parse the thing). Does that make sense? Thanks, Ludo=E2=80=99.
X-Loop: help-debbugs@HIDDEN Subject: [bug#77387] [PATCH v2 1/2] man-db: Parse man macro arguments better. References: <cover.1743343624.git.sarg@HIDDEN> In-Reply-To: <cover.1743343624.git.sarg@HIDDEN> Resent-From: Sergey Trofimov <sarg@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: sarg@HIDDEN, ludo@HIDDEN, guix@HIDDEN, dev@HIDDEN, othacehe@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN Resent-Date: Wed, 09 Apr 2025 12:47:02 +0000 Resent-Message-ID: <handler.77387.B77387.174420281814692 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 77387 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77387 <at> debbugs.gnu.org Cc: Sergey Trofimov <sarg@HIDDEN>, Sergey Trofimov <sarg@HIDDEN>, Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>, Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN> X-Debbugs-Original-Xcc: Sergey Trofimov <sarg@HIDDEN>, Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>, Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN> Received: via spool by 77387-submit <at> debbugs.gnu.org id=B77387.174420281814692 (code B ref 77387); Wed, 09 Apr 2025 12:47:02 +0000 Received: (at 77387) by debbugs.gnu.org; 9 Apr 2025 12:46:58 +0000 Received: from localhost ([127.0.0.1]:38223 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1u2UpV-0003on-AB for submit <at> debbugs.gnu.org; Wed, 09 Apr 2025 08:46:57 -0400 Received: from mail-ed1-x52d.google.com ([2a00:1450:4864:20::52d]:54593) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from <sarg@HIDDEN>) id 1u2UpS-0003oQ-22 for 77387 <at> debbugs.gnu.org; Wed, 09 Apr 2025 08:46:55 -0400 Received: by mail-ed1-x52d.google.com with SMTP id 4fb4d7f45d1cf-5efe8d9eb12so9908364a12.1 for <77387 <at> debbugs.gnu.org>; Wed, 09 Apr 2025 05:46:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sarg.org.ru; s=google; t=1744202807; x=1744807607; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=oBly8/ybtx0vOTH8DSTkoRFYmSxWC/vxVFPkOmU9JUk=; b=J9nhG90jN914UKkGIVcBP/1tH9l9tZ5BaweCNUTcn4ESn5614LPtHJUIR93TmG2j8J cFfj3U64fBUEheibD8s7ntZHxPjAlhffuELAII70d+WvCBqk0wfdpvn4p7w0WOe8TReH 6rt35AUiRWOCKAj6QgrpOVodbPBVZlSKkNYuEl8MnMZFQ0LvCGm3HsPMA0be03PaHFsh hkVnVOQF+frRhAfp6HFudBIY60BhEcI7W9mJ1KyO3pvWLFtstt/t3CxcZdjPxhb/lVTq Wwy6I5OFMNjbYnpgUE6Iy4eGxs/BOn0+uycyEwFh6Th4yvCKlfovxLQdSCkFTlhWw24t zU+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744202807; x=1744807607; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=oBly8/ybtx0vOTH8DSTkoRFYmSxWC/vxVFPkOmU9JUk=; b=FZTLqiXZqtow+za8gJRyyIy1VASG8XiKpoLy/9eRtSfVbBfK9k8zQIIPsC6kxWBace My3YqNGnx9dWpFU0eCK9+DOEuWdwut/XUblv70/lb83W8hY+RRA8Z6HyEunfIjVIuMQv TOmLIxlOjIx1bQ4QnRXBeyt9YsoEQ/9wvwCXllF+kCzfIb4OJ9PBycRsvd8FAUARHHo/ eeZoH+8y+QSjDzMBlWQJ+ydEk15Y2/Jppn3+I37EXjLaZpJmmpF/o1BFOofKJ3hufWMs SzFIXr9H6xkbgxna1cJ8IdPCBfyZt02EeEf63agJE2hIAO92bDprbI+b/zl6dNijzUSm MG6Q== X-Gm-Message-State: AOJu0Yz/ZGA1oeBXDKWF4K93wTRM73iiEQfZ3pyJkZonJaAYmEXYnyJs W+3a/Jbe4gSoGdgwf/BUlnA0vpH7mRYS9+Og8LCrgoE2ZV68/fzaOfcT1sxWds9yHsJ+kxvgESC CSjA= X-Gm-Gg: ASbGncuNseZknHcUMjX+1ajXyC25k/7HWZJRLc3e+KiEDSpxSYIQp1u1DVDt+xFBj+K AKWobEZzARC/vZHMe+al5JKjrqHty1WQ55DNeH0z9O5/HYTywBk9qKvHp10RBv8YhOZlUIBn7HE fmXPwg+kwLnlgwisiOUI/jmBGawB/NHlqURGfcV+NJfi5KLW4QsHncTMATJLhpuZ8Vcpk5U0v5C AV8Muut8/DQT6ec85Svo3fU6akGHj5tv3ipDbX8cxlvDaqfEcu5l2RZDN8FixmI0LTUx4ZZUDyS HJgPr5HoDHSYfTsQTU7ojuNX1mNmvctPZvLe/NBD+N8vCEF2 X-Google-Smtp-Source: AGHT+IFpD8u96UD8JU2yZppn8BNtTniP+gQ95XU/N92kuPDvbBloe3QGdHn1S7io9Ta2lfpB7JeS5w== X-Received: by 2002:a17:906:e87:b0:ac1:fb27:d3a2 with SMTP id a640c23a62f3a-aca9d5cedebmr207689566b.5.1744202806332; Wed, 09 Apr 2025 05:46:46 -0700 (PDT) Received: from localhost ([2a02:2454:a095:5600:a64e:31ff:fe38:fd6c]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-acaa1c0126asm92676766b.78.2025.04.09.05.46.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Apr 2025 05:46:45 -0700 (PDT) From: Sergey Trofimov <sarg@HIDDEN> Date: Wed, 9 Apr 2025 14:46:40 +0200 Message-ID: <a0040cd0faf8501a35b71848b33d83dc45d6659b.1744202723.git.sarg@HIDDEN> X-Mailer: git-send-email 2.49.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) * guix/man-db.scm (man-macro-tokenize): New procedure to parse man macros. (man-page->entry): Parse macro line using man-macro-tokenize. Change-Id: Iea0ffbc65290757df746138e0a6174646b5a3eb8 --- guix/man-db.scm | 55 +++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 9 deletions(-) diff --git a/guix/man-db.scm b/guix/man-db.scm index bba90ed473..1259658f52 100644 --- a/guix/man-db.scm +++ b/guix/man-db.scm @@ -161,16 +161,51 @@ (define (read-synopsis port) (line (loop (cons line lines)))))) +(define (man-macro-tokenize input) + "Split INPUT string, a man macro invocation, into a list containing the macro's +name followed by its arguments." + (let loop ((pos 0) + (tokens '()) + (characters '()) + (in-string? #f)) + (if (>= pos (string-length input)) + ;; End of input + (reverse (if (null? characters) + tokens + (cons (list->string (reverse characters)) tokens))) + (let ((c (string-ref input pos))) + (cond + ;; Inside a string + (in-string? + (if (char=? c #\") + (if (and (< (+ pos 1) (string-length input)) + (char=? (string-ref input (+ pos 1)) #\")) + ;; Double quote inside string + (loop (+ pos 2) tokens (cons #\" characters) #t) + ;; End of string + (loop (+ pos 1) (cons (list->string (reverse characters)) tokens) '() #f)) + ;; Regular character in string + (loop (+ pos 1) tokens (cons c characters) #t))) + + ;; Whitespace outside string + ((char-whitespace? c) + (if (null? characters) + (loop (+ pos 1) tokens '() #f) + (loop (+ pos 1) (cons (list->string (reverse characters)) tokens) '() #f))) + + ;; Start of string + ((char=? c #\") + (if (null? characters) + (loop (+ pos 1) tokens '() #t) + (loop pos (cons (list->string (reverse characters)) tokens) '() #f))) + + ;; Symbol character + (else + (loop (+ pos 1) tokens (cons c characters) #f))))))) + (define* (man-page->entry file #:optional (resolve identity)) "Parse FILE, a gzip or zstd compressed man page, and return a <mandb-entry> for it." - (define (string->number* str) - (if (and (string-prefix? "\"" str) - (> (string-length str) 1) - (string-suffix? "\"" str)) - (string->number (string-drop (string-drop-right str 1) 1)) - (string->number str))) - (define call-with-input-port* (cond ((gzip-compressed? file) call-with-gzip-input-port) @@ -189,8 +224,10 @@ (define* (man-page->entry file #:optional (resolve identity)) (if (eof-object? line) (mandb-entry file name (or section 0) (or synopsis "") kind) - (match (string-tokenize line) - ((".TH" name (= string->number* section) _ ...) + ;; man 7 groff groff_mdoc groff_man + ;; look for metadata in macro invocations (lines starting with .) + (match (and (string-prefix? "." line) (man-macro-tokenize line)) + ((".TH" name (= string->number section) _ ...) (loop name section synopsis kind)) ((".SH" (or "NAME" "\"NAME\"")) (loop name section (read-synopsis port) kind)) base-commit: 621d09a185b106364fe7636923ab39c8bca35141 -- 2.49.0
X-Loop: help-debbugs@HIDDEN Subject: [bug#77387] [PATCH v2 2/2] man-db: Support mdoc-formatted man pages. Resent-From: Sergey Trofimov <sarg@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: sarg@HIDDEN, ludo@HIDDEN, guix@HIDDEN, dev@HIDDEN, othacehe@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN Resent-Date: Wed, 09 Apr 2025 12:48:02 +0000 Resent-Message-ID: <handler.77387.B77387.174420282214720 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 77387 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77387 <at> debbugs.gnu.org Cc: Sergey Trofimov <sarg@HIDDEN>, Sergey Trofimov <sarg@HIDDEN>, Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>, Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN> X-Debbugs-Original-Xcc: Sergey Trofimov <sarg@HIDDEN>, Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>, Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN> Received: via spool by 77387-submit <at> debbugs.gnu.org id=B77387.174420282214720 (code B ref 77387); Wed, 09 Apr 2025 12:48:02 +0000 Received: (at 77387) by debbugs.gnu.org; 9 Apr 2025 12:47:02 +0000 Received: from localhost ([127.0.0.1]:38226 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1u2Upa-0003pF-4A for submit <at> debbugs.gnu.org; Wed, 09 Apr 2025 08:47:02 -0400 Received: from mail-ed1-x530.google.com ([2a00:1450:4864:20::530]:54446) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from <sarg@HIDDEN>) id 1u2UpV-0003oU-9p for 77387 <at> debbugs.gnu.org; Wed, 09 Apr 2025 08:46:57 -0400 Received: by mail-ed1-x530.google.com with SMTP id 4fb4d7f45d1cf-5eb92df4fcbso11467490a12.0 for <77387 <at> debbugs.gnu.org>; Wed, 09 Apr 2025 05:46:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sarg.org.ru; s=google; t=1744202811; x=1744807611; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ucLOSm14qKdOSQif27H7Y9oQ4cdaGa8rKhIfks6CXtI=; b=sZnMT8OWxxS6o7kruGOBVx9oh7tIyuWOicMM8yRsX+TWEVP+hM1iiiZ/oIQTlUVheb 45DHHaw+TRGEFG73p3A66fDJzBhyH+aK6AAND1t9ZkYYg6/xFyrc8Rj1B5tgrJRPQnPy K+cO1HH8zVtZ+Rhe0CYCMDmd6jvmrZCgLgmknNYwrZyEk6huL7yEvfFZ3btBLvrFe1wD HXkUjmS/QvKww4KeZnlneyhqPUQHj9jexbQp/ERWhPDNhaqQlVt0r4TbtXUHZCie23mw YuLrR4NmNiNLley/n7Y7TGDHJLOIqYoXETSDvI6Cr0qJz6sSdL0kWxvSWHb1Z9LFOpE0 +X0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744202811; x=1744807611; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ucLOSm14qKdOSQif27H7Y9oQ4cdaGa8rKhIfks6CXtI=; b=tAnH/f43ViXY+izL+2nzpOav+cj15YvHT7xRn1q33j36gMDXVn1T37ZkwmepfJVmlH At99WGJXDYGKga+X3A0Ri+bRnC9g5Ox9ugaxomi3NArc6BbKsg/fFGysadtXAm6uFGrO B6Gc31SPqWbvc7/mMUffLyphDKSUpgXGdLkQIv3gkAQhJrkQAOQYf3HZrvYAmPD4vuct Pb2ShHo9NFHD9knaV/gAQ+JWEougiAhMAB1f2Za1Wuatq7CNnGVD8P/wzJpHJYMoZJwQ 8Vl0JeavAi+UIyOZC4PV40EduIh0jzDefV8QsrY0ffzbpOsbhybdRMxA0VdsBO0CYdLN UGqg== X-Gm-Message-State: AOJu0YySlocZZiifz//f7b0hG7eb21qXz6PtFcEqt8gCGZq4mDWdjC0S LmHxwNVOA06je27NEQJOoRWZ/JMTPqUbvKar9FJJQbk+hDoTLwMVMzW4pUcj367eXiakZGBZXm7 J+zI= X-Gm-Gg: ASbGnctFtt5OSUeywR0q7dxLgbLDY9fjYiEJSRCeCHniQeo5l3iJMfr4lo0E6aEp3GY rXhw+xWvcSK+x13c9TzzNNlAJdI97ET0gP8cHeut7NvOBUU63mSYyvgTbfVRYKDMG9CRgc5+9u9 XVz1/CgIl+py89PIeIeBgLuhx8FVIOlqfu7zsemCn3oP6i3cbzbUi5gZbGP17zJJkLPye/FJBzk zURFqhE7TMMkL58mR+L8OvNH/8wwVHZZI455pLbrBZac5YpYEqDOsob41rMJ2uiWVQmoglfUt1o GkAwVmFYv7e5FjLE8/I+lvNVSxd0ec9h8RUB0gVjfN0KFUkg X-Google-Smtp-Source: AGHT+IFOcntlBj4xBVUTRo5xqPBvmzH7gj96AOyI2A+8nLDPbH3Tx1L6zs9kK5J0ip2fnC4BSaVkgA== X-Received: by 2002:a05:6402:1941:b0:5f0:b245:a15 with SMTP id 4fb4d7f45d1cf-5f2f86a3573mr1895032a12.33.1744202809851; Wed, 09 Apr 2025 05:46:49 -0700 (PDT) Received: from localhost ([2a02:2454:a095:5600:a64e:31ff:fe38:fd6c]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5f2fbc2d6a4sm773171a12.40.2025.04.09.05.46.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Apr 2025 05:46:49 -0700 (PDT) From: Sergey Trofimov <sarg@HIDDEN> Date: Wed, 9 Apr 2025 14:46:41 +0200 Message-ID: <df4d607fdf72164e9507a085c6cde892ecd8f5f4.1744202723.git.sarg@HIDDEN> X-Mailer: git-send-email 2.49.0 In-Reply-To: <a0040cd0faf8501a35b71848b33d83dc45d6659b.1744202723.git.sarg@HIDDEN> References: <a0040cd0faf8501a35b71848b33d83dc45d6659b.1744202723.git.sarg@HIDDEN> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) * guix/man-db.scm (man-page->entry): Extract man name and section from .Dt macro. Change-Id: I02dc99d73dceecdb077315805025efad9a650e91 --- guix/man-db.scm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/guix/man-db.scm b/guix/man-db.scm index 1259658f52..59723fb336 100644 --- a/guix/man-db.scm +++ b/guix/man-db.scm @@ -227,10 +227,13 @@ (define* (man-page->entry file #:optional (resolve identity)) ;; man 7 groff groff_mdoc groff_man ;; look for metadata in macro invocations (lines starting with .) (match (and (string-prefix? "." line) (man-macro-tokenize line)) - ((".TH" name (= string->number section) _ ...) + ;; "Title Header" or "Document title" + (((or ".TH" ".Dt") name (= string->number section) _ ...) (loop name section synopsis kind)) + ;; "Section Header" ((".SH" (or "NAME" "\"NAME\"")) (loop name section (read-synopsis port) kind)) + ;; include source ((".so" link) (match (and=> (resolve link) (cut man-page->entry <> resolve)) -- 2.49.0
X-Loop: help-debbugs@HIDDEN Subject: [bug#77387] [PATCH 1/2] man-db: Parse man macro arguments better. Resent-From: Sergey Trofimov <sarg@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: guix-patches@HIDDEN Resent-Date: Wed, 09 Apr 2025 13:01:02 +0000 Resent-Message-ID: <handler.77387.B77387.174420360717316 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 77387 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN> Cc: Josselin Poiret <dev@HIDDEN>, 77387 <at> debbugs.gnu.org, Simon Tournier <zimon.toutoune@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>, Christopher Baines <guix@HIDDEN> Received: via spool by 77387-submit <at> debbugs.gnu.org id=B77387.174420360717316 (code B ref 77387); Wed, 09 Apr 2025 13:01:02 +0000 Received: (at 77387) by debbugs.gnu.org; 9 Apr 2025 13:00:07 +0000 Received: from localhost ([127.0.0.1]:38267 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1u2V2E-0004Up-Kj for submit <at> debbugs.gnu.org; Wed, 09 Apr 2025 09:00:07 -0400 Received: from mail-ej1-x636.google.com ([2a00:1450:4864:20::636]:53409) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from <sarg@HIDDEN>) id 1u2V2B-0004Ri-SP for 77387 <at> debbugs.gnu.org; Wed, 09 Apr 2025 09:00:05 -0400 Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-ac2963dc379so194805466b.2 for <77387 <at> debbugs.gnu.org>; Wed, 09 Apr 2025 06:00:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sarg.org.ru; s=google; t=1744203598; x=1744808398; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:user-agent :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=QvcuQ2DRyo0TmylsQeHtNTrTxtIFql2NoHQagYAUvyY=; b=nAdaqCC1AVV1tt5H/4cBOBDUg4q4bVofVdmJt9Fy4X+uQNkuCdbZU2AQQ4hkUQPu1/ CW/swA/BRzGmO/MDQ0lIXYSYnCMHp/EeBmGDBNE/lusiR9mpN/irNYTvvl0UzCUMVGLn m/CT3rObREZ1lgMk7s4u8/i9UR3G4VGy9iRlam+NvfTX+CC23yGf528oQ9l/JmAnDam0 bqQh4tcM9+nCt+prhWAh2XXAGOo8rJ1lDdakKtTXszBCd/9SOkiqAMhpgg/gakAbnCxc ihxMlw2L3werzMH0ViqEzvXF/K/9jccYGzynnlqmnZEYBN6/Jvjqjq+A4HlG25/Gy+j/ TNKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744203598; x=1744808398; h=content-transfer-encoding:mime-version:message-id:date:user-agent :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=QvcuQ2DRyo0TmylsQeHtNTrTxtIFql2NoHQagYAUvyY=; b=CCdrvCljQxx6jMB1RL7XAPrbS/FoMCImGtGS5NajNAMXjCNJPyLcBYIbxKG9jtt6Oj XWZfelliZgb3u6Dj0JcALc3Oig8DpYNXQ5oDYY/o+mn6iVX10iEbP1cvkaabGFePDL89 HauyPNNbBDxaksm6DJqyg8QmCdF31D/MB0HiBqeWnj3bozv/R9QuyK0APuYd+tHMxbTf r2h6QZI2/T7JSKPfInCNwuabaXfO/moNaiq49UX/I4RxI4rGWFpSM1OfLcU/SP5IFJ70 uD37Yl8FToOp1eIj+IyT52WgNlm3psXl4IIWPg3GRWI+3mMYlvr8jMw1gnBj8g2iB+d9 3Luw== X-Forwarded-Encrypted: i=1; AJvYcCU3yG87b9mgNkQflBHI+XZG3AieGP0+aJLLHZazf1vvmfB5gC5BI5bn/0DtY0ep6+JlITOk1w==@debbugs.gnu.org X-Gm-Message-State: AOJu0Yy38ilAFEJrjuV/0Eud1VPCIlKGQc0e5xiRANNGnxsnapXEScr5 1FpV8XvIR1IpvNNI+jdE/RdT8YWsIH3xYQREijMpqiclmVl5iVGAYBboPTl3fdw= X-Gm-Gg: ASbGnctOMhKWfgZNDqIipQTPd7MAvqdWFP3N84R8tY3KWAyZz2isnb8jwsMPGyQ/cjT jqumdIi3QY8/bQTscTzqURaDfLHNbc1ANd/BsALKzRPh954vkV5a98P0Y9em9kA+CDlOey5nvyI /jqrfI/SfQv5eIXX//YlQpwLmF5t3FutxmUBbrdJd2NTNj0bL+T46rzi9FtMPWlrwu0igClHOec 6gwKsx0ExhOUgCQXDb7DtuA8hnqlKZnSfyeEaVrTAWwG40+GEvPg5egE+8Qq+pcbuVdJjT3bsWC yoX4xF8eFT5ctwyvftItfZn4kiUT7hNiby0lAg== X-Google-Smtp-Source: AGHT+IH9QIh6IwSNHX1ArmVa94Pv7SoTkCdEdJGXliq4xseSjs1UvCH+Wrq0+j6jlzCX0CQoO05BWQ== X-Received: by 2002:a17:907:3ea2:b0:ac6:fc40:c996 with SMTP id a640c23a62f3a-aca9d6183b5mr230261266b.23.1744203597277; Wed, 09 Apr 2025 05:59:57 -0700 (PDT) Received: from localhost ([2a02:2454:a095:5600:a64e:31ff:fe38:fd6c]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-acaa1cb4070sm94092166b.102.2025.04.09.05.59.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Apr 2025 05:59:56 -0700 (PDT) From: Sergey Trofimov <sarg@HIDDEN> In-Reply-To: <87ikne4ric.fsf@HIDDEN> ("Ludovic =?UTF-8?Q?Court=C3=A8s?="'s message of "Tue, 08 Apr 2025 17:11:55 +0200") References: <cover.1743343624.git.sarg@HIDDEN> <7068d5eb173f3d0c7cb69ae9592cb61b2dd84281.1743343624.git.sarg@HIDDEN> <87r02cdr08.fsf@HIDDEN> <87h637ekj9.fsf@HIDDEN> <87ikne4ric.fsf@HIDDEN> User-Agent: mu4e 1.12.9; emacs 30.0.92 Date: Wed, 09 Apr 2025 14:59:55 +0200 Message-ID: <87h62xh4ms.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Hi, Ludovic Courtès <ludo@HIDDEN> writes: >>>> + (in-string? #f)) >>>> + (if (>= pos (string-length input)) >>>> + ;; End of input >>>> + (unless in-string? >>>> + (reverse (if (null? current) >>>> + tokens >>>> + (cons (list->string (reverse current)) tokens)))) >>> >>> So this procedure can return *unspecified*, right? Sounds fishy. >>> >> Why is it fishy? Is it unconventional? Such return value is handled >> correctly by the calling code (`match`). > > It’s unconventional; usually, procedures are monomorphic and in this > case, the expectation is that it always returns a list of tokens. > > I would either return the empty list in the ‘in-string?’ case or throw > an exception (because that means we failed to parse the thing). > > Does that make sense? I wouldn't throw an exception as this would break the derivation building an consequently profile switch. I've removed the offending `unless` altogether. `man` itself seem to be forgiving for such syntax violations.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.