diff --git a/src/runtime/c/pgf/pgf.cxx b/src/runtime/c/pgf/pgf.cxx index 1374d3667..1c90bbf3c 100644 --- a/src/runtime/c/pgf/pgf.cxx +++ b/src/runtime/c/pgf/pgf.cxx @@ -49,7 +49,7 @@ PgfDB *pgf_read_pgf(const char* fpath, { DB_scope scope(db, WRITER_SCOPE); - PgfReader rdr(in, fpath); + PgfReader rdr(in); ref pgf = rdr.read_pgf(); PgfDB::set_revision(pgf); @@ -88,7 +88,7 @@ PgfDB *pgf_boot_ngf(const char* pgf_path, const char* ngf_path, { DB_scope scope(db, WRITER_SCOPE); - PgfReader rdr(in, pgf_path); + PgfReader rdr(in); ref pgf = rdr.read_pgf(); PgfDB::set_revision(pgf); @@ -200,7 +200,7 @@ void pgf_write_pgf(const char* fpath, DB_scope scope(db, READER_SCOPE); ref pgf = PgfDB::revision2pgf(revision); - PgfWriter wtr(out, fpath); + PgfWriter wtr(out); wtr.write_pgf(pgf); } } PGF_API_END diff --git a/src/runtime/c/pgf/reader.cxx b/src/runtime/c/pgf/reader.cxx index 45ea438d7..cb0e7098a 100644 --- a/src/runtime/c/pgf/reader.cxx +++ b/src/runtime/c/pgf/reader.cxx @@ -3,10 +3,9 @@ #include #include -PgfReader::PgfReader(FILE *in, const char *filepath) +PgfReader::PgfReader(FILE *in) { this->in = in; - this->filepath = filepath; } uint8_t PgfReader::read_uint8() @@ -14,9 +13,9 @@ uint8_t PgfReader::read_uint8() uint8_t b; size_t n_bytes = fread((char*) &b, sizeof(b), 1, in); if (feof(in)) - throw pgf_error("reached end of file while reading a grammar"); + throw pgf_error("reached end of file while reading the grammar"); if (ferror(in)) - throw pgf_systemerror(ferror(in), filepath); + throw pgf_error("an error occured while reading the grammar"); return b; } @@ -28,7 +27,7 @@ uint16_t PgfReader::read_u16be() if (feof(in)) throw pgf_error("reached end of file while reading a grammar"); if (ferror(in)) - throw pgf_systemerror(ferror(in), filepath); + throw pgf_error("an error occured while reading the grammar"); return (((uint16_t) buf[0]) << 8 | buf[1]); } @@ -40,7 +39,7 @@ uint64_t PgfReader::read_u64be() if (feof(in)) throw pgf_error("reached end of file while reading a grammar"); if (ferror(in)) - throw pgf_systemerror(ferror(in), filepath); + throw pgf_error("an error occured while reading the grammar"); return (((uint64_t) buf[0]) << 56 | ((uint64_t) buf[1]) << 48 | @@ -96,7 +95,7 @@ object PgfReader::read_name_internal(size_t struct_size) if (feof(in)) throw pgf_error("utf8 decoding error"); if (ferror(in)) - throw pgf_systemerror(ferror(in), filepath); + throw pgf_error("an error occured while reading the grammar"); ptext->text[size] = 0; @@ -132,7 +131,7 @@ object PgfReader::read_text_internal(size_t struct_size) if (feof(in)) throw pgf_error("utf8 decoding error"); if (ferror(in)) - throw pgf_systemerror(ferror(in), filepath); + throw pgf_error("an error occured while reading the grammar"); p += len; } diff --git a/src/runtime/c/pgf/reader.h b/src/runtime/c/pgf/reader.h index b14bc6665..3cb097d97 100644 --- a/src/runtime/c/pgf/reader.h +++ b/src/runtime/c/pgf/reader.h @@ -8,7 +8,7 @@ class PGF_INTERNAL_DECL PgfReader { public: - PgfReader(FILE *in, const char *filepath); + PgfReader(FILE *in); uint8_t read_uint8(); uint16_t read_u16be(); @@ -72,7 +72,6 @@ public: private: FILE *in; - const char* filepath; object read_name_internal(size_t struct_size); object read_text_internal(size_t struct_size); diff --git a/src/runtime/c/pgf/writer.cxx b/src/runtime/c/pgf/writer.cxx index 74728e61a..4a2278015 100644 --- a/src/runtime/c/pgf/writer.cxx +++ b/src/runtime/c/pgf/writer.cxx @@ -2,10 +2,9 @@ #include "data.h" #include "writer.h" -PgfWriter::PgfWriter(FILE *out, const char *filepath) +PgfWriter::PgfWriter(FILE *out) { this->out = out; - this->filepath = filepath; this->abstract = 0; } @@ -13,7 +12,7 @@ void PgfWriter::write_uint8(uint8_t b) { size_t n_items = fwrite(&b, sizeof(b), 1, out); if (ferror(out)) - throw pgf_systemerror(ferror(out), filepath); + throw pgf_error("an error occured while writing out the grammar"); if (n_items != 1) throw pgf_error("couldn't write to the output file"); } @@ -26,7 +25,7 @@ void PgfWriter::write_u16be(uint16_t u) size_t n_items = fwrite(&buf, sizeof(buf), 1, out); if (ferror(out)) - throw pgf_systemerror(ferror(out), filepath); + throw pgf_error("an error occured while writing out the grammar"); if (n_items != 1) throw pgf_error("couldn't write to the output file"); } @@ -45,7 +44,7 @@ void PgfWriter::write_u64be(uint64_t u) size_t n_items = fwrite(&buf, sizeof(buf), 1, out); if (ferror(out)) - throw pgf_systemerror(ferror(out), filepath); + throw pgf_error("an error occured while writing out the grammar"); if (n_items != 1) throw pgf_error("couldn't write to the output file"); } @@ -90,7 +89,7 @@ void PgfWriter::write_uint(uint64_t u) if (u == 0) { size_t n_items = fwrite(&b, sizeof(b), 1, out); if (ferror(out)) - throw pgf_systemerror(ferror(out), filepath); + throw pgf_error("an error occured while writing out the grammar"); if (n_items != 1) throw pgf_error("couldn't write to the output file"); @@ -100,7 +99,7 @@ void PgfWriter::write_uint(uint64_t u) size_t n_items = fwrite(&b, sizeof(b), 1, out); if (ferror(out)) - throw pgf_systemerror(ferror(out), filepath); + throw pgf_error("an error occured while writing out the grammar"); if (n_items != 1) throw pgf_error("couldn't write to the output file"); } @@ -112,7 +111,7 @@ void PgfWriter::write_name(PgfText *text) write_len(text->size); size_t n_items = fwrite(&text->text, text->size, 1, out); if (ferror(out)) - throw pgf_systemerror(ferror(out), filepath); + throw pgf_error("an error occured while writing out the grammar"); if (n_items != 1) throw pgf_error("couldn't write to the output file"); } @@ -128,7 +127,7 @@ void PgfWriter::write_text(PgfText *text) write_len(len); size_t n_items = fwrite(&text->text, text->size, 1, out); if (ferror(out)) - throw pgf_systemerror(ferror(out), filepath); + throw pgf_error("an error occured while writing out the grammar"); if (n_items != 1) throw pgf_error("couldn't write to the output file"); } diff --git a/src/runtime/c/pgf/writer.h b/src/runtime/c/pgf/writer.h index 6cde9d3f9..fa0f246ad 100644 --- a/src/runtime/c/pgf/writer.h +++ b/src/runtime/c/pgf/writer.h @@ -4,7 +4,7 @@ class PGF_INTERNAL_DECL PgfWriter { public: - PgfWriter(FILE *out, const char *filepath); + PgfWriter(FILE *out); void write_uint8(uint8_t b); void write_u16be(uint16_t u); @@ -49,7 +49,6 @@ private: void write_namespace_helper(Namespace nmsp, void (PgfWriter::*write_value)(ref)); FILE *out; - const char* filepath; ref abstract; };