comparison src/insdel.c @ 377:d883f39b8495 r21-2b4

Import from CVS: tag r21-2b4
author cvs
date Mon, 13 Aug 2007 11:05:42 +0200
parents 6240c7796c7a
children 8626e4521993
comparison
equal deleted inserted replaced
376:e2295b4d9f2e 377:d883f39b8495
2990 /************************************************************************/ 2990 /************************************************************************/
2991 2991
2992 /* Make a string from a buffer. This needs to take into account the gap, 2992 /* Make a string from a buffer. This needs to take into account the gap,
2993 and add any necessary extents from the buffer. */ 2993 and add any necessary extents from the buffer. */
2994 2994
2995 Lisp_Object 2995 static Lisp_Object
2996 make_string_from_buffer (struct buffer *buf, Bufpos pos, Charcount length) 2996 make_string_from_buffer_1 (struct buffer *buf, Bufpos pos, Charcount length,
2997 int no_extents)
2997 { 2998 {
2998 /* This function can GC */ 2999 /* This function can GC */
2999 Lisp_Object val; 3000 Bytind bi_ind = bufpos_to_bytind (buf, pos);
3001 Bytecount bi_len = bufpos_to_bytind (buf, pos + length) - bi_ind;
3002 Lisp_Object val = make_uninit_string (bi_len);
3003
3000 struct gcpro gcpro1; 3004 struct gcpro gcpro1;
3001 Bytind bi_ind;
3002 Bytecount bi_len;
3003
3004 bi_ind = bufpos_to_bytind (buf, pos);
3005 bi_len = bufpos_to_bytind (buf, pos + length) - bi_ind;
3006
3007 val = make_uninit_string (bi_len);
3008 GCPRO1 (val); 3005 GCPRO1 (val);
3009 3006
3010 add_string_extents (val, buf, bi_ind, bi_len); 3007 if (!no_extents)
3008 add_string_extents (val, buf, bi_ind, bi_len);
3011 3009
3012 { 3010 {
3013 Bytecount len1 = BI_BUF_GPT (buf) - bi_ind; 3011 Bytecount len1 = BI_BUF_GPT (buf) - bi_ind;
3014 Bufbyte *start1 = BI_BUF_BYTE_ADDRESS (buf, bi_ind); 3012 Bufbyte *start1 = BI_BUF_BYTE_ADDRESS (buf, bi_ind);
3015 Bufbyte *dest = XSTRING_DATA (val); 3013 Bufbyte *dest = XSTRING_DATA (val);
3037 3035
3038 UNGCPRO; 3036 UNGCPRO;
3039 return val; 3037 return val;
3040 } 3038 }
3041 3039
3040 Lisp_Object
3041 make_string_from_buffer (struct buffer *buf, Bufpos pos, Charcount length)
3042 {
3043 return make_string_from_buffer_1 (buf, pos, length, 0);
3044 }
3045
3046 Lisp_Object
3047 make_string_from_buffer_no_extents (struct buffer *buf, Bufpos pos,
3048 Charcount length)
3049 {
3050 return make_string_from_buffer_1 (buf, pos, length, 1);
3051 }
3052
3042 void 3053 void
3043 barf_if_buffer_read_only (struct buffer *buf, Bufpos from, Bufpos to) 3054 barf_if_buffer_read_only (struct buffer *buf, Bufpos from, Bufpos to)
3044 { 3055 {
3045 Lisp_Object buffer; 3056 Lisp_Object buffer;
3046 Lisp_Object iro; 3057 Lisp_Object iro;