Skip to content

Commit

Permalink
Strip new line from raw string
Browse files Browse the repository at this point in the history
  • Loading branch information
adamritter committed Jun 29, 2023
1 parent 4416ab6 commit 0ef8006
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,7 @@ if(BASH_PROGRAM)

add_test(multi4 ${BASH_PROGRAM} -c "echo '{\"aa\":[1,2,3],\"b\":[2,3,4],\"c\":[4,5,6]}' | ${CMAKE_CURRENT_BINARY_DIR}/fastgron -p '[#][0]'")
set_tests_properties(multi4 PROPERTIES PASS_REGULAR_EXPRESSION "json.b\\[0\\] = 2")

add_test(bad_new_line ${BASH_PROGRAM} -c "echo '[{\"a\":1},3]' | ${CMAKE_CURRENT_BINARY_DIR}/fastgron")
set_tests_properties(bad_new_line PROPERTIES PASS_REGULAR_EXPRESSION "json\\[0\\].a = 1\njson\\[1\\] = 3")
endif(BASH_PROGRAM)
2 changes: 1 addition & 1 deletion src/print_gron.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ void recursive_print_gron(simdjson::ondemand::value element, growing_string &pat
*ptr++ = 'm';
}
string_view s = element.raw_json_token();
while (s.size() > 0 && s[s.size() - 1] == ' ')
while (s.size() > 0 && (s[s.size() - 1] == ' ' || s[s.size() - 1] == '\n'))
{
s.remove_suffix(1);
}
Expand Down

0 comments on commit 0ef8006

Please sign in to comment.