curses: Add __NetBSD_Curses_Version__

Similar to __NetBSD_Version__ from sys/param.h but has no
correlation to it or the ELF symver libcurses is built as.

If we say that v1 was everything prior to this, it makes sense to
start this from v2.
This commit is contained in:
roy 2019-09-03 10:36:17 +00:00
parent 1222d7c306
commit b02c2cea81
4 changed files with 83 additions and 9 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.91 2019/09/02 09:08:29 roy Exp $
# $NetBSD: Makefile,v 1.92 2019/09/03 10:36:17 roy Exp $
# @(#)Makefile 8.2 (Berkeley) 1/2/94
.include <bsd.own.mk>
@ -210,10 +210,8 @@ SUBDIR.roff+= PSD.doc
fileio.h: shlib_version genfileioh.awk
${TOOL_AWK} -f ${.CURDIR}/genfileioh.awk < ${.CURDIR}/shlib_version > ${.CURDIR}/fileio.h
NETBSD_VERSION!= ${HOST_SH} ${NETBSDSRCDIR}/sys/conf/osrelease.sh
CPPFLAGS.version.c+= -DNETBSD_VERSION=\"${NETBSD_VERSION}\"
.PATH: ${NETBSDSRCDIR}/sys/sys
version.o: param.h
CURSES_VERSION!= ${HOST_SH} ${.CURDIR}/cursesrelease.sh
CPPFLAGS.version.c+= -DCURSES_VERSION=\"${CURSES_VERSION}\"
.include <bsd.lib.mk>
.include <bsd.subdir.mk>

View File

@ -1,4 +1,4 @@
/* $NetBSD: curses.h,v 1.124 2019/09/02 09:08:29 roy Exp $ */
/* $NetBSD: curses.h,v 1.125 2019/09/03 10:36:17 roy Exp $ */
/*
* Copyright (c) 1981, 1993, 1994
@ -47,6 +47,23 @@
#include <stdio.h>
#include <stdbool.h>
/*
* #define __NetBSD_Curses_Version__ MMmmrrpp00
*
* M = major version
* m = minor version; a minor number of 99 indicates current
* r = 0 (*)
* p = patchlevel
*
* This is similar to __NetBSD_Version__ as found in sys/param.h
* It is maintained seperately and has no correlation to it or the
* ELF symver libcurses is built as.
*/
#define __NetBSD_Curses_Version__ 0200000000 /* NetBSD-Curses 2.0.0 */
#define __NetBSD_Curses_Prereq__(M,m,p) (((((M) * 100000000) + \
(m) * 1000000) + (p) * 100) <= __NetBSD_Curses_Version__)
/*
* attr_t must be the same size as wchar_t (see <wchar.h>) to avoid padding
* in __LDATA.

View File

@ -0,0 +1,59 @@
#!/bin/sh
# $NetBSD: cursesrelease.sh,v 1.1 2019/09/03 10:36:17 roy Exp $
#
# Copyright (c) 1997 The NetBSD Foundation, Inc.
# All rights reserved.
#
# This code is derived from software contributed to The NetBSD Foundation
# by Luke Mewburn.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# We use the number specified in <curses.h>
path="$0"
[ "${path#/*}" = "$path" ] && path="./$path"
exec < ${path%/*}/curses.h
# Search for line
# #define __NetBSD_Curses_Version__ <ver_num> /* NetBSD-Curses <ver_text> */
#
# <ver_num> and <ver_text> should match!
while
read define ver_tag rel_num comment_start NetBSD rel_text rest || exit 1
do
[ "$define" = "#define" ] || continue;
[ "$ver_tag" = "__NetBSD_Curses_Version__" ] || continue
break
done
# ${rel_num} is [M]Mmm00pp00
rel_num=${rel_num%??}
rel_MMmm=${rel_num%????}
rel_MM=${rel_MMmm%??}
rel_mm=${rel_MMmm#${rel_MM}}
rel_pp=${rel_num#${rel_MMmm}00}
echo "${rel_MM#0}.${rel_mm#0}.${rel_pp#0}"

View File

@ -1,4 +1,4 @@
/* $NetBSD: version.c,v 1.1 2019/09/02 09:08:29 roy Exp $ */
/* $NetBSD: version.c,v 1.2 2019/09/03 10:36:17 roy Exp $ */
/*-
* Copyright (c) 2019 The NetBSD Foundation, Inc.
@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: version.c,v 1.1 2019/09/02 09:08:29 roy Exp $");
__RCSID("$NetBSD: version.c,v 1.2 2019/09/03 10:36:17 roy Exp $");
#endif
#include "curses.h"
@ -40,5 +40,5 @@ const char *
curses_version()
{
return "NetBSD-Curses " NETBSD_VERSION;
return "NetBSD-Curses " CURSES_VERSION;
}