Remove test prints and fix cursor checks in dictionary.
This commit is contained in:
parent
930a2d68f4
commit
a0edf915ad
|
@ -22,6 +22,7 @@
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <iomanip>
|
||||||
#include <ios>
|
#include <ios>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
cmake_minimum_required(VERSION 3.22)
|
cmake_minimum_required(VERSION 3.22)
|
||||||
project(scsl LANGUAGES CXX
|
project(scsl LANGUAGES CXX
|
||||||
VERSION 0.2.4
|
VERSION 0.2.5
|
||||||
DESCRIPTION "Shimmering Clarity Standard Library")
|
DESCRIPTION "Shimmering Clarity Standard Library")
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 14)
|
set(CMAKE_CXX_STANDARD 14)
|
||||||
|
|
15
TLV.cc
15
TLV.cc
|
@ -116,8 +116,10 @@ FindTag(Arena &arena, uint8_t *cursor, Record &rec)
|
||||||
{
|
{
|
||||||
cursor = LocateTag(arena, cursor, rec);
|
cursor = LocateTag(arena, cursor, rec);
|
||||||
if (rec.Tag != TAG_EMPTY) {
|
if (rec.Tag != TAG_EMPTY) {
|
||||||
std::cout << "skipping record\n";
|
|
||||||
cursor = SkipRecord(rec, cursor);
|
cursor = SkipRecord(rec, cursor);
|
||||||
|
if (!arena.CursorInArena(cursor)) {
|
||||||
|
cursor = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return cursor;
|
return cursor;
|
||||||
|
@ -134,23 +136,24 @@ LocateTag(Arena &arena, uint8_t *cursor, Record &rec)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cursor == nullptr) {
|
if (cursor == nullptr) {
|
||||||
std::cout << "move cursor to arena start\n";
|
|
||||||
cursor = arena.Start();
|
cursor = arena.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((tag = cursor[0]) != rec.Tag) {
|
while (((tag = cursor[0]) != rec.Tag) &&
|
||||||
|
(arena.CursorInArena(cursor))) {
|
||||||
assert(arena.CursorInArena(cursor));
|
assert(arena.CursorInArena(cursor));
|
||||||
std::cout << "cursor is in arena\n";
|
|
||||||
len = cursor[1];
|
len = cursor[1];
|
||||||
std::cout << "record length" << len << "\n";
|
|
||||||
if (!spaceAvailable(arena, cursor, len)) {
|
if (!spaceAvailable(arena, cursor, len)) {
|
||||||
std::cout << "no space available\n";
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
cursor += len;
|
cursor += len;
|
||||||
cursor += 2;
|
cursor += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!arena.CursorInArena(cursor)) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
if (tag != rec.Tag) {
|
if (tag != rec.Tag) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue