Function: string-lessp
string-lessp is a function defined in fns.c.
Signature
(string-lessp STRING1 STRING2)
Documentation
Return non-nil if STRING1 is less than STRING2 in lexicographic order.
Case is significant. Symbols are also allowed; their print names are used instead.
Other relevant functions are documented in the string group.
Probably introduced at or before Emacs version 20.4.
Shortdoc
;; string
(string-lessp "foo" "bar")
=> nil
Aliases
Source Code
// Defined in /usr/src/emacs/src/fns.c
{
if (SYMBOLP (string1))
string1 = SYMBOL_NAME (string1);
if (SYMBOLP (string2))
string2 = SYMBOL_NAME (string2);
CHECK_STRING (string1);
CHECK_STRING (string2);
ptrdiff_t i1 = 0, i1_byte = 0, i2 = 0, i2_byte = 0;
ptrdiff_t end = min (SCHARS (string1), SCHARS (string2));
while (i1 < end)
{
/* When we find a mismatch, we must compare the
characters, not just the bytes. */
int c1 = fetch_string_char_advance (string1, &i1, &i1_byte);
int c2 = fetch_string_char_advance (string2, &i2, &i2_byte);
if (c1 != c2)
return c1 < c2 ? Qt : Qnil;
}
return i1 < SCHARS (string2) ? Qt : Qnil;
}