Skip to content

Commit 74012d8

Browse files
committed
Small adjustments
1 parent c4128d1 commit 74012d8

File tree

2 files changed

+26
-9
lines changed

2 files changed

+26
-9
lines changed

src/app/InfoPrinter.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ void InfoPrinter::processEvent(const Event& evt)
156156
ss << "{ \"type\":\"" << evt.getTypeAsString() << "\"";
157157

158158
if (nbTokens > 1)
159-
ss << ", \"bsVersion\":" << tokens[1];
159+
ss << ", \"bsversion\":" << tokens[1];
160160

161161
if (nbTokens > 2)
162162
ss << ", \"checksize\":" << tokens[2];
@@ -165,10 +165,10 @@ void InfoPrinter::processEvent(const Event& evt)
165165
ss << ", \"blocksize\":" << tokens[3];
166166

167167
if (nbTokens > 4)
168-
ss << ", \"entropy\":" << (tokens[4] == "" ? "none" : "\"" + tokens[4] + "\"");
168+
ss << ", \"entropy\":" << (tokens[4] == "" ? "\"NONE\"" : "\"" + tokens[4] + "\"");
169169

170170
if (nbTokens > 5)
171-
ss << ", \"transforms\":" << (tokens[5] == "" ? "none" : "\"" + tokens[5] + "\"");
171+
ss << ", \"transforms\":" << (tokens[5] == "" ? "\"NONE\"" : "\"" + tokens[5] + "\"");
172172

173173
if (nbTokens > 6)
174174
ss << ", \"compressed\":" << (tokens[6] == "" ? "N/A" : tokens[6]);

src/app/Kanzi.cpp

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ void printHelp(Printer& log, const string& mode, bool showHeader)
106106

107107
if (mode != "y") {
108108
log.println(" -o, --output=<outputName>", true);
109-
109+
110110
if (mode == "c") {
111111
log.println(" Optional name of the output file or directory (defaults to", true);
112112
log.println(" <inputName.knz> if input is <inputName> or 'stdout' if input is 'stdin').", true);
@@ -343,6 +343,11 @@ void printHeader(Printer& log, int verbose, bool& showHeader)
343343
ss << "Warning: ignoring option [" << opt << "]. Only applicable in decompression mode."; \
344344
log.println(ss.str(), verbose > 0)
345345

346+
#define WARNING_OPT_INVALID(opt) \
347+
stringstream ss; \
348+
ss << "Warning: ignoring option [" << opt << "]. Not applicable in this mode."; \
349+
log.println(ss.str(), verbose > 0)
350+
346351
#define WARNING_OPT_DUPLICATE(opt, val) \
347352
stringstream ss; \
348353
ss << "Warning: ignoring duplicate option [" << opt << "]: " << val;\
@@ -488,7 +493,7 @@ int processCommandLine(int argc, const char* argv[], Context& map, Printer& log)
488493
}
489494
else {
490495
if (mode == "y") {
491-
log.println("Warning: ignoring option [" + outputName + "]. Only applicable in compression or decompression mode.", verbose > 0);
496+
WARNING_OPT_INVALID(outputName);
492497
}
493498
else {
494499
string str = outputName;
@@ -538,7 +543,8 @@ int processCommandLine(int argc, const char* argv[], Context& map, Printer& log)
538543
}
539544

540545
if (mode == "y") {
541-
WARNING_OPT_COMP_ONLY(arg);
546+
WARNING_OPT_INVALID(arg);
547+
ctx = - 1;
542548
continue;
543549
}
544550

@@ -590,12 +596,14 @@ int processCommandLine(int argc, const char* argv[], Context& map, Printer& log)
590596
WARNING_OPT_DUPLICATE(arg, "true");
591597
}
592598

599+
ctx = -1;
600+
593601
if (mode == "y") {
594-
WARNING_OPT_COMP_ONLY(arg);
602+
WARNING_OPT_INVALID(arg);
595603
continue;
596604
}
605+
597606
remove = 1;
598-
ctx = -1;
599607
continue;
600608
}
601609

@@ -662,11 +670,20 @@ int processCommandLine(int argc, const char* argv[], Context& map, Printer& log)
662670

663671
if (outputName != "") {
664672
string msg = (ctx == ARG_IDX_OUTPUT) ? CMD_LINE_ARGS[ctx] : arg;
673+
674+
if (mode == "y") {
675+
WARNING_OPT_INVALID(msg);
676+
ctx = -1;
677+
continue;
678+
}
679+
665680
WARNING_OPT_DUPLICATE(msg, arg);
666681
}
667682
else {
668683
if (mode == "y") {
669-
WARNING_OPT_COMP_ONLY(arg);
684+
string msg = (ctx == ARG_IDX_OUTPUT) ? CMD_LINE_ARGS[ctx] : arg;
685+
WARNING_OPT_INVALID(msg);
686+
ctx = -1;
670687
continue;
671688
}
672689

0 commit comments

Comments
 (0)