From 11238b27edcc5ee8b49ffeb5d739852fd90182a8 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 19 May 2023 09:00:24 -0700 Subject: [PATCH] diff: avoid a macro in diff.h * src/diff.h (FILE_BUFFER): Remove. * src/io.c (file_buffer): New static function. All uses of FILE_BUFFER replaced. --- src/diff.h | 4 ---- src/io.c | 15 ++++++++++++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/diff.h b/src/diff.h index 53f09cf..276e2d4 100644 --- a/src/diff.h +++ b/src/diff.h @@ -337,10 +337,6 @@ struct file_data { lin equiv_max; }; -/* The file buffer, considered as an array of bytes rather than - as an array of words. */ -#define FILE_BUFFER(f) ((char *) (f)->buffer) - /* Data on two input files being compared. */ struct comparison diff --git a/src/io.c b/src/io.c index 6612a20..fe4f8b4 100644 --- a/src/io.c +++ b/src/io.c @@ -64,6 +64,15 @@ static lin equivs_index; /* Number of elements allocated in the array 'equivs'. */ static lin equivs_alloc; +/* The file buffer, considered as an array of bytes rather than + as an array of words. */ + +static char * +file_buffer (struct file_data const *f) +{ + return (char *) f->buffer; +} + /* Read a block of data into a file buffer, checking for EOF and error. */ void @@ -72,7 +81,7 @@ file_block_read (struct file_data *current, size_t size) if (size && ! current->eof) { size_t s = block_read (current->desc, - FILE_BUFFER (current) + current->buffered, size); + file_buffer (current) + current->buffered, size); if (s == SIZE_MAX) pfatal_with_name (current->name); current->buffered += s; @@ -232,7 +241,7 @@ find_and_hash_each_line (struct file_data *current) lin eqs_index = equivs_index; lin eqs_alloc = equivs_alloc; char const *suffix_begin = current->suffix_begin; - char const *bufend = FILE_BUFFER (current) + current->buffered; + char const *bufend = file_buffer (current) + current->buffered; bool ig_case = ignore_case; enum DIFF_white_space ig_white_space = ignore_white_space; bool diff_length_compare_anyway = @@ -479,7 +488,7 @@ static void prepare_text (struct file_data *current) { size_t buffered = current->buffered; - char *p = FILE_BUFFER (current); + char *p = file_buffer (current); if (!p) return;