X-Spam-Check-By: sourceware.org Message-ID: <4624E50A.2F30A6D9@dessent.net> Date: Tue, 17 Apr 2007 08:17:30 -0700 From: Brian Dessent X-Mailer: Mozilla 4.79 [en] (Windows NT 5.0; U) MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: Re: 1.5.24: gcc / libc problem with sscanf References: <4624D8C0 DOT 6010809 AT id DOT ethz DOT ch> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Reply-To: cygwin AT cygwin DOT com Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Matteo Corti wrote: > I get strange results when using the %zi flag for the sscanf and fscanf > functions. > > The following code scans a line and parses an integer and a size_t value. > > size_t var_size_t = 0; > int var_int = 0; > > char * string = "2 10"; > > sscanf(string, "%zi %i\n", &var_size_t, &var_int); > > printf("size_t = %zi\n", var_size_t); > printf("int = %i\n", var_int); > > The code when compiled and run generates 2 followed by 0 instead of the > correct 2 and 10 (that I get on linux and mac os x). Yes, unfortunately newlib does not support the 'z' size flag for the scanf family of functions. It's got nothing to do with gcc or Cygwin directly, we just inherit whatever functionality newlib has, as that's where all the stdio implementation comes from. From what I can tell this is a C99 item that wasn't in POSIX/SUSv3/ANSI C/C90, so it's no surprise that it's not implemented as widely. I think Eric Blake has been recently working on getting more C99 printf/scanf specifiers implemented in newlib, so there's a chance this is on his TODO list, but no guarantees. Brian -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/