Switch to 'char' type for core strings; this adds some new warnings which will be taken care of later
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3451 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -32,7 +32,7 @@ typedef sint32 SDWORD;
|
|||||||
typedef UWORD COUNT;
|
typedef UWORD COUNT;
|
||||||
typedef SWORD SIZE;
|
typedef SWORD SIZE;
|
||||||
|
|
||||||
typedef unsigned char UNICODE;
|
typedef char UNICODE;
|
||||||
|
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ TextRect (TEXT *lpText, RECT *pRect, BYTE *pdelta)
|
|||||||
COORD top_y, bot_y;
|
COORD top_y, bot_y;
|
||||||
SIZE width;
|
SIZE width;
|
||||||
UniChar next_ch = 0;
|
UniChar next_ch = 0;
|
||||||
const unsigned char *pStr;
|
const char *pStr;
|
||||||
COUNT num_chars;
|
COUNT num_chars;
|
||||||
|
|
||||||
num_chars = lpText->CharCount;
|
num_chars = lpText->CharCount;
|
||||||
@@ -240,7 +240,7 @@ _text_blt (RECT *pClipRect, TEXT *TextPtr, POINT ctxOrigin)
|
|||||||
FONT FontPtr;
|
FONT FontPtr;
|
||||||
COUNT num_chars;
|
COUNT num_chars;
|
||||||
UniChar next_ch;
|
UniChar next_ch;
|
||||||
const unsigned char *pStr;
|
const char *pStr;
|
||||||
POINT origin;
|
POINT origin;
|
||||||
TFB_Image *backing;
|
TFB_Image *backing;
|
||||||
|
|
||||||
|
|||||||
@@ -16,11 +16,13 @@
|
|||||||
|
|
||||||
#include "port.h"
|
#include "port.h"
|
||||||
|
|
||||||
|
#define UNICODE_INTERNAL
|
||||||
|
#include "libs/unicode.h"
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "libs/strlib.h"
|
|
||||||
#include "libs/log.h"
|
#include "libs/log.h"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+27
-18
@@ -18,38 +18,47 @@
|
|||||||
#define UNICODE_H
|
#define UNICODE_H
|
||||||
|
|
||||||
#include "port.h"
|
#include "port.h"
|
||||||
|
#include "types.h"
|
||||||
|
// for uint32
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
// For size_t
|
// For size_t
|
||||||
|
|
||||||
typedef uint32 UniChar;
|
typedef uint32 UniChar;
|
||||||
|
|
||||||
UniChar getCharFromString(const unsigned char **ptr);
|
#ifdef UNICODE_INTERNAL
|
||||||
UniChar getCharFromStringN(const unsigned char **ptr,
|
# define UNICODE_CHAR unsigned char
|
||||||
const unsigned char *end);
|
#else
|
||||||
unsigned char *getLineFromString(const unsigned char *start,
|
# define UNICODE_CHAR char
|
||||||
const unsigned char **end, const unsigned char **startNext);
|
#endif
|
||||||
size_t utf8StringCount(const unsigned char *start);
|
|
||||||
size_t utf8StringCountN(const unsigned char *start,
|
UniChar getCharFromString(const UNICODE_CHAR **ptr);
|
||||||
const unsigned char *end);
|
UniChar getCharFromStringN(const UNICODE_CHAR **ptr,
|
||||||
int utf8StringPos (const unsigned char *pStr, UniChar ch);
|
const UNICODE_CHAR *end);
|
||||||
unsigned char *utf8StringCopy (unsigned char *dst, size_t size,
|
unsigned char *getLineFromString(const UNICODE_CHAR *start,
|
||||||
const unsigned char *src);
|
const UNICODE_CHAR **end, const UNICODE_CHAR **startNext);
|
||||||
int utf8StringCompare (const unsigned char *str1, const unsigned char *str2);
|
size_t utf8StringCount(const UNICODE_CHAR *start);
|
||||||
unsigned char *skipUTF8Chars(const unsigned char *ptr, size_t num);
|
size_t utf8StringCountN(const UNICODE_CHAR *start,
|
||||||
|
const UNICODE_CHAR *end);
|
||||||
|
int utf8StringPos (const UNICODE_CHAR *pStr, UniChar ch);
|
||||||
|
unsigned char *utf8StringCopy (UNICODE_CHAR *dst, size_t size,
|
||||||
|
const UNICODE_CHAR *src);
|
||||||
|
int utf8StringCompare (const UNICODE_CHAR *str1, const UNICODE_CHAR *str2);
|
||||||
|
UNICODE_CHAR *skipUTF8Chars(const UNICODE_CHAR *ptr, size_t num);
|
||||||
size_t getUniCharFromString(UniChar *wstr, size_t maxcount,
|
size_t getUniCharFromString(UniChar *wstr, size_t maxcount,
|
||||||
const unsigned char *start);
|
const UNICODE_CHAR *start);
|
||||||
size_t getUniCharFromStringN(UniChar *wstr, size_t maxcount,
|
size_t getUniCharFromStringN(UniChar *wstr, size_t maxcount,
|
||||||
const unsigned char *start, const unsigned char *end);
|
const UNICODE_CHAR *start, const UNICODE_CHAR *end);
|
||||||
int getStringFromChar(unsigned char *ptr, size_t size, UniChar ch);
|
int getStringFromChar(UNICODE_CHAR *ptr, size_t size, UniChar ch);
|
||||||
size_t getStringFromWideN(unsigned char *ptr, size_t size,
|
size_t getStringFromWideN(UNICODE_CHAR *ptr, size_t size,
|
||||||
const UniChar *wstr, size_t count);
|
const UniChar *wstr, size_t count);
|
||||||
size_t getStringFromWide(unsigned char *ptr, size_t size,
|
size_t getStringFromWide(UNICODE_CHAR *ptr, size_t size,
|
||||||
const UniChar *wstr);
|
const UniChar *wstr);
|
||||||
int UniChar_isGraph(UniChar ch);
|
int UniChar_isGraph(UniChar ch);
|
||||||
int UniChar_isPrint(UniChar ch);
|
int UniChar_isPrint(UniChar ch);
|
||||||
UniChar UniChar_toUpper(UniChar ch);
|
UniChar UniChar_toUpper(UniChar ch);
|
||||||
UniChar UniChar_toLower(UniChar ch);
|
UniChar UniChar_toLower(UniChar ch);
|
||||||
|
|
||||||
|
#undef UNICODE_CHAR
|
||||||
|
|
||||||
#endif /* UNICODE_H */
|
#endif /* UNICODE_H */
|
||||||
|
|
||||||
|
|||||||
+6
-6
@@ -121,7 +121,7 @@ static int
|
|||||||
_count_lines (TEXT *pText)
|
_count_lines (TEXT *pText)
|
||||||
{
|
{
|
||||||
SIZE text_width;
|
SIZE text_width;
|
||||||
const unsigned char *pStr;
|
const char *pStr;
|
||||||
int numLines = 0;
|
int numLines = 0;
|
||||||
BOOLEAN eol;
|
BOOLEAN eol;
|
||||||
|
|
||||||
@@ -151,7 +151,7 @@ add_text (int status, TEXT *pTextIn)
|
|||||||
TEXT locText;
|
TEXT locText;
|
||||||
TEXT *pText;
|
TEXT *pText;
|
||||||
SIZE leading;
|
SIZE leading;
|
||||||
const unsigned char *pStr;
|
const char *pStr;
|
||||||
SIZE text_width;
|
SIZE text_width;
|
||||||
int num_lines = 0;
|
int num_lines = 0;
|
||||||
static COORD last_baseline;
|
static COORD last_baseline;
|
||||||
@@ -311,7 +311,7 @@ add_text (int status, TEXT *pTextIn)
|
|||||||
// TRUE is returned if a complete line fitted
|
// TRUE is returned if a complete line fitted
|
||||||
// FALSE otherwise
|
// FALSE otherwise
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
getLineWithinWidth(TEXT *pText, const unsigned char **startNext,
|
getLineWithinWidth(TEXT *pText, const char **startNext,
|
||||||
SIZE maxWidth, COUNT maxChars)
|
SIZE maxWidth, COUNT maxChars)
|
||||||
{
|
{
|
||||||
BOOLEAN eol;
|
BOOLEAN eol;
|
||||||
@@ -320,8 +320,8 @@ getLineWithinWidth(TEXT *pText, const unsigned char **startNext,
|
|||||||
// We cannot add any more words.
|
// We cannot add any more words.
|
||||||
RECT rect;
|
RECT rect;
|
||||||
COUNT oldCount;
|
COUNT oldCount;
|
||||||
const unsigned char *ptr;
|
const char *ptr;
|
||||||
const unsigned char *wordStart;
|
const char *wordStart;
|
||||||
UniChar ch;
|
UniChar ch;
|
||||||
COUNT charCount;
|
COUNT charCount;
|
||||||
|
|
||||||
@@ -861,7 +861,7 @@ DoConvSummary (SUMMARY_STATE *pSS)
|
|||||||
for (row = 0; row < MAX_SUMM_ROWS && pSS->NextSub;
|
for (row = 0; row < MAX_SUMM_ROWS && pSS->NextSub;
|
||||||
++row, pSS->NextSub = GetNextTrackSubtitle (pSS->NextSub))
|
++row, pSS->NextSub = GetNextTrackSubtitle (pSS->NextSub))
|
||||||
{
|
{
|
||||||
const unsigned char *next = NULL;
|
const char *next = NULL;
|
||||||
|
|
||||||
if (pSS->LeftOver)
|
if (pSS->LeftOver)
|
||||||
{ // some text left from last subtitle
|
{ // some text left from last subtitle
|
||||||
|
|||||||
+1
-1
@@ -113,7 +113,7 @@ extern void RaceCommunication (void);
|
|||||||
|
|
||||||
#define WAIT_TRACK_ALL ((COUNT)~0)
|
#define WAIT_TRACK_ALL ((COUNT)~0)
|
||||||
extern void AlienTalkSegue (COUNT wait_track);
|
extern void AlienTalkSegue (COUNT wait_track);
|
||||||
BOOLEAN getLineWithinWidth(TEXT *pText, const unsigned char **startNext,
|
BOOLEAN getLineWithinWidth(TEXT *pText, const char **startNext,
|
||||||
SIZE maxWidth, COUNT maxChars);
|
SIZE maxWidth, COUNT maxChars);
|
||||||
|
|
||||||
extern RECT CommWndRect; /* comm window rect */
|
extern RECT CommWndRect; /* comm window rect */
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ Credits_RenderTextFrame (CONTEXT TempContext, int *istr, int dir,
|
|||||||
CONTEXT OldContext;
|
CONTEXT OldContext;
|
||||||
FRAME OldFrame;
|
FRAME OldFrame;
|
||||||
TEXT TextLines[MAX_TEXT_LINES];
|
TEXT TextLines[MAX_TEXT_LINES];
|
||||||
STRINGPTR pStr = NULL;
|
char *pStr = NULL;
|
||||||
int size;
|
int size;
|
||||||
char salign[32];
|
char salign[32];
|
||||||
char *scol;
|
char *scol;
|
||||||
|
|||||||
@@ -27,10 +27,14 @@
|
|||||||
#include "resinst.h"
|
#include "resinst.h"
|
||||||
#include "nameref.h"
|
#include "nameref.h"
|
||||||
|
|
||||||
|
|
||||||
|
// TODO: This may be better done with UniChar at the cost of a tiny bit
|
||||||
|
// of overhead to convert UniChar back to UTF8 string. This overhead
|
||||||
|
// will probably be offset by removal of looped string-compare overhead ;)
|
||||||
struct joy_char
|
struct joy_char
|
||||||
{
|
{
|
||||||
unsigned char len;
|
unsigned char len;
|
||||||
unsigned char enc[7];
|
char enc[7];
|
||||||
// 1+7 is a nice round number
|
// 1+7 is a nice round number
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -338,8 +338,8 @@ DoPresentation (void *pIS)
|
|||||||
while (pPIS->OperIndex < GetStringTableCount (pPIS->SlideShow))
|
while (pPIS->OperIndex < GetStringTableCount (pPIS->SlideShow))
|
||||||
{
|
{
|
||||||
char Opcode[16];
|
char Opcode[16];
|
||||||
|
char *pStr = GetStringAddress (pPIS->SlideShow);
|
||||||
|
|
||||||
STRINGPTR pStr = GetStringAddress (pPIS->SlideShow);
|
|
||||||
pPIS->OperIndex++;
|
pPIS->OperIndex++;
|
||||||
pPIS->SlideShow = SetRelStringTableIndex (pPIS->SlideShow, 1);
|
pPIS->SlideShow = SetRelStringTableIndex (pPIS->SlideShow, 1);
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -592,7 +592,7 @@ multiLineDrawText (TEXT *textIn, RECT *clipRect) {
|
|||||||
lineWidth = clipRect->extent.width - text.baseline.x;
|
lineWidth = clipRect->extent.width - text.baseline.x;
|
||||||
|
|
||||||
while (*text.pStr != '\0') {
|
while (*text.pStr != '\0') {
|
||||||
const unsigned char *nextLine;
|
const char *nextLine;
|
||||||
|
|
||||||
text.baseline.y += leading;
|
text.baseline.y += leading;
|
||||||
text.CharCount = (COUNT) ~0;
|
text.CharCount = (COUNT) ~0;
|
||||||
|
|||||||
+1
-1
@@ -345,7 +345,7 @@ DrawSISMessageEx (const UNICODE *pStr, SIZE CurPos, SIZE ExPos, COUNT flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DateToString (unsigned char *buf, size_t bufLen,
|
DateToString (char *buf, size_t bufLen,
|
||||||
BYTE month_index, BYTE day_index, COUNT year_index)
|
BYTE month_index, BYTE day_index, COUNT year_index)
|
||||||
{
|
{
|
||||||
snprintf (buf, bufLen, "%s %02d" STR_MIDDLE_DOT "%04d",
|
snprintf (buf, bufLen, "%s %02d" STR_MIDDLE_DOT "%04d",
|
||||||
|
|||||||
+1
-1
@@ -198,7 +198,7 @@ extern BOOLEAN DrawSISMessageEx (const UNICODE *pStr, SIZE CurPos,
|
|||||||
SIZE ExPos, COUNT flags);
|
SIZE ExPos, COUNT flags);
|
||||||
|
|
||||||
extern void DrawSISMessage (const UNICODE *pStr);
|
extern void DrawSISMessage (const UNICODE *pStr);
|
||||||
extern void DateToString (unsigned char *buf, size_t bufLen,
|
extern void DateToString (char *buf, size_t bufLen,
|
||||||
BYTE month_index, BYTE day_index, COUNT year_index);
|
BYTE month_index, BYTE day_index, COUNT year_index);
|
||||||
|
|
||||||
// Returned RECT is relative to the StatusContext
|
// Returned RECT is relative to the StatusContext
|
||||||
|
|||||||
Reference in New Issue
Block a user