10e3d5408SPeter Wemm#!/bin/sh 2*21817992SBaptiste Daroussin# $Id: edit_cfg.sh,v 1.16 2022/07/16 18:02:32 tom Exp $ 30e3d5408SPeter Wemm############################################################################## 4*21817992SBaptiste Daroussin# Copyright 2020,2022 Thomas E. Dickey # 5e1865124SBaptiste Daroussin# Copyright 1998-2001,2017 Free Software Foundation, Inc. # 60e3d5408SPeter Wemm# # 70e3d5408SPeter Wemm# Permission is hereby granted, free of charge, to any person obtaining a # 80e3d5408SPeter Wemm# copy of this software and associated documentation files (the "Software"), # 90e3d5408SPeter Wemm# to deal in the Software without restriction, including without limitation # 100e3d5408SPeter Wemm# the rights to use, copy, modify, merge, publish, distribute, distribute # 110e3d5408SPeter Wemm# with modifications, sublicense, and/or sell copies of the Software, and to # 120e3d5408SPeter Wemm# permit persons to whom the Software is furnished to do so, subject to the # 130e3d5408SPeter Wemm# following conditions: # 140e3d5408SPeter Wemm# # 150e3d5408SPeter Wemm# The above copyright notice and this permission notice shall be included in # 160e3d5408SPeter Wemm# all copies or substantial portions of the Software. # 170e3d5408SPeter Wemm# # 180e3d5408SPeter Wemm# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # 190e3d5408SPeter Wemm# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # 200e3d5408SPeter Wemm# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL # 210e3d5408SPeter Wemm# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # 220e3d5408SPeter Wemm# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # 230e3d5408SPeter Wemm# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # 240e3d5408SPeter Wemm# DEALINGS IN THE SOFTWARE. # 250e3d5408SPeter Wemm# # 260e3d5408SPeter Wemm# Except as contained in this notice, the name(s) of the above copyright # 270e3d5408SPeter Wemm# holders shall not be used in advertising or otherwise to promote the sale, # 280e3d5408SPeter Wemm# use or other dealings in this Software without prior written # 290e3d5408SPeter Wemm# authorization. # 300e3d5408SPeter Wemm############################################################################## 310e3d5408SPeter Wemm# 3218259542SPeter Wemm# Author: Thomas E. Dickey <dickey@clark.net> 1996,1997,2000 330e3d5408SPeter Wemm# 340e3d5408SPeter Wemm# Edit the default value of the term.h file based on the autoconf-generated 350e3d5408SPeter Wemm# values: 360e3d5408SPeter Wemm# 370e3d5408SPeter Wemm# $1 = ncurses_cfg.h 380e3d5408SPeter Wemm# $2 = term.h 390e3d5408SPeter Wemm# 400e3d5408SPeter WemmBAK=save$$ 410e3d5408SPeter WemmTMP=edit$$ 42*21817992SBaptiste Daroussintrap "rm -f $BAK $TMP; exit 1" 1 2 3 15 43*21817992SBaptiste Daroussintrap "rm -f $BAK $TMP" 0 440e3d5408SPeter Wemmfor name in \ 450e3d5408SPeter Wemm HAVE_TCGETATTR \ 460e3d5408SPeter Wemm HAVE_TERMIOS_H \ 470e3d5408SPeter Wemm HAVE_TERMIO_H \ 480e3d5408SPeter Wemm BROKEN_LINKER 490e3d5408SPeter Wemmdo 50*21817992SBaptiste Daroussin mv "$2" "$BAK" 51*21817992SBaptiste Daroussin if ( grep "[ ]${name}[ ]" "$1" >$TMP 2>&1 ) 520e3d5408SPeter Wemm then 5339f2269fSPeter Wemm value=1 540e3d5408SPeter Wemm else 5539f2269fSPeter Wemm value=0 560e3d5408SPeter Wemm fi 5739f2269fSPeter Wemm echo '** edit: '$name $value 5839f2269fSPeter Wemm sed \ 5939f2269fSPeter Wemm -e "s@#define ${name}.*\$@#define $name $value@" \ 6039f2269fSPeter Wemm -e "s@#if $name\$@#if $value /* $name */@" \ 6139f2269fSPeter Wemm -e "s@#if !$name\$@#if $value /* !$name */@" \ 62*21817992SBaptiste Daroussin "$BAK" >"$2" 63*21817992SBaptiste Daroussin if (cmp -s "$2" "$BAK") 640e3d5408SPeter Wemm then 65*21817992SBaptiste Daroussin mv "$BAK" "$2" 660e3d5408SPeter Wemm else 67*21817992SBaptiste Daroussin rm -f "$BAK" 680e3d5408SPeter Wemm fi 690e3d5408SPeter Wemmdone 70