annotate src/shared-fcns.h @ 18360:f1ee47866e6b stable

use common code to get OCTAVE_HOME in main, octave-config and mkoctfile * src/shared-fcns.h: New file. * src/Makefile.in: Include it in the list of headers to distribute. * main.in.cc, mkoctfile.in.cc, octave-config.in.cc: Use functions from shared-fcns.h to find and substitute OCTAVE_HOME.
author John W. Eaton <jwe@octave.org>
date Fri, 24 Jan 2014 03:40:55 -0500
parents
children e0b96a751afc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18360
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1 /*
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
3 Copyright (C) 2008-2013 Michael Goffioul
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
4
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
5 This file is part of Octave.
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
6
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
10 option) any later version.
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
11
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
15 for more details.
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
16
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
18 along with Octave; see the file COPYING. If not, see
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
19 <http://www.gnu.org/licenses/>.
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
20
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
21 */
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
22
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
23 #if defined (__WIN32__) && ! defined (_POSIX_VERSION)
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
24
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
25 #include <windows.h>
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
26
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
27 #ifdef _MSC_VER
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
28 #define popen _popen
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
29 #define pclose _pclose
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
30 #endif
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
31
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
32 static std::string
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
33 w32_get_octave_home (void)
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
34 {
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
35 std::string retval;
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
36
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
37 std::string bin_dir;
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
38
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
39 HANDLE h = CreateToolhelp32Snapshot (TH32CS_SNAPMODULE
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
40 #ifdef TH32CS_SNAPMODULE32
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
41 | TH32CS_SNAPMODULE32
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
42 #endif
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
43 , 0);
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
44
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
45 if (h != INVALID_HANDLE_VALUE)
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
46 {
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
47 MODULEENTRY32 mod_info;
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
48
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
49 ZeroMemory (&mod_info, sizeof (mod_info));
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
50 mod_info.dwSize = sizeof (mod_info);
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
51
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
52 if (Module32First (h, &mod_info))
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
53 {
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
54 do
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
55 {
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
56 std::string mod_name (mod_info.szModule);
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
57
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
58 if (mod_name.find ("octave") != std::string::npos)
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
59 {
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
60 bin_dir = mod_info.szExePath;
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
61
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
62 if (bin_dir[bin_dir.length () - 1] != '\\')
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
63 bin_dir.append (1, '\\');
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
64
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
65 break;
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
66 }
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
67 }
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
68 while (Module32Next (h, &mod_info));
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
69 }
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
70
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
71 CloseHandle (h);
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
72 }
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
73
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
74 if (! bin_dir.empty ())
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
75 {
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
76 size_t pos = bin_dir.rfind ("\\bin\\");
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
77
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
78 if (pos != std::string::npos)
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
79 retval = bin_dir.substr (0, pos);
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
80 }
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
81
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
82 return retval;
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
83 }
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
84
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
85 #endif
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
86
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
87 // Find the directory where the octave binary is supposed to be
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
88 // installed.
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
89
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
90 #if (defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) \
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
91 && ! defined (OCTAVE_HAVE_POSIX_FILESYSTEM))
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
92 static const char dir_sep_char = '\\';
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
93 #else
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
94 static const char dir_sep_char = '/';
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
95 #endif
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
96
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
97 static std::string
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
98 octave_getenv (const std::string& name)
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
99 {
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
100 char *value = ::getenv (name.c_str ());
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
101
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
102 return value ? value : "";
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
103 }
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
104
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
105 static std::string
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
106 get_octave_home (void)
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
107 {
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
108 std::string oh = octave_getenv ("OCTAVE_HOME");
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
109
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
110 #if defined (__WIN32__) && ! defined (_POSIX_VERSION)
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
111 if (oh.empty ())
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
112 oh = w32_get_octave_home ();
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
113 #endif
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
114
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
115 return oh.empty () ? std::string (OCTAVE_PREFIX) : oh;
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
116 }
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
117
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
118 static std::string
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
119 subst_octave_home (const std::string& s)
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
120 {
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
121 std::string retval;
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
122
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
123 std::string octave_home = get_octave_home ();
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
124
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
125 std::string prefix = OCTAVE_PREFIX;
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
126
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
127 retval = s;
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
128
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
129 if (octave_home != prefix)
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
130 {
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
131 octave_idx_type len = prefix.length ();
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
132
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
133 if (s.substr (0, len) == prefix)
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
134 retval.replace (0, len, octave_home);
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
135 }
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
136
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
137 if (dir_sep_char != '/')
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
138 std::replace (retval.begin (), retval.end (), '/', dir_sep_char);
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
139
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
140 return retval;
f1ee47866e6b use common code to get OCTAVE_HOME in main, octave-config and mkoctfile
John W. Eaton <jwe@octave.org>
parents:
diff changeset
141 }