aboutsummaryrefslogtreecommitdiff
path: root/src/minimacro.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2008-02-07 14:59:11 +0000
committerMike Buland <eichlan@xagasoft.com>2008-02-07 14:59:11 +0000
commit5574841cc88412854b2cb94253152b3606803e2a (patch)
tree444381af56492c049e00b9b717a225333de614a5 /src/minimacro.cpp
parent3e581ae682dc6050b8b8c41c917ae62a040719d8 (diff)
downloadlibbu++-5574841cc88412854b2cb94253152b3606803e2a.tar.gz
libbu++-5574841cc88412854b2cb94253152b3606803e2a.tar.bz2
libbu++-5574841cc88412854b2cb94253152b3606803e2a.tar.xz
libbu++-5574841cc88412854b2cb94253152b3606803e2a.zip
Corrected a very rare race condition in Bu::ItoServer where there was a chance
that the client would disconnect so quickly that it would be cleaned up before it was properly accounted for. I apparently added something to MiniMacro a while ago...probably the end tags I think...
Diffstat (limited to 'src/minimacro.cpp')
-rw-r--r--src/minimacro.cpp33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/minimacro.cpp b/src/minimacro.cpp
index 2bd156c..1d2abf8 100644
--- a/src/minimacro.cpp
+++ b/src/minimacro.cpp
@@ -20,8 +20,9 @@ Bu::MiniMacro::~MiniMacro()
20 20
21Bu::FString Bu::MiniMacro::parse( const Bu::FString &sIn ) 21Bu::FString Bu::MiniMacro::parse( const Bu::FString &sIn )
22{ 22{
23 bContinue = true;
23 Bu::FString sOut; 24 Bu::FString sOut;
24 for( sCur = sIn.getStr(); *sCur; sCur++ ) 25 for( sCur = sIn.getStr(); *sCur && bContinue; sCur++ )
25 { 26 {
26 if( *sCur == '{' ) 27 if( *sCur == '{' )
27 { 28 {
@@ -53,6 +54,8 @@ Bu::FString Bu::MiniMacro::parse( const Bu::FString &sIn )
53 } 54 }
54 } 55 }
55 56
57 iLastPos = (int)sCur - (int)sIn.getStr();
58
56 return sOut; 59 return sOut;
57} 60}
58 61
@@ -101,6 +104,29 @@ Bu::FString Bu::MiniMacro::parseCond()
101Bu::FString Bu::MiniMacro::parseCmd() 104Bu::FString Bu::MiniMacro::parseCmd()
102{ 105{
103 Bu::FString sOut; 106 Bu::FString sOut;
107 const char *sNext = sCur;
108 for(; *sNext != ':' && *sNext != '}' && *sNext != '\0'; sNext++ );
109 if( *sNext != '\0' )
110 {
111 Bu::FString sName( sCur, (int)sNext-(int)sCur );
112 if( sName == "end" )
113 {
114 sCur = sNext;
115 bContinue = false;
116 return sOut;
117 }
118 else
119 {
120 throw Bu::ExceptionBase("Unknown command '%s'.",
121 sName.getStr()
122 );
123 }
124 }
125 else
126 {
127 printf("Uh...?\n");
128 }
129
104 printf("%20s\n", sCur ); 130 printf("%20s\n", sCur );
105 return sOut; 131 return sOut;
106} 132}
@@ -142,3 +168,8 @@ const Bu::FString &Bu::MiniMacro::getvar( const Bu::FString &sName )
142 return hVars.get( sName ); 168 return hVars.get( sName );
143} 169}
144 170
171int Bu::MiniMacro::getPosition()
172{
173 return iLastPos;
174}
175