1. juster
  2. passcard

Commits

juster  committed 5597aea

Rename passcard.awk to passcard.

  • Participants
  • Parent commits b4da181
  • Branches default

Comments (0)

Files changed (2)

File passcard

View file
+#!/bin/sh
+
+unset d s
+
+while [ $# -gt 0 ]
+do
+	case "$1" in
+	-d)	d=1 ;;
+	-s)	s=1 ;;
+	*)	echo "usage: passcard [-d] [-s]" 1>&2
+		exit 2
+	esac
+	shift
+done
+
+awk -v usedigits="$d" -v usesyms="$s" '
+BEGIN {
+	for(i=1; i<=ARGC; i++){
+		if(ARGV[i] == "-s"){
+			usesyms = 1; ARGV[i] = ""
+		}else if(ARGV[i] == "-0"){
+			usedigits = 1; ARGV[i] = ""
+		}
+	}
+
+	end = split("■ □ ▲ △ ○ ● ★ ☂ ☀ ☁ ☹ ☺ ♠ ♣ ♥ ♦ ♫ € ¥ £ $ ! ? ¡ ¿ ⊙ ◐ ◩ �", hdr)
+	alphanum = "23456789abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"
+	alphanumsym = alphanum "@#$%&*<>?€+{}[]()/\\"
+	nums = "0123456789"
+}
+
+function randidx(len)
+{
+	return int(rand() * len) + 1
+}
+
+function header()
+{
+	for(i=2; i<=end; i++){
+		j = randidx(i)
+		tmp = hdr[i]
+		hdr[i] = hdr[j]
+		hdr[j] = tmp
+	}
+
+	outstr = ""
+	for(i=1; i<=end; i++){
+		outstr = outstr hdr[i]
+	}
+	return outstr
+}
+
+0 + $0 { srand($0) }
+!(0 + $0) { srand() }
+
+{
+	print "  " header()
+	print " +-----------------------------"
+	for(i=1; i<=9; i++){
+		line = i "|"
+		for(j=0; j<29; j++){
+			charset = (usedigits && i > 5 ? nums : \
+				usesyms && j % 2 == 0 ? alphanumsym : \
+				alphanum)
+			line = line substr(charset, randidx(length(charset)), 1)
+		}
+		print line
+	}
+}
+'

File passcard.awk

-#!/bin/sh
-
-unset d s
-
-while [ $# -gt 0 ]
-do
-	case "$1" in
-	-d)	d=1 ;;
-	-s)	s=1 ;;
-	*)	echo "usage: passcard [-d] [-s]" 1>&2
-		exit 2
-	esac
-	shift
-done
-
-awk -v usedigits="$d" -v usesyms="$s" '
-BEGIN {
-	for(i=1; i<=ARGC; i++){
-		if(ARGV[i] == "-s"){
-			usesyms = 1; ARGV[i] = ""
-		}else if(ARGV[i] == "-0"){
-			usedigits = 1; ARGV[i] = ""
-		}
-	}
-
-	end = split("■ □ ▲ △ ○ ● ★ ☂ ☀ ☁ ☹ ☺ ♠ ♣ ♥ ♦ ♫ € ¥ £ $ ! ? ¡ ¿ ⊙ ◐ ◩ �", hdr)
-	alphanum = "23456789abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"
-	alphanumsym = alphanum "@#$%&*<>?€+{}[]()/\\"
-	nums = "0123456789"
-}
-
-function randidx(len)
-{
-	return int(rand() * len) + 1
-}
-
-function header()
-{
-	for(i=2; i<=end; i++){
-		j = randidx(i)
-		tmp = hdr[i]
-		hdr[i] = hdr[j]
-		hdr[j] = tmp
-	}
-
-	outstr = ""
-	for(i=1; i<=end; i++){
-		outstr = outstr hdr[i]
-	}
-	return outstr
-}
-
-0 + $0 { srand($0) }
-!(0 + $0) { srand() }
-
-{
-	print "  " header()
-	print " +-----------------------------"
-	for(i=1; i<=9; i++){
-		line = i "|"
-		for(j=0; j<29; j++){
-			charset = (usedigits && i > 5 ? nums : \
-				usesyms && j % 2 == 0 ? alphanumsym : \
-				alphanum)
-			line = line substr(charset, randidx(length(charset)), 1)
-		}
-		print line
-	}
-}
-'