128
124
int ws_index = line.index(' ', -1) + 1;
129
125
line = line.from(ws_index);
130
126
strip_leading_space(line);
131
if (line != "" && line.contains(rxidentifier, 0))
127
if (!line.empty() && line.contains(rxidentifier, 0))
236
247
string pfx = app_data.auto_command_prefix;
238
if (auto_cmd_buffer != "" && !auto_cmd_buffer.contains('\n', -1))
249
if (!auto_cmd_buffer.empty() && !auto_cmd_buffer.contains('\n', -1))
240
251
// Complete pending auto command
241
252
if (answer.contains('\n'))
390
if (check_pc && pc_buffer == "" ||
391
check_func && func_buffer == "")
409
if (check_pc && pc_buffer.empty() ||
410
check_func && func_buffer.empty())
393
412
// `No line number available for
394
413
// address ADDRESS <FUNCTION>'
402
421
pc_index = answer.index(' ');
403
422
fetch_address(answer, pc_index, pc_buffer);
404
if (func_buffer == "")
423
if (func_buffer.empty())
406
425
string line = answer.from(pc_index);
407
426
line = line.after('<');
408
427
line = line.before('>');
410
429
func_buffer = line;
415
if (check_pc && pc_buffer == "" && answer != "")
434
if (check_pc && pc_buffer.empty() && !answer.empty())
417
436
// `ADDRESS in FUNCTION'
418
437
#if RUNTIME_REGEX
442
461
// Try to find out current function name, even for
443
462
// non-existing addresses
444
if (check_func && func_buffer == "")
463
if (check_func && func_buffer.empty())
446
465
// `Breakpoint N, FUNCTION (ARGS...)'
447
466
// This regex used for PYDB as well.
531
550
// which is the output of an 'info line' command
532
551
string line = answer.after("Line ");
533
552
string file = answer.after('\"');
534
if (line != "" && file != "")
553
if (!line.empty() && !file.empty())
536
555
line = line.before(" of");
537
556
file = file.before('\"') + ":" + line;
538
if (line != "" && file != "")
557
if (!line.empty() && !file.empty())
540
559
pos_buffer = file;
541
560
already_read = PosComplete;
788
807
func_buffer = func_buffer.after(' ');
793
812
line = answer.after("at line ", stopped_index);
794
813
line = line.through(rxint);
795
if ((file != "" || func_buffer != "") &&
814
if ((!file.empty() || !func_buffer.empty()) &&
796
815
!answer.contains("at line "))
801
820
already_read = PosComplete;
1159
void PosBuffer::filter_dbg(string& answer)
1163
if (already_read != PosComplete && !answer.contains('\n'))
1165
// Position info is incomplete
1166
answer_buffer = answer;
1168
already_read = PosPart;
1173
while (idx1 < (int)answer.length())
1175
idx2 = answer.index('\n', idx1);
1176
if (idx2 < 0) idx2 = answer.length();
1177
string line = answer.at(idx1, idx2 - idx1);
1178
if (line.contains('\n'))
1179
line = line.before('\n');
1180
strip_trailing_space(line);
1182
// DBG uses a format like `test.php:4 <main>\n echo $a."hello world."'
1184
static regex rxdbgpos("[^ \t]*:[ \t]*[1-9][0-9]*[ \t]*<.*>");
1185
static regex rxdbgframepos("#[0-9]*[ \t]*<.*>[ \t]*at[ \t]*[^ \t]*:[ \t]*[1-9][0-9]*");
1187
if (line.matches(rxdbgpos))
1189
string file = line.before(':');
1190
line = line.after(':');
1192
string line_no = line;
1193
strip_leading_space(line_no);
1194
line_no = line_no.before(' ');
1196
line = line.after('<');
1197
func_buffer = line.before('>');
1198
strip_leading_space(func_buffer);
1200
pos_buffer = file + ":" + line_no;
1202
// Delete this line from output
1203
answer.at(idx1, idx2 - idx1 + 1) = "";
1204
already_read = PosComplete;
1207
} else if (line.matches(rxdbgframepos))
1209
string addr = line.before(">");
1210
func_buffer = addr.after('<');
1211
strip_leading_space(func_buffer);
1213
string file = line.after(">");
1214
file = file.after("at");
1215
strip_leading_space(file);
1217
string line_no = file.after(':');
1218
strip_leading_space(line_no);
1220
file = file.before(':');
1222
pos_buffer = file + ":" + line_no;
1224
// Delete this line from output
1225
answer.at(idx1, idx2 - idx1 + 1) = "";
1226
already_read = PosComplete;
1140
1234
void PosBuffer::filter_perl(string& answer)
1142
1236
// Check for regular source info
1318
void PosBuffer::filter_bash(string& answer)
1320
// Check for regular source info
1321
int index1 = answer.index ("\032\032");
1325
int index_p = answer.index ("\032");
1326
if (index_p >= 0 && index_p == int(answer.length()) - 1)
1328
// Possible begin of position info at end of ANSWER
1329
answer_buffer = "\032";
1330
answer = answer.before (index_p);
1331
already_read = PosPart;
1337
// ANSWER contains position info
1338
int index2 = answer.index("\n", index1);
1342
// Position info is incomplete
1343
answer_buffer = answer.from (index1);
1344
answer = answer.before (index1);
1345
already_read = PosPart;
1350
assert (index1 < index2);
1352
// Position info is complete
1353
already_read = PosComplete;
1354
pos_buffer = answer.at(index1 + 2, index2 - (index1 + 2));
1355
answer.at(index1, index2 - index1 + 1) = "";
1359
if (already_read != PosComplete)
1361
// Try '(FILE:LINE):\n';
1363
// INDEX points at the start of a line
1365
while (index >= 0 && !answer.empty())
1367
string line = answer.from(index);
1368
if (line.contains('\n'))
1369
line = line.before('\n');
1370
strip_trailing_space(line);
1373
static regex rxbashpos("[(][^:]*:[1-9][0-9]*[)]:");
1375
if (line.matches(rxbashpos))
1378
pos_buffer = line.after('(');
1379
pos_buffer = pos_buffer.before(')');
1380
already_read = PosComplete;
1382
// Delete this line from output
1383
int next_index = answer.index('\n', index);
1385
next_index = answer.length();
1388
answer.at(index, next_index - index) = "";
1393
// Look at next line
1394
index = answer.index('\n', index);
1224
1402
string PosBuffer::answer_ended ()
1226
1404
switch (already_read)
1230
assert (pos_buffer == "");
1408
assert (pos_buffer.empty());
1231
1409
return auto_cmd_part;
1236
assert (pos_buffer == "");
1237
string ans = answer_buffer;
1414
assert (pos_buffer.empty());
1415
const string ans = auto_cmd_part + answer_buffer;
1238
1416
answer_buffer = "";
1239
return auto_cmd_part + ans;
1242
1420
case PosComplete:
1244
assert (pos_buffer != "");
1422
assert (!pos_buffer.empty());
1245
1423
return auto_cmd_part;
1250
1428
assert(0); // This can't happen