From 0f35e89f4e94b597aa6569fc0911cf579ce54bf7 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Sat, 24 Jun 2023 23:03:43 +0200 Subject: [PATCH] data diff now prints filenames if they fit in the header. Spiff filenames and other params is untouched --- CHANGELOG.md | 3 ++- client/src/cmddata.c | 19 ++++++++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1af068e19..3c11a1112 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,8 @@ All notable changes to this project will be documented in this file. This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log... ## [unreleased][unreleased] - - Change viewing MFC dump files - it now colors ACL + GPB bytes (@iceman1001) + - Changed `data diff` - to print filenames in header if it fits (@iceman1001) + - Changed viewing MFC dump files - it now colors ACL + GPB bytes (@iceman1001) - Added `hf mf supercard --furui` - now supports key recovery from Furui detection card. Thanks foxushka! (@iceman1001) - Added `hf topaz dump --ns` - now supports nosave param (@iceman1001) - Changed `hf topaz rdbl` - unified output (@iceman1001) diff --git a/client/src/cmddata.c b/client/src/cmddata.c index 9524cbc63..e1bf655e4 100644 --- a/client/src/cmddata.c +++ b/client/src/cmddata.c @@ -2939,7 +2939,7 @@ static int CmdDiff(const char *Cmd) { // "data diff -a fileA --cb\n" "data diff --fa fileA -b fileB\n" "data diff --fa fileA --fb fileB\n" - "data diff --ea --cb\n" +// "data diff --ea --cb\n" ); void *argtable[] = { @@ -3082,11 +3082,20 @@ static int CmdDiff(const char *Cmd) { if (inB == NULL) PrintAndLogEx(INFO, "inB null"); - int hdr_sln = (width * 4) + 2; + int hdr_sln = (width * 4) + 2; + char hdr0[300] = {0}; - char hdr0[200] = " # | " _CYAN_("a"); - memset(hdr0 + strlen(hdr0), ' ', hdr_sln - 2); - strcat(hdr0 + strlen(hdr0), "| " _CYAN_("b")); + int max_fn_space = (width * 5); + + if (fnlenA && fnlenB && (max_fn_space > fnlenA) && (max_fn_space > fnlenB)) { + snprintf(hdr0, sizeof(hdr0) - 1, " # | " _CYAN_("%.*s"), max_fn_space, filenameA); + memset(hdr0 + strlen(hdr0), ' ', hdr_sln - strlen(filenameA) - 1 ); + snprintf(hdr0 + strlen(hdr0), sizeof(hdr0) - 1 - strlen(hdr0), "| " _CYAN_("%.*s"), max_fn_space, filenameB); + } else { + strcat(hdr0, " # | " _CYAN_("a")); + memset(hdr0 + strlen(hdr0), ' ', hdr_sln - 2); + strcat(hdr0 + strlen(hdr0), "| " _CYAN_("b")); + } char hdr1[200] = "----+"; memset(hdr1 + strlen(hdr1), '-', hdr_sln);