Skip to content

Commit 697bfa8

Browse files
authored
Update -h handling code to be consistent with latest (#5419)
* Rename `totalFlagAndArgLength` to `flagAndArgLength` * Rename `maxOptionAndArgLength` to `maxFlagAndArgLength` * Rename `optionLength` to `flagLength` * Rename `totalLength` to `flagAndArgLength` * Replace `sizeof(options) / sizeof(options[0])` with `RZ_ARRAY_SIZE(options)`
1 parent fef5cb0 commit 697bfa8

File tree

11 files changed

+93
-93
lines changed

11 files changed

+93
-93
lines changed

binrz/rz-test/rz-test.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,18 +88,18 @@ static int help(bool verbose) {
8888
"-x", "[num]", "Number of expected failed tests",
8989
// clang-format on
9090
};
91-
size_t maxOptionAndArgLength = 0;
92-
for (int i = 0; i < sizeof(options) / sizeof(options[0]); i += 3) {
93-
size_t optionLength = strlen(options[i]);
91+
size_t maxFlagAndArgLength = 0;
92+
for (int i = 0; i < RZ_ARRAY_SIZE(options); i += 3) {
93+
size_t flagLength = strlen(options[i]);
9494
size_t argLength = strlen(options[i + 1]);
95-
size_t totalLength = optionLength + argLength;
96-
if (totalLength > maxOptionAndArgLength) {
97-
maxOptionAndArgLength = totalLength;
95+
size_t flagAndArgLength = flagLength + argLength;
96+
if (flagAndArgLength > maxFlagAndArgLength) {
97+
maxFlagAndArgLength = flagAndArgLength;
9898
}
9999
}
100-
for (int i = 0; i < sizeof(options) / sizeof(options[0]); i += 3) {
101-
if (i + 1 < sizeof(options) / sizeof(options[0])) {
102-
rz_print_colored_help_option(options[i], options[i + 1], options[i + 2], maxOptionAndArgLength);
100+
for (int i = 0; i < RZ_ARRAY_SIZE(options); i += 3) {
101+
if (i + 1 < RZ_ARRAY_SIZE(options)) {
102+
rz_print_colored_help_option(options[i], options[i + 1], options[i + 2], maxFlagAndArgLength);
103103
}
104104
}
105105
printf("Supported test types: @json @unit @fuzz @cmds\n"

librz/main/rizin.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -139,18 +139,18 @@ static int main_help(RZ_BORROW RZ_NONNULL RzCore *core, int line) {
139139
"-z, -zz", "", "Do not load strings or load them even in raw",
140140
// clang-format on
141141
};
142-
size_t maxOptionAndArgLength = 0;
143-
for (int i = 0; i < sizeof(options) / sizeof(options[0]); i += 3) {
144-
size_t optionLength = strlen(options[i]);
142+
size_t maxFlagAndArgLength = 0;
143+
for (int i = 0; i < RZ_ARRAY_SIZE(options); i += 3) {
144+
size_t flagLength = strlen(options[i]);
145145
size_t argLength = strlen(options[i + 1]);
146-
size_t totalLength = optionLength + argLength;
147-
if (totalLength > maxOptionAndArgLength) {
148-
maxOptionAndArgLength = totalLength;
146+
size_t flagAndArgLength = flagLength + argLength;
147+
if (flagAndArgLength > maxFlagAndArgLength) {
148+
maxFlagAndArgLength = flagAndArgLength;
149149
}
150150
}
151-
for (int i = 0; i < sizeof(options) / sizeof(options[0]); i += 3) {
152-
if (i + 1 < sizeof(options) / sizeof(options[0])) {
153-
rz_print_colored_help_option(options[i], options[i + 1], options[i + 2], maxOptionAndArgLength);
151+
for (int i = 0; i < RZ_ARRAY_SIZE(options); i += 3) {
152+
if (i + 1 < RZ_ARRAY_SIZE(options)) {
153+
rz_print_colored_help_option(options[i], options[i + 1], options[i + 2], maxFlagAndArgLength);
154154
}
155155
}
156156
}

librz/main/rz-asm.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -207,18 +207,18 @@ static int rasm_show_help(int v) {
207207
// clang-format on
208208
};
209209
if (v != 1) {
210-
size_t maxOptionAndArgLength = 0;
211-
for (int i = 0; i < sizeof(options) / sizeof(options[0]); i += 3) {
212-
size_t optionLength = strlen(options[i]);
210+
size_t maxFlagAndArgLength = 0;
211+
for (int i = 0; i < RZ_ARRAY_SIZE(options); i += 3) {
212+
size_t flagLength = strlen(options[i]);
213213
size_t argLength = strlen(options[i + 1]);
214-
size_t totalLength = optionLength + argLength;
215-
if (totalLength > maxOptionAndArgLength) {
216-
maxOptionAndArgLength = totalLength;
214+
size_t flagAndArgLength = flagLength + argLength;
215+
if (flagAndArgLength > maxFlagAndArgLength) {
216+
maxFlagAndArgLength = flagAndArgLength;
217217
}
218218
}
219-
for (int i = 0; i < sizeof(options) / sizeof(options[0]); i += 3) {
220-
if (i + 1 < sizeof(options) / sizeof(options[0])) {
221-
rz_print_colored_help_option(options[i], options[i + 1], options[i + 2], maxOptionAndArgLength);
219+
for (int i = 0; i < RZ_ARRAY_SIZE(options); i += 3) {
220+
if (i + 1 < RZ_ARRAY_SIZE(options)) {
221+
rz_print_colored_help_option(options[i], options[i + 1], options[i + 2], maxFlagAndArgLength);
222222
}
223223
}
224224
}

librz/main/rz-ax.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,9 @@ static int help(void) {
253253
for (int i = 0; i < RZ_ARRAY_SIZE(options); i += 4) {
254254
size_t flagLength = options[i] ? strlen(options[i]) : 0;
255255
size_t argLength = options[i + 1] ? strlen(options[i + 1]) : 0;
256-
size_t totalFlagAndArgLength = flagLength + argLength;
257-
if (totalFlagAndArgLength > maxFlagAndArgLength) {
258-
maxFlagAndArgLength = totalFlagAndArgLength;
256+
size_t flagAndArgLength = flagLength + argLength;
257+
if (flagAndArgLength > maxFlagAndArgLength) {
258+
maxFlagAndArgLength = flagAndArgLength;
259259
}
260260
size_t descLength = strlen(options[i + 2]);
261261
if (descLength > maxDescLength) {

librz/main/rz-bin.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -218,18 +218,18 @@ static int rzbin_show_help(int v) {
218218
"-Z", "", "Guess size of binary program",
219219
// clang-format on
220220
};
221-
size_t maxOptionAndArgLength = 0;
222-
for (int i = 0; i < sizeof(options) / sizeof(options[0]); i += 3) {
223-
size_t optionLength = strlen(options[i]);
221+
size_t maxFlagAndArgLength = 0;
222+
for (int i = 0; i < RZ_ARRAY_SIZE(options); i += 3) {
223+
size_t flagLength = strlen(options[i]);
224224
size_t argLength = strlen(options[i + 1]);
225-
size_t totalLength = optionLength + argLength;
226-
if (totalLength > maxOptionAndArgLength) {
227-
maxOptionAndArgLength = totalLength;
225+
size_t flagAndArgLength = flagLength + argLength;
226+
if (flagAndArgLength > maxFlagAndArgLength) {
227+
maxFlagAndArgLength = flagAndArgLength;
228228
}
229229
}
230-
for (int i = 0; i < sizeof(options) / sizeof(options[0]); i += 3) {
231-
if (i + 1 < sizeof(options) / sizeof(options[0])) {
232-
rz_print_colored_help_option(options[i], options[i + 1], options[i + 2], maxOptionAndArgLength);
230+
for (int i = 0; i < RZ_ARRAY_SIZE(options); i += 3) {
231+
if (i + 1 < RZ_ARRAY_SIZE(options)) {
232+
rz_print_colored_help_option(options[i], options[i + 1], options[i + 2], maxFlagAndArgLength);
233233
}
234234
}
235235
}

librz/main/rz-diff.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -243,18 +243,18 @@ static void rz_diff_show_help(bool usage_only) {
243243
"", "", " symbols | compare symbols found in the files",
244244
// clang-format on
245245
};
246-
size_t maxOptionAndArgLength = 0;
247-
for (int i = 0; i < sizeof(options) / sizeof(options[0]); i += 3) {
248-
size_t optionLength = strlen(options[i]);
246+
size_t maxFlagAndArgLength = 0;
247+
for (int i = 0; i < RZ_ARRAY_SIZE(options); i += 3) {
248+
size_t flagLength = strlen(options[i]);
249249
size_t argLength = strlen(options[i + 1]);
250-
size_t totalLength = optionLength + argLength;
251-
if (totalLength > maxOptionAndArgLength) {
252-
maxOptionAndArgLength = totalLength;
250+
size_t flagAndArgLength = flagLength + argLength;
251+
if (flagAndArgLength > maxFlagAndArgLength) {
252+
maxFlagAndArgLength = flagAndArgLength;
253253
}
254254
}
255-
for (int i = 0; i < sizeof(options) / sizeof(options[0]); i += 3) {
256-
if (i + 1 < sizeof(options) / sizeof(options[0])) {
257-
rz_print_colored_help_option(options[i], options[i + 1], options[i + 2], maxOptionAndArgLength);
255+
for (int i = 0; i < RZ_ARRAY_SIZE(options); i += 3) {
256+
if (i + 1 < RZ_ARRAY_SIZE(options)) {
257+
rz_print_colored_help_option(options[i], options[i + 1], options[i + 2], maxFlagAndArgLength);
258258
}
259259
}
260260

librz/main/rz-find.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -223,18 +223,18 @@ static int show_help(const char *argv0, int line) {
223223
"-Z", "", "Show string found on each search hit",
224224
// clang-format on
225225
};
226-
size_t maxOptionAndArgLength = 0;
227-
for (int i = 0; i < sizeof(options) / sizeof(options[0]); i += 3) {
228-
size_t optionLength = strlen(options[i]);
226+
size_t maxFlagAndArgLength = 0;
227+
for (int i = 0; i < RZ_ARRAY_SIZE(options); i += 3) {
228+
size_t flagLength = strlen(options[i]);
229229
size_t argLength = strlen(options[i + 1]);
230-
size_t totalLength = optionLength + argLength;
231-
if (totalLength > maxOptionAndArgLength) {
232-
maxOptionAndArgLength = totalLength;
230+
size_t flagAndArgLength = flagLength + argLength;
231+
if (flagAndArgLength > maxFlagAndArgLength) {
232+
maxFlagAndArgLength = flagAndArgLength;
233233
}
234234
}
235-
for (int i = 0; i < sizeof(options) / sizeof(options[0]); i += 3) {
236-
if (i + 1 < sizeof(options) / sizeof(options[0])) {
237-
rz_print_colored_help_option(options[i], options[i + 1], options[i + 2], maxOptionAndArgLength);
235+
for (int i = 0; i < RZ_ARRAY_SIZE(options); i += 3) {
236+
if (i + 1 < RZ_ARRAY_SIZE(options)) {
237+
rz_print_colored_help_option(options[i], options[i + 1], options[i + 2], maxFlagAndArgLength);
238238
}
239239
}
240240
return 0;

librz/main/rz-gg.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,18 @@ static int usage(int v) {
5050
"-z", "" ,"Output in C string syntax",
5151
// clang-format on
5252
};
53-
size_t maxOptionAndArgLength = 0;
54-
for (int i = 0; i < sizeof(options) / sizeof(options[0]); i += 3) {
55-
size_t optionLength = strlen(options[i]);
53+
size_t maxFlagAndArgLength = 0;
54+
for (int i = 0; i < RZ_ARRAY_SIZE(options); i += 3) {
55+
size_t flagLength = strlen(options[i]);
5656
size_t argLength = strlen(options[i + 1]);
57-
size_t totalLength = optionLength + argLength;
58-
if (totalLength > maxOptionAndArgLength) {
59-
maxOptionAndArgLength = totalLength;
57+
size_t flagAndArgLength = flagLength + argLength;
58+
if (flagAndArgLength > maxFlagAndArgLength) {
59+
maxFlagAndArgLength = flagAndArgLength;
6060
}
6161
}
62-
for (int i = 0; i < sizeof(options) / sizeof(options[0]); i += 3) {
63-
if (i + 1 < sizeof(options) / sizeof(options[0])) {
64-
rz_print_colored_help_option(options[i], options[i + 1], options[i + 2], maxOptionAndArgLength);
62+
for (int i = 0; i < RZ_ARRAY_SIZE(options); i += 3) {
63+
if (i + 1 < RZ_ARRAY_SIZE(options)) {
64+
rz_print_colored_help_option(options[i], options[i + 1], options[i + 2], maxFlagAndArgLength);
6565
}
6666
}
6767
}

librz/main/rz-hash.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -109,18 +109,18 @@ static void rz_hash_show_help(bool usage_only) {
109109
"", "", "If 's:' prefix is specified",
110110
// clang-format on
111111
};
112-
size_t maxOptionAndArgLength = 0;
113-
for (int i = 0; i < sizeof(options) / sizeof(options[0]); i += 3) {
114-
size_t optionLength = strlen(options[i]);
112+
size_t maxFlagAndArgLength = 0;
113+
for (int i = 0; i < RZ_ARRAY_SIZE(options); i += 3) {
114+
size_t flagLength = strlen(options[i]);
115115
size_t argLength = strlen(options[i + 1]);
116-
size_t totalLength = optionLength + argLength;
117-
if (totalLength > maxOptionAndArgLength) {
118-
maxOptionAndArgLength = totalLength;
116+
size_t flagAndArgLength = flagLength + argLength;
117+
if (flagAndArgLength > maxFlagAndArgLength) {
118+
maxFlagAndArgLength = flagAndArgLength;
119119
}
120120
}
121-
for (int i = 0; i < sizeof(options) / sizeof(options[0]); i += 3) {
122-
if (i + 1 < sizeof(options) / sizeof(options[0])) {
123-
rz_print_colored_help_option(options[i], options[i + 1], options[i + 2], maxOptionAndArgLength);
121+
for (int i = 0; i < RZ_ARRAY_SIZE(options); i += 3) {
122+
if (i + 1 < RZ_ARRAY_SIZE(options)) {
123+
rz_print_colored_help_option(options[i], options[i + 1], options[i + 2], maxFlagAndArgLength);
124124
}
125125
}
126126
}

librz/main/rz-run.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,18 @@ static void rz_run_help(int v) {
3737
"--", "[program] [args]", "Run commands",
3838
// clang-format on
3939
};
40-
size_t maxOptionAndArgLength = 0;
41-
for (int i = 0; i < sizeof(options) / sizeof(options[0]); i += 3) {
42-
size_t optionLength = strlen(options[i]);
40+
size_t maxFlagAndArgLength = 0;
41+
for (int i = 0; i < RZ_ARRAY_SIZE(options); i += 3) {
42+
size_t flagLength = strlen(options[i]);
4343
size_t argLength = strlen(options[i + 1]);
44-
size_t totalLength = optionLength + argLength;
45-
if (totalLength > maxOptionAndArgLength) {
46-
maxOptionAndArgLength = totalLength;
44+
size_t flagAndArgLength = flagLength + argLength;
45+
if (flagAndArgLength > maxFlagAndArgLength) {
46+
maxFlagAndArgLength = flagAndArgLength;
4747
}
4848
}
49-
for (int i = 0; i < sizeof(options) / sizeof(options[0]); i += 3) {
50-
if (i + 1 < sizeof(options) / sizeof(options[0])) {
51-
rz_print_colored_help_option(options[i], options[i + 1], options[i + 2], maxOptionAndArgLength);
49+
for (int i = 0; i < RZ_ARRAY_SIZE(options); i += 3) {
50+
if (i + 1 < RZ_ARRAY_SIZE(options)) {
51+
rz_print_colored_help_option(options[i], options[i + 1], options[i + 2], maxFlagAndArgLength);
5252
}
5353
}
5454
}

0 commit comments

Comments
 (0)