projects
/
yaz-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Update RPM requires
[yaz-moved-to-github.git]
/
src
/
nmemsdup.c
diff --git
a/src/nmemsdup.c
b/src/nmemsdup.c
index
75b6e85
..
f72936a
100644
(file)
--- a/
src/nmemsdup.c
+++ b/
src/nmemsdup.c
@@
-1,5
+1,5
@@
/* This file is part of the YAZ toolkit.
/* This file is part of the YAZ toolkit.
- * Copyright (C) 1995-2011 Index Data
+ * Copyright (C) Index Data
* See the file LICENSE for details.
*/
* See the file LICENSE for details.
*/
@@
-15,10
+15,10
@@
#include <string.h>
#include <yaz/nmem_xml.h>
#include <string.h>
#include <yaz/nmem_xml.h>
-char *nmem_strdup (NMEM mem, const char *src)
+char *nmem_strdup(NMEM mem, const char *src)
{
{
- char *dst = (char *)nmem_malloc (mem, strlen(src)+1);
- strcpy (dst, src);
+ char *dst = (char *) nmem_malloc(mem, strlen(src)+1);
+ strcpy(dst, src);
return dst;
}
return dst;
}
@@
-30,24
+30,24
@@
char *nmem_strdup_null(NMEM mem, const char *src)
return nmem_strdup(mem, src);
}
return nmem_strdup(mem, src);
}
-char *nmem_strdupn (NMEM mem, const char *src, size_t n)
+char *nmem_strdupn(NMEM mem, const char *src, size_t n)
{
{
- char *dst = (char *)nmem_malloc (mem, n+1);
- memcpy (dst, src, n);
+ char *dst = (char *) nmem_malloc(mem, n+1);
+ memcpy(dst, src, n);
dst[n] = '\0';
return dst;
}
nmem_int_t *nmem_intdup(NMEM mem, nmem_int_t v)
{
dst[n] = '\0';
return dst;
}
nmem_int_t *nmem_intdup(NMEM mem, nmem_int_t v)
{
- nmem_int_t *dst = (nmem_int_t*) nmem_malloc (mem, sizeof(*dst));
+ nmem_int_t *dst = (nmem_int_t*) nmem_malloc(mem, sizeof(*dst));
*dst = v;
return dst;
}
nmem_bool_t *nmem_booldup(NMEM mem, nmem_bool_t v)
{
*dst = v;
return dst;
}
nmem_bool_t *nmem_booldup(NMEM mem, nmem_bool_t v)
{
- nmem_bool_t *dst = (nmem_bool_t*) nmem_malloc (mem, sizeof(*dst));
+ nmem_bool_t *dst = (nmem_bool_t*) nmem_malloc(mem, sizeof(*dst));
*dst = v;
return dst;
}
*dst = v;
return dst;
}
@@
-74,6
+74,14
@@
void nmem_strsplit_escape(NMEM nmem, const char *delim, const char *dstr,
char ***darray, int *num, int collapse,
int escape_char)
{
char ***darray, int *num, int collapse,
int escape_char)
{
+ nmem_strsplit_escape2(nmem, delim, dstr, darray, num, collapse,
+ escape_char, 1);
+}
+
+void nmem_strsplit_escape2(NMEM nmem, const char *delim, const char *dstr,
+ char ***darray, int *num, int collapse,
+ int escape_char, int subst_escape)
+{
*darray = 0;
/* two passes over the input string.. */
while (1)
*darray = 0;
/* two passes over the input string.. */
while (1)
@@
-102,16
+110,19
@@
void nmem_strsplit_escape(NMEM nmem, const char *delim, const char *dstr,
}
if (*darray)
{
}
if (*darray)
{
- char *dst, *src;
(*darray)[i] = nmem_strdupn(nmem, cp0, cp - cp0);
(*darray)[i] = nmem_strdupn(nmem, cp0, cp - cp0);
- dst = src = (*darray)[i];
- while (*src != '\0')
+ if (subst_escape)
{
{
- if (*src == escape_char && src[1])
- src++;
- *dst++ = *src++;
+ char *dst = (*darray)[i];
+ const char *src = dst;
+ while (*src != '\0')
+ {
+ if (*src == escape_char && src[1])
+ src++;
+ *dst++ = *src++;
+ }
+ *dst = '\0';
}
}
- *dst = '\0';
}
i++;
if (!collapse)
}
i++;
if (!collapse)