mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 10:40:03 +01:00
xen: Remove unused vsscanf/sscanf functions
Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov> Committed-by: Keir Fraser <keir@xen.org>
This commit is contained in:
1 parent
9ea4c2df15
commit
1f46c58d45
2 files changed
-240
No files matched your search
@@ -511,223 +511,6 @@ int vscnprintf(char *buf, size_t size, const char *fmt, va_list args)
|
||||
|
||||
EXPORT_SYMBOL(vscnprintf);
|
||||
|
||||
/**
|
||||
* vsscanf - Unformat a buffer into a list of arguments
|
||||
* @buf: input buffer
|
||||
* @fmt: format of buffer
|
||||
* @args: arguments
|
||||
*/
|
||||
int vsscanf(const char * buf, const char * fmt, va_list args)
|
||||
{
|
||||
const char *str = buf;
|
||||
const char *next;
|
||||
char digit;
|
||||
int num = 0;
|
||||
int qualifier;
|
||||
int base;
|
||||
int field_width;
|
||||
int is_sign = 0;
|
||||
|
||||
while (*fmt && *str) {
|
||||
/* skip any white space in format */
|
||||
/* white space in format matchs any amount of
|
||||
* white space, including none, in the input.
|
||||
*/
|
||||
if (isspace(*fmt)) {
|
||||
while (isspace(*fmt))
|
||||
++fmt;
|
||||
while (isspace(*str))
|
||||
++str;
|
||||
}
|
||||
|
||||
/* anything that is not a conversion must match exactly */
|
||||
if (*fmt != '%' && *fmt) {
|
||||
if (*fmt++ != *str++)
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!*fmt)
|
||||
break;
|
||||
++fmt;
|
||||
|
||||
/* skip this conversion.
|
||||
* advance both strings to next white space
|
||||
*/
|
||||
if (*fmt == '*') {
|
||||
while (!isspace(*fmt) && *fmt)
|
||||
fmt++;
|
||||
while (!isspace(*str) && *str)
|
||||
str++;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* get field width */
|
||||
field_width = -1;
|
||||
if (isdigit(*fmt))
|
||||
field_width = skip_atoi(&fmt);
|
||||
|
||||
/* get conversion qualifier */
|
||||
qualifier = -1;
|
||||
if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L' || *fmt == 'Z'
|
||||
|| *fmt == 'z') {
|
||||
qualifier = *fmt++;
|
||||
if (unlikely(qualifier == *fmt)) {
|
||||
if (qualifier == 'h') {
|
||||
qualifier = 'H';
|
||||
fmt++;
|
||||
} else if (qualifier == 'l') {
|
||||
qualifier = 'L';
|
||||
fmt++;
|
||||
}
|
||||
}
|
||||
}
|
||||
base = 10;
|
||||
is_sign = 0;
|
||||
|
||||
if (!*fmt || !*str)
|
||||
break;
|
||||
|
||||
switch(*fmt++) {
|
||||
case 'c': {
|
||||
char *s = (char *) va_arg(args,char*);
|
||||
if (field_width == -1)
|
||||
field_width = 1;
|
||||
do {
|
||||
*s++ = *str++;
|
||||
} while (--field_width > 0 && *str);
|
||||
num++;
|
||||
}
|
||||
continue;
|
||||
case 's': {
|
||||
char *s = (char *) va_arg(args, char *);
|
||||
if(field_width == -1)
|
||||
field_width = INT_MAX;
|
||||
/* first, skip leading white space in buffer */
|
||||
while (isspace(*str))
|
||||
str++;
|
||||
|
||||
/* now copy until next white space */
|
||||
while (*str && !isspace(*str) && field_width--)
|
||||
*s++ = *str++;
|
||||
*s = '\0';
|
||||
num++;
|
||||
}
|
||||
continue;
|
||||
case 'n': {
|
||||
/* return number of characters read so far */
|
||||
int *i = (int *)va_arg(args,int*);
|
||||
*i = str - buf;
|
||||
}
|
||||
continue;
|
||||
case 'o':
|
||||
base = 8;
|
||||
break;
|
||||
case 'x':
|
||||
case 'X':
|
||||
base = 16;
|
||||
break;
|
||||
case 'i':
|
||||
base = 0;
|
||||
case 'd':
|
||||
is_sign = 1;
|
||||
case 'u':
|
||||
break;
|
||||
case '%':
|
||||
/* looking for '%' in str */
|
||||
if (*str++ != '%')
|
||||
return num;
|
||||
continue;
|
||||
default:
|
||||
/* invalid format; stop here */
|
||||
return num;
|
||||
}
|
||||
|
||||
/* have some sort of integer conversion.
|
||||
* first, skip white space in buffer.
|
||||
*/
|
||||
while (isspace(*str))
|
||||
str++;
|
||||
|
||||
digit = *str;
|
||||
if (is_sign && digit == '-')
|
||||
digit = *(str + 1);
|
||||
|
||||
if (!digit || (base == 16 && !isxdigit(digit))
|
||||
|| (base == 10 && !isdigit(digit))
|
||||
|| (base == 8 && (!isdigit(digit) || digit > '7'))
|
||||
|| (base == 0 && !isdigit(digit)))
|
||||
break;
|
||||
|
||||
switch(qualifier) {
|
||||
case 'H': /* that's 'hh' in format */
|
||||
if (is_sign) {
|
||||
signed char *s = (signed char *) va_arg(args,signed char *);
|
||||
*s = (signed char) simple_strtol(str,&next,base);
|
||||
} else {
|
||||
unsigned char *s = (unsigned char *)
|
||||
va_arg(args, unsigned char *);
|
||||
*s = (unsigned char) simple_strtoul(str, &next, base);
|
||||
}
|
||||
break;
|
||||
case 'h':
|
||||
if (is_sign) {
|
||||
short *s = (short *) va_arg(args,short *);
|
||||
*s = (short) simple_strtol(str,&next,base);
|
||||
} else {
|
||||
unsigned short *s = (unsigned short *)
|
||||
va_arg(args, unsigned short *);
|
||||
*s = (unsigned short) simple_strtoul(str, &next, base);
|
||||
}
|
||||
break;
|
||||
case 'l':
|
||||
if (is_sign) {
|
||||
long *l = (long *) va_arg(args,long *);
|
||||
*l = simple_strtol(str,&next,base);
|
||||
} else {
|
||||
unsigned long *l = (unsigned long*)
|
||||
va_arg(args,unsigned long*);
|
||||
*l = simple_strtoul(str,&next,base);
|
||||
}
|
||||
break;
|
||||
case 'L':
|
||||
if (is_sign) {
|
||||
long long *l = (long long*) va_arg(args,long long *);
|
||||
*l = simple_strtoll(str,&next,base);
|
||||
} else {
|
||||
unsigned long long *l = (unsigned long long*)
|
||||
va_arg(args,unsigned long long*);
|
||||
*l = simple_strtoull(str,&next,base);
|
||||
}
|
||||
break;
|
||||
case 'Z':
|
||||
case 'z': {
|
||||
size_t *s = (size_t*) va_arg(args,size_t*);
|
||||
*s = (size_t) simple_strtoul(str,&next,base);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (is_sign) {
|
||||
int *i = (int *) va_arg(args, int*);
|
||||
*i = (int) simple_strtol(str,&next,base);
|
||||
} else {
|
||||
unsigned int *i = (unsigned int*)
|
||||
va_arg(args, unsigned int*);
|
||||
*i = (unsigned int) simple_strtoul(str,&next,base);
|
||||
}
|
||||
break;
|
||||
}
|
||||
num++;
|
||||
|
||||
if (!next)
|
||||
break;
|
||||
str = next;
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
EXPORT_SYMBOL(vsscanf);
|
||||
|
||||
/**
|
||||
* snprintf - Format a string and place it in a buffer
|
||||
* @buf: The buffer to place the result into
|
||||
@@ -779,25 +562,6 @@ int scnprintf(char * buf, size_t size, const char *fmt, ...)
|
||||
}
|
||||
EXPORT_SYMBOL(scnprintf);
|
||||
|
||||
/**
|
||||
* sscanf - Unformat a buffer into a list of arguments
|
||||
* @buf: input buffer
|
||||
* @fmt: formatting of buffer
|
||||
* @...: resulting arguments
|
||||
*/
|
||||
int sscanf(const char * buf, const char * fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
int i;
|
||||
|
||||
va_start(args,fmt);
|
||||
i = vsscanf(buf,fmt,args);
|
||||
va_end(args);
|
||||
return i;
|
||||
}
|
||||
|
||||
EXPORT_SYMBOL(sscanf);
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* mode: C
|
||||
|
||||
@@ -89,10 +89,6 @@ extern int scnprintf(char * buf, size_t size, const char * fmt, ...)
|
||||
__attribute__ ((format (printf, 3, 4)));
|
||||
extern int vscnprintf(char *buf, size_t size, const char *fmt, va_list args)
|
||||
__attribute__ ((format (printf, 3, 0)));
|
||||
extern int sscanf(const char * buf, const char * fmt, ...)
|
||||
__attribute__ ((format (scanf, 2, 3)));
|
||||
extern int vsscanf(const char * buf, const char * fmt, va_list args)
|
||||
__attribute__ ((format (scanf, 2, 0)));
|
||||
|
||||
long simple_strtol(
|
||||
const char *cp,const char **endp, unsigned int base);
|
||||
|
||||