@@ -339,41 +339,16 @@ macro_rules! g_log_inner {
339
339
fn check_log_args( _log_level: LogLevel , _format: & str ) { }
340
340
341
341
check_log_args( $log_level, $format) ;
342
-
343
- // Replace literal percentage signs with two so that they are not interpreted as printf
344
- // format specifiers
345
- struct GWrite ( $crate:: GStringBuilder ) ;
346
-
347
- impl fmt:: Write for GWrite {
348
- fn write_str( & mut self , mut s: & str ) -> :: std:: result:: Result <( ) , fmt:: Error > {
349
- while let Some ( ( prefix, suffix) ) = s. split_once( '%' ) {
350
- self . 0 . append( prefix) ;
351
- self . 0 . append( "%%" ) ;
352
- s = suffix;
353
- }
354
- self . 0 . append( s) ;
355
- Ok ( ( ) )
356
- }
357
-
358
- fn write_char( & mut self , c: char ) -> fmt:: Result {
359
- if c == '%' {
360
- self . 0 . append( "%%" ) ;
361
- } else {
362
- self . 0 . append_c( c) ;
363
- }
364
- Ok ( ( ) )
365
- }
366
- }
367
-
368
- let mut w = GWrite ( $crate:: GStringBuilder :: default ( ) ) ;
342
+ let mut w = $crate:: GStringBuilder :: default ( ) ;
369
343
370
344
// Can't really happen but better safe than sorry
371
345
if !std:: write!( & mut w, $format, $( $arg) ,* ) . is_err( ) {
372
346
unsafe {
373
347
$crate:: ffi:: g_log(
374
348
$log_domain,
375
349
$log_level. into_glib( ) ,
376
- w. 0 . into_string( ) . to_glib_none( ) . 0 ,
350
+ b"%s\0 " . as_ptr( ) as * const i8 ,
351
+ ToGlibPtr :: <* const i8 >:: to_glib_none( & w. into_string( ) ) . 0 ,
377
352
) ;
378
353
}
379
354
}
@@ -666,38 +641,15 @@ macro_rules! g_print_inner {
666
641
fn check_arg( _format: & str ) { }
667
642
668
643
check_arg( $format) ;
669
-
670
- // Replace literal percentage signs with two so that they are not interpreted as printf
671
- // format specifiers
672
- struct GWrite ( $crate:: GStringBuilder ) ;
673
-
674
- impl fmt:: Write for GWrite {
675
- fn write_str( & mut self , mut s: & str ) -> :: std:: result:: Result <( ) , fmt:: Error > {
676
- while let Some ( ( prefix, suffix) ) = s. split_once( '%' ) {
677
- self . 0 . append( prefix) ;
678
- self . 0 . append( "%%" ) ;
679
- s = suffix;
680
- }
681
- self . 0 . append( s) ;
682
- Ok ( ( ) )
683
- }
684
-
685
- fn write_char( & mut self , c: char ) -> fmt:: Result {
686
- if c == '%' {
687
- self . 0 . append( "%%" ) ;
688
- } else {
689
- self . 0 . append_c( c) ;
690
- }
691
- Ok ( ( ) )
692
- }
693
- }
694
-
695
- let mut w = GWrite ( $crate:: GStringBuilder :: default ( ) ) ;
644
+ let mut w = $crate:: GStringBuilder :: default ( ) ;
696
645
697
646
// Can't really happen but better safe than sorry
698
647
if !std:: write!( & mut w, $format, $( $arg) ,* ) . is_err( ) {
699
648
unsafe {
700
- $crate:: ffi:: $func( w. 0 . into_string( ) . to_glib_none( ) . 0 ) ;
649
+ $crate:: ffi:: $func(
650
+ b"%s\0 " . as_ptr( ) as * const i8 ,
651
+ ToGlibPtr :: <* const i8 >:: to_glib_none( & w. into_string( ) ) . 0 ,
652
+ ) ;
701
653
}
702
654
}
703
655
} } ;
0 commit comments