~extremepopcorn/dhlib/dhlib_ep

« back to all changes in this revision

Viewing changes to m4/array.m4

  • Committer: edA-qa mort-ora-y
  • Date: 2010-02-16 05:36:32 UTC
  • Revision ID: eda-qa@disemia.com-20100216053632-60lt7fndfi3fgblw
first

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
divert(`-1')
 
2
# Creates a new array with the given name
 
3
# CREATEARRAY(Name)
 
4
define(`CREATEARRAY',`define(`$1_COUNT',0)')
 
5
 
 
6
# Pushes a value onto the array
 
7
# PUSHARRAY(ArrayName,Value)
 
8
define(`PUSHARRAY',
 
9
        `define($1_`'$1_COUNT,`$2')dnl
 
10
        define(`$1_COUNT',eval($1_COUNT+1))')
 
11
 
 
12
# Obtains the current length of the array
 
13
define(`LENGTHARRAY',$1_COUNT)
 
14
 
 
15
# Iterates over th array, expanding "Expand" on each iteration
 
16
# setting the value "Var" to the current value from the array
 
17
# ITERARRAY(ArrayName, Var, Expand)
 
18
define(`ITERARRAY',`_ITERARRAY($1,$2,$3,0)')
 
19
define(`_ITERARRAY',
 
20
        `ifelse($1_COUNT,$4,`',`dnl
 
21
define(`$2',$1_`'$4)dnl
 
22
$3`'dnl
 
23
undefine(`$2')dnl
 
24
_ITERARRAY(`$1',`$2',`$3',eval($4+1))dnl
 
25
')')
 
26
divert
 
 
b'\\ No newline at end of file'