diff options
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | debug.c | 7 | ||||
-rw-r--r-- | io.c | 15 |
3 files changed, 22 insertions, 8 deletions
@@ -1,3 +1,11 @@ +2013-06-11 Arnold D. Robbins <arnold@skeeve.com> + + * debug.c (print_lines): Move setting of binary mode to after all + the messing with the fd. Simplifies code some. + * io.c (srcopen): Rearrange so that can add call to setbinmode + here too. This fixes the debugger and makes reading source + files a little faster. Thanks again to Corinna Vinschen. + 2013-06-10 Arnold D. Robbins <arnold@skeeve.com> * debug.c (print_lines): Set binary mode so that calculation of the @@ -519,9 +519,6 @@ print_lines(char *src, int start_line, int nlines) return -1; } - /* set binary mode so that byte offset calculations will be right */ - os_setbinmode(s->fd, O_BINARY); - if (fstat(s->fd, &sbuf) == 0 && s->mtime < sbuf.st_mtime) { fprintf(out_fp, _("WARNING: source file `%s' modified since program compilation.\n"), src); @@ -537,9 +534,11 @@ print_lines(char *src, int start_line, int nlines) src, strerror(errno)); return -1; } - os_setbinmode(s->fd, O_BINARY); } + /* set binary mode so that byte offset calculations will be right */ + os_setbinmode(s->fd, O_BINARY); + if (s->line_offset == NULL && find_lines(s) != 0) return -1; if (start_line < 1 || start_line > s->srclines) { @@ -2731,11 +2731,18 @@ find_source(const char *src, struct stat *stb, int *errcode, int is_extlib) int srcopen(SRCFILE *s) { + int fd = INVALID_HANDLE; + if (s->stype == SRC_STDIN) - return fileno(stdin); - if (s->stype == SRC_FILE || s->stype == SRC_INC) - return devopen(s->fullpath, "r"); - return INVALID_HANDLE; + fd = fileno(stdin); + else if (s->stype == SRC_FILE || s->stype == SRC_INC) + fd = devopen(s->fullpath, "r"); + + /* set binary mode so that debugger byte offset calculations will be right */ + if (fd != INVALID_HANDLE) + os_setbinmode(fd, O_BINARY); + + return fd; } /* input parsers, mainly for use by extension functions */ |