delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2016/07/08/13:16:42

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:date:from:reply-to:to:message-id:subject
:mime-version:content-type:content-transfer-encoding:references;
q=dns; s=default; b=JKgMCWVpeosL1kSLISIM+pfsLeSCt+NySZcIWq2ymPe
PXndy4tpR84q9zGfYKK2kSqnf3G1F76WtpVJpMg2PIFBwZ5JUZ3uaj305lcdj1pm
XgnhB8X6Wg9O+Y8QvhdGCgbX5o9yol08O/5hqy7+7FugfrZDSMJDhWoPpMKB1Fng
=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:date:from:reply-to:to:message-id:subject
:mime-version:content-type:content-transfer-encoding:references;
s=default; bh=0m0MTRXQHQzn05NtT80nh0r2ypY=; b=Coowp1rtbA0WZeU9r
eddu7qBmexSnGYwDiRQv8XBOwITGk3T1NQ1o8eVAZ5XUAgy3OmbEN4+MJOK25FVK
a13Bc+ZVjSV2jqdpDWbdspHzX4c5kZ1sTy5LcYPiKGgzANW2+kP4vRHfLb/BZeei
3D7NjtXd5Qm3n23l0J90cOyNfM=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=-3.4 required=5.0 tests=BAYES_00,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,FREEMAIL_REPLYTO_END_DIGIT,RCVD_IN_DNSWL_LOW,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 spammy=HX-Envelope-From:sk:eclipse, Hx-spam-relays-external:sk:tm3.bul, H*RU:sk:tm3.bul, ideal
X-HELO: nm24-vm4.bullet.mail.gq1.yahoo.com
Date: Fri, 8 Jul 2016 17:16:22 +0000 (UTC)
From: Owen Leibman <eclipsechasers2 AT yahoo DOT com>
Reply-To: Owen Leibman <eclipsechasers2 AT yahoo DOT com>
To: "cygwin AT cygwin DOT com" <cygwin AT cygwin DOT com>
Message-ID: <768145014.4380137.1467998182030.JavaMail.yahoo@mail.yahoo.com>
Subject: scanf and m modifier
MIME-Version: 1.0
References: <768145014 DOT 4380137 DOT 1467998182030 DOT JavaMail DOT yahoo DOT ref AT mail DOT 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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019