From 8bbdc3652fd3221d38c6cbbda3a77542cc09f27e Mon Sep 17 00:00:00 2001 From: spth Date: Mon, 19 May 2008 19:58:11 +0000 Subject: [PATCH] Support nested parenthesis in peephole function arguments (#1967300) git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@5163 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 5 +++++ src/SDCCpeeph.c | 15 ++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 76bd8640..7f37a001 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-05-19 Philipp Klaus Krause + + * src/SDCCpeeph.c (callFuncByName): + Support nested parenthesis in peephole function arguments (#1967300) + 2008-05-19 Raphael Neider * src/pic16/gen.c (pic16_emitpLabel,pic16_emitpLabelFORCE): diff --git a/src/SDCCpeeph.c b/src/SDCCpeeph.c index 075cad2a..e413d499 100644 --- a/src/SDCCpeeph.c +++ b/src/SDCCpeeph.c @@ -1269,9 +1269,18 @@ callFuncByName (char *fname, /* and there can be no additional conditions. */ if (c == '(') { - cmdTerm = funcArgs; - while ((c = *cmdTerm) && c != ')') - cmdTerm++; + + int num_parenthesis = 0; + cmdTerm = funcArgs; + + while ((c = *cmdTerm) && (c != ')' || num_parenthesis)) + { + if (c == '(') + num_parenthesis++; + else if (c == ')') + num_parenthesis--; + cmdTerm++; + } *cmdTerm = '\0'; /* terminate the arguments */ if (c == ')') { -- 2.30.2