Mercurial > octave
comparison liboctave/system/oct-env.cc @ 21614:9bb39b754ab1
finish previous change to octave_env::set_program_name
* oct-env.cc (octave_env::set_program_name):
Only perform initialization once.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 12 Apr 2016 10:36:36 -0400 |
parents | eff26982a19b |
children | aba2e6293dd8 |
comparison
equal
deleted
inserted
replaced
21613:e15d3387fc59 | 21614:9bb39b754ab1 |
---|---|
259 } | 259 } |
260 | 260 |
261 void | 261 void |
262 octave_env::do_set_program_name (const std::string& s) const | 262 octave_env::do_set_program_name (const std::string& s) const |
263 { | 263 { |
264 bool initialized = false; | 264 static bool initialized = false; |
265 | 265 |
266 if (! initialized) | 266 if (! initialized) |
267 { | 267 { |
268 // The string passed to gnulib's ::set_program_name function must | 268 // The string passed to gnulib's ::set_program_name function must |
269 // exist for the duration of the program so allocate a copy here | 269 // exist for the duration of the program so allocate a copy here |
281 | 281 |
282 // Also keep a shortened version of the program name. | 282 // Also keep a shortened version of the program name. |
283 prog_name = (pos == std::string::npos | 283 prog_name = (pos == std::string::npos |
284 ? prog_invocation_name | 284 ? prog_invocation_name |
285 : prog_invocation_name.substr (pos+1)); | 285 : prog_invocation_name.substr (pos+1)); |
286 | |
287 initialized = true; | |
286 } | 288 } |
287 } | 289 } |
288 | 290 |
289 // Return a pretty pathname. If the first part of the pathname is the | 291 // Return a pretty pathname. If the first part of the pathname is the |
290 // same as $HOME, then replace that with '~'. | 292 // same as $HOME, then replace that with '~'. |