Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: $BAUD is strange on Linux for 115200



Janos Farkas wrote:
> 
> If I am using an 'extended' speed (i.e. >38400), BAUD used to be
> something like 4098, because the original logic in this code thought
> that if the speed code returned by cfget?speed() is larger than
> 100, then it's the real baud rate, not a symbolic value.  This
> is not so on Linux.  [Taking the opportunity, I added some recently
> added baud rates to the list]. Anyone can see any problems with the code
> below?
> 
> Janos
> 
> diff -urN zsh-2.6-beta21.orig/Src/utils.c zsh-2.6-beta21/Src/utils.c
> --- zsh-2.6-beta21.orig/Src/utils.c	Wed Jun 19 22:01:40 1996
> +++ zsh-2.6-beta21/Src/utils.c	Sun Jun 23 22:55:21 1996
> @@ -2715,9 +2715,16 @@
>  
>  # if defined(HAVE_TCGETATTR) && defined(HAVE_TERMIOS_H)
>      tempbaud = cfgetospeed(&shttyinfo->tio);
> +#if defined CBAUDEX && CBAUDEX > 100
> +    /* If we have CBAUDEX, then it's a mask of the extended
> +       speeds, and the baud rates are still encoded.  At least
> +       this is so on Linux, and I hope this logic is true on
> +       most systems.  */
> +#else
>      if (tempbaud >= 100)
>          return tempbaud;
>      else
> +#endif
>          speedcode = (int) tempbaud;
>  # else
>      speedcode = shttyinfo->tio.c_cflag & CBAUD;

Is'n it better to move the tempbaud >= 100 check to the default case in
switch (speedcode) (modifying the type of speedcode from int to long)?
I'm sure that if cfgetospeed() returns the value of a B... macro than its
the logical meaning should always be used.

Zoltan




Messages sorted by: Reverse Date, Date, Thread, Author