This is the mail archive of the glibc-bugs@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/1056] New: Wrong count return from fprintf(strderr,...), printf() is ok...


After updating my gentoo systems i'v got different returns from 
fprintf(stdout,...) and printf(). 
When there are nor characters after the format fprintf() returns 
1 instead the number of characters written...: 
Example: 
------------------------------------------------------- 
#include <stdio.h> 
#include <string.h> 
 
int main(int argc,char *argv[]) 
 
{ 
char  *s = "123"; 
int   return_of_printf; 
int   return_of_fprintf; 
int   return_of_fprintf_fixed; 
 
 
    return_of_printf        = printf("%s",s); 
    printf("\n"); 
    return_of_fprintf       = fprintf(stdout,"%s",s); 
    printf("\n"); 
    return_of_fprintf_fixed = fprintf(stdout,"%s ",s);      // One char after 
%s.... 
    printf("\n"); 
 
    if (return_of_printf != return_of_fprintf || 
        return_of_printf != (int) strlen(s)) { 
 
        printf("BAD !\n"); 
        printf("strlen()                = %d\n",(int) strlen(s)); 
        printf("return_of_printf        = %d\n",return_of_printf); 
        printf("return_of_fprintf       = %d\n",return_of_fprintf); 
        printf("return_of_fprintf_fixed = %d\n",return_of_fprintf_fixed); 
    } 
    else { 
        printf("Good\n"); 
    } 
 
    return 0 ; 
} 
------------------------------------------------------- 
Output: 
------------------------------------------------------- 
123 
123 
123  
BAD ! 
strlen()                = 3 
return_of_printf        = 3 
return_of_fprintf       = 1 
return_of_fprintf_fixed = 4 
------------------------------------------------------- 
 
The 1 is wrong (I think...)

-- 
           Summary: Wrong count return from fprintf(strderr,...), printf()
                    is ok...
           Product: glibc
           Version: 2.3.5
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: gotom at debian dot or dot jp
        ReportedBy: thomas dot welsch at hauk-sasko dot de
                CC: glibc-bugs at sources dot redhat dot com
  GCC host triplet: i686-pc-linux-gnu


http://sources.redhat.com/bugzilla/show_bug.cgi?id=1056

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]