fgetl.c
资源名称:DOS系统的源代码.rar [点击查看]
上传用户:xiaoan1112
上传日期:2013-04-11
资源大小:19621k
文件大小:1k
源码类别:
操作系统开发
开发平台:
Visual C++
- /* fgetl.c - expand tabs and return lines w/o separators
- *
- * Modifications
- * 05-Aug-1988 mz Make exact length lines work correctly
- *
- */
- #include "..htools.h"
- /* returns line from file (no CRLFs); returns NULL if EOF */
- fgetl (buf, len, fh)
- char *buf;
- int len;
- FILE *fh;
- {
- register int c;
- register char *p;
- /* remember NUL at end */
- len--;
- p = buf;
- while (TRUE) {
- c = fgetc (fh);
- if (c == EOF || c == 'n')
- break;
- if (c != 'r')
- if (len == 0) {
- ungetc (c, fh);
- break;
- }
- else
- if (c != 't') {
- *p++ = (char) c;
- len--;
- }
- else {
- c = min (8 - ((p-buf) & 0x0007), len);
- Fill (p, ' ', c);
- p += c;
- len -= c;
- }
- }
- *p = 0;
- return ! ( (c == EOF) && (p == buf) );
- }