# HG changeset patch # User Karl Heuer # Date 760764325 0 # Node ID 021e589059633855c2f4b969c5a2522b12db70ae # Parent 03f8720af7fb4a5269c0637539738abde42dac73 (compute_char_face): Extract overlay-sorting code as a separate function, which is now in buffer.c. diff -r 03f8720af7fb -r 021e58905963 src/xfaces.c --- a/src/xfaces.c Wed Feb 09 03:23:48 1994 +0000 +++ b/src/xfaces.c Wed Feb 09 03:25:25 1994 +0000 @@ -170,7 +170,7 @@ does not specify that display aspect. */ #define FACE_DEFAULT (~0) -Lisp_Object Qface, Qwindow, Qpriority; +Lisp_Object Qface; static void build_face ( /* FRAME_PTR, struct face * */ ); int face_name_id_number ( /* FRAME_PTR, Lisp_Object name */ ); @@ -700,26 +700,6 @@ } -struct sortvec -{ - Lisp_Object overlay; - int beg, end; - int priority; -}; - -static int -sort_overlays (s1, s2) - struct sortvec *s1, *s2; -{ - if (s1->priority != s2->priority) - return s1->priority - s2->priority; - if (s1->beg != s2->beg) - return s1->beg - s2->beg; - if (s1->end != s2->end) - return s2->end - s1->end; - return 0; -} - /* Return the face ID associated with a buffer position POS. Store into *ENDPTR the position at which a different face is needed. This does not take account of glyphs that specify their own face codes. @@ -745,7 +725,6 @@ int i, j, noverlays; int facecode; Lisp_Object *overlay_vec; - struct sortvec *sortvec; Lisp_Object frame; int endpos; @@ -811,52 +790,12 @@ merge_faces (FRAME_PARAM_FACES (f) [facecode], &face); } - /* Put the valid and relevant overlays into sortvec. */ - sortvec = (struct sortvec *) alloca (noverlays * sizeof (struct sortvec)); - - for (i = 0, j = 0; i < noverlays; i++) - { - Lisp_Object overlay = overlay_vec[i]; - - if (OVERLAY_VALID (overlay) - && OVERLAY_POSITION (OVERLAY_START (overlay)) > 0 - && OVERLAY_POSITION (OVERLAY_END (overlay)) > 0) - { - Lisp_Object window; - window = Foverlay_get (overlay, Qwindow); - - /* Also ignore overlays limited to one window - if it's not the window we are using. */ - if (XTYPE (window) != Lisp_Window - || XWINDOW (window) == w) - { - Lisp_Object tem; - - /* This overlay is good and counts: - put it in sortvec. */ - sortvec[j].overlay = overlay; - sortvec[j].beg = OVERLAY_POSITION (OVERLAY_START (overlay)); - sortvec[j].end = OVERLAY_POSITION (OVERLAY_END (overlay)); - tem = Foverlay_get (overlay, Qpriority); - if (INTEGERP (tem)) - sortvec[j].priority = XINT (tem); - else - sortvec[j].priority = 0; - j++; - } - } - } - noverlays = j; - - /* Sort the overlays into the proper order: increasing priority. */ - - if (noverlays > 1) - qsort (sortvec, noverlays, sizeof (struct sortvec), sort_overlays); + noverlays = sort_overlays (overlay_vec, noverlays, w); /* Now merge the overlay data in that order. */ for (i = 0; i < noverlays; i++) { - prop = Foverlay_get (sortvec[i].overlay, Qface); + prop = Foverlay_get (overlay_vec[i], Qface); if (!NILP (prop)) { Lisp_Object oend; @@ -867,7 +806,7 @@ && FRAME_PARAM_FACES (f) [facecode] != 0) merge_faces (FRAME_PARAM_FACES (f) [facecode], &face); - oend = OVERLAY_END (sortvec[i].overlay); + oend = OVERLAY_END (overlay_vec[i]); oendpos = OVERLAY_POSITION (oend); if (oendpos < endpos) endpos = oendpos; @@ -1102,12 +1041,8 @@ void syms_of_xfaces () { - Qwindow = intern ("window"); - staticpro (&Qwindow); Qface = intern ("face"); staticpro (&Qface); - Qpriority = intern ("priority"); - staticpro (&Qpriority); DEFVAR_INT ("region-face", ®ion_face, "Face number to use to highlight the region\n\