aboutsummaryrefslogtreecommitdiffstats
path: root/devel/tclgetopts
diff options
context:
space:
mode:
authorsteve <steve@FreeBSD.org>1999-05-03 11:23:01 +0800
committersteve <steve@FreeBSD.org>1999-05-03 11:23:01 +0800
commit03d45c05301836cae88bb3706d3337f72c8d8791 (patch)
tree47018eecb9e7d04ea64ad256556e2d71142bd6a7 /devel/tclgetopts
parent6bd1a30a7abbd2f1648f846a1f729d57dd4ee116 (diff)
downloadfreebsd-ports-gnome-03d45c05301836cae88bb3706d3337f72c8d8791.tar.gz
freebsd-ports-gnome-03d45c05301836cae88bb3706d3337f72c8d8791.tar.zst
freebsd-ports-gnome-03d45c05301836cae88bb3706d3337f72c8d8791.zip
Initial import of tclGetOpts version 1.0.
Pure TCL code for command line options parsing. PR: 10661 Submitted by: Mikhail Teterin <mi@aldan.algebra.com>
Diffstat (limited to 'devel/tclgetopts')
-rw-r--r--devel/tclgetopts/Makefile29
-rw-r--r--devel/tclgetopts/distinfo1
-rw-r--r--devel/tclgetopts/files/patch-aa148
-rw-r--r--devel/tclgetopts/files/patch-ab10
-rw-r--r--devel/tclgetopts/files/pkgIndex.tcl6
-rw-r--r--devel/tclgetopts/pkg-comment1
-rw-r--r--devel/tclgetopts/pkg-descr23
-rw-r--r--devel/tclgetopts/pkg-plist4
8 files changed, 222 insertions, 0 deletions
diff --git a/devel/tclgetopts/Makefile b/devel/tclgetopts/Makefile
new file mode 100644
index 000000000000..ae3888ad0985
--- /dev/null
+++ b/devel/tclgetopts/Makefile
@@ -0,0 +1,29 @@
+# New ports collection makefile for: tcl-getopt
+# Version required: 1.0
+# Date created: Mar 18, 1999
+# Whom: mi
+#
+# $Id$
+#
+
+DISTNAME= tclGetOpts
+PKGNAME= tclGetOpts-1.0
+CATEGORIES= devel tcl
+MASTER_SITES= ftp://ftp.neosoft.com/pub/tcl/sorted/devel/
+
+MAINTAINER= mi@aldan.algebra.com
+
+NO_BUILD= YES
+
+MANN= getopt.n typedopts.n
+
+do-install:
+ ${MKDIR} ${PREFIX}/lib/foxGetOpt
+ ${INSTALL_SCRIPT} \
+ ${FILESDIR}/pkgIndex.tcl \
+ ${WRKSRC}/foxTypedOpts.tcl \
+ ${WRKSRC}/foxGetOpt.tcl ${PREFIX}/lib/foxGetOpt/
+ ${INSTALL_MAN} ${WRKSRC}/getopt.n ${WRKSRC}/typedopts.n \
+ ${PREFIX}/man/mann/
+
+.include <bsd.port.mk>
diff --git a/devel/tclgetopts/distinfo b/devel/tclgetopts/distinfo
new file mode 100644
index 000000000000..b742cc598f19
--- /dev/null
+++ b/devel/tclgetopts/distinfo
@@ -0,0 +1 @@
+MD5 (tclGetOpts.tar.gz) = f0a701007a5374980c97a5306ce62141
diff --git a/devel/tclgetopts/files/patch-aa b/devel/tclgetopts/files/patch-aa
new file mode 100644
index 000000000000..b6758e7bbdb3
--- /dev/null
+++ b/devel/tclgetopts/files/patch-aa
@@ -0,0 +1,148 @@
+--- foxTypedOpts.tcl.orig Sat Feb 19 19:46:50 1994
++++ foxTypedOpts.tcl Thu Mar 18 16:15:13 1999
+@@ -80,9 +80,8 @@
+ # typedopts several times with different <arg-list>s without losing the
+ # information from previous calls.
+ #
+-# if typedopts can't parse its options for any reason, it will print an
+-# error message to stderr and return a -1 without modifying any other
+-# variables.
++# if typedopts can't parse its options for any reason, it return an
++# error message without modifying any other variables.
+ #
+ # EXAMPLE:
+ #
+@@ -157,8 +156,7 @@
+ # Initial revision
+ #
+
+-proc typedopts { args } {
+-
++namespace eval foxOpts {
+ proc abbr { s1 s2 } {
+ if { [ set len [ string length $s1 ]] } then {
+ if { ! [ string compare $s1 [ string range $s2 0 [ expr $len - 1 ]]] } then {
+@@ -298,8 +296,7 @@
+ return 1
+ }
+ default {
+- puts stderr "Eek! Option type <$otype> not supported yet!"
+- set var "isn't a supported type."
++ set var "<$otype> isn't a supported type."
+ return 0
+ }
+ }
+@@ -315,54 +312,52 @@
+ "floats" -
+ "strings" {
+ if { [ llength $optlist ] } then {
+- puts stderr "typedopts: Type $type doesn't take arguments"
+- return ""
++ return -code error "typedopts: Type $type doesn't take arguments"
+ }
+ return [ string index $type 0 ]
+ }
+ "one-of" {
+ if { ! [ llength $optlist ] } then {
+- puts stderr "typedopts: No arguments given to type $type"
+- return ""
++ return -code error "typedopts: No arguments given to type $type"
+ }
+ return [ concat [ string index $type 0 ] $optlist ]
+ }
+ "list-of" -
+ "multiple" {
+ if { ! [ llength $optlist ] } then {
+- puts stderr "typedopts: No arguments given to type $type"
+- return ""
+- }
+- if { ! [ string length [ set subtype [ parseOption $optlist ]]] } then {
+- return ""
++ return -code error "typedopts: No arguments given to type $type"
+ }
++ if [catch {parseOption $optlist} subtype] {
++ return -code error $subtype
++ }
+ return [ concat [ string index $type 0 ] $subtype ]
+ }
+ default {
+- puts stderr "typedopts: Unknown option type $type"
+- return ""
++ return -code error "typedopts: Unknown option type $type"
+ }
+ }
+ }
++}
++
++proc typedopts { args } {
+
+ set doinit 1
+
+ if { [ llength $args ] < 5 } then {
+- puts stderr "typedopts: bad number of arguments."
+- return -1
++ return -code error "typedopts: bad number of arguments."
+ }
+
+- set args [ extract $args arglist optlist optret argret restret ]
++ set args [ foxOpts::extract $args arglist optlist optret argret restret ]
+
+ while { [ llength $args ] } {
+- set opt [ shift args ]
+- switch -exact [ findabbr { -noinitialize } $opt ] {
++ set opt [ foxOpts::shift args ]
++ switch -exact [ foxOpts::findabbr { -noinitialize } $opt ] {
+ -noinitialize {
+ set doinit 0
+ }
+ default {
+- puts stderr "typedopts: bad option \"$opt\": should be -noinitialize or --"
+- return -1
++ return -code error \
++ "typedopts: bad option \"$opt\": should be -noinitialize or --"
+ }
+ }
+ }
+@@ -380,16 +375,15 @@
+ if { [ string length $type ] } then {
+ foreach arg $word {
+ if { [ lsearch -exact $arg $allopts ] > -1 } then {
+- puts stderr "typedopts: option -$arg multiply declared."
+- return -1
++ return -code error "typedopts: option -$arg multiply declared."
+ }
+ lappend allopts $arg
+ set opttype($arg) $type
+ }
+ set type ""
+ } else {
+- if { ! [ string length [ set type [ parseOption $word ]]] } then {
+- return -1
++ if [catch {foxOpts::parseOption $word} type] then {
++ return -code error $type
+ }
+ }
+ }
+@@ -408,7 +402,7 @@
+ while { [ llength $arglist ] } {
+ switch -glob -- $arglist {
+ -- {
+- shift arglist
++ foxOpts::shift arglist
+ break
+ }
+ -* {
+@@ -417,10 +411,10 @@
+ break
+ }
+ }
+- set opt [ string range [ shift arglist ] 1 end ]
+- if { [ string length [ set fnd [ findabbr $allopts $opt ]]] } then {
++ set opt [ string range [ foxOpts::shift arglist ] 1 end ]
++ if { [ string length [set fnd [foxOpts::findabbr $allopts $opt]]] } then {
+ set type $opttype($fnd)
+- if { [ parseOptionType $opttype($fnd) arglist arg ] } then {
++ if { [ foxOpts::parseOptionType $opttype($fnd) arglist arg ] } then {
+ if { $_opts($fnd) && ! [ string match "m*" $type ] } then {
+ set _args(_ERROR_) "Found multiple occurrences of option -$fnd"
+ set retval 0
diff --git a/devel/tclgetopts/files/patch-ab b/devel/tclgetopts/files/patch-ab
new file mode 100644
index 000000000000..89e871460b92
--- /dev/null
+++ b/devel/tclgetopts/files/patch-ab
@@ -0,0 +1,10 @@
+--- typedopts.n.orig Sat Feb 19 19:30:19 1994
++++ typedopts.n Thu Mar 18 16:05:00 1999
+@@ -155,5 +155,4 @@
+ .B typedopts
+-can't parse its options for any reason, it will print an
+-error message to stderr and return a
+-.B -1
++can't parse its options for any reason, it will
++fail with an error message and return
+ without modifying any other variables.
diff --git a/devel/tclgetopts/files/pkgIndex.tcl b/devel/tclgetopts/files/pkgIndex.tcl
new file mode 100644
index 000000000000..22ab83b0138c
--- /dev/null
+++ b/devel/tclgetopts/files/pkgIndex.tcl
@@ -0,0 +1,6 @@
+# This file was NOT auto generated! pkg_mkIndex(n) will NOT re-create it -mi
+
+package ifneeded foxgetopt 1.0 [list tclPkgSetup $dir foxgetopt 1.0 {
+ {foxTypedOpts.tcl source typedopts}
+ {foxGetOpt.tcl source getopt}
+}]
diff --git a/devel/tclgetopts/pkg-comment b/devel/tclgetopts/pkg-comment
new file mode 100644
index 000000000000..cd622376d2d7
--- /dev/null
+++ b/devel/tclgetopts/pkg-comment
@@ -0,0 +1 @@
+Pure TCL code for command line options parsing
diff --git a/devel/tclgetopts/pkg-descr b/devel/tclgetopts/pkg-descr
new file mode 100644
index 000000000000..cb0e592c2553
--- /dev/null
+++ b/devel/tclgetopts/pkg-descr
@@ -0,0 +1,23 @@
+The package is slightly altered by this porter to:
+ a) use namespace for auxiliary procedures
+ b) return an error rather then output it to stderr
+
+The original README follows:
+
+This package includes two routines for parsing command-line options in
+a TCL script:
+
+foxGetOpt.tcl -- this file contains the routine "getopt", a close
+emulation of the getopt(3) library routine for C programs.
+
+foxTypedOpts.tcl -- This contains the routine "typedopts", which uses
+long option names and which does type checking on option arguments.
+
+There is also a man page for each routine (named after the routine, not
+the file), and an ASCII'fied version of each man page called
+<file>.README.
+
+If you have any comments / suggestions / bug-reports / bug-fixes, etc.,
+please email me at: darkfox@netcom.com
+
+Thanks, and enjoy! - Johnson Earls
diff --git a/devel/tclgetopts/pkg-plist b/devel/tclgetopts/pkg-plist
new file mode 100644
index 000000000000..a17165e40c6c
--- /dev/null
+++ b/devel/tclgetopts/pkg-plist
@@ -0,0 +1,4 @@
+lib/foxGetOpt/pkgIndex.tcl
+lib/foxGetOpt/foxTypedOpts.tcl
+lib/foxGetOpt/foxGetOpt.tcl
+@dirrm lib/foxGetOpt