Skip to content

Commit

Permalink
Fix for github #4
Browse files Browse the repository at this point in the history
  • Loading branch information
itkatchev committed Jan 28, 2023
1 parent 1f44815 commit e868764
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 12 deletions.
9 changes: 6 additions & 3 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
{
pkgs ? import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/21.11.tar.gz") {}
pkgs ? import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/22.05.tar.gz") {}
} :
with pkgs;
mkShell.override { stdenv = gcc11Stdenv; } {
buildInputs = [ python3 glibc.static ];
let
stdenv = gcc11Stdenv;
in
mkShell.override { inherit stdenv; } {
buildInputs = [ stdenv.glibc.static python3 ];
}

22 changes: 14 additions & 8 deletions object.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,24 @@ namespace obj {

struct Printer {

virtual void val(tab::UInt v) { printf("%lu", v); }
virtual void val(tab::Int v) { printf("%ld", v); }
virtual void val(tab::Real v) { printf("%g", v); }
virtual void hex(tab::UInt v) { printf("0x%lX", v); }
bool null;
Printer() : null(true) {}

void bump() { null = false; }

virtual void val(tab::UInt v) { bump(); printf("%lu", v); }
virtual void val(tab::Int v) { bump(); printf("%ld", v); }
virtual void val(tab::Real v) { bump(); printf("%g", v); }
virtual void hex(tab::UInt v) { bump(); printf("0x%lX", v); }

virtual void val(const std::string& v) {
bump();
fwrite(v.data(), sizeof(char), v.size(), stdout);
}

virtual void rs() { printf("\t"); }
virtual void nl() { printf("\n"); }
virtual void alts() { printf(";"); }
virtual void rs() { bump(); printf("\t"); }
virtual void nl() { bump(); printf("\n"); }
virtual void alts() { bump(); printf(";"); }
};

template <bool COMPACT=false>
Expand Down Expand Up @@ -555,7 +561,7 @@ struct SeqBase : public Object {
void print(Printer& p) {

bool first = true;

while (1) {

Object* v = this->next();
Expand Down
6 changes: 5 additions & 1 deletion tab.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ void run(size_t seed, const std::string& program, const std::string& infile, uns

tab::obj::Printer p;
output->print(p);
p.nl();

// https://github.com/ivan-tkatchev/tab/issues/4
if (!p.null) {
p.nl();
}
}

void show_help(const std::string& help_section) {
Expand Down

0 comments on commit e868764

Please sign in to comment.