[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Two notes about curses_version()
From: |
Stanislav Ievlev |
Subject: |
Two notes about curses_version() |
Date: |
Mon, 5 Jan 2004 15:56:36 +0300 |
Hello friends!
There are two little problems with this functions.
1. Ncurses allows to build a separate terminfo library. tput,tset,toe,tic,tack
and infocmp are pure terminfo utils, but we cannot link these tools with
terminfo only, because they use
curses_version() from ncurses.
Note: all these tools use curses_version() to print version string only.
There are two possible solutions:
a)(preferable way) move curses_version() from ncurses library to terminfo
b) use simple printf("ncurses %s.%d",NCURSES_VERSION, NCURSES_VERSION_PATCH)
2. As I understand, curses_version() should return pointer to constant
(read-only) area. But it not so. Current curses_version() implementation
returns pointer to read-write static area.
----------------
#include <curses.h>
int main()
{
char *z = curses_version();
sprintf(z,"test");
printf("ver=%s\n",z);
return 0;
}
----------------
$gcc ll.c -lncurses
$./a.out
ver=test
----------------
Right implementation shold put version string to read-only data section.
Sample implementation you can see below:
----------------
include <curses.h>
const char *my_version()
{
return NCURSES_VERSION;
}
int main()
{
char *z = my_version();
sprintf(z,"test");
printf("ver=%s\n",z);
return 0;
}
----------------
$gcc ll.c
$ ./a.out
Segmentation fault
----------------
--
With best regards
Stanislav Ievlev.
- Two notes about curses_version(),
Stanislav Ievlev <=