1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-24 22:40:51 -08:00
Commit graph

91 commits

Author SHA1 Message Date
Eli Zaretskii
cae528457c ; Add 2023 to copyright years. 2023-01-01 05:31:12 -05:00
Eli Zaretskii
58b8ed8b55 ; Avoid compilation warning on MS-Windows
* src/timefns.c (sys_clock): Declare, to avoid compilation
warning.
2022-12-12 20:01:23 +02:00
Paul Eggert
55f6f1c82a Work around lsp-mode compatibility bug
* src/timefns.c (Ftime_subtract): Respect current-time-list when
args are eq (Bug#59506).
2022-11-24 12:57:02 -08:00
Paul Eggert
a64fe6f319 Improve timefns speed on integers
* src/timefns.c (decode_lisp_time) [FASTER_TIMEFNS]:
Speed up when SPECIFIED_TIME is an integer.
(time_cmp) [FASTER_TIMEFNS]: Speed up when comparing integers.
2022-08-14 13:49:33 -07:00
Paul Eggert
15aba5e644 Decode time conses before floats
* src/timefns.c (decode_lisp_time): Test for conses before floats,
as conses are more common.
2022-08-14 13:49:33 -07:00
Stefan Monnier
397fdc22eb * lisp/calendar/time-date.el (seconds-to-time): Use the original arg list 2022-08-14 10:41:40 -04:00
Basil L. Contovounesios
864847bf3c Document time-convert FORM argument as mandatory
This is a followup to commit b70369c557 of 2022-08-05
"time-convert): Deprecate calls without an explicit FORM arg".

* doc/lispref/os.texi (Time Conversion):
* src/timefns.c (Ftime_convert): Describe FORM argument as required
as per the advertised calling convention.
2022-08-13 21:59:39 +03:00
Stefan Kangas
0a93759385 Improve time-convert docstring formatting for readability
* src/timefns.c (Ftime_convert): Doc fix; improve formatting for
readability.
2022-08-13 20:30:12 +02:00
Paul Eggert
2fd2008e67 * src/timefns.c (Ffloat_time): Fix doc string. 2022-08-01 01:17:14 -07:00
Paul Eggert
24e1123241 Improve time-equal-p etc. performance
* src/timefns.c (time_cmp): Return EMACS_INT, not int; no need to
change callers.  Compare (X . Z) to (Y . Z) quickly if X and Y are
fixnums.
2022-08-01 01:17:14 -07:00
Paul Eggert
0a4477415c Improve float-time etc. performance
* src/timefns.c (decode_float_time): Assume T is finite.
All callers changed.
(decode_time_components): Assume FORM is not TIMEFORM_FLOAT.
All callers changed.
(decode_lisp_time): If the specified time is a float,
signal an error if it is not finite.
(Ffloat_time): If the specified time is a float,
simply return it.
2022-08-01 01:17:14 -07:00
Paul Eggert
914cf4b91b Make time arithmetic more like comparison
Since time comparison says X == X, have time arithmetic behave
similarly for X - X.  This should also be a bit faster due to not
having to test for floats and NaNs.
* src/timefns.c (time_arith, time_cmp):
Simplify by not worrying about NaNs, which are not time values.
(time_arith): Simplify by not worrying about subtracting nil from
nil; the caller now handles this.
(Ftime_subtract): Handle subtracting X from X specially.
2022-08-01 01:17:13 -07:00
Paul Eggert
9d4633e934 (time-equal-p nil X) returns nil
* src/timefns.c (Ftime_equal_p): nil compares unequal to non-nil.
2022-08-01 01:17:13 -07:00
Lars Ingebrigtsen
6db5c7f8c4 Improve time parsing documentation
* doc/lispref/os.texi (Time Parsing): Clarify which functions
take/return timestamps and which ones take decoded time structures.
* src/timefns.c (Fdecode_time): Clarify TIME argument (bug#46505).
2022-06-17 16:03:48 +02:00
Paul Eggert
343482d641 Streamline time decoding and conversion
* src/lisp.h (lisp_h_BASE2_EQ, BASE2_EQ): New macros and functions.
* src/timefns.c (tzlookup, Fdecode_time): Use them.
(Ftime_convert): Convert to symbol once, instead of many times.
2022-06-15 23:27:08 -05:00
Paul Eggert
9bce1f3d70 Prefer BASE_EQ in time-sensitive ops
* src/timefns.c (tzlookup, lisp_time_hz_ticks)
(decode_time_components, lisp_to_timespec, lispint_arith)
(time_arith, time_cmp, Fdecode_time, Fencode_time)
(Ftime_convert): Prefer BASE_EQ to EQ where either will do.
2022-06-15 23:27:07 -05:00
Eli Zaretskii
5c606a46bf ; Fix typo in documentation of 'current-time-list'
* src/timefns.c (syms_of_timefns) <current-time-list>:
* etc/NEWS:
* doc/lispref/os.texi (Time of Day): Fix a typo.
2022-04-29 10:12:02 +03:00
Paul Eggert
083d2708f9 Change current-time back to list form
Change current-time and related functions back to using the
traditional list form.  Also, add a new boolean variable
current-time-list that lets people try out (TICKS . HZ) form,
with the goal of smoothing the transition.
* src/timefns.c (CURRENT_TIME_LIST): Change default back to true.
(current-time-list): New boolean Lisp variable, which defaults to
CURRENT_TIME_LIST.  All uses of CURRENT_TIME_LIST changed to
use current_time_list, and all documentation changed.
2022-04-28 12:54:06 -07:00
Stefan Monnier
1110d7326f Add new function current-cpu-time
* doc/lispref/os.texi (Time of Day): Document it.
* src/timefns.c (Fcurrent_cpu_time): New function (bug#44674).
2022-04-27 19:20:41 +02:00
Paul Eggert
4a1f69ebca Use (TICKS . HZ) for current-time etc.
* src/timefns.c (CURRENT_TIME_LIST): Change default to false.
All documentation changed.
2022-04-25 12:40:20 -07:00
Paul Eggert
d75e2c12eb Support (encode-time (list s m h D M Y))
* src/timefns.c (Fencode_time): Add support for a 6-elt list arg.
Requested by Max Nikulin for Org (bug#54764).
* test/src/timefns-tests.el (encode-time-alternate-apis): New test.
2022-04-25 12:40:20 -07:00
Paul Eggert
f1ba92448d Document encode-time caveats
* doc/lispref/os.texi (Time of Day, Time Conversion):
Move the warnings about DST being -1 to closer to where DST is
discussed, and reword and improve the discussions and warnings.
Be more precise about years before 1969 (possible west of UTC) vs the
Epoch.  Mention some problems due to leap seconds, leap years,
daylight saving transitions, and time zone changes.  Modernize
discussion of OS timestamp range.  Prefer secular ‘BCE’ to religious
‘BC’.  Omit discussion of decoded-time-add and make-decoded-time, as
they are in a library and are not always available; instead, mention
the library.  Warn about common mistakes when doing simple date
arithmetic.
* src/timefns.c (Fencode_time): In doc string, mention date
arithmetic and tighten up the wording a bit.
2022-04-16 18:54:31 -07:00
Max Nikulin
15a5cf9a9a Stress difference of new and old ways to call `encode-time'
* doc/lispref/os.texi (Time Conversion): Add a warning that blind
changing of code calling `encode-time' to use single list instead of
multiple values may cause deferred bugs since it is common to use nil
for ignored arguments such as DST in the old calling convention.
* src/timefns.c (encode-time): Mention the warning added to the elisp
reference in the docstring.

Refactoring related to `encode-time' caused (bug#54731), so it is better
to make apparent the difference between the recommended and the
obsolescent ways to call the function.  More details concerning the
purpose and limitations of the DST field are added after discussion with
Paul Eggert in (bug#54764).
2022-04-16 18:54:30 -07:00
Paul Eggert
7c17bd2a6d New time-equal-p test
* test/src/timefns-tests.el (time-equal-p-NaN-NaN): New test.
2022-04-14 19:09:51 -07:00
Philip Kaludercic
17b639aabb Avoid possibly unnecessary lisp_time_struct call
* timefns.c (time_cmp): Defer the calculation of the time struct, in
  case A and B are eq to one another.
2022-04-14 18:39:35 +02:00
Paul Eggert
0fed561042 Remove unused fns/data and make fns static
* src/comp.c (saved_sigset, helper_temp_output_buffer_setup):
Remove; unused.
* src/comp.c (logfile, helper_link_table):
* src/fns.c (hashfn_equal, hashfn_eql):
* src/frame.c (frame_windows_min_size):
* src/gnutls.c (emacs_gnutls_global_init):
* src/minibuf.c (Vcommand_loop_level_list):
* src/syntax.c (syntax_code_spec):
* src/timefns.c (time_overflow):
* src/xterm.c (x_xrender_color_from_gc_foreground)
(x_display_set_last_user_time):
Now static, since it’s not used elsewhere.
* src/xterm.c (x_xrender_color_from_gc_foreground)
(x_xrender_color_from_gc_background): Move earlier to avoid
forward use.
(x_xrender_color_from_gc_foreground): Do not define unless
!defined USE_CAIRO && (RENDER_MAJOR > 0 || RENDER_MINOR >= 2),
since it’s not used otherwise.
2022-03-19 12:48:53 -07:00
Paul Eggert
2fbd48f733 Fix process-attributes time precision on GNU/Linux
* src/sysdep.c [GNU_LINUX]:
(time_from_jiffies): Simplify by using time-convert.  Change args
and result type.  All uses changed.
(ltime_from_jiffies): Remove; call time_from_jiffies instead.
(put_jiffies): New function.
(get_up_time): Return Lisp_Object not struct timespec.
All uses changed.  Simplify by using time-add.
(system_process_attributes): Simplify by using the above.
This fixes some minor problems where timestamps promised more
precision than was actually available.  When info is not
available (e.g., sysconf fails) do not place it into the alist.
* src/timefns.c (float_time): Now extern.
2022-03-04 19:29:05 -08:00
Paul Eggert
af742bb3bb Avoid unnecessary make_float in time arithmetic
* src/timefns.c (float_time): New function.
(time_arith, Ffloat_time): Use it.
2022-03-04 19:29:04 -08:00
Stefan Monnier
04c0245d36 Merge remote-tracking branch 'origin/emacs-28' into trunk 2022-01-02 17:07:42 -05:00
Eli Zaretskii
b477cff35d Clarify %g and %G time format specs
* src/timefns.c (Fformat_time_string):
* doc/lispref/os.texi (Time Parsing): Clarify %g/%G.  (Bug#52934)
2022-01-02 09:30:15 +02:00
Eli Zaretskii
dcd76bd48d Merge from origin/emacs-28
836be7a112 ; * etc/refcards/ru-refcard.tex: Update Copyright year.
86cbc6ee4a * lisp/net/tramp-sh.el: Adapt copyright year
ebe8772f65 ; Minor fixes related to copyright years
23c1ee6989 ; * test/manual/etags/ETAGS.good_N: Adjust to copyright ye...
8d3fc7ec89 * src/xfaces.c (face_for_font): Make 'hash' be uintptr_t.
19dcb237b5 ; Add 2022 to copyright years.

# Conflicts:
#	etc/NEWS
#	etc/refcards/ru-refcard.tex
#	lib/cdefs.h
#	lisp/erc/erc-dcc.el
#	lisp/erc/erc-imenu.el
#	lisp/erc/erc-replace.el
#	lisp/image-dired.el
#	lisp/progmodes/xref.el
#	m4/alloca.m4
#	m4/byteswap.m4
#	m4/errno_h.m4
#	m4/getopt.m4
#	m4/gnulib-common.m4
#	m4/inttypes.m4
#	m4/stddef_h.m4
#	m4/stdint.m4
#	m4/sys_socket_h.m4
2022-01-01 07:03:03 -05:00
Eli Zaretskii
19dcb237b5 ; Add 2022 to copyright years. 2022-01-01 02:45:51 -05:00
Paul Eggert
895215854d * src/timefns.c: Minor comment fix. 2021-12-16 15:35:32 -08:00
Paul Eggert
73d6b19024 Omit temporary warning re obsolete timestamps
Do not warn about timestamps like (1 . 1000).  This warning was added
in Emacs 27 as a temporary transition aid, and has now served its
purpose.  These timestamps, which Emacs 26 and earlier treated as (HI
. LO) instead of as (TICKS . HZ), were never generated by Emacs
primitives, and in practice the warning seems to have been triggered
only by test cases designed to generate it.
* src/timefns.c (WARN_OBSOLETE_TIMESTAMPS): Remove.
All uses changed to assume it’s false.
(decode_lisp_time): Simplify by taking a bool instead of an
integer bitmask.  All uses changed.
2021-12-16 11:17:27 -08:00
Paul Eggert
34e3ad5ae4 Fix encode-time doc string
* src/timefns.c (Fencode_time): Fix incorrect doc string
that talks about FORM (which doesn’t exist) by copying
wording from the manual instead.
2021-12-16 11:17:24 -08:00
Paul Eggert
0d374b1b83 Work around GCC bug 102671
This is for --enable-gcc-warnings on GCC 11.2.1.
* src/window.c, src/timefns.c: Disable -Wanalyzer-null-dereference.
2021-10-11 09:24:56 -07:00
Paul Eggert
ba05d005e5 Update copyright year to 2021
Run "TZ=UTC0 admin/update-copyright".
2021-01-01 01:13:56 -08:00
Andreas Schwab
a9f147af71 Use the full name of the null byte/character, not its abbreviation
* lisp/subr.el (inhibit-nul-byte-detection): Make it an obsolete alias.
* src/coding.c (setup_coding_system): Use original name.
(detect_coding): Rename nul_byte_found => null_byte_found.
(detect_coding_system): Use original name.
Rename nul_byte_found => null_byte_found.
(Fdefine_coding_system_internal): Use original name.
(syms_of_coding): Rename inhibit-nul-byte-detection to
inhibit-null-byte-detection.
* src/w16select.c (get_clipboard_data): Rename nul_char to null_char.
* src/json.c (check_string_without_embedded_nulls): Rename from
check_string_without_embedded_nuls.
(Fjson_parse_string): Adjust accordingly.
* src/coding.h (enum define_coding_undecided_arg_index)
(enum coding_attr_index): Rename ...nul_byte... to ...null_byte....
* lisp/info.el (info-insert-file-contents, Info-insert-dir):
* lisp/international/mule.el (define-coding-system):
* lisp/vc/vc-git.el (vc-git--call):
* doc/lispref/nonascii.texi (Lisp and Coding Systems): Use original name.
2020-10-05 20:19:59 +02:00
Paul Eggert
0c86f5592e Simplify format_time_string
* src/timefns.c (emacs_nmemftime, format_time_string):
Simplify on the basis of recent nstrftime changes.
Propagate nstrftime errno.
2020-08-16 14:30:29 -07:00
Paul Eggert
669aeafbd1 Prefer make_nil_vector to make-vector with nil
* src/pdumper.c (hash_table_thaw): Pacify -Wconversion so
we can use make_nil_vector again.
* src/timefns.c (syms_of_timefns): Prefer make_nil_vector
to make_vector with Qnil.
2020-08-11 10:30:05 -07:00
Paul Eggert
37d3c1618b Tiny simplification of frac_to_double
* src/timefns.c (frac_to_double): Remove unnecessary runtime check,
since the denominator is always positive.
2020-03-19 00:11:16 -07:00
Paul Eggert
efb5115ba2 Omit timestamp optimization invalid on 387 FPU
* src/timefns.c (frac_to_double): Omit optimization that is
invalid on machines with excess precision (e.g., gcc x86 with 387
FPU), because it double-rounds.  Found via ‘gcc -m32’ on x86-64.
2020-03-19 00:11:15 -07:00
Paul Eggert
a461baae79 Merge from origin/emacs-27
cf223dc928 ; * src/timefns.c: Fix typo in previous change.
20d3d3a950 * src/timefns.c: Add comments.
2020-03-08 16:57:41 -07:00
Paul Eggert
cf223dc928 ; * src/timefns.c: Fix typo in previous change. 2020-03-08 16:49:32 -07:00
Paul Eggert
20d3d3a950 * src/timefns.c: Add comments. 2020-03-08 16:44:49 -07:00
Paul Eggert
4415534ef0 Merge from origin/emacs-27
0a3682a566 * src/timefns.c: Add comments.
b16ba4041d ; lisp/emacs-lisp/seq.el: Explain why we don't use cl-lib ...
3cbf4cb796 Eliminate use of cl-concatenate in 'seq' package
363d927086 Fix bug with JIT stealth timers
818333c85a * doc/lispref/os.texi (time-subtract): Doc fix.
2020-03-08 00:20:57 -08:00
Paul Eggert
0a3682a566 * src/timefns.c: Add comments. 2020-03-08 00:16:49 -08:00
Glenn Morris
6a0e1c4104 Merge from origin/emacs-27
a4e4510ccd Fix handling MS-Windows keyboard input above the BMP
a38bebb0c1 * etc/NEWS: More complete description of rx 'not' changes.
d373647e8f ; * doc/emacs/mini.texi (Yes or No Prompts): Fix last change.
1ca6d15656 * doc/emacs/mini.texi (Yes or No Prompts): 'y-or-n-p' now ...
fe1a447d52 Don't attempt to cache glyph metrics for FONT_INVALID_CODE
b42b894d1d Fix fit-frame-to-buffer for multi-monitor setup
366fd4fd07 (emacs-27) ; * etc/NEWS: Fix typo.
49d3cd90bd rx: Improve 'or' compositionality (bug#37659)
6b48aedb6b * lisp/tab-line.el: Fix auto-hscrolling (bug#39649)
c5f255d681 (tag: emacs-27.0.90) ; Update lisp/ldefs-boot.el
60c84ad992 ; * etc/TODO: Fix last change.
5af9e5baad ; Add an entry to TODO
d424195905 Fix rx charset generation
9908b5a614 Merge branch 'emacs-27' of git.savannah.gnu.org:/srv/git/e...
6dc2ebe00e Fix overquoting in mule.el
5cca73dd82 * src/timefns.c (time_arith): Omit incorrect comment.
d767c357ca Merge branch 'emacs-27' of git.savannah.gnu.org:/srv/git/e...
4dec693f70 * lisp/vc/vc-cvs.el (vc-cvs-ignore): Copy-edit doc string
ff729e3f97 ; bug#39779: Fix some typos in documentation.
696ee02c3a checkdoc: Don't mistake "cf." for sentence end

# Conflicts:
#	etc/NEWS
2020-03-04 13:57:58 -08:00
Paul Eggert
b48142ba19 Time division speedups
* src/timefns.c (frac_to_double) [FASTER_TIMEFNS]: Prefer intmax_t
division or double division to mpz division if they also yield the
correctly rounded result.
2020-03-03 10:20:33 -08:00
Paul Eggert
5e229f88f9 Fix rounding errors in time conversion
* src/timefns.c (frac_to_double): Pass FLT_RADIX to mpz_sizeinbase
instead of doing the radix calculation ourselves, not always
correctly.  Fix off-by-one error in scale, which caused
double-rounding.
(decode_time_components): Use frac_to_double (via decode_ticks_hz)
to fix double-rounding error that can occur even though
intermediate results are long double.
* test/src/timefns-tests.el (float-time-precision):
Test the above fixes.
2020-03-03 10:20:32 -08:00