comparison liboctave/oct-env.cc @ 2934:dddc1b5c324e

[project @ 1997-05-05 22:56:37 by jwe]
author jwe
date Mon, 05 May 1997 22:59:00 +0000
parents 66ef74ee5d9f
children 9d26524e2869
comparison
equal deleted inserted replaced
2933:b53d9b2acd88 2934:dddc1b5c324e
48 #include <sys/types.h> 48 #include <sys/types.h>
49 #endif 49 #endif
50 #include <unistd.h> 50 #include <unistd.h>
51 #endif 51 #endif
52 52
53 #ifdef HAVE_PWD_H
54 #include <pwd.h>
55 #endif
56
57 #include "lo-error.h" 53 #include "lo-error.h"
58 #include "lo-sysdep.h" 54 #include "lo-sysdep.h"
59 #include "lo-utils.h" 55 #include "lo-utils.h"
60 #include "oct-env.h" 56 #include "oct-env.h"
57 #include "oct-passwd.h"
61 58
62 octave_env::octave_env (void) 59 octave_env::octave_env (void)
63 : follow_symbolic_links (true), verbatim_pwd (true), 60 : follow_symbolic_links (true), verbatim_pwd (true),
64 current_directory (), program_name (), program_invocation_name (), 61 current_directory (), program_name (), program_invocation_name (),
65 user_name (), host_name () 62 user_name (), host_name ()
372 // XXX FIXME XXX -- is it possible for this to change while Octave 369 // XXX FIXME XXX -- is it possible for this to change while Octave
373 // is running? 370 // is running?
374 371
375 if (user_name.empty ()) 372 if (user_name.empty ())
376 { 373 {
377 struct passwd *entry = getpwuid (getuid ()); 374 octave_passwd pw = octave_passwd::getpwuid (getuid ());
378 375
379 user_name = entry ? entry->pw_name : "I have no name!"; 376 user_name = pw.empty () ? string ("I have no name!") : pw.name ();
380 } 377 }
381 378
382 return user_name; 379 return user_name;
383 } 380 }
384 381