trailer: spread usage of "trailer_block" language
Deprecate the "trailer_info" struct name and replace it with "trailer_block". This is more readable, for two reasons: 1. "trailer_info" on the surface sounds like it's about a single trailer when in reality it is a collection of one or more trailers, and 2. the "*_block" suffix is more informative than "*_info", because it describes a block (or region) of contiguous text which has trailers in it, which has been parsed into the trailer_block structure. Rename the size_t trailer_block_start, trailer_block_end; members of trailer_info to just "start" and "end". Rename the "info" pointer to "trailer_block" because it is more descriptive. Update comments accordingly. Signed-off-by: Linus Arver <linus@ucla.edu> Signed-off-by: Taylor Blau <me@ttaylorr.com>
This commit is contained in:
@ -141,8 +141,8 @@ static void interpret_trailers(const struct process_trailer_options *opts,
|
||||
{
|
||||
LIST_HEAD(head);
|
||||
struct strbuf sb = STRBUF_INIT;
|
||||
struct strbuf trailer_block = STRBUF_INIT;
|
||||
struct trailer_info *info;
|
||||
struct strbuf trailer_block_sb = STRBUF_INIT;
|
||||
struct trailer_block *trailer_block;
|
||||
FILE *outfile = stdout;
|
||||
|
||||
trailer_config_init();
|
||||
@ -152,13 +152,13 @@ static void interpret_trailers(const struct process_trailer_options *opts,
|
||||
if (opts->in_place)
|
||||
outfile = create_in_place_tempfile(file);
|
||||
|
||||
info = parse_trailers(opts, sb.buf, &head);
|
||||
trailer_block = parse_trailers(opts, sb.buf, &head);
|
||||
|
||||
/* Print the lines before the trailers */
|
||||
/* Print the lines before the trailer block */
|
||||
if (!opts->only_trailers)
|
||||
fwrite(sb.buf, 1, trailer_block_start(info), outfile);
|
||||
fwrite(sb.buf, 1, trailer_block_start(trailer_block), outfile);
|
||||
|
||||
if (!opts->only_trailers && !blank_line_before_trailer_block(info))
|
||||
if (!opts->only_trailers && !blank_line_before_trailer_block(trailer_block))
|
||||
fprintf(outfile, "\n");
|
||||
|
||||
|
||||
@ -172,15 +172,16 @@ static void interpret_trailers(const struct process_trailer_options *opts,
|
||||
}
|
||||
|
||||
/* Print trailer block. */
|
||||
format_trailers(opts, &head, &trailer_block);
|
||||
format_trailers(opts, &head, &trailer_block_sb);
|
||||
free_trailers(&head);
|
||||
fwrite(trailer_block.buf, 1, trailer_block.len, outfile);
|
||||
strbuf_release(&trailer_block);
|
||||
fwrite(trailer_block_sb.buf, 1, trailer_block_sb.len, outfile);
|
||||
strbuf_release(&trailer_block_sb);
|
||||
|
||||
/* Print the lines after the trailers as is */
|
||||
/* Print the lines after the trailer block as is. */
|
||||
if (!opts->only_trailers)
|
||||
fwrite(sb.buf + trailer_block_end(info), 1, sb.len - trailer_block_end(info), outfile);
|
||||
trailer_info_release(info);
|
||||
fwrite(sb.buf + trailer_block_end(trailer_block), 1,
|
||||
sb.len - trailer_block_end(trailer_block), outfile);
|
||||
trailer_block_release(trailer_block);
|
||||
|
||||
if (opts->in_place)
|
||||
if (rename_tempfile(&trailers_tempfile, file))
|
||||
|
Reference in New Issue
Block a user