]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
Replaced snprintf and vnsprintf calls by dpsnprintf and dpvsnprintf calls, to ensure...
authormolivier <molivier@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 3 Feb 2005 12:17:10 +0000 (12:17 +0000)
committermolivier <molivier@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 3 Feb 2005 12:17:10 +0000 (12:17 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@4991 d7cf8633-e32d-0410-b094-e92efae38249

21 files changed:
cl_parse.c
common.c
common.h
console.c
fs.c
host.c
host_cmd.c
keys.c
model_brush.c
netconn.c
pr_edict.c
prvm_edict.c
r_shadow.c
r_sky.c
sbar.c
snd_mem.c
sv_main.c
sys_linux.c
sys_sdl.c
sys_shared.c
sys_win.c

index a0af3961b7df3a68e694e72cc9cd3eb1c3a277c7..271d29af0a25d22901f272fd6285ebeb854b8431 100644 (file)
@@ -1410,7 +1410,7 @@ void CL_ParseServerMessage(void)
                                i &= 31;
                                while(count > 0)
                                {
-                                       snprintf (temp, sizeof (temp), "%3i:%s ", cmdlog[i], cmdlogname[i]);
+                                       dpsnprintf (temp, sizeof (temp), "%3i:%s ", cmdlog[i], cmdlogname[i]);
                                        strlcat (description, temp, sizeof (description));
                                        count--;
                                        i++;
index 63d6a2d9a2f8e2235e8d02901ed00eae059209e4..09acf5820d23663fd02ada794ef9f0b42c6d1a11 100644 (file)
--- a/common.c
+++ b/common.c
@@ -1067,13 +1067,54 @@ char *va(const char *format, ...)
        s = string[stringindex];
        stringindex = (stringindex + 1) & 7;
        va_start (argptr, format);
-       vsnprintf (s, sizeof (string[0]), format,argptr);
+       dpvsnprintf (s, sizeof (string[0]), format,argptr);
        va_end (argptr);
 
        return s;
 }
 
 
+//======================================
+
+// snprintf and vsnprintf are NOT portable. Use their DP counterparts instead
+
+#undef snprintf
+#undef vsnprintf
+
+#ifdef WIN32
+# define snprintf _snprintf
+# define vsnprintf _vsnprintf
+#endif
+
+
+int dpsnprintf (char *buffer, size_t buffersize, const char *format, ...)
+{
+       va_list args;
+       int result;
+
+       va_start (args, format);
+       result = dpvsnprintf (buffer, buffersize, format, args);
+       va_end (args);
+
+       return result;
+}
+
+
+int dpvsnprintf (char *buffer, size_t buffersize, const char *format, va_list args)
+{
+       int result;
+
+       result = vsnprintf (buffer, buffersize, format, args);
+       if (result < 0 || (size_t)result >= buffersize)
+       {
+               buffer[buffersize - 1] = '\0';
+               return -1;
+       }
+
+       return result;
+}
+
+
 //======================================
 
 void COM_ToLowerString (const char *in, char *out, size_t size_out)
index 6ce65f463dd39b098e2b6f84a1abde593ec49577..891f6783680a40b26829bd1340832461d4f4651a 100644 (file)
--- a/common.h
+++ b/common.h
@@ -24,8 +24,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 // MSVC has a different name for several standard functions
 #ifdef WIN32
-# define snprintf _snprintf
-# define vsnprintf _vsnprintf
 # define strcasecmp stricmp
 # define strncasecmp strnicmp
 #endif
@@ -182,6 +180,18 @@ char       *va(const char *format, ...);
 // does a varargs printf into a temp buffer
 
 
+// snprintf and vsnprintf are NOT portable. Use their DP counterparts instead
+#define snprintf DO_NOT_USE_SNPRINTF__USE_DPSNPRINTF
+#define vsnprintf DO_NOT_USE_VSNPRINTF__USE_DPVSNPRINTF
+
+// dpsnprintf and dpvsnprintf
+// return the number of printed characters, excluding the final '\0'
+// or return -1 if the buffer isn't big enough to contain the entire string.
+// buffer is ALWAYS null-terminated
+extern int dpsnprintf (char *buffer, size_t buffersize, const char *format, ...);
+extern int dpvsnprintf (char *buffer, size_t buffersize, const char *format, va_list args);
+
+
 //============================================================================
 
 extern struct cvar_s   registered;
index 018f4908dca793723bd551b9b9bc2bc943f281eb..043dbeb8e6d17ac7bd919408212302661fd9f264 100644 (file)
--- a/console.c
+++ b/console.c
@@ -99,9 +99,9 @@ const char* Log_Timestamp (const char *desc)
        strftime (timestring, sizeof (timestring), "%a %b %d %H:%M:%S %Y", crt_tm);
 
        if (desc != NULL)
-               snprintf (timestamp, sizeof (timestamp), "====== %s (%s) ======\n", desc, timestring);
+               dpsnprintf (timestamp, sizeof (timestamp), "====== %s (%s) ======\n", desc, timestring);
        else
-               snprintf (timestamp, sizeof (timestamp), "====== %s ======\n", timestring);
+               dpsnprintf (timestamp, sizeof (timestamp), "====== %s ======\n", timestring);
 
        return timestamp;
 }
@@ -637,7 +637,7 @@ void Con_Printf(const char *fmt, ...)
        char msg[MAXPRINTMSG];
 
        va_start(argptr,fmt);
-       vsnprintf(msg,sizeof(msg),fmt,argptr);
+       dpvsnprintf(msg,sizeof(msg),fmt,argptr);
        va_end(argptr);
 
        Con_Print(msg);
@@ -673,7 +673,7 @@ void Con_DPrintf(const char *fmt, ...)
                return;                 // don't confuse non-developers with techie stuff...
 
        va_start(argptr,fmt);
-       vsnprintf(msg,sizeof(msg),fmt,argptr);
+       dpvsnprintf(msg,sizeof(msg),fmt,argptr);
        va_end(argptr);
 
        Con_Print(msg);
diff --git a/fs.c b/fs.c
index c6742d390f527d0ac44c2ac2d3f4346d036b3497..9ad570557915918b2c082aaf285735c4e92c26e5 100644 (file)
--- a/fs.c
+++ b/fs.c
@@ -803,7 +803,7 @@ void FS_AddGameDirectory (const char *dir)
        {
                if (matchpattern(current->text, "*.pak", true))
                {
-                       snprintf (pakfile, sizeof (pakfile), "%s/%s", dir, current->text);
+                       dpsnprintf (pakfile, sizeof (pakfile), "%s/%s", dir, current->text);
                        pak = FS_LoadPackPAK (pakfile);
                        if (pak)
                        {
@@ -822,7 +822,7 @@ void FS_AddGameDirectory (const char *dir)
        {
                if (matchpattern(current->text, "*.pk3", true))
                {
-                       snprintf (pakfile, sizeof (pakfile), "%s/%s", dir, current->text);
+                       dpsnprintf (pakfile, sizeof (pakfile), "%s/%s", dir, current->text);
                        pak = FS_LoadPackPK3 (pakfile);
                        if (pak)
                        {
@@ -1260,7 +1260,7 @@ static searchpath_t *FS_FindFile (const char *name, int* index, qboolean quiet)
                else
                {
                        char netpath[MAX_OSPATH];
-                       snprintf(netpath, sizeof(netpath), "%s/%s", search->filename, name);
+                       dpsnprintf(netpath, sizeof(netpath), "%s/%s", search->filename, name);
                        if (FS_SysFileExists (netpath))
                        {
                                if (!quiet)
@@ -1309,7 +1309,7 @@ qfile_t *FS_OpenReadFile (const char *filename, qboolean quiet)
        if (pack_ind < 0)
        {
                char path [MAX_OSPATH];
-               snprintf (path, sizeof (path), "%s/%s", search->filename, filename);
+               dpsnprintf (path, sizeof (path), "%s/%s", search->filename, filename);
                return FS_SysOpen (path, "rb");
        }
 
@@ -1349,7 +1349,7 @@ qfile_t* FS_Open (const char* filepath, const char* mode, qboolean quiet)
                char real_path [MAX_OSPATH];
 
                // Open the file on disk directly
-               snprintf (real_path, sizeof (real_path), "%s/%s", fs_gamedir, filepath);
+               dpsnprintf (real_path, sizeof (real_path), "%s/%s", fs_gamedir, filepath);
 
                // Create directories up to the file
                FS_CreatePath (real_path);
@@ -1604,19 +1604,24 @@ Print a string into a file
 int FS_VPrintf (qfile_t* file, const char* format, va_list ap)
 {
        int len;
-       char tempstring [1024];
+       size_t buff_size;
+       char *tempbuff = NULL;
 
-       len = vsnprintf (tempstring, sizeof(tempstring), format, ap);
-       if (len >= sizeof (tempstring))
+       buff_size = 1024;
+       tempbuff = Mem_Alloc (tempmempool, buff_size);
+       len = dpvsnprintf (tempbuff, buff_size, format, ap);
+       while (len < 0)
        {
-               char *temp = Mem_Alloc (tempmempool, len + 1);
-               len = vsnprintf (temp, len + 1, format, ap);
-               len = write (file->handle, temp, len);
-               Mem_Free (temp);
-               return len;
+               Mem_Free (tempbuff);
+               buff_size *= 2;
+               tempbuff = Mem_Alloc (tempmempool, buff_size);
+               len = dpvsnprintf (tempbuff, buff_size, format, ap);
        }
 
-       return write (file->handle, tempstring, len);
+       len = write (file->handle, tempbuff, len);
+       Mem_Free (tempbuff);
+
+       return len;
 }
 
 
@@ -2019,12 +2024,12 @@ fssearch_t *FS_Search(const char *pattern, int caseinsensitive, int quiet)
                else
                {
                        // get a directory listing and look at each name
-                       snprintf(netpath, sizeof (netpath), "%s/%s", searchpath->filename, basepath);
+                       dpsnprintf(netpath, sizeof (netpath), "%s/%s", searchpath->filename, basepath);
                        if ((dir = listdirectory(netpath)))
                        {
                                for (dirfile = dir;dirfile;dirfile = dirfile->next)
                                {
-                                       snprintf(temp, sizeof(temp), "%s/%s", basepath, dirfile->text);
+                                       dpsnprintf(temp, sizeof(temp), "%s/%s", basepath, dirfile->text);
                                        if (matchpattern(temp, (char *)pattern, true))
                                        {
                                                for (listtemp = liststart;listtemp;listtemp = listtemp->next)
diff --git a/host.c b/host.c
index f04472d4cb24725eba2d4e02d5faac5a77c8ebc0..833fce9e3a66bcc419fc6874d4533a99a6ef1bff 100644 (file)
--- a/host.c
+++ b/host.c
@@ -112,7 +112,7 @@ void Host_Error (const char *error, ...)
        va_list argptr;
 
        va_start (argptr,error);
-       vsnprintf (hosterrorstring1,sizeof(hosterrorstring1),error,argptr);
+       dpvsnprintf (hosterrorstring1,sizeof(hosterrorstring1),error,argptr);
        va_end (argptr);
 
        Con_Printf("Host_Error: %s\n", hosterrorstring1);
@@ -323,7 +323,7 @@ void SV_ClientPrintf(const char *fmt, ...)
        char msg[4096];
 
        va_start(argptr,fmt);
-       vsnprintf(msg,sizeof(msg),fmt,argptr);
+       dpvsnprintf(msg,sizeof(msg),fmt,argptr);
        va_end(argptr);
 
        SV_ClientPrint(msg);
@@ -367,7 +367,7 @@ void SV_BroadcastPrintf(const char *fmt, ...)
        char msg[4096];
 
        va_start(argptr,fmt);
-       vsnprintf(msg,sizeof(msg),fmt,argptr);
+       dpvsnprintf(msg,sizeof(msg),fmt,argptr);
        va_end(argptr);
 
        SV_BroadcastPrint(msg);
@@ -386,7 +386,7 @@ void Host_ClientCommands(const char *fmt, ...)
        char string[1024];
 
        va_start(argptr,fmt);
-       vsnprintf(string, sizeof(string), fmt, argptr);
+       dpvsnprintf(string, sizeof(string), fmt, argptr);
        va_end(argptr);
 
        MSG_WriteByte(&host_client->message, svc_stufftext);
index 995e61bc203ee72f5291cd41c1cf0035426d2a70..2efcdd05626f41c1fd4f5a84b6673c6bcb3438d0 100644 (file)
@@ -919,9 +919,9 @@ void Host_Say(qboolean teamonly)
                p1++;
        }
        if (!fromServer)
-               snprintf (text, sizeof(text), "%c%s: %s", 1, host_client->name, p1);
+               dpsnprintf (text, sizeof(text), "%c%s: %s", 1, host_client->name, p1);
        else
-               snprintf (text, sizeof(text), "%c<%s> %s", 1, hostname.string, p1);
+               dpsnprintf (text, sizeof(text), "%c<%s> %s", 1, hostname.string, p1);
        p2 = text + strlen(text);
        while ((const char *)p2 > (const char *)text && (p2[-1] == '\r' || p2[-1] == '\n' || (p2[-1] == '\"' && quoted)))
        {
diff --git a/keys.c b/keys.c
index 37f33affb851df013b02f7a200311384984034fc..c3c1b9cd83cc1bd6285dda9c34790fdac33bca04 100644 (file)
--- a/keys.c
+++ b/keys.c
@@ -947,7 +947,7 @@ Key_Event (int key, char ascii, qboolean down)
                                kb = keybindings[key_bmap2][key];
 
                        if (kb && kb[0] == '+') {
-                               snprintf (cmd, sizeof(cmd), "-%s %i\n", kb + 1, key);
+                               dpsnprintf (cmd, sizeof(cmd), "-%s %i\n", kb + 1, key);
                                Cbuf_AddText (cmd);
                        }
                        return;
@@ -972,7 +972,7 @@ Key_Event (int key, char ascii, qboolean down)
                                kb = keybindings[key_bmap2][key];
                        if (kb) {
                                if (kb[0] == '+') {                     // button commands add keynum as a parm
-                                       snprintf (cmd, sizeof(cmd), "%s %i\n", kb, key);
+                                       dpsnprintf (cmd, sizeof(cmd), "%s %i\n", kb, key);
                                        Cbuf_AddText (cmd);
                                } else {
                                        Cbuf_AddText (kb);
index 9be6bb45853769effff53e9280a4640ae578c00f..3eab23d01edcd1e0b336649ea5c12cc6a06bb031 100644 (file)
@@ -3978,7 +3978,7 @@ static void Mod_Q3BSP_LoadTextures(lump_t *l)
                                                                if ((flags & Q3SURFACEPARM_SKY) && sky[0])
                                                                {
                                                                        // quake3 seems to append a _ to the skybox name, so this must do so as well
-                                                                       snprintf(loadmodel->brush.skybox, sizeof(loadmodel->brush.skybox), "%s_", sky);
+                                                                       dpsnprintf(loadmodel->brush.skybox, sizeof(loadmodel->brush.skybox), "%s_", sky);
                                                                }
                                                        }
                                                }
index 4d6967693f0a25fa5752638e8595016831d3e8fb..53446bac14f234c359e6c250c90030eccdcad07d 100755 (executable)
--- a/netconn.c
+++ b/netconn.c
@@ -299,7 +299,7 @@ static void _HostCache_Test(void)
        for( i = 0 ; i < 1024 ; i++ ) {
                memset( &hostcache_cache[hostcache_cachecount], 0, sizeof( hostcache_t ) );
                hostcache_cache[hostcache_cachecount].info.ping = rand() % 450 + 250;
-               snprintf( hostcache_cache[hostcache_cachecount].info.name, 128, "Black's HostCache Test %i", i );
+               dpsnprintf( hostcache_cache[hostcache_cachecount].info.name, 128, "Black's HostCache Test %i", i );
                hostcache_cache[hostcache_cachecount].finished = true;
                sprintf( hostcache_cache[hostcache_cachecount].line1, "%i %s", hostcache_cache[hostcache_cachecount].info.ping, hostcache_cache[hostcache_cachecount].info.name );
                _HostCache_Insert( &hostcache_cache[hostcache_cachecount] );
@@ -942,8 +942,8 @@ int NetConn_ClientParsePacket(lhnetsocket_t *mysocket, qbyte *data, int length,
                        // legacy/old stuff move it to the menu ASAP
 
                        // build description strings for the things users care about
-                       snprintf(hostcache_cache[n].line1, sizeof(hostcache_cache[n].line1), "%5d%c%3u/%3u %-65.65s", (int)pingtime, info->protocol != NET_PROTOCOL_VERSION ? '*' : ' ', info->numplayers, info->maxplayers, info->name);
-                       snprintf(hostcache_cache[n].line2, sizeof(hostcache_cache[n].line2), "%-21.21s %-19.19s %-17.17s %-20.20s", info->cname, info->game, info->mod, info->map);
+                       dpsnprintf(hostcache_cache[n].line1, sizeof(hostcache_cache[n].line1), "%5d%c%3u/%3u %-65.65s", (int)pingtime, info->protocol != NET_PROTOCOL_VERSION ? '*' : ' ', info->numplayers, info->maxplayers, info->name);
+                       dpsnprintf(hostcache_cache[n].line2, sizeof(hostcache_cache[n].line2), "%-21.21s %-19.19s %-17.17s %-20.20s", info->cname, info->game, info->mod, info->map);
                        // if ping is especially high, display it as such
                        if (pingtime >= 300)
                        {
@@ -982,7 +982,7 @@ int NetConn_ClientParsePacket(lhnetsocket_t *mysocket, qbyte *data, int length,
                        {
                                serverquerycount++;
        
-                               snprintf (ipstring, sizeof (ipstring), "%u.%u.%u.%u:%u", data[1], data[2], data[3], data[4], (data[5] << 8) | data[6]);
+                               dpsnprintf (ipstring, sizeof (ipstring), "%u.%u.%u.%u:%u", data[1], data[2], data[3], data[4], (data[5] << 8) | data[6]);
                                if (developer.integer)
                                        Con_Printf("Requesting info from server %s\n", ipstring);                               
                                // ignore the rest of the message if the hostcache is full
@@ -1318,13 +1318,13 @@ int NetConn_ServerParsePacket(lhnetsocket_t *mysocket, qbyte *data, int length,
                                for (i = 0, n = 0;i < svs.maxclients;i++)
                                        if (svs.clients[i].active)
                                                n++;
-                               responselength = snprintf(response, sizeof(response), "\377\377\377\377infoResponse\x0A"
+                               responselength = dpsnprintf(response, sizeof(response), "\377\377\377\377infoResponse\x0A"
                                                        "\\gamename\\%s\\modname\\%s\\sv_maxclients\\%d"
                                                        "\\clients\\%d\\mapname\\%s\\hostname\\%s\\protocol\\%d%s%s",
                                                        gamename, com_modname, svs.maxclients, n,
                                                        sv.name, hostname.string, NET_PROTOCOL_VERSION, challenge ? "\\challenge\\" : "", challenge ? challenge : "");
                                // does it fit in the buffer?
-                               if (responselength < (int)sizeof(response))
+                               if (responselength >= 0)
                                {
                                        if (developer.integer)
                                                Con_Printf("Sending reply to master %s - %s\n", addressstring2, response);
@@ -1613,7 +1613,7 @@ void NetConn_QueryMasters(void)
 #endif
 
                        // build the getservers
-                       snprintf(request, sizeof(request), "\377\377\377\377getservers %s %u empty full\x0A", gamename, NET_PROTOCOL_VERSION);
+                       dpsnprintf(request, sizeof(request), "\377\377\377\377getservers %s %u empty full\x0A", gamename, NET_PROTOCOL_VERSION);
 
                        // search internet
                        for (masternum = 0;sv_masters[masternum].name;masternum++)
index 96e73fbe368efc1629278beee9c17e27bba54a47..5e3f6a4f099079cbe73ac6aa521348a4acdee65a 100644 (file)
@@ -439,34 +439,34 @@ char *PR_ValueString (etype_t type, eval_t *val)
                //n = NoCrash_NUM_FOR_EDICT(PROG_TO_EDICT(val->edict));
                n = val->edict;
                if (n < 0 || n >= MAX_EDICTS)
-                       snprintf (line, sizeof (line), "entity %i (invalid!)", n);
+                       dpsnprintf (line, sizeof (line), "entity %i (invalid!)", n);
                else
-                       snprintf (line, sizeof (line), "entity %i", n);
+                       dpsnprintf (line, sizeof (line), "entity %i", n);
                break;
        case ev_function:
                f = pr_functions + val->function;
-               snprintf (line, sizeof (line), "%s()", PR_GetString(f->s_name));
+               dpsnprintf (line, sizeof (line), "%s()", PR_GetString(f->s_name));
                break;
        case ev_field:
                def = ED_FieldAtOfs ( val->_int );
-               snprintf (line, sizeof (line), ".%s", PR_GetString(def->s_name));
+               dpsnprintf (line, sizeof (line), ".%s", PR_GetString(def->s_name));
                break;
        case ev_void:
-               snprintf (line, sizeof (line), "void");
+               dpsnprintf (line, sizeof (line), "void");
                break;
        case ev_float:
                // LordHavoc: changed from %5.1f to %10.4f
-               snprintf (line, sizeof (line), "%10.4f", val->_float);
+               dpsnprintf (line, sizeof (line), "%10.4f", val->_float);
                break;
        case ev_vector:
                // LordHavoc: changed from %5.1f to %10.4f
-               snprintf (line, sizeof (line), "'%10.4f %10.4f %10.4f'", val->vector[0], val->vector[1], val->vector[2]);
+               dpsnprintf (line, sizeof (line), "'%10.4f %10.4f %10.4f'", val->vector[0], val->vector[1], val->vector[2]);
                break;
        case ev_pointer:
-               snprintf (line, sizeof (line), "pointer");
+               dpsnprintf (line, sizeof (line), "pointer");
                break;
        default:
-               snprintf (line, sizeof (line), "bad type %i", type);
+               dpsnprintf (line, sizeof (line), "bad type %i", type);
                break;
        }
 
@@ -517,7 +517,7 @@ char *PR_UglyValueString (etype_t type, eval_t *val)
                line[i] = '\0';
                break;
        case ev_entity:
-               snprintf (line, sizeof (line), "%i", NUM_FOR_EDICT(PROG_TO_EDICT(val->edict)));
+               dpsnprintf (line, sizeof (line), "%i", NUM_FOR_EDICT(PROG_TO_EDICT(val->edict)));
                break;
        case ev_function:
                f = pr_functions + val->function;
@@ -525,19 +525,19 @@ char *PR_UglyValueString (etype_t type, eval_t *val)
                break;
        case ev_field:
                def = ED_FieldAtOfs ( val->_int );
-               snprintf (line, sizeof (line), ".%s", PR_GetString(def->s_name));
+               dpsnprintf (line, sizeof (line), ".%s", PR_GetString(def->s_name));
                break;
        case ev_void:
-               snprintf (line, sizeof (line), "void");
+               dpsnprintf (line, sizeof (line), "void");
                break;
        case ev_float:
-               snprintf (line, sizeof (line), "%f", val->_float);
+               dpsnprintf (line, sizeof (line), "%f", val->_float);
                break;
        case ev_vector:
-               snprintf (line, sizeof (line), "%f %f %f", val->vector[0], val->vector[1], val->vector[2]);
+               dpsnprintf (line, sizeof (line), "%f %f %f", val->vector[0], val->vector[1], val->vector[2]);
                break;
        default:
-               snprintf (line, sizeof (line), "bad type %i", type);
+               dpsnprintf (line, sizeof (line), "bad type %i", type);
                break;
        }
 
@@ -563,11 +563,11 @@ char *PR_GlobalString (int ofs)
        val = (void *)&pr_globals[ofs];
        def = ED_GlobalAtOfs(ofs);
        if (!def)
-               snprintf (line, sizeof (line), "%i(?)", ofs);
+               dpsnprintf (line, sizeof (line), "%i(?)", ofs);
        else
        {
                s = PR_ValueString (def->type, val);
-               snprintf (line, sizeof (line), "%i(%s)%s", ofs, PR_GetString(def->s_name), s);
+               dpsnprintf (line, sizeof (line), "%i(%s)%s", ofs, PR_GetString(def->s_name), s);
        }
 
        i = strlen(line);
@@ -586,9 +586,9 @@ char *PR_GlobalStringNoContents (int ofs)
 
        def = ED_GlobalAtOfs(ofs);
        if (!def)
-               snprintf (line, sizeof (line), "%i(?)", ofs);
+               dpsnprintf (line, sizeof (line), "%i(?)", ofs);
        else
-               snprintf (line, sizeof (line), "%i(%s)", ofs, PR_GetString(def->s_name));
+               dpsnprintf (line, sizeof (line), "%i(%s)", ofs, PR_GetString(def->s_name));
 
        i = strlen(line);
        for ( ; i<20 ; i++)
@@ -625,7 +625,7 @@ void ED_Print(edict_t *ed)
        }
 
        tempstring[0] = 0;
-       snprintf (tempstring, sizeof (tempstring), "\nEDICT %i:\n", NUM_FOR_EDICT(ed));
+       dpsnprintf (tempstring, sizeof (tempstring), "\nEDICT %i:\n", NUM_FOR_EDICT(ed));
        for (i=1 ; i<progs->numfielddefs ; i++)
        {
                d = &pr_fielddefs[i];
@@ -1108,7 +1108,7 @@ const char *ED_ParseEdict (const char *data, edict_t *ent)
                {
                        char    temp[32];
                        strlcpy (temp, com_token, sizeof (temp));
-                       snprintf (com_token, sizeof (com_token), "0 %s 0", temp);
+                       dpsnprintf (com_token, sizeof (com_token), "0 %s 0", temp);
                }
 
                if (!ED_ParseEpair(ent, key, com_token))
@@ -1579,7 +1579,7 @@ void PR_Fields_f (void)
                        strlcat (tempstring, "pointer  ", sizeof (tempstring));
                        break;
                default:
-                       snprintf (tempstring2, sizeof (tempstring2), "bad type %i ", d->type & ~DEF_SAVEGLOBAL);
+                       dpsnprintf (tempstring2, sizeof (tempstring2), "bad type %i ", d->type & ~DEF_SAVEGLOBAL);
                        strlcat (tempstring, tempstring2, sizeof (tempstring));
                        break;
                }
@@ -1593,7 +1593,7 @@ void PR_Fields_f (void)
                strcat (tempstring, name);
                for (j = strlen(name);j < 25;j++)
                        strcat(tempstring, " ");
-               snprintf (tempstring2, sizeof (tempstring2), "%5d", counts[i]);
+               dpsnprintf (tempstring2, sizeof (tempstring2), "%5d", counts[i]);
                strlcat (tempstring, tempstring2, sizeof (tempstring));
                strlcat (tempstring, "\n", sizeof (tempstring));
                if (strlen(tempstring) >= 4096)
index 76b364eeddd336ae15877a4b104d456b4eb68f7c..0dceb6900892eed0c61edf3cbb337f813daaddb9 100644 (file)
@@ -467,7 +467,7 @@ char *PRVM_UglyValueString (etype_t type, prvm_eval_t *val)
                line[i] = '\0';
                break;
        case ev_entity:
-               snprintf (line, sizeof (line), "%i", PRVM_NUM_FOR_EDICT(PRVM_PROG_TO_EDICT(val->edict)));
+               dpsnprintf (line, sizeof (line), "%i", PRVM_NUM_FOR_EDICT(PRVM_PROG_TO_EDICT(val->edict)));
                break;
        case ev_function:
                f = pr_functions + val->function;
@@ -475,19 +475,19 @@ char *PRVM_UglyValueString (etype_t type, prvm_eval_t *val)
                break;
        case ev_field:
                def = PRVM_ED_FieldAtOfs ( val->_int );
-               snprintf (line, sizeof (line), ".%s", PRVM_GetString(def->s_name));
+               dpsnprintf (line, sizeof (line), ".%s", PRVM_GetString(def->s_name));
                break;
        case ev_void:
-               snprintf (line, sizeof (line), "void");
+               dpsnprintf (line, sizeof (line), "void");
                break;
        case ev_float:
-               snprintf (line, sizeof (line), "%f", val->_float);
+               dpsnprintf (line, sizeof (line), "%f", val->_float);
                break;
        case ev_vector:
-               snprintf (line, sizeof (line), "%f %f %f", val->vector[0], val->vector[1], val->vector[2]);
+               dpsnprintf (line, sizeof (line), "%f %f %f", val->vector[0], val->vector[1], val->vector[2]);
                break;
        default:
-               snprintf (line, sizeof (line), "bad type %i", type);
+               dpsnprintf (line, sizeof (line), "bad type %i", type);
                break;
        }
        
index d12b3c9c034c44e7bf5b77acc7a20ec934720087..258c3e33aa29754e0c5d6d3798861a30d1e6b896 100644 (file)
@@ -2951,7 +2951,7 @@ rtexture_t *R_Shadow_LoadCubemap(const char *basename)
                for (i = 0;i < 6;i++)
                {
                        // generate an image name based on the base and and suffix
-                       snprintf(name, sizeof(name), "%s%s", basename, suffix[j][i].suffix);
+                       dpsnprintf(name, sizeof(name), "%s%s", basename, suffix[j][i].suffix);
                        // load it
                        if ((image_rgba = loadimagepixels(name, false, cubemapsize, cubemapsize)))
                        {
diff --git a/r_sky.c b/r_sky.c
index b58ada98e34467f7c062e9c5526ad5d955177c22..135d2dab2d38cdafbfa2d41b8a2b9733acfc377a 100644 (file)
--- a/r_sky.c
+++ b/r_sky.c
@@ -102,13 +102,13 @@ void R_LoadSkyBox(void)
                success = 0;
                for (i=0; i<6; i++)
                {
-                       if (snprintf(name, sizeof(name), "%s_%s", skyname, suffix[j][i].suffix) >= (int)sizeof(name) || !(image_rgba = loadimagepixels(name, false, 0, 0)))
+                       if (dpsnprintf(name, sizeof(name), "%s_%s", skyname, suffix[j][i].suffix) < 0 || !(image_rgba = loadimagepixels(name, false, 0, 0)))
                        {
-                               if (snprintf(name, sizeof(name), "%s%s", skyname, suffix[j][i].suffix) >= (int)sizeof(name) || !(image_rgba = loadimagepixels(name, false, 0, 0)))
+                               if (dpsnprintf(name, sizeof(name), "%s%s", skyname, suffix[j][i].suffix) < 0 || !(image_rgba = loadimagepixels(name, false, 0, 0)))
                                {
-                                       if (snprintf(name, sizeof(name), "env/%s%s", skyname, suffix[j][i].suffix) >= (int)sizeof(name) || !(image_rgba = loadimagepixels(name, false, 0, 0)))
+                                       if (dpsnprintf(name, sizeof(name), "env/%s%s", skyname, suffix[j][i].suffix) < 0 || !(image_rgba = loadimagepixels(name, false, 0, 0)))
                                        {
-                                               if (snprintf(name, sizeof(name), "gfx/env/%s%s", skyname, suffix[j][i].suffix) >= (int)sizeof(name) || !(image_rgba = loadimagepixels(name, false, 0, 0)))
+                                               if (dpsnprintf(name, sizeof(name), "gfx/env/%s%s", skyname, suffix[j][i].suffix) < 0 || !(image_rgba = loadimagepixels(name, false, 0, 0)))
                                                        continue;
                                        }
                                }
diff --git a/sbar.c b/sbar.c
index 24f9634051f5a4821309c06ec412d77eaeb8f5cf..7512d953d47cbadb0b7aa8b13a1055a54a64177c 100644 (file)
--- a/sbar.c
+++ b/sbar.c
@@ -847,7 +847,7 @@ void Sbar_ShowFPS(void)
                        framecount++;
                        calc = framerate;
                }
-               snprintf(fpsstring, sizeof(fpsstring), "%4i fps", calc);
+               dpsnprintf(fpsstring, sizeof(fpsstring), "%4i fps", calc);
        }
        if (showtime.integer)
                strlcpy(timestring, Sys_TimeString(showtime_format.string), sizeof(timestring));
index 7422a01b1b9fe1c98d03f9459a991e871cb30d7d..07c32eb1865d4c1f780dd89e2e73cea311e64455 100644 (file)
--- a/snd_mem.c
+++ b/snd_mem.c
@@ -174,8 +174,8 @@ qboolean S_LoadSound (sfx_t *s, qboolean complain)
        // LordHavoc: if the sound filename does not begin with sound/, try adding it
        if (strncasecmp(s->name, "sound/", 6))
        {
-               len = snprintf (namebuffer, sizeof(namebuffer), "sound/%s", s->name);
-               if (len >= sizeof (namebuffer))
+               len = dpsnprintf (namebuffer, sizeof(namebuffer), "sound/%s", s->name);
+               if (len < 0)
                {
                        // name too long
                        Con_Printf("S_LoadSound: name \"%s\" is too long\n", s->name);
@@ -190,8 +190,8 @@ qboolean S_LoadSound (sfx_t *s, qboolean complain)
        }
 
        // LordHavoc: then try without the added sound/ as wav and ogg
-       len = snprintf (namebuffer, sizeof(namebuffer), "%s", s->name);
-       if (len >= sizeof (namebuffer))
+       len = dpsnprintf (namebuffer, sizeof(namebuffer), "%s", s->name);
+       if (len < 0)
        {
                // name too long
                Con_Printf("S_LoadSound: name \"%s\" is too long\n", s->name);
index 75cf3703ea0c388bc23392b2ad52bf917a6aee46..d85aba281e10a340d4b0f0126e572a35834aebae 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -314,7 +314,7 @@ void SV_SendServerinfo (client_t *client)
                client->entitydatabase5 = EntityFrame5_AllocDatabase(sv_clients_mempool);
 
        MSG_WriteByte (&client->message, svc_print);
-       snprintf (message, sizeof (message), "\002\nServer: %s build %s (progs %i crc)", gamename, buildstring, pr_crc);
+       dpsnprintf (message, sizeof (message), "\002\nServer: %s build %s (progs %i crc)", gamename, buildstring, pr_crc);
        MSG_WriteString (&client->message,message);
 
        MSG_WriteByte (&client->message, svc_serverinfo);
@@ -1610,7 +1610,7 @@ void SV_SpawnServer (const char *server)
        if (cls.state != ca_dedicated)
                SCR_BeginLoadingPlaque();
 
-       snprintf (modelname, sizeof(modelname), "maps/%s.bsp", server);
+       dpsnprintf (modelname, sizeof(modelname), "maps/%s.bsp", server);
        worldmodel = Mod_ForName(modelname, false, true, true);
        if (!worldmodel || !worldmodel->TraceBox)
        {
@@ -1750,7 +1750,7 @@ void SV_SpawnServer (const char *server)
        strlcpy(sv.model_precache[1], sv.modelname, sizeof(sv.model_precache[1]));
        for (i = 1;i < sv.worldmodel->brush.numsubmodels;i++)
        {
-               snprintf(sv.model_precache[i+1], sizeof(sv.model_precache[i+1]), "*%i", i);
+               dpsnprintf(sv.model_precache[i+1], sizeof(sv.model_precache[i+1]), "*%i", i);
                sv.models[i+1] = Mod_ForName (sv.model_precache[i+1], false, false, false);
        }
 
index ea91828fcc01419a788eca385eb510ff319ebc6b..1666a7f5c4aab49d8d9727e29bea964e846ac6a0 100644 (file)
@@ -40,7 +40,7 @@ void Sys_Error (const char *error, ...)
 #endif
 
        va_start (argptr,error);
-       vsnprintf (string, sizeof (string), error, argptr);
+       dpvsnprintf (string, sizeof (string), error, argptr);
        va_end (argptr);
        fprintf(stderr, "Error: %s\n", string);
 
index 11d4894dfbb022964e4eb7c376280f127371b41a..6f1653177c2536aa67cab1c4a039a29671a35701 100644 (file)
--- a/sys_sdl.c
+++ b/sys_sdl.c
@@ -42,7 +42,7 @@ void Sys_Error (const char *error, ...)
 #endif
 
        va_start (argptr,error);
-       vsnprintf (string, sizeof (string), error, argptr);
+       dpvsnprintf (string, sizeof (string), error, argptr);
        va_end (argptr);
        fprintf(stderr, "Error: %s\n", string);
 
index e876daf18ae32d0c73741eb90ed9a05f9a11325a..9b4aea623989069b6ad652e912625c7ef3609052 100644 (file)
@@ -53,7 +53,7 @@ void Sys_Shared_EarlyInit(void)
 #else
        os = "Unknown";
 #endif
-       snprintf (engineversion, sizeof (engineversion), "%s %s %s", gamename, os, buildstring);
+       dpsnprintf (engineversion, sizeof (engineversion), "%s %s %s", gamename, os, buildstring);
 
 // COMMANDLINEOPTION: Console: -nostdout disables text output to the terminal the game was launched from
        if (COM_CheckParm("-nostdout"))
index 36ab6e59efef73a816815bf92803ee93bc75e97e..4fa62ee06cc5e4c6186ffc1fdab6fb02019e6452 100644 (file)
--- a/sys_win.c
+++ b/sys_win.c
@@ -57,7 +57,7 @@ void Sys_Error (const char *error, ...)
        static int      in_sys_error3 = 0;
 
        va_start (argptr, error);
-       vsnprintf (text, sizeof (text), error, argptr);
+       dpvsnprintf (text, sizeof (text), error, argptr);
        va_end (argptr);
 
        Con_Printf ("Quake Error: %s\n", text);