Mercurial > hg > xemacs-beta
comparison src/editfns.c @ 4990:8f0cf4fd3d2c
Automatic merge
| author | Ben Wing <ben@xemacs.org> |
|---|---|
| date | Sat, 06 Feb 2010 04:01:46 -0600 |
| parents | 3c3c1d139863 |
| children | 1537701f08a1 |
comparison
equal
deleted
inserted
replaced
| 4989:d2ec55325515 | 4990:8f0cf4fd3d2c |
|---|---|
| 93 return; | 93 return; |
| 94 | 94 |
| 95 if ((p = egetenv ("NAME"))) | 95 if ((p = egetenv ("NAME"))) |
| 96 /* I don't think it's the right thing to do the ampersand | 96 /* I don't think it's the right thing to do the ampersand |
| 97 modification on NAME. Not that it matters anymore... -hniksic */ | 97 modification on NAME. Not that it matters anymore... -hniksic */ |
| 98 Vuser_full_name = build_intstring (p); | 98 Vuser_full_name = build_istring (p); |
| 99 else | 99 else |
| 100 Vuser_full_name = Fuser_full_name (Qnil); | 100 Vuser_full_name = Fuser_full_name (Qnil); |
| 101 } | 101 } |
| 102 | 102 |
| 103 DEFUN ("char-to-string", Fchar_to_string, 1, 1, 0, /* | 103 DEFUN ("char-to-string", Fchar_to_string, 1, 1, 0, /* |
| 647 tmpdir = (Ibyte *) "/tmp"; | 647 tmpdir = (Ibyte *) "/tmp"; |
| 648 } | 648 } |
| 649 } | 649 } |
| 650 #endif | 650 #endif |
| 651 | 651 |
| 652 return build_intstring (tmpdir); | 652 return build_istring (tmpdir); |
| 653 } | 653 } |
| 654 | 654 |
| 655 DEFUN ("user-login-name", Fuser_login_name, 0, 1, 0, /* | 655 DEFUN ("user-login-name", Fuser_login_name, 0, 1, 0, /* |
| 656 Return the name under which the user logged in, as a string. | 656 Return the name under which the user logged in, as a string. |
| 657 This is based on the effective uid, not the real uid. | 657 This is based on the effective uid, not the real uid. |
| 676 returned_name = user_login_name (NULL); | 676 returned_name = user_login_name (NULL); |
| 677 } | 677 } |
| 678 /* #### - I believe this should return nil instead of "unknown" when pw==0 | 678 /* #### - I believe this should return nil instead of "unknown" when pw==0 |
| 679 pw=0 is indicated by a null return from user_login_name | 679 pw=0 is indicated by a null return from user_login_name |
| 680 */ | 680 */ |
| 681 return returned_name ? build_intstring (returned_name) : Qnil; | 681 return returned_name ? build_istring (returned_name) : Qnil; |
| 682 } | 682 } |
| 683 | 683 |
| 684 /* This function may be called from other C routines when a | 684 /* This function may be called from other C routines when a |
| 685 character string representation of the user_login_name is | 685 character string representation of the user_login_name is |
| 686 needed but a Lisp Object is not. The UID is passed by | 686 needed but a Lisp Object is not. The UID is passed by |
| 742 ()) | 742 ()) |
| 743 { | 743 { |
| 744 struct passwd *pw = qxe_getpwuid (getuid ()); | 744 struct passwd *pw = qxe_getpwuid (getuid ()); |
| 745 /* #### - I believe this should return nil instead of "unknown" when pw==0 */ | 745 /* #### - I believe this should return nil instead of "unknown" when pw==0 */ |
| 746 | 746 |
| 747 return build_string (pw ? pw->pw_name : "unknown"); | 747 return build_extstring (pw ? pw->pw_name : "unknown", Quser_name_encoding); |
| 748 } | 748 } |
| 749 | 749 |
| 750 DEFUN ("user-uid", Fuser_uid, 0, 0, 0, /* | 750 DEFUN ("user-uid", Fuser_uid, 0, 0, 0, /* |
| 751 Return the effective uid of Emacs, as an integer. | 751 Return the effective uid of Emacs, as an integer. |
| 752 */ | 752 */ |
| 829 | 829 |
| 830 void | 830 void |
| 831 uncache_home_directory (void) | 831 uncache_home_directory (void) |
| 832 { | 832 { |
| 833 if (cached_home_directory) | 833 if (cached_home_directory) |
| 834 xfree (cached_home_directory, Ibyte *); | 834 xfree (cached_home_directory); |
| 835 cached_home_directory = NULL; | 835 cached_home_directory = NULL; |
| 836 } | 836 } |
| 837 | 837 |
| 838 /* Returns the home directory */ | 838 /* Returns the home directory */ |
| 839 Ibyte * | 839 Ibyte * |
| 867 /* Unix, typically. | 867 /* Unix, typically. |
| 868 Using "/" isn't quite right, but what should we do? | 868 Using "/" isn't quite right, but what should we do? |
| 869 We probably should try to extract pw_dir from /etc/passwd, | 869 We probably should try to extract pw_dir from /etc/passwd, |
| 870 before falling back to this. */ | 870 before falling back to this. */ |
| 871 cached_home_directory | 871 cached_home_directory |
| 872 = qxestrdup ((const Ibyte *)DEFAULT_DIRECTORY_FALLBACK); | 872 = qxestrdup ((const Ibyte *) DEFAULT_DIRECTORY_FALLBACK); |
| 873 output_home_warning = 1; | 873 output_home_warning = 1; |
| 874 } | 874 } |
| 875 } | 875 } |
| 876 if (initialized && output_home_warning) | 876 if (initialized && output_home_warning) |
| 877 { | 877 { |
| 893 ()) | 893 ()) |
| 894 { | 894 { |
| 895 Ibyte *path = get_home_directory (); | 895 Ibyte *path = get_home_directory (); |
| 896 | 896 |
| 897 return !path ? Qnil : | 897 return !path ? Qnil : |
| 898 Fexpand_file_name (Fsubstitute_in_file_name (build_intstring (path)), | 898 Fexpand_file_name (Fsubstitute_in_file_name (build_istring (path)), |
| 899 Qnil); | 899 Qnil); |
| 900 } | 900 } |
| 901 | 901 |
| 902 DEFUN ("system-name", Fsystem_name, 0, 0, 0, /* | 902 DEFUN ("system-name", Fsystem_name, 0, 0, 0, /* |
| 903 Return the name of the machine you are running on, as a string. | 903 Return the name of the machine you are running on, as a string. |
| 1066 while (1) | 1066 while (1) |
| 1067 { | 1067 { |
| 1068 Extbyte *buf = alloca_extbytes (size); | 1068 Extbyte *buf = alloca_extbytes (size); |
| 1069 Extbyte *formext; | 1069 Extbyte *formext; |
| 1070 /* make a copy of the static buffer returned by localtime() */ | 1070 /* make a copy of the static buffer returned by localtime() */ |
| 1071 struct tm tm = * localtime(&value); | 1071 struct tm tm = *localtime (&value); |
| 1072 | 1072 |
| 1073 *buf = 1; | 1073 *buf = 1; |
| 1074 | 1074 |
| 1075 /* !!#### this use of external here is not totally safe, and | 1075 /* !!#### this use of external here is not totally safe, and |
| 1076 potentially data lossy. */ | 1076 potentially data lossy. */ |
| 1077 LISP_STRING_TO_EXTERNAL (format_string, formext, | 1077 formext = LISP_STRING_TO_EXTERNAL (format_string, |
| 1078 Qtime_function_encoding); | 1078 Qtime_function_encoding); |
| 1079 if (emacs_strftime (buf, size, formext, &tm) | 1079 if (emacs_strftime (buf, size, formext, &tm) |
| 1080 || !*buf) | 1080 || !*buf) |
| 1081 return build_ext_string (buf, Qtime_function_encoding); | 1081 return build_extstring (buf, Qtime_function_encoding); |
| 1082 /* If buffer was too small, make it bigger. */ | 1082 /* If buffer was too small, make it bigger. */ |
| 1083 size *= 2; | 1083 size *= 2; |
| 1084 } | 1084 } |
| 1085 } | 1085 } |
| 1086 | 1086 |
| 1186 Extbyte tzbuf[100]; | 1186 Extbyte tzbuf[100]; |
| 1187 Extbyte *tzstring; | 1187 Extbyte *tzstring; |
| 1188 Extbyte **oldenv = environ, **newenv; | 1188 Extbyte **oldenv = environ, **newenv; |
| 1189 | 1189 |
| 1190 if (STRINGP (zone)) | 1190 if (STRINGP (zone)) |
| 1191 LISP_STRING_TO_EXTERNAL (zone, tzstring, Qtime_zone_encoding); | 1191 tzstring = LISP_STRING_TO_EXTERNAL (zone, Qtime_zone_encoding); |
| 1192 else if (INTP (zone)) | 1192 else if (INTP (zone)) |
| 1193 { | 1193 { |
| 1194 int abszone = abs (XINT (zone)); | 1194 int abszone = abs (XINT (zone)); |
| 1195 sprintf (tzbuf, "XXX%s%d:%02d:%02d", "-" + (XINT (zone) < 0), | 1195 sprintf (tzbuf, "XXX%s%d:%02d:%02d", "-" + (XINT (zone) < 0), |
| 1196 abszone / (60*60), (abszone/60) % 60, abszone % 60); | 1196 abszone / (60*60), (abszone/60) % 60, abszone % 60); |
| 1235 */ | 1235 */ |
| 1236 (specified_time)) | 1236 (specified_time)) |
| 1237 { | 1237 { |
| 1238 time_t value; | 1238 time_t value; |
| 1239 Ibyte *the_ctime; | 1239 Ibyte *the_ctime; |
| 1240 EMACS_INT len; /* this is what make_ext_string() accepts; #### | 1240 EMACS_INT len; /* this is what make_extstring() accepts; #### |
| 1241 should it be an Bytecount? */ | 1241 should it be an Bytecount? */ |
| 1242 | 1242 |
| 1243 if (! lisp_to_time (specified_time, &value)) | 1243 if (! lisp_to_time (specified_time, &value)) |
| 1244 value = -1; | 1244 value = -1; |
| 1245 the_ctime = qxe_ctime (&value); | 1245 the_ctime = qxe_ctime (&value); |
| 1318 if (t->tm_isdst == 0 || t->tm_isdst == 1) | 1318 if (t->tm_isdst == 0 || t->tm_isdst == 1) |
| 1319 s = tzname[t->tm_isdst]; | 1319 s = tzname[t->tm_isdst]; |
| 1320 #endif | 1320 #endif |
| 1321 #endif /* not HAVE_TM_ZONE */ | 1321 #endif /* not HAVE_TM_ZONE */ |
| 1322 if (s) | 1322 if (s) |
| 1323 tem = build_ext_string (s, Qtime_zone_encoding); | 1323 tem = build_extstring (s, Qtime_zone_encoding); |
| 1324 else | 1324 else |
| 1325 { | 1325 { |
| 1326 Ibyte buf[6]; | 1326 Ibyte buf[6]; |
| 1327 | 1327 |
| 1328 /* No local time zone name is available; use "+-NNNN" instead. */ | 1328 /* No local time zone name is available; use "+-NNNN" instead. */ |
| 1329 int am = (offset < 0 ? -offset : offset) / 60; | 1329 int am = (offset < 0 ? -offset : offset) / 60; |
| 1330 qxesprintf (buf, "%c%02d%02d", (offset < 0 ? '-' : '+'), am/60, | 1330 qxesprintf (buf, "%c%02d%02d", (offset < 0 ? '-' : '+'), am/60, |
| 1331 am%60); | 1331 am%60); |
| 1332 tem = build_intstring (buf); | 1332 tem = build_istring (buf); |
| 1333 } | 1333 } |
| 1334 return list2 (make_int (offset), tem); | 1334 return list2 (make_int (offset), tem); |
| 1335 } | 1335 } |
| 1336 else | 1336 else |
| 1337 return list2 (Qnil, Qnil); | 1337 return list2 (Qnil, Qnil); |
| 1432 if (NILP (tz)) | 1432 if (NILP (tz)) |
| 1433 tzstring = 0; | 1433 tzstring = 0; |
| 1434 else | 1434 else |
| 1435 { | 1435 { |
| 1436 CHECK_STRING (tz); | 1436 CHECK_STRING (tz); |
| 1437 LISP_STRING_TO_EXTERNAL (tz, tzstring, Qtime_zone_encoding); | 1437 tzstring = LISP_STRING_TO_EXTERNAL (tz, Qtime_zone_encoding); |
| 1438 } | 1438 } |
| 1439 | 1439 |
| 1440 set_time_zone_rule (tzstring); | 1440 set_time_zone_rule (tzstring); |
| 1441 if (environbuf) | 1441 if (environbuf) |
| 1442 xfree (environbuf, Extbyte **); | 1442 xfree (environbuf); |
| 1443 environbuf = environ; | 1443 environbuf = environ; |
| 1444 | 1444 |
| 1445 return Qnil; | 1445 return Qnil; |
| 1446 } | 1446 } |
| 1447 | 1447 |
