~mdw
/
tig
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Remove redundant ending ';'
[tig]
/
tig.c
diff --git
a/tig.c
b/tig.c
index
48fbca0
..
4f43681
100644
(file)
--- a/
tig.c
+++ b/
tig.c
@@
-145,7
+145,7
@@
set_from_int_map(struct int_map *map, size_t map_size,
*/
static inline void
*/
static inline void
-string_ncopy(char *dst, const char *src,
in
t dstlen)
+string_ncopy(char *dst, const char *src,
size_
t dstlen)
{
strncpy(dst, src, dstlen - 1);
dst[dstlen - 1] = 0;
{
strncpy(dst, src, dstlen - 1);
dst[dstlen - 1] = 0;
@@
-172,10
+172,10
@@
chomp_string(char *name)
}
static bool
}
static bool
-string_nformat(char *buf, size_t bufsize,
in
t *bufpos, const char *fmt, ...)
+string_nformat(char *buf, size_t bufsize,
size_
t *bufpos, const char *fmt, ...)
{
va_list args;
{
va_list args;
-
in
t pos = bufpos ? *bufpos : 0;
+
size_
t pos = bufpos ? *bufpos : 0;
va_start(args, fmt);
pos += vsnprintf(buf + pos, bufsize - pos, fmt, args);
va_start(args, fmt);
pos += vsnprintf(buf + pos, bufsize - pos, fmt, args);
@@
-714,7
+714,7
@@
static struct keybinding default_keybindings[] = {
{ 'z', REQ_STOP_LOADING },
{ 'v', REQ_SHOW_VERSION },
{ 'r', REQ_SCREEN_REDRAW },
{ 'z', REQ_STOP_LOADING },
{ 'v', REQ_SHOW_VERSION },
{ 'r', REQ_SCREEN_REDRAW },
- { '
n
', REQ_TOGGLE_LINENO },
+ { '
.
', REQ_TOGGLE_LINENO },
{ 'g', REQ_TOGGLE_REV_GRAPH },
{ ':', REQ_PROMPT },
{ 'g', REQ_TOGGLE_REV_GRAPH },
{ ':', REQ_PROMPT },
@@
-847,7
+847,7
@@
get_key(enum request request)
{
static char buf[BUFSIZ];
static char key_char[] = "'X'";
{
static char buf[BUFSIZ];
static char key_char[] = "'X'";
-
in
t pos = 0;
+
size_
t pos = 0;
char *sep = " ";
int i;
char *sep = " ";
int i;
@@
-1152,7
+1152,7
@@
struct view_ops;
static struct view *display[2];
static unsigned int current_view;
static struct view *display[2];
static unsigned int current_view;
-#define foreach_view(view, i) \
+#define foreach_
displayed_
view(view, i) \
for (i = 0; i < ARRAY_SIZE(display) && (view = display[i]); i++)
#define displayed_views() (display[1] != NULL ? 2 : 1)
for (i = 0; i < ARRAY_SIZE(display) && (view = display[i]); i++)
#define displayed_views() (display[1] != NULL ? 2 : 1)
@@
-1240,10
+1240,17
@@
static struct view views[] = {
#define VIEW(req) (&views[(req) - REQ_OFFSET - 1])
#define VIEW(req) (&views[(req) - REQ_OFFSET - 1])
+#define foreach_view(view, i) \
+ for (i = 0; i < ARRAY_SIZE(views) && (view = &views[i]); i++)
+
+#define view_is_displayed(view) \
+ (view == display[0] || view == display[1])
static bool
draw_view_line(struct view *view, unsigned int lineno)
{
static bool
draw_view_line(struct view *view, unsigned int lineno)
{
+ assert(view_is_displayed(view));
+
if (view->offset + lineno >= view->lines)
return FALSE;
if (view->offset + lineno >= view->lines)
return FALSE;
@@
-1275,6
+1282,8
@@
redraw_view(struct view *view)
static void
update_view_title(struct view *view)
{
static void
update_view_title(struct view *view)
{
+ assert(view_is_displayed(view));
+
if (view == display[current_view])
wbkgdset(view->title, get_line_attr(LINE_TITLE_FOCUS));
else
if (view == display[current_view])
wbkgdset(view->title, get_line_attr(LINE_TITLE_FOCUS));
else
@@
-1342,7
+1351,7
@@
resize_display(void)
offset = 0;
offset = 0;
- foreach_view (view, i) {
+ foreach_
displayed_
view (view, i) {
if (!view->win) {
view->win = newwin(view->height, 0, offset, 0);
if (!view->win)
if (!view->win) {
view->win = newwin(view->height, 0, offset, 0);
if (!view->win)
@@
-1370,7
+1379,7
@@
redraw_display(void)
struct view *view;
int i;
struct view *view;
int i;
- foreach_view (view, i) {
+ foreach_
displayed_
view (view, i) {
redraw_view(view);
update_view_title(view);
}
redraw_view(view);
update_view_title(view);
}
@@
-1399,6
+1408,8
@@
update_display_cursor(void)
static void
do_scroll_view(struct view *view, int lines, bool redraw)
{
static void
do_scroll_view(struct view *view, int lines, bool redraw)
{
+ assert(view_is_displayed(view));
+
/* The rendering expects the new offset. */
view->offset += lines;
/* The rendering expects the new offset. */
view->offset += lines;
@@
-1586,6
+1597,8
@@
static void search_view(struct view *view, enum request request, const char *sea
static bool
find_next_line(struct view *view, unsigned long lineno, struct line *line)
{
static bool
find_next_line(struct view *view, unsigned long lineno, struct line *line)
{
+ assert(view_is_displayed(view));
+
if (!view->ops->grep(view, line))
return FALSE;
if (!view->ops->grep(view, line))
return FALSE;
@@
-1671,7
+1684,7
@@
search_view(struct view *view, enum request request, const char *search)
char buf[SIZEOF_STR] = "unknown error";
regerror(regex_err, &view->regex, buf, sizeof(buf));
char buf[SIZEOF_STR] = "unknown error";
regerror(regex_err, &view->regex, buf, sizeof(buf));
- report("Search failed: %s", buf);
;
+ report("Search failed: %s", buf);
return;
}
return;
}
@@
-1795,6
+1808,7
@@
update_view(struct view *view)
if (view->offset + view->height >= view->lines)
redraw_from = view->lines - view->offset;
if (view->offset + view->height >= view->lines)
redraw_from = view->lines - view->offset;
+ /* FIXME: This is probably not perfect for backgrounded views. */
if (!realloc_lines(view, view->lines + lines))
goto alloc_error;
if (!realloc_lines(view, view->lines + lines))
goto alloc_error;
@@
-1841,6
+1855,9
@@
update_view(struct view *view)
}
}
}
}
+ if (!view_is_displayed(view))
+ goto check_pipe;
+
if (view == VIEW(REQ_VIEW_TREE)) {
/* Clear the view and redraw everything since the tree sorting
* might have rearranged things. */
if (view == VIEW(REQ_VIEW_TREE)) {
/* Clear the view and redraw everything since the tree sorting
* might have rearranged things. */
@@
-1861,6
+1878,7
@@
update_view(struct view *view)
* commit reference in view->ref it'll be available here. */
update_view_title(view);
* commit reference in view->ref it'll be available here. */
update_view_title(view);
+check_pipe:
if (ferror(view->pipe)) {
report("Failed to read: %s", strerror(errno));
goto end;
if (ferror(view->pipe)) {
report("Failed to read: %s", strerror(errno));
goto end;
@@
-2252,7
+2270,7
@@
pager_draw(struct view *view, struct line *line, unsigned int lineno)
}
static bool
}
static bool
-add_describe_ref(char *buf,
in
t *bufpos, char *commit_id, const char *sep)
+add_describe_ref(char *buf,
size_
t *bufpos, char *commit_id, const char *sep)
{
char refbuf[SIZEOF_STR];
char *ref = NULL;
{
char refbuf[SIZEOF_STR];
char *ref = NULL;
@@
-2285,7
+2303,7
@@
add_pager_refs(struct view *view, struct line *line)
char buf[SIZEOF_STR];
char *commit_id = line->data + STRING_SIZE("commit ");
struct ref **refs;
char buf[SIZEOF_STR];
char *commit_id = line->data + STRING_SIZE("commit ");
struct ref **refs;
-
in
t bufpos = 0, refpos = 0;
+
size_
t bufpos = 0, refpos = 0;
const char *sep = "Refs: ";
bool is_tag = FALSE;
const char *sep = "Refs: ";
bool is_tag = FALSE;
@@
-2525,7
+2543,7
@@
tree_enter(struct view *view, struct line *line)
dirsep[0] = 0;
} else {
dirsep[0] = 0;
} else {
-
in
t pathlen = strlen(opt_path);
+
size_
t pathlen = strlen(opt_path);
char *basename = data + SIZEOF_TREE_ATTR;
string_format_from(opt_path, &pathlen, "%s/", basename);
char *basename = data + SIZEOF_TREE_ATTR;
string_format_from(opt_path, &pathlen, "%s/", basename);