comparison src/extents.c @ 5125:b5df3737028a ben-lisp-object

merge
author Ben Wing <ben@xemacs.org>
date Wed, 24 Feb 2010 01:58:04 -0600
parents 623d57b7fbe8 16112448d484
children 2a462149bd6a
comparison
equal deleted inserted replaced
5124:623d57b7fbe8 5125:b5df3737028a
769 #ifndef NEW_GC 769 #ifndef NEW_GC
770 static void 770 static void
771 free_gap_array (Gap_Array *ga) 771 free_gap_array (Gap_Array *ga)
772 { 772 {
773 gap_array_delete_all_markers (ga); 773 gap_array_delete_all_markers (ga);
774 xfree (ga, Gap_Array *); 774 xfree (ga);
775 } 775 }
776 #endif /* not NEW_GC */ 776 #endif /* not NEW_GC */
777 777
778 778
779 /************************************************************************/ 779 /************************************************************************/
992 static void 992 static void
993 free_extent_list (Extent_List *el) 993 free_extent_list (Extent_List *el)
994 { 994 {
995 free_gap_array (el->start); 995 free_gap_array (el->start);
996 free_gap_array (el->end); 996 free_gap_array (el->end);
997 xfree (el, Extent_List *); 997 xfree (el);
998 } 998 }
999 #endif /* not NEW_GC */ 999 #endif /* not NEW_GC */
1000 1000
1001 1001
1002 /************************************************************************/ 1002 /************************************************************************/
1797 #ifndef NEW_GC 1797 #ifndef NEW_GC
1798 static void 1798 static void
1799 free_soe (struct stack_of_extents *soe) 1799 free_soe (struct stack_of_extents *soe)
1800 { 1800 {
1801 free_extent_list (soe->extents); 1801 free_extent_list (soe->extents);
1802 xfree (soe, struct stack_of_extents *); 1802 xfree (soe);
1803 } 1803 }
1804 #endif /* not NEW_GC */ 1804 #endif /* not NEW_GC */
1805 1805
1806 /* ------------------------------- */ 1806 /* ------------------------------- */
1807 /* other primitives */ 1807 /* other primitives */
2911 extent_fragment_delete (struct extent_fragment *ef) 2911 extent_fragment_delete (struct extent_fragment *ef)
2912 { 2912 {
2913 Dynarr_free (ef->extents); 2913 Dynarr_free (ef->extents);
2914 Dynarr_free (ef->begin_glyphs); 2914 Dynarr_free (ef->begin_glyphs);
2915 Dynarr_free (ef->end_glyphs); 2915 Dynarr_free (ef->end_glyphs);
2916 xfree (ef, struct extent_fragment *); 2916 xfree (ef);
2917 } 2917 }
2918 2918
2919 static int 2919 static int
2920 extent_priority_sort_function (const void *humpty, const void *dumpty) 2920 extent_priority_sort_function (const void *humpty, const void *dumpty)
2921 { 2921 {
2953 } 2953 }
2954 else 2954 else
2955 /* But some loser programs mess up and may create a large number 2955 /* But some loser programs mess up and may create a large number
2956 of extents overlapping the same spot. This will result in 2956 of extents overlapping the same spot. This will result in
2957 catastrophic behavior if we use the bubble sort above. */ 2957 catastrophic behavior if we use the bubble sort above. */
2958 qsort (Dynarr_atp (extarr, 0), Dynarr_length (extarr), 2958 qsort (Dynarr_begin (extarr), Dynarr_length (extarr),
2959 sizeof (EXTENT), extent_priority_sort_function); 2959 sizeof (EXTENT), extent_priority_sort_function);
2960 } 2960 }
2961 2961
2962 /* If PROP is the `invisible' property of an extent, 2962 /* If PROP is the `invisible' property of an extent,
2963 this is 1 if the extent should be treated as invisible. */ 2963 this is 1 if the extent should be treated as invisible. */
3096 { 3096 {
3097 EXTENT e = extent_list_at (sel, i, 0); 3097 EXTENT e = extent_list_at (sel, i, 0);
3098 if (extent_start (e) == mempos && !NILP (extent_begin_glyph (e))) 3098 if (extent_start (e) == mempos && !NILP (extent_begin_glyph (e)))
3099 { 3099 {
3100 Lisp_Object glyph = extent_begin_glyph (e); 3100 Lisp_Object glyph = extent_begin_glyph (e);
3101 if (seen_glyph) { 3101 if (seen_glyph)
3102 struct glyph_block gb; 3102 {
3103 3103 struct glyph_block gb;
3104 gb.glyph = glyph; 3104
3105 gb.extent = wrap_extent (e); 3105 xzero (gb);
3106 Dynarr_add (ef->begin_glyphs, gb); 3106 gb.glyph = glyph;
3107 } 3107 gb.extent = wrap_extent (e);
3108 Dynarr_add (ef->begin_glyphs, gb);
3109 }
3108 else if (EQ (glyph, last_glyph)) 3110 else if (EQ (glyph, last_glyph))
3109 seen_glyph = 1; 3111 seen_glyph = 1;
3110 } 3112 }
3111 } 3113 }
3112 3114
3115 { 3117 {
3116 EXTENT e = extent_list_at (sel, i, 1); 3118 EXTENT e = extent_list_at (sel, i, 1);
3117 if (extent_end (e) == mempos && !NILP (extent_end_glyph (e))) 3119 if (extent_end (e) == mempos && !NILP (extent_end_glyph (e)))
3118 { 3120 {
3119 Lisp_Object glyph = extent_end_glyph (e); 3121 Lisp_Object glyph = extent_end_glyph (e);
3120 if (seen_glyph) { 3122 if (seen_glyph)
3121 struct glyph_block gb; 3123 {
3122 3124 struct glyph_block gb;
3123 gb.glyph = glyph; 3125
3124 gb.extent = wrap_extent (e); 3126 xzero (gb);
3125 Dynarr_add (ef->end_glyphs, gb); 3127 gb.glyph = glyph;
3126 } 3128 gb.extent = wrap_extent (e);
3129 Dynarr_add (ef->end_glyphs, gb);
3130 }
3127 else if (EQ (glyph, last_glyph)) 3131 else if (EQ (glyph, last_glyph))
3128 seen_glyph = 1; 3132 seen_glyph = 1;
3129 } 3133 }
3130 } 3134 }
3131 3135
3250 int UNUSED (escapeflag)) 3254 int UNUSED (escapeflag))
3251 { 3255 {
3252 EXTENT ext = XEXTENT (obj); 3256 EXTENT ext = XEXTENT (obj);
3253 EXTENT anc = extent_ancestor (ext); 3257 EXTENT anc = extent_ancestor (ext);
3254 Lisp_Object tail; 3258 Lisp_Object tail;
3255 char buf[64], *bp = buf; 3259 Ascbyte buf[64], *bp = buf;
3256 3260
3257 /* Retrieve the ancestor and use it, for faster retrieval of properties */ 3261 /* Retrieve the ancestor and use it, for faster retrieval of properties */
3258 3262
3259 if (!NILP (extent_begin_glyph (anc))) *bp++ = '*'; 3263 if (!NILP (extent_begin_glyph (anc))) *bp++ = '*';
3260 *bp++ = (extent_start_open_p (anc) ? '(': '['); 3264 *bp++ = (extent_start_open_p (anc) ? '(': '[');
3278 if (!NILP (extent_read_only (anc)) || !NILP (extent_mouse_face (anc)) || 3282 if (!NILP (extent_read_only (anc)) || !NILP (extent_mouse_face (anc)) ||
3279 extent_unique_p (anc) || 3283 extent_unique_p (anc) ||
3280 extent_duplicable_p (anc) || !NILP (extent_invisible (anc))) 3284 extent_duplicable_p (anc) || !NILP (extent_invisible (anc)))
3281 *bp++ = ' '; 3285 *bp++ = ' ';
3282 *bp = '\0'; 3286 *bp = '\0';
3283 write_c_string (printcharfun, buf); 3287 write_ascstring (printcharfun, buf);
3284 3288
3285 tail = extent_plist_slot (anc); 3289 tail = extent_plist_slot (anc);
3286 3290
3287 for (; !NILP (tail); tail = Fcdr (Fcdr (tail))) 3291 for (; !NILP (tail); tail = Fcdr (Fcdr (tail)))
3288 { 3292 {
3340 printing_unreadable_object ("#<extent 0x%lx>", 3344 printing_unreadable_object ("#<extent 0x%lx>",
3341 (long) XEXTENT (obj)); 3345 (long) XEXTENT (obj));
3342 } 3346 }
3343 3347
3344 if (!EXTENT_LIVE_P (XEXTENT (obj))) 3348 if (!EXTENT_LIVE_P (XEXTENT (obj)))
3345 write_c_string (printcharfun, "#<destroyed extent"); 3349 write_ascstring (printcharfun, "#<destroyed extent");
3346 else 3350 else
3347 { 3351 {
3348 write_c_string (printcharfun, "#<extent "); 3352 write_ascstring (printcharfun, "#<extent ");
3349 print_extent_1 (obj, printcharfun, escapeflag); 3353 print_extent_1 (obj, printcharfun, escapeflag);
3350 write_c_string (printcharfun, extent_detached_p (XEXTENT (obj)) 3354 write_ascstring (printcharfun, extent_detached_p (XEXTENT (obj))
3351 ? " from " : " in "); 3355 ? " from " : " in ");
3352 write_fmt_string (printcharfun, "%s%s%s", title, name, posttitle); 3356 write_fmt_string (printcharfun, "%s%s%s", title, name, posttitle);
3353 } 3357 }
3354 } 3358 }
3355 else 3359 else
3356 { 3360 {
3357 if (print_readably) 3361 if (print_readably)
3358 printing_unreadable_object ("#<extent>"); 3362 printing_unreadable_object ("#<extent>");
3359 write_c_string (printcharfun, "#<extent"); 3363 write_ascstring (printcharfun, "#<extent");
3360 } 3364 }
3361 write_c_string (printcharfun, ">"); 3365 write_ascstring (printcharfun, ">");
3362 } 3366 }
3363 3367
3364 static int 3368 static int
3365 properties_equal (EXTENT e1, EXTENT e2, int depth) 3369 properties_equal (EXTENT e1, EXTENT e2, int depth)
3366 { 3370 {
3392 } 3396 }
3393 3397
3394 /* compare the random elements of the plists. */ 3398 /* compare the random elements of the plists. */
3395 return !plists_differ (extent_no_chase_plist (e1), 3399 return !plists_differ (extent_no_chase_plist (e1),
3396 extent_no_chase_plist (e2), 3400 extent_no_chase_plist (e2),
3397 0, 0, depth + 1); 3401 0, 0, depth + 1, 0);
3398 } 3402 }
3399 3403
3400 static int 3404 static int
3401 extent_equal (Lisp_Object obj1, Lisp_Object obj2, int depth) 3405 extent_equal (Lisp_Object obj1, Lisp_Object obj2, int depth,
3406 int UNUSED (foldcase))
3402 { 3407 {
3403 struct extent *e1 = XEXTENT (obj1); 3408 struct extent *e1 = XEXTENT (obj1);
3404 struct extent *e2 = XEXTENT (obj2); 3409 struct extent *e2 = XEXTENT (obj2);
3405 return 3410 return
3406 (extent_start (e1) == extent_start (e2) && 3411 (extent_start (e1) == extent_start (e2) &&
3861 if (!NILP (cur_parent)) 3866 if (!NILP (cur_parent))
3862 extent_properties (XEXTENT (cur_parent), oldprops); 3867 extent_properties (XEXTENT (cur_parent), oldprops);
3863 if (!NILP (parent)) 3868 if (!NILP (parent))
3864 extent_properties (XEXTENT (parent), newprops); 3869 extent_properties (XEXTENT (parent), newprops);
3865 3870
3866 qsort (Dynarr_atp (oldprops, 0), Dynarr_length (oldprops), 3871 qsort (Dynarr_begin (oldprops), Dynarr_length (oldprops),
3867 sizeof (Lisp_Object_pair), compare_key_value_pairs); 3872 sizeof (Lisp_Object_pair), compare_key_value_pairs);
3868 qsort (Dynarr_atp (newprops, 0), Dynarr_length (newprops), 3873 qsort (Dynarr_begin (newprops), Dynarr_length (newprops),
3869 sizeof (Lisp_Object_pair), compare_key_value_pairs); 3874 sizeof (Lisp_Object_pair), compare_key_value_pairs);
3870 orignewlength = Dynarr_length (newprops); 3875 orignewlength = Dynarr_length (newprops);
3871 for (i = 0; i < Dynarr_length (oldprops); i++) 3876 for (i = 0; i < Dynarr_length (oldprops); i++)
3872 { 3877 {
3873 if (!bsearch (Dynarr_atp (oldprops, i), Dynarr_atp (newprops, 0), 3878 if (!bsearch (Dynarr_atp (oldprops, i), Dynarr_begin (newprops),
3874 Dynarr_length (newprops), sizeof (Lisp_Object_pair), 3879 Dynarr_length (newprops), sizeof (Lisp_Object_pair),
3875 compare_key_value_pairs)) 3880 compare_key_value_pairs))
3876 { 3881 {
3877 Lisp_Object_pair new_; 3882 Lisp_Object_pair new_;
3878 new_.key = Dynarr_at (oldprops, i).key; 3883 new_.key = Dynarr_at (oldprops, i).key;
3881 } 3886 }
3882 } 3887 }
3883 for (i = 0; i < orignewlength; i++) 3888 for (i = 0; i < orignewlength; i++)
3884 { 3889 {
3885 if (!Dynarr_length (oldprops) || !bsearch (Dynarr_atp (newprops, i), 3890 if (!Dynarr_length (oldprops) || !bsearch (Dynarr_atp (newprops, i),
3886 Dynarr_atp (oldprops, 0), 3891 Dynarr_begin (oldprops),
3887 Dynarr_length (oldprops), 3892 Dynarr_length (oldprops),
3888 sizeof (Lisp_Object_pair), 3893 sizeof (Lisp_Object_pair),
3889 compare_key_value_pairs)) 3894 compare_key_value_pairs))
3890 { 3895 {
3891 Lisp_Object_pair new_; 3896 Lisp_Object_pair new_;
3892 new_.key = Dynarr_at (newprops, i).key; 3897 new_.key = Dynarr_at (newprops, i).key;
3893 new_.value = Qunbound; 3898 new_.value = Qunbound;
3894 Dynarr_add (oldprops, new_); 3899 Dynarr_add (oldprops, new_);
3895 } 3900 }
3896 } 3901 }
3897 qsort (Dynarr_atp (oldprops, 0), Dynarr_length (oldprops), 3902 qsort (Dynarr_begin (oldprops), Dynarr_length (oldprops),
3898 sizeof (Lisp_Object_pair), compare_key_value_pairs); 3903 sizeof (Lisp_Object_pair), compare_key_value_pairs);
3899 qsort (Dynarr_atp (newprops, 0), Dynarr_length (newprops), 3904 qsort (Dynarr_begin (newprops), Dynarr_length (newprops),
3900 sizeof (Lisp_Object_pair), compare_key_value_pairs); 3905 sizeof (Lisp_Object_pair), compare_key_value_pairs);
3901 for (i = 0; i < Dynarr_length (oldprops); i++) 3906 for (i = 0; i < Dynarr_length (oldprops); i++)
3902 { 3907 {
3903 assert (EQ (Dynarr_at (oldprops, i).key, Dynarr_at (newprops, i).key)); 3908 assert (EQ (Dynarr_at (oldprops, i).key, Dynarr_at (newprops, i).key));
3904 if (!EQ (Dynarr_at (oldprops, i).value, Dynarr_at (newprops, i).value)) 3909 if (!EQ (Dynarr_at (oldprops, i).value, Dynarr_at (newprops, i).value))
7619 make_lisp_hash_table (100, HASH_TABLE_VALUE_WEAK, HASH_TABLE_EQUAL); 7624 make_lisp_hash_table (100, HASH_TABLE_VALUE_WEAK, HASH_TABLE_EQUAL);
7620 staticpro (&Vextent_face_reverse_memoize_hash_table); 7625 staticpro (&Vextent_face_reverse_memoize_hash_table);
7621 Vextent_face_reverse_memoize_hash_table = 7626 Vextent_face_reverse_memoize_hash_table =
7622 make_lisp_hash_table (100, HASH_TABLE_KEY_WEAK, HASH_TABLE_EQ); 7627 make_lisp_hash_table (100, HASH_TABLE_KEY_WEAK, HASH_TABLE_EQ);
7623 7628
7624 QSin_map_extents_internal = build_msg_string ("(in map-extents-internal)"); 7629 QSin_map_extents_internal = build_defer_string ("(in map-extents-internal)");
7625 staticpro (&QSin_map_extents_internal); 7630 staticpro (&QSin_map_extents_internal);
7626 } 7631 }