Unicode fixes. Avoid int 'ch' and '(wx)char ch' in the same scope.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30399 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Włodzimierz Skiba
2004-11-09 19:17:05 +00:00
parent 55b46fd164
commit 1b392b3a68
2 changed files with 44 additions and 44 deletions

View File

@@ -262,7 +262,7 @@ void ProcessText2HTML(TexChunk *chunk)
bool changed = false; bool changed = false;
int ptr = 0; int ptr = 0;
int i = 0; int i = 0;
char ch = 1; wxChar ch = 1;
int len = wxStrlen(chunk->value); int len = wxStrlen(chunk->value);
while (ch != 0) while (ch != 0)
{ {
@@ -277,19 +277,19 @@ void ProcessText2HTML(TexChunk *chunk)
i += 2; i += 2;
changed = true; changed = true;
} }
else if (!inVerbatim && ch == '`' && (len >= i+1 && chunk->value[i+1] == '`')) else if (!inVerbatim && ch == _T('`') && (len >= i+1 && chunk->value[i+1] == '`'))
{ {
BigBuffer[ptr] = '"'; ptr ++; BigBuffer[ptr] = '"'; ptr ++;
i += 2; i += 2;
changed = true; changed = true;
} }
else if (!inVerbatim && ch == '`') // Change ` to ' else if (!inVerbatim && ch == _T('`')) // Change ` to '
{ {
BigBuffer[ptr] = 39; ptr ++; BigBuffer[ptr] = 39; ptr ++;
i += 1; i += 1;
changed = true; changed = true;
} }
else if (ch == '<') // Change < to &lt else if (ch == _T('<')) // Change < to &lt
{ {
BigBuffer[ptr] = 0; BigBuffer[ptr] = 0;
wxStrcat(BigBuffer, _T("&lt;")); wxStrcat(BigBuffer, _T("&lt;"));
@@ -297,7 +297,7 @@ void ProcessText2HTML(TexChunk *chunk)
i += 1; i += 1;
changed = true; changed = true;
} }
else if (ch == '>') // Change > to &gt else if (ch == _T('>')) // Change > to &gt
{ {
BigBuffer[ptr] = 0; BigBuffer[ptr] = 0;
wxStrcat(BigBuffer, _T("&gt;")); wxStrcat(BigBuffer, _T("&gt;"));

View File

@@ -901,7 +901,7 @@ bool ParseNewCommand(wxChar *buffer, int *pos)
int braceCount = 0; int braceCount = 0;
while (!end) while (!end)
{ {
char ch = buffer[*pos]; wxChar ch = buffer[*pos];
if (ch == _T('{')) if (ch == _T('{'))
braceCount ++; braceCount ++;
else if (ch == _T('}')) else if (ch == _T('}'))
@@ -942,7 +942,7 @@ void MacroError(wxChar *buffer)
wxChar macroBuf[200]; wxChar macroBuf[200];
macroBuf[0] = '\\'; macroBuf[0] = '\\';
int i = 1; int i = 1;
char ch; wxChar ch;
while (((ch = buffer[i-1]) != '\n') && (ch != 0)) while (((ch = buffer[i-1]) != '\n') && (ch != 0))
{ {
macroBuf[i] = ch; macroBuf[i] = ch;
@@ -1093,15 +1093,15 @@ int ParseArg(TexChunk *thisArg, wxList& children, wxChar *buffer, int pos, wxCha
} }
} }
char ch = buffer[pos]; wxChar wxCh = buffer[pos];
// End of optional argument -- pretend it's right brace for simplicity // End of optional argument -- pretend it's right brace for simplicity
if (thisArg->optional && (ch == ']')) if (thisArg->optional && (wxCh == _T(']')))
ch = '}'; wxCh = _T('}');
switch (ch) switch (wxCh)
{ {
case 0: case 0:
case '}': // End of argument case _T('}'): // End of argument
{ {
if (buf_ptr > 0) if (buf_ptr > 0)
{ {
@@ -1110,10 +1110,10 @@ int ParseArg(TexChunk *thisArg, wxList& children, wxChar *buffer, int pos, wxCha
chunk->value = copystring(BigBuffer); chunk->value = copystring(BigBuffer);
children.Append((wxObject *)chunk); children.Append((wxObject *)chunk);
} }
if (ch == '}') pos ++; if (wxCh == _T('}')) pos ++;
return pos; return pos;
} }
case '\\': case _T('\\'):
{ {
if (buf_ptr > 0) // Finish off the string we've read so far if (buf_ptr > 0) // Finish off the string we've read so far
{ {
@@ -1154,8 +1154,8 @@ int ParseArg(TexChunk *thisArg, wxList& children, wxChar *buffer, int pos, wxCha
bool end = false; bool end = false;
while (!end) while (!end)
{ {
int ch = buffer[pos]; wxChar ch = buffer[pos];
if (ch == '}') if (ch == _T('}'))
{ {
noBraces --; noBraces --;
if (noBraces == 0) if (noBraces == 0)
@@ -1165,32 +1165,32 @@ int ParseArg(TexChunk *thisArg, wxList& children, wxChar *buffer, int pos, wxCha
} }
else else
{ {
wxTex2RTFBuffer[i] = '}'; wxTex2RTFBuffer[i] = _T('}');
i ++; i ++;
} }
pos ++; pos ++;
} }
else if (ch == '{') else if (ch == _T('{'))
{ {
wxTex2RTFBuffer[i] = '{'; wxTex2RTFBuffer[i] = _T('{');
i ++; i ++;
pos ++; pos ++;
} }
else if (ch == '\\' && buffer[pos+1] == '}') else if (ch == _T('\\') && buffer[pos+1] == _T('}'))
{ {
wxTex2RTFBuffer[i] = '}'; wxTex2RTFBuffer[i] = _T('}');
pos += 2; pos += 2;
i++; i++;
} }
else if (ch == '\\' && buffer[pos+1] == '{') else if (ch == _T('\\') && buffer[pos+1] == _T('{'))
{ {
wxTex2RTFBuffer[i] = '{'; wxTex2RTFBuffer[i] = _T('{');
pos += 2; pos += 2;
i++; i++;
} }
else else
{ {
wxTex2RTFBuffer[i] = (wxChar)ch; wxTex2RTFBuffer[i] = ch;
pos ++; pos ++;
i ++; i ++;
if (ch == 0) if (ch == 0)
@@ -1218,7 +1218,7 @@ int ParseArg(TexChunk *thisArg, wxList& children, wxChar *buffer, int pos, wxCha
else if (wxStrncmp(buffer+pos, _T("verb"), 4) == 0) else if (wxStrncmp(buffer+pos, _T("verb"), 4) == 0)
{ {
pos += 4; pos += 4;
if (buffer[pos] == '*') if (buffer[pos] == _T('*'))
pos ++; pos ++;
// Find the delimiter character // Find the delimiter character
@@ -1256,8 +1256,8 @@ int ParseArg(TexChunk *thisArg, wxList& children, wxChar *buffer, int pos, wxCha
children.Append((wxObject *)chunk); children.Append((wxObject *)chunk);
} }
else else
{ {
wxChar *env = NULL; wxChar *env = NULL;
bool tmpParseToBrace = true; bool tmpParseToBrace = true;
TexMacroDef *def = MatchMacro(buffer, &pos, &env, &tmpParseToBrace); TexMacroDef *def = MatchMacro(buffer, &pos, &env, &tmpParseToBrace);
@@ -1310,10 +1310,10 @@ int ParseArg(TexChunk *thisArg, wxList& children, wxChar *buffer, int pos, wxCha
} }
// Parse constructs like {\bf thing} as if they were // Parse constructs like {\bf thing} as if they were
// \bf{thing} // \bf{thing}
case '{': case _T('{'):
{ {
pos ++; pos ++;
if (buffer[pos] == '\\') if (buffer[pos] == _T('\\'))
{ {
if (buf_ptr > 0) if (buf_ptr > 0)
{ {
@@ -1363,7 +1363,7 @@ int ParseArg(TexChunk *thisArg, wxList& children, wxChar *buffer, int pos, wxCha
} }
} }
else else
{ {
/* /*
* If all else fails, we assume that we have * If all else fails, we assume that we have
* a pair of braces on their own, so return a `dummy' macro * a pair of braces on their own, so return a `dummy' macro
@@ -1396,10 +1396,10 @@ int ParseArg(TexChunk *thisArg, wxList& children, wxChar *buffer, int pos, wxCha
arg->macroId = chunk->macroId; arg->macroId = chunk->macroId;
pos = ParseArg(arg, arg->children, buffer, pos, NULL, true, customMacroArgs); pos = ParseArg(arg, arg->children, buffer, pos, NULL, true, customMacroArgs);
} }
break; break;
} }
case '$': case _T('$'):
{ {
if (buf_ptr > 0) if (buf_ptr > 0)
{ {
@@ -1412,7 +1412,7 @@ int ParseArg(TexChunk *thisArg, wxList& children, wxChar *buffer, int pos, wxCha
pos ++; pos ++;
if (buffer[pos] == '$') if (buffer[pos] == _T('$'))
{ {
TexChunk *chunk = new TexChunk(CHUNK_TYPE_MACRO); TexChunk *chunk = new TexChunk(CHUNK_TYPE_MACRO);
chunk->no_args = 0; chunk->no_args = 0;
@@ -1431,7 +1431,7 @@ int ParseArg(TexChunk *thisArg, wxList& children, wxChar *buffer, int pos, wxCha
} }
break; break;
} }
case '~': case _T('~'):
{ {
if (buf_ptr > 0) if (buf_ptr > 0)
{ {
@@ -1450,7 +1450,7 @@ int ParseArg(TexChunk *thisArg, wxList& children, wxChar *buffer, int pos, wxCha
children.Append((wxObject *)chunk); children.Append((wxObject *)chunk);
break; break;
} }
case '#': // Either treat as a special TeX character or as a macro arg case _T('#'): // Either treat as a special TeX character or as a macro arg
{ {
if (buf_ptr > 0) if (buf_ptr > 0)
{ {
@@ -1486,12 +1486,12 @@ int ParseArg(TexChunk *thisArg, wxList& children, wxChar *buffer, int pos, wxCha
} }
break; break;
} }
case '&': case _T('&'):
{ {
// Remove white space before and after the ampersand, // Remove white space before and after the ampersand,
// since this is probably a table column separator with // since this is probably a table column separator with
// some convenient -- but useless -- white space in the text. // some convenient -- but useless -- white space in the text.
while ((buf_ptr > 0) && ((BigBuffer[buf_ptr-1] == ' ') || (BigBuffer[buf_ptr-1] == 9))) while ((buf_ptr > 0) && ((BigBuffer[buf_ptr-1] == _T(' ')) || (BigBuffer[buf_ptr-1] == 9)))
buf_ptr --; buf_ptr --;
if (buf_ptr > 0) if (buf_ptr > 0)
@@ -1505,7 +1505,7 @@ int ParseArg(TexChunk *thisArg, wxList& children, wxChar *buffer, int pos, wxCha
pos ++; pos ++;
while (buffer[pos] == ' ' || buffer[pos] == 9) while (buffer[pos] == _T(' ') || buffer[pos] == 9)
pos ++; pos ++;
TexChunk *chunk = new TexChunk(CHUNK_TYPE_MACRO); TexChunk *chunk = new TexChunk(CHUNK_TYPE_MACRO);
@@ -1516,13 +1516,13 @@ int ParseArg(TexChunk *thisArg, wxList& children, wxChar *buffer, int pos, wxCha
break; break;
} }
// Eliminate end-of-line comment // Eliminate end-of-line comment
case '%': case _T('%'):
{ {
ch = buffer[pos]; wxCh = buffer[pos];
while (ch != 10 && ch != 13 && ch != 0) while (wxCh != 10 && wxCh != 13 && wxCh != 0)
{ {
pos ++; pos ++;
ch = buffer[pos]; wxCh = buffer[pos];
} }
if (buffer[pos] == 10 || buffer[pos] == 13) if (buffer[pos] == 10 || buffer[pos] == 13)
{ {
@@ -1534,7 +1534,7 @@ int ParseArg(TexChunk *thisArg, wxList& children, wxChar *buffer, int pos, wxCha
// Eliminate tab // Eliminate tab
case 9: case 9:
{ {
BigBuffer[buf_ptr] = ' '; BigBuffer[buf_ptr] = _T(' ');
BigBuffer[buf_ptr+1] = 0; BigBuffer[buf_ptr+1] = 0;
buf_ptr ++; buf_ptr ++;
pos ++; pos ++;
@@ -1542,7 +1542,7 @@ int ParseArg(TexChunk *thisArg, wxList& children, wxChar *buffer, int pos, wxCha
} }
default: default:
{ {
BigBuffer[buf_ptr] = ch; BigBuffer[buf_ptr] = wxCh;
BigBuffer[buf_ptr+1] = 0; BigBuffer[buf_ptr+1] = 0;
buf_ptr ++; buf_ptr ++;
pos ++; pos ++;