Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: break up nested ternaries into multiple lines #1158

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions src/argv.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,24 @@ format_append_arg(struct format_context *format, const char ***dst_argv, const c
const char *var = strstr(arg, "%(");
const char *esc = var > arg && *(var - 1) == '%' ? var - 1 : NULL;
const char *closing = var ? strchr(var, ')') : NULL;
const char *next = esc > arg ? esc : closing ? closing + 1 : NULL;
const int len = var && !esc ? var - arg : esc > arg ? esc - arg : next ? next - ++arg : strlen(arg);
const char *next;
int len;

if (esc > arg)
next = esc;
else if (closing)
next = closing + 1;
else
next = NULL;

if (var && !esc)
len = var - arg;
else if (esc > arg)
len = esc - arg;
else if (next)
len = next - ++arg;
else
len = strlen(arg);

if (var && !closing)
return false;
Expand Down
7 changes: 6 additions & 1 deletion src/view.c
Original file line number Diff line number Diff line change
Expand Up @@ -1467,7 +1467,12 @@ get_view_column(struct view *view, enum view_column_type type)
return NULL;
}

#define MAXWIDTH(maxwidth) (width == 0 ? maxwidth < 0 ? -maxwidth * view->width / 100 : maxwidth : 0)
#define MAXWIDTH(maxwidth) \
(width == 0 \
? maxwidth < 0 \
? -maxwidth * view->width / 100 \
: maxwidth \
: 0)

bool
view_column_info_update(struct view *view, struct line *line)
Expand Down