# HG changeset patch # User LYH # Date 1380133322 -28800 # Node ID a0014fa5cf6391d394b7ec8a235f1d19c41a866f # Parent 320daec7af26359cf9b81ada735c82425f570976# Parent b4343603f7ab1a4248e30011273cdb76fb15c07b Merge the official development diff --git a/.hgtags b/.hgtags --- a/.hgtags +++ b/.hgtags @@ -79,3 +79,4 @@ 4e50bd2946d8563d3e201cc04b3ba0720c991b06 ss-3-7-4 608e307b49149b32a6d09c2f06493d04d3af9be4 ss-3-7-5 3a9efb68272df556dccb84c87933dd8238e88902 ss-3-7-6 +cc13924a4266fb0359f59fabdce11071e6051d48 ss-3-7-7 diff --git a/configure.ac b/configure.ac --- a/configure.ac +++ b/configure.ac @@ -19,13 +19,13 @@ ### . AC_PREREQ([2.62]) -AC_INIT([GNU Octave], [3.7.6+], [http://octave.org/bugs.html], [octave]) +AC_INIT([GNU Octave], [3.7.7+], [http://octave.org/bugs.html], [octave]) dnl PACKAGE_VERSION is set by the AC_INIT VERSION arg OCTAVE_VERSION="$PACKAGE_VERSION" OCTAVE_API_VERSION_NUMBER="48" OCTAVE_API_VERSION="api-v$OCTAVE_API_VERSION_NUMBER+" -OCTAVE_RELEASE_DATE="2013-08-20" +OCTAVE_RELEASE_DATE="2013-09-23" OCTAVE_COPYRIGHT="Copyright (C) 2013 John W. Eaton and others." AC_SUBST(OCTAVE_VERSION) AC_SUBST(OCTAVE_API_VERSION_NUMBER) diff --git a/doc/interpreter/contributors.in b/doc/interpreter/contributors.in --- a/doc/interpreter/contributors.in +++ b/doc/interpreter/contributors.in @@ -224,6 +224,7 @@ Joshua Redstone Lukas Reichlin Michael Reifenberger +Jens Restemeier Anthony Richardson Jason Riedy E. Joshua Rigler diff --git a/doc/interpreter/plot.txi b/doc/interpreter/plot.txi --- a/doc/interpreter/plot.txi +++ b/doc/interpreter/plot.txi @@ -406,7 +406,7 @@ @subsubsection Aspect Ratio For three-dimensional plots the aspect ratio can be set for data with -@code{daspect} and for the plot box with @code{pbaspect}. +@code{daspect} and for the plot box with @code{pbaspect}. @xref{Axis Configuration}, for controlling the x-, y-, and z-limits for plotting. @@ -597,7 +597,7 @@ The @qcode{"tex"} option implements a subset of @TeX{} functionality in the rendering of the text. This allows the insertion of special characters such as Greek or mathematical symbols within the text. The special -characters are also inserted with a code starting with the back-slash +characters are also inserted with a code starting with the backslash (\) character, as in the table @ref{tab:extended}. In addition, the formatting of the text can be changed within the string @@ -639,169 +639,233 @@ @float Table,tab:extended @tex \vskip 6pt -{\hbox to \hsize {\hfill\vbox{\offinterlineskip \tabskip=0pt +\def\symtable#1#2#3{\hbox to \hsize {\hfill\vbox{\offinterlineskip \tabskip=0pt +\hskip36pt #1 +\vskip6pt \halign{ -\vrule height2.0ex depth1.ex width 0.6pt #\tabskip=0.3em & -# \hfil & \vrule # & # \hfil & # \vrule & -# \hfil & \vrule # & # \hfil & # \vrule & -# \hfil & \vrule # & # \hfil & # \vrule +\vrule height2.0ex depth1.ex width 0.6pt #2\tabskip=0.3em & +#2 \hfil & \vrule #2 & #2 \hfil & #2 \vrule & +#2 \hfil & \vrule #2 & #2 \hfil & #2 \vrule & +#2 \hfil & \vrule #2 & #2 \hfil & #2 \vrule width 0.6pt \tabskip=0pt\cr \noalign{\hrule height 0.6pt} & Code && Sym && Code && Sym && Code && Sym &\cr \noalign{\hrule} -& $\backslash$forall && $\forall$ -&& $\backslash$exists && $\exists$ -&& $\backslash$ni && $\ni$ &\cr -& $\backslash$cong && $\cong$ -&& $\backslash$Delta && $\Delta$ -&& $\backslash$Phi && $\Phi$ &\cr -& $\backslash$Gamma && $\Gamma$ -&& $\backslash$vartheta && $\vartheta$ -&& $\backslash$Lambda && $\Lambda$ &\cr -& $\backslash$Pi && $\Pi$ -&& $\backslash$Theta && $\Theta$ -&& $\backslash$Sigma && $\Sigma$ &\cr -& $\backslash$varsigma && $\varsigma$ -&& $\backslash$Omega && $\Omega$ -&& $\backslash$Xi && $\Xi$ &\cr -& $\backslash$Psi && $\Psi$ -&& $\backslash$perp && $\perp$ -&& $\backslash$alpha && $\alpha$ &\cr -& $\backslash$beta && $\beta$ -&& $\backslash$chi && $\chi$ -&& $\backslash$delta && $\delta$ &\cr -& $\backslash$epsilon && $\epsilon$ -&& $\backslash$phi && $\phi$ -&& $\backslash$gamma && $\gamma$ &\cr -& $\backslash$eta && $\eta$ -&& $\backslash$iota && $\iota$ -&& $\backslash$varphi && $\varphi$ &\cr -& $\backslash$kappa && $\kappa$ -&& $\backslash$lambda && $\lambda$ -&& $\backslash$mu && $\mu$ &\cr -& $\backslash$nu && $\nu$ -&& $\backslash$o && $\o$ -&& $\backslash$pi && $\pi$ &\cr -& $\backslash$theta && $\theta$ -&& $\backslash$rho && $\rho$ -&& $\backslash$sigma && $\sigma$ &\cr -& $\backslash$tau && $\tau$ -&& $\backslash$upsilon && $\upsilon$ -&& $\backslash$varpi && $\varpi$ &\cr -& $\backslash$omega && $\omega$ -&& $\backslash$xi && $\xi$ -&& $\backslash$psi && $\psi$ &\cr -& $\backslash$zeta && $\zeta$ -&& $\backslash$sim && $\sim$ -&& $\backslash$Upsilon && $\Upsilon$ &\cr -& $\backslash$prime && $\prime$ -&& $\backslash$leq && $\leq$ -&& $\backslash$infty && $\infty$ &\cr -& $\backslash$clubsuit && $\clubsuit$ -&& $\backslash$diamondsuit && $\diamondsuit$ -&& $\backslash$heartsuit && $\heartsuit$ &\cr -& $\backslash$spadesuit && $\spadesuit$ -&& $\backslash$leftrightarrow && $\leftrightarrow$ -&& $\backslash$leftarrow && $\leftarrow$ &\cr -& $\backslash$uparrow && $\uparrow$ -&& $\backslash$rightarrow && $\rightarrow$ -&& $\backslash$downarrow && $\downarrow$ &\cr -& $\backslash$circ && $\circ$ -&& $\backslash$pm && $\pm$ -&& $\backslash$geq && $\geq$ &\cr -& $\backslash$times && $\times$ -&& $\backslash$propto && $\propto$ -&& $\backslash$partial && $\partial$ &\cr -& $\backslash$bullet && $\bullet$ -&& $\backslash$div && $\div$ -&& $\backslash$neq && $\neq$ &\cr -& $\backslash$equiv && $\equiv$ -&& $\backslash$approx && $\approx$ -&& $\backslash$ldots && $\ldots$ &\cr -& $\backslash$mid && $\mid$ -&& $\backslash$aleph && $\aleph$ -&& $\backslash$Im && $\Im$ &\cr -& $\backslash$Re && $\Re$ -&& $\backslash$wp && $\wp$ -&& $\backslash$otimes && $\otimes$ &\cr -& $\backslash$oplus && $\oplus$ -&& $\backslash$oslash && $\oslash$ -&& $\backslash$cap && $\cap$ &\cr -& $\backslash$cup && $\cup$ -&& $\backslash$supset && $\supset$ -&& $\backslash$supseteq && $\supseteq$ &\cr -& $\backslash$subset && $\subset$ -&& $\backslash$subseteq && $\subseteq$ -&& $\backslash$in && $\in$ &\cr -& $\backslash$notin && $\notin$ -&& $\backslash$angle && $\angle$ -&& $\backslash$bigtriangledown && $\bigtriangledown$ &\cr -& $\backslash$langle && $\langle$ -&& $\backslash$rangle && $\rangle$ -&& $\backslash$nabla && $\nabla$ &\cr -& $\backslash$prod && $\prod$ -&& $\backslash$surd && $\surd$ -&& $\backslash$cdot && $\cdot$ &\cr -& $\backslash$neg && $\neg$ -&& $\backslash$wedge && $\wedge$ -&& $\backslash$vee && $\vee$ &\cr -& $\backslash$Leftrightarrow && $\Leftrightarrow$ -&& $\backslash$Leftarrow && $\Leftarrow$ -&& $\backslash$Uparrow && $\Uparrow$ &\cr -& $\backslash$Rightarrow && $\Rightarrow$ -&& $\backslash$Downarrow && $\Downarrow$ -&& $\backslash$diamond && $\diamond$ &\cr -& $\backslash$copyright && $\copyright$ -&& $\backslash$rfloor && $\rfloor$ -&& $\backslash$lceil && $\lceil$ &\cr -& $\backslash$lfloor && $\lfloor$ -&& $\backslash$rceil && $\rceil$ -&& $\backslash$int && $\int$ &\cr +#3 \noalign{\hrule height 0.6pt} -}}\hfill}} +} +}\hfill}} +\symtable{Greek Lowercase Letters} {#} +{& $\backslash$alpha && $\alpha$ +&& $\backslash$beta && $\beta$ +&& $\backslash$gamma && $\gamma$ &\cr +& $\backslash$delta && $\delta$ +&& $\backslash$epsilon && $\epsilon$ +&& $\backslash$zeta && $\zeta$ &\cr +& $\backslash$eta && $\eta$ +&& $\backslash$theta && $\theta$ +&& $\backslash$vartheta && $\vartheta$ &\cr +& $\backslash$iota && $\iota$ +&& $\backslash$kappa && $\kappa$ +&& $\backslash$lambda && $\lambda$ &\cr +& $\backslash$mu && $\mu$ +&& $\backslash$nu && $\nu$ +&& $\backslash$xi && $\xi$ &\cr +& $\backslash$o && $o$ +&& $\backslash$pi && $\pi$ +&& $\backslash$varpi && $\varpi$ &\cr +& $\backslash$rho && $\rho$ +&& $\backslash$sigma && $\sigma$ +&& $\backslash$varsigma && $\varsigma$ &\cr +& $\backslash$tau && $\tau$ +&& $\backslash$upsilon && $\upsilon$ +&& $\backslash$phi && $\phi$ &\cr +& $\backslash$chi && $\chi$ +&& $\backslash$psi && $\psi$ +&& $\backslash$omega && $\omega$ &\cr} +\vskip12pt +\symtable{Greek Uppercase Letters} {#} +{& $\backslash$Gamma && $\Gamma$ +&& $\backslash$Delta && $\Delta$ +&& $\backslash$Theta && $\Theta$ &\cr +& $\backslash$Lambda && $\Lambda$ +&& $\backslash$Xi && $\Xi$ +&& $\backslash$Pi && $\Pi$ &\cr +& $\backslash$Sigma && $\Sigma$ +&& $\backslash$Upsilon && $\Upsilon$ +&& $\backslash$Phi && $\Phi$ &\cr +& $\backslash$Psi && $\Psi$ +&& $\backslash$Omega && $\Omega$ +&& && &\cr} +\vskip12pt +\symtable{Misc Symbols Type Ord} {#} +{& $\backslash$aleph && $\aleph$ +&& $\backslash$wp && $\wp$ +&& $\backslash$Re && $\Re$ &\cr +& $\backslash$Im && $\Im$ +&& $\backslash$partial && $\partial$ +&& $\backslash$infty && $\infty$ &\cr +& $\backslash$prime && $\prime$ +&& $\backslash$nabla && $\nabla$ +&& $\backslash$surd && $\surd$ &\cr +& $\backslash$angle && $\angle$ +&& $\backslash$forall && $\forall$ +&& $\backslash$exists && $\exists$ &\cr +& $\backslash$neg && $\neg$ +&& $\backslash$clubsuit && $\clubsuit$ +&& $\backslash$diamondsuit && $\diamondsuit$ &\cr +& $\backslash$heartsuit && $\heartsuit$ +&& $\backslash$spadesuit && $\spadesuit$ +&& && &\cr} +\vskip12pt +\symtable{``Large'' Operators} {#} +{& $\backslash$int && $\int$ +&& && +&& && &\cr} +\vskip12pt +\symtable{Binary operators} {#} +{& $\backslash$pm && $\pm$ +&& $\backslash$cdot && $\cdot$ +&& $\backslash$times && $\times$ &\cr +& $\backslash$ast && $\ast$ +&& $\backslash$circ && $\circ$ +&& $\backslash$bullet && $\bullet$ &\cr +& $\backslash$div && $\div$ +&& $\backslash$cap && $\cap$ +&& $\backslash$cup && $\cup$ &\cr +& $\backslash$vee && $\vee$ +&& $\backslash$wedge && $\wedge$ +&& $\backslash$oplus && $\oplus$ &\cr +& $\backslash$otimes && $\otimes$ +&& $\backslash$oslash && $\oslash$ +&& && &\cr} @end tex @ifnottex -@multitable @columnfractions .125 .25 .25 .25 .125 -@item @tab \forall @tab \exists @tab \ni @tab -@item @tab \cong @tab \Delta @tab \Phi @tab -@item @tab \Gamma @tab \vartheta @tab \Lambda @tab -@item @tab \Pi @tab \Theta @tab \Sigma @tab -@item @tab \varsigma @tab \Omega @tab \Xi @tab -@item @tab \Psi @tab \perp @tab \alpha @tab -@item @tab \beta @tab \chi @tab \delta @tab -@item @tab \epsilon @tab \phi @tab \gamma @tab -@item @tab \eta @tab \iota @tab \varphi @tab -@item @tab \kappa @tab \lambda @tab \mu @tab -@item @tab \nu @tab \o @tab \pi @tab -@item @tab \theta @tab \rho @tab \sigma @tab -@item @tab \tau @tab \upsilon @tab \varpi @tab -@item @tab \omega @tab \xi @tab \psi @tab -@item @tab \zeta @tab \sim @tab \Upsilon @tab -@item @tab \prime @tab \leq @tab \infty @tab -@item @tab \clubsuit @tab \diamondsuit @tab \heartsuit @tab -@item @tab \spadesuit @tab \leftrightarrow @tab \leftarrow @tab -@item @tab \uparrow @tab \rightarrow @tab \downarrow @tab -@item @tab \circ @tab \pm @tab \geq @tab -@item @tab \times @tab \propto @tab \partial @tab -@item @tab \bullet @tab \div @tab \neq @tab -@item @tab \equiv @tab \approx @tab \ldots @tab -@item @tab \mid @tab \aleph @tab \Im @tab -@item @tab \Re @tab \wp @tab \otimes @tab -@item @tab \oplus @tab \oslash @tab \cap @tab -@item @tab \cup @tab \supset @tab \supseteq @tab -@item @tab \subset @tab \subseteq @tab \in @tab -@item @tab \notin @tab \angle @tab \bigrightriangledown @tab -@item @tab \langle @tab \rangle @tab \nabla @tab -@item @tab \prod @tab \surd @tab \cdot @tab -@item @tab \neg @tab \wedge @tab \vee @tab -@item @tab \Leftrightarrow @tab \Leftarrow @tab \Uparrow @tab -@item @tab \Rightarrow @tab \Downarrow @tab \diamond @tab -@item @tab \copyright @tab \lfloor @tab \lceil @tab -@item @tab \rfloor @tab \rceil @tab \int @tab +@multitable @columnfractions .25 .25 .25 .25 +@item Greek Lowercase Letters +@item @tab \alpha @tab \beta @tab \gamma +@item @tab \delta @tab \epsilon @tab \zeta +@item @tab \eta @tab \theta @tab \vartheta +@item @tab \iota @tab \kappa @tab \lambda +@item @tab \mu @tab \nu @tab \xi +@item @tab \o @tab \pi @tab \varpi +@item @tab \rho @tab \sigma @tab \varsigma +@item @tab \tau @tab \upsilon @tab \phi +@item @tab \chi @tab \psi @tab \omega +@item Greek Uppercase Letters +@item @tab \Gamma @tab \Delta @tab \Theta +@item @tab \Lambda @tab \Xi @tab \Pi +@item @tab \Sigma @tab \Upsilon @tab \Phi +@item @tab \Psi @tab \Omega @tab +@item Misc Symbols Type Ord +@item @tab \aleph @tab \wp @tab \Re +@item @tab \Im @tab \partial @tab \infty +@item @tab \prime @tab \nabla @tab \surd +@item @tab \angle @tab \forall @tab \exists +@item @tab \neg @tab \clubsuit @tab \diamondsuit +@item @tab \heartsuit @tab \spadesuit @tab +@item ``Large'' Operators +@item @tab \int +@item Binary Operators +@item @tab \pm @tab \cdot @tab \times +@item @tab \ast @tab \circ @tab \bullet +@item @tab \div @tab \cap @tab \cup +@item @tab \vee @tab \wedge @tab \oplus +@item @tab \otimes @tab \oslash @tab +@item Relations +@item @tab \leq @tab \subset @tab \subseteq +@item @tab \in @tab \geq @tab \supset +@item @tab \supseteq @tab \ni @tab \mid +@item @tab \equiv @tab \sim @tab \approx +@item @tab \cong @tab \propto @tab \perp +@item Arrows +@item @tab \leftarrow @tab \Leftarrow @tab \rightarrow +@item @tab \Rightarrow @tab \leftrightarrow @tab \uparrow +@item @tab \downarrow @tab @tab +@item Openings and Closings +@item @tab \lfloor @tab \langle @tab \lceil +@item @tab \rfloor @tab \rangle @tab \rceil +@item Alternate Names +@item @tab \neq +@item Other +@item @tab \ldots @tab \0 @tab \copyright +@item @tab \deg @end multitable @end ifnottex @caption{Available special characters in @TeX{} mode} @end float +@float +@tex +\vskip 6pt +\def\symtable#1#2#3{\hbox to \hsize {\hfill\vbox{\offinterlineskip \tabskip=0pt +\hskip36pt #1 +\vskip6pt +\halign{ +\vrule height2.0ex depth1.ex width 0.6pt #2\tabskip=0.3em & +#2 \hfil & \vrule #2 & #2 \hfil & #2 \vrule & +#2 \hfil & \vrule #2 & #2 \hfil & #2 \vrule & +#2 \hfil & \vrule #2 & #2 \hfil & #2 \vrule +width 0.6pt \tabskip=0pt\cr +\noalign{\hrule height 0.6pt} +& Code && Sym && Code && Sym && Code && Sym &\cr +\noalign{\hrule} +#3 +\noalign{\hrule height 0.6pt} +} +}\hfill}} +\vskip6pt +\symtable{Relations} {#} +{& $\backslash$leq && $\leq$ +&& $\backslash$subset && $\subset$ +&& $\backslash$subseteq && $\subseteq$ &\cr +& $\backslash$in && $\in$ +&& $\backslash$geq && $\geq$ +&& $\backslash$supset && $\supset$ &\cr +& $\backslash$supseteq && $\supseteq$ +&& $\backslash$ni && $\ni$ +&& $\backslash$mid && $\mid$ &\cr +& $\backslash$equiv && $\equiv$ +&& $\backslash$sim && $\sim$ +&& $\backslash$approx && $\approx$ &\cr +& $\backslash$cong && $\cong$ +&& $\backslash$propto && $\propto$ +&& $\backslash$perp && $\perp$ &\cr} +\vskip6pt +\symtable{Arrows} {#} +{& $\backslash$leftarrow && $\leftarrow$ +&& $\backslash$Leftarrow && $\Leftarrow$ +&& $\backslash$rightarrow && $\rightarrow$ &\cr +& $\backslash$Rightarrow && $\Rightarrow$ +&& $\backslash$leftrightarrow && $\leftrightarrow$ +&& $\backslash$uparrow && $\uparrow$ &\cr +& $\backslash$downarrow && $\downarrow$ +&& && +&& && &\cr} +\vskip12pt +\symtable{Openings and Closings} {#} +{& $\backslash$lfloor && $\lfloor$ +&& $\backslash$langle && $\langle$ +&& $\backslash$lceil && $\lceil$ &\cr +& $\backslash$rfloor && $\rfloor$ +&& $\backslash$rangle && $\rangle$ +&& $\backslash$rceil && $\rceil$ &\cr} +\vskip12pt +\symtable{Alternate Names} {#} +{& $\backslash$neq && $\neq$ +&& && +&& && &\cr} +\vskip12pt +\symtable{Other (not in Appendix F Tables)} {#} +{& $\backslash$ldots && $\ldots$ +&& $\backslash$0 && $\oslash$ +&& $\backslash$copyright && $\copyright$ &\cr +& $\backslash$deg && $\deg$ +&& && +&& && &\cr} +\vskip12pt +\hskip36pt Table 15.1: Available special characters in \TeX\ mode (cont.) +@end tex +@end float A complete example showing the capabilities of the extended text is @@ -936,8 +1000,8 @@ Graphics handles may be distinguished from function handles (@pxref{Function Handles}) by means of the function @code{ishandle}. -@code{ishandle} returns true if its argument is a handle of a graphics object. -In addition, the figure object may be tested using @code{isfigure}. +@code{ishandle} returns true if its argument is a handle of a graphics object. +In addition, the figure object may be tested using @code{isfigure}. @code{isfigure} returns true only if its argument is a handle of a figure. The @code{whos} function can be used to show the object type of each currently defined graphics handle. (Note: this is not true today, but it is, I hope, @@ -1180,9 +1244,9 @@ Figures can be printed or saved in many graphics formats with @code{print} and @code{saveas}. Occasionally, however, it may be useful to save the original Octave handle graphic directly so that further modifications can be made such -as modifying a title or legend. - -This can be accomplished with the following functions by +as modifying a title or legend. + +This can be accomplished with the following functions by @example @group @@ -1226,12 +1290,12 @@ The @code{root figure} properties are: @table @code -@item __modified__ +@item __modified__ --- Values: @qcode{"on"}, @qcode{"off"} @item __myhandle__ -@item beingdeleted +@item beingdeleted --- Values: @qcode{"on"}, @qcode{"off"} @item busyaction @@ -1251,13 +1315,13 @@ @item deletefcn -@item handlevisibility +@item handlevisibility --- Values: @qcode{"on"}, @qcode{"off"} @item hittest --- Values: @qcode{"on"}, @qcode{"off"} -@item interruptible +@item interruptible --- Values: @qcode{"on"}, @qcode{"off"} @item parent @@ -1276,7 +1340,7 @@ @item screenpixelsperinch -@item showhiddenhandles +@item showhiddenhandles --- Values: @qcode{"on"}, @qcode{"off"} @item tag @@ -1299,7 +1363,7 @@ The @code{figure} properties are: @table @code -@item __graphics_toolkit__ +@item __graphics_toolkit__ --- The graphics toolkit currently in use. @item __enhanced__ @@ -1312,7 +1376,7 @@ @item alphamap -@item beingdeleted +@item beingdeleted --- Values: @qcode{"on"}, @qcode{"off"} @item busyaction @@ -1325,7 +1389,7 @@ @item clipping --- Values: @qcode{"on"}, @qcode{"off"} -@item closerequestfcn +@item closerequestfcn --- Handle of function to call on close. @item color @@ -1337,7 +1401,7 @@ @item createfcn -@item currentaxes +@item currentaxes Handle to graphics object of current axes. @item currentcharacter @@ -1352,22 +1416,22 @@ @item deletefcn -@item dockcontrols +@item dockcontrols --- Values: @qcode{"on"}, @qcode{"off"} -@item doublebuffer +@item doublebuffer --- Values: @qcode{"on"}, @qcode{"off"} @item filename -@item handlevisibility +@item handlevisibility --- Values: @qcode{"on"}, @qcode{"off"} @item hittest @item integerhandle -@item interruptible +@item interruptible --- Values: @qcode{"on"}, @qcode{"off"} @item inverthardcopy @@ -1448,7 +1512,7 @@ @item selected -@item selectionhighlight +@item selectionhighlight --- Values: @qcode{"on"}, @qcode{"off"} @item selectiontype @@ -1516,7 +1580,7 @@ @item beingdeleted @item box -Box surrounding axes. +Box surrounding axes. --- Values: @qcode{"on"}, @qcode{"off"} @item busyaction @@ -1572,7 +1636,7 @@ @code{dataaspectratio} also forces the @code{dataaspectratiomode} property to be set to @qcode{"manual"}. -@item dataaspectratiomode +@item dataaspectratiomode Either @qcode{"manual"} or @qcode{"auto"}. @item deletefcn @@ -1685,7 +1749,7 @@ @item x_viewtransform -@item xaxislocation +@item xaxislocation Either @qcode{"top"} or @qcode{"bottom"}. @item xcolor @@ -1707,7 +1771,7 @@ @item xlimmode Either @qcode{"manual"} or @qcode{"auto"}. -@item xminorgrid +@item xminorgrid Either @qcode{"on"} or @qcode{"off"} to toggle display of minor grid lines. @item xminortick @@ -1724,13 +1788,13 @@ Setting this property also forces the corresponding mode property to be set to @qcode{"manual"}. -@item xticklabelmode +@item xticklabelmode Either @qcode{"manual"} or @qcode{"auto"}. -@item xtickmode +@item xtickmode Either @qcode{"manual"} or @qcode{"auto"}. -@item yaxislocation +@item yaxislocation Either @qcode{"left"} or @qcode{"right"} @item ycolor @@ -1752,7 +1816,7 @@ @item ylimmode Either @qcode{"manual"} or @qcode{"auto"}. -@item yminorgrid +@item yminorgrid Either @qcode{"on"} or @qcode{"off"} to toggle display of minor grid lines. @item yminortick @@ -1769,10 +1833,10 @@ Setting this property also forces the corresponding mode property to be set to @qcode{"manual"}. -@item yticklabelmode +@item yticklabelmode Either @qcode{"manual"} or @qcode{"auto"}. -@item ytickmode +@item ytickmode Either @qcode{"manual"} or @qcode{"auto"}. @item zcolor @@ -1794,7 +1858,7 @@ @item zlimmode Either @qcode{"manual"} or @qcode{"auto"}. -@item zminorgrid +@item zminorgrid Either @qcode{"on"} or @qcode{"off"} to toggle display of minor grid lines. @item zminortick @@ -1807,11 +1871,11 @@ Setting this property also forces the corresponding mode property to be set to @qcode{"manual"}. -@item zticklabel +@item zticklabel Setting this property also forces the corresponding mode property to be set to @qcode{"manual"}. -@item zticklabelmode +@item zticklabelmode Either @qcode{"manual"} or @qcode{"auto"}. @item ztickmode @@ -2876,7 +2940,7 @@ @item edgecolor @itemx facecolor -The line and fill color of the patch objects making up the areas. +The line and fill color of the patch objects making up the areas. @xref{Colors}. @item xdata @@ -3035,7 +3099,7 @@ @table @code @item color -The RGB color or color name of the line objects of the error bars. +The RGB color or color name of the line objects of the error bars. @xref{Colors}. @item linewidth @@ -3294,7 +3358,7 @@ @item edgecolor @item facecolor -The RGB color or color name of the edges or faces of the surface. +The RGB color or color name of the edges or faces of the surface. @xref{Colors}. @item linewidth diff --git a/libgui/languages/es_ES.ts b/libgui/languages/es_ES.ts --- a/libgui/languages/es_ES.ts +++ b/libgui/languages/es_ES.ts @@ -41,6 +41,52 @@ persistent persistente + + + foreground + primer plano + + + + background + plano de fondo + + + + selection + selección + + + + cursor + cursor + + + + QTerminal + + + Copy + Copiar + + + + Paste + Pegar + + + + Clear All + Limpiar todo + + + + QWinTerminalImpl + + + copied selection to clipboard + selección copiada al portapapeles + documentation_dock_widget @@ -58,19 +104,19 @@ file_editor - + Octave Editor Editor de Octave - + Octave Files (*.m);;All Files (*) Archivos de Octave (*.m);;Todos los archivos (*) - + Could not open file %1 for read: %2. No se ha podido abrir el archivo %1 para su lectura:\n%2. @@ -93,7 +139,7 @@ &%1 %2 - + &New File Archivo &nuevo @@ -108,12 +154,12 @@ &Guardar archivo - + Save File &As Guardar archivo &como - + Print Imprimir @@ -143,17 +189,17 @@ Pegar - + &Next Bookmark &Marcador siguiente - + Pre&vious Bookmark Marcador &anterior - + Toggle &Bookmark &Alternar marcadores @@ -193,27 +239,27 @@ &Eliminar comentario - + &Recent Editor Files Archivos &recientes - + &Close C&errar - + Close All Cerrar todo - + Close Other Files Cerrar otros archivos - + &Find and Replace &Buscar y reemplazar @@ -228,12 +274,12 @@ &Ir a línea - + &File &Archivo - + &Edit &Editar @@ -278,14 +324,14 @@ - + Octave Editor Editor de Octave - + The file %1 is about to be closed but has been modified. @@ -293,7 +339,7 @@ El archivo\n%1\n está a punto de ser cerrado pero ha sido modificado.\n%2 - + Octave Files (*.m);;All Files (*) Archivos de Octave(*.m);;Todos los archivos(*) @@ -319,13 +365,13 @@ Al parecer el archivo\n%1\n ha sido eliminado o renombrado.¿Desea guardarlo ahora?%2 - + Could not open file %1 for write: %2. No se ha podido abrir el archivo %1 para escritura:\n%2. - + It seems that '%1' has been modified by another application. Do you want to reload it? Al parecer el archivo \'%1\' ha sido modificado por otra aplicación. ¿Desea recargarlo? @@ -485,12 +531,12 @@ No se puede eliminar un directorio que no esté vacio - + Set directory of file browser Fijar directorio de explorador de archivos - + Create File Crear archivo @@ -585,7 +631,7 @@ Buscar se&lección - + Search from end Buscar desde el final @@ -708,12 +754,12 @@ Establecer distinción entre mayúsculas y minúsculas en el texto - + Search results Resultados de la búsqueda - + Idle. Inactivo. @@ -748,7 +794,7 @@ Contenido del archivo - + Searching... Buscando... @@ -761,7 +807,7 @@ find_files_model - + Filename Nombre de archivo @@ -774,7 +820,7 @@ history_dock_widget - + Browse and search the command history. Explorar y buscar en el historial de comandos. @@ -813,23 +859,23 @@ main_window - + Load Workspace Cargar espacio de trabajo - - + + About Octave Acerca de Octave - + &File &Archivo - + New Nuevo @@ -840,7 +886,7 @@ Guión - + Function Función @@ -850,12 +896,12 @@ Figura - + Open... Abrir... - + Preferences... Preferencias... @@ -865,7 +911,7 @@ Salir - + &Edit &Editar @@ -880,28 +926,33 @@ Copiar - + Paste Pegar - - + + Save Workspace As Guardar espacio de trabajo como - + Set working directory Fijar directorio de trabajo - + + Clear Clipboard + Limpiar el Portapapeles + + + Find Files... Buscar archivos... - + Clear Command Window Limpiar ventana de comandos @@ -916,7 +967,7 @@ Limpiar espacio de trabajo - + De&bug &Depurar @@ -991,12 +1042,12 @@ Explorar directorios - + Load workspace Cargar espacio de trabajo - + &Window &Ventana @@ -1076,18 +1127,19 @@ octave_dock_widget + Undock widget Uso "widget" por ser el término usual: http://es.wikipedia.org/wiki/Widget Desacoplar widget - + Hide widget Uso "widget" por ser el término usual: http://es.wikipedia.org/wiki/Widget Ocultar widget - + Dock widget Uso "widget" por ser el término usual: http://es.wikipedia.org/wiki/Widget Acoplar widget @@ -1274,12 +1326,12 @@ Colores de la terminal - + Font Tipo de fuente - + Show line numbers Mostrar numeros de línea @@ -1319,7 +1371,7 @@ Cursor parpadeante - + Font size Tamaño de fuente @@ -1389,7 +1441,7 @@ HttpProxy - + Icon set for dock widgets Íconos para widget acoplados @@ -1404,7 +1456,7 @@ Tamaño de ícono - + Socks5Proxy "Socks5Proxy" @@ -1436,7 +1488,22 @@ Configuración del sistema - + + IBeam Cursor + cursor IBeam + + + + Block Cursor + cursor de bloque + + + + Underline Cursor + cursor subrayado + + + Difference to the default size Diferencia con el tamaño predeterminado @@ -1472,7 +1539,7 @@ webinfo - + Type here and press 'Return' to search Escriba aquí y pulse la tecla de 'Retorno' para buscar diff --git a/libinterp/corefcn/graphics.cc b/libinterp/corefcn/graphics.cc --- a/libinterp/corefcn/graphics.cc +++ b/libinterp/corefcn/graphics.cc @@ -9787,6 +9787,7 @@ @end group\n\ @end example\n\ \n\ +@seealso{addproperty, hggroup}\n\ @end deftypefn") { gh_manager::auto_lock guard; @@ -9979,6 +9980,7 @@ @end group\n\ @end example\n\ \n\ +@seealso{addlistener, hggroup}\n\ @end deftypefn") { gh_manager::auto_lock guard; @@ -10207,11 +10209,12 @@ @deftypefnx {Built-in Function} {} waitfor (@var{h}, @var{prop}, @var{value})\n\ @deftypefnx {Built-in Function} {} waitfor (@dots{}, \"timeout\", @var{timeout})\n\ Suspend the execution of the current program until a condition is\n\ -satisfied on the graphics handle @var{h}. While the program is suspended\n\ -graphics events are still being processed normally, allowing callbacks to\n\ -modify the state of graphics objects. This function is reentrant and can be\n\ -called from a callback, while another @code{waitfor} call is pending at\n\ -top-level.\n\ +satisfied on the graphics handle @var{h}.\n\ +\n\ +While the program is suspended graphics events are still being processed\n\ +normally, allowing callbacks to modify the state of graphics objects. This\n\ +function is reentrant and can be called from a callback, while another\n\ +@code{waitfor} call is pending at the top-level.\n\ \n\ In the first form, program execution is suspended until the graphics object\n\ @var{h} is destroyed. If the graphics handle is invalid, the function\n\ @@ -10238,7 +10241,7 @@ @code{\\timeout} instead.\n\ \n\ In all cases, typing CTRL-C stops program execution immediately.\n\ -@seealso{isequal}\n\ +@seealso{waitforbuttonpress, isequal}\n\ @end deftypefn") { if (args.length () > 0) @@ -10406,7 +10409,7 @@ // FIXME: There is still a "hole" in the following loop. The code // assumes that an object handle is unique, which is a fair - // assumptions, except for figures. If a figure is destroyed + // assumption, except for figures. If a figure is destroyed // then recreated with the same figure ID, within the same // run of event hooks, then the figure destruction won't be // caught and the loop will not stop. This is an unlikely diff --git a/libinterp/corefcn/oct-stream.cc b/libinterp/corefcn/oct-stream.cc --- a/libinterp/corefcn/oct-stream.cc +++ b/libinterp/corefcn/oct-stream.cc @@ -2980,21 +2980,47 @@ { SRC_T *data = static_cast (*it); - for (octave_idx_type i = 0; i < input_buf_elts && j < elts_read; i++, j++) + if (swap || do_float_fmt_conv) { - if (swap) - swap_bytes (&data[i]); - else if (do_float_fmt_conv) - do_float_format_conversion (&data[i], sizeof (SRC_T), - 1, from_flt_fmt, - oct_mach_info::float_format ()); - - dst_elt_type tmp (data[i]); - - if (do_NA_conv && __lo_ieee_is_old_NA (tmp)) - tmp = __lo_ieee_replace_old_NA (tmp); - - conv_data[j] = tmp; + for (octave_idx_type i = 0; i < input_buf_elts && j < elts_read; + i++, j++) + { + if (swap) + swap_bytes (&data[i]); + else if (do_float_fmt_conv) + do_float_format_conversion (&data[i], sizeof (SRC_T), + 1, from_flt_fmt, + oct_mach_info::float_format ()); + + dst_elt_type tmp (data[i]); + + if (do_NA_conv && __lo_ieee_is_old_NA (tmp)) + tmp = __lo_ieee_replace_old_NA (tmp); + + conv_data[j] = tmp; + } + } + else + { + if (do_NA_conv) + { + for (octave_idx_type i = 0; i < input_buf_elts && j < elts_read; + i++, j++) + { + dst_elt_type tmp (data[i]); + + if (__lo_ieee_is_old_NA (tmp)) + tmp = __lo_ieee_replace_old_NA (tmp); + + conv_data[j] = tmp; + } + } + else + { + for (octave_idx_type i = 0; i < input_buf_elts && j < elts_read; + i++, j++) + conv_data[j] = data[i]; + } } delete [] data; @@ -3017,7 +3043,6 @@ #define TABLE_ELT(T, U, V, W) \ conv_fptr_table[oct_data_conv::T][oct_data_conv::U] = convert_and_copy -#undef FILL_TABLE_ROW #define FILL_TABLE_ROW(T, V) \ TABLE_ELT (T, dt_int8, V, int8NDArray); \ TABLE_ELT (T, dt_uint8, V, uint8NDArray); \ diff --git a/libinterp/corefcn/oct-tex-symbols.in b/libinterp/corefcn/oct-tex-symbols.in --- a/libinterp/corefcn/oct-tex-symbols.in +++ b/libinterp/corefcn/oct-tex-symbols.in @@ -3,10 +3,12 @@ # - symbol name # - Unicode code # - MS symbol code (http://www.kostis.net/charsets/symbol.htm) +# - Arranged by listings in The TeXbook, Appendix F +# - Lowercase Greek letters: Greek Upper case: Misc Symbols type Ord: "Large" operators: +# - Binary operators: Relations: Negated relations: Arrows: Openings: Closings: Alternate names: +# - Other (not in Appendix F Tables): alpha 0x03B1 0xF061 -angle 0x2220 0xF0D0 -ast 0x2217 0xF02A beta 0x03B2 0xF062 gamma 0x03B3 0xF067 delta 0x03B4 0xF064 @@ -21,25 +23,13 @@ mu 0x03BC 0xF06D nu 0x03BD 0xF06E xi 0x03BE 0xF078 +o 0x03BF 0xF0B0 pi 0x03C0 0xF070 +varpi 0x03D6 0xF076 rho 0x03C1 0xF072 sigma 0x03C3 0xF073 varsigma 0x03C2 0xF056 tau 0x03C4 0xF074 -equiv 0x2261 0xF0BA -Im 0x2111 0xF0C1 -otimes 0x2297 0xF0C4 -cap 0x2229 0xF0C7 -supset 0x2283 0xF0C9 -int 0x222B 0xF0F2 -rfloor 0x230B 0xF0FB -lfloor 0x230A 0xF0EB -perp 0x22A5 0xF05E -wedge 0x2227 0xF0D9 -rceil 0x2309 0xF0F9 -vee 0x2228 0xF0DA -langle 0x27E8 0xF0E1 - upsilon 0x03C5 0xF075 phi 0x03C6 0xF066 chi 0x03C7 0xF063 @@ -56,57 +46,68 @@ Phi 0x03A6 0xF046 Psi 0x03A8 0xF059 Omega 0x03A9 0xF057 +aleph 0x2135 0xF0C0 +wp 0x2118 0xF0C3 +Re 0x211C 0xF0C2 +Im 0x2111 0xF0C1 +partial 0x2202 0xF0B6 +infty 0x221E 0xF0A5 +prime 0x2032 0xF0A2 +nabla 0x2207 0xF0D1 +surd 0x221A 0xF0D6 +angle 0x2220 0xF0D0 forall 0x2200 0xF022 exists 0x2203 0xF024 -ni 0x220B 0xF027 -cong 0x2245 0xF040 -approx 0x2248 0xF0BB -Re 0x211C 0xF0C2 -oplus 0x2295 0xF0C5 -cup 0x222A 0xF0C8 -subseteq 0x2286 0xF0CD -in 0x2208 0xF0CE -lceil 0x2308 0xF0E9 -cdot 0x22C5 0xF0D7 neg 0x00AC 0xF0D8 -times 0x00D7 0xF0B4 -surd 0x221A 0xF0D6 -varpi 0x03D6 0xF076 -rangle 0x27E9 0xF0F1 - -sim 0x223C 0xF07E -leq 0x2264 0xF0A3 -infty 0x221E 0xF0A5 clubsuit 0x2663 0xF0A7 diamondsuit 0x2666 0xF0A8 heartsuit 0x2665 0xF0A9 spadesuit 0x2660 0xF0AA -leftrightarrow 0x2194 0xF0AB -leftarrow 0x2190 0xF0AC -Leftarrow 0x21D0 0xF0DC -uparrow 0x2191 0xF0AD -rightarrow 0x2192 0xF0AE -Rightarrow 0x21D2 0xF0DE -downarrow 0x2193 0xF0AF +int 0x222B 0xF0F2 +pm 0x00B1 0xF0B1 +cdot 0x22C5 0xF0D7 +times 0x00D7 0xF0B4 +ast 0x2217 0xF02A circ 0x2218 0xF0B0 -pm 0x00B1 0xF0B1 -geq 0x2265 0xF0B3 -propto 0x221D 0xF0B5 -partial 0x2202 0xF0B6 bullet 0x2219 0xF0B7 div 0x00F7 0xF0B8 -neq 0x2260 0xF0B9 -aleph 0x2135 0xF0C0 -wp 0x2118 0xF0C3 +cap 0x2229 0xF0C7 +cup 0x222A 0xF0C8 +vee 0x2228 0xF0DA +wedge 0x2227 0xF0D9 +oplus 0x2295 0xF0C5 +otimes 0x2297 0xF0C4 oslash 0x2298 0xF0C6 -supseteq 0x2287 0xF0CA +leq 0x2264 0xF0A3 subset 0x2282 0xF0CC -o 0x03BF 0xF0B0 -nabla 0x2207 0xF0D1 +subseteq 0x2286 0xF0CD +in 0x2208 0xF0CE +geq 0x2265 0xF0B3 +supset 0x2283 0xF0C9 +supseteq 0x2287 0xF0CA +ni 0x220B 0xF027 +mid 0x2223 0xF0BD +equiv 0x2261 0xF0BA +sim 0x223C 0xF07E +approx 0x2248 0xF0BB +cong 0x2245 0xF040 +propto 0x221D 0xF0B5 +perp 0x22A5 0xF05E +leftarrow 0x2190 0xF0AC +Leftarrow 0x21D0 0xF0DC +rightarrow 0x2192 0xF0AE +Rightarrow 0x21D2 0xF0DE +leftrightarrow 0x2194 0xF0AB +uparrow 0x2191 0xF0AD +downarrow 0x2193 0xF0AF +lfloor 0x230A 0xF0EB +langle 0x27E8 0xF0E1 +lceil 0x2308 0xF0E9 +rfloor 0x230B 0xF0FB +rangle 0x27E9 0xF0F1 +rceil 0x2309 0xF0F9 +neq 0x2260 0xF0B9 ldots 0x2026 0xF0BC -prime 0x2032 0xF0A2 -0 0x2205 0xF0C6 -mid 0x2223 0xF0BD +0 0x2298 0xF0C6 copyright 0x00A9 0xF0E3 - deg 0x00B0 0xF0B0 diff --git a/libinterp/octave-value/ov-class.cc b/libinterp/octave-value/ov-class.cc --- a/libinterp/octave-value/ov-class.cc +++ b/libinterp/octave-value/ov-class.cc @@ -1239,13 +1239,19 @@ if (have_ctor) { + unwind_protect frame; + + // Simulate try/catch. + + interpreter_try (frame); + octave_value_list result = ctor.do_multi_index_op (1, octave_value_list ()); - if (result.length () == 1) + if (! error_state && result.length () == 1) retval = true; - else - warning ("call to constructor for class %s failed", c_name.c_str ()); + + error_state = false; } else warning ("no constructor for class %s", c_name.c_str ()); @@ -1401,19 +1407,17 @@ if (! reconstruct_parents ()) warning ("load: unable to reconstruct object inheritance"); - else + + if (load_path::find_method (classname, "loadobj") + != std::string ()) { - if (load_path::find_method (classname, "loadobj") - != std::string ()) - { - octave_value in = new octave_class (*this); - octave_value_list tmp = feval ("loadobj", in, 1); + octave_value in = new octave_class (*this); + octave_value_list tmp = feval ("loadobj", in, 1); - if (! error_state) - map = tmp(0).map_value (); - else - success = false; - } + if (! error_state) + map = tmp(0).map_value (); + else + success = false; } } else @@ -1548,18 +1552,16 @@ if (! reconstruct_parents ()) warning ("load: unable to reconstruct object inheritance"); - else + + if (load_path::find_method (c_name, "loadobj") != std::string ()) { - if (load_path::find_method (c_name, "loadobj") != std::string ()) - { - octave_value in = new octave_class (*this); - octave_value_list tmp = feval ("loadobj", in, 1); + octave_value in = new octave_class (*this); + octave_value_list tmp = feval ("loadobj", in, 1); - if (! error_state) - map = tmp(0).map_value (); - else - success = false; - } + if (! error_state) + map = tmp(0).map_value (); + else + success = false; } } else @@ -1788,23 +1790,19 @@ if (!reconstruct_parents ()) warning ("load: unable to reconstruct object inheritance"); - else - { - if (load_path::find_method (c_name, "loadobj") != std::string ()) - { - octave_value in = new octave_class (*this); - octave_value_list tmp = feval ("loadobj", in, 1); - if (! error_state) - { - map = tmp(0).map_value (); - retval = true; - } - else - retval = false; + if (load_path::find_method (c_name, "loadobj") != std::string ()) + { + octave_value in = new octave_class (*this); + octave_value_list tmp = feval ("loadobj", in, 1); + + if (! error_state) + { + map = tmp(0).map_value (); + retval = true; } else - retval = true; + retval = false; } } diff --git a/scripts/plot/clabel.m b/scripts/plot/clabel.m --- a/scripts/plot/clabel.m +++ b/scripts/plot/clabel.m @@ -61,11 +61,11 @@ ## @seealso{contour, contourf, contour3, meshc, surfc, text} ## @end deftypefn -function retval = clabel (c, varargin) +function h = clabel (c, varargin) - label_spacing = 2 * 72; have_hg = false; have_labelspacing = false; + label_spacing = 144; # 2 inches in points if (nargin < 1) print_usage (); @@ -75,12 +75,13 @@ arg = varargin{1}; if (isscalar (arg) && ishandle (arg) && strcmp (get (arg, "type"), "hggroup")) - obj = get (arg); - if (! isfield (obj, "contourmatrix")) - error ("clabel: expecting the handle to be a contour group"); - endif + try + get (arg, "contourmatrix"); + catch + error ("clabel: H must be a handle to a contour group"); + end_try_catch + have_hg = true; hg = arg; - have_hg = true; varargin(1) = []; else hparent = gca (); @@ -94,44 +95,43 @@ v = []; endif - for i = 1 : length (varargin) - 1 - arg = varargin{i}; - if (strcmpi (arg, "labelspacing")) - label_spacing = varargin{i+1}; - have_labelspacing = true; - varargin(i:i+1) = []; - break; - endif - endfor + idx = strcmpi (varargin(1:2:end), "manual"); + if (any (idx)) + error ('clabel: "manual" contour mode is not supported'); + endif - for i = 1 : length (varargin) - arg = varargin{i}; - if (strcmpi (arg, "manual")) - error ("clabel: manual contouring mode not supported"); - endif - endfor + idx = find (strcmpi (varargin(1:2:end), "labelspacing"), 1); + if (! isempty (idx)) + have_labelspacing = true; + label_spacing = varargin{2*idx}; + varargin(2*idx+(-1:0)) = []; + endif if (have_hg) if (! isempty (v)) if (have_labelspacing) set (hg, "textlistmode", "manual", "textlist", v, - "labelspacing", label_spacing, "showtext", "on"); + "labelspacing", label_spacing, "showtext", "on"); else set (hg, "textlistmode", "manual", "textlist", v, "showtext", "on"); endif else if (have_labelspacing) - set (hg,"showtext", "on", "labelspacing", label_spacing); + set (hg, "showtext", "on", "labelspacing", label_spacing); else - set (hg,"showtext", "on"); + set (hg, "showtext", "on"); endif endif - retval = findobj (hg, "type", "text"); + htmp = findobj (hg, "type", "text"); if (! isempty (varargin)) - set (retval, varargin {:}); + set (htmp, varargin{:}); endif else - retval = __clabel__ (c, v, hparent, label_spacing, [], varargin{:}); + htmp = __clabel__ (c, v, hparent, label_spacing, [], varargin{:}); + endif + + if (nargout > 0) + h = htmp; endif endfunction diff --git a/scripts/plot/compass.m b/scripts/plot/compass.m --- a/scripts/plot/compass.m +++ b/scripts/plot/compass.m @@ -88,7 +88,7 @@ endif ## Matlab draws compass plots with the arrow head as one continous line, - ## and each arrow separately. This is completely different than quiver + ## and each arrow separately. This is completely different from quiver ## and quite ugly. n = length (u); xend = u; @@ -128,3 +128,10 @@ %! a = toeplitz ([1;randn_9x1_data], [1,randn_1x9_data]); %! compass (eig (a)); +%% Test input validation +%!error compass () +%!error compass (1,2,3,4) +%!error compass (1, "-r", 2) +%!error compass (1, "abc") +%!error compass (1, {1}) + diff --git a/scripts/plot/contourf.m b/scripts/plot/contourf.m --- a/scripts/plot/contourf.m +++ b/scripts/plot/contourf.m @@ -72,7 +72,7 @@ hax = newplot (hax); [ctmp, htmp] = __contour__ (hax, "none", "fill", "on", - "linecolor", "black", varargin{:}); + "linecolor", "black", varargin{:}); unwind_protect_cleanup if (! isempty (oldfig)) set (0, "currentfigure", oldfig); diff --git a/scripts/plot/cylinder.m b/scripts/plot/cylinder.m --- a/scripts/plot/cylinder.m +++ b/scripts/plot/cylinder.m @@ -55,11 +55,11 @@ [hax, args, nargs] = __plt_get_axis_arg__ ("cylinder", varargin{:}); if (nargs == 0) + r = [1, 1]; n = 20; - r = [1, 1]; elseif (nargs == 1) + r = args{1}; n = 20; - r = args{1}; elseif (nargs == 2) r = args{1}; n = args{2}; @@ -83,13 +83,12 @@ yy = y; zz = z; else - oldfig = []; - if (! isempty (hax)) - oldfig = get (0, "currentfigure"); - endif + oldfig = []; + if (! isempty (hax)) + oldfig = get (0, "currentfigure"); + endif unwind_protect hax = newplot (hax); - surf (x, y, z); unwind_protect_cleanup if (! isempty (oldfig)) diff --git a/scripts/plot/ellipsoid.m b/scripts/plot/ellipsoid.m --- a/scripts/plot/ellipsoid.m +++ b/scripts/plot/ellipsoid.m @@ -74,10 +74,10 @@ yy = y; zz = z; else - oldfig = []; - if (! isempty (hax)) - oldfig = get (0, "currentfigure"); - endif + oldfig = []; + if (! isempty (hax)) + oldfig = get (0, "currentfigure"); + endif unwind_protect hax = newplot (hax); diff --git a/scripts/plot/feather.m b/scripts/plot/feather.m --- a/scripts/plot/feather.m +++ b/scripts/plot/feather.m @@ -48,54 +48,56 @@ ## @seealso{plot, quiver, compass} ## @end deftypefn -function retval = feather (varargin) +function h = feather (varargin) [hax, varargin, nargin] = __plt_get_axis_arg__ ("feather", varargin{:}); - arrowsize = 0.25; + if (nargin == 0 || nargin > 3) + print_usage (); + endif - if (nargin == 0) - print_usage (); - elseif (nargin == 1 || (nargin == 2 && ! isnumeric (varargin{2}))) - ioff = 2; + if (nargin == 1 || (nargin == 2 && ! isnumeric (varargin{2}))) z = varargin{1}(:).'; u = real (z); v = imag (z); - elseif (nargin > 1 && isnumeric (varargin{2})) + have_line_spec = (nargin == 2); + elseif (nargin >= 2 && isnumeric (varargin{2})) ioff = 3; u = varargin{1}(:).'; v = varargin{2}(:).'; + have_line_spec = (nargin == 3); + else + print_usage (); endif - line_spec = "b-"; - have_line_spec = false; - while (ioff <= nargin) - arg = varargin{ioff++}; - if ((ischar (arg) || iscell (arg)) && ! have_line_spec) - [linespec, valid] = __pltopt__ ("feather", arg, false); + arrowsize = 0.20; + line_spec = "-b"; + + if (have_line_spec) + arg = varargin{end}; + if (ischar (arg) || iscellstr (arg)) + [~, valid] = __pltopt__ ("feather", arg, false); if (valid) line_spec = arg; - have_line_spec = false; - break; else - error ("feather: invalid linespec"); + error ("feather: invalid linestyle STYLE"); endif else - error ("feather: unrecognized argument"); + error ("feather: invalid linestyle STYLE"); endif - endwhile + endif ## Matlab draws feather plots, with the arrow head as one continous - ## line, and each arrow separately. This is completely different than + ## line, and each arrow separately. This is completely different from ## quiver and quite ugly. n = length (u); xend = [1 : n] + u; xtmp = [1 : n] + u .* (1 - arrowsize); yend = v; ytmp = v .* (1 - arrowsize); - x = [[1 : n]; xend; xtmp - v * arrowsize; xend; ... - xtmp + v * arrowsize]; - y = [zeros(1, n); yend; ytmp + u * arrowsize / 3; yend; ... + x = [[1 : n]; xend; xtmp - v * arrowsize / 3; xend; ... + xtmp + v * arrowsize / 3]; + y = [zeros(1, n); yend; ytmp + u * arrowsize / 3; yend; ... ytmp - u * arrowsize / 3]; oldfig = []; @@ -112,7 +114,7 @@ end_unwind_protect if (nargout > 0) - retval = hlist; + h = hlist; endif endfunction @@ -125,3 +127,10 @@ %! axis tight; %! title ('feather plot'); +%% Test input validation +%!error feather () +%!error feather (1,2,3,4) +%!error feather (1, "-r", 2) +%!error feather (1, "abc") +%!error feather (1, {1}) + diff --git a/scripts/plot/findfigs.m b/scripts/plot/findfigs.m --- a/scripts/plot/findfigs.m +++ b/scripts/plot/findfigs.m @@ -29,12 +29,10 @@ function findfigs () - figh = allchild (0); + hfigs = allchild (0); units = get (0, "units"); unwind_protect - if (!strcmp (units, "pixels")) - set (0, "units", "pixels"); - endif + set (0, "units", "pixels"); screensize = get (0, "screensize"); unwind_protect_cleanup set (0, "units", units); @@ -46,37 +44,34 @@ screensize(1:2) += margin; screensize(3:4) -= margin; - for i = 1:numel (figh) - if (strcmp (get (figh(i), "visible"), "on")) + hfigs = hfigs(strcmp (get (hfigs, "visible"), "on")); + for hf = hfigs' + units = get (hf, "units"); + unwind_protect + set (hf, "units", "pixels"); + pos = get (hf, "position"); + ## Test if (in order): + ## The left side is outside the right side of the screen + ## The bottom is above the top of the screen + ## The right side is outside the left of the screen + ## the top is below the bottom of the screen + if (pos(1) > screensize(3) + || pos(2) > screensize(4) + || pos(1)+pos(3) < screensize(1) + || pos(2)+pos(4) < screensize(2)) - units = get (figh(i), "units"); - unwind_protect - if (!strcmp (units, "pixels")) - set (figh(i), "units", "pixels"); - endif - pos = get (figh(i), "position"); - ## Test if (in order): - ## The left side is outside the right side of the screen - ## The bottom is above the top of the screen - ## The right side is outside the left of the screen - ## the top is below the bottom of the screen - if (pos(1) > screensize(3) - || pos(2) > screensize(4) - || pos(1)+pos(3) < screensize(1) - || pos(2)+pos(4) < screensize(2)) + ## the new position will be at the top left of the screen + ## (all moved figures will overlap). The bottom left is chosen + ## instead of the top left because that allows for the unknown + ## amount of space for the menu bar and the title bar. + pos(1) = screensize(1); + pos(2) = screensize(2); + set (hf, "position", pos); + endif + unwind_protect_cleanup + set (hf, "units", units); + end_unwind_protect + endfor - ## the new position will be at the top left of the screen - ## (all moved figures will overlap). The bottom left is chosen - ## instead of the top left because that allows for the unknown - ## amount of space for the menu bar and the title bar. - pos(1) = screensize(1); - pos(2) = screensize(2); - set (figh(i), "position", pos); - endif - unwind_protect_cleanup - set (figh(i), "units", units); - end_unwind_protect - endif - endfor endfunction diff --git a/scripts/plot/findobj.m b/scripts/plot/findobj.m --- a/scripts/plot/findobj.m +++ b/scripts/plot/findobj.m @@ -48,7 +48,7 @@ ## of children is: ## ## @example -## findobj (@var{hlist}, "-depth", @var{d}, @var{prop_name}, @var{prop_value}) +## findobj (@var{hlist}, "-depth", 3, @var{prop_name}, @var{prop_value}) ## @end example ## ## Specifying a depth @var{d} of 0, limits the search to the set of objects diff --git a/scripts/plot/fplot.m b/scripts/plot/fplot.m --- a/scripts/plot/fplot.m +++ b/scripts/plot/fplot.m @@ -18,25 +18,29 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {} fplot (@var{fn}, @var{limits}) -## @deftypefnx {Function File} {} fplot (@var{fn}, @var{limits}, @var{tol}) -## @deftypefnx {Function File} {} fplot (@var{fn}, @var{limits}, @var{n}) -## @deftypefnx {Function File} {} fplot (@var{fn}, @var{limits}, @var{fmt}) -## @deftypefnx {Function File} {} fplot (@var{fn}, @var{limits}, @var{tol}, @var{n}, @var{fmt}) +## @deftypefnx {Function File} {} fplot (@dots{}, @var{tol}) +## @deftypefnx {Function File} {} fplot (@dots{}, @var{n}) +## @deftypefnx {Function File} {} fplot (@dots{}, @var{fmt}) ## @deftypefnx {Function File} {[@var{x}, @var{y}] =} fplot (@dots{}) ## Plot a function @var{fn} within the range defined by @var{limits}. ## -## @var{fn} is a function handle, inline function, or string -## containing the name of the function to evaluate. -## The limits of the plot are of the form @code{[@var{xlo}, @var{xhi}]} or -## @code{[@var{xlo}, @var{xhi}, @var{ylo}, @var{yhi}]}. +## @var{fn} is a function handle, inline function, or string containing the +## name of the function to evaluate. +## +## The limits of the plot are of the form @w{@code{[@var{xlo}, @var{xhi}]}} or +## @w{@code{[@var{xlo}, @var{xhi}, @var{ylo}, @var{yhi}]}}. +## ## The next three arguments are all optional and any number of them may be ## given in any order. +## ## @var{tol} is the relative tolerance to use for the plot and defaults ## to 2e-3 (.2%). -## @var{n} is the minimum number of points to use. When @var{n} is -## specified, the maximum stepsize will be -## @code{@var{xhi} - @var{xlo} / @var{n}}. More than @var{n} points may still -## be used in order to meet the relative tolerance requirement. +## +## @var{n} is the minimum number of points to use. When @var{n} is specified, +## the maximum stepsize will be @code{@var{xhi} - @var{xlo} / @var{n}}. More +## than @var{n} points may still be used in order to meet the relative +## tolerance requirement. +## ## The @var{fmt} argument specifies the linestyle to be used by the plot ## command. ## @@ -137,8 +141,8 @@ ## FIXME: This algorithm should really use adaptive scaling as the ## the numerical quadrature algorithms do so that extra points are ## used where they are needed and not spread evenly over the entire - ## x-range. Try any function with a discontinuity such as - ## fplot (@tan, [-2, 2]) or fplot ("1./x", [-3, 2]) to see the + ## x-range. Try any function with a discontinuity, such as + ## fplot (@tan, [-2, 2]) or fplot ("1./x", [-3, 2]), to see the ## problems with the current solution. while (n < 2^18) # Something is wrong if we need more than 250K points diff --git a/scripts/plot/gca.m b/scripts/plot/gca.m --- a/scripts/plot/gca.m +++ b/scripts/plot/gca.m @@ -20,8 +20,13 @@ ## @deftypefn {Function File} {@var{h} =} gca () ## Return a handle to the current axis object. ## -## If no axis object exists, create one and return its handle. The handle may -## then be used to examine or set properties of the axes. For example, +## The current axis is the default target for graphics output. In the case +## of a figure with multiple axes, @code{gca} returns the last created axes +## or the last axes that was clicked on with the mouse. +## +## If no current axes object exists, create one and return its handle. The +## handle may then be used to examine or set properties of the axes. For +## example, ## ## @example ## @group @@ -31,8 +36,15 @@ ## @end example ## ## @noindent -## creates an empty axes object, then changes its location and size in the +## creates an empty axes object and then changes its location and size in the ## figure window. +## +## Note: To find the current axis without creating a new axes object if it +## does not exist, query the @qcode{"CurrentAxes"} property of a figure. +## +## @example +## get (gcf, "currentaxes"); +## @end example ## @seealso{gcf, gco, gcbf, gcbo, get, set} ## @end deftypefn diff --git a/scripts/plot/gcbf.m b/scripts/plot/gcbf.m --- a/scripts/plot/gcbf.m +++ b/scripts/plot/gcbf.m @@ -30,7 +30,7 @@ function fig = gcbf () - [dummy, fig] = gcbo (); + [~, fig] = gcbo (); endfunction diff --git a/scripts/plot/gcf.m b/scripts/plot/gcf.m --- a/scripts/plot/gcf.m +++ b/scripts/plot/gcf.m @@ -18,23 +18,36 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {@var{h} =} gcf () -## Return the current figure handle. +## Return a handle to the current figure. ## -## If a figure does not exist, create one and return its handle. The handle -## may then be used to examine or set properties of the figure. For example, +## The current figure is the default target for graphics output. If multiple +## figures exist, @code{gcf} returns the last created figure or the last figure +## that was clicked on with the mouse. +## +## If a current figure does not exist, create one and return its handle. The +## handle may then be used to examine or set properties of the figure. For +## example, ## ## @example ## @group ## fplot (@@sin, [-10, 10]); ## fig = gcf (); -## set (fig, "visible", "off"); +## set (fig, "numbertitle", "off", "name", "sin plot") ## @end group ## @end example ## ## @noindent ## plots a sine wave, finds the handle of the current figure, and then -## makes that figure invisible. Setting the visible property of the -## figure to @qcode{"on"} will cause it to be displayed again. +## renames the figure window to describe the contents. +## +## Note: To find the current figure without creating a new one if it does not +## exist, query the @qcode{"CurrentFigure"} property of the root graphics +## object. +## +## @example +## get (0, "currentfigure"); +## @end example +## ## @seealso{gca, gco, gcbf, gcbo, get, set} ## @end deftypefn diff --git a/scripts/plot/ginput.m b/scripts/plot/ginput.m --- a/scripts/plot/ginput.m +++ b/scripts/plot/ginput.m @@ -30,7 +30,7 @@ ## was clicked in the units of the current axes. The return value @var{button} ## is 1, 2, or 3 for the left, middle, or right button. If a key is pressed ## the ASCII value is returned in @var{button}. -## @seealso{gtext} +## @seealso{gtext, waitforbuttonpress} ## @end deftypefn function varargout = ginput (n) diff --git a/scripts/plot/guidata.m b/scripts/plot/guidata.m --- a/scripts/plot/guidata.m +++ b/scripts/plot/guidata.m @@ -25,38 +25,43 @@ ## figure handle then it's parent figure will be used for storage. ## ## @var{data} must be a single object which means it is usually preferable -## for it to be a data container such as a cell array or struct. +## for it to be a data container such as a cell array or struct so that +## additional data items can be added easily. ## ## @seealso{getappdata, setappdata, get, set, getpref, setpref} ## @end deftypefn ## Author: goffioul -function varargout = guidata (varargin) +function dataout = guidata (h, data) + + if (nargin < 1 || nargin > 2) + print_usage (); + endif - if (nargin == 1 || nargin == 2) - h = varargin{1}; - if (ishandle (h)) - h = ancestor (h, "figure"); - if (! isempty (h)) - if (nargin == 1) - varargout{1} = get (h, "__guidata__"); - else - data = varargin{2}; - set (h, "__guidata__", data); - if (nargout == 1) - varargout{1} = data; - endif - endif - else - error ("no ancestor figure found"); - endif - else - error ("invalid object handle"); + if (! ishandle (h)) + error ("guidata: H must be a valid object handle"); + endif + h = ancestor (h, "figure"); + if (isempty (h)) + error ("guidata: no ancestor figure of H found"); + endif + + if (nargin == 1) + dataout = get (h, "__guidata__"); + else + set (h, "__guidata__", data); + if (nargout == 1) + dataout = data; endif - else - print_usage (); endif endfunction + +%% Test input validation +%!error guidata () +%!error guidata (1,2,3) +%!error guidata ({1}) +%!error guidata (0) + diff --git a/scripts/plot/guihandles.m b/scripts/plot/guihandles.m --- a/scripts/plot/guihandles.m +++ b/scripts/plot/guihandles.m @@ -17,37 +17,44 @@ ## . ## -*- texinfo -*- -## @deftypefn {Function File} {@var{hdata} =} guihandles (@var{handle}) +## @deftypefn {Function File} {@var{hdata} =} guihandles (@var{h}) ## @deftypefnx {Function File} {@var{hdata} =} guihandles +## Return a structure of object handles for the figure associated with +## handle @var{h}. +## +## If no handle is specified the current figure returned by @code{gcf} is used. ## -## @seealso{guidata, getappdata, setappdata} +## The fieldname for each entry of @var{hdata} is taken from the @qcode{"tag"} +## property of the graphic object. If the tag is empty then the handle is not +## returned. If there are multiple graphic objects with the same tag then +## the entry in @var{hdata} will be a vector of handles. @code{guihandles} +## includes all possible handles, including those for +## which @qcode{"HandleVisibility"} is @qcode{"off"}. +## @seealso{guidata, findobj, findall, allchild} ## @end deftypefn ## Author: goffioul -function hdata = guihandles (varargin) - - hdata = []; +function hdata = guihandles (h) - if (nargin == 0 || nargin == 1) - if (nargin == 1) - h = varargin{1}; - if (ishandle (h)) - h = ancestor (h, "figure"); - if (isempty (h)) - error ("no ancestor figure found"); - endif - else - error ("invalid object handle"); - endif - else - h = gcf (); - endif - hdata = __make_guihandles_struct__ (h, hdata); - else + if (nargin > 2) print_usage (); endif + if (nargin == 1) + if (! ishandle (h)) + error ("guidata: H must be a valid object handle"); + endif + h = ancestor (h, "figure"); + if (isempty (h)) + error ("guidata: no ancestor figure of H found"); + endif + else + h = gcf (); + endif + + hdata = __make_guihandles_struct__ (h, []); + endfunction function hdata = __make_guihandles_struct__ (h, hdata) @@ -65,8 +72,8 @@ endif kids = allchild (h); - for i = 1 : length (kids) - hdata = __make_guihandles_struct__ (kids(i), hdata); + for hkid = kids' + hdata = __make_guihandles_struct__ (hkid, hdata); endfor endfunction diff --git a/scripts/plot/hggroup.m b/scripts/plot/hggroup.m --- a/scripts/plot/hggroup.m +++ b/scripts/plot/hggroup.m @@ -37,6 +37,7 @@ ## collected into a single hggroup so that they can be made visible/invisible ## with a single command, @code{set (hg_handle, "visible", "off")}. ## +## @seealso{addproperty, addlistener} ## @end deftypefn ## Author: goffioul diff --git a/scripts/plot/plotmatrix.m b/scripts/plot/plotmatrix.m --- a/scripts/plot/plotmatrix.m +++ b/scripts/plot/plotmatrix.m @@ -129,7 +129,7 @@ parent = get (bigax, "parent"); for i = 1 : nargin - 1 arg = varargin{i}; - if (ischar (arg) || iscell (arg)) + if (ischar (arg) || iscellstr (arg)) [linespec, valid] = __pltopt__ ("plotmatrix", varargin{i}, false); if (valid) have_line_spec = true; diff --git a/scripts/plot/private/__bar__.m b/scripts/plot/private/__bar__.m --- a/scripts/plot/private/__bar__.m +++ b/scripts/plot/private/__bar__.m @@ -73,7 +73,7 @@ group = false; idx++; else - if ((ischar (varargin{idx}) || iscell (varargin{idx})) + if ((ischar (varargin{idx}) || iscellstr (varargin{idx})) && ! have_line_spec) [linespec, valid] = __pltopt__ (func, varargin{idx}, false); if (valid) diff --git a/scripts/plot/private/__clabel__.m b/scripts/plot/private/__clabel__.m --- a/scripts/plot/private/__clabel__.m +++ b/scripts/plot/private/__clabel__.m @@ -23,11 +23,14 @@ function h = __clabel__ (c, v, hparent, label_spacing, z, varargin) - ## FIXME: Why assume? Can get position in points directly from axis. - ## Assume that the plot size is 4 by 3 inches. + hax = ancestor (hparent, "axes"); + units = get (hax, "units"); + set (hax, "units", "points"); + axpos = get (hax, "position"); + set (hax, "units", units); lims = axis (); - xspacing = 72 * 4 / abs (lims(1) - lims(2)); - yspacing = 72 * 3 / abs (lims(3) - lims(4)); + xspacing = axpos(3) / (lims(2) - lims (1)); + yspacing = axpos(4) / (lims(4) - lims (3)); if (isscalar (hparent) && ishandle (hparent) && strcmp (get (hparent, "type"), "hggroup")) @@ -38,80 +41,89 @@ ymin = min (y(:)); ymax = max (y(:)); else - i1 = 1; - while (i1 < length (c)) - clev = c(1,i1); - clen = c(2,i1); - p = c(:, i1+1:i1+clen); + xmin = xmax = ymin = ymax = NaN; + i = 1; + while (i < length (c)) + clen = c(2,i); + data = c(:, i+(1:clen)); - xmin = min (c(1,:)); - xmax = max (c(1,:)); - ymin = min (c(2,:)); - ymax = max (c(2,:)); + xmin = min ([xmin, data(1,:)]); + xmax = max ([xmax, data(1,:)]); + ymin = min ([ymin, data(2,:)]); + ymax = max ([ymax, data(2,:)]); - i1 += clen+1; + i += clen+1; endwhile endif ## Decode contourc output format and place labels. - i1 = 1; h = []; - while (i1 < length (c)) - clev = c(1,i1); - clen = c(2,i1); + i = 1; + while (i < length (c)) + clev = c(1,i); + clen = c(2,i); - if (!isempty (v) && ! any (find (clev == v))) - i1 += clen+1; + if (! isempty (v) && ! any (v == clev)) + i += clen+1; continue; endif - p = c(:, i1+1:i1+clen) .* repmat ([xspacing; yspacing], 1, clen); + p = bsxfun (@times, c(:, i+(1:clen)), [xspacing; yspacing]); d = sqrt (sumsq (diff (p, 1, 2))); cumd = cumsum (d); - td = sum (d); + td = cumd(end); ntag = ceil (td / label_spacing); - if (all (c(:,i1+1) == c(:,i1+clen))) - Spacing = td / ntag; - pos = Spacing / 2 + [0:ntag-1] * Spacing; + if (all (c(:,i+1) == c(:,i+clen))) + ## Closed contour + ## FIXME: This spreads the tags uniformly around the contour which + ## looks nice, but it does not respect the label_spacing attribute. + ## Should we follow user input, which can result in two labels being + ## quite close to each other? + spacing = td / ntag; + pos = spacing/2 + spacing*[0:ntag-1]; else + ## Open contour pos = zeros (1, ntag); - pos(1) = (td - label_spacing * (ntag - 1)) ./ 2; - pos(2:ntag) = pos(1) + [1:ntag-1] * label_spacing; + pos(1) = (td - label_spacing*(ntag - 1)) / 2; + pos(2:ntag) = pos(1) + label_spacing*[1:ntag-1]; endif - j1 = 2; - tlabel = sprintf ("%g", clev); - for i = 1 : ntag - tagpos = pos(i); + tlabel = sprintf ("%.5g", clev); + + for tagpos = pos - while (j1 < clen && cumd(j1) < tagpos) - j1++; - endwhile - tpos = sum (c(:,i1+j1-1:i1+j1), 2) ./ 2; + j = find (cumd > tagpos, 1); + if (isempty (j)) + j = clen; + endif + tpos = sum (c(:,i+j-1:i+j), 2) / 2; if ( tpos(1) != xmin && tpos(1) != xmax && tpos(2) != ymin && tpos(2) != ymax) - trot = 180 / pi * atan2 (diff (c(2,i1+j1-1:i1+j1)), - diff (c(1,i1+j1-1:i1+j1))); - + trot = 180 / pi * atan2 (diff (c(2,i+j-1:i+j)), + diff (c(1,i+j-1:i+j))); + if (abs (trot) > 90) + trot += 180; + endif if (ischar (z)) ht = text (tpos(1), tpos(2), clev, tlabel, "rotation", trot, - "parent", hparent, "horizontalalignment", "center", - "userdata", clev, varargin{:}); - elseif (!isempty (z)) + "horizontalalignment", "center", "userdata", clev, + "parent", hparent, varargin{:}); + elseif (! isempty (z)) ht = text (tpos(1), tpos(2), z, tlabel, "rotation", trot, - "parent", hparent, "horizontalalignment", "center", - "userdata", clev, varargin{:}); + "horizontalalignment", "center", "userdata", clev, + "parent", hparent, varargin{:}); else ht = text (tpos(1), tpos(2), tlabel, "rotation", trot, - "parent", hparent, "horizontalalignment", "center", - "userdata", clev, varargin{:}); + "horizontalalignment", "center", "userdata", clev, + "parent", hparent, varargin{:}); endif h = [h; ht]; endif endfor - i1 += clen+1; + i += clen+1; endwhile + endfunction diff --git a/scripts/plot/private/__contour__.m b/scripts/plot/private/__contour__.m --- a/scripts/plot/private/__contour__.m +++ b/scripts/plot/private/__contour__.m @@ -26,22 +26,22 @@ zlevel = varargin{2}; filled = "off"; + linespec.color = "auto"; linespec.linestyle = "-"; - linespec.color = "auto"; - edgecolor = "flat"; - for i = 3 : nargin - arg = varargin {i}; - if ((ischar (arg) || iscell (arg))) - [linespec, valid] = __pltopt__ ("__contour__", arg, false); - if (isempty (linespec.color)) - linespec.color = "auto"; - endif - if (isempty (linespec.linestyle)) - linespec.linestyle = "-"; - endif + for i = 3:2:nargin + arg = varargin{i}; + if (ischar (arg) || iscellstr (arg)) + [lspec, valid] = __pltopt__ ("__contour__", arg, false); if (valid) have_line_spec = true; varargin(i) = []; + linespec = lspec; + if (isempty (linespec.color)) + linespec.color = "auto"; + endif + if (isempty (linespec.linestyle)) + linespec.linestyle = "-"; + endif break; endif endif @@ -50,29 +50,16 @@ opts = {}; i = 3; while (i < length (varargin)) - if (ischar (varargin {i})) + if (ischar (varargin{i})) if (strcmpi (varargin{i}, "fill")) - filled = varargin {i + 1}; + filled = varargin{i+1}; varargin(i:i+1) = []; elseif (strcmpi (varargin{i}, "linecolor")) - linespec.color = varargin {i + 1}; - edgecolor = linespec.color; - if (ischar (edgecolor) && strcmpi (edgecolor, "auto")) - edgecolor = "flat"; - endif - varargin(i:i+1) = []; - elseif (strcmpi (varargin{i}, "edgecolor")) - linespec.color = varargin {i + 1}; - edgecolor = linespec.color; - if (ischar (edgecolor) && strcmpi (edgecolor, "flat")) - linespec.color = "auto"; - endif + linespec.color = varargin{i+1}; varargin(i:i+1) = []; else - opts{end+1} = varargin{i}; - varargin(i) = []; - opts{end+1} = varargin{i}; - varargin(i) = []; + opts(end+(1:2)) = varargin(i:i+1); + varargin(i:i+1) = []; endif else i++; @@ -88,23 +75,24 @@ y1 = varargin{4}; z1 = varargin{5}; endif - if (!ismatrix (z1) || isvector (z1) || isscalar (z1)) - error ("__contour__: z argument must be a matrix"); + if (! ismatrix (z1) || ! ismatrix (x1) || ! ismatrix (y1)) + error ("__contour__: X, Y, and Z must be matrices"); endif if (length (varargin) == 4 || length (varargin) == 6) vn = varargin{end}; vnauto = false; else + vn = 10; vnauto = true; - vn = 10; endif if (isscalar (vn)) - ## FIXME - the levels should be determined similarly to {x,y,z}ticks - lvl = linspace (min (z1(!isinf (z1))), max (z1(!isinf (z1))), - vn + 2)(1:end-1); + ## FIXME: The levels should be determined similarly to {x,y,z}ticks + ## so that they aren't set at extremely odd values. + lvl = linspace (min (z1(!isinf (z1))), max (z1(!isinf (z1))), vn + 2); + lvl = lvl(2:end-1); # Strip off max, min outliers else - lvl = vn; + lvl = unique (sort (vn)); endif if (strcmpi (filled, "on")) @@ -147,16 +135,10 @@ addproperty ("zlevel", hg, "data", zlevel); else addproperty ("zlevelmode", hg, "radio", "{none}|auto|manual", zlevel); - if (ischar (zlevel) && strcmpi (zlevel, "manual")) - z = varargin{3}; - z = 2 * (min (z(:)) - max (z(:))); - addproperty ("zlevel", hg, "data", z); - else - addproperty ("zlevel", hg, "data", 0.); - endif + addproperty ("zlevel", hg, "data", 0.); endif - lvlstep = sum (abs (diff (lvl))) / (length (lvl) - 1); + lvlstep = sum (diff (lvl)) / (length (lvl) - 1); addproperty ("levellist", hg, "data", lev); addproperty ("levelstep", hg, "double", lvlstep); @@ -182,10 +164,6 @@ addproperty ("linestyle", hg, "linelinestyle", linespec.linestyle); addproperty ("linewidth", hg, "linelinewidth", 0.5); - ## FIXME: It would be good to hide this property which is just an - ## undocumented alias for linecolor - addproperty ("edgecolor", hg, "color", edgecolor, "{flat}|none"); - addlistener (hg, "fill", @update_data); addlistener (hg, "zlevelmode", @update_zlevel); @@ -207,8 +185,6 @@ addlistener (hg, "linestyle", @update_line); addlistener (hg, "linewidth", @update_line); - addlistener (hg, "edgecolor", @update_edgecolor); - ## Set axis before adding patches so that each new patch does not trigger ## new axis calculation. No need if mode is already "manual". if (all (strcmp (get (gca (), {"xlimmode", "ylimmode"}), "auto"))) @@ -239,27 +215,25 @@ climmode = get (ca, "climmode"); set (ca, "climmode", "manual"); - if (strcmpi (lc, "auto")) + if (strcmp (lc, "auto")) lc = "flat"; endif - if (strcmpi (filled, "on")) + if (strcmp (filled, "on")) lvl_eps = get_lvl_eps (lev); ## Decode contourc output format. - i1 = 1; + i = 1; ncont = 0; - cont_lev = []; - cont_area = []; - while (i1 < columns (c)) + while (i < columns (c)) ncont++; - cont_lev(ncont) = c(1, i1); - cont_len(ncont) = c(2, i1); - cont_idx(ncont) = i1+1; - ii = i1+1:i1+cont_len(ncont); + cont_lev(ncont) = c(1, i); + cont_len(ncont) = c(2, i); + cont_idx(ncont) = i+1; + ii = i + (1:cont_len(ncont)); cont_area(ncont) = polyarea (c(1, ii), c(2, ii)); - i1 += c(2, i1) + 1; + i += cont_len(ncont) + 1; endwhile ## Handle for each level the case where we have (a) hole(s) in a patch. @@ -269,12 +243,10 @@ lvl_idx = find (abs (cont_lev - lev(k)) < lvl_eps); len = numel (lvl_idx); if (len > 1) - ## mark = logical (zeros (size (lvl_idx))); mark = false (size (lvl_idx)); a = 1; while (a < len) ## take 1st patch - b = a + 1; pa_idx = lvl_idx(a); ## get pointer to contour start, and contour length curr_ct_idx = cont_idx(pa_idx); @@ -285,7 +257,7 @@ next_ct_pt_vec = c(:, cont_idx(lvl_idx(b_vec))); in = inpolygon (next_ct_pt_vec(1,:), next_ct_pt_vec(2,:), curr_ct(1, :), curr_ct(2, :)); - mark(b_vec(in)) = !mark(b_vec(in)); + mark(b_vec(in)) = ! mark(b_vec(in)); a++; endwhile if (numel (mark) > 0) @@ -319,16 +291,15 @@ ## Now we have everything together and can start plotting the patches ## beginning with largest area. - [tmp, svec] = sort (cont_area); + [~, svec] = sort (cont_area); len = ncont - numel (del_idx); h = []; - for n = len:(-1):1 + for n = len:-1:1 idx = svec(n); ctmp = c(:, cont_idx(idx):cont_idx(idx) + cont_len(idx) - 1); if (all (ctmp(:,1) == ctmp(:,end))) - ctmp(:, end) = []; - else - ## Special case unclosed contours + ## patch() doesn't need/want closed contour. It will do it itself. + ctmp(:,end) = []; endif if (isnan (cont_lev (idx))) fc = get (ca, "color"); @@ -340,10 +311,10 @@ endif h = [h; __go_patch__(ca, "xdata", ctmp(1, :)(:), "ydata", ctmp(2, :)(:), "vertices", ctmp.', "faces", 1:(cont_len(idx)-1), - "facevertexcdata", cont_lev(idx), - "facecolor", fc, "cdata", cont_lev(idx), - "edgecolor", lc, "linestyle", ls, - "linewidth", lw, "parent", hg)]; + "facevertexcdata", cont_lev(idx), "facecolor", fc, + "cdata", cont_lev(idx), "edgecolor", lc, + "linestyle", ls, "linewidth", lw, + "parent", hg)]; endfor if (min (lev) == max (lev)) @@ -353,47 +324,47 @@ endif else ## Decode contourc output format. - i1 = 1; h = []; - while (i1 < length (c)) - clev = c(1,i1); - clen = c(2,i1); + i = 1; + while (i < length (c)) + clev = c(1,i); + clen = c(2,i); - if (all (c(:,i1+1) == c(:,i1+clen))) - p = c(:, i1+1:i1+clen-1).'; + if (all (c(:,i+1) == c(:,i+clen))) + p = c(:, i+1:i+clen-1).'; else - p = [c(:, i1+1:i1+clen), NaN(2, 1)].'; + p = [c(:, i+1:i+clen), NaN(2, 1)].'; endif switch (zmode) case "none" h = [h; __go_patch__(ca, "xdata", p(:,1), "ydata", p(:,2), - "zdata", [], "facecolor", "none", - "vertices", p, "faces", 1:rows(p), - "facevertexcdata", clev, - "edgecolor", lc, "linestyle", ls, - "linewidth", lw, - "cdata", clev, "parent", hg)]; + "zdata", [], + "vertices", p, "faces", 1:rows (p), + "facevertexcdata", clev, "facecolor", "none", + "cdata", clev, "edgecolor", lc, + "linestyle", ls, "linewidth", lw, + "parent", hg)]; case "auto" h = [h; __go_patch__(ca, "xdata", p(:,1), "ydata", p(:,2), - "zdata", clev * ones(rows(p),1), + "zdata", clev * ones (rows (p),1), "vertices", [p, clev * ones(rows(p),1)], "faces", 1:rows(p), - "facevertexcdata", clev, - "facecolor", "none", "edgecolor", lc, + "facevertexcdata", clev, "facecolor", "none", + "cdata", clev, "edgecolor", lc, "linestyle", ls, "linewidth", lw, - "cdata", clev, "parent", hg)]; + "parent", hg)]; otherwise h = [h; __go_patch__(ca, "xdata", p(:,1), "ydata", p(:,2), - "zdata", zlev * ones (rows(p), 1), + "zdata", zlev * ones (rows (p), 1), "vertices", [p, zlev * ones(rows(p),1)], - "faces", 1:rows(p), - "facevertexcdata", clev, - "facecolor", "none", "edgecolor", lc, + "faces", 1:rows (p), + "facevertexcdata", clev, "facecolor", "none", + "cdata", clev, "edgecolor", lc, "linestyle", ls, "linewidth", lw, - "cdata", clev, "parent", hg)]; + "parent", hg)]; endswitch - i1 += clen + 1; + i += clen + 1; endwhile endif @@ -401,8 +372,7 @@ endfunction -function update_zlevel (h, d) - +function update_zlevel (h, ~) z = get (h, "zlevel"); zmode = get (h, "zlevelmode"); kids = get (h, "children"); @@ -412,45 +382,29 @@ set (kids, "zdata", []); case "auto" for i = 1 : length (kids) - set (kids(i), "zdata", get (kids (i), "cdata") .* - ones (size (get (kids (i), "xdata")))); + set (kids(i), "zdata", get (kids(i), "cdata") .* + ones (size (get (kids(i), "xdata")))); endfor otherwise for i = 1 : length (kids) - set (kids(i), "zdata", z .* ones (size (get (kids (i), "xdata")))); + set (kids(i), "zdata", z .* ones (size (get (kids(i), "xdata")))); endfor endswitch endfunction -function update_edgecolor (h, d) - ec = get (h, "edgecolor"); +function update_line (h, ~) lc = get (h, "linecolor"); - if (ischar (ec) && strcmpi (ec, "flat")) - if (! strcmpi (lc, "auto")) - set (h, "linecolor", "auto"); - endif - elseif (! isequal (ec, lc)) - set (h, "linecolor", ec); - endif -endfunction - -function update_line (h, d) - lc = get (h, "linecolor"); - ec = get (h, "edgecolor"); - if (strcmpi (lc, "auto")) + if (strcmp (lc, "auto")) lc = "flat"; endif - if (! isequal (ec, lc)) - set (h, "edgecolor", lc); - endif set (findobj (h, "type", "patch"), "edgecolor", lc, "linewidth", get (h, "linewidth"), "linestyle", get (h, "linestyle")); endfunction -function update_data (h, d, prop = "") +function update_data (h, ~, prop = "") persistent recursive = false; - if (!recursive) + if (! recursive) recursive = true; delete (get (h, "children")); @@ -462,10 +416,10 @@ set (h, "levelstepmode", "manual") endswitch - if (strcmpi (get (h, "levellistmode"), "manual") + if (strcmp (get (h, "levellistmode"), "manual") && ! strcmp (prop, "levelstep")) lvl = get (h, "levellist"); - elseif (strcmpi (get (h, "levelstepmode"), "manual")) + elseif (strcmp (get (h, "levelstepmode"), "manual")) z = get (h, "zdata"); lvs = get (h, "levelstep"); lvl(1) = ceil (min (z(:)) / lvs) * lvs; @@ -481,7 +435,7 @@ lvl = 10; endif - if (strcmpi (get (h, "fill"), "on")) + if (strcmp (get (h, "fill"), "on")) X = get (h, "xdata"); Y = get (h, "ydata"); Z = get (h, "zdata"); @@ -504,9 +458,9 @@ endif set (h, "contourmatrix", c); - if (strcmpi (get (h, "levellistmode"), "manual")) + if (strcmp (get (h, "levellistmode"), "manual")) ## Do nothing - elseif (strcmpi (get (h, "levelstepmode"), "manual")) + elseif (strcmp (get (h, "levelstepmode"), "manual")) set (h, "levellist", lev); else set (h, "levellist", lev); @@ -516,23 +470,23 @@ endif add_patch_children (h); - update_text (h, d); + update_text (h); recursive = false; endif endfunction -function update_text (h, d) +function update_text (h, ~) persistent recursive = false; - if (!recursive) + if (! recursive) recursive = true; delete (findobj (h, "type", "text")); - if (strcmpi (get (h, "textlistmode"), "manual")) + if (strcmp (get (h, "textlistmode"), "manual")) lvl = get (h, "textlist"); - elseif (strcmpi (get (h, "textstepmode"), "manual")) + elseif (strcmp (get (h, "textstepmode"), "manual")) lev = get (h, "levellist"); lvl_eps = get_lvl_eps (lev); @@ -546,7 +500,7 @@ set (h, "textlist", lvl, "textstep", get (h, "levelstep")); endif - if (strcmpi (get (h, "showtext"), "on")) + if (strcmp (get (h, "showtext"), "on")) switch (get (h, "zlevelmode")) case "manual" __clabel__ (get (h, "contourmatrix"), lvl, h, diff --git a/scripts/plot/private/__pltopt__.m b/scripts/plot/private/__pltopt__.m --- a/scripts/plot/private/__pltopt__.m +++ b/scripts/plot/private/__pltopt__.m @@ -89,24 +89,19 @@ ## Author: jwe -function [options, valid] = __pltopt__ (caller, opt, err_on_invalid) - - valid = true; - options = __default_plot_options__ (); +function [options, valid] = __pltopt__ (caller, opt, err_on_invalid = true) - if (nargin == 2) - err_on_invalid = true; - endif + options = __default_plot_options__ (); + valid = true; + if (ischar (opt)) - nel = rows (opt); - elseif (iscellstr (opt)) - nel = numel (opt); - else + opt = cellstr (opt); + elseif (! iscellstr (opt)) error ("__pltopt__: argument must be a character string or cell array of character strings"); endif - if (ischar (opt)) - opt = cellstr (opt); - endif + + nel = numel (opt); + for i = nel:-1:1 [options(i), valid] = __pltopt1__ (caller, opt{i}, err_on_invalid); if (! err_on_invalid && ! valid) @@ -127,17 +122,11 @@ options = __default_plot_options__ (); valid = true; - more_opts = 1; - - if (! ischar (opt)) - return; - endif - have_linestyle = false; have_marker = false; ## If called by __errplot__, extract the linestyle before proceeding. - if (strcmp (caller,"__errplot__")) + if (strcmp (caller, "__errplot__")) if (strncmp (opt, "#~>", 3)) n = 3; elseif (strncmp (opt, "#~", 2) || strncmp (opt, "~>", 2)) diff --git a/scripts/plot/private/__quiver__.m b/scripts/plot/private/__quiver__.m --- a/scripts/plot/private/__quiver__.m +++ b/scripts/plot/private/__quiver__.m @@ -83,7 +83,7 @@ arg = varargin{ioff++}; if (ischar (arg) && strcmpi (arg, "filled")) have_filled = true; - elseif ((ischar (arg) || iscell (arg)) + elseif ((ischar (arg) || iscellstr (arg)) && ! have_line_spec) [linespec, valid] = __pltopt__ ("quiver", arg, false); if (valid) diff --git a/scripts/plot/private/__scatter__.m b/scripts/plot/private/__scatter__.m --- a/scripts/plot/private/__scatter__.m +++ b/scripts/plot/private/__scatter__.m @@ -93,7 +93,7 @@ arg = varargin{iarg++}; if (ischar (arg) && (strcmpi (arg, "filled") || strcmpi (arg, "fill"))) filled = true; - elseif ((ischar (arg) || iscell (arg)) && ! have_marker) + elseif ((ischar (arg) || iscellstr (arg)) && ! have_marker) [linespec, valid] = __pltopt__ (fcn, arg, false); if (valid) have_marker = true; diff --git a/scripts/plot/private/__stem__.m b/scripts/plot/private/__stem__.m --- a/scripts/plot/private/__stem__.m +++ b/scripts/plot/private/__stem__.m @@ -274,7 +274,7 @@ arg = varargin{ioff++}; if (ischar (arg) && any (strcmpi (arg, {"fill", "filled"}))) dofill = true; - elseif ((ischar (arg) || iscell (arg)) && ! have_line_spec) + elseif ((ischar (arg) || iscellstr (arg)) && ! have_line_spec) [linespec, valid] = __pltopt__ (caller, arg, false); if (valid) have_line_spec = true; diff --git a/scripts/plot/rose.m b/scripts/plot/rose.m --- a/scripts/plot/rose.m +++ b/scripts/plot/rose.m @@ -90,10 +90,10 @@ r(3:4:end, :) = nn; if (nargout < 2) - oldfig = []; - if (! isempty (hax)) - oldfig = get (0, "currentfigure"); - endif + oldfig = []; + if (! isempty (hax)) + oldfig = get (0, "currentfigure"); + endif unwind_protect hax = newplot (hax); htmp = polar (th, r); diff --git a/scripts/plot/sphere.m b/scripts/plot/sphere.m --- a/scripts/plot/sphere.m +++ b/scripts/plot/sphere.m @@ -71,10 +71,10 @@ yy = y; zz = z; else - oldfig = []; - if (! isempty (hax)) - oldfig = get (0, "currentfigure"); - endif + oldfig = []; + if (! isempty (hax)) + oldfig = get (0, "currentfigure"); + endif unwind_protect hax = newplot (hax); diff --git a/scripts/plot/stairs.m b/scripts/plot/stairs.m --- a/scripts/plot/stairs.m +++ b/scripts/plot/stairs.m @@ -149,7 +149,7 @@ have_line_spec = false; for i = 1:2:numel (varargin) arg = varargin{i}; - if (ischar (arg) || iscell (arg)) + if (ischar (arg) || iscellstr (arg)) [linespec, valid] = __pltopt__ ("stairs", arg, false); if (valid) have_line_spec = true; diff --git a/scripts/plot/surfnorm.m b/scripts/plot/surfnorm.m --- a/scripts/plot/surfnorm.m +++ b/scripts/plot/surfnorm.m @@ -114,30 +114,30 @@ nz = nz ./ len; if (nargout == 0) - oldfig = []; - if (! isempty (hax)) - oldfig = get (0, "currentfigure"); - endif - unwind_protect - hax = newplot (hax); - - surf (x, y, z, varargin{ioff:end}); - old_hold_state = get (hax, "nextplot"); - unwind_protect - set (hax, "nextplot", "add"); - plot3 ([x(:)'; x(:).' + nx(:).' ; NaN(size(x(:).'))](:), - [y(:)'; y(:).' + ny(:).' ; NaN(size(y(:).'))](:), - [z(:)'; z(:).' + nz(:).' ; NaN(size(z(:).'))](:), - varargin{ioff:end}); - unwind_protect_cleanup - set (hax, "nextplot", old_hold_state); - end_unwind_protect - - unwind_protect_cleanup - if (! isempty (oldfig)) - set (0, "currentfigure", oldfig); - endif - end_unwind_protect + oldfig = []; + if (! isempty (hax)) + oldfig = get (0, "currentfigure"); + endif + unwind_protect + hax = newplot (hax); + + surf (x, y, z, varargin{ioff:end}); + old_hold_state = get (hax, "nextplot"); + unwind_protect + set (hax, "nextplot", "add"); + plot3 ([x(:)'; x(:).' + nx(:).' ; NaN(size(x(:).'))](:), + [y(:)'; y(:).' + ny(:).' ; NaN(size(y(:).'))](:), + [z(:)'; z(:).' + nz(:).' ; NaN(size(z(:).'))](:), + varargin{ioff:end}); + unwind_protect_cleanup + set (hax, "nextplot", old_hold_state); + end_unwind_protect + + unwind_protect_cleanup + if (! isempty (oldfig)) + set (0, "currentfigure", oldfig); + endif + end_unwind_protect else Nx = nx; Ny = ny; diff --git a/scripts/plot/waitforbuttonpress.m b/scripts/plot/waitforbuttonpress.m --- a/scripts/plot/waitforbuttonpress.m +++ b/scripts/plot/waitforbuttonpress.m @@ -23,7 +23,7 @@ ## ## The return value of @var{b} is 0 if a mouse button was pressed or 1 if a ## key was pressed. -## @seealso{waitfor, ginput} +## @seealso{waitfor, ginput, kbhit} ## @end deftypefn ## The original version of this code bore the copyright diff --git a/scripts/testfun/assert.m b/scripts/testfun/assert.m --- a/scripts/testfun/assert.m +++ b/scripts/testfun/assert.m @@ -69,18 +69,13 @@ errmsg = ""; endif - in = deblank (argn(1,:)); - for i = 2:rows (argn) - in = [in "," deblank(argn(i,:))]; - endfor - in = ["(" in ")"]; - if (nargin == 1 || (nargin > 1 && islogical (cond) && ischar (varargin{1}))) if ((! isnumeric (cond) && ! islogical (cond)) || ! all (cond(:))) call_depth--; if (nargin == 1) ## Perhaps, say which elements failed? - error ("assert %s failed", in); + argin = ["(" strjoin(cellstr (argn), ",") ")"]; + error ("assert %s failed", argin); else error (varargin{:}); endif @@ -292,7 +287,7 @@ A_null = complex (A_null_real, A_null_imag); B_null = complex (B_null_real, B_null_imag); if (isscalar (tol)) - mtol = repmat (tol, size (A)); + mtol = tol * ones (size (A)); else mtol = tol; endif @@ -363,10 +358,11 @@ ## Print any errors if (! isempty (err.index)) + argin = ["(" strjoin(cellstr (argn), ",") ")"]; if (! isempty (errmsg)) errmsg = [errmsg "\n"]; endif - errmsg = [errmsg, pprint(in, err)]; + errmsg = [errmsg, pprint(argin, err)]; endif endif @@ -629,9 +625,9 @@ ## Pretty print the various errors in a condensed tabular format. -function str = pprint (in, err) +function str = pprint (argin, err) - str = ["ASSERT errors for: assert " in "\n"]; + str = ["ASSERT errors for: assert " argin "\n"]; str = [str, "\n Location | Observed | Expected | Reason\n"]; for i = 1:length (err.index) leni = length (err.index{i}); diff --git a/scripts/testfun/rundemos.m b/scripts/testfun/rundemos.m --- a/scripts/testfun/rundemos.m +++ b/scripts/testfun/rundemos.m @@ -64,10 +64,10 @@ endfunction function run_all_demos (directory, do_class_dirs) - flist = dir (directory); + flist = readdir (directory); dirs = {}; for i = 1:numel (flist) - f = flist(i).name; + f = flist{i}; if ((length (f) > 2 && strcmpi (f((end-1):end), ".m")) || (length (f) > 3 && strcmpi (f((end-2):end), ".cc"))) f = fullfile (directory, f); @@ -81,9 +81,11 @@ input ("Press to continue: ", "s"); endif endif - elseif (flist(i).isdir && f(1) == "@") + elseif (f(1) == "@") f = fullfile (directory, f); - dirs = {dirs{:}, f}; + if (isdir (f)) + dirs(end+1) = f; + endif endif endfor @@ -101,9 +103,9 @@ if (f < 0) error ("rundemos: fopen failed: %s", f); else - str = fscanf (fid, "%s"); + str = fread (fid, "*char").'; fclose (fid); - retval = strfind (str, "%!demo"); + retval = ! isempty (regexp (str, '^%!demo', 'lineanchors', 'once')); endif endfunction diff --git a/scripts/testfun/runtests.m b/scripts/testfun/runtests.m --- a/scripts/testfun/runtests.m +++ b/scripts/testfun/runtests.m @@ -64,13 +64,13 @@ endfunction function run_all_tests (directory, do_class_dirs) - flist = dir (directory); + flist = readdir (directory); dirs = {}; no_tests = {}; printf ("Processing files in %s:\n\n", directory); fflush (stdout); for i = 1:numel (flist) - f = flist(i).name; + f = flist{i}; if ((length (f) > 2 && strcmpi (f((end-1):end), ".m")) || (length (f) > 3 && strcmpi (f((end-2):end), ".cc"))) ff = fullfile (directory, f); @@ -80,11 +80,13 @@ print_pass_fail (n, p); fflush (stdout); elseif (has_functions (ff)) - no_tests{end+1} = f; + no_tests(end+1) = f; endif - elseif (flist(i).isdir && f(1) == "@") + elseif (f(1) == "@") f = fullfile (directory, f); - dirs = {dirs{:}, f}; + if (isdir (f)) + dirs(end+1) = f; + endif endif endfor if (! isempty (no_tests)) @@ -108,7 +110,7 @@ if (fid >= 0) str = fread (fid, "*char")'; fclose (fid); - retval = ! isempty (regexp (str,'^(DEFUN|DEFUN_DLD|DEFUNX)\>', + retval = ! isempty (regexp (str,'^(?:DEFUN|DEFUN_DLD|DEFUNX)\>', 'lineanchors', 'once')); else error ("fopen failed: %s", f);