hexdiff

Highlighted diff for binary files
git clone https://git.sinitax.com/sinitax/hexdiff
Log | Files | Refs | LICENSE | sfeed.txt

commit 7041fcde68c2f9cafbece1650611ced0d29aed64
parent 429a08d099c104950dfed8d7340cb1bc99831f6e
Author: Louis Burda <quent.burda@gmail.com>
Date:   Thu, 22 Jun 2023 17:57:35 +0200

Add warning flags and LICENSE

Diffstat:
ALICENSE | 21+++++++++++++++++++++
MMakefile | 8+++++++-
Mhexdiff.c | 12+++++-------
3 files changed, 33 insertions(+), 8 deletions(-)

diff --git a/LICENSE 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 @@ -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 @@ -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;