[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

function calls vs indexing (was Re: Extra spaces in functions)

From: John Eaton
Subject: function calls vs indexing (was Re: Extra spaces in functions)
Date: Fri, 25 Aug 1995 12:52:29 -0500

Doug Warner <address@hidden> wrote:

: >>>>> "Eyal" == Eyal Doron <address@hidden> writes:
:     Eyal> Hi, On the subject of extra spaces screwing up .M files in
:     Eyal> whitespace_in_literal_matrix = "traditional" mode, you might
:     Eyal> me interested in the following:
:     Eyal>  grep -n "\[.*zeros (" lib/octave/1.1.1/m/*/*.m
: The command
:   grep -n "\[[^]]*[[:alpha:]]\{1,\} (" lib/octave/1.1.1/m/*/*.m
: shows other function calls besides zeros.

Here is a way to check all the function files, without having to write
a sed/grep/awk/perl parser yourself:

1. Save the following script in a file, say ~/check_octave_functions

  # script to check for dependency on whitespace_in_literal_matrix
  # Originally by R. D. Auchterlounie <address@hidden>

  1;  # Don't interpret this a file that defines a single function.

  function t = wlm_check (wlm, fname)
    whitespace_in_literal_matrix = wlm;
    bc = "printf (\" %s\", wlm)";
    eval (["t = type ", fname, ";"], ["t = \"failed\";", bc]);

  # Someone should make fgets work for a single argument, or implement
  # fgetl!  :-)

  while (isstr (fname = fgets (stdin, 100)))

    # Someone should improve Octave's string handling capabilities! :-)

    tmp = toascii (fname);
    tmp (length (tmp)) = 0;
    fname = setstr (tmp);

    printf ("checking %s ...", fname);

    eval (["clear ", fname]); trd = wlm_check ("traditional", fname);
    eval (["clear ", fname]); ign = wlm_check ("ignore", fname);
    eval (["clear ", fname]); def = wlm_check ("default", fname);

    if (strcmp  (trd, "failed")
        || strcmp (ign, "failed")
        || strcmp (def, "failed"))
      printf (" FAILED\n");
      printf (" ok\n");


2. cd to the top of the directory tree that you want to check.

3. Execute the following command:

  find . -name '*.m' -print | \
    sed -e 's,^.*/,,' -e 's,\.m$,,' | \
    octave --silent --path "`pwd`//:" ~/check_octave_functions

  This will print a list of all the functions as they are checked and
  tell you which functions pass or fail the test.

Thanks to R. D. Auchterlounie <address@hidden> for writing the
initial version of this.

I've used it to find and remove all dependencies on
whitespace_in_literal_matrix in my sources.  I'll be using some
variant of it to check for other similar problems, and it should
eventually end up in Octave's test suite so that these kinds of
problems don't reappear in the future.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]