summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLouis Burda <quent.burda@gmail.com>2023-06-22 17:57:35 +0200
committerLouis Burda <quent.burda@gmail.com>2023-06-22 17:57:35 +0200
commit7041fcde68c2f9cafbece1650611ced0d29aed64 (patch)
tree12e1531ca02541f210393655bd2a0e8510d3a319
parent429a08d099c104950dfed8d7340cb1bc99831f6e (diff)
downloadhexdiff-7041fcde68c2f9cafbece1650611ced0d29aed64.tar.gz
hexdiff-7041fcde68c2f9cafbece1650611ced0d29aed64.zip
Add warning flags and LICENSE
-rw-r--r--LICENSE21
-rw-r--r--Makefile8
-rw-r--r--hexdiff.c12
3 files changed, 33 insertions, 8 deletions
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..361f116
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2023 Louis Burda
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/Makefile b/Makefile
index 1a85bee..54cdfdb 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,13 @@
PREFIX ?= /usr/local
BINDIR ?= /bin
-CFLAGS = -O2 -g
+CFLAGS = -Wunused-variable -Wunused-function -Wconversion
+
+ifeq ($(DEBUG),1)
+CFLAGS += -Og -g
+else
+CFLAGS += -O2
+endif
all: hexdiff
diff --git a/hexdiff.c b/hexdiff.c
index d414849..da9a9d8 100644
--- a/hexdiff.c
+++ b/hexdiff.c
@@ -12,7 +12,7 @@ struct file {
size_t buflen;
};
-const int equal_gradient[256] = {
+static const int equal_gradient[256] = {
[0] = 241,
[1 ... 31] = 242,
[32 ... 63] = 244,
@@ -25,7 +25,7 @@ const int equal_gradient[256] = {
[255] = 255,
};
-const int diff_gradient[256] = {
+static const int diff_gradient[256] = {
[0] = 52,
[1 ... 95] = 88,
[96 ... 159] = 124,
@@ -33,11 +33,11 @@ const int diff_gradient[256] = {
[224 ... 255] = 196,
};
-bool use_color;
-bool has_color;
+static bool use_color = true;
+static bool has_color = false;
static inline void
-color_byte(struct file *cur, struct file *other, int i)
+color_byte(struct file *cur, struct file *other, size_t i)
{
if (i >= other->buflen || cur->buf[i] != other->buf[i])
printf("\x1b[38:5:%um", diff_gradient[cur->buf[i]]);
@@ -62,8 +62,6 @@ main(int argc, const char **argv)
memset(&f1, 0, sizeof(f1));
memset(&f2, 0, sizeof(f2));
- has_color = false;
- use_color = true;
for (arg = &argv[1]; *arg; arg++) {
if (!strcmp(*arg, "-c")) {
use_color = true;