Re: style of reference API documentation

2025-01-04 Thread Jim Meyering
On Sat, Jan 4, 2025 at 12:22 AM Bruno Haible wrote: > Hi Jim, Hi again :-) > > I'm surprised that you would use "more sources use Y" as a rationale > > for using Y. > > I do so for language-related topics. Because language gets defined by > how people use it in their majority. > > Like you, I'm

Re: new modules mbs_startswith, mbs_endswith

2025-01-04 Thread Bruno Haible via Gnulib discussion list
Paul Eggert wrote: > > if (!mbi_avail (iter)) > > -abort (); > > +/* We can get here due to incomplete multibyte characters. > > */ > > +return false; > > mbi_advance (iter); > > If the string ends in an incomplete s

Re: new modules mbs_startswith, mbs_endswith

2025-01-04 Thread Bruno Haible via Gnulib discussion list
Paul Eggert wrote: > >> * What happens when strings contain encoding errors? It's not clear from > >> the spec. I hope behavior isn't simply undefined. > > > > When the str_* functions are used, the byte-wise encoding will matter. > > I thought that str_* functions didn't care about locale, which

Re: new modules mbs_startswith, mbs_endswith

2025-01-04 Thread Paul Eggert
On 2025-01-04 09:25, Bruno Haible wrote: if (!mbi_avail (iter)) -abort (); +/* We can get here due to incomplete multibyte characters. */ +return false; mbi_advance (iter); If the string ends in an incomplete seque

[PATCH 2/3] mktime: support glibc locking

2025-01-04 Thread Paul Eggert
This is part of my attempt to merge glibc and gnulib mktime.c. It should not affect Gnulib-using code. * lib/mktime.c [_LIBC]: Include . (convert_time, __tz_convert) [_LIBC]: Omit definitions, since glibc supplies __tz_convert internally. (__mktime64) [_LIBC]: Lock __tzset_lock while running. ---

[PATCH 1/3] mktime: prefer bool to int

2025-01-04 Thread Paul Eggert
* lib/mktime.c (__mktime_internal): Use bool for a boolean local. --- ChangeLog| 5 + lib/mktime.c | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 06819500ab..335a97d8cb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2025-01-04

[PATCH 3/3] mktime: improve tm_isdst heuristic

2025-01-04 Thread Paul Eggert
* lib/mktime.c (__mktime_internal): When tm_isdst disagrees with what was requested, search at most a year (+ stride) from the requested time for a matching tm_isdst, and ignore the request if the search fails. This is more likely to match user expectations in timezones like Asia/Kolkata. Problem

Re: [PATCH 3/3] mktime: improve tm_isdst heuristic

2025-01-04 Thread Paul Eggert
On 2025-01-04 19:23, Bruno Haible wrote: Does this revert the change from https://git.savannah.gnu.org/gitweb/? p=gnulib.git;a=commitdiff;h=836c32a5915826c529b310981a149050bdd9db14 that was done for the sake of 'timegm'? Or is that change now implemented in a different way? It's now implemen

[PATCH] mktime: ease merge of locking code with glibc

2025-01-04 Thread Paul Eggert
This shouldn't affect behavior of either Gnulib or glibc. * lib/mktime-internal.h (__libc_lock_lock, __libc_lock_unlock) (__tzset_unlocked) [!_LIBC]: New macros. * lib/mktime.c (tzset) [!_LIBC]: Define this instead of __tzset, if defining either. (__mktime64): Simplify now that mktime-internal defi

Re: new modules mbs_startswith, mbs_endswith

2025-01-04 Thread Bruno Haible via Gnulib discussion list
Hi Simon, > Would adding mem_startswith (arbitrary char* buffers) and/or > c_startswith (arbitrary NUL-terminated 7-bit strings) make sense? c_startswith and str_startswith are the same. mem_startswith and mem_endswith would make sense, if some package needs them. We already have them in the for

Re: style of reference API documentation

2025-01-04 Thread Bruno Haible via Gnulib discussion list
Hi Jim, > I'm surprised that you would use "more sources use Y" as a rationale > for using Y. I do so for language-related topics. Because language gets defined by how people use it in their majority. Like you, I'm not generally in favour of accepting majority votes - for determining what are

Re: new modules mbs_startswith, mbs_endswith

2025-01-04 Thread Bruno Haible via Gnulib discussion list
Paul Eggert wrote: > > Should we break the "tradition" here to use 'int' for a Boolean value, > > and actually use 'bool' for the first time in ? > > I would prefer it, if it's a boolean function. Done: 2025-01-04 Bruno Haible *_startswith, *_endswith: Change return type to 'bool'.

Re: overfull tables

2025-01-04 Thread Bruno Haible via Gnulib discussion list
Paul Eggert wrote: > > I don't know what to do about it. Generate an 'info' file with a > > page width of 100 instead of 80? Splitting each table into 2 tables, > > thus making it harder for the reader to get a synopsis? > > Maybe hyphenation? No solution is good here. Automatic hyphenation is no

Re: new modules mbs_startswith, mbs_endswith

2025-01-04 Thread Paul Eggert
On 2025-01-03 23:39, Paul Eggert wrote: Don't we have problems with mbs_startswith, though? If the prefix ends in an incomplete multibyte character (an encoding error), the current code can match that to part of a multibyte character in the string. This doesn't match what you'd get if you ran m

Re: new modules mbs_startswith, mbs_endswith

2025-01-04 Thread Paul Eggert
On 2025-01-04 09:37, Bruno Haible wrote: No, that unfortunate property ... is a problem with the BIG5-HKSCS encoding, not with the GB18030 encoding. (Recall that GB18030 is more-or-less a Unicode transformation format like UTF-8, UTF-16, UTF-32.) See https://www.gnu.org/software/gnulib/manual/ht

Re: new modules mbs_startswith, mbs_endswith

2025-01-04 Thread Bruno Haible via Gnulib discussion list
Paul Eggert wrote: > Come to think of it, isn't there a different problem with > mbs_startswith? As I recall, mbiter supports GB18030, which has the > unfortunate property that an indivisible sequence of encoding bytes > stands for two Unicode characters No, that unfortunate property (that part

Re: [PATCH 3/3] mktime: improve tm_isdst heuristic

2025-01-04 Thread Bruno Haible via Gnulib discussion list
Paul Eggert wrote: > --- a/lib/mktime.c > +++ b/lib/mktime.c > @@ -355,9 +355,7 @@ __mktime_internal (struct tm *tp, bool local, > mktime_offset_t *offset) >int mday = tp->tm_mday; >int mon = tp->tm_mon; >int year_requested = tp->tm_year; > - > - /* Ignore any tm_isdst request for tim