Logo Search packages:      
Sourcecode: uncrustify version File versions

void space_text ( void   ) 

Marches through the whole file and checks to see how many spaces should be between two chunks

Definition at line 679 of file space.cpp.

References AV_FORCE, chunk_t::column, do_space(), chunk_t::len, chunk_t::nl_count, chunk_t::orig_col, chunk_t::orig_col_end, and chunk_t::type.

Referenced by uncrustify_file().

{
   chunk_t *pc;
   chunk_t *next;
   int     column = 1;
   int     delta;

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

      /* If the current chunk contains a newline, do not change the column
       * of the next item */
      if ((pc->type == CT_NEWLINE) ||
          (pc->type == CT_NL_CONT) ||
          (pc->type == CT_COMMENT_MULTI))
      {
         column = next->column;
      }
      else
      {
         /* Set to the minimum allowed column */
         if (pc->nl_count == 0)
         {
            column += pc->len;
         }
         else
         {
            column = pc->orig_col_end;
         }

         switch (do_space(pc, next))
         {
         case AV_FORCE:
            /* add exactly one space */
            column++;
            break;

         case AV_ADD:
            delta = 1;
            if ((next->orig_col >= pc->orig_col_end) && (pc->orig_col_end != 0))
            {
               /* Keep the same relative spacing, minimum 1 */
               delta = next->orig_col - pc->orig_col_end;
               if (delta < 1)
               {
                  delta = 1;
               }
            }
            column += delta;
            break;

         case AV_REMOVE:
            /* the symbols will be back-to-back "a+3" */
            break;

         default:
            /* Keep the same relative spacing, if possible */
            if ((next->orig_col >= pc->orig_col_end) && (pc->orig_col_end != 0))
            {
               column += next->orig_col - pc->orig_col_end;
            }
            break;
         }
         next->column = column;
      }

      pc = next;
   }
}


Generated by  Doxygen 1.6.0   Back to index