git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1362
91ce42f0-d328-0410-95d8-
f526ca767f89
*p = 0;
for (int i=0; i < size-1; i++) {
do {
- errno = 0;
- ch = fgetc(fd);
+ errno = 0;
+ ch = fgetc(fd);
} while (ch == -1 && (errno == EINTR || errno == EAGAIN));
if (ch == -1) {
- if (i == 0) {
- return NULL;
- } else {
- return s;
- }
+ if (i == 0) {
+ return NULL;
+ } else {
+ return s;
+ }
}
*p++ = ch;
*p = 0;
+ if (ch == '\r') { /* Support for Mac/Windows file format */
+ ch = fgetc(fd);
+ if (ch == '\n') { /* Windows (\r\n) */
+ *p++ = ch;
+ *p = 0;
+ }
+ else { /* Mac (\r only) */
+ ungetc(ch, fd); /* Push next character back to fd */
+ }
+ break;
+ }
if (ch == '\n') {
- break;
+ break;
}
}
return s;
Emsg0(M_ABORT, 0, "get_char: called after EOF\n");
}
if (lf->ch == L_EOL) {
- if (fgets(lf->line, MAXSTRING, lf->fd) == NULL) {
+ if (bfgets(lf->line, MAXSTRING, lf->fd) == NULL) {
lf->ch = L_EOF;
if (lf->next) {
lex_close_file(lf);