X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c74caa095c12410bd6a555df248699cb35821a8d..3030ae493df7500fd5da7555f141c0c8a690bd8a:/contrib/src/deprecated/wxexpr.cpp diff --git a/contrib/src/deprecated/wxexpr.cpp b/contrib/src/deprecated/wxexpr.cpp index c859d8bccf..c1345a610e 100644 --- a/contrib/src/deprecated/wxexpr.cpp +++ b/contrib/src/deprecated/wxexpr.cpp @@ -9,10 +9,6 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifdef __GNUG__ -#pragma implementation "wxexpr.h" -#endif - // For compilers that support precompilation, includes "wx/wx.h". #include "wx/wxprec.h" @@ -32,8 +28,10 @@ #include "wx/deprecated/expr.h" #include "wx/deprecated/wxexpr.h" +#if !WXWIN_COMPATIBILITY_2_4 static inline wxChar* copystring(const wxChar* s) { return wxStrcpy(new wxChar[wxStrlen(s) + 1], s); } +#endif extern "C" void add_expr(char *); extern "C" void LexFromFile(FILE *fd); @@ -144,7 +142,7 @@ wxExpr::wxExpr(wxExprType the_type, const wxString& word_or_string) break; case wxExprReal: case wxExprInteger: - case wxExprNull: + case wxExprNull: break; } client_data = NULL; @@ -169,7 +167,7 @@ wxExpr::wxExpr(wxExprType the_type, wxChar *word_or_string, bool allocate) break; case wxExprReal: case wxExprInteger: - case wxExprNull: + case wxExprNull: break; } client_data = NULL; @@ -302,7 +300,7 @@ wxExpr *wxExpr::Copy(void) const } return new_list; } - case wxExprNull: + case wxExprNull: break; } return NULL; @@ -325,7 +323,7 @@ wxExpr *wxExpr::GetAttributeValueNode(const wxString& word) const // Use only fo if ((firstNode->type == wxExprWord) && (firstNode->value.word[0] == '=')) { wxExpr *secondNode = firstNode->next; - if ((secondNode->type == wxExprWord) && + if ((secondNode->type == wxExprWord) && (wxStrcmp((const wxChar *)word, secondNode->value.word) == 0)) { return expr; @@ -364,9 +362,9 @@ wxString wxExpr::Functor(void) const // Use only for a clause bool wxExpr::IsFunctor(const wxString& f) const // Use only for a clause { if ((type != wxExprList) || !value.first) - return FALSE; + return false; - return (value.first->type == wxExprWord && + return (value.first->type == wxExprWord && (wxStrcmp((const wxChar *)f, value.first->value.word) == 0)); } @@ -435,7 +433,7 @@ void wxExpr::DeleteAttributeValue(const wxString& attribute) if ((firstNode->type == wxExprWord) && (firstNode->value.word[0] == '=')) { wxExpr *secondNode = firstNode->next; - if ((secondNode->type == wxExprWord) && + if ((secondNode->type == wxExprWord) && (wxStrcmp((const wxChar *)attribute, secondNode->value.word) == 0)) { wxExpr *nextExpr = expr->next; @@ -639,10 +637,10 @@ bool wxExpr::GetAttributeValue(const wxString& att, int& var) const if (expr && (expr->Type() == wxExprInteger || expr->Type() == wxExprReal)) { var = (int)(expr->IntegerValue()); - return TRUE; + return true; } else - return FALSE; + return false; } bool wxExpr::GetAttributeValue(const wxString& att, long& var) const @@ -652,10 +650,10 @@ bool wxExpr::GetAttributeValue(const wxString& att, long& var) const if (expr && (expr->Type() == wxExprInteger || expr->Type() == wxExprReal)) { var = expr->IntegerValue(); - return TRUE; + return true; } else - return FALSE; + return false; } bool wxExpr::GetAttributeValue(const wxString& att, float& var) const @@ -664,10 +662,10 @@ bool wxExpr::GetAttributeValue(const wxString& att, float& var) const if (expr && (expr->Type() == wxExprInteger || expr->Type() == wxExprReal)) { var = (float) expr->RealValue(); - return TRUE; + return true; } else - return FALSE; + return false; } bool wxExpr::GetAttributeValue(const wxString& att, double& var) const @@ -676,10 +674,10 @@ bool wxExpr::GetAttributeValue(const wxString& att, double& var) const if (expr && (expr->Type() == wxExprInteger || expr->Type() == wxExprReal)) { var = expr->RealValue(); - return TRUE; + return true; } else - return FALSE; + return false; } bool wxExpr::GetAttributeValue(const wxString& att, wxString& var) const // Word OR string -> string @@ -688,15 +686,15 @@ bool wxExpr::GetAttributeValue(const wxString& att, wxString& var) const // Wor if (expr && expr->Type() == wxExprWord) { var = expr->WordValue(); - return TRUE; + return true; } else if (expr && expr->Type() == wxExprString) { var = expr->StringValue(); - return TRUE; + return true; } else - return FALSE; + return false; } bool wxExpr::GetAttributeValue(const wxString& att, wxExpr **var) const @@ -705,10 +703,10 @@ bool wxExpr::GetAttributeValue(const wxString& att, wxExpr **var) const if (expr) { *var = expr; - return TRUE; + return true; } else - return FALSE; + return false; } bool wxExpr::GetAttributeValueStringList(const wxString& att, wxList *var) const @@ -724,10 +722,10 @@ bool wxExpr::GetAttributeValueStringList(const wxString& att, wxList *var) const string_expr = string_expr->next; } - return TRUE; + return true; } else - return FALSE; + return false; } // Compatibility @@ -753,16 +751,16 @@ void wxExpr::WriteClause(FILE* stream) // Write this expression as a top-level node->WriteExpr(stream); fprintf( stream, "(" ); node = node->next; - bool first = TRUE; + bool first = true; while (node) { if (!first) fprintf( stream, " " ); node->WriteExpr(stream); node = node->next; - if (node) + if (node) fprintf( stream, ",\n" ); - first = FALSE; + first = false; } fprintf( stream, ").\n\n" ); } @@ -815,18 +813,18 @@ void wxExpr::WriteExpr(FILE* stream) // Write as any other subexpression } case wxExprWord: { - bool quote_it = FALSE; + bool quote_it = false; const wxWX2MBbuf val = wxConvLibc.cWX2MB(value.word); size_t len = strlen(val); if ((len == 0) || (len > 0 && (val[(size_t) 0] > 64 && val[(size_t) 0] < 91))) - quote_it = TRUE; + quote_it = true; else { size_t i; for (i = 0; i < len; i++) if ((!isalpha(val[i])) && (!isdigit(val[i])) && (val[i] != '_')) - { quote_it = TRUE; i = len; } + { quote_it = true; i = len; } } if (quote_it) @@ -862,8 +860,8 @@ void wxExpr::WriteExpr(FILE* stream) // Write as any other subexpression { expr->WriteExpr(stream); expr = expr->next; - if (expr) - fprintf( stream, ", " ); + if (expr) + fprintf( stream, ", " ); } fprintf( stream, "]" ); } @@ -877,7 +875,7 @@ void wxExpr::WriteExpr(FILE* stream) // Write as any other subexpression /* * wxExpr 'database' (list of expressions) */ - + IMPLEMENT_DYNAMIC_CLASS(wxExprDatabase, wxList) wxExprDatabase::wxExprDatabase(wxExprErrorHandler handler) @@ -922,7 +920,7 @@ wxExpr *wxExprDatabase::FindClause(long id) // Find a term based on an integer while (position && !found) { wxExpr *term = (wxExpr *)position->GetData(); - + if (term->Type() == wxExprList) { wxExpr *value = term->AttributeValue(wxT("id")); @@ -941,7 +939,7 @@ wxExpr *wxExprDatabase::FindClause(const wxString& word, const wxString& val) while (position && !found) { wxExpr *term = (wxExpr *)position->GetData(); - + if (term->Type() == wxExprList) { wxExpr *value = term->AttributeValue(word); @@ -960,7 +958,7 @@ wxExpr *wxExprDatabase::FindClause(const wxString& word, long val) while (position && !found) { wxExpr *term = (wxExpr *)position->GetData(); - + if (term->Type() == wxExprList) { wxExpr *value = term->AttributeValue(word); @@ -978,7 +976,7 @@ wxExpr *wxExprDatabase::FindClause(const wxString& word, double val) while (position && !found) { wxExpr *term = (wxExpr *)position->GetData(); - + if (term->Type() == wxExprList) { wxExpr *value = term->AttributeValue(word); @@ -996,7 +994,7 @@ wxExpr *wxExprDatabase::FindClauseByFunctor(const wxString& functor) while (position && !found) { wxExpr *term = (wxExpr *)position->GetData(); - + if (term->Type() == wxExprList) { if (term->Functor() == functor) @@ -1018,7 +1016,7 @@ void wxExprDatabase::Append(wxExpr *clause) if (expr) { long functor_key = hash_table->MakeKey(WXSTRINGCAST functor); - long value_key = 0; + long value_key; if (expr && expr->Type() == wxExprString) { value_key = hash_table->MakeKey(WXSTRINGCAST expr->StringValue()); @@ -1084,7 +1082,7 @@ bool wxExprDatabase::Read(const wxString& filename) } else { - return FALSE; + return false; } } @@ -1103,10 +1101,10 @@ bool wxExprDatabase::ReadFromString(const wxString& buffer) bool wxExprDatabase::Write(const wxString& fileName) { FILE *stream = wxFopen( fileName, _T("w+")); - + if (!stream) - return FALSE; - + return false; + bool success = Write(stream); fclose(stream); return success; @@ -1139,12 +1137,12 @@ bool wxExprIsFunctor(wxExpr *expr, const wxString& functor) if (first_expr && (first_expr->Type() == wxExprWord) && (first_expr->WordValue() == functor)) - return TRUE; - else - return FALSE; - } - else - return FALSE; + return true; + else + return false; + } + else + return false; } /* @@ -1211,11 +1209,11 @@ char *wxmake_string(char *str) size_t len, i; const wxMB2WXbuf sbuf = wxConvLibc.cMB2WX(str); -// str++; /* skip leading quote */ - len = wxStrlen(sbuf) - 1; /* ignore trailing quote */ - +// str++; /* skip leading quote */ + len = wxStrlen(sbuf) - 1; /* ignore trailing quote */ + s = new wxChar[len + 1]; - + t = s; for(i=1; i