From: Vadim Zeitlin Date: Sat, 17 Mar 2007 22:52:29 +0000 (+0000) Subject: compilation fixes after c_str() changes (due to casting of its return value to non... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/1693108cfeb77447c492714a0a7936c35a51c284?ds=sidebyside;hp=f705f97d31756e00d3553210a5623e07df48cd81 compilation fixes after c_str() changes (due to casting of its return value to non-const wxChar *) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44880 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/utils/tex2rtf/src/htmlutil.cpp b/utils/tex2rtf/src/htmlutil.cpp index c78636b467..374113764e 100644 --- a/utils/tex2rtf/src/htmlutil.cpp +++ b/utils/tex2rtf/src/htmlutil.cpp @@ -1874,7 +1874,7 @@ static bool CheckTypeRef() label.Trim(true); label.Trim(false); wxString typeName = label; label.MakeLower(); - TexRef *texRef = FindReference((wxChar*)label.c_str()); + TexRef *texRef = FindReference(label); if (texRef && texRef->refFile && wxStrcmp(texRef->refFile, _T("??")) != 0) { int a = typeDecl.Find(typeName); @@ -2150,7 +2150,7 @@ bool HTMLOnArgument(int macroId, int arg_no, bool start) { wxString errBuf; errBuf.Printf(_T("Warning: unresolved reference '%s'"), refName); - OnInform((wxChar *)errBuf.c_str()); + OnInform(errBuf); } } } @@ -2302,7 +2302,7 @@ bool HTMLOnArgument(int macroId, int arg_no, bool start) if (f != _T("")) { // The default HTML file to go to is THIS file (so a no-op) - SHGToMap((wxChar *)f.c_str(), currentFileName); + SHGToMap(f, currentFileName); } wxChar *mapName = GetArgData(); diff --git a/utils/tex2rtf/src/readshg.cpp b/utils/tex2rtf/src/readshg.cpp index 3d5cc5ee12..86e08e5eef 100644 --- a/utils/tex2rtf/src/readshg.cpp +++ b/utils/tex2rtf/src/readshg.cpp @@ -107,7 +107,7 @@ int ParseSHG( const wxChar* fileName, HotSpot **hotspots) // Convert Windows .SHG file to HTML map file -bool SHGToMap(wxChar *filename, wxChar *defaultFile) +bool SHGToMap(const wxChar *filename, const wxChar *defaultFile) { // Test the SHG parser HotSpot *hotspots = NULL; diff --git a/utils/tex2rtf/src/readshg.h b/utils/tex2rtf/src/readshg.h index f710f3a341..36df3f9d2e 100644 --- a/utils/tex2rtf/src/readshg.h +++ b/utils/tex2rtf/src/readshg.h @@ -58,7 +58,7 @@ struct HotSpot extern int ParseSHG( const wxChar* fileName, HotSpot **hotspots); // Converts Windows .SHG file to HTML map file -extern bool SHGToMap(wxChar *filename, wxChar *defaultFile); +extern bool SHGToMap(const wxChar *filename, const wxChar *defaultFile); #endif diff --git a/utils/tex2rtf/src/rtfutils.cpp b/utils/tex2rtf/src/rtfutils.cpp index 7bd7636c42..5f59fea4e3 100644 --- a/utils/tex2rtf/src/rtfutils.cpp +++ b/utils/tex2rtf/src/rtfutils.cpp @@ -3552,7 +3552,7 @@ bool RTFOnArgument(int macroId, int arg_no, bool start) if(tok.HasMoreTokens()) { wxString token = tok.GetNextToken(); - imageWidth = (int)(20*ParseUnitArgument((wxChar*)token.c_str())); + imageWidth = (int)(20*ParseUnitArgument(token)); } else { @@ -3563,7 +3563,7 @@ bool RTFOnArgument(int macroId, int arg_no, bool start) if(tok.HasMoreTokens()) { wxString token = tok.GetNextToken(); - imageHeight = (int)(20*ParseUnitArgument((wxChar*)token.c_str())); + imageHeight = (int)(20*ParseUnitArgument(token)); } else { diff --git a/utils/tex2rtf/src/tex2any.cpp b/utils/tex2rtf/src/tex2any.cpp index 01db1ed032..488a200c85 100644 --- a/utils/tex2rtf/src/tex2any.cpp +++ b/utils/tex2rtf/src/tex2any.cpp @@ -283,13 +283,13 @@ void ForbidWarning(TexMacroDef *def) case FORBID_WARN: { informBuf.Printf(_T("Warning: it is recommended that command %s is not used."), def->name); - OnInform((const wxChar *)informBuf.c_str()); + OnInform(informBuf); break; } case FORBID_ABSOLUTELY: { informBuf.Printf(_T("Error: command %s cannot be used and will lead to errors."), def->name); - OnInform((const wxChar *)informBuf.c_str()); + OnInform(informBuf); break; } default: @@ -449,7 +449,7 @@ bool read_a_line(wxChar *buf) wxString errBuf; errBuf.Printf(_T("Line %lu of file %s is too long. Lines can be no longer than %lu characters. Truncated."), LineNumbers[CurrentInputIndex], (const wxChar*) currentFileName.c_str(), MAX_LINE_BUFFER_SIZE); - OnError((wxChar *)errBuf.c_str()); + OnError(errBuf); return false; } @@ -471,7 +471,7 @@ bool read_a_line(wxChar *buf) { wxString errBuf; errBuf.Printf(_T("An extra right Curly brace ('}') was detected at line %lu inside file %s"), LineNumbers[CurrentInputIndex], (const wxChar*) currentFileName.c_str()); - OnError((wxChar *)errBuf.c_str()); + OnError(errBuf); // Reduce the count of right Curly braces, so the mismatched count // isn't reported on every line that has a '}' after the first mismatch @@ -500,7 +500,7 @@ bool read_a_line(wxChar *buf) wxString errBuf; errBuf.Printf(_T("Line %lu of file %s is too long. Lines can be no longer than %lu characters. Truncated."), LineNumbers[CurrentInputIndex], (const wxChar*) currentFileName.c_str(),MAX_LINE_BUFFER_SIZE); - OnError((wxChar *)errBuf.c_str()); + OnError(errBuf); return false; } wxStrcat(buf, _T("\\par")); @@ -515,7 +515,7 @@ bool read_a_line(wxChar *buf) wxString errBuf; errBuf.Printf(_T("Line %lu of file %s is too long. Lines can be no longer than %lu characters. Truncated."), LineNumbers[CurrentInputIndex], (const wxChar*) currentFileName.c_str(),MAX_LINE_BUFFER_SIZE); - OnError((wxChar *)errBuf.c_str()); + OnError(errBuf); return false; } @@ -540,7 +540,7 @@ bool read_a_line(wxChar *buf) wxString errBuf; errBuf.Printf(_T("Line %lu of file %s is too long. Lines can be no longer than %lu characters. Truncated."), LineNumbers[CurrentInputIndex], (const wxChar*) currentFileName.c_str(),MAX_LINE_BUFFER_SIZE); - OnError((wxChar *)errBuf.c_str()); + OnError(errBuf); return false; } buf[bufIndex++]='\\'; @@ -563,7 +563,7 @@ bool read_a_line(wxChar *buf) wxString errBuf; errBuf.Printf(_T("Line %lu of file %s is too long. Lines can be no longer than %lu characters. Truncated."), LineNumbers[CurrentInputIndex], (const wxChar*) currentFileName.c_str(),MAX_LINE_BUFFER_SIZE); - OnError((wxChar *)errBuf.c_str()); + OnError(errBuf); return false; } buf[bufIndex++]='\\'; @@ -578,7 +578,7 @@ bool read_a_line(wxChar *buf) wxString errBuf; errBuf.Printf(_T("Line %lu of file %s is too long. Lines can be no longer than %lu characters. Truncated."), LineNumbers[CurrentInputIndex], (const wxChar*) currentFileName.c_str(),MAX_LINE_BUFFER_SIZE); - OnError((wxChar *)errBuf.c_str()); + OnError(errBuf); return false; } // If the current character read in is a '_', we need to check @@ -599,7 +599,7 @@ bool read_a_line(wxChar *buf) // wxString errBuf; // errBuf.Printf(_T("An underscore ('_') was detected at line %lu inside file %s that should NOT have a '\\' before it."), // LineNumbers[CurrentInputIndex], (const wxChar*) currentFileName.c_str()); -// OnError((wxChar *)errBuf.c_str()); +// OnError(errBuf); } } else @@ -610,7 +610,7 @@ bool read_a_line(wxChar *buf) wxString errBuf; errBuf.Printf(_T("An underscore ('_') was detected at line %lu inside file %s that may need a '\\' before it."), LineNumbers[CurrentInputIndex], (const wxChar*) currentFileName.c_str()); - OnError((wxChar *)errBuf.c_str()); + OnError(errBuf); } else if ((buf[bufIndex-1] != '\\') && (buf[0] != '%') && // If it is a comment line, then no warnings (wxStrncmp(buf, _T("\\input"), 6))) // do not report filenames that have underscores in them @@ -618,7 +618,7 @@ bool read_a_line(wxChar *buf) wxString errBuf; errBuf.Printf(_T("An underscore ('_') was detected at line %lu inside file %s that may need a '\\' before it."), LineNumbers[CurrentInputIndex], (const wxChar*) currentFileName.c_str()); - OnError((wxChar *)errBuf.c_str()); + OnError(errBuf); } } } @@ -643,7 +643,7 @@ bool read_a_line(wxChar *buf) wxString errBuf; errBuf.Printf(_T("Curly braces do not match inside file %s\n%lu opens, %lu closes"), (const wxChar*) currentFileName.c_str(),leftCurly,rightCurly); - OnError((wxChar *)errBuf.c_str()); + OnError(errBuf); } leftCurly = 0; rightCurly = 0; @@ -694,13 +694,13 @@ bool read_a_line(wxChar *buf) { wxString errBuf; errBuf.Printf(_T("Could not find file: %s"),fileName); - OnError((wxChar *)errBuf.c_str()); + OnError(errBuf); } else { wxString informStr; informStr.Printf(_T("Processing: %s"),actualFile.c_str()); - OnInform((wxChar *)informStr.c_str()); + OnInform(informStr); CurrentInputIndex ++; Inputs[CurrentInputIndex] = wxFopen(actualFile, _T("r")); @@ -758,7 +758,7 @@ bool read_a_line(wxChar *buf) fileNameStr.Replace(_T("\\"), _T("")); // Ignore some types of input files (e.g. macro definition files) - wxChar *fileOnly = wxFileNameFromPath((wxChar*) (const wxChar*) fileNameStr); + wxString fileOnly = wxFileNameFromPath(fileNameStr); currentFileName = fileOnly; if (IgnorableInputFiles.Member(fileOnly)) return read_a_line(buf); @@ -776,7 +776,7 @@ bool read_a_line(wxChar *buf) { wxString errBuf; errBuf.Printf(_T("Could not find file: %s"),fileName); - OnError((wxChar *)errBuf.c_str()); + OnError(errBuf); } else { @@ -786,7 +786,7 @@ bool read_a_line(wxChar *buf) wxString informStr; informStr.Printf(_T("Processing: %s"),actualFile.c_str()); - OnInform((wxChar *)informStr.c_str()); + OnInform(informStr); CurrentInputIndex ++; Inputs[CurrentInputIndex] = wxFopen(actualFile, _T("r")); @@ -800,7 +800,7 @@ bool read_a_line(wxChar *buf) wxString errBuf; errBuf.Printf(_T("Could not open include file %s"), (const wxChar*) actualFile); CurrentInputIndex --; - OnError((wxChar *)errBuf.c_str()); + OnError(errBuf); } } bool succ = read_a_line(buf); @@ -833,7 +833,7 @@ bool read_a_line(wxChar *buf) LineNumbers[CurrentInputIndex], currentFileName.c_str()); } - OnError((wxChar *)errBuf.c_str()); + OnError(errBuf); } } } @@ -853,7 +853,7 @@ bool read_a_line(wxChar *buf) wxString errBuf; errBuf.Printf(_T("Curly braces do not match inside file %s\n%lu opens, %lu closes"), (const wxChar*) currentFileName.c_str(),leftCurly,rightCurly); - OnError((wxChar *)errBuf.c_str()); + OnError(errBuf); } } @@ -951,7 +951,7 @@ void MacroError(wxChar *buffer) errBuf.Printf(_T("Could not find macro: %s at line %d, file %s"), macroBuf, (int)(LineNumbers[CurrentInputIndex]-1), FileNames[CurrentInputIndex]); - OnError((wxChar *)errBuf.c_str()); + OnError(errBuf); if (wxStrcmp(macroBuf,_T("\\end{document}")) == 0) { @@ -1634,7 +1634,7 @@ int ParseMacroBody(const wxChar *WXUNUSED(macro_name), TexChunk *parent, tmpBuffer = tmpBuffer.Mid(0,tmpBuffer.length()-4); } errBuf.Printf(_T("Missing macro argument in the line:\n\t%s\n"),tmpBuffer.c_str()); - OnError((wxChar *)errBuf.c_str()); + OnError(errBuf); } } @@ -3249,7 +3249,7 @@ bool DefaultOnArgument(int macroId, int arg_no, bool start) { wxString informBuf; informBuf.Printf(_T("Warning: unresolved reference '%s'"), refName); - OnInform((wxChar *)informBuf.c_str()); + OnInform(informBuf); } } else TexOutput(_T("??"), true); @@ -3403,7 +3403,7 @@ bool DefaultOnArgument(int macroId, int arg_no, bool start) { wxString informBuf; informBuf.Printf(_T("Warning: unresolved citation %s."), citeKey); - OnInform((wxChar *)informBuf.c_str()); + OnInform(informBuf); } } citeKey = ParseMultifieldString(citeKeys, &pos); @@ -3544,14 +3544,14 @@ bool DefaultOnArgument(int macroId, int arg_no, bool start) { wxString errBuf; errBuf.Printf(_T(".bib file %s not found or malformed"), (const wxChar*) actualFile); - OnError((wxChar *)errBuf.c_str()); + OnError(errBuf); } } else { wxString errBuf; errBuf.Printf(_T(".bib file %s not found"), fileBuf); - OnError((wxChar *)errBuf.c_str()); + OnError(errBuf); } bibFile = ParseMultifieldString(allFiles, &pos); } diff --git a/utils/tex2rtf/src/tex2any.h b/utils/tex2rtf/src/tex2any.h index 9b78d397c9..d05a643333 100644 --- a/utils/tex2rtf/src/tex2any.h +++ b/utils/tex2rtf/src/tex2any.h @@ -356,10 +356,10 @@ void DefaultOnMacro(int macroId, int no_args, bool start); bool DefaultOnArgument(int macroId, int arg_no, bool start); // Called on error -void OnError(const wxChar *msg); +void OnError(const wxString& msg); // Called for information -void OnInform(const wxChar *msg); +void OnInform(const wxString& msg); // Special yield wrapper void Tex2RTFYield(bool force = false); @@ -377,7 +377,7 @@ void ForceTopicName(const wxChar *name); void ResetTopicCounter(void); // Parse unit eg. 14, 12pt, 34cm and return value in points. -int ParseUnitArgument(wxChar *unitArg); +int ParseUnitArgument(const wxChar *unitArg); // Set small, large, normal etc. point sizes for reference size void SetFontSizes(int pointSize); @@ -483,11 +483,11 @@ class BibEntry: public wxObject extern wxList BibList; extern wxStringList CitationList; -bool ReadBib(wxChar *filename); +bool ReadBib(const wxChar *filename); void OutputBib(void); void ResolveBibReferences(void); -void AddCitation(wxChar *citeKey); -TexRef *FindReference(wxChar *key); +void AddCitation(const wxChar *citeKey); +TexRef *FindReference(const wxChar *key); /* * Ability to customize, or at least suppress unknown macro errors diff --git a/utils/tex2rtf/src/tex2rtf.cpp b/utils/tex2rtf/src/tex2rtf.cpp index b560cd0c04..55e7af99d8 100644 --- a/utils/tex2rtf/src/tex2rtf.cpp +++ b/utils/tex2rtf/src/tex2rtf.cpp @@ -290,7 +290,7 @@ bool MyApp::OnInit() { wxString buf; buf.Printf(_T("Invalid switch %s.\n"), argv[i]); - OnError((wxChar *)buf.c_str()); + OnError(buf); #ifdef NO_GUI ShowOptions(); exit(1); @@ -701,7 +701,7 @@ void MyFrame::OnGo(wxCommandEvent& WXUNUSED(event)) #endif // wxUSE_STATUSBAR wxString errBuf; errBuf.Printf(_T("\nErrors encountered during this pass: %lu\n"), errorCount); - OnInform((wxChar *)errBuf.c_str()); + OnInform(errBuf); } @@ -898,7 +898,7 @@ void ChooseInputFile(bool force) wxString str = wxFileNameFromPath(InputFile); wxString buf; buf.Printf(_T("Tex2RTF [%s]"), str.c_str()); - frame->SetTitle((wxChar *)buf.c_str()); + frame->SetTitle(buf); OutputFile = wxEmptyString; } } @@ -1027,7 +1027,7 @@ bool Go(void) { wxString buf; buf.Printf(_T("Working, pass %d...Click CLOSE to abort"), passNumber); - frame->SetStatusText((wxChar *)buf.c_str()); + frame->SetStatusText(buf); } #endif OkToClose = false; @@ -1077,28 +1077,28 @@ bool Go(void) #ifndef NO_GUI wxLongLong elapsed = wxGetLocalTimeMillis() - localTime; buf.Printf(_T("Finished PASS #%d in %ld seconds.\n"), passNumber, (long)(elapsed.GetLo()/1000.0)); - OnInform((wxChar *)buf.c_str()); + OnInform(buf); if (errorCount) { buf.Printf(_T("Errors encountered during this pass: %lu\n"), errorCount); - OnInform((wxChar *)buf.c_str()); + OnInform(buf); } #if wxUSE_STATUSBAR if (isInteractive) { buf.Printf(_T("Done, %d %s."), passNumber, (passNumber > 1) ? _T("passes") : _T("pass")); - frame->SetStatusText((wxChar *)buf.c_str()); + frame->SetStatusText(buf); } #endif // wxUSE_STATUSBAR #else buf.Printf(_T("Done, %d %s."), passNumber, (passNumber > 1) ? _T("passes") : _T("pass")); - OnInform((wxChar *)buf.c_str()); + OnInform(buf); if (errorCount) { buf.Printf(_T("Errors encountered during this pass: %lu\n"), errorCount); - OnInform((wxChar *)buf.c_str()); + OnInform(buf.c_str()); } #endif passNumber ++; @@ -1119,13 +1119,12 @@ bool Go(void) return false; } -void OnError(const wxChar *msg) +void OnError(const wxString& msg) { - wxString msg_string = msg; errorCount++; #ifdef NO_GUI - wxSTD cerr << "Error: " << msg_string.mb_str() << "\n"; + wxSTD cerr << "Error: " << msg.mb_str() << "\n"; wxSTD cerr.flush(); #else if (isInteractive && frame) @@ -1135,7 +1134,7 @@ void OnError(const wxChar *msg) else { #if defined(__UNIX__) - wxSTD cerr << "Error: " << msg_string.mb_str() << "\n"; + wxSTD cerr << "Error: " << msg.mb_str() << "\n"; wxSTD cerr.flush(); #elif defined(__WXMSW__) wxLogError(msg); @@ -1146,11 +1145,10 @@ void OnError(const wxChar *msg) #endif // NO_GUI } -void OnInform(const wxChar *msg) +void OnInform(const wxString& msg) { - wxString msg_string = msg; #ifdef NO_GUI - wxSTD cout << msg_string.mb_str() << "\n"; + wxSTD cout << msg.mb_str() << "\n"; wxSTD cout.flush(); #else if (isInteractive && frame) @@ -1160,7 +1158,7 @@ void OnInform(const wxChar *msg) else { #if defined(__UNIX__) - wxSTD cout << msg_string.mb_str() << "\n"; + wxSTD cout << msg.mb_str() << "\n"; wxSTD cout.flush(); #elif defined(__WXMSW__) wxLogInfo(msg); diff --git a/utils/tex2rtf/src/texutils.cpp b/utils/tex2rtf/src/texutils.cpp index 44e97bf267..58d5bb7076 100644 --- a/utils/tex2rtf/src/texutils.cpp +++ b/utils/tex2rtf/src/texutils.cpp @@ -207,7 +207,7 @@ wxChar *FindTopicName(TexChunk *chunk) * */ -void StartSimulateArgument(wxChar *data) +void StartSimulateArgument(const wxChar *data) { wxStrcpy(currentArgData, data); haveArgData = true; @@ -223,8 +223,11 @@ void EndSimulateArgument(void) * */ -int ParseUnitArgument(wxChar *unitArg) +int ParseUnitArgument(const wxChar *unitArg_) { + wxWxCharBuffer unitBuf(unitArg_); + wxChar *unitArg = unitBuf.data(); + float conversionFactor = 1.0; float unitValue = 0.0; int len = wxStrlen(unitArg); @@ -470,7 +473,7 @@ void BibEatWhiteSpace(wxString& line) { while(!line.empty() && (line[0] == _T(' ') || line[0] == _T('\t') || line[0] == (wxChar)EOF)) { - if (line[0] == 10) + if (line[0] == '\r') BibLine ++; line = line.substr(1); } @@ -560,7 +563,7 @@ wxString BibReadToEOL(wxString& line) // If in quotes, read white space too. If not, // stop at white space or comment. while (!line.empty() && line[0] != _T('"') && - (inQuotes || ((line[0] != _T(' ')) && (line[0] != 9) && + (inQuotes || ((line[0] != _T(' ')) && (line[0] != '\t') && (line[0] != _T(';')) && (line[0] != _T('%')) && (line[0] != _T('#'))))) { val << line[0]; @@ -704,7 +707,7 @@ void BibReadValue(wxSTD istream& istr, wxChar *buffer, bool ignoreBraces = true, wxUnusedVar(stopping); } -bool ReadBib(wxChar *filename) +bool ReadBib(const wxChar *filename) { if (!wxFileExists(filename)) return false; @@ -1156,7 +1159,7 @@ void ResolveBibReferences(void) } // Remember we need to resolve this citation -void AddCitation(wxChar *citeKey) +void AddCitation(const wxChar *citeKey) { if (!CitationList.Member(citeKey)) CitationList.Add(citeKey); @@ -1167,7 +1170,7 @@ void AddCitation(wxChar *citeKey) } } -TexRef *FindReference(wxChar *key) +TexRef *FindReference(const wxChar *key) { return (TexRef *)TexReferences.Get(key); }