Skip to content

Commit

Permalink
Unix: Relocated strupr/strlwr to libdeng1
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Jan 2, 2013
1 parent ecbe1e8 commit 9b74db4
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 27 deletions.
6 changes: 0 additions & 6 deletions doomsday/engine/api/dd_share.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,6 @@ extern "C" {
#if UNIX
# define stricmp strcasecmp
# define strnicmp strncasecmp

/**
* There are manual implementations for these string handling routines:
*/
char* strupr(char *string);
char* strlwr(char *string);
#endif

int dd_snprintf(char* str, size_t size, const char* format, ...);
Expand Down
21 changes: 0 additions & 21 deletions doomsday/engine/src/dd_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2934,27 +2934,6 @@ D_CMD(ReloadGame)
return true;
}

#ifdef UNIX
/**
* Some routines not available on the *nix platform.
*/
char* strupr(char* string)
{
char* ch = string;
for(; *ch; ch++)
*ch = toupper(*ch);
return string;
}

char* strlwr(char* string)
{
char* ch = string;
for(; *ch; ch++)
*ch = tolower(*ch);
return string;
}
#endif

/**
* Prints a formatted string into a fixed-size buffer. At most @c size
* characters will be written to the output buffer @c str. The output will
Expand Down
6 changes: 6 additions & 0 deletions doomsday/libdeng/include/de/str.h
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,12 @@ DENG_PUBLIC Str *Str_FromAutoStr(AutoStr *as);
*/
DENG_PUBLIC int dd_vsnprintf(char *str, size_t size, char const *format, va_list ap);

#ifdef UNIX
// Some routines not available on the *nix platform.
DENG_PUBLIC char *strupr(char *string);
DENG_PUBLIC char *strlwr(char *string);
#endif // UNIX

#ifdef __cplusplus
} // extern "C"
# include "str.hh" // C++ wrapper for ddstring_t
Expand Down
19 changes: 19 additions & 0 deletions doomsday/libdeng/src/str.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <ctype.h>

#if WIN32
# define strcasecmp _stricmp
Expand Down Expand Up @@ -885,3 +886,21 @@ int dd_vsnprintf(char *str, size_t size, char const *format, va_list ap)
return result >= (int)size? -1 : (int)size;
#endif
}

#ifdef UNIX

char* strupr(char* string)
{
char* ch = string;
for(; *ch; ch++) *ch = toupper(*ch);
return string;
}

char* strlwr(char* string)
{
char* ch = string;
for(; *ch; ch++) *ch = tolower(*ch);
return string;
}

#endif

0 comments on commit 9b74db4

Please sign in to comment.