[neomutt-devel] how does mutt determines if the debugfilename has changed?

Richard Russon rich at flatcap.org
Wed Jun 14 10:27:48 CEST 2017

>  bool file_changed =
>       ((mutt_strlen(debugfilename) - 1) != mutt_strlen(DebugFile) ||
>         mutt_strncmp(debugfilename, DebugFile, mutt_strlen(debugfilename) - 1));

> * I don't understand why the length of debugfilename *minus 1* is
>   compared to the one from DebugFile. Shouldn't both use the original
>   length?

DebugFile is the stem of the filename.  It will have a digit appended.

    DebugFile = mylog
    actual files: mylog0 mylog1 ...

> * I don't understand why the length comparison is needed at all.
>   because, when two strings have the same characters, they would also
>   have the same length.

It's to prevent short comparisons.  If we were comparing the whole
strings, it wouldn't be necessary.

We have to take the length of one of the strings for strncmp.
What we don't want, is to say: "the strings match", when what we
actually have is:
    strncmp("red", "redder", 3)

    Rich / FlatCap
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 854 bytes
Desc: not available
URL: <http://mailman.neomutt.org/pipermail/neomutt-devel-neomutt.org/attachments/20170614/4c9dae8c/attachment.sig>

More information about the neomutt-devel mailing list