📄 main.c
字号:
char *end; opt_state.limit = strtol(opt_arg, &end, 10); if (end == opt_arg || *end != '\0') { err = svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL, _("Non-numeric limit argument given")); return svn_cmdline_handle_exit_error(err, pool, "svn: "); } if (opt_state.limit <= 0) { err = svn_error_create(SVN_ERR_INCORRECT_PARAMS, NULL, _("Argument to --limit must be positive")); return svn_cmdline_handle_exit_error(err, pool, "svn: "); } } break; case 'm': /* Note that there's no way here to detect if the log message contains a zero byte -- if it does, then opt_arg will just be shorter than the user intended. Oh well. */ opt_state.message = apr_pstrdup(pool, opt_arg); dash_m_arg = opt_arg; break; case 'c': { char *end; svn_revnum_t changeno; if (opt_state.start_revision.kind != svn_opt_revision_unspecified) { err = svn_error_create (SVN_ERR_CL_ARG_PARSING_ERROR, NULL, _("Multiple revision arguments encountered; " "can't specify -c twice, or both -c and -r")); return svn_cmdline_handle_exit_error(err, pool, "svn: "); } if (opt_state.old_target) { err = svn_error_create (SVN_ERR_CL_ARG_PARSING_ERROR, NULL, _("Can't specify -c with --old")); return svn_cmdline_handle_exit_error(err, pool, "svn: "); } changeno = strtol(opt_arg, &end, 10); if (end == opt_arg || *end != '\0') { err = svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL, _("Non-numeric change argument given to -c")); return svn_cmdline_handle_exit_error(err, pool, "svn: "); } if (changeno == 0) { err = svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL, _("There is no change 0")); return svn_cmdline_handle_exit_error(err, pool, "svn: "); } /* Figure out the range: -c N -> -r N-1:N -c -N -> -r N:N-1 */ if (changeno > 0) { opt_state.start_revision.value.number = changeno - 1; opt_state.end_revision.value.number = changeno; } else { changeno = -changeno; opt_state.start_revision.value.number = changeno; opt_state.end_revision.value.number = changeno - 1; } opt_state.start_revision.kind = svn_opt_revision_number; opt_state.end_revision.kind = svn_opt_revision_number; used_change_arg = TRUE; } break; case 'r': if (opt_state.start_revision.kind != svn_opt_revision_unspecified) { err = svn_error_create (SVN_ERR_CL_ARG_PARSING_ERROR, NULL, _("Multiple revision arguments encountered; " "can't specify -r and -c, or " "try '-r N:M' instead of '-r N -r M'")); return svn_cmdline_handle_exit_error(err, pool, "svn: "); } if (svn_opt_parse_revision(&(opt_state.start_revision), &(opt_state.end_revision), opt_arg, pool) != 0) { err = svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool); if (! err) err = svn_error_createf (SVN_ERR_CL_ARG_PARSING_ERROR, NULL, _("Syntax error in revision argument '%s'"), utf8_opt_arg); return svn_cmdline_handle_exit_error(err, pool, "svn: "); } break; case 'v': opt_state.verbose = TRUE; break; case 'u': opt_state.update = TRUE; break; case 'h': case '?': opt_state.help = TRUE; break; case 'q': opt_state.quiet = TRUE; break; case svn_cl__incremental_opt: opt_state.incremental = TRUE; break; case 'F': err = svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool); if (! err) err = svn_stringbuf_from_file(&(opt_state.filedata), utf8_opt_arg, pool); if (err) return svn_cmdline_handle_exit_error(err, pool, "svn: "); dash_F_arg = opt_arg; break; case svn_cl__targets_opt: { svn_stringbuf_t *buffer, *buffer_utf8; /* We need to convert to UTF-8 now, even before we divide the targets into an array, because otherwise we wouldn't know what delimiter to use for svn_cstring_split(). */ err = svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool); if (! err) err = svn_stringbuf_from_file(&buffer, utf8_opt_arg, pool); if (! err) err = svn_utf_stringbuf_to_utf8(&buffer_utf8, buffer, pool); if (err) return svn_cmdline_handle_exit_error(err, pool, "svn: "); opt_state.targets = svn_cstring_split(buffer_utf8->data, "\n\r", TRUE, pool); } break; case svn_cl__force_opt: opt_state.force = TRUE; break; case svn_cl__force_log_opt: opt_state.force_log = TRUE; break; case svn_cl__dry_run_opt: opt_state.dry_run = TRUE; break; case svn_cl__revprop_opt: opt_state.revprop = TRUE; break; case 'R': opt_state.recursive = TRUE; break; case 'N': opt_state.nonrecursive = TRUE; break; case svn_cl__version_opt: opt_state.version = TRUE; break; case svn_cl__auth_username_opt: err = svn_utf_cstring_to_utf8(&opt_state.auth_username, opt_arg, pool); if (err) return svn_cmdline_handle_exit_error(err, pool, "svn: "); break; case svn_cl__auth_password_opt: err = svn_utf_cstring_to_utf8(&opt_state.auth_password, opt_arg, pool); if (err) return svn_cmdline_handle_exit_error(err, pool, "svn: "); break; case svn_cl__encoding_opt: opt_state.encoding = apr_pstrdup(pool, opt_arg); break; case svn_cl__xml_opt: opt_state.xml = TRUE; break; case svn_cl__stop_on_copy_opt: opt_state.stop_on_copy = TRUE; break; case svn_cl__strict_opt: opt_state.strict = TRUE; break; case svn_cl__no_ignore_opt: opt_state.no_ignore = TRUE; break; case svn_cl__no_auth_cache_opt: opt_state.no_auth_cache = TRUE; break; case svn_cl__non_interactive_opt: opt_state.non_interactive = TRUE; break; case svn_cl__no_diff_deleted: opt_state.no_diff_deleted = TRUE; break; case svn_cl__notice_ancestry_opt: opt_state.notice_ancestry = TRUE; break; case svn_cl__ignore_ancestry_opt: opt_state.ignore_ancestry = TRUE; break; case svn_cl__ignore_externals_opt: opt_state.ignore_externals = TRUE; break; case svn_cl__relocate_opt: opt_state.relocate = TRUE; break; case 'x': err = svn_utf_cstring_to_utf8(&opt_state.extensions, opt_arg, pool); if (err) return svn_cmdline_handle_exit_error(err, pool, "svn: "); break; case svn_cl__diff_cmd_opt: opt_state.diff_cmd = apr_pstrdup(pool, opt_arg); break; case svn_cl__merge_cmd_opt: opt_state.merge_cmd = apr_pstrdup(pool, opt_arg); break; case svn_cl__editor_cmd_opt: opt_state.editor_cmd = apr_pstrdup(pool, opt_arg); break; case svn_cl__old_cmd_opt: if (used_change_arg) { err = svn_error_create (SVN_ERR_CL_ARG_PARSING_ERROR, NULL, _("Can't specify -c with --old")); return svn_cmdline_handle_exit_error(err, pool, "svn: "); } opt_state.old_target = apr_pstrdup(pool, opt_arg); break; case svn_cl__new_cmd_opt: opt_state.new_target = apr_pstrdup(pool, opt_arg); break; case svn_cl__config_dir_opt: err = svn_utf_cstring_to_utf8(&path_utf8, opt_arg, pool); opt_state.config_dir = svn_path_canonicalize(path_utf8, pool); break; case svn_cl__autoprops_opt: if (opt_state.no_autoprops) { err = svn_error_create(SVN_ERR_CL_MUTUALLY_EXCLUSIVE_ARGS, NULL, _("--auto-props and --no-auto-props are " "mutually exclusive")); return svn_cmdline_handle_exit_error(err, pool, "svn: "); } opt_state.autoprops = TRUE; break; case svn_cl__no_autoprops_opt: if (opt_state.autoprops) { err = svn_error_create(SVN_ERR_CL_MUTUALLY_EXCLUSIVE_ARGS, NULL, _("--auto-props and --no-auto-props are " "mutually exclusive")); return svn_cmdline_handle_exit_error(err, pool, "svn: "); } opt_state.no_autoprops = TRUE; break; case svn_cl__native_eol_opt: if ( !strcmp("LF", opt_arg) || !strcmp("CR", opt_arg) || !strcmp("CRLF", opt_arg)) opt_state.native_eol = apr_pstrdup(pool, opt_arg); else { err = svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool); if (! err) err = svn_error_createf (SVN_ERR_CL_ARG_PARSING_ERROR, NULL, _("Syntax error in native-eol argument '%s'"), utf8_opt_arg); svn_handle_error2(err, stderr, FALSE, "svn: "); svn_error_clear(err); svn_pool_destroy(pool); return EXIT_FAILURE; } break; case svn_cl__no_unlock_opt: opt_state.no_unlock = TRUE; break; case svn_cl__summarize: opt_state.summarize = TRUE; break; default: /* Hmmm. Perhaps this would be a good place to squirrel away opts that commands like svn diff might need. Hmmm indeed. */ break; } } /* ### This really belongs in libsvn_client. The trouble is, there's no one place there to run it from, no svn_client_init(). We'd have to add it to all the public functions that a client might call. It's unmaintainable to do initialization from within libsvn_client itself, but it seems burdensome to demand that all clients call svn_client_init() before calling any other libsvn_client function... On the other hand, the alternative is effectively to demand that they call svn_config_ensure() instead, so maybe we should have a generic init function anyway. Thoughts? */ err = svn_config_ensure(opt_state.config_dir, pool);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -