* lib/fputsx.c: Add brackets.
* lib/fputsx.c: Avoid assignments in comparisons. * lib/fputsx.c: Avoid implicit conversion of pointers / integers / chars to booleans.
This commit is contained in:
parent
f16c6bd7dd
commit
14839257ac
@ -1,3 +1,10 @@
|
|||||||
|
2008-05-26 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
|
* lib/fputsx.c: Add brackets.
|
||||||
|
* lib/fputsx.c: Avoid assignments in comparisons.
|
||||||
|
* lib/fputsx.c: Avoid implicit conversion of pointers / integers /
|
||||||
|
chars to booleans.
|
||||||
|
|
||||||
2008-05-26 Nicolas François <nicolas.francois@centraliens.net>
|
2008-05-26 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
* lib/commonio.h: commonio_entry.changed, commonio_db.changed,
|
* lib/commonio.h: commonio_entry.changed, commonio_db.changed,
|
||||||
|
24
lib/fputsx.c
24
lib/fputsx.c
@ -46,17 +46,23 @@ char *fgetsx (char *buf, int cnt, FILE * f)
|
|||||||
|
|
||||||
while (cnt > 0) {
|
while (cnt > 0) {
|
||||||
if (fgets (cp, cnt, f) == 0) {
|
if (fgets (cp, cnt, f) == 0) {
|
||||||
if (cp == buf)
|
if (cp == buf) {
|
||||||
return 0;
|
return 0;
|
||||||
else
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if ((ep = strrchr (cp, '\\')) && *(ep + 1) == '\n') {
|
}
|
||||||
if ((cnt -= ep - cp) > 0)
|
ep = strrchr (cp, '\\');
|
||||||
*(cp = ep) = '\0';
|
if ((NULL != ep) && (*(ep + 1) == '\n')) {
|
||||||
} else
|
cnt -= ep - cp;
|
||||||
|
if (cnt > 0) {
|
||||||
|
cp = ep;
|
||||||
|
*cp = '\0';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,9 +70,10 @@ int fputsx (const char *s, FILE * stream)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; *s; i++, s++) {
|
for (i = 0; '\0' != *s; i++, s++) {
|
||||||
if (putc (*s, stream) == EOF)
|
if (putc (*s, stream) == EOF) {
|
||||||
return EOF;
|
return EOF;
|
||||||
|
}
|
||||||
|
|
||||||
#if 0 /* The standard getgr*() can't handle that. --marekm */
|
#if 0 /* The standard getgr*() can't handle that. --marekm */
|
||||||
if (i > (BUFSIZ / 2)) {
|
if (i > (BUFSIZ / 2)) {
|
||||||
@ -80,3 +87,4 @@ int fputsx (const char *s, FILE * stream)
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user