head	1.48;
access;
symbols
	netbsd-11-0-RC4:1.48
	netbsd-11-0-RC3:1.48
	netbsd-11-0-RC2:1.48
	netbsd-11-0-RC1:1.48
	perseant-exfatfs-base-20250801:1.48
	netbsd-11:1.48.0.12
	netbsd-11-base:1.48
	netbsd-10-1-RELEASE:1.48
	perseant-exfatfs-base-20240630:1.48
	perseant-exfatfs:1.48.0.10
	perseant-exfatfs-base:1.48
	netbsd-8-3-RELEASE:1.41
	netbsd-9-4-RELEASE:1.47.2.1
	netbsd-10-0-RELEASE:1.48
	netbsd-10-0-RC6:1.48
	netbsd-10-0-RC5:1.48
	netbsd-10-0-RC4:1.48
	netbsd-10-0-RC3:1.48
	netbsd-10-0-RC2:1.48
	netbsd-10-0-RC1:1.48
	netbsd-10:1.48.0.8
	netbsd-10-base:1.48
	netbsd-9-3-RELEASE:1.47.2.1
	cjep_sun2x-base1:1.48
	cjep_sun2x:1.48.0.6
	cjep_sun2x-base:1.48
	cjep_staticlib_x-base1:1.48
	netbsd-9-2-RELEASE:1.47.2.1
	cjep_staticlib_x:1.48.0.4
	cjep_staticlib_x-base:1.48
	netbsd-9-1-RELEASE:1.47.2.1
	phil-wifi-20200421:1.48
	phil-wifi-20200411:1.48
	is-mlppp:1.48.0.2
	is-mlppp-base:1.48
	phil-wifi-20200406:1.48
	netbsd-8-2-RELEASE:1.41
	netbsd-9-0-RELEASE:1.47.2.1
	netbsd-9-0-RC2:1.47.2.1
	netbsd-9-0-RC1:1.47.2.1
	phil-wifi-20191119:1.48
	netbsd-9:1.47.0.2
	netbsd-9-base:1.47
	phil-wifi-20190609:1.44
	netbsd-8-1-RELEASE:1.41
	netbsd-8-1-RC1:1.41
	pgoyette-compat-merge-20190127:1.41.30.1
	pgoyette-compat-20190127:1.43
	pgoyette-compat-20190118:1.41
	pgoyette-compat-1226:1.41
	pgoyette-compat-1126:1.41
	pgoyette-compat-1020:1.41
	pgoyette-compat-0930:1.41
	pgoyette-compat-0906:1.41
	netbsd-7-2-RELEASE:1.41
	pgoyette-compat-0728:1.41
	netbsd-8-0-RELEASE:1.41
	phil-wifi:1.41.0.32
	phil-wifi-base:1.41
	pgoyette-compat-0625:1.41
	netbsd-8-0-RC2:1.41
	pgoyette-compat-0521:1.41
	pgoyette-compat-0502:1.41
	pgoyette-compat-0422:1.41
	netbsd-8-0-RC1:1.41
	pgoyette-compat-0415:1.41
	pgoyette-compat-0407:1.41
	pgoyette-compat-0330:1.41
	pgoyette-compat-0322:1.41
	pgoyette-compat-0315:1.41
	netbsd-7-1-2-RELEASE:1.41
	pgoyette-compat:1.41.0.30
	pgoyette-compat-base:1.41
	netbsd-7-1-1-RELEASE:1.41
	matt-nb8-mediatek:1.41.0.28
	matt-nb8-mediatek-base:1.41
	perseant-stdc-iso10646:1.41.0.26
	perseant-stdc-iso10646-base:1.41
	netbsd-8:1.41.0.24
	netbsd-8-base:1.41
	prg-localcount2-base3:1.41
	prg-localcount2-base2:1.41
	prg-localcount2-base1:1.41
	prg-localcount2:1.41.0.22
	prg-localcount2-base:1.41
	pgoyette-localcount-20170426:1.41
	bouyer-socketcan-base1:1.41
	pgoyette-localcount-20170320:1.41
	netbsd-7-1:1.41.0.20
	netbsd-7-1-RELEASE:1.41
	netbsd-7-1-RC2:1.41
	netbsd-7-nhusb-base-20170116:1.41
	bouyer-socketcan:1.41.0.18
	bouyer-socketcan-base:1.41
	pgoyette-localcount-20170107:1.41
	netbsd-7-1-RC1:1.41
	pgoyette-localcount-20161104:1.41
	netbsd-7-0-2-RELEASE:1.41
	localcount-20160914:1.41
	netbsd-7-nhusb:1.41.0.16
	netbsd-7-nhusb-base:1.41
	pgoyette-localcount-20160806:1.41
	pgoyette-localcount-20160726:1.41
	pgoyette-localcount:1.41.0.14
	pgoyette-localcount-base:1.41
	netbsd-7-0-1-RELEASE:1.41
	netbsd-7-0:1.41.0.12
	netbsd-7-0-RELEASE:1.41
	netbsd-7-0-RC3:1.41
	netbsd-7-0-RC2:1.41
	netbsd-7-0-RC1:1.41
	netbsd-5-2-3-RELEASE:1.37
	netbsd-5-1-5-RELEASE:1.37
	netbsd-6-0-6-RELEASE:1.38
	netbsd-6-1-5-RELEASE:1.38
	netbsd-7:1.41.0.10
	netbsd-7-base:1.41
	yamt-pagecache-base9:1.41
	yamt-pagecache-tag8:1.38.6.1
	netbsd-6-1-4-RELEASE:1.38
	netbsd-6-0-5-RELEASE:1.38
	tls-earlyentropy:1.41.0.8
	tls-earlyentropy-base:1.41
	riastradh-xf86-video-intel-2-7-1-pre-2-21-15:1.41
	riastradh-drm2-base3:1.41
	netbsd-6-1-3-RELEASE:1.38
	netbsd-6-0-4-RELEASE:1.38
	netbsd-5-2-2-RELEASE:1.37
	netbsd-5-1-4-RELEASE:1.37
	netbsd-6-1-2-RELEASE:1.38
	netbsd-6-0-3-RELEASE:1.38
	netbsd-5-2-1-RELEASE:1.37
	netbsd-5-1-3-RELEASE:1.37
	netbsd-6-1-1-RELEASE:1.38
	riastradh-drm2-base2:1.41
	riastradh-drm2-base1:1.41
	riastradh-drm2:1.41.0.4
	riastradh-drm2-base:1.41
	netbsd-6-1:1.38.0.14
	netbsd-6-0-2-RELEASE:1.38
	netbsd-6-1-RELEASE:1.38
	netbsd-6-1-RC4:1.38
	netbsd-6-1-RC3:1.38
	agc-symver:1.41.0.6
	agc-symver-base:1.41
	netbsd-6-1-RC2:1.38
	netbsd-6-1-RC1:1.38
	yamt-pagecache-base8:1.41
	netbsd-5-2:1.37.0.30
	netbsd-6-0-1-RELEASE:1.38
	yamt-pagecache-base7:1.41
	netbsd-5-2-RELEASE:1.37
	netbsd-5-2-RC1:1.37
	matt-nb6-plus-nbase:1.38
	yamt-pagecache-base6:1.41
	netbsd-6-0:1.38.0.12
	netbsd-6-0-RELEASE:1.38
	netbsd-6-0-RC2:1.38
	tls-maxphys:1.41.0.2
	tls-maxphys-base:1.41
	matt-nb6-plus:1.38.0.10
	matt-nb6-plus-base:1.38
	netbsd-6-0-RC1:1.38
	yamt-pagecache-base5:1.41
	yamt-pagecache-base4:1.41
	netbsd-6:1.38.0.8
	netbsd-6-base:1.38
	netbsd-5-1-2-RELEASE:1.37
	netbsd-5-1-1-RELEASE:1.37
	yamt-pagecache-base3:1.38
	yamt-pagecache-base2:1.38
	yamt-pagecache:1.38.0.6
	yamt-pagecache-base:1.38
	cherry-xenmp:1.38.0.4
	cherry-xenmp-base:1.38
	bouyer-quota2-nbase:1.38
	bouyer-quota2:1.38.0.2
	bouyer-quota2-base:1.38
	matt-mips64-premerge-20101231:1.38
	matt-nb5-mips64-premerge-20101231:1.37
	matt-nb5-pq3:1.37.0.28
	matt-nb5-pq3-base:1.37
	netbsd-5-1:1.37.0.26
	netbsd-5-1-RELEASE:1.37
	netbsd-5-1-RC4:1.37
	matt-nb5-mips64-k15:1.37
	netbsd-5-1-RC3:1.37
	netbsd-5-1-RC2:1.37
	netbsd-5-1-RC1:1.37
	netbsd-5-0-2-RELEASE:1.37
	matt-nb5-mips64-premerge-20091211:1.37
	matt-premerge-20091211:1.37
	matt-nb5-mips64-u2-k2-k4-k7-k8-k9:1.37
	matt-nb4-mips64-k7-u2a-k9b:1.37
	matt-nb5-mips64-u1-k1-k5:1.37
	matt-nb5-mips64:1.37.0.24
	netbsd-5-0-1-RELEASE:1.37
	jym-xensuspend-nbase:1.37
	netbsd-5-0:1.37.0.22
	netbsd-5-0-RELEASE:1.37
	netbsd-5-0-RC4:1.37
	netbsd-5-0-RC3:1.37
	netbsd-5-0-RC2:1.37
	jym-xensuspend:1.37.0.20
	jym-xensuspend-base:1.37
	netbsd-5-0-RC1:1.37
	netbsd-5:1.37.0.18
	netbsd-5-base:1.37
	matt-mips64-base2:1.37
	matt-mips64:1.37.0.16
	mjf-devfs2:1.37.0.14
	mjf-devfs2-base:1.37
	netbsd-4-0-1-RELEASE:1.36.2.1
	wrstuden-revivesa-base-3:1.37
	wrstuden-revivesa-base-2:1.37
	wrstuden-fixsa-newbase:1.36.2.1
	wrstuden-revivesa-base-1:1.37
	yamt-pf42-base4:1.37
	yamt-pf42-base3:1.37
	hpcarm-cleanup-nbase:1.37
	yamt-pf42-baseX:1.37
	yamt-pf42-base2:1.37
	wrstuden-revivesa:1.37.0.12
	wrstuden-revivesa-base:1.37
	yamt-pf42:1.37.0.10
	yamt-pf42-base:1.37
	keiichi-mipv6-nbase:1.37
	keiichi-mipv6:1.37.0.8
	keiichi-mipv6-base:1.37
	matt-armv6-nbase:1.37
	matt-armv6-prevmlocking:1.37
	wrstuden-fixsa-base-1:1.36.2.1
	netbsd-4-0:1.36.2.1.0.4
	netbsd-4-0-RELEASE:1.36.2.1
	cube-autoconf:1.37.0.6
	cube-autoconf-base:1.37
	netbsd-4-0-RC5:1.36.2.1
	netbsd-4-0-RC4:1.36.2.1
	netbsd-4-0-RC3:1.36.2.1
	netbsd-4-0-RC2:1.36.2.1
	netbsd-4-0-RC1:1.36.2.1
	matt-armv6:1.37.0.4
	matt-armv6-base:1.37
	matt-mips64-base:1.37
	hpcarm-cleanup:1.37.0.2
	hpcarm-cleanup-base:1.37
	netbsd-3-1-1-RELEASE:1.31.2.1
	netbsd-3-0-3-RELEASE:1.31
	wrstuden-fixsa:1.36.2.1.0.2
	wrstuden-fixsa-base:1.36.2.1
	abandoned-netbsd-4-base:1.34
	abandoned-netbsd-4:1.34.0.4
	netbsd-3-1:1.31.2.1.0.2
	netbsd-3-1-RELEASE:1.31.2.1
	netbsd-3-0-2-RELEASE:1.31
	netbsd-3-1-RC4:1.31.2.1
	netbsd-3-1-RC3:1.31.2.1
	netbsd-3-1-RC2:1.31
	netbsd-3-1-RC1:1.31
	netbsd-4:1.36.0.2
	netbsd-4-base:1.36
	chap-midi-nbase:1.34
	netbsd-3-0-1-RELEASE:1.31
	chap-midi:1.34.0.2
	chap-midi-base:1.34
	netbsd-3-0:1.31.0.4
	netbsd-3-0-RELEASE:1.31
	netbsd-3-0-RC6:1.31
	netbsd-3-0-RC5:1.31
	netbsd-3-0-RC4:1.31
	netbsd-3-0-RC3:1.31
	netbsd-3-0-RC2:1.31
	netbsd-3-0-RC1:1.31
	netbsd-2-0-3-RELEASE:1.26.2.1
	netbsd-2-1:1.26.2.1.2.5.0.2
	netbsd-2-1-RELEASE:1.26.2.1.2.5
	netbsd-2-1-RC6:1.26.2.1.2.5
	netbsd-2-1-RC5:1.26.2.1.2.5
	netbsd-2-1-RC4:1.26.2.1.2.5
	netbsd-2-1-RC3:1.26.2.1.2.5
	netbsd-2-1-RC2:1.26.2.1.2.5
	netbsd-2-1-RC1:1.26.2.1.2.5
	netbsd-2-0-2-RELEASE:1.26.2.1
	netbsd-3:1.31.0.2
	netbsd-3-base:1.31
	netbsd-2-0-1-RELEASE:1.26.2.1
	netbsd-2:1.26.2.1.0.2
	netbsd-2-base:1.26.2.1
	netbsd-2-0-RELEASE:1.26.2.1
	netbsd-2-0-RC5:1.26.2.1
	netbsd-2-0-RC4:1.26.2.1
	netbsd-2-0-RC3:1.26.2.1
	netbsd-2-0-RC2:1.26.2.1
	netbsd-2-0-RC1:1.26.2.1
	netbsd-2-0:1.26.0.2
	netbsd-2-0-base:1.26
	netbsd-1-6-PATCH002-RELEASE:1.17
	netbsd-1-6-PATCH002:1.17
	netbsd-1-6-PATCH002-RC4:1.17
	netbsd-1-6-PATCH002-RC3:1.17
	netbsd-1-6-PATCH002-RC2:1.17
	netbsd-1-6-PATCH002-RC1:1.17
	netbsd-1-6-PATCH001:1.17
	netbsd-1-6-PATCH001-RELEASE:1.17
	netbsd-1-6-PATCH001-RC3:1.17
	netbsd-1-6-PATCH001-RC2:1.17
	netbsd-1-6-PATCH001-RC1:1.17
	fvdl_fs64_base:1.17
	netbsd-1-6-RELEASE:1.17
	netbsd-1-6-RC3:1.17
	netbsd-1-6-RC2:1.17
	netbsd-1-6-RC1:1.17
	netbsd-1-6:1.17.0.10
	netbsd-1-6-base:1.17
	netbsd-1-5-PATCH003:1.17
	netbsd-1-5-PATCH002:1.17
	netbsd-1-5-PATCH001:1.17
	netbsd-1-5-RELEASE:1.17
	netbsd-1-5-BETA2:1.17
	netbsd-1-5-BETA:1.17
	netbsd-1-4-PATCH003:1.1.1.1.4.1
	netbsd-1-5-ALPHA2:1.17
	netbsd-1-5:1.17.0.8
	netbsd-1-5-base:1.17
	minoura-xpg4dl-base:1.17
	minoura-xpg4dl:1.17.0.6
	netbsd-1-4-PATCH002:1.1.1.1.4.1
	wrstuden-devbsize-19991221:1.17
	wrstuden-devbsize:1.17.0.4
	wrstuden-devbsize-base:1.17
	comdex-fall-1999:1.17.0.2
	comdex-fall-1999-base:1.17
	netbsd-1-4-PATCH001:1.1.1.1.4.1
	netbsd-1-4-RELEASE:1.1.1.1
	netbsd-1-4:1.1.1.1.0.4
	netbsd-1-4-base:1.1.1.1
	netbsd-1-3-PATCH003:1.1.1.1
	netbsd-1-3-PATCH003-CANDIDATE2:1.1.1.1
	netbsd-1-3-PATCH003-CANDIDATE1:1.1.1.1
	netbsd-1-3-PATCH003-CANDIDATE0:1.1.1.1
	netbsd-1-3-PATCH002:1.1.1.1
	netbsd-1-3-PATCH001:1.1.1.1
	netbsd-1-3-RELEASE:1.1.1.1
	netbsd-1-3-BETA:1.1.1.1
	netbsd-1-3:1.1.1.1.0.2
	netbsd-1-3-base:1.1.1.1
	REL_0:1.1.1.1
	PIERMONT_NELSON:1.1.1;
locks; strict;
comment	@# @;


1.48
date	2019.11.16.17.38.09;	author martin;	state Exp;
branches;
next	1.47;
commitid	Ep2cqGUr8B9gk6LB;

1.47
date	2019.06.25.21.09.33;	author joerg;	state Exp;
branches
	1.47.2.1;
next	1.46;
commitid	fIgOkRdUYXKD7CsB;

1.46
date	2019.06.20.11.31.12;	author martin;	state Exp;
branches;
next	1.45;
commitid	NKr0ldW4Rs7l5VrB;

1.45
date	2019.06.20.00.45.18;	author christos;	state Exp;
branches;
next	1.44;
commitid	yLSzKX1UFAKCvRrB;

1.44
date	2019.03.01.17.02.21;	author martin;	state Exp;
branches;
next	1.43;
commitid	Nt5uC90Nw3n2uGdB;

1.43
date	2019.01.22.18.39.49;	author martin;	state Exp;
branches;
next	1.42;
commitid	6XNuO4PnknVafO8B;

1.42
date	2019.01.21.20.28.08;	author martin;	state Exp;
branches;
next	1.41;
commitid	KXA41E1Zi98bSG8B;

1.41
date	2012.03.06.16.26.01;	author mbalmer;	state Exp;
branches
	1.41.30.1
	1.41.32.1;
next	1.40;

1.40
date	2012.03.02.14.27.48;	author mbalmer;	state Exp;
branches;
next	1.39;

1.39
date	2012.03.02.13.11.57;	author mbalmer;	state Exp;
branches;
next	1.38;

1.38
date	2010.01.02.16.08.20;	author dsl;	state Exp;
branches
	1.38.6.1;
next	1.37;

1.37
date	2006.12.03.01.18.34;	author christos;	state Exp;
branches;
next	1.36;

1.36
date	2006.09.06.19.24.15;	author dsl;	state Exp;
branches
	1.36.2.1;
next	1.35;

1.35
date	2006.09.06.19.13.51;	author dsl;	state Exp;
branches;
next	1.34;

1.34
date	2006.05.12.07.20.13;	author he;	state Exp;
branches
	1.34.4.1;
next	1.33;

1.33
date	2006.05.12.07.19.43;	author he;	state Exp;
branches;
next	1.32;

1.32
date	2005.04.09.13.12.31;	author dsl;	state Exp;
branches;
next	1.31;

1.31
date	2004.11.05.20.45.48;	author dsl;	state Exp;
branches
	1.31.2.1;
next	1.30;

1.30
date	2004.10.16.12.49.14;	author dsl;	state Exp;
branches;
next	1.29;

1.29
date	2004.08.14.15.15.57;	author dsl;	state Exp;
branches;
next	1.28;

1.28
date	2004.08.13.18.26.52;	author dsl;	state Exp;
branches;
next	1.27;

1.27
date	2004.06.05.19.05.36;	author dsl;	state Exp;
branches;
next	1.26;

1.26
date	2003.09.25.18.32.10;	author dsl;	state Exp;
branches
	1.26.2.1;
next	1.25;

1.25
date	2003.07.28.09.55.24;	author dsl;	state Exp;
branches;
next	1.24;

1.24
date	2003.07.25.07.48.02;	author dsl;	state Exp;
branches;
next	1.23;

1.23
date	2003.07.14.09.34.01;	author itojun;	state Exp;
branches;
next	1.22;

1.22
date	2003.07.07.12.22.35;	author dsl;	state Exp;
branches;
next	1.21;

1.21
date	2003.06.27.22.11.59;	author dsl;	state Exp;
branches;
next	1.20;

1.20
date	2003.06.10.17.24.17;	author dsl;	state Exp;
branches;
next	1.19;

1.19
date	2003.06.04.19.00.26;	author dsl;	state Exp;
branches;
next	1.18;

1.18
date	2003.01.10.20.01.12;	author christos;	state Exp;
branches;
next	1.17;

1.17
date	99.07.04.22.55.48;	author cgd;	state Exp;
branches;
next	1.16;

1.16
date	99.07.04.21.30.14;	author cgd;	state Exp;
branches;
next	1.15;

1.15
date	99.07.04.10.39.40;	author cgd;	state Exp;
branches;
next	1.14;

1.14
date	99.07.04.10.35.19;	author cgd;	state Exp;
branches;
next	1.13;

1.13
date	99.07.04.10.29.30;	author cgd;	state Exp;
branches;
next	1.12;

1.12
date	99.07.04.10.13.12;	author cgd;	state Exp;
branches;
next	1.11;

1.11
date	99.07.04.09.37.18;	author cgd;	state Exp;
branches;
next	1.10;

1.10
date	99.07.04.07.40.51;	author cgd;	state Exp;
branches;
next	1.9;

1.9
date	99.06.23.17.42.11;	author cgd;	state Exp;
branches;
next	1.8;

1.8
date	99.06.23.17.32.32;	author cgd;	state Exp;
branches;
next	1.7;

1.7
date	99.06.23.09.19.33;	author cgd;	state Exp;
branches;
next	1.6;

1.6
date	99.06.22.15.00.37;	author cgd;	state Exp;
branches;
next	1.5;

1.5
date	99.06.19.00.40.29;	author cgd;	state Exp;
branches;
next	1.4;

1.4
date	99.06.19.00.13.19;	author cgd;	state Exp;
branches;
next	1.3;

1.3
date	99.06.19.00.00.48;	author cgd;	state Exp;
branches;
next	1.2;

1.2
date	99.04.25.09.10.07;	author veego;	state Exp;
branches;
next	1.1;

1.1
date	97.09.26.21.16.38;	author phil;	state Exp;
branches
	1.1.1.1;
next	;

1.47.2.1
date	2019.11.17.13.36.18;	author msaitoh;	state Exp;
branches;
next	;
commitid	Qjw6YFV0ezPnXcLB;

1.41.30.1
date	2019.01.26.22.00.39;	author pgoyette;	state Exp;
branches;
next	;
commitid	JKpcmvSjdT25dl9B;

1.41.32.1
date	2019.06.10.22.10.22;	author christos;	state Exp;
branches;
next	1.41.32.2;
commitid	jtc8rnCzWiEEHGqB;

1.41.32.2
date	2020.04.13.08.05.44;	author martin;	state Exp;
branches;
next	;
commitid	X01YhRUPVUDaec4C;

1.38.6.1
date	2012.04.17.00.09.36;	author yamt;	state Exp;
branches;
next	;

1.36.2.1
date	2006.12.03.21.03.25;	author tron;	state Exp;
branches;
next	;

1.34.4.1
date	2006.09.14.19.21.21;	author riz;	state Exp;
branches;
next	;

1.31.2.1
date	2006.09.16.16.08.30;	author ghen;	state Exp;
branches;
next	;

1.26.2.1
date	2004.06.07.10.16.58;	author tron;	state Exp;
branches
	1.26.2.1.2.1;
next	;

1.26.2.1.2.1
date	2005.07.23.22.43.19;	author snj;	state Exp;
branches;
next	1.26.2.1.2.2;

1.26.2.1.2.2
date	2005.07.23.22.44.18;	author snj;	state Exp;
branches;
next	1.26.2.1.2.3;

1.26.2.1.2.3
date	2005.07.23.22.45.41;	author snj;	state Exp;
branches;
next	1.26.2.1.2.4;

1.26.2.1.2.4
date	2005.07.23.22.46.58;	author snj;	state Exp;
branches;
next	1.26.2.1.2.5;

1.26.2.1.2.5
date	2005.07.23.22.47.48;	author snj;	state Exp;
branches;
next	;

1.1.1.1
date	97.09.26.21.16.38;	author phil;	state Exp;
branches
	1.1.1.1.4.1;
next	;

1.1.1.1.4.1
date	99.06.24.00.34.39;	author cgd;	state Exp;
branches;
next	;


desc
@@


1.48
log
@msg_table_add(): fix mishap in the format safety changes in r1.45
@
text
@/*	$NetBSD: msg_sys.def,v 1.47 2019/06/25 21:09:33 joerg Exp $	*/

/*
 * Copyright 1997 Piermont Information Systems Inc.
 * All rights reserved.
 *
 * Written by Philip A. Nelson for Piermont Information Systems Inc.
 *
 * 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.
 * 3. The name of Piermont Information Systems Inc. may not be used to endorse
 *    or promote products derived from this software without specific prior
 *    written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY PIERMONT INFORMATION SYSTEMS INC. ``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 PIERMONT INFORMATION SYSTEMS INC. 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.
 *
 */

static WINDOW *msg_win = NULL;
static char *cbuffer;
static size_t cbuffersize;

static int last_i_was_nl, last_i_was_space;
static int last_o_was_punct, last_o_was_space;

static void	_msg_beep(void);
static int	_msg_vprintf(int, const char *, va_list);
#define MSG_PROMPT_ECHO		1
#define MSG_PROMPT_HIDE_DFLT	2
static void	_msg_vprompt(const char *, int, const char *, char *,
			size_t, va_list);

static char *msgmap = MAP_FAILED;
static size_t msgmapsz;
static unsigned int msgmapcount;

/* Routines */

static void
_msg_beep(void)
{

	fprintf(stderr, "\a");
}

WINDOW *
msg_window(WINDOW *window)
{
	size_t ncbuffersize;
	char *ncbuffer;
	WINDOW *old;

	old = msg_win;
	if (!window)
		return old;
	msg_win = window;

	ncbuffersize = getmaxx(window) * getmaxy(window) + 1;
	while (ncbuffersize > cbuffersize) {
		ncbuffer = malloc(ncbuffersize);
		if (ncbuffer == NULL) {
			/* we might get truncated messages... */
			ncbuffersize <<= 1;
			continue;
		}
		if (cbuffer != NULL)
			free(cbuffer);
		cbuffer = ncbuffer;
		cbuffersize = ncbuffersize;
		break;
	}
	last_o_was_punct = 0;
	last_o_was_space = 1;
	return old;
}

int
msg_file(const char *file)
{
	int fd;

	if (msgmap != MAP_FAILED)
		munmap(msgmap, msgmapsz);
	msgmap = MAP_FAILED;
	if (!file)
		return 0;
	fd = open(file, O_RDONLY, 0);
	if (fd == -1)
		return -1;
	msgmapsz = lseek(fd, 0, SEEK_END);
	msgmap = mmap(0, msgmapsz, PROT_READ, MAP_SHARED, fd, 0);
	close(fd);
	if (msgmap == MAP_FAILED)
		return -1;
	/* check_magic */
	if (strcmp(msgmap, "MSGTXTS") != 0) {
		msg_file(NULL);
		return -1;
	}
	msgmapcount = atoi(msgmap + 8);
	return 0;
}

const char *
msg_string(msg msg_no)
{
	uintptr_t m = (uintptr_t)msg_no;

	if (m > sizeof msg_list / sizeof msg_list[0])
		/* guess that we were passed a text string */
		return msg_no;

	if (msgmap != MAP_FAILED && m != 0 && m <= msgmapcount) {
		unsigned int offset = atoi(msgmap + 8 + 8 * m);
		if (offset != 0 && offset < msgmapsz)
			return msgmap + offset;
	}

	return msg_list[m];
}

void
msg_clear(void)
{

	wclear(msg_win);
	last_o_was_punct = 0;
	last_o_was_space = 1;
}

void
msg_standout(void)
{

	wstandout(msg_win);
}

void
msg_standend(void)
{

	wstandend(msg_win);
}

static int __printflike(2, 0)
_msg_vprintf(int auto_fill, const char *fmt, va_list ap)
{
	const char *wstart, *afterw;
	int wordlen, nspaces;
	int ret;

	ret = vsnprintf(cbuffer, cbuffersize, fmt, ap);

	if (!auto_fill) {
		waddstr(msg_win, cbuffer);

		/*
		 * nothing is perfect if they flow text after a table,
		 * but this may be decent.
		 */
		last_i_was_nl = last_i_was_space = 1;
		last_o_was_punct = 0;
		last_o_was_space = 1;
		goto out;
	}

	for (wstart = afterw = cbuffer; *wstart; wstart = afterw) {

		/* eat one space, or a whole word of non-spaces */
		if (isspace((unsigned char)*afterw))
			afterw++;
		else
			while (*afterw && !isspace((unsigned char)*afterw))
				afterw++;

		/* this is an nl: special formatting necessary */
		if (*wstart == '\n') {
			if (last_i_was_nl || last_i_was_space) {

				if (getcurx(msg_win) != 0)
					waddch(msg_win, '\n');
				if (last_i_was_nl) {
					/* last was an nl: paragraph break */
					waddch(msg_win, '\n');
				} else {
					/* last was space: line break */
				}
				last_o_was_punct = 0;
				last_o_was_space = 1;
			} else {
				/* last_o_was_punct unchanged */
				/* last_o_was_space unchanged */
			}
			last_i_was_space = 1;
			last_i_was_nl = 1;
			continue;
		}

		/* this is a tab: special formatting necessary. */
		if (*wstart == '\t') {
			if (last_i_was_nl) {
				/* last was an nl: list indent */
				if (getcurx(msg_win) != 0)
					waddch(msg_win, '\n');
			} else {
				/* last was not an nl: columns */
			}
			waddch(msg_win, '\t');
			last_i_was_nl = 0;
			last_i_was_space = 1;
			last_o_was_punct = 0;
			last_o_was_space = 1;
			continue;
		}

		/* this is a space: ignore it but set flags */
		last_i_was_nl = 0;	/* all newlines handled above */
		last_i_was_space = isspace((unsigned char)*wstart);
		if (last_i_was_space)
			continue;

		/*
		 * we have a real "word," i.e. a sequence of non-space
		 * characters.  wstart is now the start of the word,
		 * afterw is the next character after the end.
		 */
		wordlen = afterw - wstart;
		nspaces = last_o_was_space ? 0 : (last_o_was_punct ? 2 : 1);
		if ((getcurx(msg_win) + nspaces + wordlen) >=
		      getmaxx(msg_win) &&
		    wordlen < (getmaxx(msg_win) / 3)) {
			/* wrap the line */
			waddch(msg_win, '\n');
			nspaces = 0;
		}

		/* output the word, preceded by spaces if necessary */
		while (nspaces-- > 0)
			waddch(msg_win, ' ');
		waddbytes(msg_win, wstart, wordlen);

		/* set up the 'last' state for the next time around */
		switch (afterw[-1]) {
		case '.':
		case '?':
		case '!':
			last_o_was_punct = 1;
			break;
		default:
			last_o_was_punct = 0;
			break;
		}
		last_o_was_space = 0;

		/* ... and do it all again! */
	}

	/* String ended with a newline.  They really want a line break. */
	if (last_i_was_nl) {
		if (getcurx(msg_win) != 0)
			waddch(msg_win, '\n');
		last_o_was_punct = 0;
		last_o_was_space = 1;
	}

out:
	wrefresh(msg_win);
	return ret;
}

void
msg_display(msg msg_no)
{

	msg_clear();
	msg_printf("%s", msg_string(msg_no));
}

void __printflike(2, 3)
msg_fmt_display(msg msg_no, const char *fmt, ...)
{
	va_list ap;

	msg_clear();

	va_start(ap, fmt);
	(void)_msg_vprintf(1, fmtcheck(msg_string(msg_no), fmt), ap);
	va_end(ap);
}

void
msg_display_add(msg msg_no)
{

	msg_printf("%s", msg_string(msg_no));
}

void __printflike(2, 3)
msg_fmt_display_add(msg msg_no, const char *fmt, ...)
{
	va_list ap;

	va_start(ap, fmt);
	(void)_msg_vprintf(1, fmtcheck(msg_string(msg_no), fmt), ap);
	va_end(ap);
}

void __printflike(1, 2)
msg_printf(const char *fmt, ...)
{
	va_list ap;

	va_start(ap, fmt);
	(void)_msg_vprintf(1, fmt, ap);
	va_end(ap);
}

static void __printflike(1, 0)
_msg_vprompt(const char *fmt, int flags, const char *def, char *val,
    size_t val_buf_len, va_list ap)
{
	int ch;
	int len, pos, npos, off;
	int first;
	int txt_y, txt_x;
	char *ibuf;
	int maxx;

	if (val == NULL || val_buf_len == 0) {
		/* No answer wanted */
		val = NULL;
		val_buf_len = 1;
	}

	ibuf = malloc(val_buf_len);

	keypad(msg_win, TRUE);
	_msg_vprintf(0, fmt, ap);
	ibuf[0] = 0;
	if (def != NULL && *def) {
		if (flags & MSG_PROMPT_HIDE_DFLT)
			strlcpy(ibuf, def, val_buf_len);
		else {
			waddstr(msg_win, " [");
			waddstr(msg_win, def);
			waddstr(msg_win, "]");
		}
	}
	waddstr(msg_win, ": ");
	len = strlen(ibuf);
	pos = len;
	getyx(msg_win, txt_y, txt_x);
	maxx = getmaxx(msg_win) - txt_x - 1;
	off = 0;

	for (first = 1; ; first = 0) {

		if (flags & MSG_PROMPT_ECHO) {
			/* shift text right as we near the buffer start */
			if (pos - off < 4)
				off = pos - 4;
			/* keep offset to a minimum if we are at the end */
			if (pos == len)
				off = pos - maxx;
			if (off < 0 || len <= maxx)
				off = 0;
			/* shift text left as we near the buffer end */
			npos = pos + 4;
			if (npos > len)
				npos = len;
			if (npos - off > maxx)
				off = npos - maxx;
			/* calc. length to display */
			npos = len - off;
			if (npos > maxx)
				npos = maxx;
			mvwaddnstr(msg_win, txt_y, txt_x, ibuf + off, npos);
			wclrtoeol(msg_win);
			if (off != 0)
				mvwaddstr(msg_win, txt_y, txt_x, "+");
			wmove(msg_win, txt_y, txt_x + pos - off);
			wrefresh(msg_win);
		}

		ch = wgetch(msg_win);
		if (ch == '\n')
			break;

		switch (ch) {
		case KEY_BACKSPACE:
		case 'h' & 0x1f: case 0x7f:  /* bs or del - delete left */
			if (first) {
				/* delete all of default string */
				len = pos = 0;
				break;
			}
			if (pos > 0) {
				memmove(ibuf + pos - 1, ibuf + pos, len - pos);
				len--;
				pos--;
			} else
				_msg_beep();
			break;
		case 'l' & 0x1f:
			endwin();
			doupdate();
			break;
		case 'u' & 0x1f:	/* ^U; line kill */
			/* kill line */
			len = pos = 0;
			break;
		case 'w' & 0x1f:        /* ^W; word kill */
			/*
			 * word kill kills the spaces and the 'word'
			 * (non-spaces) last typed.  the spaces before
			 * the 'word' aren't killed.
			 */
			npos = pos;
			while (npos > 0 && isspace((unsigned char)ibuf[npos - 1]))
				npos--;
			while (npos > 0 && !isspace((unsigned char)ibuf[npos - 1]))
				npos--;
			memmove(ibuf + npos, ibuf + pos, len - pos);
			len -= pos - npos;
			pos = npos;
			break;
		case KEY_LEFT:
			if (pos > 0)
				pos--;
			break;
		case KEY_RIGHT:
			if (len == 0 && pos == 0 && def != NULL) {
				/* restore default! */
				strlcpy(ibuf, def, val_buf_len);
				len = pos = strlen(ibuf);
				break;
			}
			if (pos < len)
				pos++;
			break;
		default:
			if (len < (int)(val_buf_len - 1) && isprint(ch)) {
				memmove(ibuf + pos + 1, ibuf + pos, len - pos);
				ibuf[pos++] = ch;
				len++;
			} else
				_msg_beep();
			break;
		}
	}

	if (flags & MSG_PROMPT_ECHO) {
		mvwaddch(msg_win, txt_y, txt_x + len - off, '\n');
		last_o_was_punct = 0;
		last_o_was_space = 1;
	}

	if (val != NULL) {
		/* copy the appropriate string to the output */
		if (len != 0 || flags & MSG_PROMPT_HIDE_DFLT) {
			ibuf[len] = '\0';
			strlcpy(val, ibuf, val_buf_len);
		} else if (def != NULL && val != def) {
			strlcpy(val, def, val_buf_len);
		}
	}
	free(ibuf);
}

void
msg_prompt(msg msg_no, const char *def, char *val, size_t val_buf_len)
{

	msg_fmt_prompt(msg_no, def, val, val_buf_len, "");
}

void __printflike(5, 6)
msg_fmt_prompt(msg msg_no, const char *def, char *val, size_t val_buf_len,
    const char *fmt, ...)
{
	va_list ap;

	msg_clear();

	va_start(ap, fmt);
	_msg_vprompt(fmtcheck(msg_string(msg_no), fmt), MSG_PROMPT_ECHO,
		def, val, val_buf_len, ap);
	va_end(ap);
}

void
msg_prompt_win(msg msg_no, int x, int y, int w, int h,
    const char *def, char *val, size_t val_buf_len)
{
    msg_fmt_prompt_win(msg_no, x, y, w, h, def, val, val_buf_len, "");
}

void __printflike(9, 10)
msg_fmt_prompt_win(msg msg_no, int x, int y, int w, int h,
    const char *def, char *val, size_t val_buf_len, const char *fmt, ...)
{
	va_list ap;
	WINDOW *win;
	WINDOW *svmsg = NULL, *sv_win = NULL; /* XXX -Wuninitialized [many] */
	int maxx, maxy;
	int msg_flags = MSG_PROMPT_ECHO | MSG_PROMPT_HIDE_DFLT;
	const char *np, *ep;

	maxx = getmaxx(msg_win);
	maxy = getmaxy(msg_win);
	if (w == 0) {
		va_start(ap, fmt);
		w = vsnprintf(NULL, 0, fmtcheck(msg_string(msg_no), fmt), ap);
		va_end(ap);
		if (def != NULL && *def != 0 && w + (int)val_buf_len * 2 < maxx) 		{
			w += 2 + strlen(def) + 1;
			msg_flags &= ~MSG_PROMPT_HIDE_DFLT;
		}
		w += 1 + 2 + val_buf_len + 1;
		if (w > maxx) {
			if (!(msg_flags & MSG_PROMPT_HIDE_DFLT)) {
				w -= 2 + strlen(def) + 1;
				msg_flags |= MSG_PROMPT_HIDE_DFLT;
			}
			w = maxx;
		}
	} else if (w > 0 && def != NULL && *def != 0) {
		size_t tl = strlen(def);
		if (tl + 1 + 2 + val_buf_len + 1 < (unsigned)w)
			msg_flags &= ~MSG_PROMPT_HIDE_DFLT;
	}

	if (x == -1)
		x = (maxx - w) / 2 + 1;
	if (h < 0) {
		h = 3;
		for (np = msg_string(msg_no); (ep = strchr(np, '\n'));
		    np = ep + 1)
			h++;
	}
	if (h < 3)
		h = 3;
	if (y < 3)
		y = (maxy - h) / 2;
	if (y + h > maxy)
		y = maxy - h;

	win = subwin(msg_win, h, w, y, x);
	if (win == NULL)
		wprintw(msg_win, "msg_prompt_win: "
			"newwin(%d, %d, %d, %d) failed\n",
			h, w, y, x);
	else {
		/*
		 * Save screen contents from under our window
		 * Due to a mis-feature of NetBSD curses, curscr contains
		 * the data processed by doupdate() not that by wnoutrefresh().
		 * We must call doupdate() here to ensure we save the correct
		 * data.  See PR 26660
		 */
		doupdate();
		sv_win = dupwin(win);
		if (sv_win)
			overwrite(curscr, sv_win);
		wbkgd(win, getbkgd(msg_win));
		wattrset(win, getattrs(msg_win));
		box(win, 0, 0);
		wrefresh(win);

		/* Change message window to be our little box */
		svmsg = msg_window(subwin(msg_win, h - 2, w - 2, y + 1, x + 1));
		wbkgd(msg_win, getbkgd(win));
		wattrset(msg_win, getattrs(win));

		msg_clear();
	}

	va_start(ap, fmt);
	_msg_vprompt(fmtcheck(msg_string(msg_no), fmt), msg_flags, def, val,
	    val_buf_len, ap);
	va_end(ap);

	if (win != NULL) {
		wclear(win);
		if (sv_win) {
			/* Restore original screen contents */
			overwrite(sv_win, win);
			delwin(sv_win);
		}
		wnoutrefresh(win);
		/* Restore normal message window */
		delwin(msg_window(svmsg));
		delwin(win);
	}
}

void 
msg_prompt_add(msg msg_no, const char *def, char *val, size_t val_buf_len)
{

	msg_fmt_prompt_add(msg_no, def, val, val_buf_len, "");
}

void __printflike(5, 6)
msg_fmt_prompt_add(msg msg_no, const char *def, char *val, size_t val_buf_len,
    const char *fmt, ...)
{
	va_list ap;

	va_start(ap, fmt);
	_msg_vprompt(fmtcheck(msg_string(msg_no), fmt), MSG_PROMPT_ECHO, def,
	    val, val_buf_len, ap);
	va_end(ap);
}

void
msg_prompt_noecho(msg msg_no, const char *def, char *val, size_t val_buf_len)
{
	msg_fmt_prompt_noecho(msg_no, def, val, val_buf_len, "");
}

void __printflike(5, 6)
msg_fmt_prompt_noecho(msg msg_no, const char *def, char *val,
    size_t val_buf_len, const char *fmt, ...)
{
	va_list ap;

	msg_clear();

	va_start(ap, fmt);
	_msg_vprompt(fmtcheck(msg_string(msg_no), fmt), 0, def, val,
	    val_buf_len, ap);
	va_end(ap);
}

void
msg_table_add(msg msg_no)
{

	msg_fmt_table_add(msg_no, "");
}

void __printflike(2, 3)
msg_fmt_table_add(msg msg_no, const char *fmt, ...)
{
	va_list ap;

	va_start(ap, fmt);
	(void)_msg_vprintf(0, fmtcheck(msg_string(msg_no), fmt), ap);
	va_end(ap);
}

int
msg_row(void)
{

	return getcury(msg_win) + getbegy(msg_win);
}
@


1.47
log
@Do the fmtcheck for both message lookups to satisfy format string
literal checks.
@
text
@d1 1
a1 1
/*	$NetBSD: msg_sys.def,v 1.46 2019/06/20 11:31:12 martin Exp $	*/
d656 1
a656 1
	msg_printf("%s", msg_string(msg_no));
@


1.47.2.1
log
@Pull up following revision(s) (requested by martin in ticket #433):
	usr.bin/msgc/msg_sys.def: revision 1.48
msg_table_add(): fix mishap in the format safety changes in r1.45
@
text
@d1 1
a1 1
/*	$NetBSD: msg_sys.def,v 1.47 2019/06/25 21:09:33 joerg Exp $	*/
d656 1
a656 1
	msg_fmt_table_add(msg_no, "");
@


1.46
log
@Re-add msg_clear() accidently dropped in previous.
@
text
@d1 1
a1 1
/*	$NetBSD: msg_sys.def,v 1.45 2019/06/20 00:45:18 christos Exp $	*/
d595 2
a596 1
	_msg_vprompt(msg_string(msg_no), msg_flags, def, val, val_buf_len, ap);
@


1.45
log
@Introduce _fmt_ flavors of the menu functions that take a formatting string
so we can use fmtcheck(3) to check the formats of the messages strings.
@
text
@d1 1
a1 1
/*	$NetBSD: msg_sys.def,v 1.44 2019/03/01 17:02:21 martin Exp $	*/
d291 1
@


1.44
log
@msg_prompt_win: allow automatic window height calculation (by passing
height = -1).
@
text
@d1 1
a1 1
/*	$NetBSD: msg_sys.def,v 1.43 2019/01/22 18:39:49 martin Exp $	*/
d161 1
a161 1
static int
d288 8
a295 1
msg_display(msg msg_no, ...)
d301 2
a302 2
	va_start(ap, msg_no);
	(void)_msg_vprintf(1, msg_string(msg_no), ap);
d307 8
a314 1
msg_display_add(msg msg_no, ...)
d318 2
a319 2
	va_start(ap, msg_no);
	(void)_msg_vprintf(1, msg_string(msg_no), ap);
d323 1
a323 1
void
d333 1
a333 1
static void
d486 9
a494 1
msg_prompt(msg msg_no, const char *def, char *val, size_t val_buf_len, ...)
d500 2
a501 2
	va_start(ap, val_buf_len);
	_msg_vprompt(msg_string(msg_no), MSG_PROMPT_ECHO,
d508 8
a515 1
	const char *def, char *val, size_t val_buf_len, ...)
d527 2
a528 2
		va_start(ap, val_buf_len);
		w = vsnprintf(NULL, 0, msg_string(msg_no), ap);
d530 1
a530 1
		if (def != NULL && *def != 0 && w + (int)val_buf_len * 2 < maxx) {
d593 1
a593 1
	va_start(ap, val_buf_len);
d611 10
a620 2
void
msg_prompt_add(msg msg_no, const char *def, char *val, size_t val_buf_len, ...)
d624 3
a626 2
	va_start(ap, val_buf_len);
	_msg_vprompt(msg_string(msg_no), MSG_PROMPT_ECHO, def, val, val_buf_len, ap);
d631 8
a638 1
msg_prompt_noecho(msg msg_no, const char *def, char *val, size_t val_buf_len, ...)
d644 3
a646 2
	va_start(ap, val_buf_len);
	_msg_vprompt(msg_string(msg_no), 0, def, val, val_buf_len, ap);
d651 8
a658 1
msg_table_add(msg msg_no, ...)
d662 2
a663 2
	va_start(ap, msg_no);
	(void)_msg_vprintf(0, msg_string(msg_no), ap);
@


1.43
log
@Support redrawing all windows when in a msg prompt via Ctrl-l.
@
text
@d1 1
a1 1
/*	$NetBSD: msg_sys.def,v 1.42 2019/01/21 20:28:08 martin Exp $	*/
d493 1
d521 6
@


1.42
log
@msg_prompt_win: if the default string fits, show it separately even
in fixed size windows. Previously it would only show up when auto-sizing
prompts figured it would fit (probably an oversight).
@
text
@d1 1
a1 1
/*	$NetBSD: msg_sys.def,v 1.41 2012/03/06 16:26:01 mbalmer Exp $	*/
d405 4
@


1.41
log
@Remove the advertising clause with the explicit ok from Perry E. Metzger.
@
text
@d1 1
a1 1
/*	$NetBSD: msg_sys.def,v 1.40 2012/03/02 14:27:48 mbalmer Exp $	*/
d508 4
@


1.41.32.1
log
@Sync with HEAD
@
text
@d1 1
a1 1
/*	$NetBSD: msg_sys.def,v 1.44 2019/03/01 17:02:21 martin Exp $	*/
a404 4
		case 'l' & 0x1f:
			endwin();
			doupdate();
			break;
a488 1
	const char *np, *ep;
a507 4
	} else if (w > 0 && def != NULL && *def != 0) {
		size_t tl = strlen(def);
		if (tl + 1 + 2 + val_buf_len + 1 < (unsigned)w)
			msg_flags &= ~MSG_PROMPT_HIDE_DFLT;
a511 6
	if (h < 0) {
		h = 3;
		for (np = msg_string(msg_no); (ep = strchr(np, '\n'));
		    np = ep + 1)
			h++;
	}
@


1.41.32.2
log
@Mostly merge changes from HEAD upto 20200411
@
text
@d1 1
a1 1
/*	$NetBSD$	*/
d161 1
a161 1
static int __printflike(2, 0)
d288 1
a288 9
msg_display(msg msg_no)
{

	msg_clear();
	msg_printf("%s", msg_string(msg_no));
}

void __printflike(2, 3)
msg_fmt_display(msg msg_no, const char *fmt, ...)
d294 2
a295 2
	va_start(ap, fmt);
	(void)_msg_vprintf(1, fmtcheck(msg_string(msg_no), fmt), ap);
d300 1
a300 8
msg_display_add(msg msg_no)
{

	msg_printf("%s", msg_string(msg_no));
}

void __printflike(2, 3)
msg_fmt_display_add(msg msg_no, const char *fmt, ...)
d304 2
a305 2
	va_start(ap, fmt);
	(void)_msg_vprintf(1, fmtcheck(msg_string(msg_no), fmt), ap);
d309 1
a309 1
void __printflike(1, 2)
d319 1
a319 1
static void __printflike(1, 0)
d472 1
a472 9
msg_prompt(msg msg_no, const char *def, char *val, size_t val_buf_len)
{

	msg_fmt_prompt(msg_no, def, val, val_buf_len, "");
}

void __printflike(5, 6)
msg_fmt_prompt(msg msg_no, const char *def, char *val, size_t val_buf_len,
    const char *fmt, ...)
d478 2
a479 2
	va_start(ap, fmt);
	_msg_vprompt(fmtcheck(msg_string(msg_no), fmt), MSG_PROMPT_ECHO,
d486 1
a486 8
    const char *def, char *val, size_t val_buf_len)
{
    msg_fmt_prompt_win(msg_no, x, y, w, h, def, val, val_buf_len, "");
}

void __printflike(9, 10)
msg_fmt_prompt_win(msg msg_no, int x, int y, int w, int h,
    const char *def, char *val, size_t val_buf_len, const char *fmt, ...)
d498 2
a499 2
		va_start(ap, fmt);
		w = vsnprintf(NULL, 0, fmtcheck(msg_string(msg_no), fmt), ap);
d501 1
a501 1
		if (def != NULL && *def != 0 && w + (int)val_buf_len * 2 < maxx) 		{
d564 2
a565 3
	va_start(ap, fmt);
	_msg_vprompt(fmtcheck(msg_string(msg_no), fmt), msg_flags, def, val,
	    val_buf_len, ap);
d582 2
a583 10
void 
msg_prompt_add(msg msg_no, const char *def, char *val, size_t val_buf_len)
{

	msg_fmt_prompt_add(msg_no, def, val, val_buf_len, "");
}

void __printflike(5, 6)
msg_fmt_prompt_add(msg msg_no, const char *def, char *val, size_t val_buf_len,
    const char *fmt, ...)
d587 2
a588 3
	va_start(ap, fmt);
	_msg_vprompt(fmtcheck(msg_string(msg_no), fmt), MSG_PROMPT_ECHO, def,
	    val, val_buf_len, ap);
d593 1
a593 8
msg_prompt_noecho(msg msg_no, const char *def, char *val, size_t val_buf_len)
{
	msg_fmt_prompt_noecho(msg_no, def, val, val_buf_len, "");
}

void __printflike(5, 6)
msg_fmt_prompt_noecho(msg msg_no, const char *def, char *val,
    size_t val_buf_len, const char *fmt, ...)
d599 2
a600 3
	va_start(ap, fmt);
	_msg_vprompt(fmtcheck(msg_string(msg_no), fmt), 0, def, val,
	    val_buf_len, ap);
d605 1
a605 8
msg_table_add(msg msg_no)
{

	msg_fmt_table_add(msg_no, "");
}

void __printflike(2, 3)
msg_fmt_table_add(msg msg_no, const char *fmt, ...)
d609 2
a610 2
	va_start(ap, fmt);
	(void)_msg_vprintf(0, fmtcheck(msg_string(msg_no), fmt), ap);
@


1.41.30.1
log
@Sync with HEAD
@
text
@d1 1
a1 1
/*	$NetBSD: msg_sys.def,v 1.41 2012/03/06 16:26:01 mbalmer Exp $	*/
a404 4
		case 'l' & 0x1f:
			endwin();
			doupdate();
			break;
a507 4
	} else if (w > 0 && def != NULL && *def != 0) {
		size_t tl = strlen(def);
		if (tl + 1 + 2 + val_buf_len + 1 < (unsigned)w)
			msg_flags &= ~MSG_PROMPT_HIDE_DFLT;
@


1.40
log
@Add msg_printf(fmt, ...), a function to display raw messages without
going through the message catalog.
@
text
@d1 1
a1 1
/*	$NetBSD: msg_sys.def,v 1.39 2012/03/02 13:11:57 mbalmer Exp $	*/
d17 1
a17 5
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *      This product includes software develooped for the NetBSD Project by
 *      Piermont Information Systems Inc.
 * 4. The name of Piermont Information Systems Inc. may not be used to endorse
@


1.39
log
@Removing trailing whitespace.
@
text
@d1 1
a1 1
/*	$NetBSD: msg_sys.def,v 1.38 2010/01/02 16:08:20 dsl Exp $	*/
d313 10
@


1.38
log
@Remove some sign compare warnings.
@
text
@d1 1
a1 1
/*	$NetBSD: msg_sys.def,v 1.37 2006/12/03 01:18:34 christos Exp $	*/
d28 3
a30 3
 * ARE DISCLAIMED. IN NO EVENT SHALL PIERMONT INFORMATION SYSTEMS INC. BE 
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
d34 1
a34 1
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 
@


1.38.6.1
log
@sync with head
@
text
@d1 1
a1 1
/*	$NetBSD$	*/
d17 5
a21 1
 * 3. The name of Piermont Information Systems Inc. may not be used to endorse
d28 3
a30 3
 * ARE DISCLAIMED. IN NO EVENT SHALL PIERMONT INFORMATION SYSTEMS INC. BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
d34 1
a34 1
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
a312 10
void
msg_printf(const char *fmt, ...)
{
	va_list ap;

	va_start(ap, fmt);
	(void)_msg_vprintf(1, fmt, ap);
	va_end(ap);
}

@


1.37
log
@eliminate an alloca use.
@
text
@d1 1
a1 1
/*	$NetBSD: msg_sys.def,v 1.36 2006/09/06 19:24:15 dsl Exp $	*/
d55 1
a55 1
static int msgmapcount;
d127 1
a127 1
	int m = (intptr_t)msg_no;
d433 1
a433 1
			if (len < (val_buf_len - 1) && isprint(ch)) {
d490 1
a490 1
		if (def != NULL && *def != 0 && w + val_buf_len * 2 < maxx) {
@


1.36
log
@Fix requests for msg input with a NULL target buffer (or zero length one)
to core dumps from sysinsts mbr code (and others) that use message boxes
for 'press enter to continue' actions.
Fixes PR/34206
@
text
@d1 1
a1 1
/*	$NetBSD: msg_sys.def,v 1.35 2006/09/06 19:13:51 dsl Exp $	*/
d330 1
a330 1
	ibuf = alloca(val_buf_len);
d458 1
@


1.36.2.1
log
@Pull up following revision(s) (requested by tls in ticket #243):
	usr.bin/msgc/msg_sys.def: revision 1.37
eliminate an alloca use.
@
text
@d1 1
a1 1
/*	$NetBSD$	*/
d330 1
a330 1
	ibuf = malloc(val_buf_len);
a457 1
	free(ibuf);
@


1.35
log
@Rename 'max_chars' to 'val_buf_len' to make it clearer that it has to include
the trailing NUL.
@
text
@d1 1
a1 1
/*	$NetBSD: msg_sys.def,v 1.34 2006/05/12 07:20:13 he Exp $	*/
d321 1
a321 1
	char *ibuf = alloca(val_buf_len);
d324 8
d449 8
a456 6
	/* copy the appropriate string to the output */
	if (len != 0 || flags & MSG_PROMPT_HIDE_DFLT) {
		ibuf[len] = '\0';
		strlcpy(val, ibuf, val_buf_len);
	} else if (def != NULL && val != def) {
		strlcpy(val, def, val_buf_len);
@


1.34
log
@Sorry, fix syntax error in previous.
@
text
@d1 1
a1 1
/*	$NetBSD: msg_sys.def,v 1.33 2006/05/12 07:19:43 he Exp $	*/
d315 1
a315 1
    size_t max_chars, va_list ap)
d321 1
a321 1
	char *ibuf = alloca(max_chars);
d329 1
a329 1
			strlcpy(ibuf, def, max_chars);
d417 1
a417 1
				strlcpy(ibuf, def, max_chars);
d425 1
a425 1
			if (len < (max_chars - 1) && isprint(ch)) {
d444 1
a444 1
		strlcpy(val, ibuf, max_chars);
d446 1
a446 1
		strlcpy(val, def, max_chars);
d451 1
a451 1
msg_prompt(msg msg_no, const char *def, char *val, size_t max_chars, ...)
d457 1
a457 1
	va_start(ap, max_chars);
d459 1
a459 1
		def, val, max_chars, ap);
d465 1
a465 1
	const char *def, char *val, size_t max_chars, ...)
d476 1
a476 1
		va_start(ap, max_chars);
d479 1
a479 1
		if (def != NULL && *def != 0 && w + max_chars * 2 < maxx) {
d483 1
a483 1
		w += 1 + 2 + max_chars + 1;
d532 2
a533 2
	va_start(ap, max_chars);
	_msg_vprompt(msg_string(msg_no), msg_flags, def, val, max_chars, ap);
d551 1
a551 1
msg_prompt_add(msg msg_no, const char *def, char *val, size_t max_chars, ...)
d555 2
a556 2
	va_start(ap, max_chars);
	_msg_vprompt(msg_string(msg_no), MSG_PROMPT_ECHO, def, val, max_chars, ap);
d561 1
a561 1
msg_prompt_noecho(msg msg_no, const char *def, char *val, size_t max_chars, ...)
d567 2
a568 2
	va_start(ap, max_chars);
	_msg_vprompt(msg_string(msg_no), 0, def, val, max_chars, ap);
@


1.34.4.1
log
@Pull up following revision(s) (requested by dsl in ticket #155):
	usr.bin/msgc/msg_sys.def: revision 1.35
	usr.bin/msgc/msg_sys.def: revision 1.36
Rename 'max_chars' to 'val_buf_len' to make it clearer that it has to include
the trailing NUL.
Fix requests for msg input with a NULL target buffer (or zero length one)
to core dumps from sysinsts mbr code (and others) that use message boxes
for 'press enter to continue' actions.
Fixes PR/34206
@
text
@d1 1
a1 1
/*	$NetBSD$	*/
d315 1
a315 1
    size_t val_buf_len, va_list ap)
d321 1
a321 1
	char *ibuf;
a323 8
	if (val == NULL || val_buf_len == 0) {
		/* No answer wanted */
		val = NULL;
		val_buf_len = 1;
	}

	ibuf = alloca(val_buf_len);

d329 1
a329 1
			strlcpy(ibuf, def, val_buf_len);
d417 1
a417 1
				strlcpy(ibuf, def, val_buf_len);
d425 1
a425 1
			if (len < (val_buf_len - 1) && isprint(ch)) {
d441 6
a446 8
	if (val != NULL) {
		/* copy the appropriate string to the output */
		if (len != 0 || flags & MSG_PROMPT_HIDE_DFLT) {
			ibuf[len] = '\0';
			strlcpy(val, ibuf, val_buf_len);
		} else if (def != NULL && val != def) {
			strlcpy(val, def, val_buf_len);
		}
d451 1
a451 1
msg_prompt(msg msg_no, const char *def, char *val, size_t val_buf_len, ...)
d457 1
a457 1
	va_start(ap, val_buf_len);
d459 1
a459 1
		def, val, val_buf_len, ap);
d465 1
a465 1
	const char *def, char *val, size_t val_buf_len, ...)
d476 1
a476 1
		va_start(ap, val_buf_len);
d479 1
a479 1
		if (def != NULL && *def != 0 && w + val_buf_len * 2 < maxx) {
d483 1
a483 1
		w += 1 + 2 + val_buf_len + 1;
d532 2
a533 2
	va_start(ap, val_buf_len);
	_msg_vprompt(msg_string(msg_no), msg_flags, def, val, val_buf_len, ap);
d551 1
a551 1
msg_prompt_add(msg msg_no, const char *def, char *val, size_t val_buf_len, ...)
d555 2
a556 2
	va_start(ap, val_buf_len);
	_msg_vprompt(msg_string(msg_no), MSG_PROMPT_ECHO, def, val, val_buf_len, ap);
d561 1
a561 1
msg_prompt_noecho(msg msg_no, const char *def, char *val, size_t val_buf_len, ...)
d567 2
a568 2
	va_start(ap, val_buf_len);
	_msg_vprompt(msg_string(msg_no), 0, def, val, val_buf_len, ap);
@


1.33
log
@Appease gcc 3.3.3 -Wuninitialized warning; fixes build problem for
a multitude of archtectures (prep, alpha, i386, acorn32 and probably
more).
To be documented in doc/HACKS.
@
text
@d1 1
a1 1
/*	$NetBSD: msg_sys.def,v 1.32 2005/04/09 13:12:31 dsl Exp $	*/
d468 1
a468 1
	WINDOW *win
@


1.32
log
@If the user removed the default string (after we had put it into the buffer
area - rather than in []), then don't reinstate it on exit
@
text
@d1 1
a1 1
/*	$NetBSD: msg_sys.def,v 1.31 2004/11/05 20:45:48 dsl Exp $	*/
d468 2
a469 1
	WINDOW *win, *svmsg, *sv_win;
@


1.31
log
@Add (unsigned char) cast to ctype functions
Fixes problems displaying German 'sharp-s', see PR install/27281
@
text
@d1 1
a1 1
/*	$NetBSD: msg_sys.def,v 1.30 2004/10/16 12:49:14 dsl Exp $	*/
d442 1
a442 1
	if (len != 0) {
@


1.31.2.1
log
@Pull up following revision(s) (requested by dsl in ticket #1513):
	usr.bin/msgc/msg_sys.def: revision 1.32
If the user removed the default string (after we had put it into the buffer
area - rather than in []), then don't reinstate it on exit
@
text
@d1 1
a1 1
/*	$NetBSD$	*/
d442 1
a442 1
	if (len != 0 || flags & MSG_PROMPT_HIDE_DFLT) {
@


1.30
log
@Remove _erase_ch() it isn't used any more
@
text
@d1 1
a1 1
/*	$NetBSD: msg_sys.def,v 1.29 2004/08/14 15:15:57 dsl Exp $	*/
d190 1
a190 1
		if (isspace(*afterw))
d193 1
a193 1
			while (*afterw && !isspace(*afterw))
d238 1
a238 1
		last_i_was_space = isspace(*wstart);
d402 1
a402 1
			while (npos > 0 && isspace(ibuf[npos - 1]))
d404 1
a404 1
			while (npos > 0 && !isspace(ibuf[npos - 1]))
@


1.29
log
@NetBSD curses gives the wrong data when you read curscr, need to
add a doupdate() so we save from the correct screen image.
@
text
@d1 1
a1 1
/*	$NetBSD: msg_sys.def,v 1.28 2004/08/13 18:26:52 dsl Exp $	*/
a313 12
_erase_ch(void)
{
	int y, x;

	getyx(msg_win, y, x);
	x--;
	wmove(msg_win, y, x);
	waddch(msg_win, ' ');
	wmove(msg_win, y, x);
}

static void
@


1.28
log
@Save and restore screen underneath prompt boxes
@
text
@d1 1
a1 1
/*	$NetBSD: msg_sys.def,v 1.27 2004/06/05 19:05:36 dsl Exp $	*/
d519 8
a526 1
		/* Save screen contents from under out window */
@


1.27
log
@Improve editing of input fields:
<- and -> move within the field
-> will pull default string into empty buffer
^H (etc) will delete default string from buffer (first press)
Put default string into display buffer if long and input in box.
Scroll input text if longer than space on line.
@
text
@d1 1
a1 1
/*	$NetBSD: msg_sys.def,v 1.26 2003/09/25 18:32:10 dsl Exp $	*/
d480 1
a480 1
	WINDOW *win, *svwin;
d519 4
d529 1
a529 1
		svwin = msg_window(subwin(msg_win, h - 2, w - 2, y + 1, x + 1));
d542 6
a547 1
		wrefresh(win);
d549 1
a549 1
		delwin(msg_window(svwin));
@


1.26
log
@Add a msg_row() function that returns the current screen row.
Allows sysinst to place menus below any header text.
Remove msg_*.1 man pages for all the functions (they are in the wrong place
are a fair waste of directory space).
@
text
@d1 1
a1 1
/*	$NetBSD: msg_sys.def,v 1.25 2003/07/28 09:55:24 dsl Exp $	*/
d48 2
d326 1
a326 1
_msg_vprompt(const char *fmt, int do_echo, const char *def, char *val,
d330 3
a332 1
	int count = 0;
d334 1
d336 1
d338 1
d340 7
a346 3
		waddstr(msg_win, " [");
		waddstr(msg_win, def);
		waddstr(msg_win, "]");
d349 38
a386 1
	wrefresh(msg_win);
d388 12
a399 6
	while ((ch = wgetch(msg_win)) != '\n') {
		if (ch == 0x08 || ch == 0x7f) {  /* bs or del */
			if (count > 0) {
				count--;
				if (do_echo)
					_erase_ch();
d402 6
a407 7
		} else if (ch == 0x15) {	/* ^U; line kill */
			while (count > 0) {
				count--;
				if (do_echo)
					_erase_ch();
			}
		} else if (ch == 0x17) {        /* ^W; word kill */
d413 19
a431 4
			while (count > 0 && isspace(ibuf[count - 1])) {
				count--;
				if (do_echo)
					_erase_ch();
d433 12
a444 13
			while (count > 0 && !isspace(ibuf[count - 1])) {
				count--;
				if (do_echo)
					_erase_ch();
			}
		} else if (count < (max_chars - 1) && isprint(ch)) {
			if (do_echo)
				waddch(msg_win, ch);
			ibuf[count++] = ch;
		} else
			_msg_beep();
		if (do_echo)
			wrefresh(msg_win);
d446 3
a448 2
	if (do_echo) {
		waddch(msg_win, '\n');
d454 2
a455 2
	if (count != 0) {
		ibuf[count] = '\0';
d470 2
a471 1
	_msg_vprompt(msg_string(msg_no), 1, def, val, max_chars, ap);
d482 1
d490 1
a490 1
		if (def != NULL && *def != 0)
d492 2
d495 5
a499 1
		if (w > maxx)
d501 1
d505 1
a505 1
		x = (maxx - w) / 2;
d524 1
d533 1
a533 1
	_msg_vprompt(msg_string(msg_no), 1, def, val, max_chars, ap);
d539 1
d551 1
a551 1
	_msg_vprompt(msg_string(msg_no), 1, def, val, max_chars, ap);
@


1.26.2.1
log
@Pull up revision 1.27 (requested by dsl in ticket #452):
Improve editing of input fields:
<- and -> move within the field
-> will pull default string into empty buffer
^H (etc) will delete default string from buffer (first press)
Put default string into display buffer if long and input in box.
Scroll input text if longer than space on line.
@
text
@d1 1
a1 1
/*	$NetBSD$	*/
a47 2
#define MSG_PROMPT_ECHO		1
#define MSG_PROMPT_HIDE_DFLT	2
d324 1
a324 1
_msg_vprompt(const char *fmt, int flags, const char *def, char *val,
d328 1
a328 3
	int len, pos, npos, off;
	int first;
	int txt_y, txt_x;
a329 1
	int maxx;
a330 1
	keypad(msg_win, TRUE);
a331 1
	ibuf[0] = 0;
d333 3
a335 7
		if (flags & MSG_PROMPT_HIDE_DFLT)
			strlcpy(ibuf, def, max_chars);
		else {
			waddstr(msg_win, " [");
			waddstr(msg_win, def);
			waddstr(msg_win, "]");
		}
d338 1
a338 38
	len = strlen(ibuf);
	pos = len;
	getyx(msg_win, txt_y, txt_x);
	maxx = getmaxx(msg_win) - txt_x - 1;
	off = 0;

	for (first = 1; ; first = 0) {

		if (flags & MSG_PROMPT_ECHO) {
			/* shift text right as we near the buffer start */
			if (pos - off < 4)
				off = pos - 4;
			/* keep offset to a minimum if we are at the end */
			if (pos == len)
				off = pos - maxx;
			if (off < 0 || len <= maxx)
				off = 0;
			/* shift text left as we near the buffer end */
			npos = pos + 4;
			if (npos > len)
				npos = len;
			if (npos - off > maxx)
				off = npos - maxx;
			/* calc. length to display */
			npos = len - off;
			if (npos > maxx)
				npos = maxx;
			mvwaddnstr(msg_win, txt_y, txt_x, ibuf + off, npos);
			wclrtoeol(msg_win);
			if (off != 0)
				mvwaddstr(msg_win, txt_y, txt_x, "+");
			wmove(msg_win, txt_y, txt_x + pos - off);
			wrefresh(msg_win);
		}

		ch = wgetch(msg_win);
		if (ch == '\n')
			break;
d340 6
a345 12
		switch (ch) {
		case KEY_BACKSPACE:
		case 'h' & 0x1f: case 0x7f:  /* bs or del - delete left */
			if (first) {
				/* delete all of default string */
				len = pos = 0;
				break;
			}
			if (pos > 0) {
				memmove(ibuf + pos - 1, ibuf + pos, len - pos);
				len--;
				pos--;
d348 7
a354 6
			break;
		case 'u' & 0x1f:	/* ^U; line kill */
			/* kill line */
			len = pos = 0;
			break;
		case 'w' & 0x1f:        /* ^W; word kill */
d360 9
a368 19
			npos = pos;
			while (npos > 0 && isspace(ibuf[npos - 1]))
				npos--;
			while (npos > 0 && !isspace(ibuf[npos - 1]))
				npos--;
			memmove(ibuf + npos, ibuf + pos, len - pos);
			len -= pos - npos;
			pos = npos;
			break;
		case KEY_LEFT:
			if (pos > 0)
				pos--;
			break;
		case KEY_RIGHT:
			if (len == 0 && pos == 0 && def != NULL) {
				/* restore default! */
				strlcpy(ibuf, def, max_chars);
				len = pos = strlen(ibuf);
				break;
d370 8
a377 12
			if (pos < len)
				pos++;
			break;
		default:
			if (len < (max_chars - 1) && isprint(ch)) {
				memmove(ibuf + pos + 1, ibuf + pos, len - pos);
				ibuf[pos++] = ch;
				len++;
			} else
				_msg_beep();
			break;
		}
d379 2
a380 3

	if (flags & MSG_PROMPT_ECHO) {
		mvwaddch(msg_win, txt_y, txt_x + len - off, '\n');
d386 2
a387 2
	if (len != 0) {
		ibuf[len] = '\0';
d402 1
a402 2
	_msg_vprompt(msg_string(msg_no), MSG_PROMPT_ECHO,
		def, val, max_chars, ap);
a412 1
	int msg_flags = MSG_PROMPT_ECHO | MSG_PROMPT_HIDE_DFLT;
d420 1
a420 1
		if (def != NULL && *def != 0 && w + max_chars * 2 < maxx) {
a421 2
			msg_flags &= ~MSG_PROMPT_HIDE_DFLT;
		}
d423 1
a423 5
		if (w > maxx) {
			if (!(msg_flags & MSG_PROMPT_HIDE_DFLT)) {
				w -= 2 + strlen(def) + 1;
				msg_flags |= MSG_PROMPT_HIDE_DFLT;
			}
a424 1
		}
d428 1
a428 1
		x = (maxx - w) / 2 + 1;
a446 1
		/* Change message window to be our little box */
d455 1
a455 1
	_msg_vprompt(msg_string(msg_no), msg_flags, def, val, max_chars, ap);
a460 1
		/* Restore normal message window */
d472 1
a472 1
	_msg_vprompt(msg_string(msg_no), MSG_PROMPT_ECHO, def, val, max_chars, ap);
@


1.26.2.1.2.1
log
@Pull up revision 1.28 (requested by riz in ticket #5514):
Save and restore screen underneath prompt boxes
@
text
@d1 1
a1 1
/*	$NetBSD: msg_sys.def,v 1.26.2.1 2004/06/07 10:16:58 tron Exp $	*/
d480 1
a480 1
	WINDOW *win, *svmsg, *sv_win;
a518 4
		/* Save screen contents from under out window */
		sv_win = dupwin(win);
		if (sv_win)
			overwrite(curscr, sv_win);
d525 1
a525 1
		svmsg = msg_window(subwin(msg_win, h - 2, w - 2, y + 1, x + 1));
d538 1
a538 6
		if (sv_win) {
			/* Restore original screen contents */
			overwrite(sv_win, win);
			delwin(sv_win);
		}
		wnoutrefresh(win);
d540 1
a540 1
		delwin(msg_window(svmsg));
@


1.26.2.1.2.2
log
@Pull up revision 1.29 (requested by riz in ticket #5514):
NetBSD curses gives the wrong data when you read curscr, need to
add a doupdate() so we save from the correct screen image.
@
text
@d1 1
a1 1
/*	$NetBSD: msg_sys.def,v 1.26.2.1.2.1 2005/07/23 22:43:19 snj Exp $	*/
d519 1
a519 8
		/*
		 * Save screen contents from under our window
		 * Due to a mis-feature of NetBSD curses, curscr contains
		 * the data processed by doupdate() not that by wnoutrefresh().
		 * We must call doupdate() here to ensure we save the correct
		 * data.  See PR 26660
		 */
		doupdate();
@


1.26.2.1.2.3
log
@Pull up revision 1.30 (requested by riz in ticket #5514):
Remove _erase_ch() it isn't used any more
@
text
@d1 1
a1 1
/*	$NetBSD: msg_sys.def,v 1.26.2.1.2.2 2005/07/23 22:44:18 snj Exp $	*/
d314 12
@


1.26.2.1.2.4
log
@Pull up revision 1.31 (requested by riz in ticket #5514):
Add (unsigned char) cast to ctype functions
Fixes problems displaying German 'sharp-s', see PR install/27281
@
text
@d1 1
a1 1
/*	$NetBSD: msg_sys.def,v 1.26.2.1.2.3 2005/07/23 22:45:41 snj Exp $	*/
d190 1
a190 1
		if (isspace((unsigned char)*afterw))
d193 1
a193 1
			while (*afterw && !isspace((unsigned char)*afterw))
d238 1
a238 1
		last_i_was_space = isspace((unsigned char)*wstart);
d402 1
a402 1
			while (npos > 0 && isspace((unsigned char)ibuf[npos - 1]))
d404 1
a404 1
			while (npos > 0 && !isspace((unsigned char)ibuf[npos - 1]))
@


1.26.2.1.2.5
log
@Pull up revision 1.32 (requested by riz in ticket #5514):
If the user removed the default string (after we had put it into the buffer
area - rather than in []), then don't reinstate it on exit
@
text
@d1 1
a1 1
/*	$NetBSD: msg_sys.def,v 1.26.2.1.2.4 2005/07/23 22:46:58 snj Exp $	*/
d442 1
a442 1
	if (len != 0 || flags & MSG_PROMPT_HIDE_DFLT) {
@


1.25
log
@No need for wrefresh() in msg_clear(), screen will be updated later.
Stops obvious redraw of header of some menus.
@
text
@d1 1
a1 1
/*	$NetBSD: msg_sys.def,v 1.24 2003/07/25 07:48:02 dsl Exp $	*/
d498 6
@


1.24
log
@Change variable name to compiles with WARNS=3
@
text
@d1 1
a1 1
/*	$NetBSD: msg_sys.def,v 1.23 2003/07/14 09:34:01 itojun Exp $	*/
a144 1
	wrefresh(msg_win);
@


1.23
log
@use bounded string op
@
text
@d1 1
a1 1
/*	$NetBSD: msg_sys.def,v 1.22 2003/07/07 12:22:35 dsl Exp $	*/
d325 1
a325 1
_msg_vprompt(const char *msg, int do_echo, const char *def, char *val,
d332 1
a332 1
	_msg_vprintf(0, msg, ap);
@


1.22
log
@Change 'Magic number' of menu text files.
Correct calculation of window width in msg_prompt_win().
@
text
@d1 1
a1 1
/*	$NetBSD: msg_sys.def,v 1.21 2003/06/27 22:11:59 dsl Exp $	*/
d389 1
a389 1
		strcpy(val, ibuf);		/* size known to be OK */
@


1.21
log
@Add support for reading messages from a text file - msg_file() and msg_string().
Use subwin() in msg_prompt_win() now libcurses is fixed.
Some KNF changes I seem to have forgotten to commit on their own :-(
@
text
@d1 1
a1 1
/*	$NetBSD: msg_sys.def,v 1.20 2003/06/10 17:24:17 dsl Exp $	*/
d114 1
a114 1
	if (memcmp(msgmap, "INSTMSGS", 8)) {
d422 1
a422 1
			w += 2 + strlen(def);
@


1.20
log
@Change msg_window() to return old window (temp buffer size isn't too important)
Change msg_promt_win() to create the window.
Number MSG_xxx from 1 (because 0 is NULL)
@
text
@d1 1
a1 1
/*	$NetBSD: msg_sys.def,v 1.19 2003/06/04 19:00:26 dsl Exp $	*/
d47 7
a53 3
static int	_msg_vprintf(int auto_fill, const char *fmt, va_list ap);
static void	_msg_vprompt(const char *msg, int do_echo, const char *def,
		    char *val, size_t max_chars, va_list ap);
d60 1
d95 29
a123 1
const char *msg_string (msg msg_no)
d130 7
d140 2
a141 1
void msg_clear(void)
d143 3
a145 2
	wclear (msg_win);
	wrefresh (msg_win);
d150 2
a151 1
void msg_standout(void)
d153 1
d157 2
a158 1
void msg_standend(void)
d160 1
d171 1
a171 1
	ret = vsnprintf (cbuffer, cbuffersize, fmt, ap);
d286 1
a286 1
	wrefresh (msg_win);
d290 2
a291 1
void msg_display(msg msg_no, ...)
d302 2
a303 1
void msg_display_add(msg msg_no, ...)
d307 1
a307 1
	va_start (ap, msg_no);
d309 1
a309 1
	va_end (ap);
d334 3
a336 3
		waddstr (msg_win, " [");
		waddstr (msg_win, def);
		waddstr (msg_win, "]");
d338 2
a339 2
	waddstr (msg_win, ": ");
	wrefresh (msg_win);
d373 1
a373 1
				waddch (msg_win, ch);
d402 1
a402 1
	va_start (ap, max_chars);
d404 1
a404 1
	va_end (ap);
d415 2
a416 2
	maxx = getmaxx(stdscr);
	maxy = getmaxy(stdscr);
d437 1
a437 1
	win = newwin(h, w, y, x);
d448 1
a448 1
		svwin = msg_window(derwin(win, -1, -1, 1, 1));
d472 1
a472 1
	va_start (ap, max_chars);
d484 1
a484 1
	va_start (ap, max_chars);
d486 1
a486 1
	va_end (ap);
d489 2
a490 1
void msg_table_add(msg msg_no, ...)
d494 1
a494 1
	va_start (ap, msg_no);
d496 1
a496 1
	va_end (ap);
@


1.19
log
@Add msg_prompt_win() that will prompt in the specified window (instead of
the default one), and with a box around the window if >= 3 lines.
Stop the char delete from killingthe RHS of any box.
Make msg_string a noop for invalid strings (might be quoted text).
@
text
@d1 1
a1 1
/*	$NetBSD: msg_sys.def,v 1.18 2003/01/10 20:01:12 christos Exp $	*/
d59 2
a60 1
int msg_window(WINDOW *window)
d64 1
d66 3
d72 1
a72 1
	if (ncbuffersize > cbuffersize) {
d74 5
a78 2
		if (ncbuffer == NULL)
			return 1;
d83 1
d85 3
a87 1
	return 0;
d360 1
a360 1
msg_prompt_win(msg msg_no, WINDOW *win,
d364 2
a365 1
	WINDOW *sv_win;
d367 12
a378 1
	sv_win = msg_win;
d380 19
a398 1
	msg_window(win);
d400 3
a402 1
	msg_clear();
d404 1
a404 3
	if (getmaxy(win) >= 3) {
		box(win, 0, 0);
		wmove(win, 1, 1);
d407 1
a407 1
	va_start (ap, max_chars);
d409 1
a409 1
	va_end (ap);
d411 6
a416 2
	msg_clear();
	msg_window(sv_win);
@


1.18
log
@produce lint free code.
@
text
@d1 1
a1 1
/*	$NetBSD: msg_sys.def,v 1.17 1999/07/04 22:55:48 cgd Exp $	*/
d81 6
a86 1
	return msg_list[(size_t)(intptr_t)msg_no];
d253 11
a270 1
	int y,x;
d286 2
a287 6
				if (do_echo) {
					getyx(msg_win, y, x);
					x--;
					wmove(msg_win, y, x);
					wdelch(msg_win);
				}
d293 2
a294 6
				if (do_echo) {
					getyx(msg_win, y, x);
					x--;
					wmove(msg_win, y, x);
					wdelch(msg_win);
				}
d304 2
a305 6
				if (do_echo) {
					getyx(msg_win, y, x);
					x--;
					wmove(msg_win, y, x);
					wdelch(msg_win);
				}
d309 2
a310 6
				if (do_echo) {
					getyx(msg_win, y, x);
					x--;
					wmove(msg_win, y, x);
					wdelch(msg_win);
				}
d332 1
a332 2
		strncpy(val, def, max_chars);
		val[max_chars - 1] = '\0';
d346 26
@


1.17
log
@nuke msg_printf() and msg_printf_add().
@
text
@d1 1
a1 1
/*	$NetBSD: msg_sys.def,v 1.16 1999/07/04 21:30:14 cgd Exp $	*/
d49 1
a49 1
		    char *val, int max_chars, va_list ap);
d81 1
a81 1
	return msg_list[(long)msg_no];
d251 1
a251 1
    int max_chars, va_list ap)
d339 1
a339 1
msg_prompt(msg msg_no, const char *def, char *val, int max_chars, ...)
d351 1
a351 1
msg_prompt_add(msg msg_no, const char *def, char *val, int max_chars, ...)
d361 1
a361 1
msg_prompt_noecho(msg msg_no, const char *def, char *val, int max_chars, ...)
@


1.16
log
@const-ify strings as appropriate, and convert message 'numbers' from
ints to 'msg's.  'msg' is currently typedef'd as 'const char *', but it'll
become more complex eventually.
@
text
@d1 1
a1 1
/*	$NetBSD: msg_sys.def,v 1.15 1999/07/04 10:39:40 cgd Exp $	*/
a245 24
}

int msg_printf (const char *fmt, ...)
{
	va_list ap;
	int  res;

	msg_clear();

	va_start (ap, fmt);
	res = _msg_vprintf(1, fmt, ap);
	va_end (ap);
	return res;
}

int msg_printf_add (const char *fmt, ...)
{
	va_list ap;
	int  res;

	va_start (ap, fmt);
	res = _msg_vprintf(1, fmt, ap);
	va_end (ap);
	return res;
@


1.15
log
@oops, forgot an _
@
text
@d1 1
a1 1
/*	$NetBSD: msg_sys.def,v 1.14 1999/07/04 10:35:19 cgd Exp $	*/
d47 3
a49 3
static int	_msg_vprintf(int auto_fill, char *fmt, va_list ap);
static void	_msg_vprompt(char *msg, int do_echo, char *def, char *val,
		    int max_chars, va_list ap);
d79 1
a79 1
char *msg_string (int msg_no)
d81 1
a81 1
	return msg_list[msg_no];
d103 1
a103 1
_msg_vprintf(int auto_fill, char *fmt, va_list ap)
d228 1
a228 1
void msg_display(int msg_no, ...)
d235 1
a235 1
	(void)_msg_vprintf(1, msg_list[msg_no], ap);
d239 1
a239 1
void msg_display_add(int msg_no, ...)
d244 1
a244 1
	(void)_msg_vprintf(1, msg_list[msg_no], ap);
d248 1
a248 1
int msg_printf (char *fmt, ...)
d261 1
a261 1
int msg_printf_add (char *fmt, ...)
d274 2
a275 2
_msg_vprompt(char *msg, int do_echo, char *def, char *val, int max_chars,
    va_list ap)
d363 1
a363 1
msg_prompt(int msg_no, char *def, char *val, int max_chars, ...)
d370 1
a370 1
	_msg_vprompt(msg_list[msg_no], 1, def, val, max_chars, ap);
d375 1
a375 1
msg_prompt_add(int msg_no, char *def, char *val, int max_chars, ...)
d380 1
a380 1
	_msg_vprompt(msg_list[msg_no], 1, def, val, max_chars, ap);
d385 1
a385 1
msg_prompt_noecho(int msg_no, char *def, char *val, int max_chars, ...)
d392 1
a392 1
	_msg_vprompt(msg_list[msg_no], 0, def, val, max_chars, ap);
d396 1
a396 1
void msg_table_add(int msg_no, ...)
d401 1
a401 1
	(void)_msg_vprintf(0, msg_list[msg_no], ap);
@


1.14
log
@privatize msg_beep
@
text
@d1 1
a1 1
/*	$NetBSD: msg_sys.def,v 1.13 1999/07/04 10:29:30 cgd Exp $	*/
d54 1
a54 1
msg_beep(void)
@


1.13
log
@nuke msg_{,no}echo, add msg_prompt_noecho
@
text
@d1 1
a1 1
/*	$NetBSD: msg_sys.def,v 1.12 1999/07/04 10:13:12 cgd Exp $	*/
d46 1
d53 2
a54 1
void msg_beep (void)
d56 1
a56 1
	fprintf (stderr, "\a");
d302 1
a302 1
				msg_beep ();
d342 1
a342 1
			msg_beep ();
@


1.12
log
@nuke msg_prompt_str, msg_prompt_addstr, and msg_table (unused), and make
msg_vprintf private.
@
text
@d1 1
a1 1
/*	$NetBSD: msg_sys.def,v 1.11 1999/07/04 09:37:18 cgd Exp $	*/
a41 1
static int do_echo = 1;
d47 2
a48 2
static void	_msg_vprompt(char *msg, char *def, char *val, int max_chars,
		    va_list ap);
d272 2
a273 1
_msg_vprompt(char *msg, char *def, char *val, int max_chars, va_list ap)
d360 2
a361 1
void msg_prompt_add (int msg_no, char *def, char *val, int max_chars, ...)
d365 2
d368 11
a378 1
	_msg_vprompt(msg_list[msg_no], def, val, max_chars, ap);
d382 2
a383 1
void msg_prompt (int msg_no, char *def, char *val, int max_chars, ...)
d390 1
a390 1
	_msg_vprompt(msg_list[msg_no], def, val, max_chars, ap);
a391 10
}

void msg_noecho()
{
	do_echo = 0;
}

void msg_echo()
{
	do_echo = 1;
@


1.11
log
@turn on automatic text layout for the printf and display fns
@
text
@d1 1
a1 1
/*	$NetBSD: msg_sys.def,v 1.10 1999/07/04 07:40:51 cgd Exp $	*/
d47 4
d101 2
a102 1
int msg_vprintf (int auto_fill, char *fmt, va_list ap)
d234 1
a234 1
	(void)msg_vprintf(1, msg_list[msg_no], ap);
d243 1
a243 1
	(void)msg_vprintf(1, msg_list[msg_no], ap);
d255 1
a255 1
	res = msg_vprintf (1, fmt, ap);
d266 1
a266 1
	res = msg_vprintf (1, fmt, ap);
d272 2
a273 2
static void msg_vprompt (char *msg, char *def, char *val, int max_chars,
			 va_list ap)
d280 1
a280 1
	msg_vprintf (0, msg, ap);
a359 9
void msg_prompt_addstr (char *fmt, char *def, char *val, int max_chars, ...)
{
	va_list ap;

	va_start (ap, max_chars);
	msg_vprompt (fmt, def, val, max_chars, ap);
	va_end(ap);
}

d365 1
a365 1
	msg_vprompt (msg_list[msg_no], def, val, max_chars, ap);
a368 11
void msg_prompt_str (char *msg, char *def, char *val, int max_chars, ...)
{
	va_list ap;

	msg_clear();

	va_start (ap, max_chars);
	msg_vprompt (msg, def, val, max_chars, ap);
	va_end (ap);
}

d376 1
a376 1
	msg_vprompt (msg_list[msg_no], def, val, max_chars, ap);
a389 11
void msg_table(int msg_no, ...)
{
	va_list ap;

	msg_clear();

	va_start(ap, msg_no);
	(void)msg_vprintf(0, msg_list[msg_no], ap);
	va_end(ap);
}

d395 1
a395 1
	(void)msg_vprintf(0, msg_list[msg_no], ap);
@


1.10
log
@provide APIs (currently mostly undocumented) to print pre-formatted
(table) text.
@
text
@d1 1
a1 1
/*	$NetBSD: msg_sys.def,v 1.9 1999/06/23 17:42:11 cgd Exp $	*/
d229 1
a229 1
	(void)msg_vprintf(0/*XXX*/, msg_list[msg_no], ap);
d238 1
a238 1
	(void)msg_vprintf(0/*XXX*/, msg_list[msg_no], ap);
d250 1
a250 1
	res = msg_vprintf (0/*XXX*/, fmt, ap);
d261 1
a261 1
	res = msg_vprintf (0/*XXX*/, fmt, ap);
@


1.9
log
@implement word kill with control-W
@
text
@d1 1
a1 1
/*	$NetBSD: msg_sys.def,v 1.8 1999/06/23 17:32:32 cgd Exp $	*/
a43 1
#if defined(DYNAMIC_MESSAGE_LAYOUT)
a45 2
#endif /* defined(DYNAMIC_MESSAGE_LAYOUT) */

a82 1
#if defined(DYNAMIC_MESSAGE_LAYOUT)
a84 1
#endif /* defined(DYNAMIC_MESSAGE_LAYOUT) */
d97 1
a97 1
int msg_vprintf (char *fmt, va_list ap)
a98 1
#if defined(DYNAMIC_MESSAGE_LAYOUT)
a100 1
#endif /* defined(DYNAMIC_MESSAGE_LAYOUT) */
d105 13
a117 1
#if defined(DYNAMIC_MESSAGE_LAYOUT)
a126 1
		/* last was an nl, this is an nl: paragraph break */
a215 3
#else /* defined(DYNAMIC_MESSAGE_LAYOUT) */
	waddstr (msg_win, cbuffer);
#endif /* defined(DYNAMIC_MESSAGE_LAYOUT) */
d217 1
d229 1
a229 1
	(void)msg_vprintf (msg_list[msg_no], ap);
d238 1
a238 1
	(void)msg_vprintf (msg_list[msg_no], ap);
d250 1
a250 1
	res = msg_vprintf (fmt, ap);
d261 1
a261 1
	res = msg_vprintf (fmt, ap);
d275 1
a275 1
	msg_vprintf (msg, ap);
a340 1
#if defined(DYNAMIC_MESSAGE_LAYOUT)
a342 1
#endif /* defined(DYNAMIC_MESSAGE_LAYOUT) */
d404 21
@


1.8
log
@add code to do dynamic message text layout, currently completely disabled.
@
text
@d1 1
a1 1
/*	$NetBSD: msg_sys.def,v 1.7 1999/06/23 09:19:33 cgd Exp $	*/
d296 24
@


1.7
log
@replace lots of wclear()/wmove() calls with calls to msg_clear().  wmove()
to 0,0 was unnecessary because wclear() is documented to do that.  also,
the immediate wrefresh() done by msg_clear() means that if we can take
advantage of full screen clear sequence, we will.
@
text
@d1 1
a1 1
/*	$NetBSD: msg_sys.def,v 1.6 1999/06/22 15:00:37 cgd Exp $	*/
d44 5
d86 4
d104 4
d111 102
d214 2
d313 1
a313 1
	if (do_echo)
d315 5
@


1.6
log
@don't bother calculated up MAXSTR, especially since the value calculated
is _bogus_ in the face of printf-like message formatting!  Instead,
calcuate the max size to format when the message window is set.  We know
that we'll never want to format more characters than can fit in the window.
@
text
@d1 1
a1 1
/*	$NetBSD: msg_sys.def,v 1.5 1999/06/19 00:40:29 cgd Exp $	*/
d44 1
d107 2
a109 2
	wclear (msg_win);
	wmove (msg_win, 0, 0);
d128 2
a130 2
	wclear (msg_win);
	wmove (msg_win, 0, 0);
d231 2
a233 2
	wclear (msg_win);
	wmove (msg_win, 0, 0);
d242 2
a244 2
	wclear (msg_win);
	wmove (msg_win, 0, 0);
@


1.5
log
@don't dereference NULL when thinking about copying the default
@
text
@d1 1
a1 1
/*	$NetBSD: msg_sys.def,v 1.4 1999/06/19 00:13:19 cgd Exp $	*/
d40 2
a41 1
static char cbuffer [ MAXSTR ];
d51 1
a51 1
void msg_window(WINDOW *window)
d53 3
d57 12
d96 1
a96 1
	ret = vsnprintf (cbuffer, MAXSTR, fmt, ap);
@


1.4
log
@teach the message prompting code to use control-U as line kill character.
(not really the right thing, but it already hard-codes backspace and
delete rather than using the terminal settings...)
@
text
@d1 1
a1 1
/*	$NetBSD: msg_sys.def,v 1.3 1999/06/19 00:00:48 cgd Exp $	*/
d186 1
a186 1
	} else if (val != def) {
@


1.3
log
@fix an off-by-one error (it would put up to max_chars plus NUL into the string,
which is one too many).  Also, msgc manual page says that 'def' and 'val'
can be the same string, but the way input was done (characters typed
went directly into val) meant that the contents of 'def' would be corrupted.
If the user backspaced to the beginning of the line and hit return (to accept
the default), they'd get a combination of the old default string and the
new characters they typed.  alloca() a buffer an put new input there to
avoid this problem.
@
text
@d1 1
a1 1
/*	$NetBSD: msg_sys.def,v 1.2 1999/04/25 09:10:07 veego Exp $	*/
d160 11
a170 2
		}
		else if (count < (max_chars - 1) && isprint(ch)) {
@


1.2
log
@It was a bad idea to call a function 'beep'.
Rename it to msg_beep to avoid conflicts with the new curses.h.
@
text
@d1 1
a1 1
/*	$NetBSD: msg_sys.def,v 1.1.1.1 1997/09/26 21:16:38 phil Exp $	*/
d137 1
d161 1
a161 1
		else if (count < max_chars && isprint(ch)) {
d164 1
a164 1
			val[count++] = ch;
d173 8
a180 7
	if (count != 0)
		val[count] = '\0';

	/* Do a string copy if needed to get default */
	if (count == 0 && def != NULL && val != def)
		strncpy (val, def, max_chars);

@


1.1
log
@Initial revision
@
text
@d1 1
a1 1
/*	$NetBSD: $	*/
d45 1
a45 1
void beep (void)
d158 1
a158 1
				beep ();
d165 1
a165 1
			beep ();
@


1.1.1.1
log
@Import a simple message system with 'compiled' messages.  Used by
the net system install program.
@
text
@@


1.1.1.1.4.1
log
@pull up rev(s) 1.2-1.9 from trunk. (cgd)
@
text
@d1 1
a1 1
/*	$NetBSD$	*/
d40 1
a40 2
static char *cbuffer;
static size_t cbuffersize;
a42 6
#if defined(DYNAMIC_MESSAGE_LAYOUT)
static int last_i_was_nl, last_i_was_space;
static int last_o_was_punct, last_o_was_space;
#endif /* defined(DYNAMIC_MESSAGE_LAYOUT) */


d45 1
a45 1
void msg_beep (void)
d50 1
a50 1
int msg_window(WINDOW *window)
a51 3
	size_t ncbuffersize;
	char *ncbuffer;

a52 12

	ncbuffersize = getmaxx(window) * getmaxy(window) + 1;
	if (ncbuffersize > cbuffersize) {
		ncbuffer = malloc(ncbuffersize);
		if (ncbuffer == NULL)
			return 1;
		if (cbuffer != NULL)
			free(cbuffer);
		cbuffer = ncbuffer;
		cbuffersize = ncbuffersize;
	}
	return 0;
a63 4
#if defined(DYNAMIC_MESSAGE_LAYOUT)
	last_o_was_punct = 0;
	last_o_was_space = 1;
#endif /* defined(DYNAMIC_MESSAGE_LAYOUT) */
a77 4
#if defined(DYNAMIC_MESSAGE_LAYOUT)
	const char *wstart, *afterw;
	int wordlen, nspaces;
#endif /* defined(DYNAMIC_MESSAGE_LAYOUT) */
d80 1
a80 103
	ret = vsnprintf (cbuffer, cbuffersize, fmt, ap);

#if defined(DYNAMIC_MESSAGE_LAYOUT)
	for (wstart = afterw = cbuffer; *wstart; wstart = afterw) {

		/* eat one space, or a whole word of non-spaces */
		if (isspace(*afterw))
			afterw++;
		else
			while (*afterw && !isspace(*afterw))
				afterw++;

		/* last was an nl, this is an nl: paragraph break */
		/* this is an nl: special formatting necessary */
		if (*wstart == '\n') {
			if (last_i_was_nl || last_i_was_space) {

				if (getcurx(msg_win) != 0)
					waddch(msg_win, '\n');
				if (last_i_was_nl) {
					/* last was an nl: paragraph break */
					waddch(msg_win, '\n');
				} else {
					/* last was space: line break */
				}
				last_o_was_punct = 0;
				last_o_was_space = 1;
			} else {
				/* last_o_was_punct unchanged */
				/* last_o_was_space unchanged */
			}
			last_i_was_space = 1;
			last_i_was_nl = 1;
			continue;
		}

		/* this is a tab: special formatting necessary. */
		if (*wstart == '\t') {
			if (last_i_was_nl) {
				/* last was an nl: list indent */
				if (getcurx(msg_win) != 0)
					waddch(msg_win, '\n');
			} else {
				/* last was not an nl: columns */
			}
			waddch(msg_win, '\t');
			last_i_was_nl = 0;
			last_i_was_space = 1;
			last_o_was_punct = 0;
			last_o_was_space = 1;
			continue;
		}

		/* this is a space: ignore it but set flags */
		last_i_was_nl = 0;	/* all newlines handled above */
		last_i_was_space = isspace(*wstart);
		if (last_i_was_space)
			continue;

		/*
		 * we have a real "word," i.e. a sequence of non-space
		 * characters.  wstart is now the start of the word,
		 * afterw is the next character after the end.
		 */
		wordlen = afterw - wstart;
		nspaces = last_o_was_space ? 0 : (last_o_was_punct ? 2 : 1);
		if ((getcurx(msg_win) + nspaces + wordlen) >=
		      getmaxx(msg_win) &&
		    wordlen < (getmaxx(msg_win) / 3)) {
			/* wrap the line */
			waddch(msg_win, '\n');
			nspaces = 0;
		}

		/* output the word, preceded by spaces if necessary */
		while (nspaces-- > 0)
			waddch(msg_win, ' ');
		waddbytes(msg_win, wstart, wordlen);

		/* set up the 'last' state for the next time around */
		switch (afterw[-1]) {
		case '.':
		case '?':
		case '!':
			last_o_was_punct = 1;
			break;
		default:
			last_o_was_punct = 0;
			break;
		}
		last_o_was_space = 0;

		/* ... and do it all again! */
	}

	/* String ended with a newline.  They really want a line break. */
	if (last_i_was_nl) {
		if (getcurx(msg_win) != 0)
			waddch(msg_win, '\n');
		last_o_was_punct = 0;
		last_o_was_space = 1;
	}
#else /* defined(DYNAMIC_MESSAGE_LAYOUT) */
a81 2
#endif /* defined(DYNAMIC_MESSAGE_LAYOUT) */

a89 2
	msg_clear();

d91 2
a110 2
	msg_clear();

d112 2
a136 1
	char *ibuf = alloca(max_chars);
d158 3
a160 36
				msg_beep ();
		} else if (ch == 0x15) {	/* ^U; line kill */
			while (count > 0) {
				count--;
				if (do_echo) {
					getyx(msg_win, y, x);
					x--;
					wmove(msg_win, y, x);
					wdelch(msg_win);
				}
			}
		} else if (ch == 0x17) {        /* ^W; word kill */
			/*
			 * word kill kills the spaces and the 'word'
			 * (non-spaces) last typed.  the spaces before
			 * the 'word' aren't killed.
			 */
			while (count > 0 && isspace(ibuf[count - 1])) {
				count--;
				if (do_echo) {
					getyx(msg_win, y, x);
					x--;
					wmove(msg_win, y, x);
					wdelch(msg_win);
				}
			}
			while (count > 0 && !isspace(ibuf[count - 1])) {
				count--;
				if (do_echo) {
					getyx(msg_win, y, x);
					x--;
					wmove(msg_win, y, x);
					wdelch(msg_win);
				}
			}
		} else if (count < (max_chars - 1) && isprint(ch)) {
d163 1
a163 1
			ibuf[count++] = ch;
d165 1
a165 1
			msg_beep ();
d169 1
a169 1
	if (do_echo) {
a170 5
#if defined(DYNAMIC_MESSAGE_LAYOUT)
		last_o_was_punct = 0;
		last_o_was_space = 1;
#endif /* defined(DYNAMIC_MESSAGE_LAYOUT) */
	}
d172 7
a178 8
	/* copy the appropriate string to the output */
	if (count != 0) {
		ibuf[count] = '\0';
		strcpy(val, ibuf);		/* size known to be OK */
	} else if (def != NULL && val != def) {
		strncpy(val, def, max_chars);
		val[max_chars - 1] = '\0';
	}
a202 2
	msg_clear();

d204 2
a213 2
	msg_clear();

d215 2
@

