]> git.ipfire.org Git - thirdparty/coreutils.git/commit
stty: arbitrary or non-a priori known speed_t support
authorH. Peter Anvin <hpa@zytor.com>
Mon, 16 Jun 2025 21:58:01 +0000 (14:58 -0700)
committerPádraig Brady <P@draigBrady.com>
Wed, 18 Jun 2025 13:20:17 +0000 (14:20 +0100)
commit357fda90d15fd3f7dba61e1ab322b183a48d0081
tree0d96d968daa9297adf67e738d9f67d37dc3d5cb9
parent5c5e8b4a981346086449f3b8c37e0a85dbfdfabe
stty: arbitrary or non-a priori known speed_t support

Support the case where speed_t is simply a number, and in that case
assume that arbitrary values can be passed.  This is assumed to be the
case when all known speed_t macros equal their own value.

Try to probe for a variety of speed_t constants by trying to coax
$(CC) into emitting macro definitions (-E -dM).  If this is not
supported, use a fairly extensive list of constants as a
fallback.  This both improves the test for arbitrary speed support, as
well as allowing proper operation in the case where the constants are
not plain numbers and allows for handing enumerated speed constants
that were not known a priori when the source code was written.

A simple shell script (mostly using sed) is used to turn the list of
constants (probed and predefined) into a pair of conversion functions,
baud_to_value() and value_to_baud(); string_to_baud() is then
reimplemented as a wrapper around the latter.

* src/.gitignore: Add generated speedlist.h.
* src/local.mk: Generate speedlist.h.
* src/speedgen: Portable shell script to generate speedlist.h.
* src/stty.c: Adjust string_to_baud to
convert from arbitrary numeric values.
* src/termios.c: A helper used when generating speedlist.h
* NEWS: Mention the improvement.
NEWS
src/.gitignore
src/local.mk
src/speedgen [new file with mode: 0755]
src/stty.c
src/termios.c [new file with mode: 0644]