comparison src/syntax.c @ 20766:92c662c4ab0e

(back_comment): Move the find_defun_start call out of the scan_sexps_forward call. No need to call find_defun_start if we found the defun start in the initial scan.
author Richard M. Stallman <rms@gnu.org>
date Sun, 25 Jan 1998 01:55:51 +0000
parents 10eb136ca94b
children e646a6ae42cd
comparison
equal deleted inserted replaced
20765:2bdc3877262b 20766:92c662c4ab0e
405 int my_stringend = 0; 405 int my_stringend = 0;
406 int string_lossage = 0; 406 int string_lossage = 0;
407 int comment_end = from; 407 int comment_end = from;
408 int comment_end_byte = from_byte; 408 int comment_end_byte = from_byte;
409 int comstart_pos = 0; 409 int comstart_pos = 0;
410 int comstart_byte;
411 /* Value that PARITY had, when we reached the position
412 in COMSTART_POS. */
410 int comstart_parity = 0; 413 int comstart_parity = 0;
411 int comstart_byte;
412 int scanstart = from - 1; 414 int scanstart = from - 1;
415 /* Place where the containing defun starts,
416 or 0 if we didn't come across it yet. */
417 int defun_start = 0;
418 int defun_start_byte = 0;
413 register enum syntaxcode code; 419 register enum syntaxcode code;
414 int c; 420 int c;
415 421
416 /* At beginning of range to scan, we're outside of strings; 422 /* At beginning of range to scan, we're outside of strings;
417 that determines quote parity to the comment-end. */ 423 that determines quote parity to the comment-end. */
495 /* Assume a defun-start point is outside of strings. */ 501 /* Assume a defun-start point is outside of strings. */
496 if (code == Sopen 502 if (code == Sopen
497 && (from == stop 503 && (from == stop
498 || (temp_byte = dec_bytepos (from_byte), 504 || (temp_byte = dec_bytepos (from_byte),
499 FETCH_CHAR (temp_byte) == '\n'))) 505 FETCH_CHAR (temp_byte) == '\n')))
500 break; 506 {
507 defun_start = from;
508 defun_start_byte = from_byte;
509 break;
510 }
501 } 511 }
502 512
503 if (comstart_pos == 0) 513 if (comstart_pos == 0)
504 { 514 {
505 from = comment_end; 515 from = comment_end;
523 together. Decode this going forwards. 533 together. Decode this going forwards.
524 Scan fwd from the previous comment ender 534 Scan fwd from the previous comment ender
525 to the one in question; this records where we 535 to the one in question; this records where we
526 last passed a comment starter. */ 536 last passed a comment starter. */
527 struct lisp_parse_state state; 537 struct lisp_parse_state state;
538 /* If we did not already find the defun start, find it now. */
539 if (defun_start == 0)
540 {
541 defun_start = find_defun_start (comment_end, comment_end_byte);
542 defun_start_byte = find_start_value_byte;
543 }
528 scan_sexps_forward (&state, 544 scan_sexps_forward (&state,
529 find_defun_start (comment_end, comment_end_byte), 545 defun_start, defun_start_byte,
530 find_start_value_byte,
531 comment_end - 1, -10000, 0, Qnil, 0); 546 comment_end - 1, -10000, 0, Qnil, 0);
532 if (state.incomment) 547 if (state.incomment)
533 { 548 {
534 /* scan_sexps_forward changed the direction of search in 549 /* scan_sexps_forward changed the direction of search in
535 global variables, so we need to update it completely. */ 550 global variables, so we need to update it completely. */