diff options
-rw-r--r-- | editors/vi.c | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/editors/vi.c b/editors/vi.c index e79787977..05d30f2ff 100644 --- a/editors/vi.c +++ b/editors/vi.c | |||
@@ -2969,26 +2969,20 @@ static int file_insert(const char *fn, char *p, int initial) | |||
2969 | status_line_bold_errno(fn); | 2969 | status_line_bold_errno(fn); |
2970 | p = text_hole_delete(p, p + size - 1, NO_UNDO); // un-do buffer insert | 2970 | p = text_hole_delete(p, p + size - 1, NO_UNDO); // un-do buffer insert |
2971 | } else if (cnt < size) { | 2971 | } else if (cnt < size) { |
2972 | // There was a partial read, shrink unused space | ||
2973 | #if ENABLE_PLATFORM_MINGW32 | 2972 | #if ENABLE_PLATFORM_MINGW32 |
2974 | int i, newline; | 2973 | int i, cnt_cr; |
2975 | 2974 | ||
2976 | newline = 0; | 2975 | // on WIN32 a partial read might just mean CRs have been removed |
2977 | for ( i=0; i<cnt; ++i ) { | 2976 | for (i = 0, cnt_cr = cnt; i < cnt; ++i) |
2978 | if ( p[i] == '\n' ) { | 2977 | if (p[i] == '\n') |
2979 | ++newline; | 2978 | ++cnt_cr; |
2980 | } | ||
2981 | } | ||
2982 | #endif | 2979 | #endif |
2980 | // There was a partial read, shrink unused space | ||
2983 | p = text_hole_delete(p + cnt, p + size - 1, NO_UNDO); | 2981 | p = text_hole_delete(p + cnt, p + size - 1, NO_UNDO); |
2984 | #if ENABLE_PLATFORM_MINGW32 | 2982 | #if ENABLE_PLATFORM_MINGW32 |
2985 | // on WIN32 a partial read might just mean CRs have been removed | 2983 | if (cnt_cr < size) |
2986 | if ( cnt+newline != size ) { | ||
2987 | status_line_bold("can't read '%s'", fn); | ||
2988 | } | ||
2989 | #else | ||
2990 | status_line_bold("can't read '%s'", fn); | ||
2991 | #endif | 2984 | #endif |
2985 | status_line_bold("can't read '%s'", fn); | ||
2992 | } | 2986 | } |
2993 | fi: | 2987 | fi: |
2994 | close(fd); | 2988 | close(fd); |