aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2011-03-21 09:40:05 -0700
committerPaul Eggert2011-03-21 09:40:05 -0700
commit3ef271f27f47dab138d431a72838d43a17102e27 (patch)
tree1c39e0b53f29906f531c6e37177d939d4391bfb5
parenta44c5709cecc6d21246c66651ea8c51201b8881a (diff)
downloademacs-3ef271f27f47dab138d431a72838d43a17102e27.tar.gz
emacs-3ef271f27f47dab138d431a72838d43a17102e27.zip
etags: In Prolog functions, don't assume int fits in size_t.
This avoids a warning with gcc -Wstrict-overflow. * etags.c (Prolog_functions, prolog_pr, prolog_atom): Use size_t, not int, to store sizes. (prolog_atom): Return 0, not -1, on error. All callers changed.
-rw-r--r--lib-src/ChangeLog6
-rw-r--r--lib-src/etags.c32
2 files changed, 22 insertions, 16 deletions
diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog
index a5d20af4263..cb847669deb 100644
--- a/lib-src/ChangeLog
+++ b/lib-src/ChangeLog
@@ -1,5 +1,11 @@
12011-03-21 Paul Eggert <eggert@cs.ucla.edu> 12011-03-21 Paul Eggert <eggert@cs.ucla.edu>
2 2
3 etags: In Prolog functions, don't assume int fits in size_t.
4 This avoids a warning with gcc -Wstrict-overflow.
5 * etags.c (Prolog_functions, prolog_pr, prolog_atom): Use size_t,
6 not int, to store sizes.
7 (prolog_atom): Return 0, not -1, on error. All callers changed.
8
3 update-game-score: fix bug with -r 9 update-game-score: fix bug with -r
4 * update-game-score.c (main): Don't set 'scores' to garbage when 10 * update-game-score.c (main): Don't set 'scores' to garbage when
5 -r is specified and scorecount != MAX_SCORES (Bug#8310). This bug 11 -r is specified and scorecount != MAX_SCORES (Bug#8310). This bug
diff --git a/lib-src/etags.c b/lib-src/etags.c
index 385e4cc9721..0c14a0d1663 100644
--- a/lib-src/etags.c
+++ b/lib-src/etags.c
@@ -5254,16 +5254,16 @@ HTML_labels (FILE *inf)
5254 * Original code by Sunichirou Sugou (1989) 5254 * Original code by Sunichirou Sugou (1989)
5255 * Rewritten by Anders Lindgren (1996) 5255 * Rewritten by Anders Lindgren (1996)
5256 */ 5256 */
5257static int prolog_pr (char *, char *); 5257static size_t prolog_pr (char *, char *);
5258static void prolog_skip_comment (linebuffer *, FILE *); 5258static void prolog_skip_comment (linebuffer *, FILE *);
5259static int prolog_atom (char *, int); 5259static size_t prolog_atom (char *, size_t);
5260 5260
5261static void 5261static void
5262Prolog_functions (FILE *inf) 5262Prolog_functions (FILE *inf)
5263{ 5263{
5264 char *cp, *last; 5264 char *cp, *last;
5265 int len; 5265 size_t len;
5266 int allocated; 5266 size_t allocated;
5267 5267
5268 allocated = 0; 5268 allocated = 0;
5269 len = 0; 5269 len = 0;
@@ -5320,16 +5320,16 @@ prolog_skip_comment (linebuffer *plb, FILE *inf)
5320 * Return the size of the name of the predicate or rule, or 0 if no 5320 * Return the size of the name of the predicate or rule, or 0 if no
5321 * header was found. 5321 * header was found.
5322 */ 5322 */
5323static int 5323static size_t
5324prolog_pr (char *s, char *last) 5324prolog_pr (char *s, char *last)
5325 5325
5326 /* Name of last clause. */ 5326 /* Name of last clause. */
5327{ 5327{
5328 int pos; 5328 size_t pos;
5329 int len; 5329 size_t len;
5330 5330
5331 pos = prolog_atom (s, 0); 5331 pos = prolog_atom (s, 0);
5332 if (pos < 1) 5332 if (! pos)
5333 return 0; 5333 return 0;
5334 5334
5335 len = pos; 5335 len = pos;
@@ -5339,7 +5339,7 @@ prolog_pr (char *s, char *last)
5339 || (s[pos] == '(' && (pos += 1)) 5339 || (s[pos] == '(' && (pos += 1))
5340 || (s[pos] == ':' && s[pos + 1] == '-' && (pos += 2))) 5340 || (s[pos] == ':' && s[pos + 1] == '-' && (pos += 2)))
5341 && (last == NULL /* save only the first clause */ 5341 && (last == NULL /* save only the first clause */
5342 || len != (int)strlen (last) 5342 || len != strlen (last)
5343 || !strneq (s, last, len))) 5343 || !strneq (s, last, len)))
5344 { 5344 {
5345 make_tag (s, len, TRUE, s, pos, lineno, linecharno); 5345 make_tag (s, len, TRUE, s, pos, lineno, linecharno);
@@ -5351,17 +5351,17 @@ prolog_pr (char *s, char *last)
5351 5351
5352/* 5352/*
5353 * Consume a Prolog atom. 5353 * Consume a Prolog atom.
5354 * Return the number of bytes consumed, or -1 if there was an error. 5354 * Return the number of bytes consumed, or 0 if there was an error.
5355 * 5355 *
5356 * A prolog atom, in this context, could be one of: 5356 * A prolog atom, in this context, could be one of:
5357 * - An alphanumeric sequence, starting with a lower case letter. 5357 * - An alphanumeric sequence, starting with a lower case letter.
5358 * - A quoted arbitrary string. Single quotes can escape themselves. 5358 * - A quoted arbitrary string. Single quotes can escape themselves.
5359 * Backslash quotes everything. 5359 * Backslash quotes everything.
5360 */ 5360 */
5361static int 5361static size_t
5362prolog_atom (char *s, int pos) 5362prolog_atom (char *s, size_t pos)
5363{ 5363{
5364 int origpos; 5364 size_t origpos;
5365 5365
5366 origpos = pos; 5366 origpos = pos;
5367 5367
@@ -5390,11 +5390,11 @@ prolog_atom (char *s, int pos)
5390 } 5390 }
5391 else if (s[pos] == '\0') 5391 else if (s[pos] == '\0')
5392 /* Multiline quoted atoms are ignored. */ 5392 /* Multiline quoted atoms are ignored. */
5393 return -1; 5393 return 0;
5394 else if (s[pos] == '\\') 5394 else if (s[pos] == '\\')
5395 { 5395 {
5396 if (s[pos+1] == '\0') 5396 if (s[pos+1] == '\0')
5397 return -1; 5397 return 0;
5398 pos += 2; 5398 pos += 2;
5399 } 5399 }
5400 else 5400 else
@@ -5403,7 +5403,7 @@ prolog_atom (char *s, int pos)
5403 return pos - origpos; 5403 return pos - origpos;
5404 } 5404 }
5405 else 5405 else
5406 return -1; 5406 return 0;
5407} 5407}
5408 5408
5409 5409