diff options
| author | Richard M. Stallman | 1994-11-01 08:50:20 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1994-11-01 08:50:20 +0000 |
| commit | 4691c06db4f966b99fe312fb6495f3b27f076a26 (patch) | |
| tree | 70e38b3eb755ec1bc94bcd85fa963f4b34705c84 /src | |
| parent | bc536d847736f466727453ca6aa7c07aef6fce46 (diff) | |
| download | emacs-4691c06db4f966b99fe312fb6495f3b27f076a26.tar.gz emacs-4691c06db4f966b99fe312fb6495f3b27f076a26.zip | |
(init_editfns): Get the username from the environment
variable USERNAME instead of USER.
(Fdecode_time): New function.
(syms_of_editfns): defsubr it.
Diffstat (limited to 'src')
| -rw-r--r-- | src/editfns.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/editfns.c b/src/editfns.c index 654c0da2713..31e4fcb4767 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -79,7 +79,11 @@ init_editfns () | |||
| 79 | or the effective uid if those are unset. */ | 79 | or the effective uid if those are unset. */ |
| 80 | user_name = (char *) getenv ("LOGNAME"); | 80 | user_name = (char *) getenv ("LOGNAME"); |
| 81 | if (!user_name) | 81 | if (!user_name) |
| 82 | #ifdef WINDOWSNT | ||
| 83 | user_name = (char *) getenv ("USERNAME"); /* it's USERNAME on NT */ | ||
| 84 | #else /* WINDOWSNT */ | ||
| 82 | user_name = (char *) getenv ("USER"); | 85 | user_name = (char *) getenv ("USER"); |
| 86 | #endif /* WINDOWSNT */ | ||
| 83 | if (!user_name) | 87 | if (!user_name) |
| 84 | { | 88 | { |
| 85 | pw = (struct passwd *) getpwuid (geteuid ()); | 89 | pw = (struct passwd *) getpwuid (geteuid ()); |
| @@ -683,6 +687,41 @@ The number of options reflects the strftime(3) function.") | |||
| 683 | } | 687 | } |
| 684 | } | 688 | } |
| 685 | 689 | ||
| 690 | DEFUN ("decode-time", Fdecode_time, Sdecode_time, 0, 1, 0, | ||
| 691 | "Decode a time value as (SEC MINUTE HOUR DAY MONTH YEAR DOW DST ZONE).\n\ | ||
| 692 | The optional SPECIFIED-TIME should be a list of (HIGH LOW . IGNORED)\n\ | ||
| 693 | or (HIGH . LOW), as from `current-time' and `file-attributes', or `nil'\n\ | ||
| 694 | to use the current time. The list has the following nine members:\n\ | ||
| 695 | SEC is an integer between 0 and 59. MINUTE is an integer between 0 and 59.\n\ | ||
| 696 | HOUR is an integer between 0 and 23. DAY is an integer between 1 and 31.\n\ | ||
| 697 | MONTH is an integer between 1 and 12. YEAR is an integer indicating the\n\ | ||
| 698 | four-digit year. DOW is the day of week, an integer between 0 and 6, where\n\ | ||
| 699 | 0 is Sunday. DST is t if daylight savings time is effect, otherwise nil.\n\ | ||
| 700 | ZONE is an integer indicating the number of seconds east of Greenwich.\n\ | ||
| 701 | (Note that Common Lisp has different meanings for DOW and ZONE.)") | ||
| 702 | (specified_time) | ||
| 703 | Lisp_Object specified_time; | ||
| 704 | { | ||
| 705 | time_t time_spec; | ||
| 706 | struct tm *decoded_time; | ||
| 707 | Lisp_Object list_args[9]; | ||
| 708 | |||
| 709 | if (! lisp_time_argument (specified_time, &time_spec)) | ||
| 710 | error ("Invalid time specification"); | ||
| 711 | |||
| 712 | decoded_time = localtime (&time_spec); | ||
| 713 | list_args[0] = XFASTINT (decoded_time->tm_sec); | ||
| 714 | list_args[1] = XFASTINT (decoded_time->tm_min); | ||
| 715 | list_args[2] = XFASTINT (decoded_time->tm_hour); | ||
| 716 | list_args[3] = XFASTINT (decoded_time->tm_mday); | ||
| 717 | list_args[4] = XFASTINT (decoded_time->tm_mon + 1); | ||
| 718 | list_args[5] = XFASTINT (decoded_time->tm_year + 1900); | ||
| 719 | list_args[6] = XFASTINT (decoded_time->tm_wday); | ||
| 720 | list_args[7] = (decoded_time->tm_isdst)? Qt : Qnil; | ||
| 721 | list_args[8] = XFASTINT (decoded_time->tm_gmtoff); | ||
| 722 | return Flist (9, list_args); | ||
| 723 | } | ||
| 724 | |||
| 686 | DEFUN ("current-time-string", Fcurrent_time_string, Scurrent_time_string, 0, 1, 0, | 725 | DEFUN ("current-time-string", Fcurrent_time_string, Scurrent_time_string, 0, 1, 0, |
| 687 | "Return the current time, as a human-readable string.\n\ | 726 | "Return the current time, as a human-readable string.\n\ |
| 688 | Programs can use this function to decode a time,\n\ | 727 | Programs can use this function to decode a time,\n\ |
| @@ -2159,6 +2198,7 @@ syms_of_editfns () | |||
| 2159 | defsubr (&Semacs_pid); | 2198 | defsubr (&Semacs_pid); |
| 2160 | defsubr (&Scurrent_time); | 2199 | defsubr (&Scurrent_time); |
| 2161 | defsubr (&Sformat_time_string); | 2200 | defsubr (&Sformat_time_string); |
| 2201 | defsubr (&Sdecode_time); | ||
| 2162 | defsubr (&Scurrent_time_string); | 2202 | defsubr (&Scurrent_time_string); |
| 2163 | defsubr (&Scurrent_time_zone); | 2203 | defsubr (&Scurrent_time_zone); |
| 2164 | defsubr (&Ssystem_name); | 2204 | defsubr (&Ssystem_name); |