From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dmitry Antipov Newsgroups: gmane.emacs.devel Subject: One more string functions change Date: Fri, 27 Jun 2014 19:27:21 +0400 Message-ID: <53AD8D59.5000207@yandex.ru> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------010106030402080305090204" X-Trace: ger.gmane.org 1403883045 22523 80.91.229.3 (27 Jun 2014 15:30:45 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 27 Jun 2014 15:30:45 +0000 (UTC) To: Emacs development discussions Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jun 27 17:30:31 2014 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1X0Y6d-0004qX-1w for ged-emacs-devel@m.gmane.org; Fri, 27 Jun 2014 17:30:27 +0200 Original-Received: from localhost ([::1]:51016 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X0Y6c-0001bG-K3 for ged-emacs-devel@m.gmane.org; Fri, 27 Jun 2014 11:30:26 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45502) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X0Y3z-0006jH-SP for emacs-devel@gnu.org; Fri, 27 Jun 2014 11:27:51 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X0Y3r-0006kt-If for emacs-devel@gnu.org; Fri, 27 Jun 2014 11:27:43 -0400 Original-Received: from forward1l.mail.yandex.net ([84.201.143.144]:47930) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X0Y3q-0006je-Ri for emacs-devel@gnu.org; Fri, 27 Jun 2014 11:27:35 -0400 Original-Received: from smtp13.mail.yandex.net (smtp13.mail.yandex.net [95.108.130.68]) by forward1l.mail.yandex.net (Yandex) with ESMTP id E5FC315218BE for ; Fri, 27 Jun 2014 19:27:32 +0400 (MSK) Original-Received: from smtp13.mail.yandex.net (localhost [127.0.0.1]) by smtp13.mail.yandex.net (Yandex) with ESMTP id A53B1E40095 for ; Fri, 27 Jun 2014 19:27:32 +0400 (MSK) Original-Received: from 235.gprs.mts.ru (235.gprs.mts.ru [213.87.135.235]) by smtp13.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 4MZXZEYzTQ-RPW0uk9q; Fri, 27 Jun 2014 19:27:25 +0400 (using TLSv1 with cipher AES128-SHA (128/128 bits)) (Client certificate not present) X-Yandex-Uniq: e7a512c8-895d-4bb2-878f-2ee2873c5bf6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1403882852; bh=p1W22iBH80feoz8a68TkS5IiC8x2Xlvwmvv8gMfilYQ=; h=Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: Content-Type; b=DkxFz2kgO1ObF4/AZIoi9Tg9qYR1uFN7bFmpic+dp/k4MPvKWqjMCtFxqatXSiD2l g7on4qDSXL/iG1ZUZUNQ5ZCYIwLtEq2KmLOTc8k8N2qGrqWXV5Zw34kXc05uanQOF6 8qSUWPIjU344SoDjuGkd160uIwM2Unz/efFBg4Ks= Authentication-Results: smtp13.mail.yandex.net; dkim=pass header.i=@yandex.ru User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 84.201.143.144 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:172768 Archived-At: This is a multi-part message in MIME format. --------------010106030402080305090204 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit I would like to convert string-equal and string-lessp to (defun string-equal s1 s2 &optional ignore-case) and (defun string-lessp s1 s2 &optional ignore-case), respectively. The goals are 1) to provide more consistent interface similar to compare-strings and 2) to avoid an endless and annoying Elisp up/downcasing like: (defun gnus-string< (s1 s2) "Return t if first arg string is less than second in lexicographic order. Case is significant if and only if `case-fold-search' is nil. Symbols are also allowed; their print names are used instead." (if case-fold-search (string-lessp (downcase (if (symbolp s1) (symbol-name s1) s1)) (downcase (if (symbolp s2) (symbol-name s2) s2))) (string-lessp s1 s2))) Note that unlike previous compare-strings change, this shouldn't break backward compatibility. Objections? Dmitry --------------010106030402080305090204 Content-Type: text/x-patch; name="string_comparison.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="string_comparison.patch" =3D=3D=3D modified file 'doc/lispintro/emacs-lisp-intro.texi' --- doc/lispintro/emacs-lisp-intro.texi 2014-06-10 02:20:31 +0000 +++ doc/lispintro/emacs-lisp-intro.texi 2014-06-27 14:49:59 +0000 @@ -4457,7 +4457,9 @@ @itemx string-equal The @code{string-lessp} function tests whether its first argument is smaller than the second argument. A shorter, alternative name for the -same function (a @code{defalias}) is @code{string<}. +same function (a @code{defalias}) is @code{string<}. If the optional +third argument is non-nil, strings are compared ignoring case +differences. =20 The arguments to @code{string-lessp} must be strings or symbols; the ordering is lexicographic, so case is significant. The print names of @@ -4469,7 +4471,9 @@ =20 @code{string-equal} provides the corresponding test for equality. Its shorter, alternative name is @code{string=3D}. There are no string test= -functions that correspond to @var{>}, @code{>=3D}, or @code{<=3D}. +functions that correspond to @var{>}, @code{>=3D}, or @code{<=3D}. This= +function accepts an optional third argument with the same meaning as +in @code{stirng-lessp}. =20 @item message Print a message in the echo area. The first argument is a string that =3D=3D=3D modified file 'doc/lispref/strings.texi' --- doc/lispref/strings.texi 2014-04-24 15:11:04 +0000 +++ doc/lispref/strings.texi 2014-06-27 14:43:36 +0000 @@ -415,25 +415,27 @@ @end example @end defun =20 -@defun string=3D string1 string2 +@defun string-equal string1 string2 &optional ignore-case This function returns @code{t} if the characters of the two strings match exactly. Symbols are also allowed as arguments, in which case -the symbol names are used. Case is always significant, regardless of -@code{case-fold-search}. +the symbol names are used. If the optional argument @var{ignore-case} +is non-@code{nil}, characters are matched ignoring case differences. =20 This function is equivalent to @code{equal} for comparing two strings (@pxref{Equality Predicates}). In particular, the text properties of the two strings are ignored; use @code{equal-including-properties} if you need to distinguish between strings that differ only in their text properties. However, unlike @code{equal}, if either argument is not a -string or symbol, @code{string=3D} signals an error. +string or symbol, @code{string-equal} signals an error. =20 @example -(string=3D "abc" "abc") +(string-equal "abc" "abc") @result{} t -(string=3D "abc" "ABC") +(string-equal "abc" "ABC") @result{} nil -(string=3D "ab" "ABC") +(string-equal "abc" "ABC" t) + @result{} t +(string-equal "ab" "ABC") @result{} nil @end example =20 @@ -454,13 +456,12 @@ Representations}. @end defun =20 -@defun string-equal string1 string2 -@code{string-equal} is another name for @code{string=3D}. +@defun string=3D string1 string2 +@code{string=3D} is another name for @code{string-equal}. @end defun =20 @cindex lexical comparison -@defun string< string1 string2 -@c (findex string< causes problems for permuted index!!) +@defun string-lessp string1 string2 &optional ignore-case This function compares two strings a character at a time. It scans both the strings at the same time to find the first pair of corres= ponding characters that do not match. If the lesser character of these two is @@ -468,6 +469,8 @@ function returns @code{t}. If the lesser character is the one from @var{string2}, then @var{string1} is greater, and this function returns @code{nil}. If the two strings match entirely, the value is @code{nil}.= +If the optional argument @var{ignore-case} is non-@code{nil}, characters= +are compared ignoring case differences. =20 Pairs of characters are compared according to their character codes. Keep in mind that lower case letters have higher numeric values in the @@ -479,11 +482,11 @@ =20 @example @group -(string< "abc" "abd") +(string-lessp "abc" "abd") @result{} t -(string< "abd" "abc") +(string-lessp "abd" "abc") @result{} nil -(string< "123" "abc") +(string-lessp "123" "abc") @result{} t @end group @end example @@ -495,15 +498,15 @@ =20 @example @group -(string< "" "abc") - @result{} t -(string< "ab" "abc") - @result{} t -(string< "abc" "") - @result{} nil -(string< "abc" "ab") - @result{} nil -(string< "" "") +(string-lessp "" "abc") + @result{} t +(string-lessp "ab" "abc") + @result{} t +(string-lessp "abc" "") + @result{} nil +(string-lessp "abc" "ab") + @result{} nil +(string-lessp "" "") @result{} nil @end group @end example @@ -512,8 +515,8 @@ are used. @end defun =20 -@defun string-lessp string1 string2 -@code{string-lessp} is another name for @code{string<}. +@defun string< string1 string2 +@code{string<} is another name for @code{string-lessp}. @end defun =20 @defun string-prefix-p string1 string2 &optional ignore-case =3D=3D=3D modified file 'src/buffer.c' --- src/buffer.c 2014-06-23 04:11:29 +0000 +++ src/buffer.c 2014-06-27 14:33:07 +0000 @@ -435,7 +435,7 @@ return general; } =20 -/* Like Fassoc, but use Fstring_equal to compare +/* Like Fassoc, but use string_equal to compare (which ignores text properties), and don't ever QUIT. */ =20 @@ -447,7 +447,7 @@ { register Lisp_Object elt, tem; elt =3D XCAR (tail); - tem =3D Fstring_equal (Fcar (elt), key); + tem =3D string_equal (Fcar (elt), key); if (!NILP (tem)) return elt; } @@ -493,7 +493,7 @@ FOR_EACH_LIVE_BUFFER (tail, buf) { if (!STRINGP (BVAR (XBUFFER (buf), filename))) continue; - if (!NILP (Fstring_equal (BVAR (XBUFFER (buf), filename), filename= ))) + if (!NILP (string_equal (BVAR (XBUFFER (buf), filename), filename)= )) return buf; } return Qnil; @@ -507,7 +507,7 @@ FOR_EACH_LIVE_BUFFER (tail, buf) { if (!STRINGP (BVAR (XBUFFER (buf), file_truename))) continue; - if (!NILP (Fstring_equal (BVAR (XBUFFER (buf), file_truename), fil= ename))) + if (!NILP (string_equal (BVAR (XBUFFER (buf), file_truename), file= name))) return buf; } return Qnil; @@ -1076,7 +1076,7 @@ =20 CHECK_STRING (name); =20 - tem =3D Fstring_equal (name, ignore); + tem =3D string_equal (name, ignore); if (!NILP (tem)) return name; tem =3D Fget_buffer (name); @@ -1101,7 +1101,7 @@ { gentemp =3D concat2 (tem2, make_formatted_string (number, "<%"pD"d>", ++count)); - tem =3D Fstring_equal (gentemp, ignore); + tem =3D string_equal (gentemp, ignore); if (!NILP (tem)) return gentemp; tem =3D Fget_buffer (gentemp); =3D=3D=3D modified file 'src/bytecode.c' --- src/bytecode.c 2014-05-27 23:48:35 +0000 +++ src/bytecode.c 2014-06-27 14:33:07 +0000 @@ -1787,7 +1787,7 @@ Lisp_Object v1; BEFORE_POTENTIAL_GC (); v1 =3D POP; - TOP =3D Fstring_equal (TOP, v1); + TOP =3D string_equal (TOP, v1); AFTER_POTENTIAL_GC (); NEXT; } @@ -1797,7 +1797,7 @@ Lisp_Object v1; BEFORE_POTENTIAL_GC (); v1 =3D POP; - TOP =3D Fstring_lessp (TOP, v1); + TOP =3D string_lessp (TOP, v1); AFTER_POTENTIAL_GC (); NEXT; } =3D=3D=3D modified file 'src/dbusbind.c' --- src/dbusbind.c 2014-05-20 08:25:18 +0000 +++ src/dbusbind.c 2014-06-27 14:33:07 +0000 @@ -283,7 +283,7 @@ dbus_address_entries_free (entries); \ /* Canonicalize session bus address. */ \ if ((session_bus_address !=3D NULL) \ - && (!NILP (Fstring_equal \ + && (!NILP (string_equal \ (bus, build_string (session_bus_address))))) \ bus =3D QCdbus_session_bus; \ } \ =3D=3D=3D modified file 'src/dired.c' --- src/dired.c 2014-04-16 19:43:46 +0000 +++ src/dired.c 2014-06-27 14:33:07 +0000 @@ -996,9 +996,8 @@ Comparison is in lexicographic order and case is significant. */) (Lisp_Object f1, Lisp_Object f2) { - return Fstring_lessp (Fcar (f1), Fcar (f2)); + return string_lessp (Fcar (f1), Fcar (f2)); } -=0C =20 DEFUN ("system-users", Fsystem_users, Ssystem_users, 0, 0, 0, doc: /* Return a list of user names currently registered in the s= ystem. =3D=3D=3D modified file 'src/editfns.c' --- src/editfns.c 2014-06-23 04:11:29 +0000 +++ src/editfns.c 2014-06-27 14:33:07 +0000 @@ -137,7 +137,7 @@ =20 /* If the user name claimed in the environment vars differs from the real uid, use the claimed name to find the full name. */ - tem =3D Fstring_equal (Vuser_login_name, Vuser_real_login_name); + tem =3D string_equal (Vuser_login_name, Vuser_real_login_name); if (! NILP (tem)) tem =3D Vuser_login_name; else =3D=3D=3D modified file 'src/fileio.c' --- src/fileio.c 2014-06-23 04:11:29 +0000 +++ src/fileio.c 2014-06-27 14:33:07 +0000 @@ -2301,7 +2301,7 @@ #ifdef DOS_NT /* If the file names are identical but for the case, don't attempt to move directory to itself. */ - && (NILP (Fstring_equal (Fdowncase (file), Fdowncase (newname)))) + && (NILP (Fstring_equal (file, newname, Qt))) #endif ) { @@ -2328,7 +2328,7 @@ /* If the file names are identical but for the case, don't ask for confirmation: they simply want to change the letter-case of the file name. */ - if (NILP (Fstring_equal (Fdowncase (file), Fdowncase (newname)))) + if (NILP (Fstring_equal (file, newname, Qt))) #endif if (NILP (ok_if_already_exists) || INTEGERP (ok_if_already_exists)) @@ -4544,8 +4544,8 @@ } =20 if (auto_saving - && NILP (Fstring_equal (BVAR (current_buffer, filename), - BVAR (current_buffer, auto_save_file_name)))) + && NILP (string_equal (BVAR (current_buffer, filename), + BVAR (current_buffer, auto_save_file_name)))) { val =3D Qutf_8_emacs; eol_parent =3D Qunix; @@ -5023,8 +5023,8 @@ else if (quietly) { if (auto_saving - && ! NILP (Fstring_equal (BVAR (current_buffer, filename), - BVAR (current_buffer, auto_save_file_name)))) + && ! NILP (string_equal (BVAR (current_buffer, filename), + BVAR (current_buffer, auto_save_file_name)))) SAVE_MODIFF =3D MODIFF; =20 return Qnil; =3D=3D=3D modified file 'src/fns.c' --- src/fns.c 2014-06-26 07:13:13 +0000 +++ src/fns.c 2014-06-27 14:33:07 +0000 @@ -204,11 +204,43 @@ return make_number (SBYTES (string)); } =20 -DEFUN ("string-equal", Fstring_equal, Sstring_equal, 2, 2, 0, +/* Similar to strcasecmp but for Lisp strings. */ + +static int +string_compare (Lisp_Object s1, Lisp_Object s2, Lisp_Object ignore_case)= +{ + ptrdiff_t i1 =3D 0, i1_byte =3D 0, i2 =3D 0, i2_byte =3D 0; + + while (i1 < SCHARS (s1) && i2 < SCHARS (s2)) + { + int c1, c2; + + FETCH_STRING_CHAR_ADVANCE (c1, s1, i1, i1_byte); + FETCH_STRING_CHAR_ADVANCE (c2, s2, i2, i2_byte); + + if (! NILP (ignore_case)) + { + c1 =3D XINT (Fdowncase (make_number (c1))); + c2 =3D XINT (Fdowncase (make_number (c2))); + } + + if (c1 !=3D c2) + return c1 < c2 ? -1 : 1; + } + + if (i1 < SCHARS (s2)) + return -1; + else if (i2 < SCHARS (s1)) + return 1; + return 0; +} + +DEFUN ("string-equal", Fstring_equal, Sstring_equal, 2, 3, 0, doc: /* Return t if two strings have identical contents. -Case is significant, but text properties are ignored. -Symbols are also allowed; their print names are used instead. */) - (register Lisp_Object s1, Lisp_Object s2) +If IGNORE-CASE is non-nil, characters are converted to lower-case +before comparing them. Text properties are ignored. Symbols are +also allowed; their print names are used instead. */) + (Lisp_Object s1, Lisp_Object s2, Lisp_Object ignore_case) { if (SYMBOLP (s1)) s1 =3D SYMBOL_NAME (s1); @@ -217,11 +249,11 @@ CHECK_STRING (s1); CHECK_STRING (s2); =20 - if (SCHARS (s1) !=3D SCHARS (s2) - || SBYTES (s1) !=3D SBYTES (s2) - || memcmp (SDATA (s1), SDATA (s2), SBYTES (s1))) - return Qnil; - return Qt; + if (NILP (ignore_case)) + return (SCHARS (s1) !=3D SCHARS (s2) + || SBYTES (s1) !=3D SBYTES (s2) + || memcmp (SDATA (s1), SDATA (s2), SBYTES (s1))) ? Qnil : Qt; + return string_compare (s1, s2, ignore_case) =3D=3D 0 ? Qt : Qnil; } =20 DEFUN ("compare-strings", Fcompare_strings, Scompare_strings, 6, 7, 0, @@ -300,15 +332,12 @@ return Qt; } =20 -DEFUN ("string-lessp", Fstring_lessp, Sstring_lessp, 2, 2, 0, +DEFUN ("string-lessp", Fstring_lessp, Sstring_lessp, 2, 3, 0, doc: /* Return t if first arg string is less than second in lexic= ographic order. -Case is significant. -Symbols are also allowed; their print names are used instead. */) - (register Lisp_Object s1, Lisp_Object s2) +If IGNORE-CASE is non-nil, characters are converted to lower-case before= +comparing them. Symbols are also allowed; their print names are used in= stead. */) + (Lisp_Object s1, Lisp_Object s2, Lisp_Object ignore_case) { - register ptrdiff_t end; - register ptrdiff_t i1, i1_byte, i2, i2_byte; - if (SYMBOLP (s1)) s1 =3D SYMBOL_NAME (s1); if (SYMBOLP (s2)) @@ -316,27 +345,9 @@ CHECK_STRING (s1); CHECK_STRING (s2); =20 - i1 =3D i1_byte =3D i2 =3D i2_byte =3D 0; - - end =3D SCHARS (s1); - if (end > SCHARS (s2)) - end =3D SCHARS (s2); - - while (i1 < end) - { - /* When we find a mismatch, we must compare the - characters, not just the bytes. */ - int c1, c2; - - FETCH_STRING_CHAR_ADVANCE (c1, s1, i1, i1_byte); - FETCH_STRING_CHAR_ADVANCE (c2, s2, i2, i2_byte); - - if (c1 !=3D c2) - return c1 < c2 ? Qt : Qnil; - } - return i1 < SCHARS (s2) ? Qt : Qnil; + return string_compare (s1, s2, ignore_case) < 0 ? Qt : Qnil; } -=0C + static Lisp_Object concat (ptrdiff_t nargs, Lisp_Object *args, enum Lisp_Type target_type, bool last_special); =20 =3D=3D=3D modified file 'src/font.c' --- src/font.c 2014-06-21 19:45:59 +0000 +++ src/font.c 2014-06-27 14:33:07 +0000 @@ -717,7 +717,7 @@ Lisp_Object prev =3D Qnil; =20 while (CONSP (extra) - && NILP (Fstring_lessp (prop, XCAR (XCAR (extra))))) + && NILP (string_lessp (prop, XCAR (XCAR (extra))))) prev =3D extra, extra =3D XCDR (extra); =20 if (NILP (prev)) =3D=3D=3D modified file 'src/frame.c' --- src/frame.c 2014-06-17 16:09:19 +0000 +++ src/frame.c 2014-06-27 14:33:07 +0000 @@ -2050,7 +2050,7 @@ CHECK_STRING (name); =20 /* Don't change the name if it's already NAME. */ - if (! NILP (Fstring_equal (name, f->name))) + if (! NILP (string_equal (name, f->name))) return; =20 /* Don't allow the user to set the frame name to F, so it =3D=3D=3D modified file 'src/ftfont.c' --- src/ftfont.c 2014-06-17 16:09:19 +0000 +++ src/ftfont.c 2014-06-27 14:33:07 +0000 @@ -1119,8 +1119,8 @@ if (! NILP (AREF (spec, FONT_FAMILY_INDEX)) && NILP (assq_no_quit (AREF (spec, FONT_FAMILY_INDEX), ftfont_generic_family_list)) - && NILP (Fstring_equal (AREF (spec, FONT_FAMILY_INDEX), - AREF (entity, FONT_FAMILY_INDEX)))) + && NILP (string_equal (AREF (spec, FONT_FAMILY_INDEX), + AREF (entity, FONT_FAMILY_INDEX)))) entity =3D Qnil; } } =3D=3D=3D modified file 'src/keymap.c' --- src/keymap.c 2014-06-12 14:55:48 +0000 +++ src/keymap.c 2014-06-27 14:33:07 +0000 @@ -3199,8 +3199,8 @@ if (INTEGERP (a->event) && !INTEGERP (b->event)) return -1; if (SYMBOLP (a->event) && SYMBOLP (b->event)) - return (!NILP (Fstring_lessp (a->event, b->event)) ? -1 - : !NILP (Fstring_lessp (b->event, a->event)) ? 1 + return (!NILP (string_lessp (a->event, b->event)) ? -1 + : !NILP (string_lessp (b->event, a->event)) ? 1 : 0); return 0; } =3D=3D=3D modified file 'src/lisp.h' --- src/lisp.h 2014-06-25 12:11:08 +0000 +++ src/lisp.h 2014-06-27 14:33:07 +0000 @@ -3482,6 +3482,18 @@ extern Lisp_Object string_make_unibyte (Lisp_Object); extern void syms_of_fns (void); =20 +INLINE Lisp_Object +string_equal (Lisp_Object s1, Lisp_Object s2) +{ + return Fstring_equal (s1, s2, Qnil); +} + +INLINE Lisp_Object +string_lessp (Lisp_Object s1, Lisp_Object s2) +{ + return Fstring_lessp (s1, s2, Qnil); +} + /* Defined in floatfns.c. */ extern void syms_of_floatfns (void); extern Lisp_Object fmod_float (Lisp_Object x, Lisp_Object y); =3D=3D=3D modified file 'src/nsfns.m' --- src/nsfns.m 2014-06-01 08:23:18 +0000 +++ src/nsfns.m 2014-06-27 14:33:07 +0000 @@ -180,7 +180,7 @@ CHECK_STRING (name); =20 for (dpyinfo =3D x_display_list; dpyinfo; dpyinfo =3D dpyinfo->next) - if (!NILP (Fstring_equal (XCAR (dpyinfo->name_list_element), name)))= + if (!NILP (string_equal (XCAR (dpyinfo->name_list_element), name))) return dpyinfo; =20 error ("Emacs for Nextstep does not yet support multi-display"); @@ -390,7 +390,7 @@ /* see if it's changed */ if (STRINGP (arg)) { - if (STRINGP (oldval) && EQ (Fstring_equal (oldval, arg), Qt)) + if (STRINGP (oldval) && EQ (string_equal (oldval, arg), Qt)) return; } else if (!STRINGP (oldval) && EQ (oldval, Qnil) =3D=3D EQ (arg, Qnil))= @@ -482,7 +482,7 @@ CHECK_STRING (name); =20 /* Don't change the name if it's already NAME. */ - if (! NILP (Fstring_equal (name, f->name))) + if (! NILP (string_equal (name, f->name))) return; =20 fset_name (f, name); =3D=3D=3D modified file 'src/search.c' --- src/search.c 2014-06-23 04:11:29 +0000 +++ src/search.c 2014-06-27 14:33:07 +0000 @@ -227,7 +227,7 @@ goto compile_it; if (SCHARS (cp->regexp) =3D=3D SCHARS (pattern) && STRING_MULTIBYTE (cp->regexp) =3D=3D STRING_MULTIBYTE (pattern) - && !NILP (Fstring_equal (cp->regexp, pattern)) + && !NILP (string_equal (cp->regexp, pattern)) && EQ (cp->buf.translate, (! NILP (translate) ? translate : make_numb= er (0))) && cp->posix =3D=3D posix && (EQ (cp->syntax_table, Qt) =3D=3D=3D modified file 'src/w32fns.c' --- src/w32fns.c 2014-06-22 23:12:17 +0000 +++ src/w32fns.c 2014-06-27 14:33:07 +0000 @@ -1543,7 +1543,7 @@ return; =20 if (STRINGP (arg) && STRINGP (oldval) - && EQ (Fstring_equal (oldval, arg), Qt)) + && EQ (string_equal (oldval, arg), Qt)) return; =20 if (SYMBOLP (arg) && SYMBOLP (oldval) && EQ (arg, oldval)) @@ -1566,7 +1566,7 @@ { if (STRINGP (arg)) { - if (STRINGP (oldval) && EQ (Fstring_equal (oldval, arg), Qt)) + if (STRINGP (oldval) && EQ (string_equal (oldval, arg), Qt)) return; } else if (!NILP (arg) || NILP (oldval)) @@ -1774,7 +1774,7 @@ CHECK_STRING (name); =20 /* Don't change the name if it's already NAME. */ - if (! NILP (Fstring_equal (name, f->name))) + if (! NILP (string_equal (name, f->name))) return; =20 fset_name (f, name); @@ -5200,7 +5200,7 @@ CHECK_STRING (name); =20 for (dpyinfo =3D &one_w32_display_info; dpyinfo; dpyinfo =3D dpyinfo->= next) - if (!NILP (Fstring_equal (XCAR (dpyinfo->name_list_element), name)))= + if (!NILP (string_equal (XCAR (dpyinfo->name_list_element), name))) return dpyinfo; =20 /* Use this general default value to start with. */ =3D=3D=3D modified file 'src/w32menu.c' --- src/w32menu.c 2014-06-04 04:58:31 +0000 +++ src/w32menu.c 2014-06-27 14:33:07 +0000 @@ -1060,9 +1060,9 @@ return 0; name =3D XCAR (name); =20 - if (!NILP (Fstring_equal (name, yes))) + if (!NILP (string_equal (name, yes))) other =3D no; - else if (!NILP (Fstring_equal (name, no))) + else if (!NILP (string_equal (name, no))) other =3D yes; else return 0; @@ -1075,7 +1075,7 @@ if (!CONSP (name)) return 0; name =3D XCAR (name); - if (NILP (Fstring_equal (name, other))) + if (NILP (string_equal (name, other))) return 0; =20 /* Check there are no more options. */ @@ -1181,7 +1181,7 @@ value =3D Qnil; } =20 - if (!NILP (Fstring_equal (name, lispy_answer))) + if (!NILP (string_equal (name, lispy_answer))) { return value; } =3D=3D=3D modified file 'src/xfaces.c' --- src/xfaces.c 2014-06-10 03:32:36 +0000 +++ src/xfaces.c 2014-06-27 14:33:07 +0000 @@ -976,7 +976,7 @@ lookup STD_COLOR separately. If it's impossible to lookup a standard color, we just give up and use TTY_COLOR. */ if ((!STRINGP (XCAR (color_desc)) - || NILP (Fstring_equal (color, XCAR (color_desc)))) + || NILP (string_equal (color, XCAR (color_desc)))) && !NILP (Ffboundp (Qtty_color_standard_values))) { /* Look up STD_COLOR separately. */ =3D=3D=3D modified file 'src/xfns.c' --- src/xfns.c 2014-06-22 05:00:14 +0000 +++ src/xfns.c 2014-06-27 14:33:07 +0000 @@ -895,7 +895,7 @@ =20 if (STRINGP (arg)) { - if (STRINGP (oldval) && EQ (Fstring_equal (oldval, arg), Qt)) + if (STRINGP (oldval) && EQ (string_equal (oldval, arg), Qt)) return; } else if (!STRINGP (oldval) && EQ (oldval, Qnil) =3D=3D EQ (arg, Qnil))= @@ -927,7 +927,7 @@ =20 if (STRINGP (arg)) { - if (STRINGP (oldval) && EQ (Fstring_equal (oldval, arg), Qt)) + if (STRINGP (oldval) && EQ (string_equal (oldval, arg), Qt)) return; } else if (!NILP (arg) || NILP (oldval)) @@ -1442,7 +1442,7 @@ CHECK_STRING (name); =20 /* Don't change the name if it's already NAME. */ - if (! NILP (Fstring_equal (name, f->name))) + if (! NILP (string_equal (name, f->name))) return; =20 fset_name (f, name); @@ -4343,7 +4343,7 @@ CHECK_STRING (name); =20 for (dpyinfo =3D x_display_list; dpyinfo; dpyinfo =3D dpyinfo->next) - if (!NILP (Fstring_equal (XCAR (dpyinfo->name_list_element), name)))= + if (!NILP (string_equal (XCAR (dpyinfo->name_list_element), name))) return dpyinfo; =20 /* Use this general default value to start with. */ =3D=3D=3D modified file 'test/automated/fns-tests.el' --- test/automated/fns-tests.el 2014-06-25 10:36:51 +0000 +++ test/automated/fns-tests.el 2014-06-27 15:15:23 +0000 @@ -100,3 +100,38 @@ (should (compare-strings "=E3=81=93=E3=82=93=E3=81=AB=E3=81=A1=E3=81=AF= =EF=BD=BA=EF=BE=9D=EF=BE=86=EF=BE=81=EF=BE=8A" nil nil "=E3=81=93=E3=82=93= =E3=81=AB=E3=81=A1=E3=81=AF=EF=BD=BA=EF=BE=9D=EF=BE=86=EF=BE=81=EF=BE=8A"= nil nil)) (should (=3D (compare-strings "=E3=82=93=E3=81=AB=E3=81=A1=E3=81=AF=EF= =BD=BA=EF=BE=9D=EF=BE=86=EF=BE=81=EF=BE=8A=E3=81=93" nil nil "=E3=81=93=E3= =82=93=E3=81=AB=E3=81=A1=E3=81=AF=EF=BD=BA=EF=BE=9D=EF=BE=86=EF=BE=81=EF=BE= =8A" nil nil) 1)) (should (=3D (compare-strings "=E3=81=93=E3=82=93=E3=81=AB=E3=81=A1=E3= =81=AF=EF=BD=BA=EF=BE=9D=EF=BE=86=EF=BE=81=EF=BE=8A" nil nil "=E3=82=93=E3= =81=AB=E3=81=A1=E3=81=AF=EF=BD=BA=EF=BE=9D=EF=BE=86=EF=BE=81=EF=BE=8A=E3=81= =93" nil nil) -1))) + +(ert-deftest fns-test-string-equal () + (should-error (string-equal)) + (should-error (string-equal 1 2)) + (should-error (string-equal '[1 2 3 4] "1 2 3 4")) + (should-error (string-equal "aaa" "bbb" "ccc" "ddd")) + (should (string-equal "foo" 'foo)) + (should (string-equal "BAR" 'bar t)) + (should (string-equal "aaa" "aaa")) + (should-not (string-equal "aaa" "aaaa")) + (should-not (string-equal "aaaa" "aaa")) + (should-not (string-equal "aaa" "aab")) + (should-not (string-equal "aab" "aaa")) + (should (string-equal "AAA" "aaa" t)) + (should (string-equal "bbb" "BBB" t)) + (should-not (string-equal (make-string 10 1234) (make-string 11 1234))= ) + (should (string-equal "=D3=92=D3=92=D3=92" "=D3=92=D3=92=D3=92")) + (should-not (string-equal "=D3=93=D3=93=D3=93" "=D3=92=D3=92=D3=92")) + (should (string-equal "=D3=93=D3=93=D3=93" "=D3=92=D3=92=D3=92" t))) + +(ert-deftest fns-test-string-lessp () + (should-error (string-lessp)) + (should-error (string-lessp 1 2)) + (should-error (string-lessp '[1 2 3 4] "1 2 3 4")) + (should-error (string-lessp "aaa" "bbb" "ccc" "ddd")) + (should (string-lessp "" "a")) + (should-not (string-lessp "" "")) + (should (string-lessp "aaa" "bbb")) + (should (string-lessp "aaa" "aab")) + (should (string-lessp "aaa" "aaaa")) + (should-not (string-lessp "ddd" "ddd")) + (should-not (string-lessp "ddd" "ccc")) + (should (string-lessp (make-string 4 1111) (make-string 4 1112))) + (should (string-lessp "=D3=92=D3=92=D3=92" "=D3=93=D3=93=D3=93")) + (should-not (string-lessp "=D3=92=D3=92=D3=92" "=D3=93=D3=93=D3=93" t)= )) --------------010106030402080305090204--