1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "wxexpr.h"
16 // For compilers that support precompilation, includes "wx/wx.h".
17 #include "wx/wxprec.h"
39 #include "wx/wxexpr.h"
41 extern "C" void add_expr(char *);
42 extern "C" void LexFromFile(FILE *fd
);
43 extern "C" void LexFromString(char *buf
);
45 wxExprDatabase
*thewxExprDatabase
= NULL
;
46 wxExprErrorHandler currentwxExprErrorHandler
;
48 wxExpr::wxExpr(const wxString
& functor
)
55 wxExpr
*pfunctor
= new wxExpr(wxExprWord
, functor
);
60 wxExpr::wxExpr(wxExprType the_type
, const wxString
& word_or_string
)
67 value
.word
= copystring((const char *)word_or_string
);
70 value
.string
= copystring((const char *)word_or_string
);
85 wxExpr::wxExpr(wxExprType the_type
, char *word_or_string
, bool allocate
)
92 value
.word
= allocate
? copystring(word_or_string
) : word_or_string
;
95 value
.string
= allocate
? copystring(word_or_string
) : word_or_string
;
110 wxExpr::wxExpr(long the_integer
)
112 type
= wxExprInteger
;
113 value
.integer
= the_integer
;
118 wxExpr::wxExpr(double the_real
)
121 value
.real
= the_real
;
126 wxExpr::wxExpr(wxList
*the_list
)
133 wxExpr
*listExpr
= new wxExpr(wxExprList
);
135 wxNode
*node
= the_list
->First();
138 wxExpr
*expr
= (wxExpr
*)node
->Data();
139 listExpr
->Append(expr
);
147 wxExpr::~wxExpr(void)
158 delete[] value
.string
;
168 wxExpr
*expr
= value
.first
;
171 wxExpr
*expr1
= expr
->next
;
178 case wxExprNull
: break;
182 void wxExpr::Append(wxExpr
*expr
)
192 void wxExpr::Insert(wxExpr
*expr
)
194 expr
->next
= value
.first
;
201 wxExpr
*wxExpr::Copy(void) const
203 // This seems to get round an optimizer bug when
204 // using Watcom C++ 10a in WIN32 compilation mode.
205 // If these lines not present, the type seems to be
206 // interpreted wrongly as an integer.
207 // I don't want to turn optimization off since it's needed
208 // for reading in files quickly.
209 #if defined(__WATCOMC__)
217 return new wxExpr(value
.integer
);
219 return new wxExpr(value
.real
);
221 return new wxExpr(wxExprString
, wxString(value
.string
));
223 return new wxExpr(wxExprWord
, wxString(value
.word
));
226 wxExpr
*expr
= value
.first
;
227 wxExpr
*new_list
= new wxExpr(wxExprList
);
230 wxExpr
*expr2
= expr
->Copy();
231 new_list
->Append(expr2
);
243 // Get the wxExpr (containing (= wxExpr Value) form) for the given word
244 // or string, assuming that we have Attribute=Value, ...
245 wxExpr
*wxExpr::GetAttributeValueNode(const wxString
& word
) const // Use only for a clause or list
247 if (type
!= wxExprList
)
250 wxExpr
*expr
= value
.first
;
253 if (expr
->type
== wxExprList
)
255 wxExpr
*firstNode
= expr
->value
.first
;
256 if ((firstNode
->type
== wxExprWord
) && (firstNode
->value
.word
[0] == '='))
258 wxExpr
*secondNode
= firstNode
->next
;
259 if ((secondNode
->type
== wxExprWord
) &&
260 (strcmp((const char *)word
, secondNode
->value
.word
) == 0))
271 // Get the value (in wxExpr form) for the given word or string, assuming
272 // that we have Attribute=Value, ...
273 wxExpr
*wxExpr::AttributeValue(const wxString
& word
) const // Use only for a clause or list
275 if (type
!= wxExprList
)
278 wxExpr
*attExpr
= GetAttributeValueNode(word
);
279 if (attExpr
&& attExpr
->value
.first
&& attExpr
->value
.first
->next
)
280 return attExpr
->value
.first
->next
->next
;
284 wxString
wxExpr::Functor(void) const // Use only for a clause
286 if ((type
!= wxExprList
) || !value
.first
)
289 if (value
.first
->type
== wxExprWord
)
290 return wxString(value
.first
->value
.word
);
295 bool wxExpr::IsFunctor(const wxString
& f
) const // Use only for a clause
297 if ((type
!= wxExprList
) || !value
.first
)
300 return (value
.first
->type
== wxExprWord
&&
301 (strcmp((const char *)f
, value
.first
->value
.word
) == 0));
304 // Return nth argument of a clause (starting from 1)
305 wxExpr
*wxExpr::Arg(wxExprType theType
, int arg
) const
307 wxExpr
*expr
= value
.first
;
309 for (i
= 1; i
< arg
; i
++)
313 if (expr
&& (expr
->type
== theType
))
319 // Return nth argument of a list expression (starting from zero)
320 wxExpr
*wxExpr::Nth(int arg
) const
322 if (type
!= wxExprList
)
325 wxExpr
*expr
= value
.first
;
327 for (i
= 0; i
< arg
; i
++)
338 // Returns the number of elements in a list expression
339 int wxExpr::Number(void) const
341 if (type
!= wxExprList
)
345 wxExpr
*expr
= value
.first
;
354 void wxExpr::DeleteAttributeValue(const wxString
& attribute
)
356 if (type
!= wxExprList
)
359 wxExpr
*expr
= value
.first
;
360 wxExpr
*lastExpr
= this;
363 if (expr
->type
== wxExprList
)
365 wxExpr
*firstNode
= expr
->value
.first
;
366 if ((firstNode
->type
== wxExprWord
) && (firstNode
->value
.word
[0] == '='))
368 wxExpr
*secondNode
= firstNode
->next
;
369 if ((secondNode
->type
== wxExprWord
) &&
370 (strcmp((const char *)attribute
, secondNode
->value
.word
) == 0))
372 wxExpr
*nextExpr
= expr
->next
;
375 lastExpr
->next
= nextExpr
;
390 void wxExpr::AddAttributeValue(const wxString
& attribute
, wxExpr
*val
)
392 if (type
!= wxExprList
)
394 // cout << "Error! tried to add an attribute-value pair to a nonlist wxExpr expression\n";
397 // Warning - existing code may assume that any existing value
398 // is deleted first. For efficiency, we leave this to the application.
399 // DeleteAttributeValue(attribute);
401 wxExpr
*patt
= new wxExpr(wxExprWord
, attribute
);
402 wxExpr
*pequals
= new wxExpr(wxExprWord
, "=");
404 wxExpr
*listExpr
= new wxExpr(wxExprList
);
406 listExpr
->Append(pequals
);
407 listExpr
->Append(patt
);
408 listExpr
->Append(val
);
413 void wxExpr::AddAttributeValue(const wxString
& attribute
, long val
)
415 if (type
!= wxExprList
)
417 // cout << "Error! tried to add an attribute-value pair to a nonlist wxExpr expression\n";
420 // Warning - existing code may assume that any existing value
421 // is deleted first. For efficiency, we leave this to the application.
422 // DeleteAttributeValue(attribute);
424 wxExpr
*patt
= new wxExpr(wxExprWord
, attribute
);
425 wxExpr
*pval
= new wxExpr(val
);
426 wxExpr
*pequals
= new wxExpr(wxExprWord
, "=");
428 wxExpr
*listExpr
= new wxExpr(wxExprList
);
430 listExpr
->Append(pequals
);
431 listExpr
->Append(patt
);
432 listExpr
->Append(pval
);
437 void wxExpr::AddAttributeValue(const wxString
& attribute
, double val
)
439 if (type
!= wxExprList
)
441 // cout << "Error! tried to add an attribute-value pair to a nonlist wxExpr expression\n";
445 // DeleteAttributeValue(attribute);
446 wxExpr
*patt
= new wxExpr(wxExprWord
, attribute
);
447 wxExpr
*pval
= new wxExpr(val
);
448 wxExpr
*pequals
= new wxExpr(wxExprWord
, "=");
450 wxExpr
*listExpr
= new wxExpr(wxExprList
);
452 listExpr
->Append(pequals
);
453 listExpr
->Append(patt
);
454 listExpr
->Append(pval
);
459 void wxExpr::AddAttributeValueString(const wxString
& attribute
, const wxString
& val
)
461 if (type
!= wxExprList
)
463 // cout << "Error! tried to add an attribute-value pair to a nonlist wxExpr expression\n";
467 // DeleteAttributeValue(attribute);
469 wxExpr
*patt
= new wxExpr(wxExprWord
, attribute
);
470 wxExpr
*pval
= new wxExpr(wxExprString
, val
);
471 wxExpr
*pequals
= new wxExpr(wxExprWord
, "=");
473 wxExpr
*listExpr
= new wxExpr(wxExprList
);
475 listExpr
->Append(pequals
);
476 listExpr
->Append(patt
);
477 listExpr
->Append(pval
);
482 void wxExpr::AddAttributeValueWord(const wxString
& attribute
, const wxString
& val
)
484 if (type
!= wxExprList
)
486 // cout << "Error! tried to add an attribute-value pair to a nonlist wxExpr expression\n";
490 // DeleteAttributeValue(attribute);
492 wxExpr
*patt
= new wxExpr(wxExprWord
, attribute
);
493 wxExpr
*pval
= new wxExpr(wxExprWord
, val
);
494 wxExpr
*pequals
= new wxExpr(wxExprWord
, "=");
496 wxExpr
*listExpr
= new wxExpr(wxExprList
);
498 listExpr
->Append(pequals
);
499 listExpr
->Append(patt
);
500 listExpr
->Append(pval
);
505 void wxExpr::AddAttributeValue(const wxString
& attribute
, wxList
*val
)
507 if (type
!= wxExprList
)
509 // cout << "Error! tried to add an attribute-value pair to a nonlist wxExpr expression\n";
515 // DeleteAttributeValue(attribute);
517 wxExpr
*patt
= new wxExpr(wxExprWord
, attribute
);
518 wxExpr
*pval
= new wxExpr(val
);
519 wxExpr
*pequals
= new wxExpr(wxExprWord
, "=");
521 wxExpr
*listExpr
= new wxExpr(wxExprList
);
523 listExpr
->Append(pequals
);
524 listExpr
->Append(patt
);
525 listExpr
->Append(pval
);
530 void wxExpr::AddAttributeValueStringList(const wxString
& attribute
, wxList
*string_list
)
532 if (type
!= wxExprList
)
534 // cout << "Error! tried to add an attribute-value pair to a nonlist wxExpr expression\n";
540 // DeleteAttributeValue(attribute);
542 // First make a list of wxExpr strings
543 wxExpr
*listExpr
= new wxExpr(wxExprList
);
544 wxNode
*node
= string_list
->First();
547 char *string
= (char *)node
->Data();
548 wxExpr
*expr
= new wxExpr(wxExprString
, wxString(string
));
549 listExpr
->Append(expr
);
553 // Now make an (=, Att, Value) triple
554 wxExpr
*patt
= new wxExpr(wxExprWord
, attribute
);
555 wxExpr
*pequals
= new wxExpr(wxExprWord
, "=");
557 wxExpr
*listExpr2
= new wxExpr(wxExprList
);
559 listExpr2
->Append(pequals
);
560 listExpr2
->Append(patt
);
561 listExpr2
->Append(listExpr
);
566 bool wxExpr::GetAttributeValue(const wxString
& att
, int& var
) const
568 wxExpr
*expr
= AttributeValue(att
);
570 if (expr
&& (expr
->Type() == wxExprInteger
|| expr
->Type() == wxExprReal
))
572 var
= (int)(expr
->IntegerValue());
579 bool wxExpr::GetAttributeValue(const wxString
& att
, long& var
) const
581 wxExpr
*expr
= AttributeValue(att
);
583 if (expr
&& (expr
->Type() == wxExprInteger
|| expr
->Type() == wxExprReal
))
585 var
= expr
->IntegerValue();
592 bool wxExpr::GetAttributeValue(const wxString
& att
, float& var
) const
594 wxExpr
*expr
= AttributeValue(att
);
595 if (expr
&& (expr
->Type() == wxExprInteger
|| expr
->Type() == wxExprReal
))
597 var
= (float) expr
->RealValue();
604 bool wxExpr::GetAttributeValue(const wxString
& att
, double& var
) const
606 wxExpr
*expr
= AttributeValue(att
);
607 if (expr
&& (expr
->Type() == wxExprInteger
|| expr
->Type() == wxExprReal
))
609 var
= expr
->RealValue();
616 bool wxExpr::GetAttributeValue(const wxString
& att
, wxString
& var
) const // Word OR string -> string
618 wxExpr
*expr
= AttributeValue(att
);
619 if (expr
&& expr
->Type() == wxExprWord
)
621 var
= expr
->WordValue();
624 else if (expr
&& expr
->Type() == wxExprString
)
626 var
= expr
->StringValue();
633 bool wxExpr::GetAttributeValue(const wxString
& att
, wxExpr
**var
) const
635 wxExpr
*expr
= AttributeValue(att
);
645 bool wxExpr::GetAttributeValueStringList(const wxString
& att
, wxList
*var
) const
647 wxExpr
*expr
= AttributeValue(att
);
648 if (expr
&& expr
->Type() == wxExprList
)
650 wxExpr
*string_expr
= expr
->value
.first
;
653 if (string_expr
->Type() == wxExprString
)
654 var
->Append((wxObject
*)copystring(string_expr
->StringValue()));
656 string_expr
= string_expr
->next
;
665 void wxExpr::AssignAttributeValue(char *att
, char **var
) const
668 if (GetAttributeValue(att
, str
))
672 *var
= copystring((const char *) str
);
676 void wxExpr::WriteClause(ostream
& stream
) // Write this expression as a top-level clause
678 if (type
!= wxExprList
)
681 wxExpr
*node
= value
.first
;
684 node
->WriteExpr(stream
);
692 node
->WriteExpr(stream
);
694 if (node
) stream
<< ",\n";
701 void wxExpr::WriteExpr(ostream
& stream
) // Write as any other subexpression
703 // This seems to get round an optimizer bug when
704 // using Watcom C++ 10a in WIN32 compilation mode.
705 // If these lines not present, the type seems to be
706 // interpreted wrongly as an integer.
707 // I don't want to turn optimization off since it's needed
708 // for reading in files quickly.
709 #if defined(__WATCOMC__)
718 stream
<< value
.integer
;
723 double f
= value
.real
;
724 /* Now the parser can cope with this.
725 // Prevent printing in 'e' notation. Any better way?
726 if (fabs(f) < 0.00001)
730 sprintf(buf
, "%.6g", f
);
738 int len
= strlen(value
.string
);
739 for (i
= 0; i
< len
; i
++)
741 char ch
= value
.string
[i
];
742 if (ch
== '"' || ch
== '\\')
752 bool quote_it
= FALSE
;
753 int len
= strlen(value
.word
);
754 if ((len
== 0) || (len
> 0 && (value
.word
[0] > 64 && value
.word
[0] < 91)))
759 for (i
= 0; i
< len
; i
++)
760 if ((!isalpha(value
.word
[i
])) && (!isdigit(value
.word
[i
])) &&
761 (value
.word
[i
] != '_'))
762 { quote_it
= TRUE
; i
= len
; }
768 stream
<< value
.word
;
781 wxExpr
*expr
= value
.first
;
783 if ((expr
->Type() == wxExprWord
) && (strcmp(expr
->WordValue(), "=") == 0))
785 wxExpr
*arg1
= expr
->next
;
786 wxExpr
*arg2
= arg1
->next
;
787 arg1
->WriteExpr(stream
);
789 arg2
->WriteExpr(stream
);
796 expr
->WriteExpr(stream
);
798 if (expr
) stream
<< ", ";
805 case wxExprNull
: break;
809 void wxExpr::WriteLispExpr(ostream
& stream
)
815 stream
<< value
.integer
;
820 stream
<< value
.real
;
825 stream
<< "\"" << value
.string
<< "\"";
830 stream
<< value
.word
;
835 wxExpr
*expr
= value
.first
;
840 expr
->WriteLispExpr(stream
);
842 if (expr
) stream
<< " ";
848 case wxExprNull
: break;
853 * wxExpr 'database' (list of expressions)
856 #if !USE_SHARED_LIBRARIES
857 IMPLEMENT_DYNAMIC_CLASS(wxExprDatabase
, wxList
)
860 wxExprDatabase::wxExprDatabase(wxExprErrorHandler handler
)
864 currentwxExprErrorHandler
= handler
;
868 wxExprDatabase::wxExprDatabase(wxExprType type
, const wxString
& attribute
, int size
,
869 wxExprErrorHandler handler
)
872 attribute_to_hash
= attribute
;
873 if (type
== wxExprString
)
874 hash_table
= new wxHashTable(wxKEY_STRING
, size
);
875 else if (type
== wxExprInteger
)
876 hash_table
= new wxHashTable(wxKEY_INTEGER
, size
);
877 else hash_table
= NULL
;
879 currentwxExprErrorHandler
= handler
;
883 wxExprDatabase::~wxExprDatabase(void)
890 void wxExprDatabase::BeginFind(void) // Initialise a search
895 wxExpr
*wxExprDatabase::FindClause(long id
) // Find a term based on an integer id attribute
896 // e.g. node(id=23, type=rectangle, ....).
898 wxExpr
*found
= NULL
;
899 while (position
&& !found
)
901 wxExpr
*term
= (wxExpr
*)position
->Data();
903 if (term
->Type() == wxExprList
)
905 wxExpr
*value
= term
->AttributeValue("id");
906 if (value
->Type() == wxExprInteger
&& value
->IntegerValue() == id
)
909 position
= position
->Next();
914 // Find on basis of attribute/value pairs, e.g. type=rectangle
915 wxExpr
*wxExprDatabase::FindClause(const wxString
& word
, const wxString
& val
)
917 wxExpr
*found
= NULL
;
918 while (position
&& !found
)
920 wxExpr
*term
= (wxExpr
*)position
->Data();
922 if (term
->Type() == wxExprList
)
924 wxExpr
*value
= term
->AttributeValue(word
);
925 if ((value
->Type() == wxExprWord
&& value
->WordValue() == val
) ||
926 (value
->Type() == wxExprString
&& value
->StringValue() == val
))
929 position
= position
->Next();
934 wxExpr
*wxExprDatabase::FindClause(const wxString
& word
, long val
)
936 wxExpr
*found
= NULL
;
937 while (position
&& !found
)
939 wxExpr
*term
= (wxExpr
*)position
->Data();
941 if (term
->Type() == wxExprList
)
943 wxExpr
*value
= term
->AttributeValue(word
);
944 if ((value
->Type() == wxExprInteger
) && (value
->IntegerValue() == val
))
947 position
= position
->Next();
952 wxExpr
*wxExprDatabase::FindClause(const wxString
& word
, double val
)
954 wxExpr
*found
= NULL
;
955 while (position
&& !found
)
957 wxExpr
*term
= (wxExpr
*)position
->Data();
959 if (term
->Type() == wxExprList
)
961 wxExpr
*value
= term
->AttributeValue(word
);
962 if ((value
->Type() == wxExprReal
) && (value
->RealValue() == val
))
965 position
= position
->Next();
970 wxExpr
*wxExprDatabase::FindClauseByFunctor(const wxString
& functor
)
972 wxExpr
*found
= NULL
;
973 while (position
&& !found
)
975 wxExpr
*term
= (wxExpr
*)position
->Data();
977 if (term
->Type() == wxExprList
)
979 if (term
->Functor() == functor
)
982 position
= position
->Next();
987 // If hashing is on, must store in hash table too
988 void wxExprDatabase::Append(wxExpr
*clause
)
990 wxList::Append((wxObject
*)clause
);
993 wxString
functor(clause
->Functor());
994 wxExpr
*expr
= clause
->AttributeValue(attribute_to_hash
);
997 long functor_key
= hash_table
->MakeKey((char *)(const char *)functor
);
999 if (expr
&& expr
->Type() == wxExprString
)
1001 value_key
= hash_table
->MakeKey((char *)(const char *)expr
->StringValue());
1002 hash_table
->Put(functor_key
+ value_key
, (char *)(const char *)expr
->StringValue(), (wxObject
*)clause
);
1004 else if (expr
&& expr
->Type() == wxExprInteger
)
1006 value_key
= expr
->IntegerValue();
1007 hash_table
->Put(functor_key
+ value_key
, expr
->IntegerValue(), (wxObject
*)clause
);
1014 wxExpr
*wxExprDatabase::HashFind(const wxString
& functor
, long value
) const
1016 long key
= hash_table
->MakeKey((char *)(const char *)functor
) + value
;
1018 // The key alone isn't guaranteed to be unique:
1019 // must supply value too. Let's assume the value of the
1020 // id is going to be reasonably unique.
1021 return (wxExpr
*)hash_table
->Get(key
, value
);
1024 wxExpr
*wxExprDatabase::HashFind(const wxString
& functor
, const wxString
& value
) const
1026 long key
= hash_table
->MakeKey((char *)(const char *)functor
) + hash_table
->MakeKey((char *)(const char *)value
);
1027 return (wxExpr
*)hash_table
->Get(key
, (char *)(const char *)value
);
1030 void wxExprDatabase::ClearDatabase(void)
1033 wxNode
*node
= First();
1036 wxExpr
*expr
= (wxExpr
*)node
->Data();
1043 hash_table
->Clear();
1046 bool wxExprDatabase::Read(const wxString
& filename
)
1050 FILE *f
= fopen((const char *)filename
, "r");
1053 thewxExprDatabase
= this;
1060 return (noErrors
== 0);
1068 bool wxExprDatabase::ReadFromString(const wxString
& buffer
)
1071 thewxExprDatabase
= this;
1073 LexFromString((char *)(const char *)buffer
);
1076 return (noErrors
== 0);
1079 bool wxExprDatabase::Write(const wxString
& fileName
)
1081 ofstream
str((char *)(const char *)fileName
);
1087 bool wxExprDatabase::Write(ostream
& stream
)
1090 wxNode
*node
= First();
1093 wxExpr
*expr
= (wxExpr
*)node
->Data();
1094 expr
->WriteClause(stream
);
1095 node
= node
->Next();
1097 return (noErrors
== 0);
1100 void wxExprDatabase::WriteLisp(ostream
& stream
)
1103 wxNode
*node
= First();
1106 wxExpr
*expr
= (wxExpr
*)node
->Data();
1107 expr
->WriteLispExpr(stream
);
1109 node
= node
->Next();
1113 void add_expr(wxExpr
* expr
)
1115 thewxExprDatabase
->Append(expr
);
1119 bool wxExprIsFunctor(wxExpr
*expr
, const wxString
& functor
)
1121 if (expr
&& (expr
->Type() == wxExprList
))
1123 wxExpr
*first_expr
= expr
->value
.first
;
1125 if (first_expr
&& (first_expr
->Type() == wxExprWord
) &&
1126 (first_expr
->WordValue() == functor
))
1136 * Called from parser
1140 char *make_integer(char *str
)
1142 wxExpr
*x
= new wxExpr(atol(str
));
1147 char *make_real(char *str1
, char *str2
)
1151 sprintf(buf
, "%s.%s", str1
, str2
);
1152 double f
= (double)atof(buf
);
1153 wxExpr
*x
= new wxExpr(f
);
1158 // extern "C" double exp10(double);
1160 char *make_exp(char *str1
, char *str2
)
1162 double mantissa
= (double)atoi(str1
);
1163 double exponent
= (double)atoi(str2
);
1165 double d
= mantissa
* pow(10.0, exponent
);
1167 wxExpr
*x
= new wxExpr(d
);
1172 char *make_exp2(char *str1
, char *str2
, char *str3
)
1176 sprintf(buf
, "%s.%s", str1
, str2
);
1177 double mantissa
= (double)atof(buf
);
1178 double exponent
= (double)atoi(str3
);
1180 double d
= mantissa
* pow(10.0, exponent
);
1182 wxExpr
*x
= new wxExpr(d
);
1187 char *make_word(char *str
)
1189 wxExpr
*x
= new wxExpr(wxExprWord
, str
);
1193 char *make_string(char *str
)
1198 str
++; /* skip leading quote */
1199 len
= strlen(str
) - 1; /* ignore trailing quote */
1201 s
= new char[len
+ 1];
1204 for(i
=0; i
<len
; i
++)
1206 if (str
[i
] == '\\' && str
[i
+1] == '"')
1211 else if (str
[i
] == '\\' && str
[i
+1] == '\\')
1222 wxExpr
*x
= new wxExpr(wxExprString
, s
, FALSE
);
1226 char *proio_cons(char * ccar
, char * ccdr
)
1228 wxExpr
*car
= (wxExpr
*)ccar
;
1229 wxExpr
*cdr
= (wxExpr
*)ccdr
;
1233 cdr
= new wxExpr(wxExprList
);
1240 void process_command(char * cexpr
)
1242 wxExpr
*expr
= (wxExpr
*)cexpr
;
1246 void syntax_error(char *WXUNUSED(s
))
1248 if (currentwxExprErrorHandler
)
1249 (void)(*(currentwxExprErrorHandler
))(WXEXPR_ERROR_SYNTAX
, "syntax error");
1250 if (thewxExprDatabase
) thewxExprDatabase
->noErrors
+= 1;
1255 // char *__cdecl strdup(const char *s)
1256 WXDLLEXPORT
char *strdup(const char *s
)
1258 int len
= strlen(s
);
1259 char *new_s
= (char *)malloc(sizeof(char)*(len
+1));