+If BASE, interpret STRING as a number in that base. If BASE isn't
+present, base 10 is used. BASE must be between 2 and 16 (inclusive).
+If the base used is not 10, floating point is not recognized."
+ (if (or (null base) (= base 10))
+ (si:string-to-number string)
+ (if (or (< base 2)(> base 16))
+ (signal 'args-out-of-range (cons base nil)))
+ (let ((len (length string))
+ (pos 0))
+ ;; skip leading whitespace.
+ (while (and (< pos len)
+ (memq (aref string pos) '(?\ ?\t)))
+ (setq pos (1+ pos)))
+ (if (= pos len)
+ 0
+ (let ((number 0)(negative 1)
+ chr num)
+ (if (eq (aref string pos) ?-)
+ (setq negative -1
+ pos (1+ pos))
+ (if (eq (aref string pos) ?+)
+ (setq pos (1+ pos))))
+ (while (and (< pos len)
+ (setq chr (aref string pos)
+ num (cond
+ ((and (<= ?0 chr)(<= chr ?9))
+ (- chr ?0))
+ ((and (<= ?A chr)(<= chr ?F))
+ (+ (- chr ?A) 10))
+ ((and (<= ?a chr)(<= chr ?f))
+ (+ (- chr ?a) 10))
+ (t nil)))
+ (< num base))
+ (setq number (+ (* number base) num)
+ pos (1+ pos)))
+ (* negative number))))))))))
+
+;; Emacs 20.1 and 20.2: (concat-chars &rest CHARS)
+;; Emacs 20.3/XEmacs 21.0 and later: (string &rest CHARS)
+(static-cond
+ ((and (fboundp 'string)
+ (subrp (symbol-function 'string)))
+ ;; Emacs 20.3/XEmacs 21.0 and later.
+ )
+ ((and (fboundp 'concat-chars)
+ (subrp (symbol-function 'concat-chars)))
+ ;; Emacs 20.1 and 20.2.
+ (defalias 'string 'concat-chars))
+ (t
+ ;; Use `defun-maybe' to update `load-history'.
+ (defun-maybe string (&rest chars)
+ "Concatenate all the argument characters and make the result a string."
+ ;; We cannot use (apply 'concat chars) here because `concat' does not
+ ;; work with multibyte chars on Mule 1.* and 2.*.
+ (mapconcat (function char-to-string) chars ""))))
+
+;; Mule: (char-before POS)
+;; v20: (char-before &optional POS)
+(static-condition-case nil
+ ;; compile-time check.
+ (progn
+ (char-before)
+ (if (get 'char-before 'defun-maybe)
+ (error "`char-before' is already defined")))
+ (wrong-number-of-arguments ; Mule.
+ ;; load-time check.
+ (or (fboundp 'si:char-before)
+ (progn
+ (fset 'si:char-before (symbol-function 'char-before))
+ (put 'char-before 'defun-maybe t)
+ ;; takes IGNORED for backward compatibility.
+ (defun char-before (&optional pos ignored)
+ "\
+Return character in current buffer preceding position POS.
+POS is an integer or a buffer pointer.
+If POS is out of range, the value is nil."
+ (si:char-before (or pos (point)))))))
+ (void-function ; non-Mule.
+ ;; load-time check.
+ (defun-maybe char-before (&optional pos)
+ "\
+Return character in current buffer preceding position POS.
+POS is an integer or a buffer pointer.
+If POS is out of range, the value is nil."
+ (if pos
+ (save-excursion
+ (and (= (goto-char pos) (point))
+ (not (bobp))
+ (preceding-char)))
+ (and (not (bobp))
+ (preceding-char)))))
+ (error ; found our definition at compile-time.
+ ;; load-time check.
+ (condition-case nil
+ (char-before)
+ (wrong-number-of-arguments ; Mule.
+ (or (fboundp 'si:char-before)
+ (progn
+ (fset 'si:char-before (symbol-function 'char-before))
+ (put 'char-before 'defun-maybe t)
+ ;; takes IGNORED for backward compatibility.
+ (defun char-before (&optional pos ignored)
+ "\
+Return character in current buffer preceding position POS.
+POS is an integer or a buffer pointer.
+If POS is out of range, the value is nil."
+ (si:char-before (or pos (point)))))))
+ (void-function ; non-Mule.
+ (defun-maybe char-before (&optional pos)
+ "\
+Return character in current buffer preceding position POS.
+POS is an integer or a buffer pointer.
+If POS is out of range, the value is nil."
+ (if pos
+ (save-excursion
+ (and (= (goto-char pos) (point))
+ (not (bobp))
+ (preceding-char)))
+ (and (not (bobp))
+ (preceding-char))))))))
+
+;; v18, v19: (char-after POS)
+;; v20: (char-after &optional POS)
+(static-condition-case nil
+ ;; compile-time check.
+ (progn
+ (char-after)
+ (if (get 'char-after 'defun-maybe)
+ (error "`char-after' is already redefined")))
+ (wrong-number-of-arguments ; v18, v19
+ ;; load-time check.
+ (or (fboundp 'si:char-after)
+ (progn
+ (fset 'si:char-after (symbol-function 'char-after))
+ (put 'char-after 'defun-maybe t)
+ (defun char-after (&optional pos)
+ "\
+Return character in current buffer at position POS.
+POS is an integer or a buffer pointer.
+If POS is out of range, the value is nil."
+ (si:char-after (or pos (point)))))))
+ (void-function ; NEVER happen?
+ ;; load-time check.
+ (defun-maybe char-after (&optional pos)
+ "\
+Return character in current buffer at position POS.
+POS is an integer or a buffer pointer.
+If POS is out of range, the value is nil."
+ (if pos
+ (save-excursion
+ (and (= (goto-char pos) (point))
+ (not (eobp))
+ (following-char)))
+ (and (not (eobp))
+ (following-char)))))
+ (error ; found our definition at compile-time.
+ ;; load-time check.
+ (condition-case nil
+ (char-after)
+ (wrong-number-of-arguments ; v18, v19
+ (or (fboundp 'si:char-after)
+ (progn
+ (fset 'si:char-after (symbol-function 'char-after))
+ (put 'char-after 'defun-maybe t)
+ (defun char-after (&optional pos)
+ "\
+Return character in current buffer at position POS.
+POS is an integer or a buffer pointer.
+If POS is out of range, the value is nil."
+ (si:char-after (or pos (point)))))))
+ (void-function ; NEVER happen?
+ (defun-maybe char-after (&optional pos)
+ "\
+Return character in current buffer at position POS.
+POS is an integer or a buffer pointer.
+If POS is out of range, the value is nil."
+ (if pos
+ (save-excursion
+ (and (= (goto-char pos) (point))
+ (not (eobp))
+ (following-char)))
+ (and (not (eobp))
+ (following-char))))))))
+
+;; Emacs 19.29 and later: (buffer-substring-no-properties START END)