comparison src/search.c @ 20:859a2309aef8 r19-15b93

Import from CVS: tag r19-15b93
author cvs
date Mon, 13 Aug 2007 08:50:05 +0200
parents 0293115a14e9
children 56c54cf7c5b6
comparison
equal deleted inserted replaced
19:ac1f612d5250 20:859a2309aef8
312 XSETBUFFER (last_thing_searched, buf); 312 XSETBUFFER (last_thing_searched, buf);
313 fixup_search_regs_for_buffer (buf); 313 fixup_search_regs_for_buffer (buf);
314 return val; 314 return val;
315 } 315 }
316 316
317 DEFUN ("looking-at", Flooking_at, Slooking_at, 1, 2, 0 /* 317 DEFUN ("looking-at", Flooking_at, 1, 2, 0, /*
318 Return t if text after point matches regular expression REGEXP. 318 Return t if text after point matches regular expression REGEXP.
319 This function modifies the match data that `match-beginning', 319 This function modifies the match data that `match-beginning',
320 `match-end' and `match-data' access; save and restore the match 320 `match-end' and `match-data' access; save and restore the match
321 data if you want to preserve them. 321 data if you want to preserve them.
322 322
323 Optional argument BUFFER defaults to the current buffer. 323 Optional argument BUFFER defaults to the current buffer.
324 */ ) 324 */
325 (regexp, buffer) 325 (regexp, buffer))
326 Lisp_Object regexp, buffer;
327 { 326 {
328 return looking_at_1 (regexp, decode_buffer (buffer, 0), 0); 327 return looking_at_1 (regexp, decode_buffer (buffer, 0), 0);
329 } 328 }
330 329
331 DEFUN ("posix-looking-at", Fposix_looking_at, Sposix_looking_at, 1, 2, 0 /* 330 DEFUN ("posix-looking-at", Fposix_looking_at, 1, 2, 0, /*
332 Return t if text after point matches regular expression REGEXP. 331 Return t if text after point matches regular expression REGEXP.
333 Find the longest match, in accord with Posix regular expression rules. 332 Find the longest match, in accord with Posix regular expression rules.
334 This function modifies the match data that `match-beginning', 333 This function modifies the match data that `match-beginning',
335 `match-end' and `match-data' access; save and restore the match 334 `match-end' and `match-data' access; save and restore the match
336 data if you want to preserve them. 335 data if you want to preserve them.
337 336
338 Optional argument BUFFER defaults to the current buffer. 337 Optional argument BUFFER defaults to the current buffer.
339 */ ) 338 */
340 (regexp, buffer) 339 (regexp, buffer))
341 Lisp_Object regexp, buffer;
342 { 340 {
343 return looking_at_1 (regexp, decode_buffer (buffer, 0), 1); 341 return looking_at_1 (regexp, decode_buffer (buffer, 0), 1);
344 } 342 }
345 343
346 static Lisp_Object 344 static Lisp_Object
392 last_thing_searched = Qt; 390 last_thing_searched = Qt;
393 fixup_search_regs_for_string (string); 391 fixup_search_regs_for_string (string);
394 return make_int (bytecount_to_charcount (XSTRING_DATA (string), val)); 392 return make_int (bytecount_to_charcount (XSTRING_DATA (string), val));
395 } 393 }
396 394
397 DEFUN ("string-match", Fstring_match, Sstring_match, 2, 4, 0 /* 395 DEFUN ("string-match", Fstring_match, 2, 4, 0, /*
398 Return index of start of first match for REGEXP in STRING, or nil. 396 Return index of start of first match for REGEXP in STRING, or nil.
399 If third arg START is non-nil, start search at that index in STRING. 397 If third arg START is non-nil, start search at that index in STRING.
400 For index of first char beyond the match, do (match-end 0). 398 For index of first char beyond the match, do (match-end 0).
401 `match-end' and `match-beginning' also give indices of substrings 399 `match-end' and `match-beginning' also give indices of substrings
402 matched by parenthesis constructs in the pattern. 400 matched by parenthesis constructs in the pattern.
403 401
404 Optional arg BUFFER controls how case folding is done (according to 402 Optional arg BUFFER controls how case folding is done (according to
405 the value of `case-fold-search' in that buffer and that buffer's case 403 the value of `case-fold-search' in that buffer and that buffer's case
406 tables) and defaults to the current buffer. 404 tables) and defaults to the current buffer.
407 */ ) 405 */
408 (regexp, string, start, buffer) 406 (regexp, string, start, buffer))
409 Lisp_Object regexp, string, start, buffer;
410 { 407 {
411 return string_match_1 (regexp, string, start, decode_buffer (buffer, 0), 0); 408 return string_match_1 (regexp, string, start, decode_buffer (buffer, 0), 0);
412 } 409 }
413 410
414 DEFUN ("posix-string-match", Fposix_string_match, Sposix_string_match, 2, 4, 0 /* 411 DEFUN ("posix-string-match", Fposix_string_match, 2, 4, 0, /*
415 Return index of start of first match for REGEXP in STRING, or nil. 412 Return index of start of first match for REGEXP in STRING, or nil.
416 Find the longest match, in accord with Posix regular expression rules. 413 Find the longest match, in accord with Posix regular expression rules.
417 If third arg START is non-nil, start search at that index in STRING. 414 If third arg START is non-nil, start search at that index in STRING.
418 For index of first char beyond the match, do (match-end 0). 415 For index of first char beyond the match, do (match-end 0).
419 `match-end' and `match-beginning' also give indices of substrings 416 `match-end' and `match-beginning' also give indices of substrings
420 matched by parenthesis constructs in the pattern. 417 matched by parenthesis constructs in the pattern.
421 418
422 Optional arg BUFFER controls how case folding is done (according to 419 Optional arg BUFFER controls how case folding is done (according to
423 the value of `case-fold-search' in that buffer and that buffer's case 420 the value of `case-fold-search' in that buffer and that buffer's case
424 tables) and defaults to the current buffer. 421 tables) and defaults to the current buffer.
425 */ ) 422 */
426 (regexp, string, start, buffer) 423 (regexp, string, start, buffer))
427 Lisp_Object regexp, string, start, buffer;
428 { 424 {
429 return string_match_1 (regexp, string, start, decode_buffer (buffer, 0), 1); 425 return string_match_1 (regexp, string, start, decode_buffer (buffer, 0), 1);
430 } 426 }
431 427
432 /* Match REGEXP against STRING, searching all of STRING, 428 /* Match REGEXP against STRING, searching all of STRING,
844 QUIT; 840 QUIT;
845 return make_int (BUF_PT (buf) - start_point); 841 return make_int (BUF_PT (buf) - start_point);
846 } 842 }
847 } 843 }
848 844
849 DEFUN ("skip-chars-forward", Fskip_chars_forward, Sskip_chars_forward, 1, 3, 0 /* 845 DEFUN ("skip-chars-forward", Fskip_chars_forward, 1, 3, 0, /*
850 Move point forward, stopping before a char not in STRING, or at pos LIM. 846 Move point forward, stopping before a char not in STRING, or at pos LIM.
851 STRING is like the inside of a `[...]' in a regular expression 847 STRING is like the inside of a `[...]' in a regular expression
852 except that `]' is never special and `\\' quotes `^', `-' or `\\'. 848 except that `]' is never special and `\\' quotes `^', `-' or `\\'.
853 Thus, with arg \"a-zA-Z\", this skips letters stopping before first nonletter. 849 Thus, with arg \"a-zA-Z\", this skips letters stopping before first nonletter.
854 With arg \"^a-zA-Z\", skips nonletters stopping before first letter. 850 With arg \"^a-zA-Z\", skips nonletters stopping before first letter.
855 Returns the distance traveled, either zero or positive. 851 Returns the distance traveled, either zero or positive.
856 852
857 Optional argument BUFFER defaults to the current buffer. 853 Optional argument BUFFER defaults to the current buffer.
858 */ ) 854 */
859 (string, lim, buffer) 855 (string, lim, buffer))
860 Lisp_Object string, lim, buffer;
861 { 856 {
862 return skip_chars (decode_buffer (buffer, 0), 1, 0, string, lim); 857 return skip_chars (decode_buffer (buffer, 0), 1, 0, string, lim);
863 } 858 }
864 859
865 DEFUN ("skip-chars-backward", Fskip_chars_backward, Sskip_chars_backward, 1, 3, 0 /* 860 DEFUN ("skip-chars-backward", Fskip_chars_backward, 1, 3, 0, /*
866 Move point backward, stopping after a char not in STRING, or at pos LIM. 861 Move point backward, stopping after a char not in STRING, or at pos LIM.
867 See `skip-chars-forward' for details. 862 See `skip-chars-forward' for details.
868 Returns the distance traveled, either zero or negative. 863 Returns the distance traveled, either zero or negative.
869 864
870 Optional argument BUFFER defaults to the current buffer. 865 Optional argument BUFFER defaults to the current buffer.
871 */ ) 866 */
872 (string, lim, buffer) 867 (string, lim, buffer))
873 Lisp_Object string, lim, buffer;
874 { 868 {
875 return skip_chars (decode_buffer (buffer, 0), 0, 0, string, lim); 869 return skip_chars (decode_buffer (buffer, 0), 0, 0, string, lim);
876 } 870 }
877 871
878 872
879 DEFUN ("skip-syntax-forward", Fskip_syntax_forward, Sskip_syntax_forward, 1, 3, 0 /* 873 DEFUN ("skip-syntax-forward", Fskip_syntax_forward, 1, 3, 0, /*
880 Move point forward across chars in specified syntax classes. 874 Move point forward across chars in specified syntax classes.
881 SYNTAX is a string of syntax code characters. 875 SYNTAX is a string of syntax code characters.
882 Stop before a char whose syntax is not in SYNTAX, or at position LIM. 876 Stop before a char whose syntax is not in SYNTAX, or at position LIM.
883 If SYNTAX starts with ^, skip characters whose syntax is NOT in SYNTAX. 877 If SYNTAX starts with ^, skip characters whose syntax is NOT in SYNTAX.
884 This function returns the distance traveled, either zero or positive. 878 This function returns the distance traveled, either zero or positive.
885 879
886 Optional argument BUFFER defaults to the current buffer. 880 Optional argument BUFFER defaults to the current buffer.
887 */ ) 881 */
888 (syntax, lim, buffer) 882 (syntax, lim, buffer))
889 Lisp_Object syntax, lim, buffer;
890 { 883 {
891 return skip_chars (decode_buffer (buffer, 0), 1, 1, syntax, lim); 884 return skip_chars (decode_buffer (buffer, 0), 1, 1, syntax, lim);
892 } 885 }
893 886
894 DEFUN ("skip-syntax-backward", Fskip_syntax_backward, Sskip_syntax_backward, 1, 3, 0 /* 887 DEFUN ("skip-syntax-backward", Fskip_syntax_backward, 1, 3, 0, /*
895 Move point backward across chars in specified syntax classes. 888 Move point backward across chars in specified syntax classes.
896 SYNTAX is a string of syntax code characters. 889 SYNTAX is a string of syntax code characters.
897 Stop on reaching a char whose syntax is not in SYNTAX, or at position LIM. 890 Stop on reaching a char whose syntax is not in SYNTAX, or at position LIM.
898 If SYNTAX starts with ^, skip characters whose syntax is NOT in SYNTAX. 891 If SYNTAX starts with ^, skip characters whose syntax is NOT in SYNTAX.
899 This function returns the distance traveled, either zero or negative. 892 This function returns the distance traveled, either zero or negative.
900 893
901 Optional argument BUFFER defaults to the current buffer. 894 Optional argument BUFFER defaults to the current buffer.
902 */ ) 895 */
903 (syntax, lim, buffer) 896 (syntax, lim, buffer))
904 Lisp_Object syntax, lim, buffer;
905 { 897 {
906 return skip_chars (decode_buffer (buffer, 0), 0, 1, syntax, lim); 898 return skip_chars (decode_buffer (buffer, 0), 0, 1, syntax, lim);
907 } 899 }
908 900
909 901
1552 1544
1553 return make_string (storage, o - storage); 1545 return make_string (storage, o - storage);
1554 } 1546 }
1555 } 1547 }
1556 1548
1557 DEFUN ("search-backward", Fsearch_backward, Ssearch_backward, 1, 5, 1549 DEFUN ("search-backward", Fsearch_backward, 1, 5, "sSearch backward: ", /*
1558 "sSearch backward: " /*
1559 Search backward from point for STRING. 1550 Search backward from point for STRING.
1560 Set point to the beginning of the occurrence found, and return point. 1551 Set point to the beginning of the occurrence found, and return point.
1561 An optional second argument bounds the search; it is a buffer position. 1552 An optional second argument bounds the search; it is a buffer position.
1562 The match found must not extend before that position. 1553 The match found must not extend before that position.
1563 Optional third argument, if t, means if fail just return nil (no error). 1554 Optional third argument, if t, means if fail just return nil (no error).
1564 If not nil and not t, position at limit of search and return nil. 1555 If not nil and not t, position at limit of search and return nil.
1565 Optional fourth argument is repeat count--search for successive occurrences. 1556 Optional fourth argument is repeat count--search for successive occurrences.
1566 Optional fifth argument BUFFER specifies the buffer to search in and 1557 Optional fifth argument BUFFER specifies the buffer to search in and
1567 defaults to the current buffer. 1558 defaults to the current buffer.
1568 See also the functions `match-beginning', `match-end' and `replace-match'. 1559 See also the functions `match-beginning', `match-end' and `replace-match'.
1569 */ ) 1560 */
1570 (string, bound, no_error, count, buffer) 1561 (string, bound, no_error, count, buffer))
1571 Lisp_Object string, bound, no_error, count, buffer;
1572 { 1562 {
1573 return search_command (string, bound, no_error, count, buffer, -1, 0, 0); 1563 return search_command (string, bound, no_error, count, buffer, -1, 0, 0);
1574 } 1564 }
1575 1565
1576 DEFUN ("search-forward", Fsearch_forward, Ssearch_forward, 1, 5, "sSearch: " /* 1566 DEFUN ("search-forward", Fsearch_forward, 1, 5, "sSearch: ", /*
1577 Search forward from point for STRING. 1567 Search forward from point for STRING.
1578 Set point to the end of the occurrence found, and return point. 1568 Set point to the end of the occurrence found, and return point.
1579 An optional second argument bounds the search; it is a buffer position. 1569 An optional second argument bounds the search; it is a buffer position.
1580 The match found must not extend after that position. nil is equivalent 1570 The match found must not extend after that position. nil is equivalent
1581 to (point-max). 1571 to (point-max).
1583 If not nil and not t, move to limit of search and return nil. 1573 If not nil and not t, move to limit of search and return nil.
1584 Optional fourth argument is repeat count--search for successive occurrences. 1574 Optional fourth argument is repeat count--search for successive occurrences.
1585 Optional fifth argument BUFFER specifies the buffer to search in and 1575 Optional fifth argument BUFFER specifies the buffer to search in and
1586 defaults to the current buffer. 1576 defaults to the current buffer.
1587 See also the functions `match-beginning', `match-end' and `replace-match'. 1577 See also the functions `match-beginning', `match-end' and `replace-match'.
1588 */ ) 1578 */
1589 (string, bound, no_error, count, buffer) 1579 (string, bound, no_error, count, buffer))
1590 Lisp_Object string, bound, no_error, count, buffer;
1591 { 1580 {
1592 return search_command (string, bound, no_error, count, buffer, 1, 0, 0); 1581 return search_command (string, bound, no_error, count, buffer, 1, 0, 0);
1593 } 1582 }
1594 1583
1595 DEFUN ("word-search-backward", Fword_search_backward, Sword_search_backward, 1584 DEFUN ("word-search-backward", Fword_search_backward, 1, 5,
1596 1, 5, 1585 "sWord search backward: ", /*
1597 "sWord search backward: " /*
1598 Search backward from point for STRING, ignoring differences in punctuation. 1586 Search backward from point for STRING, ignoring differences in punctuation.
1599 Set point to the beginning of the occurrence found, and return point. 1587 Set point to the beginning of the occurrence found, and return point.
1600 An optional second argument bounds the search; it is a buffer position. 1588 An optional second argument bounds the search; it is a buffer position.
1601 The match found must not extend before that position. 1589 The match found must not extend before that position.
1602 Optional third argument, if t, means if fail just return nil (no error). 1590 Optional third argument, if t, means if fail just return nil (no error).
1603 If not nil and not t, move to limit of search and return nil. 1591 If not nil and not t, move to limit of search and return nil.
1604 Optional fourth argument is repeat count--search for successive occurrences. 1592 Optional fourth argument is repeat count--search for successive occurrences.
1605 Optional fifth argument BUFFER specifies the buffer to search in and 1593 Optional fifth argument BUFFER specifies the buffer to search in and
1606 defaults to the current buffer. 1594 defaults to the current buffer.
1607 */ ) 1595 */
1608 (string, bound, no_error, count, buffer) 1596 (string, bound, no_error, count, buffer))
1609 Lisp_Object string, bound, no_error, count, buffer;
1610 { 1597 {
1611 return search_command (wordify (buffer, string), bound, no_error, count, 1598 return search_command (wordify (buffer, string), bound, no_error, count,
1612 buffer, -1, 1, 0); 1599 buffer, -1, 1, 0);
1613 } 1600 }
1614 1601
1615 DEFUN ("word-search-forward", Fword_search_forward, Sword_search_forward, 1, 5, 1602 DEFUN ("word-search-forward", Fword_search_forward, 1, 5, "sWord search: ", /*
1616 "sWord search: " /*
1617 Search forward from point for STRING, ignoring differences in punctuation. 1603 Search forward from point for STRING, ignoring differences in punctuation.
1618 Set point to the end of the occurrence found, and return point. 1604 Set point to the end of the occurrence found, and return point.
1619 An optional second argument bounds the search; it is a buffer position. 1605 An optional second argument bounds the search; it is a buffer position.
1620 The match found must not extend after that position. 1606 The match found must not extend after that position.
1621 Optional third argument, if t, means if fail just return nil (no error). 1607 Optional third argument, if t, means if fail just return nil (no error).
1622 If not nil and not t, move to limit of search and return nil. 1608 If not nil and not t, move to limit of search and return nil.
1623 Optional fourth argument is repeat count--search for successive occurrences. 1609 Optional fourth argument is repeat count--search for successive occurrences.
1624 Optional fifth argument BUFFER specifies the buffer to search in and 1610 Optional fifth argument BUFFER specifies the buffer to search in and
1625 defaults to the current buffer. 1611 defaults to the current buffer.
1626 */ ) 1612 */
1627 (string, bound, no_error, count, buffer) 1613 (string, bound, no_error, count, buffer))
1628 Lisp_Object string, bound, no_error, count, buffer;
1629 { 1614 {
1630 return search_command (wordify (buffer, string), bound, no_error, count, 1615 return search_command (wordify (buffer, string), bound, no_error, count,
1631 buffer, 1, 1, 0); 1616 buffer, 1, 1, 0);
1632 } 1617 }
1633 1618
1634 DEFUN ("re-search-backward", Fre_search_backward, Sre_search_backward, 1, 5, 1619 DEFUN ("re-search-backward", Fre_search_backward, 1, 5,
1635 "sRE search backward: " /* 1620 "sRE search backward: ", /*
1636 Search backward from point for match for regular expression REGEXP. 1621 Search backward from point for match for regular expression REGEXP.
1637 Set point to the beginning of the match, and return point. 1622 Set point to the beginning of the match, and return point.
1638 The match found is the one starting last in the buffer 1623 The match found is the one starting last in the buffer
1639 and yet ending before the origin of the search. 1624 and yet ending before the origin of the search.
1640 An optional second argument bounds the search; it is a buffer position. 1625 An optional second argument bounds the search; it is a buffer position.
1643 If not nil and not t, move to limit of search and return nil. 1628 If not nil and not t, move to limit of search and return nil.
1644 Optional fourth argument is repeat count--search for successive occurrences. 1629 Optional fourth argument is repeat count--search for successive occurrences.
1645 Optional fifth argument BUFFER specifies the buffer to search in and 1630 Optional fifth argument BUFFER specifies the buffer to search in and
1646 defaults to the current buffer. 1631 defaults to the current buffer.
1647 See also the functions `match-beginning', `match-end' and `replace-match'. 1632 See also the functions `match-beginning', `match-end' and `replace-match'.
1648 */ ) 1633 */
1649 (regexp, bound, no_error, count, buffer) 1634 (regexp, bound, no_error, count, buffer))
1650 Lisp_Object regexp, bound, no_error, count, buffer;
1651 { 1635 {
1652 return search_command (regexp, bound, no_error, count, buffer, -1, 1, 0); 1636 return search_command (regexp, bound, no_error, count, buffer, -1, 1, 0);
1653 } 1637 }
1654 1638
1655 DEFUN ("re-search-forward", Fre_search_forward, Sre_search_forward, 1, 5, 1639 DEFUN ("re-search-forward", Fre_search_forward, 1, 5, "sRE search: ", /*
1656 "sRE search: " /*
1657 Search forward from point for regular expression REGEXP. 1640 Search forward from point for regular expression REGEXP.
1658 Set point to the end of the occurrence found, and return point. 1641 Set point to the end of the occurrence found, and return point.
1659 An optional second argument bounds the search; it is a buffer position. 1642 An optional second argument bounds the search; it is a buffer position.
1660 The match found must not extend after that position. 1643 The match found must not extend after that position.
1661 Optional third argument, if t, means if fail just return nil (no error). 1644 Optional third argument, if t, means if fail just return nil (no error).
1662 If not nil and not t, move to limit of search and return nil. 1645 If not nil and not t, move to limit of search and return nil.
1663 Optional fourth argument is repeat count--search for successive occurrences. 1646 Optional fourth argument is repeat count--search for successive occurrences.
1664 Optional fifth argument BUFFER specifies the buffer to search in and 1647 Optional fifth argument BUFFER specifies the buffer to search in and
1665 defaults to the current buffer. 1648 defaults to the current buffer.
1666 See also the functions `match-beginning', `match-end' and `replace-match'. 1649 See also the functions `match-beginning', `match-end' and `replace-match'.
1667 */ ) 1650 */
1668 (regexp, bound, no_error, count, buffer) 1651 (regexp, bound, no_error, count, buffer))
1669 Lisp_Object regexp, bound, no_error, count, buffer;
1670 { 1652 {
1671 return search_command (regexp, bound, no_error, count, buffer, 1, 1, 0); 1653 return search_command (regexp, bound, no_error, count, buffer, 1, 1, 0);
1672 } 1654 }
1673 1655
1674 DEFUN ("posix-search-backward", Fposix_search_backward, Sposix_search_backward, 1656 DEFUN ("posix-search-backward", Fposix_search_backward, 1, 5,
1675 1, 5, 1657 "sPosix search backward: ", /*
1676 "sPosix search backward: " /*
1677 Search backward from point for match for regular expression REGEXP. 1658 Search backward from point for match for regular expression REGEXP.
1678 Find the longest match in accord with Posix regular expression rules. 1659 Find the longest match in accord with Posix regular expression rules.
1679 Set point to the beginning of the match, and return point. 1660 Set point to the beginning of the match, and return point.
1680 The match found is the one starting last in the buffer 1661 The match found is the one starting last in the buffer
1681 and yet ending before the origin of the search. 1662 and yet ending before the origin of the search.
1685 If not nil and not t, move to limit of search and return nil. 1666 If not nil and not t, move to limit of search and return nil.
1686 Optional fourth argument is repeat count--search for successive occurrences. 1667 Optional fourth argument is repeat count--search for successive occurrences.
1687 Optional fifth argument BUFFER specifies the buffer to search in and 1668 Optional fifth argument BUFFER specifies the buffer to search in and
1688 defaults to the current buffer. 1669 defaults to the current buffer.
1689 See also the functions `match-beginning', `match-end' and `replace-match'. 1670 See also the functions `match-beginning', `match-end' and `replace-match'.
1690 */ ) 1671 */
1691 (regexp, bound, no_error, count, buffer) 1672 (regexp, bound, no_error, count, buffer))
1692 Lisp_Object regexp, bound, no_error, count, buffer;
1693 { 1673 {
1694 return search_command (regexp, bound, no_error, count, buffer, -1, 1, 1); 1674 return search_command (regexp, bound, no_error, count, buffer, -1, 1, 1);
1695 } 1675 }
1696 1676
1697 DEFUN ("posix-search-forward", Fposix_search_forward, Sposix_search_forward, 1677 DEFUN ("posix-search-forward", Fposix_search_forward, 1, 5,
1698 1, 5, 1678 "sPosix search: ", /*
1699 "sPosix search: " /*
1700 Search forward from point for regular expression REGEXP. 1679 Search forward from point for regular expression REGEXP.
1701 Find the longest match in accord with Posix regular expression rules. 1680 Find the longest match in accord with Posix regular expression rules.
1702 Set point to the end of the occurrence found, and return point. 1681 Set point to the end of the occurrence found, and return point.
1703 An optional second argument bounds the search; it is a buffer position. 1682 An optional second argument bounds the search; it is a buffer position.
1704 The match found must not extend after that position. 1683 The match found must not extend after that position.
1706 If not nil and not t, move to limit of search and return nil. 1685 If not nil and not t, move to limit of search and return nil.
1707 Optional fourth argument is repeat count--search for successive occurrences. 1686 Optional fourth argument is repeat count--search for successive occurrences.
1708 Optional fifth argument BUFFER specifies the buffer to search in and 1687 Optional fifth argument BUFFER specifies the buffer to search in and
1709 defaults to the current buffer. 1688 defaults to the current buffer.
1710 See also the functions `match-beginning', `match-end' and `replace-match'. 1689 See also the functions `match-beginning', `match-end' and `replace-match'.
1711 */ ) 1690 */
1712 (regexp, bound, no_error, count, buffer) 1691 (regexp, bound, no_error, count, buffer))
1713 Lisp_Object regexp, bound, no_error, count, buffer;
1714 { 1692 {
1715 return search_command (regexp, bound, no_error, count, buffer, 1, 1, 1); 1693 return search_command (regexp, bound, no_error, count, buffer, 1, 1, 1);
1716 } 1694 }
1717 1695
1718 1696
1725 free_opaque_ptr (XCDR (cons)); 1703 free_opaque_ptr (XCDR (cons));
1726 free_cons (XCONS (cons)); 1704 free_cons (XCONS (cons));
1727 return Qnil; 1705 return Qnil;
1728 } 1706 }
1729 1707
1730 DEFUN ("replace-match", Freplace_match, Sreplace_match, 1, 5, 0 /* 1708 DEFUN ("replace-match", Freplace_match, 1, 5, 0, /*
1731 Replace text matched by last search with NEWTEXT. 1709 Replace text matched by last search with NEWTEXT.
1732 If second arg FIXEDCASE is non-nil, do not alter case of replacement text. 1710 If second arg FIXEDCASE is non-nil, do not alter case of replacement text.
1733 Otherwise maybe capitalize the whole text, or maybe just word initials, 1711 Otherwise maybe capitalize the whole text, or maybe just word initials,
1734 based on the replaced text. 1712 based on the replaced text.
1735 If the replaced text has only capital letters 1713 If the replaced text has only capital letters
1759 When fourth argument is a string, fifth argument STRBUFFER specifies 1737 When fourth argument is a string, fifth argument STRBUFFER specifies
1760 the buffer to be used for syntax-table and case-table lookup and 1738 the buffer to be used for syntax-table and case-table lookup and
1761 defaults to the current buffer. (When fourth argument is not a string, 1739 defaults to the current buffer. (When fourth argument is not a string,
1762 the buffer that the match occurred in has automatically been remembered 1740 the buffer that the match occurred in has automatically been remembered
1763 and you do not need to specify it.) 1741 and you do not need to specify it.)
1764 */ ) 1742 */
1765 (newtext, fixedcase, literal, string, strbuffer) 1743 (newtext, fixedcase, literal, string, strbuffer))
1766 Lisp_Object newtext, fixedcase, literal, string, strbuffer;
1767 { 1744 {
1768 /* This function has been Mule-ized. */ 1745 /* This function has been Mule-ized. */
1769 /* This function can GC */ 1746 /* This function can GC */
1770 enum { nochange, all_caps, cap_initial } case_action; 1747 enum { nochange, all_caps, cap_initial } case_action;
1771 Bufpos pos, last; 1748 Bufpos pos, last;
2201 return Qnil; 2178 return Qnil;
2202 return (make_int ((beginningp) ? search_regs.start[n] 2179 return (make_int ((beginningp) ? search_regs.start[n]
2203 : search_regs.end[n])); 2180 : search_regs.end[n]));
2204 } 2181 }
2205 2182
2206 DEFUN ("match-beginning", Fmatch_beginning, Smatch_beginning, 1, 1, 0 /* 2183 DEFUN ("match-beginning", Fmatch_beginning, 1, 1, 0, /*
2207 Return position of start of text matched by last regexp search. 2184 Return position of start of text matched by last regexp search.
2208 NUM, specifies which parenthesized expression in the last regexp. 2185 NUM, specifies which parenthesized expression in the last regexp.
2209 Value is nil if NUMth pair didn't match, or there were less than NUM pairs. 2186 Value is nil if NUMth pair didn't match, or there were less than NUM pairs.
2210 Zero means the entire text matched by the whole regexp or whole string. 2187 Zero means the entire text matched by the whole regexp or whole string.
2211 */ ) 2188 */
2212 (num) 2189 (num))
2213 Lisp_Object num;
2214 { 2190 {
2215 return match_limit (num, 1); 2191 return match_limit (num, 1);
2216 } 2192 }
2217 2193
2218 DEFUN ("match-end", Fmatch_end, Smatch_end, 1, 1, 0 /* 2194 DEFUN ("match-end", Fmatch_end, 1, 1, 0, /*
2219 Return position of end of text matched by last regexp search. 2195 Return position of end of text matched by last regexp search.
2220 NUM specifies which parenthesized expression in the last regexp. 2196 NUM specifies which parenthesized expression in the last regexp.
2221 Value is nil if NUMth pair didn't match, or there were less than NUM pairs. 2197 Value is nil if NUMth pair didn't match, or there were less than NUM pairs.
2222 Zero means the entire text matched by the whole regexp or whole string. 2198 Zero means the entire text matched by the whole regexp or whole string.
2223 */ ) 2199 */
2224 (num) 2200 (num))
2225 Lisp_Object num;
2226 { 2201 {
2227 return match_limit (num, 0); 2202 return match_limit (num, 0);
2228 } 2203 }
2229 2204
2230 DEFUN ("match-data", Fmatch_data, Smatch_data, 0, 0, 0 /* 2205 DEFUN ("match-data", Fmatch_data, 0, 0, 0, /*
2231 Return a list containing all info on what the last regexp search matched. 2206 Return a list containing all info on what the last regexp search matched.
2232 Element 2N is `(match-beginning N)'; element 2N + 1 is `(match-end N)'. 2207 Element 2N is `(match-beginning N)'; element 2N + 1 is `(match-end N)'.
2233 All the elements are markers or nil (nil if the Nth pair didn't match) 2208 All the elements are markers or nil (nil if the Nth pair didn't match)
2234 if the last match was on a buffer; integers or nil if a string was matched. 2209 if the last match was on a buffer; integers or nil if a string was matched.
2235 Use `store-match-data' to reinstate the data in this list. 2210 Use `store-match-data' to reinstate the data in this list.
2236 */ ) 2211 */
2237 () 2212 ())
2238 { 2213 {
2239 /* This function has been Mule-ized. */ 2214 /* This function has been Mule-ized. */
2240 Lisp_Object *data; 2215 Lisp_Object *data;
2241 int i; 2216 int i;
2242 Charcount len; 2217 Charcount len;
2280 } 2255 }
2281 return Flist (2 * len + 2, data); 2256 return Flist (2 * len + 2, data);
2282 } 2257 }
2283 2258
2284 2259
2285 DEFUN ("store-match-data", Fstore_match_data, Sstore_match_data, 1, 1, 0 /* 2260 DEFUN ("store-match-data", Fstore_match_data, 1, 1, 0, /*
2286 Set internal data on last search match from elements of LIST. 2261 Set internal data on last search match from elements of LIST.
2287 LIST should have been created by calling `match-data' previously. 2262 LIST should have been created by calling `match-data' previously.
2288 */ ) 2263 */
2289 (list) 2264 (list))
2290 Lisp_Object list;
2291 { 2265 {
2292 /* This function has been Mule-ized. */ 2266 /* This function has been Mule-ized. */
2293 register int i; 2267 register int i;
2294 register Lisp_Object marker; 2268 register Lisp_Object marker;
2295 2269
2407 } 2381 }
2408 } 2382 }
2409 2383
2410 /* Quote a string to inactivate reg-expr chars */ 2384 /* Quote a string to inactivate reg-expr chars */
2411 2385
2412 DEFUN ("regexp-quote", Fregexp_quote, Sregexp_quote, 1, 1, 0 /* 2386 DEFUN ("regexp-quote", Fregexp_quote, 1, 1, 0, /*
2413 Return a regexp string which matches exactly STRING and nothing else. 2387 Return a regexp string which matches exactly STRING and nothing else.
2414 */ ) 2388 */
2415 (str) 2389 (str))
2416 Lisp_Object str;
2417 { 2390 {
2418 /* This function has been Mule-ized. */ 2391 /* This function has been Mule-ized. */
2419 register Bufbyte *in, *out, *end; 2392 register Bufbyte *in, *out, *end;
2420 register Bufbyte *temp; 2393 register Bufbyte *temp;
2421 2394
2452 { 2425 {
2453 2426
2454 deferror (&Qsearch_failed, "search-failed", "Search failed", Qerror); 2427 deferror (&Qsearch_failed, "search-failed", "Search failed", Qerror);
2455 deferror (&Qinvalid_regexp, "invalid-regexp", "Invalid regexp", Qerror); 2428 deferror (&Qinvalid_regexp, "invalid-regexp", "Invalid regexp", Qerror);
2456 2429
2457 defsubr (&Slooking_at); 2430 DEFSUBR (Flooking_at);
2458 defsubr (&Sposix_looking_at); 2431 DEFSUBR (Fposix_looking_at);
2459 defsubr (&Sstring_match); 2432 DEFSUBR (Fstring_match);
2460 defsubr (&Sposix_string_match); 2433 DEFSUBR (Fposix_string_match);
2461 defsubr (&Sskip_chars_forward); 2434 DEFSUBR (Fskip_chars_forward);
2462 defsubr (&Sskip_chars_backward); 2435 DEFSUBR (Fskip_chars_backward);
2463 defsubr (&Sskip_syntax_forward); 2436 DEFSUBR (Fskip_syntax_forward);
2464 defsubr (&Sskip_syntax_backward); 2437 DEFSUBR (Fskip_syntax_backward);
2465 defsubr (&Ssearch_forward); 2438 DEFSUBR (Fsearch_forward);
2466 defsubr (&Ssearch_backward); 2439 DEFSUBR (Fsearch_backward);
2467 defsubr (&Sword_search_forward); 2440 DEFSUBR (Fword_search_forward);
2468 defsubr (&Sword_search_backward); 2441 DEFSUBR (Fword_search_backward);
2469 defsubr (&Sre_search_forward); 2442 DEFSUBR (Fre_search_forward);
2470 defsubr (&Sre_search_backward); 2443 DEFSUBR (Fre_search_backward);
2471 defsubr (&Sposix_search_forward); 2444 DEFSUBR (Fposix_search_forward);
2472 defsubr (&Sposix_search_backward); 2445 DEFSUBR (Fposix_search_backward);
2473 defsubr (&Sreplace_match); 2446 DEFSUBR (Freplace_match);
2474 defsubr (&Smatch_beginning); 2447 DEFSUBR (Fmatch_beginning);
2475 defsubr (&Smatch_end); 2448 DEFSUBR (Fmatch_end);
2476 defsubr (&Smatch_data); 2449 DEFSUBR (Fmatch_data);
2477 defsubr (&Sstore_match_data); 2450 DEFSUBR (Fstore_match_data);
2478 defsubr (&Sregexp_quote); 2451 DEFSUBR (Fregexp_quote);
2479 } 2452 }
2480 2453
2481 void 2454 void
2482 vars_of_search (void) 2455 vars_of_search (void)
2483 { 2456 {