diff options
| author | Nicolas Petton | 2015-06-04 18:20:18 +0200 |
|---|---|---|
| committer | Nicolas Petton | 2015-06-04 18:27:54 +0200 |
| commit | 41a929c5ae1110e39f94c018dc2b3e224e884f18 (patch) | |
| tree | 6fc7c92f12861766329c6d4daac52bf9547a77ea /src | |
| parent | 285260fce84c945acb588a7c70d3df5d8271f586 (diff) | |
| download | emacs-41a929c5ae1110e39f94c018dc2b3e224e884f18.tar.gz emacs-41a929c5ae1110e39f94c018dc2b3e224e884f18.zip | |
Add new function string-greaterp
* lisp/subr.el (string-greaterp): New function. Also aliased to
`string>'.
* test/automated/subr-tests.el (string-comparison-test): Add unit
tests for `string>'and `string<'.
* src/fns.c (string-lessp): Better docstring.
Diffstat (limited to 'src')
| -rw-r--r-- | src/fns.c | 28 |
1 files changed, 14 insertions, 14 deletions
| @@ -303,26 +303,26 @@ If string STR1 is greater, the value is a positive number N; | |||
| 303 | } | 303 | } |
| 304 | 304 | ||
| 305 | DEFUN ("string-lessp", Fstring_lessp, Sstring_lessp, 2, 2, 0, | 305 | DEFUN ("string-lessp", Fstring_lessp, Sstring_lessp, 2, 2, 0, |
| 306 | doc: /* Return t if first arg string is less than second in lexicographic order. | 306 | doc: /* Return non-nil if STRING1 is less than STRING2 in lexicographic order. |
| 307 | Case is significant. | 307 | Case is significant. |
| 308 | Symbols are also allowed; their print names are used instead. */) | 308 | Symbols are also allowed; their print names are used instead. */) |
| 309 | (register Lisp_Object s1, Lisp_Object s2) | 309 | (register Lisp_Object string1, Lisp_Object string2) |
| 310 | { | 310 | { |
| 311 | register ptrdiff_t end; | 311 | register ptrdiff_t end; |
| 312 | register ptrdiff_t i1, i1_byte, i2, i2_byte; | 312 | register ptrdiff_t i1, i1_byte, i2, i2_byte; |
| 313 | 313 | ||
| 314 | if (SYMBOLP (s1)) | 314 | if (SYMBOLP (string1)) |
| 315 | s1 = SYMBOL_NAME (s1); | 315 | string1 = SYMBOL_NAME (string1); |
| 316 | if (SYMBOLP (s2)) | 316 | if (SYMBOLP (string2)) |
| 317 | s2 = SYMBOL_NAME (s2); | 317 | string2 = SYMBOL_NAME (string2); |
| 318 | CHECK_STRING (s1); | 318 | CHECK_STRING (string1); |
| 319 | CHECK_STRING (s2); | 319 | CHECK_STRING (string2); |
| 320 | 320 | ||
| 321 | i1 = i1_byte = i2 = i2_byte = 0; | 321 | i1 = i1_byte = i2 = i2_byte = 0; |
| 322 | 322 | ||
| 323 | end = SCHARS (s1); | 323 | end = SCHARS (string1); |
| 324 | if (end > SCHARS (s2)) | 324 | if (end > SCHARS (string2)) |
| 325 | end = SCHARS (s2); | 325 | end = SCHARS (string2); |
| 326 | 326 | ||
| 327 | while (i1 < end) | 327 | while (i1 < end) |
| 328 | { | 328 | { |
| @@ -330,13 +330,13 @@ Symbols are also allowed; their print names are used instead. */) | |||
| 330 | characters, not just the bytes. */ | 330 | characters, not just the bytes. */ |
| 331 | int c1, c2; | 331 | int c1, c2; |
| 332 | 332 | ||
| 333 | FETCH_STRING_CHAR_ADVANCE (c1, s1, i1, i1_byte); | 333 | FETCH_STRING_CHAR_ADVANCE (c1, string1, i1, i1_byte); |
| 334 | FETCH_STRING_CHAR_ADVANCE (c2, s2, i2, i2_byte); | 334 | FETCH_STRING_CHAR_ADVANCE (c2, string2, i2, i2_byte); |
| 335 | 335 | ||
| 336 | if (c1 != c2) | 336 | if (c1 != c2) |
| 337 | return c1 < c2 ? Qt : Qnil; | 337 | return c1 < c2 ? Qt : Qnil; |
| 338 | } | 338 | } |
| 339 | return i1 < SCHARS (s2) ? Qt : Qnil; | 339 | return i1 < SCHARS (string2) ? Qt : Qnil; |
| 340 | } | 340 | } |
| 341 | 341 | ||
| 342 | DEFUN ("string-collate-lessp", Fstring_collate_lessp, Sstring_collate_lessp, 2, 4, 0, | 342 | DEFUN ("string-collate-lessp", Fstring_collate_lessp, Sstring_collate_lessp, 2, 4, 0, |