GNU bug report logs - #65703
gnus-cut-thread loop condition oddity

Previous Next

Package: emacs;

Reported by: Mattias EngdegÄrd <mattias.engdegard <at> gmail.com>

Date: Sat, 2 Sep 2023 14:25:02 UTC

Severity: normal

Full log


Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Mattias EngdegÄrd <mattias.engdegard <at> gmail.com>
To: Emacs Bug Report <bug-gnu-emacs <at> gnu.org>
Cc: Lars Ingebrigtsen <larsi <at> gnus.org>, Andrew G Cohen <cohen <at> andy.bu.edu>
Subject: gnus-cut-thread loop condition oddity
Date: Sat, 2 Sep 2023 16:24:38 +0200
This is about code I know nothing about but a tool of mine noticed it in the passing:

The loop in gnus-cut-thread in lisp/gnus/gnus-sum.el, replicated below, has a very odd loop condition: the latter half looks misplaced, as if it would belong in the loop body.

In particular, there is a definite possibility that the little `while` loop at the end will end up supplying the value for the loop condition of the outer loop, which of course terminates it since `while` forms are always nil.

Maybe someone who knows Gnus please take a look?

  (while (and
          thread
          (or
           (gnus-summary-article-sparse-p (mail-header-number (car thread)))
           (gnus-summary-article-ancient-p
            (mail-header-number (car thread))))
          (if (or (<= (length (cdr thread)) 1)           ; Should this be here?
                  (eq gnus-fetch-old-headers 'invisible))
              (setq gnus-newsgroup-limit
                    (delq (mail-header-number (car thread))
                          gnus-newsgroup-limit)
                    thread (cadr thread))
            (when (gnus-invisible-cut-children (cdr thread))
              (let ((th (cdr thread)))
                (while th                                ; And this?
                  (if (memq (mail-header-number (caar th))
                            gnus-newsgroup-limit)
                      (setq thread (car th)
                            th nil)
                    (setq th (cdr th))))))))))





This bug report was last modified 1 year and 321 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.