From 685d9970cc58adc93500058215ae6c9337790a59 Mon Sep 17 00:00:00 2001 From: Christian Schneider Date: Mon, 17 Aug 2009 17:37:31 +0000 Subject: Replace all {params} in one go to avoid double replacements --- it.class | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'it.class') diff --git a/it.class b/it.class index 32b6a13..9d43983 100644 --- a/it.class +++ b/it.class @@ -425,8 +425,9 @@ function exec(/* $cmd, $values1 = array(), ... */) #for escapeshellarg in it::_exec_quotevalue $oldlocale = setlocale(LC_CTYPE, 0); setlocale(LC_CTYPE, 'de_CH'); - while (list($tag, $option, $key) = it::match('({(-?)(\w+)})', $cmd)) + foreach (it::match('({(-?)([a-z]\w*)})', $cmd, array('all' => true)) as $tags) { + list($tag, $option, $key) = $tags; $parts = array(); if ($option) @@ -445,8 +446,10 @@ function exec(/* $cmd, $values1 = array(), ... */) $parts[] = it::_exec_quotevalue($value); } - $cmd = str_replace($tag, join(" ", $parts), $cmd); + $replacements[$tag] = join(" ", $parts); } + + $cmd = strtr($cmd, (array)$replacements); # Use strtr behaviour of going through source string once setlocale(LC_CTYPE, $oldlocale); $s = gettimeofday(); -- cgit v1.2.3