A problem with regex in sscanf on uclibc

Anthony G. Basile basile at opensource.dyc.edu
Wed Aug 14 13:10:21 UTC 2013


Hi everyone,

I hit an issue sscanf when trying to compile bind9 on a uclibc system. 
The following is reduced code which illustrates the problem:

#include <stdio.h>

int
main()
{
	char* filename = "txt_16.c";
	char buf[30], typename[30];
	int type;

	//sscanf(filename, "%20[0-9a-z]_%d.c", typename, &type);

	sscanf(filename, "%20[^_]_%d.c", typename, &type);
	printf("filename = %s\n", filename);
	printf("typename = %s\n", typename);
	printf("type     = %d\n", type);
}


This gives:

filename = txt_16.c
typename = txt
type     = 16

as expected.  However, if one replaces the active sscanf with the one 
commented out, one gets

filename = txt_16.c
typename =
type     = 16

with uclibc but still gets 'typename = txt' with glibc.  It looks like 
[0-9a-z] is failing.

Before I jump in and try to fix this, I wanted to tap into the 
community's knowledge if this is known or what's up with sscanf.

-- 
Anthony G. Basile, Ph. D.
Chair of Information Technology
D'Youville College
Buffalo, NY 14201
(716) 829-8197


More information about the uClibc mailing list