# HG changeset patch # User jwe # Date 784519602 0 # Node ID b843a65fa97767fd5d699cea03178b6ff7501e2f # Parent 2f35156aa18b429273ab45a5a523d5dfa39842d4 [project @ 1994-11-11 02:00:28 by jwe] diff -r 2f35156aa18b -r b843a65fa977 scripts/general/reshape.m --- a/scripts/general/reshape.m Fri Nov 11 00:36:31 1994 +0000 +++ b/scripts/general/reshape.m Fri Nov 11 02:06:42 1994 +0000 @@ -31,10 +31,13 @@ [nr, nc] = size (a); if (nr * nc == m * n) tmp = do_fortran_indexing; - do_fortran_indexing = "true"; - retval = zeros (m, n); - retval (:) = a; - do_fortran_indexing = tmp; + unwind_protect + do_fortran_indexing = "true"; + retval = zeros (m, n); + retval (:) = a; + unwind_protect_cleanup + do_fortran_indexing = tmp; + end_unwind_protect else error ("reshape: sizes must match"); endif diff -r 2f35156aa18b -r b843a65fa977 scripts/image/ind2gray.m --- a/scripts/image/ind2gray.m Fri Nov 11 00:36:31 1994 +0000 +++ b/scripts/image/ind2gray.m Fri Nov 11 02:06:42 1994 +0000 @@ -19,18 +19,24 @@ yiq = rgb2ntsc(map); y = yiq(:,1); - # We need Fortran indexing capability, but be sure to save the user's - # preference. +# We need Fortran indexing capability, but be sure to save the user's +# preference. + pref = do_fortran_indexing; - do_fortran_indexing = "true"; + + unwind_protect + + do_fortran_indexing = "true"; - # Replace indices in the input matrix with indexed values in the output - # matrix. - [rows, cols] = size(X); - Y = y(X(:)); - Y = reshape(Y,rows,cols); +# Replace indices in the input matrix with indexed values in the output +# matrix. - # Restore the user's preference. - do_fortran_indexing = pref; + [rows, cols] = size(X); + Y = y(X(:)); + Y = reshape(Y,rows,cols); + + unwind_protect_cleanup + do_fortran_indexing = pref; + end_unwind_protect endfunction diff -r 2f35156aa18b -r b843a65fa977 scripts/image/ind2rgb.m --- a/scripts/image/ind2rgb.m Fri Nov 11 00:36:31 1994 +0000 +++ b/scripts/image/ind2rgb.m Fri Nov 11 02:06:42 1994 +0000 @@ -15,16 +15,21 @@ [hi wi] = size(X); pref = do_fortran_indexing; - do_fortran_indexing = "true"; - R = map(X(:),1); - G = map(X(:),2); - B = map(X(:),3); + unwind_protect + + do_fortran_indexing = "true"; - R = reshape(R,hi,wi); - G = reshape(G,hi,wi); - B = reshape(B,hi,wi); + R = map(X(:),1); + G = map(X(:),2); + B = map(X(:),3); - do_fortran_indexing = pref; + R = reshape(R,hi,wi); + G = reshape(G,hi,wi); + B = reshape(B,hi,wi); + + unwind_protect_cleanup + do_fortran_indexing = pref; + end_unwind_protect endfunction diff -r 2f35156aa18b -r b843a65fa977 scripts/image/rgb2ind.m --- a/scripts/image/rgb2ind.m Fri Nov 11 00:36:31 1994 +0000 +++ b/scripts/image/rgb2ind.m Fri Nov 11 02:06:42 1994 +0000 @@ -19,14 +19,19 @@ map = zeros(hi*wi,3); pref = do_fortran_indexing; - do_fortran_indexing = "true"; + + unwind_protect + + do_fortran_indexing = "true"; - map(:,1) = R(:); - map(:,2) = G(:); - map(:,3) = B(:); + map(:,1) = R(:); + map(:,2) = G(:); + map(:,3) = B(:); - X(:) = 1:(hi*wi); + X(:) = 1:(hi*wi); - do_fortran_indexing = pref; + unwind_protect_cleanup + do_fortran_indexing = pref; + end_unwind_protect endfunction diff -r 2f35156aa18b -r b843a65fa977 scripts/miscellaneous/menu.m --- a/scripts/miscellaneous/menu.m Fri Nov 11 00:36:31 1994 +0000 +++ b/scripts/miscellaneous/menu.m Fri Nov 11 02:06:42 1994 +0000 @@ -34,36 +34,43 @@ # major confusion. save_page_screen_output = page_screen_output; - page_screen_output = "false"; + + unwind_protect + + page_screen_output = "false"; - if (! isempty (t)) - disp (t); - printf ("\n"); - endif + if (! isempty (t)) + disp (t); + printf ("\n"); + endif - nopt = nargin - 1; + nopt = nargin - 1; - while (1) - va_start (); - for i = 1:nopt - printf (" [%2d] ", i); - disp (va_arg ()); - endfor - printf ("\n"); - s = ""; - s = input ("pick a number, any number: ", "s"); - if (strcmp (s, "")) + while (1) + va_start (); + for i = 1:nopt + printf (" [%2d] ", i); + disp (va_arg ()); + endfor printf ("\n"); - continue; - endif - eval (sprintf ("num = %s;", s)); - if (! is_scalar (num) || num < 1 || num > nopt) - printf ("\nerror: input invalid or out of range\n\n"); - else - break; - endif - endwhile + s = ""; + s = input ("pick a number, any number: ", "s"); + if (strcmp (s, "")) + printf ("\n"); + continue; + endif + eval (sprintf ("num = %s;", s)); + if (! is_scalar (num) || num < 1 || num > nopt) + printf ("\nerror: input invalid or out of range\n\n"); + else + break; + endif + endwhile - page_screen_output = save_page_screen_output; + unwind_protect_cleanup + + page_screen_output = save_page_screen_output; + + end_unwind_protect endfunction diff -r 2f35156aa18b -r b843a65fa977 scripts/strings/strcmp.m --- a/scripts/strings/strcmp.m Fri Nov 11 00:36:31 1994 +0000 +++ b/scripts/strings/strcmp.m Fri Nov 11 02:06:42 1994 +0000 @@ -39,9 +39,12 @@ status = 1; else tmp = implicit_str_to_num_ok; - implicit_str_to_num_ok = "true"; - status = all (s1 == s2); - implicit_str_to_num_ok = tmp; + unwind_protect + implicit_str_to_num_ok = "true"; + status = all (s1 == s2); + unwind_protect_cleanup + implicit_str_to_num_ok = tmp; + end_unwind_protect endif endif endif