• Home
  • Raw
  • Download

Lines Matching refs:list

40 #define VERIFY_LIST(list) verify_list (list)  argument
78 struct format_arg_list *list; /* For FAT_LIST: List elements. */ member
109 struct format_arg_list *list; member
132 static void verify_list (const struct format_arg_list *list);
133 static void free_list (struct format_arg_list *list);
134 static struct format_arg_list * copy_list (const struct format_arg_list *list);
141 (struct format_arg_list *list);
155 verify_list (e->list); in verify_element()
161 verify_list (const struct format_arg_list *list) in verify_list() argument
166 ASSERT (list->initial.count <= list->initial.allocated); in verify_list()
168 for (i = 0; i < list->initial.count; i++) in verify_list()
170 verify_element (&list->initial.element[i]); in verify_list()
171 total_repcount += list->initial.element[i].repcount; in verify_list()
173 ASSERT (total_repcount == list->initial.length); in verify_list()
175 ASSERT (list->repeated.count <= list->repeated.allocated); in verify_list()
177 for (i = 0; i < list->repeated.count; i++) in verify_list()
179 verify_element (&list->repeated.element[i]); in verify_list()
180 total_repcount += list->repeated.element[i].repcount; in verify_list()
182 ASSERT (total_repcount == list->repeated.length); in verify_list()
185 #define VERIFY_LIST(list) verify_list (list) argument
195 free_list (element->list); in free_element()
201 free_list (struct format_arg_list *list) in free_list() argument
205 for (i = 0; i < list->initial.count; i++) in free_list()
206 free_element (&list->initial.element[i]); in free_list()
207 if (list->initial.element != NULL) in free_list()
208 free (list->initial.element); in free_list()
210 for (i = 0; i < list->repeated.count; i++) in free_list()
211 free_element (&list->repeated.element[i]); in free_list()
212 if (list->repeated.element != NULL) in free_list()
213 free (list->repeated.element); in free_list()
228 newelement->list = copy_list (oldelement->list); in copy_element()
234 copy_list (const struct format_arg_list *list) in copy_list() argument
240 VERIFY_LIST (list); in copy_list()
244 newlist->initial.count = newlist->initial.allocated = list->initial.count; in copy_list()
246 if (list->initial.count == 0) in copy_list()
252 for (i = 0; i < list->initial.count; i++) in copy_list()
255 &list->initial.element[i]); in copy_list()
256 length += list->initial.element[i].repcount; in copy_list()
259 ASSERT (length == list->initial.length); in copy_list()
262 newlist->repeated.count = newlist->repeated.allocated = list->repeated.count; in copy_list()
264 if (list->repeated.count == 0) in copy_list()
270 for (i = 0; i < list->repeated.count; i++) in copy_list()
273 &list->repeated.element[i]); in copy_list()
274 length += list->repeated.element[i].repcount; in copy_list()
277 ASSERT (length == list->repeated.length); in copy_list()
295 && (e1->type == FAT_LIST ? equal_list (e1->list, e2->list) : true)); in equal_element()
341 ensure_initial_alloc (struct format_arg_list *list, unsigned int newcount) in ensure_initial_alloc() argument
343 if (newcount > list->initial.allocated) in ensure_initial_alloc()
345 list->initial.allocated = in ensure_initial_alloc()
346 MAX (2 * list->initial.allocated + 1, newcount); in ensure_initial_alloc()
347 list->initial.element = in ensure_initial_alloc()
349 xrealloc (list->initial.element, in ensure_initial_alloc()
350 list->initial.allocated * sizeof (struct format_arg)); in ensure_initial_alloc()
356 grow_initial_alloc (struct format_arg_list *list) in grow_initial_alloc() argument
358 if (list->initial.count >= list->initial.allocated) in grow_initial_alloc()
360 list->initial.allocated = in grow_initial_alloc()
361 MAX (2 * list->initial.allocated + 1, list->initial.count + 1); in grow_initial_alloc()
362 list->initial.element = in grow_initial_alloc()
364 xrealloc (list->initial.element, in grow_initial_alloc()
365 list->initial.allocated * sizeof (struct format_arg)); in grow_initial_alloc()
371 ensure_repeated_alloc (struct format_arg_list *list, unsigned int newcount) in ensure_repeated_alloc() argument
373 if (newcount > list->repeated.allocated) in ensure_repeated_alloc()
375 list->repeated.allocated = in ensure_repeated_alloc()
376 MAX (2 * list->repeated.allocated + 1, newcount); in ensure_repeated_alloc()
377 list->repeated.element = in ensure_repeated_alloc()
379 xrealloc (list->repeated.element, in ensure_repeated_alloc()
380 list->repeated.allocated * sizeof (struct format_arg)); in ensure_repeated_alloc()
386 grow_repeated_alloc (struct format_arg_list *list) in grow_repeated_alloc() argument
388 if (list->repeated.count >= list->repeated.allocated) in grow_repeated_alloc()
390 list->repeated.allocated = in grow_repeated_alloc()
391 MAX (2 * list->repeated.allocated + 1, list->repeated.count + 1); in grow_repeated_alloc()
392 list->repeated.element = in grow_repeated_alloc()
394 xrealloc (list->repeated.element, in grow_repeated_alloc()
395 list->repeated.allocated * sizeof (struct format_arg)); in grow_repeated_alloc()
406 normalize_outermost_list (struct format_arg_list *list) in normalize_outermost_list() argument
413 n = list->initial.count; in normalize_outermost_list()
416 && equal_element (&list->initial.element[i], in normalize_outermost_list()
417 &list->initial.element[j-1])) in normalize_outermost_list()
419 list->initial.element[j-1].repcount += in normalize_outermost_list()
420 list->initial.element[i].repcount; in normalize_outermost_list()
421 free_element (&list->initial.element[i]); in normalize_outermost_list()
426 list->initial.element[j] = list->initial.element[i]; in normalize_outermost_list()
429 list->initial.count = j; in normalize_outermost_list()
431 n = list->repeated.count; in normalize_outermost_list()
434 && equal_element (&list->repeated.element[i], in normalize_outermost_list()
435 &list->repeated.element[j-1])) in normalize_outermost_list()
437 list->repeated.element[j-1].repcount += in normalize_outermost_list()
438 list->repeated.element[i].repcount; in normalize_outermost_list()
439 free_element (&list->repeated.element[i]); in normalize_outermost_list()
444 list->repeated.element[j] = list->repeated.element[i]; in normalize_outermost_list()
447 list->repeated.count = j; in normalize_outermost_list()
450 if (list->repeated.count > 0) in normalize_outermost_list()
455 n = list->repeated.count; in normalize_outermost_list()
458 && equal_element (&list->repeated.element[0], in normalize_outermost_list()
459 &list->repeated.element[n-1])) in normalize_outermost_list()
461 repcount0_extra = list->repeated.element[n-1].repcount; in normalize_outermost_list()
473 if (!((list->repeated.element[i].repcount in normalize_outermost_list()
475 == list->repeated.element[i+m].repcount) in normalize_outermost_list()
476 && equal_element (&list->repeated.element[i], in normalize_outermost_list()
477 &list->repeated.element[i+m]))) in normalize_outermost_list()
485 free_element (&list->repeated.element[i]); in normalize_outermost_list()
486 if (n < list->repeated.count) in normalize_outermost_list()
487 list->repeated.element[m] = list->repeated.element[n]; in normalize_outermost_list()
488 list->repeated.count = list->repeated.count - n + m; in normalize_outermost_list()
489 list->repeated.length /= n / m; in normalize_outermost_list()
496 if (list->repeated.count == 1) in normalize_outermost_list()
498 if (list->initial.count > 0 in normalize_outermost_list()
499 && equal_element (&list->initial.element[list->initial.count-1], in normalize_outermost_list()
500 &list->repeated.element[0])) in normalize_outermost_list()
505 list->initial.length -= in normalize_outermost_list()
506 list->initial.element[list->initial.count-1].repcount; in normalize_outermost_list()
507 list->initial.count--; in normalize_outermost_list()
512 while (list->initial.count > 0 in normalize_outermost_list()
513 && equal_element (&list->initial.element[list->initial.count-1], in normalize_outermost_list()
514 &list->repeated.element[list->repeated.count-1])) in normalize_outermost_list()
517 MIN (list->initial.element[list->initial.count-1].repcount, in normalize_outermost_list()
518 list->repeated.element[list->repeated.count-1].repcount); in normalize_outermost_list()
521 if (equal_element (&list->repeated.element[0], in normalize_outermost_list()
522 &list->repeated.element[list->repeated.count-1])) in normalize_outermost_list()
523 list->repeated.element[0].repcount += moved_repcount; in normalize_outermost_list()
526 unsigned int newcount = list->repeated.count + 1; in normalize_outermost_list()
527 ensure_repeated_alloc (list, newcount); in normalize_outermost_list()
529 list->repeated.element[i] = list->repeated.element[i-1]; in normalize_outermost_list()
530 list->repeated.count = newcount; in normalize_outermost_list()
531 copy_element (&list->repeated.element[0], in normalize_outermost_list()
532 &list->repeated.element[list->repeated.count-1]); in normalize_outermost_list()
533 list->repeated.element[0].repcount = moved_repcount; in normalize_outermost_list()
537 list->repeated.element[list->repeated.count-1].repcount -= in normalize_outermost_list()
539 if (list->repeated.element[list->repeated.count-1].repcount == 0) in normalize_outermost_list()
541 free_element (&list->repeated.element[list->repeated.count-1]); in normalize_outermost_list()
542 list->repeated.count--; in normalize_outermost_list()
546 list->initial.element[list->initial.count-1].repcount -= in normalize_outermost_list()
548 if (list->initial.element[list->initial.count-1].repcount == 0) in normalize_outermost_list()
550 free_element (&list->initial.element[list->initial.count-1]); in normalize_outermost_list()
551 list->initial.count--; in normalize_outermost_list()
553 list->initial.length -= moved_repcount; in normalize_outermost_list()
562 normalize_list (struct format_arg_list *list) in normalize_list() argument
566 VERIFY_LIST (list); in normalize_list()
569 n = list->initial.count; in normalize_list()
571 if (list->initial.element[i].type == FAT_LIST) in normalize_list()
572 normalize_list (list->initial.element[i].list); in normalize_list()
573 n = list->repeated.count; in normalize_list()
575 if (list->repeated.element[i].type == FAT_LIST) in normalize_list()
576 normalize_list (list->repeated.element[i].list); in normalize_list()
579 normalize_outermost_list (list); in normalize_list()
581 VERIFY_LIST (list); in normalize_list()
596 struct format_arg_list *list; in make_unconstrained_list() local
598 list = XMALLOC (struct format_arg_list); in make_unconstrained_list()
599 list->initial.count = 0; in make_unconstrained_list()
600 list->initial.allocated = 0; in make_unconstrained_list()
601 list->initial.element = NULL; in make_unconstrained_list()
602 list->initial.length = 0; in make_unconstrained_list()
603 list->repeated.count = 1; in make_unconstrained_list()
604 list->repeated.allocated = 1; in make_unconstrained_list()
605 list->repeated.element = XNMALLOC (1, struct format_arg); in make_unconstrained_list()
606 list->repeated.element[0].repcount = 1; in make_unconstrained_list()
607 list->repeated.element[0].presence = FCT_OPTIONAL; in make_unconstrained_list()
608 list->repeated.element[0].type = FAT_OBJECT; in make_unconstrained_list()
609 list->repeated.length = 1; in make_unconstrained_list()
611 VERIFY_LIST (list); in make_unconstrained_list()
613 return list; in make_unconstrained_list()
622 struct format_arg_list *list; in make_empty_list() local
624 list = XMALLOC (struct format_arg_list); in make_empty_list()
625 list->initial.count = 0; in make_empty_list()
626 list->initial.allocated = 0; in make_empty_list()
627 list->initial.element = NULL; in make_empty_list()
628 list->initial.length = 0; in make_empty_list()
629 list->repeated.count = 0; in make_empty_list()
630 list->repeated.allocated = 0; in make_empty_list()
631 list->repeated.element = NULL; in make_empty_list()
632 list->repeated.length = 0; in make_empty_list()
634 VERIFY_LIST (list); in make_empty_list()
636 return list; in make_empty_list()
643 is_empty_list (const struct format_arg_list *list) in is_empty_list() argument
645 return (list->initial.count == 0 && list->repeated.count == 0); in is_empty_list()
655 unfold_loop (struct format_arg_list *list, unsigned int m) in unfold_loop() argument
661 unsigned int newcount = list->repeated.count * m; in unfold_loop()
662 ensure_repeated_alloc (list, newcount); in unfold_loop()
663 i = list->repeated.count; in unfold_loop()
665 for (j = 0; j < list->repeated.count; j++, i++) in unfold_loop()
666 copy_element (&list->repeated.element[i], &list->repeated.element[j]); in unfold_loop()
667 list->repeated.count = newcount; in unfold_loop()
668 list->repeated.length = list->repeated.length * m; in unfold_loop()
676 rotate_loop (struct format_arg_list *list, unsigned int m) in rotate_loop() argument
678 if (m == list->initial.length) in rotate_loop()
681 if (list->repeated.count == 1) in rotate_loop()
687 newcount = list->initial.count + 1; in rotate_loop()
688 ensure_initial_alloc (list, newcount); in rotate_loop()
689 i = list->initial.count; in rotate_loop()
690 copy_element (&list->initial.element[i], &list->repeated.element[0]); in rotate_loop()
691 list->initial.element[i].repcount = m - list->initial.length; in rotate_loop()
692 list->initial.count = newcount; in rotate_loop()
693 list->initial.length = m; in rotate_loop()
697 unsigned int n = list->repeated.length; in rotate_loop()
700 unsigned int q = (m - list->initial.length) / n; in rotate_loop()
701 unsigned int r = (m - list->initial.length) % n; in rotate_loop()
709 s < list->repeated.count && t >= list->repeated.element[s].repcount; in rotate_loop()
710 t -= list->repeated.element[s].repcount, s++) in rotate_loop()
714 ASSERT (s < list->repeated.count); in rotate_loop()
723 i = list->initial.count; in rotate_loop()
724 newcount = i + q * list->repeated.count + s + (t > 0 ? 1 : 0); in rotate_loop()
725 ensure_initial_alloc (list, newcount); in rotate_loop()
727 for (j = 0; j < list->repeated.count; j++, i++) in rotate_loop()
728 copy_element (&list->initial.element[i], in rotate_loop()
729 &list->repeated.element[j]); in rotate_loop()
731 copy_element (&list->initial.element[i], &list->repeated.element[j]); in rotate_loop()
734 copy_element (&list->initial.element[i], in rotate_loop()
735 &list->repeated.element[j]); in rotate_loop()
736 list->initial.element[i].repcount = t; in rotate_loop()
740 list->initial.count = newcount; in rotate_loop()
748 list->initial.length = m; in rotate_loop()
757 oldcount = list->repeated.count; in rotate_loop()
758 newcount = list->repeated.count + (t > 0 ? 1 : 0); in rotate_loop()
762 newelement[i] = list->repeated.element[j]; in rotate_loop()
764 newelement[i] = list->repeated.element[j]; in rotate_loop()
771 free (list->repeated.element); in rotate_loop()
772 list->repeated.element = newelement; in rotate_loop()
783 initial_splitelement (struct format_arg_list *list, unsigned int n) in initial_splitelement() argument
791 VERIFY_LIST (list); in initial_splitelement()
793 if (n > list->initial.length) in initial_splitelement()
795 ASSERT (list->repeated.count > 0); in initial_splitelement()
796 rotate_loop (list, n); in initial_splitelement()
797 ASSERT (n <= list->initial.length); in initial_splitelement()
802 s < list->initial.count && t >= list->initial.element[s].repcount; in initial_splitelement()
803 t -= list->initial.element[s].repcount, s++) in initial_splitelement()
809 ASSERT (s < list->initial.count); in initial_splitelement()
812 oldrepcount = list->initial.element[s].repcount; in initial_splitelement()
813 newcount = list->initial.count + 1; in initial_splitelement()
814 ensure_initial_alloc (list, newcount); in initial_splitelement()
815 for (i = list->initial.count - 1; i > s; i--) in initial_splitelement()
816 list->initial.element[i+1] = list->initial.element[i]; in initial_splitelement()
817 copy_element (&list->initial.element[s+1], &list->initial.element[s]); in initial_splitelement()
818 list->initial.element[s].repcount = t; in initial_splitelement()
819 list->initial.element[s+1].repcount = oldrepcount - t; in initial_splitelement()
820 list->initial.count = newcount; in initial_splitelement()
822 VERIFY_LIST (list); in initial_splitelement()
831 initial_unshare (struct format_arg_list *list, unsigned int n) in initial_unshare() argument
840 VERIFY_LIST (list); in initial_unshare()
842 if (n >= list->initial.length) in initial_unshare()
844 ASSERT (list->repeated.count > 0); in initial_unshare()
845 rotate_loop (list, n + 1); in initial_unshare()
846 ASSERT (n < list->initial.length); in initial_unshare()
851 s < list->initial.count && t >= list->initial.element[s].repcount; in initial_unshare()
852 t -= list->initial.element[s].repcount, s++) in initial_unshare()
856 ASSERT (s < list->initial.count); in initial_unshare()
858 if (list->initial.element[s].repcount > 1) in initial_unshare()
862 unsigned int oldrepcount = list->initial.element[s].repcount; in initial_unshare()
864 list->initial.count + (t == 0 || t == oldrepcount - 1 ? 1 : 2); in initial_unshare()
865 ensure_initial_alloc (list, newcount); in initial_unshare()
870 for (i = list->initial.count - 1; i > s; i--) in initial_unshare()
871 list->initial.element[i+1] = list->initial.element[i]; in initial_unshare()
872 copy_element (&list->initial.element[s+1], &list->initial.element[s]); in initial_unshare()
875 list->initial.element[s].repcount = 1; in initial_unshare()
876 list->initial.element[s+1].repcount = oldrepcount - 1; in initial_unshare()
880 list->initial.element[s].repcount = oldrepcount - 1; in initial_unshare()
881 list->initial.element[s+1].repcount = 1; in initial_unshare()
888 for (i = list->initial.count - 1; i > s; i--) in initial_unshare()
889 list->initial.element[i+2] = list->initial.element[i]; in initial_unshare()
890 copy_element (&list->initial.element[s+2], &list->initial.element[s]); in initial_unshare()
891 copy_element (&list->initial.element[s+1], &list->initial.element[s]); in initial_unshare()
892 list->initial.element[s].repcount = t; in initial_unshare()
893 list->initial.element[s+1].repcount = 1; in initial_unshare()
894 list->initial.element[s+2].repcount = oldrepcount - 1 - t; in initial_unshare()
896 list->initial.count = newcount; in initial_unshare()
902 ASSERT (list->initial.element[s].repcount == 1); in initial_unshare()
904 VERIFY_LIST (list); in initial_unshare()
913 shift_list (struct format_arg_list *list, unsigned int n) in shift_list() argument
915 VERIFY_LIST (list); in shift_list()
921 grow_initial_alloc (list); in shift_list()
922 for (i = list->initial.count; i > 0; i--) in shift_list()
923 list->initial.element[i] = list->initial.element[i-1]; in shift_list()
924 list->initial.element[0].repcount = n; in shift_list()
925 list->initial.element[0].presence = FCT_REQUIRED; in shift_list()
926 list->initial.element[0].type = FAT_OBJECT; in shift_list()
927 list->initial.count++; in shift_list()
928 list->initial.length += n; in shift_list()
930 normalize_outermost_list (list); in shift_list()
933 VERIFY_LIST (list); in shift_list()
959 re->list = copy_list (e2->list); in make_intersected_element()
965 re->list = copy_list (e1->list); in make_intersected_element()
973 re->list = make_intersection_with_empty_list (e1->list); in make_intersected_element()
974 if (re->list == NULL) in make_intersected_element()
983 re->list = make_intersection_with_empty_list (e2->list); in make_intersected_element()
984 if (re->list == NULL) in make_intersected_element()
1028 re->list = make_intersected_list (copy_list (e1->list), in make_intersected_element()
1029 copy_list (e2->list)); in make_intersected_element()
1030 if (re->list == NULL) in make_intersected_element()
1045 append_repeated_to_initial (struct format_arg_list *list) in append_repeated_to_initial() argument
1047 if (list->repeated.count > 0) in append_repeated_to_initial()
1052 newcount = list->initial.count + list->repeated.count; in append_repeated_to_initial()
1053 ensure_initial_alloc (list, newcount); in append_repeated_to_initial()
1054 i = list->initial.count; in append_repeated_to_initial()
1055 for (j = 0; j < list->repeated.count; j++, i++) in append_repeated_to_initial()
1056 list->initial.element[i] = list->repeated.element[j]; in append_repeated_to_initial()
1057 list->initial.count = newcount; in append_repeated_to_initial()
1058 list->initial.length = list->initial.length + list->repeated.length; in append_repeated_to_initial()
1059 free (list->repeated.element); in append_repeated_to_initial()
1060 list->repeated.element = NULL; in append_repeated_to_initial()
1061 list->repeated.allocated = 0; in append_repeated_to_initial()
1062 list->repeated.count = 0; in append_repeated_to_initial()
1063 list->repeated.length = 0; in append_repeated_to_initial()
1074 backtrack_in_initial (struct format_arg_list *list) in backtrack_in_initial() argument
1076 ASSERT (list->repeated.count == 0); in backtrack_in_initial()
1078 while (list->initial.count > 0) in backtrack_in_initial()
1080 unsigned int i = list->initial.count - 1; in backtrack_in_initial()
1081 if (list->initial.element[i].presence == FCT_REQUIRED) in backtrack_in_initial()
1084 list->initial.length -= list->initial.element[i].repcount; in backtrack_in_initial()
1085 free_element (&list->initial.element[i]); in backtrack_in_initial()
1086 list->initial.count = i; in backtrack_in_initial()
1091 list->initial.length--; in backtrack_in_initial()
1092 if (list->initial.element[i].repcount > 1) in backtrack_in_initial()
1093 list->initial.element[i].repcount--; in backtrack_in_initial()
1096 free_element (&list->initial.element[i]); in backtrack_in_initial()
1097 list->initial.count = i; in backtrack_in_initial()
1099 VERIFY_LIST (list); in backtrack_in_initial()
1100 return list; in backtrack_in_initial()
1104 free_list (list); in backtrack_in_initial()
1324 make_intersection_with_empty_list (struct format_arg_list *list) in make_intersection_with_empty_list() argument
1327 return make_intersected_list (copy_list (list), make_empty_list ()); in make_intersection_with_empty_list()
1329 if (list->initial.count > 0 in make_intersection_with_empty_list()
1330 ? list->initial.element[0].presence == FCT_REQUIRED in make_intersection_with_empty_list()
1331 : list->repeated.count > 0 in make_intersection_with_empty_list()
1332 && list->repeated.element[0].presence == FCT_REQUIRED) in make_intersection_with_empty_list()
1392 re->list = make_union_list (copy_list (e1->list), in make_union_element()
1393 copy_list (e2->list)); in make_union_element()
1431 else if (e1->type == FAT_LIST && is_empty_list (e1->list)) in make_union_element()
1444 else if (e2->type == FAT_LIST && is_empty_list (e2->list)) in make_union_element()
1750 make_union_with_empty_list (struct format_arg_list *list) in make_union_with_empty_list() argument
1753 return make_union_list (list, make_empty_list ()); in make_union_with_empty_list()
1755 VERIFY_LIST (list); in make_union_with_empty_list()
1757 if (list->initial.count > 0 in make_union_with_empty_list()
1758 ? list->initial.element[0].presence == FCT_REQUIRED in make_union_with_empty_list()
1759 : list->repeated.count > 0 in make_union_with_empty_list()
1760 && list->repeated.element[0].presence == FCT_REQUIRED) in make_union_with_empty_list()
1762 initial_splitelement (list, 1); in make_union_with_empty_list()
1763 ASSERT (list->initial.count > 0); in make_union_with_empty_list()
1764 ASSERT (list->initial.element[0].repcount == 1); in make_union_with_empty_list()
1765 ASSERT (list->initial.element[0].presence == FCT_REQUIRED); in make_union_with_empty_list()
1766 list->initial.element[0].presence = FCT_OPTIONAL; in make_union_with_empty_list()
1770 normalize_outermost_list (list); in make_union_with_empty_list()
1773 VERIFY_LIST (list); in make_union_with_empty_list()
1775 return list; in make_union_with_empty_list()
1809 is_required (const struct format_arg_list *list, unsigned int n) in is_required() argument
1819 s < list->initial.count && t >= list->initial.element[s].repcount; in is_required()
1820 t -= list->initial.element[s].repcount, s++) in is_required()
1821 if (list->initial.element[s].presence != FCT_REQUIRED) in is_required()
1827 if (s < list->initial.count) in is_required()
1829 if (list->initial.element[s].presence != FCT_REQUIRED) in is_required()
1836 if (list->repeated.count == 0) in is_required()
1840 s < list->repeated.count && t >= list->repeated.element[s].repcount; in is_required()
1841 t -= list->repeated.element[s].repcount, s++) in is_required()
1842 if (list->repeated.element[s].presence != FCT_REQUIRED) in is_required()
1848 if (s < list->repeated.count) in is_required()
1850 if (list->repeated.element[s].presence != FCT_REQUIRED) in is_required()
1867 add_required_constraint (struct format_arg_list *list, unsigned int n) in add_required_constraint() argument
1871 if (list == NULL) in add_required_constraint()
1874 VERIFY_LIST (list); in add_required_constraint()
1876 if (list->repeated.count == 0 && list->initial.length <= n) in add_required_constraint()
1880 free_list (list); in add_required_constraint()
1884 initial_splitelement (list, n + 1); in add_required_constraint()
1888 list->initial.element[i].presence = FCT_REQUIRED; in add_required_constraint()
1889 rest -= list->initial.element[i].repcount; in add_required_constraint()
1893 VERIFY_LIST (list); in add_required_constraint()
1895 return list; in add_required_constraint()
1904 add_end_constraint (struct format_arg_list *list, unsigned int n) in add_end_constraint() argument
1909 if (list == NULL) in add_end_constraint()
1912 VERIFY_LIST (list); in add_end_constraint()
1914 if (list->repeated.count == 0 && list->initial.length <= n) in add_end_constraint()
1916 return list; in add_end_constraint()
1918 s = initial_splitelement (list, n); in add_end_constraint()
1920 (s < list->initial.count in add_end_constraint()
1921 ? /* n < list->initial.length */ list->initial.element[s].presence in add_end_constraint()
1922 : /* n >= list->initial.length */ list->repeated.element[0].presence); in add_end_constraint()
1924 for (i = s; i < list->initial.count; i++) in add_end_constraint()
1926 list->initial.length -= list->initial.element[i].repcount; in add_end_constraint()
1927 free_element (&list->initial.element[i]); in add_end_constraint()
1929 list->initial.count = s; in add_end_constraint()
1931 for (i = 0; i < list->repeated.count; i++) in add_end_constraint()
1932 free_element (&list->repeated.element[i]); in add_end_constraint()
1933 if (list->repeated.element != NULL) in add_end_constraint()
1934 free (list->repeated.element); in add_end_constraint()
1935 list->repeated.element = NULL; in add_end_constraint()
1936 list->repeated.allocated = 0; in add_end_constraint()
1937 list->repeated.count = 0; in add_end_constraint()
1938 list->repeated.length = 0; in add_end_constraint()
1941 return backtrack_in_initial (list); in add_end_constraint()
1943 return list; in add_end_constraint()
1952 add_type_constraint (struct format_arg_list *list, unsigned int n, in add_type_constraint() argument
1959 if (list == NULL) in add_type_constraint()
1965 s = initial_unshare (list, n); in add_type_constraint()
1970 &list->initial.element[s], &newconstraint)) in add_type_constraint()
1971 return add_end_constraint (list, n); in add_type_constraint()
1972 free_element (&list->initial.element[s]); in add_type_constraint()
1973 list->initial.element[s].type = tmpelement.type; in add_type_constraint()
1974 list->initial.element[s].list = tmpelement.list; in add_type_constraint()
1976 VERIFY_LIST (list); in add_type_constraint()
1978 return list; in add_type_constraint()
1987 add_listtype_constraint (struct format_arg_list *list, unsigned int n, in add_listtype_constraint() argument
1995 if (list == NULL) in add_listtype_constraint()
2001 s = initial_unshare (list, n); in add_listtype_constraint()
2005 newconstraint.list = sublist; in add_listtype_constraint()
2007 &list->initial.element[s], &newconstraint)) in add_listtype_constraint()
2008 return add_end_constraint (list, n); in add_listtype_constraint()
2009 free_element (&list->initial.element[s]); in add_listtype_constraint()
2010 list->initial.element[s].type = tmpelement.type; in add_listtype_constraint()
2011 list->initial.element[s].list = tmpelement.list; in add_listtype_constraint()
2013 VERIFY_LIST (list); in add_listtype_constraint()
2015 return list; in add_listtype_constraint()
2065 listlist->repeated.element[0].list = sublist; in make_repeated_list_of_lists()
2090 struct format_arg_list *list; in make_repeated_list() local
2149 list = XMALLOC (struct format_arg_list); in make_repeated_list()
2150 list->initial.count = 0; in make_repeated_list()
2151 list->initial.allocated = 0; in make_repeated_list()
2152 list->initial.element = NULL; in make_repeated_list()
2153 list->initial.length = 0; in make_repeated_list()
2154 list->repeated.count = 0; in make_repeated_list()
2155 list->repeated.allocated = 0; in make_repeated_list()
2156 list->repeated.element = NULL; in make_repeated_list()
2157 list->repeated.length = 0; in make_repeated_list()
2175 grow_initial_alloc (list); in make_repeated_list()
2176 copy_element (&list->initial.element[list->initial.count], in make_repeated_list()
2178 list->initial.element[list->initial.count].repcount = k; in make_repeated_list()
2179 list->initial.count++; in make_repeated_list()
2180 list->initial.length += k; in make_repeated_list()
2191 ASSERT (list->initial.count > 0); in make_repeated_list()
2192 if (list->initial.element[0].presence == FCT_REQUIRED) in make_repeated_list()
2194 initial_splitelement (list, 1); in make_repeated_list()
2195 ASSERT (list->initial.element[0].presence == FCT_REQUIRED); in make_repeated_list()
2196 ASSERT (list->initial.element[0].repcount == 1); in make_repeated_list()
2197 list->initial.element[0].presence = FCT_OPTIONAL; in make_repeated_list()
2205 list->initial.element[sj].repcount - tj); in make_repeated_list()
2208 grow_initial_alloc (list); in make_repeated_list()
2209 if (!make_intersected_element (&list->initial.element[list->initial.count], in make_repeated_list()
2211 &list->initial.element[sj])) in make_repeated_list()
2213 if (list->initial.element[list->initial.count].presence == FCT_REQUIRED) in make_repeated_list()
2216 list = backtrack_in_initial (list); in make_repeated_list()
2217 ASSERT (list != NULL); /* at least the empty list is valid */ in make_repeated_list()
2218 return list; in make_repeated_list()
2227 list->initial.element[list->initial.count].repcount = k; in make_repeated_list()
2228 list->initial.count++; in make_repeated_list()
2229 list->initial.length += k; in make_repeated_list()
2241 if (tj == list->initial.element[sj].repcount) in make_repeated_list()
2248 ASSERT (list->initial.length == n); in make_repeated_list()
2252 for (i = 0; i < list->initial.length; i += period) in make_repeated_list()
2254 si = initial_unshare (list, i); in make_repeated_list()
2255 list->initial.element[si].presence = FCT_OPTIONAL; in make_repeated_list()
2261 splitindex = initial_splitelement (list, n - p); in make_repeated_list()
2262 newcount = list->initial.count - splitindex; in make_repeated_list()
2263 if (newcount > list->repeated.allocated) in make_repeated_list()
2265 list->repeated.allocated = newcount; in make_repeated_list()
2266 list->repeated.element = XNMALLOC (newcount, struct format_arg); in make_repeated_list()
2269 list->repeated.element[j] = list->initial.element[i]; in make_repeated_list()
2270 list->repeated.count = newcount; in make_repeated_list()
2271 list->repeated.length = p; in make_repeated_list()
2272 list->initial.count = splitindex; in make_repeated_list()
2273 list->initial.length = n - p; in make_repeated_list()
2276 VERIFY_LIST (list); in make_repeated_list()
2278 return list; in make_repeated_list()
2452 struct format_arg_list *list = *listp; in parse_upto() local
2575 if (!check_params (&list, paramcount, params, 4, IIIC, in parse_upto()
2582 add_req_type_constraint (&list, position++, FAT_OBJECT); in parse_upto()
2586 if (!check_params (&list, paramcount, params, 0, NULL, in parse_upto()
2593 add_req_type_constraint (&list, position++, FAT_OBJECT); in parse_upto()
2600 if (!check_params (&list, paramcount, params, 4, ICCI, in parse_upto()
2607 add_req_type_constraint (&list, position++, FAT_INTEGER); in parse_upto()
2611 if (!check_params (&list, paramcount, params, 5, IICCI, in parse_upto()
2618 add_req_type_constraint (&list, position++, FAT_INTEGER); in parse_upto()
2622 if (!check_params (&list, paramcount, params, 0, NULL, in parse_upto()
2635 add_req_type_constraint (&list, position++, FAT_OBJECT); in parse_upto()
2639 if (!check_params (&list, paramcount, params, 0, NULL, in parse_upto()
2646 add_req_type_constraint (&list, position++, FAT_CHARACTER); in parse_upto()
2650 if (!check_params (&list, paramcount, params, 5, IIICC, in parse_upto()
2657 add_req_type_constraint (&list, position++, FAT_REAL); in parse_upto()
2662 if (!check_params (&list, paramcount, params, 7, IIIICCC, in parse_upto()
2669 add_req_type_constraint (&list, position++, FAT_REAL); in parse_upto()
2673 if (!check_params (&list, paramcount, params, 4, IIIC, in parse_upto()
2680 add_req_type_constraint (&list, position++, FAT_REAL); in parse_upto()
2688 if (!check_params (&list, paramcount, params, 1, I, in parse_upto()
2698 if (!check_params (&list, paramcount, params, 0, NULL, in parse_upto()
2707 if (!check_params (&list, paramcount, params, 2, II, in parse_upto()
2716 if (!check_params (&list, paramcount, params, 1, I, in parse_upto()
2774 if (!check_params (&list, paramcount, params, 0, NULL, in parse_upto()
2781 add_req_type_constraint (&list, position++, FAT_FORMATSTRING); in parse_upto()
2788 add_req_listtype_constraint (&list, position++, in parse_upto()
2795 if (!check_params (&list, paramcount, params, 0, NULL, in parse_upto()
2802 add_req_type_constraint (&list, position++, FAT_OBJECT); in parse_upto()
2816 if (!check_params (&list, paramcount, params, 0, NULL, in parse_upto()
2824 *listp = list; in parse_upto()
2838 list = *listp; in parse_upto()
2850 if (!check_params (&list, paramcount, params, 0, NULL, in parse_upto()
2858 *listp = list; in parse_upto()
2875 if (!check_params (&list, paramcount, params, 0, NULL, in parse_upto()
2886 nil_list = (list != NULL ? copy_list (list) : NULL); in parse_upto()
2899 (list != NULL ? copy_list (list) : NULL); in parse_upto()
2931 if (list != NULL) in parse_upto()
2932 free_list (list); in parse_upto()
2933 list = union_list; in parse_upto()
2940 if (!check_params (&list, paramcount, params, 0, NULL, in parse_upto()
2948 add_req_type_constraint (&list, position++, FAT_OBJECT); in parse_upto()
2959 (list != NULL ? copy_list (list) : NULL); in parse_upto()
2993 (list != NULL ? copy_list (list) : NULL); in parse_upto()
3018 if (list != NULL) in parse_upto()
3019 free_list (list); in parse_upto()
3020 list = union_list; in parse_upto()
3029 if (!check_params (&list, paramcount, params, 1, I, in parse_upto()
3042 add_req_type_constraint (&list, position++, FAT_OBJECT); in parse_upto()
3056 (list != NULL ? copy_list (list) : NULL); in parse_upto()
3092 if (list != NULL) in parse_upto()
3093 union_list = union (union_list, copy_list (list)); in parse_upto()
3101 if (list != NULL) in parse_upto()
3102 free_list (list); in parse_upto()
3103 list = union_list; in parse_upto()
3115 if (!check_params (&list, paramcount, params, 0, NULL, in parse_upto()
3123 *listp = list; in parse_upto()
3128 if (!check_params (&list, paramcount, params, 1, I, in parse_upto()
3141 sub_spec.list = sub_list; in parse_upto()
3156 add_req_type_constraint (&list, position++, FAT_FORMATSTRING); in parse_upto()
3206 if (list != NULL && position >= 0) in parse_upto()
3209 list = make_intersected_list (list, sub_list); in parse_upto()
3217 add_req_listtype_constraint (&list, position++, in parse_upto()
3232 if (!check_params (&list, paramcount, params, 0, NULL, in parse_upto()
3240 *listp = list; in parse_upto()
3245 if (!check_params (&list, paramcount, params, 4, IIIC, in parse_upto()
3256 *listp = list; in parse_upto()
3275 list = *listp; in parse_upto()
3280 list = union (list, sub_escape); in parse_upto()
3292 if (!check_params (&list, paramcount, params, 0, NULL, in parse_upto()
3300 *listp = list; in parse_upto()
3305 if (!check_params (&list, paramcount, params, 3, THREE, in parse_upto()
3311 if (position >= 0 && list != NULL && is_required (list, position)) in parse_upto()
3314 if (list != NULL) in parse_upto()
3316 struct format_arg_list *this_escape = copy_list (list); in parse_upto()
3322 list = add_required_constraint (list, position); in parse_upto()
3335 if (!check_params (&list, paramcount, params, 1, I, in parse_upto()
3344 if (!check_params (&list, paramcount, params, 0, NULL, in parse_upto()
3353 *listp = list; in parse_upto()
3359 if (!nocheck_params (&list, paramcount, params, in parse_upto()
3367 add_req_type_constraint (&list, position++, FAT_FUNCTION); in parse_upto()
3368 add_req_type_constraint (&list, position++, FAT_OBJECT); in parse_upto()
3395 *listp = list; in parse_upto()
3419 spec.list = make_unconstrained_list (); in format_parse()
3422 if (!parse_upto (&format, &position, &spec.list, &escape, in format_parse()
3429 spec.list = union (spec.list, escape); in format_parse()
3431 if (spec.list == NULL) in format_parse()
3440 normalize_list (spec.list); in format_parse()
3452 free_list (spec->list); in format_free()
3474 if (!equal_list (spec1->list, spec2->list)) in format_check()
3485 make_intersected_list (copy_list (spec1->list), in format_check()
3486 copy_list (spec2->list)); in format_check()
3490 equal_list (intersection, spec2->list)))) in format_check()
3524 static void print_list (struct format_arg_list *list);
3564 print_list (element->list); in print_element()
3578 print_list (struct format_arg_list *list) in print_list() argument
3584 for (i = 0; i < list->initial.count; i++) in print_list()
3585 for (j = 0; j < list->initial.element[i].repcount; j++) in print_list()
3589 print_element (&list->initial.element[i]); in print_list()
3592 if (list->repeated.count > 0) in print_list()
3595 for (i = 0; i < list->repeated.count; i++) in print_list()
3596 for (j = 0; j < list->repeated.element[i].repcount; j++) in print_list()
3599 print_element (&list->repeated.element[i]); in print_list()
3617 print_list (spec->list); in format_print()