]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - util.c
Mask out the math constant precedence stuff unless -fftepp-mathdefs
[xonotic/gmqcc.git] / util.c
diff --git a/util.c b/util.c
index 4253bd3cd53c18ed66575f02bc2ae6bae7dafd02..84be6f31cc18cf89a542c6f9fda129f45b5f9cab 100644 (file)
--- a/util.c
+++ b/util.c
@@ -22,6 +22,7 @@
  * SOFTWARE.
  */
 #define GMQCC_PLATFORM_HEADER
+#include <stdlib.h>
 #include "gmqcc.h"
 #include "platform.h"
 
@@ -456,11 +457,11 @@ static const uint16_t util_crc16_table[8][256] = {{
 }};
 
 /* Non - Reflected */
-uint16_t util_crc16(uint16_t current, const char *k, size_t len) {
+uint16_t util_crc16(uint16_t current, const char *GMQCC_RESTRICT k, size_t len) {
     register uint16_t h = current;
 
     /* don't load twice */
-    uint8_t *GMQCC_RESTRICT data = (uint8_t *GMQCC_RESTRICT)k;
+    const uint8_t *GMQCC_RESTRICT data = (const uint8_t *GMQCC_RESTRICT)k;
     size_t n;
 
     /* deal with the first bytes as bytes until we reach an 8 byte boundary */
@@ -482,8 +483,12 @@ uint16_t util_crc16(uint16_t current, const char *k, size_t len) {
             SELECT_DATA(1) ^
             SELECT_DATA(0);
         data += 8;
+        len  -= 8;
     }
 
+    #undef SELECT_BULK
+    #undef SELECT_DATA
+
     /* deal with the rest with the byte method */
     for (n = len & 7; n; --n)
         h = (uint16_t)(h << 8) ^ (*util_crc16_table)[(h >> 8) ^ *data++];
@@ -495,7 +500,7 @@ uint16_t util_crc16(uint16_t current, const char *k, size_t len) {
  * modifier is the match to make and the transposition from it, while add is the upper-value that determines the
  * transposition from uppercase to lower case.
  */
-static GMQCC_INLINE size_t util_strtransform(const char *in, char *out, size_t outsz, const char *mod, int add) {
+static size_t util_strtransform(const char *in, char *out, size_t outsz, const char *mod, int add) {
     size_t sz = 1;
     for (; *in && sz < outsz; ++in, ++out, ++sz) {
         *out = (*in == mod[0])