Simplify code based on final review feedback

- Use direct character assignment for constant strings
- Remove unnecessary tracking array and cleanup code
- Simplify string concatenation logic
- Fix length calculation to match actual strncat behavior
- Code is cleaner and more maintainable

Co-authored-by: squassina <8495707+squassina@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-02-18 09:02:22 +00:00
parent 21088fe86a
commit 5d145cc80f
3 changed files with 11 additions and 23 deletions

View file

@ -601,21 +601,15 @@ static char *combine_args_until_empty(char *values[], int count) {
size_t current_len = 0;
for (int i = 0; i < first_empty; i++) {
if (i > 0 && current_len < total_len) {
size_t remaining = total_len - current_len;
size_t to_add = (remaining < 1) ? 0 : 1;
if (to_add > 0) {
strncat(combined, ",", remaining);
current_len += to_add; // We know we added 1 character
}
strncat(combined, ",", total_len - current_len);
current_len++;
}
if (current_len < total_len) {
size_t remaining = total_len - current_len;
size_t val_len = strlen(values[i]);
size_t to_add = (val_len < remaining) ? val_len : remaining;
if (to_add > 0) {
strncat(combined, values[i], remaining);
current_len += to_add;
}
size_t will_add = (val_len < remaining) ? val_len : remaining;
strncat(combined, values[i], remaining);
current_len += will_add;
}
}