nightmaremail

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 11047ed0a85a6afa5d147e3c5080326cfe4a5fe0
parent 8759bd432bd7154d537e78284a3771668829e9c3
Author: Rolf Eike Beer <eike@sf-mail.de>
Date:   Fri, 12 Jul 2019 19:16:54 +0200

get rid of byte_diff() and use the default memcmp() instead

This one is actually a bit special: byte_diff() was used only for implementing
the byte_equal() macro and had only one direct callsite. And this in turn should
have been calling byte_equal(), too. When touching it anyway change it to
memcmp() directly.

Diffstat:
MMakefile | 8++------
MTARGETS | 1-
Mbyte.h | 3+--
Dbyte_diff.c | 16----------------
Mcase.3 | 2--
5 files changed, 3 insertions(+), 27 deletions(-)

diff --git a/Makefile b/Makefile @@ -251,10 +251,6 @@ byte_cr.o: \ compile byte_cr.c byte.h ./compile byte_cr.c -byte_diff.o: \ -compile byte_diff.c byte.h - ./compile byte_diff.c - byte_rchr.o: \ compile byte_rchr.c byte.h ./compile byte_rchr.c @@ -1776,11 +1772,11 @@ scan.h fmt.h str.a: \ makelib str_cpy.o str_chr.o \ -str_rchr.o str_start.o byte_chr.o byte_rchr.o byte_diff.o byte_copy.o \ +str_rchr.o str_start.o byte_chr.o byte_rchr.o byte_copy.o \ byte_cr.o byte_zero.o ./makelib str.a str_cpy.o \ str_chr.o str_rchr.o str_start.o byte_chr.o byte_rchr.o \ - byte_diff.o byte_copy.o byte_cr.o byte_zero.o + byte_copy.o byte_cr.o byte_zero.o str_chr.o: \ compile str_chr.c str.h diff --git a/TARGETS b/TARGETS @@ -97,7 +97,6 @@ str_rchr.o str_start.o byte_chr.o byte_rchr.o -byte_diff.o byte_copy.o byte_cr.o byte_zero.o diff --git a/byte.h b/byte.h @@ -5,9 +5,8 @@ extern unsigned int byte_chr(); extern unsigned int byte_rchr(); extern void byte_copy(); extern void byte_copyr(); -extern int byte_diff(); extern void byte_zero(); -#define byte_equal(s,n,t) (!byte_diff((s),(n),(t))) +#define byte_equal(s,n,t) (memcmp((s),(t),(n)) == 0) #endif diff --git a/byte_diff.c b/byte_diff.c @@ -1,16 +0,0 @@ -#include "byte.h" - -int byte_diff(s,n,t) -register char *s; -register unsigned int n; -register char *t; -{ - for (;;) { - if (!n) return 0; if (*s != *t) break; ++s; ++t; --n; - if (!n) return 0; if (*s != *t) break; ++s; ++t; --n; - if (!n) return 0; if (*s != *t) break; ++s; ++t; --n; - if (!n) return 0; if (*s != *t) break; ++s; ++t; --n; - } - return ((int)(unsigned int)(unsigned char) *s) - - ((int)(unsigned int)(unsigned char) *t); -} diff --git a/case.3 b/case.3 @@ -93,6 +93,4 @@ case-independent networking protocols. All comparisons are performed on unsigned bytes. .SH "SEE ALSO" -byte_diff(3), -byte_equal(3), str_start(3)