improve readability of stdlib: fix indentation and remove trailing spaces

Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com>

Change-Id: I7dd90a0816b5376ffc1de4499d56935e0bd574a1
This commit is contained in:
André Goddard Rosa 2010-02-05 18:32:52 -02:00 committed by Jean-Baptiste Queru
parent 1698d9ebfc
commit e734769276
11 changed files with 230 additions and 232 deletions

View File

@ -49,6 +49,6 @@ __assert2(const char *file, int line, const char *func, const char *failedexpr)
(void)fprintf(stderr, (void)fprintf(stderr,
"assertion \"%s\" failed: file \"%s\", line %d, function \"%s\"\n", "assertion \"%s\" failed: file \"%s\", line %d, function \"%s\"\n",
failedexpr, file, line, func); failedexpr, file, line, func);
abort(); abort();
/* NOTREACHED */ /* NOTREACHED */
} }

View File

@ -53,7 +53,7 @@ const char _C_ctype_[1 + CTYPE_NUM_CHARS] = {
_P, _L|_X, _L|_X, _L|_X, _L|_X, _L|_X, _L|_X, _L, _P, _L|_X, _L|_X, _L|_X, _L|_X, _L|_X, _L|_X, _L,
_L, _L, _L, _L, _L, _L, _L, _L, _L, _L, _L, _L, _L, _L, _L, _L,
_L, _L, _L, _L, _L, _L, _L, _L, _L, _L, _L, _L, _L, _L, _L, _L,
/* determine printability based on the IS0 8859 8-bit standard */ /* determine printability based on the IS0 8859 8-bit standard */
_L, _L, _L, _P, _P, _P, _P, _C, _L, _L, _L, _P, _P, _P, _P, _C,
_C, _C, _C, _C, _C, _C, _C, _C, /* 80 */ _C, _C, _C, _C, _C, _C, _C, _C, /* 80 */

View File

@ -62,8 +62,8 @@ __findenv(const char *name, int *offset)
if (i == 0 && *cp++ == '=') { if (i == 0 && *cp++ == '=') {
*offset = p - environ; *offset = p - environ;
return (cp); return (cp);
} }
} }
return (NULL); return (NULL);
} }

View File

@ -42,7 +42,7 @@ putenv(const char *str)
if ((equal = strchr(p, '=')) == NULL) { if ((equal = strchr(p, '=')) == NULL) {
(void)free(p); (void)free(p);
return (-1); return (-1);
} }
*equal = '\0'; *equal = '\0';
rval = setenv(p, equal + 1, 1); rval = setenv(p, equal + 1, 1);
(void)free(p); (void)free(p);

View File

@ -39,11 +39,11 @@ static __inline void swapfunc(char *, char *, int, int);
/* /*
* Qsort routine from Bentley & McIlroy's "Engineering a Sort Function". * Qsort routine from Bentley & McIlroy's "Engineering a Sort Function".
*/ */
#define swapcode(TYPE, parmi, parmj, n) { \ #define swapcode(TYPE, parmi, parmj, n) { \
long i = (n) / sizeof (TYPE); \ long i = (n) / sizeof (TYPE); \
TYPE *pi = (TYPE *) (parmi); \ TYPE *pi = (TYPE *) (parmi); \
TYPE *pj = (TYPE *) (parmj); \ TYPE *pj = (TYPE *) (parmj); \
do { \ do { \
TYPE t = *pi; \ TYPE t = *pi; \
*pi++ = *pj; \ *pi++ = *pj; \
*pj++ = t; \ *pj++ = t; \
@ -56,7 +56,7 @@ static __inline void swapfunc(char *, char *, int, int);
static __inline void static __inline void
swapfunc(char *a, char *b, int n, int swaptype) swapfunc(char *a, char *b, int n, int swaptype)
{ {
if (swaptype <= 1) if (swaptype <= 1)
swapcode(long, a, b, n) swapcode(long, a, b, n)
else else
swapcode(char, a, b, n) swapcode(char, a, b, n)
@ -70,7 +70,7 @@ swapfunc(char *a, char *b, int n, int swaptype)
} else \ } else \
swapfunc(a, b, es, swaptype) swapfunc(a, b, es, swaptype)
#define vecswap(a, b, n) if ((n) > 0) swapfunc(a, b, n, swaptype) #define vecswap(a, b, n) if ((n) > 0) swapfunc(a, b, n, swaptype)
static __inline char * static __inline char *
med3(char *a, char *b, char *c, int (*cmp)(const void *, const void *)) med3(char *a, char *b, char *c, int (*cmp)(const void *, const void *))
@ -110,7 +110,7 @@ loop: SWAPINIT(a, es);
} }
swap(a, pm); swap(a, pm);
pa = pb = (char *)a + es; pa = pb = (char *)a + es;
pc = pd = (char *)a + (n - 1) * es; pc = pd = (char *)a + (n - 1) * es;
for (;;) { for (;;) {
while (pb <= pc && (r = cmp(pb, a)) <= 0) { while (pb <= pc && (r = cmp(pb, a)) <= 0) {
@ -118,7 +118,7 @@ loop: SWAPINIT(a, es);
swap_cnt = 1; swap_cnt = 1;
swap(pa, pb); swap(pa, pb);
pa += es; pa += es;
} }
pb += es; pb += es;
} }
while (pb <= pc && (r = cmp(pc, a)) >= 0) { while (pb <= pc && (r = cmp(pc, a)) >= 0) {
@ -138,11 +138,11 @@ loop: SWAPINIT(a, es);
} }
if (swap_cnt == 0) { /* Switch to insertion sort */ if (swap_cnt == 0) { /* Switch to insertion sort */
for (pm = (char *) a + es; pm < (char *) a + n * es; pm += es) for (pm = (char *) a + es; pm < (char *) a + n * es; pm += es)
for (pl = pm; pl > (char *) a && cmp(pl - es, pl) > 0; for (pl = pm; pl > (char *) a && cmp(pl - es, pl) > 0;
pl -= es) pl -= es)
swap(pl, pl - es); swap(pl, pl - es);
return; return;
} }
pn = (char *)a + n * es; pn = (char *)a + n * es;
r = min(pa - (char *)a, pb - pa); r = min(pa - (char *)a, pb - pa);
@ -151,11 +151,11 @@ loop: SWAPINIT(a, es);
vecswap(pb, pn - r, r); vecswap(pb, pn - r, r);
if ((r = pb - pa) > (int)es) if ((r = pb - pa) > (int)es)
qsort(a, r / es, es, cmp); qsort(a, r / es, es, cmp);
if ((r = pd - pc) > (int)es) { if ((r = pd - pc) > (int)es) {
/* Iterate rather than recurse to save stack space */ /* Iterate rather than recurse to save stack space */
a = pn - r; a = pn - r;
n = r / es; n = r / es;
goto loop; goto loop;
} }
/* qsort(pn - r, r / es, es, cmp);*/ /* qsort(pn - r, r / es, es, cmp); */
} }

View File

@ -22,7 +22,7 @@ unsigned short *
seed48(unsigned short xseed[3]) seed48(unsigned short xseed[3])
{ {
static unsigned short sseed[3]; static unsigned short sseed[3];
sseed[0] = __rand48_seed[0]; sseed[0] = __rand48_seed[0];
sseed[1] = __rand48_seed[1]; sseed[1] = __rand48_seed[1];
sseed[2] = __rand48_seed[2]; sseed[2] = __rand48_seed[2];

View File

@ -4,7 +4,7 @@ By Steve Reid <sreid@sea-to-sky.net>
100% Public Domain 100% Public Domain
----------------- -----------------
Modified 7/98 Modified 7/98
By James H. Brown <jbrown@burgoyne.com> By James H. Brown <jbrown@burgoyne.com>
Still 100% Public Domain Still 100% Public Domain
@ -26,7 +26,7 @@ Since the file IO in main() reads 16K at a time, any file 8K or larger would
be guaranteed to generate the wrong hash (e.g. Test Vector #3, a million be guaranteed to generate the wrong hash (e.g. Test Vector #3, a million
"a"s). "a"s).
I also changed the declaration of variables i & j in SHA1Update to I also changed the declaration of variables i & j in SHA1Update to
unsigned long from unsigned int for the same reason. unsigned long from unsigned int for the same reason.
These changes should make no difference to any 32 bit implementations since These changes should make no difference to any 32 bit implementations since
@ -53,7 +53,7 @@ Still 100% public domain
Modified 4/01 Modified 4/01
By Saul Kravitz <Saul.Kravitz@celera.com> By Saul Kravitz <Saul.Kravitz@celera.com>
Still 100% PD Still 100% PD
Modified to run on Compaq Alpha hardware. Modified to run on Compaq Alpha hardware.
----------------- -----------------
Modified 2/03 Modified 2/03
@ -116,7 +116,7 @@ void SHA1Final(unsigned char digest[20], SHA1_CTX* context);
void SHAPrintContext(SHA1_CTX *context, char *msg){ void SHAPrintContext(SHA1_CTX *context, char *msg){
printf("%s (%d,%d) %x %x %x %x %x\n", printf("%s (%d,%d) %x %x %x %x %x\n",
msg, msg,
context->count[0], context->count[1], context->count[0], context->count[1],
context->state[0], context->state[0],
context->state[1], context->state[1],
context->state[2], context->state[2],
@ -238,8 +238,7 @@ unsigned char finalcount[8];
while ((context->count[0] & 504) != 448) { while ((context->count[0] & 504) != 448) {
SHA1Update(context, (unsigned char *)"\0", 1); SHA1Update(context, (unsigned char *)"\0", 1);
} }
SHA1Update(context, finalcount, 8); /* Should cause a SHA1Transform() SHA1Update(context, finalcount, 8); /* Should cause a SHA1Transform() */
*/
for (i = 0; i < 20; i++) { for (i = 0; i < 20; i++) {
digest[i] = (unsigned char) digest[i] = (unsigned char)
((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255); ((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255);
@ -254,7 +253,7 @@ unsigned char finalcount[8];
SHA1Transform(context->state, context->buffer); SHA1Transform(context->state, context->buffer);
#endif #endif
} }
/*************************************************************/ /*************************************************************/
/* This is not quite the MIME base64 algorithm: it uses _ instead of /, /* This is not quite the MIME base64 algorithm: it uses _ instead of /,
@ -302,7 +301,7 @@ int main(int argc, char** argv)
fputs("Unable to open file.", stderr); fputs("Unable to open file.", stderr);
return(-1); return(-1);
} }
} }
SHA1Init(&context); SHA1Init(&context);
while (!feof(file)) { /* note: what if ferror(file) */ while (!feof(file)) { /* note: what if ferror(file) */
i = fread(buffer, 1, 16384, file); i = fread(buffer, 1, 16384, file);

File diff suppressed because it is too large Load Diff

View File

@ -103,7 +103,7 @@ strtoimax(const char *nptr, char **endptr, int base)
cutoff = INTMAX_MAX / x; \ cutoff = INTMAX_MAX / x; \
}; \ }; \
break break
switch (base) { switch (base) {
case 4: case 4:
if (neg) { if (neg) {
@ -118,13 +118,13 @@ strtoimax(const char *nptr, char **endptr, int base)
CASE_BASE(8); CASE_BASE(8);
CASE_BASE(10); CASE_BASE(10);
CASE_BASE(16); CASE_BASE(16);
default: default:
cutoff = neg ? INTMAX_MIN : INTMAX_MAX; cutoff = neg ? INTMAX_MIN : INTMAX_MAX;
cutlim = cutoff % base; cutlim = cutoff % base;
cutoff /= base; cutoff /= base;
} }
#undef CASE_BASE #undef CASE_BASE
if (neg) { if (neg) {
if (cutlim > 0) { if (cutlim > 0) {
cutlim -= base; cutlim -= base;

View File

@ -57,7 +57,7 @@ strtoumax(const char *nptr, char **endptr, int base)
if (c == '-') { if (c == '-') {
neg = 1; neg = 1;
c = *s++; c = *s++;
} else { } else {
neg = 0; neg = 0;
if (c == '+') if (c == '+')
c = *s++; c = *s++;
@ -76,7 +76,7 @@ strtoumax(const char *nptr, char **endptr, int base)
case x: cutoff = UINTMAX_MAX / x; \ case x: cutoff = UINTMAX_MAX / x; \
cutlim = UINTMAX_MAX % x; \ cutlim = UINTMAX_MAX % x; \
break break
switch (base) { switch (base) {
CASE_BASE(8); CASE_BASE(8);
CASE_BASE(10); CASE_BASE(10);
@ -85,7 +85,7 @@ strtoumax(const char *nptr, char **endptr, int base)
cutoff = UINTMAX_MAX / base; cutoff = UINTMAX_MAX / base;
cutlim = UINTMAX_MAX % base; cutlim = UINTMAX_MAX % base;
} }
for (acc = 0, any = 0;; c = (unsigned char) *s++) { for (acc = 0, any = 0;; c = (unsigned char) *s++) {
if (isdigit(c)) if (isdigit(c))
c -= '0'; c -= '0';

View File

@ -387,7 +387,7 @@ size_t wcsxfrm(wchar_t *ws1, const wchar_t *ws2, size_t n)
int wctob(wint_t c) int wctob(wint_t c)
{ {
return c; return c;
} }
wctype_t wctype(const char *property) wctype_t wctype(const char *property)