• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ chunk_get_prev函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中chunk_get_prev函数的典型用法代码示例。如果您正苦于以下问题:C++ chunk_get_prev函数的具体用法?C++ chunk_get_prev怎么用?C++ chunk_get_prev使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了chunk_get_prev函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: LOG_FUNC_ENTRY

/*
 * the value of after determines:
 *   true:  insert_vbrace_close_after(pc, frm)
 *   false: insert_vbrace_open_before(pc, frm)
 */
static chunk_t *insert_vbrace(chunk_t *pc, bool after,
                              struct parse_frame *frm)
{
    LOG_FUNC_ENTRY();
    chunk_t chunk;
    chunk_t *rv;
    chunk_t *ref;

    chunk.orig_line   = pc->orig_line;
    chunk.parent_type = frm->pse[frm->pse_tos].type;
    chunk.level       = frm->level;
    chunk.brace_level = frm->brace_level;
    chunk.flags       = pc->flags & PCF_COPY_FLAGS;
    chunk.str         = "";
    if (after)
    {
        chunk.type = CT_VBRACE_CLOSE;
        rv         = chunk_add_after(&chunk, pc);
    }
    else
    {
        ref = chunk_get_prev(pc);
        if ((ref->flags & PCF_IN_PREPROC) == 0)
        {
            chunk.flags &= ~PCF_IN_PREPROC;
        }

        while (chunk_is_newline(ref) || chunk_is_comment(ref))
        {
            ref->level++;
            ref->brace_level++;
            ref = chunk_get_prev(ref);
        }

        /* Don't back into a preprocessor */
        if (((pc->flags & PCF_IN_PREPROC) == 0) &&
                (ref->flags & PCF_IN_PREPROC))
        {
            if (ref->type == CT_PREPROC_BODY)
            {
                do
                {
                    ref = chunk_get_prev(ref);
                } while ((ref != NULL) && (ref->flags & PCF_IN_PREPROC));
            }
            else
            {
                ref = chunk_get_next(ref);
            }
        }

        chunk.orig_line = ref->orig_line;
        chunk.column    = ref->column + ref->len() + 1;
        chunk.type      = CT_VBRACE_OPEN;
        rv              = chunk_add_after(&chunk, ref);
    }
    return(rv);
} // insert_vbrace
开发者ID:bengardner,项目名称:uncrustify,代码行数:63,代码来源:brace_cleanup.cpp


示例2: indent_comment

/**
 * REVISIT: This needs to be re-checked, maybe cleaned up
 *
 * Indents comments in a (hopefully) smart manner.
 *
 * There are two type of comments that get indented:
 *  - stand alone (ie, no tokens on the line before the comment)
 *  - trailing comments (last token on the line apart from a linefeed)
 *    + note that a stand-alone comment is a special case of a trailing
 *
 * The stand alone comments will get indented in one of three ways:
 *  - column 1:
 *    + There is an empty line before the comment AND the indent level is 0
 *    + The comment was originally in column 1
 *
 *  - Same column as trailing comment on previous line (ie, aligned)
 *    + if originally within TBD (3) columns of the previous comment
 *
 *  - syntax indent level
 *    + doesn't fit in the previous categories
 *
 * Options modify this behavior:
 *  - keep original column (don't move the comment, if possible)
 *  - keep relative column (move out the same amount as first item on line)
 *  - fix trailing comment in column TBD
 *
 * @param pc   The comment, which is the first item on a line
 * @param col  The column if this is to be put at indent level
 */
static void indent_comment(chunk_t *pc, int col)
{
    chunk_t *nl;
    chunk_t *prev;

    LOG_FMT(LCMTIND, "%s: line %d, col %d, level %d: ", __func__,
            pc->orig_line, pc->orig_col, pc->level);

    /* force column 1 comment to column 1 if not changing them */
    if ((pc->orig_col == 1) && !cpd.settings[UO_indent_col1_comment].b)
    {
        LOG_FMT(LCMTIND, "rule 1 - keep in col 1\n");
        pc->column = 1;
        return;
    }

    nl = chunk_get_prev(pc);

    /* outside of any expression or statement? */
    if (pc->level == 0)
    {
        if ((nl != NULL) && (nl->nl_count > 1))
        {
            LOG_FMT(LCMTIND, "rule 2 - level 0, nl before\n");
            pc->column = 1;
            return;
        }
    }

    prev = chunk_get_prev(nl);

    if (chunk_is_comment(prev) && (nl->nl_count == 1))
    {
        int coldiff = prev->orig_col - pc->orig_col;

        if ((coldiff <= 3) && (coldiff >= -3))
        {
            pc->column = prev->column;
            LOG_FMT(LCMTIND, "rule 3 - prev comment, coldiff = %d, now in %d\n",
                    coldiff, pc->column);
            return;
        }
    }

    /* check if special single line comment rule applies */
    if (cpd.settings[UO_indent_sing_line_comments].n > 0 && single_line_comment_indent_rule_applies(pc))
    {
        pc->column = col + cpd.settings[UO_indent_sing_line_comments].n;
        LOG_FMT(LCMTIND, "rule 4 - single line comment indent, now in %d\n", pc->column);
        return;
    }

    LOG_FMT(LCMTIND, "rule 5 - fall-through, stay in %d\n", col);

    pc->column = col;
}
开发者ID:CDanU,项目名称:uncrustify,代码行数:85,代码来源:02102-indent.cpp


示例3: chunk_log

static void chunk_log(chunk_t *pc, const char *text)
{
   if (pc && (cpd.unc_stage != US_TOKENIZE) && (cpd.unc_stage != US_CLEANUP))
   {
      chunk_t *prev = chunk_get_prev(pc);
      chunk_t *next = chunk_get_next(pc);

      LOG_FMT(LCHUNK, " -- %s: %lu:%lu '%s' [%s]",
              text, pc->orig_line, pc->orig_col, pc->text(),
              get_token_name(pc->type));

      if (prev && next)
      {
         LOG_FMT(LCHUNK, " @ between %lu:%lu '%s' [%s] and %lu:%lu '%s' [%s]",
                 prev->orig_line, prev->orig_col, prev->text(),
                 get_token_name(prev->type),
                 next->orig_line, next->orig_col, next->text(),
                 get_token_name(next->type));
      }
      else if (next)
      {
         LOG_FMT(LCHUNK, " @ before %lu:%lu '%s' [%s]",
                 next->orig_line, next->orig_col, next->text(),
                 get_token_name(next->type));
      }
      else if (prev)
      {
         LOG_FMT(LCHUNK, " @ after %lu:%lu '%s' [%s]",
                 prev->orig_line, prev->orig_col, prev->text(),
                 get_token_name(prev->type));
      }
      LOG_FMT(LCHUNK, " stage=%d", cpd.unc_stage);
      log_func_stack_inline(LCHUNK);
   }
}
开发者ID:bengardner,项目名称:uncrustify,代码行数:35,代码来源:chunk_list.cpp


示例4: split_fcn_params_full

static void split_fcn_params_full(chunk_t *start)
{
   LOG_FUNC_ENTRY();
   LOG_FMT(LSPLIT, "%s(%d): %s\n", __func__, __LINE__, start->text());

   // Find the opening function parenthesis
   chunk_t *fpo = start;
   LOG_FMT(LSPLIT, "  %s(%d): Find the opening function parenthesis\n", __func__, __LINE__);
   while ((fpo = chunk_get_prev(fpo)) != nullptr)
   {
      LOG_FMT(LSPLIT, "%s(%d): %s, orig_col is %zu, level is %zu\n",
              __func__, __LINE__, fpo->text(), fpo->orig_col, fpo->level);
      if (fpo->type == CT_FPAREN_OPEN && (fpo->level == start->level - 1))
      {
         break;  // opening parenthesis found. Issue #1020
      }
   }

   // Now break after every comma
   chunk_t *pc = fpo;
   while ((pc = chunk_get_next_ncnl(pc)) != nullptr)
   {
      if (pc->level <= fpo->level)
      {
         break;
      }
      if ((pc->level == (fpo->level + 1)) && pc->type == CT_COMMA)
      {
         split_before_chunk(chunk_get_next(pc));
      }
   }
}
开发者ID:CDanU,项目名称:uncrustify,代码行数:32,代码来源:width.cpp


示例5: split_fcn_params_full

/**
 * Splits the parameters at every comma that is at the fparen level.
 *
 * @param start   the offending token
 */
static void split_fcn_params_full(chunk_t *start)
{
   LOG_FMT(LSPLIT, "%s", __func__);

   chunk_t *fpo;
   chunk_t *pc;

   /* Find the opening fparen */
   fpo = start;
   while (((fpo = chunk_get_prev(fpo)) != NULL) &&
          (fpo->type != CT_FPAREN_OPEN))
   {
      /* do nothing */
   }

   /* Now break after every comma */
   pc = fpo;
   while ((pc = chunk_get_next_ncnl(pc)) != NULL)
   {
      if (pc->level <= fpo->level)
      {
         break;
      }
      if ((pc->level == (fpo->level + 1)) && (pc->type == CT_COMMA))
      {
         split_before_chunk(chunk_get_next(pc));
      }
   }
}
开发者ID:Limsik,项目名称:e17,代码行数:34,代码来源:width.cpp


示例6: align_oc_msg_colon

/**
 * Aligns an OC message
 *
 * @param so   the square open of the message
 * @param span the span value
 */
static void align_oc_msg_colon(chunk_t *so)
{
   int        span = cpd.settings[UO_align_oc_msg_colon_span].n;
   chunk_t    *pc;
   chunk_t    *tmp;
   AlignStack cas;   /* for the colons */
   AlignStack nas;   /* for the parameter tag */
   int        level;
   bool       did_line;
   int        lcnt;  /* line count with no colon for span */
   bool       has_colon;


   nas.Reset();
   nas.m_right_align = true;

   cas.Start(span);

   level = so->level;
   pc    = chunk_get_next_ncnl(so, CNAV_PREPROC);

   did_line  = false;
   has_colon = false;
   lcnt      = 0;

   while ((pc != NULL) && (pc->level > level))
   {
      if (pc->level > (level + 1))
      {
         /* do nothing */
      }
      else if (chunk_is_newline(pc))
      {
         if (!has_colon)
         {
            ++lcnt;
         }
         did_line  = false;
         has_colon = !has_colon;
      }
      else if (!did_line && (lcnt - 1 < span) && (pc->type == CT_OC_COLON))
      {
         has_colon = true;
         cas.Add(pc);
         tmp = chunk_get_prev(pc);
         if ((tmp != NULL) &&
             ((tmp->type == CT_OC_MSG_FUNC) ||
              (tmp->type == CT_OC_MSG_NAME)))
         {
            nas.Add(tmp);
         }
         did_line = true;
      }
      pc = chunk_get_next(pc, CNAV_PREPROC);
   }
   nas.End();
   cas.End();
}
开发者ID:jscipione,项目名称:Paladin,代码行数:64,代码来源:align.cpp


示例7: space_text_balance_nested_parens

/**
 * Marches through the whole file and adds spaces around nested parens
 */
void space_text_balance_nested_parens(void)
{
   chunk_t *first;
   chunk_t *next;
   chunk_t *cur;
   chunk_t *prev;

   first = chunk_get_head();
   while (first != NULL)
   {
      next = chunk_get_next(first);
      if (next == NULL)
      {
         break;
      }

      if (chunk_is_str(first, "(", 1) && chunk_is_str(next, "(", 1))
      {
         /* insert a space between the two opening parens */
         space_add_after(first, 1);

         /* find the closing paren that matches the 'first' open paren and force
          * a space before it */
         cur  = next;
         prev = cur;
         while ((cur = chunk_get_next(cur)) != NULL)
         {
            if (cur->level == first->level)
            {
               space_add_after(prev, 1);
               break;
            }
            prev = cur;
         }
      }
      else if (chunk_is_str(first, ")", 1) && chunk_is_str(next, ")", 1))
      {
         /* insert a space between the two closing parens */
         space_add_after(first, 1);

         /* find the opening paren that matches the 'next' close paren and force
          * a space after it */
         cur = first;
         while ((cur = chunk_get_prev(cur)) != NULL)
         {
            if (cur->level == next->level)
            {
               space_add_after(cur, 1);
               break;
            }
         }
      }

      first = next;
   }
}
开发者ID:billcox,项目名称:uncrustify,代码行数:59,代码来源:space.cpp


示例8: chunk_get_prev

/**
 * Gets the prev non-NEWLINE chunk
 */
chunk_t *chunk_get_prev_nnl(chunk_t *cur, chunk_nav_t nav)
{
   chunk_t *pc = cur;

   do
   {
      pc = chunk_get_prev(pc, nav);
   } while ((pc != NULL) && chunk_is_newline(pc));
   return(pc);
}
开发者ID:bengardner,项目名称:uncrustify,代码行数:13,代码来源:chunk_list.cpp


示例9: add_file_footer

static void add_file_footer()
{
   chunk_t *pc = chunk_get_tail();

   /* Back up if the file ends with a newline */
   if ((pc != NULL) && chunk_is_newline(pc))
   {
      pc = chunk_get_prev(pc);
   }
   if ((pc != NULL) &&
       (!chunk_is_comment(pc) || !chunk_is_newline(chunk_get_prev(pc))))
   {
      pc = chunk_get_tail();
      if (!chunk_is_newline(pc))
      {
         LOG_FMT(LSYS, "Adding a newline at the end of the file\n");
         newline_add_after(pc);
      }
      tokenize(cpd.file_ftr.data, NULL);
   }
}
开发者ID:GerHobbelt,项目名称:uncrustify,代码行数:21,代码来源:uncrustify.cpp


示例10: LOG_FUNC_ENTRY

/**
 * Remove the case brace, if allowable.
 */
static chunk_t *mod_case_brace_remove(chunk_t *br_open)
{
   LOG_FUNC_ENTRY();
   chunk_t *pc;
   chunk_t *br_close;
   chunk_t *next = chunk_get_next_ncnl(br_open, CNAV_PREPROC);

   LOG_FMT(LMCB, "%s: line %lu", __func__, br_open->orig_line);

   /* Find the matching brace close */
   br_close = chunk_get_next_type(br_open, CT_BRACE_CLOSE, br_open->level, CNAV_PREPROC);
   if (br_close == NULL)
   {
      LOG_FMT(LMCB, " - no close\n");
      return(next);
   }

   /* Make sure 'break', 'return', 'goto', 'case' or '}' is after the close brace */
   pc = chunk_get_next_ncnl(br_close, CNAV_PREPROC);
   if ((pc == NULL) ||
       ((pc->type != CT_BREAK) &&
        (pc->type != CT_RETURN) &&
        (pc->type != CT_CASE) &&
        (pc->type != CT_GOTO) &&
        (pc->type != CT_BRACE_CLOSE)))
   {
      LOG_FMT(LMCB, " - after '%s'\n",
              (pc == NULL) ? "<null>" : get_token_name(pc->type));
      return(next);
   }

   /* scan to make sure there are no definitions at brace level between braces */
   for (pc = br_open; pc != br_close; pc = chunk_get_next_ncnl(pc, CNAV_PREPROC))
   {
      if ((pc->level == (br_open->level + 1)) && (pc->flags & PCF_VAR_DEF))
      {
         LOG_FMT(LMCB, " - vardef on line %lu: '%s'\n", pc->orig_line, pc->text());
         return(next);
      }
   }
   LOG_FMT(LMCB, " - removing braces on lines %lu and %lu\n",
           br_open->orig_line, br_close->orig_line);

   for (pc = br_open; pc != br_close; pc = chunk_get_next_ncnl(pc, CNAV_PREPROC))
   {
      pc->brace_level--;
      pc->level--;
   }
   next = chunk_get_prev(br_open, CNAV_PREPROC);
   chunk_del(br_open);
   chunk_del(br_close);
   return(chunk_get_next(next, CNAV_PREPROC));
} // mod_case_brace_remove
开发者ID:bengardner,项目名称:uncrustify,代码行数:56,代码来源:braces.cpp


示例11: split_before_chunk

/**
 * Split right after the chunk
 */
static void split_before_chunk(chunk_t *pc)
{
   LOG_FMT(LSPLIT, "%s: %s\n", __func__, pc->str.c_str());

   if (!chunk_is_newline(pc) &&
       !chunk_is_newline(chunk_get_prev(pc)))
   {
      newline_add_before(pc);
      reindent_line(pc, pc->brace_level * cpd.settings[UO_indent_columns].n);
      cpd.changes++;
   }
}
开发者ID:EvilOne,项目名称:uncrustify,代码行数:15,代码来源:width.cpp


示例12: align_left_shift

/**
 * Align '<<' (CT_ARITH?)
 */
static void align_left_shift(void)
{
   chunk_t    *pc;
   chunk_t    *start = NULL;
   AlignStack as;

   as.Start(2);

   pc = chunk_get_head();
   while (pc != NULL)
   {
      if (chunk_is_newline(pc))
      {
         as.NewLines(pc->nl_count);
      }
      else if ((start != NULL) && (pc->level < start->level))
      {
         /* A drop in level restarts the aligning */
         as.Flush();
         start = NULL;
      }
      else if ((start != NULL) && (pc->level > start->level))
      {
         /* Ignore any deeper levels when aligning */
      }
      else if (pc->type == CT_SEMICOLON)
      {
         /* A semicolon at the same level flushes */
         as.Flush();
         start = NULL;
      }
      else if (chunk_is_str(pc, "<<", 2))
      {
         if (as.m_aligned.Empty())
         {
            /* first one can be anywhere */
            as.Add(pc);
            start = pc;
         }
         else if (chunk_is_newline(chunk_get_prev(pc)))
         {
            /* subsequent ones must be after a newline */
            as.Add(pc);
         }
      }

      pc = chunk_get_next(pc);
   }
   as.End();
}
开发者ID:jscipione,项目名称:Paladin,代码行数:53,代码来源:align.cpp


示例13: split_before_chunk

/**
 * Split right after the chunk
 */
static void split_before_chunk(chunk_t *pc)
{
   LOG_FMT(LSPLIT, "%s: %s\n", __func__, pc->str.c_str());

   if (!chunk_is_newline(pc) &&
       !chunk_is_newline(chunk_get_prev(pc)))
   {
      newline_add_before(pc);
      // reindent needs to include the indent_continue value and was off by one
      reindent_line(pc, pc->brace_level * cpd.settings[UO_indent_columns].n +
                    abs(cpd.settings[UO_indent_continue].n) + 1);
      cpd.changes++;
   }
}
开发者ID:Limsik,项目名称:e17,代码行数:17,代码来源:width.cpp


示例14: align_add

/**
 * Adds an item to the align stack and adjust the nl_count and max_col.
 * Adjust max_col as needed
 *
 * @param pc         the item to add
 * @param max_col    pointer to the column variable
 * @param extra_pad  extra padding
 */
static void align_add(ChunkStack& cs, chunk_t *pc, int& max_col, int min_pad, bool squeeze)
{
   chunk_t *prev;
   int     min_col;

   prev = chunk_get_prev(pc);
   if ((prev == NULL) || chunk_is_newline(prev))
   {
      min_col = squeeze ? 1 : pc->column;
      LOG_FMT(LALADD, "%s: pc->col=%d max_col=%d min_pad=%d min_col=%d\n",
              __func__, pc->column, max_col, min_pad, min_col);
   }
   else
   {
      if (prev->type == CT_COMMENT_MULTI)
      {
         min_col = prev->orig_col_end + min_pad;
      }
      else
      {
         min_col = prev->column + prev->len + min_pad;
      }
      if (!squeeze)
      {
         if (min_col < pc->column)
         {
            min_col = pc->column;
         }
      }
      LOG_FMT(LALADD, "%s: pc->col=%d max_col=%d min_pad=%d min_col=%d multi:%s prev->col=%d prev->len=%d %s\n",
              __func__, pc->column, max_col, min_pad, min_col, (prev->type == CT_COMMENT_MULTI) ? "Y" : "N",
              (prev->type == CT_COMMENT_MULTI) ? prev->orig_col_end : prev->column, prev->len, get_token_name(prev->type));
   }

   if (cs.Empty())
   {
      max_col = 0;
   }

   cs.Push(pc);
   if (min_col > max_col)
   {
      max_col = min_col;
   }
}
开发者ID:jscipione,项目名称:Paladin,代码行数:53,代码来源:align.cpp


示例15: convert_brace

/**
 * Converts a single brace into a virtual brace
 */
static void convert_brace(chunk_t *br)
{
   chunk_t *tmp;

   if (br == NULL)
   {
      return;
   }
   else if (br->type == CT_BRACE_OPEN)
   {
      br->type = CT_VBRACE_OPEN;
      br->len  = 0;
      br->str  = "";
      tmp      = chunk_get_prev(br);
   }
   else if (br->type == CT_BRACE_CLOSE)
   {
      br->type = CT_VBRACE_CLOSE;
      br->len  = 0;
      br->str  = "";
      tmp      = chunk_get_next(br);
   }
   else
   {
      return;
   }

   if (chunk_is_newline(tmp))
   {
      if (tmp->nl_count > 1)
      {
         tmp->nl_count--;
      }
      else
      {
         if (chunk_safe_to_del_nl(tmp))
         {
            chunk_del(tmp);
         }
      }
   }
}
开发者ID:jscipione,项目名称:Paladin,代码行数:45,代码来源:braces.cpp


示例16: get_comment_align_type

static CmtAlignType get_comment_align_type(chunk_t *cmt)
{
   chunk_t      *prev;
   CmtAlignType cmt_type = CAT_REGULAR;

   if (!cpd.settings[UO_align_right_cmt_mix].b &&
       ((prev = chunk_get_prev(cmt)) != NULL))
   {
      if ((prev->type == CT_PP_ENDIF) ||
          (prev->type == CT_PP_ELSE) ||
          (prev->type == CT_ELSE) ||
          (prev->type == CT_BRACE_CLOSE))
      {
         /* REVISIT: someone may want this configurable */
         if ((cmt->column - (prev->column + prev->len)) < 3)
         {
            cmt_type = (prev->type == CT_PP_ENDIF) ? CAT_ENDIF : CAT_BRACE;
         }
      }
   }
   return(cmt_type);
}
开发者ID:jscipione,项目名称:Paladin,代码行数:22,代码来源:align.cpp


示例17: align_add

void align_add(ChunkStack &cs, chunk_t *pc, size_t &max_col)
{
   LOG_FUNC_ENTRY();

   size_t  min_col;
   chunk_t *prev = chunk_get_prev(pc);
   if (prev == nullptr || chunk_is_newline(prev))
   {
      min_col = 1;
      LOG_FMT(LALADD, "%s(%d): pc->orig_line=%zu, pc->col=%zu max_col=%zu min_col=%zu\n",
              __func__, __LINE__, pc->orig_line, pc->column, max_col, min_col);
   }
   else
   {
      if (chunk_is_token(prev, CT_COMMENT_MULTI))
      {
         min_col = prev->orig_col_end + 1;
      }
      else
      {
         min_col = prev->column + prev->len() + 1;
      }
      LOG_FMT(LALADD, "%s(%d): pc->orig_line=%zu, pc->col=%zu max_col=%zu min_col=%zu multi:%s prev->col=%zu prev->len()=%zu %s\n",
              __func__, __LINE__, pc->orig_line, pc->column, max_col, min_col, (chunk_is_token(prev, CT_COMMENT_MULTI)) ? "Y" : "N",
              (chunk_is_token(prev, CT_COMMENT_MULTI)) ? prev->orig_col_end : (UINT32)prev->column, prev->len(), get_token_name(prev->type));
   }

   if (cs.Empty())
   {
      max_col = 0;
   }

   cs.Push_Back(pc);
   if (min_col > max_col)
   {
      max_col = min_col;
   }
} // align_add
开发者ID:nivekkagicom,项目名称:uncrustify,代码行数:38,代码来源:align_add.cpp


示例18: try_split_here

/**
 * Checks to see if pc is a better spot to split.
 * This should only be called going BACKWARDS (ie prev)
 * A lower level wins
 *
 * Splitting Preference:
 *  - semicolon
 *  - comma
 *  - boolean op
 *  - comparison
 *  - arithmetic op
 *  - assignment
 */
static void try_split_here(cw_entry& ent, chunk_t *pc)
{
   chunk_t *prev;
   int     pc_pri = get_split_pri(pc->type);

   if (pc_pri == 0)
   {
      return;
   }

   /* Can't split after a newline */
   prev = chunk_get_prev(pc);
   if ((prev == NULL) || chunk_is_newline(prev))
   {
      return;
   }

   /* Check levels first */
   bool change = false;
   if ((ent.pc == NULL) || (pc->level < ent.pc->level))
   {
      change = true;
   }
   else
   {
      if ((pc->level > ent.pc->level) &&
          (pc_pri <= ent.pri))
      {
         change = true;
      }
   }

   if (change)
   {
      ent.pc  = pc;
      ent.pri = pc_pri;
   }
}
开发者ID:EvilOne,项目名称:uncrustify,代码行数:51,代码来源:width.cpp


示例19: split_template

static void split_template(chunk_t *start)
{
   LOG_FUNC_ENTRY();
   LOG_FMT(LSPLIT, "  %s(%d): start %s\n", __func__, __LINE__, start->text());
   LOG_FMT(LSPLIT, "  %s(%d): back up until the prev is a comma\n", __func__, __LINE__);

   // back up until the prev is a comma
   chunk_t *prev = start;
   while ((prev = chunk_get_prev(prev)) != nullptr)
   {
      LOG_FMT(LSPLIT, "  %s(%d): prev '%s'\n", __func__, __LINE__, prev->text());
      if (chunk_is_newline(prev) || prev->type == CT_COMMA)
      {
         break;
      }
   }

   if (prev != nullptr && !chunk_is_newline(prev))
   {
      LOG_FMT(LSPLIT, "  %s(%d):", __func__, __LINE__);
      LOG_FMT(LSPLIT, " -- ended on [%s] --\n", get_token_name(prev->type));
      chunk_t *pc = chunk_get_next(prev);
      newline_add_before(pc);
      size_t  min_col = 1;
      if (cpd.settings[UO_indent_continue].n == 0)
      {
         min_col += cpd.settings[UO_indent_columns].u;
      }
      else
      {
         min_col += abs(cpd.settings[UO_indent_continue].n);
      }
      reindent_line(pc, min_col);
      cpd.changes++;
   }
} // split_templatefcn_params
开发者ID:CDanU,项目名称:uncrustify,代码行数:36,代码来源:width.cpp



注:本文中的chunk_get_prev函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ chunk_is_comment函数代码示例发布时间:2022-05-30
下一篇:
C++ chunk_get_next_ncnl函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap