Loading ...
Sorry, an error occurred while loading the content.

Patch 6.3a.007

Expand Messages
  • Bram Moolenaar
    Patch 6.3a.007 Problem: cindent recognizes enum but not typedef enum . Solution: Skip over typedef before checking for enum . (Helmut Stiegler)
    Message 1 of 1 , May 10, 2004
    • 0 Attachment
      Patch 6.3a.007
      Problem: 'cindent' recognizes "enum" but not "typedef enum".
      Solution: Skip over "typedef" before checking for "enum". (Helmut Stiegler)
      Also avoid that searching for this item goes too far back.
      Files: src/misc1.c, src/testdir/test3.in, src/testdir/test3.ok


      *** ../vim-6.3a.006/src/misc1.c Fri May 7 10:59:37 2004
      --- src/misc1.c Sat May 8 22:55:46 2004
      ***************
      *** 4526,4532 ****
      /*
      * Recognize structure initialization and enumerations.
      * Q&D-Implementation:
      ! * check for "=" at end or "enum" at beginning of line.
      */
      static int
      cin_isinit(void)
      --- 4526,4532 ----
      /*
      * Recognize structure initialization and enumerations.
      * Q&D-Implementation:
      ! * check for "=" at end or "[typedef] enum" at beginning of line.
      */
      static int
      cin_isinit(void)
      ***************
      *** 4535,4540 ****
      --- 4535,4543 ----

      s = cin_skipcomment(ml_get_curline());

      + if (STRNCMP(s, "typedef", 7) == 0 && !vim_isIDc(s[7]))
      + s = cin_skipcomment(s + 7);
      +
      if (STRNCMP(s, "enum", 4) == 0 && !vim_isIDc(s[4]))
      return TRUE;

      ***************
      *** 6209,6214 ****
      --- 6212,6219 ----
      if (cin_nocode(l))
      continue;

      + terminated = cin_isterminated(l, FALSE, TRUE);
      +
      /*
      * If we are at top level and the line looks like a
      * function declaration, we are done
      ***************
      *** 6217,6224 ****
      if (start_brace != BRACE_IN_COL0
      || !cin_isfuncdecl(&l, curwin->w_cursor.lnum))
      {
      - terminated = cin_isterminated(l, FALSE, TRUE);
      -
      /* if the line is terminated with another ','
      * it is a continued variable initialization.
      * don't add extra indent.
      --- 6222,6227 ----
      ***************
      *** 6240,6261 ****
      continue;
      }

      ! /* Skip parens and braces. Position the cursor over
      ! * the rightmost paren, so that matching it will take
      ! * us back to the start of the line.
      ! */ /* XXX */
      ! trypos = NULL;
      ! if (find_last_paren(l, '(', ')'))
      ! trypos = find_match_paren(ind_maxparen,
      ! ind_maxcomment);

      ! if (trypos == NULL && find_last_paren(l, '{', '}'))
      ! trypos = find_start_brace(ind_maxcomment);

      ! if (trypos != NULL)
      ! {
      ! curwin->w_cursor.lnum = trypos->lnum + 1;
      ! continue;
      }

      /* it's a variable declaration, add indentation
      --- 6243,6267 ----
      continue;
      }

      ! if (terminated != ';')
      ! {
      ! /* Skip parens and braces. Position the cursor
      ! * over the rightmost paren, so that matching it
      ! * will take us back to the start of the line.
      ! */ /* XXX */
      ! trypos = NULL;
      ! if (find_last_paren(l, '(', ')'))
      ! trypos = find_match_paren(ind_maxparen,
      ! ind_maxcomment);

      ! if (trypos == NULL && find_last_paren(l, '{', '}'))
      ! trypos = find_start_brace(ind_maxcomment);

      ! if (trypos != NULL)
      ! {
      ! curwin->w_cursor.lnum = trypos->lnum + 1;
      ! continue;
      ! }
      }

      /* it's a variable declaration, add indentation
      *** ../vim-6.3a.006/src/testdir/test3.in Fri May 7 10:59:36 2004
      --- src/testdir/test3.in Sat May 8 22:56:44 2004
      ***************
      *** 297,302 ****
      --- 297,321 ----
      "bar",
      }

      + enum soppie
      + {
      + yes = 0,
      + no,
      + maybe
      + };
      +
      + typedef enum soppie
      + {
      + yes = 0,
      + no,
      + maybe
      + };
      +
      + {
      + int a,
      + b;
      + }
      +
      {
      struct Type
      {
      *** ../vim-6.3a.006/src/testdir/test3.ok Fri May 7 10:59:36 2004
      --- src/testdir/test3.ok Sat May 8 22:59:53 2004
      ***************
      *** 285,290 ****
      --- 285,309 ----
      "bar",
      }

      + enum soppie
      + {
      + yes = 0,
      + no,
      + maybe
      + };
      +
      + typedef enum soppie
      + {
      + yes = 0,
      + no,
      + maybe
      + };
      +
      + {
      + int a,
      + b;
      + }
      +
      {
      struct Type
      {
      *** ../vim-6.3a.006/src/version.c Sat May 8 22:17:54 2004
      --- src/version.c Mon May 10 12:47:34 2004
      ***************
      *** 643,644 ****
      --- 643,646 ----
      { /* Add new patch number below this line */
      + /**/
      + 7,
      /**/

      --
      "You mean there really is an answer?"
      "Yes! But you're not going to like it!"
      "Oh do please tell us!"
      "You're really not going to like it!"
      "but we MUST know - tell us"
      "Alright, the answer is...."
      "yes..."
      "... is ..."
      "yes... come on!"
      "is 42!"
      (Douglas Adams - The Hitchhiker's Guide to the Galaxy)

      /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
      /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
      \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
      \\\ Buy at Amazon and help AIDS victims -- http://ICCF.nl/click1.html ///
    Your message has been successfully submitted and would be delivered to recipients shortly.