summaryrefslogtreecommitdiff
path: root/src/m_misc.h
AgeCommit message (Collapse)Author
2014-10-24Replace strdup() with M_StringDuplicate().Simon Howard
strdup() can theoretically fail and return NULL. This could lead to a crash or undesirable behavior. Add M_StringDuplicate() which does the same thing but exits with an error if a string cannot be allocated. This fixes #456. Thanks to Quasar for the suggestion.
2014-05-05Clean up file headers.Simon Howard
This change rewrites and simplifies the copyright headers at the top of all source files: * Remove "Emacs style mode select" line; this line was included in the headers for the originally released source files and appears to be to set the file type for old versions of Emacs. I'm not sure entirely why it was required but I don't think it is any more. * Remove "You should have received a copy of..." text from copyright header. This refers to the old 59 Temple Place address where the FSF headquarters used to be located and is no longer correct. Rather than change to the new address, just remove the paragraph as it is superfluous anyway. This fixes #311. * Remove ---- separator lines so that the file headers are barer and more simplified.
2014-04-01Replace all snprintf() calls with M_snprintf().Simon Howard
The Windows API has an _snprintf function that is not the same as Unix's snprintf(): if the string is truncated then no trailing NUL character is appended. This makes the function unsafe. Define a replacement/wrapper called M_snprintf that works the same but always appends a trailing NUL, for safety on Windows and other OSes that behave like this. Do the same thing for vsnprintf(), and update HACKING to list snprintf/vsnprintf as forbidden functions. This fixes #375; thanks to Quasar for pointing out the different behavior of these functions.
2014-03-29misc: Make arguments to string functions const.Simon Howard
Where a pointer is to a buffer that does not need to be mutable for the operation of the function, use const char * instead. This avoids some type errors where constant string are passed.
2014-03-29misc: Add M_StringConcat.Simon Howard
Just as M_StringCopy behaves the same as strlcpy(), M_StringConcat behaves the same as strlcat(). Use this in one location.
2014-03-29misc: Add string utility functions.Simon Howard
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.
2013-09-20Set setup tool title so that it it shows the name of the correct gameSimon Howard
being configured, not just always "Chocolate Doom". Subversion-branch: /branches/v2-branch Subversion-revision: 2669
2012-10-28Merge from trunk.Simon Howard
Subversion-branch: /branches/v2-branch Subversion-revision: 2537
2012-02-04On Windows, convert the USER and USERNAME environment variables from OEMSimon Howard
codepage to UTF-8 encoding. This should fix the case where the user has a username that includes non-ASCII characters (thanks Alexandre Xavier). Subversion-branch: /trunk/chocolate-doom Subversion-revision: 2495
2010-02-08Add case-insensitive version of strstr(), and use this instead ofSimon Howard
strstr() in dehacked code to determine when to map frame numbers. Subversion-branch: /branches/raven-branch Subversion-revision: 1861
2009-11-21Merge from trunk.Simon Howard
Subversion-branch: /branches/raven-branch Subversion-revision: 1737
2009-10-17Import donut overrun emulation code from PrBoom+ (Thanks entryway).Simon Howard
Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1720
2008-10-30Factor out Heretic and Hexen versions of m_misc.c. Make -file forSimon Howard
Heretic and Hexen use WAD path lookup. Subversion-branch: /branches/raven-branch Subversion-revision: 1368
2008-03-09Split out configuration file code from m_misc.c into m_config.c. MoveSimon Howard
screenshot code into v_video.c Add M_FileLength common function for finding the length of an open file. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1102
2007-01-06Choose the locations for temporary files more intelligently.Simon Howard
Subversion-branch: /trunk/chocolate-doom Subversion-revision: 821
2006-12-21Split off IWAD-related code into separate d_iwad.c. On Windows, searchSimon Howard
the registry to automatically find the locations of installed IWADs. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 791
2006-10-23Move MakeDirectory function into m_misc.c. Move configdir related codeSimon Howard
into m_misc.c. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 715
2006-10-18Strip out CVS logs, RCS Id tags.Simon Howard
Subversion-branch: /trunk/chocolate-doom Subversion-revision: 704
2005-07-23Update copyright to GNU GPLSimon Howard
Subversion-branch: /trunk/chocolate-doom Subversion-revision: 8
2005-07-23Initial revisionSimon Howard
Subversion-branch: /trunk/chocolate-doom Subversion-revision: 4