Mercurial > hg > xemacs-beta
comparison src/editfns.c @ 380:8626e4521993 r21-2-5
Import from CVS: tag r21-2-5
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:07:10 +0200 |
parents | d883f39b8495 |
children | 4af0ddfb7c5b |
comparison
equal
deleted
inserted
replaced
379:76b7d63099ad | 380:8626e4521993 |
---|---|
368 if that was true previously. That avoids some anomalies. | 368 if that was true previously. That avoids some anomalies. |
369 But it creates others, and it wasn't documented, and it is simpler | 369 But it creates others, and it wasn't documented, and it is simpler |
370 and cleaner never to alter the window/buffer connections. */ | 370 and cleaner never to alter the window/buffer connections. */ |
371 /* I'm certain some code somewhere depends on this behavior. --jwz */ | 371 /* I'm certain some code somewhere depends on this behavior. --jwz */ |
372 /* Even if it did, it certainly doesn't matter anymore, because | 372 /* Even if it did, it certainly doesn't matter anymore, because |
373 this has been the behaviour for countless XEmacs releases | 373 this has been the behavior for countless XEmacs releases |
374 now. --hniksic */ | 374 now. --hniksic */ |
375 if (visible | 375 if (visible |
376 && (current_buffer != XBUFFER (XWINDOW (selected_window)->buffer))) | 376 && (current_buffer != XBUFFER (XWINDOW (selected_window)->buffer))) |
377 switch_to_buffer (Fcurrent_buffer (), Qnil); | 377 switch_to_buffer (Fcurrent_buffer (), Qnil); |
378 #endif | 378 #endif |
547 If BUFFER is nil, the current buffer is assumed. | 547 If BUFFER is nil, the current buffer is assumed. |
548 */ | 548 */ |
549 (buffer)) | 549 (buffer)) |
550 { | 550 { |
551 struct buffer *b = decode_buffer (buffer, 1); | 551 struct buffer *b = decode_buffer (buffer, 1); |
552 | |
553 return beginning_of_line_p (b, BUF_PT (b)) ? Qt : Qnil; | 552 return beginning_of_line_p (b, BUF_PT (b)) ? Qt : Qnil; |
554 } | 553 } |
555 | 554 |
556 DEFUN ("eolp", Feolp, 0, 1, 0, /* | 555 DEFUN ("eolp", Feolp, 0, 1, 0, /* |
557 Return t if point is at the end of a line. | 556 Return t if point is at the end of a line. |
666 */ | 665 */ |
667 char* | 666 char* |
668 user_login_name (int *uid) | 667 user_login_name (int *uid) |
669 { | 668 { |
670 struct passwd *pw = NULL; | 669 struct passwd *pw = NULL; |
671 | 670 |
672 /* uid == NULL to return name of this user */ | 671 /* uid == NULL to return name of this user */ |
673 if (uid != NULL) | 672 if (uid != NULL) |
674 { | 673 { |
675 pw = getpwuid (*uid); | 674 pw = getpwuid (*uid); |
676 return pw ? pw->pw_name : NULL; | 675 return pw ? pw->pw_name : NULL; |
756 (user)) | 755 (user)) |
757 { | 756 { |
758 Lisp_Object user_name; | 757 Lisp_Object user_name; |
759 struct passwd *pw = NULL; | 758 struct passwd *pw = NULL; |
760 Lisp_Object tem; | 759 Lisp_Object tem; |
761 char *p, *q; | 760 const char *p, *q; |
762 | 761 |
763 if (NILP (user) && STRINGP (Vuser_full_name)) | 762 if (NILP (user) && STRINGP (Vuser_full_name)) |
764 return Vuser_full_name; | 763 return Vuser_full_name; |
765 | 764 |
766 user_name = (STRINGP (user) ? user : Fuser_login_name (user)); | 765 user_name = (STRINGP (user) ? user : Fuser_login_name (user)); |
831 { | 830 { |
832 if ((cached_home_directory = getenv("HOME")) == NULL) | 831 if ((cached_home_directory = getenv("HOME")) == NULL) |
833 { | 832 { |
834 #if defined(WINDOWSNT) && !defined(__CYGWIN32__) | 833 #if defined(WINDOWSNT) && !defined(__CYGWIN32__) |
835 char *homedrive, *homepath; | 834 char *homedrive, *homepath; |
836 | 835 |
837 if ((homedrive = getenv("HOMEDRIVE")) != NULL && | 836 if ((homedrive = getenv("HOMEDRIVE")) != NULL && |
838 (homepath = getenv("HOMEPATH")) != NULL) | 837 (homepath = getenv("HOMEPATH")) != NULL) |
839 { | 838 { |
840 cached_home_directory = | 839 cached_home_directory = |
841 (char *) xmalloc(strlen(homedrive) + strlen(homepath) + 1); | 840 (char *) xmalloc(strlen(homedrive) + strlen(homepath) + 1); |
1061 The number of options reflects the `strftime' function. | 1060 The number of options reflects the `strftime' function. |
1062 | 1061 |
1063 BUG: If the charset used by the current locale is not ISO 8859-1, the | 1062 BUG: If the charset used by the current locale is not ISO 8859-1, the |
1064 characters appearing in the day and month names may be incorrect. | 1063 characters appearing in the day and month names may be incorrect. |
1065 */ | 1064 */ |
1066 (format_string, _time)) | 1065 (format_string, time_)) |
1067 { | 1066 { |
1068 time_t value; | 1067 time_t value; |
1069 size_t size; | 1068 size_t size; |
1070 | 1069 |
1071 CHECK_STRING (format_string); | 1070 CHECK_STRING (format_string); |
1072 | 1071 |
1073 if (! lisp_to_time (_time, &value)) | 1072 if (! lisp_to_time (time_, &value)) |
1074 error ("Invalid time specification"); | 1073 error ("Invalid time specification"); |
1075 | 1074 |
1076 /* This is probably enough. */ | 1075 /* This is probably enough. */ |
1077 size = XSTRING_LENGTH (format_string) * 6 + 50; | 1076 size = XSTRING_LENGTH (format_string) * 6 + 50; |
1078 | 1077 |
1113 | 1112 |
1114 if (! lisp_to_time (specified_time, &time_spec)) | 1113 if (! lisp_to_time (specified_time, &time_spec)) |
1115 error ("Invalid time specification"); | 1114 error ("Invalid time specification"); |
1116 | 1115 |
1117 decoded_time = localtime (&time_spec); | 1116 decoded_time = localtime (&time_spec); |
1118 XSETINT (list_args[0], decoded_time->tm_sec); | 1117 list_args[0] = make_int (decoded_time->tm_sec); |
1119 XSETINT (list_args[1], decoded_time->tm_min); | 1118 list_args[1] = make_int (decoded_time->tm_min); |
1120 XSETINT (list_args[2], decoded_time->tm_hour); | 1119 list_args[2] = make_int (decoded_time->tm_hour); |
1121 XSETINT (list_args[3], decoded_time->tm_mday); | 1120 list_args[3] = make_int (decoded_time->tm_mday); |
1122 XSETINT (list_args[4], decoded_time->tm_mon + 1); | 1121 list_args[4] = make_int (decoded_time->tm_mon + 1); |
1123 XSETINT (list_args[5], decoded_time->tm_year + 1900); | 1122 list_args[5] = make_int (decoded_time->tm_year + 1900); |
1124 XSETINT (list_args[6], decoded_time->tm_wday); | 1123 list_args[6] = make_int (decoded_time->tm_wday); |
1125 list_args[7] = (decoded_time->tm_isdst)? Qt : Qnil; | 1124 list_args[7] = (decoded_time->tm_isdst)? Qt : Qnil; |
1126 | 1125 |
1127 /* Make a copy, in case gmtime modifies the struct. */ | 1126 /* Make a copy, in case gmtime modifies the struct. */ |
1128 save_tm = *decoded_time; | 1127 save_tm = *decoded_time; |
1129 decoded_time = gmtime (&time_spec); | 1128 decoded_time = gmtime (&time_spec); |
1130 if (decoded_time == 0) | 1129 if (decoded_time == 0) |
1131 list_args[8] = Qnil; | 1130 list_args[8] = Qnil; |
1132 else | 1131 else |
1133 XSETINT (list_args[8], difftm (&save_tm, decoded_time)); | 1132 list_args[8] = make_int (difftm (&save_tm, decoded_time)); |
1134 return Flist (9, list_args); | 1133 return Flist (9, list_args); |
1135 } | 1134 } |
1136 | 1135 |
1137 static void set_time_zone_rule (char *tzstring); | 1136 static void set_time_zone_rule (char *tzstring); |
1138 | 1137 |
1154 Year numbers less than 100 are treated just like other year numbers. | 1153 Year numbers less than 100 are treated just like other year numbers. |
1155 If you want them to stand for years in this century, you must do that yourself. | 1154 If you want them to stand for years in this century, you must do that yourself. |
1156 */ | 1155 */ |
1157 (int nargs, Lisp_Object *args)) | 1156 (int nargs, Lisp_Object *args)) |
1158 { | 1157 { |
1159 time_t _time; | 1158 time_t the_time; |
1160 struct tm tm; | 1159 struct tm tm; |
1161 Lisp_Object zone = (nargs > 6) ? args[nargs - 1] : Qnil; | 1160 Lisp_Object zone = (nargs > 6) ? args[nargs - 1] : Qnil; |
1162 | 1161 |
1163 CHECK_INT (*args); tm.tm_sec = XINT (*args++); /* second */ | 1162 CHECK_INT (*args); tm.tm_sec = XINT (*args++); /* second */ |
1164 CHECK_INT (*args); tm.tm_min = XINT (*args++); /* minute */ | 1163 CHECK_INT (*args); tm.tm_min = XINT (*args++); /* minute */ |
1170 tm.tm_isdst = -1; | 1169 tm.tm_isdst = -1; |
1171 | 1170 |
1172 if (CONSP (zone)) | 1171 if (CONSP (zone)) |
1173 zone = XCAR (zone); | 1172 zone = XCAR (zone); |
1174 if (NILP (zone)) | 1173 if (NILP (zone)) |
1175 _time = mktime (&tm); | 1174 the_time = mktime (&tm); |
1176 else | 1175 else |
1177 { | 1176 { |
1178 char tzbuf[100]; | 1177 char tzbuf[100]; |
1179 char *tzstring; | 1178 char *tzstring; |
1180 char **oldenv = environ, **newenv; | 1179 char **oldenv = environ, **newenv; |
1193 | 1192 |
1194 /* Set TZ before calling mktime; merely adjusting mktime's returned | 1193 /* Set TZ before calling mktime; merely adjusting mktime's returned |
1195 value doesn't suffice, since that would mishandle leap seconds. */ | 1194 value doesn't suffice, since that would mishandle leap seconds. */ |
1196 set_time_zone_rule (tzstring); | 1195 set_time_zone_rule (tzstring); |
1197 | 1196 |
1198 _time = mktime (&tm); | 1197 the_time = mktime (&tm); |
1199 | 1198 |
1200 /* Restore TZ to previous value. */ | 1199 /* Restore TZ to previous value. */ |
1201 newenv = environ; | 1200 newenv = environ; |
1202 environ = oldenv; | 1201 environ = oldenv; |
1203 free (newenv); | 1202 free (newenv); |
1204 #ifdef LOCALTIME_CACHE | 1203 #ifdef LOCALTIME_CACHE |
1205 tzset (); | 1204 tzset (); |
1206 #endif | 1205 #endif |
1207 } | 1206 } |
1208 | 1207 |
1209 if (_time == (time_t) -1) | 1208 if (the_time == (time_t) -1) |
1210 error ("Specified time is not representable"); | 1209 error ("Specified time is not representable"); |
1211 | 1210 |
1212 return wasteful_word_to_lisp (_time); | 1211 return wasteful_word_to_lisp (the_time); |
1213 } | 1212 } |
1214 | 1213 |
1215 DEFUN ("current-time-string", Fcurrent_time_string, 0, 1, 0, /* | 1214 DEFUN ("current-time-string", Fcurrent_time_string, 0, 1, 0, /* |
1216 Return the current time, as a human-readable string. | 1215 Return the current time, as a human-readable string. |
1217 Programs can use this function to decode a time, | 1216 Programs can use this function to decode a time, |