[neomutt-devel] how does mutt determines if the debugfilename has changed?
toogley at mailbox.org
toogley at mailbox.org
Wed Jun 14 18:10:55 CEST 2017
Hey,
On Wed 14 Jun 2017, 10:27:48 CEST, rich at flatcap.org wrote:
> > 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 ...
>
Ah, i see. thanks.
> > * 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)
Hm.. Why don't we use mutt_strcmp() for that?
More information about the neomutt-devel
mailing list