From 74908098f40d844a565dc728c6c738bd1cedff2b Mon Sep 17 00:00:00 2001 From: Ryan Stecker Date: Sat, 23 Aug 2014 18:11:03 -0500 Subject: [PATCH 1/2] Allow trailing commas in string array declarations. (bug 6239) --- sourcepawn/compiler/sc1.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sourcepawn/compiler/sc1.cpp b/sourcepawn/compiler/sc1.cpp index 4baca471..80fdad7b 100644 --- a/sourcepawn/compiler/sc1.cpp +++ b/sourcepawn/compiler/sc1.cpp @@ -2720,8 +2720,11 @@ static cell initvector(int ident,int tag,cell size,int fillzero, } while (matchtoken(',')); /* do */ needtoken('}'); } else { - init(ident,&ctag,errorfound); - matchtag(tag,ctag,TRUE); + if (!lexpeek('}')) + { + init(ident,&ctag,errorfound); + matchtag(tag,ctag,TRUE); + } } /* if */ /* fill up the literal queue with a series */ if (ellips) { From 302dc1cb8aad10d155c09c543a36ee9235ee7d58 Mon Sep 17 00:00:00 2001 From: Ryan Stecker Date: Tue, 26 Aug 2014 14:58:58 -0500 Subject: [PATCH 2/2] Add test. --- .../tests/ok-trailing-comma-in-literal.sp | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 sourcepawn/compiler/tests/ok-trailing-comma-in-literal.sp diff --git a/sourcepawn/compiler/tests/ok-trailing-comma-in-literal.sp b/sourcepawn/compiler/tests/ok-trailing-comma-in-literal.sp new file mode 100644 index 00000000..e1876f6d --- /dev/null +++ b/sourcepawn/compiler/tests/ok-trailing-comma-in-literal.sp @@ -0,0 +1,20 @@ + +new String:oldArray[][] = +{ + "string", + "string2", +}; + +char newArray[][] = +{ + "another string", + "more strings", +}; + +native Print( const String:string[] ); + +public OnPluginStart() +{ + Print( oldArray[ 0 ] ); + Print( newArray[ 0 ] ); +}