1
0
mirror of https://github.com/Interlisp/maiko.git synced 2026-02-11 18:45:10 +00:00

Fix lispcmp bytecmp (#211)

* Correct signedness of 2nd parameter of lispcmp().

* Be clear that comparison of characters in bytecmp is unsigned since GETBYTE returns unsigned char.

* Make bytecmp() and lispcmp() helper functions static and removed from mkatomdefs.h.

* If no BYTESWAP we need to include <string.h> for memcmp()

* Use (uint8_t) rather than (unsigned char) in bytecmp when comparing to GETBYTE()
This commit is contained in:
Nick Briggs
2021-01-25 09:57:55 -08:00
committed by GitHub
parent 987c38b465
commit 364420db88
2 changed files with 18 additions and 15 deletions

View File

@@ -31,6 +31,10 @@
*/
/**********************************************************************/
#ifndef BYTESWAP
#include <string.h>
#endif
#include <stdint.h>
#include "lispemul.h"
#include "adr68k.h"
#include "lsptypes.h"
@@ -128,6 +132,17 @@ DLword compute_lisp_hash(const char *char_base, DLword offset, DLword length, DL
} /* end compute_lisp_hash */
#ifdef BYTESWAP
int bytecmp(const char *char1, const char *char2, int len)
{
int index;
for (index = 0; index < len; index++) {
if (GETBYTE(char1++) != *(uint8_t *)(char2++)) return (0);
}
return (1);
}
#endif /* BYTESWAP */
/**********************************************************************/
/*
Func name : compare_chars
@@ -160,16 +175,14 @@ LispPTR compare_chars(register const char *char1, register const char *char2, re
}
} /* end compare_chars */
#ifdef BYTESWAP
int bytecmp(const char *char1, const char *char2, int len)
{
int lispcmp(const DLword *char1, const char *char2, int len) {
int index;
for (index = 0; index < len; index++) {
if (GETBYTE(char1++) != *(char2++)) return (0);
if (GETWORD(char1++) != GETBYTE(char2++)) return (0);
}
return (1);
}
#endif /* BYTESWAP */
/**********************************************************************/
/*
@@ -231,14 +244,6 @@ LispPTR compare_lisp_chars(register const char *char1, register const char *char
} /* end compare_lisp_chars */
int lispcmp(const DLword *char1, const unsigned char *char2, int len) {
int index;
for (index = 0; index < len; index++) {
if (GETWORD(char1++) != (unsigned char)GETBYTE(char2++)) return (0);
}
return (1);
}
/**********************************************************************/
/*
Func name : make_atom