bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: about termname() implementation


From: Thomas Dickey
Subject: Re: about termname() implementation
Date: Tue, 23 Dec 2003 06:09:56 -0500 (EST)

On Tue, 23 Dec 2003, Stanislav Ievlev wrote:

>
> Hello, friends!
>
> As I understand termname() function doesn't match definition in X/Open Curses 
> (Issue 4,Version 2) standart.
>
> In ncurses manual I see:
> "The termname routine returns the value of  the  environmental  variable TERM 
> (truncated to 14 characters)."

I didn't notice that.  Actually - checking the code, it may return up to
32 or 14, depending on whether the system supports long filenames.  The
reason for this (perhaps not good) is that the result from termname is
(a) a static buffer, and (b) it is used as the actual filename in the
terminfo directory tree.  The latter is why it's truncated - but having
pointed this out, I'll check/see whether I should change it (thanks).

> (Second question: Why truncated?)
>
> But in standart I see:
> "The termname() function obtains the terminal name as recorded by 
> setupterm()."
>
> As a result test program bellow will fail if enviroment variable TERM value 
> differ
> from terminal name.
> --
> int main()
> {
>     int retcode = EXIT_SUCCESS;
>     const char terminal[]="vt100";
>     setupterm(terminal, 1, (int *)0);
>     const char *name=termname();
>     printf("termname=%s, terminal=%s\n",name,terminal);
>     if (strcmp(termname,name))
>     {
>         puts("test failed");
>         retcode = EXIT_FAILURE;
>     }
>     return retcode;
> }
> --
>
> $gcc -lncurses l.c
> $ ./a.out
> termname=xterm, terminal=vt100
> test failed
>
> --
> With best regards
> Stanislav Ievlev.
>
>

-- 
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net




reply via email to

[Prev in Thread] Current Thread [Next in Thread]