@ -302,6 +302,8 @@ struct d_print_info
/* The current index into any template argument packs we are using
/* The current index into any template argument packs we are using
for printing . */
for printing . */
int pack_index ;
int pack_index ;
/* Number of d_print_flush calls so far. */
unsigned long int flush_count ;
} ;
} ;
# ifdef CP_DEMANGLE_DEBUG
# ifdef CP_DEMANGLE_DEBUG
@ -3285,6 +3287,7 @@ d_print_init (struct d_print_info *dpi, int options,
dpi - > last_char = ' \0 ' ;
dpi - > last_char = ' \0 ' ;
dpi - > templates = NULL ;
dpi - > templates = NULL ;
dpi - > modifiers = NULL ;
dpi - > modifiers = NULL ;
dpi - > flush_count = 0 ;
dpi - > callback = callback ;
dpi - > callback = callback ;
dpi - > opaque = opaque ;
dpi - > opaque = opaque ;
@ -3314,6 +3317,7 @@ d_print_flush (struct d_print_info *dpi)
dpi - > buf [ dpi - > len ] = ' \0 ' ;
dpi - > buf [ dpi - > len ] = ' \0 ' ;
dpi - > callback ( dpi - > buf , dpi - > len , dpi - > opaque ) ;
dpi - > callback ( dpi - > buf , dpi - > len , dpi - > opaque ) ;
dpi - > len = 0 ;
dpi - > len = 0 ;
dpi - > flush_count + + ;
}
}
/* Append characters and buffers for printing. */
/* Append characters and buffers for printing. */
@ -4047,12 +4051,18 @@ d_print_comp (struct d_print_info *dpi,
if ( d_right ( dc ) ! = NULL )
if ( d_right ( dc ) ! = NULL )
{
{
size_t len ;
size_t len ;
unsigned long int flush_count ;
/* Make sure ", " isn't flushed by d_append_string, otherwise
dpi - > len - = 2 wouldn ' t work . */
if ( dpi - > len > = sizeof ( dpi - > buf ) - 2 )
d_print_flush ( dpi ) ;
d_append_string ( dpi , " , " ) ;
d_append_string ( dpi , " , " ) ;
len = dpi - > len ;
len = dpi - > len ;
flush_count = dpi - > flush_count ;
d_print_comp ( dpi , d_right ( dc ) ) ;
d_print_comp ( dpi , d_right ( dc ) ) ;
/* If that didn't print anything (which can happen with empty
/* If that didn't print anything (which can happen with empty
template argument packs ) , remove the comma and space . */
template argument packs ) , remove the comma and space . */
if ( dpi - > len = = len )
if ( dpi - > flush_count = = flush_count & & dpi - > len = = len )
dpi - > len - = 2 ;
dpi - > len - = 2 ;
}
}
return ;
return ;