summaryrefslogtreecommitdiff
path: root/src/m_misc.c
AgeCommit message (Collapse)Author
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-01misc: Fix safe vsnprintf() function.Simon Howard
An off-by-one error in the function caused the strings to be truncated one character too early. Change the return value check so that negative values are also interpreted as indicating truncation; this is the behavior of the Win32 API.
2014-04-01misc: Tweak safe string functions slightly.Simon Howard
Properly handle cases where a very small string buffer is specified.
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-30Eliminate some uses of sprintf() from common code.Simon Howard
As part of this, add DIR_SEPARATOR_S as a string version of the DIR_SEPARATOR macro. Change M_TempFile() to return a string allocated on the C heap rather than the zone heap. This is a first step towards fixing #371.
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
2011-06-13Merge from trunk.Simon Howard
Subversion-branch: /branches/raven-branch Subversion-revision: 2347
2010-04-18Fix unsigned integer overflow with calls to M_StrCaseStr whereSimon Howard
strlen(haystack) < strlen(needle) Subversion-branch: /branches/raven-branch Subversion-revision: 1906
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-12-01Add missing header includes.Simon Howard
Subversion-branch: /branches/raven-branch Subversion-revision: 1398
2008-11-02Fix up raven-branch copyright notices.Simon Howard
Subversion-branch: /branches/raven-branch Subversion-revision: 1375
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-09-07Move m_bbox.[ch] back to common (needed by v_video.c). Remove someSimon Howard
common->doom header dependencies. Subversion-branch: /branches/raven-branch Subversion-revision: 1211
2008-09-07Move dehacked code to doom/. Split dehacked string replacement code intoSimon Howard
common code and remove dependencies on deh_main.h. Subversion-branch: /branches/raven-branch Subversion-revision: 1210
2008-09-06Remove includes of doomdef.h where possible, move generic parts into topSimon Howard
level. Subversion-branch: /branches/raven-branch Subversion-revision: 1204
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
2008-02-28Add fixes for MSVC warnings (thanks entryway).Simon Howard
Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1095
2008-02-26Minor config file documentation fixes.Simon Howard
Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1092
2008-02-25Replace manpage header, footer, environment files with a single templateSimon Howard
file. Generate documentation for the default.cfg and chocolate-doom.cfg configuration files. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1091
2008-02-24Switch to using CONFIG_VARIABLE_ macros for the configuration fileSimon Howard
tables. Add documentation for each value (for autogenerating documentation). Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1090
2008-02-11Add support for sample rate conversion using libsamplerate (thanks toSimon Howard
David Flater for this patch). Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1076
2008-01-24Make lookup tables const where possible.Simon Howard
Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1015
2008-01-20Refactor the video mode configuration system.Simon Howard
The previous system was built around the program choosing a screen mode from the user's settings, this is based around choosing settings from the specified screen mode. As such, the old screenmultiply config variable is now gone. Also, aspect ratio correction is now on by default. Add new aspect ratio correction functions for horizontal squashing (as a complement to the existing vertical stretching). Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1005
2007-12-13Add missing argument to the extraconfig command line parameter.Simon Howard
Subversion-branch: /trunk/chocolate-doom Subversion-revision: 986
2007-12-13Add @vanilla tag for Vanilla doom command line options. Add missingSimon Howard
documentation for -nosound, -nomusic, -nosfx. Fix up some bugs with the docgen wikitext output and allow control over output of Vanilla options. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 984
2007-08-31Use gcc packed attribute for all structures read/written to disk. ThisSimon Howard
fixes architectures where structure fields are aligned differently to optimise reads, causing the game to crash. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 960
2007-08-08Make M_FileExists work on directories.Simon Howard
Subversion-branch: /trunk/chocolate-doom Subversion-revision: 949
2007-08-06Remove duplicate FileExists function.Simon Howard
Subversion-branch: /trunk/chocolate-doom Subversion-revision: 944
2007-07-08Make the numeric keypad behave like Vanilla does.Simon Howard
Subversion-branch: /trunk/chocolate-doom Subversion-revision: 935
2007-06-21Add arrlen() macro as a clearer way of doing sizeof(array) /Simon Howard
sizeof(*array) Subversion-branch: /trunk/chocolate-doom Subversion-revision: 922
2007-06-20Add new configuration options for the mouse and joystick for controlsSimon Howard
that are available through the keyboard. Justification: this is already possible through advanced mouse drivers and programs like js2x, so there might as well be a proper interface for it. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 918
2007-06-14Add configuration file variable to change the sound sample rateSimon Howard
(snd_samplerate) Subversion-branch: /trunk/chocolate-doom Subversion-revision: 906
2007-05-31Initial joystick support.Simon Howard
Subversion-branch: /trunk/chocolate-doom Subversion-revision: 887
2007-03-16Add back shiftxform table so that the shift key works in multiplayerSimon Howard
chat when vanilla_keyboard_mapping is enabled. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 861
2007-03-16Add config file option to enable/disable native keyboard bindings.Simon Howard
Subversion-branch: /trunk/chocolate-doom Subversion-revision: 860
2007-03-15Use SDL for endianness byte swapping. m_swap.c removed; m_swap.h renamedSimon Howard
to i_swap.h. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 857
2007-03-10Ignore the HOME environment variable on Windows - just behave likeSimon Howard
Vanilla Doom. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 853
2007-02-23Add a configuration file value to allow the SDL video driver to beSimon Howard
explicitly specified. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 838
2007-01-06temp -> tempdirRussell Rice
update codeblocks projects (which is a new format, latest cb svn build is needed) Subversion-branch: /trunk/chocolate-doom Subversion-revision: 822
2007-01-06Choose the locations for temporary files more intelligently.Simon Howard
Subversion-branch: /trunk/chocolate-doom Subversion-revision: 821
2006-12-24Javadoc-style self-documenting system for command line options.Simon Howard
Subversion-branch: /trunk/chocolate-doom Subversion-revision: 806
2006-12-22Add definitions for PATH and directory separators.Simon Howard
Allow multiple directories to be specified in DOOMWADDIR, in the same way as PATH. Make -iwad search through all search paths for the specified IWAD. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 799
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