Rearrangements for smaller size of generated code.
git-svn-id: svn://svn.cc65.org/cc65/trunk@5704 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -18,8 +18,9 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
char* __fastcall__ fgets (char* s, unsigned size, FILE* f)
|
char* __fastcall__ fgets (char* s, unsigned size, register FILE* f)
|
||||||
{
|
{
|
||||||
|
register char* p = s;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
@@ -34,28 +35,30 @@ char* __fastcall__ fgets (char* s, unsigned size, FILE* f)
|
|||||||
|
|
||||||
/* Get next character */
|
/* Get next character */
|
||||||
if ((c = fgetc (f)) == EOF) {
|
if ((c = fgetc (f)) == EOF) {
|
||||||
s[i] = '\0';
|
|
||||||
/* Error or EOF */
|
/* Error or EOF */
|
||||||
if ((f->f_flags & _FERROR) != 0 || i == 0) {
|
if ((f->f_flags & _FERROR) != 0 || i == 0) {
|
||||||
/* ERROR or EOF on first char */
|
/* ERROR or EOF on first char */
|
||||||
|
*p = '\0';
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
/* EOF with data already read */
|
/* EOF with data already read */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* One char more */
|
/* One char more */
|
||||||
s[i++] = c;
|
*p = c;
|
||||||
|
++p;
|
||||||
|
++i;
|
||||||
|
|
||||||
/* Stop at end of line */
|
/* Stop at end of line */
|
||||||
if (c == '\n') {
|
if ((char)c == '\n') {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Terminate the string */
|
/* Terminate the string */
|
||||||
s[i] = '\0';
|
*p = '\0';
|
||||||
|
|
||||||
/* Done */
|
/* Done */
|
||||||
return s;
|
return s;
|
||||||
|
|||||||
Reference in New Issue
Block a user