Skip to Content.
Sympa Menu

sm-commit - [SM-Commit] GIT changes to master sorcery by Jaka Kranjc (72afeab44f120ca41c5e013d38ce3752e48194c5)

sm-commit AT lists.ibiblio.org

Subject: Source Mage code commit list

List archive

Chronological Thread  
  • From: Jaka Kranjc <scm AT sourcemage.org>
  • To: sm-commit AT lists.ibiblio.org
  • Subject: [SM-Commit] GIT changes to master sorcery by Jaka Kranjc (72afeab44f120ca41c5e013d38ce3752e48194c5)
  • Date: Fri, 28 Mar 2008 12:32:09 -0500

GIT changes to master sorcery by Jaka Kranjc <lynxlynxlynx AT sourcemage.org>:

ChangeLog | 4 +++
var/lib/sorcery/modules/liblock | 7 +++---
var/lib/sorcery/modules/libmisc | 21 +++++++++++++------
var/lib/sorcery/modules/libsorcery | 5 ++--
var/lib/sorcery/modules/libstate | 38
++++++++++++++++++++++--------------
var/lib/sorcery/modules/libtriggers | 2 -
6 files changed, 50 insertions(+), 27 deletions(-)

New commits:
commit 72afeab44f120ca41c5e013d38ce3752e48194c5
Author: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
Commit: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>

libstate: converted two inline esc_str calls to the forkless version

with this + the previous commit to libstate there is a noticeable speedup
in
dependency resolution :)

time cast atk curl libao lyx xine-lib sip # which pulled in other spells
average of 3 isolated hot runs:
before: 95,51
after: 74,47
~20% gain :D

commit d5a2e5a097997a1da1acae2ce008f643710ee0d2
Author: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
Commit: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>

liblock: save the escaped string in lock_kill_transaction

commit bfbe4aecf8442e497d3c1ae79099025ef88f1926
Author: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
Commit: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>

lib*: use esc_str by reference

commit 6022a66eee03202c8eedc4f9a3ed269c047eb0ab
Author: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
Commit: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>

libmisc: made esc_str forkless and optionally return by reference

diff --git a/ChangeLog b/ChangeLog
index 8a91d88..8ecfcee 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,10 @@
* gaze, gaze.1: added size -all, initial patch from Danilo Vidovic
#13556
* url_git_local: added an url handler for local git urls, patch by
Andraž
Levstik #14397; fixed the comments and removed the netselect
function
+ * libmisc: made esc_str forkless and optionally return by reference
+ * libstate, libtriggers, libsorcery: use esc_str by reference
+ * liblock: save the escaped string in lock_kill_transaction
+ * libstate: converted two inline esc_str calls to the forkless version

2008-03-27 Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
* changed uses of plain sort|uniq to the featurewise equivalent sort
-u
diff --git a/var/lib/sorcery/modules/liblock b/var/lib/sorcery/modules/liblock
index c012281..8dc6676 100755
--- a/var/lib/sorcery/modules/liblock
+++ b/var/lib/sorcery/modules/liblock
@@ -341,14 +341,15 @@ function lock_commit_transaction()
function lock_kill_transaction()
{
debug "liblock" "$FUNCNAME - $*"
- local TMP_FILE
+ local TMP_FILE string

lock_file $LOCK_TRANSACTIONS
for i in $* ; do
- TMP_FILE=$(grep $(esc_str ".*:$i:$$") $LOCK_TRANSACTIONS | cut -d : -f 1)
+ esc_str ".*:$i:$$" string
+ TMP_FILE=$(grep "$string" $LOCK_TRANSACTIONS | cut -d : -f 1)
unlock_file $i
cp $LOCK_TRANSACTIONS $LOCK_TRANSACTIONS.1
- grep -v $(esc_str ".*:$i:$$") $LOCK_TRANSACTIONS.1 >$LOCK_TRANSACTIONS
+ grep -v "$string" $LOCK_TRANSACTIONS.1 >$LOCK_TRANSACTIONS
done
unlock_file $LOCK_TRANSACTIONS
}
diff --git a/var/lib/sorcery/modules/libmisc b/var/lib/sorcery/modules/libmisc
index fd5879a..f1e4b07 100755
--- a/var/lib/sorcery/modules/libmisc
+++ b/var/lib/sorcery/modules/libmisc
@@ -367,6 +367,7 @@ function edit_file() {

#---------------------------------------------------------------------
## @param string
+## @param (optional) upvar
## @Stdout escaped string
##
## Adds escape sequences to strings for special characters.
@@ -377,15 +378,21 @@ function edit_file() {
#---------------------------------------------------------------------
function esc_str()
{
-
- local OUT
- if [[ $* == ".*" ]] ; then
- echo "$1"
+ if [[ $1 == ".*" ]]; then
+ if [[ -z $2 ]]; then
+ echo "$1"
+ else
+ upvar $2 "$1"
+ fi
else
- echo "$@" | sed -e 's:\.:\\\.:'g \
- -e 's:\*:\\\*:'g
+ local escaped="${1//./\.}"
+ escaped="${escaped//\*/\*}"
+ if [[ -z $2 ]]; then
+ echo "$escaped"
+ else
+ upvar $2 "$escaped"
+ fi
fi
-
}


diff --git a/var/lib/sorcery/modules/libsorcery
b/var/lib/sorcery/modules/libsorcery
index 3f646d7..db26792 100755
--- a/var/lib/sorcery/modules/libsorcery
+++ b/var/lib/sorcery/modules/libsorcery
@@ -656,9 +656,10 @@ function dirnames() {
#---------------------------------------------------------------------
function pop_queue() { (

- local ITEM=`esc_str $2`
+ local ITEM
local exit_code=0

+ esc_str "$2" ITEM
lock_start_transaction "$1" tQUEUE_FILE
if ! [ -f "$1" ]; then
exit_code=1
@@ -670,7 +671,7 @@ function pop_queue() { (
if [ -z "$FOUND" ]; then
exit_code=1
else
- FOUND=`esc_str $FOUND`
+ esc_str "$FOUND" FOUND
grep -v "^$FOUND$" $1 > $tQUEUE_FILE
echo $FOUND
fi
diff --git a/var/lib/sorcery/modules/libstate
b/var/lib/sorcery/modules/libstate
index a1537b3..3ce15be 100755
--- a/var/lib/sorcery/modules/libstate
+++ b/var/lib/sorcery/modules/libstate
@@ -78,7 +78,8 @@ function search_depends_status_exact()
shift

local a1 a2 a3 a4 a5 a6
- a1=`esc_str "$1"` ; a2=`esc_str "$2"` ; a3=`esc_str "$3"` ; a4=`esc_str
"$4"`; a5=`esc_str "$5"`; a6=`esc_str "$6"`
+ esc_str "$1" a1; esc_str "$2" a2; esc_str "$3" a3
+ esc_str "$4" a4; esc_str "$5" a5; esc_str "$6" a6
debug "libstate" "search_depends_status_exact: [$a1:$a2:$a3:$a4:$a5:$a6]"

lock_file "$depends_status"
@@ -113,9 +114,9 @@ function search_depends_status_simple()
shift

local a1 a2 a3 a4 a5 a6
- a1=`esc_str "$1"` ; a2=`esc_str "$2"`
+ esc_str "$1" a1; esc_str "$2" a2
a3=${3:-.*} ; a4=${4:-.*}
- a5=`esc_str "$5"`; a6=`esc_str "$6"`
+ esc_str "$5" a5; esc_str "$6" a6
a5=${5:-.*} ; a6=${6:-.*}

lock_file "$depends_status"
@@ -143,11 +144,15 @@ function search_depends_status()
local depends_status=$1
shift

+ local spell
+ esc_str "$1" spell
# lock_file "$depends_status"
if [[ -z $2 ]]; then
- grep "^`esc_str "$1"`:" "$depends_status"
+ grep "^$spell:" "$depends_status"
else
- grep "^`esc_str "$1"`:`esc_str "$2"`:" "$depends_status"
+ local depends
+ esc_str "$2" depends
+ grep "^$spell:$depends:" "$depends_status"
fi
# unlock_file "$depends_status"
}
@@ -177,7 +182,8 @@ function get_depends_options()
return
}

- local START="$(esc_str $1)"
+ local START
+ esc_str "$1" START
debug "libstate" "get_depends_options() - START=$START"
lock_file "$depends_status"
awk -F ':' -v start=$START "{ if (\$1 == start) if (\$3 == \"on\") OPTS =
OPTS \" \" \$5; else OPTS = OPTS \" \" \$6; } END { print OPTS; }"
$depends_status 2> /dev/null
@@ -209,12 +215,12 @@ function remove_depends_status()
# look like regexps, 5 and 6 might like funny too
# contrast 3 and 4 which are "on", "off", "required" or "optional"
# if they are regexps its probably desired so dont escape those
- a1=`esc_str "$1"`; a2=`esc_str "$2"`
+ esc_str "$1" a1; esc_str "$2" a2
a1=${a1:-.*}; a2=${a2:-.*}

a3=${3:-.*} ; a4=${4:-.*}

- a5=`esc_str "$5"`; a6=`esc_str "$6"`
+ esc_str "$5" a5; esc_str "$6" a6
a5=${a5:-.*}; a6=${a6:-.*}
[[ "$a5" == "[none]" ]] && a5="\\[none\\]"

@@ -327,7 +333,7 @@ function search_sub_depends() {
local file=$1
shift
local a1 a2 a3
- a1=`esc_str "$1"` ; a2=`esc_str "$2"` ; a3=`esc_str "$3"`
+ esc_str "$1" a1; esc_str "$2" a2; esc_str "$3" a3
a1=${a1:-.*}
a2=${a2:-.*}
a3=${a3:-.*}
@@ -353,7 +359,7 @@ function remove_sub_depends() {
test -f $file || return

local a1 a2 a3
- a1=`esc_str "$1"`; a2=`esc_str "$2"`; a3=`esc_str "$3"`
+ esc_str "$1" a1; esc_str "$2" a2; esc_str "$3" a3
a1=${a1:-.*}; a2=${a2:-.*}; a3=${a3:-.*}

local t_file
@@ -443,7 +449,7 @@ function remove_default_depends() {
test -e $file || return

local a1 a2 a3
- a1=`esc_str $1` ; a2=`esc_str $2` ; a3=`esc_str $3`
+ esc_str "$1" a1; esc_str "$2" a2; esc_str "$3" a3

a3=${a3:-.*}

@@ -470,7 +476,7 @@ function search_default_depends() {
[[ -s $default_depends ]] || return

local a1 a2 a3
- a1=`esc_str "$1"` ; a2=`esc_str "$2"` ; a3=`esc_str "$3"`
+ esc_str "$1" a1; esc_str "$2" a2; esc_str "$3" a3
a3=${a3:-.*}

debug "libstate" "search_default_depends: [$a1:$a2:$a3]"
@@ -592,11 +598,15 @@ function search_spell_status() {
local spell_status=$1
shift

+ local spell
+ esc_str "$1" spell
lock_file "$spell_status"
if [[ -z $2 ]]; then
- grep "^`esc_str "$1"`:" $spell_status
+ grep "^$spell:" $spell_status
else
- grep "^`esc_str "$1:$2"`:" $spell_status
+ local version
+ esc_str "$2" version
+ grep "^$spell:$version:" $spell_status
fi
unlock_file "$spell_status"
}
diff --git a/var/lib/sorcery/modules/libtriggers
b/var/lib/sorcery/modules/libtriggers
index 58950e8..c8e36eb 100755
--- a/var/lib/sorcery/modules/libtriggers
+++ b/var/lib/sorcery/modules/libtriggers
@@ -57,7 +57,7 @@ function trigger ()

local spell TRIGGER action
action=$1
- spell=`esc_str ${SPELL:-$2}`
+ esc_str "${SPELL:-$2}" spell

[ -f $TRIGGER_LIST ] || return 0
iterate do_trigger $'\n' "`grep "^[^:]*:$spell:on_$action" $TRIGGER_LIST`"



  • [SM-Commit] GIT changes to master sorcery by Jaka Kranjc (72afeab44f120ca41c5e013d38ce3752e48194c5), Jaka Kranjc, 03/28/2008

Archive powered by MHonArc 2.6.24.

Top of Page