Finish backing out the last PR that corrupted the file coding standard

This commit is contained in:
Gregory Nutt 2016-10-15 10:42:15 -06:00
parent 887895bf16
commit 4034a23704

View File

@ -103,8 +103,8 @@ static int findwidth(FAR const char *buf, FAR const char *fmt)
return strcspn(buf, spaces);
}
/* No.. Another possibility is the format character is followed by some
* recognizable delimiting value.
/* No.. Another possibility is the format character is followed by
* some recognizable delimiting value.
*/
if (*next != '%')
@ -120,14 +120,15 @@ static int findwidth(FAR const char *buf, FAR const char *fmt)
}
}
/* No... the format has no delimiter and is back-to-back with the next format
* (or is followed by a delimiter that does not exist in the input string).
* At this point we just bail and Use the input up until the first white
* space is encountered. NOTE: This means that values from the following
* format may be concatenated with the first. This is a bug. We have no
* generic way of determining the width of the data if there is no
* fieldwidth, no space separating the input, and no usable delimiter
* character.
/* No... the format has no delimiter and is back-to-back with the next
* format (or is followed by a delimiter that does not exist in the
* input string). At this point we just bail and Use the input up until
* the first white space is encountered.
*
* NOTE: This means that values from the following format may be
* concatenated with the first. This is a bug. We have no generic way of
* determining the width of the data if there is no fieldwidth, no space
* separating the input, and no usable delimiter character.
*/
return strcspn(buf, spaces);
@ -173,7 +174,6 @@ int vsscanf(FAR const char *buf, FAR const char *fmt, va_list ap)
bool noassign;
int count;
int width;
int fwidth;
int base = 10;
char tmp[MAXLN];
@ -192,9 +192,9 @@ int vsscanf(FAR const char *buf, FAR const char *fmt, va_list ap)
noassign = false;
lflag = false;
/* Loop until all characters in the fmt string have been processed. We may
* have to continue loop after reaching the end the input data in order to
* handle trailing %n format specifiers.
/* Loop until all characters in the fmt string have been processed. We
* may have to continue loop after reaching the end the input data in
* order to handle trailing %n format specifiers.
*/
while (*fmt)
@ -250,9 +250,9 @@ int vsscanf(FAR const char *buf, FAR const char *fmt, va_list ap)
{
linfo("vsscanf: Performing string conversion\n");
/* Get a pointer to the char * value. We need to do this even if
* we have reached the end of the input data in order to update
* the 'ap' variable.
/* Get a pointer to the char * value. We need to do this even
* if we have reached the end of the input data in order to
* update the 'ap' variable.
*/
tv = NULL; /* To avoid warnings about begin uninitialized */
@ -262,8 +262,8 @@ int vsscanf(FAR const char *buf, FAR const char *fmt, va_list ap)
tv[0] = '\0';
}
/* But we only perform the data conversion is we still have bytes
* remaining in the input data stream.
/* But we only perform the data conversion is we still have
* bytes remaining in the input data stream.
*/
if (*buf)
@ -275,21 +275,15 @@ int vsscanf(FAR const char *buf, FAR const char *fmt, va_list ap)
buf++;
}
/* Guess a field width using some heuristics */
/* Was a fieldwidth specified? */
fwidth = findwidth(buf, fmt);
/* Use the actual field's width if 1) no fieldwidth specified
* or 2) the actual field's width is smaller than fieldwidth
* specified
*/
if (!width || fwidth < width)
if (!width)
{
width = fwidth;
}
/* No... Guess a field width using some heuristics */
width = MIN(sizeof(tmp) - 1, width);
int tmpwidth = findwidth(buf, fmt);
width = MIN(sizeof(tmp) - 1, tmpwidth);
}
/* Copy the string (if we are making an assignment) */
@ -312,9 +306,9 @@ int vsscanf(FAR const char *buf, FAR const char *fmt, va_list ap)
{
linfo("vsscanf: Performing character conversion\n");
/* Get a pointer to the char * value. We need to do this even if
* we have reached the end of the input data in order to update
* the 'ap' variable.
/* Get a pointer to the char * value. We need to do this even
* if we have reached the end of the input data in order to
* update the 'ap' variable.
*/
tv = NULL; /* To avoid warnings about beign uninitialized */
@ -324,8 +318,8 @@ int vsscanf(FAR const char *buf, FAR const char *fmt, va_list ap)
tv[0] = '\0';
}
/* But we only perform the data conversion is we still have bytes
* remaining in the input data stream.
/* But we only perform the data conversion is we still have
* bytes remaining in the input data stream.
*/
if (*buf)
@ -349,7 +343,7 @@ int vsscanf(FAR const char *buf, FAR const char *fmt, va_list ap)
}
/* Update the buffer pointer past the character(s) in the
* input.
* input
*/
buf += width;
@ -389,8 +383,8 @@ int vsscanf(FAR const char *buf, FAR const char *fmt, va_list ap)
}
}
/* But we only perform the data conversion if we still have bytes
* remaining in the input data stream.
/* But we only perform the data conversion if we still have
* bytes remaining in the input data stream.
*/
if (*buf)
@ -406,8 +400,8 @@ int vsscanf(FAR const char *buf, FAR const char *fmt, va_list ap)
buf++;
}
/* The base of the integer conversion depends on the specific
* conversion specification.
/* The base of the integer conversion depends on the
* specific conversion specification.
*/
sign = false;
@ -444,7 +438,9 @@ int vsscanf(FAR const char *buf, FAR const char *fmt, va_list ap)
width = MIN(sizeof(tmp) - 1, tmpwidth);
}
/* Copy the numeric string into a temporary working buffer. */
/* Copy the numeric string into a temporary working
* buffer.
*/
strncpy(tmp, buf, width);
tmp[width] = '\0';
@ -479,8 +475,8 @@ int vsscanf(FAR const char *buf, FAR const char *fmt, va_list ap)
if (!noassign)
{
/* We have to check whether we need to return a long or
* an int.
/* We have to check whether we need to return a long
* or an int.
*/
if (lflag)
@ -491,7 +487,8 @@ int vsscanf(FAR const char *buf, FAR const char *fmt, va_list ap)
}
else
{
linfo("vsscanf: Return %ld to 0x%p\n", tmplong, pint);
linfo("vsscanf: Return %ld to 0x%p\n",
tmplong, pint);
*pint = (int)tmplong;
}
@ -501,7 +498,7 @@ int vsscanf(FAR const char *buf, FAR const char *fmt, va_list ap)
}
/* Process %a, %A, %f, %F, %e, %E, %g, and %G: Floating point
* conversions.
* conversions
*/
else if (strchr("aAfFeEgG", *fmt) != NULL)
@ -513,9 +510,9 @@ int vsscanf(FAR const char *buf, FAR const char *fmt, va_list ap)
linfo("vsscanf: Performing floating point conversion\n");
/* Get a pointer to the double value. We need to do this even if
* we have reached the end of the input data in order to update
* the 'ap' variable.
/* Get a pointer to the double value. We need to do this even
* if we have reached the end of the input data in order to
* update the 'ap' variable.
*/
if (!noassign)
@ -539,8 +536,8 @@ int vsscanf(FAR const char *buf, FAR const char *fmt, va_list ap)
}
#ifdef CONFIG_LIBC_FLOATINGPOINT
/* But we only perform the data conversion is we still have bytes
* remaining in the input data stream.
/* But we only perform the data conversion is we still have
* bytes remaining in the input data stream.
*/
if (*buf)
@ -594,8 +591,8 @@ int vsscanf(FAR const char *buf, FAR const char *fmt, va_list ap)
set_errno(errsave);
/* We have to check whether we need to return a float or
* a double.
/* We have to check whether we need to return a float
* or a double.
*/
#ifdef CONFIG_HAVE_DOUBLE
@ -625,7 +622,7 @@ int vsscanf(FAR const char *buf, FAR const char *fmt, va_list ap)
if (!noassign)
{
size_t nchars = (size_t) (buf - bufstart);
size_t nchars = (size_t)(buf - bufstart);
/* Note %n does not count as a conversion */