Mercurial > hg > octave-lyh
changeset 6071:950d8cb39617
[project @ 2006-10-23 19:30:28 by jwe]
author | jwe |
---|---|
date | Mon, 23 Oct 2006 19:30:28 +0000 |
parents | df821c22355c |
children | 4036e6fca790 |
files | ChangeLog emacs/Makefile.in emacs/octave-tags emacs/octave-tags.1 emacs/otags emacs/otags.1 src/ChangeLog src/mex.cc |
diffstat | 8 files changed, 137 insertions(+), 99 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-10-23 John W. Eaton <jwe@octave.org> + + * emacs/Makefile.in (SOURCES, DISTFILES, install, install-strip, + uninstall): Handle otags name change. + * emacs/octave-tags, emacs/octave-tags.1: Rename from otags. + 2006-10-17 John W. Eaton <jwe@octave.org> * configure.in: Check for _isnan, _finite, and _copysign.
--- a/emacs/Makefile.in +++ b/emacs/Makefile.in @@ -21,19 +21,19 @@ EL_FILES = octave-hlp.el octave-inf.el octave-mod.el -SOURCES = $(EL_FILES) otags +SOURCES = $(EL_FILES) octave-tags -DISTFILES = Makefile.in $(EL_FILES) otags otags.1 NEWS TODO README +DISTFILES = Makefile.in $(EL_FILES) octave-tags octave-tags.1 NEWS TODO README all: .PHONY: all install install-strip: - $(INSTALL_SCRIPT) otags $(DESTDIR)$(bindir)/otags + $(INSTALL_SCRIPT) octave-tags $(DESTDIR)$(bindir)/octave-tags .PHONY: install install-strip uninstall: - rm -f $(DESTDIR)$(bindir)/otags + rm -f $(DESTDIR)$(bindir)/octave-tags .PHONY: uninstall tags:
new file mode 100644 --- /dev/null +++ b/emacs/octave-tags @@ -0,0 +1,29 @@ +#! /bin/sh + +# Generate a TAGS file from a set of Octave .m files for use with Emacs. +# +# Run as '$ octave-tags' in the given Octave directory to generate a +# TAGS file. If you want to include another directory, add a line +# prior to the "*.m" line containing something like +# `--include=/path/to/other/directory/TAGS" \'. + +# Tags are generated for function names and for global variables. For +# global variables it doesn't work for more than one line global +# variables. :-( + +# Tags are also created for lines of the form '###key foobar' so that +# you can jump to this specific place just by typing `M-. foobar'. +# Note that tags are not generated for scripts so that you have to add +# a line by yourself of the form `###key <script-name>' if you want to +# jump to it. :-( + +# Author: Mario Storti <mstorti@minerva.unl.edu.ar> + +etags --lang=none \ + --regex='/[ \t]*function.*=[ \t]*\([^ \t()]*\)[ \t]*(/\1/' \ + --regex='/[ \t]*function.*=[ \t]*\([^ \t()]*\)[ \t]*$/\1/' \ + --regex='/[ \t]*function[ \t]*\([^ \t()]*\)[ \t]*(/\1/' \ + --regex='/[ \t]*function[ \t]*\([^ \t()]*\)[ \t]*$/\1/' \ + --regex='/###key \(.*\)/\1/' \ + --regex='/[ \t]*global[ \t].*/' \ + *.m
new file mode 100644 --- /dev/null +++ b/emacs/octave-tags.1 @@ -0,0 +1,46 @@ +.\" Man page contributed by Dirk Eddelbuettel <edd@debian.org> +.\" and released under the GNU GPL +.TH OCTAVE-TAGS 1 "31 October 2001" "GNU Octave" +.SH NAME +OCTAVE-TAGS - Generate Emacs tags file from GNU Octave code +.SH SYNOPSIS +.BR octave-tags\ [--include\ dir] +\fIfile\fP .\|.\|. +.SH DESCRIPTION +.PP +.B octave-tags +program is used to create a tag table file, in a format understood by +.BR emacs (1) +and +.BR xemacs (1). +.B octave-tags +reads the files specified on the command line, and write a tag table +(defaults: `TAGS') in the current working directory. Files specified with +relative file names will be recorded in the tag table with file names +relative to the directory where the tag table resides. Files specified with +absolute file names will be recorded with absolute file names. + +The +.I --include +option can be used to specify another directoy with Octave files for which +tags shall be generated. + +Tags are generated for function names and for global variables. For +global variables it doesn't work for more than one line global +variables. + +Tags are also created for lines of the form '###key foobar' so that +you can jump to this specific place just by typing `M-. foobar'. +Note that tags are not generated for scripts so that you have to add +a line by yourself of the form `###key <script-name>' if you want to +jump to it. + +.SH SEE ALSO +.BR etags (1). + +.SH AUTHORS +Mario Storti <mstorti@minerva.unl.edu.ar> + +This manual page was contributed by Dirk Eddelbuettel +<edd@debian.org> for the Debian GNU/Linux distribution but +may be used by others.
deleted file mode 100644 --- a/emacs/otags +++ /dev/null @@ -1,29 +0,0 @@ -#! /bin/sh - -# Generate a TAGS file from a set of Octave .m files for use with Emacs. -# -# Run as '$ otags' in the given Octave directory to generate a -# TAGS file. If you want to include another directory, add a line -# prior to the "*.m" line containing something like -# `--include=/path/to/other/directory/TAGS" \'. - -# Tags are generated for function names and for global variables. For -# global variables it doesn't work for more than one line global -# variables. :-( - -# Tags are also created for lines of the form '###key foobar' so that -# you can jump to this specific place just by typing `M-. foobar'. -# Note that tags are not generated for scripts so that you have to add -# a line by yourself of the form `###key <script-name>' if you want to -# jump to it. :-( - -# Author: Mario Storti <mstorti@minerva.unl.edu.ar> - -etags --lang=none \ - --regex='/[ \t]*function.*=[ \t]*\([^ \t()]*\)[ \t]*(/\1/' \ - --regex='/[ \t]*function.*=[ \t]*\([^ \t()]*\)[ \t]*$/\1/' \ - --regex='/[ \t]*function[ \t]*\([^ \t()]*\)[ \t]*(/\1/' \ - --regex='/[ \t]*function[ \t]*\([^ \t()]*\)[ \t]*$/\1/' \ - --regex='/###key \(.*\)/\1/' \ - --regex='/[ \t]*global[ \t].*/' \ - *.m
deleted file mode 100644 --- a/emacs/otags.1 +++ /dev/null @@ -1,46 +0,0 @@ -.\" Man page contributed by Dirk Eddelbuettel <edd@debian.org> -.\" and released under the GNU GPL -.TH OTAGS 1 "31 October 2001" "GNU Octave" -.SH NAME -OTAGS - Generate Emacs tags file from GNU Octave code -.SH SYNOPSIS -.BR otags\ [--include\ dir] -\fIfile\fP .\|.\|. -.SH DESCRIPTION -.PP -.B otags -program is used to create a tag table file, in a format understood by -.BR emacs (1) -and -.BR xemacs (1). -.B otags -reads the files specified on the command line, and write a tag table -(defaults: `TAGS') in the current working directory. Files specified with -relative file names will be recorded in the tag table with file names -relative to the directory where the tag table resides. Files specified with -absolute file names will be recorded with absolute file names. - -The -.I --include -option can be used to specify another directoy with Octave files for which -tags shall be generated. - -Tags are generated for function names and for global variables. For -global variables it doesn't work for more than one line global -variables. - -Tags are also created for lines of the form '###key foobar' so that -you can jump to this specific place just by typing `M-. foobar'. -Note that tags are not generated for scripts so that you have to add -a line by yourself of the form `###key <script-name>' if you want to -jump to it. - -.SH SEE ALSO -.BR etags (1). - -.SH AUTHORS -Mario Storti <mstorti@minerva.unl.edu.ar> - -This manual page was contributed by Dirk Eddelbuettel -<edd@debian.org> for the Debian GNU/Linux distribution but -may be used by others.
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,13 @@ +2006-10-23 John W. Eaton <jwe@octave.org> + + * mex.cc (mex::unmark_array): New function. + (mex::persistent): Define with unmark_array. + (maybe_unmark_array): New function. + (mxArray_struct::set_field_by_number, mxArray_cell::set_cell): + Call maybe_unmark_array on val to avoid freeing val twice on exit + from mex function. + (mxFree): Call xfree, not free. + 2006-10-21 John W. Eaton <jwe@octave.org> * ov-intx.h
--- a/src/mex.cc +++ b/src/mex.cc @@ -1646,12 +1646,7 @@ return data[idx]; } - void set_field_by_number (int index, int key_num, mxArray *val) - { - int idx = nfields * index + key_num; - - data[idx] = val; - } + void set_field_by_number (int index, int key_num, mxArray *val); int get_number_of_fields (void) const { return nfields; } @@ -1763,7 +1758,7 @@ mxArray *get_cell (int idx) const { return data[idx]; } - void set_cell (int idx, mxArray *val) { data[idx] = val; } + void set_cell (int idx, mxArray *val); void *get_data (void) const { return data; } @@ -1961,7 +1956,7 @@ context->arraylist.clear (); } - // allocate a pointer, and mark it to be freed on exit + // Allocate memory. void *malloc_unmarked (size_t n) { void *ptr = ::malloc (n); @@ -1981,6 +1976,7 @@ return ptr; } + // Allocate memory to be freed on exit. void *malloc (size_t n) { void *ptr = malloc_unmarked (n); @@ -1990,7 +1986,7 @@ return ptr; } - // Allocate a pointer to be freed on exit, and initialize to 0. + // Allocate memory and initialize to 0. void *calloc_unmarked (size_t n, size_t t) { void *ptr = malloc_unmarked (n*t); @@ -2000,6 +1996,7 @@ return ptr; } + // Allocate memory to be freed on exit and initialize to 0. void *calloc (size_t n, size_t t) { void *ptr = calloc_unmarked (n, t); @@ -2063,6 +2060,14 @@ return ptr; } + void unmark_array (mxArray *ptr) + { + std::set<mxArray *>::iterator p = arraylist.find (ptr); + + if (p != arraylist.end ()) + arraylist.erase (p); + } + // Make a new array value and initialize from an octave value; it will be // freed on exit unless marked as persistent. mxArray *make_value (const octave_value& ov) @@ -2092,13 +2097,7 @@ } // Remove PTR from the list of arrays to be free on exit. - void persistent (mxArray *ptr) - { - std::set<mxArray *>::iterator p = arraylist.find (ptr); - - if (p != arraylist.end ()) - arraylist.erase (p); - } + void persistent (mxArray *ptr) { unmark_array (ptr); } octave_mex_function *current_mex_function (void) const { @@ -2128,14 +2127,14 @@ mutable char *fname; // Mark a pointer to be freed on exit. - void mark (void *p) + void mark (void *ptr) { #ifdef DEBUG - if (memlist.find (p) != memlist.end ()) + if (memlist.find (ptr) != memlist.end ()) warning ("%s: double registration ignored", function_name ()); #endif - memlist.insert (p); + memlist.insert (ptr); } // Unmark a pointer to be freed on exit, either because it was @@ -2199,6 +2198,29 @@ return mex_context ? mex_context->calloc_unmarked (n, t) : ::calloc (n, t); } +static inline mxArray * +maybe_unmark_array (mxArray *ptr) +{ + if (mex_context) + mex_context->unmark_array (ptr); + + return ptr; +} + +void +mxArray_struct::set_field_by_number (int index, int key_num, mxArray *val) +{ + int idx = nfields * index + key_num; + + data[idx] = maybe_unmark_array (val); +} + +void +mxArray_cell::set_cell (int idx, mxArray *val) +{ + data[idx] = maybe_unmark_array (val); +} + // ------------------------------------------------------------------ // C interface to mxArray objects: @@ -2266,7 +2288,7 @@ if (mex_context) mex_context->free (ptr); else - free (ptr); + xfree (ptr); } static inline mxArray *