# HG changeset patch # User HIROSE Yuuji # Date 1487659599 -32373 # Node ID 2011de73a671f7c8e37bbc036aa0a93ad8bed0d6 # Parent 8871fe9f563bb13344ebc39bb8963babcb091d64 Who owes the incompatibility of string-to-int? diff -r 8871fe9f563b -r 2011de73a671 yahtml.el --- a/yahtml.el Wed Jan 18 07:49:03 2017 +0900 +++ b/yahtml.el Tue Feb 21 15:46:12 2017 +0859 @@ -3,7 +3,7 @@ ;;; Last modified Thu Jan 5 17:45:36 2017 on firestorm ;;; $Id$ -(defconst yahtml-revision-number "1.79" +(defconst yahtml-revision-number "1.79.2" "Revision number of running yahtml.el") ;;; Commentary: @@ -1302,7 +1302,7 @@ (cons "align" alg)) (if (string< "" brd) (cons "border" - (format "%dpx" (string-to-int brd)))))))) + (format "%dpx" (YaTeX-str2int brd)))))))) (concat (yahtml-make-optional-argument "border" brd) (yahtml-make-optional-argument "align" alg)))))) @@ -1524,7 +1524,7 @@ (append (if (string< "" b) (list - (cons "border" (format "%dpx solid" (string-to-int b))) + (cons "border" (format "%dpx solid" (YaTeX-str2int b))) (cons "border-collapse" "collapse"))) (if (string< "" a) (cond @@ -2995,7 +2995,7 @@ (progn (skip-chars-forward "\"' \t\n") (looking-at "[0-9]+"))) - (setq cols (+ (string-to-int (YaTeX-match-string 0)) cols)) + (setq cols (+ (YaTeX-str2int (YaTeX-match-string 0)) cols)) (setq cols (1+ cols))) (goto-char rb) (setq p (point))) @@ -3095,7 +3095,7 @@ (let ((f (if (string= "" (YaTeX-match-string 1)) YaTeX-current-file-name (YaTeX-match-string 1))) - (l (string-to-int (or (YaTeX-match-string 2) + (l (YaTeX-str2int (or (YaTeX-match-string 2) (YaTeX-match-string 3))))) (if sit (sit-for 1)) (forward-line -1) diff -r 8871fe9f563b -r 2011de73a671 yatex.el --- a/yatex.el Wed Jan 18 07:49:03 2017 +0900 +++ b/yatex.el Tue Feb 21 15:46:12 2017 +0859 @@ -8,7 +8,7 @@ ;;; Code: (require 'comment) (require 'yatexlib) -(defconst YaTeX-revision-number "1.79.1" +(defconst YaTeX-revision-number "1.79.2" "Revision number of running yatex.el") ;---------- Local variables ---------- @@ -1310,7 +1310,7 @@ (car (where-is-internal 'YaTeX-make-begin-end)))) (point)) (put 'YaTeX-insert-braces 'begend-guide - (+ 1 (string-to-int ;increment counter of beg-end guidance + (+ 1 (YaTeX-str2int ;increment counter of beg-end guidance (prin1-to-string (get 'YaTeX-insert-braces 'begend-guide))))))))) env macro not-literal b e) diff -r 8871fe9f563b -r 2011de73a671 yatexadd.el --- a/yatexadd.el Wed Jan 18 07:49:03 2017 +0900 +++ b/yatexadd.el Tue Feb 21 15:46:12 2017 +0859 @@ -571,19 +571,19 @@ (Y (substring ts -4)) (y (substring ts -2)) (b (substring ts 0 3)) - (d (format "%d" (string-to-int (substring ts 4 6)))) + (d (format "%d" (YaTeX-str2int (substring ts 4 6)))) (H (substring ts 7 9)) (M (substring ts 10 12)) (S (substring ts 13 15)) - (HMS (+ (* 10000 (string-to-int H)) - (* 100 (string-to-int M)) - (string-to-int S))) + (HMS (+ (* 10000 (YaTeX-str2int H)) + (* 100 (YaTeX-str2int M)) + (YaTeX-str2int S))) (talphabex (YaTeX::ref-alphabex HMS)) (mnames "JanFebMarAprMayJunJulAugSepOctNovDec") (m (format "%02d" (/ (string-match b mnames) 3))) - (ymd (+ (* 10000 (string-to-int y)) - (* 100 (string-to-int m)) - (string-to-int d))) + (ymd (+ (* 10000 (YaTeX-str2int y)) + (* 100 (YaTeX-str2int m)) + (YaTeX-str2int d))) (dalphabex (YaTeX::ref-alphabex ymd))) (YaTeX-replace-formats (or format YaTeX-ref-default-label-string) diff -r 8871fe9f563b -r 2011de73a671 yatexgen.el --- a/yatexgen.el Wed Jan 18 07:49:03 2017 +0900 +++ b/yatexgen.el Tue Feb 21 15:46:12 2017 +0859 @@ -1,6 +1,6 @@ ;;; yatexgen.el --- YaTeX add-in function generator(rev.5) -;;; (c)1991-1995,1999,2000 by HIROSE Yuuji.[yuuji@yatex.org] +;;; (c)1991-1995,1999,2000,2017 by HIROSE Yuuji.[yuuji@yatex.org] ;;; Last modified Sun Dec 21 14:04:49 2014 on firestorm ;;; $Id$ @@ -582,6 +582,6 @@ (YaTeX-generate-option-type command) (YaTeX-generate-argument-type command - (string-to-int (read-string "How many arguments?: ")))) nil)) + (YaTeX-str2int (read-string "How many arguments?: ")))) nil)) (provide 'yatexgen) diff -r 8871fe9f563b -r 2011de73a671 yatexlib.el --- a/yatexlib.el Wed Jan 18 07:49:03 2017 +0900 +++ b/yatexlib.el Tue Feb 21 15:46:12 2017 +0859 @@ -1,16 +1,25 @@ ;;; yatexlib.el --- YaTeX and yahtml common libraries -*- coding: sjis -*- ;;; ;;; (c)1994-2017 by HIROSE Yuuji.[yuuji@yatex.org] -;;; Last modified Thu Jan 5 17:46:13 2017 on firestorm +;;; Last modified Sat Jan 28 15:59:00 2017 on firestorm ;;; $Id$ ;;; Code: + +;; High-precedence compatible function +(fset 'YaTeX-str2int + (if (fboundp 'string-to-number) + (function + (lambda (string &optional base) + (ceiling (string-to-number string base)))) + 'string-to-int)) + ;; General variables (defvar YaTeX-dos (memq system-type '(ms-dos windows-nt OS/2))) (defvar YaTeX-macos (memq system-type '(darwin))) -(defvar YaTeX-emacs-19 (>= (string-to-int emacs-version) 19)) -(defvar YaTeX-emacs-20 (>= (string-to-int emacs-version) 20)) -(defvar YaTeX-emacs-21 (>= (string-to-int emacs-version) 21)) +(defvar YaTeX-emacs-19 (>= (YaTeX-str2int emacs-version) 19)) +(defvar YaTeX-emacs-20 (>= (YaTeX-str2int emacs-version) 20)) +(defvar YaTeX-emacs-21 (>= (YaTeX-str2int emacs-version) 21)) (defvar YaTeX-user-completion-table (if YaTeX-dos "~/_yatexrc" "~/.yatexrc") "*Default filename in which user completion table is saved.") @@ -559,7 +568,7 @@ (if (numberp height) (+ height 2) (/ (* (YaTeX-screen-height) - (string-to-int height)) + (YaTeX-str2int height)) 100))) (- (YaTeX-screen-height) window-min-height 1)) window-min-height)))) @@ -1037,7 +1046,7 @@ (cons env m0))) ;else, return meaningful values (store-match-data md))))))) -(defun YaTeX-goto-corresponding-environment (&optional allow-mismatch noerr) +(defun YaTeX-goto-corresponding-environment (&optional allow-mismatch noerr bg) "Go to corresponding begin/end enclosure. Optional argument ALLOW-MISMATCH allows mismatch open/clese. Use this for \left(, \right). @@ -1049,14 +1058,14 @@ (m1 (match-beginning 1)) ;environment in \begin{} (m2 (match-beginning 2)) ;environment in \end{} (m3 (match-beginning 3))) ;environment in \[ \] \( \) - ;(setq env (regexp-quote (buffer-substring p (match-beginning 0)))) + ;(setq env (regexp-quote (buffer-substring p (match-beginning 0)))) (if (cond (m1 ;if begin{xxx} (setq env (if allow-mismatch YaTeX-struct-name-regexp (regexp-quote (buffer-substring m1 (match-end 1))))) - ; (setq regexp (concat "\\(\\\\end{" env "}\\)\\|" - ; "\\(\\\\begin{" env "}\\)")) + ; (setq regexp (concat "\\(\\\\end{" env "}\\)\\|" + ; "\\(\\\\begin{" env "}\\)")) (setq regexp (concat "\\(" @@ -1071,8 +1080,8 @@ (setq env (if allow-mismatch YaTeX-struct-name-regexp (regexp-quote (buffer-substring m2 (match-end 2))))) - ; (setq regexp (concat "\\(\\\\begin{" env "}\\)\\|" - ; "\\(\\\\end{" env "}\\)")) + ; (setq regexp (concat "\\(\\\\begin{" env "}\\)\\|" + ; "\\(\\\\end{" env "}\\)")) (setq regexp (concat "\\(" @@ -1110,7 +1119,7 @@ (funcall (if noerr 'message 'error) "Corresponding environment `%s' not found." env) - (sit-for 1) + (or bg (sit-for 1)) nil)))))) (defun YaTeX-end-environment () diff -r 8871fe9f563b -r 2011de73a671 yatexsec.el --- a/yatexsec.el Wed Jan 18 07:49:03 2017 +0900 +++ b/yatexsec.el Tue Feb 21 15:46:12 2017 +0859 @@ -1,6 +1,6 @@ ;;; yatexsec.el --- YaTeX sectioning browser ;;; -;;; (c) 1994-2013 by HIROSE Yuuji [yuuji@yatex.org] +;;; (c) 1994-2017 by HIROSE Yuuji [yuuji@yatex.org] ;;; Last modified Sun Dec 21 14:16:35 2014 on firestorm ;;; $Id$ @@ -134,7 +134,7 @@ (and ln (string< "" ln) (progn (goto-char (point-min)) - (forward-line (max 0 (- (string-to-int ln) 2))) + (forward-line (max 0 (- (YaTeX-str2int ln) 2))) (and (search-forward ptn nil t) (goto-char (match-beginning 0))))) @@ -345,7 +345,7 @@ (set-buffer secbuf) (goto-char (point-max)) (while (re-search-backward pattern nil t) - (if (< ln (string-to-int (YaTeX-match-string 1))) nil + (if (< ln (YaTeX-str2int (YaTeX-match-string 1))) nil (beginning-of-line) (search-forward YaTeX-ec) (looking-at YaTeX-TeX-token-regexp)