13
13
* Copyright (c) 2013, 2014 Christian Couder <[email protected] >
14
14
*/
15
15
16
- struct trailer_info {
16
+ struct trailer_block {
17
17
/*
18
18
* True if there is a blank line before the location pointed to by
19
- * trailer_block_start .
19
+ * "start" .
20
20
*/
21
21
int blank_line_before_trailer ;
22
22
23
23
/*
24
- * Offsets to the trailer block start and end positions in the input
25
- * string. If no trailer block is found, these are both set to the
26
- * "true" end of the input (find_end_of_log_message()).
24
+ * The locations of the start and end positions of the trailer block
25
+ * found, as offsets from the beginning of the source text from which
26
+ * this trailer block was parsed. If no trailer block is found, these
27
+ * are both set to 0.
27
28
*/
28
- size_t trailer_block_start , trailer_block_end ;
29
+ size_t start , end ;
29
30
30
31
/*
31
32
* Array of trailers found.
@@ -975,16 +976,16 @@ static void unfold_value(struct strbuf *val)
975
976
strbuf_release (& out );
976
977
}
977
978
978
- static struct trailer_info * trailer_info_new (void )
979
+ static struct trailer_block * trailer_block_new (void )
979
980
{
980
- struct trailer_info * info = xcalloc (1 , sizeof (* info ));
981
- return info ;
981
+ struct trailer_block * trailer_block = xcalloc (1 , sizeof (* trailer_block ));
982
+ return trailer_block ;
982
983
}
983
984
984
- static struct trailer_info * trailer_info_get (const struct process_trailer_options * opts ,
985
- const char * str )
985
+ static struct trailer_block * trailer_block_get (const struct process_trailer_options * opts ,
986
+ const char * str )
986
987
{
987
- struct trailer_info * info = trailer_info_new ();
988
+ struct trailer_block * trailer_block = trailer_block_new ();
988
989
size_t end_of_log_message = 0 , trailer_block_start = 0 ;
989
990
struct strbuf * * trailer_lines , * * ptr ;
990
991
char * * trailer_strings = NULL ;
@@ -1017,34 +1018,34 @@ static struct trailer_info *trailer_info_get(const struct process_trailer_option
1017
1018
}
1018
1019
strbuf_list_free (trailer_lines );
1019
1020
1020
- info -> blank_line_before_trailer = ends_with_blank_line (str ,
1021
- trailer_block_start );
1022
- info -> trailer_block_start = trailer_block_start ;
1023
- info -> trailer_block_end = end_of_log_message ;
1024
- info -> trailers = trailer_strings ;
1025
- info -> trailer_nr = nr ;
1021
+ trailer_block -> blank_line_before_trailer = ends_with_blank_line (str ,
1022
+ trailer_block_start );
1023
+ trailer_block -> start = trailer_block_start ;
1024
+ trailer_block -> end = end_of_log_message ;
1025
+ trailer_block -> trailers = trailer_strings ;
1026
+ trailer_block -> trailer_nr = nr ;
1026
1027
1027
- return info ;
1028
+ return trailer_block ;
1028
1029
}
1029
1030
1030
1031
/*
1031
- * Parse trailers in "str", populating the trailer info and "trailer_objects"
1032
+ * Parse trailers in "str", populating the trailer_block and "trailer_objects"
1032
1033
* linked list structure.
1033
1034
*/
1034
- struct trailer_info * parse_trailers (const struct process_trailer_options * opts ,
1035
- const char * str ,
1036
- struct list_head * trailer_objects )
1035
+ struct trailer_block * parse_trailers (const struct process_trailer_options * opts ,
1036
+ const char * str ,
1037
+ struct list_head * trailer_objects )
1037
1038
{
1038
- struct trailer_info * info ;
1039
+ struct trailer_block * trailer_block ;
1039
1040
struct strbuf tok = STRBUF_INIT ;
1040
1041
struct strbuf val = STRBUF_INIT ;
1041
1042
size_t i ;
1042
1043
1043
- info = trailer_info_get (opts , str );
1044
+ trailer_block = trailer_block_get (opts , str );
1044
1045
1045
- for (i = 0 ; i < info -> trailer_nr ; i ++ ) {
1046
+ for (i = 0 ; i < trailer_block -> trailer_nr ; i ++ ) {
1046
1047
int separator_pos ;
1047
- char * trailer = info -> trailers [i ];
1048
+ char * trailer = trailer_block -> trailers [i ];
1048
1049
if (starts_with (trailer , comment_line_str ))
1049
1050
continue ;
1050
1051
separator_pos = find_separator (trailer , separators );
@@ -1065,7 +1066,7 @@ struct trailer_info *parse_trailers(const struct process_trailer_options *opts,
1065
1066
}
1066
1067
}
1067
1068
1068
- return info ;
1069
+ return trailer_block ;
1069
1070
}
1070
1071
1071
1072
void free_trailers (struct list_head * trailers )
@@ -1077,28 +1078,28 @@ void free_trailers(struct list_head *trailers)
1077
1078
}
1078
1079
}
1079
1080
1080
- size_t trailer_block_start (struct trailer_info * info )
1081
+ size_t trailer_block_start (struct trailer_block * trailer_block )
1081
1082
{
1082
- return info -> trailer_block_start ;
1083
+ return trailer_block -> start ;
1083
1084
}
1084
1085
1085
- size_t trailer_block_end (struct trailer_info * info )
1086
+ size_t trailer_block_end (struct trailer_block * trailer_block )
1086
1087
{
1087
- return info -> trailer_block_end ;
1088
+ return trailer_block -> end ;
1088
1089
}
1089
1090
1090
- int blank_line_before_trailer_block (struct trailer_info * info )
1091
+ int blank_line_before_trailer_block (struct trailer_block * trailer_block )
1091
1092
{
1092
- return info -> blank_line_before_trailer ;
1093
+ return trailer_block -> blank_line_before_trailer ;
1093
1094
}
1094
1095
1095
- void trailer_info_release (struct trailer_info * info )
1096
+ void trailer_block_release (struct trailer_block * trailer_block )
1096
1097
{
1097
1098
size_t i ;
1098
- for (i = 0 ; i < info -> trailer_nr ; i ++ )
1099
- free (info -> trailers [i ]);
1100
- free (info -> trailers );
1101
- free (info );
1099
+ for (i = 0 ; i < trailer_block -> trailer_nr ; i ++ )
1100
+ free (trailer_block -> trailers [i ]);
1101
+ free (trailer_block -> trailers );
1102
+ free (trailer_block );
1102
1103
}
1103
1104
1104
1105
void format_trailers (const struct process_trailer_options * opts ,
@@ -1166,19 +1167,19 @@ void format_trailers_from_commit(const struct process_trailer_options *opts,
1166
1167
struct strbuf * out )
1167
1168
{
1168
1169
LIST_HEAD (trailer_objects );
1169
- struct trailer_info * info = parse_trailers (opts , msg , & trailer_objects );
1170
+ struct trailer_block * trailer_block = parse_trailers (opts , msg , & trailer_objects );
1170
1171
1171
1172
/* If we want the whole block untouched, we can take the fast path. */
1172
1173
if (!opts -> only_trailers && !opts -> unfold && !opts -> filter &&
1173
1174
!opts -> separator && !opts -> key_only && !opts -> value_only &&
1174
1175
!opts -> key_value_separator ) {
1175
- strbuf_add (out , msg + info -> trailer_block_start ,
1176
- info -> trailer_block_end - info -> trailer_block_start );
1176
+ strbuf_add (out , msg + trailer_block -> start ,
1177
+ trailer_block -> end - trailer_block -> start );
1177
1178
} else
1178
1179
format_trailers (opts , & trailer_objects , out );
1179
1180
1180
1181
free_trailers (& trailer_objects );
1181
- trailer_info_release ( info );
1182
+ trailer_block_release ( trailer_block );
1182
1183
}
1183
1184
1184
1185
void trailer_iterator_init (struct trailer_iterator * iter , const char * msg )
@@ -1187,14 +1188,14 @@ void trailer_iterator_init(struct trailer_iterator *iter, const char *msg)
1187
1188
strbuf_init (& iter -> key , 0 );
1188
1189
strbuf_init (& iter -> val , 0 );
1189
1190
opts .no_divider = 1 ;
1190
- iter -> internal .info = trailer_info_get (& opts , msg );
1191
+ iter -> internal .trailer_block = trailer_block_get (& opts , msg );
1191
1192
iter -> internal .cur = 0 ;
1192
1193
}
1193
1194
1194
1195
int trailer_iterator_advance (struct trailer_iterator * iter )
1195
1196
{
1196
- if (iter -> internal .cur < iter -> internal .info -> trailer_nr ) {
1197
- char * line = iter -> internal .info -> trailers [iter -> internal .cur ++ ];
1197
+ if (iter -> internal .cur < iter -> internal .trailer_block -> trailer_nr ) {
1198
+ char * line = iter -> internal .trailer_block -> trailers [iter -> internal .cur ++ ];
1198
1199
int separator_pos = find_separator (line , separators );
1199
1200
1200
1201
iter -> raw = line ;
@@ -1211,7 +1212,7 @@ int trailer_iterator_advance(struct trailer_iterator *iter)
1211
1212
1212
1213
void trailer_iterator_release (struct trailer_iterator * iter )
1213
1214
{
1214
- trailer_info_release (iter -> internal .info );
1215
+ trailer_block_release (iter -> internal .trailer_block );
1215
1216
strbuf_release (& iter -> val );
1216
1217
strbuf_release (& iter -> key );
1217
1218
}
0 commit comments