head 1.66; access; symbols netbsd-10-0-RC6:1.65 netbsd-10-0-RC5:1.65 netbsd-10-0-RC4:1.65 netbsd-10-0-RC3:1.65 netbsd-10-0-RC2:1.65 netbsd-10-0-RC1:1.65 netbsd-10:1.65.0.2 netbsd-10-base:1.65 netbsd-9-3-RELEASE:1.55.2.1 cjep_sun2x-base1:1.55 cjep_sun2x:1.55.0.8 cjep_sun2x-base:1.55 cjep_staticlib_x-base1:1.55 netbsd-9-2-RELEASE:1.55 cjep_staticlib_x:1.55.0.6 cjep_staticlib_x-base:1.55 netbsd-9-1-RELEASE:1.55 phil-wifi-20200421:1.55 phil-wifi-20200411:1.55 is-mlppp:1.55.0.4 is-mlppp-base:1.55 phil-wifi-20200406:1.55 netbsd-8-2-RELEASE:1.48.8.2 netbsd-9-0-RELEASE:1.55 netbsd-9-0-RC2:1.55 netbsd-9-0-RC1:1.55 phil-wifi-20191119:1.55 netbsd-9:1.55.0.2 netbsd-9-base:1.55 phil-wifi-20190609:1.55 netbsd-8-1-RELEASE:1.48.8.2 netbsd-8-1-RC1:1.48.8.2 pgoyette-compat-merge-20190127:1.52.4.1 pgoyette-compat-20190127:1.53 pgoyette-compat-20190118:1.53 pgoyette-compat-1226:1.53 pgoyette-compat-1126:1.53 pgoyette-compat-1020:1.53 pgoyette-compat-0930:1.53 pgoyette-compat-0906:1.53 netbsd-7-2-RELEASE:1.47 pgoyette-compat-0728:1.53 netbsd-8-0-RELEASE:1.48.8.1 phil-wifi:1.52.0.6 phil-wifi-base:1.52 pgoyette-compat-0625:1.52 netbsd-8-0-RC2:1.48.8.1 pgoyette-compat-0521:1.52 pgoyette-compat-0502:1.52 pgoyette-compat-0422:1.52 netbsd-8-0-RC1:1.48.8.1 pgoyette-compat-0415:1.52 pgoyette-compat-0407:1.52 pgoyette-compat-0330:1.52 pgoyette-compat-0322:1.52 pgoyette-compat-0315:1.52 netbsd-7-1-2-RELEASE:1.47 pgoyette-compat:1.52.0.4 pgoyette-compat-base:1.52 netbsd-7-1-1-RELEASE:1.47 matt-nb8-mediatek:1.48.8.1.0.2 matt-nb8-mediatek-base:1.48.8.1 perseant-stdc-iso10646:1.52.0.2 perseant-stdc-iso10646-base:1.52 netbsd-8:1.48.0.8 netbsd-8-base:1.48 prg-localcount2-base3:1.48 prg-localcount2-base2:1.48 prg-localcount2-base1:1.48 prg-localcount2:1.48.0.6 prg-localcount2-base:1.48 pgoyette-localcount-20170426:1.48 bouyer-socketcan-base1:1.48 pgoyette-localcount-20170320:1.48 netbsd-7-1:1.47.0.8 netbsd-7-1-RELEASE:1.47 netbsd-7-1-RC2:1.47 netbsd-7-nhusb-base-20170116:1.47 bouyer-socketcan:1.48.0.4 bouyer-socketcan-base:1.48 pgoyette-localcount-20170107:1.48 netbsd-7-1-RC1:1.47 pgoyette-localcount-20161104:1.48 netbsd-7-0-2-RELEASE:1.47 localcount-20160914:1.48 netbsd-7-nhusb:1.47.0.6 netbsd-7-nhusb-base:1.47 pgoyette-localcount-20160806:1.48 pgoyette-localcount-20160726:1.48 pgoyette-localcount:1.48.0.2 pgoyette-localcount-base:1.48 netbsd-7-0-1-RELEASE:1.47 netbsd-7-0:1.47.0.4 netbsd-7-0-RELEASE:1.47 netbsd-7-0-RC3:1.47 netbsd-7-0-RC2:1.47 netbsd-7-0-RC1:1.47 netbsd-5-2-3-RELEASE:1.41 netbsd-5-1-5-RELEASE:1.41 netbsd-6-0-6-RELEASE:1.44 netbsd-6-1-5-RELEASE:1.44 netbsd-7:1.47.0.2 netbsd-7-base:1.47 yamt-pagecache-base9:1.46 yamt-pagecache-tag8:1.44.2.1 netbsd-6-1-4-RELEASE:1.44 netbsd-6-0-5-RELEASE:1.44 tls-earlyentropy:1.46.0.2 tls-earlyentropy-base:1.47 riastradh-xf86-video-intel-2-7-1-pre-2-21-15:1.46 riastradh-drm2-base3:1.45 netbsd-6-1-3-RELEASE:1.44 netbsd-6-0-4-RELEASE:1.44 netbsd-5-2-2-RELEASE:1.41 netbsd-5-1-4-RELEASE:1.41 netbsd-6-1-2-RELEASE:1.44 netbsd-6-0-3-RELEASE:1.44 netbsd-5-2-1-RELEASE:1.41 netbsd-5-1-3-RELEASE:1.41 netbsd-6-1-1-RELEASE:1.44 riastradh-drm2-base2:1.45 riastradh-drm2-base1:1.45 riastradh-drm2:1.45.0.4 riastradh-drm2-base:1.45 netbsd-6-1:1.44.0.10 netbsd-6-0-2-RELEASE:1.44 netbsd-6-1-RELEASE:1.44 khorben-n900:1.45.0.8 netbsd-6-1-RC4:1.44 netbsd-6-1-RC3:1.44 agc-symver:1.45.0.6 agc-symver-base:1.45 netbsd-6-1-RC2:1.44 netbsd-6-1-RC1:1.44 yamt-pagecache-base8:1.45 netbsd-5-2:1.41.0.22 netbsd-6-0-1-RELEASE:1.44 yamt-pagecache-base7:1.45 netbsd-5-2-RELEASE:1.41 netbsd-5-2-RC1:1.41 matt-nb6-plus-nbase:1.44 yamt-pagecache-base6:1.45 netbsd-6-0:1.44.0.8 netbsd-6-0-RELEASE:1.44 netbsd-6-0-RC2:1.44 tls-maxphys:1.45.0.2 tls-maxphys-base:1.47 matt-nb6-plus:1.44.0.6 matt-nb6-plus-base:1.44 netbsd-6-0-RC1:1.44 yamt-pagecache-base5:1.45 yamt-pagecache-base4:1.45 netbsd-6:1.44.0.4 netbsd-6-base:1.44 netbsd-5-1-2-RELEASE:1.41 netbsd-5-1-1-RELEASE:1.41 yamt-pagecache-base3:1.44 yamt-pagecache-base2:1.44 yamt-pagecache:1.44.0.2 yamt-pagecache-base:1.44 cherry-xenmp:1.42.0.4 cherry-xenmp-base:1.42 bouyer-quota2-nbase:1.42 bouyer-quota2:1.42.0.2 bouyer-quota2-base:1.42 matt-mips64-premerge-20101231:1.41 matt-nb5-mips64-premerge-20101231:1.41 matt-nb5-pq3:1.41.0.20 matt-nb5-pq3-base:1.41 netbsd-5-1:1.41.0.18 netbsd-5-1-RELEASE:1.41 netbsd-5-1-RC4:1.41 matt-nb5-mips64-k15:1.41 netbsd-5-1-RC3:1.41 netbsd-5-1-RC2:1.41 netbsd-5-1-RC1:1.41 netbsd-5-0-2-RELEASE:1.41 matt-nb5-mips64-premerge-20091211:1.41 matt-premerge-20091211:1.41 matt-nb5-mips64-u2-k2-k4-k7-k8-k9:1.41 matt-nb4-mips64-k7-u2a-k9b:1.41 matt-nb5-mips64-u1-k1-k5:1.41 matt-nb5-mips64:1.41.0.16 netbsd-5-0-1-RELEASE:1.41 jym-xensuspend-nbase:1.41 netbsd-5-0:1.41.0.14 netbsd-5-0-RELEASE:1.41 netbsd-5-0-RC4:1.41 netbsd-5-0-RC3:1.41 netbsd-5-0-RC2:1.41 jym-xensuspend:1.41.0.12 jym-xensuspend-base:1.41 netbsd-5-0-RC1:1.41 netbsd-5:1.41.0.10 netbsd-5-base:1.41 matt-mips64-base2:1.41 matt-mips64:1.40.0.14 mjf-devfs2:1.41.0.8 mjf-devfs2-base:1.41 netbsd-4-0-1-RELEASE:1.40 wrstuden-revivesa-base-3:1.41 wrstuden-revivesa-base-2:1.41 wrstuden-fixsa-newbase:1.40 wrstuden-revivesa-base-1:1.41 yamt-pf42-base4:1.41 yamt-pf42-base3:1.41 hpcarm-cleanup-nbase:1.41 yamt-pf42-baseX:1.41 yamt-pf42-base2:1.41 wrstuden-revivesa:1.41.0.6 wrstuden-revivesa-base:1.41 yamt-pf42:1.41.0.4 yamt-pf42-base:1.41 keiichi-mipv6:1.41.0.2 keiichi-mipv6-base:1.41 matt-armv6-nbase:1.41 matt-armv6-prevmlocking:1.40 wrstuden-fixsa-base-1:1.40 netbsd-4-0:1.40.0.12 netbsd-4-0-RELEASE:1.40 cube-autoconf:1.40.0.10 cube-autoconf-base:1.40 netbsd-4-0-RC5:1.40 netbsd-4-0-RC4:1.40 netbsd-4-0-RC3:1.40 netbsd-4-0-RC2:1.40 netbsd-4-0-RC1:1.40 matt-armv6:1.40.0.8 matt-armv6-base:1.40 matt-mips64-base:1.40 hpcarm-cleanup:1.40.0.6 hpcarm-cleanup-base:1.41 netbsd-3-1-1-RELEASE:1.34 netbsd-3-0-3-RELEASE:1.34 wrstuden-fixsa:1.40.0.4 wrstuden-fixsa-base:1.40 abandoned-netbsd-4-base:1.39 abandoned-netbsd-4:1.39.0.2 netbsd-3-1:1.34.0.12 netbsd-3-1-RELEASE:1.34 netbsd-3-0-2-RELEASE:1.34 netbsd-3-1-RC4:1.34 netbsd-3-1-RC3:1.34 netbsd-3-1-RC2:1.34 netbsd-3-1-RC1:1.34 netbsd-4:1.40.0.2 netbsd-4-base:1.40 netbsd-3-0-1-RELEASE:1.34 netbsd-3-0:1.34.0.10 netbsd-3-0-RELEASE:1.34 netbsd-3-0-RC6:1.34 netbsd-3-0-RC5:1.34 netbsd-3-0-RC4:1.34 netbsd-3-0-RC3:1.34 netbsd-3-0-RC2:1.34 netbsd-3-0-RC1:1.34 netbsd-2-0-3-RELEASE:1.34 netbsd-2-1:1.34.0.8 netbsd-2-1-RELEASE:1.34 netbsd-2-1-RC6:1.34 netbsd-2-1-RC5:1.34 netbsd-2-1-RC4:1.34 netbsd-2-1-RC3:1.34 netbsd-2-1-RC2:1.34 netbsd-2-1-RC1:1.34 netbsd-2-0-2-RELEASE:1.34 netbsd-3:1.34.0.6 netbsd-3-base:1.34 netbsd-2-0-1-RELEASE:1.34 netbsd-2:1.34.0.4 netbsd-2-base:1.34 netbsd-2-0-RELEASE:1.34 netbsd-2-0-RC5:1.34 netbsd-2-0-RC4:1.34 netbsd-2-0-RC3:1.34 netbsd-2-0-RC2:1.34 netbsd-2-0-RC1:1.34 netbsd-2-0:1.34.0.2 netbsd-2-0-base:1.34 netbsd-1-6-PATCH002-RELEASE:1.26 netbsd-1-6-PATCH002:1.26 netbsd-1-6-PATCH002-RC4:1.26 netbsd-1-6-PATCH002-RC3:1.26 netbsd-1-6-PATCH002-RC2:1.26 netbsd-1-6-PATCH002-RC1:1.26 netbsd-1-6-PATCH001:1.26 netbsd-1-6-PATCH001-RELEASE:1.26 netbsd-1-6-PATCH001-RC3:1.26 netbsd-1-6-PATCH001-RC2:1.26 netbsd-1-6-PATCH001-RC1:1.26 fvdl_fs64_base:1.27 netbsd-1-6-RELEASE:1.26 netbsd-1-6-RC3:1.26 netbsd-1-6-RC2:1.26 netbsd-1-6-RC1:1.26 netbsd-1-6:1.26.0.4 netbsd-1-6-base:1.26 netbsd-1-5-PATCH003:1.23 ELRICshvfork:1.26.0.2 ELRICshvfork-base:1.26 netbsd-1-5-PATCH002:1.23 netbsd-1-5-PATCH001:1.23 netbsd-1-5-RELEASE:1.23 netbsd-1-5-BETA2:1.23 netbsd-1-5-BETA:1.23 netbsd-1-4-PATCH003:1.20 netbsd-1-5-ALPHA2:1.23 netbsd-1-5:1.23.0.4 netbsd-1-5-base:1.23 minoura-xpg4dl:1.23.0.2 minoura-xpg4dl-base:1.23 netbsd-1-4-PATCH002:1.20 wrstuden-devbsize-19991221:1.21 wrstuden-devbsize:1.21.0.4 wrstuden-devbsize-base:1.21 comdex-fall-1999:1.21.0.2 comdex-fall-1999-base:1.21 netbsd-1-4-PATCH001:1.20 netbsd-1-4-RELEASE:1.20 netbsd-1-4:1.20.0.2 netbsd-1-4-base:1.20 netbsd-1-3-PATCH003:1.16.2.2 netbsd-1-3-PATCH003-CANDIDATE2:1.16.2.2 netbsd-1-3-PATCH003-CANDIDATE1:1.16.2.2 netbsd-1-3-PATCH003-CANDIDATE0:1.16.2.2 netbsd-1-3-PATCH002:1.16.2.2 netbsd-1-3-PATCH001:1.16.2.1 netbsd-1-3-RELEASE:1.16.2.1 netbsd-1-3-BETA:1.16.2.1 netbsd-1-3:1.16.0.2 netbsd-1-3-base:1.16 netbsd-1-2-PATCH001:1.8.6.1 netbsd-1-2-RELEASE:1.8 netbsd-1-2-BETA:1.8 netbsd-1-2-base:1.8 netbsd-1-2:1.8.0.6 netbsd-1-1-PATCH001:1.8 netbsd-1-1-RELEASE:1.8 netbsd-1-1:1.8.0.2 netbsd-1-1-base:1.8 netbsd-1-0-PATCH06:1.3 netbsd-1-0-PATCH05:1.3 netbsd-1-0-PATCH04:1.3 netbsd-1-0-PATCH03:1.3 netbsd-1-0-PATCH02:1.3 netbsd-1-0-PATCH1:1.3 netbsd-1-0-PATCH0:1.3 netbsd-1-0-RELEASE:1.3 netbsd-1-0:1.3.0.2 netbsd-1-0-base:1.3 lite-1:1.1.1.1 CSRG:1.1.1; locks; strict; comment @ * @; 1.66 date 2023.04.07.10.34.13; author kre; state Exp; branches; next 1.65; commitid 8FpW2wyuWp9nbakE; 1.65 date 2022.08.22.17.33.11; author kre; state Exp; branches; next 1.64; commitid DGZNvbSOd2zXMTQD; 1.64 date 2022.08.21.21.35.36; author nia; state Exp; branches; next 1.63; commitid Br3PXw9VvoALcNQD; 1.63 date 2022.08.18.14.10.05; author nia; state Exp; branches; next 1.62; commitid dbMBTOqzvOe1QmQD; 1.62 date 2022.08.17.22.27.17; author nia; state Exp; branches; next 1.61; commitid CbbbHbYxXooqChQD; 1.61 date 2022.02.08.20.39.59; author rillig; state Exp; branches; next 1.60; commitid Db0djI6umuXt8RrD; 1.60 date 2022.02.02.01.21.34; author kre; state Exp; branches; next 1.59; commitid ozkPh2GqCgF3VYqD; 1.59 date 2022.01.31.18.15.45; author kre; state Exp; branches; next 1.58; commitid CYslr8tTRrl9AOqD; 1.58 date 2022.01.31.16.54.28; author kre; state Exp; branches; next 1.57; commitid T2Hc0K0zxJmn6OqD; 1.57 date 2021.09.14.15.04.09; author christos; state Exp; branches; next 1.56; commitid KNlwG51GnTuc0W8D; 1.56 date 2021.08.15.10.17.55; author christos; state Exp; branches; next 1.55; commitid qyiZbbh4fUQGn35D; 1.55 date 2019.02.10.19.21.52; author kre; state Exp; branches 1.55.2.1; next 1.54; commitid pr2ZwtBtlh4HRfbB; 1.54 date 2019.02.09.03.35.55; author kre; state Exp; branches; next 1.53; commitid beAXZdtNE2VCE2bB; 1.53 date 2018.07.13.22.43.44; author kre; state Exp; branches; next 1.52; commitid TdYFDlxEZ4rFN1KA; 1.52 date 2017.06.28.13.46.06; author kre; state Exp; branches 1.52.4.1 1.52.6.1; next 1.51; commitid JgXsbLAWc8A529Xz; 1.51 date 2017.06.27.23.27.03; author christos; state Exp; branches; next 1.50; commitid Lu592LAKcAoDh4Xz; 1.50 date 2017.06.27.02.22.08; author kre; state Exp; branches; next 1.49; commitid a0CAYBSyIt8phXWz; 1.49 date 2017.06.26.20.28.01; author christos; state Exp; branches; next 1.48; commitid 0p5I13xEFktjkVWz; 1.48 date 2016.03.16.22.36.40; author christos; state Exp; branches 1.48.8.1; next 1.47; commitid l20MBDEXLbUa3VYy; 1.47 date 2014.06.18.18.17.30; author christos; state Exp; branches; next 1.46; commitid jsgkMkv8gyJK52Fx; 1.46 date 2014.03.23.05.07.59; author dholland; state Exp; branches 1.46.2.1; next 1.45; commitid oiaGYVVO8kfjwMtx; 1.45 date 2012.03.20.18.42.29; author matt; state Exp; branches 1.45.2.1; next 1.44; 1.44 date 2011.07.12.16.40.41; author joerg; state Exp; branches 1.44.2.1; next 1.43; 1.43 date 2011.06.18.21.18.46; author christos; state Exp; branches; next 1.42; 1.42 date 2011.01.07.22.21.56; author jmmv; state Exp; branches 1.42.4.1; next 1.41; 1.41 date 2008.02.13.12.57.16; author joerg; state Exp; branches; next 1.40; 1.40 date 2006.10.16.00.36.19; author christos; state Exp; branches 1.40.8.1; next 1.39; 1.39 date 2006.05.10.21.53.14; author mrg; state Exp; branches; next 1.38; 1.38 date 2006.03.06.00.09.22; author aymeric; state Exp; branches; next 1.37; 1.37 date 2005.07.15.17.49.43; author christos; state Exp; branches; next 1.36; 1.36 date 2005.05.09.11.35.19; author christos; state Exp; branches; next 1.35; 1.35 date 2005.05.07.19.52.17; author dsl; state Exp; branches; next 1.34; 1.34 date 2003.10.27.06.19.29; author lukem; state Exp; branches 1.34.6.1; next 1.33; 1.33 date 2003.10.19.19.13.21; author christos; state Exp; branches; next 1.32; 1.32 date 2003.10.19.01.55.05; author lukem; state Exp; branches; next 1.31; 1.31 date 2003.08.07.09.05.32; author agc; state Exp; branches; next 1.30; 1.30 date 2003.07.13.08.31.13; author itojun; state Exp; branches; next 1.29; 1.29 date 2003.05.04.06.36.50; author gmcgarry; state Exp; branches; next 1.28; 1.28 date 2003.05.04.01.05.24; author gmcgarry; state Exp; branches; next 1.27; 1.27 date 2002.11.24.22.35.40; author christos; state Exp; branches; next 1.26; 1.26 date 2002.03.12.00.14.31; author christos; state Exp; branches; next 1.25; 1.25 date 2001.02.04.19.52.06; author christos; state Exp; branches; next 1.24; 1.24 date 2000.11.06.04.21.14; author mycroft; state Exp; branches; next 1.23; 1.23 date 2000.04.14.05.52.58; author simonb; state Exp; branches; next 1.22; 1.22 date 2000.01.27.23.39.40; author christos; state Exp; branches; next 1.21; 1.21 date 99.07.09.03.05.50; author christos; state Exp; branches; next 1.20; 1.20 date 98.07.28.11.41.55; author mycroft; state Exp; branches; next 1.19; 1.19 date 98.05.20.00.29.26; author christos; state Exp; branches; next 1.18; 1.18 date 98.04.07.10.16.04; author fair; state Exp; branches; next 1.17; 1.17 date 97.11.12.03.40.55; author cjs; state Exp; branches; next 1.16; 1.16 date 97.10.14.15.06.42; author christos; state Exp; branches 1.16.2.1; next 1.15; 1.15 date 97.09.14.07.43.56; author lukem; state Exp; branches; next 1.14; 1.14 date 97.07.04.21.02.02; author christos; state Exp; branches; next 1.13; 1.13 date 97.04.11.22.45.41; author christos; state Exp; branches; next 1.12; 1.12 date 97.03.14.01.42.20; author christos; state Exp; branches; next 1.11; 1.11 date 97.03.13.21.57.32; author christos; state Exp; branches; next 1.10; 1.10 date 96.10.16.14.40.32; author christos; state Exp; branches; next 1.9; 1.9 date 96.06.25.16.43.34; author christos; state Exp; branches; next 1.8; 1.8 date 95.05.11.21.29.12; author christos; state Exp; branches 1.8.6.1; next 1.7; 1.7 date 95.03.31.21.58.13; author christos; state Exp; branches; next 1.6; 1.6 date 95.03.21.09.09.09; author cgd; state Exp; branches; next 1.5; 1.5 date 94.12.05.19.07.42; author cgd; state Exp; branches; next 1.4; 1.4 date 94.12.04.07.12.13; author cgd; state Exp; branches; next 1.3; 1.3 date 94.06.11.16.11.57; author mycroft; state Exp; branches; next 1.2; 1.2 date 94.05.12.17.03.40; author jtc; state Exp; branches; next 1.1; 1.1 date 94.05.11.17.01.56; author jtc; state Exp; branches 1.1.1.1; next ; 1.55.2.1 date 2022.02.21.17.58.11; author martin; state Exp; branches; next ; commitid fdcvDhR5m456PvtD; 1.52.4.1 date 2018.07.28.04.32.56; author pgoyette; state Exp; branches; next ; commitid 1UP1xAIUxv1ZgRLA; 1.52.6.1 date 2019.06.10.21.41.03; author christos; state Exp; branches; next 1.52.6.2; commitid jtc8rnCzWiEEHGqB; 1.52.6.2 date 2020.04.21.18.41.06; author martin; state dead; branches; next 1.52.6.3; commitid 86tA4aEmdr3VCh5C; 1.52.6.3 date 2020.04.21.19.37.34; author martin; state Exp; branches; next ; commitid x6IB64bYH9UmWh5C; 1.48.8.1 date 2017.07.23.14.58.14; author snj; state Exp; branches; next 1.48.8.2; commitid IcSSefq8ASq6Dm0A; 1.48.8.2 date 2018.08.25.14.45.37; author martin; state Exp; branches; next 1.48.8.3; commitid 4qHcGnEEMLiYLvPA; 1.48.8.3 date 2022.02.24.10.07.46; author martin; state Exp; branches; next ; commitid RjC7kP7aBJ8K7RtD; 1.46.2.1 date 2014.08.10.06.41.18; author tls; state Exp; branches; next ; commitid cmSmsS7FIRrlxMLx; 1.45.2.1 date 2014.08.19.23.45.11; author tls; state Exp; branches; next ; commitid jTnpym9Qu0o4R1Nx; 1.44.2.1 date 2012.04.17.00.01.38; author yamt; state Exp; branches; next 1.44.2.2; 1.44.2.2 date 2014.05.22.11.26.23; author yamt; state Exp; branches; next ; commitid OarWMuV9WFtzGwBx; 1.42.4.1 date 2011.06.23.14.17.48; author cherry; state Exp; branches; next ; 1.40.8.1 date 2008.03.23.00.11.41; author matt; state Exp; branches; next ; 1.34.6.1 date 2007.03.31.14.04.58; author bouyer; state Exp; branches; next ; 1.16.2.1 date 97.11.13.00.07.29; author mellon; state Exp; branches; next 1.16.2.2; 1.16.2.2 date 98.05.08.06.01.03; author mycroft; state Exp; branches; next ; 1.8.6.1 date 97.01.26.04.57.20; author rat; state Exp; branches; next ; 1.1.1.1 date 94.05.11.17.01.57; author jtc; state Exp; branches; next ; desc @@ 1.66 log @ The great shell trailing whitespace cleanup of 2023... Inspired by private e-mail comments from mouse@@ NFCI. @ text @/* $NetBSD: histedit.c,v 1.65 2022/08/22 17:33:11 kre Exp $ */ /*- * Copyright (c) 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Kenneth Almquist. * * 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. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. */ #include #ifndef lint #if 0 static char sccsid[] = "@@(#)histedit.c 8.2 (Berkeley) 5/4/95"; #else __RCSID("$NetBSD: histedit.c,v 1.65 2022/08/22 17:33:11 kre Exp $"); #endif #endif /* not lint */ #include #include #include #include #include #include #include /* * Editline and history functions (and glue). */ #include "shell.h" #include "parser.h" #include "var.h" #include "options.h" #include "builtins.h" #include "main.h" #include "output.h" #include "mystring.h" #include "myhistedit.h" #include "error.h" #include "alias.h" #ifndef SMALL #include "eval.h" #include "memalloc.h" #include "show.h" #define MAXHISTLOOPS 4 /* max recursions through fc */ #define DEFEDITOR "ed" /* default editor *should* be $EDITOR */ History *hist; /* history cookie */ EditLine *el; /* editline cookie */ int displayhist; static FILE *el_in, *el_out; static int curpos; #ifdef DEBUG extern FILE *tracefile; #endif static const char *fc_replace(const char *, char *, char *); static int not_fcnumber(const char *); static int str_to_event(const char *, int); static int comparator(const void *, const void *); static char **sh_matches(const char *, int, int); static unsigned char sh_complete(EditLine *, int); /* * Set history and editing status. Called whenever the status may * have changed (figures out what to do). */ void histedit(void) { FILE *el_err; #define editing (Eflag || Vflag) CTRACE(DBG_HISTORY, ("histedit: %cE%cV %sinteractive\n", Eflag ? '-' : '+', Vflag ? '-' : '+', iflag ? "" : "not ")); if (iflag == 1) { if (!hist) { /* * turn history on */ INTOFF; hist = history_init(); INTON; if (hist != NULL) sethistsize(histsizeval()); else out2str("sh: can't initialize history\n"); } if (editing && !el && isatty(0)) { /* && isatty(2) ??? */ /* * turn editing on */ char *term; INTOFF; if (el_in == NULL) el_in = fdopen(0, "r"); if (el_out == NULL) el_out = fdopen(2, "w"); if (el_in == NULL || el_out == NULL) goto bad; el_err = el_out; #if DEBUG if (tracefile) el_err = tracefile; #endif /* * This odd piece of code doesn't affect the shell * at all, the environment modified here is the * stuff accessed via "environ" (the incoming * environment to the shell) which is only ever * touched at sh startup time (long before we get * here) and ignored thereafter. * * But libedit calls getenv() to discover TERM * and that searches the "environ" environment, * not the shell's internal variable data struct, * so we need to make sure that TERM in there is * correct. * * This sequence copies TERM from the shell into * the old "environ" environment. */ term = lookupvar("TERM"); if (term) setenv("TERM", term, 1); else unsetenv("TERM"); el = el_init("sh", el_in, el_out, el_err); VTRACE(DBG_HISTORY, ("el_init() %sed\n", el != NULL ? "succeed" : "fail")); if (el != NULL) { if (hist) el_set(el, EL_HIST, history, hist); set_prompt_lit(lookupvar("PSlit")); el_set(el, EL_SIGNAL, 1); el_set(el, EL_SAFEREAD, 1); el_set(el, EL_ALIAS_TEXT, alias_text, NULL); el_set(el, EL_ADDFN, "rl-complete", "ReadLine compatible completion function", sh_complete); } else { bad: out2str("sh: can't initialize editing\n"); } INTON; } else if (!editing && el) { INTOFF; el_end(el); el = NULL; VTRACE(DBG_HISTORY, ("line editing disabled\n")); INTON; } if (el) { INTOFF; if (Vflag) el_set(el, EL_EDITOR, "vi"); else if (Eflag) el_set(el, EL_EDITOR, "emacs"); VTRACE(DBG_HISTORY, ("reading $EDITRC\n")); el_source(el, lookupvar("EDITRC")); el_set(el, EL_BIND, "^I", tabcomplete ? "rl-complete" : "ed-insert", NULL); INTON; } } else { INTOFF; if (el) { /* no editing if not interactive */ el_end(el); el = NULL; } if (hist) { history_end(hist); hist = NULL; } INTON; VTRACE(DBG_HISTORY, ("line editing & history disabled\n")); } } void set_prompt_lit(const char *lit_ch) { wchar_t wc; if (!(iflag && editing && el)) return; if (lit_ch == NULL) { el_set(el, EL_PROMPT, getprompt); return; } mbtowc(&wc, NULL, 1); /* state init */ INTOFF; if (mbtowc(&wc, lit_ch, strlen(lit_ch)) <= 0) el_set(el, EL_PROMPT, getprompt); else el_set(el, EL_PROMPT_ESC, getprompt, (int)wc); INTON; } void set_editrc(const char *fname) { INTOFF; if (iflag && editing && el) el_source(el, fname); INTON; } void sethistsize(const char *hs) { int histsize; HistEvent he; if (hist != NULL) { if (hs == NULL || *hs == '\0' || *hs == '-' || (histsize = number(hs)) < 0) histsize = 100; INTOFF; history(hist, &he, H_SETSIZE, histsize); history(hist, &he, H_SETUNIQUE, 1); INTON; } } void setterm(const char *term) { INTOFF; if (el != NULL && term != NULL) if (el_set(el, EL_TERMINAL, term) != 0) { outfmt(out2, "sh: Can't set terminal type %s\n", term); outfmt(out2, "sh: Using dumb terminal settings.\n"); } INTON; } int inputrc(int argc, char **argv) { CTRACE(DBG_HISTORY, ("inputrc (%d arg%s)", argc-1, argc==2?"":"s")); if (argc != 2) { CTRACE(DBG_HISTORY, (" -- bad\n")); out2str("usage: inputrc file\n"); return 1; } CTRACE(DBG_HISTORY, (" file: \"%s\"\n", argv[1])); if (el != NULL) { INTOFF; if (el_source(el, argv[1])) { INTON; out2str("inputrc: failed\n"); return 1; } INTON; return 0; } else { out2str("sh: inputrc ignored, not editing\n"); return 1; } } /* * This command is provided since POSIX decided to standardize * the Korn shell fc command. Oh well... */ int histcmd(volatile int argc, char ** volatile argv) { int ch; const char * volatile editor = NULL; HistEvent he; volatile int lflg = 0, nflg = 0, rflg = 0, sflg = 0; int i, retval; const char *firststr, *laststr; int first, last, direction; char * volatile pat = NULL, * volatile repl; /* ksh "fc old=new" crap */ static int active = 0; struct jmploc jmploc; struct jmploc *volatile savehandler; char editfile[MAXPATHLEN + 1]; FILE * volatile efp; #ifdef __GNUC__ repl = NULL; /* XXX gcc4 */ efp = NULL; /* XXX gcc4 */ #endif if (hist == NULL) error("history not active"); CTRACE(DBG_HISTORY, ("histcmd (fc) %d arg%s\n", argc, argc==1?"":"s")); if (argc == 1) error("missing history argument"); optreset = 1; optind = 1; /* initialize getopt */ while (not_fcnumber(argv[optind]) && (ch = getopt(argc, argv, ":e:lnrs")) != -1) switch ((char)ch) { case 'e': editor = optarg; VTRACE(DBG_HISTORY, ("histcmd -e %s\n", editor)); break; case 'l': lflg = 1; VTRACE(DBG_HISTORY, ("histcmd -l\n")); break; case 'n': nflg = 1; VTRACE(DBG_HISTORY, ("histcmd -n\n")); break; case 'r': rflg = 1; VTRACE(DBG_HISTORY, ("histcmd -r\n")); break; case 's': sflg = 1; VTRACE(DBG_HISTORY, ("histcmd -s\n")); break; case ':': error("option -%c expects argument", optopt); /* NOTREACHED */ case '?': default: error("unknown option: -%c", optopt); /* NOTREACHED */ } argc -= optind, argv += optind; /* * If executing... */ if (lflg == 0 || editor || sflg) { lflg = 0; /* ignore */ editfile[0] = '\0'; /* * Catch interrupts to reset active counter and * cleanup temp files. */ savehandler = handler; if (setjmp(jmploc.loc)) { active = 0; if (*editfile) { VTRACE(DBG_HISTORY, ("histcmd err jump unlink temp \"%s\"\n", *editfile)); unlink(editfile); } handler = savehandler; longjmp(handler->loc, 1); } handler = &jmploc; VTRACE(DBG_HISTORY, ("histcmd was active %d (++)\n", active)); if (++active > MAXHISTLOOPS) { active = 0; displayhist = 0; error("called recursively too many times"); } /* * Set editor. */ if (sflg == 0) { if (editor == NULL && (editor = bltinlookup("FCEDIT", 1)) == NULL && (editor = bltinlookup("EDITOR", 1)) == NULL) editor = DEFEDITOR; if (editor[0] == '-' && editor[1] == '\0') { sflg = 1; /* no edit */ editor = NULL; } VTRACE(DBG_HISTORY, ("histcmd using %s as editor\n", editor == NULL ? "-nothing-" : editor)); } } /* * If executing, parse [old=new] now */ if (lflg == 0 && argc > 0 && ((repl = strchr(argv[0], '=')) != NULL)) { pat = argv[0]; *repl++ = '\0'; argc--, argv++; VTRACE(DBG_HISTORY, ("histcmd replace old=\"%s\" new=\"%s\"" " (%d args)\n", pat, repl, argc)); } /* * If -s is specified, accept only one operand */ if (sflg && argc >= 2) error("too many args"); /* * determine [first] and [last] */ switch (argc) { case 0: firststr = lflg ? "-16" : "-1"; laststr = "-1"; break; case 1: firststr = argv[0]; laststr = lflg ? "-1" : argv[0]; break; case 2: firststr = argv[0]; laststr = argv[1]; break; default: error("too many args"); /* NOTREACHED */ } /* * Turn into event numbers. */ first = str_to_event(firststr, 0); last = str_to_event(laststr, 1); if (rflg) { i = last; last = first; first = i; } VTRACE(DBG_HISTORY, ("histcmd%s first=\"%s\" (#%d) last=\"%s\" (#%d)\n", rflg ? " reversed" : "", rflg ? laststr : firststr, first, rflg ? firststr : laststr, last)); /* * XXX - this should not depend on the event numbers * always increasing. Add sequence numbers or offset * to the history element in next (diskbased) release. */ direction = first < last ? H_PREV : H_NEXT; /* * If editing, grab a temp file. */ if (editor) { int fd; INTOFF; /* easier */ snprintf(editfile, sizeof(editfile), "%s_shXXXXXX", _PATH_TMP); if ((fd = mkstemp(editfile)) < 0) error("can't create temporary file %s", editfile); if ((efp = fdopen(fd, "w")) == NULL) { close(fd); error("can't allocate stdio buffer for temp"); } VTRACE(DBG_HISTORY, ("histcmd created \"%s\" for edit buffer" " fd=%d\n", editfile, fd)); } /* * Loop through selected history events. If listing or executing, * do it now. Otherwise, put into temp file and call the editor * after. * * The history interface needs rethinking, as the following * convolutions will demonstrate. */ history(hist, &he, H_FIRST); retval = history(hist, &he, H_NEXT_EVENT, first); for (;retval != -1; retval = history(hist, &he, direction)) { if (lflg) { if (!nflg) out1fmt("%5d ", he.num); out1str(he.str); } else { const char *s = pat ? fc_replace(he.str, pat, repl) : he.str; if (sflg) { VTRACE(DBG_HISTORY, ("histcmd -s \"%s\"\n", s)); if (displayhist) { out2str(s); } evalstring(strcpy(stalloc(strlen(s) + 1), s), 0); if (displayhist && hist) { /* * XXX what about recursive and * relative histnums. */ history(hist, &he, H_ENTER, s); } break; } else fputs(s, efp); } /* * At end? (if we were to lose last, we'd sure be * messed up). */ if (he.num == last) break; } if (editor) { char *editcmd; size_t cmdlen; fclose(efp); cmdlen = strlen(editor) + strlen(editfile) + 2; editcmd = stalloc(cmdlen); snprintf(editcmd, cmdlen, "%s %s", editor, editfile); VTRACE(DBG_HISTORY, ("histcmd editing: \"%s\"\n", editcmd)); evalstring(editcmd, 0); /* XXX - should use no JC command */ stunalloc(editcmd); VTRACE(DBG_HISTORY, ("histcmd read cmds from %s\n", editfile)); readcmdfile(editfile); /* XXX - should read back - quick tst */ VTRACE(DBG_HISTORY, ("histcmd unlink %s\n", editfile)); unlink(editfile); INTON; } if (lflg == 0 && active > 0) --active; if (displayhist) displayhist = 0; return 0; } static const char * fc_replace(const char *s, char *p, char *r) { char *dest; int plen = strlen(p); VTRACE(DBG_HISTORY, ("histcmd s/%s/%s/ in \"%s\" -> ", p, r, s)); STARTSTACKSTR(dest); while (*s) { if (*s == *p && strncmp(s, p, plen) == 0) { while (*r) STPUTC(*r++, dest); s += plen; *p = '\0'; /* so no more matches */ } else STPUTC(*s++, dest); } STACKSTRNUL(dest); dest = grabstackstr(dest); VTRACE(DBG_HISTORY, ("\"%s\"\n", dest)); return dest; } /* * Comparator function for qsort(). The use of curpos here is to skip * characters that we already know to compare equal (common prefix). */ static int comparator(const void *a, const void *b) { return strcmp(*(char *const *)a + curpos, *(char *const *)b + curpos); } /* * This function is passed to libedit's fn_complete(). The library will * use it instead of its standard function to find matches, which * searches for files in current directory. If we're at the start of the * line, we want to look for available commands from all paths in $PATH. */ static char **sh_matches(const char *text, int start, int end) { char *free_path = NULL, *dirname, *path; char **matches = NULL; size_t i = 0, size = 16; if (start > 0) return NULL; curpos = end - start; if ((free_path = path = strdup(pathval())) == NULL) goto out; if ((matches = malloc(size * sizeof(matches[0]))) == NULL) goto out; while ((dirname = strsep(&path, ":")) != NULL) { struct dirent *entry; DIR *dir; int dfd; if ((dir = opendir(dirname)) == NULL) continue; if ((dfd = dirfd(dir)) == -1) continue; while ((entry = readdir(dir)) != NULL) { struct stat statb; if (strncmp(entry->d_name, text, curpos) != 0) continue; if (entry->d_type == DT_UNKNOWN || entry->d_type == DT_LNK) { if (fstatat(dfd, entry->d_name, &statb, 0) == -1) continue; if (!S_ISREG(statb.st_mode)) continue; } else if (entry->d_type != DT_REG) continue; if (++i >= size - 1) { size *= 2; if (reallocarr(&matches, size, sizeof(*matches))) { closedir(dir); goto out; } } matches[i] = strdup(entry->d_name); } closedir(dir); } out: free(free_path); if (i == 0) { free(matches); return NULL; } if (i == 1) { matches[0] = strdup(matches[1]); matches[i + 1] = NULL; } else { size_t j, k; qsort(matches + 1, i, sizeof(matches[0]), comparator); for (j = 1, k = 2; k <= i; k++) if (strcmp(matches[j] + curpos, matches[k] + curpos) == 0) free(matches[k]); else matches[++j] = matches[k]; matches[0] = strdup(text); matches[j + 1] = NULL; } return matches; } /* * This is passed to el_set(el, EL_ADDFN, ...) so that it's possible to * bind a key (tab by default) to execute the function. */ unsigned char sh_complete(EditLine *sel, int ch __unused) { return (unsigned char)fn_complete2(sel, NULL, sh_matches, L" \t\n\"\\'`@@$><=;|&{(", NULL, NULL, (size_t)100, NULL, &((int) {0}), NULL, NULL, FN_QUOTE_MATCH); } static int not_fcnumber(const char *s) { if (s == NULL) return 0; if (*s == '-') s++; return !is_number(s); } static int str_to_event(const char *str, int last) { HistEvent he; const char *s = str; int relative = 0; int i, retval; retval = history(hist, &he, H_FIRST); switch (*s) { case '-': relative = 1; /*FALLTHROUGH*/ case '+': s++; } if (is_number(s)) { i = number(s); if (relative) { while (retval != -1 && i--) { retval = history(hist, &he, H_NEXT); } if (retval == -1) retval = history(hist, &he, H_LAST); } else { retval = history(hist, &he, H_NEXT_EVENT, i); if (retval == -1) { /* * the notion of first and last is * backwards to that of the history package */ retval = history(hist, &he, last ? H_FIRST : H_LAST); } } if (retval == -1) error("history number %s not found (internal error)", str); } else { /* * pattern */ retval = history(hist, &he, H_PREV_STR, str); if (retval == -1) error("history pattern not found: %s", str); } return he.num; } #else int histcmd(int argc, char **argv) { error("not compiled with history support"); /* NOTREACHED */ } int inputrc(int argc, char **argv) { error("not compiled with history support"); /* NOTREACHED */ } #endif @ 1.65 log @ Add debugging trace points for history and the editline interface. NFC for any normal shell (not compiled with debugging (sh DEBUG) enabled. We have had a defined debug mode for this for years, but since I have not often played in this arena, never used it. Until recently (relatively). This (or a small part of it) played a part in discovering the fc -e bug cause. I have had it in my tree a while now - recent changes kept causing merge conflicts (all because I hadn't bothered to commit this), so I think now is the time... @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.64 2022/08/21 21:35:36 nia Exp $ */ d40 1 a40 1 __RCSID("$NetBSD: histedit.c,v 1.64 2022/08/21 21:35:36 nia Exp $"); d192 1 a192 1 el_set(el, EL_BIND, "^I", @ 1.64 log @sh(1): revert previous because it interferes with custom user bindings @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.62 2022/08/17 22:27:17 nia Exp $ */ d40 1 a40 1 __RCSID("$NetBSD: histedit.c,v 1.62 2022/08/17 22:27:17 nia Exp $"); d68 1 d101 3 d159 2 d181 1 d190 1 d207 1 d275 1 d277 1 d281 1 d325 1 d335 1 d339 1 d343 1 d347 1 d351 1 d376 4 a379 1 if (*editfile) d381 1 d386 1 d404 2 d417 2 d458 4 d482 2 d506 1 d539 1 d542 1 d544 1 d562 1 d575 1 @ 1.63 log @sh(1): Allow an explicit set -o vi or set -o emacs to override ~/.editrc @ text @a178 1 el_source(el, lookupvar("EDITRC")); d183 1 @ 1.62 log @sh(1): Assign the tab completion key binding last so a user having "bind -v" or "bind -e" in ~/.editrc doesn't cause tab completion to no longer function. @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.61 2022/02/08 20:39:59 rillig Exp $ */ d40 1 a40 1 __RCSID("$NetBSD: histedit.c,v 1.61 2022/02/08 20:39:59 rillig Exp $"); d179 1 a183 1 el_source(el, lookupvar("EDITRC")); @ 1.61 log @sh: fix typo in comment @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.60 2022/02/02 01:21:34 kre Exp $ */ d40 1 a40 1 __RCSID("$NetBSD: histedit.c,v 1.60 2022/02/02 01:21:34 kre Exp $"); d183 1 a185 1 el_source(el, lookupvar("EDITRC")); @ 1.60 log @After (a few days short of) 21 years, revert 1.25, which did nothing except make the -e option to "fc" fail to work (the commit message was about some other changes entirely, so I an only assume this was committed by mistake). It says a lot about the use of the fc command that no-one noticed that this did not work properly for all this time. Internally in sh, it is possible for built in commands to use either getopt(3) (from libc) or the much simpler internal shell nextopt() routine for option (flag) parsing. However it makes no sense to use getopt() and then access a global variable set only by nextopt() instead of the one getopt() sets (which is what the code had used previously, forever). Use the correct variable again. XXX pullup -9 -8 (-7 -6 -5 ...) @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.59 2022/01/31 18:15:45 kre Exp $ */ d40 1 a40 1 __RCSID("$NetBSD: histedit.c,v 1.59 2022/01/31 18:15:45 kre Exp $"); d136 1 a136 1 * envoironment to the shell) which is only ever @ 1.59 log @ When we initialize libedit (editline) always call ourselves "sh" no matter what $0 is (or is not) set to. This means that editrc(5) lines that start "sh:" are used (in addition to those with no prefix, which will usually be most of them), regardless of the name or manner in which we were invoked. OK christos@@ @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.58 2022/01/31 16:54:28 kre Exp $ */ d40 1 a40 1 __RCSID("$NetBSD: histedit.c,v 1.58 2022/01/31 16:54:28 kre Exp $"); d321 1 a321 1 editor = optionarg; @ 1.58 log @ Add some comments explaining accesses to the environment via getenv()/setenv()/unsetenv() which manipulate the envornoment the shell was passed at entry. These are a little odd in sh as that environment is copied into the shell's internal variable data struct at shell startup, and normally never accessed after that - in builtin commands (test. printf, ...) getenv() is #defined to become an internal sh lookup function instead, so even those never use the startup environment). NFCI @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.57 2021/09/14 15:04:09 christos Exp $ */ d40 1 a40 1 __RCSID("$NetBSD: histedit.c,v 1.57 2021/09/14 15:04:09 christos Exp $"); d118 1 a118 1 char *term, *shname; d154 1 a154 4 shname = arg0; if (shname[0] == '-') shname++; el = el_init(shname, el_in, el_out, el_err); @ 1.57 log @Quote the filenames like before @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.56 2021/08/15 10:17:55 christos Exp $ */ d40 1 a40 1 __RCSID("$NetBSD: histedit.c,v 1.56 2021/08/15 10:17:55 christos Exp $"); d132 17 @ 1.56 log @- Add command completion (from FreeBSD) - Use EL_SAFEREAD @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.55 2019/02/10 19:21:52 kre Exp $ */ d40 1 a40 1 __RCSID("$NetBSD: histedit.c,v 1.55 2019/02/10 19:21:52 kre Exp $"); d625 1 a625 1 return (unsigned char)fn_complete(sel, NULL, sh_matches, d627 1 a627 1 NULL, &((int) {0}), NULL, NULL); @ 1.55 log @ Remove a function prototype which was added to in 2005. I think we can trust it to be stable by now, and doin't need the dup. @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.54 2019/02/09 03:35:55 kre Exp $ */ d40 1 a40 1 __RCSID("$NetBSD: histedit.c,v 1.54 2019/02/09 03:35:55 kre Exp $"); d45 2 d76 1 a76 2 STATIC const char *fc_replace(const char *, char *, char *); d82 7 d147 1 d151 1 a151 1 _el_fn_complete); d505 1 a505 1 STATIC const char * d524 104 a627 1 return (dest); d630 2 a631 2 int not_fcnumber(char *s) d637 1 a637 1 return (!is_number(s)); d640 1 a640 1 int d686 1 a686 1 return (he.num); @ 1.55.2.1 log @Pull up following revision(s) (requested by kre in ticket #1429): bin/sh/histedit.c: revision 1.60 After (a few days short of) 21 years, revert 1.25, which did nothing except make the -e option to "fc" fail to work (the commit message was about some other changes entirely, so I an only assume this was committed by mistake). It says a lot about the use of the fc command that no-one noticed that this did not work properly for all this time. Internally in sh, it is possible for built in commands to use either getopt(3) (from libc) or the much simpler internal shell nextopt() routine for option (flag) parsing. However it makes no sense to use getopt() and then access a global variable set only by nextopt() instead of the one getopt() sets (which is what the code had used previously, forever). Use the correct variable again. XXX pullup -9 -8 (-7 -6 -5 ...) @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.55 2019/02/10 19:21:52 kre Exp $ */ d40 1 a40 1 __RCSID("$NetBSD: histedit.c,v 1.55 2019/02/10 19:21:52 kre Exp $"); d298 1 a298 1 editor = optarg; @ 1.54 log @ INTON / INTOFF audit and cleanup. No visible differences expected - there is a remote chance that some internal lossage may no longer occur in interactive shells that receive SIGINT (untrapped) at inopportune times, but you would have had to have been very unlucky to have ever suffered from that. @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.53 2018/07/13 22:43:44 kre Exp $ */ d40 1 a40 1 __RCSID("$NetBSD: histedit.c,v 1.53 2018/07/13 22:43:44 kre Exp $"); a73 1 unsigned char _el_fn_complete(EditLine *, int); @ 1.53 log @Remove atoi() Mostly use number() (no longer implemented using atoi()) when an unsigned integer is required, but use strtoXXX() when a conversion is wanted, without the possibility or error (like setting OPTIND and RANDOM). Always init OPTIND to 1 when sh starts (overriding anything in environ.) @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.52 2017/06/28 13:46:06 kre Exp $ */ d40 1 a40 1 __RCSID("$NetBSD: histedit.c,v 1.52 2017/06/28 13:46:06 kre Exp $"); d156 1 d164 1 d195 1 d200 1 d206 1 d209 1 d222 1 d225 1 d232 1 d238 1 d249 1 d251 1 d254 3 a256 2 } else return 0; d484 1 a484 1 INTON; d487 1 @ 1.52 log @ Now libedit supports embedded mode switch sequence, improve sh support for them (adds PSlit variable to set the magic character). @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.51 2017/06/27 23:27:03 christos Exp $ */ d40 1 a40 1 __RCSID("$NetBSD: histedit.c,v 1.51 2017/06/27 23:27:03 christos Exp $"); d213 2 a214 2 if (hs == NULL || *hs == '\0' || (histsize = atoi(hs)) < 0) d532 1 a532 1 i = atoi(s); @ 1.52.6.1 log @Sync with HEAD @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.55 2019/02/10 19:21:52 kre Exp $ */ d40 1 a40 1 __RCSID("$NetBSD: histedit.c,v 1.55 2019/02/10 19:21:52 kre Exp $"); d74 1 a155 1 INTOFF; a162 1 INTON; a192 1 INTOFF; a196 1 INTON; a201 1 INTOFF; a203 1 INTON; d213 2 a214 2 if (hs == NULL || *hs == '\0' || *hs == '-' || (histsize = number(hs)) < 0) a215 1 INTOFF; a217 1 INTON; a223 1 INTOFF; a228 1 INTON; a238 1 INTOFF; a239 1 INTON; d242 2 a243 3 } INTON; return 0; d471 1 a471 1 stunalloc(editcmd); a473 1 INTON; d532 1 a532 1 i = number(s); @ 1.52.6.2 log @Sync with HEAD @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.52.6.1 2019/06/10 21:41:03 christos Exp $ */ d40 1 a40 1 __RCSID("$NetBSD: histedit.c,v 1.52.6.1 2019/06/10 21:41:03 christos Exp $"); @ 1.52.6.3 log @Ooops, restore accidently removed files from merge mishap @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.55 2019/02/10 19:21:52 kre Exp $ */ d40 1 a40 1 __RCSID("$NetBSD: histedit.c,v 1.55 2019/02/10 19:21:52 kre Exp $"); @ 1.52.4.1 log @Sync with HEAD @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.53 2018/07/13 22:43:44 kre Exp $ */ d40 1 a40 1 __RCSID("$NetBSD: histedit.c,v 1.53 2018/07/13 22:43:44 kre Exp $"); d213 2 a214 2 if (hs == NULL || *hs == '\0' || *hs == '-' || (histsize = number(hs)) < 0) d532 1 a532 1 i = number(s); @ 1.51 log @Add literal prompt support this allows one to do: CA="$(printf '\1')" PS1="${CA}$(tput bold)${CA}\$${CA}$(tput sgr0)${CA} " @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.50 2017/06/27 02:22:08 kre Exp $ */ d40 1 a40 1 __RCSID("$NetBSD: histedit.c,v 1.50 2017/06/27 02:22:08 kre Exp $"); d137 2 a138 1 el_set(el, EL_PROMPT_ESC, getprompt, L'\1'); d179 21 @ 1.50 log @ Properly support EDITRC - use it as (naming) the file when setting up libedit, and re-do the config whenever EDITRC is set. @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.49 2017/06/26 20:28:01 christos Exp $ */ d40 1 a40 1 __RCSID("$NetBSD: histedit.c,v 1.49 2017/06/26 20:28:01 christos Exp $"); d137 1 a137 1 el_set(el, EL_PROMPT, getprompt); @ 1.49 log @source .editrc after we initialize so that commands persist! @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.48 2016/03/16 22:36:40 christos Exp $ */ d40 1 a40 1 __RCSID("$NetBSD: histedit.c,v 1.48 2016/03/16 22:36:40 christos Exp $"); d161 1 a161 1 el_source(el, NULL); d177 6 @ 1.48 log @Sprinkle volatile for gcc 5! @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.47 2014/06/18 18:17:30 christos Exp $ */ d40 1 a40 1 __RCSID("$NetBSD: histedit.c,v 1.47 2014/06/18 18:17:30 christos Exp $"); a154 1 el_source(el, NULL); d161 1 @ 1.48.8.1 log @Pull up following revision(s) (requested by kre in ticket #103): bin/kill/kill.c: 1.28 bin/sh/Makefile: 1.111-1.113 bin/sh/arith_token.c: 1.5 bin/sh/arith_tokens.h: 1.2 bin/sh/arithmetic.c: 1.3 bin/sh/arithmetic.h: 1.2 bin/sh/bltin/bltin.h: 1.15 bin/sh/cd.c: 1.49-1.50 bin/sh/error.c: 1.40 bin/sh/eval.c: 1.142-1.151 bin/sh/exec.c: 1.49-1.51 bin/sh/exec.h: 1.26 bin/sh/expand.c: 1.113-1.119 bin/sh/expand.h: 1.23 bin/sh/histedit.c: 1.49-1.52 bin/sh/input.c: 1.57-1.60 bin/sh/input.h: 1.19-1.20 bin/sh/jobs.c: 1.86-1.87 bin/sh/main.c: 1.71-1.72 bin/sh/memalloc.c: 1.30 bin/sh/memalloc.h: 1.17 bin/sh/mknodenames.sh: 1.4 bin/sh/mkoptions.sh: 1.3-1.4 bin/sh/myhistedit.h: 1.12-1.13 bin/sh/nodetypes: 1.16-1.18 bin/sh/option.list: 1.3-1.5 bin/sh/parser.c: 1.133-1.141 bin/sh/parser.h: 1.22-1.23 bin/sh/redir.c: 1.58 bin/sh/redir.h: 1.24 bin/sh/sh.1: 1.149-1.159 bin/sh/shell.h: 1.24 bin/sh/show.c: 1.43-1.47 bin/sh/show.h: 1.11 bin/sh/syntax.c: 1.4 bin/sh/syntax.h: 1.8 bin/sh/trap.c: 1.41 bin/sh/var.c: 1.56-1.65 bin/sh/var.h: 1.29-1.35 An initial attempt at implementing LINENO to meet the specs. Aside from one problem (not too hard to fix if it was ever needed) this version does about as well as most other shell implementations when expanding $((LINENO)) and better for ${LINENO} as it retains the "LINENO hack" for the latter, and that is very accurate. Unfortunately that means that ${LINENO} and $((LINENO)) do not always produce the same value when used on the same line (a defect that other shells do not share - aside from the FreeBSD sh as it is today, where only the LINENO hack exists and so (like for us before this commit) $((LINENO)) is always either 0, or at least whatever value was last set, perhaps by LINENO=${LINENO} which does actually work ... for that one line...) This could be corrected by simply removing the LINENO hack (look for the string LINENO in parser.c) in which case ${LINENO} and $((LINENO)) would give the same (not perfectly accurate) values, as do most other shells. POSIX requires that LINENO be set before each command, and this implementation does that fairly literally - except that we only bother before the commands which actually expand words (for, case and simple commands). Unfortunately this forgot that expansions also occur in redirects, and the other compound commands can also have redirects, so if a redirect on one of the other compound commands wants to use the value of $((LINENO)) as a part of a generated file name, then it will get an incorrect value. This is the "one problem" above. (Because the LINENO hack is still enabled, using ${LINENO} works.) This could be fixed, but as this version of the LINENO implementation is just for reference purposes (it will be superseded within minutes by a better one) I won't bother. However should anyone else decide that this is a better choice (it is probably a smaller implementation, in terms of code & data space then the replacement, but also I would expect, slower, and definitely less accurate) this defect is something to bear in mind, and fix. This version retains the *BSD historical practice that line numbers in functions (all functions) count from 1 from the start of the function, and elsewhere, start from 1 from where the shell started reading the input file/stream in question. In an "eval" expression the line number starts at the line of the "eval" (and then increases if the input is a multi-line string). Note: this version is not documented (beyond as much as LINENO was before) hence this slightly longer than usual commit message. A better LINENO implementation. This version deletes (well, #if 0's out) the LINENO hack, and uses the LINENO var for both ${LINENO} and $((LINENO)). (Code to invert the LINENO hack when required, like when de-compiling the execution tree to provide the "jobs" command strings, is still included, that can be deleted when the LINENO hack is completely removed - look for refs to VSLINENO throughout the code. The var funclinno in parser.c can also be removed, it is used only for the LINENO hack.) This version produces accurate results: $((LINENO)) was made as accurate as the LINENO hack made ${LINENO} which is very good. That's why the LINENO hack is not yet completely removed, so it can be easily re-enabled. If you can tell the difference when it is in use, or not in use, then something has broken (or I managed to miss a case somewhere.) The way that LINENO works is documented in its own (new) section in the man page, so nothing more about that, or the new options, etc, here. This version introduces the possibility of having a "reference" function associated with a variable, which gets called whenever the value of the variable is required (that's what implements LINENO). There is just one function pointer however, so any particular variable gets at most one of the set function (as used for PATH, etc) or the reference function. The VFUNCREF bit in the var flags indicates which func the variable in question uses (if any - the func ptr, as before, can be NULL). I would not call the results of this perfect yet, but it is close. Unbreak (at least) i386 build .... I have no idea why this built for me on amd64 (problem was missing prototype for snprintf witout ) While here, add some (DEBUG mode only) tracing that proved useful in solving another problem. Set the line number before expanding args, not after. As the line_number would have usually been set earlier, this change is mostly an effective no-op, but it is better this way (just in case) - not observed to have caused any problems. Undo some over agressive fixes for a (pre-commit) bug that did not need these changes to be fixed - and these cause problems in another absurd use case. Either of these issues is unlikely to be seen by anyone who isn't an idiot masochist... PR bin/52280 removescapes_nl in expari() even when not quoted, CRTNONL's appear regardless of quoting (unlike CTLESC). New sentence, new line. Whitespace. Improve the (new) LINENO section, markup changes (with thanks to wiz@@ for assistace) and some better wording in a few placed. I am an idiot... revert the previous unintended commit. Remove some left over baggage from the LINENO v1 implementation that didn't get removed with v2, and should have. This would have had (I think, without having tested it) one very minor effect on the way LINENO worked in the v2 implementation, but my guess is it would have taken a long time before anyone noticed... Correct spelling in comments of DEBUG only code... (Perhaps) temporary fix to pkgtools (cwrappers) build (configure). Expanding `` containing \ \n sequences looks to have been giving problems. I don't think this is the correct fix, but it will do no worse harm than (perhaps) incorrectly calculating LINENO in this kind of (rare) circumstance. I'll look and see if there should be a better fix later. s/volatile/const/ -- wonderful how opposites attract like this. NFC (normal use) - DEBUG only change, when showing empty arg list don't omit terminating \n. Free stack memory in a couple of obscure cases where it wasn't being done (one in probably dead code that is never compiled, the other in a very rare error case.) Since it is stack memory it wasn't lost in any case, just held longer than needed. Many internal memory management type fixes. PR bin/52302 (core dump with interactive shell, here doc and error on same line) is fixed. (An old bug.) echo "$( echo x; for a in $( seq 1000 ); do printf '%s\n'; done; echo y )" consistently prints 1002 lines (x, 1000 empty ones, then y) as it should (And you don't want to know what it did before, or why.) (Another old one.) (Recently added) Problems with ~ expansion fixed (mem management related). Proper fix for the cwrappers configure problem (which includes the quick fix that was done earlier, but extends upon that to be correct). (This was another newly added problem.) And the really devious (and rare) old bug - if STACKSTRNUL() needs to allocate a new buffer in which to store the \0, calculate the size of the string space remaining correctly, unlike when SPUTC() grows the buffer, there is no actual data being stored in the STACKSTRNUL() case - the string space remaining was calculated as one byte too few. That would be harmless, unless the next buffer also filled, in which case it was assumed that it was really full, not one byte less, meaning one junk char (a nul, or anything) was being copied into the next (even bigger buffer) corrupting the data. Consistent use of stalloc() to allocate a new block of (stack) memory, and grabstackstr() to claim a block of (stack) memory that had already been occupied but not claimed as in use. Since grabstackstr is implemented as just a call to stalloc() this is a no-op change in practice, but makes it much easier to comprehend what is really happening. Previous code sometimes used stalloc() when the use case was really for grabstackstr(). Change grabstackstr() to actually use the arg passed to it, instead of (not much better than) guessing how much space to claim, More care when using unstalloc()/ungrabstackstr() to return space, and in particular when the stack must be returned to its previous state, rather than just returning no-longer needed space, neither of those work. They also don't work properly if there have been (really, even might have been) any stack mem allocations since the last stalloc()/grabstackstr(). (If we know there cannot have been then the alloc/release sequence is kind of pointless.) To work correctly in general we must use setstackmark()/popstackmark() so do that when needed. Have those also save/restore the top of stack string space remaining. [Aside: for those reading this, the "stack" mentioned is not in any way related to the thing used for maintaining the C function call state, ie: the "stack segment" of the program, but the shell's internal memory management strategy.] More comments to better explain what is happening in some cases. Also cleaned up some hopelessly broken DEBUG mode data that were recently added (no effect on anyone but the poor semi-human attempting to make sense of it...). User visible changes: Proper counting of line numbers when a here document is delimited by a multi-line end-delimiter, as in cat << 'REALLY END' here doc line 1 here doc line 2 REALLY END (which is an obscure case, but nothing says should not work.) The \n in the end-delimiter of the here doc (the last one) was not incrementing the line number, which from that point on in the script would be 1 too low (or more, for end-delimiters with more than one \n in them.) With tilde expansion: unset HOME; echo ~ changed to return getpwuid(getuid())->pw_home instead of failing (returning ~) POSIX says this is unspecified, which makes it difficult for a script to compensate for being run without HOME set (as in env -i sh script), so while not able to be used portably, this seems like a useful extension (and is implemented the same way by some other shells). Further, with HOME=; printf %s ~ we now write nothing (which is required by POSIX - which requires ~ to expand to the value of $HOME if it is set) previously if $HOME (in this case) or a user's directory in the passwd file (for ~user) were a null STRING, We failed the ~ expansion and left behind '~' or '~user'. Changed the long name for the -L option from lineno_fn_relative to local_lineno as the latter seemed to be marginally more popular, and perhaps more importantly, is the same length as the peviously existing quietprofile option, which means the man page indentation for the list of options can return to (about) what it was before... (That is, less indented, which means more data/line, which means less lines of man page - a good thing!) Cosmetic changes to variable flags - make their values more suited to my delicate sensibilities... (NFC). Arrange not to barf (ever) if some turkey makes _ readonly. Do this by adding a VNOERROR flag that causes errors in var setting to be ignored (intended use is only for internal shell var setting, like of "_"). (nb: invalid var name errors ignore this flag, but those should never occur on a var set by the shell itself.) From FreeBSD: don't simply discard memory if a variable is not set for any reason (including because it is readonly) if the var's value had been malloc'd. Free it instead... NFC - DEBUG changes, update this to new TRACE method. KNF - white space and comment formatting. NFC - DEBUG mode only change - convert this to the new TRACE() format. NFC - DEBUG mode only change - complete a change made earlier (marking the line number when included in the trace line tag to show whether it comes from the parser, or the elsewhere as they tend to be quite different). Initially only one case was changed, while I pondered whether I liked it or not. Now it is all done... Also when there is a line tag at all, always include the root/sub-shell indicator character, not only when the pid is included. NFC: DEBUG related comment change - catch up with reality. NFC: DEBUG mode only change. Fix botched cleanup of one TRACE(). "b" more forgiving when sorting options to allow reasonable (and intended) flexibility in option.list format. Changes nothing for current option.list. Now that excessive use of STACKSTRNUL has served its purpose (well, accidental purpose) in exposing the bug in its implementation, go back to not using it when not needed for DEBUG TRACE purposes. This change should have no practical effect on either a DEBUG shell (where the STACKSTRNUL() calls remain) or a non DEBUG shell where they are not needed. Correct the initial line number used for processing -c arg strings. (It was inheriting the value from end of profile file processing) - I didn't notice before as I usually test with empty or no profile files to avoid complications. Trivial change which should have very limited impact. Fix from FreeBSD (applied there in July 2008...) Don't dump core with input like sh -c 'x=; echo >&$x' - that is where the word after a >& or <& redirect expands to nothing at all. Another fix from FreeBSD (this one from April 2009). When processing a string (as in eval, trap, or sh -c) don't allow trailing \n's to destroy the exit status of the last command executed. That is: sh -c 'false ' echo $? should produce 1, not 0. It is amazing what nonsense appears to work sometimes... (all my nonsense too!) Two bugs here, one benign because of the way the script is used. The other hidden by NetBSD's sort being stable, and the data not really requiring sorting at all... So as it happens these fixes change nothing, but they are needed anyway. (The contents of the generated file are only used in DEBUG shells, so this is really even less important than it seems.) Another ancient (highly improbable) bug bites the dust. This one caused by incorrect macro usage (ie: using the wrong one) which has been in the sources since version 1.1 (ie: forever). Like the previous (STACKSTRNUL) bug, the probability of this one actually occurring has been infinitesimal but the LINENO code increases that to infinitesimal and a smidgen... (or a few, depending upon usage). Still, apparently that was enough, Kamil Rytarowski discovered that the zsh configure script (damn competition!) managed to trigger this problem. source .editrc after we initialize so that commands persist! Make arg parsing in kill POSIX compatible with POSIX (XBD 2.12) by parsing the way getopt(3) would, if only it could handle the (required) -signumber and -signame options. This adds two "features" to kill, -ssigname and -lstatus now work (ie: one word with all of the '-', the option letter, and its value) and "--" also now works (kill -- -pid1 pid2 will not attempt to send the pid1 signal to pid2, but rather SIGTERM to the pid1 process group and pid2). It is still the case that (apart from --) at most 1 option is permitted (-l, -s, -signame, or -signumber.) Note that we now have an ambiguity, -sname might mean "-s name" or send the signal "sname" - if one of those turns out to be valid, that will be accepted, otherwise the error message will indicate that "sname" is not a valid signal name, not that "name" is not. Keeping the "-s" and signal name as separate words avoids this issue. Also caution: should someone be weird enough to define a new signal name (as in the part after SIG) which is almost the same name as an existing name that starts with 'S' by adding an extra 'S' prepended (eg: adding a SIGSSYS) then the ambiguity problem becomes much worse. In that case "kill -ssys" will be resolved in favour of the "-s" flag being used (the more modern syntax) and would send a SIGSYS, rather that a SIGSSYS. So don't do that. While here, switch to using signalname(3) (bye bye NSIG, et. al.), add some constipation, and show a little pride in formatting the signal names for "kill -l" (and in the usage when appropriate -- same routine.) Respect COLUMNS (POSIX XBD 8.3) as primary specification of the width (terminal width, not number of columns to print) for kill -l, a very small value for COLUMNS will cause kill -l output to list signals one per line, a very large value will cause them all to be listed on one line.) (eg: "COLUMNS=1 kill -l") TODO: the signal printing for "trap -l" and that for "kill -l" should be switched to use a common routine (for the sh builtin versions.) All changes of relevance here are to bin/kill - the (minor) changes to bin/sh are only to properly expose the builtin version of getenv(3) so the builtin version of kill can use it (ie: make its prototype available.) Properly support EDITRC - use it as (naming) the file when setting up libedit, and re-do the config whenever EDITRC is set. Get rid of workarounds for ancient groff html backend. Simplify macro usage. Make one example more like a real world possibility (it still isn't, but is closer) - though the actual content is irrelevant to the point being made. Add literal prompt support this allows one to do: CA="$(printf '\1')" PS1="${CA}$(tput bold)${CA}\$${CA}$(tput sgr0)${CA} " Now libedit supports embedded mode switch sequence, improve sh support for them (adds PSlit variable to set the magic character). NFC: DEBUG only change - provide an externally visible (to the DEBUG sh internals) interface to one of the internal (private to trace code) functions Include redirections in trace output from "set -x" Implement PS1, PS2 and PS4 expansions (variable expansions, arithmetic expansions, and if enabled by the promptcmds option, command substitutions.) Implement a bunch of new shell environment variables. many mostly useful in prompts when expanded at prompt time, but all available for general use. Many of the new ones are not available in SMALL shells (they work as normal if assigned, but the shell does not set or use them - and there is no magic in a SMALL shell (usually for install media.)) Omnibus manual update for prompt expansions and new variables. Throw in some random cleanups as a bonus. Correct a markup typo (why did I not see this before the prev commit??) Sort options (our default is 0..9AaBbZz). Fix markup problems and a typo. Make $- list flags in the same order they appear in sh(1) Do a better job of detecting the error in pkgsrc/devel/libbson-1.6.3's configure script, ie: $(( which is intended to be a sub-shell in a command substitution, but is an arith subst instead, it needs to be written $( ( to do as intended. Instead of just blindly carrying on to find the missing )) somewhere, anywhere, give up as soon as we have seen an unbalanced ')' that isn't immediately followed by another ')' which in a valid arith subst it always would be. While here, there has been a comment in the code for quite a while noting a difference in the standard between the text descr & grammar when it comes to the syntax of case statements. Add more comments to explain why parsing it as we do is in fact definitely the correct way (ie: the grammar wins arguments like this...). DEBUG and white space changes only. Convert TRACE() calls for DEBUg mode to the new style. NFC (when not debugging sh). Mostly DEBUG and white space changes. Convert DEEBUG TRACE() calls to the new format. Also #if 0 a function definition that is used nowhere. While here, change the function of pushfile() slightly - it now sets the buf pointer in the top (new) input descriptor to NULL, instead of simply leaving it - code that needs a buffer always (before and after) must malloc() one and assign it after the call. But code which does not (which will be reading from a string or similar) now does not have to explicitly set it to NULL (cleaner interface.) NFC intended (or observed.) DEBUG changes: convert DEBUG TRACE() calls to new format. ALso, cause exec failures to always cause the shell to exit with status 126 or 127, whatever the cause. 127 is intended for lookup failures (and is used that way), 126 is used for anything else that goes wrong (as in several other shells.) We no longer use 2 (more easily confused with an exit status of the command exec'd) for shell exec failures. DEBUG only changes. Convert the TRACE() calls in the remaining files that still used it to the new format. NFC. Fix a reference after free (and consequent nonsense diagnostic for attempts to set readonly variables) I added in 1.60 by incompletely copying the FreeBSD fix for the lost memory issue. @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.48 2016/03/16 22:36:40 christos Exp $ */ d40 1 a40 1 __RCSID("$NetBSD: histedit.c,v 1.48 2016/03/16 22:36:40 christos Exp $"); d137 1 a137 2 set_prompt_lit(lookupvar("PSlit")); d155 1 a161 1 el_source(el, lookupvar("EDITRC")); a176 27 void set_prompt_lit(const char *lit_ch) { wchar_t wc; if (!(iflag && editing && el)) return; if (lit_ch == NULL) { el_set(el, EL_PROMPT, getprompt); return; } mbtowc(&wc, NULL, 1); /* state init */ if (mbtowc(&wc, lit_ch, strlen(lit_ch)) <= 0) el_set(el, EL_PROMPT, getprompt); else el_set(el, EL_PROMPT_ESC, getprompt, (int)wc); } void set_editrc(const char *fname) { if (iflag && editing && el) el_source(el, fname); } @ 1.48.8.2 log @Pull up following revision(s) (requested by kre in ticket #988): bin/sh/parser.c: revision 1.147 bin/sh/var.c: revision 1.70 bin/sh/mystring.c: revision 1.18 bin/sh/options.c: revision 1.53 bin/sh/histedit.c: revision 1.53 Remove atoi() Mostly use number() (no longer implemented using atoi()) when an unsigned integer is required, but use strtoXXX() when a conversion is wanted, without the possibility or error (like setting OPTIND and RANDOM). Always init OPTIND to 1 when sh starts (overriding anything in environ.) @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.48.8.1 2017/07/23 14:58:14 snj Exp $ */ d40 1 a40 1 __RCSID("$NetBSD: histedit.c,v 1.48.8.1 2017/07/23 14:58:14 snj Exp $"); d213 2 a214 2 if (hs == NULL || *hs == '\0' || *hs == '-' || (histsize = number(hs)) < 0) d532 1 a532 1 i = number(s); @ 1.48.8.3 log @Pull up following revision(s) (requested by kre in ticket #1736): bin/sh/histedit.c: revision 1.60 After (a few days short of) 21 years, revert 1.25, which did nothing except make the -e option to "fc" fail to work (the commit message was about some other changes entirely, so I an only assume this was committed by mistake). It says a lot about the use of the fc command that no-one noticed that this did not work properly for all this time. Internally in sh, it is possible for built in commands to use either getopt(3) (from libc) or the much simpler internal shell nextopt() routine for option (flag) parsing. However it makes no sense to use getopt() and then access a global variable set only by nextopt() instead of the one getopt() sets (which is what the code had used previously, forever). Use the correct variable again. XXX pullup -9 -8 (-7 -6 -5 ...) @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.48.8.2 2018/08/25 14:45:37 martin Exp $ */ d40 1 a40 1 __RCSID("$NetBSD: histedit.c,v 1.48.8.2 2018/08/25 14:45:37 martin Exp $"); d286 1 a286 1 editor = optarg; @ 1.47 log @Adjust to the new alias text libedit API. @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.46 2014/03/23 05:07:59 dholland Exp $ */ d40 1 a40 1 __RCSID("$NetBSD: histedit.c,v 1.46 2014/03/23 05:07:59 dholland Exp $"); d227 1 a227 1 histcmd(int argc, char **argv) d232 1 a232 2 int lflg = 0; volatile int nflg = 0, rflg = 0, sflg = 0; d236 1 a236 1 char *pat = NULL, *repl; /* ksh "fc old=new" crap */ d241 1 a241 1 FILE *efp; @ 1.46 log @don't use sprintf @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.45 2012/03/20 18:42:29 matt Exp $ */ d40 1 a40 1 __RCSID("$NetBSD: histedit.c,v 1.45 2012/03/20 18:42:29 matt Exp $"); d62 1 d139 1 @ 1.46.2.1 log @Rebase. @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.47 2014/06/18 18:17:30 christos Exp $ */ d40 1 a40 1 __RCSID("$NetBSD: histedit.c,v 1.47 2014/06/18 18:17:30 christos Exp $"); a61 1 #include "alias.h" a137 1 el_set(el, EL_ALIAS_TEXT, alias_text, NULL); @ 1.45 log @Use C89 function definitions @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.44 2011/07/12 16:40:41 joerg Exp $ */ d40 1 a40 1 __RCSID("$NetBSD: histedit.c,v 1.44 2011/07/12 16:40:41 joerg Exp $"); d435 1 d438 3 a440 2 editcmd = stalloc(strlen(editor) + strlen(editfile) + 2); sprintf(editcmd, "%s %s", editor, editfile); @ 1.45.2.1 log @Rebase to HEAD as of a few days ago. @ text @d1 1 a1 1 /* $NetBSD$ */ d40 1 a40 1 __RCSID("$NetBSD$"); a61 1 #include "alias.h" a137 1 el_set(el, EL_ALIAS_TEXT, alias_text, NULL); a434 1 size_t cmdlen; d437 2 a438 3 cmdlen = strlen(editor) + strlen(editfile) + 2; editcmd = stalloc(cmdlen); snprintf(editcmd, cmdlen, "%s %s", editor, editfile); @ 1.44 log @Move the savehandler assignment before setjmp() to avoid triggering warnings about use before initialization with clang. @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.43 2011/06/18 21:18:46 christos Exp $ */ d40 1 a40 1 __RCSID("$NetBSD: histedit.c,v 1.43 2011/06/18 21:18:46 christos Exp $"); d202 1 a202 3 inputrc(argc, argv) int argc; char **argv; @ 1.44.2.1 log @sync with head @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.44 2011/07/12 16:40:41 joerg Exp $ */ d40 1 a40 1 __RCSID("$NetBSD: histedit.c,v 1.44 2011/07/12 16:40:41 joerg Exp $"); d202 3 a204 1 inputrc(int argc, char **argv) @ 1.44.2.2 log @sync with head. for a reference, the tree before this commit was tagged as yamt-pagecache-tag8. this commit was splitted into small chunks to avoid a limitation of cvs. ("Protocol error: too many arguments") @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.44.2.1 2012/04/17 00:01:38 yamt Exp $ */ d40 1 a40 1 __RCSID("$NetBSD: histedit.c,v 1.44.2.1 2012/04/17 00:01:38 yamt Exp $"); a434 1 size_t cmdlen; d437 2 a438 3 cmdlen = strlen(editor) + strlen(editfile) + 2; editcmd = stalloc(cmdlen); snprintf(editcmd, cmdlen, "%s %s", editor, editfile); @ 1.43 log @PR/45069: Henning Petersen: Use prototypes from builtins.h . @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.42 2011/01/07 22:21:56 jmmv Exp $ */ d40 1 a40 1 __RCSID("$NetBSD: histedit.c,v 1.42 2011/01/07 22:21:56 jmmv Exp $"); d293 1 a300 1 savehandler = handler; @ 1.42 log @Call el_source before initializing sh-specific editline properties (i.e. the editor type and the tab completion binding). This allows tab completion to work when a user has an ~/.editrc file. Addresses PR bin/43404. @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.41 2008/02/13 12:57:16 joerg Exp $ */ d40 1 a40 1 __RCSID("$NetBSD: histedit.c,v 1.41 2008/02/13 12:57:16 joerg Exp $"); d56 1 @ 1.42.4.1 log @Catchup with rmind-uvmplock merge. @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.43 2011/06/18 21:18:46 christos Exp $ */ d40 1 a40 1 __RCSID("$NetBSD: histedit.c,v 1.43 2011/06/18 21:18:46 christos Exp $"); a55 1 #include "builtins.h" @ 1.41 log @Set unique mode for the history, so that repeating a command doesn't spam the history. @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.40 2006/10/16 00:36:19 christos Exp $ */ d40 1 a40 1 __RCSID("$NetBSD: histedit.c,v 1.40 2006/10/16 00:36:19 christos Exp $"); d152 1 a158 1 el_source(el, NULL); @ 1.40 log @sprinkle volatile. @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.39 2006/05/10 21:53:14 mrg Exp $ */ d40 1 a40 1 __RCSID("$NetBSD: histedit.c,v 1.39 2006/05/10 21:53:14 mrg Exp $"); d186 1 @ 1.40.8.1 log @sync with HEAD @ text @d1 1 a1 1 /* histedit.c,v 1.40 2006/10/16 00:36:19 christos Exp */ d40 1 a40 1 __RCSID("histedit.c,v 1.40 2006/10/16 00:36:19 christos Exp"); a185 1 history(hist, &he, H_SETUNIQUE, 1); @ 1.39 log @quell GCC 4.1 uninitialised variable warnings. XXX: we should audit the tree for which old ones are no longer needed after getting the older compilers out of the tree.. @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.38 2006/03/06 00:09:22 aymeric Exp $ */ d40 1 a40 1 __RCSID("$NetBSD: histedit.c,v 1.38 2006/03/06 00:09:22 aymeric Exp $"); d228 1 a228 1 const char *editor = NULL; d230 2 a231 1 int lflg = 0, nflg = 0, rflg = 0, sflg = 0; a241 13 /* Avoid longjmp clobbering */ (void) &editor; (void) &lflg; (void) &nflg; (void) &rflg; (void) &sflg; (void) &firststr; (void) &laststr; (void) &pat; (void) &repl; (void) &efp; (void) &argc; (void) &argv; @ 1.38 log @Make the -s flag of fc work correctly. Ensure that only one command is specified and ensure that we break out of the loop after executing it. With the previous code, because the re-executed command was added to the history, it would think that it still had to execute it, leading to an infinite loop. The last thing which differs from ksh is that we get the "fc -s " command into the history, but this is actually rather a feature in my humble opinion. To test: $ echo hello $ fc -s ec @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.37 2005/07/15 17:49:43 christos Exp $ */ d40 1 a40 1 __RCSID("$NetBSD: histedit.c,v 1.37 2005/07/15 17:49:43 christos Exp $"); d254 2 @ 1.37 log @Only do certain actions when we are trully interactive, not just when we are connected to a tty: 1. enable editor 2. print directory on directory change. 3. print job messages @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.36 2005/05/09 11:35:19 christos Exp $ */ d40 1 a40 1 __RCSID("$NetBSD: histedit.c,v 1.36 2005/05/09 11:35:19 christos Exp $"); d339 7 d431 2 @ 1.36 log @Only add the function when we initialize. Restore the binding of tab to ed-insert if tabcomplete is cleared. @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.35 2005/05/07 19:52:17 dsl Exp $ */ d40 1 a40 1 __RCSID("$NetBSD: histedit.c,v 1.35 2005/05/07 19:52:17 dsl Exp $"); d91 1 a91 1 if (iflag) { @ 1.35 log @If 'set -o tabcomplete' it set, then bind to the libedit filename completion function. Note that the libedit code will probably want fine-tuning! While editing the man page, add a note that non-whitespace IFS chars are terminators and can generate null arguments. @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.34 2003/10/27 06:19:29 lukem Exp $ */ d40 1 a40 1 __RCSID("$NetBSD: histedit.c,v 1.34 2003/10/27 06:19:29 lukem Exp $"); d137 3 d156 2 a157 6 if (tabcomplete) { el_set(el, EL_ADDFN, "rl_complete", "ReadLine compatible completion function", _el_fn_complete); el_set(el, EL_BIND, "^I", "rl_complete", NULL); } @ 1.34 log @skip a leading `-' on the arg0 name when calling el_init() @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.33 2003/10/19 19:13:21 christos Exp $ */ d40 1 a40 1 __RCSID("$NetBSD: histedit.c,v 1.33 2003/10/19 19:13:21 christos Exp $"); d72 1 d153 6 @ 1.34.6.1 log @Pull up following revision(s) (requested by mjf in ticket #1689): bin/sh/histedit.c: revision 1.38 Make the -s flag of fc work correctly. Ensure that only one command is specified and ensure that we break out of the loop after executing it. With the previous code, because the re-executed command was added to the history, it would think that it still had to execute it, leading to an infinite loop. @ text @d1 1 a1 1 /* $NetBSD$ */ d40 1 a40 1 __RCSID("$NetBSD$"); a332 7 /* * If -s is specified, accept only one operand */ if (sflg && argc >= 2) error("too many args"); a417 2 break; @ 1.33 log @Let libedit handle signals so we resize properly. I might change my mind later on that. @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.32 2003/10/19 01:55:05 lukem Exp $ */ d40 1 a40 1 __RCSID("$NetBSD: histedit.c,v 1.32 2003/10/19 01:55:05 lukem Exp $"); d108 1 a108 1 char *term; d127 4 a130 1 el = el_init(arg0, el_in, el_out, el_err); @ 1.32 log @Ensure that $TERM is set in the real environment before calling el_init(3) when executing "set -o (emacs|vi)". Fixes [bin/23175] from me. @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.31 2003/08/07 09:05:32 agc Exp $ */ d40 1 a40 1 __RCSID("$NetBSD: histedit.c,v 1.31 2003/08/07 09:05:32 agc Exp $"); d132 1 @ 1.31 log @Move UCB-licensed code from 4-clause to 3-clause licence. Patches provided by Joel Baker in PR 22249, verified by myself. @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.30 2003/07/13 08:31:13 itojun Exp $ */ d40 1 a40 1 __RCSID("$NetBSD: histedit.c,v 1.30 2003/07/13 08:31:13 itojun Exp $"); d108 2 d122 5 @ 1.30 log @use bounded string op @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.29 2003/05/04 06:36:50 gmcgarry Exp $ */ d18 1 a18 5 * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors d40 1 a40 1 __RCSID("$NetBSD: histedit.c,v 1.29 2003/05/04 06:36:50 gmcgarry Exp $"); @ 1.29 log @ANSIify. @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.28 2003/05/04 01:05:24 gmcgarry Exp $ */ d44 1 a44 1 __RCSID("$NetBSD: histedit.c,v 1.28 2003/05/04 01:05:24 gmcgarry Exp $"); d370 1 a370 1 sprintf(editfile, "%s_shXXXXXX", _PATH_TMP); @ 1.28 log @Add new builtin 'inputrc' which allows keybindings to be redefined for the current shell. From Arne H Juul in PR#10097. @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.27 2002/11/24 22:35:40 christos Exp $ */ d44 1 a44 1 __RCSID("$NetBSD: histedit.c,v 1.27 2002/11/24 22:35:40 christos Exp $"); a528 2 int argc; char **argv; @ 1.27 log @Fixes from David Laight: - ansification - format of output of jobs command (etc) - job identiers %+, %- etc - $? and $(...) - correct quoting of output of set, export -p and readonly -p - differentiation between nornal and 'posix special' builtins - correct behaviour (posix) for errors on builtins and special builtins - builtin printf and kill - set -o debug (if compiled with DEBUG) - cd src obj (as ksh - too useful to do without) - unset -e name, remove non-readonly variable from export list. (so I could unset -e PS1 before running the test shell...) @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.26 2002/03/12 00:14:31 christos Exp $ */ d44 1 a44 1 __RCSID("$NetBSD: histedit.c,v 1.26 2002/03/12 00:14:31 christos Exp $"); d186 21 d523 8 @ 1.26 log @get rid of sp completely, we were free-ing a bogus pointer; found by simonb. @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.25 2001/02/04 19:52:06 christos Exp $ */ d44 1 a44 1 __RCSID("$NetBSD: histedit.c,v 1.25 2001/02/04 19:52:06 christos Exp $"); d77 5 a81 1 STATIC const char *fc_replace __P((const char *, char *, char *)); d88 1 a88 1 histedit() d90 1 d119 6 a124 1 el = el_init(arg0, el_in, el_out, el_out); d163 1 a163 2 sethistsize(hs) const char *hs; d177 1 a177 2 setterm(term) const char *term; d191 1 a191 3 histcmd(argc, argv) int argc; char **argv; d420 1 a420 3 fc_replace(s, p, r) const char *s; char *p, *r; d442 1 a442 2 not_fcnumber(s) char *s; d452 1 a452 3 str_to_event(str, last) const char *str; int last; d501 1 a501 3 histcmd(argc, argv) int argc; char **argv; @ 1.25 log @remove redundant declarations and nexted externs. @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.24 2000/11/06 04:21:14 mycroft Exp $ */ d44 1 a44 1 __RCSID("$NetBSD: histedit.c,v 1.24 2000/11/06 04:21:14 mycroft Exp $"); a369 1 char *sp; a376 1 free(sp); @ 1.24 log @Call el_source() to use .editrc. @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.23 2000/04/14 05:52:58 simonb Exp $ */ d44 1 a44 1 __RCSID("$NetBSD: histedit.c,v 1.23 2000/04/14 05:52:58 simonb Exp $"); d227 1 a227 1 editor = optarg; @ 1.23 log @Don't declare 'extern opt*' getopt variables. @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.22 2000/01/27 23:39:40 christos Exp $ */ d44 1 a44 1 __RCSID("$NetBSD: histedit.c,v 1.22 2000/01/27 23:39:40 christos Exp $"); d135 1 @ 1.22 log @Fix bin/9184, bin/9194, bin/9265, bin/9266 Exitcode and negation problems (From Martin Husemann) @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.21 1999/07/09 03:05:50 christos Exp $ */ d44 1 a44 1 __RCSID("$NetBSD: histedit.c,v 1.21 1999/07/09 03:05:50 christos Exp $"); a185 2 extern char *optarg; extern int optind, optopt, optreset; @ 1.21 log @compile with WARNS = 2 @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.20 1998/07/28 11:41:55 mycroft Exp $ */ d44 1 a44 1 __RCSID("$NetBSD: histedit.c,v 1.20 1998/07/28 11:41:55 mycroft Exp $"); d378 1 a378 1 evalstring(strcpy(stalloc(strlen(s) + 1), s)); d403 1 a403 1 evalstring(editcmd); /* XXX - should use no JC command */ @ 1.20 log @Be more retentive about use of NOTREACHED and noreturn. @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.19 1998/05/20 00:29:26 christos Exp $ */ d44 1 a44 1 __RCSID("$NetBSD: histedit.c,v 1.19 1998/05/20 00:29:26 christos Exp $"); d77 1 a77 1 STATIC char *fc_replace __P((const char *, char *, char *)); d189 1 a189 1 char *editor = NULL; d193 1 a193 1 char *firststr, *laststr; d369 3 a371 2 char *s = pat ? fc_replace(he.str, pat, repl) : (char *)he.str; d377 3 a379 1 evalstring(s); d416 1 a416 1 STATIC char * d453 1 a453 1 char *str; d457 1 a457 1 char *s = str; @ 1.19 log @fix bug where if moving in history during a multi-line event, the append to history event would end up in the last event where the history was moved to instead of the multi-line event; reported by Mycroft @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.18 1998/04/07 10:16:04 fair Exp $ */ d44 1 a44 1 __RCSID("$NetBSD: histedit.c,v 1.18 1998/04/07 10:16:04 fair Exp $"); d244 1 d248 1 d318 1 d505 1 a505 1 return 0; @ 1.18 log @Change a few things to reference /usr/include/paths.h instead of local references. Fixing the default PATH is a bit more effort. @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.17 1997/11/12 03:40:55 cjs Exp $ */ d44 1 a44 1 __RCSID("$NetBSD: histedit.c,v 1.17 1997/11/12 03:40:55 cjs Exp $"); d114 1 a114 1 el = el_init(arg0, el_in, el_out); d162 1 a162 1 history(hist, &he, H_SETMAXSIZE, histsize); @ 1.17 log @Make this compile with -DSMALL and warnings on. @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.16 1997/10/14 15:06:42 christos Exp $ */ d44 1 a44 1 __RCSID("$NetBSD: histedit.c,v 1.16 1997/10/14 15:06:42 christos Exp $"); d341 1 a341 1 sprintf(editfile, "%s/_shXXXXXX", _PATH_TMP); @ 1.16 log @PR/4257: Jaromir Dolecek: Update for libedit interface change. @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.15 1997/09/14 07:43:56 lukem Exp $ */ d44 1 a44 1 __RCSID("$NetBSD: histedit.c,v 1.15 1997/09/14 07:43:56 lukem Exp $"); a62 1 #ifndef SMALL d65 1 d502 1 @ 1.16.2.1 log @Pull rev 1.17 up from trunk (cjs) @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.17 1997/11/12 03:40:55 cjs Exp $ */ d44 1 a44 1 __RCSID("$NetBSD: histedit.c,v 1.17 1997/11/12 03:40:55 cjs Exp $"); d63 1 a65 1 #ifndef SMALL a501 1 return 0; @ 1.16.2.2 log @Sync with trunk, per request of christos. @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.16.2.1 1997/11/13 00:07:29 mellon Exp $ */ d44 1 a44 1 __RCSID("$NetBSD: histedit.c,v 1.16.2.1 1997/11/13 00:07:29 mellon Exp $"); d341 1 a341 1 sprintf(editfile, "%s_shXXXXXX", _PATH_TMP); @ 1.15 log @getopt returns -1 not EOF @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.14 1997/07/04 21:02:02 christos Exp $ */ d44 1 a44 1 __RCSID("$NetBSD: histedit.c,v 1.14 1997/07/04 21:02:02 christos Exp $"); d156 1 d162 1 a162 1 history(hist, H_EVENT, histsize); d190 1 a190 1 const HistEvent *he; d192 1 a192 1 int i; d358 3 a360 3 history(hist, H_FIRST); he = history(hist, H_NEXT_EVENT, first); for (;he != NULL; he = history(hist, direction)) { d363 2 a364 2 out1fmt("%5d ", he->num); out1str(he->str); d367 1 a367 1 fc_replace(he->str, pat, repl) : (char *)he->str; d379 1 a379 1 history(hist, H_ENTER, s); d385 1 a385 1 * At end? (if we were to loose last, we'd sure be d388 1 a388 1 if (he->num == last) d450 1 a450 1 const HistEvent *he; d453 1 a453 1 int i; d455 1 a455 1 he = history(hist, H_FIRST); d466 2 a467 2 while (he != NULL && i--) { he = history(hist, H_NEXT); d469 2 a470 2 if (he == NULL) he = history(hist, H_LAST); d472 2 a473 2 he = history(hist, H_NEXT_EVENT, i); if (he == NULL) { d478 2 a479 1 he = history(hist, last ? H_FIRST : H_LAST); d482 1 a482 1 if (he == NULL) d489 2 a490 2 he = history(hist, H_PREV_STR, str); if (he == NULL) d493 1 a493 1 return (he->num); @ 1.14 log @Fix compiler warnings. @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.13 1997/04/11 22:45:41 christos Exp $ */ d44 1 a44 1 __RCSID("$NetBSD$"); d224 1 a224 1 (ch = getopt(argc, argv, ":e:lnrs")) != EOF) @ 1.13 log @Track $TERM and call the appropriate editline(3) routine to update the terminal type. @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.12 1997/03/14 01:42:20 christos Exp $ */ d39 1 d44 1 a44 1 static char rcsid[] = "$NetBSD: histedit.c,v 1.12 1997/03/14 01:42:20 christos Exp $"; @ 1.12 log @NO_HISTORY->SMALL @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.11 1997/03/13 21:57:32 christos Exp $ */ d43 1 a43 1 static char rcsid[] = "$NetBSD: histedit.c,v 1.11 1997/03/13 21:57:32 christos Exp $"; d162 11 @ 1.11 log @Fix problems with -DNO_HISTORY @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.10 1996/10/16 14:40:32 christos Exp $ */ d43 1 a43 1 static char rcsid[] = "$NetBSD: histedit.c,v 1.10 1996/10/16 14:40:32 christos Exp $"; d62 1 a62 1 #ifndef NO_HISTORY @ 1.10 log @PR/2808: Remove extraneous newlines from error routines (from FreeBSD) @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.9 1996/06/25 16:43:34 christos Exp $ */ d43 1 a43 1 static char rcsid[] = "$NetBSD: histedit.c,v 1.9 1996/06/25 16:43:34 christos Exp $"; a63 1 #endif d481 9 @ 1.9 log @change sethistsize() to take the history size as an argument so it can be used directly by the new variable callback functions. @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.8 1995/05/11 21:29:12 christos Exp $ */ d43 1 a43 1 static char rcsid[] = "$NetBSD: histedit.c,v 1.8 1995/05/11 21:29:12 christos Exp $"; d84 1 a84 1 histedit() d158 1 a158 1 if (hs == NULL || *hs == '\0' || d207 1 a207 1 d280 1 a280 1 if (lflg == 0 && argc > 0 && d318 1 a318 1 * always increasing. Add sequence numbers or offset d334 1 a334 1 error("can't allocate stdio buffer for temp\n"); d354 1 a354 1 char *s = pat ? d364 1 a364 1 * XXX what about recursive and d390 1 a390 1 d474 1 a474 1 * pattern @ 1.8 log @Merge in my changes from vangogh, and fix the x=`false`; echo $? == 0 bug. @ text @d1 1 a1 1 /* $NetBSD$ */ d43 1 a43 1 static char rcsid[] = "$NetBSD$"; d99 1 a99 1 sethistsize(); d152 2 a153 1 sethistsize() a154 1 char *cp; d158 2 a159 3 cp = lookupvar("HISTSIZE"); if (cp == NULL || *cp == '\0' || (histsize = atoi(cp)) < 0) @ 1.8.6.1 log @Update /bin/sh from trunk per request of Christos Zoulas. Fixes many bugs. @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.10 1996/10/16 14:40:32 christos Exp $ */ d43 1 a43 1 static char rcsid[] = "$NetBSD: histedit.c,v 1.10 1996/10/16 14:40:32 christos Exp $"; d84 1 a84 1 histedit() d99 1 a99 1 sethistsize(histsizeval()); d152 1 a152 2 sethistsize(hs) const char *hs; d154 1 d158 3 a160 2 if (hs == NULL || *hs == '\0' || (histsize = atoi(hs)) < 0) d208 1 a208 1 d281 1 a281 1 if (lflg == 0 && argc > 0 && d319 1 a319 1 * always increasing. Add sequence numbers or offset d335 1 a335 1 error("can't allocate stdio buffer for temp"); d355 1 a355 1 char *s = pat ? d365 1 a365 1 * XXX what about recursive and d391 1 a391 1 d475 1 a475 1 * pattern @ 1.7 log @1. Don't core dump on 'fc -l' (From Gerard J van der Grinten) 2. PATH=xxx ls, does the PATH assignment first and then tries to find ls in xxx 3. VAR=xxx exec ls, does the variable assignment. @ text @d1 1 a1 1 /* $NetBSD: histedit.c,v 1.6 1995/03/21 09:09:09 cgd Exp $ */ d41 1 a41 1 static char sccsid[] = "@@(#)histedit.c 8.1 (Berkeley) 5/31/93"; d43 1 a43 1 static char rcsid[] = "$NetBSD: histedit.c,v 1.6 1995/03/21 09:09:09 cgd Exp $"; a46 3 /* * Editline and history functions (and glue). */ d52 3 d59 1 d62 3 a66 1 #include "histedit.h" a67 1 #include "extern.h" a77 2 int not_fcnumber __P((char *)); int str_to_event __P((char *, int)); d152 2 a153 1 sethistsize() { d173 1 a173 1 char *argv[]; d190 15 d396 1 @ 1.6 log @convert to new RCS id conventions. @ text @d1 1 a1 1 /* $NetBSD$ */ d43 1 a43 1 static char rcsid[] = "$NetBSD$"; d410 2 @ 1.5 log @clean up further. more patches from Jim Jegers @ text @d1 2 d40 5 a44 2 /*static char sccsid[] = "from: @@(#)histedit.c 8.1 (Berkeley) 5/31/93";*/ static char *rcsid = "$Id: histedit.c,v 1.4 1994/12/04 07:12:13 cgd Exp $"; @ 1.4 log @from James Jegers : quiet -Wall, and squelch some of the worst style errors. @ text @d39 1 a39 1 static char *rcsid = "$Id: histedit.c,v 1.3 1994/06/11 16:11:57 mycroft Exp $"; d57 1 d78 1 @ 1.3 log @Add RCS ids. @ text @d39 1 a39 1 static char *rcsid = "$Id: $"; d54 1 d59 1 d70 2 d77 2 a78 1 histedit() { d143 2 d162 1 d164 1 d399 1 d408 1 d416 1 a416 1 int i, j; @ 1.2 log @Include appropriate header files to bring function prototypes into scope. @ text @d38 2 a39 1 static char sccsid[] = "@@(#)histedit.c 8.1 (Berkeley) 5/31/93"; @ 1.1 log @Initial revision @ text @d47 2 @ 1.1.1.1 log @44lite code @ text @@