updated for version 7.4.279
Problem: globpath() returns a string, making it difficult to get a list of
matches. (Greg Novack)
Solution: Add an optional argument like with glob(). (Adnan Zafar)
diff --git a/src/misc2.c b/src/misc2.c
index a20337f..b0673d4 100644
--- a/src/misc2.c
+++ b/src/misc2.c
@@ -2087,29 +2087,37 @@
/*
* For a growing array that contains a list of strings: concatenate all the
- * strings with a separating comma.
+ * strings with a separating "sep".
* Returns NULL when out of memory.
*/
char_u *
-ga_concat_strings(gap)
+ga_concat_strings(gap, sep)
garray_T *gap;
+ char *sep;
{
int i;
int len = 0;
+ int sep_len = (int)STRLEN(sep);
char_u *s;
+ char_u *p;
for (i = 0; i < gap->ga_len; ++i)
- len += (int)STRLEN(((char_u **)(gap->ga_data))[i]) + 1;
+ len += (int)STRLEN(((char_u **)(gap->ga_data))[i]) + sep_len;
s = alloc(len + 1);
if (s != NULL)
{
*s = NUL;
+ p = s;
for (i = 0; i < gap->ga_len; ++i)
{
- if (*s != NUL)
- STRCAT(s, ",");
- STRCAT(s, ((char_u **)(gap->ga_data))[i]);
+ if (p != s)
+ {
+ STRCPY(p, sep);
+ p += sep_len;
+ }
+ STRCPY(p, ((char_u **)(gap->ga_data))[i]);
+ p += STRLEN(p);
}
}
return s;