xref: /illumos-gate/usr/src/test/util-tests/tests/awk/gnu/arrayind3.awk (revision e6d6c189fa3a95d7aa27bbe0aeacf7c1a6b57c8c)
1*e6d6c189SCody Peter MelloBEGIN {
2*e6d6c189SCody Peter Mello	# initialize cint arrays
3*e6d6c189SCody Peter Mello        pos[0] = 0
4*e6d6c189SCody Peter Mello        posout[0] = 0
5*e6d6c189SCody Peter Mello        split("00000779770060", f)      # f[1] is a strnum
6*e6d6c189SCody Peter Mello        pos[f[1]] = 1                   # subscripts must be strings!
7*e6d6c189SCody Peter Mello        for (x in pos) {
8*e6d6c189SCody Peter Mello                # if x is a strnum, then the
9*e6d6c189SCody Peter Mello                # x != 0 test may convert it to an integral NUMBER,
10*e6d6c189SCody Peter Mello		# and we might lose the unusual string representation
11*e6d6c189SCody Peter Mello		# if the cint code is not careful to recognize that this is
12*e6d6c189SCody Peter Mello		# actually a string
13*e6d6c189SCody Peter Mello                if (x != 0)
14*e6d6c189SCody Peter Mello                        posout[x] = pos[x]
15*e6d6c189SCody Peter Mello        }
16*e6d6c189SCody Peter Mello        # which array element is populated?
17*e6d6c189SCody Peter Mello        print posout[779770060]
18*e6d6c189SCody Peter Mello        print posout["00000779770060"]
19*e6d6c189SCody Peter Mello}
20