Skip to content

Commit

Permalink
Merge pull request #41 from joescharf/master
Browse files Browse the repository at this point in the history
Missing for loops in sexp.parseSymName() and sexp.parseString() causing vector attributes to be parsed incorrectly
  • Loading branch information
dareid committed Sep 4, 2018
2 parents b3077dc + d851b4a commit 5a944f2
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion sexp/xt-string.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package sexp

func parseString(buf []byte, offset, end int) (interface{}, int, error) {
endOfString := offset
if buf[endOfString] != 0 && endOfString < end {
for buf[endOfString] != 0 && endOfString < end {
endOfString = endOfString + 1
}
return []string{string(buf[offset:endOfString])}, end, nil
Expand Down
2 changes: 1 addition & 1 deletion sexp/xt-sym-name.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package sexp

func parseSymName(buf []byte, offset, end int) (interface{}, int, error) {
endOfString := offset
if buf[endOfString] != 0 && endOfString < end {
for buf[endOfString] != 0 && endOfString < end {
endOfString = endOfString + 1
}
return string(buf[offset:endOfString]), end, nil
Expand Down
4 changes: 2 additions & 2 deletions sexp/xt-vector.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ func parseVectorAttr(attr interface{}, vectorArr []interface{}, offset int) (int
if !ok {
return vectorArr, offset, nil
}
names, ok := attrMap["n"].([]string)
names, ok := attrMap["names"].([]string)
if !ok {
name, ok := attrMap["n"].(string)
name, ok := attrMap["names"].(string)
if !ok {
return nil, offset, errors.New("Vector names not parsed correctly")
}
Expand Down
5 changes: 5 additions & 0 deletions sexp_parsing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,8 @@ func TestLangTag(t *testing.T) {
_, err := getResultObject("expression(2^x)")
assert.Nil(t, err)
}

func TestClass(t *testing.T) {
_, err := getResultObject("setClass('test_class', slots=c(listslot='list', aslot='apNull', numslot='numeric', chrslot='character'), contains='data.frame'); j <- new('test_class'); d <- j")
assert.Nil(t, err)
}
4 changes: 2 additions & 2 deletions test/Dockerfile-RServe-Cran
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FROM r-base:3.2.1
FROM r-base:3.5.1

RUN apt-get update

RUN apt-get install -y --no-install-recommends \
RUN apt-get install -y --no-install-recommends\
libxml2-dev \
libcurl4-gnutls-dev \
libssl-dev
Expand Down
2 changes: 1 addition & 1 deletion test/Dockerfile-RServe-RForge
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM r-base:3.2.1
FROM r-base:3.5.1

RUN apt-get update

Expand Down

0 comments on commit 5a944f2

Please sign in to comment.