Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

It is much easier to suggest solutions when you know nothing about the problem.


devel / comp.lang.postscript / getopt.ps

SubjectAuthor
* getopt.psnews
`* Re: getopt.psluser droog
 +- Re: getopt.psluser droog
 `* Re: getopt.psnews
  `- Re: getopt.psken

1
getopt.ps

<1627849972.bystand@zzo38computer.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=56&group=comp.lang.postscript#56

  copy link   Newsgroups: comp.lang.postscript
Path: i2pn2.org!i2pn.org!aioe.org!P703Hxu1m1uplaQVJzdzug.user.46.165.242.75.POSTED!not-for-mail
From: news@zzo38computer.org.invalid
Newsgroups: comp.lang.postscript
Subject: getopt.ps
Date: Sun, 01 Aug 2021 14:05:14 -0700
Organization: Aioe.org NNTP Server
Message-ID: <1627849972.bystand@zzo38computer.org>
Mime-Version: 1.0
Injection-Info: gioia.aioe.org; logging-data="62132"; posting-host="P703Hxu1m1uplaQVJzdzug.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: bystand/1.2.0
X-Notice: Filtered by postfilter v. 0.9.2
 by: news@zzo38computer.org.invalid - Sun, 1 Aug 2021 21:05 UTC

I wrote a PostScript program for parsing command-line switches similar to
how the getopt function of UNIX is doing. I might use it myself in some of
my own programs, but it might be useful for other programmers to use, too.
You can also tell me if you have a suggestion for improvement, too.

Long option parameters without = are not implemented, and it will always
use the POSIXLY_CORRECT kind of parsing.

***BEGIN***

% PostScript code for parsing command-line arguments
% (public domain)

<< /V [0 0] /L ARGUMENTS length >> begin
/D exch def
/G {//D 1 index known {//D exch get} {clear //D /Error get exec stop} ifelse} def
/T <<
/N {
% No value
exch pop //null exch exec
} bind
/O {
% Optional value
//V 1 get 3 -1 roll 1 add 1 index length 1 index sub getinterval
dup () eq {pop //null} if
exch exec exit
} bind
/R {
% Required value
//V 1 get 3 -1 roll 1 add 1 index length 1 index sub getinterval
dup () eq {
pop //V 0 get 1 add //V 0 2 index put
//ARGUMENTS length 1 index eq {//G 5 get exec} if
//ARGUMENTS exch get
} if
exch exec exit
} bind
>> def
{ {
//V 0 get //L ge {exit} if
//ARGUMENTS //V 0 get get
dup length 2 lt {pop exit} if
dup (--) eq {pop //V 0 //V 0 get 1 add put exit} if
dup 0 get 45 ne {pop exit} if
dup 1 get 45 eq {
% Long option
(=) search {
exch pop //G exec exec
} {
//G exec //null exch exec
} ifelse
} {
% Short option
//V 1 2 index put
1 exch 1 exch length 1 sub {
//V 1 get 1 index 1 getinterval //G exec
dup 1 get dup type /nametype eq //G if
exch 0 get //T exch get exec
} for
} ifelse
//V 0 //V 0 get 1 add put
} loop
//userdict /ARGUMENTS //ARGUMENTS //V 0 get //L 1 index sub getinterval put
} end bind exec

***END***

--
Don't laugh at the moon when it is day time in France.

Re: getopt.ps

<0ac2aeb1-c2b3-4253-a90c-04c299ecb13fn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=58&group=comp.lang.postscript#58

  copy link   Newsgroups: comp.lang.postscript
X-Received: by 2002:a05:620a:20ce:: with SMTP id f14mr3309992qka.367.1628144264244;
Wed, 04 Aug 2021 23:17:44 -0700 (PDT)
X-Received: by 2002:a05:6808:194:: with SMTP id w20mr1396244oic.142.1628144263923;
Wed, 04 Aug 2021 23:17:43 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.postscript
Date: Wed, 4 Aug 2021 23:17:43 -0700 (PDT)
In-Reply-To: <1627849972.bystand@zzo38computer.org>
Injection-Info: google-groups.googlegroups.com; posting-host=24.207.183.245; posting-account=G1KGwgkAAAAyw4z0LxHH0fja6wAbo7Cz
NNTP-Posting-Host: 24.207.183.245
References: <1627849972.bystand@zzo38computer.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <0ac2aeb1-c2b3-4253-a90c-04c299ecb13fn@googlegroups.com>
Subject: Re: getopt.ps
From: luser.droog@gmail.com (luser droog)
Injection-Date: Thu, 05 Aug 2021 06:17:44 +0000
Content-Type: text/plain; charset="UTF-8"
 by: luser droog - Thu, 5 Aug 2021 06:17 UTC

On Sunday, August 1, 2021 at 4:03:18 PM UTC-5, ne...@zzo38computer.org.invalid wrote:
> I wrote a PostScript program for parsing command-line switches similar to
> how the getopt function of UNIX is doing. I might use it myself in some of
> my own programs, but it might be useful for other programmers to use, too.
> You can also tell me if you have a suggestion for improvement, too.
>
> Long option parameters without = are not implemented, and it will always
> use the POSIXLY_CORRECT kind of parsing.
>
> ***BEGIN***
>
> % PostScript code for parsing command-line arguments
> % (public domain)

I think this is interesting code (and it's great to see people writing PS!).
But I'm not sure if it's actually very useful. If you're using ghostscript,
you can combine the ARGUMENTS form with -D definitions, so you
don't really need to parse any option style syntax from the ARGUMENTS
list. Just define those with -D and use ARGUMENTS for strings
or filenames or whatever.

I started a thread recently listing every way I could think of to pass
arguments into a PS program. Lots of them can be combined.
You can even define parameters with regular PS code and concatenate
the files before processing.

Re: getopt.ps

<961a28df-ed55-4d49-a876-9d297bc2d1fcn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=59&group=comp.lang.postscript#59

  copy link   Newsgroups: comp.lang.postscript
X-Received: by 2002:ae9:e887:: with SMTP id a129mr10870280qkg.151.1628313329831;
Fri, 06 Aug 2021 22:15:29 -0700 (PDT)
X-Received: by 2002:a9d:6490:: with SMTP id g16mr10078959otl.184.1628313329587;
Fri, 06 Aug 2021 22:15:29 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.postscript
Date: Fri, 6 Aug 2021 22:15:29 -0700 (PDT)
In-Reply-To: <0ac2aeb1-c2b3-4253-a90c-04c299ecb13fn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=24.207.183.245; posting-account=G1KGwgkAAAAyw4z0LxHH0fja6wAbo7Cz
NNTP-Posting-Host: 24.207.183.245
References: <1627849972.bystand@zzo38computer.org> <0ac2aeb1-c2b3-4253-a90c-04c299ecb13fn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <961a28df-ed55-4d49-a876-9d297bc2d1fcn@googlegroups.com>
Subject: Re: getopt.ps
From: luser.droog@gmail.com (luser droog)
Injection-Date: Sat, 07 Aug 2021 05:15:29 +0000
Content-Type: text/plain; charset="UTF-8"
 by: luser droog - Sat, 7 Aug 2021 05:15 UTC

On Thursday, August 5, 2021 at 1:17:44 AM UTC-5, luser droog wrote:
> On Sunday, August 1, 2021 at 4:03:18 PM UTC-5, ne...@zzo38computer.org.invalid wrote:
> > I wrote a PostScript program for parsing command-line switches similar to
> > how the getopt function of UNIX is doing. I might use it myself in some of
> > my own programs, but it might be useful for other programmers to use, too.
> > You can also tell me if you have a suggestion for improvement, too.
> >
> > Long option parameters without = are not implemented, and it will always
> > use the POSIXLY_CORRECT kind of parsing.
> >
> > ***BEGIN***
> >
> > % PostScript code for parsing command-line arguments
> > % (public domain)
> I think this is interesting code (and it's great to see people writing PS!).
> But I'm not sure if it's actually very useful. If you're using ghostscript,
> you can combine the ARGUMENTS form with -D definitions, so you
> don't really need to parse any option style syntax from the ARGUMENTS
> list. Just define those with -D and use ARGUMENTS for strings
> or filenames or whatever.
>
> I started a thread recently listing every way I could think of to pass
> arguments into a PS program. Lots of them can be combined.
> You can even define parameters with regular PS code and concatenate
> the files before processing.

Another way which could be cool is use -c "(some)(options)" and just
leave stuff on the stack. The program can then use

count 0 ne {
...
} if

to check for and process optional parameters.

Re: getopt.ps

<1628187236.bystand@zzo38computer.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=60&group=comp.lang.postscript#60

  copy link   Newsgroups: comp.lang.postscript
Path: i2pn2.org!i2pn.org!aioe.org!P703Hxu1m1uplaQVJzdzug.user.46.165.242.75.POSTED!not-for-mail
From: news@zzo38computer.org.invalid
Newsgroups: comp.lang.postscript
Subject: Re: getopt.ps
Date: Fri, 20 Aug 2021 13:14:51 -0700
Organization: Aioe.org NNTP Server
Message-ID: <1628187236.bystand@zzo38computer.org>
References: <1627849972.bystand@zzo38computer.org> <0ac2aeb1-c2b3-4253-a90c-04c299ecb13fn@googlegroups.com>
Mime-Version: 1.0
Injection-Info: gioia.aioe.org; logging-data="41612"; posting-host="P703Hxu1m1uplaQVJzdzug.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: bystand/1.2.0
X-Notice: Filtered by postfilter v. 0.9.2
 by: news@zzo38computer.org.invalid - Fri, 20 Aug 2021 20:14 UTC

luser droog <luser.droog@gmail.com> wrote:
> I think this is interesting code (and it's great to see people writing PS!).
> But I'm not sure if it's actually very useful. If you're using ghostscript,
> you can combine the ARGUMENTS form with -D definitions, so you
> don't really need to parse any option style syntax from the ARGUMENTS
> list. Just define those with -D and use ARGUMENTS for strings
> or filenames or whatever.

While that is true, I don't really like -d and -s for your own program's
options; the -d and -s are for setting the options of Ghostscript itself
(such as specifying what file or printer to use for graphical output, and
some other options).

--
Don't laugh at the moon when it is day time in France.

Re: getopt.ps

<MPG.3b8abc325e5daf6b9898ca@usenet.plus.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=63&group=comp.lang.postscript#63

  copy link   Newsgroups: comp.lang.postscript
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!4.us.feeder.erje.net!2.eu.feeder.erje.net!feeder.erje.net!feeds.phibee-telecom.net!border2.nntp.ams1.giganews.com!nntp.giganews.com!buffer2.nntp.ams1.giganews.com!nntp.brightview.co.uk!news.brightview.co.uk.POSTED!not-for-mail
NNTP-Posting-Date: Sat, 21 Aug 2021 02:31:34 -0500
From: ken@spamcop.net (ken)
Newsgroups: comp.lang.postscript
Subject: Re: getopt.ps
Date: Sat, 21 Aug 2021 08:31:33 +0100
Message-ID: <MPG.3b8abc325e5daf6b9898ca@usenet.plus.net>
References: <1627849972.bystand@zzo38computer.org> <0ac2aeb1-c2b3-4253-a90c-04c299ecb13fn@googlegroups.com> <1628187236.bystand@zzo38computer.org>
Reply-To: ken@spamcop.net
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
User-Agent: MicroPlanet-Gravity/3.0.4
X-Antivirus: Avast (VPS 210821-0, 21/8/2021), Outbound message
X-Antivirus-Status: Clean
Lines: 22
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-rMBYZyplSaBTLfJ7UkRXtqx7a0NAhKK7rrLHyMDvE35tzcOj+JhazJvN6VrHhev1vWE2zOsaTe+rEwW!m85gsCRe86Ji45zWW/f5T0bXg+2Wp+DVq27fBrrfuPyj/7FkLcPNAGT5mcGyaDqDWHa2zIq02EiX!ixLnMLMK8aal75o=
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
X-Original-Bytes: 1951
 by: ken - Sat, 21 Aug 2021 07:31 UTC

In article <1628187236.bystand@zzo38computer.org>,
news@zzo38computer.org.invalid says...
> While that is true, I don't really like -d and -s for your own program's
> options; the -d and -s are for setting the options of Ghostscript itself
> (such as specifying what file or printer to use for graphical output, and
> some other options).

Although that is what they do, it's not the case that they are intended
to be specific to Ghostscript internals.

Most command line options, including the ones processed by Ghostscript,
are stored in systemdict and are available for use by PostScript
programs.

A number of the example/utility PostScript programs supplied with
Ghostscript make use of parameters passed to the program on the command
line.

Ken

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor