40
40
41
41
#define MINIMAL_SIZE 20 /* minimal size for b_str */
42
42
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 };
46
46
47
47
static int typeahead_char = 0 ; /* typeahead char that's not flushed */
48
48
@@ -138,13 +138,12 @@ free_buff(buffheader_T *buf)
138
138
{
139
139
buffblock_T * p , * np ;
140
140
141
- for (p = buf -> bh_first ; p != NULL ; p = np )
141
+ for (p = buf -> bh_first . b_next ; p != NULL ; p = np )
142
142
{
143
143
np = p -> b_next ;
144
144
vim_free (p );
145
145
}
146
- buf -> bh_first = NULL ;
147
- buf -> bh_curr = NULL ;
146
+ buf -> bh_first .b_next = NULL ;
148
147
}
149
148
150
149
/*
@@ -160,16 +159,16 @@ get_buffcont(
160
159
char_u * p = NULL ;
161
160
char_u * p2 ;
162
161
char_u * str ;
163
- buffblock_T * bp ;
162
+ buffblock_T * bp ;
164
163
165
164
/* 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 )
167
166
count += (long_u )STRLEN (bp -> b_str );
168
167
169
168
if ((count || dozero ) && (p = lalloc (count + 1 , TRUE)) != NULL )
170
169
{
171
170
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 )
173
172
for (str = bp -> b_str ; * str ; )
174
173
* p2 ++ = * str ++ ;
175
174
* p2 = NUL ;
@@ -233,27 +232,27 @@ add_buff(
233
232
long slen ) /* length of "s" or -1 */
234
233
{
235
234
buffblock_T * p ;
236
- long_u len ;
235
+ long_u len ;
237
236
238
237
if (slen < 0 )
239
238
slen = (long )STRLEN (s );
240
239
if (slen == 0 ) /* don't add empty strings */
241
240
return ;
242
241
243
- if (buf -> bh_first == NULL ) /* first add to list */
242
+ if (buf -> bh_first . b_next == NULL ) /* first add to list */
244
243
{
245
244
buf -> bh_space = 0 ;
246
- buf -> bh_curr = NULL ;
245
+ buf -> bh_curr = & ( buf -> bh_first ) ;
247
246
}
248
247
else if (buf -> bh_curr == NULL ) /* buffer has already been read */
249
248
{
250
249
IEMSG (_ ("E222: Add to read buffer" ));
251
250
return ;
252
251
}
253
252
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 );
257
256
buf -> bh_index = 0 ;
258
257
259
258
if (buf -> bh_space >= (int )slen )
@@ -268,25 +267,16 @@ add_buff(
268
267
len = MINIMAL_SIZE ;
269
268
else
270
269
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);
273
272
if (p == NULL )
274
273
return ; /* no space, just forget it */
275
274
buf -> bh_space = (int )(len - slen );
276
275
vim_strncpy (p -> b_str , s , (size_t )slen );
277
276
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 ;
290
280
}
291
281
return ;
292
282
}
@@ -358,10 +348,10 @@ add_char_buff(buffheader_T *buf, int c)
358
348
}
359
349
360
350
/* 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 };
362
352
363
353
/* 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 };
365
355
366
356
/*
367
357
* Get one byte from the read buffers. Use readbuf1 one first, use readbuf2
@@ -386,17 +376,17 @@ read_readbuf(buffheader_T *buf, int advance)
386
376
char_u c ;
387
377
buffblock_T * curr ;
388
378
389
- if (buf -> bh_first == NULL ) /* buffer is empty */
379
+ if (buf -> bh_first . b_next == NULL ) /* buffer is empty */
390
380
return NUL ;
391
381
392
- curr = buf -> bh_first ;
382
+ curr = buf -> bh_first . b_next ;
393
383
c = curr -> b_str [buf -> bh_index ];
394
384
395
385
if (advance )
396
386
{
397
387
if (curr -> b_str [++ buf -> bh_index ] == NUL )
398
388
{
399
- buf -> bh_first = curr -> b_next ;
389
+ buf -> bh_first . b_next = curr -> b_next ;
400
390
vim_free (curr );
401
391
buf -> bh_index = 0 ;
402
392
}
@@ -410,14 +400,14 @@ read_readbuf(buffheader_T *buf, int advance)
410
400
static void
411
401
start_stuff (void )
412
402
{
413
- if (readbuf1 .bh_first != NULL )
403
+ if (readbuf1 .bh_first . b_next != NULL )
414
404
{
415
- readbuf1 .bh_curr = readbuf1 .bh_first ;
405
+ readbuf1 .bh_curr = & ( readbuf1 .bh_first ) ;
416
406
readbuf1 .bh_space = 0 ;
417
407
}
418
- if (readbuf2 .bh_first != NULL )
408
+ if (readbuf2 .bh_first . b_next != NULL )
419
409
{
420
- readbuf2 .bh_curr = readbuf2 .bh_first ;
410
+ readbuf2 .bh_curr = & ( readbuf2 .bh_first ) ;
421
411
readbuf2 .bh_space = 0 ;
422
412
}
423
413
}
@@ -428,8 +418,8 @@ start_stuff(void)
428
418
int
429
419
stuff_empty (void )
430
420
{
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 );
433
423
}
434
424
435
425
/*
@@ -439,7 +429,7 @@ stuff_empty(void)
439
429
int
440
430
readbuf1_empty (void )
441
431
{
442
- return (readbuf1 .bh_first == NULL );
432
+ return (readbuf1 .bh_first . b_next == NULL );
443
433
}
444
434
445
435
/*
@@ -504,7 +494,7 @@ ResetRedobuff(void)
504
494
{
505
495
free_buff (& old_redobuff );
506
496
old_redobuff = redobuff ;
507
- redobuff .bh_first = NULL ;
497
+ redobuff .bh_first . b_next = NULL ;
508
498
}
509
499
}
510
500
@@ -519,7 +509,7 @@ CancelRedo(void)
519
509
{
520
510
free_buff (& redobuff );
521
511
redobuff = old_redobuff ;
522
- old_redobuff .bh_first = NULL ;
512
+ old_redobuff .bh_first . b_next = NULL ;
523
513
start_stuff ();
524
514
while (read_readbuffers (TRUE) != NUL )
525
515
;
@@ -536,9 +526,9 @@ saveRedobuff(save_redo_T *save_redo)
536
526
char_u * s ;
537
527
538
528
save_redo -> sr_redobuff = redobuff ;
539
- redobuff .bh_first = NULL ;
529
+ redobuff .bh_first . b_next = NULL ;
540
530
save_redo -> sr_old_redobuff = old_redobuff ;
541
- old_redobuff .bh_first = NULL ;
531
+ old_redobuff .bh_first . b_next = NULL ;
542
532
543
533
/* Make a copy, so that ":normal ." in a function works. */
544
534
s = get_buffcont (& save_redo -> sr_redobuff , FALSE);
@@ -757,9 +747,9 @@ read_redo(int init, int old_redo)
757
747
if (init )
758
748
{
759
749
if (old_redo )
760
- bp = old_redobuff .bh_first ;
750
+ bp = old_redobuff .bh_first . b_next ;
761
751
else
762
- bp = redobuff .bh_first ;
752
+ bp = redobuff .bh_first . b_next ;
763
753
if (bp == NULL )
764
754
return FAIL ;
765
755
p = bp -> b_str ;
@@ -1382,9 +1372,9 @@ save_typeahead(tasave_T *tp)
1382
1372
old_char = -1 ;
1383
1373
1384
1374
tp -> save_readbuf1 = readbuf1 ;
1385
- readbuf1 .bh_first = NULL ;
1375
+ readbuf1 .bh_first . b_next = NULL ;
1386
1376
tp -> save_readbuf2 = readbuf2 ;
1387
- readbuf2 .bh_first = NULL ;
1377
+ readbuf2 .bh_first . b_next = NULL ;
1388
1378
# ifdef USE_INPUT_BUF
1389
1379
tp -> save_inputbuf = get_input_buf ();
1390
1380
# endif
0 commit comments