aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog6
-rw-r--r--src/editfns.c27
2 files changed, 20 insertions, 13 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 16cfc1d6d2f..c477a43693f 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,9 @@
12011-03-16 Paul Eggert <eggert@cs.ucla.edu>
2
3 * editfns.c (init_editfns, Fuser_login_name, Fuser_uid):
4 (Fuser_real_uid, Fuser_full_name): Remove unnecessary casts,
5 some of which prompt warnings from gcc -Wbad-function-cast.
6
12011-03-15 Paul Eggert <eggert@cs.ucla.edu> 72011-03-15 Paul Eggert <eggert@cs.ucla.edu>
2 8
3 * doc.c (Fdocumentation, Fsnarf_documentation): Move locals to 9 * doc.c (Fdocumentation, Fsnarf_documentation): Move locals to
diff --git a/src/editfns.c b/src/editfns.c
index 8d428eb4815..bfe07163cc8 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -122,7 +122,7 @@ Lisp_Object Qboundary;
122void 122void
123init_editfns (void) 123init_editfns (void)
124{ 124{
125 char *user_name; 125 const char *user_name;
126 register char *p; 126 register char *p;
127 struct passwd *pw; /* password entry for the current user */ 127 struct passwd *pw; /* password entry for the current user */
128 Lisp_Object tem; 128 Lisp_Object tem;
@@ -136,7 +136,7 @@ init_editfns (void)
136 return; 136 return;
137#endif /* not CANNOT_DUMP */ 137#endif /* not CANNOT_DUMP */
138 138
139 pw = (struct passwd *) getpwuid (getuid ()); 139 pw = getpwuid (getuid ());
140#ifdef MSDOS 140#ifdef MSDOS
141 /* We let the real user name default to "root" because that's quite 141 /* We let the real user name default to "root" because that's quite
142 accurate on MSDOG and because it lets Emacs find the init file. 142 accurate on MSDOG and because it lets Emacs find the init file.
@@ -148,17 +148,17 @@ init_editfns (void)
148 148
149 /* Get the effective user name, by consulting environment variables, 149 /* Get the effective user name, by consulting environment variables,
150 or the effective uid if those are unset. */ 150 or the effective uid if those are unset. */
151 user_name = (char *) getenv ("LOGNAME"); 151 user_name = getenv ("LOGNAME");
152 if (!user_name) 152 if (!user_name)
153#ifdef WINDOWSNT 153#ifdef WINDOWSNT
154 user_name = (char *) getenv ("USERNAME"); /* it's USERNAME on NT */ 154 user_name = getenv ("USERNAME"); /* it's USERNAME on NT */
155#else /* WINDOWSNT */ 155#else /* WINDOWSNT */
156 user_name = (char *) getenv ("USER"); 156 user_name = getenv ("USER");
157#endif /* WINDOWSNT */ 157#endif /* WINDOWSNT */
158 if (!user_name) 158 if (!user_name)
159 { 159 {
160 pw = (struct passwd *) getpwuid (geteuid ()); 160 pw = getpwuid (geteuid ());
161 user_name = (char *) (pw ? pw->pw_name : "unknown"); 161 user_name = pw ? pw->pw_name : "unknown";
162 } 162 }
163 Vuser_login_name = build_string (user_name); 163 Vuser_login_name = build_string (user_name);
164 164
@@ -1266,9 +1266,9 @@ of the user with that uid, or nil if there is no such user. */)
1266 if (NILP (uid)) 1266 if (NILP (uid))
1267 return Vuser_login_name; 1267 return Vuser_login_name;
1268 1268
1269 id = (uid_t)XFLOATINT (uid); 1269 id = XFLOATINT (uid);
1270 BLOCK_INPUT; 1270 BLOCK_INPUT;
1271 pw = (struct passwd *) getpwuid (id); 1271 pw = getpwuid (id);
1272 UNBLOCK_INPUT; 1272 UNBLOCK_INPUT;
1273 return (pw ? build_string (pw->pw_name) : Qnil); 1273 return (pw ? build_string (pw->pw_name) : Qnil);
1274} 1274}
@@ -1300,7 +1300,7 @@ Value is an integer or a float, depending on the value. */)
1300 /* Make sure we don't produce a negative UID due to signed integer 1300 /* Make sure we don't produce a negative UID due to signed integer
1301 overflow. */ 1301 overflow. */
1302 if (euid < 0) 1302 if (euid < 0)
1303 return make_float ((double)geteuid ()); 1303 return make_float (geteuid ());
1304 return make_fixnum_or_float (euid); 1304 return make_fixnum_or_float (euid);
1305} 1305}
1306 1306
@@ -1316,7 +1316,7 @@ Value is an integer or a float, depending on the value. */)
1316 /* Make sure we don't produce a negative UID due to signed integer 1316 /* Make sure we don't produce a negative UID due to signed integer
1317 overflow. */ 1317 overflow. */
1318 if (uid < 0) 1318 if (uid < 0)
1319 return make_float ((double)getuid ()); 1319 return make_float (getuid ());
1320 return make_fixnum_or_float (uid); 1320 return make_fixnum_or_float (uid);
1321} 1321}
1322 1322
@@ -1339,14 +1339,15 @@ name, or nil if there is no such user. */)
1339 return Vuser_full_name; 1339 return Vuser_full_name;
1340 else if (NUMBERP (uid)) 1340 else if (NUMBERP (uid))
1341 { 1341 {
1342 uid_t u = XFLOATINT (uid);
1342 BLOCK_INPUT; 1343 BLOCK_INPUT;
1343 pw = (struct passwd *) getpwuid ((uid_t) XFLOATINT (uid)); 1344 pw = getpwuid (u);
1344 UNBLOCK_INPUT; 1345 UNBLOCK_INPUT;
1345 } 1346 }
1346 else if (STRINGP (uid)) 1347 else if (STRINGP (uid))
1347 { 1348 {
1348 BLOCK_INPUT; 1349 BLOCK_INPUT;
1349 pw = (struct passwd *) getpwnam (SSDATA (uid)); 1350 pw = getpwnam (SSDATA (uid));
1350 UNBLOCK_INPUT; 1351 UNBLOCK_INPUT;
1351 } 1352 }
1352 else 1353 else