in tools/diff/diff.c [66:164]
int main(int argc, const char *argv[])
{
apr_pool_t *pool;
svn_stream_t *ostream;
svn_error_t *svn_err;
svn_boolean_t has_changes;
svn_diff_file_options_t *diff_options;
apr_array_header_t *options_array;
int i;
const char *from = NULL;
const char *to = NULL;
svn_boolean_t show_c_function = FALSE;
svn_boolean_t no_more_options = FALSE;
apr_initialize();
atexit(apr_terminate);
pool = svn_pool_create(NULL);
svn_err = svn_stream_for_stdout(&ostream, pool);
if (svn_err)
{
svn_handle_error2(svn_err, stdout, FALSE, "diff: ");
return 2;
}
options_array = apr_array_make(pool, 0, sizeof(const char *));
diff_options = svn_diff_file_options_create(pool);
for (i = 1 ; i < argc ; i++)
{
if (!no_more_options && (argv[i][0] == '-'))
{
/* Special case: '--' means "no more options follow" */
if (argv[i][1] == '-' && !argv[i][2])
{
no_more_options = TRUE;
continue;
}
/* Special case: we need to detect '-p' and handle it specially */
if (argv[i][1] == 'p' && !argv[i][2])
{
show_c_function = TRUE;
continue;
}
if (argv[i][1] == 'w' && !argv[i][2])
{
diff_options->ignore_space = svn_diff_file_ignore_space_all;
continue;
}
APR_ARRAY_PUSH(options_array, const char *) = argv[i];
/* Special case: '-U' takes an argument, so capture the
* next argument in the array. */
if (argv[i][1] == 'U' && !argv[i][2])
{
i++;
APR_ARRAY_PUSH(options_array, const char *) = argv[i];
}
}
else
{
if (from == NULL)
from = argv[i];
else if (to == NULL)
to = argv[i];
else
{
print_usage(ostream, argv[0], pool);
return 2;
}
}
}
if (!from || !to)
{
print_usage(ostream, argv[0], pool);
return 2;
}
svn_err = svn_diff_file_options_parse(diff_options, options_array, pool);
if (svn_err)
{
svn_handle_error2(svn_err, stdout, FALSE, "diff: ");
return 2;
}
svn_err = do_diff(ostream, from, to, &has_changes,
diff_options, show_c_function, pool);
if (svn_err)
{
svn_handle_error2(svn_err, stdout, FALSE, "diff: ");
return 2;
}
return has_changes ? 1 : 0;
}