[CEDET-devel] Compatibility
Brought to you by:
zappo
From: David P. <dav...@wa...> - 2003-09-30 20:42:53
|
Hi Eric, I recently had the opportunity to work a little bit more with XEmacs than I usually do, and discovered that semantic regularly failed because of the missing `compare-strings' function. A quick grep across CEDET packages shows that `compare-strings' is used in these libraries: ./semantic/semantic-complete.el:421: ./semantic/semantic-find.el:290: ./semantic/semantic-sort.el:54: An Elisp implementation of `compare-strings' is in the eieio directory but no more used there. I propose to move that `compare-strings' implementation in a new cedet-compat.el library in the common directory, and make `compare-strings' an auto loaded function, so it will be automatically provided when necessary. In the future we could move other compatibility stuff (like overlay/extent) to the cedet-compat library. Following is a change log, the source of cedet-compat.el, and a patch to include that file in the "common" project. What do you think? David 2003-09-30 David Ponce <da...@dp...> * common/cedet-compat.el New file. * common/Makefile Re-generate. * common/Project.ede (common): Add cedet-compat.el to target sources. * eieio/compare-strings.el Remove. ;;; cedet-compat.el --- Compatibility across (X)Emacs versions ;; Copyright (C) 2003 David Ponce ;; Author: David Ponce <da...@dp...> ;; Maintainer: David Ponce <da...@dp...> ;; Keywords: compatibility ;; X-RCS: $Id$ ;; This file is not part of Emacs ;; This program is free software; you can redistribute it and/or ;; modify it under the terms of the GNU General Public License as ;; published by the Free Software Foundation; either version 2, or (at ;; your option) any later version. ;; This program is distributed in the hope that it will be useful, but ;; WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with this program; see the file COPYING. If not, write to ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, ;; Boston, MA 02111-1307, USA. ;;; Commentary: ;; ;; This library provides functions to allow running CEDET packages on ;; a variety of [X]Emacs versions. ;;; History: ;; ;;; Code: ;; XEmacs does not have the `compare-strings' function. Here is an ;; implementation in Emacs Lisp, derived from the C implementation ;; found in src/fns.c, in GNU Emacs 21.3.1 sources. ;;;###autoload (defun compare-strings (str1 start1 end1 str2 start2 end2 &optional ignore-case) "Compare the contents of two strings. In string STR1, skip the first START1 characters and stop at END1. In string STR2, skip the first START2 characters and stop at END2. END1 and END2 default to the full lengths of the respective strings. Case is significant in this comparison if IGNORE-CASE is nil. The value is t if the strings (or specified portions) match. If string STR1 is less, the value is a negative number N; - 1 - N is the number of characters that match at the beginning. If string STR1 is greater, the value is a positive number N; N - 1 is the number of characters that match at the beginning." (or start1 (setq start1 0)) (or start2 (setq start2 0)) (setq end1 (if end1 (min end1 (length str1)) (length str1))) (setq end2 (if end2 (min end2 (length str2)) (length str2))) (let ((i1 start1) (i2 start2) result c1 c2) (while (and (not result) (< i1 end1) (< i2 end2)) (setq c1 (aref str1 i1) c2 (aref str2 i2) i1 (1+ i1) i2 (1+ i2)) (if ignore-case (setq c1 (upcase c1) c2 (upcase c2))) (setq result (cond ((< c1 c2) (- i1)) ((> c1 c2) i1)))) (or result (cond ((< i1 end1) (1+ (- i1 start1))) ((< i2 end2) (1- (- start1 i1))) (t))) )) (provide 'cedet-compat) ;;; cedet-compat.el ends here Index: common/Makefile =================================================================== RCS file: /cvsroot/cedet/cedet/common/Makefile,v retrieving revision 1.2 diff -c -r1.2 Makefile *** common/Makefile 24 Sep 2003 08:04:30 -0000 1.2 --- common/Makefile 30 Sep 2003 20:18:10 -0000 *************** *** 16,22 **** init_LISP=cedet-load.el EMACS=emacs setup_LISP=cedet.el ! common_LISP=cedet-autogen.el ezimage.el inversion.el pprint.el sformat.el working.el VERSION=1.0beta1 DISTDIR=$(top)common-$(VERSION) --- 16,22 ---- init_LISP=cedet-load.el EMACS=emacs setup_LISP=cedet.el ! common_LISP=cedet-autogen.el cedet-compat.el ezimage.el inversion.el pprint.el sformat.el working.el VERSION=1.0beta1 DISTDIR=$(top)common-$(VERSION) Index: common/Project.ede =================================================================== RCS file: /cvsroot/cedet/cedet/common/Project.ede,v retrieving revision 1.2 diff -c -r1.2 Project.ede *** common/Project.ede 24 Sep 2003 08:04:09 -0000 1.2 --- common/Project.ede 30 Sep 2003 20:18:10 -0000 *************** *** 24,30 **** (ede-proj-target-elisp "common" :name "common" :path "" ! :source '("cedet-autogen.el" "ezimage.el" "inversion.el" "pprint.el" "sformat.el" "working.el") ) ) :web-site-url "http://cedet.sourceforge.net/" --- 24,30 ---- (ede-proj-target-elisp "common" :name "common" :path "" ! :source '("cedet-autogen.el" "cedet-compat.el" "ezimage.el" "inversion.el" "pprint.el" "sformat.el" "working.el") ) ) :web-site-url "http://cedet.sourceforge.net/" |