Find a style for a string.
295{
297 struct QuoteStyle *qc = NULL, *tmp = NULL, *ptr = NULL, *save = NULL;
298 const char *tail_qptr = NULL;
299 size_t offset, tail_lng;
300 int index = -1;
301
302
303 while (q_list)
304 {
306 {
307
308
310 {
312 return q_list;
313
314
315 if (tmp)
316 {
317
318
319
321
322
327
328
330
331 while (ptr->next)
337
339
340
341 q_list = save;
342 }
343 else
344 {
345
348 tmp->prefix_len = length;
349
350
352 {
353 tmp->next = q_list->
next;
355 }
357 {
360 }
361
362
365
366
369
370
371 if (q_list == *quote_list)
372 *quote_list = tmp;
373
375
376
377 qc = tmp;
378
379
380
381
383 }
384
385
386 *force_redraw = true;
387 continue;
388 }
389 else
390 {
391
392 q_list = q_list->
next;
393 continue;
394 }
395 }
396 else
397 {
398
399
400
402 {
403
404
405 ptr = q_list;
407
408 q_list = q_list->
down;
409 tail_lng = length - offset;
410 tail_qptr = qptr + offset;
411
412 while (q_list)
413 {
415 {
417 {
418
420 return q_list;
421
422
423 if (!tmp)
424 {
425
428 tmp->prefix_len = length;
429
430
432 {
433 tmp->next = q_list->
next;
435 }
437 {
440 }
441
442
444 tmp->
up = q_list->
up;
446 if (tmp->up->down == q_list)
448
449
452
454
455
456 qc = tmp;
457
458
460 }
461 else
462 {
463
464
465
467
468
473
474
476 while (ptr->next)
482
484
485
486 q_list = save;
487 }
488
489
490 *force_redraw = true;
491 continue;
492 }
493 else
494 {
495 q_list = q_list->
next;
496 continue;
497 }
498 }
499 else
500 {
501
504 {
505
506 ptr = q_list;
508
509 q_list = q_list->
down;
510 tail_lng = length - offset;
511 tail_qptr = qptr + offset;
512
513 continue;
514 }
515 else
516 {
517
518 q_list = q_list->
next;
519 continue;
520 }
521 }
522 }
523
524
525 if (!qc)
526 {
529 tmp->prefix_len = length;
530
531 if (ptr->down)
532 {
533 tmp->next = ptr->down;
534 ptr->down->prev = tmp;
535 }
536 ptr->down = tmp;
537 tmp->up = ptr;
538
539 tmp->quote_n = (*q_level)++;
541
542 return tmp;
543 }
544 else
545 {
546 if (index != -1)
548
549 return qc;
550 }
551 }
552 else
553 {
554
555 q_list = q_list->
next;
556 continue;
557 }
558 }
559 }
560
561 if (!qc)
562 {
563
569
570 if (*quote_list)
571 {
572 if ((*quote_list)->next)
573 {
576 }
577 (*quote_list)->
next = qc;
578 qc->
prev = *quote_list;
579 }
580 else
581 {
582 *quote_list = qc;
583 }
584 }
585
586 if (index != -1)
588
589 return qc;
590}
char * mutt_strn_dup(const char *begin, size_t len)
Duplicate a sub-string.
bool mutt_strn_equal(const char *a, const char *b, size_t num)
Check for equality of two strings (to a maximum), safely.
static void qstyle_insert(struct QuoteStyle *quote_list, struct QuoteStyle *new_class, int index, int *q_level)
Insert a new quote colour class into a list.
static struct QuoteStyle * qstyle_new(void)
Create a new QuoteStyle.
size_t prefix_len
Length of the prefix string.