FreeBSD Bugzilla – Attachment 159753 Details for
Bug 202240
[patch] fwscanf return EOF instead of ZERO in the event of matching failure
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
Source file compares fwscanf & fscanf return values
fbsd_fwscanf_check.c (text/plain), 1.15 KB, created by
Rajendra
on 2015-08-11 07:11:24 UTC
(
hide
)
Description:
Source file compares fwscanf & fscanf return values
Filename:
MIME Type:
Creator:
Rajendra
Created:
2015-08-11 07:11:24 UTC
Size:
1.15 KB
patch
obsolete
>#include <stdio.h> >#include <stdlib.h> >#include <string.h> >#include <errno.h> >#include <wchar.h> > > >FILE *file_open(const char *filename) >{ > FILE *fptr = fopen(filename, "w+"); > if (NULL == fptr) { > printf("Error: Failed to open '%s' file (%s)\n", filename, strerror(errno)); > exit(1); > } > return fptr; >} > >FILE *open_file1(const char *filename) >{ > FILE *fptr = file_open(filename); > const char buf[20] = "raj\n"; > fprintf(fptr, buf); > rewind(fptr); > return fptr; >} > >FILE *open_file2(const char *filename) >{ > FILE *fptr = file_open(filename); > const wchar_t buf[20] = L"raj\n"; > fwprintf(fptr, buf); > rewind(fptr); > return fptr; >} > >void return_value(const char *func, int ret) >{ > if (ret == 0) { > printf("%s return value is ZERO \n", func); > } else if(ret == EOF) { > printf("%s return value is EOF \n", func); > } else { > printf("%s return value is %d \n", func, ret); > } >} > >int main(int argc, char *argv[]) >{ > > FILE *fptr1 = open_file1("tmp1.txt"); > char buf1[20]; > return_value("fscanf", fscanf(fptr1, "j%s", buf1)); > fclose(fptr1); > > FILE *fptr2 = open_file2("tmp2.txt"); > wchar_t buf2[20]; > return_value("fwscanf", fwscanf(fptr2, L"j%s", buf2)); > fclose(fptr2); > > return 0; >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 202240
: 159753