Commit 3c6f9e2a authored by David Byers's avatar David Byers
Browse files

First set of fixes for Gnu Emacs 22.1

parent db2b9968
2007-06-08 <David Byers@TAMIZDAT>
* lyskom-rest.el (lyskom-sentinel): Check that proc is a process
before using it as such. Call lyskom-remove-unread-buffer with the
right argument (the buffer, not the process).
(lyskom-session-nickname): Don't croak if the process is nil.
* language.el (lyskom-get-menu-string): Decode menu string from
latin-1 rather than encoding it.
* compatibility.el (lyskom-frame-width): Dummy definition of
lyskom-frame-width to suppress compilation warning.
* view-text.el: Replaced string-to-int with
lyskom-string-to-number.
* aux-items.el: Same.
* commands1.el: Same.
* compatibility.el: Same.
* completing-read.el: Same.
* edit-text.el: Same.
* faqs.el: Same.
* filter-edit.el: Same.
* flags.el: Same.
* lyskom-buttons.el: Same.
* lyskom-rest.el: Same.
* option-edit.el: Same.
* parse.el: Same.
* regexp.el: Same.
* review.el: Same.
* startup.el: Same.
* utilities.el: Same.
* utilities.el: Fix for Emacs 22.1 (should also improve
performance on XEmacs).
(lyskom-string-to-int): Clarifyig comment in docstring.
2007-04-26 Hans Eric Svensson <eric+lyskom@lysator.liu.se>
* lyskom-rest.el (lyskom-cache-all-memberships): New function
......
......@@ -452,19 +452,19 @@ Invalid tests are silently ignored."
(concat
(cond ((string-match "^P\\([0-9]+\\)" (aux-item->data item))
(lyskom-format 'cross-reference-pers-aux
(string-to-int
(lyskom-string-to-number
(match-string 1 (aux-item->data item)))
pers
))
((string-match "^C\\([0-9]+\\)" (aux-item->data item))
(lyskom-format 'cross-reference-conf-aux
(string-to-int
(lyskom-string-to-number
(match-string 1 (aux-item->data item)))
pers
))
((string-match "^T\\([0-9]+\\)" (aux-item->data item))
(lyskom-format 'cross-reference-text-aux
(string-to-int
(lyskom-string-to-number
(match-string 1 (aux-item->data item)))
pers
))
......@@ -482,19 +482,19 @@ Invalid tests are silently ignored."
(concat
(cond ((string-match "^P\\([0-9]+\\)" (aux-item->data item))
(lyskom-format 'cross-reference-pers-status-aux
(string-to-int
(lyskom-string-to-number
(match-string 1 (aux-item->data item)))
(aux-item->creator pers)
))
((string-match "^C\\([0-9]+\\)" (aux-item->data item))
(lyskom-format 'cross-reference-conf-status-aux
(string-to-int
(lyskom-string-to-number
(match-string 1 (aux-item->data item)))
pers
))
((string-match "^T\\([0-9]+\\)" (aux-item->data item))
(lyskom-format 'cross-reference-text-status-aux
(string-to-int
(lyskom-string-to-number
(match-string 1 (aux-item->data item)))
(aux-item->creator pers)
))
......@@ -597,7 +597,7 @@ Invalid tests are silently ignored."
(match-string 1 (aux-item->data item))))
((string-match "^LysKOM:\\(.*\\)$" (aux-item->data item))
(lyskom-format 'redirect-lyskom-aux
(string-to-int
(lyskom-string-to-number
(match-string 1 (aux-item->data item))))))
(lyskom-aux-item-terminating-button item obj)))
......@@ -666,7 +666,7 @@ Invalid tests are silently ignored."
(defun lyskom-status-print-faq-text (item &optional obj)
(if (lyskom-aux-item-validate (aux-item->data item) 'lyskom-string-to-int)
(let* ((text-no (string-to-int (aux-item->data item)))
(let* ((text-no (lyskom-string-to-number (aux-item->data item)))
(subject (if kom-deferred-printing
(lyskom-create-defer-info 'get-text-stat
text-no
......@@ -688,7 +688,7 @@ Invalid tests are silently ignored."
(defun lyskom-print-faq-for-conf (item &optional obj)
(if (lyskom-aux-item-validate (aux-item->data item) 'lyskom-string-to-int)
(let ((conf-no (string-to-int (aux-item->data item))))
(let ((conf-no (lyskom-string-to-number (aux-item->data item))))
(concat
(cond ((zerop conf-no) (lyskom-get-string 'faq-for-server-aux))
(t (lyskom-format 'faq-for-conf-aux conf-no)))
......@@ -707,7 +707,7 @@ Invalid tests are silently ignored."
(defun lyskom-print-send-comments-to (item &optional obj)
(if (lyskom-aux-item-validate (aux-item->data item) 'lyskom-string-to-int)
(let ((conf-no (string-to-int (aux-item->data item))))
(let ((conf-no (lyskom-string-to-number (aux-item->data item))))
(lyskom-format-insert 'status-send-comments-to
conf-no
(lyskom-aux-item-terminating-button item obj)))
......@@ -746,7 +746,7 @@ Invalid tests are silently ignored."
(defun lyskom-print-recommended-conf (item &optional obj)
(if (lyskom-aux-item-validate (aux-item->data item) 'lyskom-string-to-int)
(let ((conf-no (string-to-int (aux-item->data item))))
(let ((conf-no (lyskom-string-to-number (aux-item->data item))))
(lyskom-format-insert 'recommended-conf-aux
conf-no
(lyskom-aux-item-terminating-button item obj)))
......@@ -773,7 +773,7 @@ Invalid tests are silently ignored."
(defun lyskom-print-elisp-client-rejected-invitation (item &optional obj)
(if (lyskom-aux-item-validate (aux-item->data item) 'lyskom-string-to-int)
(let ((conf-no (string-to-int (aux-item->data item))))
(let ((conf-no (lyskom-string-to-number (aux-item->data item))))
(lyskom-format-insert 'status-rejected-recommendation-aux-item
conf-no
(lyskom-aux-item-terminating-button item obj)))
......
......@@ -240,7 +240,7 @@ This command accepts text number prefix arguments (see
(defun lyskom-print-comment-like-aux (item object)
(when (lyskom-aux-item-validate (aux-item->data item) 'lyskom-string-to-int)
(let* ((text-no (string-to-int (aux-item->data item)))
(let* ((text-no (lyskom-string-to-number (aux-item->data item)))
(text-stat nil)
(text nil))
(unless kom-deferred-printing
......@@ -2269,7 +2269,7 @@ exist."
;; Incorrect completion, integer entered.
((string-match "\\`\\s-*[0-9]+\\s-*\\'" mark)
(setq mark-type (string-to-int mark)))
(setq mark-type (lyskom-string-to-number mark)))
;; Incorrect completion; create new symbolic mark type.
((and create-nonexistent
......
......@@ -134,6 +134,7 @@ KEYS should be a string in the format used for saving keyboard macros
;; If we use lyskom-function-alias here we'll get an obsolecense
;; warning about screen-width. This way the compiler won't notice :-)
(defun lyskom-frame-width ())
(if (fboundp 'frame-width)
(defalias 'lyskom-frame-width 'frame-width)
(fset 'lyskom-frame-width 'screen-width))
......@@ -677,6 +678,13 @@ Emacsen."
(defun lyskom-make-local-hook (hook))
(fset 'lyskom-make-local-hook 'make-local-hook)))
;;; ================================================================
;;; Emacs 22.1 stuff
(defun lyskom-string-to-number(string &optional base))
(if (fboundp 'string-to-number)
(defalias 'lyskom-string-to-number 'string-to-number)
(defalias 'lyskom-string-to-number 'string-to-int))
;;; ================================================================
......
......@@ -407,7 +407,7 @@ persons who are logged on."
"Used internally by lyskom-read-conf-internal to expand person and
conference number specifications to something useful."
(cond ((string-match (lyskom-get-string 'person-or-conf-no-regexp) string)
(let* ((no (string-to-int (match-string 1 string)))
(let* ((no (lyskom-string-to-number (match-string 1 string)))
(cs (blocking-do 'get-uconf-stat no)))
(if (and cs
(lyskom-read-conf-internal-verify-type
......@@ -420,7 +420,7 @@ conference number specifications to something useful."
cs
(list string)))))
((string-match (lyskom-get-string 'session-no-regexp) string)
(let* ((no (string-to-int (match-string 1 string)))
(let* ((no (lyskom-string-to-number (match-string 1 string)))
(si (blocking-do 'get-session-info no))
(cs (and si
(blocking-do 'get-uconf-stat
......
......@@ -1670,7 +1670,7 @@ non-nil. If MATCH-NUMBER is 'angled, only match a number inside <>."
(nil
""))))
(if match-number
(string-to-int (buffer-substring (match-beginning 2)
(lyskom-string-to-number (buffer-substring (match-beginning 2)
(match-end 2)))
t)
nil))
......
......@@ -68,8 +68,8 @@
(lyskom-traverse item aux-list
(when (string-match "^\\([0-9]+\\) \\([0-9]+\\)" (aux-item->data item))
(setq lyskom-read-faqs
(cons (cons (string-to-int (match-string 1 (aux-item->data item)))
(string-to-int (match-string 2 (aux-item->data item))))
(cons (cons (lyskom-string-to-number (match-string 1 (aux-item->data item)))
(lyskom-string-to-number (match-string 2 (aux-item->data item))))
lyskom-read-faqs))))))
;;; ======================================================================
......@@ -170,9 +170,9 @@ do this. To add a FAQ, use `kom-add-server-faq'."
nil t)))
(when text-no
(lyskom-format-insert 'deleting-faq
(string-to-int text-no)
(lyskom-string-to-number text-no)
conf-stat)
(cache-del-text-stat (string-to-int text-no))
(cache-del-text-stat (lyskom-string-to-number text-no))
(when conf-stat
(cache-del-conf-stat (conf-stat->conf-no conf-stat)))
(lyskom-report-command-answer
......@@ -310,7 +310,7 @@ create a new FAQ."
faq-list)
nil t)
faq-list))))
(text-no (and text-no-aux (string-to-int (car text-no-aux))))
(text-no (and text-no-aux (lyskom-string-to-number (car text-no-aux))))
(aux-no (and text-no-aux (cdr text-no-aux))))
(cond
......
......@@ -499,7 +499,7 @@ If NEWLINE is non-nil, insert a newline after the header."
(cond ((memq what '(author subject text recipient))
(setq arg argstring))
((memq what '(author-no recipient-no))
(setq arg (string-to-int argstring)))
(setq arg (lyskom-string-to-number argstring)))
((memq what '(author-re subject-re text-re recipient-re))
(setq arg argstring)
(lyskom-filter-verify-regexp arg))))
......
......@@ -391,7 +391,7 @@ for more information."
;; Read the explicit coding, if any
(when (string-match "^[0-9]+C" lyskom-options-text)
(let ((len (string-to-int lyskom-options-text)))
(let ((len (lyskom-string-to-number lyskom-options-text)))
(setq coding (intern
(substring lyskom-options-text
(match-end 0)
......@@ -401,7 +401,7 @@ for more information."
;; Read the string
(let ((len (string-to-int lyskom-options-text))
(let ((len (lyskom-string-to-number lyskom-options-text))
(start (progn (string-match "[0-9]+H" lyskom-options-text)
(match-end 0))))
(let ((name (substring lyskom-options-text start (+ start len))))
......@@ -424,7 +424,7 @@ If optional NO-CODING is set, assume the string has internal coding."
;; Read the explicit coding, if any
(when (string-match "^[0-9]+C" string)
(let ((len (string-to-int string)))
(let ((len (lyskom-string-to-number string)))
(setq coding (intern
(substring string
(match-end 0)
......@@ -433,7 +433,7 @@ If optional NO-CODING is set, assume the string has internal coding."
;; Read the string
(let ((len (string-to-int string))
(let ((len (lyskom-string-to-number string))
(start (progn (string-match "[0-9]+H" string)
(match-end 0))))
(let ((name (substring string start (+ start len))))
......@@ -514,7 +514,7 @@ elisp variable VAR."
(defun lyskom-flag-read-integer (str)
(cond ((equal str "nil") nil)
(t (string-to-int str))))
(t (lyskom-string-to-number str))))
(defun lyskom-flag-write-integer (val)
(cond ((integerp val) (prin1-to-string val))
......
......@@ -1429,7 +1429,7 @@ ARG may be a conf-stat, pers-stat, uconf-stat, conf-z-info, integer or string."
((lyskom-uconf-stat-p arg) (uconf-stat->conf-no arg))
((numberp arg) arg)
((lyskom-conf-z-info-p arg) (conf-z-info->conf-no arg))
((stringp arg) (string-to-int arg)))))
((stringp arg) (lyskom-string-to-number arg)))))
(when conf-no
(cond ((cache-get-conf-stat conf-no))
(conf-no (initiate-get-conf-stat 'background nil conf-no)
......
......@@ -948,7 +948,7 @@ by PERS-NO"
(lyskom-traverse item aux-list
(when (string-match "^\\([0-9]+\\)" (aux-item->data item))
(setq lyskom-rejected-recommendations
(cons (string-to-int (match-string 1 (aux-item->data item)))
(cons (lyskom-string-to-number (match-string 1 (aux-item->data item)))
lyskom-rejected-recommendations))))))
(defun lyskom-startup-check-recommended-memberships ()
......@@ -959,8 +959,8 @@ by PERS-NO"
(not (lyskom-recommendation-already-rejected (car rec))))
(mapcar (lambda (aux)
(when (string-match "^\\([0-9]+\\)\\( [0-9]+\\)?\\( [01]+\\)?" (aux-item->data aux))
(let* ((conf-no (string-to-int (match-string 1 (aux-item->data aux))))
(priority (and conf-no (match-string 2) (string-to-int (match-string 2 (aux-item->data aux)))))
(let* ((conf-no (lyskom-string-to-number (match-string 1 (aux-item->data aux))))
(priority (and conf-no (match-string 2) (lyskom-string-to-number (match-string 2 (aux-item->data aux)))))
(mship-type (and priority (match-string 3) (match-string 3 (aux-item->data aux)))))
(list conf-no priority mship-type (aux-item->creator aux)))))
(lyskom-get-aux-item (server-info->aux-item-list
......@@ -1011,8 +1011,8 @@ that are no longer FAQs or are missing."
(lyskom-traverse item (lyskom-get-aux-item (conf-stat->aux-items conf-stat)
10000)
(when (string-match "^\\([0-9]+\\) \\([0-9]+\\)" (aux-item->data item))
(let ((conf-no (string-to-int (match-string 1 (aux-item->data item))))
(text-no (string-to-int (match-string 2 (aux-item->data item)))))
(let ((conf-no (lyskom-string-to-number (match-string 1 (aux-item->data item))))
(text-no (lyskom-string-to-number (match-string 2 (aux-item->data item)))))
(initiate-get-text-stat 'background
'lyskom-clean-read-faqs-1
text-no
......@@ -1581,10 +1581,10 @@ Deferred insertions are not supported."
(let* ((s (match-string 2 (format-state->format-string format-state))))
(cond ((or (string-match "\\(-?[0-9]+\\)\\.\\([0-9]+\\)\\.\\([0-9]+\\)" s)
(string-match "\\(-?[0-9]+\\)\\.\\([0-9]+\\)" s))
(setq pad-length (string-to-int (match-string 1 s)))
(setq frac-min (string-to-int (match-string 2 s)))
(setq frac-max (string-to-int (or (match-string 3 s) (match-string 2 s)))))
(t (setq pad-length (string-to-int s))))))
(setq pad-length (lyskom-string-to-number (match-string 1 s)))
(setq frac-min (lyskom-string-to-number (match-string 2 s)))
(setq frac-max (lyskom-string-to-number (or (match-string 3 s) (match-string 2 s)))))
(t (setq pad-length (lyskom-string-to-number s))))))
(setq pad-length nil))
(setq equals-flag (and (match-beginning 1)
......@@ -1592,7 +1592,7 @@ Deferred insertions are not supported."
(format-state->format-string
format-state)) 0))
arg-no (if (match-beginning 6)
(string-to-int
(lyskom-string-to-number
(match-string 6 (format-state->format-string
format-state)))
nil)
......@@ -3132,7 +3132,7 @@ See `kom-save-text-body' for an alternative to this command."
(while (and arg (> arg 0))
(backward-text 1)
(if (looking-at "\\([0-9]+\\)\\s-")
(setq list-of-texts (cons (string-to-int (match-string 1))
(setq list-of-texts (cons (lyskom-string-to-number (match-string 1))
list-of-texts)
arg (1- arg))
(setq arg 0)))
......@@ -3788,7 +3788,7 @@ The result will be a number or a list of (YEAR MONTH DATE)."
(lambda (val)
(cond
((string-match "^\\s-*[0-9]+\\s-*$" val)
(let ((num (string-to-int val)))
(let ((num (lyskom-string-to-number val)))
(unless (and (>= num low) (<= num high))
(lyskom-get-string 'number-out-of-range))))
((and empty (string-match "^\\s-*$" val)) nil)
......@@ -3797,7 +3797,7 @@ The result will be a number or a list of (YEAR MONTH DATE)."
(progn (lyskom-parse-date val) nil)
(lyskom-error (lyskom-get-string 'invalid-date-entry))))))))
(cond ((string-match "^\\s-*[0-9]+\\s-*$" val)
(let ((num (string-to-int val)))
(let ((num (lyskom-string-to-number val)))
(when (and (>= num low) (<= num high))
(setq result num))))
((and empty (string-match "^\\s-*$" val))
......@@ -4171,8 +4171,9 @@ If MEMBERSHIPs prioriy is 0, it always returns nil."
(defun lyskom-sentinel (proc sentinel)
"Handles changes in the lyskom-process."
(lyskom-remove-unread-buffer proc)
(set-buffer (process-buffer proc))
(when (processp proc)
(lyskom-remove-unread-buffer (process-buffer proc))
(set-buffer (process-buffer proc)))
(lyskom-start-of-command (lyskom-get-string 'process-signal) t t)
(lyskom-format-insert 'closed-connection
sentinel
......@@ -4470,7 +4471,8 @@ One parameter - the prompt string."
"Return the nickname to use for this LysKOM session."
(if kom-session-nickname
kom-session-nickname
(let ((server (process-name (get-buffer-process (current-buffer)))))
(let* ((proc (get-buffer-process (current-buffer)))
(server (if proc (process-name proc) lyskom-server-name)))
(or (cdr (assoc server
(append kom-server-aliases
kom-builtin-server-aliases)))
......
......@@ -1733,7 +1733,7 @@ All key bindings:
(widget-setup)))
(defun lyskom-widget-number-value-to-external (widget value)
(cond ((stringp value) (string-to-int value))
(cond ((stringp value) (lyskom-string-to-number value))
((numberp value) value)
((null value) 0)
(t (error "unable to convert settings value"))))
......
......@@ -119,7 +119,7 @@ Signal lyskom-protocol-error if the next token is not a number."
((looking-at "[ \n]*[0-9]+")
(if (char-after (match-end 0))
(progn (setq lyskom-parse-pos (goto-char (match-end 0)))
(string-to-int (match-string 0)))
(lyskom-string-to-number (match-string 0)))
(signal 'lyskom-parse-incomplete nil)))
((looking-at "[ \n]*\\'")
(goto-char (point-max))
......@@ -174,7 +174,7 @@ Signal lyskom-protocol-error if the next token is not a string."
(t
(let* ((num (match-string 0))
(end (match-end 0))
(len (string-to-int num)))
(len (lyskom-string-to-number num)))
(setq lyskom-parse-pos end)
(cond
((< (point-max) (+ lyskom-parse-pos len))
......@@ -207,7 +207,7 @@ Signal lyskom-protocol-error if the next token is not a string."
;; to-parse)) ;Not a legal string.
;; (t
;; (let ((end (match-end 0))
;; (len (string-to-int to-parse)))
;; (len (lyskom-string-to-number to-parse)))
;; (setq lyskom-parse-pos (+ lyskom-parse-pos end))
;; (cond
;; ((< (point-max) (+ lyskom-parse-pos len))
......@@ -239,7 +239,7 @@ Signal lyskom-protocol-error if the next token is not a string."
to-parse)) ;Not a legal string.
(t
(let ((end (match-end 0))
(len (string-to-int to-parse)))
(len (lyskom-string-to-number to-parse)))
(setq lyskom-parse-pos (+ lyskom-parse-pos end))
(cond
((< (point-max) (+ lyskom-parse-pos len))
......
......@@ -77,8 +77,8 @@ regexp is in the cache."
(lyskom-re-parse-modify-last
parse
'LIMIT
(cons (string-to-int (match-string 1 (regex-parse->re parse)))
(string-to-int (match-string 1 (regex-parse->re parse))))))
(cons (lyskom-string-to-number (match-string 1 (regex-parse->re parse)))
(lyskom-string-to-number (match-string 1 (regex-parse->re parse))))))
((eq (string-match "\\([0-9]+\\)?,\\([0-9]+\\)?}" (regex-parse->re parse)
(regex-parse->pos parse))
......@@ -88,8 +88,8 @@ regexp is in the cache."
(lyskom-re-parse-modify-last
parse
'LIMIT
(cons (and min (string-to-int min))
(and max (string-to-int max))))))
(cons (and min (lyskom-string-to-number min))
(and max (lyskom-string-to-number max))))))
(t (throw 'lyskom-re-parse 'syntax-error)))
(set-regex-parse->pos parse (match-end 0)))
......
......@@ -1640,7 +1640,7 @@ all review-related functions."
(defun lyskom-cross-referenced-text (aux-item-xref)
(and (string-match "^T\\([0-9]+\\)" (aux-item->data aux-item-xref))
(string-to-int (match-string 1 (aux-item->data aux-item-xref)))))
(lyskom-string-to-number (match-string 1 (aux-item->data aux-item-xref)))))
(defun lyskom-review-cross-references (text-stat)
"Handles the return from the initiate-get-text-stat,
......
......@@ -114,7 +114,7 @@ clients of the event. See lyskom-mode for details on lyskom."
(init-done nil))
(cond ;Allow "nanny:4892" to use port 4892.
((string-match ":" host)
(setq port (string-to-int (substring host (match-end 0))))
(setq port (lyskom-string-to-number (substring host (match-end 0))))
(cond
((zerop (match-beginning 0))
(setq host (or lyskom-default-server kom-default-server)))
......@@ -183,7 +183,7 @@ clients of the event. See lyskom-mode for details on lyskom."
(match-string 1 www-proxy-host-string))
www-proxy-host-string)
www-proxy-port (or (and match
(string-to-int
(lyskom-string-to-number
(match-string 2
www-proxy-host-string)))
80))
......
......@@ -210,10 +210,20 @@ Returns t if the feature is loaded or can be loaded, and nil otherwise."
(defvar lyskom-apo-timeout-index 0
"Index in lyskom-apo-timeout-vector-max where last timeout is")
(defconst lyskom-apo-timeout-vector
[0 1000 1000 2000 3000 5000 8000 13000 21000 34000 55000 89000 144000 233000 377000 610000]
(defvar lyskom-apo-timeout-vector
[0 1000 1000 2000 3000 5000 8000 13000 21000
34000 55000 89000 144000 233000 377000 610000]
"Vector of timeout values (usecs) for accept-process-output")
;;; Emacs 22.1 introduced a non-backwards-compatible change to
;;; accept-process-output. The most reliable way to detect which
;;; version is in play, is to look at the documentation.
(when (string-match "milliseconds" (documentation 'accept-process-output))
(setq lyskom-apo-timeout-vector
(apply 'vector
(mapcar (lambda (x) (/ x 1000)) lyskom-apo-timeout-vector))))
(defconst lyskom-apo-timeout-vector-max (1- (length lyskom-apo-timeout-vector))
"Maximum index in lyskom-apo-timeout-vector")
......@@ -632,12 +642,12 @@ non-negative integer and 0 means the given text-no."
(let ((former-point (point)))
(backward-text (+ 1 arg))
(if (looking-at "\\([0-9]+\\)\\s-")
(string-to-int (match-string 1))
(lyskom-string-to-number (match-string 1))
(progn ;; we probably ended up above the first message in the buffer
(forward-text)
(if (and (< (point) former-point)
(looking-at "\\([0-9]+\\)\\s-"))
(string-to-int (match-string 1))
(lyskom-string-to-number (match-string 1))
(lyskom-error (lyskom-get-string 'bad-text-no-prefix) arg)))))))
(defun lyskom-get-text-below-point (arg)
......@@ -647,12 +657,12 @@ non-negative integer and 0 means the given text-no."
(let ((former-point (point)))
(forward-text arg)
(if (looking-at "\\([0-9]+\\)\\s-")
(string-to-int (match-string 1))
(lyskom-string-to-number (match-string 1))
(progn ;; we probably ended up below the final message in the buffer
(backward-text)
(if (and (> (point) former-point)
(looking-at "\\([0-9]+\\)\\s-"))
(string-to-int (match-string 1))
(lyskom-string-to-number (match-string 1))
(lyskom-error (lyskom-get-string 'bad-text-no-prefix) arg))))))))
(defun lyskom-read-text-no-prompt-p (command)
......@@ -1484,26 +1494,26 @@ Returns a list (YEAR MONTH DAY) corresponding to the date in ARG."
;; Match various variants
(cond ((string-match "^\\s-*\\([0-9][0-9][0-9][0-9]?\\)\\s-*[ -./]\\s-*\\([0-9][0-9]?\\)\\s-*[ -./]\\s-*\\([0-9][0-9]?\\)\\s-*$" arg)
;; YYYY-MM-DD
(setq year (string-to-int (match-string 1 arg))
month (string-to-int (match-string (if (> mi di) 3 2) arg))
day (string-to-int (match-string (if (> mi di) 2 3) arg)))
(setq year (lyskom-string-to-number (match-string 1 arg))
month (lyskom-string-to-number (match-string (if (> mi di) 3 2) arg))
day (lyskom-string-to-number (match-string (if (> mi di) 2 3) arg)))
(when (> month 12) (setq month day day month))
)
((string-match "^\\s-*\\([0-9][0-9]?\\)\\s-*[ -./]\\s-*\\([0-9][0-9]?\\)\\s-*[ -./]\\s-*\\([0-9][0-9][0-9][0-9]?\\)\\s-*$" arg)
;; MM-DD-YYYY
(setq year (string-to-int (match-string 3 arg))
month (string-to-int (match-string (if (> mi di) 2 1) arg))
day (string-to-int (match-string (if (> mi di) 1 2) arg)))
(setq year (lyskom-string-to-number (match-string 3 arg))
month (lyskom-string-to-number (match-string (if (> mi di) 2 1) arg))
day (lyskom-string-to-number (match-string (if (> mi di) 1 2) arg)))
(when (> month 12) (setq month day day month))
)
((string-match "^\\s-*\\([0-9][0-9]\\)\\s-*[ -./]\\s-*\\([0-9][0-9]?\\)\\s-*[ -./]\\s-*\\([0-9][0-9]?\\)\\s-*$" arg)
;; Ambiguous:
;; YY/MM/DD, YY/DD/MM, MM/DD/YY, DD/MM/YY
(setq year (string-to-int (match-string yi arg))
month (string-to-int (match-string mi arg))
day (string-to-int (match-string di arg)))
(setq year (lyskom-string-to-number (match-string yi arg))
month (lyskom-string-to-number (match-string mi arg))
day (lyskom-string-to-number (match-string di arg)))
(when (> month 12) (setq month day day month))
)
......@@ -1511,8 +1521,8 @@ Returns a list (YEAR MONTH DAY) corresponding to the date in ARG."
;; Ambiguous:
;; MM/DD Euro
;; DD/MM US
(let ((a (string-to-int (match-string 1 arg)))
(b (string-to-int (match-string 2 arg))))
(let ((a (lyskom-string-to-number (match-string 1 arg)))
(b (lyskom-string-to-number (match-string 2 arg))))
(cond ((> a 12) (setq month b day a))
((> b 12) (setq month a day b))