summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2002-09-28 16:32:23 +0000
committerJim Meyering <jim@meyering.net>2002-09-28 16:32:23 +0000
commit16b4b4f86171fc78f894f4e4dbbe1e70914c533a (patch)
tree912bf98edf1b756b32754f0d042253559b1badd4 /src
parent106025744633376a086a7fa2ab8f32a454840ef2 (diff)
downloadcoreutils-16b4b4f86171fc78f894f4e4dbbe1e70914c533a.tar.xz
(begfield, limfield): Rearrange comparisons to avoid compiler warnings.
(fillbuf, keycompare): Cast literal `-1' to size_t in comparisons, to avoid compiler warnings.
Diffstat (limited to 'src')
-rw-r--r--src/sort.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/sort.c b/src/sort.c
index c8230fbed..9ba085dc5 100644
--- a/src/sort.c
+++ b/src/sort.c
@@ -799,7 +799,7 @@ begfield (const struct line *line, const struct keyfield *key)
while (ptr < lim && blanks[UCHAR (*ptr)])
++ptr;
- if (schar < lim - ptr)
+ if (ptr + schar <= lim)
ptr += schar;
else
ptr = lim;
@@ -902,7 +902,7 @@ limfield (const struct line *line, const struct keyfield *key)
++ptr;
/* Advance PTR by ECHAR (if possible), but no further than LIM. */
- if (echar < lim - ptr)
+ if (ptr + echar < lim)
ptr += echar;
else
ptr = lim;
@@ -992,9 +992,11 @@ fillbuf (struct buffer *buf, register FILE *fp, char const *file)
{
/* Precompute the position of the first key for
efficiency. */
- line->keylim = key->eword == -1 ? p : limfield (line, key);
+ line->keylim = (key->eword == (size_t) -1
+ ? p
+ : limfield (line, key));
- if (key->sword != -1)
+ if (key->sword != (size_t) -1)
line->keybeg = begfield (line, key);
else
{
@@ -1464,12 +1466,12 @@ keycompare (const struct line *a, const struct line *b)
break;
/* Find the beginning and limit of the next field. */
- if (key->eword != -1)
+ if (key->eword != (size_t) -1)
lima = limfield (a, key), limb = limfield (b, key);
else
lima = a->text + a->length - 1, limb = b->text + b->length - 1;
- if (key->sword != -1)
+ if (key->sword != (size_t) -1)
texta = begfield (a, key), textb = begfield (b, key);
else
{