From 44a45d1f441ee8a6819f9e2521f6b6df4e02c376 Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Fri, 7 Mar 2014 00:47:28 -0500 Subject: [PATCH] rmtrail now handles single-line comments following trailing comma --- test/test-rmtrail | 12 ++++++++++-- tools/rmtrail | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/test/test-rmtrail b/test/test-rmtrail index 3760ca2..46aedc9 100755 --- a/test/test-rmtrail +++ b/test/test-rmtrail @@ -27,7 +27,11 @@ TEST_DATA=$( echo '[a,b,]{a,b,}[ ]{ a, b, - }' \ + } + [c, // comment] + [d, //comment + ] + [e,// comment]' \ | $PATH_TOOLS/rmtrail ) @@ -38,7 +42,11 @@ TEST_CMP='[a,b]{a,b}[ ]{ a, b - }' + } + [c // comment] + [d //comment + ] + [e// comment]' \ # perform the assertion if [ ! "$TEST_DATA" == "$TEST_CMP" ]; then diff --git a/tools/rmtrail b/tools/rmtrail index 2f813c5..7445af4 100755 --- a/tools/rmtrail +++ b/tools/rmtrail @@ -41,7 +41,7 @@ cat - \ $ { # pull from hold and perform replacement g - s/,\(\s*[]}]\)/\1/g + s/,\(\s*\(\/\/[^]}\n]\+\s*\)\?[]}]\)/\1/g # print result p