From a82c24b304d3a6727a9cd210d82b33b2c9e3119b Mon Sep 17 00:00:00 2001
From: Karl Berry <karl@freefriends.org>
Date: Thu, 11 Feb 2010 23:48:39 +0000
Subject: pstricks 0.41 (11feb10)

git-svn-id: svn://tug.org/texlive/trunk@16973 c570f23f-e606-0410-a88d-b1316a301751
---
 .../texmf-dist/tex/generic/pstricks/pstricks.tex   | 1412 +++++++++++---------
 1 file changed, 806 insertions(+), 606 deletions(-)

(limited to 'Master/texmf-dist/tex/generic/pstricks/pstricks.tex')

diff --git a/Master/texmf-dist/tex/generic/pstricks/pstricks.tex b/Master/texmf-dist/tex/generic/pstricks/pstricks.tex
index 68310975004..06f90a2553e 100644
--- a/Master/texmf-dist/tex/generic/pstricks/pstricks.tex
+++ b/Master/texmf-dist/tex/generic/pstricks/pstricks.tex
@@ -20,13 +20,20 @@
 % See the PSTricks User's Guide for description.
 % This uses the header file `pstricks.pro'.
 %
-\def\fileversion{1.31}
-\def\filedate{2009/11/27}
 %
 \csname PSTricksLoaded\endcsname
 \let\PSTricksLoaded\endinput
+\ifx\PSTXKeyLoaded\endinput\else \input pst-xkey.tex \fi
+\ifx\PSTFPloaded\endinput\else   \input pst-fp.tex\fi
+%
+\def\fileversion{2.0}
+\def\filedate{2010/02/11}
+%
 \edef\PstAtCode{\the\catcode`\@}
 \catcode`\@=11\relax
+%
+\pst@addfams{pstricks}
+%
 \expandafter\ifx\csname @latexerr\endcsname\relax%	do we have LaTeX?
   \def\typeout#1{\immediate\write\@unused{#1}}
   \alloc@7\write\chardef\sixt@@n\@unused
@@ -59,8 +66,80 @@
   \def\:{\@xifnch} \expandafter\gdef\: {\futurelet\@tempc\@ifnch}
   \endgroup
 \fi
+% stolen from latex.ltx to make it TeX compatible
+\newcount\psLoopIndex
+\def\@fornoop#1\@@#2#3{}
+\long\def\@for#1:=#2\do#3{%
+  \pst@cntm=0%
+  \expandafter\def\expandafter\@fortmp\expandafter{#2}%
+  \ifx\@fortmp\@empty \else
+    \expandafter\@forloop#2,\@nil,\@nil\@@#1{#3}\fi}
+\long\def\@forloop#1,#2,#3\@@#4#5{\def#4{#1}\ifx #4\@nnil \else
+       #5\def#4{#2}\ifx #4\@nnil \else\global\advance\psLoopIndex by \@ne\relax%
+       #5\@iforloop #3\@@#4{#5}\fi\fi}
+\long\def\@iforloop#1,#2\@@#3#4{\global\advance\psLoopIndex by \@ne\relax%
+   \def#3{#1}\ifx #3\@nnil
+     \expandafter\@fornoop \else
+     #4\relax\expandafter\@iforloop\fi#2\@@#3{#4}}
+%
+\long\def\psforeach#1#2#3{%
+  \global\psLoopIndex=0\relax
+  \if$\ifnum9<1#2$ \else \fi \psforeach@ii{#1}{#2}{#3}
+  \else                      \expandafter\psforeach@i#2,..,,..,\@nil{#1}{#3}\fi}
+\long\def\psforeach@i#1,#2,..,#3,..,#4\@nil#5#6{% 
+  \ifx\relax#3\relax\psforeach@ii{#5}{#1,#2}{#6}
+  \else\psforeach@iii{#5}{#1}{#2}{#3}{#6}\fi}
+\long\def\psforeach@ii#1#2#3{%
+  \begingroup%
+  \edef\reserved@a{#2}%
+  \@for#1:=\reserved@a\do{#3}%
+  \endgroup}
+\long\def\psforeach@iii#1#2#3#4#5{%
+  \pstFPsub\pst@tempA{#3}{#2}%
+  \pst@dimm=\pst@tempA pt
+  \pstFPstripZeros{\pst@tempA}\pst@tempB%
+  \def\pst@tempA{#2}%
+  \def\pst@tempa{#2}%
+  \pst@dimn=#4pt%
+  \loop%
+    \pst@dimm=\pst@tempA pt%
+    \ifdim\pst@dimm<\pst@dimn%
+      \pstFPadd\pst@tempA{\pst@tempA}{\pst@tempB}%
+      \pstFPstripZeros{\pst@tempA}\pst@tempA
+      \edef\pst@tempa{\pst@tempa,\pst@tempA}%
+  \repeat%
+  \psforeach@ii{#1}{\pst@tempa}{#5}}
+%
+\long\def\psForeach#1#2#3{%
+  \global\psLoopIndex=0\relax
+  \if$\ifnum9<1#2$ \else \fi \psforeach@ii{#1}{#2}{#3}
+  \else                    \expandafter\psForeach@i#2,..,,..,\@nil{#1}{#3}\fi}
+\long\def\psForeach@i#1,#2,..,#3,..,#4\@nil#5#6{% 
+  \ifx\relax#3\relax\psForeach@ii{#5}{#1,#2}{#6}
+  \else\psForeach@iii{#5}{#1}{#2}{#3}{#6}\fi}
+\long\def\psForeach@ii#1#2#3{%
+  \edef\reserved@a{#2}%
+  \@for#1:=\reserved@a\do{#3}}
+\long\def\psForeach@iii#1#2#3#4#5{%
+  \pstFPsub\pst@tempA{#3}{#2}%
+  \pst@dimm=\pst@tempA pt
+  \pstFPstripZeros{\pst@tempA}\pst@tempB%
+  \def\pst@tempA{#2}%
+  \def\pst@tempa{#2}%
+  \pst@dimn=#4pt%
+  \loop%
+    \pst@dimm=\pst@tempA pt%
+    \ifdim\pst@dimm<\pst@dimn%
+      \pstFPadd\pst@tempA{\pst@tempA}{\pst@tempB}%
+      \pstFPstripZeros{\pst@tempA}\pst@tempA
+      \edef\pst@tempa{\pst@tempa,\pst@tempA}%
+  \repeat%
+  \psForeach@ii{#1}{\pst@tempa}{#5}}
+%
+%
 %
 % hv 2007-10-16 to fix the bug in pst-node with \\[name=...]
+% hv fix bug with empty fnodes in psmatrix
 \def\ps@ifnextchar#1#2#3{%
   \let\reserved@d= #1%
   \def\reserved@a{#2}\def\reserved@b{#3}%
@@ -69,6 +148,7 @@
   \ifx\@let@token\reserved@d \let\reserved@b\reserved@a \fi
   \reserved@b
 }
+\def\pshskip#1{\vrule \@width\z@\nobreak \hskip #1\hskip \z@skip}
 % end bugfix
 \typeout{`PSTricks' v\fileversion\space\space <\filedate> (tvz)}
 \def\@pstrickserr#1#2{%
@@ -92,6 +172,10 @@
   You better fix this before proceding.^^J
   See the PSTricks User's Guide or ask your system administrator for help.^^J
   Type \space X <return> \space to quit.}
+\def\@ehpd{%
+  Not allowed optional argument.^^J
+  Will proceed with the default setting.^^J
+  Type \space X <return> \space to quit.}
 \def\pst@misplaced#1{\@pstrickserr{Misplaced \string#1 command}\@ehpb}
 \newdimen\pst@dima
 \newdimen\pst@dimb
@@ -99,6 +183,12 @@
 \newdimen\pst@dimd
 \newdimen\pst@dimg
 \newdimen\pst@dimh
+\newdimen\pst@dimm
+\newdimen\pst@dimn
+\newdimen\pst@dimo
+\newdimen\pst@dimp
+\chardef\f@ur=4
+%
 \newbox\pst@hbox
 \newbox\pst@boxg
 \newcount\pst@cnta
@@ -107,6 +197,11 @@
 \newcount\pst@cntd
 \newcount\pst@cntg
 \newcount\pst@cnth
+\newcount\pst@cntm
+\newcount\pst@cntn
+\newcount\pst@cnto
+\newcount\pst@cntp
+\newcount\@zero\@zero=0\relax
 %
 \newif\ifPst@SpecialLength
 \Pst@SpecialLengthfalse
@@ -124,10 +219,90 @@
     \def\@tempa{\@empty}%
   \fi
   \expandafter\ps@next\@tempa}
+%
 \def\pst@dimtonum#1#2{\edef#2{\pst@@dimtonum#1}}
 \def\pst@@dimtonum#1{\expandafter\pst@@@dimtonum\the#1}
 {\catcode`\p=12 \catcode`\t=12 \global\@namedef{pst@@@dimtonum}#1pt{#1}}
 %
+\def\pst@getdimdim#1 #2 #3\@nil{%
+  \def\pst@tempA{#2}%
+  \ifx\pst@tempA\@empty
+    \pssetlength\pst@dimn{#1}%
+    \pst@dimm=\z@%
+  \else%
+    \pssetlength\pst@dimm{#1}%
+    \pssetlength\pst@dimn{#2}%
+  \fi%
+}
+\def\pst@getxdimdim#1 #2 #3\@nil{%
+  \def\pst@tempA{#2}%
+  \ifx\pst@tempA\@empty
+    \pssetxlength\pst@dimn{#1}%
+    \pst@dimm=\z@
+  \else%
+    \pssetxlength\pst@dimm{#1}%
+    \pssetxlength\pst@dimn{#2}%
+  \fi%
+}
+\def\pst@getydimdim#1 #2 #3\@nil{%
+  \def\pst@tempA{#2}
+  \ifx\pst@tempA\@empty
+    \pssetylength\pst@dimn{#1}
+    \pst@dimm=\z@
+  \else
+    \pssetylength\pst@dimm{#1}%
+    \pssetylength\pst@dimn{#2}%
+  \fi%
+}
+%
+% A modulo macro for integer values
+% \pst@mod{34}{6}\value ==> \value is 4
+%
+\def\pst@mod#1#2#3{%
+  \begingroup%
+  \pst@cntm=#1\pst@cntn=#2\relax%
+  \pst@cnto=\pst@cntm%
+  \divide\pst@cntm by \pst@cntn%
+  \multiply\pst@cntn by \pst@cntm%
+  \advance\pst@cnto by -\pst@cntn%
+  \edef\value{\endgroup\def\noexpand#3{\number\pst@cnto}}\value%
+}
+\def\pst@max#1#2#3{%
+  \begingroup%
+  \pst@cntm=#1\pst@cntn=#2\relax%
+  \ifnum\pst@cntm<\pst@cntn\pst@cntm=\pst@cntn\fi
+  \global#3=\the\pst@cntm%
+  \endgroup%
+}
+\def\pst@maxdim#1#2#3{%
+  \begingroup%
+  \pst@dimm=#1\pst@dimn=#2\relax%
+  \ifdim\pst@dimm<\pst@dimn\pst@dimm=\pst@dimn\fi
+  \global#3=\the\pst@dimm%
+  \endgroup%
+}
+\def\pst@mindim#1#2#3{%
+  \begingroup%
+  \pst@dimm=#1\pst@dimn=#2\relax%
+  \ifdim\pst@dimm>\pst@dimn\pst@dimm=\pst@dimn\fi
+  \global#3=\the\pst@dimm%
+  \endgroup%
+}
+\def\pst@abs#1#2{%
+  \begingroup%
+  \pst@cntm=#1\relax%
+  \ifnum\pst@cntm<\z@\pst@cntm=-\pst@cntm\fi%
+  \global#2=\the\pst@cntm
+  \endgroup%
+}
+\def\pst@absdim#1#2{%
+  \begingroup%
+  \pst@dimm=#1\relax%
+  \ifdim\pst@dimm<\z@\pst@dimm=-\pst@dimm\fi%
+  \global#2=\the\pst@dimm%
+  \endgroup%
+}
+%
 \def\pst@pyth#1#2#3{% from pst-3d
   \begingroup
     \pst@dima=#1\relax
@@ -286,24 +461,6 @@
   \pssetlength\pst@dimg{#1}%
   \pst@checknum{#2}\pst@tempg%
 }
-% DG/SR modification begin - Jan. 7, 1998 - Patch 9
-% Missing from pstricks.bug 0.93
-%\def\pst@getscale#1#2{%
-%\pst@expandafter\pst@getnumii{#1 #1} {} {} {}\@nil
-%\@psttrue
-%\ifdim\pst@tempg\p@=\z@
-%\@pstrickserr{Bad scaling argument `#1'}\@ehpa
-%\def\pst@tempg{1 }%
-%\@pstfalse
-%\fi
-%\ifdim\pst@temph\p@=\z@
-%\if@pst\@pstrickserr{Bad scaling argument `#1'}\@ehpa\fi
-%\def\pst@temph{1 }%
-%\fi
-%\edef#2{\pst@tempg\space \pst@temph\space scale }%
-%\ifdim\pst@tempg\p@=\p@ \ifdim\pst@temph\p@=\p@
-%\def#2{}%
-%\fi\fi}
 \def\pst@getscale#1#2{%	read and check a scale input x [y]
   \edef\pst@tempg{#1}%
   \ifx\pst@tempg\@none
@@ -323,7 +480,6 @@
     \fi
   \fi%
 }
-% DG/SR modification end
 \def\pst@getint#1#2{%	read and check an integer
   \pst@cntg=#1\relax
   \edef#2{\the\pst@cntg\space}%
@@ -384,28 +540,17 @@
 \newrgbcolor{yellow}{1 1 0}
 \newrgbcolor{cyan}{0 1 1}
 \newrgbcolor{magenta}{1 0 1}
-\def\psset#1{\@psset#1,\@nil\ignorespaces}
-\def\@psset#1,{%
-  \@@psset#1==\@nil%
-  \@ifnextchar\@nil{\@gobble}{\@psset}%
-}
-\def\@@psset#1=#2=#3\@nil{%
-  \@ifundefined{psset@#1}%
-    {\@pstrickserr{Graphics parameter `#1' not defined.}\@ehpa}%
-    {\@nameuse{psset@#1}{#2}}%
-}%
-\def\psset@style#1{%
+%
+\define@key[psset]{pstricks}{style}{%
   \@ifundefined{pscs@#1}%
     {\@pstrickserr{Custom style `#1' undefined}\@ehpa}%
     {\@nameuse{pscs@#1}}%
 }
-%\def\newpsstyle#1#2{\@namedef{pscs@#1}{\psset{#2}}}
-%------------ hv 1.10 beg -------------------
 \def\newpsstyle#1#2{\@namedef{pscs@#1}{%
   \def\pst@tempA{#2}%
-  \ifx\pst@tempA\@empty\else\psset{#2}\fi}}
-%------------ hv 1.10 end -------------------
-%------------ hv 1.16 begin -------------------
+  \ifx\pst@tempA\@empty\else\psset{#2}\fi}%
+}
+%
 \def\addto@psstyle#1#2{%
     \pst@toks=\expandafter{#1#2}%
     \edef#1{\the\pst@toks}}
@@ -452,20 +597,20 @@
   \afterassignment\pstunit@off
   #1 #2\@psunit%
 }
-\def\psset@unit#1{%
+\define@key[psset]{pstricks}{unit}[1cm]{%
   \pssetlength\psunit{#1}%
   \psxunit=\psunit%
   \psyunit=\psunit%
 }
-\def\psset@runit#1{\pssetlength\psrunit{#1}}
-\def\psset@xunit#1{\pssetxlength\psxunit{#1}}
-\def\psset@yunit#1{\pssetylength\psyunit{#1}}
-% v 1.05   begin
-\def\psset@PstDebug#1{\pst@getint{#1}{\Pst@Debug}}% hv 2004-06-22
-\psset{PstDebug=0}
+\define@key[psset]{pstricks}{runit}[1cm]{\pssetlength\psrunit{#1}}
+\define@key[psset]{pstricks}{xunit}[1cm]{\pssetxlength\psxunit{#1}}
+\define@key[psset]{pstricks}{yunit}[1cm]{\pssetylength\psyunit{#1}}
+%
+\define@key[psset]{pstricks}{PstDebug}[0]{\pst@getint{#1}\Pst@Debug}% hv 2004-06-22
+\psset[pstricks]{PstDebug=0}
 \def\psDEBUG{\@ifnextchar[\psDEBUG@i{\psDEBUG@i[PSTricks]}}%
 \def\psDEBUG@i[#1]#2{\ifnum\Pst@Debug>0 \expandafter\typeout{<#1>: #2}\fi}%
-% end
+%
 \def\pst@getlength#1#2{%
   \pssetlength\pst@dimg{#1}%
   \edef#2{\pst@number\pst@dimg}%
@@ -674,56 +819,47 @@
   \def\psput@cartesian{\psput@special}%
   \def\cartesian@coor##1,##2,##3\@nil{\polar@coor{##1}{##2}}%
 }%
-\def\psset@origin#1{%
+\define@key[psset]{pstricks}{origin}[]{%
   \pst@@getcoor{#1}%
-% ----------- 1.10 beg hv -------------------
-%  \edef\psk@origin{\pst@coor \tx@NET }}
   \edef\psk@origin{\pst@coor T }}
-% ----------- 1.10 end hv -------------------
 \def\psk@origin{}
 %
-\newif\ifswapaxes
-\def\psset@swapaxes#1{%			\if@pst
+\newif\ifPst@algebraic
+\define@boolkey[psset]{pstricks}[Pst@]{algebraic}[true]{}
+\psset[pstricks]{algebraic=false}
+%
+\define@boolkey[psset]{pstricks}[]{swapaxes}[true]{%			\if@pst
   \@nameuse{@pst#1}%
   \if@pst\def\psk@swapaxes{-90 rotate -1 1 scale }%
   \else\def\psk@swapaxes{}%
-  \fi%
-}
-\psset@swapaxes{false}
+  \fi}
+\psset[pstricks]{swapaxes=false}
 %
-\newif\ifshowpoints
-\def\psset@showpoints#1{\@nameuse{showpoints#1}}
-\psset@showpoints{false}
+\define@boolkey[psset]{pstricks}[]{showpoints}[true]{}
+\psset[pstricks]{showpoints=false}
 %
 \let\pst@setrepeatarrowsflag\relax
 %
-\def\psset@border#1{%
-\pst@getlength{#1}\psk@border
-\pst@setrepeatarrowsflag}
-\psset@border{0pt}
-\def\psset@bordercolor#1{\pst@getcolor{#1}\psbordercolor}
-\psset@bordercolor{white}
-\newif\ifpsdoubleline
-\def\psset@doubleline#1{%
-  \@nameuse{psdoubleline#1}%
-  \pst@setrepeatarrowsflag}
-\psset@doubleline{false}
-\def\psset@doublesep#1{\def\psdoublesep{#1}}
-\psset@doublesep{1.25\pslinewidth}
-\def\psset@doublecolor#1{\pst@getcolor{#1}\psdoublecolor}
-\psset@doublecolor{white}
-%
-\newif\ifpsshadow
-\def\psset@shadow#1{%
-  \@nameuse{psshadow#1}%
-  \pst@setrepeatarrowsflag}
-\psset@shadow{false}
-\def\psset@shadowsize#1{\pst@getlength{#1}\psk@shadowsize}
-\psset@shadowsize{3pt}
-\def\psset@shadowangle#1{\pst@getangle{#1}\psk@shadowangle}
-\psset@shadowangle{-45}
-\def\psset@shadowcolor#1{\pst@getcolor{#1}\psshadowcolor}
-\psset@shadowcolor{darkgray}
+\define@key[psset]{pstricks}{border}[0pt]{\pst@getlength{#1}\psk@border \pst@setrepeatarrowsflag}
+\psset[pstricks]{border=0pt}
+\define@key[psset]{pstricks}{bordercolor}[white]{\pst@getcolor{#1}\psbordercolor}
+\psset[pstricks]{bordercolor=white}
+\define@boolkey[psset]{pstricks}[ps]{doubleline}[true]{\pst@setrepeatarrowsflag}
+\psset[pstricks]{doubleline=false}
+\define@key[psset]{pstricks}{doublesep}[1.25\pslinewidth]{\def\psdoublesep{#1}}
+\psset[pstricks]{doublesep=1.25\pslinewidth}
+\define@key[psset]{pstricks}{doublecolor}[white]{\pst@getcolor{#1}\psdoublecolor}
+\psset[pstricks]{doublecolor=white}
+%
+\define@boolkey[psset]{pstricks}[ps]{shadow}[true]{\pst@setrepeatarrowsflag}
+\psset[pstricks]{shadow=false}
+\define@key[psset]{pstricks}{shadowsize}[3pt]{\pst@getlength{#1}\psk@shadowsize}
+\psset[pstricks]{shadowsize=3pt}
+\define@key[psset]{pstricks}{shadowangle}[-45]{\pst@getangle{#1}\psk@shadowangle}
+\psset[pstricks]{shadowangle=-45}
+\define@key[psset]{pstricks}{shadowcolor}[darkgrey]{\pst@getcolor{#1}\psshadowcolor}
+\psset[pstricks]{shadowcolor=darkgray}
+%
 \def\pst@repeatarrowsflag{\z@}
 \def\pst@setrepeatarrowsflag{%
   \edef\pst@repeatarrowsflag{%
@@ -731,88 +867,90 @@
       \ifpsshadow 1\else \z@\fi\fi\fi}}
 %
 \def\psls@none{}
-\newdimen\pslinewidth
-\def\psset@linewidth#1{\pssetlength\pslinewidth{#1}}
-\psset@linewidth{.8pt}
-\def\psset@linecolor#1{\pst@getcolor{#1}\pslinecolor}
-\psset@linecolor{black}
 \def\psls@solid{\psk@linecap\space setlinecap stroke }
 %
-\def\psset@linecap#1{\pst@getint{#1}\psk@linecap}%	hv 2007-12-01
-\psset@linecap{0}%					hv 2007-12-01
-\def\psset@linejoin#1{\pst@getint{#1}\psk@linejoin}%	hv 2007-10-13
+\newdimen\pslinewidth
+\define@key[psset]{pstricks}{linewidth}[0.8pt]{\pssetlength\pslinewidth{#1}}
+\psset[pstricks]{linewidth=.8pt}
+\define@key[psset]{pstricks}{linecolor}[black]{\pst@getcolor{#1}\pslinecolor}
+\psset[pstricks]{linecolor=black}
+\define@key[psset]{pstricks}{linecap}[0]{\pst@getint{#1}\psk@linecap}%	hv 2007-12-01
+\psset[pstricks]{linecap=0}
+\define@key[psset]{pstricks}{linejoin}[0]{\pst@getint{#1}\psk@linejoin}%	hv 2007-10-13
+\psset[pstricks]{linejoin=0}
 \def\tx@setlinejoin{\psk@linejoin\space setlinejoin }%	hv 2007-10-13
-\psset@linejoin{0}%					hv 2007-10-13
 %
 \def\pst@missing{%
   \z@
   \@pstrickserr{Missing number or dimension. 0 substituted}\@ehpa}
 %
 %%------------------- begin patch 15 HV 2004-05-15 -------------
-%\def\psset@dash#1{%
-%  \pst@expandafter\psset@@dash{#1} {\pst@missing} {\pst@missing} {}\@nil
-%  \edef\psk@dash{\pst@number\pst@dimg \pst@number\pst@dimh}%
-%}
-%\def\psset@@dash#1 #2 #3\@nil{%
-%\pssetlength\pst@dimg{#1}%
-%\pssetlength\pst@dimh{#2}}
-%\psset@dash{5pt 3pt}
 \def\pst@empty{\z@}
-\def\psset@dash#1{% black white [ black white ] 
-  \pst@expandafter\psset@@dash{#1} {\pst@empty} {\pst@empty} %
-                  {\pst@missing} {\pst@missing} {}\@nil
-  \edef\psk@dash{\pst@number\pst@dimg \pst@number\pst@dimh 
-                 \pst@number\pst@dimc \pst@number\pst@dimd}%
-}
-\def\psset@@dash#1 #2 #3 #4 #5\@nil{% 
-  \pssetlength\pst@dimg{#1}%
-  \pssetlength\pst@dimh{#2}%
-  \pssetlength\pst@dimc{#3}%
-  \pssetlength\pst@dimd{#4}%
-}
-\psset@dash{5pt 3pt 0pt 0pt}% black white black white 
+
+\define@key[psset]{pstricks}{dash}[5pt 3pt 0pt 0pt]{%	defined in pstricks.tex
+  \pst@expandafter\psset@@dash{#1}\@nil}% Error handling for empty argument.
+\define@key[psset]{pstricks}{maxdashes}[11]{\def\psk@maxdashes{#1}}
+\psset[pstricks]{maxdashes=11}
+%
+\def\psset@@dash#1\@nil{%
+ \def\psk@dash{}%
+ \pst@cntm0
+ \def\next##1 ##2\relax{%
+   \expandafter\ifnum\psk@maxdashes>\pst@cntm\relax  % 04-08-07
+     \edef\@tempa{##1}%
+     \ifx\@tempa\@empty\else% gobble leading spaces
+       \pssetlength\pst@dimc{##1}%
+       \advance\pst@cntm by 1
+       \edef\psk@dash{\psk@dash\space\pst@number\pst@dimc}%
+     \fi%
+     \edef\@tempa{##2}%
+     \ifx\@tempa\@empty\else% detect end
+       \ifx\@tempa\space\else% gobble trailing spaces
+         \next##2\relax%
+     \fi\fi%
+   \else% 04-08-07
+     \@pstrickserr{Number of dashes > \psk@maxdashes. Increasing 
+        'maxdashes' might work.}\@ehpa% 04-08-07
+   \fi% 04-08-07
+ }%
+ \expandafter\next#1 \relax}
+\psset[pstricks]{dash=5pt 3pt 0pt 0pt}% black white black white 
 %%------------------- end patch 15 HV 2004-05-15 -------------
-\newif\ifpsdashadjust
-\def\psset@dashadjust#1{\@nameuse{psdashadjust#1}}
-\psset@dashadjust{true}
+\define@boolkey[psset]{pstricks}[ps]{dashadjust}[true]{}
+\psset[pstricks]{dashadjust}
 \def\tx@DashLine{DashLine }
-\def\psls@dashed{%
-%%--------------------------------- hv 2006-04-29 beg ---------------------
-  \psk@linecap\space setlinecap
-%%--------------------------------- hv 2006-04-29 end ---------------------
+%
+\def\psls@dashed{
+  \psk@linecap\space setlinecap 
   \ifpsdashadjust
-%    \psk@dash \pst@linetype\space \tx@DashLine
-    \psk@dash \@ifundefined{pst@linetype}{2}{\pst@linetype}\space \tx@DashLine
+    [ \psk@dash ] \pst@linetype\space \tx@DashLine
   \else
     [ \psk@dash ] 0 setdash stroke
   \fi}
+%% End patch TN; Date (YY-MM-DD): 04-07-17; 2nd part
 %
-\def\psset@dotsep#1{\pst@getlength{#1}\psk@dotsep}
-\psset@dotsep{3pt}
+\define@key[psset]{pstricks}{dotsep}[3pt]{\pst@getlength{#1}\psk@dotsep}
+\psset[pstricks]{dotsep=3pt}
 \def\tx@DotLine{DotLine }
-\def\psls@dotted{%
+\def\psls@dotted{
   \ifpsdashadjust
     \psk@dotsep \pst@linetype\space \tx@DotLine
   \else
     [ 0 \psk@dotsep CLW add ] 0 setdash 1 setlinecap stroke
-  \fi%
+  \fi
 }
-\def\psset@linestyle#1{%
+\define@key[psset]{pstricks}{linestyle}[solid]{%
   \@ifundefined{psls@#1}%
     {\@pstrickserr{Line style `#1' not defined}\@eha}%
-    {\edef\pslinestyle{#1}}%
-}
-\psset@linestyle{solid}
-%%--------------------------------- hv 2006-04-29 beg ---------------------
-\def\psset@linecap#1{%
+    {\def\pslinestyle{#1}}}
+\psset[pstricks]{linestyle=solid}
+\define@key[psset]{pstricks}{linecap}[0]{%
   \def\psk@linecap{0}%
   \ifnum#1>-1
     \ifnum#1<3
       \pst@getint{#1}\psk@linecap%
-  \fi\fi%
-}
+  \fi\fi}
 \psset{linecap=0}
-%--------------------------------- hv 2006-04-29 end ---------------------
 %------------------------- Transparency modes ----------------------------
 \pst@def{setTransparency}< \psk@opacityalpha .setopacityalpha >
 \pst@def{setStrokeTransparency}< \psk@strokeopacityalpha .setopacityalpha >
@@ -831,21 +969,25 @@
 %--------------------------------- hv 2007-09-09 begin ---------------------
 % transparency needs a run through latex -> dvips -> ps2pdf14(!) 
 %
-\def\psset@fillcolor#1{\pst@getcolor{#1}\psfillcolor}
-\psset@fillcolor{white}
-\def\psset@strokeopacity#1{\pst@checknum{#1}\psk@strokeopacityalpha }% for lines
-\psset@strokeopacity{1}
-\def\psset@opacity#1{\pst@checknum{#1}\psk@opacityalpha }% for filled areas 
-\psset@opacity{1}
-\def\psset@shapealpha#1{\pst@checknum{#1}\psk@shapealpha }
-\psset@shapealpha{0.6}
-\def\psset@blendmode#1{\pst@getint{#1}\psk@blendmode }% must be one of 
+\define@key[psset]{pstricks}{fillcolor}[white]{\pst@getcolor{#1}\psfillcolor}
+\psset[pstricks]{fillcolor=white}
+\define@key[psset]{pstricks}{strokeopacity}[1]{\pst@checknum{#1}\psk@strokeopacityalpha }% for lines
+\psset[pstricks]{strokeopacity=1}
+\define@key[psset]{pstricks}{opacity}[1]{\pst@checknum{#1}\psk@opacityalpha }% for filled areas 
+\psset[pstricks]{opacity=1}
+\define@key[psset]{pstricks}{shapealpha}[0.6]{\pst@checknum{#1}\psk@shapealpha }
+\psset[pstricks]{shapealpha=0.6}
+\define@key[psset]{pstricks}{blendmode}[0]{\pst@getint{#1}\psk@blendmode }% must be one of 
 % /Normal     0
 % /Compatible 1
 % /Screen     2
 % /Multiply   3
 % /HardLight  4
-\psset@blendmode{0}
+\psset[pstricks]{blendmode=0}
+\define@key[psset]{pstricks}{fsAngle}[137.50775]{\pst@getangle{#1}\pst@fsAngle }
+\define@key[psset]{pstricks}{fsOrigin}[(0,0)]{%
+  \pst@@getcoor{#1}\edef\pst@fsOrigin{\pst@coor T }}
+\psset[pstricks]{fsOrigin={0,0},fsAngle=137.50775}
 %
 \def\tx@LineFill{LineFill }
 \def\tx@PenroseFill{PenroseFill }
@@ -853,23 +995,21 @@
 \def\psfs@none{}
 \def\psfs@solid{\pst@fill{\pst@usecolor\psfillcolor \tx@setTransparency fill }}
 \def\psfs@eofill{\pst@fill{\pst@usecolor\psfillcolor \tx@setTransparency eofill}}
-\def\psfs@shape{\pst@fill{ \pst@usecolor\psfillcolor \tx@setBlendmode fill }}
-%
-%--------------------------------- hv 2007-09-09 end ---------------------
-%
-\def\psset@hatchwidth#1{\pst@getlength{#1}\psk@hatchwidth}
-\psset@hatchwidth{.8pt}
-\def\psset@hatchsep#1{\pst@getlength{#1}\psk@hatchsep}
-\psset@hatchsep{4pt}
-\def\psset@hatchcolor#1{\pst@getcolor{#1}\pshatchcolor}
-\psset@hatchcolor{black}
-\def\psset@hatchangle#1{\pst@getangle{#1}\psk@hatchangle}
-\psset@hatchangle{45}
-% ------------ hv 1.11 ------------
-\def\psset@hatchsepinc#1{\pst@getlength{#1}\psk@hatchsepinc}
-\def\psset@hatchwidthinc#1{\pst@getlength{#1}\psk@hatchwidthinc}
-\psset@hatchwidthinc{0pt}
-\psset@hatchsepinc{0pt}
+\def\psfs@shape{\pst@fill{\pst@usecolor\psfillcolor \tx@setBlendmode fill }}
+\def\psfs@spiral{\pst@fill{\pst@fsOrigin \pst@usecolor\psfillcolor clip newpath
+    0 .1 500 { dup dup sqrt 4 div 0 360 arc fill \pst@fsAngle rotate } for }}
+%
+\define@key[psset]{pstricks}{hatchwidth}[0.8pt]{\pst@getlength{#1}\psk@hatchwidth}
+\psset[pstricks]{hatchwidth=.8pt}
+\define@key[psset]{pstricks}{hatchsep}[4pt]{\pst@getlength{#1}\psk@hatchsep}
+\psset[pstricks]{hatchsep=4pt}
+\define@key[psset]{pstricks}{hatchcolor}[black]{\pst@getcolor{#1}\pshatchcolor}
+\psset[pstricks]{hatchcolor=black}
+\define@key[psset]{pstricks}{hatchangle}[45]{\pst@getangle{#1}\psk@hatchangle}
+\psset[pstricks]{hatchangle=45}
+\define@key[psset]{pstricks}{hatchsepinc}[0pt]{\pst@getlength{#1}\psk@hatchsepinc}
+\define@key[psset]{pstricks}{hatchwidthinc}[0pt]{\pst@getlength{#1}\psk@hatchwidthinc}
+\psset[pstricks]{hatchwidthinc=0pt,hatchsepinc=0pt}
 %
 \def\pst@linefill{%
   \psk@hatchangle rotate
@@ -879,7 +1019,6 @@
   \psk@hatchsepinc
   \psk@hatchwidthinc
   \tx@LineFill }
-% ------------ hv 1.11 ------------
 %
 \def\psfs@vlines{\pst@fill\pst@linefill}
 \@namedef{psfs@vlines*}{\psfs@solid \psfs@vlines}
@@ -888,8 +1027,10 @@
 \def\psfs@crosshatch{\psfs@vlines \psfs@hlines}
 \@namedef{psfs@crosshatch*}{\psfs@solid \psfs@vlines \psfs@hlines}
 %
-\def\psset@psscale#1{\pst@checknum{#1}\psk@psscale}
-\psset@psscale{1}
+\define@key[psset]{pstricks}{psscale}[1]{%
+  \def\psk@@psscale{#1}%   for use with \psscalebox
+  \pst@checknum{#1}\psk@psscale}
+\psset[pstricks]{psscale=1}
 %
 \def\pst@penroseFill{%
   gsave					% restore in PenroseFill
@@ -900,7 +1041,7 @@
 \def\psfs@penrose{\pst@fill\pst@penroseFill}
 \@namedef{psfs@penrose*}{\psfs@solid \psfs@penrose}
 %
-\def\psset@fillstyle#1{%
+\define@key[psset]{pstricks}{fillstyle}[none]{%
   \edef\pst@tempg{#1}\def\pst@temph{none}%
   \ifx\pst@tempg\pst@temph
      \let\psk@fillstyle\relax
@@ -910,41 +1051,21 @@
     {\edef\psk@fillstyle{\expandafter\noexpand\csname psfs@#1\endcsname}}%
   \fi%
 }
-\def\psset@addfillstyle#1{%
+\define@key[psset]{pstricks}{addfillstyle}[]{%
   \@ifundefined{psfs@#1}%
     {\@pstrickserr{Undefined fill style: `#1'}\@eha}%
     {\edef\psk@fillstyle{%
       \expandafter\noexpand\psk@fillstyle
       \expandafter\noexpand\csname psfs@#1\endcsname}%
-    }%
-}
-\psset@fillstyle{none}
+    }}
+\psset[pstricks]{fillstyle=none}
+%
+%--------------------------- A R R O W S ---------------------------
 %
-\def\psset@arrows#1{%
-  \begingroup
-    \pst@activearrows
-    \xdef\pst@tempg{#1}%
-  \endgroup
-  \expandafter\psset@@arrows\pst@tempg\@empty-\@empty\@nil
-  \if@pst\else
-    \@pstrickserr{Bad arrows specification: #1}\@ehpa
-  \fi%
-}
-\def\psset@@arrows#1-#2\@empty#3\@nil{%
-  \@psttrue
-  \def\ps@next##1,#1-##2,##3\@nil{\def\pst@tempg{##2}}%
-  \expandafter\ps@next\pst@arrowtable,#1-#1,\@nil
-  \@ifundefined{psas@\pst@tempg}%
-    {\@pstfalse\def\psk@arrowA{}}%
-    {\let\psk@arrowA\pst@tempg}%
-  \@ifundefined{psas@#2}%
-    {\@pstfalse\def\psk@arrowB{}}%
-    {\def\psk@arrowB{#2}}%
-}
 \def\psk@arrowA{}
 \def\psk@arrowB{}
-%\def\pst@arrowtable{,<->,<<->>,>-<,>>-<<,(-),[-]}
-\def\pst@arrowtable{,<->,<<->>,>-<,>>-<<,(-),[-],)-(,]-[,|>-<|,<D-D>,D>-<D,<D<D-D>D>} % hv --1.16
+\def\pst@arrowtable{,-,<->,<<->>,>-<,>>-<<,(-),[-],)-(,]-[,|>-<|,<D-D>,D>-<D,<D<D-D>D>} % hv --1.16
+\edef\pst@arrowtable{\pst@arrowtable,|<*->|*,|<->|}
 \begingroup
   \catcode`\<=13
   \catcode`\>=13
@@ -953,25 +1074,8 @@
 \endgroup
 \def\tx@BeginArrow{BeginArrow }
 \def\tx@EndArrow{EndArrow }
-% Redefininition of \psset@arrowscale to store value of X scale factor  hv --1.12
-%\def\psset@arrowscale#1{\pst@getscale{#1}\psk@arrowscale}
-\def\psset@arrowscale#1{%                                   hv --1.12
-  \pst@@arrowscale@i#1 \@nil%                               hv -- 1.12 
-  \pst@getscale{\pst@arrowscale}\psk@arrowscale}%           hv --1.12
-\def\pst@@arrowscale@i#1 #2\@nil{\edef\pst@arrowscale{#1}}% hv --1.12
-\psset@arrowscale{1}
 %
-\def\psset@arrowsize#1{%
-  \pst@expandafter\pst@getdimnum{#1} 0 {} {}\@nil
-  \edef\psk@arrowsize{\pst@number\pst@dimg \pst@tempg}%
-}
-\psset@arrowsize{1.5pt 2}
-\def\psset@arrowlength#1{\pst@checknum{#1}\psk@arrowlength}
-\psset@arrowlength{1.4}
-\def\psset@arrowinset#1{\pst@checknum{#1}\psk@arrowinset}%
-\psset@arrowinset{.4}
 \def\tx@Arrow{ \tx@setStrokeTransparency Arrow }% hv 2008-01-13
-% new definitions of the missing arrows ---- hv 1.1.2
 \def\tx@ArrowD{ \tx@setStrokeTransparency ArrowD }% hv 2008-01-13
 %
 \@namedef{psas@<|}{ 
@@ -1050,11 +1154,11 @@
   CP newpath moveto 0 a neg L stroke 0 h neg T
   true \psk@arrowinset \psk@arrowlength \psk@arrowsize \tx@ArrowD
 }
-\def\psset@tbarsize#1{%
+\define@key[psset]{pstricks}{tbarsize}[2pt 5]{%
   \pst@expandafter\pst@getdimnum{#1} 0 {} {}\@nil
-  \edef\psk@tbarsize{\pst@number\pst@dimg \pst@tempg}%
-}
-\psset@tbarsize{2pt 5}
+  \edef\psk@tbarsize{\pst@number\pst@dimg \pst@tempg}}
+\psset[pstricks]{tbarsize=2pt 5}
+%
 \def\tx@Tbar{Tbar }
 \@namedef{psas@|}{\psk@tbarsize \tx@Tbar}
 \@namedef{psas@|*}{0 CLW -2 div T \psk@tbarsize \tx@Tbar}
@@ -1071,36 +1175,75 @@
   newpath
   false \psk@arrowinset \psk@arrowlength \psk@arrowsize \tx@Arrow
 }
-\edef\pst@arrowtable{\pst@arrowtable,|<*->|*,|<->|}
-\def\psset@bracketlength#1{\pst@checknum{#1}\psk@bracketlength}
-\psset@bracketlength{.15}
+%
+\define@key[psset]{pstricks}{bracketlength}[0.15]{\pst@checknum{#1}\psk@bracketlength}
+\psset[pstricks]{bracketlength=.15}
 \def\tx@Bracket{Bracket }
 \@namedef{psas@]}{\psk@bracketlength \psk@tbarsize \tx@Bracket}
-\def\psset@rbracketlength#1{\pst@checknum{#1}\psk@rbracketlength}
-\psset@rbracketlength{.15}
+\define@key[psset]{pstricks}{rbracketlength}[0.15]{\pst@checknum{#1}\psk@rbracketlength}
+\psset[pstricks]{rbracketlength=.15}
 \def\tx@RoundBracket{RoundBracket }
 \@namedef{psas@)}{\psk@rbracketlength \psk@tbarsize \tx@RoundBracket}
+%
 \def\psas@c{1 \psas@@c}
 \def\psas@cc{0 CLW 2 div T 1 \psas@@c}
 \def\psas@C{2 \psas@@c}
 \def\psas@@c{%
   setlinecap
   0 0 moveto
-%%-------------------- v.1.04 begin HV 2004-05-18 ----------------
-%  0 CLW 2 div L
   0 0.1 L % changed value from 0.5 to 0.1
-%%-------------------- v. 1.04 end HV 2004-05-18 ----------------
   stroke
-  0 0 moveto
-}
+  0 0 moveto }
+%
 \def\psas@{}
-\psset@arrows{-}
+%
+\define@key[psset]{pstricks}{arrowLW}{\pst@getlength{#1}\psk@arrowLW}
+\psset[pstricks]{arrowLW=0}
+% arrowLW as LineWidth for the circled line ends
+%
+\def\psas@o{\psk@arrowLW\space dup 0 eq { pop }{ SLW } ifelse
+  {\pst@usecolor\psfillcolor true} false \psk@dotsize \tx@EndDot }
+\def\psas@oo{\psk@arrowLW\space dup 0 eq { pop }{ SLW } ifelse
+  {\pst@usecolor\psfillcolor true} true \psk@dotsize \tx@EndDot }
+\@namedef{psas@*}{\psk@arrowLW\space dup 0 eq { pop }{ SLW } ifelse
+  {false} false \psk@dotsize \tx@EndDot }
+\@namedef{psas@**}{\psk@arrowLW\space dup 0 eq { pop }{ SLW } ifelse
+  {false} true \psk@dotsize \tx@EndDot }
+%
+\define@key[psset]{pstricks}{arrows}[-]{%
+  \begingroup
+    \pst@activearrows
+    \xdef\pst@tempg{#1}%
+  \endgroup
+  \expandafter\psset@@arrows\pst@tempg\@empty-\@empty\@nil
+  \if@pst\else\@pstrickserr{Bad arrows specification: #1}\@ehpa\fi}
+\def\psset@@arrows#1-#2\@empty#3\@nil{%
+  \@psttrue
+  \def\ps@next##1,#1-##2,##3\@nil{\def\pst@tempg{##2}}%
+  \expandafter\ps@next\pst@arrowtable,#1-#1,\@nil
+  \@ifundefined{psas@\pst@tempg}{\@pstfalse\def\psk@arrowA{}}{\let\psk@arrowA\pst@tempg}%
+  \@ifundefined{psas@#2}{\@pstfalse\def\psk@arrowB{}}{\def\psk@arrowB{#2}}}
+\psset[pstricks]{arrows=-}
+%
+\define@key[psset]{pstricks}{arrowscale}[1]{%                                   hv --1.12
+  \pst@@arrowscale@i#1 \@nil%                               hv -- 1.12 
+  \pst@getscale{\pst@arrowscale}\psk@arrowscale}%           hv --1.12
+\def\pst@@arrowscale@i#1 #2\@nil{\edef\pst@arrowscale{#1}}% hv --1.12
+\psset[pstricks]{arrowscale=1}
+%
+\define@key[psset]{pstricks}{arrowsize}[1.5pt 2]{%
+  \pst@expandafter\pst@getdimnum{#1} 0 {} {}\@nil
+  \edef\psk@arrowsize{\pst@number\pst@dimg \pst@tempg}%
+}
+\psset[pstricks]{arrowsize=1.5pt 2}
+\define@key[psset]{pstricks}{arrowlength}[1.4]{\pst@checknum{#1}\psk@arrowlength}
+\psset[pstricks]{arrowlength=1.4}
+\define@key[psset]{pstricks}{arrowinset}[0.4]{\pst@checknum{#1}\psk@arrowinset}%
+\psset[pstricks]{arrowinset=0.4}
+%
 \def\tx@SD{ \tx@setTransparency SD }
 \def\tx@EndDot{EndDot }
-\def\psas@oo{{\pst@usecolor\psfillcolor true} true \psk@dotsize \tx@EndDot}
-\def\psas@o{{\pst@usecolor\psfillcolor true} false \psk@dotsize \tx@EndDot}
-\@namedef{psas@**}{{false} true \psk@dotsize \tx@EndDot}
-\@namedef{psas@*}{{false} false \psk@dotsize \tx@EndDot}
+%
 \def\pst@par{}
 \def\addto@par#1{%
   \ifx\pst@par\@empty
@@ -1119,11 +1262,16 @@
   \fi%
 }
 \def\use@par{%
+  \ifx\pst@par\@empty\else%
+    \expandafter\@psset\pst@par,\@nil%
+    \def\pst@par{}%
+  \fi}
+\def\use@keep@par{%			same as \use@par, but keeps the values
   \ifx\pst@par\@empty\else
     \expandafter\@psset\pst@par,\@nil
-    \def\pst@par{}%
-  \fi%
-}
+%    \def\pst@par{}%
+  \fi}
+%
 \def\pst@object#1{%
   \def\pst@par{}%
   \pst@ifstar{%
@@ -1149,14 +1297,15 @@
 % ------------------------- hv 1.10 end ------------------------
 %
 \def\begin@ClosedObj{%
-  \leavevmode
-  \pst@killglue
-  \begingroup
-    \use@par
-    \solid@star
-    \ifpsdoubleline \pst@setdoublesep \fi
-    \init@pscode%
-}
+  \leavevmode%
+  \pst@killglue%
+  \begingroup%
+  \use@par%
+  \solid@star%
+  \ifpsdoubleline\pst@setdoublesep\fi%
+  \pst@addarrowdef% DG addition
+  \init@pscode}
+%
 \def\end@ClosedObj{%
   \ifpsshadow \pst@closedshadow \fi
   \ifdim\psk@border\p@>\z@ \pst@addborder \fi
@@ -1366,46 +1515,48 @@
     grestore
 }}
 %
-\def\pscustom{\def\pst@par{}\pst@object{pscustom}}
+\newif\ifPst@custom\Pst@customfalse
+%
+\def\pscustom{\pst@object{pscustom}}
 \long\def\pscustom@i#1{%
-  \begin@SpecialObj
-  \solid@star
-  \let\pst@ifcustom\iftrue
-  \let\begin@ClosedObj\begin@CustomObj
-  \let\end@ClosedObj\endgroup
+  \begin@SpecialObj%
+  \solid@star%
+  \let\pst@ifcustom\iftrue%
+  \Pst@customtrue%
+  \let\begin@ClosedObj\begin@CustomObj%
+  \let\end@ClosedObj\endgroup%
   \def\begin@OpenObj{\begin@CustomObj\pst@addarrowdef}%
-  \let\end@OpenObj\endgroup
-  \let\begin@AltOpenObj\begin@CustomObj
+  \let\end@OpenObj\endgroup%
+  \let\begin@AltOpenObj\begin@CustomObj%
   \def\begin@SpecialObj{%
-    \begingroup
+    \begingroup%
     \pst@misplaced{special graphics object}%
-    \def\addto@pscode####1{}
+    \def\addto@pscode####1{}%
     \let\end@SpecialObj\endgroup}%
-    \def\@multips(##1)(##2)##3##4{\pst@misplaced\multips}%
-    \def\psclip##1{\pst@misplaced\psclip}%
-    \def\pst@repeatarrowsflag{\z@}%
-    \let\pst@setrepeatarrowsflag\relax
-    \showpointsfalse
-    \let\showpointstrue\relax
-    \def\pst@linetype{\pslinetype}%
-    \let\psset@liftpen\psset@@liftpen
-    \psset@liftpen{\z@}%
-    \def\pst@cp{/currentpoint load stopped pop }%
-    \def\pst@oplineto{/lineto load stopped { moveto } if }%
-    \def\pst@optcp##1##2{%
-    \ifnum##1=\z@\def##2{/currentpoint load stopped { 0 0 } if }\fi}%
-    \let\caddto@pscode\addto@pscode
-    \def\cuse@par##1{{\use@par##1}}%
-    \the\pst@customdefs
-    \setbox\pst@hbox=\hbox{#1}%
-    \psk@fillstyle
-    \pst@stroke
-  \end@SpecialObj}
+  \def\@multips(##1)(##2)##3##4{\pst@misplaced\multips}%
+  \def\psclip##1{\pst@misplaced\psclip}%
+  \def\pst@repeatarrowsflag{\z@}%
+  \let\pst@setrepeatarrowsflag\relax%
+  \showpointsfalse%
+  \def\pst@linetype{\pslinetype}%
+  \def\psk@liftpen{\z@}%
+%  \psset{liftpen=0}%
+  \def\pst@cp{/currentpoint load stopped pop }%
+  \def\pst@oplineto{/lineto load stopped { moveto } if }%
+  \def\pst@optcp##1##2{\ifnum##1=\z@\def##2{/currentpoint load stopped { 0 0 } if }\fi}%
+  \let\caddto@pscode\addto@pscode%
+  \def\cuse@par##1{{\use@par##1}}%
+  \the\pst@customdefs%
+  \setbox\pst@hbox=\hbox{#1}%
+  \psk@fillstyle%
+  \pst@stroke%
+  \end@SpecialObj%
+}
 %
 \def\begin@CustomObj{%
-  \begingroup
-  \use@par
-  \addto@pscode{%
+  \begingroup%
+  \use@par%
+  \addto@pscode{
     \pst@number\pslinewidth SLW
     \pst@usecolor\pslinecolor
   }%
@@ -1413,45 +1564,36 @@
 \def\pst@oplineto{moveto }
 \def\pst@cp{}
 \def\pst@optcp#1#2{}
-\def\psset@liftpen#1{}
-\def\psset@@liftpen#1{%
-  \ifcase#1\relax
+\define@key[psset]{pstricks}{liftpen}[0]{%
+  \ifPst@custom%
+  \ifcase#1\relax%
     \def\psk@liftpen{\z@}%
     \def\pst@cp{/currentpoint load stopped pop }%
     \def\pst@oplineto{/lineto load stopped { moveto } if }%
-  \or
+  \or%
     \def\psk@liftpen{1}%
     \def\pst@cp{}%
     \def\pst@oplineto{/lineto load stopped { moveto } if }%
-  \or
+  \or%
     \def\psk@liftpen{2}%
     \def\pst@cp{}%
     \def\pst@oplineto{moveto }%
-  \fi%
+  \fi\fi%
 }
-\psset@liftpen{0}
+\psset[pstricks]{liftpen=0}
 \def\psk@liftpen{-1}
 %
-\def\psset@linetype#1{%
+\define@key[psset]{pstricks}{linetype}[2]{%
   \pst@getint{#1}\pslinetype
-%----------------- hv begin 2006-04-20 ------------- patch 1.14b
   \ifnum\pst@cntg<-3
-%  \ifnum\pst@dimg<-3
-%----------------- hv end 2004-05-07 ------------- patch 1.14b
     \@pstrickserr{linetype must be greater than -3}\@ehpa
-%----------------- hv begin 2004-05-07 ------------- patch 15
-%	\def\pslinetype{0}%
     \def\pslinetype{2}%
-  \fi%
-}
-%\psset@linetype{0}
-\psset@linetype{2}% otherwise there is a problem when using e.g.
+  \fi}
+\psset[pstricks]{linetype=2}% otherwise there is a problem when using e.g.
 %                     \psaxes[axesstyle=frame,linestyle=dashed]{->}(3,-2)
-%----------------- hv end 2004-05-07 ------------- patch 15
 %
 \def\caddto@pscode#1{%
-    \@pstrickserr{Command can only be used in \string\pscustom}\@ehpa%
-}
+    \@pstrickserr{Command can only be used in \string\pscustom}\@ehpa}
 \let\cuse@par\caddto@pscode
 %
 \def\tx@MSave{%
@@ -1477,10 +1619,7 @@
   \def\closepath{\addto@pscode{closepath}}%
   \def\gsave{\begingroup\addto@pscode{gsave}}%
   \def\grestore{\endgroup\addto@pscode{grestore}}%
-% DG/SR modification begin - May 12, 1997 - Patch 2
-%  \def\translate(#1){\pst@@getcoor{#1}\addto@pscode{\pst@coor moveto}}%
   \def\translate(#1){\pst@@getcoor{#1}\addto@pscode{\pst@coor translate}}%
-% DG/SR modification end
   \def\rotate#1{\pst@@getangle{#1}\addto@pscode{\pst@angle rotate}}%
   \def\scale#1{\pst@getscale{#1}\pst@tempg\addto@pscode{\pst@tempg}}%
   \def\msave{\addto@pscode{\tx@MSave}}%
@@ -1490,10 +1629,7 @@
   \def\fill{\def\pst@par{}\pst@object{fill}}%
   \def\openshadow{\def\pst@par{}\pst@object{openshadow}}%
   \def\closedshadow{\def\pst@par{}\pst@object{closedshadow}}%
-% DG/SR modification begin - Jan. 7, 1998 - Patch 8
-% \def\movepath(#1){\pst@@getcoor{#1}\addto@pscode{\pst@coor tx@Shadow}}%
   \def\movepath(#1){\pst@@getcoor{#1}\addto@pscode{\pst@coor \tx@Shadow}}%
-% DG/SR modification end
   \def\lineto{\pst@onecoor{lineto}}%
   \def\rlineto{\pst@onecoor{rlineto}}%
   \def\curveto{\pst@threecoor{curveto}}%
@@ -1503,13 +1639,9 @@
   \def\rcoor{\pst@getcoors{}{}}%
   \def\dim#1{\pssetlength\pst@dimg{#1}\addto@pscode{\pst@number\pst@dimg}}%
   \def\setcolor#1{%
-% ----------------hv begin 2004-05-07-------------------- patch 15
-%  \@ifundefined{color@#1}{}{\addto@pscode{\use@color{#1}}}}%
-%    \@ifundefined{color@#1}{}{\addto@pscode{\pst@usecolor{#1}}}}%
     \@ifundefined{\string\color@#1}{}{\addto@pscode{\pst@usecolor{#1}}}}%  hv 1.14  2005-12-17
-% ----------------hv end 2004-05-07--------------------
-  \def\arrows#1{{\psset@arrows{#1}\pst@addarrowdef}}%
-  \let\file\pst@rawfile
+  \def\arrows#1{{\psset[pstricks]{arrows=#1}\pst@addarrowdef}}%
+  \let\file\pst@rawfile%
 } % END \pst@customdefs
 %
 \def\closedshadow@i{\cuse@par\pst@closedshadow}
@@ -1559,8 +1691,9 @@
 \def\tx@Arcto{Arcto }
 \def\tx@CheckClosed{CheckClosed }
 \def\tx@Polygon{Polygon }
-\def\psset@gangle#1{\pst@getangle{#1}\psk@gangle}
-\psset@gangle{0}
+\define@key[psset]{pstricks}{gangle}[0]{\pst@getangle{#1}\psk@gangle}
+\define@boolkey[psset]{pstricks}[Pst@]{trueAngle}[true]{}
+\psset[pstricks]{trueAngle=false,gangle=0}
 %
 \def\tx@Diamond{Diamond }
 \def\psdiamond{\def\pst@par{}\pst@object{psdiamond}}
@@ -1613,16 +1746,19 @@
 \def\tx@OpenCurve{OpenCurve }
 \def\tx@AltCurve{AltCurve }
 \def\tx@ClosedCurve{ClosedCurve }
-\def\psset@curvature#1{%
-\edef\pst@tempg{#1 }%
-\expandafter\psset@@curvature\pst@tempg * * * \@nil}
+%
+\define@key[psset]{pstricks}{curvature}[1 0.1 0]{%
+  \edef\pst@tempg{#1 }%
+  \expandafter\psset@@curvature\pst@tempg * * * \@nil}
 \def\psset@@curvature#1 #2 #3 #4\@nil{%
-\pst@checknum{#1}\pst@tempg
-\pst@checknum{#2}\pst@temph
-\pst@checknum{#3}\pst@tempi
-\edef\psk@curvature{\pst@tempg \pst@temph \pst@tempi}}
-\psset@curvature{1 .1 0}
-\def\pscurve{\def\pst@par{}\pst@object{pscurve}}
+  \pst@checknum{#1}\pst@tempg
+  \pst@checknum{#2}\pst@temph
+  \pst@checknum{#3}\pst@tempi
+  \edef\psk@curvature{\pst@tempg \pst@temph \pst@tempi}}
+%
+\psset[pstricks]{curvature=1 .1 0}
+%
+\def\pscurve{\pst@object{pscurve}}
 \def\pscurve@i{%
   \pst@getarrows{%
     \begin@OpenObj
@@ -1631,74 +1767,68 @@
 }
 \def\pscurve@ii{%
   \addto@pscode{
-    \pst@cp	% current point
+    \pst@cp					% current point
     \psk@curvature\space /c ED /b ED /a ED
     \ifshowpoints true \else false \fi
-    \tx@OpenCurve
+    \ifx\pslinestyle\psls@@symbol \psls@symbol OpenSymbolCurve \else \tx@OpenCurve \fi
   }%
+  \ifx\pslinestyle\psls@@symbol\def\pslinestyle{none}\fi%
   \end@OpenObj%
 }
-\def\psecurve{\def\pst@par{}\pst@object{psecurve}}
-\def\psecurve@i{%
-\pst@getarrows{%
-\begin@OpenObj
-\pst@getcoors[\psecurve@ii}}
+\def\psecurve{\pst@object{psecurve}}
+\def\psecurve@i{\pst@getarrows{\begin@OpenObj\pst@getcoors[\psecurve@ii}}
 \def\psecurve@ii{%
-\addto@pscode{%
-\psk@curvature\space /c ED /b ED /a ED
-\ifshowpoints true \else false \fi
-\tx@AltCurve}%
-\end@OpenObj}
-\def\psccurve{\def\pst@par{}\pst@object{psccurve}}
-\def\psccurve@i{%
-\begin@ClosedObj
-\pst@getcoors[\psccurve@ii}
+  \addto@pscode{
+    \psk@curvature\space /c ED /b ED /a ED
+    \ifshowpoints true \else false \fi
+    \ifx\pslinestyle\psls@@symbol \psls@symbol AltOpenSymbolCurve \else \tx@AltCurve \fi
+  }%
+  \ifx\pslinestyle\psls@@symbol\def\pslinestyle{none}\fi%
+  \end@OpenObj}
+%
+\def\psccurve{\pst@object{psccurve}}
+\def\psccurve@i{\begin@ClosedObj\pst@getcoors[\psccurve@ii}
 \def\psccurve@ii{%
-\addto@pscode{%
-\psk@curvature\space /c ED /b ED /a ED
-\ifshowpoints true \else false \fi
-\tx@ClosedCurve}%
-\def\pst@linetype{1}%
-\end@ClosedObj}
-\def\psset@dotsize#1{%
+  \addto@pscode{%
+    \psk@curvature\space /c ED /b ED /a ED
+    \ifshowpoints true \else false \fi
+    \ifx\pslinestyle\psls@@symbol \psls@symbol ClosedSymbolCurve \else \tx@ClosedCurve \fi
+  }%
+  \def\pst@linetype{1}%
+  \ifx\pslinestyle\psls@@symbol\def\pslinestyle{none}\fi%
+  \end@ClosedObj}
+%
+\define@key[psset]{pstricks}{dotsize}[2pt 2]{%
   \pst@expandafter\pst@getdimnum{#1} 0 {} {}\@nil%
   \edef\psk@@dotsize{\pst@number\pst@dimg}%
   \let\psk@@@dotsize\pst@tempg%
-  \edef\psk@dotsize{%
-    /DS \psk@@dotsize \psk@@@dotsize CLW mul add 2 div def }}
-\psset@dotsize{2pt 2}
-\def\psset@dotscale#1{%
-\pst@getscale{#1}\psk@dotscale
-\ifx\psk@dotscale\@empty
-\def\psk@xdotscale{1 }%
-\def\psk@ydotscale{1 }%
-\else
-\let\psk@xdotscale\pst@tempg
-\let\psk@ydotscale\pst@temph
-\fi}
-% DG/SR modification begin - Oct. 17, 1997 - Patch 5
-%\psset@dotscale{1}
-% DG/SR modification end
+  \edef\psk@dotsize{ /DS \psk@@dotsize \psk@@@dotsize CLW mul add 2 div def }}
+\psset[pstricks]{dotsize=2pt 2}
+%
+\define@key[psset]{pstricks}{dotscale}[1]{%
+  \pst@getscale{#1}\psk@dotscale
+  \ifx\psk@dotscale\@empty
+    \def\psk@xdotscale{1 }%
+    \def\psk@ydotscale{1 }%
+  \else
+    \let\psk@xdotscale\pst@tempg
+    \let\psk@ydotscale\pst@temph
+  \fi}
+%
 \def\pst@Getangle#1#2{%
-\pst@getangle{#1}\pst@tempg
-\def\pst@temph{0. }%
-\ifx\pst@tempg\pst@temph
-\def#2{}%
-\else
-\edef#2{\pst@tempg\space rotate }%
-\fi}
-\def\psset@dotangle#1{%
-\pst@getangle{#1}\psk@@dotangle
-\ifdim\psk@@dotangle\p@=\z@
-\let\psk@dotangle\@empty
-\else
-% DG/SR modification begin - Aug. 8, 1997 - Patch 4
-%\edef\psk@dotangle{\psk@@dotangle rotate }
-\edef\psk@dotangle{\psk@@dotangle rotate }%
-% DG/SR modification end
-\fi}
+  \pst@getangle{#1}\pst@tempg
+  \def\pst@temph{0. }%
+  \ifx\pst@tempg\pst@temph\def#2{}\else\edef#2{\pst@tempg\space rotate }\fi}
+%
+\define@key[psset]{pstricks}{dotangle}[0]{%
+  \pst@getangle{#1}\psk@@dotangle
+  \ifdim\psk@@dotangle\p@=\z@
+    \let\psk@dotangle\@empty
+  \else
+    \edef\psk@dotangle{\psk@@dotangle rotate }%
+  \fi}
+\psset[pstricks]{dotangle=0}
 %
-\psset@dotangle{0}
 \def\pst@getdotsize{%
 \pst@dimg=\psk@@@dotsize\pslinewidth
 \advance\pst@dimg\psk@@dotsize\p@
@@ -1706,11 +1836,10 @@
 \pst@dimg=\psk@xdotscale\pst@dimg
 \divide\pst@dimh 2
 \divide\pst@dimg 2\relax}
-% DG/SR modification begin - Oct. 17, 1997 - Patch 5
-\psset@dotscale{1}
-% DG/SR modification end
 %
-\def\psdot{\def\pst@par{}\pst@object{psdot}}
+\psset[pstricks]{dotscale=1}
+%
+\def\psdot{\pst@object{psdot}}
 \def\psdot@i{\@ifnextchar({\psdot@ii}{\psdot@ii(\z@,\z@)}}
 \def\psdot@ii(#1){%
   \begin@SpecialObj%
@@ -1720,11 +1849,11 @@
   \pst@@getcoor{#1}%
   \addto@pscode{
     \psk@dotsize
-    \@nameuse{psds@\psk@dotstyle}%
+    \@nameuse{psds@\psk@dotstyle}
     \pst@coor Dot}%
   \end@SpecialObj}
 %
-\def\psdots{\def\pst@par{}\pst@object{psdots}}
+\def\psdots{\pst@object{psdots}}
 \def\psdots@i{%
   \begin@SpecialObj%
   \pst@getcoors[\psdots@ii}
@@ -1737,7 +1866,7 @@
   newpath
   n { transform floor .5 add exch floor .5 add exch itransform Dot } repeat }
 %
-% DG: dead code (to suppress until \psset@dotstyle) ? - Aug. 4, 1997
+% DG: dead code (to suppress until \psset[pstricks]{dotstyle) ? - Aug. 4, 1997
 \def\tx@SQ{SQ }
 \def\tx@ST{ST }
 \def\tx@SP{SP }
@@ -1773,11 +1902,11 @@
   \pst@gdot{0 DS moveto 0 DS neg L stroke}}
 % DG: end dead code?
 %
-\def\psset@dotstyle#1{%
-\@ifundefined{psds@#1}%
-{\@pstrickserr{Dot style `#1' not defined}\@eha}%
-{\edef\psk@dotstyle{#1}}}
-\psset@dotstyle{*}
+\define@key[psset]{pstricks}{dotstyle}[*]{%
+  \@ifundefined{psds@#1}%
+    {\@pstrickserr{Dot style `#1' not defined}\@eha}%
+    {\edef\psk@dotstyle{#1}}}
+\psset[pstricks]{dotstyle=*}
 %
 \def\tx@FontDot{FontDot }
 \def\newpsfontdot#1[#2]#3#4{%
@@ -1889,12 +2018,12 @@
 \newpsfontdotH{Diamond}[1.0 0.0 0.0 1.0 0.0 0.0]{PSTricksDotFont}{(d)}{(l)}
 \newpsfontdotH{BoldDiamond}[1.0 0.0 0.0 1.0 0.0 0.0]{PSTricksDotFont}{(D)}{(l)}
 \newpsfontdot{SolidDiamond}[1.0 0.0 0.0 1.0 0.0 0.0]{PSTricksDotFont}{(l)}
-%%
+%
 \newdimen\pslinearc
-\def\psset@linearc#1{\pssetlength\pslinearc{#1}}
-\psset@linearc{0pt}
+\define@key[psset]{pstricks}{linearc}[0pt]{\pssetlength\pslinearc{#1}}
+\psset[pstricks]{linearc=0pt}
 %
-\def\psline{\def\pst@par{}\pst@object{psline}}
+\def\psline{\pst@object{psline}}
 \def\psline@i{%
   \pst@getarrows{%
     \begin@OpenObj
@@ -1902,11 +2031,14 @@
   }%
 }
 \def\psline@ii{%
-  \addto@pscode{
-    \pst@cp 	% current point
-    \psline@iii % arc and lineto type
-    \tx@Line	% .pro function
-  }%
+  \ifx\pslinestyle\psls@@symbol\addto@pscode{ \psls@symbol SymbolLine }%
+  \else
+    \addto@pscode{
+      \pst@cp 	  % current point
+      \psline@iii % arc and lineto type
+      \tx@Line	  % .pro function
+    }%
+  \fi%
   \end@OpenObj%
 }
 \def\psline@iii{%
@@ -1920,6 +2052,55 @@
   \tx@setlinejoin 			% hv 2007-10-13
 }
 %
+\def\pst@isnum#1{\pst@isnum@i\zap@space#1 \@empty\@nil}%
+\def\pst@isnum@i#1\@nil{%
+  \if!\ifnum9<1#1!\else_\fi
+      \expandafter\@firstoftwo
+  \else
+      \expandafter\@secondoftwo
+  \fi
+}
+\def\psset@@symbol#1#2#3#4\@nil{%
+  \ifx\relax#4\relax\def\psk@symbol{(#1)}%
+  \else
+    \pst@isnum{#1#2#3}{%
+      \pst@cnta='#1#2#3\relax
+      \ifnum\pst@cnta>'377\relax
+        \@pstrickserr{Number too large!}\@ehpb
+      \else
+        \def\psk@symbol{(\@backslashchar#1#2#3)}%
+      \fi%
+    }{\@pstrickserr{Not a number!}\@ehpb}
+  \fi}
+\define@key[psset]{pstricks}{symbol}[a]{\expandafter\psset@@symbol#1!!\@nil}
+\psset[pstricks]{symbol=a}
+%
+\newdimen\pst@symbolStep
+\define@key[psset]{pstricks}{symbolStep}[20pt]{\pssetlength\pst@symbolStep{#1}}
+\psset[pstricks]{symbolStep=20pt}
+\newdimen\pst@symbolWidth
+\define@key[psset]{pstricks}{symbolWidth}[10pt]{\pssetlength\pst@symbolWidth{#1}}
+\psset[pstricks]{symbolWidth=10pt}
+\define@key[psset]{pstricks}{symbolFont}[Dingbats]{\def\psk@symbolFont{/#1 }}
+\psset[pstricks]{symbolFont=Dingbats}
+\define@boolkey[psset]{pstricks}[Pst@]{rotateSymbol}[true]{}
+\psset[pstricks]{rotateSymbol=false}
+\define@key[psset]{pstricks}{startAngle}[0]{\pst@getangle{#1}\psk@startAngle}
+\psset[pstricks]{startAngle=0}
+%
+\def\psls@symbol{
+  /Symbol \psk@symbol def
+  /SymbolWidth \pst@number\pst@symbolWidth def
+  /SymStep \pst@number\pst@symbolStep def
+  \psk@symbolFont findfont %0. [1.0 0.0 0.0 1.0 0.0 0.0]
+  \pst@number\pst@symbolWidth scalefont %dup 
+  setfont 
+  /rotateSymbol \ifPst@rotateSymbol true \else false \fi def
+  /startAngle \psk@startAngle\space def
+  /CorrAngle \ifx\psk@rot\@empty 0 \else \psk@rot \fi def
+}
+\def\psls@@symbol{symbol}
+%
 \def\psPline{\def\pst@par{}\pst@object{psPline}}% perpendicular to another line B-C
 \def\psPline@i{%
   \pst@getarrows{%
@@ -1954,33 +2135,36 @@
     \@nameuse{psls@\pslinestyle}%
   }%
   \end@SpecialObj}
-\def\pspolygon{\def\pst@par{}\pst@object{pspolygon}}
+%
+\def\pspolygon{\pst@object{pspolygon}}
 \def\pspolygon@i{%
   \begin@ClosedObj%
   \def\pst@cp{}%
   \pst@getcoors[\pspolygon@ii%
 }
 \def\pspolygon@ii{%
-  \addto@pscode{\psline@iii \tx@Polygon}%
+  \ifx\pslinestyle\psls@@symbol\addto@pscode{ \psls@symbol SymbolPolygon }%
+  \else                        \addto@pscode{\psline@iii \tx@Polygon}%
+  \fi%
   \def\pst@linetype{1}%
   \end@ClosedObj}
 %
-\def\psset@framearc#1{\pst@checknum{#1}\psk@framearc}
-\psset@framearc{0}
+\define@key[psset]{pstricks}{framearc}[0]{\pst@checknum{#1}\psk@framearc}
+\psset[pstricks]{framearc=0}
 %
-\def\psset@cornersize#1{\pst@expandafter\psset@@cornersize{#1}\@nil}
+\define@key[psset]{pstricks}{cornersize}[relative]{\pst@expandafter\psset@@cornersize{#1}\@nil}
 \def\psset@@cornersize#1#2\@nil{%
   \if #1a\relax
     \def\psk@cornersize{\pst@number\pslinearc false }%
   \else\def\psk@cornersize{\psk@framearc true }%
   \fi}
-\psset@cornersize{relative}
+\psset[pstricks]{cornersize=relative}
 %
 \def\tx@Rect{Rect }
 \def\tx@OvalFrame{OvalFrame }
 \def\tx@Frame{Frame }
 %
-\def\psset@dimen#1{\pst@expandafter\psset@@dimen{#1}\@nil}
+\define@key[psset]{pstricks}{dimen}[outer]{\pst@expandafter\psset@@dimen{#1}\@nil}
 \def\psset@@dimen#1#2\@nil{%
   \if #1o\relax%	outer
     \def\psk@dimen{.5 }%
@@ -1991,9 +2175,9 @@
       \if #1i\relax%	inner
         \def\psk@dimen{-.5 }%
   \fi\fi\fi}
-\psset@dimen{outer}
+\psset[pstricks]{dimen=outer}
 %
-\def\psframe{\def\pst@par{}\pst@object{psframe}}
+\def\psframe{\pst@object{psframe}}
 \def\psframe@i(#1){%
   \@ifnextchar({\psframe@ii(#1)}{\psframe@ii(0,0)(#1)}}
 \def\psframe@ii(#1)(#2){%
@@ -2006,7 +2190,7 @@
   \end@ClosedObj%
 }
 %
-\def\psTextFrame{\def\pst@par{}\pst@object{psTextFrame}}
+\def\psTextFrame{\pst@object{psTextFrame}}
 \def\psTextFrame@i(#1)(#2)#3{%
   \addbefore@par{ref=c}%	to prevent an empty value
   \leavevmode%
@@ -2029,14 +2213,14 @@
   \endgroup
   \ignorespaces}
 %
-\def\tx@BezierNArray{BezierNArray }
-\def\tx@OpenBezier{OpenBezier }
-\def\tx@ClosedBezier{ClosedBezier }
-\def\tx@BezierShowPoints{BezierShowPoints }
-\def\tx@BezierCurve{BezierCurve }
+\def\tx@BezierNArray{ BezierNArray }
+\def\tx@OpenBezier{ OpenBezier }
+\def\tx@ClosedBezier{ ClosedBezier }
+\def\tx@BezierShowPoints{ BezierShowPoints }
+\def\tx@BezierCurve{ BezierCurve }
 \def\pst@BezierType{2 }	% the default
 %
-\def\psbezier{\def\pst@par{}\pst@object{psbezier}}
+\def\psbezier{\pst@object{psbezier}}
 \def\psbezier@i{%
   \pst@getarrows{%
     \begin@OpenObj
@@ -2044,30 +2228,40 @@
   }%
 }
 \def\psbezier@ii{%
-  \addto@pscode{%
-% DG/SR modification begin - Apr. 28, 1997 - Patch 1
-% \psbezier doesn't work inside \pscustom
-\pst@cp
-% DG/SR modification end
+  \addto@pscode{
+    \pst@cp
     \ifshowpoints true \else false \fi
-    \tx@OpenBezier
-    \ifshowpoints \tx@BezierShowPoints \fi}%
+    \ifx\pslinestyle\psls@@symbol \psls@symbol OpenSymbolBezier 
+    \else 
+      \tx@OpenBezier 
+      \ifshowpoints \tx@BezierShowPoints \fi
+    \fi
+  }%
+  \def\pst@linetype{1}%
+  \ifx\pslinestyle\psls@@symbol\def\pslinestyle{none}\fi%
   \end@OpenObj}
+%
 \def\pscbezier{\def\pst@par{}\pst@object{pscbezier}}
 \def\pscbezier@i{%
   \begin@ClosedObj
   \pst@getcoors[\pscbezier@ii}
+%
 \def\pscbezier@ii{%
   \addto@pscode{%
     \ifshowpoints true \else false \fi
-    \tx@ClosedBezier
-    \ifshowpoints \tx@BezierShowPoints \fi}%
-  \chardef\pst@linetype=1
+    \ifx\pslinestyle\psls@@symbol \psls@symbol ClosedSymbolBezier 
+    \else 
+      \tx@ClosedBezier
+      \ifshowpoints \tx@BezierShowPoints \fi
+    \fi}%
+%  \chardef\pst@linetype=1
+  \def\pst@linetype{1}%
+  \ifx\pslinestyle\psls@@symbol\def\pslinestyle{none}\fi%
   \end@ClosedObj}
-
+%
 \iffalse
-\def\psset@epsilon#1{\pst@checknum{#1}\psk@epsilon}
-\psset@epsilon{0.005}		% 200 steps for one curve
+\define@key[psset]{pstricks}{epsilon}[0.005]{\pst@checknum{#1}\psk@epsilon}
+\psset[pstricks]{epsilon=0.005}		% 200 steps for one curve
 %
 \def\psBezier#1{%		% allowed order is 1 ... 9
   \ifnum#1>0 \ifnum#1<10 \def\pst@BezierType{#1 }\fi\fi%
@@ -2087,11 +2281,12 @@
   \end@OpenObj}
 \fi
 %
-\def\psset@pType#1{\pst@cntg=#1\relax\edef\psk@pType{\the\pst@cntg}}
-\psset@pType{0}
+\define@key[psset]{pstricks}{pType}[0]{\pst@cntg=#1\relax\edef\psk@pType{\the\pst@cntg}}
+\psset[pstricks]{pType=0}
 \def\tx@Parab{Parab }%	 given by 1 point and the min/max
 \def\tx@Parabo{Parab1 }% given by 2 points for y-a=(x-b)^2
-\def\psparabola{\def\pst@par{}\pst@object{psparabola}}%  2009-05-19 (hv)
+%
+\def\psparabola{\pst@object{psparabola}}%  2009-05-19 (hv)
 \def\psparabola@i{\pst@getarrows\psparabola@ii}
 \def\psparabola@ii#1(#2)#3(#4){%  #2 P #4 SP
   \begin@OpenObj
@@ -2106,36 +2301,36 @@
 \let\parabola\psparabola% compatibility  (hv)
 %
 %
-\def\psset@gridwidth#1{\pst@getlength{#1}\psk@gridwidth}
-\psset@gridwidth{.8pt}
-\def\psset@griddots#1{%
+\define@key[psset]{pstricks}{gridwidth}[0.8pt]{\pst@getlength{#1}\psk@gridwidth}
+\psset[pstricks]{gridwidth=.8pt}
+\define@key[psset]{pstricks}{griddots}[0]{%
   \pst@cntg=#1\relax
   \edef\psk@griddots{\the\pst@cntg}}
-\psset@griddots{0}
-\def\psset@gridcolor#1{\pst@getcolor{#1}\psgridcolor}
-\psset@gridcolor{black}
-\def\psset@subgridwidth#1{\pst@getlength{#1}\psk@subgridwidth}
-\psset@subgridwidth{.4pt}
-\def\psset@subgridcolor#1{\pst@getcolor{#1}\pssubgridcolor}
-\psset@subgridcolor{gray}
-\def\psset@subgriddots#1{%
+\psset[pstricks]{griddots=0}
+\define@key[psset]{pstricks}{gridcolor}[black]{\pst@getcolor{#1}\psgridcolor}
+\psset[pstricks]{gridcolor=black}
+\define@key[psset]{pstricks}{subgridwidth}[0.4pt]{\pst@getlength{#1}\psk@subgridwidth}
+\psset[pstricks]{subgridwidth=0.4pt}
+\define@key[psset]{pstricks}{subgridcolor}[gray]{\pst@getcolor{#1}\pssubgridcolor}
+\psset[pstricks]{subgridcolor=gray}
+\define@key[psset]{pstricks}{subgriddots}[0]{%
   \pst@cntg=#1\relax\edef\psk@subgriddots{\the\pst@cntg}}
-\psset@subgriddots{0}
-\def\psset@subgriddiv#1{%
+\psset[pstricks]{subgriddots=0}
+\define@key[psset]{pstricks}{subgriddiv}[5]{%
   \pst@cntg=#1\relax\edef\psk@subgriddiv{\the\pst@cntg}}
-\psset@subgriddiv{5}
+\psset[pstricks]{subgriddiv=5}
 %
-\def\psset@gridfont#1{\def\psk@gridfont{/#1 }}%   hv 2007-11-13
-\psset@gridfont{Helvetica}
+\define@key[psset]{pstricks}{gridfont}[Helvetica]{\def\psk@gridfont{/#1 }}%   hv 2007-11-13
+\psset[pstricks]{gridfont=Helvetica}
 %
-\def\psset@gridlabels#1{\pst@getlength{#1}\psk@gridlabels}
-\psset@gridlabels{10pt}
-\def\psset@gridlabelcolor#1{\pst@getcolor{#1}\psgridlabelcolor}
-\psset@gridlabelcolor{black}
+\define@key[psset]{pstricks}{gridlabels}[10pt]{\pst@getlength{#1}\psk@gridlabels}
+\psset[pstricks]{gridlabels=10pt}
+\define@key[psset]{pstricks}{gridlabelcolor}[black]{\pst@getcolor{#1}\psgridlabelcolor}
+\psset[pstricks]{gridlabelcolor=black}
 
 \def\tx@Grid{Grid }
 
-\def\psgrid{\def\pst@par{}\pst@object{psgrid}}
+\def\psgrid{\pst@object{psgrid}}
 \def\psgrid@i{\@ifnextchar({\psgrid@ii}{\expandafter\psgrid@iv\pic@coor}}
 \def\psgrid@ii(#1){\@ifnextchar({\psgrid@iii(#1)}{\psgrid@iv(0,0)(0,0)(#1)}}
 \def\psgrid@iii(#1)(#2){\@ifnextchar({\psgrid@iv(#1)(#2)}{\psgrid@iv(#1)(#1)(#2)}}
@@ -2189,21 +2384,19 @@
 %
 \def\pst@makeverbbox#1{%
   \def\pst@afterbox{#1}%
-  \edef\pst@mathflag{%
-    \ifpsmathbox\ifmmode\ifinner 1\else 2\fi\else \z@\fi\else \z@\fi%
-  }%
-  \afterassignment\pst@beginbox
+  \edef\pst@mathflag{\ifpsmathbox\ifmmode\ifinner1\else2\fi\else\z@\fi\else\z@\fi}%
+  \afterassignment\pst@beginbox%
   \setbox\pst@hbox\hbox%
 }
 \def\pst@beginbox{%
-  \ifcase\pst@mathflag\or$\m@th\or$\m@th\displaystyle\fi
-  \bgroup\aftergroup\pst@endbox
-  \pst@thisbox
+  \ifcase\pst@mathflag\or$\m@th\or$\m@th\displaystyle\fi%
+  \bgroup\aftergroup\pst@endbox%
+  \pst@thisbox%
   \the\everypsbox%
 }
 \def\pst@endbox{%
-  \ifnum\pst@mathflag>\z@$\fi		%$
-  \egroup
+  \ifnum\pst@mathflag>\z@\relax$\fi%                      $
+  \egroup%
   \pst@afterbox%
 }
 \def\pst@makebox{\pst@@makebox}
@@ -2238,13 +2431,11 @@
   \@namedef{end#1}{\pst@endlongbox}}
 %
 \newdimen\psframesep
-\def\psset@framesep#1{\pssetlength\psframesep{#1}}
-\psset@framesep{3pt}
+\define@key[psset]{pstricks}{framesep}[3pt]{\pssetlength\psframesep{#1}}
+\psset[pstricks]{framesep=3pt}
 %
-\newif\ifpsboxsep
-\def\psset@boxsep#1{\@nameuse{psboxsep#1}}
-%
-\psset@boxsep{true}
+\define@boolkey[psset]{pstricks}[ps]{boxsep}[true]{}
+\psset[pstricks]{boxsep}
 %
 \def\pst@useboxpar{%
   \use@par
@@ -2536,89 +2727,100 @@ pop
 \ht\pst@hbox\pst@dimd
 \advance\pst@dimd-2\pst@dimb
 \dp\pst@hbox\pst@dimd}
-\def\psset@trimode#1{\pst@expandafter\psset@@trimode{#1}\@empty\@empty\@nil}
+%
+\define@key[psset]{pstricks}{trimode}[U]{\pst@expandafter\psset@@trimode{#1}\@empty\@empty\@nil}
 \def\psset@@trimode#1#2#3\@nil{%
-\let\pst@tempg#1\relax
-\ifx\pst@tempg*%
-\let\psk@@trimode\@empty
-\let\pst@tempg#2\relax
-\else
-\let\psk@@trimode\relax
-\fi
-\edef\psk@trimode{%
-\ifx R\pst@tempg 1 \else\ifx D\pst@tempg 2
-\else\ifx L\pst@tempg 3 \else 0 \fi\fi\fi}}
-\psset@trimode{U}
-\def\pstribox{\def\pst@par{}\pst@object{pstribox}}
+  \let\pst@tempg#1\relax
+  \ifx\pst@tempg*
+    \let\psk@@trimode\@empty
+    \let\pst@tempg#2\relax
+  \else
+    \let\psk@@trimode\relax
+  \fi
+  \edef\psk@trimode{%
+    \ifx R\pst@tempg 1 % Right
+    \else
+      \ifx D\pst@tempg 2 % Down
+      \else
+        \ifx L\pst@tempg 3 % Left
+        \else 0 % Up
+        \fi
+      \fi
+    \fi}%
+}
+\psset[pstricks]{trimode=U}
+%
+\def\pstribox{\pst@object{pstribox}}
 \def\pstribox@i{\pst@makebox{\pstribox@ii}}
 \def\pstribox@ii{%
-\begingroup
-\pst@useboxpar
-\pstribox@iii
-\ifpsboxsep\pstribox@sep\fi
-\leavevmode
-\box\pst@hbox
-\endgroup}
+  \begingroup
+  \pst@useboxpar
+  \pstribox@iii
+  \ifpsboxsep\pstribox@sep\fi
+  \leavevmode
+  \box\pst@hbox
+  \endgroup}
+%
 \def\pstribox@iii{%
-\pstribox@iv
-\setbox\pst@hbox=\hbox{%
-\begin@ClosedObj
-\addto@pscode{%
-\psline@iii
-pop
-.5
-\pst@number\pst@dimc \pst@number\pst@dimd
-\ifodd\psk@trimode exch \fi
-\psk@trimode -90 mul
-\pst@number\pst@dima \pst@number\pst@dimb
-\tx@Triangle}%
-\def\pst@linetype{2}%
-\end@ClosedObj
-\box\pst@hbox}}
+  \pstribox@iv
+  \setbox\pst@hbox=\hbox{%
+    \begin@ClosedObj
+    \addto@pscode{
+      \psline@iii
+      pop
+      0.5
+      \pst@number\pst@dimc \pst@number\pst@dimd
+      \ifodd\psk@trimode exch \fi
+      \psk@trimode -90 mul
+      \pst@number\pst@dima \pst@number\pst@dimb
+      \tx@Triangle}%
+    \def\pst@linetype{2}%
+    \end@ClosedObj
+    \box\pst@hbox}%
+}
+%
 \def\pstribox@iv{%
-\pst@dimh=\pslinewidth
-\advance\pst@dimh\psframesep
-\pst@dimg=\ht\pst@hbox
-\advance\pst@dimg-\dp\pst@hbox
-\divide\pst@dimg 2
-\edef\pst@tempa{\number\pst@dimg sp}% For use by nodes.
-\ifodd\psk@trimode
-\pst@dimb\pst@dimg
-\else
-\pst@dima=\wd\pst@hbox
-\divide\pst@dima 2
-\fi
-\ifcase\psk@trimode
-\pst@dimb=-\dp\pst@hbox
-\advance\pst@dimb-\pst@dimh
-\or
-\pst@dima=-\pst@dimh
-\or
-\pst@dimb=\ht\pst@hbox
-\advance\pst@dimb\pst@dimh
-\or
-\pst@dima=\wd\pst@hbox
-\advance\pst@dima\pst@dimh
-\fi
-\pst@dimd=\dp\pst@hbox
-\advance\pst@dimd\ht\pst@hbox
-\ifx\psk@@trimode\relax
-\pst@dimc=\wd\pst@hbox
-\advance\pst@dimc\ifodd\psk@trimode 1.447\else 1.789\fi\pst@dimh
-\multiply\pst@dimc 2
-\advance\pst@dimd\ifodd\psk@trimode 1.789\else 1.447\fi\pst@dimh
-\multiply\pst@dimd 2
-\else
-\ifodd\psk@trimode
-\advance\pst@dimd 1.1547\wd\pst@hbox
-\advance\pst@dimd 3.4641\pst@dimh
-\pst@dimc=.866\pst@dimd
-\else
-\advance\pst@dimd .866\wd\pst@hbox %.866=(sqrt(3)/2)
-\advance\pst@dimd 3\pst@dimh
-\pst@dimc=1.1547\pst@dimd % 1.1547=(2/sqrt(3))
-\fi
-\fi}
+  \pst@dimh=\pslinewidth
+  \advance\pst@dimh\psframesep
+  \pst@dimg=\ht\pst@hbox
+  \advance\pst@dimg-\dp\pst@hbox
+  \divide\pst@dimg 2
+  \edef\pst@tempa{\number\pst@dimg sp}% For use by nodes.
+  \ifodd\psk@trimode
+    \pst@dimb\pst@dimg
+  \else
+    \pst@dima=\wd\pst@hbox
+    \divide\pst@dima 2
+  \fi
+  \ifcase\psk@trimode
+    \pst@dimb=-\dp\pst@hbox
+    \advance\pst@dimb-\pst@dimh
+  \or\pst@dima=-\pst@dimh
+  \or\pst@dimb=\ht\pst@hbox
+     \advance\pst@dimb\pst@dimh
+  \or\pst@dima=\wd\pst@hbox
+     \advance\pst@dima\pst@dimh
+  \fi
+  \pst@dimd=\dp\pst@hbox
+  \advance\pst@dimd\ht\pst@hbox
+  \ifx\psk@@trimode\relax% no star for trimode=
+    \pst@dimc=\wd\pst@hbox
+    \advance\pst@dimc\ifodd\psk@trimode 1.447\else 1.789\fi\pst@dimh
+    \multiply\pst@dimc 2
+    \advance\pst@dimd\ifodd\psk@trimode 1.789\else 1.447\fi\pst@dimh
+    \multiply\pst@dimd 2
+  \else% trimode=R*,L*,U*,D*
+    \ifodd\psk@trimode
+      \advance\pst@dimd 1.1547\wd\pst@hbox
+      \advance\pst@dimd 3.4641\pst@dimh
+      \pst@dimc=.866\pst@dimd
+    \else
+      \advance\pst@dimd .866\wd\pst@hbox %.866=(sqrt(3)/2)
+      \advance\pst@dimd 3\pst@dimh 
+      \pst@dimc=1.1547\pst@dimd % 1.1547=(2/sqrt(3))
+    \fi
+  \fi}
+%
 \def\pstribox@sep{%
 \ifodd\psk@trimode
 \advance\pst@dimb.5\pst@dimd
@@ -2649,14 +2851,14 @@ pop
 \hss\box\pst@hbox\kern\psframesep\kern\pslinewidth}%
 \fi}
 %
-\def\psset@arcsepA#1{\pst@getlength{#1}\psk@arcsepA}
-\def\psset@arcsepB#1{\pst@getlength{#1}\psk@arcsepB}
-\def\psset@arcsep#1{%
-\psset@arcsepA{#1}\let\psk@arcsepB\psk@arcsepA}
-\psset@arcsep{0}
+\define@key[psset]{pstricks}{arcsepA}[0]{\pst@getlength{#1}\psk@arcsepA}
+\define@key[psset]{pstricks}{arcsepB}[0]{\pst@getlength{#1}\psk@arcsepB}
+\define@key[psset]{pstricks}{arcsep}[0]{%
+  \pst@getlength{#1}\psk@arcsepA\let\psk@arcsepB\psk@arcsepA}
+\psset[pstricks]{arcsep=0}
 \def\tx@ArcArrow{ArcArrow }
 %
-\def\psarc{\def\pst@par{}\pst@object{psarc}}
+\def\psarc{\pst@object{psarc}}
 \def\psarc@i{\@ifnextchar({\psarc@iii}{\psarc@ii}}
 \def\psarc@ii#1{\addto@par{arrows=#1}%
   \@ifnextchar({\psarc@iii}{\psarc@iii(0,0)}%
@@ -2738,16 +2940,16 @@ pop
 \def\psarcn{\def\pst@par{}\pst@object{psarcn}}
 \def\psarcn@i{\def\psarc@type{1}\psarc@i}
 %
-\def\psarcAB{\def\pst@par{}\pst@object{psarcAB}}%		hv 2008-11-26
+\def\psarcAB{\pst@object{psarcAB}}%		hv 2008-11-26
 \def\psarcAB@i{%
   \addbefore@par{psscale=1}% be sure, that it is defined
   \pst@getarrows{%
-    \begin@OpenObj
+    \begin@OpenObj%
       \pst@getcoors{}\psarcAB@ii%
     }%
 }
 \def\psarcAB@ii{%
-  \addto@pscode{%
+  \addto@pscode{
   /y ED /x ED /yA ED /xA ED /yB ED /xB ED 
   /r xB yB x y Pyth2 \psk@psscale\space mul def
   /c 57.2957 r \tx@Div def
@@ -2767,10 +2969,9 @@ pop
       y add exch x add exch moveto
     \fi
   \fi
-  \psarc@v 
-  }
+  \psarc@v }%
   \gdef\psarc@type{0}%
-  \showpointsfalse
+  \showpointsfalse%
   \end@OpenObj%
 }
 \def\psarcnAB{\def\pst@par{}\pst@object{psarcnAB}}
@@ -2943,14 +3144,14 @@ pop
     \tx@SD }%
   \end@SpecialObj}
 %
-\def\psset@radius#1{\pst@@getlength{#1}\psk@radius}
-\psset@radius{.25cm}
+\define@key[psset]{pstricks}{radius}[0.25cm]{\pst@@getlength{#1}\psk@radius}
+\psset[pstricks]{radius=.25cm}
 %
-\def\psCircle{\def\pst@par{}\pst@object{psCircle}}% same as \pscircle, but uses \psk@radius
+\def\psCircle{\pst@object{psCircle}}% same as \pscircle, but uses \psk@radius
 \def\psCircle@i{\@ifnextchar({\psCircle@ii}{\psCircle@ii(0,0)}}
 \def\psCircle@ii(#1){\pscircle@do(#1){\psk@radius}}
 %
-\def\pswedge{\def\pst@par{}\pst@object{pswedge}}
+\def\pswedge{\pst@object{pswedge}}
 \def\pswedge@i{\@ifnextchar({\pswedge@ii}{\pswedge@ii(0,0)}}
 \def\pswedge@ii(#1)#2#3#4{%
   \begin@ClosedObj%
@@ -3135,7 +3336,7 @@ pop
 \fi
 \setbox#1=\hbox to\z@{%
 \kern-\pst@dimh\vbox to\z@{\vss\box#1\kern-\pst@dimg}\hss}}
-\def\psset@ref#1{\pst@expandafter\psset@@ref{#1}\@empty,,\@nil}
+\define@key[psset]{pstricks}{ref}[c]{\pst@expandafter\psset@@ref{#1}\@empty,,\@nil}
 \def\psset@@ref#1#2,#3,#4\@nil{%
   \def\psk@xref{.5}%
   \def\psk@yref{.5}%
@@ -3153,18 +3354,15 @@ pop
 \def\getref@B{\let\psk@yref\relax}
 \def\getref@l{\def\psk@xref{0}}
 \def\getref@r{\def\psk@xref{1}}
-\psset@ref{c}
+\psset[pstricks]{ref=c}
 %
-\def\psset@rot#1{%
-\pst@expandafter{\@ifnextchar*{\psset@@@rot}{\psset@@rot}}{#1}\@nil}
+\define@key[psset]{pstricks}{rot}[0]{%
+  \pst@expandafter{\@ifnextchar*{\psset@@@rot}{\psset@@rot}}{#1}\@nil}
 \def\psset@@rot#1\@nil{%
 \def\ps@next##1@#1=##2@##3\@nil{%
-\ifx\relax##2%
-\pst@getangle{#1}\psk@rot
-\else
-\def\psk@rot{##2}%
-\fi}%
+\ifx\relax##2\pst@getangle{#1}\psk@rot\else\def\psk@rot{##2}\fi}%
 \expandafter\ps@next\pst@rottable @#1=\relax @\@nil}
+%
 \def\psset@@@rot#1#2\@nil{%
 \psset@@rot#2\@nil
 \edef\psk@rot{\pst@rotlist \ifx\psk@rot\@empty\else\psk@rot add \fi}}
@@ -3179,7 +3377,8 @@ pop
 @W=\pst@rotlist 90 add %
 @S=\pst@rotlist 180 add %
 @E=\pst@rotlist 90 sub }
-\psset@rot{0}
+\psset[pstricks]{rot=0}
+%
 \def\tx@RotBegin{RotBegin }
 \def\tx@RotEnd{RotEnd }
 \def\pst@rotate#1#2{%
@@ -3281,19 +3480,20 @@ pop
 \def\Cput{\def\pst@par{}\pst@object{Cput}}
 \def\Cput@i{\@fixedradiustrue\cput@ii}
 \newdimen\pslabelsep
-\def\psset@labelsep#1{\pssetlength\pslabelsep{#1}}
-\psset@labelsep{5pt}
-\def\psset@refangle#1{\pst@expandafter\psset@@refangle{#1}\@nil}
+\define@key[psset]{pstricks}{labelsep}[5pt]{\pssetlength\pslabelsep{#1}}
+\psset[pstricks]{labelsep=5pt}
+\define@key[psset]{pstricks}{refangle}[0]{\pst@expandafter\psset@@refangle{#1}\@nil}
 \def\psset@@refangle#1\@nil{%
-\def\ps@next##1@#1=##2"##3@##4\@nil{%
-\ifx\relax##2%
-\pst@getangle{#1}\psk@refangle
-\def\psk@uputref{}%
-\else
-\def\psk@refangle{##2 }%
-\def\psk@uputref{##3}%
-\fi}%
-\expandafter\ps@next\pst@refangletable @#1=\relax"@\@nil}
+  \def\ps@next##1@#1=##2"##3@##4\@nil{%
+    \ifx\relax##2%
+      \pst@getangle{#1}\psk@refangle
+      \def\psk@uputref{}%
+    \else
+      \def\psk@refangle{##2 }%
+      \def\psk@uputref{##3}%
+    \fi}%
+  \expandafter\ps@next\pst@refangletable @#1=\relax"@\@nil}
+%
 \def\pst@refangletable{%
 @r=0"20%
 @u=90"02%
@@ -3303,7 +3503,8 @@ pop
 @ul=135"12%
 @dr=-135"21%
 @dl=-45"11}
-\psset@refangle{0}
+\psset[pstricks]{refangle=0}
+
 % DG/SR modification begin - Mar. 24, 1999 - Patch 10
 %\def\uput{\def\pst@par{}\@ifnextchar[{\uput@ii}{\uput@i}}
 \def\uput{\def\pst@par{}\pst@ifstar{\@ifnextchar[{\uput@ii}{\uput@i}}} 
@@ -3317,40 +3518,42 @@ pop
   \@ifnextchar({\uput@iv}{\uput@iv(\z@,\z@)}}
 \def\uput@iv(#1){\pst@killglue\pst@makebox{\uput@v{#1}}}
 \def\uput@v#1{%
-  \begingroup
-  \use@par
-  \if@star\pst@starbox\fi
-  \uput@vi
+  \begingroup%
+  \use@par%
+  \if@star\pst@starbox\fi%
+  \uput@vi%
   \psput@{#1}\pst@hbox
-  \endgroup
+  \endgroup%
   \ignorespaces}
 \def\uput@vi{%
   \ifx\psk@uputref\@empty\uput@vii\tx@UUput{}%
-  \else
-    \ifx\psk@rot\@empty\expandafter\uput@viii\psk@uputref
-    \else\uput@vii\tx@UUput{}\fi
+  \else%
+    \ifx\psk@rot\@empty\expandafter\uput@viii\psk@uputref%
+    \else\uput@vii\tx@UUput{}\fi%
   \fi}
 \def\uput@vii#1#2{%
-  \edef\pst@coor{%
+  \edef\pst@coor{
     \pst@number\pslabelsep
     #2%
-    \pst@number{\wd\pst@hbox}%
-    \pst@number{\ht\pst@hbox}%
-    \pst@number{\dp\pst@hbox}%
+    \pst@number{\wd\pst@hbox}
+    \pst@number{\ht\pst@hbox}
+    \pst@number{\dp\pst@hbox}
     \psk@refangle\space \ifx\psk@rot\@empty\else\psk@rot\space sub \fi
     \tx@Uput #1}%
   \setbox\pst@hbox=\hbox to\z@{\hss\vbox to\z@{\vss\box\pst@hbox\vss}\hss}%
-  \setbox\pst@hbox=\psput@special\pst@hbox
+  \setbox\pst@hbox=\psput@special\pst@hbox%
   \ifx\psk@rot\@empty\else\pst@rotate\psk@rot\pst@hbox\fi}
+%
 \def\uput@viii#1#2{%
-  \ifnum#1>\z@\ifnum#2>\z@\pslabelsep=.707\pslabelsep\fi\fi
+  \ifnum#1>\z@\relax\ifnum#2>\z@\relax\pslabelsep=.707\pslabelsep\fi\fi%
   \setbox\pst@hbox=\vbox to\z@{%
-    \ifnum#2=1 \vskip\pslabelsep\else\vss\fi
+    \ifnum#2=1\relax\vskip\pslabelsep\else\vss\fi%
     \hbox to\z@{%
-      \ifnum#1=2 \hskip\pslabelsep\else\hss\fi
-      \box\pst@hbox
-      \ifnum#1=1 \hskip\pslabelsep\else\hss\fi}%
-    \ifnum#2=2 \vskip\pslabelsep\else\vss\fi}}
+      \ifnum#1=2\relax\hskip\pslabelsep\else\hss\fi%
+      \box\pst@hbox%
+      \ifnum#1=1\relax\hskip\pslabelsep\else\hss\fi}%
+    \ifnum#2=2\relax\vskip\pslabelsep\else\vss\fi}}
+%
 \def\tx@Uput{Uput }
 \def\tx@UUput{UUput }
 %
@@ -3388,13 +3591,12 @@ pop
 %
 % ----------- 1.10/12 beg hv -------------------
 \newpsstyle{gridstyle}{subgriddiv=0,gridcolor=lightgray,griddots=10,gridlabels=8pt}
-\newif\ifshowgrid
-\def\psset@showgrid#1{\@nameuse{showgrid#1}}
-\psset@showgrid{false}
+\define@boolkey[psset]{pstricks}[]{showgrid}[true]{}
+\psset[pstricks]{showgrid=false}
 %
 \newdimen\pst@shift
 \newif\ifPst@shift@star
-\def\psset@shift#1{%
+\define@key[psset]{pstricks}{shift}[0]{%
   \ifx#1*
     \global\Pst@shift@startrue
     \pst@shift=\p@
@@ -3403,9 +3605,7 @@ pop
     \pssetlength\pst@dimg{#1}
     \global\pst@shift\pst@dimg%   only the outer pspicture env can have a shift
   \fi}
-%  \global\pst@shift\pst@dimg}
-\psset@shift{0}
-% ----------- 1.10/12 end hv -------------------
+\psset[pstricks]{shift=0}
 %
 %------------------------------- pspicture ------------------------------
 %
@@ -3476,7 +3676,7 @@ pop
   \if@star\setbox\pst@hbox=\hbox{\clipbox@@\z@}\fi%
   \leavevmode\box\pst@hbox%
   \endgroup%
-  \psset@shift{0}% reset value
+  \psset[pstricks]{shift=0}% reset value
 }
 %
 \@namedef{pspicture*}{\pspicture*}
-- 
cgit v1.2.3

