>>>> "Piotr" == Piotr Gajewski
<pg(a)matrix.pl> writes:
Piotr> Dear Bug Team!
Piotr> Here is sample code that shows nondeterministic behaviour
Piotr> of "string-match" lisp function. Results depend on the order
Piotr> of two pointed lines.
Piotr> Regards,
Piotr> Piotr Gajewski
Piotr> (defun pg-dump (name)
Piotr> (insert name " --> " (match-string 0 name) ", "
Piotr> (number-to-string (match-beginning 0)) ", "
Piotr> (number-to-string (match-end 0)))
Piotr> (newline))
Piotr> (defun pg-test1 () "Test: qwerty.cc --> .cc, 6, 9"
Piotr> (interactive)
Piotr> (let ((name "qwerty.cc"))
Piotr> (if (or (string-match "\.cc$" name) ; <---- 1
Piotr> (string-match "\.c$" name)) ; <---- 2
Piotr> (pg-dump name))))
Piotr> (defun pg-test2 () "Test: qwerty.cc --> cc, 7, 9"
Piotr> (interactive)
Piotr> (let ((name "qwerty.cc"))
Piotr> (if (or (string-match "\.c$" name) ; <---- 2
Piotr> (string-match "\.cc$" name)) ; <---- 1
Piotr> (pg-dump name))))
For me,
(string-match "\.cc$" "qwerty.cc") returns 6
(string-match "\.c$" "qwerty.cc") returns 7
So for pg-test1, the first string-match wins so the second is never
called. For pg-test2, the same holds. Thus what pg-dump sees is the
first string-match in each case.
I think your regexps might not be what you really wanted. Perhaps you
really wanted "\\.cc$" and "\\.c$"?
Ray