From 064f57e321917c7ff72d5d1b1e6ff67346b74c84 Mon Sep 17 00:00:00 2001 From: Scott Ehlert Date: Fri, 4 Apr 2008 20:24:46 +0000 Subject: [PATCH] Fixed amb1580 - trailing comma wasn't allowed in multi-dimensional array initializations Also bumped compiler copyright year, since the same file was, um, changed --HG-- branch : sourcemod-1.0.1 extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/branches/sourcemod-1.0.1%401984 --- sourcepawn/compiler/sc1.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/sourcepawn/compiler/sc1.c b/sourcepawn/compiler/sc1.c index 75828758..db539958 100644 --- a/sourcepawn/compiler/sc1.c +++ b/sourcepawn/compiler/sc1.c @@ -1191,7 +1191,7 @@ static void setconfig(char *root) static void setcaption(void) { pc_printf("SourcePawn Compiler " SVN_FULL_VERSION "\n"); - pc_printf("Copyright (c) 1997-2006, ITB CompuPhase, (C)2004-2007 AlliedModders, LLC\n\n"); + pc_printf("Copyright (c) 1997-2006, ITB CompuPhase, (C)2004-2008 AlliedModders, LLC\n\n"); } static void about(void) @@ -2777,15 +2777,21 @@ static cell initarray(int ident,int tag,int dim[],int numdim,int cur, constvalue *enumroot,int *errorfound) { cell dsize,totalsize; - int idx,abortparse; + int idx,abortparse,needbrace; assert(cur>=0 && cur=0); assert(cur+2<=numdim);/* there must be 2 dimensions or more to do */ assert(errorfound!=NULL && *errorfound==FALSE); totalsize=0; + needbrace=1; needtoken('{'); for (idx=0,abortparse=FALSE; !abortparse; idx++) { + if (matchtoken('}')) + { + needbrace=0; + break; + } /* In case the major dimension is zero, we need to store the offset * to the newly detected sub-array into the indirection table; i.e. * this table needs to be expanded and updated. @@ -2815,7 +2821,10 @@ static cell initarray(int ident,int tag,int dim[],int numdim,int cur, if (*errorfound || !matchtoken(',')) abortparse=TRUE; } /* for */ - needtoken('}'); + if (needbrace) + { + needtoken('}'); + } assert(counteddim!=NULL); if (counteddim[cur]>0) { if (idx(int)size) { /* e.g. "myvar[3]={1,2,3,4};" */ - error(18); /* initialisation data exceeds declared size */ + error(18); /* initialization data exceeds declared size */ litidx=(int)size+curlit; /* avoid overflow in memory moves */ } /* if */ return size;