+2009-12-09 Bruno Haible <bruno@clisp.org>
+
+ * lib/mgetgroups.c (mgetgroups): Don't remove duplicates if there is at
+ most one group.
+
2009-12-09 Simon Josefsson <simon@josefsson.org>
Bruno Haible <bruno@clisp.org>
duplicate removal via an O(n) hash-table. Hence, this function
is only documented as guaranteeing no pair-wise duplicates,
rather than returning the minimal set. */
- {
- gid_t first = *g;
- gid_t *next;
- gid_t *sentinel = g + ng;
-
- for (next = g + 1; next < sentinel; next++)
- {
- if (*next == first || *next == *g)
- ng--;
- else
- *++g = *next;
- }
- }
+ if (1 < ng)
+ {
+ gid_t first = *g;
+ gid_t *next;
+ gid_t *groups_end = g + ng;
+
+ for (next = g + 1; next < groups_end; next++)
+ {
+ if (*next == first || *next == *g)
+ ng--;
+ else
+ *++g = *next;
+ }
+ }
return ng;
}