if (fs_eof(fh))
return NULL;
- while (count > 1 && (c = fs_getc(fh)) >= 0)
- {
- count--;
+ while (count > 1)
+ if ((c = fs_getc(fh)) >= 0)
+ {
+ count--;
- *s = c;
+ *s = c;
- /* Keep a newline and break. */
+ /* Keep a newline and break. */
- if (*s == '\n')
- {
- s++;
- break;
- }
+ if (*s == '\n')
+ {
+ s++;
+ break;
+ }
- /* Ignore carriage returns. */
+ /* Ignore carriage returns. */
- if (*s == '\r')
- {
- count++;
- s--;
- }
+ if (*s == '\r')
+ {
+ count++;
+ s--;
+ }
- s++;
- }
+ s++;
+ }
+ else if (s == dst)
+ return NULL;
+ else
+ break;
*s = '\0';