From 612ea8d837f14a15a44c2d4941ff62c0ebf30461 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Tue, 11 Jun 2013 18:44:10 +0300 Subject: Improve fix for debugger on Windows. --- io.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'io.c') diff --git a/io.c b/io.c index a918c390..44530967 100644 --- a/io.c +++ b/io.c @@ -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 */ -- cgit v1.2.3