Skip to content

Commit 8a5883b

Browse files
committed
patch 8.0.0075
Problem: Using number for exception type lacks type checking. Solution: Use an enum.
1 parent 95f0960 commit 8a5883b

File tree

5 files changed

+17
-14
lines changed

5 files changed

+17
-14
lines changed

src/ex_docmd.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1388,8 +1388,6 @@ do_cmdline(
13881388
break;
13891389
case ET_INTERRUPT:
13901390
break;
1391-
default:
1392-
p = vim_strsave((char_u *)_(e_internal));
13931391
}
13941392

13951393
saved_sourcing_name = sourcing_name;

src/ex_eval.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#if defined(FEAT_EVAL) || defined(PROTO)
1717

1818
static void free_msglist(struct msglist *l);
19-
static int throw_exception(void *, int, char_u *);
19+
static int throw_exception(void *, except_type_T, char_u *);
2020
static char_u *get_end_emsg(struct condstack *cstack);
2121

2222
/*
@@ -422,7 +422,7 @@ do_intthrow(struct condstack *cstack)
422422
char_u *
423423
get_exception_string(
424424
void *value,
425-
int type,
425+
except_type_T type,
426426
char_u *cmdname,
427427
int *should_free)
428428
{
@@ -503,7 +503,7 @@ get_exception_string(
503503
* error exception.
504504
*/
505505
static int
506-
throw_exception(void *value, int type, char_u *cmdname)
506+
throw_exception(void *value, except_type_T type, char_u *cmdname)
507507
{
508508
except_T *excp;
509509
int should_free;

src/proto/ex_eval.pro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ int cause_errthrow(char_u *mesg, int severe, int *ignore);
77
void free_global_msglist(void);
88
void do_errthrow(struct condstack *cstack, char_u *cmdname);
99
int do_intthrow(struct condstack *cstack);
10-
char_u *get_exception_string(void *value, int type, char_u *cmdname, int *should_free);
10+
char_u *get_exception_string(void *value, except_type_T type, char_u *cmdname, int *should_free);
1111
void discard_current_exception(void);
1212
void report_make_pending(int pending, void *value);
1313
void report_resume_pending(int pending, void *value);

src/structs.h

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -814,28 +814,31 @@ struct msglist
814814
struct msglist *next; /* next of several messages in a row */
815815
};
816816

817+
/*
818+
* The exception types.
819+
*/
820+
typedef enum
821+
{
822+
ET_USER, /* exception caused by ":throw" command */
823+
ET_ERROR, /* error exception */
824+
ET_INTERRUPT /* interrupt exception triggered by Ctrl-C */
825+
} except_type_T;
826+
817827
/*
818828
* Structure describing an exception.
819829
* (don't use "struct exception", it's used by the math library).
820830
*/
821831
typedef struct vim_exception except_T;
822832
struct vim_exception
823833
{
824-
int type; /* exception type */
834+
except_type_T type; /* exception type */
825835
char_u *value; /* exception value */
826836
struct msglist *messages; /* message(s) causing error exception */
827837
char_u *throw_name; /* name of the throw point */
828838
linenr_T throw_lnum; /* line number of the throw point */
829839
except_T *caught; /* next exception on the caught stack */
830840
};
831841

832-
/*
833-
* The exception types.
834-
*/
835-
#define ET_USER 0 /* exception caused by ":throw" command */
836-
#define ET_ERROR 1 /* error exception */
837-
#define ET_INTERRUPT 2 /* interrupt exception triggered by Ctrl-C */
838-
839842
/*
840843
* Structure to save the error/interrupt/exception state between calls to
841844
* enter_cleanup() and leave_cleanup(). Must be allocated as an automatic

src/version.c

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

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
75,
767769
/**/
768770
74,
769771
/**/

0 commit comments

Comments
 (0)