From bd88bcea69549a245e85451633710fae505a24a4 Mon Sep 17 00:00:00 2001 From: Peter Veenstra Date: Sun, 13 Jan 2008 11:28:41 +0000 Subject: [PATCH] Add low- and uppercase for std::string. Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3078 --- include/support.h | 9 +++++---- src/misc/support.cpp | 18 +++++++++++++++++- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/include/support.h b/include/support.h index 2b7e66ea..5933de19 100644 --- a/include/support.h +++ b/include/support.h @@ -16,10 +16,13 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +/* $Id: support.h,v 1.16 2008-01-13 11:28:41 qbix79 Exp $ */ + #ifndef DOSBOX_SUPPORT_H #define DOSBOX_SUPPORT_H #include +#include #include #ifndef DOSBOX_DOSBOX_H #include "dosbox.h" @@ -28,10 +31,6 @@ #if defined (_MSC_VER) /* MS Visual C++ */ #define strcasecmp(a,b) stricmp(a,b) #define strncasecmp(a,b,n) _strnicmp(a,b,n) -// if (stricmp(name,devices[index]->name)==0) return index; -#else -//if (strcasecmp(name,devices[index]->name)==0) return index; -//#define nocasestrcmp(a,b) stricmp(a,b) #endif #define safe_strncpy(a,b,n) do { strncpy((a),(b),(n)-1); (a)[(n)-1] = 0; } while (0) @@ -63,5 +62,7 @@ INLINE char * lowcase(char * str) { return str; } +void upcase(std::string &str); +void lowcase(std::string &str); #endif diff --git a/src/misc/support.cpp b/src/misc/support.cpp index f51ad77b..070235e6 100644 --- a/src/misc/support.cpp +++ b/src/misc/support.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: support.cpp,v 1.33 2007-10-31 11:45:14 qbix79 Exp $ */ +/* $Id: support.cpp,v 1.34 2008-01-13 11:28:41 qbix79 Exp $ */ #include #include @@ -25,11 +25,27 @@ #include #include #include +#include +#include +#include + #include "dosbox.h" #include "debug.h" #include "support.h" #include "video.h" + +void upcase(std::string &str) { + int (*tf)(int) = std::toupper; + std::transform(str.begin(), str.end(), str.begin(), tf); +} + +void lowcase(std::string &str) { + int (*tf)(int) = std::tolower; + std::transform(str.begin(), str.end(), str.begin(), tf); +} + + /* Ripped some source from freedos for this one.