lkml.org 
[lkml]   [2002]   [Nov]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] Re: sscanf("-1", "%d", &i) fails, returns 0
On Sat, 9 Nov 2002, Douglas Gilbert wrote:

| In lk 2.5.46-bk3 the expression in the subject line
| fails to write into "i" and returns 0. Drop the minus
| sign and it works.

Here's an unobstrusive patch to correct that.
Please apply.

--
~Randy



--- ./lib/vsprintf.c%signed Mon Nov 4 14:30:49 2002
+++ ./lib/vsprintf.c Fri Nov 8 11:20:03 2002
@@ -517,6 +517,7 @@
{
const char *str = buf;
char *next;
+ char *dig;
int num = 0;
int qualifier;
int base;
@@ -638,12 +639,13 @@
while (isspace(*str))
str++;

- if (!*str
- || (base == 16 && !isxdigit(*str))
- || (base == 10 && !isdigit(*str))
- || (base == 8 && (!isdigit(*str) || *str > '7'))
- || (base == 0 && !isdigit(*str)))
- break;
+ dig = (*str == '-') ? (str + 1) : str;
+ if (!*dig
+ || (base == 16 && !isxdigit(*dig))
+ || (base == 10 && !isdigit(*dig))
+ || (base == 8 && (!isdigit(*dig) || *dig > '7'))
+ || (base == 0 && !isdigit(*dig)))
+ break;

switch(qualifier) {
case 'h':
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:30    [W:0.066 / U:0.076 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site