Skip to content

Commit b869c0d

Browse files
committed
patch 7.4.2080
Problem: When using PERROR() on some systems assert_fails() does not see the error. Solution: Make PERROR() always report the error.
1 parent 53bdec2 commit b869c0d

4 files changed

Lines changed: 19 additions & 1 deletion

File tree

src/message.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,21 @@ emsg_not_now(void)
521521
return FALSE;
522522
}
523523

524+
#if !defined(HAVE_STRERROR) || defined(PROTO)
525+
/*
526+
* Replacement for perror() that behaves more or less like emsg() was called.
527+
* v:errmsg will be set and called_emsg will be set.
528+
*/
529+
void
530+
do_perror(char *msg)
531+
{
532+
perror(msg);
533+
++emsg_silent;
534+
emsg((char_u *)msg);
535+
--emsg_silent;
536+
}
537+
#endif
538+
524539
/*
525540
* emsg() - display an error message
526541
*

src/proto/message.pro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ void trunc_string(char_u *s, char_u *buf, int room, int buflen);
88
void reset_last_sourcing(void);
99
void msg_source(int attr);
1010
int emsg_not_now(void);
11+
void do_perror(char *msg);
1112
int emsg(char_u *s);
1213
int emsg2(char_u *s, char_u *a1);
1314
void emsg_invreg(int name);

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,8 @@ static char *(features[]) =
758758

759759
static int included_patches[] =
760760
{ /* Add new patch number below this line */
761+
/**/
762+
2080,
761763
/**/
762764
2079,
763765
/**/

src/vim.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1652,7 +1652,7 @@ typedef UINT32_TYPEDEF UINT32_T;
16521652
#ifdef HAVE_STRERROR
16531653
# define PERROR(msg) (void)emsg3((char_u *)"%s: %s", (char_u *)msg, (char_u *)strerror(errno))
16541654
#else
1655-
# define PERROR(msg) perror(msg)
1655+
# define PERROR(msg) do_perror(msg)
16561656
#endif
16571657

16581658
typedef long linenr_T; /* line number type */

0 commit comments

Comments
 (0)