Skip to Content.
Sympa Menu

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

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 (fa32307cfd3a6ec35ca82ce072933906472453b3)
  • Date: Mon, 24 Mar 2008 11:58:00 -0500

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

ChangeLog | 5 ++++
var/lib/sorcery/modules/libcodex | 48
+++++++++++++++++++++++++++------------
var/lib/sorcery/modules/libstate | 4 +--
3 files changed, 41 insertions(+), 16 deletions(-)

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

fixed ENTERED typo in codex_clear_current_spell and two comments

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

libcodex: made a few trivial optimisations, making the remaining relevant
functions return by reference

diff --git a/ChangeLog b/ChangeLog
index 1f3e7d2..3210c15 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,2 +1,7 @@
2008-03-24 Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
+ * libcodex: made a few trivial optimisations, making the remaining
relevant
+ functions return by reference
+ fixed ENTERED typo in codex_clear_current_spell and two comments
+
+2008-03-24 Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
* Start 1.15 development stream.
diff --git a/var/lib/sorcery/modules/libcodex
b/var/lib/sorcery/modules/libcodex
index d01eb85..c8cf3a5 100755
--- a/var/lib/sorcery/modules/libcodex
+++ b/var/lib/sorcery/modules/libcodex
@@ -62,6 +62,7 @@
#---------------------------------------------------------------------
## @param grimoire
## @param lookup (optional)
+## @param variable to set (optional)
## @return 0 if grimoire can be canonicalized
##
## Outputs a grimoire in canonical form (full path)
@@ -74,14 +75,28 @@ function codex_canonicalize_grimoire_name() {
local grimoire=$1
if [ "${grimoire:0:1}" == "/" ] ; then
# already a full path
- echo $1
+ if [[ -z $3 ]]; then
+ echo $grimoire
+ else
+ eval "$3=\"\$grimoire\""
+ fi
return 0
fi

if [ "$2" == "lookup" ] ; then
- codex_find_grimoire $1
+ if [[ -z $3 ]]; then
+ codex_find_grimoire $grimoire
+ else
+ local grim idx
+ codex_find_grimoire $grimoire grim idx
+ eval "$3=\"\$grim\""
+ fi
else
- echo "$CODEX_ROOT/$grimoire"
+ if [[ -z $3 ]]; then
+ echo "$CODEX_ROOT/$grimoire"
+ else
+ eval "$3=\"\$CODEX_ROOT/\$grimoire\""
+ fi
fi
# do nothing and preserve return code
}
@@ -96,7 +111,8 @@ function codex_is_canonicalized() {

#---------------------------------------------------------------------
## @param grimoire name, or path to one
-## @param variable name, is set to the index number
+## @param variable name, is set to the matching grimoire (optional)
+## @param variable name, is set to the matching grimoire's index (optional)
## @Stdout the grimoire's path
## @return 0 there is a grimoire
## @return 1 there is no grimoire
@@ -318,7 +334,7 @@ function codex_set_grimoires() {
local NEW_GRIMOIRE
local GRIMOIRE_COUNT=0
for NEW_GRIMOIRE in "$@"; do
- NEW_GRIMOIRE=$(codex_canonicalize_grimoire_name $NEW_GRIMOIRE lookup) &&
+ codex_canonicalize_grimoire_name $NEW_GRIMOIRE lookup NEW_GRIMOIRE &&
test -d $NEW_GRIMOIRE ||
{ message "WARNING $NEW_GRIMOIRE does not exist!! skipping..."
continue
@@ -351,6 +367,7 @@ function codex_get_all_grimoires() {

#---------------------------------------------------------------------
## @param section
+## @param variable to set (optional)
## @return 0 if section is found
## @return 1 if section is not found
##
@@ -367,7 +384,11 @@ function codex_find_section_by_name() {
for GRIMOIRE in `codex_get_all_grimoires`; do
if [ -d "$GRIMOIRE/$SECTION_NAME" ] ; then
debug "libcodex" "codex_find_section_by_name() - found section
$GRIMOIRE/$SECTION_NAME"
- echo "$GRIMOIRE/$SECTION_NAME"
+ if [[ -z $2 ]]; then
+ echo "$GRIMOIRE/$SECTION_NAME"
+ else
+ eval "$2=\"\$GRIMOIRE/\$SECTION_NAME\""
+ fi
return 0
fi
done
@@ -503,8 +524,8 @@ function codex_find_spell_by_name() {
function codex_get_spells_in_section() {
debug "libcodex" "codex_get_spells_in_section - $*"
codex_is_canonicalized $1 || return 1
- local section=`basename $1`
- local index="`dirname $1`/$SPELL_INDEX_FILE"
+ local section="$(smgl_basename $1)"
+ local index="$(smgl_dirname $1)/$SPELL_INDEX_FILE"
if ! test -r $index || ! test -s $index; then
message "${PROBLEM_COLOR}${section:-<null>} is not a section
directory!${DEFAULT_COLOR}"
return 1
@@ -576,14 +597,14 @@ function codex_get_spell_section_name() {

#---------------------------------------------------------------------
##
-## @Globals GRIMOIRE SECTION SECTION_DIRECTORY SPELL SPELL_DIRECTORY
SCRIPT_DIRECTORY SPELL_DESCRIPTION VERSION SHORT UPDATED SOURCE WEB_SITE
ENTERRED MAINTAINER MD5 LICENSE
+## @Globals GRIMOIRE SECTION SECTION_DIRECTORY SPELL SPELL_DIRECTORY
SCRIPT_DIRECTORY SPELL_DESCRIPTION VERSION SHORT UPDATED SOURCE WEB_SITE
ENTERED MAINTAINER MD5 LICENSE
## Unets all these global variables.
##
#---------------------------------------------------------------------
function codex_clear_current_spell() {
unset GRIMOIRE SECTION SECTION_DIRECTORY SPELL \
SPELL_DIRECTORY SCRIPT_DIRECTORY SPELL_DESCRIPTION \
- VERSION SHORT UPDATED SOURCE WEB_SITE ENTERRED MAINTAINER \
+ VERSION SHORT UPDATED SOURCE WEB_SITE ENTERED MAINTAINER \
MD5 LICENSE BUILD_API SECURITY_PATCH PATCHLEVEL
}

@@ -591,7 +612,7 @@ function codex_clear_current_spell() {
## @param spell directory
## @Globals All vars set in a spell
## Sets the GRIMOIRE, SECTION, SECTION_DIRECTORY, SPELL_DIRECTORY,
-## SCRIPT_DIRECTORY, and SPELL_DESCRIPTION global variables for the
+## SCRIPT_DIRECTORY global variables for the
## given spell directory.
##
## Assumes the directory passed in is a valid spell directory.
@@ -675,8 +696,7 @@ function codex_get_spell_paths() {
#---------------------------------------------------------------------
## @param spell name
## Sets the GRIMOIRE, SECTION, SECTION_DIRECTORY, SPELL_DIRECTORY,
-## SCRIPT_DIRECTORY, and SPELL_DESCRIPTION global variables for the
-## given spell name.
+## SCRIPT_DIRECTORY global variables for the given spell name.
##
## @return 1 if the given name is not a spell.
##
@@ -881,7 +901,7 @@ function codex_find_spell_or_section_by_name() {
CODEX_FOUND_SECTION=""
CODEX_FOUND_SPELL=""

- CODEX_FOUND_SECTION=`codex_find_section_by_name $SPELL_OR_SECTION`
+ codex_find_section_by_name $SPELL_OR_SECTION CODEX_FOUND_SECTION
[ -n "$CODEX_FOUND_SECTION" ] && return

CODEX_FOUND_SPELL=`codex_find_spell_by_name $SPELL_OR_SECTION`
diff --git a/var/lib/sorcery/modules/libstate
b/var/lib/sorcery/modules/libstate
index dafec00..0b6057a 100755
--- a/var/lib/sorcery/modules/libstate
+++ b/var/lib/sorcery/modules/libstate
@@ -1011,9 +1011,9 @@ function remove_config() {
## returns true if the grimoire is set local, false otherwise.
#---------------------------------------------------------------------
function codex_is_local () {(
- local g_name=$1
+ local g_name=$1 idx

- local grimoire=$(codex_find_grimoire $g_name)
+ codex_find_grimoire $g_name grimoire idx
if ! [[ $grimoire ]]; then
return 1
fi



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

Archive powered by MHonArc 2.6.24.

Top of Page