예제 #1
0
파일: side.c 프로젝트: NaiyanXu/gitroot
static void
print_1sdiff_line (char const *const *left, char sep,
                   char const *const *right)
{
    FILE *out = outfile;
    size_t hw = sdiff_half_width;
    size_t c2o = sdiff_column2_offset;
    size_t col = 0;
    bool put_newline = false;
    bool color_to_reset = false;

    if (sep == '<')
    {
        set_color_context (DELETE_CONTEXT);
        color_to_reset = true;
    }
    else if (sep == '>')
    {
        set_color_context (ADD_CONTEXT);
        color_to_reset = true;
    }

    if (left)
    {
        put_newline |= left[1][-1] == '\n';
        col = print_half_line (left, 0, hw);
    }

    if (sep != ' ')
    {
        col = tab_from_to (col, (hw + c2o - 1) / 2) + 1;
        if (sep == '|' && put_newline != (right[1][-1] == '\n'))
            sep = put_newline ? '/' : '\\';
        putc (sep, out);
    }

    if (right)
    {
        put_newline |= right[1][-1] == '\n';
        if (**right != '\n')
        {
            col = tab_from_to (col, c2o);
            print_half_line (right, col, hw);
        }
    }

    if (put_newline)
        putc ('\n', out);

    if (color_to_reset)
        set_color_context (RESET_CONTEXT);
}
예제 #2
0
파일: side.c 프로젝트: Rekoz/CS35L
static void
print_1sdiff_line (char const *const *left, char sep,
		   char const *const *right)
{
  FILE *out = outfile;
  size_t hw = sdiff_half_width;
  size_t c2o = sdiff_column2_offset;
  size_t col = 0;
  bool put_newline = false;

  if (left)
    {
      put_newline |= left[1][-1] == '\n';
      col = print_half_line (left, 0, hw);
    }

  if (sep != ' ')
    {
      col = tab_from_to (col, (hw + c2o - 1) / 2) + 1;
      if (sep == '|' && put_newline != (right[1][-1] == '\n'))
	sep = put_newline ? '/' : '\\';
      putc (sep, out);
    }

  if (right)
    {
      put_newline |= right[1][-1] == '\n';
      if (**right != '\n')
	{
	  col = tab_from_to (col, c2o);
	  print_half_line (right, col, hw);
	}
    }

  if (put_newline)
    putc ('\n', out);
}