This is the mail archive of the
cygwin
mailing list for the Cygwin project.
scanf and m modifier
- From: Owen Leibman <eclipsechasers2 at yahoo dot com>
- To: "cygwin at cygwin dot com" <cygwin at cygwin dot com>
- Date: Fri, 8 Jul 2016 17:16:22 +0000 (UTC)
- Subject: scanf and m modifier
- Authentication-results: sourceware.org; auth=none
- References: <768145014.4380137.1467998182030.JavaMail.yahoo.ref@mail.yahoo.com>
- Reply-to: Owen Leibman <eclipsechasers2 at yahoo dot com>
The m modifier is handled just fine by the compiler, but
the results of using it are different on Cygwin than on several other systems
I've tried. Here is a sample program:
#include <stdio.h>
#include <stdlib.h>
#define NAMELEN 100
int main(void) {
char *f =
"inputstring", title[NAMELEN], *buffer = 0;
int scanrc;
scanrc =
sscanf(f, "%ms", &buffer);
if (scanrc <
1) {
snprintf(title,
sizeof(title), "sscanf failed");
} else {
snprintf(title,
sizeof(title), "%s", buffer);
free(buffer);
}
printf("title is %s.\n", title);
return 0;
}
The expected result is "title is inputstring",
which is what I see on Ubuntu and RedHat systems.
What I see in Cygwin is "sscanf failed".
My compile command is:
gcc -Wall program.c
No warnings are issued. I have also tried adding various
flavors of -D_XOPEN_SOURCE and -D_POSIX_SOURCE, all without success. Is there
some compile option I need to add, or is my program wrong, or is there a
problem with the library code in Cygwin?
BTW, on a very old Solaris system with a very old version of gcc (3.3), I did receive the following message:
replscan3.c:7: warning: unknown conversion type character `m' in format
That is far from ideal, but it is better than the inconsistency between the compiler and the run-time which I'm seeing in Cygwin.
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple