Changeset 624 for trunk/libs
- Timestamp:
- Mar 12, 2019, 1:37:38 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libs/mini-libc/stdio.c
r623 r624 52 52 53 53 /////////////////////////////////////////////////// 54 static unsignedint xprintf( char * string,55 unsigned intlength,56 57 58 { 59 unsignedint ps = 0; // write index to the string buffer60 61 #define TO_STREAM(x) do { string[ps] = (x); ps++; if(ps==length) return 0xFFFFFFFF; } while(0);54 static int xprintf( char * string, 55 int length, 56 const char * format, 57 va_list * args ) 58 { 59 int ps = 0; // write index to the string buffer 60 61 #define TO_STREAM(x) do { string[ps] = (x); ps++; if(ps==length) return -1; } while(0); 62 62 63 63 xprintf_text: … … 259 259 default: // unsupported argument type 260 260 { 261 return 0xFFFFFFFF;261 return -1; 262 262 } 263 263 } // end switch on argument type … … 326 326 327 327 va_start( args, format ); 328 count = xprintf( string , length , format , &args );328 count = xprintf( string , (int)length , format , &args ); 329 329 va_end( args ); 330 330 … … 398 398 char string[4096]; 399 399 va_list args; 400 unsigned int count; 400 int count; 401 int writen; 401 402 int fd; 402 403 … … 408 409 va_end( args ); 409 410 410 if ( count == 0xFFFFFFFF)411 if ( count < 0 ) 411 412 { 412 413 display_string( "fprintf : xprintf failure" ); … … 421 422 string[count] = 0; 422 423 423 printf("\n[%s] fd = %d for string :\n", __FUNCTION__, fd, string ); 424 425 return write( fd , &string , count ); 424 printf("\n[%s] fd = %d for string : %s\n", __FUNCTION__, fd, string ); 425 426 idbg(); 427 428 // copy string to file 429 writen = write( fd , &string , count ); 430 431 if( writen != count ) 432 { 433 display_string( "fprintf : write failure" ); 434 return -1; 435 } 436 437 idbg(); 438 439 return writen; 426 440 } 427 441 } // end fprintf()
Note: See TracChangeset
for help on using the changeset viewer.