improve readability of stdio: fix indentation and remove trailing spaces

Change-Id: Ic51e58a7c75d20bf770dc0ebd7f97a338fbe0036
Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com>
This commit is contained in:
André Goddard Rosa 2010-01-30 22:46:25 -02:00 committed by Jean-Baptiste Queru
parent 1297428e89
commit a910abcd19
15 changed files with 56 additions and 57 deletions

View file

@ -63,12 +63,12 @@ fgets(char *buf, int n, FILE *fp)
/* EOF/error: stop with partial or no line */
if (s == buf)
return (NULL);
break;
}
break;
}
}
len = fp->_r;
p = fp->_p;
/*
* Scan through at most n bytes of the current buffer,
* looking for '\n'. If found, copy up to and including

View file

@ -50,7 +50,7 @@ int __sdidinit;
/* p r w flags file _bf z cookie close read seek write
ext */
/* the usual - (stdin + stdout + stderr) */
/* the usual - (stdin + stdout + stderr) */
static FILE usual[FOPEN_MAX - 3];
static struct __sfileext usualext[FOPEN_MAX - 3];
static struct glue uglue = { 0, FOPEN_MAX - 3, usual };

View file

@ -53,7 +53,7 @@ fopen(const char *file, const char *mode)
if ((f = open(file, oflags, DEFFILEMODE)) < 0) {
fp->_flags = 0; /* release */
return (NULL);
}
}
fp->_file = f;
fp->_flags = flags;
fp->_cookie = fp;

View file

@ -38,10 +38,10 @@ int
fprintf(FILE *fp, const char *fmt, ...)
{
int ret;
va_list ap;
va_list ap;
va_start(ap, fmt);
ret = vfprintf(fp, fmt, ap);
va_end(ap);
va_end(ap);
return (ret);
}

View file

@ -48,29 +48,29 @@ lflush(FILE *fp)
size_t
fread(void *buf, size_t size, size_t count, FILE *fp)
{
size_t resid;
char *p;
int r;
size_t total;
size_t resid;
char *p;
int r;
size_t total;
/*
* The ANSI standard requires a return value of 0 for a count
* or a size of 0. Peculiarily, it imposes no such requirements
* on fwrite; it only requires fread to be broken.
*/
if ((resid = count * size) == 0)
return (0);
if (fp->_r < 0)
fp->_r = 0;
total = resid;
p = buf;
/*
* The ANSI standard requires a return value of 0 for a count
* or a size of 0. Peculiarily, it imposes no such requirements
* on fwrite; it only requires fread to be broken.
*/
if ((resid = count * size) == 0)
return (0);
if (fp->_r < 0)
fp->_r = 0;
total = resid;
p = buf;
#if 1 /* BIONIC: optimize unbuffered reads */
if (fp->_flags & __SNBF && fp->_ur == 0)
{
/* the following comes mainly from __srefill(), with slight
* modifications
*/
/* the following comes mainly from __srefill(), with slight
* modifications
*/
/* make sure stdio is set up */
if (!__sdidinit)
@ -99,22 +99,22 @@ fread(void *buf, size_t size, size_t count, FILE *fp)
}
fp->_flags |= __SRD;
} else {
/*
* We were reading. If there is an ungetc buffer,
* we must have been reading from that. Drop it,
* restoring the previous buffer (if any). If there
* is anything in that buffer, return.
*/
/*
* We were reading. If there is an ungetc buffer,
* we must have been reading from that. Drop it,
* restoring the previous buffer (if any). If there
* is anything in that buffer, return.
*/
if (HASUB(fp)) {
FREEUB(fp);
}
}
/*
* Before reading from a line buffered or unbuffered file,
* flush all line buffered output files, per the ANSI C
* standard.
*/
/*
* Before reading from a line buffered or unbuffered file,
* flush all line buffered output files, per the ANSI C
* standard.
*/
if (fp->_flags & (__SLBF|__SNBF))
(void) _fwalk(lflush);
@ -151,8 +151,8 @@ fread(void *buf, size_t size, size_t count, FILE *fp)
}
}
(void)memcpy((void *)p, (void *)fp->_p, resid);
fp->_r -= resid;
fp->_p += resid;
return (count);
(void)memcpy((void *)p, (void *)fp->_p, resid);
fp->_r -= resid;
fp->_p += resid;
return (count);
}

View file

@ -40,8 +40,8 @@
#include <stdlib.h>
#include "local.h"
/*
* Re-direct an existing, open (probably) file to some other file.
/*
* Re-direct an existing, open (probably) file to some other file.
* ANSI is written such that the original file gets closed if at
* all possible, no matter what.
*/

View file

@ -204,7 +204,7 @@ fseeko(FILE *fp, off_t offset, int whence)
if ((*seekfn)(fp->_cookie, curoff, SEEK_SET) == POS_ERR)
goto dumb;
fp->_r = 0;
fp->_p = fp->_bf._base;
fp->_p = fp->_bf._base;
if (HASUB(fp))
FREEUB(fp);
fp->_flags &= ~__SEOF;

View file

@ -83,7 +83,7 @@ __sfvwrite(FILE *fp, struct __suio *uio)
do {
GETIOV(;);
#if 1 /* BIONIC: don't limit to 1KB writes */
w = (*fp->_write)(fp->_cookie, p, len);
w = (*fp->_write)(fp->_cookie, p, len);
#else
w = (*fp->_write)(fp->_cookie, p, MIN(len, BUFSIZ2));
#endif
@ -183,7 +183,7 @@ __sfvwrite(FILE *fp, struct __suio *uio)
} else if (s >= (w = fp->_bf._size)) {
w = (*fp->_write)(fp->_cookie, p, w);
if (w <= 0)
goto err;
goto err;
} else {
w = s;
COPY(w);

View file

@ -38,10 +38,10 @@ int
printf(const char *fmt, ...)
{
int ret;
va_list ap;
va_list ap;
va_start(ap, fmt);
ret = vfprintf(stdout, fmt, ap);
va_end(ap);
va_end(ap);
return (ret);
}

View file

@ -42,7 +42,7 @@ putchar_unlocked(int c)
{
FILE *so = stdout;
return (putc_unlocked(c,so));
return (putc_unlocked(c, so));
}
#undef putchar

View file

@ -40,7 +40,7 @@
int
snprintf(char *str, size_t n, const char *fmt, ...)
{
va_list ap;
va_list ap;
int ret;
char dummy;
FILE f;
@ -61,7 +61,7 @@ snprintf(char *str, size_t n, const char *fmt, ...)
f._bf._size = f._w = n - 1;
va_start(ap, fmt);
ret = vfprintf(&f, fmt, ap);
va_end(ap);
va_end(ap);
*f._p = '\0';
return (ret);
}

View file

@ -46,7 +46,7 @@ int
sprintf(char *str, const char *fmt, ...)
{
int ret;
va_list ap;
va_list ap;
FILE f;
struct __sfileext fext;
@ -57,7 +57,7 @@ sprintf(char *str, const char *fmt, ...)
f._bf._size = f._w = INT_MAX;
va_start(ap, fmt);
ret = vfprintf(&f, fmt, ap);
va_end(ap);
va_end(ap);
*f._p = '\0';
return (ret);
}

View file

@ -48,7 +48,7 @@ int
sscanf(const char *str, const char *fmt, ...)
{
int ret;
va_list ap;
va_list ap;
FILE f;
struct __sfileext fext;
@ -60,6 +60,6 @@ sscanf(const char *str, const char *fmt, ...)
f._lb._base = NULL;
va_start(ap, fmt);
ret = vfscanf(&f, fmt, ap);
va_end(ap);
va_end(ap);
return (ret);
}

View file

@ -45,7 +45,7 @@ __sread(void *cookie, char *buf, int n)
{
FILE *fp = cookie;
int ret;
ret = read(fp->_file, buf, n);
/* if the read succeeded, update the current offset */
if (ret >= 0)
@ -71,7 +71,7 @@ __sseek(void *cookie, fpos_t offset, int whence)
{
FILE *fp = cookie;
off_t ret;
ret = lseek(fp->_file, (off_t)offset, whence);
if (ret == (off_t)-1)
fp->_flags &= ~__SOFF;

View file

@ -39,7 +39,6 @@
static int
eofread(void *cookie, char *buf, int len)
{
return (0);
}