MCPcopy Create free account
hub / github.com/TASEmulators/fceux / checkCondition

Function checkCondition

src/debug.cpp:139–205  ·  view source on GitHub ↗

* Checks whether a breakpoint condition is syntactically valid * and creates a breakpoint condition object if everything's OK. * * @param condition Condition to parse * @param num Number of the breakpoint in the BP list the condition belongs to * @return 0 in case of an error; 2 if everything went fine **/

Source from the content-addressed store, hash-verified

137* @return 0 in case of an error; 2 if everything went fine
138**/
139int checkCondition(const char* condition, int num)
140{
141 const char* b = condition;
142
143 // Check if the condition isn't just all spaces.
144
145 int onlySpaces = 1;
146
147 while (*b)
148 {
149 if (*b != ' ')
150 {
151 onlySpaces = 0;
152 break;
153 }
154
155 ++b;
156 }
157
158
159 // If there's an actual condition create the BP condition object now
160
161 if (*condition && !onlySpaces)
162 {
163 Condition* c = generateCondition(condition);
164
165 // Remove the old breakpoint condition before adding a new condition.
166 if (watchpoint[num].cond)
167 {
168 delete watchpoint[num].cond;
169 free(watchpoint[num].condText);
170 watchpoint[num].cond = 0;
171 watchpoint[num].condText = 0;
172 }
173
174 // If the creation of the BP condition object was succesful
175 // the condition is apparently valid. It can be added to the
176 // breakpoint now.
177
178 if (c)
179 {
180 watchpoint[num].cond = c;
181 watchpoint[num].condText = (char*)malloc(strlen(condition) + 1);
182 if (!watchpoint[num].condText)
183 return 0;
184 strcpy(watchpoint[num].condText, condition);
185 }
186 else
187 {
188 watchpoint[num].cond = 0;
189 }
190
191 return watchpoint[num].cond == 0 ? 2 : 0;
192 }
193 else
194 {
195 // Remove the old breakpoint condition
196 if (watchpoint[num].cond)

Callers 3

NewBreakFunction · 0.85
MemViewCallBFunction · 0.85
loadDebuggerPreferencesFunction · 0.85

Calls 1

generateConditionFunction · 0.85

Tested by

no test coverage detected