Commit graph

1 commit

Author SHA1 Message Date
Rémi Verschelde c5f830d6b9 Split thirdparty smaz.c out of compressed_translation.cpp
Code comes from 150e125cba/smaz.c

With a small modification to match Godot expectations:
```
diff --git a/thirdparty/core/smaz.c b/thirdparty/core/smaz.c
index 9b1ebc2..555dfea 100644
--- a/thirdparty/core/smaz.c
+++ b/thirdparty/core/smaz.c
@@ -14,7 +14,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 #include <string.h>

 /* Our compression codebook, used for compression */
-static char *Smaz_cb[241] = {
+static const char *Smaz_cb[241] = {
 "\002s,\266", "\003had\232\002leW", "\003on \216", "", "\001yS",
 "\002ma\255\002li\227", "\003or \260", "", "\002ll\230\003s t\277",
 "\004fromg\002mel", "", "\003its\332", "\001z\333", "\003ingF", "\001>\336",
@@ -89,7 +89,7 @@ static char *Smaz_rcb[254] = {
 "e, ", " it", "whi", " ma", "ge", "x", "e c", "men", ".com"
 };

-int smaz_compress(char *in, int inlen, char *out, int outlen) {
+int smaz_compress(const char *in, int inlen, char *out, int outlen) {
     unsigned int h1,h2,h3=0;
     int verblen = 0, _outlen = outlen;
     char verb[256], *_out = out;
@@ -167,7 +167,7 @@ out:
     return out-_out;
 }

-int smaz_decompress(char *in, int inlen, char *out, int outlen) {
+int smaz_decompress(const char *in, int inlen, char *out, int outlen) {
     unsigned char *c = (unsigned char*) in;
     char *_out = out;
     int _outlen = outlen;
@@ -192,7 +192,7 @@ int smaz_decompress(char *in, int inlen, char *out, int outlen) {
             inlen -= 2+len;
         } else {
             /* Codebook entry */
-            char *s = Smaz_rcb[*c];
+            const char *s = Smaz_rcb[*c];
             int len = strlen(s);

             if (outlen < len) return _outlen+1;
diff --git a/thirdparty/core/smaz.h b/thirdparty/core/smaz.h
index a547d89..a9d8a33 100644
--- a/thirdparty/core/smaz.h
+++ b/thirdparty/core/smaz.h
@@ -14,7 +14,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 #ifndef _SMAZ_H
 #define _SMAZ_H

-int smaz_compress(char *in, int inlen, char *out, int outlen);
-int smaz_decompress(char *in, int inlen, char *out, int outlen);
+int smaz_compress(const char *in, int inlen, char *out, int outlen);
+int smaz_decompress(const char *in, int inlen, char *out, int outlen);

 #endif
```
2017-04-28 21:19:24 +02:00