/[emacs]/emacs/src/search.c
ViewVC logotype

Diff of /emacs/src/search.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.192 by handa, Wed Apr 20 07:21:47 2005 UTC revision 1.193 by kfstorm, Wed Jun 8 22:32:20 2005 UTC
# Line 2739  Zero means the entire text matched by th Line 2739  Zero means the entire text matched by th
2739    return match_limit (subexp, 0);    return match_limit (subexp, 0);
2740  }  }
2741    
2742  DEFUN ("match-data", Fmatch_data, Smatch_data, 0, 2, 0,  DEFUN ("match-data", Fmatch_data, Smatch_data, 0, 3, 0,
2743         doc: /* Return a list containing all info on what the last search matched.         doc: /* Return a list containing all info on what the last search matched.
2744  Element 2N is `(match-beginning N)'; element 2N + 1 is `(match-end N)'.  Element 2N is `(match-beginning N)'; element 2N + 1 is `(match-end N)'.
2745  All the elements are markers or nil (nil if the Nth pair didn't match)  All the elements are markers or nil (nil if the Nth pair didn't match)
# Line 2751  integers \(rather than markers) to repre Line 2751  integers \(rather than markers) to repre
2751  this case, and if the last match was in a buffer, the buffer will get  this case, and if the last match was in a buffer, the buffer will get
2752  stored as one additional element at the end of the list.  stored as one additional element at the end of the list.
2753    
2754  If REUSE is a list, reuse it as part of the value.  If REUSE is long enough  If REUSE is a list, reuse it as part of the value.  If REUSE is long
2755  to hold all the values, and if INTEGERS is non-nil, no consing is done.  enough to hold all the values, and if INTEGERS is non-nil, no consing
2756    is done.
2757    
2758    If optional third arg RESEAT is non-nil, any previous markers on the
2759    REUSE list will be modified to point to nowhere.
2760    
2761    If RESEAT is `evaporate', put markers back on the free list.
2762    Note: No other references to the markers must exist if you use this.
2763    
2764  Return value is undefined if the last search failed.  */)  Return value is undefined if the last search failed.  */)
2765       (integers, reuse)    (integers, reuse, reseat)
2766       Lisp_Object integers, reuse;       Lisp_Object integers, reuse, reseat;
2767  {  {
2768    Lisp_Object tail, prev;    Lisp_Object tail, prev;
2769    Lisp_Object *data;    Lisp_Object *data;
2770    int i, len;    int i, len;
2771    
2772      if (!NILP (reseat))
2773        for (tail = reuse; CONSP (tail); tail = XCDR (tail))
2774          if (MARKERP (XCAR (tail)))
2775            {
2776              if (EQ (reseat, Qevaporate))
2777                free_marker (XCAR (tail));
2778              else
2779                unchain_marker (XMARKER (XCAR (tail)));
2780              XSETCAR (tail, Qnil);
2781            }
2782    
2783    if (NILP (last_thing_searched))    if (NILP (last_thing_searched))
2784      return Qnil;      return Qnil;
2785    
# Line 2797  Return value is undefined if the last se Line 2815  Return value is undefined if the last se
2815              /* last_thing_searched must always be Qt, a buffer, or Qnil.  */              /* last_thing_searched must always be Qt, a buffer, or Qnil.  */
2816              abort ();              abort ();
2817    
2818            len = 2*(i+1);            len = 2 * i + 2;
2819          }          }
2820        else        else
2821          data[2 * i] = data [2 * i + 1] = Qnil;          data[2 * i] = data[2 * i + 1] = Qnil;
2822      }      }
2823    
2824    if (BUFFERP (last_thing_searched) && !NILP (integers))    if (BUFFERP (last_thing_searched) && !NILP (integers))
# Line 2834  Return value is undefined if the last se Line 2852  Return value is undefined if the last se
2852  }  }
2853    
2854    
2855  DEFUN ("set-match-data", Fset_match_data, Sset_match_data, 1, 1, 0,  DEFUN ("set-match-data", Fset_match_data, Sset_match_data, 1, 2, 0,
2856         doc: /* Set internal data on last search match from elements of LIST.         doc: /* Set internal data on last search match from elements of LIST.
2857  LIST should have been created by calling `match-data' previously.  */)  LIST should have been created by calling `match-data' previously.
2858       (list)  
2859       register Lisp_Object list;  If optional arg RESEAT is non-nil, make markers on LIST point nowhere.
2860    If RESEAT is `evaporate', put the markers back on the free list.
2861    Note: No other references to the markers must exist if you use this.  */)
2862        (list, reseat)
2863         register Lisp_Object list, reseat;
2864  {  {
2865    register int i;    register int i;
2866    register Lisp_Object marker;    register Lisp_Object marker;
# Line 2882  LIST should have been created by calling Line 2904  LIST should have been created by calling
2904          search_regs.num_regs = length;          search_regs.num_regs = length;
2905        }        }
2906    
2907      for (i = 0;; i++)      for (i = 0; CONSP (list); i++)
2908        {        {
2909          marker = Fcar (list);          marker = XCAR (list);
2910          if (BUFFERP (marker))          if (BUFFERP (marker))
2911            {            {
2912              last_thing_searched = marker;              last_thing_searched = marker;
# Line 2895  LIST should have been created by calling Line 2917  LIST should have been created by calling
2917          if (NILP (marker))          if (NILP (marker))
2918            {            {
2919              search_regs.start[i] = -1;              search_regs.start[i] = -1;
2920              list = Fcdr (list);              list = XCDR (list);
2921            }            }
2922          else          else
2923            {            {
2924              int from;              int from;
2925                Lisp_Object m;
2926    
2927                m = marker;
2928              if (MARKERP (marker))              if (MARKERP (marker))
2929                {                {
2930                  if (XMARKER (marker)->buffer == 0)                  if (XMARKER (marker)->buffer == 0)
# Line 2911  LIST should have been created by calling Line 2935  LIST should have been created by calling
2935    
2936              CHECK_NUMBER_COERCE_MARKER (marker);              CHECK_NUMBER_COERCE_MARKER (marker);
2937              from = XINT (marker);              from = XINT (marker);
             list = Fcdr (list);  
2938    
2939              marker = Fcar (list);              if (!NILP (reseat) && MARKERP (m))
2940                  {
2941                    if (EQ (reseat, Qevaporate))
2942                      free_marker (m);
2943                    else
2944                      unchain_marker (XMARKER (m));
2945                  }
2946    
2947                if ((list = XCDR (list), !CONSP (list)))
2948                  break;
2949    
2950                m = marker = XCAR (list);
2951    
2952              if (MARKERP (marker) && XMARKER (marker)->buffer == 0)              if (MARKERP (marker) && XMARKER (marker)->buffer == 0)
2953                XSETFASTINT (marker, 0);                XSETFASTINT (marker, 0);
2954    
2955              CHECK_NUMBER_COERCE_MARKER (marker);              CHECK_NUMBER_COERCE_MARKER (marker);
2956              search_regs.start[i] = from;              search_regs.start[i] = from;
2957              search_regs.end[i] = XINT (marker);              search_regs.end[i] = XINT (marker);
2958    
2959                if (!NILP (reseat) && MARKERP (m))
2960                  {
2961                    if (EQ (reseat, Qevaporate))
2962                      free_marker (m);
2963                    else
2964                      unchain_marker (XMARKER (m));
2965                  }
2966            }            }
2967          list = Fcdr (list);          list = XCDR (list);
2968        }        }
2969    
2970      for (; i < search_regs.num_regs; i++)      for (; i < search_regs.num_regs; i++)
# Line 2959  save_search_regs () Line 3002  save_search_regs ()
3002    
3003  /* Called upon exit from filters and sentinels. */  /* Called upon exit from filters and sentinels. */
3004  void  void
3005  restore_match_data ()  restore_search_regs ()
3006  {  {
3007    if (search_regs_saved)    if (search_regs_saved)
3008      {      {
# Line 2977  restore_match_data () Line 3020  restore_match_data ()
3020      }      }
3021  }  }
3022    
3023    static Lisp_Object
3024    unwind_set_match_data (list)
3025         Lisp_Object list;
3026    {
3027      return Fset_match_data (list, Qevaporate);
3028    }
3029    
3030    /* Called to unwind protect the match data.  */
3031    void
3032    record_unwind_save_match_data ()
3033    {
3034      record_unwind_protect (unwind_set_match_data,
3035                             Fmatch_data (Qnil, Qnil, Qnil));
3036    }
3037    
3038  /* Quote a string to inactivate reg-expr chars */  /* Quote a string to inactivate reg-expr chars */
3039    
3040  DEFUN ("regexp-quote", Fregexp_quote, Sregexp_quote, 1, 1, 0,  DEFUN ("regexp-quote", Fregexp_quote, Sregexp_quote, 1, 1, 0,

Legend:
Removed from v.1.192  
changed lines
  Added in v.1.193

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26