aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2011-02-05 01:26:46 -0800
committerPaul Eggert2011-02-05 01:26:46 -0800
commit9bcaafce5351d270ac514e23cb69ff1a5fd35229 (patch)
tree00e222af83578d0fec4a453fb92e8ba89633a069 /src
parent03fc768bf7d870eff13ece309da2ce6e747aa5bf (diff)
downloademacs-9bcaafce5351d270ac514e23cb69ff1a5fd35229.tar.gz
emacs-9bcaafce5351d270ac514e23cb69ff1a5fd35229.zip
* xdisp.c: conform to C89 pointer rules
(store_mode_line_noprop, display_string, reseat_to_string): (c_string_pos, number_of_chars, message_dolog): (message_log_check_duplicate, set_message_1, store_mode_line_noprop): (display_mode_element, display_string): Switch between char * and unsigned char * to stay compatible wth C89 pointer rules.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog8
-rw-r--r--src/xdisp.c60
2 files changed, 39 insertions, 29 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 75113bb3c09..9765bdc18d8 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,13 @@
12011-02-05 Paul Eggert <eggert@cs.ucla.edu> 12011-02-05 Paul Eggert <eggert@cs.ucla.edu>
2 2
3 * xdisp.c: conform to C89 pointer rules
4 (store_mode_line_noprop, display_string, reseat_to_string):
5 (c_string_pos, number_of_chars, message_dolog):
6 (message_log_check_duplicate, set_message_1, store_mode_line_noprop):
7 (display_mode_element, display_string):
8 Switch between char * and unsigned char * to stay compatible wth
9 C89 pointer rules.
10
3 * regex.c: conform to C89 pointer rules 11 * regex.c: conform to C89 pointer rules
4 (re_wctype): Add cast, as C89 does not allow assigning between 12 (re_wctype): Add cast, as C89 does not allow assigning between
5 char * and unsigned char *. 13 char * and unsigned char *.
diff --git a/src/xdisp.c b/src/xdisp.c
index 5f86a594968..adf0d1b8745 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -773,7 +773,7 @@ static void reconsider_clip_changes (struct window *, struct buffer *);
773static int text_outside_line_unchanged_p (struct window *, 773static int text_outside_line_unchanged_p (struct window *,
774 EMACS_INT, EMACS_INT); 774 EMACS_INT, EMACS_INT);
775static void store_mode_line_noprop_char (char); 775static void store_mode_line_noprop_char (char);
776static int store_mode_line_noprop (const unsigned char *, int, int); 776static int store_mode_line_noprop (const char *, int, int);
777static void handle_stop (struct it *); 777static void handle_stop (struct it *);
778static void handle_stop_backwards (struct it *, EMACS_INT); 778static void handle_stop_backwards (struct it *, EMACS_INT);
779static int single_display_spec_intangible_p (Lisp_Object); 779static int single_display_spec_intangible_p (Lisp_Object);
@@ -831,7 +831,7 @@ static const char *decode_mode_spec (struct window *, int, int, int,
831static void display_menu_bar (struct window *); 831static void display_menu_bar (struct window *);
832static int display_count_lines (EMACS_INT, EMACS_INT, EMACS_INT, int, 832static int display_count_lines (EMACS_INT, EMACS_INT, EMACS_INT, int,
833 EMACS_INT *); 833 EMACS_INT *);
834static int display_string (const unsigned char *, Lisp_Object, Lisp_Object, 834static int display_string (const char *, Lisp_Object, Lisp_Object,
835 EMACS_INT, EMACS_INT, struct it *, int, int, int, int); 835 EMACS_INT, EMACS_INT, struct it *, int, int, int, int);
836static void compute_line_metrics (struct it *); 836static void compute_line_metrics (struct it *);
837static void run_redisplay_end_trigger_hook (struct it *); 837static void run_redisplay_end_trigger_hook (struct it *);
@@ -854,7 +854,7 @@ static int next_element_from_stretch (struct it *);
854static void load_overlay_strings (struct it *, EMACS_INT); 854static void load_overlay_strings (struct it *, EMACS_INT);
855static int init_from_display_pos (struct it *, struct window *, 855static int init_from_display_pos (struct it *, struct window *,
856 struct display_pos *); 856 struct display_pos *);
857static void reseat_to_string (struct it *, const unsigned char *, 857static void reseat_to_string (struct it *, const char *,
858 Lisp_Object, EMACS_INT, EMACS_INT, int, int); 858 Lisp_Object, EMACS_INT, EMACS_INT, int, int);
859static enum move_it_result 859static enum move_it_result
860 move_it_in_display_line_to (struct it *, EMACS_INT, int, 860 move_it_in_display_line_to (struct it *, EMACS_INT, int,
@@ -869,8 +869,8 @@ static int forward_to_next_line_start (struct it *, int *);
869static struct text_pos string_pos_nchars_ahead (struct text_pos, 869static struct text_pos string_pos_nchars_ahead (struct text_pos,
870 Lisp_Object, EMACS_INT); 870 Lisp_Object, EMACS_INT);
871static struct text_pos string_pos (EMACS_INT, Lisp_Object); 871static struct text_pos string_pos (EMACS_INT, Lisp_Object);
872static struct text_pos c_string_pos (EMACS_INT, const unsigned char *, int); 872static struct text_pos c_string_pos (EMACS_INT, const char *, int);
873static EMACS_INT number_of_chars (const unsigned char *, int); 873static EMACS_INT number_of_chars (const char *, int);
874static void compute_stop_pos (struct it *); 874static void compute_stop_pos (struct it *);
875static void compute_string_pos (struct text_pos *, struct text_pos, 875static void compute_string_pos (struct text_pos *, struct text_pos,
876 Lisp_Object); 876 Lisp_Object);
@@ -1383,7 +1383,7 @@ string_pos (EMACS_INT charpos, Lisp_Object string)
1383 means recognize multibyte characters. */ 1383 means recognize multibyte characters. */
1384 1384
1385static struct text_pos 1385static struct text_pos
1386c_string_pos (EMACS_INT charpos, const unsigned char *s, int multibyte_p) 1386c_string_pos (EMACS_INT charpos, const char *s, int multibyte_p)
1387{ 1387{
1388 struct text_pos pos; 1388 struct text_pos pos;
1389 1389
@@ -1397,7 +1397,7 @@ c_string_pos (EMACS_INT charpos, const unsigned char *s, int multibyte_p)
1397 SET_TEXT_POS (pos, 0, 0); 1397 SET_TEXT_POS (pos, 0, 0);
1398 while (charpos--) 1398 while (charpos--)
1399 { 1399 {
1400 string_char_and_length (s, &len); 1400 string_char_and_length ((const unsigned char *) s, &len);
1401 s += len; 1401 s += len;
1402 CHARPOS (pos) += 1; 1402 CHARPOS (pos) += 1;
1403 BYTEPOS (pos) += len; 1403 BYTEPOS (pos) += len;
@@ -1414,7 +1414,7 @@ c_string_pos (EMACS_INT charpos, const unsigned char *s, int multibyte_p)
1414 non-zero means recognize multibyte characters. */ 1414 non-zero means recognize multibyte characters. */
1415 1415
1416static EMACS_INT 1416static EMACS_INT
1417number_of_chars (const unsigned char *s, int multibyte_p) 1417number_of_chars (const char *s, int multibyte_p)
1418{ 1418{
1419 EMACS_INT nchars; 1419 EMACS_INT nchars;
1420 1420
@@ -1422,7 +1422,7 @@ number_of_chars (const unsigned char *s, int multibyte_p)
1422 { 1422 {
1423 EMACS_INT rest = strlen (s); 1423 EMACS_INT rest = strlen (s);
1424 int len; 1424 int len;
1425 unsigned char *p = (unsigned char *) s; 1425 const unsigned char *p = (const unsigned char *) s;
1426 1426
1427 for (nchars = 0; rest > 0; ++nchars) 1427 for (nchars = 0; rest > 0; ++nchars)
1428 { 1428 {
@@ -3172,7 +3172,7 @@ handle_fontified_prop (struct it *it)
3172 specbind (Qfontification_functions, Qnil); 3172 specbind (Qfontification_functions, Qnil);
3173 3173
3174 xassert (it->end_charpos == ZV); 3174 xassert (it->end_charpos == ZV);
3175 3175
3176 if (!CONSP (val) || EQ (XCAR (val), Qlambda)) 3176 if (!CONSP (val) || EQ (XCAR (val), Qlambda))
3177 safe_call1 (val, pos); 3177 safe_call1 (val, pos);
3178 else 3178 else
@@ -3218,7 +3218,7 @@ handle_fontified_prop (struct it *it)
3218 as is/was done in grep.el where some escapes sequences are turned 3218 as is/was done in grep.el where some escapes sequences are turned
3219 into face properties (bug#7876). */ 3219 into face properties (bug#7876). */
3220 it->end_charpos = ZV; 3220 it->end_charpos = ZV;
3221 3221
3222 /* Return HANDLED_RECOMPUTE_PROPS only if function fontified 3222 /* Return HANDLED_RECOMPUTE_PROPS only if function fontified
3223 something. This avoids an endless loop if they failed to 3223 something. This avoids an endless loop if they failed to
3224 fontify the text for which reason ever. */ 3224 fontify the text for which reason ever. */
@@ -5442,7 +5442,7 @@ reseat_1 (struct it *it, struct text_pos pos, int set_stop_p)
5442 calling this function. */ 5442 calling this function. */
5443 5443
5444static void 5444static void
5445reseat_to_string (struct it *it, const unsigned char *s, Lisp_Object string, 5445reseat_to_string (struct it *it, const char *s, Lisp_Object string,
5446 EMACS_INT charpos, EMACS_INT precision, int field_width, 5446 EMACS_INT charpos, EMACS_INT precision, int field_width,
5447 int multibyte) 5447 int multibyte)
5448{ 5448{
@@ -5474,7 +5474,7 @@ reseat_to_string (struct it *it, const unsigned char *s, Lisp_Object string,
5474 } 5474 }
5475 else 5475 else
5476 { 5476 {
5477 it->s = s; 5477 it->s = (const unsigned char *) s;
5478 it->string = Qnil; 5478 it->string = Qnil;
5479 5479
5480 /* Note that we use IT->current.pos, not it->current.string_pos, 5480 /* Note that we use IT->current.pos, not it->current.string_pos,
@@ -7884,6 +7884,8 @@ message_log_maybe_newline (void)
7884void 7884void
7885message_dolog (const char *m, EMACS_INT nbytes, int nlflag, int multibyte) 7885message_dolog (const char *m, EMACS_INT nbytes, int nlflag, int multibyte)
7886{ 7886{
7887 const unsigned char *msg = (const unsigned char *) m;
7888
7887 if (!NILP (Vmemory_full)) 7889 if (!NILP (Vmemory_full))
7888 return; 7890 return;
7889 7891
@@ -7934,7 +7936,7 @@ message_dolog (const char *m, EMACS_INT nbytes, int nlflag, int multibyte)
7934 for the *Message* buffer. */ 7936 for the *Message* buffer. */
7935 for (i = 0; i < nbytes; i += char_bytes) 7937 for (i = 0; i < nbytes; i += char_bytes)
7936 { 7938 {
7937 c = string_char_and_length (m + i, &char_bytes); 7939 c = string_char_and_length (msg + i, &char_bytes);
7938 work[0] = (ASCII_CHAR_P (c) 7940 work[0] = (ASCII_CHAR_P (c)
7939 ? c 7941 ? c
7940 : multibyte_char_to_unibyte (c, Qnil)); 7942 : multibyte_char_to_unibyte (c, Qnil));
@@ -7946,7 +7948,6 @@ message_dolog (const char *m, EMACS_INT nbytes, int nlflag, int multibyte)
7946 { 7948 {
7947 EMACS_INT i; 7949 EMACS_INT i;
7948 int c, char_bytes; 7950 int c, char_bytes;
7949 unsigned char *msg = (unsigned char *) m;
7950 unsigned char str[MAX_MULTIBYTE_LENGTH]; 7951 unsigned char str[MAX_MULTIBYTE_LENGTH];
7951 /* Convert a single-byte string to multibyte 7952 /* Convert a single-byte string to multibyte
7952 for the *Message* buffer. */ 7953 for the *Message* buffer. */
@@ -7959,13 +7960,13 @@ message_dolog (const char *m, EMACS_INT nbytes, int nlflag, int multibyte)
7959 } 7960 }
7960 } 7961 }
7961 else if (nbytes) 7962 else if (nbytes)
7962 insert_1 (m, nbytes, 1, 0, 0); 7963 insert_1 (msg, nbytes, 1, 0, 0);
7963 7964
7964 if (nlflag) 7965 if (nlflag)
7965 { 7966 {
7966 EMACS_INT this_bol, this_bol_byte, prev_bol, prev_bol_byte; 7967 EMACS_INT this_bol, this_bol_byte, prev_bol, prev_bol_byte;
7967 int dup; 7968 int dup;
7968 insert_1 ("\n", 1, 1, 0, 0); 7969 insert_1 ((const unsigned char *) "\n", 1, 1, 0, 0);
7969 7970
7970 scan_newline (Z, Z_BYTE, BEG, BEG_BYTE, -2, 0); 7971 scan_newline (Z, Z_BYTE, BEG, BEG_BYTE, -2, 0);
7971 this_bol = PT; 7972 this_bol = PT;
@@ -7995,7 +7996,7 @@ message_dolog (const char *m, EMACS_INT nbytes, int nlflag, int multibyte)
7995 sprintf (dupstr, " [%d times]", dup); 7996 sprintf (dupstr, " [%d times]", dup);
7996 duplen = strlen (dupstr); 7997 duplen = strlen (dupstr);
7997 TEMP_SET_PT_BOTH (Z - 1, Z_BYTE - 1); 7998 TEMP_SET_PT_BOTH (Z - 1, Z_BYTE - 1);
7998 insert_1 (dupstr, duplen, 1, 0, 1); 7999 insert_1 ((unsigned char *) dupstr, duplen, 1, 0, 1);
7999 } 8000 }
8000 } 8001 }
8001 } 8002 }
@@ -8079,7 +8080,7 @@ message_log_check_duplicate (EMACS_INT prev_bol, EMACS_INT prev_bol_byte,
8079 int n = 0; 8080 int n = 0;
8080 while (*p1 >= '0' && *p1 <= '9') 8081 while (*p1 >= '0' && *p1 <= '9')
8081 n = n * 10 + *p1++ - '0'; 8082 n = n * 10 + *p1++ - '0';
8082 if (strncmp (p1, " times]\n", 8) == 0) 8083 if (strncmp ((char *) p1, " times]\n", 8) == 0)
8083 return n+1; 8084 return n+1;
8084 } 8085 }
8085 return 0; 8086 return 0;
@@ -9154,6 +9155,7 @@ static int
9154set_message_1 (EMACS_INT a1, Lisp_Object a2, EMACS_INT nbytes, EMACS_INT multibyte_p) 9155set_message_1 (EMACS_INT a1, Lisp_Object a2, EMACS_INT nbytes, EMACS_INT multibyte_p)
9155{ 9156{
9156 const char *s = (const char *) a1; 9157 const char *s = (const char *) a1;
9158 const unsigned char *msg = (const unsigned char *) s;
9157 Lisp_Object string = a2; 9159 Lisp_Object string = a2;
9158 9160
9159 /* Change multibyteness of the echo buffer appropriately. */ 9161 /* Change multibyteness of the echo buffer appropriately. */
@@ -9196,7 +9198,7 @@ set_message_1 (EMACS_INT a1, Lisp_Object a2, EMACS_INT nbytes, EMACS_INT multiby
9196 /* Convert a multibyte string to single-byte. */ 9198 /* Convert a multibyte string to single-byte. */
9197 for (i = 0; i < nbytes; i += n) 9199 for (i = 0; i < nbytes; i += n)
9198 { 9200 {
9199 c = string_char_and_length (s + i, &n); 9201 c = string_char_and_length (msg + i, &n);
9200 work[0] = (ASCII_CHAR_P (c) 9202 work[0] = (ASCII_CHAR_P (c)
9201 ? c 9203 ? c
9202 : multibyte_char_to_unibyte (c, Qnil)); 9204 : multibyte_char_to_unibyte (c, Qnil));
@@ -9209,7 +9211,6 @@ set_message_1 (EMACS_INT a1, Lisp_Object a2, EMACS_INT nbytes, EMACS_INT multiby
9209 /* Convert from single-byte to multi-byte. */ 9211 /* Convert from single-byte to multi-byte. */
9210 EMACS_INT i; 9212 EMACS_INT i;
9211 int c, n; 9213 int c, n;
9212 const unsigned char *msg = (const unsigned char *) s;
9213 unsigned char str[MAX_MULTIBYTE_LENGTH]; 9214 unsigned char str[MAX_MULTIBYTE_LENGTH];
9214 9215
9215 /* Convert a single-byte string to multibyte. */ 9216 /* Convert a single-byte string to multibyte. */
@@ -9222,7 +9223,7 @@ set_message_1 (EMACS_INT a1, Lisp_Object a2, EMACS_INT nbytes, EMACS_INT multiby
9222 } 9223 }
9223 } 9224 }
9224 else 9225 else
9225 insert_1 (s, nbytes, 1, 0, 0); 9226 insert_1 (msg, nbytes, 1, 0, 0);
9226 } 9227 }
9227 9228
9228 return 0; 9229 return 0;
@@ -9517,7 +9518,7 @@ store_mode_line_noprop_char (char c)
9517 9518
9518 9519
9519/* Store part of a frame title in mode_line_noprop_buf, beginning at 9520/* Store part of a frame title in mode_line_noprop_buf, beginning at
9520 mode_line_noprop_ptr. STR is the string to store. Do not copy 9521 mode_line_noprop_ptr. STRING is the string to store. Do not copy
9521 characters that yield more columns than PRECISION; PRECISION <= 0 9522 characters that yield more columns than PRECISION; PRECISION <= 0
9522 means copy the whole string. Pad with spaces until FIELD_WIDTH 9523 means copy the whole string. Pad with spaces until FIELD_WIDTH
9523 number of characters have been copied; FIELD_WIDTH <= 0 means don't 9524 number of characters have been copied; FIELD_WIDTH <= 0 means don't
@@ -9525,13 +9526,14 @@ store_mode_line_noprop_char (char c)
9525 frame title. */ 9526 frame title. */
9526 9527
9527static int 9528static int
9528store_mode_line_noprop (const unsigned char *str, int field_width, int precision) 9529store_mode_line_noprop (const char *string, int field_width, int precision)
9529{ 9530{
9531 const unsigned char *str = (const unsigned char *) string;
9530 int n = 0; 9532 int n = 0;
9531 EMACS_INT dummy, nbytes; 9533 EMACS_INT dummy, nbytes;
9532 9534
9533 /* Copy at most PRECISION chars from STR. */ 9535 /* Copy at most PRECISION chars from STR. */
9534 nbytes = strlen (str); 9536 nbytes = strlen (string);
9535 n += c_string_width (str, nbytes, precision, &dummy, &nbytes); 9537 n += c_string_width (str, nbytes, precision, &dummy, &nbytes);
9536 while (nbytes--) 9538 while (nbytes--)
9537 store_mode_line_noprop_char (*str++); 9539 store_mode_line_noprop_char (*str++);
@@ -18396,7 +18398,7 @@ display_mode_element (struct it *it, int depth, int field_width, int precision,
18396 { 18398 {
18397 case MODE_LINE_NOPROP: 18399 case MODE_LINE_NOPROP:
18398 case MODE_LINE_TITLE: 18400 case MODE_LINE_TITLE:
18399 n += store_mode_line_noprop (SDATA (elt), -1, prec); 18401 n += store_mode_line_noprop (SSDATA (elt), -1, prec);
18400 break; 18402 break;
18401 case MODE_LINE_STRING: 18403 case MODE_LINE_STRING:
18402 n += store_mode_line_string (NULL, elt, 1, 0, prec, Qnil); 18404 n += store_mode_line_string (NULL, elt, 1, 0, prec, Qnil);
@@ -18440,7 +18442,7 @@ display_mode_element (struct it *it, int depth, int field_width, int precision,
18440 { 18442 {
18441 case MODE_LINE_NOPROP: 18443 case MODE_LINE_NOPROP:
18442 case MODE_LINE_TITLE: 18444 case MODE_LINE_TITLE:
18443 n += store_mode_line_noprop (SDATA (elt) + last_offset, 0, prec); 18445 n += store_mode_line_noprop (SSDATA (elt) + last_offset, 0, prec);
18444 break; 18446 break;
18445 case MODE_LINE_STRING: 18447 case MODE_LINE_STRING:
18446 { 18448 {
@@ -18495,7 +18497,7 @@ display_mode_element (struct it *it, int depth, int field_width, int precision,
18495 { 18497 {
18496 int multibyte; 18498 int multibyte;
18497 EMACS_INT bytepos, charpos; 18499 EMACS_INT bytepos, charpos;
18498 const unsigned char *spec; 18500 const char *spec;
18499 Lisp_Object string; 18501 Lisp_Object string;
18500 18502
18501 bytepos = percent_position; 18503 bytepos = percent_position;
@@ -19746,7 +19748,7 @@ display_count_lines (EMACS_INT start, EMACS_INT start_byte,
19746 Value is the number of columns displayed. */ 19748 Value is the number of columns displayed. */
19747 19749
19748static int 19750static int
19749display_string (const unsigned char *string, Lisp_Object lisp_string, Lisp_Object face_string, 19751display_string (const char *string, Lisp_Object lisp_string, Lisp_Object face_string,
19750 EMACS_INT face_string_pos, EMACS_INT start, struct it *it, 19752 EMACS_INT face_string_pos, EMACS_INT start, struct it *it,
19751 int field_width, int precision, int max_x, int multibyte) 19753 int field_width, int precision, int max_x, int multibyte)
19752{ 19754{