Remove test prints and fix cursor checks in dictionary.

This commit is contained in:
Kyle Isom 2023-10-16 17:53:50 -07:00
parent 930a2d68f4
commit a0edf915ad
4 changed files with 12 additions and 7 deletions

View File

@ -22,6 +22,7 @@
#include <cassert>
#include <cstring>
#include <iomanip>
#include <ios>
#include <iostream>

View File

@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.22)
project(scsl LANGUAGES CXX
VERSION 0.2.4
VERSION 0.2.5
DESCRIPTION "Shimmering Clarity Standard Library")
set(CMAKE_CXX_STANDARD 14)

15
TLV.cc
View File

@ -116,8 +116,10 @@ FindTag(Arena &arena, uint8_t *cursor, Record &rec)
{
cursor = LocateTag(arena, cursor, rec);
if (rec.Tag != TAG_EMPTY) {
std::cout << "skipping record\n";
cursor = SkipRecord(rec, cursor);
if (!arena.CursorInArena(cursor)) {
cursor = nullptr;
}
}
return cursor;
@ -134,23 +136,24 @@ LocateTag(Arena &arena, uint8_t *cursor, Record &rec)
}
if (cursor == nullptr) {
std::cout << "move cursor to arena start\n";
cursor = arena.Start();
}
while ((tag = cursor[0]) != rec.Tag) {
while (((tag = cursor[0]) != rec.Tag) &&
(arena.CursorInArena(cursor))) {
assert(arena.CursorInArena(cursor));
std::cout << "cursor is in arena\n";
len = cursor[1];
std::cout << "record length" << len << "\n";
if (!spaceAvailable(arena, cursor, len)) {
std::cout << "no space available\n";
return nullptr;
}
cursor += len;
cursor += 2;
}
if (!arena.CursorInArena(cursor)) {
return nullptr;
}
if (tag != rec.Tag) {
return nullptr;
}

View File

@ -23,6 +23,7 @@
#include "Exceptions.h"
#include "Test.h"
#include <cassert>
#include <iostream>
#include <sstream>