From fccf8b08f6b5a22bd43a9b05e1abb12d9a589f6f Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Thu, 14 Sep 2023 19:24:16 +1000 Subject: [PATCH] Remove pane->data when PANE_DATA_TYPE not set. This forces use of _dats which easily highlights places that still need to be converted. Signed-off-by: NeilBrown --- core-pane.c | 10 ++++----- core-pane.h | 2 -- doc-docs.c | 8 +++---- lang-python.c | 2 +- lib-charset.c | 4 ++-- lib-tile.c | 62 +++++++++++++++++++++++++-------------------------- lib-wiggle.c | 16 ++++++------- mode-emacs.c | 12 +++++----- 8 files changed, 57 insertions(+), 59 deletions(-) diff --git a/core-pane.c b/core-pane.c index 4e2932cd..3b531ecb 100644 --- a/core-pane.c +++ b/core-pane.c @@ -156,7 +156,7 @@ static struct pane *_do_pane_register(struct pane *parent, short z, if (data) alloc_size = sizeof(data); - alloc_size += offsetof(struct pane, data); + alloc_size += offsetof(struct pane, _data); p = alloc_zbuf(alloc_size, pane); pane_init(p, parent); @@ -166,7 +166,7 @@ static struct pane *_do_pane_register(struct pane *parent, short z, p->abs_z = parent->abs_z + 1; p->handle = command_get(handle); if (data) - p->data = data; + p->_data = data; p->name = handle->name; if (z >= 0) { @@ -772,9 +772,9 @@ void pane_subsume(struct pane *p safe, struct pane *parent safe) parent->handle = p->handle; p->handle = handle; - data = parent->data; - parent->data = p->data; - p->data = data; + data = parent->_data; + parent->_data = p->_data; + p->_data = data; parent->damaged |= p->damaged; pane_damaged(p, DAMAGED_SIZE); diff --git a/core-pane.h b/core-pane.h index 04afae4b..706acea7 100644 --- a/core-pane.h +++ b/core-pane.h @@ -30,8 +30,6 @@ struct pane { struct doc doc; #ifdef PANE_DATA_TYPE PANE_DATA_TYPE data[1]; -#else - void *data safe; #endif #ifdef DOC_DATA_TYPE DOC_DATA_TYPE doc_data[1]; diff --git a/doc-docs.c b/doc-docs.c index 483988ff..6824c544 100644 --- a/doc-docs.c +++ b/doc-docs.c @@ -422,7 +422,7 @@ DEF_CMD(docs_callback_appeared) DEF_CMD(doc_damage) { - struct pane *dp = ci->home->data; + struct pane *dp = ci->home->_data; struct mark *m = mark_new(dp); struct pane *child = ci->focus; @@ -441,7 +441,7 @@ DEF_CMD(doc_damage) DEF_CMD(doc_revisit) { struct pane *p = ci->focus; - struct pane *dp = ci->home->data; + struct pane *dp = ci->home->_data; struct docs *docs = dp->doc_data; if (!p) @@ -707,7 +707,7 @@ DEF_CMD(docs_destroy) DEF_CMD(docs_child_closed) { - struct pane *pd = ci->home->data; + struct pane *pd = ci->home->_data; if (ci->num < 0) docs_demark(pd, ci->focus); @@ -867,7 +867,7 @@ static void docs_init_map(void) DEF_CB(docs_callback_lookup) { struct docs *docs = container_of(ci->comm, struct docs, callback); - struct pane *home = docs->collection->data; + struct pane *home = docs->collection->_data; return do_call_val(TYPE_comm, home, &docs_callback_handle.c, ci->key, ci->focus, diff --git a/lang-python.c b/lang-python.c index 06e93c94..3f5c3f5b 100644 --- a/lang-python.c +++ b/lang-python.c @@ -206,7 +206,7 @@ static inline PyObject *safe Pane_Frompane(struct pane *p) { Pane *pane; if (p && p->handle && p->handle->func == python_pane_call.func) { - pane = p->data; + pane = p->_data; Py_INCREF(pane); } else if (p && p->handle && p->handle->func == python_doc_call.func) { struct python_doc *pd = p->doc_data; diff --git a/lib-charset.c b/lib-charset.c index 28d1076f..ecda2aa2 100644 --- a/lib-charset.c +++ b/lib-charset.c @@ -1319,7 +1319,7 @@ DEF_LOOKUP_CMD(charset_handle, charset_map); DEF_CMD(charset_char) { wint_t ret; - wchar_t *tbl = ci->home->data; + wchar_t *tbl = ci->home->_data; ret = home_call(ci->home->parent, "doc:byte", ci->focus, ci->num, ci->mark, NULL, @@ -1387,7 +1387,7 @@ DEF_CB(charset_content_cb) DEF_CMD(charset_content) { struct charsetcb c; - wchar_t *tbl = ci->home->data; + wchar_t *tbl = ci->home->_data; if (!ci->comm2 || !ci->mark) return Enoarg; diff --git a/lib-tile.c b/lib-tile.c index 868c068f..efe0a84e 100644 --- a/lib-tile.c +++ b/lib-tile.c @@ -63,7 +63,7 @@ static inline bool mine(struct pane *t safe) DEF_CMD_CLOSED(tile_close) { - struct tileinfo *ti = ci->home->data; + struct tileinfo *ti = ci->home->_data; tile_destroy(ci->home); free(ti->name); @@ -74,7 +74,7 @@ DEF_CMD_CLOSED(tile_close) DEF_CMD(tile_refresh_size) { struct pane *p = ci->home; - struct tileinfo *ti = p->data; + struct tileinfo *ti = p->_data; if (ti->direction == Neither) { tile_avail(p, NULL); @@ -93,7 +93,7 @@ DEF_CMD(tile_clone) * create a single tile, cloned from the focus pane */ child = ci->home; - cti = child->data; + cti = child->_data; alloc(ti, pane); ti->leaf = 1; ti->direction = Neither; @@ -109,10 +109,10 @@ DEF_CMD(tile_clone) attr_set_str(&p2->attrs, "borders", "BL"); while (!cti->leaf && child->focus) { child = child->focus; - cti = child->data; + cti = child->_data; } cti = list_next_entry(cti, tiles); - while (cti != child->data && + while (cti != child->_data && (cti->name == NULL || strcmp(cti->name, "main") != 0)) cti = list_next_entry(cti, tiles); child = cti->p; @@ -160,7 +160,7 @@ static struct pane *tile_split(struct pane **pp safe, int horiz, int after, int space, new_space; struct pane *p = safe_cast *pp; struct pane *ret; - struct tileinfo *ti = p->data; + struct tileinfo *ti = p->_data; struct tileinfo *ti2; if (horiz) space = p->w; @@ -185,7 +185,7 @@ static struct pane *tile_split(struct pane **pp safe, int horiz, int after, ti2->direction = ti->direction; ti2->group = ti->group; INIT_LIST_HEAD(&ti2->tiles); - p->data = ti2; + p->_data = ti2; ti2->p = p; p2 = pane_register(p, 0, &tile_handle.c, ti); if (!p2) @@ -247,7 +247,7 @@ static struct pane *tile_split(struct pane **pp safe, int horiz, int after, static int tile_destroy(struct pane *p safe) { - struct tileinfo *ti = p->data; + struct tileinfo *ti = p->_data; struct pane *prev = NULL, *next = NULL; struct pane *t, *remain = NULL; int pos, prevpos, nextpos; @@ -345,8 +345,8 @@ static int tile_destroy(struct pane *p safe) * Cannot destroy the parent, so bring child into parent */ p = remain->parent; - ti = remain->data; - ti2 = p->data; + ti = remain->_data; + ti2 = p->_data; tmp = ti2->direction; ti2->direction = ti->direction; @@ -368,7 +368,7 @@ static void tile_avail(struct pane *p safe, struct pane *ignore) * if stacking direction doesn't match 'horiz', find minimum. * If only one child, assume min of 4. */ - struct tileinfo *ti = p->data; + struct tileinfo *ti = p->_data; struct pane *t; if (ti->leaf) { @@ -387,7 +387,7 @@ static void tile_avail(struct pane *p safe, struct pane *ignore) if (t == ignore || !mine(t)) continue; tile_avail(t, NULL); - ti2 = t->data; + ti2 = t->_data; if (min < 0 || min > ti2->avail_perp) min = ti2->avail_perp; sum += ti2->avail_inline; @@ -414,7 +414,7 @@ static void tile_adjust(struct pane *p safe) int avail_cnt = 0; int pos; int size = 0; - struct tileinfo *ti = p->data; + struct tileinfo *ti = p->_data; if (ti->leaf) /* Children are responsible for themselves. */ @@ -424,7 +424,7 @@ static void tile_adjust(struct pane *p safe) if (!mine(t)) continue; - ti = t->data; + ti = t->_data; if (ti->direction == Horiz) { pane_resize(t, t->x, 0, t->w, p->h); used += t->w; @@ -446,7 +446,7 @@ static void tile_adjust(struct pane *p safe) cnt = avail_cnt; avail_cnt = 0; list_for_each_entry(t, &p->children, siblings) { - struct tileinfo *ti2 = t->data; + struct tileinfo *ti2 = t->_data; int diff; int mysize; if (!mine(t)) @@ -492,7 +492,7 @@ static void tile_adjust(struct pane *p safe) } pos = 0; list_for_each_entry(t, &p->children, siblings) { - struct tileinfo *ti2 = t->data; + struct tileinfo *ti2 = t->_data; if (!mine(t)) continue; if (ti2->direction == Horiz) { @@ -517,7 +517,7 @@ static bool tile_grow(struct pane *p safe, int horiz, int size) * Then that propagates back down. Size of this pane is adjusted * first to catch the propagations, then corrected after. */ - struct tileinfo *ti = p->data; + struct tileinfo *ti = p->_data; struct tileinfo *tip; int avail; @@ -573,7 +573,7 @@ static bool tile_grow(struct pane *p safe, int horiz, int size) /* Hoping to grow if there is room for others to shrink */ tile_avail(p->parent, p); - tip = p->parent->data; + tip = p->parent->_data; if (ti->direction == (horiz ? Horiz : Vert)) avail = tip->avail_inline; else @@ -613,7 +613,7 @@ static struct tileinfo *tile_first(struct tileinfo *ti safe) struct pane *p = next_child(ti->p, NULL, 0); if (!p) return NULL; - ti = p->data; + ti = p->_data; } return ti; } @@ -623,7 +623,7 @@ static bool tile_is_first(struct tileinfo *ti safe) while (ti->direction != Neither) { if (ti->p != next_child(ti->p->parent, NULL, 0)) return False; - ti = ti->p->parent->data; + ti = ti->p->parent->_data; } return True; } @@ -631,7 +631,7 @@ static bool tile_is_first(struct tileinfo *ti safe) static struct pane *tile_root_popup(struct tileinfo *ti safe) { while (ti->direction != Neither) - ti = ti->p->parent->data; + ti = ti->p->parent->_data; return next_child(ti->p, NULL, 1); } @@ -651,7 +651,7 @@ static struct tileinfo *safe tile_next_named(struct tileinfo *ti safe, static bool wrong_pane(struct cmd_info const *ci safe) { - struct tileinfo *ti = ci->home->data; + struct tileinfo *ti = ci->home->_data; if (ci->str || ti->group) { if (!ci->str || !ti->group) @@ -672,7 +672,7 @@ DEF_CMD(tile_window_next) */ struct pane *p = ci->home; struct pane *p2; - struct tileinfo *ti = p->data; + struct tileinfo *ti = p->_data; struct tileinfo *t2; if (wrong_pane(ci)) @@ -710,7 +710,7 @@ DEF_CMD(tile_window_next) DEF_CMD(tile_window_prev) { struct pane *p = ci->home; - struct tileinfo *ti = p->data; + struct tileinfo *ti = p->_data; struct tileinfo *t2; if (wrong_pane(ci)) @@ -785,7 +785,7 @@ DEF_CMD(tile_window_splity) DEF_CMD(tile_window_close) { struct pane *p = ci->home; - struct tileinfo *ti = p->data; + struct tileinfo *ti = p->_data; if (wrong_pane(ci)) return Efallthrough; @@ -818,7 +818,7 @@ DEF_CMD(tile_window_close_others) { struct pane *p = ci->home; struct pane *parent = p->parent; - struct tileinfo *ti = p->data; + struct tileinfo *ti = p->_data; bool found = True; if (wrong_pane(ci)) @@ -851,7 +851,7 @@ DEF_CMD(tile_other) */ struct pane *p = ci->home; struct pane *p2; - struct tileinfo *ti = p->data; + struct tileinfo *ti = p->_data; struct tileinfo *ti2; int horiz, after; @@ -902,7 +902,7 @@ DEF_CMD(tile_other) DEF_CMD(tile_this) { - struct tileinfo *ti = ci->home->data; + struct tileinfo *ti = ci->home->_data; if (ci->str || ti->group) { if (!ci->str || !ti->group) @@ -929,7 +929,7 @@ DEF_CMD(tile_doc) /* Find the pane displaying given document, preferrably not * this pane */ - struct tileinfo *ti = ci->home->data; + struct tileinfo *ti = ci->home->_data; struct tileinfo *t; char *name; @@ -968,7 +968,7 @@ DEF_CMD(tile_doc) DEF_CMD(tile_root) { struct pane *p = ci->home; - struct tileinfo *ti = p->data; + struct tileinfo *ti = p->_data; if (ti->direction != Neither) return Efallthrough; @@ -986,7 +986,7 @@ DEF_CMD(tile_root) DEF_CMD(tile_child_notify) { struct pane *p = ci->home; - struct tileinfo *ti = p->data; + struct tileinfo *ti = p->_data; struct pane *c = ci->focus; if (c->z) diff --git a/lib-wiggle.c b/lib-wiggle.c index fbc20323..1fd05191 100644 --- a/lib-wiggle.c +++ b/lib-wiggle.c @@ -203,7 +203,7 @@ struct wiggle_data { DEF_CMD(notify_close) { /* Private pane received a "close" notification. */ - struct wiggle_data *wd = ci->home->data; + struct wiggle_data *wd = ci->home->_data; int i; for (i = 0; i < 3; i++) @@ -220,7 +220,7 @@ DEF_CMD(notify_close) DEF_CMD_CLOSED(wiggle_close) { - struct wiggle_data *wd = ci->home->data; + struct wiggle_data *wd = ci->home->_data; int i; for (i = 0; i < 3 ; i++) { @@ -264,7 +264,7 @@ static void forward_lines(struct pane *p safe, struct mark *m safe, DEF_CMD(wiggle_text) { /* remember pane, mark1, mark2, num, num2 */ - struct wiggle_data *wd = ci->home->data; + struct wiggle_data *wd = ci->home->_data; struct mark *m2; char k0 = ci->key[0]; int which = k0 == 'b' ? 1 : k0 == 'a' ? 2 : 0; @@ -302,7 +302,7 @@ DEF_CMD(wiggle_text) DEF_CMD(wiggle_extract) { - struct wiggle_data *wd = ci->home->data; + struct wiggle_data *wd = ci->home->_data; struct wtxt *wt; struct stream str; @@ -330,7 +330,7 @@ DEF_CMD(wiggle_set_common) /* Set the attribute 'str' on all common ranges in * 'before' and 'after' */ - struct wiggle_data *wd = ci->home->data; + struct wiggle_data *wd = ci->home->_data; const char *attr = ci->str ?: "render:common"; struct stream before, after; struct file bfile, afile; @@ -573,7 +573,7 @@ static char *collect_merge(struct merge *merge safe, DEF_CMD(wiggle_set_wiggle) { - struct wiggle_data *wd = ci->home->data; + struct wiggle_data *wd = ci->home->_data; struct stream ostr, astr, bstr; struct file of, af, bf; struct csl *csl1, *csl2; @@ -648,7 +648,7 @@ DEF_CMD(wiggle_find) * num2 is max number of lines, defaults to searching whole file. * Returns number of fuzz lines, plus 1 */ - struct wiggle_data *wd = ci->home->data; + struct wiggle_data *wd = ci->home->_data; int lines = ci->num2; struct pane *p = ci->focus; struct stream str; @@ -744,7 +744,7 @@ DEF_CMD(wiggle_find) DEF_CMD(wiggle_get) { - struct wiggle_data *wd = ci->home->data; + struct wiggle_data *wd = ci->home->_data; if (wd->conflicts < 0) return Einval; diff --git a/mode-emacs.c b/mode-emacs.c index 001469f2..ebe17862 100644 --- a/mode-emacs.c +++ b/mode-emacs.c @@ -817,7 +817,7 @@ REDEF_CMD(emacs_cmd_complete); DEF_CMD(find_complete) { - char *type = ci->home->data; + char *type = ci->home->_data; if (strstarts(type, "file")) return emacs_file_complete_func(ci); @@ -833,7 +833,7 @@ DEF_CMD(find_complete) DEF_CMD(find_done) { int ret; - char *type = ci->home->data; + char *type = ci->home->_data; char *str = call_ret(strsave, "doc:get-str", ci->focus); const char *norm = NULL; struct stat stb; @@ -977,7 +977,7 @@ DEF_CMD(find_prevnext) * walk the list in mru order. * When we find it, insert the name into ci->focus document */ - char *type = ci->home->data; + char *type = ci->home->_data; struct find_helper h; if (strcmp(type, "doc") != 0) @@ -1006,7 +1006,7 @@ DEF_CMD(find_prevnext) DEF_CMD(find_attr) { - char *type = ci->home->data; + char *type = ci->home->_data; if (!ci->str) return Enoarg; @@ -1043,7 +1043,7 @@ DEF_CMD(find_attr) DEF_CMD(find_check_replace) { char *str, *cp, *sl; - char *type = ci->home->data; + char *type = ci->home->_data; char *initial_path; char *prev_dir; struct stat stb; @@ -1457,7 +1457,7 @@ REDEF_CMD(emacs_file_complete) int fd; struct pane *par, *pop, *docp, *p; struct call_return cr; - char *type = ci->home->data; + char *type = ci->home->_data; char *initial = attr_find(ci->home->attrs, "initial_path"); int wholebuf = strcmp(type, "file") == 0; struct mark *st; -- 2.39.5