argument is modified in place. Its size is specified by the
namesize argument. The need_escape argument is a string of
characters that require that name be escaped. */
argument is modified in place. Its size is specified by the
namesize argument. The need_escape argument is a string of
characters that require that name be escaped. */
escape_component (char *name, size_t namesize, char *chars_to_escape) {
/* If name contains any chars_to_escape:
1) enclose it in ""
escape_component (char *name, size_t namesize, char *chars_to_escape) {
/* If name contains any chars_to_escape:
1) enclose it in ""
if (strpbrk(name, chars_to_escape)) {
char *destp, *srcp;
/* Maximum space requirement would be if each character had
if (strpbrk(name, chars_to_escape)) {
char *destp, *srcp;
/* Maximum space requirement would be if each character had
E.g., 2 characters, "", would require 7, "\"\""0, where that 0
is '\0'. */
char *tmp = mh_xmalloc (2*strlen(name) + 3);
E.g., 2 characters, "", would require 7, "\"\""0, where that 0
is '\0'. */
char *tmp = mh_xmalloc (2*strlen(name) + 3);
if (strcmp (tmp, "\"")) {
size_t len = destp - tmp;
assert ((ssize_t) strlen(tmp) + 1 == destp - tmp);
if (strcmp (tmp, "\"")) {
size_t len = destp - tmp;
assert ((ssize_t) strlen(tmp) + 1 == destp - tmp);
} else {
/* Handle just " as special case here instead of above. */
strncpy (name, "\"\\\"\"", namesize);
} else {
/* Handle just " as special case here instead of above. */
strncpy (name, "\"\\\"\"", namesize);