home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / patches / 7.0 / 7.0.191 < prev    next >
Encoding:
Internet Message Format  |  2007-02-03  |  10.7 KB

  1. To: vim-dev@vim.org
  2. Subject: patch 7.0.191
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. Mime-Version: 1.0
  6. Content-Type: text/plain; charset=ISO-8859-1
  7. Content-Transfer-Encoding: 8bit
  8. ------------
  9.  
  10. Patch 7.0.191 
  11. Problem:    The items used by getqflist() and setqflist() don't match.
  12. Solution:   Support the "bufnum" item for setqflist(). (Yegappan Lakshmanan)
  13. Files:      runtime/doc/eval.txt, src/quickfix.c
  14.  
  15.  
  16. *** ../vim-7.0.190/runtime/doc/eval.txt    Wed Nov  1 15:31:02 2006
  17. --- runtime/doc/eval.txt    Sun Feb  4 01:54:35 2007
  18. ***************
  19. *** 2897,2908 ****
  20.               vcol    non-zero: "col" is visual column
  21.                   zero: "col" is byte index
  22.               nr    error number
  23.               text    description of the error
  24.               type    type of the error, 'E', '1', etc.
  25.               valid    non-zero: recognized error message
  26.   
  27.           When there is no error list or it's empty an empty list is
  28. !         returned.
  29.   
  30.           Useful application: Find pattern matches in multiple files and
  31.           do something with them: >
  32. --- 2912,2925 ----
  33.               vcol    non-zero: "col" is visual column
  34.                   zero: "col" is byte index
  35.               nr    error number
  36. +             pattern    search pattern used to locate the error
  37.               text    description of the error
  38.               type    type of the error, 'E', '1', etc.
  39.               valid    non-zero: recognized error message
  40.   
  41.           When there is no error list or it's empty an empty list is
  42. !         returned. Quickfix list entries with non-existing buffer
  43. !         number are returned with "bufnr" set to zero.
  44.   
  45.           Useful application: Find pattern matches in multiple files and
  46.           do something with them: >
  47. ***************
  48. *** 4371,4377 ****
  49.           Non-dictionary items in {list} are ignored.  Each dictionary
  50.           item can contain the following entries:
  51.   
  52. !             filename    name of a file
  53.               lnum    line number in the file
  54.               pattern    search pattern used to locate the error
  55.               col        column number
  56. --- 4401,4410 ----
  57.           Non-dictionary items in {list} are ignored.  Each dictionary
  58.           item can contain the following entries:
  59.   
  60. !             bufnr    buffer number; must be the number of a valid
  61. !                     buffer
  62. !             filename    name of a file; only used when "bufnr" is not
  63. !                     present or it is invalid.
  64.               lnum    line number in the file
  65.               pattern    search pattern used to locate the error
  66.               col        column number
  67. ***************
  68. *** 4384,4394 ****
  69.           The "col", "vcol", "nr", "type" and "text" entries are
  70.           optional.  Either "lnum" or "pattern" entry can be used to
  71.           locate a matching error line.
  72. !         If the "filename" entry is not present or neither the "lnum"
  73. !         or "pattern" entries are present, then the item will not be
  74. !         handled as an error line.
  75.           If both "pattern" and "lnum" are present then "pattern" will
  76.           be used.
  77.   
  78.           If {action} is set to 'a', then the items from {list} are
  79.           added to the existing quickfix list. If there is no existing
  80. --- 4417,4429 ----
  81.           The "col", "vcol", "nr", "type" and "text" entries are
  82.           optional.  Either "lnum" or "pattern" entry can be used to
  83.           locate a matching error line.
  84. !         If the "filename" and "bufnr" entries are not present or
  85. !         neither the "lnum" or "pattern" entries are present, then the
  86. !         item will not be handled as an error line.
  87.           If both "pattern" and "lnum" are present then "pattern" will
  88.           be used.
  89. +         Note that the list is not exactly the same as what
  90. +         |getqflist()| returns.
  91.   
  92.           If {action} is set to 'a', then the items from {list} are
  93.           added to the existing quickfix list. If there is no existing
  94. *** ../vim-7.0.190/src/quickfix.c    Fri Oct 20 20:15:05 2006
  95. --- src/quickfix.c    Sun Feb  4 01:50:17 2007
  96. ***************
  97. *** 106,112 ****
  98.   
  99.   static int    qf_init_ext __ARGS((qf_info_T *qi, char_u *efile, buf_T *buf, typval_T *tv, char_u *errorformat, int newlist, linenr_T lnumfirst, linenr_T lnumlast));
  100.   static void    qf_new_list __ARGS((qf_info_T *qi));
  101. ! static int    qf_add_entry __ARGS((qf_info_T *qi, qfline_T **prevp, char_u *dir, char_u *fname, char_u *mesg, long lnum, int col, int vis_col, char_u *pattern, int nr, int type, int valid));
  102.   static void    qf_msg __ARGS((qf_info_T *qi));
  103.   static void    qf_free __ARGS((qf_info_T *qi, int idx));
  104.   static char_u    *qf_types __ARGS((int, int));
  105. --- 106,112 ----
  106.   
  107.   static int    qf_init_ext __ARGS((qf_info_T *qi, char_u *efile, buf_T *buf, typval_T *tv, char_u *errorformat, int newlist, linenr_T lnumfirst, linenr_T lnumlast));
  108.   static void    qf_new_list __ARGS((qf_info_T *qi));
  109. ! static int    qf_add_entry __ARGS((qf_info_T *qi, qfline_T **prevp, char_u *dir, char_u *fname, int bufnum, char_u *mesg, long lnum, int col, int vis_col, char_u *pattern, int nr, int type, int valid));
  110.   static void    qf_msg __ARGS((qf_info_T *qi));
  111.   static void    qf_free __ARGS((qf_info_T *qi, int idx));
  112.   static char_u    *qf_types __ARGS((int, int));
  113. ***************
  114. *** 791,796 ****
  115. --- 791,797 ----
  116.               (*namebuf || directory)
  117.                   ? namebuf
  118.                   : ((currfile && valid) ? currfile : (char_u *)NULL),
  119. +             0,
  120.               errmsg,
  121.               lnum,
  122.               col,
  123. ***************
  124. *** 936,947 ****
  125.    * Returns OK or FAIL.
  126.    */
  127.       static int
  128. ! qf_add_entry(qi, prevp, dir, fname, mesg, lnum, col, vis_col, pattern, nr, type,
  129. !          valid)
  130.       qf_info_T    *qi;        /* quickfix list */
  131.       qfline_T    **prevp;    /* pointer to previously added entry or NULL */
  132.       char_u    *dir;        /* optional directory name */
  133.       char_u    *fname;        /* file name or NULL */
  134.       char_u    *mesg;        /* message */
  135.       long    lnum;        /* line number */
  136.       int        col;        /* column */
  137. --- 937,949 ----
  138.    * Returns OK or FAIL.
  139.    */
  140.       static int
  141. ! qf_add_entry(qi, prevp, dir, fname, bufnum, mesg, lnum, col, vis_col, pattern,
  142. !          nr, type, valid)
  143.       qf_info_T    *qi;        /* quickfix list */
  144.       qfline_T    **prevp;    /* pointer to previously added entry or NULL */
  145.       char_u    *dir;        /* optional directory name */
  146.       char_u    *fname;        /* file name or NULL */
  147. +     int        bufnum;        /* buffer number or zero */
  148.       char_u    *mesg;        /* message */
  149.       long    lnum;        /* line number */
  150.       int        col;        /* column */
  151. ***************
  152. *** 955,961 ****
  153.   
  154.       if ((qfp = (qfline_T *)alloc((unsigned)sizeof(qfline_T))) == NULL)
  155.       return FAIL;
  156. !     qfp->qf_fnum = qf_get_fnum(dir, fname);
  157.       if ((qfp->qf_text = vim_strsave(mesg)) == NULL)
  158.       {
  159.       vim_free(qfp);
  160. --- 957,966 ----
  161.   
  162.       if ((qfp = (qfline_T *)alloc((unsigned)sizeof(qfline_T))) == NULL)
  163.       return FAIL;
  164. !     if (bufnum != 0)
  165. !     qfp->qf_fnum = bufnum;
  166. !     else
  167. !     qfp->qf_fnum = qf_get_fnum(dir, fname);
  168.       if ((qfp->qf_text = vim_strsave(mesg)) == NULL)
  169.       {
  170.       vim_free(qfp);
  171. ***************
  172. *** 1106,1111 ****
  173. --- 1111,1117 ----
  174.           if (qf_add_entry(to->w_llist, &prevp,
  175.                    NULL,
  176.                    NULL,
  177. +                  0,
  178.                    from_qfp->qf_text,
  179.                    from_qfp->qf_lnum,
  180.                    from_qfp->qf_col,
  181. ***************
  182. *** 3134,3139 ****
  183. --- 3140,3146 ----
  184.               if (qf_add_entry(qi, &prevp,
  185.                   NULL,       /* dir */
  186.                   fnames[fi],
  187. +                 0,
  188.                   ml_get_buf(buf,
  189.                        regmatch.startpos[0].lnum + lnum, FALSE),
  190.                   regmatch.startpos[0].lnum + lnum,
  191. ***************
  192. *** 3419,3424 ****
  193. --- 3426,3432 ----
  194.       char_u    buf[2];
  195.       qfline_T    *qfp;
  196.       int        i;
  197. +     int        bufnum;
  198.   
  199.       if (wp != NULL)
  200.       {
  201. ***************
  202. *** 3434,3439 ****
  203. --- 3442,3452 ----
  204.       qfp = qi->qf_lists[qi->qf_curlist].qf_start;
  205.       for (i = 1; !got_int && i <= qi->qf_lists[qi->qf_curlist].qf_count; ++i)
  206.       {
  207. +     /* Handle entries with a non-existing buffer number. */
  208. +     bufnum = qfp->qf_fnum;
  209. +     if (bufnum != 0 && (buflist_findnr(bufnum) == NULL))
  210. +         bufnum = 0;
  211.       if ((dict = dict_alloc()) == NULL)
  212.           return FAIL;
  213.       if (list_append_dict(list, dict) == FAIL)
  214. ***************
  215. *** 3441,3447 ****
  216.   
  217.       buf[0] = qfp->qf_type;
  218.       buf[1] = NUL;
  219. !     if ( dict_add_nr_str(dict, "bufnr", (long)qfp->qf_fnum, NULL) == FAIL
  220.         || dict_add_nr_str(dict, "lnum",  (long)qfp->qf_lnum, NULL) == FAIL
  221.         || dict_add_nr_str(dict, "col",   (long)qfp->qf_col, NULL) == FAIL
  222.         || dict_add_nr_str(dict, "vcol",  (long)qfp->qf_viscol, NULL) == FAIL
  223. --- 3454,3460 ----
  224.   
  225.       buf[0] = qfp->qf_type;
  226.       buf[1] = NUL;
  227. !     if ( dict_add_nr_str(dict, "bufnr", (long)bufnum, NULL) == FAIL
  228.         || dict_add_nr_str(dict, "lnum",  (long)qfp->qf_lnum, NULL) == FAIL
  229.         || dict_add_nr_str(dict, "col",   (long)qfp->qf_col, NULL) == FAIL
  230.         || dict_add_nr_str(dict, "vcol",  (long)qfp->qf_viscol, NULL) == FAIL
  231. ***************
  232. *** 3472,3477 ****
  233. --- 3485,3491 ----
  234.       listitem_T    *li;
  235.       dict_T    *d;
  236.       char_u    *filename, *pattern, *text, *type;
  237. +     int        bufnum;
  238.       long    lnum;
  239.       int        col, nr;
  240.       int        vcol;
  241. ***************
  242. *** 3479,3484 ****
  243. --- 3493,3499 ----
  244.       int        valid, status;
  245.       int        retval = OK;
  246.       qf_info_T    *qi = &ql_info;
  247. +     int        did_bufnr_emsg = FALSE;
  248.   
  249.       if (wp != NULL)
  250.       {
  251. ***************
  252. *** 3508,3513 ****
  253. --- 3523,3529 ----
  254.           continue;
  255.   
  256.       filename = get_dict_string(d, (char_u *)"filename", TRUE);
  257. +     bufnum = get_dict_number(d, (char_u *)"bufnr");
  258.       lnum = get_dict_number(d, (char_u *)"lnum");
  259.       col = get_dict_number(d, (char_u *)"col");
  260.       vcol = get_dict_number(d, (char_u *)"vcol");
  261. ***************
  262. *** 3519,3530 ****
  263.           text = vim_strsave((char_u *)"");
  264.   
  265.       valid = TRUE;
  266. !     if (filename == NULL || (lnum == 0 && pattern == NULL))
  267.           valid = FALSE;
  268.   
  269.       status =  qf_add_entry(qi, &prevp,
  270.                      NULL,        /* dir */
  271.                      filename,
  272.                      text,
  273.                      lnum,
  274.                      col,
  275. --- 3535,3560 ----
  276.           text = vim_strsave((char_u *)"");
  277.   
  278.       valid = TRUE;
  279. !     if ((filename == NULL && bufnum == 0) || (lnum == 0 && pattern == NULL))
  280.           valid = FALSE;
  281.   
  282. +     /* Mark entries with non-existing buffer number as not valid. Give the
  283. +      * error message only once. */
  284. +     if (bufnum != 0 && (buflist_findnr(bufnum) == NULL))
  285. +     {
  286. +         if (!did_bufnr_emsg)
  287. +         {
  288. +         did_bufnr_emsg = TRUE;
  289. +         EMSGN(_("E92: Buffer %ld not found"), bufnum);
  290. +         }
  291. +         valid = FALSE;
  292. +         bufnum = 0;
  293. +     }
  294.       status =  qf_add_entry(qi, &prevp,
  295.                      NULL,        /* dir */
  296.                      filename,
  297. +                    bufnum,
  298.                      text,
  299.                      lnum,
  300.                      col,
  301. ***************
  302. *** 3757,3762 ****
  303. --- 3787,3793 ----
  304.                   if (qf_add_entry(qi, &prevp,
  305.                           NULL,    /* dir */
  306.                           fnames[fi],
  307. +                         0,
  308.                           IObuff,
  309.                           lnum,
  310.                           (int)(regmatch.startp[0] - IObuff)
  311. *** ../vim-7.0.190/src/version.c    Sun Feb  4 02:49:03 2007
  312. --- src/version.c    Sun Feb  4 02:50:49 2007
  313. ***************
  314. *** 668,669 ****
  315. --- 668,671 ----
  316.   {   /* Add new patch number below this line */
  317. + /**/
  318. +     191,
  319.   /**/
  320.  
  321. -- 
  322. From "know your smileys":
  323.  |-P    Reaction to unusually ugly C code
  324.  
  325.  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
  326. ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
  327. \\\        download, build and distribute -- http://www.A-A-P.org        ///
  328.  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
  329.