return NULL;
}
+/* A little helper function, acts like strcpy
+ * but safe for overlapping regions.
+ */
+static void *strmove(void *dest, const void *src) {
+ memmove(dest, src, strlen(src) + 1);
+}
+
/******************************************************************************
* Function: static int ProcessString(string, int idx);
*
if (cpy_str == True)
{
- strcpy (string, &string[*idx+1]);
+ strmove (string, &string[*idx+1]);
*idx = -1;
}
return 0;
* the string.
*/
if (_DtCvIsSegRegChar(p_seg))
- strcpy(((char *)pChar), &(((char *)pChar)[1]));
+ strmove(((char *)pChar), &(((char *)pChar)[1]));
else
{
int i;
return -1;
my_struct->flags = my_struct->flags & ~(_DtCvNON_BREAK);
- strcpy (string, &string[*idx+1]);
+ strmove (string, &string[*idx+1]);
*idx = -1;
return 0;
}
} /* End OnlyOneEach */
+
/******************************************************************************
* Function: int Cdata (FormatStruct my_struct,
* int cur_element, exceptions);
if (string[i] == '&')
{
- strcpy (&string[i], &string[i+1]);
+ strmove (&string[i], &string[i+1]);
if (string[i] == '\0')
{
string[i] = BufFileGet(my_struct->my_file);
* and copy the rest of the string to after it.
*/
string[j-1] = (char) value;
- strcpy (&string[j], &string[i]);
+ strmove (&string[j], &string[i]);
i = j;
}
if (my_struct->last_was_space == False)
my_struct->last_was_nl = True;
- strcpy (&string[i], &string[i+1]);
+ strmove (&string[i], &string[i+1]);
}
else
{
return -1;
}
- strcpy (string, &string[i+1]);
+ strmove (string, &string[i+1]);
i = 0;
}
}
if (False == my_struct->save_blank &&
type != SdlTypeLiteral && type != SdlTypeUnlinedLiteral
&& my_struct->last_was_space == True)
- strcpy (&string[i], &string[i+1]);
+ strmove (&string[i], &string[i+1]);
else
i++;
my_struct->last_was_space = True;
else /* the last was a multibyte character, tighten up */
{
i--;
- strcpy (&string[i], &string[i+1]);
+ strmove (&string[i], &string[i+1]);
}
}