ejabberd - Comments for "ejabberdctl srg_create with optional name, description and display arguments" https://www.ejabberd.im/node/3791 en Committed https://www.ejabberd.im/node/3791#comment-55083 <div class="quote-msg"> <div class="quote-author">Quote:</div> <p>This patch solves it, please verify before I commit them</p></div> <p>I've committed the patch to SVN.</p> Mon, 28 Dec 2009 11:48:36 +0000 mfoss comment 55083 at https://www.ejabberd.im Patch committed https://www.ejabberd.im/node/3791#comment-55082 <div class="quote-msg"> <div class="quote-author">Quote:</div> <p>If you don't find any problem with that patch, it will be applied to ejabberd.</p></div> <p>I've committed the patch to ejabberd SVN 2.1.x branch and trunk.</p> Mon, 28 Dec 2009 11:47:00 +0000 mfoss comment 55082 at https://www.ejabberd.im In Erlang, "" is another way https://www.ejabberd.im/node/3791#comment-55043 <p>In Erlang, "" is another way to represent the same that []. So that isn't a problem.</p> <p>The real problem is [[]]. This patch solves it, please verify before I commit them:</p> <pre>--- src/mod_admin_extra.erl (revisiĆ³n: 1041) +++ src/mod_admin_extra.erl (copia de trabajo) @@ -1017,7 +1017,10 @@ %%% srg_create(Group, Host, Name, Description, Display) -&gt; - {ok, DisplayList} = regexp:split(Display, "\\\\n"), + {ok, DisplayList} = case Display of + [] -&gt; {ok, []}; + _ -&gt; regexp:split(Display, "\\\\n") + end, Opts = [{name, Name}, {displayed_groups, DisplayList}, {description, Description}], </pre> Fri, 18 Dec 2009 12:32:21 +0000 mfoss comment 55043 at https://www.ejabberd.im My apologies. The patch https://www.ejabberd.im/node/3791#comment-55038 <p>My apologies. The patch actually doesn't do what is required. It seems to create empty lists. The below output should make this clear:</p> <p>$ ejabberdctl srg_create group1 example.net "" "" ""<br /> $ ejabberdctl srg_get_info group1 example.net<br /> name []<br /> displayed_groups [[]]<br /> description []</p> <p>where as the expected output should be:<br /> $ ejabberdctl srg_get_info group1 example.net<br /> name ""<br /> displayed_groups []<br /> description ""</p> <p>I think this is only a minor problem. Could it be fixed?</p> Wed, 16 Dec 2009 11:18:35 +0000 amaramrahul comment 55038 at https://www.ejabberd.im Though the patch did not https://www.ejabberd.im/node/3791#comment-55028 <p>Though the patch did not apply perfectly, the code seems to be working flawlessly. Also I have observed that trailing backslashes should not be used to leave the fields empty. So the correct commands would be:</p> <p>$ ejabberdctl srg_create noname localhost "" mydesc mydisp<br /> $ ejabberdctl srg_create nodisplay localhost myname mydesc ""</p> <p>Using single quotes as below also worked:</p> <p>$ ejabberdctl srg_create noname localhost '' mydesc mydisp<br /> $ ejabberdctl srg_create nodisplay localhost myname mydesc ''</p> Tue, 15 Dec 2009 06:19:01 +0000 amaramrahul comment 55028 at https://www.ejabberd.im Try to apply this patch to https://www.ejabberd.im/node/3791#comment-55024 <p>Try to apply this patch to ejabberd:</p> <pre> --- src/ejabberd_ctl.erl +++ src/ejabberd_ctl.erl @@ -318,18 +318,19 @@ format_args(Args, ArgsFormat) -&gt; [], lists:zip(ArgsFormat, Args)). -format_arg(Arg, Format) -&gt; - Parse = case Format of - integer -&gt; - "~d"; - string -&gt; - NumChars = integer_to_list(string:len(Arg)), - "~" ++ NumChars ++ "c" - end, +format_arg(Arg, integer) -&gt; + format_arg2(Arg, "~d"); +format_arg("", string) -&gt; + ""; +format_arg(Arg, string) -&gt; + NumChars = integer_to_list(string:len(Arg)), + Parse = "~" ++ NumChars ++ "c", + format_arg2(Arg, Parse). + +format_arg2(Arg, Parse)-&gt; {ok, [Arg2], _RemainingArguments} = io_lib:fread(Parse, Arg), Arg2. - %%----------------------------- %% Format result %%----------------------------- </pre><p> Now you can do things like:</p> <pre> $ ejabberdctl srg_create noname localhost \"\" mydesc mydisp $ ejabberdctl srg_create nodisplay localhost myname mydesc \"\" </pre><p> If you don't find any problem with that patch, it will be applied to ejabberd.</p> Mon, 14 Dec 2009 18:17:53 +0000 mfoss comment 55024 at https://www.ejabberd.im