Patch 8.0.0075
Problem:    Using number for exception type lacks type checking.
Solution:   Use an enum.
Files:      src/structs.h, src/ex_docmd.c, src/ex_eval.c,
            src/proto/ex_eval.pro


*** ../vim-8.0.0074/src/structs.h       2016-10-27 21:13:04.886665573 +0200
--- src/structs.h       2016-11-10 20:12:36.997428856 +0100
***************
*** 815,827 ****
  };
  
  /*
   * Structure describing an exception.
   * (don't use "struct exception", it's used by the math library).
   */
  typedef struct vim_exception except_T;
  struct vim_exception
  {
!     int                       type;           /* exception type */
      char_u            *value;         /* exception value */
      struct msglist    *messages;      /* message(s) causing error exception */
      char_u            *throw_name;    /* name of the throw point */
--- 815,837 ----
  };
  
  /*
+  * The exception types.
+  */
+ typedef enum
+ {
+     ET_USER,          /* exception caused by ":throw" command */
+     ET_ERROR,         /* error exception */
+     ET_INTERRUPT      /* interrupt exception triggered by Ctrl-C */
+ } except_type_T;
+ 
+ /*
   * Structure describing an exception.
   * (don't use "struct exception", it's used by the math library).
   */
  typedef struct vim_exception except_T;
  struct vim_exception
  {
!     except_type_T     type;           /* exception type */
      char_u            *value;         /* exception value */
      struct msglist    *messages;      /* message(s) causing error exception */
      char_u            *throw_name;    /* name of the throw point */
***************
*** 830,842 ****
  };
  
  /*
-  * The exception types.
-  */
- #define ET_USER               0       /* exception caused by ":throw" command 
*/
- #define ET_ERROR      1       /* error exception */
- #define ET_INTERRUPT  2       /* interrupt exception triggered by Ctrl-C */
- 
- /*
   * Structure to save the error/interrupt/exception state between calls to
   * enter_cleanup() and leave_cleanup().  Must be allocated as an automatic
   * variable by the (common) caller of these functions.
--- 840,845 ----
*** ../vim-8.0.0074/src/ex_docmd.c      2016-11-10 18:16:30.081477202 +0100
--- src/ex_docmd.c      2016-11-10 20:09:12.926721098 +0100
***************
*** 1388,1395 ****
                    break;
                case ET_INTERRUPT:
                    break;
-               default:
-                   p = vim_strsave((char_u *)_(e_internal));
            }
  
            saved_sourcing_name = sourcing_name;
--- 1388,1393 ----
*** ../vim-8.0.0074/src/ex_eval.c       2016-11-10 20:01:41.189582944 +0100
--- src/ex_eval.c       2016-11-10 20:10:32.982214119 +0100
***************
*** 16,22 ****
  #if defined(FEAT_EVAL) || defined(PROTO)
  
  static void   free_msglist(struct msglist *l);
! static int    throw_exception(void *, int, char_u *);
  static char_u *get_end_emsg(struct condstack *cstack);
  
  /*
--- 16,22 ----
  #if defined(FEAT_EVAL) || defined(PROTO)
  
  static void   free_msglist(struct msglist *l);
! static int    throw_exception(void *, except_type_T, char_u *);
  static char_u *get_end_emsg(struct condstack *cstack);
  
  /*
***************
*** 422,428 ****
      char_u *
  get_exception_string(
      void      *value,
!     int               type,
      char_u    *cmdname,
      int               *should_free)
  {
--- 422,428 ----
      char_u *
  get_exception_string(
      void      *value,
!     except_type_T type,
      char_u    *cmdname,
      int               *should_free)
  {
***************
*** 503,509 ****
   * error exception.
   */
      static int
! throw_exception(void *value, int type, char_u *cmdname)
  {
      except_T  *excp;
      int               should_free;
--- 503,509 ----
   * error exception.
   */
      static int
! throw_exception(void *value, except_type_T type, char_u *cmdname)
  {
      except_T  *excp;
      int               should_free;
*** ../vim-8.0.0074/src/proto/ex_eval.pro       2016-09-12 13:04:02.000000000 
+0200
--- src/proto/ex_eval.pro       2016-11-10 20:12:48.261357539 +0100
***************
*** 7,13 ****
  void free_global_msglist(void);
  void do_errthrow(struct condstack *cstack, char_u *cmdname);
  int do_intthrow(struct condstack *cstack);
! char_u *get_exception_string(void *value, int type, char_u *cmdname, int 
*should_free);
  void discard_current_exception(void);
  void report_make_pending(int pending, void *value);
  void report_resume_pending(int pending, void *value);
--- 7,13 ----
  void free_global_msglist(void);
  void do_errthrow(struct condstack *cstack, char_u *cmdname);
  int do_intthrow(struct condstack *cstack);
! char_u *get_exception_string(void *value, except_type_T type, char_u 
*cmdname, int *should_free);
  void discard_current_exception(void);
  void report_make_pending(int pending, void *value);
  void report_resume_pending(int pending, void *value);
*** ../vim-8.0.0074/src/version.c       2016-11-10 20:01:41.201582868 +0100
--- src/version.c       2016-11-10 20:19:35.890768627 +0100
***************
*** 766,767 ****
--- 766,769 ----
  {   /* Add new patch number below this line */
+ /**/
+     75,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
12. You turn off your modem and get this awful empty feeling, like you just
    pulled the plug on a loved one.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui