summaryrefslogtreecommitdiff
path: root/math/octave-forge/patches/patch-ae
blob: fcbe764fdc9ea5bda21703800cd2b0cce33e926e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
$NetBSD: patch-ae,v 1.2 2004/10/30 06:56:04 dmcmahill Exp $

--- extra/mex/mex.in.orig	Thu Sep  9 11:48:44 2004
+++ extra/mex/mex.in
@@ -34,6 +34,7 @@ else
 fi
 
 # default the name of the octave function from the first filename
+dir=`dirname $first`
 first=`basename $first`
 #echo "first= $first"
 ext=`echo $first | sed 's;.*\.;.;g'`
@@ -52,6 +53,16 @@ case "$ext" in
   ;;
 esac
 
+# search for a .m file which will be used for the help string
+# in the mex function.
+if test -f $dir/$name.m ; then
+	mfile=$dir/$name.m
+elif test -f ./$name.m ; then
+	mfile=./$name.m
+else
+	mfile=""
+fi
+
 cat <<EOF > mex_$name.cc
 #include <octave/oct.h>
 
@@ -63,10 +74,28 @@ extern "C" {
   const char *mexFunctionName = "$name";
 } ;
 
-DEFUN_DLD($name, args, nargout, "\
+DEFUN_DLD($name, args, nargout,
+EOF
+
+if test "X$mfile" = "X" ; then
+	cat <<EOF >> mex_$name.cc
+"\
 $name not directly documented. Try the following:\n\
    type(file_in_loadpath('$name.m'))\n\
 ")
+EOF
+else
+	@_AWK_@ 'BEGIN{print "\"\\"} 
+		/^[ \t]*$/ {exit} 
+		{gsub(/^%/,""); 
+		gsub(/\\/,"\\\\"); 
+		gsub(/"/,"\\\""); 
+		print $0 "\\n\\"} 
+		END{print "\")"}' \
+		$mfile >> mex_$name.cc
+fi
+
+cat <<EOF >> mex_$name.cc
 {
   octave_value_list $invoke(const octave_value_list &, const int);
   return $invoke(args, nargout);