aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--map.c8
-rw-r--r--sam.c26
-rw-r--r--text.c34
-rw-r--r--vis-core.h6
-rw-r--r--vis-text-objects.c8
5 files changed, 41 insertions, 41 deletions
diff --git a/map.c b/map.c
index 6ec02d6..d8568ea 100644
--- a/map.c
+++ b/map.c
@@ -273,11 +273,11 @@ const Map *map_prefix(const Map *map, const char *prefix)
return top;
}
-static void clear(Map n)
+static void map_clear_impl(Map n)
{
if (!n.v) {
- clear(n.u.n->child[0]);
- clear(n.u.n->child[1]);
+ map_clear_impl(n.u.n->child[0]);
+ map_clear_impl(n.u.n->child[1]);
free(n.u.n);
} else {
free((char*)n.u.s);
@@ -287,7 +287,7 @@ static void clear(Map n)
void map_clear(Map *map)
{
if (map->u.n)
- clear(*map);
+ map_clear_impl(*map);
map->u.n = NULL;
map->v = NULL;
}
diff --git a/sam.c b/sam.c
index ae4106a..0f9810d 100644
--- a/sam.c
+++ b/sam.c
@@ -39,8 +39,8 @@ typedef struct Address Address;
typedef struct Command Command;
typedef struct CommandDef CommandDef;
-struct Change {
- enum ChangeType {
+struct SamChange {
+ enum SamChangeType {
TRANSCRIPT_INSERT = 1 << 0,
TRANSCRIPT_DELETE = 1 << 1,
TRANSCRIPT_CHANGE = TRANSCRIPT_INSERT|TRANSCRIPT_DELETE,
@@ -50,7 +50,7 @@ struct Change {
Filerange range; /* inserts are denoted by zero sized range (same start/end) */
const char *data; /* will be free(3)-ed after transcript has been processed */
size_t len; /* size in bytes of the chunk pointed to by data */
- Change *next; /* modification position increase monotonically */
+ SamChange *next; /* modification position increase monotonically */
int count; /* how often should data be inserted? */
};
@@ -456,17 +456,17 @@ const char *sam_error(enum SamError err) {
return idx < LENGTH(error_msg) ? error_msg[idx] : NULL;
}
-static void change_free(Change *c) {
+static void sam_change_free(SamChange *c) {
if (!c)
return;
free((char*)c->data);
free(c);
}
-static Change *change_new(Transcript *t, enum ChangeType type, Filerange *range, Win *win, Selection *sel) {
+static SamChange *sam_change_new(Transcript *t, enum SamChangeType type, Filerange *range, Win *win, Selection *sel) {
if (!text_range_valid(range))
return NULL;
- Change **prev, *next;
+ SamChange **prev, *next;
if (t->latest && t->latest->range.end <= range->start) {
prev = &t->latest->next;
next = t->latest->next;
@@ -482,7 +482,7 @@ static Change *change_new(Transcript *t, enum ChangeType type, Filerange *range,
t->error = SAM_ERR_CONFLICT;
return NULL;
}
- Change *new = calloc(1, sizeof *new);
+ SamChange *new = calloc(1, sizeof *new);
if (new) {
new->type = type;
new->range = *range;
@@ -506,15 +506,15 @@ static bool sam_transcript_error(Transcript *t, enum SamError error) {
}
static void sam_transcript_free(Transcript *t) {
- for (Change *c = t->changes, *next; c; c = next) {
+ for (SamChange *c = t->changes, *next; c; c = next) {
next = c->next;
- change_free(c);
+ sam_change_free(c);
}
}
static bool sam_insert(Win *win, Selection *sel, size_t pos, const char *data, size_t len, int count) {
Filerange range = text_range_new(pos, pos);
- Change *c = change_new(&win->file->transcript, TRANSCRIPT_INSERT, &range, win, sel);
+ SamChange *c = sam_change_new(&win->file->transcript, TRANSCRIPT_INSERT, &range, win, sel);
if (c) {
c->data = data;
c->len = len;
@@ -524,11 +524,11 @@ static bool sam_insert(Win *win, Selection *sel, size_t pos, const char *data, s
}
static bool sam_delete(Win *win, Selection *sel, Filerange *range) {
- return change_new(&win->file->transcript, TRANSCRIPT_DELETE, range, win, sel);
+ return sam_change_new(&win->file->transcript, TRANSCRIPT_DELETE, range, win, sel);
}
static bool sam_change(Win *win, Selection *sel, Filerange *range, const char *data, size_t len, int count) {
- Change *c = change_new(&win->file->transcript, TRANSCRIPT_CHANGE, range, win, sel);
+ SamChange *c = sam_change_new(&win->file->transcript, TRANSCRIPT_CHANGE, range, win, sel);
if (c) {
c->data = data;
c->len = len;
@@ -1244,7 +1244,7 @@ enum SamError sam_cmd(Vis *vis, const char *s) {
}
vis_file_snapshot(vis, file);
ptrdiff_t delta = 0;
- for (Change *c = t->changes; c; c = c->next) {
+ for (SamChange *c = t->changes; c; c = c->next) {
c->range.start += delta;
c->range.end += delta;
if (c->type & TRANSCRIPT_DELETE) {
diff --git a/text.c b/text.c
index abc04e6..399fa4b 100644
--- a/text.c
+++ b/text.c
@@ -53,13 +53,13 @@ typedef struct {
} Span;
/* A Change keeps all needed information to redo/undo an insertion/deletion. */
-typedef struct Change Change;
-struct Change {
+typedef struct TextChange TextChange;
+struct TextChange {
Span old; /* all pieces which are being modified/swapped out by the change */
Span new; /* all pieces which are introduced/swapped in by the change */
size_t pos; /* absolute position at which the change occurred */
- Change *next; /* next change which is part of the same revision */
- Change *prev; /* previous change which is part of the same revision */
+ TextChange *next; /* next change which is part of the same revision */
+ TextChange *prev; /* previous change which is part of the same revision */
};
/* A Revision is a list of Changes which are used to undo/redo all modifications
@@ -67,7 +67,7 @@ struct Change {
*/
typedef struct Revision Revision;
struct Revision {
- Change *change; /* the most recent change */
+ TextChange *change; /* the most recent change */
Revision *next; /* the next (child) revision in the undo tree */
Revision *prev; /* the previous (parent) revision in the undo tree */
Revision *earlier; /* the previous Revision, chronologically */
@@ -113,8 +113,8 @@ static Location piece_get_extern(const Text *txt, size_t pos);
static void span_init(Span *span, Piece *start, Piece *end);
static void span_swap(Text *txt, Span *old, Span *new);
/* change management */
-static Change *change_alloc(Text *txt, size_t pos);
-static void change_free(Change *c);
+static TextChange *text_change_alloc(Text *txt, size_t pos);
+static void text_change_free(TextChange *c);
/* revision management */
static Revision *revision_alloc(Text *txt);
static void revision_free(Revision *rev);
@@ -276,9 +276,9 @@ static Revision *revision_alloc(Text *txt) {
static void revision_free(Revision *rev) {
if (!rev)
return;
- for (Change *next, *c = rev->change; c; c = next) {
+ for (TextChange *next, *c = rev->change; c; c = next) {
next = c->next;
- change_free(c);
+ text_change_free(c);
}
free(rev);
}
@@ -358,14 +358,14 @@ static Location piece_get_extern(const Text *txt, size_t pos) {
/* allocate a new change, associate it with current revision or a newly
* allocated one if none exists. */
-static Change *change_alloc(Text *txt, size_t pos) {
+static TextChange *text_change_alloc(Text *txt, size_t pos) {
Revision *rev = txt->current_revision;
if (!rev) {
rev = revision_alloc(txt);
if (!rev)
return NULL;
}
- Change *c = calloc(1, sizeof *c);
+ TextChange *c = calloc(1, sizeof *c);
if (!c)
return NULL;
c->pos = pos;
@@ -376,7 +376,7 @@ static Change *change_alloc(Text *txt, size_t pos) {
return c;
}
-static void change_free(Change *c) {
+static void text_change_free(TextChange *c) {
if (!c)
return;
/* only free the new part of the span, the old one is still in use */
@@ -429,7 +429,7 @@ bool text_insert(Text *txt, size_t pos, const char *data, size_t len) {
if (cache_insert(txt, p, off, data, len))
return true;
- Change *c = change_alloc(txt, pos);
+ TextChange *c = text_change_alloc(txt, pos);
if (!c)
return false;
@@ -472,7 +472,7 @@ bool text_insert(Text *txt, size_t pos, const char *data, size_t len) {
static size_t revision_undo(Text *txt, Revision *rev) {
size_t pos = EPOS;
- for (Change *c = rev->change; c; c = c->next) {
+ for (TextChange *c = rev->change; c; c = c->next) {
span_swap(txt, &c->new, &c->old);
pos = c->pos;
}
@@ -481,7 +481,7 @@ static size_t revision_undo(Text *txt, Revision *rev) {
static size_t revision_redo(Text *txt, Revision *rev) {
size_t pos = EPOS;
- Change *c = rev->change;
+ TextChange *c = rev->change;
while (c->next)
c = c->next;
for ( ; c; c = c->prev) {
@@ -615,7 +615,7 @@ Text *text_loadat_method(int dirfd, const char *filename, enum TextLoadMethod me
piece_init(&txt->end, p, NULL, NULL, 0);
txt->size = p->len;
/* write an empty revision */
- change_alloc(txt, EPOS);
+ text_change_alloc(txt, EPOS);
text_snapshot(txt);
txt->saved_revision = txt->history;
@@ -673,7 +673,7 @@ bool text_delete(Text *txt, size_t pos, size_t len) {
size_t off = loc.off;
if (cache_delete(txt, p, off, len))
return true;
- Change *c = change_alloc(txt, pos);
+ TextChange *c = text_change_alloc(txt, pos);
if (!c)
return false;
diff --git a/vis-core.h b/vis-core.h
index 92770ee..fb1e50d 100644
--- a/vis-core.h
+++ b/vis-core.h
@@ -124,10 +124,10 @@ typedef struct { /** collects all information until an operator is e
Arg arg;
} Action;
-typedef struct Change Change;
+typedef struct SamChange SamChange;
typedef struct {
- Change *changes; /* all changes in monotonically increasing file position */
- Change *latest; /* most recent change */
+ SamChange *changes; /* all changes in monotonically increasing file position */
+ SamChange *latest; /* most recent change */
enum SamError error; /* non-zero in case something went wrong */
} Transcript;
diff --git a/vis-text-objects.c b/vis-text-objects.c
index a0f2bbb..8a35fd0 100644
--- a/vis-text-objects.c
+++ b/vis-text-objects.c
@@ -29,7 +29,7 @@ bool vis_textobject(Vis *vis, enum VisTextObject id) {
return true;
}
-static Filerange search_forward(Vis *vis, Text *txt, size_t pos) {
+static Filerange vis_text_object_search_forward(Vis *vis, Text *txt, size_t pos) {
Filerange range = text_range_empty();
Regex *regex = vis_regex(vis, NULL);
if (regex)
@@ -38,7 +38,7 @@ static Filerange search_forward(Vis *vis, Text *txt, size_t pos) {
return range;
}
-static Filerange search_backward(Vis *vis, Text *txt, size_t pos) {
+static Filerange vis_text_object_search_backward(Vis *vis, Text *txt, size_t pos) {
Filerange range = text_range_empty();
Regex *regex = vis_regex(vis, NULL);
if (regex)
@@ -183,11 +183,11 @@ const TextObject vis_textobjects[] = {
.txt = text_object_indentation,
},
[VIS_TEXTOBJECT_SEARCH_FORWARD] = {
- .vis = search_forward,
+ .vis = vis_text_object_search_forward,
.type = TEXTOBJECT_NON_CONTIGUOUS|TEXTOBJECT_EXTEND_FORWARD,
},
[VIS_TEXTOBJECT_SEARCH_BACKWARD] = {
- .vis = search_backward,
+ .vis = vis_text_object_search_backward,
.type = TEXTOBJECT_NON_CONTIGUOUS|TEXTOBJECT_EXTEND_BACKWARD,
},
};