Skip to content

Commit ebf745d

Browse files
committed
Pedantic adjustments
- make command line help message a bit clearer - suppress fussy CppCheck warning
1 parent ddbe177 commit ebf745d

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

SAP-Report-Source-Decompressor/sap-reposrc-decompressor.cpp

+10-8
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ int main(int argc, char *argv[]) {
5353
char cuc[] = "-u"; // Unicode parameter
5454
int funicode; // Unicode flag
5555

56-
char nuc[] = "-n"; // Non-UC SAP System parameter
57-
int fnuc; // Non-UC SAP System flag
56+
char nuc[] = "-n"; // Non-Unicode SAP system parameter
57+
int fnuc; // Non-Unicode SAP system flag
5858

5959
unsigned char cbom1 = (unsigned char) 0xFE; // BOM for UTF-16: 0xFEFF
6060
unsigned char cbom2 = (unsigned char) 0xFF; // ...
@@ -67,7 +67,7 @@ int main(int argc, char *argv[]) {
6767
if (argc < 3 || argc > 4 || argv[1] == NULL || argv[2] == NULL) {
6868
printf("Usage:\n %s <infile> <outfile> [-u] [-n]\n\n", argv[0]);
6969
printf("Options:\n -u : create UTF-16 output; defaults to ASCII\n");
70-
printf(" -n : for non-unicode SAP systems; defaults to unicode\n\n");
70+
printf(" -n : assume input from non-unicode SAP system\n\n");
7171
return 0;
7272
}
7373

@@ -105,6 +105,8 @@ int main(int argc, char *argv[]) {
105105
fout = fopen(argv[2], "wb");
106106
if (fout == NULL) {
107107
printf("Error creating output file '%s'\n", argv[2]);
108+
// Make CppCheck happy ("memory leak: bin")
109+
// cppcheck-suppress memleak
108110
return 2;
109111
}
110112

@@ -164,11 +166,11 @@ int main(int argc, char *argv[]) {
164166
// The 2nd byte contains the length of the first line.
165167
// For non-unicode SAP systems the 1st byte contains the length of the first line.
166168
// Compute position of next length field.
167-
if (fnuc) {
168-
nextpos = (long)bout[0];
169+
if (fnuc) {
170+
nextpos = (long)bout[0];
169171
}
170-
else {
171-
nextpos = ((long)bout[1]) * 2 + 3;
172+
else {
173+
nextpos = ((long)bout[1]) * 2 + 3;
172174
}
173175

174176
for (i = 1; i < byte_decomp; i++) {
@@ -185,7 +187,7 @@ int main(int argc, char *argv[]) {
185187
ret = fwrite("\n", 1, 1, fout);
186188

187189
// Compute position of next length field
188-
if (fnuc) {
190+
if (fnuc) {
189191
nextpos = nextpos + (long)bout[0] + 1;
190192
i += 1;
191193
}

0 commit comments

Comments
 (0)