Logo Search packages:      
Sourcecode: uncrustify version File versions

int pf_check ( struct parse_frame *  frm,
chunk_t pc 
)

Returns the pp_indent to use for this line

Definition at line 149 of file parse_frame.cpp.

References chunk_t::flags, chunk_t::orig_line, pf_copy_tos(), pf_log(), pf_log_all(), pf_pop(), pf_push(), pf_push_under(), pf_trash_tos(), and chunk_t::type.

Referenced by indent_text(), and preproc_start().

{
   int        in_ifdef = frm->in_ifdef;
   int        b4_cnt   = cpd.frame_count;
   int        pp_level = cpd.pp_level;
   const char *txt     = NULL;

   if ((pc->flags & PCF_IN_PREPROC) != 0)
   {
      LOG_FMT(LPF, " <In> ");
      pf_log(LPF, frm);

      if (pc->type == CT_PP_IF)
      {
         cpd.pp_level++;
         pf_push(frm);
         frm->in_ifdef = CT_PP_IF;
         txt           = "if-push";
      }
      else if (pc->type == CT_PP_ELSE)
      {
         pp_level--;
         if (frm->in_ifdef == CT_PP_IF)
         {
            /* need to switch */
            pf_push_under(frm);
            pf_copy_tos(frm);
            frm->in_ifdef = CT_PP_ELSE;
            txt           = "else-push_under";
         }
         else if (frm->in_ifdef == CT_PP_ELSE)
         {
            pf_copy_tos(frm);
            frm->in_ifdef = CT_PP_ELSE;
            txt           = "else-copy";
         }
         else
         {
            txt = "???";
         }
      }
      else if (pc->type == CT_PP_ENDIF)
      {
         cpd.pp_level--;
         pp_level--;

         if (frm->in_ifdef == CT_PP_ELSE)
         {
            pf_trash_tos();
            pf_pop(frm);
            txt = "endif-trash/pop";
         }
         else if (frm->in_ifdef == CT_PP_IF)
         {
            pf_pop(frm);
            txt = "endif-pop";
         }
         else
         {
            txt = "???";
         }
      }
   }

   if (txt != NULL)
   {
      LOG_FMT(LPF, "%s: %d> %s: %s in_ifdef=%d/%d counts=%d/%d\n", __func__,
              pc->orig_line, get_token_name(pc->type), txt,
              in_ifdef, frm->in_ifdef, b4_cnt, cpd.frame_count);
      pf_log_all(LPF);
      LOG_FMT(LPF, " <Out>");
      pf_log(LPF, frm);
   }

   return(pp_level);
}


Generated by  Doxygen 1.6.0   Back to index