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.
This commit is contained in:
Paul Eggert 2023-05-19 09:00:24 -07:00
parent d3e3696ec7
commit 11238b27ed
2 changed files with 12 additions and 7 deletions

View File

@ -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

View File

@ -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;