Thread (25 messages) 25 messages, 6 authors, 2016-06-15

Re: [PATCH 3/3] git help: group common commands by theme

flat view

From: Eric Sunshine <hidden>
Date: 2016-06-15 23:04:42

On Fri, May 8, 2015 at 5:17 PM, Stefan Beller [off-list ref] wrote:
On Fri, May 8, 2015 at 2:08 PM, Sébastien Guimmara
[off-list ref] wrote:
quoted
On 05/06/2015 05:16 AM, Eric Sunshine wrote:
quoted
Do you also want to sort the commands alphabetically within group?
That is, something like this?

     struct cmdname_help *e1 = elem1;
     struct cmdname_help *e2 = elem2;

     if (e1->group < e2->group)
         return -1;
     if (e1->group > e2->group)
         return 1;
     return strcmp(e1->name, e2->name);
quoted
+}
Your version raises:

help.c:223:28: warning: initialization discards ‘const’ qualifier from
pointer target type [enabled by default]
  struct cmdname_help *e1 = elem1;
                            ^
With the cast:
struct cmdname_help *e1 = (struct cmdname_help*)elem1;
It compiles without a warning (gcc (Ubuntu 4.8.2-19ubuntu1) 4.8.2)
I'd rather change the type of struct cmdname_help to be const, such
that it reads:

      const struct cmdname_help *e1 = elem1;
      const struct cmdname_help *e2 = elem2;

      if (e1->group < e2->group)
          return -1;
      if (e1->group > e2->group)
          return 1;
      return strcmp(e1->name, e2->name);

instead of casting if possible.
Right. That was just a quickly typed example in the email. The "real"
code should use a 'const' pointer.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help