From 5b782ad5a1940fddd03bdab5028a1af2808bf385 Mon Sep 17 00:00:00 2001 From: Badlop Date: Mon, 28 Dec 2009 11:46:22 +0000 Subject: [PATCH] Support for arguments in ejabberdctl that are empty strings. SVN Revision: 2828 --- src/ejabberd_ctl.erl | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/ejabberd_ctl.erl b/src/ejabberd_ctl.erl index d8238bad7..0c19e5a62 100644 --- a/src/ejabberd_ctl.erl +++ b/src/ejabberd_ctl.erl @@ -318,18 +318,19 @@ format_args(Args, ArgsFormat) -> [], lists:zip(ArgsFormat, Args)). -format_arg(Arg, Format) -> - Parse = case Format of - integer -> - "~d"; - string -> - NumChars = integer_to_list(string:len(Arg)), - "~" ++ NumChars ++ "c" - end, +format_arg(Arg, integer) -> + format_arg2(Arg, "~d"); +format_arg("", string) -> + ""; +format_arg(Arg, string) -> + NumChars = integer_to_list(string:len(Arg)), + Parse = "~" ++ NumChars ++ "c", + format_arg2(Arg, Parse). + +format_arg2(Arg, Parse)-> {ok, [Arg2], _RemainingArguments} = io_lib:fread(Parse, Arg), Arg2. - %%----------------------------- %% Format result %%-----------------------------