From 62b5c602821cee8ac703ebe6362f3e1fc6d9ad3c Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sat, 29 Mar 2014 20:08:31 -0400 Subject: misc: Add string utility functions. It's more readable to write "M_StringEndsWith(..." than doing a bunch of pointer arithmetic, and this is a common pattern. Also add M_StringStartsWith, M_StringJoin and M_StringCopy. The latter is a safe alternative for strcpy() that works the same as OpenBSD's strlcpy(). Use these functions in a few places where it makes sense. --- src/i_pcsound.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/i_pcsound.c') diff --git a/src/i_pcsound.c b/src/i_pcsound.c index 655f5a8b..0303d2e4 100644 --- a/src/i_pcsound.c +++ b/src/i_pcsound.c @@ -30,7 +30,7 @@ #include "deh_str.h" #include "i_sound.h" - +#include "m_misc.h" #include "w_wad.h" #include "z_zone.h" @@ -253,11 +253,11 @@ static int I_PCS_GetSfxLumpNum(sfxinfo_t* sfx) if (use_sfx_prefix) { - sprintf(namebuf, "dp%s", DEH_String(sfx->name)); + snprintf(namebuf, sizeof(namebuf), "dp%s", DEH_String(sfx->name)); } else { - strcpy(namebuf, DEH_String(sfx->name)); + M_StringCopy(namebuf, DEH_String(sfx->name), sizeof(namebuf)); } return W_GetNumForName(namebuf); -- cgit v1.2.3