From 27f40a4b2fea77bfe765a31127e94c15ca54c3f0 Mon Sep 17 00:00:00 2001 From: Petr Tesarik Date: Wed, 19 Sep 2012 17:26:52 +0200 Subject: [PATCH] Rename hed_blockoff_t -> hed_cursor_t "blockoff" has always been a poor choice for a name, because it said how the type works, not what it is. This type really is a cursor in the file, as it marks the position in the file, but it will also move when you insert/delete any preceding bytes in the file. --- libhed/file.c | 82 +++++++++++++++++++++--------------------- libhed/file.h | 68 +++++++++++++++++------------------ libhed/private.h | 2 +- src/ui/fileshow.c | 106 +++++++++++++++++++++++++++--------------------------- 4 files changed, 129 insertions(+), 129 deletions(-) diff --git a/libhed/file.c b/libhed/file.c index 27a49ac..c4fdba3 100644 --- a/libhed/file.c +++ b/libhed/file.c @@ -176,36 +176,36 @@ dump_blocks(struct file *file) #endif static void -_file_get_blockoff(struct file *file, uoff_t offset, blockoff_t *blockoff) +_file_get_cursor(struct file *file, uoff_t offset, hed_cursor_t *curs) { struct file_block *block; block = find_block(file_blocks(file), offset); assert(is_a_block(file_blocks(file), block)); - blockoff->pos = offset; - blockoff->block = block; - blockoff->off = offset - block_offset(file_blocks(file), block); - list_add(&blockoff->list, &block->refs); + curs->pos = offset; + curs->block = block; + curs->off = offset - block_offset(file_blocks(file), block); + list_add(&curs->list, &block->refs); BDEBUG("Mapped %llx to %llx+%llx/%llx\n", - offset, offset - blockoff->off, blockoff->off, block->t.size); + offset, offset - curs->off, curs->off, block->t.size); } void -file_get_blockoff(struct file *file, uoff_t offset, blockoff_t *blockoff) +file_get_cursor(struct file *file, uoff_t offset, hed_cursor_t *curs) { - if (is_a_blockoff(blockoff)) - file_put_blockoff(blockoff); - _file_get_blockoff(file, offset, blockoff); + if (is_a_cursor(curs)) + file_put_cursor(curs); + _file_get_cursor(file, offset, curs); } -void file_put_blockoff(blockoff_t *blockoff) +void file_put_cursor(hed_cursor_t *curs) { - list_del(&blockoff->list); + list_del(&curs->list); } void -file_dup_blockoff(const blockoff_t *src, blockoff_t *dst) +file_dup_cursor(const hed_cursor_t *src, hed_cursor_t *dst) { dst->pos = src->pos; dst->block = src->block; @@ -214,14 +214,14 @@ file_dup_blockoff(const blockoff_t *src, blockoff_t *dst) } void -file_dup2_blockoff(const blockoff_t *src, blockoff_t *dst) +file_dup2_cursor(const hed_cursor_t *src, hed_cursor_t *dst) { - if (is_a_blockoff(dst)) - file_put_blockoff(dst); - file_dup_blockoff(src, dst); + if (is_a_cursor(dst)) + file_put_cursor(dst); + file_dup_cursor(src, dst); } -/* Returns the number of contiguous bytes following @blockoff. */ +/* Returns the number of contiguous bytes following @curs. */ static inline uoff_t blockoff_len(const blockoff_t *blockoff) { @@ -1145,7 +1145,7 @@ load_blocks(struct file *file, const blockoff_t *from) list_add(&pos.list, &pos.block->refs); nblocks = ((len + part - 1) >> FILE_BLOCK_SHIFT) + 1; alloc_caches(file, preload, nblocks); - file_put_blockoff(&pos); + file_put_cursor(&pos); remap_caches(file->cache, preload, nblocks); @@ -1536,9 +1536,9 @@ file_cpin(struct file *file, void *buf, size_t count, const blockoff_t *pos) blockoff_t mypos; size_t ret; - file_dup_blockoff(pos, &mypos); + file_dup_cursor(pos, &mypos); ret = copy_in(file, buf, count, &mypos); - file_put_blockoff(&mypos); + file_put_cursor(&mypos); return ret; } @@ -1553,7 +1553,7 @@ file_fetch_block(struct file *file, uoff_t offset, size_t *size) if (real_size > file_size(file) - offset) real_size = file_size(file) - offset; - _file_get_blockoff(file, offset, &pos_blk); + _file_get_cursor(file, offset, &pos_blk); if (file_read_begin(file, &pos_blk) < 0) goto out_err; @@ -1566,7 +1566,7 @@ file_fetch_block(struct file *file, uoff_t offset, size_t *size) goto out_err_free; file_read_end(file); - file_put_blockoff(&pos_blk); + file_put_cursor(&pos_blk); *size = real_size; return buf; @@ -1574,7 +1574,7 @@ file_fetch_block(struct file *file, uoff_t offset, size_t *size) out_err_free: free(buf); out_err: - file_put_blockoff(&pos_blk); + file_put_cursor(&pos_blk); *size = 0; return NULL; } @@ -1971,7 +1971,7 @@ commit_backwards(struct commit_control *cc) goto final; /* Handle the trailing partial block */ - file_get_blockoff(cc->file, blkpos, &cc->begoff); + file_get_cursor(cc->file, blkpos, &cc->begoff); switch_partial(cc); ret |= commit_partial(cc); retpartial = cc->partial; @@ -1979,14 +1979,14 @@ commit_backwards(struct commit_control *cc) /* Handle the middle part */ switch_partial(cc); while ( (blkpos -= FILE_BLOCK_SIZE) > begpos) { - file_get_blockoff(cc->file, blkpos, &cc->begoff); + file_get_cursor(cc->file, blkpos, &cc->begoff); ret |= commit_partial(cc); } switch_partial(cc); /* wrap around */ final: /* Handle the first block (partiall or not) */ - file_get_blockoff(cc->file, begpos, &cc->begoff); + file_get_cursor(cc->file, begpos, &cc->begoff); ret |= commit_partial(cc); cc->partial = retpartial; @@ -2013,7 +2013,7 @@ begin_skip(struct commit_control *cc) else ret |= commit_backwards(cc); file_move_relative(&cc->endoff, -(off_t)remain); - file_dup2_blockoff(&cc->endoff, &cc->begoff); + file_dup2_cursor(&cc->endoff, &cc->begoff); cc->needwrite = 0; return ret; @@ -2027,7 +2027,7 @@ end_skip(struct commit_control *cc) int ret = 0; /* Find the beginning of the physical block */ - file_dup2_blockoff(&cc->endoff, &cc->begoff); + file_dup2_cursor(&cc->endoff, &cc->begoff); partlen = FILE_BLOCK_OFF(cc->begoff.pos); file_move_relative(&cc->begoff, -(off_t)partlen); @@ -2114,8 +2114,8 @@ file_commit(struct file *file) dump_blocks(file); cc.partial = cc.partbuf; - _file_get_blockoff(file, 0,&cc.begoff); - file_dup_blockoff(&cc.begoff, &cc.endoff); + _file_get_cursor(file, 0,&cc.begoff); + file_dup_cursor(&cc.begoff, &cc.endoff); cc.shift = -cc.begoff.block->phys_pos; cc.needwrite = 0; while(!block_is_eof(cc.endoff.block)) { @@ -2125,10 +2125,10 @@ file_commit(struct file *file) if (cc.shift <= 0 && newshift > 0) { ret |= commit_forwards(&cc); - file_dup2_blockoff(&cc.endoff, &cc.begoff); + file_dup2_cursor(&cc.endoff, &cc.begoff); } else if (cc.shift > 0 && newshift <= 0) { ret |= commit_backwards(&cc); - file_dup2_blockoff(&cc.endoff, &cc.begoff); + file_dup2_cursor(&cc.endoff, &cc.begoff); } cc.shift = newshift; @@ -2150,8 +2150,8 @@ file_commit(struct file *file) ret |= commit_backwards(&cc); } - file_put_blockoff(&cc.begoff); - file_put_blockoff(&cc.endoff); + file_put_cursor(&cc.begoff); + file_put_cursor(&cc.endoff); ftruncate(cc.wfd, file_size(file)); file->phys_size = file_size(file); @@ -2264,9 +2264,9 @@ file_read_swap(struct file *file) if (! (swp = swp_init_read(file->swpname)) ) return -1; - _file_get_blockoff(file, 0, &pos); + _file_get_cursor(file, 0, &pos); ret = do_read_swap(file, swp, &pos); - file_put_blockoff(&pos); + file_put_cursor(&pos); swp_done(swp); return ret; @@ -2290,11 +2290,11 @@ eval_reg_cb(void *hookdata, char reg, off_t ofs, blockoff_t pos; long ret = AEF_DYNAMIC; - file_dup_blockoff(data->pos, &pos); + file_dup_cursor(data->pos, &pos); file_move_relative(&pos, ofs); if (copy_in(data->file, scramble, len, &pos)) ret = AEF_ERROR; - file_put_blockoff(&pos); + file_put_cursor(&pos); return ret; } @@ -2552,7 +2552,7 @@ find_expr(struct file *file, blockoff_t *from, int dir, if (file_read_begin(file, from)) return FINDOFF_ERROR; - file_dup_blockoff(from, &match); + file_dup_cursor(from, &match); p = block_data(match.block) + match.off; remain = match.block->t.size; for (pos = 0; pos < len; pos++) { @@ -2567,7 +2567,7 @@ find_expr(struct file *file, blockoff_t *from, int dir, remain--; } - file_put_blockoff(&match); + file_put_cursor(&match); file_read_end(file); if (pos == len) diff --git a/libhed/file.h b/libhed/file.h index 8b0cc5e..d4482f2 100644 --- a/libhed/file.h +++ b/libhed/file.h @@ -81,10 +81,10 @@ struct hed_file_block { /* Flags - see BLOCK_xxx below. */ long flags; - /* List of hed_blockoff_t offsets which reference this + /* List of hed_cursor_t offsets which reference this * structure. This is more flexible than refcounting, * because you may actually do something to the file_block, - * as long as you update all the hed_blockoff_t structs. + * as long as you update all the hed_cursor_t structs. */ struct hed_list_head refs; @@ -96,7 +96,7 @@ struct hed_file_block { uoff_t phys_pos; }; -/* A hed_blockoff_t consists of file position, its corresponding +/* A hed_cursor_t consists of file position, its corresponding * block pointer and the offset within that block. */ typedef struct { @@ -104,9 +104,9 @@ typedef struct { struct hed_file_block *block; uoff_t off; struct hed_list_head list; -} hed_blockoff_t; +} hed_cursor_t; -#define NULL_BLOCKOFF { 0, NULL, 0 } +#define NULL_CURSOR { 0, NULL, 0 } #define BLOCK_DIRTY 0x01 /* data has been modified */ #define BLOCK_INSERTED 0x02 /* insert/delete block */ @@ -193,7 +193,7 @@ struct hed_file { struct hed_file_block *null_block; #endif - hed_blockoff_t marks[MARKS_COUNT]; + hed_cursor_t marks[MARKS_COUNT]; }; #ifdef CONFIG_READAHEAD @@ -341,47 +341,47 @@ file_rmswp(struct hed_file *file) * want to reallocate the buffer to the exact length. */ void *file_fetch_block(struct hed_file *file, uoff_t offset, size_t *size); -/* Converts a logical @offset to a block plus offset (@blockoff). Returns +/* Converts a logical @offset to a cursor (@curs). Returns * non-zero on error, and the error code is available in @errno. */ -void file_get_blockoff(struct hed_file *file, uoff_t offset, - hed_blockoff_t *blockoff); +void file_get_cursor(struct hed_file *file, uoff_t offset, + hed_cursor_t *curs); -/* Mark @blockoff as no longer needed. In particular, this stops tracking +/* Mark @curs as no longer needed. In particular, this stops tracking * file changes with this pointer. */ -void file_put_blockoff(hed_blockoff_t *blockoff); +void file_put_cursor(hed_cursor_t *curs); -/* Duplicate into an empty hed_blockoff_t */ -void file_dup_blockoff(const hed_blockoff_t *src, hed_blockoff_t *dst); +/* Duplicate into an empty hed_cursor_t */ +void file_dup_cursor(const hed_cursor_t *src, hed_cursor_t *dst); -/* Duplicate into an initialized blockoff_t */ -void file_dup2_blockoff(const hed_blockoff_t *src, hed_blockoff_t *dst); +/* Duplicate into an initialized hed_cursor_t */ +void file_dup2_cursor(const hed_cursor_t *src, hed_cursor_t *dst); -#define is_a_blockoff(blockoff) (!!(blockoff)->block) +#define is_a_cursor(curs) (!!(curs)->block) /* Relative move from a given block offset. * If the resulting position is out of bounds (either < 0 or > OFF_MAX), * the offset is adjusted to only move to 0 or OFF_MAX. * Returns the actual offset which was used. */ -off_t file_move_relative(hed_blockoff_t *blockoff, off_t num); +off_t file_move_relative(hed_cursor_t *curs, off_t num); /* Given you know that offset is just one byte beyond the last span, - * get the block which contains byte at @blockoff. + * get the block which contains byte at @curs. * If the block is not available, it is loaded from disk, so do not * use this function if you only want to iterate through virtual * blocks. * Returns non-zero on error, and the error code is available in @errno. */ -int file_next_block(struct hed_file *file, hed_blockoff_t *blockoff); +int file_next_block(struct hed_file *file, hed_cursor_t *curs); /* Ensure reads are valid from a block offset. * Returns: * <0 on error * 0 on success */ -int file_read_begin(struct hed_file *file, const hed_blockoff_t *blockoff); +int file_read_begin(struct hed_file *file, const hed_cursor_t *curs); /* Do whatever cleanup is necessary when read is complete. */ void file_read_end(struct hed_file *file); @@ -390,23 +390,23 @@ void file_read_end(struct hed_file *file); * Returns number of bytes which were not copied, i.e. zero on success. */ size_t file_cpin(struct hed_file *file, void *buf, size_t count, - const hed_blockoff_t *pos); + const hed_cursor_t *pos); /* Find a given sequence of bytes in the file, starting at the @pos file * offset and possibly wrapping around. @dir is +1 or -1. */ -int file_find_expr(struct hed_file *file, hed_blockoff_t *pos, int dir, +int file_find_expr(struct hed_file *file, hed_cursor_t *pos, int dir, struct hed_expr *expr, hed_expr_reg_cb expr_cb, void *expr_cb_data); #define FINDOFF_NO_MATCH -1 #define FINDOFF_ERROR -2 /* Sets a single byte in the file. */ -int file_set_byte(struct hed_file *file, hed_blockoff_t *blockoff, +int file_set_byte(struct hed_file *file, hed_cursor_t *curs, unsigned char byte); /* Sets multiple bytes in the file. */ -size_t file_set_block(struct hed_file *file, hed_blockoff_t *blockoff, +size_t file_set_block(struct hed_file *file, hed_cursor_t *curs, unsigned char *buf, size_t len); -uoff_t file_set_bytes(struct hed_file *file, hed_blockoff_t *blockoff, +uoff_t file_set_bytes(struct hed_file *file, hed_cursor_t *curs, unsigned char byte, uoff_t rep); /* To insert bytes: @@ -418,28 +418,28 @@ uoff_t file_set_bytes(struct hed_file *file, hed_blockoff_t *blockoff, * be careful with aliases, because the insert might get merged/freed */ int file_insert_begin(struct hed_file *file, - hed_blockoff_t *blockoff, hed_blockoff_t *blockoff_ins); -void file_insert_end(struct hed_file *file, hed_blockoff_t *blockoff_ins); + hed_cursor_t *curs, hed_cursor_t *curs_ins); +void file_insert_end(struct hed_file *file, hed_cursor_t *curs_ins); /* Inserts a single byte to the file. */ -int file_insert_byte(struct hed_file *file, hed_blockoff_t *blockoff, +int file_insert_byte(struct hed_file *file, hed_cursor_t *curs, unsigned char byte); /* Insert a block of bytes to the file. */ -size_t file_insert_block(struct hed_file *file, hed_blockoff_t *blockoff, +size_t file_insert_block(struct hed_file *file, hed_cursor_t *curs, unsigned char *buf, size_t len); /* The following function is a shorthand for the usual * file_insert_begin, file_insert_block, file_insert_end * sequence. */ -size_t file_insert_once(struct hed_file *file, hed_blockoff_t *blockoff, +size_t file_insert_once(struct hed_file *file, hed_cursor_t *curs, unsigned char *buf, size_t len); /* Erases a single byte from the file. */ -# define file_erase_byte(file,blockoff) (file_erase_block((file),(blockoff),1)) +# define file_erase_byte(file,curs) (file_erase_block((file),(curs),1)) /* Erases a block of bytes from the file. */ -size_t file_erase_block(struct hed_file *file, hed_blockoff_t *blockoff, uoff_t len); +size_t file_erase_block(struct hed_file *file, hed_cursor_t *curs, uoff_t len); /******************************************************************* * MARK FUNCTIONS @@ -449,11 +449,11 @@ size_t file_erase_block(struct hed_file *file, hed_blockoff_t *blockoff, uoff_t static inline bool file_mark_is_valid(struct hed_file *file, int mark) { - return is_a_blockoff(&file->marks[mark]); + return is_a_cursor(&file->marks[mark]); } /* Return pointer to a mark */ -static inline hed_blockoff_t* +static inline hed_cursor_t* file_mark(struct hed_file *file, int mark) { return &file->marks[mark]; diff --git a/libhed/private.h b/libhed/private.h index 143974a..203eebc 100644 --- a/libhed/private.h +++ b/libhed/private.h @@ -7,7 +7,7 @@ #define file_block hed_file_block #define file hed_file -#define blockoff_t hed_blockoff_t +#define blockoff_t hed_cursor_t #define null_block(tree) (tree_entry(null_node(tree),struct file_block,t)) diff --git a/src/ui/fileshow.c b/src/ui/fileshow.c index a71b184..fa2b566 100644 --- a/src/ui/fileshow.c +++ b/src/ui/fileshow.c @@ -91,17 +91,17 @@ static bool subst_all; struct fileshow_priv { struct hed_file *file; - hed_blockoff_t offset; /* Beginning of screen (file offset) */ + hed_cursor_t offset; /* Beginning of screen (file offset) */ int width, height; /* Width and height of the viewport */ ssize_t ssize; /* Size (in bytes) of the viewport */ - hed_blockoff_t cursor; /* Cursor position (file offset) */ - hed_blockoff_t visual; /* Visual mark */ + hed_cursor_t cursor; /* Cursor position (file offset) */ + hed_cursor_t visual; /* Visual mark */ int digitpos; /* Selected digit in the hexadecimal column. */ unsigned char curbyte; /* The value of the current byte under the cursor. */ - hed_blockoff_t insert; + hed_cursor_t insert; char idmark; /* insertion/deletion mark at screen start */ @@ -158,7 +158,7 @@ pos_column(struct fileshow_priv *data, uoff_t pos) static void set_viewport(struct fileshow_priv *data, off_t pos) { - file_get_blockoff(data->file, pos, &data->offset); + file_get_cursor(data->file, pos, &data->offset); update_idmark(data); } @@ -177,7 +177,7 @@ fixup_viewport(struct fileshow_priv *data) static void set_cursor(struct fileshow_priv *data, off_t pos) { - file_get_blockoff(data->file, pos, &data->cursor); + file_get_cursor(data->file, pos, &data->cursor); fixup_viewport(data); } @@ -251,8 +251,8 @@ nomem: data->width = width; data->ssize = data->height * data->width; - file_get_blockoff(data->file, 0, &data->cursor); - file_dup_blockoff(&data->cursor, &data->offset); + file_get_cursor(data->file, 0, &data->cursor); + file_dup_cursor(&data->cursor, &data->offset); data->idmark = ' '; } @@ -273,9 +273,9 @@ is_inside_visual(struct fileshow_priv *data, off_t pos) /* Returns ZERO ON ERROR. */ static size_t -visual_extents(struct fileshow_priv *data, hed_blockoff_t *base) +visual_extents(struct fileshow_priv *data, hed_cursor_t *base) { - hed_blockoff_t *basesrc; + hed_cursor_t *basesrc; size_t ret; if (data->visual.pos < data->cursor.pos) { ret = data->cursor.pos - data->visual.pos + 1; @@ -284,7 +284,7 @@ visual_extents(struct fileshow_priv *data, hed_blockoff_t *base) ret = data->visual.pos - data->cursor.pos + 1; basesrc = &data->cursor; } - file_dup2_blockoff(basesrc, base); + file_dup2_cursor(basesrc, base); return ret; } @@ -377,7 +377,7 @@ static void fileshow_redraw(struct ui_component *comp) { struct fileshow_priv *data = comp->data; - hed_blockoff_t pos; + hed_cursor_t pos; char idmark; /* insertion/deletion marks */ uoff_t maxofs; @@ -406,7 +406,7 @@ fileshow_redraw(struct ui_component *comp) xindent = ofslen + 2; xascpos = xindent + data->width * 3 + 1; - file_dup_blockoff(&data->offset, &pos); + file_dup_cursor(&data->offset, &pos); p = block_data(pos.block) + pos.off; idmark = data->idmark; assert(pos.pos >= 0); @@ -497,7 +497,7 @@ fileshow_redraw(struct ui_component *comp) COLOR_NEUTRAL | COLOR_VISUAL, ' '); } done: - file_put_blockoff(&pos); + file_put_cursor(&pos); assert(data->cursor.pos >= 0); @@ -552,7 +552,7 @@ jump_relative(struct fileshow_priv *data, int num) static void finish_insert(struct fileshow_priv *data) { - if (is_a_blockoff(&data->insert)) { + if (is_a_cursor(&data->insert)) { file_insert_end(data->file, &data->insert); if (data->column == FSC_HEX && data->digitpos) jump_relative(data, 1); @@ -563,8 +563,8 @@ static void erase_at_cursor(struct fileshow_priv *data, uoff_t len) { file_erase_block(data->file, &data->cursor, len); - if (!is_a_blockoff(&data->offset)) { - file_dup2_blockoff(&data->cursor, &data->offset); + if (!is_a_cursor(&data->offset)) { + file_dup2_cursor(&data->cursor, &data->offset); file_move_relative(&data->offset, -pos_column(data, data->offset.pos)); update_idmark(data); @@ -574,10 +574,10 @@ erase_at_cursor(struct fileshow_priv *data, uoff_t len) static off_t do_search(struct fileshow_priv *data) { - hed_blockoff_t off; + hed_cursor_t off; int res; - file_dup_blockoff(&data->cursor, &off); + file_dup_cursor(&data->cursor, &off); file_move_relative(&off, data->last_search_dir); res = file_find_expr(data->file, &off, data->last_search_dir, data->last_search, eval_reg_cb, data); @@ -586,7 +586,7 @@ do_search(struct fileshow_priv *data) else if (!subst_all) errmsg("No match found"); - file_put_blockoff(&off); + file_put_cursor(&off); return off.pos; } @@ -656,10 +656,10 @@ expr_subst1(struct inputline_data *inpline, void *hookdata) static void clip_yank(struct fileshow_priv *data) { - hed_blockoff_t base = NULL_BLOCKOFF; + hed_cursor_t base = NULL_CURSOR; size_t len = visual_extents(data, &base); - file_put_blockoff(&base); + file_put_cursor(&base); if (clipboard[data->reg].data) free(clipboard[data->reg].data); clipboard[data->reg].data = @@ -696,7 +696,7 @@ clip_put(struct fileshow_priv *data) static void clip_overwrite(struct fileshow_priv *data) { - hed_blockoff_t start = NULL_BLOCKOFF; + hed_cursor_t start = NULL_CURSOR; off_t i; ssize_t len; @@ -710,14 +710,14 @@ clip_overwrite(struct fileshow_priv *data) len = visual_extents(data, &start); } else { /* splat */ - file_dup_blockoff(&data->cursor, &start); + file_dup_cursor(&data->cursor, &start); len = clipboard[data->reg].len; } i = min(len, clipboard[data->reg].len); file_set_block(data->file, &start, clipboard[data->reg].data, i); file_set_bytes(data->file, &start, 0, len - i); - file_put_blockoff(&start); + file_put_cursor(&start); } static void @@ -789,14 +789,14 @@ static void write_region(struct inputline_data *inpline, void *hookdata) { struct fileshow_priv *data = hookdata; - hed_blockoff_t base = NULL_BLOCKOFF; + hed_cursor_t base = NULL_CURSOR; size_t len = visual_extents(data, &base); unsigned char *buf; char *fname = inpline->buf; int flen = inpline->buf_len; FILE *f; - file_put_blockoff(&base); + file_put_cursor(&base); /* Trim leading/trailing whitespaces */ while (isspace(*fname)) @@ -891,15 +891,15 @@ static void pipe_region(struct inputline_data *inpline, void *hookdata) { struct fileshow_priv *data = hookdata; - hed_blockoff_t base = NULL_BLOCKOFF; + hed_cursor_t base = NULL_CURSOR; size_t len = visual_extents(data, &base); char *argv[4] = { "/bin/sh", "-c", inpline->buf, NULL }; int p_rd[2], p_wr[2]; pid_t pid; - file_put_blockoff(&base); + file_put_cursor(&base); - file_put_blockoff(&data->visual); + file_put_cursor(&data->visual); data->mode = MODE_NORMAL; pipe(p_rd); @@ -947,7 +947,7 @@ pipe_region(struct inputline_data *inpline, void *hookdata) } } -static hed_blockoff_t xre; +static hed_cursor_t xre; static long eval_mark_cb(void *hookdata, char mark, @@ -979,22 +979,22 @@ eval_reg_cb(void *hookdata, char reg, off_t ofs, struct fileshow_priv *data = hookdata; unsigned char *buf; size_t blen; - hed_blockoff_t blkpos = NULL_BLOCKOFF; + hed_cursor_t blkpos = NULL_CURSOR; off_t skip; int r; long ret; switch (reg) { case ',': - file_dup_blockoff(&data->cursor, &blkpos); + file_dup_cursor(&data->cursor, &blkpos); break; case '_': - file_get_blockoff(data->file, 0, &blkpos); + file_get_cursor(data->file, 0, &blkpos); break; case '.': - if (!is_a_blockoff(&xre)) + if (!is_a_cursor(&xre)) goto out_zero; - file_dup_blockoff(&xre, &blkpos); + file_dup_cursor(&xre, &blkpos); break; default: r = ch2reg(reg); @@ -1031,7 +1031,7 @@ eval_reg_cb(void *hookdata, char reg, off_t ofs, } ret = file_cpin(data->file, scramble, len, &blkpos) ? AEF_ERROR : 0; - file_put_blockoff(&blkpos); + file_put_cursor(&blkpos); return ret; out_zero: @@ -1127,11 +1127,11 @@ reval_expr(struct inputline_data *inpline, void *hookdata) file_set_block(data->file, &xre, ebuf, rlen); } expr_free(expr); - file_put_blockoff(&xre); + file_put_cursor(&xre); xre.block = NULL; out: if (data->mode != MODE_VISUAL) - file_put_blockoff(&data->visual); + file_put_cursor(&data->visual); } static void exmode(struct inputline_data *inpline, void *hookdata); @@ -1182,7 +1182,7 @@ static void exmode_cmd_reval(struct fileshow_priv *data) { if (data->mode != MODE_VISUAL) - file_dup_blockoff(&data->cursor, &data->visual); + file_dup_cursor(&data->cursor, &data->visual); inputline_init("Expression: ", reval_expr, data); } static void @@ -1334,17 +1334,17 @@ do_command(struct fileshow_priv *data, enum command cmd) case cmd_visual: if (data->mode == MODE_VISUAL) { - file_put_blockoff(&data->visual); + file_put_cursor(&data->visual); data->mode = MODE_NORMAL; } else { data->mode = MODE_VISUAL; - file_dup_blockoff(&data->cursor, &data->visual); + file_dup_cursor(&data->cursor, &data->visual); } break; case cmd_normal_mode: if (data->mode == MODE_VISUAL) - file_put_blockoff(&data->visual); + file_put_cursor(&data->visual); data->mode = MODE_NORMAL; break; @@ -1382,7 +1382,7 @@ do_command(struct fileshow_priv *data, enum command cmd) return EVH_SILENTHOLD; } clip_yank(data); - file_put_blockoff(&data->visual); + file_put_cursor(&data->visual); data->mode = MODE_NORMAL; break; @@ -1392,7 +1392,7 @@ do_command(struct fileshow_priv *data, enum command cmd) return EVH_SILENTHOLD; } clip_delete(data); - file_put_blockoff(&data->visual); + file_put_cursor(&data->visual); data->mode = MODE_NORMAL; break; @@ -1403,7 +1403,7 @@ do_command(struct fileshow_priv *data, enum command cmd) case cmd_clip_paste: if (data->mode == MODE_VISUAL) { clip_swap(data); - file_put_blockoff(&data->visual); + file_put_cursor(&data->visual); data->mode = MODE_NORMAL; } else { clip_put(data); @@ -1414,7 +1414,7 @@ do_command(struct fileshow_priv *data, enum command cmd) case cmd_clip_overwrite: clip_overwrite(data); if (data->mode == MODE_VISUAL) { - file_put_blockoff(&data->visual); + file_put_cursor(&data->visual); data->mode = MODE_NORMAL; } break; @@ -1728,10 +1728,10 @@ fileshow_normal_r_in(struct fileshow_priv *data, int ch) if (byte >= 0) { if (data->mode == MODE_VISUAL) { - hed_blockoff_t base = NULL_BLOCKOFF; + hed_cursor_t base = NULL_CURSOR; size_t len = visual_extents(data, &base); file_set_bytes(data->file, &base, byte, len); - file_put_blockoff(&base); + file_put_cursor(&base); } else { file_set_byte(data->file, &data->cursor, byte); } @@ -1746,7 +1746,7 @@ fileshow_normal_m_in(struct fileshow_priv *data, int ch) { int mark = ch2mark(ch); if (mark >= 0) - file_dup2_blockoff(&data->cursor, file_mark(data->file, mark)); + file_dup2_cursor(&data->cursor, file_mark(data->file, mark)); else errmsg("Invalid mark"); return EVH_SILENTHOLD; @@ -1793,11 +1793,11 @@ fileshow_byte_in(struct fileshow_priv *data, int ch) insert = (data->mode == MODE_INSERT && data->cursor.pos < OFF_MAX); - if (insert && !is_a_blockoff(&data->insert)) { + if (insert && !is_a_cursor(&data->insert)) { file_insert_begin(data->file, &data->cursor, &data->insert); data->digitpos = 0; if (data->offset.pos == data->cursor.pos) { - file_dup2_blockoff(&data->insert, &data->offset); + file_dup2_cursor(&data->insert, &data->offset); update_idmark(data); } } @@ -1827,7 +1827,7 @@ fileshow_byte_in(struct fileshow_priv *data, int ch) if (data->column != FSC_HEX) { file_insert_byte(data->file, &data->insert, byte); } else if (data->digitpos > 0) { - file_dup2_blockoff(&data->insert, &data->cursor); + file_dup2_cursor(&data->insert, &data->cursor); file_insert_byte(data->file, &data->insert, byte); } else { file_set_byte(data->file, &data->cursor, byte); -- 2.11.4.GIT