@@ -492,41 +492,29 @@ void LMDB::resolveMultiMatches(const std::string& var,
492
492
goto end_cursor_open;
493
493
}
494
494
495
- while ((rc = mdb_cursor_get (cursor, &key, &data, MDB_NEXT)) == 0 ) {
496
- //
497
- // I don't see what's the reason of this clause
498
- //
499
- // eg:
500
- // looking for the variable: 'test', keySize will 4
501
- // found key: 'test', key.mv_size will 4
502
- // key.mv_size IS LESS than keySize+1, so we will continue?
503
- //
504
- // if (key.mv_size <= keySize + 1) {
505
- // continue;
506
- // }
507
- char *a = reinterpret_cast <char *>(key.mv_data );
508
- //
509
- // also don't understand this part
510
- //
511
- // key.mv_data will 'test', but there isn't ':' at the end,
512
- // so we will skip it?
513
- //
514
- // if (a[keySize] != ':') {
515
- // continue;
516
- // }
517
-
518
- // this will never evaluate with the two statements above,
519
- // but I think this is the only required check
520
- if (strncmp (var.c_str (), a, keySize) != 0 ) {
521
- continue ;
522
- }
523
- l->insert (l->begin (), new VariableValue (
495
+ if (keySize == 0 ) {
496
+ while ((rc = mdb_cursor_get (cursor, &key, &data, MDB_NEXT)) == 0 ) {
497
+ l->insert (l->begin (), new VariableValue (
524
498
&m_name,
525
499
new std::string (reinterpret_cast <char *>(key.mv_data ),
526
500
key.mv_size ),
527
501
new std::string (reinterpret_cast <char *>(data.mv_data ),
528
502
data.mv_size ))
529
- );
503
+ );
504
+ }
505
+ } else {
506
+ while ((rc = mdb_cursor_get (cursor, &key, &data, MDB_NEXT)) == 0 ) {
507
+ char *a = reinterpret_cast <char *>(key.mv_data );
508
+ if (strncmp (var.c_str (), a, keySize) == 0 ) {
509
+ l->insert (l->begin (), new VariableValue (
510
+ &m_name,
511
+ new std::string (reinterpret_cast <char *>(key.mv_data ),
512
+ key.mv_size ),
513
+ new std::string (reinterpret_cast <char *>(data.mv_data ),
514
+ data.mv_size ))
515
+ );
516
+ }
517
+ }
530
518
}
531
519
532
520
mdb_cursor_close (cursor);
@@ -549,30 +537,7 @@ void LMDB::resolveRegularExpression(const std::string& var,
549
537
MDB_cursor *cursor;
550
538
size_t pos;
551
539
552
- pos = var.find (" :" );
553
- if (pos == std::string::npos) {
554
- return ;
555
- }
556
- if (var.size () < pos + 3 ) {
557
- return ;
558
- }
559
- pos = var.find (" :" , pos + 2 );
560
- if (pos == std::string::npos) {
561
- return ;
562
- }
563
- if (var.size () < pos + 3 ) {
564
- return ;
565
- }
566
-
567
- std::string nameSpace = std::string (var, 0 , pos);
568
- size_t pos2 = var.find (" :" , pos + 1 ) - pos - 1 ;
569
- std::string col = std::string (var, pos + 1 , pos2);
570
- pos = pos2 + pos + 3 ;
571
- pos2 = var.size () - pos2 - pos;
572
- std::string name = std::string (var, pos, pos2);
573
-
574
- size_t keySize = nameSpace.size ();
575
- Utils::Regex r = Utils::Regex (name);
540
+ Utils::Regex r = Utils::Regex (var);
576
541
577
542
rc = mdb_txn_begin (m_env, NULL , 0 , &txn);
578
543
lmdb_debug (rc, " txn" , " resolveRegularExpression" );
@@ -592,28 +557,12 @@ void LMDB::resolveRegularExpression(const std::string& var,
592
557
goto end_cursor_open;
593
558
}
594
559
595
- std::cout << std::endl;
596
560
while ((rc = mdb_cursor_get (cursor, &key, &data, MDB_NEXT)) == 0 ) {
597
- if (key.mv_size <= keySize) {
598
- continue ;
599
- }
600
561
char *a = reinterpret_cast <char *>(key.mv_data );
601
- if (a[keySize] != ' :' ) {
602
- continue ;
603
- }
604
- std::string ns = std::string (a, keySize);
605
- if (ns != nameSpace) {
606
- continue ;
607
- }
608
-
609
- std::string content = std::string (a, keySize + 1 ,
610
- key.mv_size - keySize - 1 );
611
-
612
- int ret = Utils::regex_search (content, r);
562
+ int ret = Utils::regex_search (a, r);
613
563
if (ret <= 0 ) {
614
564
continue ;
615
565
}
616
-
617
566
VariableValue *v = new VariableValue (
618
567
new std::string (reinterpret_cast <char *>(key.mv_data ),
619
568
key.mv_size ),
0 commit comments