Skip to content

Commit

Permalink
Merge branch 'main' of github.com:coolbutuseless/yyjsonr
Browse files Browse the repository at this point in the history
  • Loading branch information
coolbutuseless committed Mar 6, 2024
2 parents 3020006 + fe83868 commit 2637624
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
14 changes: 14 additions & 0 deletions .devcontainer/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
pybryt
pylint
datascience
otter-grader
numpy
pandas
scipy
folium>=0.9.1
matplotlib
ipywidgets>=7.0.0
bqplot
nbinteract>=0.0.12
okpy
scikit-learn
10 changes: 8 additions & 2 deletions src/R-yyjson-parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -1961,8 +1961,11 @@ SEXP parse_from_gzfile_(SEXP filename_, SEXP parse_opts_) {

fseek(fp, -4, SEEK_END);
int32_t uncompressed_len;
fread(&uncompressed_len, 4, 1, fp);
size_t nbytes = fread(&uncompressed_len, 1, 4, fp);
fclose(fp);
if (nbytes != 4) {
error("Couldn't read size from end of file: %s", filename);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Allocate a buffer to hold the uncompressed file.
Expand All @@ -1977,8 +1980,11 @@ SEXP parse_from_gzfile_(SEXP filename_, SEXP parse_opts_) {
// Uncompress file to buffer
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gzFile gzfp = gzopen(filename, "r");
gzread(gzfp, (void *)buf, uncompressed_len);
int N = gzread(gzfp, (void *)buf, uncompressed_len);
gzclose(gzfp);
if (N != uncompressed_len) {
error("Incorrect number of bytes read. Expected %i, read %i", uncompressed_len, N);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Parse buffer as string
Expand Down

0 comments on commit 2637624

Please sign in to comment.