From ab42b8cfd86a186447528e538ec0ae94751cfc1d Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 5 Aug 2024 11:54:32 +0200 Subject: Adding upstream version 8.2406.0. Signed-off-by: Daniel Baumann --- runtime/srutils.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'runtime/srutils.c') diff --git a/runtime/srutils.c b/runtime/srutils.c index 3369975..f949d5b 100644 --- a/runtime/srutils.c +++ b/runtime/srutils.c @@ -836,12 +836,25 @@ split_binary_parameters(uchar **const szBinary, char ***const __restrict__ aPara iCnt = iStr = 0; c = es_getBufAddr(estrParams); /* Reset to beginning */ while(iCnt < es_strlen(estrParams) ) { - if ( c[iCnt] == ' ' && !bInQuotes ) { - estrTmp = es_newStrFromSubStr( estrParams, iStr, iCnt-iStr); - } else if ( iCnt+1 >= es_strlen(estrParams) ) { - estrTmp = es_newStrFromSubStr( estrParams, iStr, iCnt-iStr+1); - } else if (c[iCnt] == '"') { - bInQuotes = !bInQuotes; + if (c[iCnt] == '"' && iCnt == iStr && !bInQuotes) { + bInQuotes = TRUE; + iStr++; + } else { + int bEOL = iCnt+1 == es_strlen(estrParams); + int bSpace = c[iCnt] == ' '; + int bQuoteEnd = bInQuotes && ((bSpace && c[iCnt-1] == '"') || + (c[iCnt] == '"' && bEOL)); + if (bEOL || bQuoteEnd || (bSpace && !bInQuotes)) { + int iSubCnt = iCnt - iStr; + if (bEOL) + iSubCnt++; + if (bQuoteEnd) + iSubCnt--; + estrTmp = es_newStrFromSubStr(estrParams, iStr, iSubCnt); + } + + if (bQuoteEnd) + bInQuotes = FALSE; } if ( estrTmp != NULL ) { -- cgit v1.2.3