4040
4141#define MINIMAL_SIZE 20 /* minimal size for b_str */
4242
43- static buffheader_T redobuff = {NULL , NULL , 0 , 0 };
44- static buffheader_T old_redobuff = {NULL , NULL , 0 , 0 };
45- static buffheader_T recordbuff = {NULL , NULL , 0 , 0 };
43+ static buffheader_T redobuff = {{ NULL , { NUL }} , NULL , 0 , 0 };
44+ static buffheader_T old_redobuff = {{ NULL , { NUL }} , NULL , 0 , 0 };
45+ static buffheader_T recordbuff = {{ NULL , { NUL }} , NULL , 0 , 0 };
4646
4747static int typeahead_char = 0 ; /* typeahead char that's not flushed */
4848
@@ -138,13 +138,12 @@ free_buff(buffheader_T *buf)
138138{
139139 buffblock_T * p , * np ;
140140
141- for (p = buf -> bh_first ; p != NULL ; p = np )
141+ for (p = buf -> bh_first . b_next ; p != NULL ; p = np )
142142 {
143143 np = p -> b_next ;
144144 vim_free (p );
145145 }
146- buf -> bh_first = NULL ;
147- buf -> bh_curr = NULL ;
146+ buf -> bh_first .b_next = NULL ;
148147}
149148
150149/*
@@ -160,16 +159,16 @@ get_buffcont(
160159 char_u * p = NULL ;
161160 char_u * p2 ;
162161 char_u * str ;
163- buffblock_T * bp ;
162+ buffblock_T * bp ;
164163
165164 /* compute the total length of the string */
166- for (bp = buffer -> bh_first ; bp != NULL ; bp = bp -> b_next )
165+ for (bp = buffer -> bh_first . b_next ; bp != NULL ; bp = bp -> b_next )
167166 count += (long_u )STRLEN (bp -> b_str );
168167
169168 if ((count || dozero ) && (p = lalloc (count + 1 , TRUE)) != NULL )
170169 {
171170 p2 = p ;
172- for (bp = buffer -> bh_first ; bp != NULL ; bp = bp -> b_next )
171+ for (bp = buffer -> bh_first . b_next ; bp != NULL ; bp = bp -> b_next )
173172 for (str = bp -> b_str ; * str ; )
174173 * p2 ++ = * str ++ ;
175174 * p2 = NUL ;
@@ -233,27 +232,27 @@ add_buff(
233232 long slen ) /* length of "s" or -1 */
234233{
235234 buffblock_T * p ;
236- long_u len ;
235+ long_u len ;
237236
238237 if (slen < 0 )
239238 slen = (long )STRLEN (s );
240239 if (slen == 0 ) /* don't add empty strings */
241240 return ;
242241
243- if (buf -> bh_first == NULL ) /* first add to list */
242+ if (buf -> bh_first . b_next == NULL ) /* first add to list */
244243 {
245244 buf -> bh_space = 0 ;
246- buf -> bh_curr = NULL ;
245+ buf -> bh_curr = & ( buf -> bh_first ) ;
247246 }
248247 else if (buf -> bh_curr == NULL ) /* buffer has already been read */
249248 {
250249 IEMSG (_ ("E222: Add to read buffer" ));
251250 return ;
252251 }
253252 else if (buf -> bh_index != 0 )
254- mch_memmove (buf -> bh_first -> b_str ,
255- buf -> bh_first -> b_str + buf -> bh_index ,
256- STRLEN (buf -> bh_first -> b_str + buf -> bh_index ) + 1 );
253+ mch_memmove (buf -> bh_first . b_next -> b_str ,
254+ buf -> bh_first . b_next -> b_str + buf -> bh_index ,
255+ STRLEN (buf -> bh_first . b_next -> b_str + buf -> bh_index ) + 1 );
257256 buf -> bh_index = 0 ;
258257
259258 if (buf -> bh_space >= (int )slen )
@@ -268,25 +267,16 @@ add_buff(
268267 len = MINIMAL_SIZE ;
269268 else
270269 len = slen ;
271- p = (buffblock_T * )lalloc ((long_u )(sizeof (buffblock_T ) + len + 1 ),
272- TRUE);
270+ p = (buffblock_T * )lalloc ((long_u )(sizeof (buffblock_T ) + len ),
271+ TRUE);
273272 if (p == NULL )
274273 return ; /* no space, just forget it */
275274 buf -> bh_space = (int )(len - slen );
276275 vim_strncpy (p -> b_str , s , (size_t )slen );
277276
278- if (buf -> bh_curr == NULL )
279- {
280- p -> b_next = NULL ;
281- buf -> bh_first = p ;
282- buf -> bh_curr = p ;
283- }
284- else
285- {
286- p -> b_next = buf -> bh_curr -> b_next ;
287- buf -> bh_curr -> b_next = p ;
288- buf -> bh_curr = p ;
289- }
277+ p -> b_next = buf -> bh_curr -> b_next ;
278+ buf -> bh_curr -> b_next = p ;
279+ buf -> bh_curr = p ;
290280 }
291281 return ;
292282}
@@ -358,10 +348,10 @@ add_char_buff(buffheader_T *buf, int c)
358348}
359349
360350/* First read ahead buffer. Used for translated commands. */
361- static buffheader_T readbuf1 = {NULL , NULL , 0 , 0 };
351+ static buffheader_T readbuf1 = {{ NULL , { NUL }} , NULL , 0 , 0 };
362352
363353/* Second read ahead buffer. Used for redo. */
364- static buffheader_T readbuf2 = {NULL , NULL , 0 , 0 };
354+ static buffheader_T readbuf2 = {{ NULL , { NUL }} , NULL , 0 , 0 };
365355
366356/*
367357 * Get one byte from the read buffers. Use readbuf1 one first, use readbuf2
@@ -386,17 +376,17 @@ read_readbuf(buffheader_T *buf, int advance)
386376 char_u c ;
387377 buffblock_T * curr ;
388378
389- if (buf -> bh_first == NULL ) /* buffer is empty */
379+ if (buf -> bh_first . b_next == NULL ) /* buffer is empty */
390380 return NUL ;
391381
392- curr = buf -> bh_first ;
382+ curr = buf -> bh_first . b_next ;
393383 c = curr -> b_str [buf -> bh_index ];
394384
395385 if (advance )
396386 {
397387 if (curr -> b_str [++ buf -> bh_index ] == NUL )
398388 {
399- buf -> bh_first = curr -> b_next ;
389+ buf -> bh_first . b_next = curr -> b_next ;
400390 vim_free (curr );
401391 buf -> bh_index = 0 ;
402392 }
@@ -410,14 +400,14 @@ read_readbuf(buffheader_T *buf, int advance)
410400 static void
411401start_stuff (void )
412402{
413- if (readbuf1 .bh_first != NULL )
403+ if (readbuf1 .bh_first . b_next != NULL )
414404 {
415- readbuf1 .bh_curr = readbuf1 .bh_first ;
405+ readbuf1 .bh_curr = & ( readbuf1 .bh_first ) ;
416406 readbuf1 .bh_space = 0 ;
417407 }
418- if (readbuf2 .bh_first != NULL )
408+ if (readbuf2 .bh_first . b_next != NULL )
419409 {
420- readbuf2 .bh_curr = readbuf2 .bh_first ;
410+ readbuf2 .bh_curr = & ( readbuf2 .bh_first ) ;
421411 readbuf2 .bh_space = 0 ;
422412 }
423413}
@@ -428,8 +418,8 @@ start_stuff(void)
428418 int
429419stuff_empty (void )
430420{
431- return (readbuf1 .bh_first == NULL
432- && readbuf2 .bh_first == NULL );
421+ return (readbuf1 .bh_first . b_next == NULL
422+ && readbuf2 .bh_first . b_next == NULL );
433423}
434424
435425/*
@@ -439,7 +429,7 @@ stuff_empty(void)
439429 int
440430readbuf1_empty (void )
441431{
442- return (readbuf1 .bh_first == NULL );
432+ return (readbuf1 .bh_first . b_next == NULL );
443433}
444434
445435/*
@@ -504,7 +494,7 @@ ResetRedobuff(void)
504494 {
505495 free_buff (& old_redobuff );
506496 old_redobuff = redobuff ;
507- redobuff .bh_first = NULL ;
497+ redobuff .bh_first . b_next = NULL ;
508498 }
509499}
510500
@@ -519,7 +509,7 @@ CancelRedo(void)
519509 {
520510 free_buff (& redobuff );
521511 redobuff = old_redobuff ;
522- old_redobuff .bh_first = NULL ;
512+ old_redobuff .bh_first . b_next = NULL ;
523513 start_stuff ();
524514 while (read_readbuffers (TRUE) != NUL )
525515 ;
@@ -536,9 +526,9 @@ saveRedobuff(save_redo_T *save_redo)
536526 char_u * s ;
537527
538528 save_redo -> sr_redobuff = redobuff ;
539- redobuff .bh_first = NULL ;
529+ redobuff .bh_first . b_next = NULL ;
540530 save_redo -> sr_old_redobuff = old_redobuff ;
541- old_redobuff .bh_first = NULL ;
531+ old_redobuff .bh_first . b_next = NULL ;
542532
543533 /* Make a copy, so that ":normal ." in a function works. */
544534 s = get_buffcont (& save_redo -> sr_redobuff , FALSE);
@@ -757,9 +747,9 @@ read_redo(int init, int old_redo)
757747 if (init )
758748 {
759749 if (old_redo )
760- bp = old_redobuff .bh_first ;
750+ bp = old_redobuff .bh_first . b_next ;
761751 else
762- bp = redobuff .bh_first ;
752+ bp = redobuff .bh_first . b_next ;
763753 if (bp == NULL )
764754 return FAIL ;
765755 p = bp -> b_str ;
@@ -1382,9 +1372,9 @@ save_typeahead(tasave_T *tp)
13821372 old_char = -1 ;
13831373
13841374 tp -> save_readbuf1 = readbuf1 ;
1385- readbuf1 .bh_first = NULL ;
1375+ readbuf1 .bh_first . b_next = NULL ;
13861376 tp -> save_readbuf2 = readbuf2 ;
1387- readbuf2 .bh_first = NULL ;
1377+ readbuf2 .bh_first . b_next = NULL ;
13881378# ifdef USE_INPUT_BUF
13891379 tp -> save_inputbuf = get_input_buf ();
13901380# endif
0 commit comments