comparison src/xdisp.c @ 46477:1e108eb581e8

(store_frame_title, string_char_and_length): (message_dolog, message2, message2_nolog, set_message): String pointer args now point to const. (set_message_1): Cast message string argument to const pointer. (string_pos_nchars_ahead, init_from_display_pos): (face_before_or_after_it_pos, next_element_from_string): (get_overlay_arrow_glyph_row, display_mode_element): (decode_mode_spec_coding): Use const for pointer to lisp string data.
author Ken Raeburn <raeburn@raeburn.org>
date Tue, 16 Jul 2002 19:49:12 +0000
parents da9e42d793d2
children f9195cae859a
comparison
equal deleted inserted replaced
46476:2b7a72428d13 46477:1e108eb581e8
711 static struct text_pos run_window_scroll_functions P_ ((Lisp_Object, 711 static struct text_pos run_window_scroll_functions P_ ((Lisp_Object,
712 struct text_pos)); 712 struct text_pos));
713 static void reconsider_clip_changes P_ ((struct window *, struct buffer *)); 713 static void reconsider_clip_changes P_ ((struct window *, struct buffer *));
714 static int text_outside_line_unchanged_p P_ ((struct window *, int, int)); 714 static int text_outside_line_unchanged_p P_ ((struct window *, int, int));
715 static void store_frame_title_char P_ ((char)); 715 static void store_frame_title_char P_ ((char));
716 static int store_frame_title P_ ((unsigned char *, int, int)); 716 static int store_frame_title P_ ((const unsigned char *, int, int));
717 static void x_consider_frame_title P_ ((Lisp_Object)); 717 static void x_consider_frame_title P_ ((Lisp_Object));
718 static void handle_stop P_ ((struct it *)); 718 static void handle_stop P_ ((struct it *));
719 static int tool_bar_lines_needed P_ ((struct frame *)); 719 static int tool_bar_lines_needed P_ ((struct frame *));
720 static int single_display_prop_intangible_p P_ ((Lisp_Object)); 720 static int single_display_prop_intangible_p P_ ((Lisp_Object));
721 static void ensure_echo_area_buffers P_ ((void)); 721 static void ensure_echo_area_buffers P_ ((void));
730 static int set_message_1 P_ ((EMACS_INT, Lisp_Object, EMACS_INT, EMACS_INT)); 730 static int set_message_1 P_ ((EMACS_INT, Lisp_Object, EMACS_INT, EMACS_INT));
731 static int display_echo_area P_ ((struct window *)); 731 static int display_echo_area P_ ((struct window *));
732 static int display_echo_area_1 P_ ((EMACS_INT, Lisp_Object, EMACS_INT, EMACS_INT)); 732 static int display_echo_area_1 P_ ((EMACS_INT, Lisp_Object, EMACS_INT, EMACS_INT));
733 static int resize_mini_window_1 P_ ((EMACS_INT, Lisp_Object, EMACS_INT, EMACS_INT)); 733 static int resize_mini_window_1 P_ ((EMACS_INT, Lisp_Object, EMACS_INT, EMACS_INT));
734 static Lisp_Object unwind_redisplay P_ ((Lisp_Object)); 734 static Lisp_Object unwind_redisplay P_ ((Lisp_Object));
735 static int string_char_and_length P_ ((unsigned char *, int, int *)); 735 static int string_char_and_length P_ ((const unsigned char *, int, int *));
736 static struct text_pos display_prop_end P_ ((struct it *, Lisp_Object, 736 static struct text_pos display_prop_end P_ ((struct it *, Lisp_Object,
737 struct text_pos)); 737 struct text_pos));
738 static int compute_window_start_on_continuation_line P_ ((struct window *)); 738 static int compute_window_start_on_continuation_line P_ ((struct window *));
739 static Lisp_Object safe_eval_handler P_ ((Lisp_Object)); 739 static Lisp_Object safe_eval_handler P_ ((Lisp_Object));
740 static void insert_left_trunc_glyphs P_ ((struct it *)); 740 static void insert_left_trunc_glyphs P_ ((struct it *));
1147 we find one, we return a `?', but with the length of the invalid 1147 we find one, we return a `?', but with the length of the invalid
1148 character. */ 1148 character. */
1149 1149
1150 static INLINE int 1150 static INLINE int
1151 string_char_and_length (str, maxlen, len) 1151 string_char_and_length (str, maxlen, len)
1152 unsigned char *str; 1152 const unsigned char *str;
1153 int maxlen, *len; 1153 int maxlen, *len;
1154 { 1154 {
1155 int c; 1155 int c;
1156 1156
1157 c = STRING_CHAR_AND_LENGTH (str, maxlen, *len); 1157 c = STRING_CHAR_AND_LENGTH (str, maxlen, *len);
1178 xassert (STRINGP (string) && nchars >= 0); 1178 xassert (STRINGP (string) && nchars >= 0);
1179 1179
1180 if (STRING_MULTIBYTE (string)) 1180 if (STRING_MULTIBYTE (string))
1181 { 1181 {
1182 int rest = SBYTES (string) - BYTEPOS (pos); 1182 int rest = SBYTES (string) - BYTEPOS (pos);
1183 unsigned char *p = SDATA (string) + BYTEPOS (pos); 1183 const unsigned char *p = SDATA (string) + BYTEPOS (pos);
1184 int len; 1184 int len;
1185 1185
1186 while (nchars--) 1186 while (nchars--)
1187 { 1187 {
1188 string_char_and_length (p, rest, &len); 1188 string_char_and_length (p, rest, &len);
1876 after-string. */ 1876 after-string. */
1877 init_iterator (it, w, charpos, bytepos, NULL, DEFAULT_FACE_ID); 1877 init_iterator (it, w, charpos, bytepos, NULL, DEFAULT_FACE_ID);
1878 1878
1879 for (i = 0; i < it->n_overlay_strings; ++i) 1879 for (i = 0; i < it->n_overlay_strings; ++i)
1880 { 1880 {
1881 char *s = SDATA (it->overlay_strings[i]); 1881 const char *s = SDATA (it->overlay_strings[i]);
1882 char *e = s + SBYTES (it->overlay_strings[i]); 1882 const char *e = s + SBYTES (it->overlay_strings[i]);
1883 1883
1884 while (s < e && *s != '\n') 1884 while (s < e && *s != '\n')
1885 ++s; 1885 ++s;
1886 1886
1887 if (s < e) 1887 if (s < e)
2483 /* Correct the face for charsets different from ASCII. Do it 2483 /* Correct the face for charsets different from ASCII. Do it
2484 for the multibyte case only. The face returned above is 2484 for the multibyte case only. The face returned above is
2485 suitable for unibyte text if IT->string is unibyte. */ 2485 suitable for unibyte text if IT->string is unibyte. */
2486 if (STRING_MULTIBYTE (it->string)) 2486 if (STRING_MULTIBYTE (it->string))
2487 { 2487 {
2488 unsigned char *p = SDATA (it->string) + BYTEPOS (pos); 2488 const unsigned char *p = SDATA (it->string) + BYTEPOS (pos);
2489 int rest = SBYTES (it->string) - BYTEPOS (pos); 2489 int rest = SBYTES (it->string) - BYTEPOS (pos);
2490 int c, len; 2490 int c, len;
2491 struct face *face = FACE_FROM_ID (it->f, face_id); 2491 struct face *face = FACE_FROM_ID (it->f, face_id);
2492 2492
2493 c = string_char_and_length (p, rest, &len); 2493 c = string_char_and_length (p, rest, &len);
4610 return 0; 4610 return 0;
4611 } 4611 }
4612 else if (STRING_MULTIBYTE (it->string)) 4612 else if (STRING_MULTIBYTE (it->string))
4613 { 4613 {
4614 int remaining = SBYTES (it->string) - IT_STRING_BYTEPOS (*it); 4614 int remaining = SBYTES (it->string) - IT_STRING_BYTEPOS (*it);
4615 unsigned char *s = SDATA (it->string) + IT_STRING_BYTEPOS (*it); 4615 const unsigned char *s = (SDATA (it->string)
4616 + IT_STRING_BYTEPOS (*it));
4616 it->c = string_char_and_length (s, remaining, &it->len); 4617 it->c = string_char_and_length (s, remaining, &it->len);
4617 } 4618 }
4618 else 4619 else
4619 { 4620 {
4620 it->c = SREF (it->string, IT_STRING_BYTEPOS (*it)); 4621 it->c = SREF (it->string, IT_STRING_BYTEPOS (*it));
4639 CHARPOS (position) = BYTEPOS (position) = -1; 4640 CHARPOS (position) = BYTEPOS (position) = -1;
4640 } 4641 }
4641 else if (STRING_MULTIBYTE (it->string)) 4642 else if (STRING_MULTIBYTE (it->string))
4642 { 4643 {
4643 int maxlen = SBYTES (it->string) - IT_STRING_BYTEPOS (*it); 4644 int maxlen = SBYTES (it->string) - IT_STRING_BYTEPOS (*it);
4644 unsigned char *s = SDATA (it->string) + IT_STRING_BYTEPOS (*it); 4645 const unsigned char *s = (SDATA (it->string)
4646 + IT_STRING_BYTEPOS (*it));
4645 it->c = string_char_and_length (s, maxlen, &it->len); 4647 it->c = string_char_and_length (s, maxlen, &it->len);
4646 } 4648 }
4647 else 4649 else
4648 { 4650 {
4649 it->c = SREF (it->string, IT_STRING_BYTEPOS (*it)); 4651 it->c = SREF (it->string, IT_STRING_BYTEPOS (*it));
5651 function calls low-level routines in order to bypass text property 5653 function calls low-level routines in order to bypass text property
5652 hooks, etc. which might not be safe to run. */ 5654 hooks, etc. which might not be safe to run. */
5653 5655
5654 void 5656 void
5655 message_dolog (m, nbytes, nlflag, multibyte) 5657 message_dolog (m, nbytes, nlflag, multibyte)
5656 char *m; 5658 const char *m;
5657 int nbytes, nlflag, multibyte; 5659 int nbytes, nlflag, multibyte;
5658 { 5660 {
5659 if (!NILP (Vmemory_full)) 5661 if (!NILP (Vmemory_full))
5660 return; 5662 return;
5661 5663
5865 not pass text that is stored in a Lisp string; do not pass text in 5867 not pass text that is stored in a Lisp string; do not pass text in
5866 a buffer that was alloca'd. */ 5868 a buffer that was alloca'd. */
5867 5869
5868 void 5870 void
5869 message2 (m, nbytes, multibyte) 5871 message2 (m, nbytes, multibyte)
5870 char *m; 5872 const char *m;
5871 int nbytes; 5873 int nbytes;
5872 int multibyte; 5874 int multibyte;
5873 { 5875 {
5874 /* First flush out any partial line written with print. */ 5876 /* First flush out any partial line written with print. */
5875 message_log_maybe_newline (); 5877 message_log_maybe_newline ();
5881 5883
5882 /* The non-logging counterpart of message2. */ 5884 /* The non-logging counterpart of message2. */
5883 5885
5884 void 5886 void
5885 message2_nolog (m, nbytes, multibyte) 5887 message2_nolog (m, nbytes, multibyte)
5886 char *m; 5888 const char *m;
5887 int nbytes; 5889 int nbytes;
5888 { 5890 {
5889 struct frame *sf = SELECTED_FRAME (); 5891 struct frame *sf = SELECTED_FRAME ();
5890 message_enable_multibyte = multibyte; 5892 message_enable_multibyte = multibyte;
5891 5893
6902 zero means use the whole string. MULTIBYTE_P non-zero means S is 6904 zero means use the whole string. MULTIBYTE_P non-zero means S is
6903 multibyte. Display the message multibyte in that case. */ 6905 multibyte. Display the message multibyte in that case. */
6904 6906
6905 void 6907 void
6906 set_message (s, string, nbytes, multibyte_p) 6908 set_message (s, string, nbytes, multibyte_p)
6907 char *s; 6909 const char *s;
6908 Lisp_Object string; 6910 Lisp_Object string;
6909 int nbytes; 6911 int nbytes;
6910 { 6912 {
6911 message_enable_multibyte 6913 message_enable_multibyte
6912 = ((s && multibyte_p) 6914 = ((s && multibyte_p)
6928 set_message_1 (a1, a2, nbytes, multibyte_p) 6930 set_message_1 (a1, a2, nbytes, multibyte_p)
6929 EMACS_INT a1; 6931 EMACS_INT a1;
6930 Lisp_Object a2; 6932 Lisp_Object a2;
6931 EMACS_INT nbytes, multibyte_p; 6933 EMACS_INT nbytes, multibyte_p;
6932 { 6934 {
6933 char *s = (char *) a1; 6935 const char *s = (const char *) a1;
6934 Lisp_Object string = a2; 6936 Lisp_Object string = a2;
6935 6937
6936 xassert (BEG == Z); 6938 xassert (BEG == Z);
6937 6939
6938 /* Change multibyteness of the echo buffer appropriately. */ 6940 /* Change multibyteness of the echo buffer appropriately. */
6982 else if (!multibyte_p 6984 else if (!multibyte_p
6983 && !NILP (current_buffer->enable_multibyte_characters)) 6985 && !NILP (current_buffer->enable_multibyte_characters))
6984 { 6986 {
6985 /* Convert from single-byte to multi-byte. */ 6987 /* Convert from single-byte to multi-byte. */
6986 int i, c, n; 6988 int i, c, n;
6987 unsigned char *msg = (unsigned char *) s; 6989 const unsigned char *msg = (const unsigned char *) s;
6988 unsigned char str[MAX_MULTIBYTE_LENGTH]; 6990 unsigned char str[MAX_MULTIBYTE_LENGTH];
6989 6991
6990 /* Convert a single-byte string to multibyte. */ 6992 /* Convert a single-byte string to multibyte. */
6991 for (i = 0; i < nbytes; i++) 6993 for (i = 0; i < nbytes; i++)
6992 { 6994 {
7220 pad. Called from display_mode_element when it is used to build a 7222 pad. Called from display_mode_element when it is used to build a
7221 frame title. */ 7223 frame title. */
7222 7224
7223 static int 7225 static int
7224 store_frame_title (str, field_width, precision) 7226 store_frame_title (str, field_width, precision)
7225 unsigned char *str; 7227 const unsigned char *str;
7226 int field_width, precision; 7228 int field_width, precision;
7227 { 7229 {
7228 int n = 0; 7230 int n = 0;
7229 int dummy, nbytes; 7231 int dummy, nbytes;
7230 7232
12508 struct window *w; 12510 struct window *w;
12509 { 12511 {
12510 struct frame *f = XFRAME (WINDOW_FRAME (w)); 12512 struct frame *f = XFRAME (WINDOW_FRAME (w));
12511 struct buffer *buffer = XBUFFER (w->buffer); 12513 struct buffer *buffer = XBUFFER (w->buffer);
12512 struct buffer *old = current_buffer; 12514 struct buffer *old = current_buffer;
12513 unsigned char *arrow_string = SDATA (Voverlay_arrow_string); 12515 const unsigned char *arrow_string = SDATA (Voverlay_arrow_string);
12514 int arrow_len = SCHARS (Voverlay_arrow_string); 12516 int arrow_len = SCHARS (Voverlay_arrow_string);
12515 unsigned char *arrow_end = arrow_string + arrow_len; 12517 const unsigned char *arrow_end = arrow_string + arrow_len;
12516 unsigned char *p; 12518 const unsigned char *p;
12517 struct it it; 12519 struct it it;
12518 int multibyte_p; 12520 int multibyte_p;
12519 int n_glyphs_before; 12521 int n_glyphs_before;
12520 12522
12521 set_buffer_temp (buffer); 12523 set_buffer_temp (buffer);
13715 { 13717 {
13716 case Lisp_String: 13718 case Lisp_String:
13717 { 13719 {
13718 /* A string: output it and check for %-constructs within it. */ 13720 /* A string: output it and check for %-constructs within it. */
13719 unsigned char c; 13721 unsigned char c;
13720 unsigned char *this, *lisp_string; 13722 const unsigned char *this, *lisp_string;
13721 13723
13722 if (!NILP (props) || risky) 13724 if (!NILP (props) || risky)
13723 { 13725 {
13724 Lisp_Object oprops, aelt; 13726 Lisp_Object oprops, aelt;
13725 oprops = Ftext_properties_at (make_number (0), elt); 13727 oprops = Ftext_properties_at (make_number (0), elt);
13792 && *this 13794 && *this
13793 && (frame_title_ptr 13795 && (frame_title_ptr
13794 || !NILP (mode_line_string_list) 13796 || !NILP (mode_line_string_list)
13795 || it->current_x < it->last_visible_x)) 13797 || it->current_x < it->last_visible_x))
13796 { 13798 {
13797 unsigned char *last = this; 13799 const unsigned char *last = this;
13798 13800
13799 /* Advance to end of string or next format specifier. */ 13801 /* Advance to end of string or next format specifier. */
13800 while ((c = *this++) != '\0' && c != '%') 13802 while ((c = *this++) != '\0' && c != '%')
13801 ; 13803 ;
13802 13804
13831 STRING_MULTIBYTE (elt)); 13833 STRING_MULTIBYTE (elt));
13832 } 13834 }
13833 } 13835 }
13834 else /* c == '%' */ 13836 else /* c == '%' */
13835 { 13837 {
13836 unsigned char *percent_position = this; 13838 const unsigned char *percent_position = this;
13837 13839
13838 /* Get the specified minimum width. Zero means 13840 /* Get the specified minimum width. Zero means
13839 don't pad. */ 13841 don't pad. */
13840 field = 0; 13842 field = 0;
13841 while ((c = *this++) >= '0' && c <= '9') 13843 while ((c = *this++) >= '0' && c <= '9')
14331 register char *buf; 14333 register char *buf;
14332 int eol_flag; 14334 int eol_flag;
14333 { 14335 {
14334 Lisp_Object val; 14336 Lisp_Object val;
14335 int multibyte = !NILP (current_buffer->enable_multibyte_characters); 14337 int multibyte = !NILP (current_buffer->enable_multibyte_characters);
14336 unsigned char *eol_str; 14338 const unsigned char *eol_str;
14337 int eol_str_len; 14339 int eol_str_len;
14338 /* The EOL conversion we are using. */ 14340 /* The EOL conversion we are using. */
14339 Lisp_Object eoltype; 14341 Lisp_Object eoltype;
14340 14342
14341 val = Fget (coding_system, Qcoding_system); 14343 val = Fget (coding_system, Qcoding_system);
14383 eol_str_len = SBYTES (eoltype); 14385 eol_str_len = SBYTES (eoltype);
14384 } 14386 }
14385 else if (INTEGERP (eoltype) 14387 else if (INTEGERP (eoltype)
14386 && CHAR_VALID_P (XINT (eoltype), 0)) 14388 && CHAR_VALID_P (XINT (eoltype), 0))
14387 { 14389 {
14388 eol_str = (unsigned char *) alloca (MAX_MULTIBYTE_LENGTH); 14390 unsigned char *tmp = (unsigned char *) alloca (MAX_MULTIBYTE_LENGTH);
14389 eol_str_len = CHAR_STRING (XINT (eoltype), eol_str); 14391 eol_str_len = CHAR_STRING (XINT (eoltype), tmp);
14392 eol_str = tmp;
14390 } 14393 }
14391 else 14394 else
14392 { 14395 {
14393 eol_str = invalid_eol_type; 14396 eol_str = invalid_eol_type;
14394 eol_str_len = sizeof (invalid_eol_type) - 1; 14397 eol_str_len = sizeof (invalid_eol_type) - 1;