@@ -34,11 +34,14 @@ macro_rules! syscall1 {
3434/// This macro returns a `Result<(), ()>` value
3535#[ macro_export]
3636macro_rules! hprint {
37- ( $s: expr) => {
38- $crate:: export:: hstdout_str( $s)
39- } ;
4037 ( $( $tt: tt) * ) => {
41- $crate:: export:: hstdout_fmt( format_args!( $( $tt) * ) )
38+ match :: core:: format_args!( $( $tt) * ) {
39+ args => if let :: core:: option:: Option :: Some ( s) = args. as_str( ) {
40+ $crate:: export:: hstdout_str( s)
41+ } else {
42+ $crate:: export:: hstdout_fmt( args)
43+ } ,
44+ }
4245 } ;
4346}
4447
@@ -47,14 +50,11 @@ macro_rules! hprint {
4750/// This macro returns a `Result<(), ()>` value
4851#[ macro_export]
4952macro_rules! hprintln {
50- ( ) => {
51- $crate:: export:: hstdout_str( "\n " )
52- } ;
53- ( $s: expr) => {
54- $crate:: export:: hstdout_str( concat!( $s, "\n " ) )
55- } ;
56- ( $s: expr, $( $tt: tt) * ) => {
57- $crate:: export:: hstdout_fmt( format_args!( concat!( $s, "\n " ) , $( $tt) * ) )
53+ ( $( $tt: tt) * ) => {
54+ match $crate:: hprint!( $( $tt) * ) {
55+ Ok ( ( ) ) => $crate:: export:: hstdout_str( "\n " ) ,
56+ Err ( ( ) ) => Err ( ( ) ) ,
57+ }
5858 } ;
5959}
6060
@@ -63,11 +63,14 @@ macro_rules! hprintln {
6363/// This macro returns a `Result<(), ()>` value
6464#[ macro_export]
6565macro_rules! heprint {
66- ( $s: expr) => {
67- $crate:: export:: hstderr_str( $s)
68- } ;
6966 ( $( $tt: tt) * ) => {
70- $crate:: export:: hstderr_fmt( format_args!( $( $tt) * ) )
67+ match :: core:: format_args!( $( $tt) * ) {
68+ args => if let :: core:: option:: Option :: Some ( s) = args. as_str( ) {
69+ $crate:: export:: hstderr_str( s)
70+ } else {
71+ $crate:: export:: hstderr_fmt( args)
72+ } ,
73+ }
7174 } ;
7275}
7376
@@ -76,14 +79,11 @@ macro_rules! heprint {
7679/// This macro returns a `Result<(), ()>` value
7780#[ macro_export]
7881macro_rules! heprintln {
79- ( ) => {
80- $crate:: export:: hstderr_str( "\n " )
81- } ;
82- ( $s: expr) => {
83- $crate:: export:: hstderr_str( concat!( $s, "\n " ) )
84- } ;
85- ( $s: expr, $( $tt: tt) * ) => {
86- $crate:: export:: hstderr_fmt( format_args!( concat!( $s, "\n " ) , $( $tt) * ) )
82+ ( $( $tt: tt) * ) => {
83+ match $crate:: heprint!( $( $tt) * ) {
84+ Ok ( ( ) ) => $crate:: export:: hstderr_str( "\n " ) ,
85+ Err ( ( ) ) => Err ( ( ) ) ,
86+ }
8787 } ;
8888}
8989
0 commit comments