From: <kt...@us...> - 2011-01-24 12:30:07
|
Revision: 3841 http://cutter.svn.sourceforge.net/cutter/?rev=3841&view=rev Author: ktou Date: 2011-01-24 12:30:00 +0000 (Mon, 24 Jan 2011) Log Message: ----------- * cutter/cut-diff.c, doc/cut-diff.rd*: add --label option. Modified Paths: -------------- cutter/trunk/ChangeLog cutter/trunk/cutter/cut-diff.c cutter/trunk/doc/cut-diff.rd cutter/trunk/doc/cut-diff.rd.ja Modified: cutter/trunk/ChangeLog =================================================================== --- cutter/trunk/ChangeLog 2011-01-19 14:33:58 UTC (rev 3840) +++ cutter/trunk/ChangeLog 2011-01-24 12:30:00 UTC (rev 3841) @@ -1,3 +1,7 @@ +2011-01-24 Kouhei Sutou <ko...@co...> + + * cutter/cut-diff.c, doc/cut-diff.rd*: add --label option. + 2011-01-19 Kouhei Sutou <ko...@co...> * misc/rd2refentry-lib.rb: add '[' and ',' to separator list. Modified: cutter/trunk/cutter/cut-diff.c =================================================================== --- cutter/trunk/cutter/cut-diff.c 2011-01-19 14:33:58 UTC (rev 3840) +++ cutter/trunk/cutter/cut-diff.c 2011-01-24 12:30:00 UTC (rev 3841) @@ -1,6 +1,6 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* - * Copyright (C) 2009-2010 Kouhei Sutou <ko...@cl...> + * Copyright (C) 2009-2011 Kouhei Sutou <ko...@cl...> * * This library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -33,6 +33,7 @@ static gboolean use_color = FALSE; static gboolean unified_diff = FALSE; static gint context_lines = -1; +static gchar **labels = NULL; static gboolean print_version (const gchar *option_name, const gchar *value, @@ -62,6 +63,8 @@ N_("Use unified diff format"), NULL}, {"context-lines", '\0', 0, G_OPTION_ARG_INT, &context_lines, N_("Use LINES as diff context lines"), "LINES"}, + {"label", 'L', 0, G_OPTION_ARG_STRING_ARRAY, &labels, + N_("Use LABEL as label"), "LABEL"}, {NULL} }; @@ -75,11 +78,12 @@ } static void -print_diff_header (CutDiffWriter *writer, const gchar *from, const gchar *to) +print_diff_header (CutDiffWriter *writer, + const gchar *from_label, const gchar *to_label) { - cut_diff_writer_mark_line(writer, "---", " ", from, + cut_diff_writer_mark_line(writer, "---", " ", from_label, CUT_DIFF_WRITER_TAG_DELETED_MARK); - cut_diff_writer_mark_line(writer, "+++", " ", to, + cut_diff_writer_mark_line(writer, "+++", " ", to_label, CUT_DIFF_WRITER_TAG_INSERTED_MARK); } @@ -90,6 +94,8 @@ gchar *from_contents, *to_contents; CutDiffer *differ; CutDiffWriter *writer; + const gchar *from_label = from; + const gchar *to_label = to; if (!g_file_get_contents(from, &from_contents, NULL, &error)) { g_print("%s\n", error->message); @@ -104,18 +110,25 @@ return FALSE; } + if (labels[0]) { + from_label = labels[0]; + if (labels[1]) { + to_label = labels[1]; + } + } + writer = cut_console_diff_writer_new(use_color); if (unified_diff) { differ = cut_unified_differ_new(from_contents, to_contents); - cut_unified_differ_set_from_label(differ, from); - cut_unified_differ_set_to_label(differ, to); + cut_unified_differ_set_from_label(differ, from_label); + cut_unified_differ_set_to_label(differ, to_label); } else { if (use_color) { differ = cut_colorize_differ_new(from_contents, to_contents); } else { differ = cut_readable_differ_new(from_contents, to_contents); } - print_diff_header(writer, from, to); + print_diff_header(writer, from_label, to_label); } if (context_lines > 0) cut_differ_set_context_size(differ, context_lines); Modified: cutter/trunk/doc/cut-diff.rd =================================================================== --- cutter/trunk/doc/cut-diff.rd 2011-01-19 14:33:58 UTC (rev 3840) +++ cutter/trunk/doc/cut-diff.rd 2011-01-24 12:30:00 UTC (rev 3841) @@ -43,6 +43,15 @@ All lines are shown by default. When unified diff format is used, 3 lines are shown by default. +: --label=LABEL, -L=LABEL + + Uses (({LABEL})) as a header label. The first + ((*--label*)) option value is used as ((*file1*))'s label + and the second ((*--label*)) option value is used as + ((*file2*))'s label. + + Labels are the same as file names by default. + == EXIT STATUS The exit status is 0 for success, non-0 otherwise. Modified: cutter/trunk/doc/cut-diff.rd.ja =================================================================== --- cutter/trunk/doc/cut-diff.rd.ja 2011-01-19 14:33:58 UTC (rev 3840) +++ cutter/trunk/doc/cut-diff.rd.ja 2011-01-24 12:30:00 UTC (rev 3841) @@ -42,6 +42,15 @@ デフォルトでは全部の行を表示します。unified diff形式の場 合は3行です。 +: --label=LABEL, -L=LABEL + + ヘッダのラベルに(({LABEL}))を使います。1つめの + ((*--label*))オプションで指定した値は((*file1*))のラベル + になり、2つめの((*--label*))オプションで指定した値は + ((*file2*))のラベルになります。 + + デフォルトではファイル名を使います。 + == 終了ステータス エラーが発生した場合は0以外、そうでない場合は0を返します。 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |