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.
@@ -981,16 +982,16 @@ static void unfold_value(struct strbuf *val)
981
982
strbuf_release (& out );
982
983
}
983
984
984
- static struct trailer_info * trailer_info_new (void )
985
+ static struct trailer_block * trailer_block_new (void )
985
986
{
986
- struct trailer_info * info = xcalloc (1 , sizeof (* info ));
987
- return info ;
987
+ struct trailer_block * trailer_block = xcalloc (1 , sizeof (* trailer_block ));
988
+ return trailer_block ;
988
989
}
989
990
990
- static struct trailer_info * trailer_info_get (const struct process_trailer_options * opts ,
991
- const char * str )
991
+ static struct trailer_block * trailer_block_get (const struct process_trailer_options * opts ,
992
+ const char * str )
992
993
{
993
- struct trailer_info * info = trailer_info_new ();
994
+ struct trailer_block * trailer_block = trailer_block_new ();
994
995
size_t end_of_log_message = 0 , trailer_block_start = 0 ;
995
996
struct strbuf * * trailer_lines , * * ptr ;
996
997
char * * trailer_strings = NULL ;
@@ -1023,34 +1024,34 @@ static struct trailer_info *trailer_info_get(const struct process_trailer_option
1023
1024
}
1024
1025
strbuf_list_free (trailer_lines );
1025
1026
1026
- info -> blank_line_before_trailer = ends_with_blank_line (str ,
1027
- trailer_block_start );
1028
- info -> trailer_block_start = trailer_block_start ;
1029
- info -> trailer_block_end = end_of_log_message ;
1030
- info -> trailers = trailer_strings ;
1031
- info -> trailer_nr = nr ;
1027
+ trailer_block -> blank_line_before_trailer = ends_with_blank_line (str ,
1028
+ trailer_block_start );
1029
+ trailer_block -> start = trailer_block_start ;
1030
+ trailer_block -> end = end_of_log_message ;
1031
+ trailer_block -> trailers = trailer_strings ;
1032
+ trailer_block -> trailer_nr = nr ;
1032
1033
1033
- return info ;
1034
+ return trailer_block ;
1034
1035
}
1035
1036
1036
1037
/*
1037
- * Parse trailers in "str", populating the trailer info and "trailer_objects"
1038
+ * Parse trailers in "str", populating the trailer_block and "trailer_objects"
1038
1039
* linked list structure.
1039
1040
*/
1040
- struct trailer_info * parse_trailers (const struct process_trailer_options * opts ,
1041
- const char * str ,
1042
- struct list_head * trailer_objects )
1041
+ struct trailer_block * parse_trailers (const struct process_trailer_options * opts ,
1042
+ const char * str ,
1043
+ struct list_head * trailer_objects )
1043
1044
{
1044
- struct trailer_info * info ;
1045
+ struct trailer_block * trailer_block ;
1045
1046
struct strbuf tok = STRBUF_INIT ;
1046
1047
struct strbuf val = STRBUF_INIT ;
1047
1048
size_t i ;
1048
1049
1049
- info = trailer_info_get (opts , str );
1050
+ trailer_block = trailer_block_get (opts , str );
1050
1051
1051
- for (i = 0 ; i < info -> trailer_nr ; i ++ ) {
1052
+ for (i = 0 ; i < trailer_block -> trailer_nr ; i ++ ) {
1052
1053
int separator_pos ;
1053
- char * trailer = info -> trailers [i ];
1054
+ char * trailer = trailer_block -> trailers [i ];
1054
1055
if (starts_with (trailer , comment_line_str ))
1055
1056
continue ;
1056
1057
separator_pos = find_separator (trailer , separators );
@@ -1071,7 +1072,7 @@ struct trailer_info *parse_trailers(const struct process_trailer_options *opts,
1071
1072
}
1072
1073
}
1073
1074
1074
- return info ;
1075
+ return trailer_block ;
1075
1076
}
1076
1077
1077
1078
void free_trailers (struct list_head * trailers )
@@ -1083,28 +1084,28 @@ void free_trailers(struct list_head *trailers)
1083
1084
}
1084
1085
}
1085
1086
1086
- size_t trailer_block_start (struct trailer_info * info )
1087
+ size_t trailer_block_start (struct trailer_block * trailer_block )
1087
1088
{
1088
- return info -> trailer_block_start ;
1089
+ return trailer_block -> start ;
1089
1090
}
1090
1091
1091
- size_t trailer_block_end (struct trailer_info * info )
1092
+ size_t trailer_block_end (struct trailer_block * trailer_block )
1092
1093
{
1093
- return info -> trailer_block_end ;
1094
+ return trailer_block -> end ;
1094
1095
}
1095
1096
1096
- int blank_line_before_trailer_block (struct trailer_info * info )
1097
+ int blank_line_before_trailer_block (struct trailer_block * trailer_block )
1097
1098
{
1098
- return info -> blank_line_before_trailer ;
1099
+ return trailer_block -> blank_line_before_trailer ;
1099
1100
}
1100
1101
1101
- void trailer_info_release (struct trailer_info * info )
1102
+ void trailer_block_release (struct trailer_block * trailer_block )
1102
1103
{
1103
1104
size_t i ;
1104
- for (i = 0 ; i < info -> trailer_nr ; i ++ )
1105
- free (info -> trailers [i ]);
1106
- free (info -> trailers );
1107
- free (info );
1105
+ for (i = 0 ; i < trailer_block -> trailer_nr ; i ++ )
1106
+ free (trailer_block -> trailers [i ]);
1107
+ free (trailer_block -> trailers );
1108
+ free (trailer_block );
1108
1109
}
1109
1110
1110
1111
void format_trailers (const struct process_trailer_options * opts ,
@@ -1174,19 +1175,19 @@ void format_trailers_from_commit(const struct process_trailer_options *opts,
1174
1175
struct strbuf * out )
1175
1176
{
1176
1177
LIST_HEAD (trailer_objects );
1177
- struct trailer_info * info = parse_trailers (opts , msg , & trailer_objects );
1178
+ struct trailer_block * trailer_block = parse_trailers (opts , msg , & trailer_objects );
1178
1179
1179
1180
/* If we want the whole block untouched, we can take the fast path. */
1180
1181
if (!opts -> only_trailers && !opts -> unfold && !opts -> filter &&
1181
1182
!opts -> separator && !opts -> key_only && !opts -> value_only &&
1182
1183
!opts -> key_value_separator ) {
1183
- strbuf_add (out , msg + info -> trailer_block_start ,
1184
- info -> trailer_block_end - info -> trailer_block_start );
1184
+ strbuf_add (out , msg + trailer_block -> start ,
1185
+ trailer_block -> end - trailer_block -> start );
1185
1186
} else
1186
1187
format_trailers (opts , & trailer_objects , out );
1187
1188
1188
1189
free_trailers (& trailer_objects );
1189
- trailer_info_release ( info );
1190
+ trailer_block_release ( trailer_block );
1190
1191
}
1191
1192
1192
1193
void trailer_iterator_init (struct trailer_iterator * iter , const char * msg )
@@ -1195,14 +1196,14 @@ void trailer_iterator_init(struct trailer_iterator *iter, const char *msg)
1195
1196
strbuf_init (& iter -> key , 0 );
1196
1197
strbuf_init (& iter -> val , 0 );
1197
1198
opts .no_divider = 1 ;
1198
- iter -> internal .info = trailer_info_get (& opts , msg );
1199
+ iter -> internal .trailer_block = trailer_block_get (& opts , msg );
1199
1200
iter -> internal .cur = 0 ;
1200
1201
}
1201
1202
1202
1203
int trailer_iterator_advance (struct trailer_iterator * iter )
1203
1204
{
1204
- if (iter -> internal .cur < iter -> internal .info -> trailer_nr ) {
1205
- char * line = iter -> internal .info -> trailers [iter -> internal .cur ++ ];
1205
+ if (iter -> internal .cur < iter -> internal .trailer_block -> trailer_nr ) {
1206
+ char * line = iter -> internal .trailer_block -> trailers [iter -> internal .cur ++ ];
1206
1207
int separator_pos = find_separator (line , separators );
1207
1208
1208
1209
iter -> raw = line ;
@@ -1219,7 +1220,7 @@ int trailer_iterator_advance(struct trailer_iterator *iter)
1219
1220
1220
1221
void trailer_iterator_release (struct trailer_iterator * iter )
1221
1222
{
1222
- trailer_info_release (iter -> internal .info );
1223
+ trailer_block_release (iter -> internal .trailer_block );
1223
1224
strbuf_release (& iter -> val );
1224
1225
strbuf_release (& iter -> key );
1225
1226
}
0 commit comments