comparison src/editfns.c @ 5125:b5df3737028a ben-lisp-object

merge
author Ben Wing <ben@xemacs.org>
date Wed, 24 Feb 2010 01:58:04 -0600
parents 3c3c1d139863
children 1537701f08a1
comparison
equal deleted inserted replaced
5124:623d57b7fbe8 5125:b5df3737028a
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, Qnative); 1077 formext = LISP_STRING_TO_EXTERNAL (format_string,
1078 Qtime_function_encoding);
1078 if (emacs_strftime (buf, size, formext, &tm) 1079 if (emacs_strftime (buf, size, formext, &tm)
1079 || !*buf) 1080 || !*buf)
1080 return build_ext_string (buf, Qnative); 1081 return build_extstring (buf, Qtime_function_encoding);
1081 /* If buffer was too small, make it bigger. */ 1082 /* If buffer was too small, make it bigger. */
1082 size *= 2; 1083 size *= 2;
1083 } 1084 }
1084 } 1085 }
1085 1086
1185 Extbyte tzbuf[100]; 1186 Extbyte tzbuf[100];
1186 Extbyte *tzstring; 1187 Extbyte *tzstring;
1187 Extbyte **oldenv = environ, **newenv; 1188 Extbyte **oldenv = environ, **newenv;
1188 1189
1189 if (STRINGP (zone)) 1190 if (STRINGP (zone))
1190 LISP_STRING_TO_EXTERNAL (zone, tzstring, Qnative); 1191 tzstring = LISP_STRING_TO_EXTERNAL (zone, Qtime_zone_encoding);
1191 else if (INTP (zone)) 1192 else if (INTP (zone))
1192 { 1193 {
1193 int abszone = abs (XINT (zone)); 1194 int abszone = abs (XINT (zone));
1194 sprintf (tzbuf, "XXX%s%d:%02d:%02d", "-" + (XINT (zone) < 0), 1195 sprintf (tzbuf, "XXX%s%d:%02d:%02d", "-" + (XINT (zone) < 0),
1195 abszone / (60*60), (abszone/60) % 60, abszone % 60); 1196 abszone / (60*60), (abszone/60) % 60, abszone % 60);
1234 */ 1235 */
1235 (specified_time)) 1236 (specified_time))
1236 { 1237 {
1237 time_t value; 1238 time_t value;
1238 Ibyte *the_ctime; 1239 Ibyte *the_ctime;
1239 EMACS_INT len; /* this is what make_ext_string() accepts; #### 1240 EMACS_INT len; /* this is what make_extstring() accepts; ####
1240 should it be an Bytecount? */ 1241 should it be an Bytecount? */
1241 1242
1242 if (! lisp_to_time (specified_time, &value)) 1243 if (! lisp_to_time (specified_time, &value))
1243 value = -1; 1244 value = -1;
1244 the_ctime = qxe_ctime (&value); 1245 the_ctime = qxe_ctime (&value);
1317 if (t->tm_isdst == 0 || t->tm_isdst == 1) 1318 if (t->tm_isdst == 0 || t->tm_isdst == 1)
1318 s = tzname[t->tm_isdst]; 1319 s = tzname[t->tm_isdst];
1319 #endif 1320 #endif
1320 #endif /* not HAVE_TM_ZONE */ 1321 #endif /* not HAVE_TM_ZONE */
1321 if (s) 1322 if (s)
1322 tem = build_ext_string (s, Qnative); 1323 tem = build_extstring (s, Qtime_zone_encoding);
1323 else 1324 else
1324 { 1325 {
1325 Ibyte buf[6]; 1326 Ibyte buf[6];
1326 1327
1327 /* No local time zone name is available; use "+-NNNN" instead. */ 1328 /* No local time zone name is available; use "+-NNNN" instead. */
1328 int am = (offset < 0 ? -offset : offset) / 60; 1329 int am = (offset < 0 ? -offset : offset) / 60;
1329 qxesprintf (buf, "%c%02d%02d", (offset < 0 ? '-' : '+'), am/60, 1330 qxesprintf (buf, "%c%02d%02d", (offset < 0 ? '-' : '+'), am/60,
1330 am%60); 1331 am%60);
1331 tem = build_intstring (buf); 1332 tem = build_istring (buf);
1332 } 1333 }
1333 return list2 (make_int (offset), tem); 1334 return list2 (make_int (offset), tem);
1334 } 1335 }
1335 else 1336 else
1336 return list2 (Qnil, Qnil); 1337 return list2 (Qnil, Qnil);
1431 if (NILP (tz)) 1432 if (NILP (tz))
1432 tzstring = 0; 1433 tzstring = 0;
1433 else 1434 else
1434 { 1435 {
1435 CHECK_STRING (tz); 1436 CHECK_STRING (tz);
1436 LISP_STRING_TO_EXTERNAL (tz, tzstring, Qnative); 1437 tzstring = LISP_STRING_TO_EXTERNAL (tz, Qtime_zone_encoding);
1437 } 1438 }
1438 1439
1439 set_time_zone_rule (tzstring); 1440 set_time_zone_rule (tzstring);
1440 if (environbuf) 1441 if (environbuf)
1441 xfree (environbuf, Extbyte **); 1442 xfree (environbuf);
1442 environbuf = environ; 1443 environbuf = environ;
1443 1444
1444 return Qnil; 1445 return Qnil;
1445 } 1446 }
1446 1447
2128 2129
2129 DEFUN ("save-restriction", Fsave_restriction, 0, UNEVALLED, 0, /* 2130 DEFUN ("save-restriction", Fsave_restriction, 0, UNEVALLED, 0, /*
2130 Execute BODY, saving and restoring current buffer's restrictions. 2131 Execute BODY, saving and restoring current buffer's restrictions.
2131 The buffer's restrictions make parts of the beginning and end invisible. 2132 The buffer's restrictions make parts of the beginning and end invisible.
2132 \(They are set up with `narrow-to-region' and eliminated with `widen'.) 2133 \(They are set up with `narrow-to-region' and eliminated with `widen'.)
2133 This special form, `save-restriction', saves the current buffer's restrictions 2134 This special operator, `save-restriction', saves the current buffer's
2134 when it is entered, and restores them when it is exited. 2135 restrictions when it is entered, and restores them when it is exited.
2135 So any `narrow-to-region' within BODY lasts only until the end of the form. 2136 So any `narrow-to-region' within BODY lasts only until the end of the form.
2136 The old restrictions settings are restored 2137 The old restrictions settings are restored
2137 even in case of abnormal exit (throw or error). 2138 even in case of abnormal exit (throw or error).
2138 2139
2139 The value returned is the value of the last form in BODY. 2140 The value returned is the value of the last form in BODY.
2255 CHECK_CHAR_COERCE_INT (character2); 2256 CHECK_CHAR_COERCE_INT (character2);
2256 x1 = XCHAR (character1); 2257 x1 = XCHAR (character1);
2257 x2 = XCHAR (character2); 2258 x2 = XCHAR (character2);
2258 2259
2259 return (!NILP (b->case_fold_search) 2260 return (!NILP (b->case_fold_search)
2260 ? DOWNCASE (b, x1) == DOWNCASE (b, x2) 2261 ? CANONCASE (b, x1) == CANONCASE (b, x2)
2261 : x1 == x2) 2262 : x1 == x2)
2262 ? Qt : Qnil; 2263 ? Qt : Qnil;
2263 } 2264 }
2264 2265
2265 DEFUN ("char=", Fchar_Equal, 2, 2, 0, /* 2266 DEFUN ("char=", Fchar_Equal, 2, 2, 0, /*