File: demo_glob2ere

package info (click to toggle)
runawk 1.6.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 712 kB
  • sloc: awk: 1,127; ansic: 736; sh: 420; makefile: 103
file content (27 lines) | stat: -rwxr-xr-x 613 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env runawk

#use "glob.awk"
#use "alt_assert.awk"

function test (input, ideal,
			   res)
{
	res = glob2ere(input)
	if (ideal != res){
		msg = ("test " num " failed")
		msg = msg "\n ideal=\"" ideal "\""
		msg = msg "\n res  =\"" res "\""
		abort(msg)
	}
}

BEGIN {
	test("osb", "osb")
	test("*.t[^.*]z", ".*[.]t[^.*]z")
	test("^$(){}.+|", "\\^[$][(][)][{][}][.][+][|]")
	test("\\^\\$\\(\\)\\{\\}\\.\\+\\|\\*\\[\\]\\?\\a\\b\\0\\9",
		 "\\^[$][(][)][{][}][.][+][|][*]\\[\\][?]ab09")
	test("*-[0-9]*\\\\", ".*-[0-9].*\\\\")
	test("?*[\\]*?\\[]?*[*\\[\\]?]*?", "..*[\\]*?\\[]..*[*\\[\\]?].*.")
	exit 0
}