summaryrefslogtreecommitdiff
path: root/lib-src
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2011-03-21 09:40:05 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2011-03-21 09:40:05 -0700
commit3ef271f27f47dab138d431a72838d43a17102e27 (patch)
tree1c39e0b53f29906f531c6e37177d939d4391bfb5 /lib-src
parenta44c5709cecc6d21246c66651ea8c51201b8881a (diff)
downloademacs-3ef271f27f47dab138d431a72838d43a17102e27.tar.gz
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.
Diffstat (limited to 'lib-src')
-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 @@
2011-03-21 Paul Eggert <eggert@cs.ucla.edu>
+ 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.
+
update-game-score: fix bug with -r
* update-game-score.c (main): Don't set 'scores' to garbage when
-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)
* Original code by Sunichirou Sugou (1989)
* Rewritten by Anders Lindgren (1996)
*/
-static int prolog_pr (char *, char *);
+static size_t prolog_pr (char *, char *);
static void prolog_skip_comment (linebuffer *, FILE *);
-static int prolog_atom (char *, int);
+static size_t prolog_atom (char *, size_t);
static void
Prolog_functions (FILE *inf)
{
char *cp, *last;
- int len;
- int allocated;
+ size_t len;
+ size_t allocated;
allocated = 0;
len = 0;
@@ -5320,16 +5320,16 @@ prolog_skip_comment (linebuffer *plb, FILE *inf)
* Return the size of the name of the predicate or rule, or 0 if no
* header was found.
*/
-static int
+static size_t
prolog_pr (char *s, char *last)
/* Name of last clause. */
{
- int pos;
- int len;
+ size_t pos;
+ size_t len;
pos = prolog_atom (s, 0);
- if (pos < 1)
+ if (! pos)
return 0;
len = pos;
@@ -5339,7 +5339,7 @@ prolog_pr (char *s, char *last)
|| (s[pos] == '(' && (pos += 1))
|| (s[pos] == ':' && s[pos + 1] == '-' && (pos += 2)))
&& (last == NULL /* save only the first clause */
- || len != (int)strlen (last)
+ || len != strlen (last)
|| !strneq (s, last, len)))
{
make_tag (s, len, TRUE, s, pos, lineno, linecharno);
@@ -5351,17 +5351,17 @@ prolog_pr (char *s, char *last)
/*
* Consume a Prolog atom.
- * Return the number of bytes consumed, or -1 if there was an error.
+ * Return the number of bytes consumed, or 0 if there was an error.
*
* A prolog atom, in this context, could be one of:
* - An alphanumeric sequence, starting with a lower case letter.
* - A quoted arbitrary string. Single quotes can escape themselves.
* Backslash quotes everything.
*/
-static int
-prolog_atom (char *s, int pos)
+static size_t
+prolog_atom (char *s, size_t pos)
{
- int origpos;
+ size_t origpos;
origpos = pos;
@@ -5390,11 +5390,11 @@ prolog_atom (char *s, int pos)
}
else if (s[pos] == '\0')
/* Multiline quoted atoms are ignored. */
- return -1;
+ return 0;
else if (s[pos] == '\\')
{
if (s[pos+1] == '\0')
- return -1;
+ return 0;
pos += 2;
}
else
@@ -5403,7 +5403,7 @@ prolog_atom (char *s, int pos)
return pos - origpos;
}
else
- return -1;
+ return 0;
}