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:
avolkov
2009-12-19 23:39:40 +00:00
parent b9472023a6
commit 5b15514f18
12 changed files with 50 additions and 35 deletions
+1 -1
View File
@@ -32,7 +32,7 @@ typedef sint32 SDWORD;
typedef UWORD COUNT;
typedef SWORD SIZE;
typedef unsigned char UNICODE;
typedef char UNICODE;
typedef enum
+2 -2
View File
@@ -130,7 +130,7 @@ TextRect (TEXT *lpText, RECT *pRect, BYTE *pdelta)
COORD top_y, bot_y;
SIZE width;
UniChar next_ch = 0;
const unsigned char *pStr;
const char *pStr;
COUNT num_chars;
num_chars = lpText->CharCount;
@@ -240,7 +240,7 @@ _text_blt (RECT *pClipRect, TEXT *TextPtr, POINT ctxOrigin)
FONT FontPtr;
COUNT num_chars;
UniChar next_ch;
const unsigned char *pStr;
const char *pStr;
POINT origin;
TFB_Image *backing;
+3 -1
View File
@@ -16,11 +16,13 @@
#include "port.h"
#define UNICODE_INTERNAL
#include "libs/unicode.h"
#include <ctype.h>
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include "libs/strlib.h"
#include "libs/log.h"
+27 -18
View File
@@ -18,38 +18,47 @@
#define UNICODE_H
#include "port.h"
#include "types.h"
// for uint32
#include <sys/types.h>
// For size_t
typedef uint32 UniChar;
UniChar getCharFromString(const unsigned char **ptr);
UniChar getCharFromStringN(const unsigned char **ptr,
const unsigned char *end);
unsigned char *getLineFromString(const unsigned char *start,
const unsigned char **end, const unsigned char **startNext);
size_t utf8StringCount(const unsigned char *start);
size_t utf8StringCountN(const unsigned char *start,
const unsigned char *end);
int utf8StringPos (const unsigned char *pStr, UniChar ch);
unsigned char *utf8StringCopy (unsigned char *dst, size_t size,
const unsigned char *src);
int utf8StringCompare (const unsigned char *str1, const unsigned char *str2);
unsigned char *skipUTF8Chars(const unsigned char *ptr, size_t num);
#ifdef UNICODE_INTERNAL
# define UNICODE_CHAR unsigned char
#else
# define UNICODE_CHAR char
#endif
UniChar getCharFromString(const UNICODE_CHAR **ptr);
UniChar getCharFromStringN(const UNICODE_CHAR **ptr,
const UNICODE_CHAR *end);
unsigned char *getLineFromString(const UNICODE_CHAR *start,
const UNICODE_CHAR **end, const UNICODE_CHAR **startNext);
size_t utf8StringCount(const UNICODE_CHAR *start);
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,
const unsigned char *start);
const UNICODE_CHAR *start);
size_t getUniCharFromStringN(UniChar *wstr, size_t maxcount,
const unsigned char *start, const unsigned char *end);
int getStringFromChar(unsigned char *ptr, size_t size, UniChar ch);
size_t getStringFromWideN(unsigned char *ptr, size_t size,
const UNICODE_CHAR *start, const UNICODE_CHAR *end);
int getStringFromChar(UNICODE_CHAR *ptr, size_t size, UniChar ch);
size_t getStringFromWideN(UNICODE_CHAR *ptr, size_t size,
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);
int UniChar_isGraph(UniChar ch);
int UniChar_isPrint(UniChar ch);
UniChar UniChar_toUpper(UniChar ch);
UniChar UniChar_toLower(UniChar ch);
#undef UNICODE_CHAR
#endif /* UNICODE_H */
+6 -6
View File
@@ -121,7 +121,7 @@ static int
_count_lines (TEXT *pText)
{
SIZE text_width;
const unsigned char *pStr;
const char *pStr;
int numLines = 0;
BOOLEAN eol;
@@ -151,7 +151,7 @@ add_text (int status, TEXT *pTextIn)
TEXT locText;
TEXT *pText;
SIZE leading;
const unsigned char *pStr;
const char *pStr;
SIZE text_width;
int num_lines = 0;
static COORD last_baseline;
@@ -311,7 +311,7 @@ add_text (int status, TEXT *pTextIn)
// TRUE is returned if a complete line fitted
// FALSE otherwise
BOOLEAN
getLineWithinWidth(TEXT *pText, const unsigned char **startNext,
getLineWithinWidth(TEXT *pText, const char **startNext,
SIZE maxWidth, COUNT maxChars)
{
BOOLEAN eol;
@@ -320,8 +320,8 @@ getLineWithinWidth(TEXT *pText, const unsigned char **startNext,
// We cannot add any more words.
RECT rect;
COUNT oldCount;
const unsigned char *ptr;
const unsigned char *wordStart;
const char *ptr;
const char *wordStart;
UniChar ch;
COUNT charCount;
@@ -861,7 +861,7 @@ DoConvSummary (SUMMARY_STATE *pSS)
for (row = 0; row < MAX_SUMM_ROWS && pSS->NextSub;
++row, pSS->NextSub = GetNextTrackSubtitle (pSS->NextSub))
{
const unsigned char *next = NULL;
const char *next = NULL;
if (pSS->LeftOver)
{ // some text left from last subtitle
+1 -1
View File
@@ -113,7 +113,7 @@ extern void RaceCommunication (void);
#define WAIT_TRACK_ALL ((COUNT)~0)
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);
extern RECT CommWndRect; /* comm window rect */
+1 -1
View File
@@ -142,7 +142,7 @@ Credits_RenderTextFrame (CONTEXT TempContext, int *istr, int dir,
CONTEXT OldContext;
FRAME OldFrame;
TEXT TextLines[MAX_TEXT_LINES];
STRINGPTR pStr = NULL;
char *pStr = NULL;
int size;
char salign[32];
char *scol;
+5 -1
View File
@@ -27,10 +27,14 @@
#include "resinst.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
{
unsigned char len;
unsigned char enc[7];
char enc[7];
// 1+7 is a nice round number
};
+1 -1
View File
@@ -338,8 +338,8 @@ DoPresentation (void *pIS)
while (pPIS->OperIndex < GetStringTableCount (pPIS->SlideShow))
{
char Opcode[16];
char *pStr = GetStringAddress (pPIS->SlideShow);
STRINGPTR pStr = GetStringAddress (pPIS->SlideShow);
pPIS->OperIndex++;
pPIS->SlideShow = SetRelStringTableIndex (pPIS->SlideShow, 1);
+1 -1
View File
@@ -592,7 +592,7 @@ multiLineDrawText (TEXT *textIn, RECT *clipRect) {
lineWidth = clipRect->extent.width - text.baseline.x;
while (*text.pStr != '\0') {
const unsigned char *nextLine;
const char *nextLine;
text.baseline.y += leading;
text.CharCount = (COUNT) ~0;
+1 -1
View File
@@ -345,7 +345,7 @@ DrawSISMessageEx (const UNICODE *pStr, SIZE CurPos, SIZE ExPos, COUNT flags)
}
void
DateToString (unsigned char *buf, size_t bufLen,
DateToString (char *buf, size_t bufLen,
BYTE month_index, BYTE day_index, COUNT year_index)
{
snprintf (buf, bufLen, "%s %02d" STR_MIDDLE_DOT "%04d",
+1 -1
View File
@@ -198,7 +198,7 @@ extern BOOLEAN DrawSISMessageEx (const UNICODE *pStr, SIZE CurPos,
SIZE ExPos, COUNT flags);
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);
// Returned RECT is relative to the StatusContext