summaryrefslogtreecommitdiffstats
path: root/contrib/tcsh
diff options
context:
space:
mode:
authormp <mp@FreeBSD.org>2007-03-11 22:33:41 +0000
committermp <mp@FreeBSD.org>2007-03-11 22:33:41 +0000
commitc77fb6f45fa6f27fca46baa53d66769e9246d705 (patch)
tree102975964ca1ed8ab7109b00012a7dd3ceb5932f /contrib/tcsh
parent176735320e11768e9f5b034525cd406666c745a6 (diff)
parenta40980339b13e3b506c2317b5b4864127039eb2c (diff)
downloadFreeBSD-src-c77fb6f45fa6f27fca46baa53d66769e9246d705.zip
FreeBSD-src-c77fb6f45fa6f27fca46baa53d66769e9246d705.tar.gz
This commit was generated by cvs2svn to compensate for changes in r167465,
which included commits to RCS files with non-trunk default branches.
Diffstat (limited to 'contrib/tcsh')
-rw-r--r--contrib/tcsh/Fixes99
-rw-r--r--contrib/tcsh/Imakefile2
-rwxr-xr-xcontrib/tcsh/MAKEDIFFS2
-rwxr-xr-xcontrib/tcsh/MAKESHAR2
-rw-r--r--contrib/tcsh/Makefile.in116
-rw-r--r--contrib/tcsh/Makefile.std2
-rw-r--r--contrib/tcsh/Makefile.vms2
-rw-r--r--contrib/tcsh/README32
-rw-r--r--contrib/tcsh/complete.tcsh2
-rw-r--r--contrib/tcsh/config.h.in48
-rw-r--r--contrib/tcsh/config/bsd4.415
-rw-r--r--contrib/tcsh/config_f.h18
-rwxr-xr-xcontrib/tcsh/configure1753
-rw-r--r--contrib/tcsh/configure.in62
-rw-r--r--contrib/tcsh/ed.chared.c1101
-rw-r--r--contrib/tcsh/ed.decls.h395
-rw-r--r--contrib/tcsh/ed.defns.c42
-rw-r--r--contrib/tcsh/ed.h58
-rw-r--r--contrib/tcsh/ed.init.c122
-rw-r--r--contrib/tcsh/ed.inputl.c218
-rw-r--r--contrib/tcsh/ed.refresh.c209
-rw-r--r--contrib/tcsh/ed.screen.c496
-rw-r--r--contrib/tcsh/ed.term.c92
-rw-r--r--contrib/tcsh/ed.term.h2
-rw-r--r--contrib/tcsh/ed.xmap.c311
-rw-r--r--contrib/tcsh/eight-bit.me2
-rw-r--r--contrib/tcsh/gethost.c21
-rw-r--r--contrib/tcsh/glob.c360
-rw-r--r--contrib/tcsh/glob.h20
-rw-r--r--contrib/tcsh/host.defs16
-rw-r--r--contrib/tcsh/imake.config2
-rw-r--r--contrib/tcsh/ma.setp.c108
-rw-r--r--contrib/tcsh/mi.termios.c4
-rw-r--r--contrib/tcsh/mi.varargs.h2
-rw-r--r--contrib/tcsh/nls/C/set12
-rw-r--r--contrib/tcsh/nls/C/set102
-rw-r--r--contrib/tcsh/nls/C/set112
-rw-r--r--contrib/tcsh/nls/C/set122
-rw-r--r--contrib/tcsh/nls/C/set132
-rw-r--r--contrib/tcsh/nls/C/set142
-rw-r--r--contrib/tcsh/nls/C/set152
-rw-r--r--contrib/tcsh/nls/C/set162
-rw-r--r--contrib/tcsh/nls/C/set172
-rw-r--r--contrib/tcsh/nls/C/set182
-rw-r--r--contrib/tcsh/nls/C/set192
-rw-r--r--contrib/tcsh/nls/C/set22
-rw-r--r--contrib/tcsh/nls/C/set202
-rw-r--r--contrib/tcsh/nls/C/set212
-rw-r--r--contrib/tcsh/nls/C/set222
-rw-r--r--contrib/tcsh/nls/C/set232
-rw-r--r--contrib/tcsh/nls/C/set242
-rw-r--r--contrib/tcsh/nls/C/set252
-rw-r--r--contrib/tcsh/nls/C/set262
-rw-r--r--contrib/tcsh/nls/C/set272
-rw-r--r--contrib/tcsh/nls/C/set292
-rw-r--r--contrib/tcsh/nls/C/set34
-rw-r--r--contrib/tcsh/nls/C/set302
-rw-r--r--contrib/tcsh/nls/C/set312
-rw-r--r--contrib/tcsh/nls/C/set42
-rw-r--r--contrib/tcsh/nls/C/set52
-rw-r--r--contrib/tcsh/nls/C/set62
-rw-r--r--contrib/tcsh/nls/C/set72
-rw-r--r--contrib/tcsh/nls/C/set82
-rw-r--r--contrib/tcsh/nls/C/set92
-rw-r--r--contrib/tcsh/nls/Makefile3
-rw-r--r--contrib/tcsh/nls/et/set12
-rw-r--r--contrib/tcsh/nls/et/set102
-rw-r--r--contrib/tcsh/nls/et/set112
-rw-r--r--contrib/tcsh/nls/et/set122
-rw-r--r--contrib/tcsh/nls/et/set132
-rw-r--r--contrib/tcsh/nls/et/set142
-rw-r--r--contrib/tcsh/nls/et/set152
-rw-r--r--contrib/tcsh/nls/et/set162
-rw-r--r--contrib/tcsh/nls/et/set172
-rw-r--r--contrib/tcsh/nls/et/set182
-rw-r--r--contrib/tcsh/nls/et/set192
-rw-r--r--contrib/tcsh/nls/et/set22
-rw-r--r--contrib/tcsh/nls/et/set202
-rw-r--r--contrib/tcsh/nls/et/set212
-rw-r--r--contrib/tcsh/nls/et/set222
-rw-r--r--contrib/tcsh/nls/et/set232
-rw-r--r--contrib/tcsh/nls/et/set242
-rw-r--r--contrib/tcsh/nls/et/set252
-rw-r--r--contrib/tcsh/nls/et/set262
-rw-r--r--contrib/tcsh/nls/et/set272
-rw-r--r--contrib/tcsh/nls/et/set292
-rw-r--r--contrib/tcsh/nls/et/set32
-rw-r--r--contrib/tcsh/nls/et/set302
-rw-r--r--contrib/tcsh/nls/et/set312
-rw-r--r--contrib/tcsh/nls/et/set42
-rw-r--r--contrib/tcsh/nls/et/set52
-rw-r--r--contrib/tcsh/nls/et/set62
-rw-r--r--contrib/tcsh/nls/et/set72
-rw-r--r--contrib/tcsh/nls/et/set82
-rw-r--r--contrib/tcsh/nls/et/set92
-rw-r--r--contrib/tcsh/nls/finnish/set12
-rw-r--r--contrib/tcsh/nls/finnish/set102
-rw-r--r--contrib/tcsh/nls/finnish/set112
-rw-r--r--contrib/tcsh/nls/finnish/set122
-rw-r--r--contrib/tcsh/nls/finnish/set132
-rw-r--r--contrib/tcsh/nls/finnish/set142
-rw-r--r--contrib/tcsh/nls/finnish/set152
-rw-r--r--contrib/tcsh/nls/finnish/set162
-rw-r--r--contrib/tcsh/nls/finnish/set172
-rw-r--r--contrib/tcsh/nls/finnish/set182
-rw-r--r--contrib/tcsh/nls/finnish/set192
-rw-r--r--contrib/tcsh/nls/finnish/set22
-rw-r--r--contrib/tcsh/nls/finnish/set202
-rw-r--r--contrib/tcsh/nls/finnish/set212
-rw-r--r--contrib/tcsh/nls/finnish/set222
-rw-r--r--contrib/tcsh/nls/finnish/set232
-rw-r--r--contrib/tcsh/nls/finnish/set242
-rw-r--r--contrib/tcsh/nls/finnish/set252
-rw-r--r--contrib/tcsh/nls/finnish/set262
-rw-r--r--contrib/tcsh/nls/finnish/set272
-rw-r--r--contrib/tcsh/nls/finnish/set292
-rw-r--r--contrib/tcsh/nls/finnish/set32
-rw-r--r--contrib/tcsh/nls/finnish/set302
-rw-r--r--contrib/tcsh/nls/finnish/set312
-rw-r--r--contrib/tcsh/nls/finnish/set42
-rw-r--r--contrib/tcsh/nls/finnish/set52
-rw-r--r--contrib/tcsh/nls/finnish/set62
-rw-r--r--contrib/tcsh/nls/finnish/set72
-rw-r--r--contrib/tcsh/nls/finnish/set82
-rw-r--r--contrib/tcsh/nls/finnish/set92
-rw-r--r--contrib/tcsh/nls/french/set12
-rw-r--r--contrib/tcsh/nls/french/set102
-rw-r--r--contrib/tcsh/nls/french/set112
-rw-r--r--contrib/tcsh/nls/french/set122
-rw-r--r--contrib/tcsh/nls/french/set132
-rw-r--r--contrib/tcsh/nls/french/set142
-rw-r--r--contrib/tcsh/nls/french/set152
-rw-r--r--contrib/tcsh/nls/french/set162
-rw-r--r--contrib/tcsh/nls/french/set172
-rw-r--r--contrib/tcsh/nls/french/set182
-rw-r--r--contrib/tcsh/nls/french/set192
-rw-r--r--contrib/tcsh/nls/french/set22
-rw-r--r--contrib/tcsh/nls/french/set202
-rw-r--r--contrib/tcsh/nls/french/set212
-rw-r--r--contrib/tcsh/nls/french/set222
-rw-r--r--contrib/tcsh/nls/french/set232
-rw-r--r--contrib/tcsh/nls/french/set242
-rw-r--r--contrib/tcsh/nls/french/set252
-rw-r--r--contrib/tcsh/nls/french/set262
-rw-r--r--contrib/tcsh/nls/french/set272
-rw-r--r--contrib/tcsh/nls/french/set292
-rw-r--r--contrib/tcsh/nls/french/set32
-rw-r--r--contrib/tcsh/nls/french/set302
-rw-r--r--contrib/tcsh/nls/french/set312
-rw-r--r--contrib/tcsh/nls/french/set42
-rw-r--r--contrib/tcsh/nls/french/set52
-rw-r--r--contrib/tcsh/nls/french/set62
-rw-r--r--contrib/tcsh/nls/french/set72
-rw-r--r--contrib/tcsh/nls/french/set82
-rw-r--r--contrib/tcsh/nls/french/set92
-rw-r--r--contrib/tcsh/nls/german/set12
-rw-r--r--contrib/tcsh/nls/german/set102
-rw-r--r--contrib/tcsh/nls/german/set112
-rw-r--r--contrib/tcsh/nls/german/set122
-rw-r--r--contrib/tcsh/nls/german/set132
-rw-r--r--contrib/tcsh/nls/german/set142
-rw-r--r--contrib/tcsh/nls/german/set152
-rw-r--r--contrib/tcsh/nls/german/set162
-rw-r--r--contrib/tcsh/nls/german/set172
-rw-r--r--contrib/tcsh/nls/german/set182
-rw-r--r--contrib/tcsh/nls/german/set192
-rw-r--r--contrib/tcsh/nls/german/set22
-rw-r--r--contrib/tcsh/nls/german/set202
-rw-r--r--contrib/tcsh/nls/german/set212
-rw-r--r--contrib/tcsh/nls/german/set222
-rw-r--r--contrib/tcsh/nls/german/set232
-rw-r--r--contrib/tcsh/nls/german/set242
-rw-r--r--contrib/tcsh/nls/german/set252
-rw-r--r--contrib/tcsh/nls/german/set262
-rw-r--r--contrib/tcsh/nls/german/set272
-rw-r--r--contrib/tcsh/nls/german/set292
-rw-r--r--contrib/tcsh/nls/german/set32
-rw-r--r--contrib/tcsh/nls/german/set302
-rw-r--r--contrib/tcsh/nls/german/set312
-rw-r--r--contrib/tcsh/nls/german/set42
-rw-r--r--contrib/tcsh/nls/german/set52
-rw-r--r--contrib/tcsh/nls/german/set62
-rw-r--r--contrib/tcsh/nls/german/set72
-rw-r--r--contrib/tcsh/nls/german/set82
-rw-r--r--contrib/tcsh/nls/german/set92
-rw-r--r--contrib/tcsh/nls/greek/set12
-rw-r--r--contrib/tcsh/nls/greek/set102
-rw-r--r--contrib/tcsh/nls/greek/set112
-rw-r--r--contrib/tcsh/nls/greek/set122
-rw-r--r--contrib/tcsh/nls/greek/set132
-rw-r--r--contrib/tcsh/nls/greek/set142
-rw-r--r--contrib/tcsh/nls/greek/set152
-rw-r--r--contrib/tcsh/nls/greek/set162
-rw-r--r--contrib/tcsh/nls/greek/set172
-rw-r--r--contrib/tcsh/nls/greek/set182
-rw-r--r--contrib/tcsh/nls/greek/set192
-rw-r--r--contrib/tcsh/nls/greek/set22
-rw-r--r--contrib/tcsh/nls/greek/set202
-rw-r--r--contrib/tcsh/nls/greek/set212
-rw-r--r--contrib/tcsh/nls/greek/set222
-rw-r--r--contrib/tcsh/nls/greek/set232
-rw-r--r--contrib/tcsh/nls/greek/set242
-rw-r--r--contrib/tcsh/nls/greek/set252
-rw-r--r--contrib/tcsh/nls/greek/set262
-rw-r--r--contrib/tcsh/nls/greek/set272
-rw-r--r--contrib/tcsh/nls/greek/set292
-rw-r--r--contrib/tcsh/nls/greek/set32
-rw-r--r--contrib/tcsh/nls/greek/set302
-rw-r--r--contrib/tcsh/nls/greek/set312
-rw-r--r--contrib/tcsh/nls/greek/set42
-rw-r--r--contrib/tcsh/nls/greek/set52
-rw-r--r--contrib/tcsh/nls/greek/set62
-rw-r--r--contrib/tcsh/nls/greek/set72
-rw-r--r--contrib/tcsh/nls/greek/set82
-rw-r--r--contrib/tcsh/nls/greek/set92
-rw-r--r--contrib/tcsh/nls/italian/set12
-rw-r--r--contrib/tcsh/nls/italian/set102
-rw-r--r--contrib/tcsh/nls/italian/set112
-rw-r--r--contrib/tcsh/nls/italian/set122
-rw-r--r--contrib/tcsh/nls/italian/set132
-rw-r--r--contrib/tcsh/nls/italian/set142
-rw-r--r--contrib/tcsh/nls/italian/set152
-rw-r--r--contrib/tcsh/nls/italian/set162
-rw-r--r--contrib/tcsh/nls/italian/set172
-rw-r--r--contrib/tcsh/nls/italian/set182
-rw-r--r--contrib/tcsh/nls/italian/set192
-rw-r--r--contrib/tcsh/nls/italian/set22
-rw-r--r--contrib/tcsh/nls/italian/set202
-rw-r--r--contrib/tcsh/nls/italian/set212
-rw-r--r--contrib/tcsh/nls/italian/set222
-rw-r--r--contrib/tcsh/nls/italian/set232
-rw-r--r--contrib/tcsh/nls/italian/set242
-rw-r--r--contrib/tcsh/nls/italian/set252
-rw-r--r--contrib/tcsh/nls/italian/set262
-rw-r--r--contrib/tcsh/nls/italian/set272
-rw-r--r--contrib/tcsh/nls/italian/set292
-rw-r--r--contrib/tcsh/nls/italian/set32
-rw-r--r--contrib/tcsh/nls/italian/set302
-rw-r--r--contrib/tcsh/nls/italian/set312
-rw-r--r--contrib/tcsh/nls/italian/set42
-rw-r--r--contrib/tcsh/nls/italian/set52
-rw-r--r--contrib/tcsh/nls/italian/set62
-rw-r--r--contrib/tcsh/nls/italian/set72
-rw-r--r--contrib/tcsh/nls/italian/set82
-rw-r--r--contrib/tcsh/nls/italian/set92
-rw-r--r--contrib/tcsh/nls/ja/set12
-rw-r--r--contrib/tcsh/nls/ja/set102
-rw-r--r--contrib/tcsh/nls/ja/set112
-rw-r--r--contrib/tcsh/nls/ja/set122
-rw-r--r--contrib/tcsh/nls/ja/set132
-rw-r--r--contrib/tcsh/nls/ja/set152
-rw-r--r--contrib/tcsh/nls/ja/set162
-rw-r--r--contrib/tcsh/nls/ja/set172
-rw-r--r--contrib/tcsh/nls/ja/set182
-rw-r--r--contrib/tcsh/nls/ja/set22
-rw-r--r--contrib/tcsh/nls/ja/set212
-rw-r--r--contrib/tcsh/nls/ja/set242
-rw-r--r--contrib/tcsh/nls/ja/set292
-rw-r--r--contrib/tcsh/nls/ja/set32
-rw-r--r--contrib/tcsh/nls/ja/set302
-rw-r--r--contrib/tcsh/nls/ja/set420
-rw-r--r--contrib/tcsh/nls/ja/set52
-rw-r--r--contrib/tcsh/nls/ja/set62
-rw-r--r--contrib/tcsh/nls/ja/set72
-rw-r--r--contrib/tcsh/nls/ja/set82
-rw-r--r--contrib/tcsh/nls/pl/set12
-rw-r--r--contrib/tcsh/nls/pl/set102
-rw-r--r--contrib/tcsh/nls/pl/set112
-rw-r--r--contrib/tcsh/nls/pl/set122
-rw-r--r--contrib/tcsh/nls/pl/set132
-rw-r--r--contrib/tcsh/nls/pl/set142
-rw-r--r--contrib/tcsh/nls/pl/set152
-rw-r--r--contrib/tcsh/nls/pl/set162
-rw-r--r--contrib/tcsh/nls/pl/set172
-rw-r--r--contrib/tcsh/nls/pl/set182
-rw-r--r--contrib/tcsh/nls/pl/set192
-rw-r--r--contrib/tcsh/nls/pl/set22
-rw-r--r--contrib/tcsh/nls/pl/set202
-rw-r--r--contrib/tcsh/nls/pl/set212
-rw-r--r--contrib/tcsh/nls/pl/set222
-rw-r--r--contrib/tcsh/nls/pl/set232
-rw-r--r--contrib/tcsh/nls/pl/set242
-rw-r--r--contrib/tcsh/nls/pl/set252
-rw-r--r--contrib/tcsh/nls/pl/set262
-rw-r--r--contrib/tcsh/nls/pl/set272
-rw-r--r--contrib/tcsh/nls/pl/set292
-rw-r--r--contrib/tcsh/nls/pl/set32
-rw-r--r--contrib/tcsh/nls/pl/set302
-rw-r--r--contrib/tcsh/nls/pl/set312
-rw-r--r--contrib/tcsh/nls/pl/set42
-rw-r--r--contrib/tcsh/nls/pl/set52
-rw-r--r--contrib/tcsh/nls/pl/set62
-rw-r--r--contrib/tcsh/nls/pl/set72
-rw-r--r--contrib/tcsh/nls/pl/set82
-rw-r--r--contrib/tcsh/nls/pl/set92
-rw-r--r--contrib/tcsh/nls/russian/set12
-rw-r--r--contrib/tcsh/nls/russian/set102
-rw-r--r--contrib/tcsh/nls/russian/set112
-rw-r--r--contrib/tcsh/nls/russian/set122
-rw-r--r--contrib/tcsh/nls/russian/set132
-rw-r--r--contrib/tcsh/nls/russian/set142
-rw-r--r--contrib/tcsh/nls/russian/set152
-rw-r--r--contrib/tcsh/nls/russian/set162
-rw-r--r--contrib/tcsh/nls/russian/set172
-rw-r--r--contrib/tcsh/nls/russian/set182
-rw-r--r--contrib/tcsh/nls/russian/set192
-rw-r--r--contrib/tcsh/nls/russian/set22
-rw-r--r--contrib/tcsh/nls/russian/set202
-rw-r--r--contrib/tcsh/nls/russian/set212
-rw-r--r--contrib/tcsh/nls/russian/set222
-rw-r--r--contrib/tcsh/nls/russian/set232
-rw-r--r--contrib/tcsh/nls/russian/set242
-rw-r--r--contrib/tcsh/nls/russian/set252
-rw-r--r--contrib/tcsh/nls/russian/set262
-rw-r--r--contrib/tcsh/nls/russian/set272
-rw-r--r--contrib/tcsh/nls/russian/set292
-rw-r--r--contrib/tcsh/nls/russian/set32
-rw-r--r--contrib/tcsh/nls/russian/set302
-rw-r--r--contrib/tcsh/nls/russian/set312
-rw-r--r--contrib/tcsh/nls/russian/set42
-rw-r--r--contrib/tcsh/nls/russian/set52
-rw-r--r--contrib/tcsh/nls/russian/set62
-rw-r--r--contrib/tcsh/nls/russian/set72
-rw-r--r--contrib/tcsh/nls/russian/set82
-rw-r--r--contrib/tcsh/nls/russian/set92
-rw-r--r--contrib/tcsh/nls/spanish/set12
-rw-r--r--contrib/tcsh/nls/spanish/set102
-rw-r--r--contrib/tcsh/nls/spanish/set112
-rw-r--r--contrib/tcsh/nls/spanish/set122
-rw-r--r--contrib/tcsh/nls/spanish/set132
-rw-r--r--contrib/tcsh/nls/spanish/set142
-rw-r--r--contrib/tcsh/nls/spanish/set152
-rw-r--r--contrib/tcsh/nls/spanish/set162
-rw-r--r--contrib/tcsh/nls/spanish/set172
-rw-r--r--contrib/tcsh/nls/spanish/set182
-rw-r--r--contrib/tcsh/nls/spanish/set192
-rw-r--r--contrib/tcsh/nls/spanish/set22
-rw-r--r--contrib/tcsh/nls/spanish/set202
-rw-r--r--contrib/tcsh/nls/spanish/set212
-rw-r--r--contrib/tcsh/nls/spanish/set222
-rw-r--r--contrib/tcsh/nls/spanish/set232
-rw-r--r--contrib/tcsh/nls/spanish/set242
-rw-r--r--contrib/tcsh/nls/spanish/set252
-rw-r--r--contrib/tcsh/nls/spanish/set262
-rw-r--r--contrib/tcsh/nls/spanish/set272
-rw-r--r--contrib/tcsh/nls/spanish/set292
-rw-r--r--contrib/tcsh/nls/spanish/set32
-rw-r--r--contrib/tcsh/nls/spanish/set302
-rw-r--r--contrib/tcsh/nls/spanish/set312
-rw-r--r--contrib/tcsh/nls/spanish/set42
-rw-r--r--contrib/tcsh/nls/spanish/set52
-rw-r--r--contrib/tcsh/nls/spanish/set62
-rw-r--r--contrib/tcsh/nls/spanish/set72
-rw-r--r--contrib/tcsh/nls/spanish/set82
-rw-r--r--contrib/tcsh/nls/spanish/set92
-rw-r--r--contrib/tcsh/nls/ukrainian/set12
-rw-r--r--contrib/tcsh/nls/ukrainian/set102
-rw-r--r--contrib/tcsh/nls/ukrainian/set112
-rw-r--r--contrib/tcsh/nls/ukrainian/set122
-rw-r--r--contrib/tcsh/nls/ukrainian/set132
-rw-r--r--contrib/tcsh/nls/ukrainian/set142
-rw-r--r--contrib/tcsh/nls/ukrainian/set152
-rw-r--r--contrib/tcsh/nls/ukrainian/set162
-rw-r--r--contrib/tcsh/nls/ukrainian/set172
-rw-r--r--contrib/tcsh/nls/ukrainian/set182
-rw-r--r--contrib/tcsh/nls/ukrainian/set192
-rw-r--r--contrib/tcsh/nls/ukrainian/set22
-rw-r--r--contrib/tcsh/nls/ukrainian/set202
-rw-r--r--contrib/tcsh/nls/ukrainian/set212
-rw-r--r--contrib/tcsh/nls/ukrainian/set222
-rw-r--r--contrib/tcsh/nls/ukrainian/set232
-rw-r--r--contrib/tcsh/nls/ukrainian/set242
-rw-r--r--contrib/tcsh/nls/ukrainian/set252
-rw-r--r--contrib/tcsh/nls/ukrainian/set262
-rw-r--r--contrib/tcsh/nls/ukrainian/set272
-rw-r--r--contrib/tcsh/nls/ukrainian/set292
-rw-r--r--contrib/tcsh/nls/ukrainian/set32
-rw-r--r--contrib/tcsh/nls/ukrainian/set302
-rw-r--r--contrib/tcsh/nls/ukrainian/set312
-rw-r--r--contrib/tcsh/nls/ukrainian/set42
-rw-r--r--contrib/tcsh/nls/ukrainian/set52
-rw-r--r--contrib/tcsh/nls/ukrainian/set62
-rw-r--r--contrib/tcsh/nls/ukrainian/set72
-rw-r--r--contrib/tcsh/nls/ukrainian/set82
-rw-r--r--contrib/tcsh/nls/ukrainian/set92
-rw-r--r--contrib/tcsh/patchlevel.h6
-rw-r--r--contrib/tcsh/pathnames.h2
-rw-r--r--contrib/tcsh/sh.c759
-rw-r--r--contrib/tcsh/sh.char.c4
-rw-r--r--contrib/tcsh/sh.char.h61
-rw-r--r--contrib/tcsh/sh.decls.h520
-rw-r--r--contrib/tcsh/sh.dir.c626
-rw-r--r--contrib/tcsh/sh.dir.h2
-rw-r--r--contrib/tcsh/sh.dol.c698
-rw-r--r--contrib/tcsh/sh.err.c233
-rw-r--r--contrib/tcsh/sh.exec.c442
-rw-r--r--contrib/tcsh/sh.exp.c282
-rw-r--r--contrib/tcsh/sh.file.c408
-rw-r--r--contrib/tcsh/sh.func.c944
-rw-r--r--contrib/tcsh/sh.glob.c693
-rw-r--r--contrib/tcsh/sh.h234
-rw-r--r--contrib/tcsh/sh.hist.c185
-rw-r--r--contrib/tcsh/sh.init.c37
-rw-r--r--contrib/tcsh/sh.lex.c707
-rw-r--r--contrib/tcsh/sh.misc.c409
-rw-r--r--contrib/tcsh/sh.parse.c206
-rw-r--r--contrib/tcsh/sh.print.c77
-rw-r--r--contrib/tcsh/sh.proc.c667
-rw-r--r--contrib/tcsh/sh.proc.h7
-rw-r--r--contrib/tcsh/sh.sem.c312
-rw-r--r--contrib/tcsh/sh.set.c342
-rw-r--r--contrib/tcsh/sh.time.c74
-rw-r--r--contrib/tcsh/sh.types.h29
-rw-r--r--contrib/tcsh/snames.h2
-rw-r--r--contrib/tcsh/tc.alloc.c145
-rw-r--r--contrib/tcsh/tc.bind.c757
-rw-r--r--contrib/tcsh/tc.const.c10
-rw-r--r--contrib/tcsh/tc.decls.h327
-rw-r--r--contrib/tcsh/tc.disc.c10
-rw-r--r--contrib/tcsh/tc.func.c1055
-rw-r--r--contrib/tcsh/tc.h33
-rw-r--r--contrib/tcsh/tc.nls.c257
-rw-r--r--contrib/tcsh/tc.nls.h53
-rw-r--r--contrib/tcsh/tc.os.c481
-rw-r--r--contrib/tcsh/tc.os.h79
-rw-r--r--contrib/tcsh/tc.printf.c171
-rw-r--r--contrib/tcsh/tc.prompt.c410
-rw-r--r--contrib/tcsh/tc.sched.c110
-rw-r--r--contrib/tcsh/tc.sig.c407
-rw-r--r--contrib/tcsh/tc.sig.h171
-rw-r--r--contrib/tcsh/tc.str.c315
-rw-r--r--contrib/tcsh/tc.vers.c27
-rw-r--r--contrib/tcsh/tc.wait.h2
-rw-r--r--contrib/tcsh/tc.who.c160
-rw-r--r--contrib/tcsh/tcsh.man69
-rw-r--r--contrib/tcsh/tcsh.man2html2
-rw-r--r--contrib/tcsh/termcap.vms2
-rw-r--r--contrib/tcsh/tw.color.c94
-rw-r--r--contrib/tcsh/tw.comp.c212
-rw-r--r--contrib/tcsh/tw.decls.h130
-rw-r--r--contrib/tcsh/tw.h4
-rw-r--r--contrib/tcsh/tw.help.c115
-rw-r--r--contrib/tcsh/tw.init.c472
-rw-r--r--contrib/tcsh/tw.parse.c1274
-rw-r--r--contrib/tcsh/tw.spell.c82
-rw-r--r--contrib/tcsh/vms.termcap.c35
446 files changed, 10718 insertions, 12180 deletions
diff --git a/contrib/tcsh/Fixes b/contrib/tcsh/Fixes
index 384c329..7da8ac9 100644
--- a/contrib/tcsh/Fixes
+++ b/contrib/tcsh/Fixes
@@ -1,3 +1,102 @@
+ 74. V6.15.00 - 20070303
+ 73. fix extension eating windows code (christos)
+ 72. fix loop in %R history expansion (christos)
+ 71. sched +X source file disables interrupts (Mike Sullivan)
+ 70. One off copying macro buffers (Jean-Luc Leger)
+ 69. Avoid infinite loops in :ga modifiers when the LHS is a substring of the
+ RHS.
+ 68. Automatically disable WIDE_STRINGS with --disable-nls (Miloslav Trmac)
+ 67. V6.14.07 - 20060825
+ 66. rename set to setv to avoid clashes (christos)
+ 65. Eliminate sighold/sigrelse (christos)
+ 64. Compilation cleanups. (Martin Kraemer)
+ 63. Don't rebuild needlessly when generated files are unchanged
+ (Martin Kraemer)
+ 62. Fix confusion between Char and eChar (Martin Kraemer)
+ 61. V6.14.06 - 20060824
+ 60. set PROGRAM_ENVIRONMENT for OSD_POSIX (Martin Kraemer)
+ 59. EBCDIC patch (Martin Kraemer)
+ 58. Remove globbing support in history rearches (Ryan Barrett)
+ 57. Highlighting patch (Ryan Barrett)
+ 56. Mark-Cursor exchange emacs editing fix (Martin Kraemer)
+ 55. V6.14.05 - 20060304
+ 54. don't limit termcap strings to 1K (Alan Ferrency)
+ 53. protect against null path.
+ 52. Be more conservative in wide_read PR#29
+ 51. remove HAVE_STRCOLL; not needed anymore (Miloslav Trmac)
+ 50. remove imake support and make nls configurable by configure
+ (Miloslav Trmac)
+ 49. V6.14.04 - 20060214
+ 48. Fixes build failure with !SHORT_STRINGS (Miloslav Trmac)
+ 47. Fixes constness warnings with !SHORT_STRINGS: short2str is "strip()",
+ which modifies its argument. Rather than verify this is safe in all
+ callers, I have added caching_strip() to mirror the behavior of other
+ modes. (Miloslav Trmac)
+ 46. Fixes some constness warnings with SHORT_STRINGS; this is orthogonal
+ to both build errors with SHORT_STRINGS in 6.14.03, and
+ short_strings.patch. (Miloslav Trmac)
+ 45. config-catalogs.patch: Autodetect catalog support (#14). (Miloslav Trmac)
+ 44. auth.patch: Handle false positives in getauthid() detection,
+ IIRC on FreeBSD. (Miloslav Trmac)
+ 43. crypt.patch: Autodetect whether <crypt.h> is available. (Miloslav Trmac)
+ 42. sigint.patch: Block SIGINT while waiting on children.
+ This is necessary, but I'll still have to look on the older
+ releases to find out why it was not necessary before
+ ("before" = 6.13 on Linux). (Miloslav Trmac)
+ 41. config-package.patch: Readd package version to configure.in,
+ the testsuite uses it.
+ (TODO: a better integration with package.h) (Miloslav Trmac)
+ 40. item_len.patch: Truncate item.len when truncating the string,
+ just to be sure. (Miloslav Trmac)
+ 39. va_list.patch: Add missing va_end(). (Miloslav Trmac)
+ 38. Use va_copy in xvasprintf(); emulate va_copy as suggested in
+ Autoconf manual if it is not available. (Miloslav Trmac)
+ 37. declarations.patch: Replace some #ifdef nests by autodetecting
+ whether the guarded declaration is necessary.
+ I'm only guessing this is the intent of the #ifdefs, though.
+ Declare environ unconditionally, it is a bit hard to detect
+ and the declaration is correct for Linux, anyway. (Miloslav Trmac)
+ 36. warning.patch: Fix a const warning.
+ 35. More color-ls variables (Jean-Luc Leger)
+ 34. V6.14.03 - 20060212
+ 33. Signal related changes (Miloslav Trmac)
+ 32. Misc cast cleanups and code clarification (Miloslav Trmac)
+ 31. Use dynamically allocated buffers everywhere (Miloslav Trmac)
+ 30. Fix reading of invalid byte sequences (Miloslav Trmac)
+ 29. read should only increment count when it succeeds (Miloslav Trmac)
+ 28. testsuiteadditions (Miloslav Trmac)
+ 27. -n fixes (Miloslav Trmac)
+ 26. signness warnings (Miloslav Trmac)
+ 25. Prevent infinite recursion in catclose (Gerhard Niklasch)
+ 24. Add Dragonfly (Joerg Sonnenberger)
+ 23. Check for wcwidth returning a negative number (TOMITA Yoshinori)
+ 22. recognize "li" and "co" in echotc (Martin Kraemer) [PR/7]
+ 21. Don't use T_Cols for wrapping purposes; use TermH consistently
+ (Martin Kraemer) [PR/8]
+ 20. Don't display duplicate utmp records (Miloslav Trmac) [PR/17]
+ 19. Clarify hashing and -f sections of man page (Volker Quetschke) [PR/20]
+ 18. Dave Yearke: configure did not recognize solaris 10 [PR/18]
+ 17. CYGWIN: Don't lowercase commands and allow foo.exe on command line.
+ (Corinna Vinschen) [PR/19]
+ 16. CYGWIN: cd /foo && cd .. ends up erroneously in // for systems that
+ HAVE_SLASHSLASH [PR/21]
+ 15. %j was broken (Peter Kruse)
+ 14. Extend // handling in pathnames from being apollo specific to also
+ cygwin (Corinna Vinschen)
+ 13. Fix uppercase/lowercase transformations (Jean-Luc Leger)
+ 12. Fix symlink expansion (revert from 6.10.00) (Jean-Luc Leger and Christos)
+ 11. Fix literal sequence in prompt (Miloslav Trmac)
+ 10. V6.14.02 - 20050412
+ 9. Prototype fixes (Miloslav Trmac and Jean-Luc Leger)
+ 8. V6.14.01 - 20050411
+ 7. Make =- refer to $owd (H.Merijn Brand)
+ 6. Use prototypes (almost) everywhere (Miloslav Trmac) (issue #5)
+ 5. Fix doc path in Cygwin installation (Corinna Vinschen)
+ 4. Fix column size calculation (Martin Kraemer)
+ 3. Implement newline-and-hold and newline-and-down-history (Per Hedeland)
+ 2. Messages fixes for the ja (Japanese) locale (NAKAMURA Takeshi) (issue #4)
+ 1. Enable charset conversion in nls (Miloslav Trmac) (issue #3)
+
76. V6.14.00 - 20050325
75. Additional messages for the ja (Japanese) locale (NAKAMURA Takeshi)
74. V6.13.10 - 20050321
diff --git a/contrib/tcsh/Imakefile b/contrib/tcsh/Imakefile
index bc77ad9..9dc3323 100644
--- a/contrib/tcsh/Imakefile
+++ b/contrib/tcsh/Imakefile
@@ -1,5 +1,5 @@
XCOMM
-XCOMM $Id: Imakefile,v 1.84 2004/12/25 21:15:05 christos Exp $
+XCOMM $tcsh: Imakefile,v 1.85 2006/03/02 18:46:44 christos Exp $
XCOMM
XCOMM Imakefile for tcsh 6.12
XCOMM Marc Horowitz, MIT SIPB
diff --git a/contrib/tcsh/MAKEDIFFS b/contrib/tcsh/MAKEDIFFS
index 3b87683..01395f0 100755
--- a/contrib/tcsh/MAKEDIFFS
+++ b/contrib/tcsh/MAKEDIFFS
@@ -2,7 +2,7 @@
#
# MAKEDIFFS.sh: Make context diffs for the csh sources
#
-# $Id: MAKEDIFFS,v 3.0 1991/07/04 21:57:47 christos Exp $
+# $tcsh: MAKEDIFFS,v 3.1 2006/03/02 18:46:44 christos Exp $
XINUDIR=/usr/share/src/mtXinu/bin/csh
BSDDIR=/usr/share/src/mtXinu/BSD/bin/csh
TAHOEDIR=/usr/share/src/mtXinu/TAHOE/bin/csh
diff --git a/contrib/tcsh/MAKESHAR b/contrib/tcsh/MAKESHAR
index 691690f..f2238e8 100755
--- a/contrib/tcsh/MAKESHAR
+++ b/contrib/tcsh/MAKESHAR
@@ -2,7 +2,7 @@
#
# MAKESHAR.sh: Make a shar file for the sources
#
-# $Id: MAKESHAR,v 3.1 1992/05/09 04:03:53 christos Exp $
+# $tcsh: MAKESHAR,v 3.2 2006/03/02 18:46:44 christos Exp $
AWK=/usr/bin/nawk # Must be nawk or gawk cause of 2D arrays
WC=/usr/ucb/wc
diff --git a/contrib/tcsh/Makefile.in b/contrib/tcsh/Makefile.in
index da0875f..f925c5a 100644
--- a/contrib/tcsh/Makefile.in
+++ b/contrib/tcsh/Makefile.in
@@ -1,4 +1,4 @@
-# $Id: Makefile.in,v 3.27 2005/03/23 13:20:30 kim Exp $
+# $tcsh: Makefile.in,v 3.36 2006/08/24 20:56:31 christos Exp $
# Makefile.in 4.3 6/11/83
#
# C Shell with process control; VM/UNIX VAX Makefile
@@ -8,7 +8,7 @@
# things; Paul Placeway, CIS Dept., Ohio State University
#
SHELL=/bin/sh
-VERSION=6.12
+VERSION=@PACKAGE_VERSION@
BUILD=tcsh$(EXEEXT)
VPATH=@srcdir@
srcdir=@srcdir@
@@ -231,7 +231,8 @@ LIBES= @LIBS@ ## This is set by autoconf.
#
EXTRAFLAGS = @HESDEF@ $(AFSDEF)
-EXTRALIBS = @HESLIB@ $(AFSLIB)
+EXTRALIBS = @HESLIB@ $(AFSLIB) @LIBICONV@
+
# The difficult choice of a c-compiler...
@@ -326,14 +327,19 @@ AVSRCS= Fixes MAKEDIFFS MAKESHAR NewThings README FAQ \
WishList config_f.h eight-bit.me glob.3 patchlevel.h \
pathnames.h tcsh.man Ported src.desc Imakefile imake.config \
README.imake complete.tcsh vmsreadme.txt termcap.vms snames.h \
- host.defs gethost.c tcsh.man2html configure.in configure config.h.in
+ host.defs gethost.c tcsh.man2html configure.in configure config.h.in \
+ tests/testsuite.at
+TESTFILES= tests/aliases.at tests/arguments.at tests/commands.at \
+ tests/expr.at tests/lexical.at tests/mb-eucjp.at tests/mb-utf8.at \
+ tests/noexec.at tests/syntax.at tests/subst.at tests/variables.at \
+ tests/sh.dol.at
VHSRCS=${PVSRCS} ${AVSRCS}
CONFSRCS=config/*
ALLSRCS= ${SHSRCS} ${TWSRCS} ${EDSRCS} ${TCSRCS} ${VHSRCS}
-DISTSRCS= ${PSSRCS} ${TWSRCS} ${EDSRCS} ${TCSRCS} ${AVSRCS}
+DISTSRCS= ${PSSRCS} ${TWSRCS} ${EDSRCS} ${TCSRCS} ${AVSRCS} $(TESTFILES)
OBJS= ${SHOBJS} ${TWOBJS} ${EDOBJS} ${TCOBJS}
@@ -362,18 +368,26 @@ gethost: gethost.c sh.err.h tc.const.h sh.h
${CC} -o gethost ${LDFLAGS} ${CFLAGS} ${CPPFLAGS} ${DFLAGS} $(srcdir)/gethost.c ${LIBES} ${EXTRALIBS}
tc.defs.c: gethost host.defs
- @rm -f $@
- @echo "/* Do not edit this file, make creates it */" > $@
- ./gethost $(srcdir)/host.defs >> $@
+ @rm -f $@.tmp
+ @echo "/* Do not edit this file, make creates it */" > $@.tmp
+ ./gethost $(srcdir)/host.defs >> $@.tmp
+ @if [ -f $@ ] && cmp -s $@.tmp $@; then echo $@ unchanged.; rm -f $@.tmp; else mv -f $@.tmp $@; echo $@ recreated.; fi
tcsh.ps: tcsh.man
rm -f tcsh.ps
-ptroff -t -man $(srcdir)/tcsh.man > tcsh.ps
-
.c.${SUF}:
${CC} ${CF} ${CFLAGS} ${CPPFLAGS} ${DFLAGS} ${EXTRAFLAGS} $<
+.SUFFIXES: .s .i
+
+.c.i:
+ ${CC} -E ${CFLAGS} ${CPPFLAGS} ${DFLAGS} ${EXTRAFLAGS} $< | cat -s > $@
+
+.c.s:
+ ${CC} -S ${CFLAGS} ${CPPFLAGS} ${DFLAGS} ${EXTRAFLAGS} $<
+
# _VMS_POSIX #module addition
#.c.${SUF}:
# @(echo '#module '`echo $< | sed -e 's/\./_/g'`; cat $<) > $*..c
@@ -410,31 +424,53 @@ tcsh.ps: tcsh.man
## co $<
ed.defns.h: ed.defns.c
- @rm -f $@
- @echo '/* Do not edit this file, make creates it. */' > $@
- @echo '#ifndef _h_ed_defns' >> $@
- @echo '#define _h_ed_defns' >> $@
- grep '[FV]_' $(srcdir)/ed.defns.c | grep '^#define' >> $@
- @echo '#endif /* _h_ed_defns */' >> $@
+ @rm -f $@.tmp
+ @echo '/* Do not edit this file, make creates it. */' > $@.tmp
+ @echo '#ifndef _h_ed_defns' >> $@.tmp
+ @echo '#define _h_ed_defns' >> $@.tmp
+ grep '[FV]_' $(srcdir)/ed.defns.c | grep '^#define' >> $@.tmp
+ @echo '#endif /* _h_ed_defns */' >> $@.tmp
+ @if [ -f $@ ] && cmp -s $@.tmp $@; then echo $@ unchanged.; rm -f $@.tmp; else mv -f $@.tmp $@; echo $@ recreated.; fi
sh.err.h: sh.err.c
- @rm -f $@
- @echo '/* Do not edit this file, make creates it. */' > $@
- @echo '#ifndef _h_sh_err' >> $@
- @echo '#define _h_sh_err' >> $@
- grep 'ERR_' $(srcdir)/sh.err.c | grep '^#define' >> $@
- @echo '#endif /* _h_sh_err */' >> $@
+ @rm -f $@.tmp
+ @echo '/* Do not edit this file, make creates it. */' > $@.tmp
+ @echo '#ifndef _h_sh_err' >> $@.tmp
+ @echo '#define _h_sh_err' >> $@.tmp
+ grep 'ERR_' $(srcdir)/sh.err.c | grep '^#define' >> $@.tmp
+ @echo '#endif /* _h_sh_err */' >> $@.tmp
+ @if [ -f $@ ] && cmp -s $@.tmp $@; then echo $@ unchanged.; rm -f $@.tmp; else mv -f $@.tmp $@; echo $@ recreated.; fi
tc.const.h: tc.const.c sh.char.h config.h config_f.h sh.types.h sh.err.h
- @rm -f $@
- @echo '/* Do not edit this file, make creates it. */' > $@
- @echo '#ifndef _h_tc_const' >> $@
- @echo '#define _h_tc_const' >> $@
+ @rm -f $@.tmp
+ @echo '/* Do not edit this file, make creates it. */' > $@.tmp
+ @echo '#ifndef _h_tc_const' >> $@.tmp
+ @echo '#define _h_tc_const' >> $@.tmp
${CPP} $(CPPFLAGS) ${DFLAGS} ${EXTRAFLAGS} -D_h_tc_const\
$(srcdir)/tc.const.c | \
sed -n -e 's/^\(Char STR[a-zA-Z0-9_]*\) *\[ *\].*/extern \1[];/p' | \
- sort >> $@
- @echo '#endif /* _h_tc_const */' >> $@
+ sort >> $@.tmp
+ @echo '#endif /* _h_tc_const */' >> $@.tmp
+ @if [ -f $@ ] && cmp -s $@.tmp $@; then echo $@ unchanged.; rm -f $@.tmp; else mv -f $@.tmp $@; echo $@ recreated.; fi
+
+$(srcdir)/tests/package.m4: $(srcdir)/configure.in
+ { \
+ echo '# Signature of the current package.'; \
+ echo 'm4_define([AT_PACKAGE_NAME], [@PACKAGE_NAME@])'; \
+ echo 'm4_define([AT_PACKAGE_TARNAME], [@PACKAGE_TARNAME@])'; \
+ echo 'm4_define([AT_PACKAGE_VERSION], [@PACKAGE_VERSION@])'; \
+ echo 'm4_define([AT_PACKAGE_STRING], [@PACKAGE_STRING@])'; \
+ echo 'm4_define([AT_PACKAGE_BUGREPORT], [@PACKAGE_BUGREPORT@])'; \
+ } >$(srcdir)/tests/package.m4
+
+$(srcdir)/tests/testsuite: tests/package.m4 tests/testsuite.at $(TESTFILES)
+ autom4te --language=autotest -I $(srcdir)/tests \
+ $(srcdir)/tests/testsuite.at -o $@.tmp
+ mv $@.tmp $@
+
+atconfig: config.status
+ $(SHELL) ./config.status ./atconfig
+
csh.prof: ${OBJS} sh.prof.${SUF} mcrt0.${SUF}
rm -f csh.prof
@@ -489,12 +525,12 @@ install.man: tcsh.man
chmod 444 ${DESTMAN}/tcsh.${MANSECT}
install.cygwin: install install.man
- -mkdir -p ${DESTDIR}${prefix}/doc/tcsh
- cp ${srcdir}/FAQ ${srcdir}/Fixes ${DESTDIR}${prefix}/doc/tcsh
- cp ${srcdir}/NewThings ${srcdir}/README ${DESTDIR}${prefix}/doc/tcsh
- cp ${srcdir}/WishList ${srcdir}/Y2K ${DESTDIR}${prefix}/doc/tcsh
+ -mkdir -p ${DESTDIR}${prefix}/share/doc/tcsh
+ cp ${srcdir}/FAQ ${srcdir}/Fixes ${DESTDIR}${prefix}/share/doc/tcsh
+ cp ${srcdir}/NewThings ${srcdir}/README ${DESTDIR}${prefix}/share/doc/tcsh
+ cp ${srcdir}/WishList ${srcdir}/Y2K ${DESTDIR}${prefix}/share/doc/tcsh
perl ${srcdir}/tcsh.man2html ${srcdir}/tcsh.man
- cp -rp tcsh.html ${DESTDIR}${prefix}/doc/tcsh
+ cp -rp tcsh.html ${DESTDIR}${prefix}/share/doc/tcsh
-mkdir -p ${DESTDIR}/etc/profile.d
-mkdir -p ${DESTDIR}/etc/postinstall
cp -p ${srcdir}/cygwin/etc/csh.* ${DESTDIR}/etc
@@ -515,7 +551,8 @@ install.cygwin: install install.man
clean:
${RM} -f a.out strings x.c xs.c tcsh$(EXEEXT) tcsh.a _MAKE_LOG gethost
- ${RM} -f *.${SUF} sh.prof.c ed.defns.h tc.const.h sh.err.h tc.defs.c
+ ${RM} -f *.${SUF} *.i *.s
+ ${RM} -f sh.prof.c ed.defns.h tc.const.h sh.err.h tc.defs.c
${RM} -f tcsh.*.m tcsh.*.cat
veryclean: clean
@@ -527,13 +564,15 @@ veryclean: clean
distclean: veryclean
+cleandir: veryclean
+
tags: /tmp
${CTAGS} sh*.c
tar.Z:
rm -f tcsh-${VERSION}.tar.Z
rm -rf tcsh-${VERSION}
- -mkdir tcsh-${VERSION} tcsh-${VERSION}/config
+ -mkdir tcsh-${VERSION} tcsh-${VERSION}/config tcsh-${VERSION}/tests
cp ${ALLSRCS} tcsh-${VERSION}
cp ${CONFSRCS} tcsh-${VERSION}/config
tar cf - nls/Makefile nls/?*/set?* | (cd tcsh-${VERSION}; tar xpf -)
@@ -543,7 +582,7 @@ tar.Z:
tar.gz:
rm -f tcsh-${VERSION}.tar.gz
rm -rf tcsh-${VERSION}
- -mkdir tcsh-${VERSION} tcsh-${VERSION}/config
+ -mkdir tcsh-${VERSION} tcsh-${VERSION}/config tcsh-${VERSION}/tests
cp ${ALLSRCS} tcsh-${VERSION}
cp ${CONFSRCS} tcsh-${VERSION}/config
tar cf - nls/Makefile nls/?*/set?* | (cd tcsh-${VERSION}; tar xpf -)
@@ -553,7 +592,7 @@ tar.gz:
shar:
rm -f tcsh-*.shar
rm -rf tcsh-${VERSION}
- -mkdir tcsh-${VERSION} tcsh-${VERSION}/config
+ -mkdir tcsh-${VERSION} tcsh-${VERSION}/config tcsh-${VERSION}/tests
cp ${ALLSRCS} tcsh-${VERSION}
cp ${CONFSRCS} tcsh-${VERSION}/config
tar cf - nls/Makefile nls/?*/set?* | (cd tcsh-${VERSION}; tar xpf -)
@@ -568,7 +607,7 @@ catalogs:
tcsh-${VERSION}.tar.Z:
rm -rf tcsh-${VERSION}
rm -f tcsh-${VERSION}.tar tcsh-${VERSION}.tar.Z DIFFS.[123]
- -mkdir tcsh-${VERSION}
+ -mkdir tcsh-${VERSION} tcsh-${VERSION}/tests
./MAKEDIFFS bsd
mv DIFFS.1 DIFFS.2 DIFFS.3 tcsh-${VERSION}
cp ${DISTSRCS} tcsh-${VERSION}
@@ -621,6 +660,9 @@ $(srcdir)/stamp-h.in: $(srcdir)/configure.in
cd $(srcdir) && autoheader
@echo timestamp > $(srcdir)/stamp-h.in
+check: atconfig $(srcdir)/tests/testsuite
+ $(SHELL) $(srcdir)/tests/testsuite
+
#
# Dependencies
#
diff --git a/contrib/tcsh/Makefile.std b/contrib/tcsh/Makefile.std
index 69219e3..1af09d9 100644
--- a/contrib/tcsh/Makefile.std
+++ b/contrib/tcsh/Makefile.std
@@ -1,4 +1,4 @@
-# $Id: Makefile.std,v 1.96 2004/12/25 21:15:05 christos Exp $
+# $tcsh: Makefile.std,v 1.97 2006/03/02 18:46:44 christos Exp $
# Makefile.std 4.3 6/11/83
#
# C Shell with process control; VM/UNIX VAX Makefile
diff --git a/contrib/tcsh/Makefile.vms b/contrib/tcsh/Makefile.vms
index 75d2c95..d3a258b 100644
--- a/contrib/tcsh/Makefile.vms
+++ b/contrib/tcsh/Makefile.vms
@@ -1,4 +1,4 @@
-# $Id: Makefile.vms,v 1.38 2004/12/25 21:15:05 christos Exp $
+# $tcsh: Makefile.vms,v 1.39 2006/03/02 18:46:44 christos Exp $
# Makefile.vms 4.3 6/11/83
#
# C Shell with process control; VM/UNIX VAX Makefile
diff --git a/contrib/tcsh/README b/contrib/tcsh/README
index 3852b66..9648c27 100644
--- a/contrib/tcsh/README
+++ b/contrib/tcsh/README
@@ -1,4 +1,4 @@
-This is tcsh version 6.14. Tcsh is a version of the Berkeley
+This is tcsh version 6.15. Tcsh is a version of the Berkeley
C-Shell, with the addition of: a command line editor, command and file
name completion, listing, etc. and a bunch of small additions to the
shell itself.
@@ -19,12 +19,12 @@ names of the authors from the source code or documentation).
To install tcsh:
-0) Try running "configure". If that works, goto step 6.
- If you are using imake, try xmkmf and goto step 3.
- If imake does not work, copy Makefile.std to Makefile.
+0) Try running "./configure". If that doesn't work, goto step 1.
+ Run "./configure --help" to see possible options. After running
+ configure, goto step 3.
-1) Look at the Makefile and make sure that you are using the right
- compilation flags.
+1) Otherwise copy Makefile.std to Makefile. Look at the Makefile and
+ make sure that you are using the right compilation flags.
2) Copy the appropriate for your machine and OS config file from the
config subdirectory into config.h. Consult the file "Ported" for
@@ -34,7 +34,7 @@ To install tcsh:
the supplied ones. If you get tcsh working on a new machine, I'd
appreciate a copy of the config file plus additional information
about the architecture/OS. If you are creating a new config file,
- look very hard at BSDJOBS, BSDSIGS, and BSDTIMES if you are running
+ look very hard at BSDJOBS and BSDTIMES if you are running
a non-BSD machine. For vanila SysV, these would all be #undef-ed,
but others may vary (such as A/UX or HPUX). On a pyramid, compile
in the UCB universe even if you are running under the ATT universe
@@ -42,33 +42,27 @@ To install tcsh:
3) Look at config_f.h, and enable or disable any features you want.
It is configured the way I like it, but you may disagree.
- If you do not have NLS, then locale.h will not be found. Undefine it
- and things should work ok. On the other hand, if you have NLS you
- might as well use it...
4) Look at host.defs to make sure that you have the right defines to set
the environment variables "HOSTTYPE", "MACHTYPE", "OSTYPE" and
"VENDOR" correctly. If you need to make changes, PLEASE SEND THEM
BACK TO ME.
-5) You may want to adjust the TCSH_BINDIR and TCSH_MANDIR entries in
+5) You may want to adjust the DESTBIN and DESTMAN entries in
the Makefile. These are the directories that tcsh, and the tcsh.1
man entry will be placed in when you do a "make install" and "make
install.man" respectively. If you decide to install tcsh somewhere
other than in /usr/local/bin/tcsh, you should #define _PATH_TCSHELL
"/your/installation/directory/tcsh" in pathnames.h.
-6) If you've changed any of the configuration variables you may need
- to re-run configure.
+6) make
-7) make
-
-8) Read the documentation while you are waiting. The file tcsh.man
+7) Read the documentation while you are waiting. The file tcsh.man
is in standard [nt]roff -man format. If you like, you can run the
tcsh.man2html script (requires Perl) to generate an HTML version of
the manpage which you can read with Mosaic, lynx or other HTML browser.
-9) Test tcsh by typing ./tcsh to see that it has compiled correctly.
+8) Test tcsh by typing ./tcsh to see that it has compiled correctly.
The history command should give a time stamp on every entry.
Typing normal characters should echo each exactly once. Control-A
should put the cursor at the beginning of the input line, but after
@@ -86,12 +80,12 @@ To install tcsh:
passwd appears on the screen, you have lost /dev/tty. Otherwise
everything is fine.
-10) Once satisfied that tcsh is working correctly, complete the installation
+9) Once satisfied that tcsh is working correctly, complete the installation
by typing "make install" to install the binary, and "make install.man" to
install the documentation. Don't forget to look at complete.tcsh for
useful completions...
-11) Enjoy.
+10) Enjoy.
12) PLEASE file any bug reports (and fixes), code for new features at:
diff --git a/contrib/tcsh/complete.tcsh b/contrib/tcsh/complete.tcsh
index 35d7a79..42edcbd 100644
--- a/contrib/tcsh/complete.tcsh
+++ b/contrib/tcsh/complete.tcsh
@@ -1,5 +1,5 @@
#
-# $Id: complete.tcsh,v 1.46 2005/03/21 21:26:08 kim Exp $
+# $tcsh: complete.tcsh,v 1.47 2006/03/02 18:46:44 christos Exp $
# example file using the new completion code
#
# Debian GNU/Linux
diff --git a/contrib/tcsh/config.h.in b/contrib/tcsh/config.h.in
index 2b40225..f2211a5 100644
--- a/contrib/tcsh/config.h.in
+++ b/contrib/tcsh/config.h.in
@@ -10,10 +10,28 @@
/* Define to 1 if you have the <auth.h> header file. */
#undef HAVE_AUTH_H
+/* Define to 1 if you have the `catgets' function. */
+#undef HAVE_CATGETS
+
+/* Define to 1 if you have the <crypt.h> header file. */
+#undef HAVE_CRYPT_H
+
+/* Define to 1 if you have the declaration of `crypt', and to 0 if you don't.
+ */
+#undef HAVE_DECL_CRYPT
+
+/* Define to 1 if you have the declaration of `environ', and to 0 if you
+ don't. */
+#undef HAVE_DECL_ENVIRON
+
/* Define to 1 if you have the declaration of `gethostname', and to 0 if you
don't. */
#undef HAVE_DECL_GETHOSTNAME
+/* Define to 1 if you have the declaration of `getpgrp', and to 0 if you
+ don't. */
+#undef HAVE_DECL_GETPGRP
+
/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
*/
#undef HAVE_DIRENT_H
@@ -21,6 +39,9 @@
/* Define to 1 if you have the `dup2' function. */
#undef HAVE_DUP2
+/* Define to 1 if you have the `getauthid' function. */
+#undef HAVE_GETAUTHID
+
/* Define to 1 if you have the `getcwd' function. */
#undef HAVE_GETCWD
@@ -33,7 +54,7 @@
/* Define to 1 if you have the `getutent' function. */
#undef HAVE_GETUTENT
-/* Define to 1 if you have the iconv () interface */
+/* Define if you have the iconv() function. */
#undef HAVE_ICONV
/* Define to 1 if you have the <inttypes.h> header file. */
@@ -42,6 +63,9 @@
/* Define to 1 if the system has the type `long long'. */
#undef HAVE_LONG_LONG
+/* Define to 1 if mbrtowc and mbstate_t are properly declared. */
+#undef HAVE_MBRTOWC
+
/* Define to 1 if you have the `memmove' function. */
#undef HAVE_MEMMOVE
@@ -78,6 +102,10 @@
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
+/* Define to 1 if you have the `strcoll' function and it is properly defined.
+ */
+#undef HAVE_STRCOLL
+
/* Define to 1 if you have the `strerror' function. */
#undef HAVE_STRERROR
@@ -143,6 +171,12 @@
/* Define to 1 if you have the `wcwidth' function. */
#undef HAVE_WCWIDTH
+/* Define as const if the declaration of iconv() needs const. */
+#undef ICONV_CONST
+
+/* Support NLS. */
+#undef NLS
+
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
@@ -158,12 +192,6 @@
/* Define to the version of this package. */
#undef PACKAGE_VERSION
-/* Define to 1 if the C compiler supports function prototypes. */
-#undef PROTOTYPES
-
-/* Define as the return type of signal handlers (`int' or `void'). */
-#undef RETSIGTYPE
-
/* Define to 1 if the `setpgrp' function takes no argument. */
#undef SETPGRP_VOID
@@ -176,9 +204,6 @@
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
-/* Define like PROTOTYPES; this can be used by system headers. */
-#undef __PROTOTYPES
-
/* Define to empty if `const' does not conform to ANSI C. */
#undef const
@@ -194,6 +219,9 @@
/* Define to `int' if neither <sys/types.h> nor <sys/socket.h> define. */
#undef socklen_t
+/* Define to `int' not defined in <sys/types.h>. */
+#undef ssize_t
+
/* Define to `int' if <sys/types.h> doesn't define. */
#undef uid_t
diff --git a/contrib/tcsh/config/bsd4.4 b/contrib/tcsh/config/bsd4.4
index 5f028de..6be4ebb 100644
--- a/contrib/tcsh/config/bsd4.4
+++ b/contrib/tcsh/config/bsd4.4
@@ -21,11 +21,6 @@
#define POSIXJOBS
/*
- * POSIXSIGS Use the POSIX signal facilities to emulate BSD signals.
- */
-#undef POSIXSIGS
-
-/*
* VFORK This machine has a vfork().
* It used to be that for job control to work, this define
* was mandatory. This is not the case any more.
@@ -47,16 +42,9 @@
#define BSDJOBS
/*
- * BSDSIGS You have 4.2-style signals, rather than USG style.
- * Note: POSIX systems should not define this unless they
- * have sigvec() and friends (ie: 4.3BSD-RENO, HP-UX).
- */
-#define BSDSIGS
-
-/*
* BSDTIMES You have BSD-style process time stuff (like rusage)
* This may or may not be true. For example, Apple Unix
- * (OREO) has BSDJOBS and BSDSIGS but not BSDTIMES.
+ * (OREO) has BSDJOBS but not BSDTIMES.
*/
#define BSDTIMES
@@ -108,7 +96,6 @@
# define _PATH_TCSHELL "/usr/contrib/bin/tcsh"
# endif
-# undef NLS
# undef NLS_CATALOGS
#elif defined(__APPLE__)
diff --git a/contrib/tcsh/config_f.h b/contrib/tcsh/config_f.h
index 2f3f403..aee7363 100644
--- a/contrib/tcsh/config_f.h
+++ b/contrib/tcsh/config_f.h
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/config_f.h,v 3.32 2005/03/04 13:46:04 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/config_f.h,v 3.40 2006/08/28 14:53:04 mitr Exp $ */
/*
* config_f.h -- configure various defines for tcsh
*
@@ -50,26 +50,20 @@
* WIDE_STRINGS Represent strings using wide characters
* Allows proper function in multibyte encodings like UTF-8
*/
-#if defined (SHORT_STRINGS) && SIZEOF_WCHAR_T >= 4 && !defined (WINNT_NATIVE) && !defined(_OSD_POSIX)
+#if defined (SHORT_STRINGS) && defined (NLS) && SIZEOF_WCHAR_T >= 4 && defined (HAVE_MBRTOWC) && !defined (WINNT_NATIVE) && !defined(_OSD_POSIX)
# define WIDE_STRINGS
#endif
/*
- * NLS: Use Native Language System
- * Routines like setlocale() are needed
- * if you don't have <locale.h>, you don't want
- * to define this.
- */
-#define NLS
-
-/*
* NLS_CATALOGS:Use Native Language System catalogs for
* international messages.
* Routines like catopen() are needed
* if you don't have <nl_types.h>, you don't want
* to define this.
*/
-#undef NLS_CATALOGS
+#if defined (NLS) && defined (HAVE_CATGETS)
+# define NLS_CATALOGS
+#endif
/*
* LOGINFIRST Source ~/.login before ~/.cshrc
@@ -149,7 +143,7 @@
* This can be much slower and no memory statistics will be
* provided.
*/
-#if defined(__MACHTEN__) || defined(PURIFY) || defined(MALLOC_TRACE) || defined(_OSD_POSIX) || defined(__MVS__)
+#if defined(__MACHTEN__) || defined(PURIFY) || defined(MALLOC_TRACE) || defined(_OSD_POSIX) || defined(__MVS__) || defined (__linux__)
# define SYSMALLOC
#else
# undef SYSMALLOC
diff --git a/contrib/tcsh/configure b/contrib/tcsh/configure
index c3e2ca1..00cf593 100755
--- a/contrib/tcsh/configure
+++ b/contrib/tcsh/configure
@@ -1,6 +1,8 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.59.
+# Generated by GNU Autoconf 2.59 for tcsh 6.15.00.
+#
+# Report bugs to <http://bugs.gw.com/>.
#
# Copyright (C) 2003 Free Software Foundation, Inc.
# This configure script is free software; the Free Software Foundation
@@ -265,11 +267,11 @@ SHELL=${CONFIG_SHELL-/bin/sh}
: ${ac_max_here_lines=38}
# Identity of this package.
-PACKAGE_NAME=
-PACKAGE_TARNAME=
-PACKAGE_VERSION=
-PACKAGE_STRING=
-PACKAGE_BUGREPORT=
+PACKAGE_NAME='tcsh'
+PACKAGE_TARNAME='tcsh'
+PACKAGE_VERSION='6.15.00'
+PACKAGE_STRING='tcsh 6.15.00'
+PACKAGE_BUGREPORT='http://bugs.gw.com/'
ac_unique_file="tc.vers.c"
# Factoring default headers for most tests.
@@ -309,7 +311,7 @@ ac_includes_default="\
# include <unistd.h>
#endif"
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP EGREP DFLAGS HESDEF HESLIB LIBOBJS LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP EGREP LIBICONV LTLIBICONV DFLAGS HESDEF HESLIB LIBOBJS LTLIBOBJS'
ac_subst_files=''
# Initialize some variables set by options.
@@ -778,7 +780,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures this package to adapt to many kinds of systems.
+\`configure' configures tcsh 6.15.00 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -838,12 +840,23 @@ _ACEOF
fi
if test -n "$ac_init_help"; then
-
+ case $ac_init_help in
+ short | recursive ) echo "Configuration of tcsh 6.15.00:";;
+ esac
cat <<\_ACEOF
+Optional Features:
+ --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
+ --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
+ --disable-rpath do not hardcode runtime library paths
+ --disable-nls Disable NLS support
+
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
+ --with-gnu-ld assume the C compiler uses GNU ld default=no
+ --with-libiconv-prefix[=DIR] search for libiconv in DIR/include and DIR/lib
+ --without-libiconv-prefix don't search for libiconv in includedir and libdir
--with-hesiod=PREFIX Use Hesiod lookup for ~ expansion
Some influential environment variables:
@@ -858,6 +871,7 @@ Some influential environment variables:
Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.
+Report bugs to <http://bugs.gw.com/>.
_ACEOF
fi
@@ -953,6 +967,8 @@ fi
test -n "$ac_init_help" && exit 0
if $ac_init_version; then
cat <<\_ACEOF
+tcsh configure 6.15.00
+generated by GNU Autoconf 2.59
Copyright (C) 2003 Free Software Foundation, Inc.
This configure script is free software; the Free Software Foundation
@@ -965,7 +981,7 @@ cat >&5 <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by $as_me, which was
+It was created by tcsh $as_me 6.15.00, which was
generated by GNU Autoconf 2.59. Invocation command line was
$ $0 $@
@@ -1294,8 +1310,19 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+
+
+
+
+
+
ac_config_headers="$ac_config_headers config.h"
+ ac_config_commands="$ac_config_commands ./atconfig"
+
+
ac_aux_dir=
for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do
@@ -1486,6 +1513,11 @@ case "${host}" in
tcsh_config_file=bsd4.4
;;
+ ## DragonFly systems
+ *-*-dragonfly*)
+ tcsh_config_file=bsd4.4
+ ;;
+
## Silicon Graphics machines
*-sgi-iri* )
tcsh_config_file=irix
@@ -1516,16 +1548,16 @@ case "${host}" in
*-sun-sunos4.1.[3456]* )
tcsh_config_file=sunos413
;;
- *-*-solaris2.[01]* ) # Should handle sparc or x86
+ *-*-solaris2.[01] ) # Should handle sparc or x86
tcsh_config_file=sol2
;;
- *-sun-solaris2.2* ) # Sparc only release
+ *-sun-solaris2.2 ) # Sparc only release
tcsh_config_file=sol22
;;
- *-sun-solaris2.3* ) # Sparc only release
+ *-sun-solaris2.3 ) # Sparc only release
tcsh_config_file=sol23
;;
- *-*-solaris2.[45]* ) # Should handle sparc, x86 and powerpc
+ *-*-solaris2.[45] ) # Should handle sparc, x86 and powerpc
tcsh_config_file=sol24
;;
*-*-solaris2.* ) # Should handle sparc, x86 and powerpc
@@ -3477,31 +3509,604 @@ if test "$ac_cv_search_connect" != no; then
fi
-echo "$as_me:$LINENO: checking for library containing iconv" >&5
-echo $ECHO_N "checking for library containing iconv... $ECHO_C" >&6
-if test "${ac_cv_search_iconv+set}" = set; then
+
+ if test "X$prefix" = "XNONE"; then
+ acl_final_prefix="$ac_default_prefix"
+ else
+ acl_final_prefix="$prefix"
+ fi
+ if test "X$exec_prefix" = "XNONE"; then
+ acl_final_exec_prefix='${prefix}'
+ else
+ acl_final_exec_prefix="$exec_prefix"
+ fi
+ acl_save_prefix="$prefix"
+ prefix="$acl_final_prefix"
+ eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
+ prefix="$acl_save_prefix"
+
+
+# Check whether --with-gnu-ld or --without-gnu-ld was given.
+if test "${with_gnu_ld+set}" = set; then
+ withval="$with_gnu_ld"
+ test "$withval" = no || with_gnu_ld=yes
+else
+ with_gnu_ld=no
+fi;
+# Prepare PATH_SEPARATOR.
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+ echo "#! /bin/sh" >conf$$.sh
+ echo "exit 0" >>conf$$.sh
+ chmod +x conf$$.sh
+ if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
+ PATH_SEPARATOR=';'
+ else
+ PATH_SEPARATOR=:
+ fi
+ rm -f conf$$.sh
+fi
+ac_prog=ld
+if test "$GCC" = yes; then
+ # Check if gcc -print-prog-name=ld gives a path.
+ echo "$as_me:$LINENO: checking for ld used by GCC" >&5
+echo $ECHO_N "checking for ld used by GCC... $ECHO_C" >&6
+ case $host in
+ *-*-mingw*)
+ # gcc leaves a trailing carriage return which upsets mingw
+ ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
+ *)
+ ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
+ esac
+ case $ac_prog in
+ # Accept absolute paths.
+ [\\/]* | [A-Za-z]:[\\/]*)
+ re_direlt='/[^/][^/]*/\.\./'
+ # Canonicalize the path of ld
+ ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
+ while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
+ ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
+ done
+ test -z "$LD" && LD="$ac_prog"
+ ;;
+ "")
+ # If it fails, then pretend we aren't using GCC.
+ ac_prog=ld
+ ;;
+ *)
+ # If it is relative, then search for the first ld in PATH.
+ with_gnu_ld=unknown
+ ;;
+ esac
+elif test "$with_gnu_ld" = yes; then
+ echo "$as_me:$LINENO: checking for GNU ld" >&5
+echo $ECHO_N "checking for GNU ld... $ECHO_C" >&6
+else
+ echo "$as_me:$LINENO: checking for non-GNU ld" >&5
+echo $ECHO_N "checking for non-GNU ld... $ECHO_C" >&6
+fi
+if test "${acl_cv_path_LD+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
- ac_func_search_save_LIBS=$LIBS
-ac_cv_search_iconv=no
-cat >conftest.$ac_ext <<_ACEOF
+ if test -z "$LD"; then
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
+ for ac_dir in $PATH; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+ acl_cv_path_LD="$ac_dir/$ac_prog"
+ # Check to see if the program is GNU ld. I'd rather use --version,
+ # but apparently some GNU ld's only accept -v.
+ # Break only if it was the GNU/non-GNU ld that we prefer.
+ case `"$acl_cv_path_LD" -v 2>&1 < /dev/null` in
+ *GNU* | *'with BFD'*)
+ test "$with_gnu_ld" != no && break ;;
+ *)
+ test "$with_gnu_ld" != yes && break ;;
+ esac
+ fi
+ done
+ IFS="$ac_save_ifs"
+else
+ acl_cv_path_LD="$LD" # Let the user override the test with a path.
+fi
+fi
+
+LD="$acl_cv_path_LD"
+if test -n "$LD"; then
+ echo "$as_me:$LINENO: result: $LD" >&5
+echo "${ECHO_T}$LD" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+test -z "$LD" && { { echo "$as_me:$LINENO: error: no acceptable ld found in \$PATH" >&5
+echo "$as_me: error: no acceptable ld found in \$PATH" >&2;}
+ { (exit 1); exit 1; }; }
+echo "$as_me:$LINENO: checking if the linker ($LD) is GNU ld" >&5
+echo $ECHO_N "checking if the linker ($LD) is GNU ld... $ECHO_C" >&6
+if test "${acl_cv_prog_gnu_ld+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ # I'd rather use --version here, but apparently some GNU ld's only accept -v.
+case `$LD -v 2>&1 </dev/null` in
+*GNU* | *'with BFD'*)
+ acl_cv_prog_gnu_ld=yes ;;
+*)
+ acl_cv_prog_gnu_ld=no ;;
+esac
+fi
+echo "$as_me:$LINENO: result: $acl_cv_prog_gnu_ld" >&5
+echo "${ECHO_T}$acl_cv_prog_gnu_ld" >&6
+with_gnu_ld=$acl_cv_prog_gnu_ld
+
+
+
+
+ echo "$as_me:$LINENO: checking for shared library run path origin" >&5
+echo $ECHO_N "checking for shared library run path origin... $ECHO_C" >&6
+if test "${acl_cv_rpath+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+ CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
+ ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
+ . ./conftest.sh
+ rm -f ./conftest.sh
+ acl_cv_rpath=done
+
+fi
+echo "$as_me:$LINENO: result: $acl_cv_rpath" >&5
+echo "${ECHO_T}$acl_cv_rpath" >&6
+ wl="$acl_cv_wl"
+ libext="$acl_cv_libext"
+ shlibext="$acl_cv_shlibext"
+ hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
+ hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
+ hardcode_direct="$acl_cv_hardcode_direct"
+ hardcode_minus_L="$acl_cv_hardcode_minus_L"
+ # Check whether --enable-rpath or --disable-rpath was given.
+if test "${enable_rpath+set}" = set; then
+ enableval="$enable_rpath"
+ :
+else
+ enable_rpath=yes
+fi;
+
+
+
+
+
+
+
+ use_additional=yes
+
+ acl_save_prefix="$prefix"
+ prefix="$acl_final_prefix"
+ acl_save_exec_prefix="$exec_prefix"
+ exec_prefix="$acl_final_exec_prefix"
+
+ eval additional_includedir=\"$includedir\"
+ eval additional_libdir=\"$libdir\"
+
+ exec_prefix="$acl_save_exec_prefix"
+ prefix="$acl_save_prefix"
+
+
+# Check whether --with-libiconv-prefix or --without-libiconv-prefix was given.
+if test "${with_libiconv_prefix+set}" = set; then
+ withval="$with_libiconv_prefix"
+
+ if test "X$withval" = "Xno"; then
+ use_additional=no
+ else
+ if test "X$withval" = "X"; then
+
+ acl_save_prefix="$prefix"
+ prefix="$acl_final_prefix"
+ acl_save_exec_prefix="$exec_prefix"
+ exec_prefix="$acl_final_exec_prefix"
+
+ eval additional_includedir=\"$includedir\"
+ eval additional_libdir=\"$libdir\"
+
+ exec_prefix="$acl_save_exec_prefix"
+ prefix="$acl_save_prefix"
+
+ else
+ additional_includedir="$withval/include"
+ additional_libdir="$withval/lib"
+ fi
+ fi
+
+fi;
+ LIBICONV=
+ LTLIBICONV=
+ INCICONV=
+ rpathdirs=
+ ltrpathdirs=
+ names_already_handled=
+ names_next_round='iconv '
+ while test -n "$names_next_round"; do
+ names_this_round="$names_next_round"
+ names_next_round=
+ for name in $names_this_round; do
+ already_handled=
+ for n in $names_already_handled; do
+ if test "$n" = "$name"; then
+ already_handled=yes
+ break
+ fi
+ done
+ if test -z "$already_handled"; then
+ names_already_handled="$names_already_handled $name"
+ uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
+ eval value=\"\$HAVE_LIB$uppername\"
+ if test -n "$value"; then
+ if test "$value" = yes; then
+ eval value=\"\$LIB$uppername\"
+ test -z "$value" || LIBICONV="${LIBICONV}${LIBICONV:+ }$value"
+ eval value=\"\$LTLIB$uppername\"
+ test -z "$value" || LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }$value"
+ else
+ :
+ fi
+ else
+ found_dir=
+ found_la=
+ found_so=
+ found_a=
+ if test $use_additional = yes; then
+ if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then
+ found_dir="$additional_libdir"
+ found_so="$additional_libdir/lib$name.$shlibext"
+ if test -f "$additional_libdir/lib$name.la"; then
+ found_la="$additional_libdir/lib$name.la"
+ fi
+ else
+ if test -f "$additional_libdir/lib$name.$libext"; then
+ found_dir="$additional_libdir"
+ found_a="$additional_libdir/lib$name.$libext"
+ if test -f "$additional_libdir/lib$name.la"; then
+ found_la="$additional_libdir/lib$name.la"
+ fi
+ fi
+ fi
+ fi
+ if test "X$found_dir" = "X"; then
+ for x in $LDFLAGS $LTLIBICONV; do
+
+ acl_save_prefix="$prefix"
+ prefix="$acl_final_prefix"
+ acl_save_exec_prefix="$exec_prefix"
+ exec_prefix="$acl_final_exec_prefix"
+ eval x=\"$x\"
+ exec_prefix="$acl_save_exec_prefix"
+ prefix="$acl_save_prefix"
+
+ case "$x" in
+ -L*)
+ dir=`echo "X$x" | sed -e 's/^X-L//'`
+ if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then
+ found_dir="$dir"
+ found_so="$dir/lib$name.$shlibext"
+ if test -f "$dir/lib$name.la"; then
+ found_la="$dir/lib$name.la"
+ fi
+ else
+ if test -f "$dir/lib$name.$libext"; then
+ found_dir="$dir"
+ found_a="$dir/lib$name.$libext"
+ if test -f "$dir/lib$name.la"; then
+ found_la="$dir/lib$name.la"
+ fi
+ fi
+ fi
+ ;;
+ esac
+ if test "X$found_dir" != "X"; then
+ break
+ fi
+ done
+ fi
+ if test "X$found_dir" != "X"; then
+ LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-L$found_dir -l$name"
+ if test "X$found_so" != "X"; then
+ if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then
+ LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so"
+ else
+ haveit=
+ for x in $ltrpathdirs; do
+ if test "X$x" = "X$found_dir"; then
+ haveit=yes
+ break
+ fi
+ done
+ if test -z "$haveit"; then
+ ltrpathdirs="$ltrpathdirs $found_dir"
+ fi
+ if test "$hardcode_direct" = yes; then
+ LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so"
+ else
+ if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then
+ LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so"
+ haveit=
+ for x in $rpathdirs; do
+ if test "X$x" = "X$found_dir"; then
+ haveit=yes
+ break
+ fi
+ done
+ if test -z "$haveit"; then
+ rpathdirs="$rpathdirs $found_dir"
+ fi
+ else
+ haveit=
+ for x in $LDFLAGS $LIBICONV; do
+
+ acl_save_prefix="$prefix"
+ prefix="$acl_final_prefix"
+ acl_save_exec_prefix="$exec_prefix"
+ exec_prefix="$acl_final_exec_prefix"
+ eval x=\"$x\"
+ exec_prefix="$acl_save_exec_prefix"
+ prefix="$acl_save_prefix"
+
+ if test "X$x" = "X-L$found_dir"; then
+ haveit=yes
+ break
+ fi
+ done
+ if test -z "$haveit"; then
+ LIBICONV="${LIBICONV}${LIBICONV:+ }-L$found_dir"
+ fi
+ if test "$hardcode_minus_L" != no; then
+ LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so"
+ else
+ LIBICONV="${LIBICONV}${LIBICONV:+ }-l$name"
+ fi
+ fi
+ fi
+ fi
+ else
+ if test "X$found_a" != "X"; then
+ LIBICONV="${LIBICONV}${LIBICONV:+ }$found_a"
+ else
+ LIBICONV="${LIBICONV}${LIBICONV:+ }-L$found_dir -l$name"
+ fi
+ fi
+ additional_includedir=
+ case "$found_dir" in
+ */lib | */lib/)
+ basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'`
+ additional_includedir="$basedir/include"
+ ;;
+ esac
+ if test "X$additional_includedir" != "X"; then
+ if test "X$additional_includedir" != "X/usr/include"; then
+ haveit=
+ if test "X$additional_includedir" = "X/usr/local/include"; then
+ if test -n "$GCC"; then
+ case $host_os in
+ linux* | gnu* | k*bsd*-gnu) haveit=yes;;
+ esac
+ fi
+ fi
+ if test -z "$haveit"; then
+ for x in $CPPFLAGS $INCICONV; do
+
+ acl_save_prefix="$prefix"
+ prefix="$acl_final_prefix"
+ acl_save_exec_prefix="$exec_prefix"
+ exec_prefix="$acl_final_exec_prefix"
+ eval x=\"$x\"
+ exec_prefix="$acl_save_exec_prefix"
+ prefix="$acl_save_prefix"
+
+ if test "X$x" = "X-I$additional_includedir"; then
+ haveit=yes
+ break
+ fi
+ done
+ if test -z "$haveit"; then
+ if test -d "$additional_includedir"; then
+ INCICONV="${INCICONV}${INCICONV:+ }-I$additional_includedir"
+ fi
+ fi
+ fi
+ fi
+ fi
+ if test -n "$found_la"; then
+ save_libdir="$libdir"
+ case "$found_la" in
+ */* | *\\*) . "$found_la" ;;
+ *) . "./$found_la" ;;
+ esac
+ libdir="$save_libdir"
+ for dep in $dependency_libs; do
+ case "$dep" in
+ -L*)
+ additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
+ if test "X$additional_libdir" != "X/usr/lib"; then
+ haveit=
+ if test "X$additional_libdir" = "X/usr/local/lib"; then
+ if test -n "$GCC"; then
+ case $host_os in
+ linux* | gnu* | k*bsd*-gnu) haveit=yes;;
+ esac
+ fi
+ fi
+ if test -z "$haveit"; then
+ haveit=
+ for x in $LDFLAGS $LIBICONV; do
+
+ acl_save_prefix="$prefix"
+ prefix="$acl_final_prefix"
+ acl_save_exec_prefix="$exec_prefix"
+ exec_prefix="$acl_final_exec_prefix"
+ eval x=\"$x\"
+ exec_prefix="$acl_save_exec_prefix"
+ prefix="$acl_save_prefix"
+
+ if test "X$x" = "X-L$additional_libdir"; then
+ haveit=yes
+ break
+ fi
+ done
+ if test -z "$haveit"; then
+ if test -d "$additional_libdir"; then
+ LIBICONV="${LIBICONV}${LIBICONV:+ }-L$additional_libdir"
+ fi
+ fi
+ haveit=
+ for x in $LDFLAGS $LTLIBICONV; do
+
+ acl_save_prefix="$prefix"
+ prefix="$acl_final_prefix"
+ acl_save_exec_prefix="$exec_prefix"
+ exec_prefix="$acl_final_exec_prefix"
+ eval x=\"$x\"
+ exec_prefix="$acl_save_exec_prefix"
+ prefix="$acl_save_prefix"
+
+ if test "X$x" = "X-L$additional_libdir"; then
+ haveit=yes
+ break
+ fi
+ done
+ if test -z "$haveit"; then
+ if test -d "$additional_libdir"; then
+ LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-L$additional_libdir"
+ fi
+ fi
+ fi
+ fi
+ ;;
+ -R*)
+ dir=`echo "X$dep" | sed -e 's/^X-R//'`
+ if test "$enable_rpath" != no; then
+ haveit=
+ for x in $rpathdirs; do
+ if test "X$x" = "X$dir"; then
+ haveit=yes
+ break
+ fi
+ done
+ if test -z "$haveit"; then
+ rpathdirs="$rpathdirs $dir"
+ fi
+ haveit=
+ for x in $ltrpathdirs; do
+ if test "X$x" = "X$dir"; then
+ haveit=yes
+ break
+ fi
+ done
+ if test -z "$haveit"; then
+ ltrpathdirs="$ltrpathdirs $dir"
+ fi
+ fi
+ ;;
+ -l*)
+ names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
+ ;;
+ *.la)
+ names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
+ ;;
+ *)
+ LIBICONV="${LIBICONV}${LIBICONV:+ }$dep"
+ LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }$dep"
+ ;;
+ esac
+ done
+ fi
+ else
+ LIBICONV="${LIBICONV}${LIBICONV:+ }-l$name"
+ LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-l$name"
+ fi
+ fi
+ fi
+ done
+ done
+ if test "X$rpathdirs" != "X"; then
+ if test -n "$hardcode_libdir_separator"; then
+ alldirs=
+ for found_dir in $rpathdirs; do
+ alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir"
+ done
+ acl_save_libdir="$libdir"
+ libdir="$alldirs"
+ eval flag=\"$hardcode_libdir_flag_spec\"
+ libdir="$acl_save_libdir"
+ LIBICONV="${LIBICONV}${LIBICONV:+ }$flag"
+ else
+ for found_dir in $rpathdirs; do
+ acl_save_libdir="$libdir"
+ libdir="$found_dir"
+ eval flag=\"$hardcode_libdir_flag_spec\"
+ libdir="$acl_save_libdir"
+ LIBICONV="${LIBICONV}${LIBICONV:+ }$flag"
+ done
+ fi
+ fi
+ if test "X$ltrpathdirs" != "X"; then
+ for found_dir in $ltrpathdirs; do
+ LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-R$found_dir"
+ done
+ fi
+
+
+
+
+
+
+
+ am_save_CPPFLAGS="$CPPFLAGS"
+
+ for element in $INCICONV; do
+ haveit=
+ for x in $CPPFLAGS; do
+
+ acl_save_prefix="$prefix"
+ prefix="$acl_final_prefix"
+ acl_save_exec_prefix="$exec_prefix"
+ exec_prefix="$acl_final_exec_prefix"
+ eval x=\"$x\"
+ exec_prefix="$acl_save_exec_prefix"
+ prefix="$acl_save_prefix"
+
+ if test "X$x" = "X$element"; then
+ haveit=yes
+ break
+ fi
+ done
+ if test -z "$haveit"; then
+ CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element"
+ fi
+ done
+
+
+ echo "$as_me:$LINENO: checking for iconv" >&5
+echo $ECHO_N "checking for iconv... $ECHO_C" >&6
+if test "${am_cv_func_iconv+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+ am_cv_func_iconv="no, consider installing GNU libiconv"
+ am_cv_lib_iconv=no
+ cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
-
-/* Override any gcc2 internal prototype to avoid an error. */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char iconv ();
+#include <stdlib.h>
+#include <iconv.h>
int
main ()
{
-iconv ();
+iconv_t cd = iconv_open("","");
+ iconv(cd,NULL,NULL,NULL,NULL);
+ iconv_close(cd);
;
return 0;
}
@@ -3528,7 +4133,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
- ac_cv_search_iconv="none required"
+ am_cv_func_iconv=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
@@ -3536,27 +4141,23 @@ sed 's/^/| /' conftest.$ac_ext >&5
fi
rm -f conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
-if test "$ac_cv_search_iconv" = no; then
- for ac_lib in iconv; do
- LIBS="-l$ac_lib $ac_func_search_save_LIBS"
- cat >conftest.$ac_ext <<_ACEOF
+ if test "$am_cv_func_iconv" != yes; then
+ am_save_LIBS="$LIBS"
+ LIBS="$LIBS $LIBICONV"
+ cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
-
-/* Override any gcc2 internal prototype to avoid an error. */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char iconv ();
+#include <stdlib.h>
+#include <iconv.h>
int
main ()
{
-iconv ();
+iconv_t cd = iconv_open("","");
+ iconv(cd,NULL,NULL,NULL,NULL);
+ iconv_close(cd);
;
return 0;
}
@@ -3583,8 +4184,8 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
- ac_cv_search_iconv="-l$ac_lib"
-break
+ am_cv_lib_iconv=yes
+ am_cv_func_iconv=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
@@ -3592,21 +4193,111 @@ sed 's/^/| /' conftest.$ac_ext >&5
fi
rm -f conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
- done
-fi
-LIBS=$ac_func_search_save_LIBS
+ LIBS="$am_save_LIBS"
+ fi
+
fi
-echo "$as_me:$LINENO: result: $ac_cv_search_iconv" >&5
-echo "${ECHO_T}$ac_cv_search_iconv" >&6
-if test "$ac_cv_search_iconv" != no; then
- test "$ac_cv_search_iconv" = "none required" || LIBS="$ac_cv_search_iconv $LIBS"
+echo "$as_me:$LINENO: result: $am_cv_func_iconv" >&5
+echo "${ECHO_T}$am_cv_func_iconv" >&6
+ if test "$am_cv_func_iconv" = yes; then
cat >>confdefs.h <<\_ACEOF
#define HAVE_ICONV 1
_ACEOF
+ fi
+ if test "$am_cv_lib_iconv" = yes; then
+ echo "$as_me:$LINENO: checking how to link with libiconv" >&5
+echo $ECHO_N "checking how to link with libiconv... $ECHO_C" >&6
+ echo "$as_me:$LINENO: result: $LIBICONV" >&5
+echo "${ECHO_T}$LIBICONV" >&6
+ else
+ CPPFLAGS="$am_save_CPPFLAGS"
+ LIBICONV=
+ LTLIBICONV=
+ fi
+
+
+
+ if test "$am_cv_func_iconv" = yes; then
+ echo "$as_me:$LINENO: checking for iconv declaration" >&5
+echo $ECHO_N "checking for iconv declaration... $ECHO_C" >&6
+ if test "${am_cv_proto_iconv+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+#include <stdlib.h>
+#include <iconv.h>
+extern
+#ifdef __cplusplus
+"C"
+#endif
+#if defined(__STDC__) || defined(__cplusplus)
+size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
+#else
+size_t iconv();
+#endif
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ am_cv_proto_iconv_arg1=""
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+am_cv_proto_iconv_arg1="const"
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+ am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"
fi
+ am_cv_proto_iconv=`echo "$am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
+ echo "$as_me:$LINENO: result: ${ac_t:-
+ }$am_cv_proto_iconv" >&5
+echo "${ECHO_T}${ac_t:-
+ }$am_cv_proto_iconv" >&6
+
+cat >>confdefs.h <<_ACEOF
+#define ICONV_CONST $am_cv_proto_iconv_arg1
+_ACEOF
+
+ fi
+
echo "$as_me:$LINENO: checking for ANSI C header files" >&5
echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6
@@ -3850,158 +4541,10 @@ done
-for ac_header in auth.h inttypes.h shadow.h stdint.h
-do
-as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
- echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
-else
- # Is the header compilable?
-echo "$as_me:$LINENO: checking $ac_header usability" >&5
-echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-#include <$ac_header>
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag"
- || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_header_compiler=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_header_compiler=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
-echo "${ECHO_T}$ac_header_compiler" >&6
-
-# Is the header present?
-echo "$as_me:$LINENO: checking $ac_header presence" >&5
-echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <$ac_header>
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- ac_header_preproc=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_header_preproc=no
-fi
-rm -f conftest.err conftest.$ac_ext
-echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
-echo "${ECHO_T}$ac_header_preproc" >&6
-
-# So? What about this header?
-case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
- yes:no: )
- { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
-echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
- ac_header_preproc=yes
- ;;
- no:yes:* )
- { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
-echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
-echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
-echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
-echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
-echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
- (
- cat <<\_ASBOX
-## ------------------------------------------ ##
-## Report this to the AC_PACKAGE_NAME lists. ##
-## ------------------------------------------ ##
-_ASBOX
- ) |
- sed "s/^/$as_me: WARNING: /" >&2
- ;;
-esac
-echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- eval "$as_ac_Header=\$ac_header_preproc"
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
-
-fi
-if test `eval echo '${'$as_ac_Header'}'` = yes; then
- cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-
-done
-for ac_header in utmpx.h utmp.h
+for ac_header in auth.h crypt.h inttypes.h shadow.h stdint.h utmp.h utmpx.h
do
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
if eval "test \"\${$as_ac_Header+set}\" = set"; then
@@ -4122,9 +4665,9 @@ echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&
echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
(
cat <<\_ASBOX
-## ------------------------------------------ ##
-## Report this to the AC_PACKAGE_NAME lists. ##
-## ------------------------------------------ ##
+## ---------------------------------- ##
+## Report this to http://bugs.gw.com/ ##
+## ---------------------------------- ##
_ASBOX
) |
sed "s/^/$as_me: WARNING: /" >&2
@@ -4272,9 +4815,9 @@ echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&
echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
(
cat <<\_ASBOX
-## ------------------------------------------ ##
-## Report this to the AC_PACKAGE_NAME lists. ##
-## ------------------------------------------ ##
+## ---------------------------------- ##
+## Report this to http://bugs.gw.com/ ##
+## ---------------------------------- ##
_ASBOX
) |
sed "s/^/$as_me: WARNING: /" >&2
@@ -4845,9 +5388,9 @@ echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&
echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
(
cat <<\_ASBOX
-## ------------------------------------------ ##
-## Report this to the AC_PACKAGE_NAME lists. ##
-## ------------------------------------------ ##
+## ---------------------------------- ##
+## Report this to http://bugs.gw.com/ ##
+## ---------------------------------- ##
_ASBOX
) |
sed "s/^/$as_me: WARNING: /" >&2
@@ -5688,75 +6231,6 @@ _ACEOF
fi
-echo "$as_me:$LINENO: checking return type of signal handlers" >&5
-echo $ECHO_N "checking return type of signal handlers... $ECHO_C" >&6
-if test "${ac_cv_type_signal+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <sys/types.h>
-#include <signal.h>
-#ifdef signal
-# undef signal
-#endif
-#ifdef __cplusplus
-extern "C" void (*signal (int, void (*)(int)))(int);
-#else
-void (*signal ()) ();
-#endif
-
-int
-main ()
-{
-int i;
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag"
- || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_type_signal=void
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_type_signal=int
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $ac_cv_type_signal" >&5
-echo "${ECHO_T}$ac_cv_type_signal" >&6
-
-cat >>confdefs.h <<_ACEOF
-#define RETSIGTYPE $ac_cv_type_signal
-_ACEOF
-
-
echo "$as_me:$LINENO: checking for size_t" >&5
echo $ECHO_N "checking for size_t... $ECHO_C" >&6
if test "${ac_cv_type_size_t+set}" = set; then
@@ -5864,6 +6338,79 @@ fi
+echo "$as_me:$LINENO: checking for ssize_t" >&5
+echo $ECHO_N "checking for ssize_t... $ECHO_C" >&6
+if test "${ac_cv_type_ssize_t+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+#include <sys/types.h>
+
+
+int
+main ()
+{
+if ((ssize_t *) 0)
+ return 0;
+if (sizeof (ssize_t))
+ return 0;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_type_ssize_t=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_type_ssize_t=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_type_ssize_t" >&5
+echo "${ECHO_T}$ac_cv_type_ssize_t" >&6
+if test $ac_cv_type_ssize_t = yes; then
+ :
+else
+
+cat >>confdefs.h <<\_ACEOF
+#define ssize_t int
+_ACEOF
+
+fi
+
+
+
+
+
echo "$as_me:$LINENO: checking for socklen_t" >&5
echo $ECHO_N "checking for socklen_t... $ECHO_C" >&6
if test "${ac_cv_type_socklen_t+set}" = set; then
@@ -6078,6 +6625,7 @@ _ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
+#include <sys/types.h>
#ifdef HAVE_UTMPX_H
#include <utmpx.h>
#define utmp utmpx
@@ -6128,6 +6676,7 @@ _ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
+#include <sys/types.h>
#ifdef HAVE_UTMPX_H
#include <utmpx.h>
#define utmp utmpx
@@ -6199,6 +6748,7 @@ _ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
+#include <sys/types.h>
#ifdef HAVE_UTMPX_H
#include <utmpx.h>
#define utmp utmpx
@@ -6249,6 +6799,7 @@ _ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
+#include <sys/types.h>
#ifdef HAVE_UTMPX_H
#include <utmpx.h>
#define utmp utmpx
@@ -6320,6 +6871,7 @@ _ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
+#include <sys/types.h>
#ifdef HAVE_UTMPX_H
#include <utmpx.h>
#define utmp utmpx
@@ -6370,6 +6922,7 @@ _ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
+#include <sys/types.h>
#ifdef HAVE_UTMPX_H
#include <utmpx.h>
#define utmp utmpx
@@ -6441,6 +6994,7 @@ _ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
+#include <sys/types.h>
#ifdef HAVE_UTMPX_H
#include <utmpx.h>
#define utmp utmpx
@@ -6491,6 +7045,7 @@ _ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
+#include <sys/types.h>
#ifdef HAVE_UTMPX_H
#include <utmpx.h>
#define utmp utmpx
@@ -6774,26 +7329,6 @@ _ACEOF
fi
-echo "$as_me:$LINENO: checking for function prototypes" >&5
-echo $ECHO_N "checking for function prototypes... $ECHO_C" >&6
-if test "$ac_cv_prog_cc_stdc" != no; then
- echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
-
-cat >>confdefs.h <<\_ACEOF
-#define PROTOTYPES 1
-_ACEOF
-
-
-cat >>confdefs.h <<\_ACEOF
-#define __PROTOTYPES 1
-_ACEOF
-
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
echo "$as_me:$LINENO: checking for working volatile" >&5
echo $ECHO_N "checking for working volatile... $ECHO_C" >&6
if test "${ac_cv_c_volatile+set}" = set; then
@@ -6858,6 +7393,158 @@ _ACEOF
fi
+echo "$as_me:$LINENO: checking whether crypt is declared" >&5
+echo $ECHO_N "checking whether crypt is declared... $ECHO_C" >&6
+if test "${ac_cv_have_decl_crypt+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include "config_p.h"
+$ac_includes_default
+#ifdef HAVE_CRYPT_H
+#include <crypt.h>
+#endif
+
+
+int
+main ()
+{
+#ifndef crypt
+ char *p = (char *) crypt;
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_have_decl_crypt=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_have_decl_crypt=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_have_decl_crypt" >&5
+echo "${ECHO_T}$ac_cv_have_decl_crypt" >&6
+if test $ac_cv_have_decl_crypt = yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_CRYPT 1
+_ACEOF
+
+
+else
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_CRYPT 0
+_ACEOF
+
+
+fi
+echo "$as_me:$LINENO: checking whether environ is declared" >&5
+echo $ECHO_N "checking whether environ is declared... $ECHO_C" >&6
+if test "${ac_cv_have_decl_environ+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include "config_p.h"
+$ac_includes_default
+#ifdef HAVE_CRYPT_H
+#include <crypt.h>
+#endif
+
+
+int
+main ()
+{
+#ifndef environ
+ char *p = (char *) environ;
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_have_decl_environ=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_have_decl_environ=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_have_decl_environ" >&5
+echo "${ECHO_T}$ac_cv_have_decl_environ" >&6
+if test $ac_cv_have_decl_environ = yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_ENVIRON 1
+_ACEOF
+
+
+else
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_ENVIRON 0
+_ACEOF
+
+
+fi
echo "$as_me:$LINENO: checking whether gethostname is declared" >&5
echo $ECHO_N "checking whether gethostname is declared... $ECHO_C" >&6
if test "${ac_cv_have_decl_gethostname+set}" = set; then
@@ -6869,7 +7556,13 @@ _ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
+#include "config_p.h"
$ac_includes_default
+#ifdef HAVE_CRYPT_H
+#include <crypt.h>
+#endif
+
+
int
main ()
{
@@ -6928,25 +7621,199 @@ _ACEOF
fi
+echo "$as_me:$LINENO: checking whether getpgrp is declared" >&5
+echo $ECHO_N "checking whether getpgrp is declared... $ECHO_C" >&6
+if test "${ac_cv_have_decl_getpgrp+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include "config_p.h"
+$ac_includes_default
+#ifdef HAVE_CRYPT_H
+#include <crypt.h>
+#endif
+int
+main ()
+{
+#ifndef getpgrp
+ char *p = (char *) getpgrp;
+#endif
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_have_decl_getpgrp=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+ac_cv_have_decl_getpgrp=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_have_decl_getpgrp" >&5
+echo "${ECHO_T}$ac_cv_have_decl_getpgrp" >&6
+if test $ac_cv_have_decl_getpgrp = yes; then
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_GETPGRP 1
+_ACEOF
+else
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_GETPGRP 0
+_ACEOF
+fi
+echo "$as_me:$LINENO: checking for setlocale" >&5
+echo $ECHO_N "checking for setlocale... $ECHO_C" >&6
+if test "${ac_cv_func_setlocale+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+/* Define setlocale to an innocuous variant, in case <limits.h> declares setlocale.
+ For example, HP-UX 11i <limits.h> declares gettimeofday. */
+#define setlocale innocuous_setlocale
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char setlocale (); below.
+ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ <limits.h> exists even on freestanding compilers. */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef setlocale
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char setlocale ();
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_setlocale) || defined (__stub___setlocale)
+choke me
+#else
+char (*f) () = setlocale;
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+int
+main ()
+{
+return f != setlocale;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_func_setlocale=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_func_setlocale=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_func_setlocale" >&5
+echo "${ECHO_T}$ac_cv_func_setlocale" >&6
+if test $ac_cv_func_setlocale = yes; then
+ have_setlocale=yes
+else
+ have_setlocale=no
+fi
-for ac_func in dup2 getcwd gethostname getpwent getutent memmove memset nice nl_langinfo sbrk setpgid setpriority strerror strstr sysconf wcwidth
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+for ac_func in catgets dup2 getauthid getcwd gethostname getpwent getutent memmove memset nice nl_langinfo sbrk setpgid setpriority strerror strstr sysconf wcwidth
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
echo "$as_me:$LINENO: checking for $ac_func" >&5
@@ -7110,6 +7977,69 @@ _ACEOF
fi
+
+ echo "$as_me:$LINENO: checking whether mbrtowc and mbstate_t are properly declared" >&5
+echo $ECHO_N "checking whether mbrtowc and mbstate_t are properly declared... $ECHO_C" >&6
+if test "${ac_cv_func_mbrtowc+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <wchar.h>
+int
+main ()
+{
+mbstate_t state; return ! (sizeof state && mbrtowc);
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_func_mbrtowc=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_func_mbrtowc=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_func_mbrtowc" >&5
+echo "${ECHO_T}$ac_cv_func_mbrtowc" >&6
+ if test $ac_cv_func_mbrtowc = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_MBRTOWC 1
+_ACEOF
+
+ fi
+
echo "$as_me:$LINENO: checking whether setpgrp takes no argument" >&5
echo $ECHO_N "checking whether setpgrp takes no argument... $ECHO_C" >&6
if test "${ac_cv_func_setpgrp_void+set}" = set; then
@@ -7174,9 +8104,84 @@ _ACEOF
fi
+echo "$as_me:$LINENO: checking for working strcoll" >&5
+echo $ECHO_N "checking for working strcoll... $ECHO_C" >&6
+if test "${ac_cv_func_strcoll_works+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test "$cross_compiling" = yes; then
+ ac_cv_func_strcoll_works=no
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+exit (strcoll ("abc", "def") >= 0 ||
+ strcoll ("ABC", "DEF") >= 0 ||
+ strcoll ("123", "456") >= 0)
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_func_strcoll_works=yes
+else
+ echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+( exit $ac_status )
+ac_cv_func_strcoll_works=no
+fi
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+fi
+echo "$as_me:$LINENO: result: $ac_cv_func_strcoll_works" >&5
+echo "${ECHO_T}$ac_cv_func_strcoll_works" >&6
+if test $ac_cv_func_strcoll_works = yes; then
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_STRCOLL 1
+_ACEOF
+
+fi
+
+
+
+
+
+if test "$have_setlocale" != no; then
+ # Check whether --enable-nls or --disable-nls was given.
+if test "${enable_nls+set}" = set; then
+ enableval="$enable_nls"
+else
+ enable_nls=yes
+fi;
+ if test "x$enable_nls" != xno; then
+
+cat >>confdefs.h <<\_ACEOF
+#define NLS 1
+_ACEOF
+
+ fi
+fi
# Check whether --with-hesiod or --without-hesiod was given.
@@ -7724,7 +8729,7 @@ _ASBOX
} >&5
cat >&5 <<_CSEOF
-This file was extended by $as_me, which was
+This file was extended by tcsh $as_me 6.15.00, which was
generated by GNU Autoconf 2.59. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -7779,12 +8784,15 @@ $config_files
Configuration headers:
$config_headers
+Configuration commands:
+$config_commands
+
Report bugs to <bug-autoconf@gnu.org>."
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\
-config.status
+tcsh config.status 6.15.00
configured by $0, generated by GNU Autoconf 2.59,
with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
@@ -7887,6 +8895,7 @@ do
case "$ac_config_target" in
# Handling of arguments.
"Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;;
+ "./atconfig" ) CONFIG_COMMANDS="$CONFIG_COMMANDS ./atconfig" ;;
"config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
*) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
@@ -7901,6 +8910,7 @@ done
if $ac_need_defaults; then
test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
+ test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands
fi
# Have a temporary directory for convenience. Make it in the build tree
@@ -7989,6 +8999,8 @@ s,@EXEEXT@,$EXEEXT,;t t
s,@OBJEXT@,$OBJEXT,;t t
s,@CPP@,$CPP,;t t
s,@EGREP@,$EGREP,;t t
+s,@LIBICONV@,$LIBICONV,;t t
+s,@LTLIBICONV@,$LTLIBICONV,;t t
s,@DFLAGS@,$DFLAGS,;t t
s,@HESDEF@,$HESDEF,;t t
s,@HESLIB@,$HESLIB,;t t
@@ -8450,6 +9462,143 @@ echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
fi
done
_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
+
+#
+# CONFIG_COMMANDS section.
+#
+for ac_file in : $CONFIG_COMMANDS; do test "x$ac_file" = x: && continue
+ ac_dest=`echo "$ac_file" | sed 's,:.*,,'`
+ ac_source=`echo "$ac_file" | sed 's,[^:]*:,,'`
+ ac_dir=`(dirname "$ac_dest") 2>/dev/null ||
+$as_expr X"$ac_dest" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$ac_dest" : 'X\(//\)[^/]' \| \
+ X"$ac_dest" : 'X\(//\)$' \| \
+ X"$ac_dest" : 'X\(/\)' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X"$ac_dest" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+ /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+ /^X\(\/\/\)$/{ s//\1/; q; }
+ /^X\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`
+ { if $as_mkdir_p; then
+ mkdir -p "$ac_dir"
+ else
+ as_dir="$ac_dir"
+ as_dirs=
+ while test ! -d "$as_dir"; do
+ as_dirs="$as_dir $as_dirs"
+ as_dir=`(dirname "$as_dir") 2>/dev/null ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$as_dir" : 'X\(//\)[^/]' \| \
+ X"$as_dir" : 'X\(//\)$' \| \
+ X"$as_dir" : 'X\(/\)' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X"$as_dir" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+ /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+ /^X\(\/\/\)$/{ s//\1/; q; }
+ /^X\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`
+ done
+ test ! -n "$as_dirs" || mkdir $as_dirs
+ fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
+echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
+ { (exit 1); exit 1; }; }; }
+
+ ac_builddir=.
+
+if test "$ac_dir" != .; then
+ ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
+ # A "../" for each directory in $ac_dir_suffix.
+ ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
+else
+ ac_dir_suffix= ac_top_builddir=
+fi
+
+case $srcdir in
+ .) # No --srcdir option. We are building in place.
+ ac_srcdir=.
+ if test -z "$ac_top_builddir"; then
+ ac_top_srcdir=.
+ else
+ ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
+ fi ;;
+ [\\/]* | ?:[\\/]* ) # Absolute path.
+ ac_srcdir=$srcdir$ac_dir_suffix;
+ ac_top_srcdir=$srcdir ;;
+ *) # Relative path.
+ ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
+ ac_top_srcdir=$ac_top_builddir$srcdir ;;
+esac
+
+# Do not use `cd foo && pwd` to compute absolute paths, because
+# the directories may not exist.
+case `pwd` in
+.) ac_abs_builddir="$ac_dir";;
+*)
+ case "$ac_dir" in
+ .) ac_abs_builddir=`pwd`;;
+ [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";;
+ *) ac_abs_builddir=`pwd`/"$ac_dir";;
+ esac;;
+esac
+case $ac_abs_builddir in
+.) ac_abs_top_builddir=${ac_top_builddir}.;;
+*)
+ case ${ac_top_builddir}. in
+ .) ac_abs_top_builddir=$ac_abs_builddir;;
+ [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;;
+ *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;;
+ esac;;
+esac
+case $ac_abs_builddir in
+.) ac_abs_srcdir=$ac_srcdir;;
+*)
+ case $ac_srcdir in
+ .) ac_abs_srcdir=$ac_abs_builddir;;
+ [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;;
+ *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;;
+ esac;;
+esac
+case $ac_abs_builddir in
+.) ac_abs_top_srcdir=$ac_top_srcdir;;
+*)
+ case $ac_top_srcdir in
+ .) ac_abs_top_srcdir=$ac_abs_builddir;;
+ [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;;
+ *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;;
+ esac;;
+esac
+
+
+ { echo "$as_me:$LINENO: executing $ac_dest commands" >&5
+echo "$as_me: executing $ac_dest commands" >&6;}
+ case $ac_dest in
+ ./atconfig ) cat >./atconfig <<ATEOF
+# Configurable variable values for building test suites.
+# Generated by $0.
+# Copyright (C) 2000, 2001, 2003 Free Software Foundation, Inc.
+
+# The test suite will define top_srcdir=$at_top_srcdir/../.. etc.
+at_testdir='.'
+abs_builddir='$ac_abs_builddir'
+at_srcdir='$ac_srcdir'
+abs_srcdir='$ac_abs_srcdir'
+at_top_srcdir='$ac_top_srcdir'
+abs_top_srcdir='$ac_abs_top_srcdir'
+at_top_builddir='$ac_top_builddir'
+abs_top_builddir='$ac_abs_top_builddir'
+
+AUTOTEST_PATH='.'
+
+SHELL=\${CONFIG_SHELL-'$SHELL'}
+ATEOF
+ ;;
+ esac
+done
+_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF
diff --git a/contrib/tcsh/configure.in b/contrib/tcsh/configure.in
index bc5e398..604ac71 100644
--- a/contrib/tcsh/configure.in
+++ b/contrib/tcsh/configure.in
@@ -9,9 +9,10 @@ dnl Written by Kaveh Ghazi (ghazi@caip.rutgers.edu) 5/11/96.
dnl
AC_PREREQ([2.59])dnl Minimum Autoconf version required.
-AC_INIT
+AC_INIT([tcsh], [6.15.00], [http://bugs.gw.com/])
AC_CONFIG_SRCDIR([tc.vers.c])
AC_CONFIG_HEADERS([config.h])
+AC_CONFIG_TESTDIR([.], [.])
AC_CANONICAL_HOST
@@ -120,6 +121,11 @@ case "${host}" in
tcsh_config_file=bsd4.4
;;
+ ## DragonFly systems
+ *-*-dragonfly*)
+ tcsh_config_file=bsd4.4
+ ;;
+
## Silicon Graphics machines
*-sgi-iri* )
tcsh_config_file=irix
@@ -150,16 +156,16 @@ case "${host}" in
*-sun-sunos4.1.[3456]* )
tcsh_config_file=sunos413
;;
- *-*-solaris2.[01]* ) # Should handle sparc or x86
+ *-*-solaris2.[01] ) # Should handle sparc or x86
tcsh_config_file=sol2
;;
- *-sun-solaris2.2* ) # Sparc only release
+ *-sun-solaris2.2 ) # Sparc only release
tcsh_config_file=sol22
;;
- *-sun-solaris2.3* ) # Sparc only release
+ *-sun-solaris2.3 ) # Sparc only release
tcsh_config_file=sol23
;;
- *-*-solaris2.[45]* ) # Should handle sparc, x86 and powerpc
+ *-*-solaris2.[45] ) # Should handle sparc, x86 and powerpc
tcsh_config_file=sol24
;;
*-*-solaris2.* ) # Should handle sparc, x86 and powerpc
@@ -260,12 +266,10 @@ AC_SEARCH_LIBS(getspnam, sec)
AC_SEARCH_LIBS(tgetent, termlib termcap curses ncurses)
AC_SEARCH_LIBS(gethostbyname, nsl)
AC_SEARCH_LIBS(connect, socket)
-AC_SEARCH_LIBS([iconv], [iconv], [AC_DEFINE([HAVE_ICONV], [1],
- [Define to 1 if you have the iconv () interface])])
+AM_ICONV
dnl Checks for header files
-AC_CHECK_HEADERS([auth.h inttypes.h shadow.h stdint.h])
-AC_CHECK_HEADERS([utmpx.h utmp.h])
+AC_CHECK_HEADERS([auth.h crypt.h inttypes.h shadow.h stdint.h utmp.h utmpx.h])
AC_CHECK_HEADERS([wchar.h],
[AC_CHECK_SIZEOF([wchar_t], [], [dnl
#include <stdio.h>
@@ -279,10 +283,18 @@ dnl Checks for types
AC_CHECK_TYPES([long long])
AC_TYPE_GETGROUPS
AC_TYPE_MODE_T
-AC_TYPE_SIGNAL
AC_TYPE_SIZE_T
AC_TYPE_UID_T
+AC_DEFUN([AC_TYPE_SSIZE_T], [
+AC_CHECK_TYPE(ssize_t,,
+AC_DEFINE(ssize_t, int, [Define to `int' not defined in <sys/types.h>.]),
+[
+#include <sys/types.h>
+])
+])
+AC_TYPE_SSIZE_T
+
AC_DEFUN([AC_TYPE_SOCKLEN_T], [
AC_CHECK_TYPE(socklen_t,,
AC_DEFINE(socklen_t, int, [Define to `int' if neither <sys/types.h> nor <sys/socket.h> define.]),
@@ -308,7 +320,8 @@ AC_CHECK_MEMBERS([struct dirent.d_ino], , ,
#endif])
AC_CHECK_MEMBERS([struct utmp.ut_host, struct utmp.ut_user, struct utmp.ut_tv,
struct utmp.ut_xtime], , ,
-[#ifdef HAVE_UTMPX_H
+[#include <sys/types.h>
+#ifdef HAVE_UTMPX_H
#include <utmpx.h>
#define utmp utmpx
#elif defined HAVE_UTMP_H
@@ -320,16 +333,24 @@ AC_CHECK_MEMBERS([struct sockaddr_storage.ss_family], , ,
dnl Checks for compiler characteristics
AC_C_CONST
-AC_C_PROTOTYPES
AC_C_VOLATILE
dnl checks for library functions
-AC_CHECK_DECLS([gethostname])
-AC_CHECK_FUNCS([dup2 getcwd gethostname getpwent getutent memmove memset] dnl
- [nice nl_langinfo sbrk setpgid setpriority strerror strstr sysconf] dnl
- [wcwidth])
+AC_CHECK_DECLS([crypt, environ, gethostname, getpgrp], , ,
+[#include "config_p.h"
+AC_INCLUDES_DEFAULT([])
+#ifdef HAVE_CRYPT_H
+#include <crypt.h>
+#endif
+])
+AC_CHECK_FUNC([setlocale], [have_setlocale=yes], [have_setlocale=no])
+AC_CHECK_FUNCS([catgets dup2 getauthid getcwd gethostname getpwent] dnl
+ [getutent memmove memset nice nl_langinfo sbrk setpgid setpriority] dnl
+ [strerror strstr sysconf wcwidth])
AC_FUNC_GETPGRP
+AC_FUNC_MBRTOWC
AC_FUNC_SETPGRP
+AC_FUNC_STRCOLL
dnl This is not good enough; we need sockaddr_storage too.
dnl See whether we can use IPv6 related functions
@@ -379,6 +400,15 @@ dnl IPv6_CHECK_FUNC(getnameinfo, DFLAGS="$DFLAGS -DINET6")
AC_SUBST(DFLAGS)
+dnl Checks for system services
+if test "$have_setlocale" != no; then
+ AC_ARG_ENABLE([nls], AS_HELP_STRING([--disable-nls], [Disable NLS support]),
+ [], [enable_nls=yes])
+ if test "x$enable_nls" != xno; then
+ AC_DEFINE([NLS], [1], [Support NLS.])
+ fi
+fi
+
AC_ARG_WITH(hesiod,
[ --with-hesiod=PREFIX Use Hesiod lookup for ~ expansion],
[hesiod="$withval"], [hesiod=no])
diff --git a/contrib/tcsh/ed.chared.c b/contrib/tcsh/ed.chared.c
index 2585d94..9f09c68 100644
--- a/contrib/tcsh/ed.chared.c
+++ b/contrib/tcsh/ed.chared.c
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/ed.chared.c,v 3.83 2005/03/03 16:21:08 kim Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/ed.chared.c,v 3.93 2006/08/23 15:03:13 christos Exp $ */
/*
* ed.chared.c: Character editing functions.
*/
@@ -72,7 +72,7 @@
#include "sh.h"
-RCSID("$Id: ed.chared.c,v 3.83 2005/03/03 16:21:08 kim Exp $")
+RCSID("$tcsh: ed.chared.c,v 3.93 2006/08/23 15:03:13 christos Exp $")
#include "ed.h"
#include "tw.h"
@@ -103,8 +103,7 @@ static int ActionFlag = TCSHOP_NOP; /* What delayed action to take */
* Word search state
*/
static int searchdir = F_UP_SEARCH_HIST; /* Direction of last search */
-static Char patbuf[INBUFSIZE]; /* Search target */
-static int patlen = 0;
+static struct Strbuf patbuf; /* = Strbuf_INIT; Search target */
/*
* Char search state
*/
@@ -112,41 +111,42 @@ static int srch_dir = CHAR_FWD; /* Direction of last search */
static Char srch_char = 0; /* Search target */
/* all routines that start with c_ are private to this set of routines */
-static void c_alternativ_key_map __P((int));
-void c_insert __P((int));
-void c_delafter __P((int));
-void c_delbefore __P((int));
-static int c_to_class __P((Char));
-static Char *c_prev_word __P((Char *, Char *, int));
-static Char *c_next_word __P((Char *, Char *, int));
-static Char *c_number __P((Char *, int *, int));
-static Char *c_expand __P((Char *));
-static void c_excl __P((Char *));
-static void c_substitute __P((void));
-static void c_delfini __P((void));
-static int c_hmatch __P((Char *));
-static void c_hsetpat __P((void));
+static void c_alternativ_key_map (int);
+void c_insert (int);
+void c_delafter (int);
+void c_delbefore (int);
+static int c_to_class (Char);
+static Char *c_prev_word (Char *, Char *, int);
+static Char *c_next_word (Char *, Char *, int);
+static Char *c_number (Char *, int *, int);
+static Char *c_expand (Char *);
+static void c_excl (Char *);
+static void c_substitute (void);
+static void c_delfini (void);
+static int c_hmatch (Char *);
+static void c_hsetpat (void);
#ifdef COMMENT
-static void c_get_word __P((Char **, Char **));
+static void c_get_word (Char **, Char **);
#endif
-static Char *c_preword __P((Char *, Char *, int, Char *));
-static Char *c_nexword __P((Char *, Char *, int));
-static Char *c_endword __P((Char *, Char *, int, Char *));
-static Char *c_eword __P((Char *, Char *, int));
-static void c_push_kill __P((Char *, Char *));
-static CCRETVAL c_get_histline __P((void));
-static CCRETVAL c_search_line __P((Char *, int));
-static CCRETVAL v_repeat_srch __P((int));
-static CCRETVAL e_inc_search __P((int));
-static CCRETVAL e_insert_str __P((Char *));
-static CCRETVAL v_search __P((int));
-static CCRETVAL v_csearch_fwd __P((Char, int, int));
-static CCRETVAL v_action __P((int));
-static CCRETVAL v_csearch_back __P((Char, int, int));
+static Char *c_preword (Char *, Char *, int, Char *);
+static Char *c_nexword (Char *, Char *, int);
+static Char *c_endword (Char *, Char *, int, Char *);
+static Char *c_eword (Char *, Char *, int);
+static void c_push_kill (Char *, Char *);
+static void c_save_inputbuf (void);
+static CCRETVAL c_search_line (Char *, int);
+static CCRETVAL v_repeat_srch (int);
+static CCRETVAL e_inc_search (int);
+#ifdef notyet
+static CCRETVAL e_insert_str (Char *);
+#endif
+static CCRETVAL v_search (int);
+static CCRETVAL v_csearch_fwd (Char, int, int);
+static CCRETVAL v_action (int);
+static CCRETVAL v_csearch_back (Char, int, int);
static void
-c_alternativ_key_map(state)
- int state;
+c_alternativ_key_map(int state)
{
switch (state) {
case 0:
@@ -163,8 +163,7 @@ c_alternativ_key_map(state)
}
void
-c_insert(num)
- int num;
+c_insert(int num)
{
Char *cp;
@@ -181,8 +180,7 @@ c_insert(num)
}
void
-c_delafter(num)
- int num;
+c_delafter(int num)
{
Char *cp, *kp = NULL;
@@ -190,7 +188,6 @@ c_delafter(num)
num = (int) (LastChar - Cursor); /* bounds check */
if (num > 0) { /* if I can delete anything */
- num = NLSExtend(Cursor, LastChar - Cursor, num);
if (VImode) {
kp = UndoBuf; /* Set Up for VI undo command */
UndoAction = TCSHOP_INSERT;
@@ -205,7 +202,11 @@ c_delafter(num)
for (cp = Cursor; cp + num <= LastChar; cp++)
*cp = cp[num];
LastChar -= num;
- if (Mark && Mark > Cursor)
+ /* Mark was within the range of the deleted word? */
+ if (Mark && Mark > Cursor && Mark <= Cursor+num)
+ Mark = Cursor;
+ /* Mark after the deleted word? */
+ else if (Mark && Mark > Cursor)
Mark -= num;
}
#ifdef notdef
@@ -220,8 +221,7 @@ c_delafter(num)
}
void
-c_delbefore(num) /* delete before dot, with bounds checking */
- int num;
+c_delbefore(int num) /* delete before dot, with bounds checking */
{
Char *cp, *kp = NULL;
@@ -229,7 +229,6 @@ c_delbefore(num) /* delete before dot, with bounds checking */
num = (int) (Cursor - InputBuf); /* bounds check */
if (num > 0) { /* if I can delete anything */
- num = NLSExtend(Cursor, Cursor - InputBuf, -num);
if (VImode) {
kp = UndoBuf; /* Set Up for VI undo command */
UndoAction = TCSHOP_INSERT;
@@ -245,15 +244,17 @@ c_delbefore(num) /* delete before dot, with bounds checking */
*cp = cp[num];
LastChar -= num;
Cursor -= num;
- if (Mark && Mark > Cursor)
+ /* Mark was within the range of the deleted word? */
+ if (Mark && Mark > Cursor && Mark <= Cursor+num)
+ Mark = Cursor;
+ /* Mark after the deleted word? */
+ else if (Mark && Mark > Cursor)
Mark -= num;
}
}
static Char *
-c_preword(p, low, n, delim)
- Char *p, *low, *delim;
- int n;
+c_preword(Char *p, Char *low, int n, Char *delim)
{
while (n--) {
Char *prev = low;
@@ -299,8 +300,7 @@ c_preword(p, low, n, delim)
* 3/ others
*/
static int
-c_to_class(ch)
-Char ch;
+c_to_class(Char ch)
{
if (Isspace(ch))
return C_CLASS_WHITE;
@@ -312,9 +312,7 @@ Char ch;
}
static Char *
-c_prev_word(p, low, n)
- Char *p, *low;
- int n;
+c_prev_word(Char *p, Char *low, int n)
{
p--;
@@ -361,9 +359,7 @@ c_prev_word(p, low, n)
}
static Char *
-c_next_word(p, high, n)
- Char *p, *high;
- int n;
+c_next_word(Char *p, Char *high, int n)
{
if (!VImode) {
while (n--) {
@@ -404,9 +400,7 @@ c_next_word(p, high, n)
}
static Char *
-c_nexword(p, high, n)
- Char *p, *high;
- int n;
+c_nexword(Char *p, Char *high, int n)
{
while (n--) {
while ((p < high) && !Isspace(*p))
@@ -438,10 +432,7 @@ c_nexword(p, high, n)
*/
static Char *
-c_number(p, num, dval)
- Char *p;
- int *num;
- int dval;
+c_number(Char *p, int *num, int dval)
{
int i;
int sign = 1;
@@ -452,7 +443,7 @@ c_number(p, num, dval)
}
if (*p == '$') {
if (*++p != '-') {
- *num = NCARGS; /* Handle $ */
+ *num = INT_MAX; /* Handle $ */
return(--p);
}
sign = -1; /* Handle $- */
@@ -471,8 +462,7 @@ c_number(p, num, dval)
*/
static Char *
-c_expand(p)
- Char *p;
+c_expand(Char *p)
{
Char *q;
struct Hist *h = Histlist.Hnext;
@@ -481,32 +471,33 @@ c_expand(p)
int all_dig;
int been_once = 0;
Char *op = p;
- Char buf[INBUFSIZE];
- Char *bend = buf;
- Char *modbuf, *omodbuf;
+ Char *buf;
+ size_t buf_len;
+ Char *modbuf;
+ buf = NULL;
if (!h)
goto excl_err;
excl_sw:
switch (*(q = p + 1)) {
case '^':
- bend = expand_lex(buf, INBUFSIZE, &h->Hlex, 1, 1);
+ buf = expand_lex(&h->Hlex, 1, 1);
break;
case '$':
if ((l = (h->Hlex).prev) != 0)
- bend = expand_lex(buf, INBUFSIZE, l->prev->prev, 0, 0);
+ buf = expand_lex(l->prev->prev, 0, 0);
break;
case '*':
- bend = expand_lex(buf, INBUFSIZE, &h->Hlex, 1, NCARGS);
+ buf = expand_lex(&h->Hlex, 1, INT_MAX);
break;
default:
if (been_once) { /* unknown argument */
/* assume it's a modifier, e.g. !foo:h, and get whole cmd */
- bend = expand_lex(buf, INBUFSIZE, &h->Hlex, 0, NCARGS);
+ buf = expand_lex(&h->Hlex, 0, INT_MAX);
q -= 2;
break;
}
@@ -599,27 +590,27 @@ excl_sw:
}
else if (q[1] == '*') {
++q;
- to = NCARGS;
+ to = INT_MAX;
}
else {
to = from;
}
if (from < 0 || to < from)
goto excl_err;
- bend = expand_lex(buf, INBUFSIZE, &h->Hlex, from, to);
- }
- else { /* get whole cmd */
- bend = expand_lex(buf, INBUFSIZE, &h->Hlex, 0, NCARGS);
+ buf = expand_lex(&h->Hlex, from, to);
}
+ else /* get whole cmd */
+ buf = expand_lex(&h->Hlex, 0, INT_MAX);
break;
}
+ if (buf == NULL)
+ buf = SAVE("");
/*
* Apply modifiers, if any.
*/
if (q[1] == ':') {
- *bend = '\0';
- modbuf = omodbuf = buf;
+ modbuf = buf;
while (q[1] == ':' && modbuf != NULL) {
switch (q[2]) {
case 'r':
@@ -630,10 +621,9 @@ excl_sw:
case 'x':
case 'u':
case 'l':
- if ((modbuf = domod(omodbuf, (int) q[2])) != NULL) {
- if (omodbuf != buf)
- xfree((ptr_t) omodbuf);
- omodbuf = modbuf;
+ if ((modbuf = domod(buf, (int) q[2])) != NULL) {
+ xfree(buf);
+ buf = modbuf;
}
++q;
break;
@@ -661,33 +651,28 @@ excl_sw:
if (q[1])
++q;
}
- if (omodbuf != buf) {
- (void) Strcpy(buf, omodbuf);
- xfree((ptr_t) omodbuf);
- bend = Strend(buf);
- }
}
+ buf_len = Strlen(buf);
/*
- * Now replace the text from op to q inclusive with the text from buf to
- * bend.
+ * Now replace the text from op to q inclusive with the text from buf.
*/
q++;
/*
* Now replace text non-inclusively like a real CS major!
*/
- if (LastChar + (bend - buf) - (q - op) >= InputLim)
+ if (LastChar + buf_len - (q - op) >= InputLim)
goto excl_err;
- (void) memmove((ptr_t) (q + (bend - buf) - (q - op)), (ptr_t) q,
- (size_t) ((LastChar - q) * sizeof(Char)));
- LastChar += (bend - buf) - (q - op);
- Cursor += (bend - buf) - (q - op);
- (void) memmove((ptr_t) op, (ptr_t) buf,
- (size_t) ((bend - buf) * sizeof(Char)));
+ (void) memmove(op + buf_len, q, (LastChar - q) * sizeof(Char));
+ LastChar += buf_len - (q - op);
+ Cursor += buf_len - (q - op);
+ (void) memcpy(op, buf, buf_len * sizeof(Char));
*LastChar = '\0';
- return(op + (bend - buf));
+ xfree(buf);
+ return op + buf_len;
excl_err:
+ xfree(buf);
SoundBeep();
return(op + 1);
}
@@ -700,8 +685,7 @@ excl_err:
*/
static void
-c_excl(p)
- Char *p;
+c_excl(Char *p)
{
int i;
Char *q;
@@ -743,7 +727,7 @@ c_excl(p)
static void
-c_substitute()
+c_substitute(void)
{
Char *p;
@@ -764,7 +748,7 @@ c_substitute()
}
static void
-c_delfini() /* Finish up delete action */
+c_delfini(void) /* Finish up delete action */
{
int Size;
@@ -796,9 +780,7 @@ c_delfini() /* Finish up delete action */
}
static Char *
-c_endword(p, high, n, delim)
- Char *p, *high, *delim;
- int n;
+c_endword(Char *p, Char *high, int n, Char *delim)
{
Char inquote = 0;
p++;
@@ -829,9 +811,7 @@ c_endword(p, high, n, delim)
static Char *
-c_eword(p, high, n)
- Char *p, *high;
- int n;
+c_eword(Char *p, Char *high, int n)
{
p++;
@@ -853,8 +833,7 @@ c_eword(p, high, n)
/* Set the max length of the kill ring */
void
-SetKillRing(max)
- int max;
+SetKillRing(int max)
{
CStr *new;
int count, i, j;
@@ -863,7 +842,7 @@ SetKillRing(max)
max = 1; /* no ring, but always one buffer */
if (max == KillRingMax)
return;
- new = (CStr *)xcalloc((size_t) max, sizeof(CStr));
+ new = xcalloc(max, sizeof(CStr));
if (KillRing != NULL) {
if (KillRingLen != 0) {
if (max >= KillRingLen) {
@@ -892,8 +871,7 @@ SetKillRing(max)
/* Push string from start upto (but not including) end onto kill ring */
static void
-c_push_kill(start, end)
- Char *start, *end;
+c_push_kill(Char *start, Char *end)
{
CStr save, *pos;
Char *dp, *cp, *kp;
@@ -939,10 +917,7 @@ c_push_kill(start, end)
pos = &KillRing[KillPos];
KillPos = (KillPos + 1) % KillRingMax;
if (pos->len < len) {
- if (pos->buf == NULL)
- pos->buf = (Char *) xmalloc(len * sizeof(Char));
- else
- pos->buf = (Char *) xrealloc((ptr_t) pos->buf, len * sizeof(Char));
+ pos->buf = xrealloc(pos->buf, len * sizeof(Char));
pos->len = len;
}
cp = start;
@@ -952,15 +927,31 @@ c_push_kill(start, end)
*kp = '\0';
}
-static CCRETVAL
-c_get_histline()
+/* Save InputBuf etc in SavedBuf etc for restore after cmd exec */
+static void
+c_save_inputbuf()
+{
+ SavedBuf.len = 0;
+ Strbuf_append(&SavedBuf, InputBuf);
+ Strbuf_terminate(&SavedBuf);
+ LastSaved = LastChar - InputBuf;
+ CursSaved = Cursor - InputBuf;
+ HistSaved = Hist_num;
+ RestoreSaved = 1;
+}
+
+CCRETVAL
+GetHistLine()
{
struct Hist *hp;
int h;
if (Hist_num == 0) { /* if really the current line */
- copyn(InputBuf, HistBuf, INBUFSIZE);
- LastChar = InputBuf + (LastHist - HistBuf);
+ if (HistBuf.s != NULL)
+ copyn(InputBuf, HistBuf.s, INBUFSIZE);/*FIXBUF*/
+ else
+ *InputBuf = '\0';
+ LastChar = InputBuf + HistBuf.len;
#ifdef KSHVI
if (VImode)
@@ -985,14 +976,18 @@ c_get_histline()
}
if (HistLit && hp->histline) {
- copyn(InputBuf, hp->histline, INBUFSIZE);
+ copyn(InputBuf, hp->histline, INBUFSIZE);/*FIXBUF*/
CurrentHistLit = 1;
}
else {
- (void) sprlex(InputBuf, sizeof(InputBuf) / sizeof(Char), &hp->Hlex);
+ Char *p;
+
+ p = sprlex(&hp->Hlex);
+ copyn(InputBuf, p, sizeof(InputBuf) / sizeof(Char));/*FIXBUF*/
+ xfree(p);
CurrentHistLit = 0;
}
- LastChar = InputBuf + Strlen(InputBuf);
+ LastChar = Strend(InputBuf);
if (LastChar > InputBuf) {
if (LastChar[-1] == '\n')
@@ -1016,18 +1011,16 @@ c_get_histline()
}
static CCRETVAL
-c_search_line(pattern, dir)
-Char *pattern;
-int dir;
+c_search_line(Char *pattern, int dir)
{
Char *cp;
- int len;
+ size_t len;
- len = (int) Strlen(pattern);
+ len = Strlen(pattern);
if (dir == F_UP_SEARCH_HIST) {
for (cp = Cursor; cp >= InputBuf; cp--)
- if (Strncmp(cp, pattern, (size_t) len) == 0 ||
+ if (Strncmp(cp, pattern, len) == 0 ||
Gmatch(cp, pattern)) {
Cursor = cp;
return(CC_NORM);
@@ -1035,7 +1028,7 @@ int dir;
return(CC_ERROR);
} else {
for (cp = Cursor; *cp != '\0' && cp < InputLim; cp++)
- if (Strncmp(cp, pattern, (size_t) len) == 0 ||
+ if (Strncmp(cp, pattern, len) == 0 ||
Gmatch(cp, pattern)) {
Cursor = cp;
return(CC_NORM);
@@ -1045,30 +1038,30 @@ int dir;
}
static CCRETVAL
-e_inc_search(dir)
- int dir;
+e_inc_search(int dir)
{
- static Char STRfwd[] = { 'f', 'w', 'd', '\0' },
- STRbck[] = { 'b', 'c', 'k', '\0' };
+ static const Char STRfwd[] = { 'f', 'w', 'd', '\0' },
+ STRbck[] = { 'b', 'c', 'k', '\0' };
static Char pchar = ':'; /* ':' = normal, '?' = failed */
static Char endcmd[2];
- Char ch, *cp,
+ const Char *cp;
+ Char ch,
*oldCursor = Cursor,
oldpchar = pchar;
CCRETVAL ret = CC_NORM;
int oldHist_num = Hist_num,
- oldpatlen = patlen,
+ oldpatlen = patbuf.len,
newdir = dir,
done, redo;
- if (LastChar + sizeof(STRfwd)/sizeof(Char) + 2 + patlen >= InputLim)
+ if (LastChar + sizeof(STRfwd)/sizeof(Char) + 2 + patbuf.len >= InputLim)
return(CC_ERROR);
for (;;) {
- if (patlen == 0) { /* first round */
+ if (patbuf.len == 0) { /* first round */
pchar = ':';
- patbuf[patlen++] = '*';
+ Strbuf_append1(&patbuf, '*');
}
done = redo = 0;
*LastChar++ = '\n';
@@ -1076,9 +1069,16 @@ e_inc_search(dir)
*cp; *LastChar++ = *cp++)
continue;
*LastChar++ = pchar;
- for (cp = &patbuf[1]; cp < &patbuf[patlen]; *LastChar++ = *cp++)
+ for (cp = &patbuf.s[1]; cp < &patbuf.s[patbuf.len];
+ *LastChar++ = *cp++)
continue;
*LastChar = '\0';
+ if (adrof(STRhighlight) && pchar == ':') {
+ /* if the no-glob-search patch is applied, remove the - 1 below */
+ IncMatchLen = patbuf.len - 1;
+ ClearLines();
+ ClearDisp();
+ }
Refresh();
if (GetNextChar(&ch) != 1)
@@ -1089,10 +1089,10 @@ e_inc_search(dir)
case F_INSERT:
case F_DIGIT:
case F_MAGIC_SPACE:
- if (patlen > INBUFSIZE - 3)
+ if (LastChar + 1 >= InputLim) /*FIXBUF*/
SoundBeep();
else {
- patbuf[patlen++] = ch;
+ Strbuf_append1(&patbuf, ch);
*LastChar++ = ch;
*LastChar = '\0';
Refresh();
@@ -1110,14 +1110,14 @@ e_inc_search(dir)
break;
case F_DELPREV:
- if (patlen > 1)
+ if (patbuf.len > 1)
done++;
else
SoundBeep();
break;
default:
- switch (ch) {
+ switch (ASC(ch)) {
case 0007: /* ^G: Abort */
ret = CC_ERROR;
done++;
@@ -1125,16 +1125,16 @@ e_inc_search(dir)
case 0027: /* ^W: Append word */
/* No can do if globbing characters in pattern */
- for (cp = &patbuf[1]; ; cp++)
- if (cp >= &patbuf[patlen]) {
- Cursor += patlen - 1;
+ for (cp = &patbuf.s[1]; ; cp++)
+ if (cp >= &patbuf.s[patbuf.len]) {
+ Cursor += patbuf.len - 1;
cp = c_next_word(Cursor, LastChar, 1);
while (Cursor < cp && *Cursor != '\n') {
- if (patlen > INBUFSIZE - 3) {
+ if (LastChar + 1 >= InputLim) {/*FIXBUF*/
SoundBeep();
break;
}
- patbuf[patlen++] = *Cursor;
+ Strbuf_append1(&patbuf, *Cursor);
*LastChar++ = *Cursor++;
}
Cursor = oldCursor;
@@ -1167,43 +1167,43 @@ e_inc_search(dir)
if (!done) {
/* Can't search if unmatched '[' */
- for (cp = &patbuf[patlen - 1], ch = ']'; cp > patbuf; cp--)
+ for (cp = &patbuf.s[patbuf.len - 1], ch = ']'; cp > patbuf.s; cp--)
if (*cp == '[' || *cp == ']') {
ch = *cp;
break;
}
- if (patlen > 1 && ch != '[') {
+ if (patbuf.len > 1 && ch != '[') {
if (redo && newdir == dir) {
if (pchar == '?') { /* wrap around */
- Hist_num = newdir == F_UP_SEARCH_HIST ? 0 : 0x7fffffff;
- if (c_get_histline() == CC_ERROR)
+ Hist_num = newdir == F_UP_SEARCH_HIST ? 0 : INT_MAX;
+ if (GetHistLine() == CC_ERROR)
/* Hist_num was fixed by first call */
- (void) c_get_histline();
+ (void) GetHistLine();
Cursor = newdir == F_UP_SEARCH_HIST ?
LastChar : InputBuf;
} else
Cursor += newdir == F_UP_SEARCH_HIST ? -1 : 1;
}
- patbuf[patlen++] = '*';
- patbuf[patlen] = '\0';
+ Strbuf_append1(&patbuf, '*');
+ Strbuf_terminate(&patbuf);
if (Cursor < InputBuf || Cursor > LastChar ||
- (ret = c_search_line(&patbuf[1], newdir)) == CC_ERROR) {
+ (ret = c_search_line(&patbuf.s[1], newdir)) == CC_ERROR) {
LastCmd = (KEYCMD) newdir; /* avoid c_hsetpat */
ret = newdir == F_UP_SEARCH_HIST ?
e_up_search_hist(0) : e_down_search_hist(0);
if (ret != CC_ERROR) {
Cursor = newdir == F_UP_SEARCH_HIST ?
LastChar : InputBuf;
- (void) c_search_line(&patbuf[1], newdir);
+ (void) c_search_line(&patbuf.s[1], newdir);
}
}
- patbuf[--patlen] = '\0';
+ patbuf.s[--patbuf.len] = '\0';
if (ret == CC_ERROR) {
SoundBeep();
if (Hist_num != oldHist_num) {
Hist_num = oldHist_num;
- if (c_get_histline() == CC_ERROR)
+ if (GetHistLine() == CC_ERROR)
return(CC_ERROR);
}
Cursor = oldCursor;
@@ -1225,10 +1225,10 @@ e_inc_search(dir)
if (ret == CC_NORM || (ret == CC_ERROR && oldpatlen == 0)) {
/* restore on normal return or error exit */
pchar = oldpchar;
- patlen = oldpatlen;
+ patbuf.len = oldpatlen;
if (Hist_num != oldHist_num) {
Hist_num = oldHist_num;
- if (c_get_histline() == CC_ERROR)
+ if (GetHistLine() == CC_ERROR)
return(CC_ERROR);
}
Cursor = oldCursor;
@@ -1243,20 +1243,19 @@ e_inc_search(dir)
}
static CCRETVAL
-v_search(dir)
- int dir;
+v_search(int dir)
{
+ struct Strbuf tmpbuf = Strbuf_INIT;
Char ch;
- Char tmpbuf[INBUFSIZE];
- Char oldbuf[INBUFSIZE];
+ Char *oldbuf;
Char *oldlc, *oldc;
- int tmplen;
- copyn(oldbuf, InputBuf, INBUFSIZE);
+ cleanup_push(&tmpbuf, Strbuf_cleanup);
+ oldbuf = Strsave(InputBuf);
+ cleanup_push(oldbuf, xfree);
oldlc = LastChar;
oldc = Cursor;
- tmplen = 0;
- tmpbuf[tmplen++] = '*';
+ Strbuf_append1(&tmpbuf, '*');
InputBuf[0] = '\0';
LastChar = InputBuf;
@@ -1268,20 +1267,23 @@ v_search(dir)
*Cursor++ = dir == F_UP_SEARCH_HIST ? '?' : '/';
Refresh();
for (ch = 0;ch == 0;) {
- if (GetNextChar(&ch) != 1)
+ if (GetNextChar(&ch) != 1) {
+ cleanup_until(&tmpbuf);
return(e_send_eof(0));
+ }
switch (ASC(ch)) {
case 0010: /* Delete and backspace */
case 0177:
- if (tmplen > 1) {
+ if (tmpbuf.len > 1) {
*Cursor-- = '\0';
LastChar = Cursor;
- tmpbuf[tmplen--] = '\0';
+ tmpbuf.len--;
}
else {
- copyn(InputBuf, oldbuf, INBUFSIZE);
+ copyn(InputBuf, oldbuf, INBUFSIZE);/*FIXBUF*/
LastChar = oldlc;
Cursor = oldc;
+ cleanup_until(&tmpbuf);
return(CC_REFRESH);
}
Refresh();
@@ -1299,45 +1301,46 @@ v_search(dir)
break;
default:
- if (tmplen >= INBUFSIZE)
- SoundBeep();
- else {
- tmpbuf[tmplen++] = ch;
- *Cursor++ = ch;
- LastChar = Cursor;
- }
+ Strbuf_append1(&tmpbuf, ch);
+ *Cursor++ = ch;
+ LastChar = Cursor;
Refresh();
ch = 0;
break;
}
}
+ cleanup_until(oldbuf);
- if (tmplen == 1) {
+ if (tmpbuf.len == 1) {
/*
* Use the old pattern, but wild-card it.
*/
- if (patlen == 0) {
+ if (patbuf.len == 0) {
InputBuf[0] = '\0';
LastChar = InputBuf;
Cursor = InputBuf;
Refresh();
+ cleanup_until(&tmpbuf);
return(CC_ERROR);
}
- if (patbuf[0] != '*') {
- (void) Strcpy(tmpbuf, patbuf);
- patbuf[0] = '*';
- (void) Strcpy(&patbuf[1], tmpbuf);
- patlen++;
- patbuf[patlen++] = '*';
- patbuf[patlen] = '\0';
+ if (patbuf.s[0] != '*') {
+ oldbuf = Strsave(patbuf.s);
+ patbuf.len = 0;
+ Strbuf_append1(&patbuf, '*');
+ Strbuf_append(&patbuf, oldbuf);
+ xfree(oldbuf);
+ Strbuf_append1(&patbuf, '*');
+ Strbuf_terminate(&patbuf);
}
}
else {
- tmpbuf[tmplen++] = '*';
- tmpbuf[tmplen] = '\0';
- (void) Strcpy(patbuf, tmpbuf);
- patlen = tmplen;
+ Strbuf_append1(&tmpbuf, '*');
+ Strbuf_terminate(&tmpbuf);
+ patbuf.len = 0;
+ Strbuf_append(&patbuf, tmpbuf.s);
+ Strbuf_terminate(&patbuf);
}
+ cleanup_until(&tmpbuf);
LastCmd = (KEYCMD) dir; /* avoid c_hsetpat */
Cursor = LastChar = InputBuf;
if ((dir == F_UP_SEARCH_HIST ? e_up_search_hist(0) :
@@ -1346,7 +1349,7 @@ v_search(dir)
return(CC_ERROR);
}
else {
- if (ch == 0033) {
+ if (ASC(ch) == 0033) {
Refresh();
*LastChar++ = '\n';
*LastChar = '\0';
@@ -1366,8 +1369,7 @@ v_search(dir)
/*ARGSUSED*/
CCRETVAL
-v_cmd_mode(c)
- Char c;
+v_cmd_mode(Char c)
{
USE(c);
InsertPos = 0;
@@ -1395,8 +1397,7 @@ v_cmd_mode(c)
/*ARGSUSED*/
CCRETVAL
-e_unassigned(c)
- Char c;
+e_unassigned(Char c)
{ /* bound to keys that arn't really assigned */
USE(c);
SoundBeep();
@@ -1404,9 +1405,9 @@ e_unassigned(c)
return(CC_NORM);
}
+#ifdef notyet
static CCRETVAL
-e_insert_str(c)
- Char *c;
+e_insert_str(Char *c)
{
int i, n;
@@ -1414,7 +1415,7 @@ e_insert_str(c)
if (LastChar + Argument * n >= InputLim)
return(CC_ERROR); /* end of buffer space */
if (inputmode != MODE_INSERT) {
- c_delafter(Argument * NLSChars(c));
+ c_delafter(Argument * Strlen(c));
}
c_insert(Argument * n);
while (Argument--) {
@@ -1424,10 +1425,10 @@ e_insert_str(c)
Refresh();
return(CC_NORM);
}
+#endif
CCRETVAL
-e_insert(c)
- Char c;
+e_insert(Char c)
{
#ifndef SHORT_STRINGS
c &= ASCII; /* no meta chars ever */
@@ -1439,28 +1440,6 @@ e_insert(c)
if (LastChar + Argument >= InputLim)
return(CC_ERROR); /* end of buffer space */
- if (!NLSFinished(Cursor, 0, c)) {
- Char buf[MB_LEN_MAX + 1];
- int f;
- size_t i = 1;
- buf[0] = c;
- do {
- if (GetNextChar(&c) != 1)
- break;
- f = NLSFinished(buf, i, (eChar)c);
- if (f == -1) {
- UngetNextChar(c);
- break;
- }
- buf[i++] = c;
- } while (!f && i < MB_CUR_MAX);
- if (i > 1) {
- buf[i] = 0;
- return e_insert_str(buf);
- }
- c = buf[0];
- }
-
if (Argument == 1) { /* How was this optimized ???? */
if (inputmode != MODE_INSERT) {
@@ -1498,8 +1477,7 @@ e_insert(c)
}
int
-InsertStr(s) /* insert ASCIZ s at cursor (for complete) */
- Char *s;
+InsertStr(Char *s) /* insert ASCIZ s at cursor (for complete) */
{
int len;
@@ -1515,8 +1493,7 @@ InsertStr(s) /* insert ASCIZ s at cursor (for complete) */
}
void
-DeleteBack(n) /* delete the n characters before . */
- int n;
+DeleteBack(int n) /* delete the n characters before . */
{
if (n <= 0)
return;
@@ -1526,8 +1503,7 @@ DeleteBack(n) /* delete the n characters before . */
}
CCRETVAL
-e_digit(c) /* gray magic here */
- Char c;
+e_digit(Char c) /* gray magic here */
{
if (!Isdigit(c))
return(CC_ERROR); /* no NULs in the input ever!! */
@@ -1560,10 +1536,13 @@ e_digit(c) /* gray magic here */
}
CCRETVAL
-e_argdigit(c) /* for ESC-n */
- Char c;
+e_argdigit(Char c) /* for ESC-n */
{
+#ifdef IS_ASCII
c &= ASCII;
+#else
+ c = CTL_ESC(ASC(c) & ASCII); /* stripping for EBCDIC done the ASCII way */
+#endif
if (!Isdigit(c))
return(CC_ERROR); /* no NULs in the input ever!! */
@@ -1581,8 +1560,7 @@ e_argdigit(c) /* for ESC-n */
}
CCRETVAL
-v_zero(c) /* command mode 0 for vi */
- Char c;
+v_zero(Char c) /* command mode 0 for vi */
{
if (DoingArg) { /* if doing an arg, add this in... */
if (Argument > 1000000)
@@ -1603,10 +1581,17 @@ v_zero(c) /* command mode 0 for vi */
/*ARGSUSED*/
CCRETVAL
-e_newline(c)
- Char c;
+e_newline(Char c)
{ /* always ignore argument */
USE(c);
+ if (adrof(STRhighlight) && MarkIsSet) {
+ MarkIsSet = 0;
+ ClearLines();
+ ClearDisp();
+ Refresh();
+ }
+ MarkIsSet = 0;
+
/* PastBottom(); NOW done in ed.inputl.c */
*LastChar++ = '\n'; /* for the benefit of CSH */
*LastChar = '\0'; /* just in case */
@@ -1617,8 +1602,32 @@ e_newline(c)
/*ARGSUSED*/
CCRETVAL
-e_send_eof(c)
- Char c;
+e_newline_hold(Char c)
+{
+ USE(c);
+ c_save_inputbuf();
+ HistSaved = 0;
+ *LastChar++ = '\n'; /* for the benefit of CSH */
+ *LastChar = '\0'; /* just in case */
+ return(CC_NEWLINE);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_newline_down_hist(Char c)
+{
+ USE(c);
+ if (Hist_num > 1) {
+ HistSaved = Hist_num;
+ }
+ *LastChar++ = '\n'; /* for the benefit of CSH */
+ *LastChar = '\0'; /* just in case */
+ return(CC_NEWLINE);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_send_eof(Char c)
{ /* for when ^D is ONLY send-eof */
USE(c);
PastBottom();
@@ -1628,8 +1637,7 @@ e_send_eof(c)
/*ARGSUSED*/
CCRETVAL
-e_complete(c)
- Char c;
+e_complete(Char c)
{
USE(c);
*LastChar = '\0'; /* just in case */
@@ -1638,8 +1646,7 @@ e_complete(c)
/*ARGSUSED*/
CCRETVAL
-e_complete_back(c)
- Char c;
+e_complete_back(Char c)
{
USE(c);
*LastChar = '\0'; /* just in case */
@@ -1648,8 +1655,7 @@ e_complete_back(c)
/*ARGSUSED*/
CCRETVAL
-e_complete_fwd(c)
- Char c;
+e_complete_fwd(Char c)
{
USE(c);
*LastChar = '\0'; /* just in case */
@@ -1658,8 +1664,7 @@ e_complete_fwd(c)
/*ARGSUSED*/
CCRETVAL
-e_complete_all(c)
- Char c;
+e_complete_all(Char c)
{
USE(c);
*LastChar = '\0'; /* just in case */
@@ -1668,8 +1673,7 @@ e_complete_all(c)
/*ARGSUSED*/
CCRETVAL
-v_cm_complete(c)
- Char c;
+v_cm_complete(Char c)
{
USE(c);
if (Cursor < LastChar)
@@ -1680,8 +1684,7 @@ v_cm_complete(c)
/*ARGSUSED*/
CCRETVAL
-e_toggle_hist(c)
- Char c;
+e_toggle_hist(Char c)
{
struct Hist *hp;
int h;
@@ -1703,7 +1706,7 @@ e_toggle_hist(c)
if (!CurrentHistLit) {
if (hp->histline) {
- copyn(InputBuf, hp->histline, INBUFSIZE);
+ copyn(InputBuf, hp->histline, INBUFSIZE);/*FIXBUF*/
CurrentHistLit = 1;
}
else {
@@ -1711,11 +1714,15 @@ e_toggle_hist(c)
}
}
else {
- (void) sprlex(InputBuf, sizeof(InputBuf) / sizeof(Char), &hp->Hlex);
+ Char *p;
+
+ p = sprlex(&hp->Hlex);
+ copyn(InputBuf, p, sizeof(InputBuf) / sizeof(Char));/*FIXBUF*/
+ xfree(p);
CurrentHistLit = 0;
}
- LastChar = InputBuf + Strlen(InputBuf);
+ LastChar = Strend(InputBuf);
if (LastChar > InputBuf) {
if (LastChar[-1] == '\n')
LastChar--;
@@ -1737,8 +1744,7 @@ e_toggle_hist(c)
/*ARGSUSED*/
CCRETVAL
-e_up_hist(c)
- Char c;
+e_up_hist(Char c)
{
Char beep = 0;
@@ -1747,15 +1753,16 @@ e_up_hist(c)
*LastChar = '\0'; /* just in case */
if (Hist_num == 0) { /* save the current buffer away */
- copyn(HistBuf, InputBuf, INBUFSIZE);
- LastHist = HistBuf + (LastChar - InputBuf);
+ HistBuf.len = 0;
+ Strbuf_append(&HistBuf, InputBuf);
+ Strbuf_terminate(&HistBuf);
}
Hist_num += Argument;
- if (c_get_histline() == CC_ERROR) {
+ if (GetHistLine() == CC_ERROR) {
beep = 1;
- (void) c_get_histline(); /* Hist_num was fixed by first call */
+ (void) GetHistLine(); /* Hist_num was fixed by first call */
}
Refresh();
@@ -1767,8 +1774,7 @@ e_up_hist(c)
/*ARGSUSED*/
CCRETVAL
-e_down_hist(c)
- Char c;
+e_down_hist(Char c)
{
USE(c);
UndoAction = TCSHOP_NOP;
@@ -1781,7 +1787,7 @@ e_down_hist(c)
return(CC_ERROR); /* make it beep */
}
- return(c_get_histline());
+ return(GetHistLine());
}
@@ -1790,42 +1796,35 @@ e_down_hist(c)
* c_hmatch() return True if the pattern matches the prefix
*/
static int
-c_hmatch(str)
-Char *str;
+c_hmatch(Char *str)
{
- if (Strncmp(patbuf, str, (size_t) patlen) == 0)
+ if (Strncmp(patbuf.s, str, patbuf.len) == 0)
return 1;
- return Gmatch(str, patbuf);
+ return Gmatch(str, patbuf.s);
}
/*
* c_hsetpat(): Set the history seatch pattern
*/
static void
-c_hsetpat()
+c_hsetpat(void)
{
if (LastCmd != F_UP_SEARCH_HIST && LastCmd != F_DOWN_SEARCH_HIST) {
- patlen = (int) (Cursor - InputBuf);
- if (patlen >= INBUFSIZE) patlen = INBUFSIZE -1;
- if (patlen >= 0) {
- (void) Strncpy(patbuf, InputBuf, (size_t) patlen);
- patbuf[patlen] = '\0';
- }
- else
- patlen = (int) Strlen(patbuf);
+ patbuf.len = 0;
+ Strbuf_appendn(&patbuf, InputBuf, Cursor - InputBuf);
+ Strbuf_terminate(&patbuf);
}
#ifdef SDEBUG
xprintf("\nHist_num = %d\n", Hist_num);
- xprintf("patlen = %d\n", patlen);
- xprintf("patbuf = \"%S\"\n", patbuf);
+ xprintf("patlen = %d\n", (int)patbuf.len);
+ xprintf("patbuf = \"%S\"\n", patbuf.s);
xprintf("Cursor %d LastChar %d\n", Cursor - InputBuf, LastChar - InputBuf);
#endif
}
/*ARGSUSED*/
CCRETVAL
-e_up_search_hist(c)
- Char c;
+e_up_search_hist(Char c)
{
struct Hist *hp;
int h;
@@ -1843,10 +1842,10 @@ e_up_search_hist(c)
return(CC_ERROR);
}
- if (Hist_num == 0)
- {
- copyn(HistBuf, InputBuf, INBUFSIZE);
- LastHist = HistBuf + (LastChar - InputBuf);
+ if (Hist_num == 0) {
+ HistBuf.len = 0;
+ Strbuf_append(&HistBuf, InputBuf);
+ Strbuf_terminate(&HistBuf);
}
@@ -1860,18 +1859,25 @@ e_up_search_hist(c)
hp = hp->Hnext;
while (hp != NULL) {
- Char sbuf[INBUFSIZE], *hl;
- if (hp->histline == NULL) {
- hp->histline = Strsave(sprlex(sbuf, sizeof(sbuf) / sizeof(Char),
- &hp->Hlex));
+ Char *hl;
+ int matched;
+
+ if (hp->histline == NULL)
+ hp->histline = sprlex(&hp->Hlex);
+ if (HistLit)
+ hl = hp->histline;
+ else {
+ hl = sprlex(&hp->Hlex);
+ cleanup_push(hl, xfree);
}
- hl = HistLit ? hp->histline : sprlex(sbuf, sizeof(sbuf) / sizeof(Char),
- &hp->Hlex);
#ifdef SDEBUG
xprintf("Comparing with \"%S\"\n", hl);
#endif
- if ((Strncmp(hl, InputBuf, (size_t) (LastChar - InputBuf)) ||
- hl[LastChar-InputBuf]) && c_hmatch(hl)) {
+ matched = (Strncmp(hl, InputBuf, (size_t) (LastChar - InputBuf)) ||
+ hl[LastChar-InputBuf]) && c_hmatch(hl);
+ if (!HistLit)
+ cleanup_until(hl);
+ if (matched) {
found++;
break;
}
@@ -1881,20 +1887,19 @@ e_up_search_hist(c)
if (!found) {
#ifdef SDEBUG
- xprintf("not found\n");
+ xprintf("not found\n");
#endif
return(CC_ERROR);
}
Hist_num = h;
- return(c_get_histline());
+ return(GetHistLine());
}
/*ARGSUSED*/
CCRETVAL
-e_down_search_hist(c)
- Char c;
+e_down_search_hist(Char c)
{
struct Hist *hp;
int h;
@@ -1915,26 +1920,30 @@ e_down_search_hist(c)
c_hsetpat(); /* Set search pattern !! */
for (h = 1; h < Hist_num && hp; h++) {
- Char sbuf[INBUFSIZE], *hl;
- if (hp->histline == NULL) {
- hp->histline = Strsave(sprlex(sbuf, sizeof(sbuf) / sizeof(Char),
- &hp->Hlex));
+ Char *hl;
+ if (hp->histline == NULL)
+ hp->histline = sprlex(&hp->Hlex);
+ if (HistLit)
+ hl = hp->histline;
+ else {
+ hl = sprlex(&hp->Hlex);
+ cleanup_push(hl, xfree);
}
- hl = HistLit ? hp->histline : sprlex(sbuf, sizeof(sbuf) / sizeof(Char),
- &hp->Hlex);
#ifdef SDEBUG
xprintf("Comparing with \"%S\"\n", hl);
#endif
if ((Strncmp(hl, InputBuf, (size_t) (LastChar - InputBuf)) ||
hl[LastChar-InputBuf]) && c_hmatch(hl))
found = h;
+ if (!HistLit)
+ cleanup_until(hl);
hp = hp->Hnext;
}
if (!found) { /* is it the current history number? */
- if (!c_hmatch(HistBuf)) {
+ if (!c_hmatch(HistBuf.s)) {
#ifdef SDEBUG
- xprintf("not found\n");
+ xprintf("not found\n");
#endif
return(CC_ERROR);
}
@@ -1942,13 +1951,12 @@ e_down_search_hist(c)
Hist_num = found;
- return(c_get_histline());
+ return(GetHistLine());
}
/*ARGSUSED*/
CCRETVAL
-e_helpme(c)
- Char c;
+e_helpme(Char c)
{
USE(c);
PastBottom();
@@ -1958,8 +1966,7 @@ e_helpme(c)
/*ARGSUSED*/
CCRETVAL
-e_correct(c)
- Char c;
+e_correct(Char c)
{
USE(c);
*LastChar = '\0'; /* just in case */
@@ -1968,8 +1975,7 @@ e_correct(c)
/*ARGSUSED*/
CCRETVAL
-e_correctl(c)
- Char c;
+e_correctl(Char c)
{
USE(c);
*LastChar = '\0'; /* just in case */
@@ -1978,19 +1984,14 @@ e_correctl(c)
/*ARGSUSED*/
CCRETVAL
-e_run_fg_editor(c)
- Char c;
+e_run_fg_editor(Char c)
{
struct process *pp;
USE(c);
if ((pp = find_stop_ed()) != NULL) {
/* save our editor state so we can restore it */
- tellwhat = 1;
- copyn(WhichBuf, InputBuf, INBUFSIZE);
- LastWhich = WhichBuf + (LastChar - InputBuf);
- CursWhich = WhichBuf + (Cursor - InputBuf);
- HistWhich = Hist_num;
+ c_save_inputbuf();
Hist_num = 0; /* for the history commands */
/* put the tty in a sane mode */
@@ -2002,15 +2003,15 @@ e_run_fg_editor(c)
(void) Rawmode(); /* go on */
Refresh();
- tellwhat = 0;
+ RestoreSaved = 0;
+ HistSaved = 0;
}
return(CC_NORM);
}
/*ARGSUSED*/
CCRETVAL
-e_list_choices(c)
- Char c;
+e_list_choices(Char c)
{
USE(c);
PastBottom();
@@ -2020,8 +2021,7 @@ e_list_choices(c)
/*ARGSUSED*/
CCRETVAL
-e_list_all(c)
- Char c;
+e_list_all(Char c)
{
USE(c);
PastBottom();
@@ -2031,8 +2031,7 @@ e_list_all(c)
/*ARGSUSED*/
CCRETVAL
-e_list_glob(c)
- Char c;
+e_list_glob(Char c)
{
USE(c);
PastBottom();
@@ -2042,8 +2041,7 @@ e_list_glob(c)
/*ARGSUSED*/
CCRETVAL
-e_expand_glob(c)
- Char c;
+e_expand_glob(Char c)
{
USE(c);
*LastChar = '\0'; /* just in case */
@@ -2052,8 +2050,7 @@ e_expand_glob(c)
/*ARGSUSED*/
CCRETVAL
-e_normalize_path(c)
- Char c;
+e_normalize_path(Char c)
{
USE(c);
*LastChar = '\0'; /* just in case */
@@ -2062,8 +2059,7 @@ e_normalize_path(c)
/*ARGSUSED*/
CCRETVAL
-e_normalize_command(c)
- Char c;
+e_normalize_command(Char c)
{
USE(c);
*LastChar = '\0'; /* just in case */
@@ -2072,8 +2068,7 @@ e_normalize_command(c)
/*ARGSUSED*/
CCRETVAL
-e_expand_vars(c)
- Char c;
+e_expand_vars(Char c)
{
USE(c);
*LastChar = '\0'; /* just in case */
@@ -2082,10 +2077,11 @@ e_expand_vars(c)
/*ARGSUSED*/
CCRETVAL
-e_which(c)
- Char c;
+e_which(Char c)
{ /* do a fast command line which(1) */
USE(c);
+ c_save_inputbuf();
+ Hist_num = 0; /* for the history commands */
PastBottom();
*LastChar = '\0'; /* just in case */
return(CC_WHICH);
@@ -2093,14 +2089,12 @@ e_which(c)
/*ARGSUSED*/
CCRETVAL
-e_last_item(c)
- Char c;
+e_last_item(Char c)
{ /* insert the last element of the prev. cmd */
- Char *cp;
struct Hist *hp;
struct wordent *wp, *firstp;
int i;
- Char buf[INBUFSIZE];
+ Char *expanded;
USE(c);
if (Argument <= 0)
@@ -2123,24 +2117,26 @@ e_last_item(c)
wp = wp->prev;
}
- cp = expand_lex(buf, INBUFSIZE, wp->prev, 0, i - 1);
- *cp = '\0';
- if (InsertStr(buf))
+ expanded = expand_lex(wp->prev, 0, i - 1);
+ if (InsertStr(expanded)) {
+ xfree(expanded);
return(CC_ERROR);
+ }
+ xfree(expanded);
return(CC_REFRESH);
}
/*ARGSUSED*/
CCRETVAL
-e_dabbrev_expand(c)
- Char c;
+e_dabbrev_expand(Char c)
{ /* expand to preceding word matching prefix */
Char *cp, *ncp, *bp;
struct Hist *hp;
- int arg = 0, len = 0, i; /* len = 0 to shut up gcc -Wall */
+ int arg = 0, i;
+ size_t len = 0;
int found = 0;
- Char hbuf[INBUFSIZE];
+ Char *hbuf;
static int oldevent, hist, word;
static Char *start, *oldcursor;
@@ -2152,18 +2148,20 @@ e_dabbrev_expand(c)
if (cp == Cursor || Isspace(*cp))
return(CC_ERROR);
+ hbuf = NULL;
hp = Histlist.Hnext;
bp = InputBuf;
if (Argument == 1 && eventno == oldevent && cp == start &&
- Cursor == oldcursor && patlen > 0 && Strncmp(patbuf, cp, patlen) == 0){
+ Cursor == oldcursor && patbuf.len > 0
+ && Strncmp(patbuf.s, cp, patbuf.len) == 0){
/* continue previous search - go to last match (hist/word) */
if (hist != 0) { /* need to move up history */
for (i = 1; i < hist && hp != NULL; i++)
hp = hp->Hnext;
if (hp == NULL) /* "can't happen" */
- return(CC_ERROR);
- cp = expand_lex(hbuf, INBUFSIZE, &hp->Hlex, 0, NCARGS);
- *cp = '\0';
+ goto err_hbuf;
+ hbuf = expand_lex(&hp->Hlex, 0, INT_MAX);
+ cp = Strend(hbuf);
bp = hbuf;
hp = hp->Hnext;
}
@@ -2171,8 +2169,8 @@ e_dabbrev_expand(c)
} else { /* starting new search */
oldevent = eventno;
start = cp;
- patlen = (int) (Cursor - cp);
- (void) Strncpy(patbuf, cp, patlen);
+ patbuf.len = 0;
+ Strbuf_appendn(&patbuf, cp, Cursor - cp);
hist = 0;
word = 0;
}
@@ -2183,43 +2181,48 @@ e_dabbrev_expand(c)
hist++;
word = 0;
if (hp == NULL)
- return(CC_ERROR);
- cp = expand_lex(hbuf, INBUFSIZE, &hp->Hlex, 0, NCARGS);
- *cp = '\0';
+ goto err_hbuf;
+ hbuf = expand_lex(&hp->Hlex, 0, INT_MAX);
+ cp = Strend(hbuf);
bp = hbuf;
hp = hp->Hnext;
continue;
} else {
word++;
- len = (int) (c_endword(ncp-1, cp, 1, STRshwordsep) - ncp + 1);
+ len = c_endword(ncp-1, cp, 1, STRshwordsep) - ncp + 1;
cp = ncp;
}
- if (len > patlen && Strncmp(cp, patbuf, patlen) == 0) {
+ if (len > patbuf.len && Strncmp(cp, patbuf.s, patbuf.len) == 0) {
/* We don't fully check distinct matches as Gnuemacs does: */
if (Argument > 1) { /* just count matches */
if (++arg >= Argument)
found++;
} else { /* match if distinct from previous */
- if (len != Cursor - start || Strncmp(cp, start, len) != 0)
+ if (len != (size_t)(Cursor - start)
+ || Strncmp(cp, start, len) != 0)
found++;
}
}
}
if (LastChar + len - (Cursor - start) >= InputLim)
- return(CC_ERROR); /* no room */
+ goto err_hbuf; /* no room */
DeleteBack(Cursor - start);
c_insert(len);
while (len--)
*Cursor++ = *cp++;
oldcursor = Cursor;
+ xfree(hbuf);
return(CC_REFRESH);
+
+ err_hbuf:
+ xfree(hbuf);
+ return CC_ERROR;
}
/*ARGSUSED*/
CCRETVAL
-e_yank_kill(c)
- Char c;
+e_yank_kill(Char c)
{ /* almost like GnuEmacs */
int len;
Char *kp, *cp;
@@ -2245,13 +2248,17 @@ e_yank_kill(c)
Mark = cp; /* else cursor at beginning, mark at end */
}
+ if (adrof(STRhighlight) && MarkIsSet) {
+ ClearLines();
+ ClearDisp();
+ }
+ MarkIsSet = 0;
return(CC_REFRESH);
}
/*ARGSUSED*/
CCRETVAL
-e_yank_pop(c)
- Char c;
+e_yank_pop(Char c)
{ /* almost like GnuEmacs */
int m_bef_c, del_len, ins_len;
Char *kp, *cp;
@@ -2305,13 +2312,17 @@ e_yank_pop(c)
Mark = cp; /* else cursor at beginning, mark at end */
}
+ if (adrof(STRhighlight) && MarkIsSet) {
+ ClearLines();
+ ClearDisp();
+ }
+ MarkIsSet = 0;
return(CC_REFRESH);
}
/*ARGSUSED*/
CCRETVAL
-v_delprev(c) /* Backspace key in insert mode */
- Char c;
+v_delprev(Char c) /* Backspace key in insert mode */
{
int rc;
@@ -2329,8 +2340,7 @@ v_delprev(c) /* Backspace key in insert mode */
/*ARGSUSED*/
CCRETVAL
-e_delprev(c)
- Char c;
+e_delprev(Char c)
{
USE(c);
if (Cursor > InputBuf) {
@@ -2344,8 +2354,7 @@ e_delprev(c)
/*ARGSUSED*/
CCRETVAL
-e_delwordprev(c)
- Char c;
+e_delwordprev(Char c)
{
Char *cp;
@@ -2392,8 +2401,7 @@ e_delwordprev(c)
/* rename e_delnext() -> e_delnext_eof() */
/*ARGSUSED*/
CCRETVAL
-e_delnext(c)
- Char c;
+e_delnext(Char c)
{
USE(c);
if (Cursor == LastChar) {/* if I'm at the end */
@@ -2416,8 +2424,7 @@ e_delnext(c)
/*ARGSUSED*/
CCRETVAL
-e_delnext_eof(c)
- Char c;
+e_delnext_eof(Char c)
{
USE(c);
if (Cursor == LastChar) {/* if I'm at the end */
@@ -2446,8 +2453,7 @@ e_delnext_eof(c)
/*ARGSUSED*/
CCRETVAL
-e_delnext_list(c)
- Char c;
+e_delnext_list(Char c)
{
USE(c);
if (Cursor == LastChar) { /* if I'm at the end */
@@ -2465,8 +2471,7 @@ e_delnext_list(c)
/*ARGSUSED*/
CCRETVAL
-e_delnext_list_eof(c)
- Char c;
+e_delnext_list_eof(Char c)
{
USE(c);
if (Cursor == LastChar) { /* if I'm at the end */
@@ -2491,8 +2496,7 @@ e_delnext_list_eof(c)
/*ARGSUSED*/
CCRETVAL
-e_list_eof(c)
- Char c;
+e_list_eof(Char c)
{
CCRETVAL rv;
@@ -2512,8 +2516,7 @@ e_list_eof(c)
/*ARGSUSED*/
CCRETVAL
-e_delwordnext(c)
- Char c;
+e_delwordnext(Char c)
{
Char *cp;
@@ -2534,8 +2537,7 @@ e_delwordnext(c)
/*ARGSUSED*/
CCRETVAL
-e_toend(c)
- Char c;
+e_toend(Char c)
{
USE(c);
Cursor = LastChar;
@@ -2550,8 +2552,7 @@ e_toend(c)
/*ARGSUSED*/
CCRETVAL
-e_tobeg(c)
- Char c;
+e_tobeg(Char c)
{
USE(c);
Cursor = InputBuf;
@@ -2571,20 +2572,21 @@ e_tobeg(c)
/*ARGSUSED*/
CCRETVAL
-e_killend(c)
- Char c;
+e_killend(Char c)
{
USE(c);
c_push_kill(Cursor, LastChar); /* copy it */
- Mark = LastChar = Cursor; /* zap! -- delete to end */
+ LastChar = Cursor; /* zap! -- delete to end */
+ if (Mark > Cursor)
+ Mark = Cursor;
+ MarkIsSet = 0;
return(CC_REFRESH);
}
/*ARGSUSED*/
CCRETVAL
-e_killbeg(c)
- Char c;
+e_killbeg(Char c)
{
USE(c);
c_push_kill(InputBuf, Cursor); /* copy it */
@@ -2596,19 +2598,18 @@ e_killbeg(c)
/*ARGSUSED*/
CCRETVAL
-e_killall(c)
- Char c;
+e_killall(Char c)
{
USE(c);
c_push_kill(InputBuf, LastChar); /* copy it */
Cursor = Mark = LastChar = InputBuf; /* zap! -- delete all of it */
+ MarkIsSet = 0;
return(CC_REFRESH);
}
/*ARGSUSED*/
CCRETVAL
-e_killregion(c)
- Char c;
+e_killregion(Char c)
{
USE(c);
if (!Mark)
@@ -2623,13 +2624,17 @@ e_killregion(c)
c_push_kill(Mark, Cursor); /* copy it */
c_delbefore((int)(Cursor - Mark));
}
+ if (adrof(STRhighlight) && MarkIsSet) {
+ ClearLines();
+ ClearDisp();
+ }
+ MarkIsSet = 0;
return(CC_REFRESH);
}
/*ARGSUSED*/
CCRETVAL
-e_copyregion(c)
- Char c;
+e_copyregion(Char c)
{
USE(c);
if (!Mark)
@@ -2646,8 +2651,7 @@ e_copyregion(c)
/*ARGSUSED*/
CCRETVAL
-e_charswitch(cc)
- Char cc;
+e_charswitch(Char cc)
{
Char c;
@@ -2669,8 +2673,7 @@ e_charswitch(cc)
/*ARGSUSED*/
CCRETVAL
-e_gcharswitch(cc)
- Char cc;
+e_gcharswitch(Char cc)
{ /* gosmacs style ^T */
Char c;
@@ -2688,17 +2691,14 @@ e_gcharswitch(cc)
/*ARGSUSED*/
CCRETVAL
-e_charback(c)
- Char c;
+e_charback(Char c)
{
- int num;
USE(c);
if (Cursor > InputBuf) {
- num = NLSExtend(Cursor, Cursor - InputBuf, -Argument);
- if (num > Cursor - InputBuf)
+ if (Argument > Cursor - InputBuf)
Cursor = InputBuf;
else
- Cursor -= num;
+ Cursor -= Argument;
if (VImode)
if (ActionFlag & TCSHOP_DELETE) {
@@ -2716,8 +2716,7 @@ e_charback(c)
/*ARGSUSED*/
CCRETVAL
-v_wordback(c)
- Char c;
+v_wordback(Char c)
{
USE(c);
if (Cursor == InputBuf)
@@ -2737,8 +2736,7 @@ v_wordback(c)
/*ARGSUSED*/
CCRETVAL
-e_wordback(c)
- Char c;
+e_wordback(Char c)
{
USE(c);
if (Cursor == InputBuf)
@@ -2759,14 +2757,11 @@ e_wordback(c)
/*ARGSUSED*/
CCRETVAL
-e_charfwd(c)
- Char c;
+e_charfwd(Char c)
{
- int num;
USE(c);
if (Cursor < LastChar) {
- num = NLSExtend(Cursor, LastChar - Cursor, Argument);
- Cursor += num;
+ Cursor += Argument;
if (Cursor > LastChar)
Cursor = LastChar;
@@ -2786,8 +2781,7 @@ e_charfwd(c)
/*ARGSUSED*/
CCRETVAL
-e_wordfwd(c)
- Char c;
+e_wordfwd(Char c)
{
USE(c);
if (Cursor == LastChar)
@@ -2808,8 +2802,7 @@ e_wordfwd(c)
/*ARGSUSED*/
CCRETVAL
-v_wordfwd(c)
- Char c;
+v_wordfwd(Char c)
{
USE(c);
if (Cursor == LastChar)
@@ -2830,8 +2823,7 @@ v_wordfwd(c)
/*ARGSUSED*/
CCRETVAL
-v_wordbegnext(c)
- Char c;
+v_wordbegnext(Char c)
{
USE(c);
if (Cursor == LastChar)
@@ -2854,13 +2846,12 @@ v_wordbegnext(c)
/*ARGSUSED*/
static CCRETVAL
-v_repeat_srch(c)
- int c;
+v_repeat_srch(int c)
{
CCRETVAL rv = CC_ERROR;
#ifdef SDEBUG
- xprintf("dir %d patlen %d patbuf %S\n",
- c, patlen, patbuf);
+ xprintf("dir %d patlen %d patbuf %S\n",
+ c, (int)patbuf.len, patbuf.s);
#endif
LastCmd = (KEYCMD) c; /* Hack to stop c_hsetpat */
@@ -2879,9 +2870,7 @@ v_repeat_srch(c)
}
static CCRETVAL
-v_csearch_back(ch, count, tflag)
- Char ch;
- int count, tflag;
+v_csearch_back(Char ch, int count, int tflag)
{
Char *cp;
@@ -2912,9 +2901,7 @@ v_csearch_back(ch, count, tflag)
}
static CCRETVAL
-v_csearch_fwd(ch, count, tflag)
- Char ch;
- int count, tflag;
+v_csearch_fwd(Char ch, int count, int tflag)
{
Char *cp;
@@ -2945,8 +2932,7 @@ v_csearch_fwd(ch, count, tflag)
/*ARGSUSED*/
static CCRETVAL
-v_action(c)
- int c;
+v_action(int c)
{
Char *cp, *kp;
@@ -2989,9 +2975,7 @@ v_action(c)
#ifdef COMMENT
/* by: Brian Allison <uiucdcs!convex!allison@RUTGERS.EDU> */
static void
-c_get_word(begin, end)
- Char **begin;
- Char **end;
+c_get_word(Char **begin, Char **end)
{
Char *cp;
@@ -3009,8 +2993,7 @@ c_get_word(begin, end)
/*ARGSUSED*/
CCRETVAL
-e_uppercase(c)
- Char c;
+e_uppercase(Char c)
{
Char *cp, *end;
@@ -3030,8 +3013,7 @@ e_uppercase(c)
/*ARGSUSED*/
CCRETVAL
-e_capitolcase(c)
- Char c;
+e_capitolcase(Char c)
{
Char *cp, *end;
@@ -3059,8 +3041,7 @@ e_capitolcase(c)
/*ARGSUSED*/
CCRETVAL
-e_lowercase(c)
- Char c;
+e_lowercase(Char c)
{
Char *cp, *end;
@@ -3080,18 +3061,22 @@ e_lowercase(c)
/*ARGSUSED*/
CCRETVAL
-e_set_mark(c)
- Char c;
+e_set_mark(Char c)
{
USE(c);
+ if (adrof(STRhighlight) && MarkIsSet && Mark != Cursor) {
+ ClearLines();
+ ClearDisp();
+ Refresh();
+ }
Mark = Cursor;
+ MarkIsSet = 1;
return(CC_NORM);
}
/*ARGSUSED*/
CCRETVAL
-e_exchange_mark(c)
- Char c;
+e_exchange_mark(Char c)
{
Char *cp;
@@ -3105,8 +3090,7 @@ e_exchange_mark(c)
/*ARGSUSED*/
CCRETVAL
-e_argfour(c)
- Char c;
+e_argfour(Char c)
{ /* multiply current argument by 4 */
USE(c);
if (Argument > 1000000)
@@ -3116,18 +3100,25 @@ e_argfour(c)
return(CC_ARGHACK);
}
+static void
+quote_mode_cleanup(void *unused)
+{
+ USE(unused);
+ QuoteModeOff();
+}
+
/*ARGSUSED*/
CCRETVAL
-e_quote(c)
- Char c;
+e_quote(Char c)
{
Char ch;
int num;
USE(c);
QuoteModeOn();
+ cleanup_push(&c, quote_mode_cleanup); /* Using &c just as a mark */
num = GetNextChar(&ch);
- QuoteModeOff();
+ cleanup_until(&c);
if (num == 1)
return e_insert(ch);
else
@@ -3136,8 +3127,7 @@ e_quote(c)
/*ARGSUSED*/
CCRETVAL
-e_metanext(c)
- Char c;
+e_metanext(Char c)
{
USE(c);
MetaNext = 1;
@@ -3147,8 +3137,7 @@ e_metanext(c)
#ifdef notdef
/*ARGSUSED*/
CCRETVAL
-e_extendnext(c)
- Char c;
+e_extendnext(Char c)
{
CurrentKeyMap = CcAltMap;
return(CC_ARGHACK); /* preserve argument */
@@ -3158,8 +3147,7 @@ e_extendnext(c)
/*ARGSUSED*/
CCRETVAL
-v_insbeg(c)
- Char c;
+v_insbeg(Char c)
{ /* move to beginning of line and start vi
* insert mode */
USE(c);
@@ -3176,8 +3164,7 @@ v_insbeg(c)
/*ARGSUSED*/
CCRETVAL
-v_replone(c)
- Char c;
+v_replone(Char c)
{ /* vi mode overwrite one character */
USE(c);
c_alternativ_key_map(0);
@@ -3190,8 +3177,7 @@ v_replone(c)
/*ARGSUSED*/
CCRETVAL
-v_replmode(c)
- Char c;
+v_replmode(Char c)
{ /* vi mode start overwriting */
USE(c);
c_alternativ_key_map(0);
@@ -3204,8 +3190,7 @@ v_replmode(c)
/*ARGSUSED*/
CCRETVAL
-v_substchar(c)
- Char c;
+v_substchar(Char c)
{ /* vi mode substitute for one char */
USE(c);
c_delafter(Argument);
@@ -3215,8 +3200,7 @@ v_substchar(c)
/*ARGSUSED*/
CCRETVAL
-v_substline(c)
- Char c;
+v_substline(Char c)
{ /* vi mode replace whole line */
USE(c);
(void) e_killall(0);
@@ -3226,8 +3210,7 @@ v_substline(c)
/*ARGSUSED*/
CCRETVAL
-v_chgtoend(c)
- Char c;
+v_chgtoend(Char c)
{ /* vi mode change to end of line */
USE(c);
(void) e_killend(0);
@@ -3237,8 +3220,7 @@ v_chgtoend(c)
/*ARGSUSED*/
CCRETVAL
-v_insert(c)
- Char c;
+v_insert(Char c)
{ /* vi mode start inserting */
USE(c);
c_alternativ_key_map(0);
@@ -3252,8 +3234,7 @@ v_insert(c)
/*ARGSUSED*/
CCRETVAL
-v_add(c)
- Char c;
+v_add(Char c)
{ /* vi mode start adding */
USE(c);
c_alternativ_key_map(0);
@@ -3274,8 +3255,7 @@ v_add(c)
/*ARGSUSED*/
CCRETVAL
-v_addend(c)
- Char c;
+v_addend(Char c)
{ /* vi mode to add at end of line */
USE(c);
c_alternativ_key_map(0);
@@ -3291,8 +3271,7 @@ v_addend(c)
/*ARGSUSED*/
CCRETVAL
-v_change_case(cc)
- Char cc;
+v_change_case(Char cc)
{
Char c;
@@ -3317,8 +3296,7 @@ v_change_case(cc)
/*ARGSUSED*/
CCRETVAL
-e_expand(c)
- Char c;
+e_expand(Char c)
{
Char *p;
@@ -3335,8 +3313,7 @@ e_expand(c)
/*ARGSUSED*/
CCRETVAL
-e_startover(c)
- Char c;
+e_startover(Char c)
{ /* erase all of current line, start again */
USE(c);
ResetInLine(0); /* reset the input pointers */
@@ -3345,8 +3322,7 @@ e_startover(c)
/*ARGSUSED*/
CCRETVAL
-e_redisp(c)
- Char c;
+e_redisp(Char c)
{
USE(c);
ClearLines();
@@ -3356,8 +3332,7 @@ e_redisp(c)
/*ARGSUSED*/
CCRETVAL
-e_cleardisp(c)
- Char c;
+e_cleardisp(Char c)
{
USE(c);
ClearScreen(); /* clear the whole real screen */
@@ -3367,8 +3342,7 @@ e_cleardisp(c)
/*ARGSUSED*/
CCRETVAL
-e_tty_int(c)
- Char c;
+e_tty_int(Char c)
{
USE(c);
#if defined(_MINIX) || defined(WINNT_NATIVE)
@@ -3390,8 +3364,7 @@ e_tty_int(c)
*/
/*ARGSUSED*/
CCRETVAL
-e_stuff_char(c)
- Char c;
+e_stuff_char(Char c)
{
#ifdef TIOCSTI
int was_raw = Tty_raw_mode;
@@ -3401,13 +3374,13 @@ e_stuff_char(c)
if (was_raw)
(void) Cookedmode();
- (void) write(SHIN, "\n", 1);
+ (void) xwrite(SHIN, "\n", 1);
len = one_wctomb(buf, c & CHAR);
for (i = 0; i < len; i++)
(void) ioctl(SHIN, TIOCSTI, (ioctl_t) &buf[i]);
if (was_raw)
- (void) Rawmode();
+ (void) Rawmode();
return(e_redisp(c));
#else /* !TIOCSTI */
return(CC_ERROR);
@@ -3416,8 +3389,7 @@ e_stuff_char(c)
/*ARGSUSED*/
CCRETVAL
-e_insovr(c)
- Char c;
+e_insovr(Char c)
{
USE(c);
inputmode = (inputmode == MODE_INSERT ? MODE_REPLACE : MODE_INSERT);
@@ -3426,8 +3398,7 @@ e_insovr(c)
/*ARGSUSED*/
CCRETVAL
-e_tty_dsusp(c)
- Char c;
+e_tty_dsusp(Char c)
{
USE(c);
/* do no editing */
@@ -3436,8 +3407,7 @@ e_tty_dsusp(c)
/*ARGSUSED*/
CCRETVAL
-e_tty_flusho(c)
- Char c;
+e_tty_flusho(Char c)
{
USE(c);
/* do no editing */
@@ -3446,8 +3416,7 @@ e_tty_flusho(c)
/*ARGSUSED*/
CCRETVAL
-e_tty_quit(c)
- Char c;
+e_tty_quit(Char c)
{
USE(c);
/* do no editing */
@@ -3456,8 +3425,7 @@ e_tty_quit(c)
/*ARGSUSED*/
CCRETVAL
-e_tty_tsusp(c)
- Char c;
+e_tty_tsusp(Char c)
{
USE(c);
/* do no editing */
@@ -3466,8 +3434,7 @@ e_tty_tsusp(c)
/*ARGSUSED*/
CCRETVAL
-e_tty_stopo(c)
- Char c;
+e_tty_stopo(Char c)
{
USE(c);
/* do no editing */
@@ -3476,8 +3443,7 @@ e_tty_stopo(c)
/*ARGSUSED*/
CCRETVAL
-e_expand_history(c)
- Char c;
+e_expand_history(Char c)
{
USE(c);
*LastChar = '\0'; /* just in case */
@@ -3487,8 +3453,7 @@ e_expand_history(c)
/*ARGSUSED*/
CCRETVAL
-e_magic_space(c)
- Char c;
+e_magic_space(Char c)
{
USE(c);
*LastChar = '\0'; /* just in case */
@@ -3498,29 +3463,48 @@ e_magic_space(c)
/*ARGSUSED*/
CCRETVAL
-e_inc_fwd(c)
- Char c;
+e_inc_fwd(Char c)
{
+ CCRETVAL ret;
+
USE(c);
- patlen = 0;
- return e_inc_search(F_DOWN_SEARCH_HIST);
+ patbuf.len = 0;
+ MarkIsSet = 0;
+ ret = e_inc_search(F_DOWN_SEARCH_HIST);
+ if (adrof(STRhighlight) && IncMatchLen) {
+ IncMatchLen = 0;
+ ClearLines();
+ ClearDisp();
+ Refresh();
+ }
+ IncMatchLen = 0;
+ return ret;
}
/*ARGSUSED*/
CCRETVAL
-e_inc_back(c)
- Char c;
+e_inc_back(Char c)
{
+ CCRETVAL ret;
+
USE(c);
- patlen = 0;
- return e_inc_search(F_UP_SEARCH_HIST);
+ patbuf.len = 0;
+ MarkIsSet = 0;
+ ret = e_inc_search(F_UP_SEARCH_HIST);
+ if (adrof(STRhighlight) && IncMatchLen) {
+ IncMatchLen = 0;
+ ClearLines();
+ ClearDisp();
+ Refresh();
+ }
+ IncMatchLen = 0;
+ return ret;
}
/*ARGSUSED*/
CCRETVAL
-e_copyprev(c)
- Char c;
+e_copyprev(Char c)
{
Char *cp, *oldc, *dp;
@@ -3544,8 +3528,7 @@ e_copyprev(c)
/*ARGSUSED*/
CCRETVAL
-e_tty_starto(c)
- Char c;
+e_tty_starto(Char c)
{
USE(c);
/* do no editing */
@@ -3554,8 +3537,7 @@ e_tty_starto(c)
/*ARGSUSED*/
CCRETVAL
-e_load_average(c)
- Char c;
+e_load_average(Char c)
{
USE(c);
PastBottom();
@@ -3572,8 +3554,7 @@ e_load_average(c)
/*ARGSUSED*/
CCRETVAL
-v_chgmeta(c)
- Char c;
+v_chgmeta(Char c)
{
USE(c);
/*
@@ -3585,8 +3566,7 @@ v_chgmeta(c)
/*ARGSUSED*/
CCRETVAL
-v_delmeta(c)
- Char c;
+v_delmeta(Char c)
{
USE(c);
return(v_action(TCSHOP_DELETE));
@@ -3595,8 +3575,7 @@ v_delmeta(c)
/*ARGSUSED*/
CCRETVAL
-v_endword(c)
- Char c;
+v_endword(Char c)
{
USE(c);
if (Cursor == LastChar)
@@ -3618,8 +3597,7 @@ v_endword(c)
/*ARGSUSED*/
CCRETVAL
-v_eword(c)
- Char c;
+v_eword(Char c)
{
USE(c);
if (Cursor == LastChar)
@@ -3640,8 +3618,7 @@ v_eword(c)
/*ARGSUSED*/
CCRETVAL
-v_char_fwd(c)
- Char c;
+v_char_fwd(Char c)
{
Char ch;
@@ -3658,8 +3635,7 @@ v_char_fwd(c)
/*ARGSUSED*/
CCRETVAL
-v_char_back(c)
- Char c;
+v_char_back(Char c)
{
Char ch;
@@ -3675,8 +3651,7 @@ v_char_back(c)
/*ARGSUSED*/
CCRETVAL
-v_charto_fwd(c)
- Char c;
+v_charto_fwd(Char c)
{
Char ch;
@@ -3690,8 +3665,7 @@ v_charto_fwd(c)
/*ARGSUSED*/
CCRETVAL
-v_charto_back(c)
- Char c;
+v_charto_back(Char c)
{
Char ch;
@@ -3704,8 +3678,7 @@ v_charto_back(c)
/*ARGSUSED*/
CCRETVAL
-v_rchar_fwd(c)
- Char c;
+v_rchar_fwd(Char c)
{
USE(c);
if (srch_char == 0)
@@ -3717,8 +3690,7 @@ v_rchar_fwd(c)
/*ARGSUSED*/
CCRETVAL
-v_rchar_back(c)
- Char c;
+v_rchar_back(Char c)
{
USE(c);
if (srch_char == 0)
@@ -3730,8 +3702,7 @@ v_rchar_back(c)
/*ARGSUSED*/
CCRETVAL
-v_undo(c)
- Char c;
+v_undo(Char c)
{
int loop;
Char *kp, *cp;
@@ -3793,8 +3764,7 @@ v_undo(c)
/*ARGSUSED*/
CCRETVAL
-v_ush_meta(c)
- Char c;
+v_ush_meta(Char c)
{
USE(c);
return v_search(F_UP_SEARCH_HIST);
@@ -3802,8 +3772,7 @@ v_ush_meta(c)
/*ARGSUSED*/
CCRETVAL
-v_dsh_meta(c)
- Char c;
+v_dsh_meta(Char c)
{
USE(c);
return v_search(F_DOWN_SEARCH_HIST);
@@ -3811,21 +3780,19 @@ v_dsh_meta(c)
/*ARGSUSED*/
CCRETVAL
-v_rsrch_fwd(c)
- Char c;
+v_rsrch_fwd(Char c)
{
USE(c);
- if (patlen == 0) return(CC_ERROR);
+ if (patbuf.len == 0) return(CC_ERROR);
return(v_repeat_srch(searchdir));
}
/*ARGSUSED*/
CCRETVAL
-v_rsrch_back(c)
- Char c;
+v_rsrch_back(Char c)
{
USE(c);
- if (patlen == 0) return(CC_ERROR);
+ if (patbuf.len == 0) return(CC_ERROR);
return(v_repeat_srch(searchdir == F_UP_SEARCH_HIST ?
F_DOWN_SEARCH_HIST : F_UP_SEARCH_HIST));
}
@@ -3835,45 +3802,39 @@ v_rsrch_back(c)
functions will keep the F_NUM_FNS consistent
*/
CCRETVAL
-e_copy_to_clipboard(c)
- Char c;
+e_copy_to_clipboard(Char c)
{
USE(c);
return CC_ERROR;
}
CCRETVAL
-e_paste_from_clipboard(c)
- Char c;
+e_paste_from_clipboard(Char c)
{
USE(c);
return (CC_ERROR);
}
CCRETVAL
-e_dosify_next(c)
- Char c;
+e_dosify_next(Char c)
{
USE(c);
return (CC_ERROR);
}
CCRETVAL
-e_dosify_prev(c)
- Char c;
+e_dosify_prev(Char c)
{
USE(c);
return (CC_ERROR);
}
CCRETVAL
-e_page_up(c)
- Char c;
+e_page_up(Char c)
{
USE(c);
return (CC_ERROR);
}
CCRETVAL
-e_page_down(c)
- Char c;
+e_page_down(Char c)
{
USE(c);
return (CC_ERROR);
@@ -3882,8 +3843,7 @@ e_page_down(c)
#ifdef notdef
void
-MoveCursor(n) /* move cursor + right - left char */
- int n;
+MoveCursor(int n) /* move cursor + right - left char */
{
Cursor = Cursor + n;
if (Cursor < InputBuf)
@@ -3894,14 +3854,13 @@ MoveCursor(n) /* move cursor + right - left char */
}
Char *
-GetCursor()
+GetCursor(void)
{
return(Cursor);
}
int
-PutCursor(p)
- Char *p;
+PutCursor(Char *p)
{
if (p < InputBuf || p > LastChar)
return 1; /* Error */
diff --git a/contrib/tcsh/ed.decls.h b/contrib/tcsh/ed.decls.h
index 2fac59a..a9628ce 100644
--- a/contrib/tcsh/ed.decls.h
+++ b/contrib/tcsh/ed.decls.h
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/ed.decls.h,v 3.39 2005/01/18 20:24:50 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/ed.decls.h,v 3.44 2006/08/23 15:03:13 christos Exp $ */
/*
* ed.decls.h: Editor external definitions
*/
@@ -36,240 +36,245 @@
/*
* ed.chared.c
*/
-extern int InsertStr __P((Char *));
-extern void DeleteBack __P((int));
-extern void SetKillRing __P((int));
+extern int InsertStr (Char *);
+extern void DeleteBack (int);
+extern void SetKillRing (int);
+extern CCRETVAL GetHistLine (void);
/*
* ed.init.c
*/
#ifdef SIG_WINDOW
-extern void check_window_size __P((int));
-extern RETSIGTYPE window_change __P((int));
+extern void check_window_size (int);
+extern void window_change (int);
#endif /* SIG_WINDOW */
-extern int ed_Setup __P((int));
-extern void ed_Init __P((void));
-extern int Cookedmode __P((void));
-extern int Rawmode __P((void));
-extern void ed_set_tty_eight_bit __P((void));
+extern int ed_Setup (int);
+extern void ed_Init (void);
+extern int Cookedmode (void);
+extern int Rawmode (void);
+extern void ed_set_tty_eight_bit (void);
-extern void QuoteModeOn __P((void));
-extern void QuoteModeOff __P((void));
-extern void ResetInLine __P((int));
-extern int Load_input_line __P((void));
+extern void QuoteModeOn (void);
+extern void QuoteModeOff (void);
+extern void ResetInLine (int);
+extern int Load_input_line (void);
/*
* ed.term.c:
*/
-extern void dosetty __P((Char **, struct command *));
-extern int tty_getty __P((int, ttydata_t *));
-extern int tty_setty __P((int, ttydata_t *));
-extern void tty_getchar __P((ttydata_t *, unsigned char *));
-extern void tty_setchar __P((ttydata_t *, unsigned char *));
-extern speed_t tty_getspeed __P((ttydata_t *));
-extern int tty_gettabs __P((ttydata_t *));
-extern int tty_geteightbit __P((ttydata_t *));
-extern int tty_cooked_mode __P((ttydata_t *));
+extern void dosetty (Char **, struct command *);
+extern int tty_getty (int, ttydata_t *);
+extern int tty_setty (int, ttydata_t *);
+extern void tty_getchar (ttydata_t *, unsigned char *);
+extern void tty_setchar (ttydata_t *, unsigned char *);
+extern speed_t tty_getspeed (ttydata_t *);
+extern int tty_gettabs (ttydata_t *);
+extern int tty_geteightbit (ttydata_t *);
+extern int tty_cooked_mode (ttydata_t *);
#ifdef _IBMR2
-extern void tty_setdisc __P((int, int));
+extern void tty_setdisc (int, int);
#endif /* _IBMR2 */
/*
* ed.screen.c
*/
-extern void terminit __P((void));
-extern void SetAttributes __P((Char));
-extern void so_write __P((Char *, int));
-extern void ClearScreen __P((void));
-extern void MoveToLine __P((int));
-extern void MoveToChar __P((int));
-extern void ClearEOL __P((int));
-extern void Insert_write __P((Char *, int));
-extern void DeleteChars __P((int));
-extern void TellTC __P((void));
-extern void SetTC __P((char *, char *));
-extern void EchoTC __P((Char **));
-extern int SetArrowKeys __P((CStr *, XmapVal *, int));
-extern int IsArrowKey __P((Char *));
-extern void ResetArrowKeys __P((void));
-extern void DefaultArrowKeys __P((void));
-extern int ClearArrowKeys __P((CStr *));
-extern void PrintArrowKeys __P((CStr *));
-extern void BindArrowKeys __P((void));
-extern void SoundBeep __P((void));
-extern int CanWeTab __P((void));
-extern void ChangeSize __P((int, int));
+extern void terminit (void);
+extern void SetAttributes (Char);
+extern void so_write (Char *, int);
+extern void ClearScreen (void);
+extern void MoveToLine (int);
+extern void MoveToChar (int);
+extern void ClearEOL (int);
+extern void Insert_write (Char *, int);
+extern void DeleteChars (int);
+extern void TellTC (void);
+extern void SetTC (char *, char *);
+extern void EchoTC (Char **);
+extern int SetArrowKeys (const CStr *, XmapVal *, int);
+extern int IsArrowKey (Char *);
+extern void ResetArrowKeys (void);
+extern void DefaultArrowKeys (void);
+extern int ClearArrowKeys (const CStr *);
+extern void PrintArrowKeys (const CStr *);
+extern void BindArrowKeys (void);
+extern void SoundBeep (void);
+extern int CanWeTab (void);
+extern void ChangeSize (int, int);
#ifdef SIG_WINDOW
-extern int GetSize __P((int *, int *));
+extern int GetSize (int *, int *);
#endif /* SIG_WINDOW */
-extern void ClearToBottom __P((void));
-extern void GetTermCaps __P((void));
+extern void ClearToBottom (void);
+extern void GetTermCaps (void);
+extern void StartHighlight (void);
+extern void StopHighlight (void);
/*
* ed.defns.c
*/
-extern void editinit __P((void));
-extern void ed_InitNLSMaps __P((void));
+extern void editinit (void);
+extern void ed_InitNLSMaps (void);
#ifdef DEBUG_EDIT
-extern void CheckMaps __P((void));
+extern void CheckMaps (void);
#endif
-extern void ed_InitMaps __P((void));
-extern void ed_InitEmacsMaps __P((void));
-extern void ed_InitVIMaps __P((void));
+extern void ed_InitMaps (void);
+extern void ed_InitEmacsMaps (void);
+extern void ed_InitVIMaps (void);
-extern CCRETVAL e_unassigned __P((Char));
-extern CCRETVAL e_insert __P((Char));
-extern CCRETVAL e_newline __P((Char));
-extern CCRETVAL e_delprev __P((Char));
-extern CCRETVAL e_delnext __P((Char));
+extern CCRETVAL e_unassigned (Char);
+extern CCRETVAL e_insert (Char);
+extern CCRETVAL e_newline (Char);
+extern CCRETVAL e_delprev (Char);
+extern CCRETVAL e_delnext (Char);
/* added by mtk@ari.ncl.omron.co.jp (920818) */
-extern CCRETVAL e_delnext_eof __P((Char));
-extern CCRETVAL e_delnext_list __P((Char));
-extern CCRETVAL e_delnext_list_eof __P((Char)); /* for ^D */
-extern CCRETVAL e_toend __P((Char));
-extern CCRETVAL e_tobeg __P((Char));
-extern CCRETVAL e_charback __P((Char));
-extern CCRETVAL e_charfwd __P((Char));
-extern CCRETVAL e_quote __P((Char));
-extern CCRETVAL e_startover __P((Char));
-extern CCRETVAL e_redisp __P((Char));
-extern CCRETVAL e_wordback __P((Char));
-extern CCRETVAL e_wordfwd __P((Char));
-extern CCRETVAL v_wordbegnext __P((Char));
-extern CCRETVAL e_uppercase __P((Char));
-extern CCRETVAL e_lowercase __P((Char));
-extern CCRETVAL e_capitolcase __P((Char));
-extern CCRETVAL e_cleardisp __P((Char));
-extern CCRETVAL e_complete __P((Char));
-extern CCRETVAL e_correct __P((Char));
-extern CCRETVAL e_correctl __P((Char));
-extern CCRETVAL e_up_hist __P((Char));
-extern CCRETVAL e_down_hist __P((Char));
-extern CCRETVAL e_up_search_hist __P((Char));
-extern CCRETVAL e_down_search_hist __P((Char));
-extern CCRETVAL e_helpme __P((Char));
-extern CCRETVAL e_list_choices __P((Char));
-extern CCRETVAL e_delwordprev __P((Char));
-extern CCRETVAL e_delwordnext __P((Char));
-extern CCRETVAL e_digit __P((Char));
-extern CCRETVAL e_argdigit __P((Char));
-extern CCRETVAL v_zero __P((Char));
-extern CCRETVAL e_killend __P((Char));
-extern CCRETVAL e_killbeg __P((Char));
-extern CCRETVAL e_metanext __P((Char));
+extern CCRETVAL e_delnext_eof (Char);
+extern CCRETVAL e_delnext_list (Char);
+extern CCRETVAL e_delnext_list_eof (Char); /* for ^D */
+extern CCRETVAL e_toend (Char);
+extern CCRETVAL e_tobeg (Char);
+extern CCRETVAL e_charback (Char);
+extern CCRETVAL e_charfwd (Char);
+extern CCRETVAL e_quote (Char);
+extern CCRETVAL e_startover (Char);
+extern CCRETVAL e_redisp (Char);
+extern CCRETVAL e_wordback (Char);
+extern CCRETVAL e_wordfwd (Char);
+extern CCRETVAL v_wordbegnext (Char);
+extern CCRETVAL e_uppercase (Char);
+extern CCRETVAL e_lowercase (Char);
+extern CCRETVAL e_capitolcase (Char);
+extern CCRETVAL e_cleardisp (Char);
+extern CCRETVAL e_complete (Char);
+extern CCRETVAL e_correct (Char);
+extern CCRETVAL e_correctl (Char);
+extern CCRETVAL e_up_hist (Char);
+extern CCRETVAL e_down_hist (Char);
+extern CCRETVAL e_up_search_hist (Char);
+extern CCRETVAL e_down_search_hist (Char);
+extern CCRETVAL e_helpme (Char);
+extern CCRETVAL e_list_choices (Char);
+extern CCRETVAL e_delwordprev (Char);
+extern CCRETVAL e_delwordnext (Char);
+extern CCRETVAL e_digit (Char);
+extern CCRETVAL e_argdigit (Char);
+extern CCRETVAL v_zero (Char);
+extern CCRETVAL e_killend (Char);
+extern CCRETVAL e_killbeg (Char);
+extern CCRETVAL e_metanext (Char);
#ifdef notdef
-extern CCRETVAL e_extendnext __P((Char));
+extern CCRETVAL e_extendnext (Char);
#endif
-extern CCRETVAL e_send_eof __P((Char));
-extern CCRETVAL e_charswitch __P((Char));
-extern CCRETVAL e_gcharswitch __P((Char));
-extern CCRETVAL e_which __P((Char));
-extern CCRETVAL e_yank_kill __P((Char));
-extern CCRETVAL e_tty_dsusp __P((Char));
-extern CCRETVAL e_tty_flusho __P((Char));
-extern CCRETVAL e_tty_quit __P((Char));
-extern CCRETVAL e_tty_tsusp __P((Char));
-extern CCRETVAL e_tty_stopo __P((Char));
-extern CCRETVAL e_tty_starto __P((Char));
-extern CCRETVAL e_argfour __P((Char));
-extern CCRETVAL e_set_mark __P((Char));
-extern CCRETVAL e_exchange_mark __P((Char));
-extern CCRETVAL e_last_item __P((Char));
-extern CCRETVAL v_cmd_mode __P((Char));
-extern CCRETVAL v_insert __P((Char));
-extern CCRETVAL v_replmode __P((Char));
-extern CCRETVAL v_replone __P((Char));
-extern CCRETVAL v_substline __P((Char));
-extern CCRETVAL v_substchar __P((Char));
-extern CCRETVAL v_add __P((Char));
-extern CCRETVAL v_addend __P((Char));
-extern CCRETVAL v_insbeg __P((Char));
-extern CCRETVAL v_chgtoend __P((Char));
-extern CCRETVAL e_killregion __P((Char));
-extern CCRETVAL e_killall __P((Char));
-extern CCRETVAL e_copyregion __P((Char));
-extern CCRETVAL e_tty_int __P((Char));
-extern CCRETVAL e_run_fg_editor __P((Char));
-extern CCRETVAL e_list_eof __P((Char));
-extern CCRETVAL e_expand_history __P((Char));
-extern CCRETVAL e_magic_space __P((Char));
-extern CCRETVAL e_list_glob __P((Char));
-extern CCRETVAL e_expand_glob __P((Char));
-extern CCRETVAL e_insovr __P((Char));
-extern CCRETVAL v_cm_complete __P((Char));
-extern CCRETVAL e_copyprev __P((Char));
-extern CCRETVAL v_change_case __P((Char));
-extern CCRETVAL e_expand __P((Char));
-extern CCRETVAL e_expand_vars __P((Char));
-extern CCRETVAL e_toggle_hist __P((Char));
-extern CCRETVAL e_load_average __P((Char));
-extern CCRETVAL v_delprev __P((Char));
-extern CCRETVAL v_delmeta __P((Char));
-extern CCRETVAL v_wordfwd __P((Char));
-extern CCRETVAL v_wordback __P((Char));
-extern CCRETVAL v_endword __P((Char));
-extern CCRETVAL v_eword __P((Char));
-extern CCRETVAL v_undo __P((Char));
-extern CCRETVAL v_ush_meta __P((Char));
-extern CCRETVAL v_dsh_meta __P((Char));
-extern CCRETVAL v_rsrch_fwd __P((Char));
-extern CCRETVAL v_rsrch_back __P((Char));
-extern CCRETVAL v_char_fwd __P((Char));
-extern CCRETVAL v_char_back __P((Char));
-extern CCRETVAL v_chgmeta __P((Char));
-extern CCRETVAL e_inc_fwd __P((Char));
-extern CCRETVAL e_inc_back __P((Char));
-extern CCRETVAL v_rchar_fwd __P((Char));
-extern CCRETVAL v_rchar_back __P((Char));
-extern CCRETVAL v_charto_fwd __P((Char));
-extern CCRETVAL v_charto_back __P((Char));
-extern CCRETVAL e_normalize_path __P((Char));
-extern CCRETVAL e_normalize_command __P((Char));
-extern CCRETVAL e_stuff_char __P((Char));
-extern CCRETVAL e_list_all __P((Char));
-extern CCRETVAL e_complete_all __P((Char));
-extern CCRETVAL e_complete_fwd __P((Char));
-extern CCRETVAL e_complete_back __P((Char));
-extern CCRETVAL e_dabbrev_expand __P((Char));
-extern CCRETVAL e_copy_to_clipboard __P((Char));
-extern CCRETVAL e_paste_from_clipboard __P((Char));
-extern CCRETVAL e_dosify_next __P((Char));
-extern CCRETVAL e_dosify_prev __P((Char));
-extern CCRETVAL e_page_up __P((Char));
-extern CCRETVAL e_page_down __P((Char));
-extern CCRETVAL e_yank_pop __P((Char));
+extern CCRETVAL e_send_eof (Char);
+extern CCRETVAL e_charswitch (Char);
+extern CCRETVAL e_gcharswitch (Char);
+extern CCRETVAL e_which (Char);
+extern CCRETVAL e_yank_kill (Char);
+extern CCRETVAL e_tty_dsusp (Char);
+extern CCRETVAL e_tty_flusho (Char);
+extern CCRETVAL e_tty_quit (Char);
+extern CCRETVAL e_tty_tsusp (Char);
+extern CCRETVAL e_tty_stopo (Char);
+extern CCRETVAL e_tty_starto (Char);
+extern CCRETVAL e_argfour (Char);
+extern CCRETVAL e_set_mark (Char);
+extern CCRETVAL e_exchange_mark (Char);
+extern CCRETVAL e_last_item (Char);
+extern CCRETVAL v_cmd_mode (Char);
+extern CCRETVAL v_insert (Char);
+extern CCRETVAL v_replmode (Char);
+extern CCRETVAL v_replone (Char);
+extern CCRETVAL v_substline (Char);
+extern CCRETVAL v_substchar (Char);
+extern CCRETVAL v_add (Char);
+extern CCRETVAL v_addend (Char);
+extern CCRETVAL v_insbeg (Char);
+extern CCRETVAL v_chgtoend (Char);
+extern CCRETVAL e_killregion (Char);
+extern CCRETVAL e_killall (Char);
+extern CCRETVAL e_copyregion (Char);
+extern CCRETVAL e_tty_int (Char);
+extern CCRETVAL e_run_fg_editor (Char);
+extern CCRETVAL e_list_eof (Char);
+extern CCRETVAL e_expand_history (Char);
+extern CCRETVAL e_magic_space (Char);
+extern CCRETVAL e_list_glob (Char);
+extern CCRETVAL e_expand_glob (Char);
+extern CCRETVAL e_insovr (Char);
+extern CCRETVAL v_cm_complete (Char);
+extern CCRETVAL e_copyprev (Char);
+extern CCRETVAL v_change_case (Char);
+extern CCRETVAL e_expand (Char);
+extern CCRETVAL e_expand_vars (Char);
+extern CCRETVAL e_toggle_hist (Char);
+extern CCRETVAL e_load_average (Char);
+extern CCRETVAL v_delprev (Char);
+extern CCRETVAL v_delmeta (Char);
+extern CCRETVAL v_wordfwd (Char);
+extern CCRETVAL v_wordback (Char);
+extern CCRETVAL v_endword (Char);
+extern CCRETVAL v_eword (Char);
+extern CCRETVAL v_undo (Char);
+extern CCRETVAL v_ush_meta (Char);
+extern CCRETVAL v_dsh_meta (Char);
+extern CCRETVAL v_rsrch_fwd (Char);
+extern CCRETVAL v_rsrch_back (Char);
+extern CCRETVAL v_char_fwd (Char);
+extern CCRETVAL v_char_back (Char);
+extern CCRETVAL v_chgmeta (Char);
+extern CCRETVAL e_inc_fwd (Char);
+extern CCRETVAL e_inc_back (Char);
+extern CCRETVAL v_rchar_fwd (Char);
+extern CCRETVAL v_rchar_back (Char);
+extern CCRETVAL v_charto_fwd (Char);
+extern CCRETVAL v_charto_back (Char);
+extern CCRETVAL e_normalize_path (Char);
+extern CCRETVAL e_normalize_command (Char);
+extern CCRETVAL e_stuff_char (Char);
+extern CCRETVAL e_list_all (Char);
+extern CCRETVAL e_complete_all (Char);
+extern CCRETVAL e_complete_fwd (Char);
+extern CCRETVAL e_complete_back (Char);
+extern CCRETVAL e_dabbrev_expand (Char);
+extern CCRETVAL e_copy_to_clipboard (Char);
+extern CCRETVAL e_paste_from_clipboard (Char);
+extern CCRETVAL e_dosify_next (Char);
+extern CCRETVAL e_dosify_prev (Char);
+extern CCRETVAL e_page_up (Char);
+extern CCRETVAL e_page_down (Char);
+extern CCRETVAL e_yank_pop (Char);
+extern CCRETVAL e_newline_hold (Char);
+extern CCRETVAL e_newline_down_hist (Char);
/*
* ed.inputl.c
*/
-extern int Inputl __P((void));
-extern int GetNextChar __P((Char *));
-extern void UngetNextChar __P((Char));
-extern void PushMacro __P((Char *));
+extern int Inputl (void);
+extern int GetNextChar (Char *);
+extern void UngetNextChar (Char);
+extern void PushMacro (Char *);
/*
* ed.refresh.c
*/
-extern void ClearLines __P((void));
-extern void ClearDisp __P((void));
-extern void Refresh __P((void));
-extern void RefCursor __P((void));
-extern void RefPlusOne __P((int));
-extern void PastBottom __P((void));
+extern void ClearLines (void);
+extern void ClearDisp (void);
+extern void Refresh (void);
+extern void RefCursor (void);
+extern void RefPlusOne (int);
+extern void PastBottom (void);
/*
* ed.xmap.c
*/
-extern XmapVal *XmapStr __P((CStr *));
-extern XmapVal *XmapCmd __P((int));
-extern void AddXkey __P((CStr *, XmapVal *, int));
-extern void ClearXkey __P((KEYCMD *, CStr *));
-extern int GetXkey __P((CStr *, XmapVal *));
-extern void ResetXmap __P((void));
-extern int DeleteXkey __P((CStr *));
-extern void PrintXkey __P((CStr *));
-extern int printOne __P((CStr *, XmapVal *, int));
-extern eChar parseescape __P((const Char **));
-extern unsigned char *unparsestring __P((CStr *, unsigned char *, Char *));
+extern XmapVal *XmapStr (CStr *);
+extern XmapVal *XmapCmd (int);
+extern void AddXkey (const CStr *, XmapVal *, int);
+extern void ClearXkey (KEYCMD *, const CStr *);
+extern int GetXkey (CStr *, XmapVal *);
+extern void ResetXmap (void);
+extern int DeleteXkey (const CStr *);
+extern void PrintXkey (const CStr *);
+extern void printOne (const Char *, const XmapVal *, int);
+extern eChar parseescape (const Char **);
+extern unsigned char *unparsestring (const CStr *, const Char *);
#endif /* _h_ed_decls */
diff --git a/contrib/tcsh/ed.defns.c b/contrib/tcsh/ed.defns.c
index ea2dbcd..5124bde 100644
--- a/contrib/tcsh/ed.defns.c
+++ b/contrib/tcsh/ed.defns.c
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/ed.defns.c,v 3.42 2005/03/03 16:49:15 kim Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/ed.defns.c,v 3.46 2006/03/02 18:46:44 christos Exp $ */
/*
* ed.defns.c: Editor function definitions and initialization
*/
@@ -32,11 +32,11 @@
*/
#include "sh.h"
-RCSID("$Id: ed.defns.c,v 3.42 2005/03/03 16:49:15 kim Exp $")
+RCSID("$tcsh: ed.defns.c,v 3.46 2006/03/02 18:46:44 christos Exp $")
#include "ed.h"
-static void ed_InitMetaBindings __P((void));
+static void ed_InitMetaBindings (void);
PFCmd CcFuncTbl[] = { /* table of available commands */
e_unassigned,
@@ -279,8 +279,12 @@ PFCmd CcFuncTbl[] = { /* table of available commands */
#define F_PAGE_DOWN 118
e_yank_pop,
#define F_YANK_POP 119
+ e_newline_hold,
+#define F_NEWLINE_HOLD 120
+ e_newline_down_hist,
+#define F_NEWLINE_DOWN_HIST 121
0 /* DUMMY VALUE */
-#define F_NUM_FNS 120
+#define F_NUM_FNS 122
};
@@ -493,7 +497,7 @@ KEYCMD CcEmacsMap[] = {
F_UNASSIGNED, /* M-> */
F_WHICH, /* M-? */
F_UNASSIGNED, /* M-@ */
- F_UNASSIGNED, /* M-A */
+ F_NEWLINE_HOLD, /* M-A */
F_WORDBACK, /* M-B */
F_CASECAPITAL, /* M-C */
F_DELWORDNEXT, /* M-D */
@@ -525,7 +529,7 @@ KEYCMD CcEmacsMap[] = {
F_UNASSIGNED, /* M-^ */
F_LAST_ITEM, /* M-_ */
F_UNASSIGNED, /* M-` */
- F_UNASSIGNED, /* M-a */
+ F_NEWLINE_HOLD, /* M-a */
F_WORDBACK, /* M-b */
F_CASECAPITAL, /* M-c */
F_DELWORDNEXT, /* M-d */
@@ -1120,7 +1124,7 @@ KEYCMD CcViCmdMap[] = {
void
-editinit()
+editinit(void)
{
struct KeyFuncs *f;
@@ -1128,7 +1132,7 @@ editinit()
int i;
for (i = 0; i < F_NUM_FUNCNAMES; i++)
- xfree((ptr_t) FuncNames[i].desc);
+ xfree((ptr_t)(intptr_t)FuncNames[i].desc);
#endif
f = FuncNames;
@@ -1408,6 +1412,16 @@ editinit()
f->desc = CSAVS(3, 52, "Execute command");
f++;
+ f->name = "newline-and-hold";
+ f->func = F_NEWLINE_HOLD;
+ f->desc = CSAVS(3, 122, "Execute command and keep current line");
+
+ f++;
+ f->name = "newline-and-down-history";
+ f->func = F_NEWLINE_DOWN_HIST;
+ f->desc = CSAVS(3, 123, "Execute command and move to next history line");
+
+ f++;
f->name = "normalize-path";
f->func = F_PATH_NORM;
f->desc = CSAVS(3, 53,
@@ -1785,7 +1799,7 @@ editinit()
#ifdef DEBUG_EDIT
void
-CheckMaps()
+CheckMaps(void)
{ /* check the size of the key maps */
int c1 = (NT_NUM_KEYS * sizeof(KEYCMD));
@@ -1817,7 +1831,7 @@ int NLSMapsAreInited = 0;
int NoNLSRebind;
void
-ed_InitNLSMaps()
+ed_InitNLSMaps(void)
{
int i;
@@ -1834,7 +1848,7 @@ ed_InitNLSMaps()
}
static void
-ed_InitMetaBindings()
+ed_InitMetaBindings(void)
{
Char buf[3];
int i;
@@ -1870,7 +1884,7 @@ ed_InitMetaBindings()
}
void
-ed_InitVIMaps()
+ed_InitVIMaps(void)
{
int i;
@@ -1887,7 +1901,7 @@ ed_InitVIMaps()
}
void
-ed_InitEmacsMaps()
+ed_InitEmacsMaps(void)
{
int i;
Char buf[3];
@@ -1930,7 +1944,7 @@ ed_InitEmacsMaps()
}
void
-ed_InitMaps()
+ed_InitMaps(void)
{
if (MapsAreInited)
return;
diff --git a/contrib/tcsh/ed.h b/contrib/tcsh/ed.h
index fba6299..10e519c 100644
--- a/contrib/tcsh/ed.h
+++ b/contrib/tcsh/ed.h
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/ed.h,v 3.44 2005/03/05 03:20:15 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/ed.h,v 3.49 2006/08/23 15:03:13 christos Exp $ */
/*
* ed.h: Editor declarations and globals
*/
@@ -37,7 +37,6 @@
# define EXTERN extern
#endif
-#define TABSIZE 8 /* usually 8 spaces/tab */
#define MAXMACROLEVELS 10 /* max number of nested kbd macros */
#ifndef WINNT_NATIVE
@@ -54,7 +53,7 @@
#define KEYCMD unsigned char /* size needed to index into CcFuncTbl */
/* Must be unsigned */
-typedef CCRETVAL(*PFCmd) __P((Char)); /* pointer to function returning CCRETVAL */
+typedef CCRETVAL(*PFCmd) (Char); /* pointer to function returning CCRETVAL */
struct KeyFuncs { /* for the "bind" shell command */
const char *name; /* function name for bind command */
@@ -100,7 +99,7 @@ typedef struct {
int len;
} CStr;
-typedef union Xmapval { /* value passed to the Xkey routines */
+typedef union { /* value passed to the Xkey routines */
KEYCMD cmd;
CStr str;
} XmapVal;
@@ -118,13 +117,14 @@ EXTERN KEYCMD *CurrentKeyMap; /* current command key map */
EXTERN int inputmode; /* insert, replace, replace1 mode */
EXTERN Char GettingInput; /* true if getting an input line (mostly) */
EXTERN Char NeedsRedraw; /* for editor and twenex error messages */
-EXTERN Char InputBuf[INBUFSIZE]; /* the real input data */
+EXTERN Char InputBuf[INBUFSIZE]; /* the real input data *//*FIXBUF*/
EXTERN Char *LastChar, *Cursor; /* point to the next open space */
EXTERN Char *InputLim; /* limit of size of InputBuf */
EXTERN Char MetaNext; /* flags for ^V and ^[ functions */
EXTERN Char AltKeyMap; /* Using alternative command map (for vi mode) */
EXTERN Char VImode; /* true if running in vi mode (PWP 6-27-88) */
EXTERN Char *Mark; /* the emacs "mark" (dot is Cursor) */
+EXTERN char MarkIsSet; /* true if the mark has been set explicitly */
EXTERN Char DoingArg; /* true if we have an argument */
EXTERN int Argument; /* "universal" argument value */
EXTERN KEYCMD LastCmd; /* previous command executed */
@@ -134,18 +134,20 @@ EXTERN int KillRingLen; /* current length of kill ring */
EXTERN int KillPos; /* points to next kill */
EXTERN int YankPos; /* points to next yank */
-EXTERN Char UndoBuf[INBUFSIZE];
+EXTERN Char UndoBuf[INBUFSIZE];/*FIXBUF*/
EXTERN Char *UndoPtr;
EXTERN int UndoSize;
EXTERN int UndoAction;
-EXTERN Char HistBuf[INBUFSIZE]; /* history buffer */
-EXTERN Char *LastHist; /* points to end of history buffer */
+EXTERN struct Strbuf HistBuf; /* = Strbuf_INIT; history buffer */
EXTERN int Hist_num; /* what point up the history we are at now. */
-EXTERN Char WhichBuf[INBUFSIZE]; /* buffer for which command */
-EXTERN Char *LastWhich; /* points to end of which buffer */
-EXTERN Char *CursWhich; /* points to the cursor point in which buf */
-EXTERN int HistWhich; /* Hist_num is saved in this */
+/* buffer for which command and others */
+EXTERN struct Strbuf SavedBuf; /* = Strbuf_INIT; */
+EXTERN size_t LastSaved; /* points to end of saved buffer */
+EXTERN size_t CursSaved; /* points to the cursor point in saved buf */
+EXTERN int HistSaved; /* Hist_num is saved in this */
+EXTERN char RestoreSaved; /* true if SavedBuf should be restored */
+EXTERN int IncMatchLen; /* current match length during incremental search */
EXTERN char Expand; /* true if we are expanding a line */
extern Char HistLit; /* true if history lines are shown literal */
EXTERN Char CurrentHistLit; /* Literal status of current show history line */
@@ -176,14 +178,14 @@ EXTERN Char **Vdisplay; /* new buffer */
EXTERN int T_Lines, T_Cols; /* Rows and Cols of the terminal */
EXTERN Char T_CanIns; /* true if I can insert characters */
EXTERN Char T_CanDel; /* dito for delete characters */
-EXTERN Char T_Tabs; /* true if tty interface is passing tabs */
-EXTERN Char T_Margin;
+EXTERN char T_Tabs; /* true if tty interface is passing tabs */
+EXTERN char T_Margin;
#define MARGIN_AUTO 1 /* term has auto margins */
#define MARGIN_MAGIC 2 /* concept glitch */
EXTERN speed_t T_Speed; /* Tty input Baud rate */
EXTERN Char T_CanCEOL; /* true if we can clear to end of line */
EXTERN Char T_CanUP; /* true if this term can do reverse linefeen */
-EXTERN Char T_HasMeta; /* true if we have a meta key */
+EXTERN char T_HasMeta; /* true if we have a meta key */
/* note the extra characters in the Strchr() call in this macro */
#define isword(c) (Isalpha(c)||Isdigit(c)||Strchr(word_chars,c))
@@ -227,22 +229,22 @@ extern ttyperm_t ttylist;
/*
* We don't prototype these, cause some systems have them wrong!
*/
-extern int tgetent __P(());
-extern char *tgetstr __P(());
-extern int tgetflag __P(());
-extern int tgetnum __P(());
-extern char *tgoto __P(());
+extern int tgetent ();
+extern char *tgetstr ();
+extern int tgetflag ();
+extern int tgetnum ();
+extern char *tgoto ();
# define PUTPURE putpure
# define PUTRAW putraw
#else
-extern int tgetent __P((char *, const char *));
-extern char *tgetstr __P((const char *, char **));
-extern int tgetflag __P((const char *));
-extern int tgetnum __P((const char *));
-extern char *tgoto __P((const char *, int, int));
-extern void tputs __P((const char *, int, void (*)(int)));
-# define PUTPURE ((void (*)__P((int))) putpure)
-# define PUTRAW ((void (*)__P((int))) putraw)
+extern int tgetent (char *, const char *);
+extern char *tgetstr (const char *, char **);
+extern int tgetflag (const char *);
+extern int tgetnum (const char *);
+extern char *tgoto (const char *, int, int);
+extern void tputs (const char *, int, void (*)(int));
+# define PUTPURE ((void (*)(int)) putpure)
+# define PUTRAW ((void (*)(int)) putraw)
#endif
#endif /* _h_ed */
diff --git a/contrib/tcsh/ed.init.c b/contrib/tcsh/ed.init.c
index 192241a..c7dfcce 100644
--- a/contrib/tcsh/ed.init.c
+++ b/contrib/tcsh/ed.init.c
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/ed.init.c,v 3.52 2005/01/18 20:24:50 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/ed.init.c,v 3.60 2006/08/24 20:56:31 christos Exp $ */
/*
* ed.init.c: Editor initializations
*/
@@ -32,7 +32,7 @@
*/
#include "sh.h"
-RCSID("$Id: ed.init.c,v 3.52 2005/01/18 20:24:50 christos Exp $")
+RCSID("$tcsh: ed.init.c,v 3.60 2006/08/24 20:56:31 christos Exp $")
#include "ed.h"
#include "tc.h"
@@ -90,20 +90,13 @@ static unsigned char ttychars[NN_IO][C_NCC] = {
#ifdef SIG_WINDOW
void
-check_window_size(force)
- int force;
+check_window_size(int force)
{
-#ifdef BSDSIGS
- sigmask_t omask;
-#endif /* BSDSIGS */
int lins, cols;
/* don't want to confuse things here */
-#ifdef BSDSIGS
- omask = sigblock(sigmask(SIG_WINDOW)) & ~sigmask(SIG_WINDOW);
-#else /* BSDSIGS */
- (void) sighold(SIG_WINDOW);
-#endif /* BSDSIGS */
+ pintr_disabled++;
+ cleanup_push(&pintr_disabled, disabled_cleanup);
/*
* From: bret@shark.agps.lanl.gov (Bret Thaeler) Avoid sunview bug, where a
* partially hidden window gets a SIG_WINDOW every time the text is
@@ -121,32 +114,22 @@ check_window_size(force)
else
ChangeSize(lins, cols);
}
-#ifdef BSDSIGS
- (void) sigsetmask(omask); /* can change it again */
-#else /* BSDSIGS */
- (void) sigrelse(SIG_WINDOW);
-#endif /* BSDSIGS */
windowchg = 0;
+ cleanup_until(&pintr_disabled); /* can change it again */
}
-RETSIGTYPE
+void
/*ARGSUSED*/
-window_change(snum)
-int snum;
+window_change(int snum)
{
USE(snum);
-#ifdef UNRELSIGS
- /* If we were called as a signal handler, restore it. */
- if (snum > 0)
- sigset(snum, window_change);
-#endif /* UNRELSIGS */
windowchg = 1;
}
#endif /* SIG_WINDOW */
void
-ed_set_tty_eight_bit()
+ed_set_tty_eight_bit(void)
{
if (tty_getty(SHTTY, &extty) == -1) {
#ifdef DEBUG_TTY
@@ -159,8 +142,7 @@ ed_set_tty_eight_bit()
int
-ed_Setup(rst)
- int rst;
+ed_Setup(int rst)
{
static int havesetup = 0;
struct varent *imode;
@@ -279,8 +261,14 @@ ed_Setup(rst)
tty_setchar(&extty, ttychars[EX_IO]);
# ifdef SIG_WINDOW
- (void) sigset(SIG_WINDOW, window_change); /* for window systems */
-# endif
+ {
+ sigset_t set;
+ (void)signal(SIG_WINDOW, window_change); /* for window systems */
+ sigemptyset(&set);
+ sigaddset(&set, SIG_WINDOW);
+ (void)sigprocmask(SIG_UNBLOCK, &set, NULL);
+ }
+# endif
#else /* WINNT_NATIVE */
# ifdef DEBUG
if (rst)
@@ -292,7 +280,7 @@ ed_Setup(rst)
}
void
-ed_Init()
+ed_Init(void)
{
ResetInLine(1); /* reset the input pointers */
GettingInput = 0; /* just in case */
@@ -308,8 +296,7 @@ ed_Init()
{ /* no kill ring - why? */
int i;
for (i = 0; i < KillRingMax; i++) {
- if (KillRing[i].buf != NULL)
- xfree((ptr_t) KillRing[i].buf);
+ xfree(KillRing[i].buf);
KillRing[i].buf = NULL;
KillRing[i].len = 0;
}
@@ -376,7 +363,7 @@ ed_Init()
* Check and re-init the line. set the terminal into 1 char at a time mode.
*/
int
-Rawmode()
+Rawmode(void)
{
if (Tty_raw_mode)
return (0);
@@ -561,12 +548,13 @@ Rawmode()
}
int
-Cookedmode()
+Cookedmode(void)
{ /* set tty in normal setup */
#ifdef WINNT_NATIVE
do_nt_cooked_mode();
#else
- signalfun_t orig_intr;
+ sigset_t set, oset;
+ int res;
# ifdef _IBMR2
tty_setdisc(SHTTY, EX_IO);
@@ -576,45 +564,18 @@ Cookedmode()
return (0);
/* hold this for reseting tty */
-# ifdef BSDSIGS
- orig_intr = (signalfun_t) signal(SIGINT, SIG_IGN);
-# else
-# ifdef SIG_HOLD
- /*
- * sigset doesn't return the previous handler if the signal is held,
- * it will return SIG_HOLD instead. So instead of restoring the
- * the signal we would end up installing a blocked SIGINT with a
- * SIG_IGN signal handler. This is what happened when Cookedmode
- * was called from sched_run, disabling interrupt for the rest
- * of your session.
- *
- * This is what we do:
- * - if the signal is blocked, keep it that way
- * - else set it to SIG_IGN
- *
- * Casper Dik (casper@fwi.uva.nl)
- */
- orig_intr = (signalfun_t) sigset(SIGINT, SIG_HOLD);
- if (orig_intr != SIG_HOLD)
- (void) sigset(SIGINT, SIG_IGN); /* returns SIG_HOLD */
-# else /* !SIG_HOLD */
- /*
- * No SIG_HOLD; probably no reliable signals as well.
- */
- orig_intr = (signalfun_t) sigset(SIGINT, SIG_IGN);
-# endif /* SIG_HOLD */
-# endif /* BSDSIGS */
- if (tty_setty(SHTTY, &extty) == -1) {
+ sigemptyset(&set);
+ sigaddset(&set, SIGINT);
+ (void)sigprocmask(SIG_BLOCK, &set, &oset);
+ cleanup_push(&oset, sigprocmask_cleanup);
+ res = tty_setty(SHTTY, &extty);
+ cleanup_until(&oset);
+ if (res == -1) {
# ifdef DEBUG_TTY
xprintf("Cookedmode: tty_setty: %s\n", strerror(errno));
# endif /* DEBUG_TTY */
return -1;
}
-# ifdef BSDSIGS
- (void) signal(SIGINT, orig_intr); /* take these again */
-# else
- (void) sigset(SIGINT, orig_intr); /* take these again */
-# endif /* BSDSIGS */
#endif /* WINNT_NATIVE */
Tty_raw_mode = 0;
@@ -622,13 +583,13 @@ Cookedmode()
}
void
-ResetInLine(macro)
- int macro;
+ResetInLine(int macro)
{
Cursor = InputBuf; /* reset cursor */
LastChar = InputBuf;
- InputLim = &InputBuf[INBUFSIZE - 2];
+ InputLim = &InputBuf[INBUFSIZE - 2];/*FIXBUF*/
Mark = InputBuf;
+ MarkIsSet = 0;
MetaNext = 0;
CurrentKeyMap = CcKeyMap;
AltKeyMap = 0;
@@ -636,14 +597,15 @@ ResetInLine(macro)
DoingArg = 0;
Argument = 1;
LastCmd = F_UNASSIGNED; /* previous command executed */
+ IncMatchLen = 0;
if (macro)
MacroLvl = -1; /* no currently active macros */
}
-static Char *Input_Line = NULL;
int
-Load_input_line()
+Load_input_line(void)
{
+ static Char *Input_Line = NULL;
#ifdef SUNOS4
long chrs = 0;
#else /* !SUNOS4 */
@@ -655,7 +617,7 @@ Load_input_line()
#endif /* SUNOS4 */
if (Input_Line)
- xfree((ptr_t) Input_Line);
+ xfree(Input_Line);
Input_Line = NULL;
if (Tty_raw_mode)
@@ -664,9 +626,9 @@ Load_input_line()
#if defined(FIONREAD) && !defined(OREO)
(void) ioctl(SHIN, FIONREAD, (ioctl_t) &chrs);
if (chrs > 0) {
- char buf[BUFSIZE];
+ char buf[BUFSIZE];
- chrs = read(SHIN, buf, (size_t) min(chrs, BUFSIZE - 1));
+ chrs = xread(SHIN, buf, min(chrs, BUFSIZE - 1));
if (chrs > 0) {
buf[chrs] = '\0';
Input_Line = Strsave(str2short(buf));
@@ -692,7 +654,7 @@ Load_input_line()
* (via Hans J Albertsson (thanks))
*/
void
-QuoteModeOn()
+QuoteModeOn(void)
{
if (MacroLvl >= 0)
return;
@@ -731,7 +693,7 @@ QuoteModeOn()
}
void
-QuoteModeOff()
+QuoteModeOff(void)
{
if (!Tty_quote_mode)
return;
diff --git a/contrib/tcsh/ed.inputl.c b/contrib/tcsh/ed.inputl.c
index fb87f8b..a97058e 100644
--- a/contrib/tcsh/ed.inputl.c
+++ b/contrib/tcsh/ed.inputl.c
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/ed.inputl.c,v 3.57 2004/12/25 21:15:06 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/ed.inputl.c,v 3.66 2006/11/29 22:32:24 christos Exp $ */
/*
* ed.inputl.c: Input line handling.
*/
@@ -32,13 +32,13 @@
*/
#include "sh.h"
-RCSID("$Id: ed.inputl.c,v 3.57 2004/12/25 21:15:06 christos Exp $")
+RCSID("$tcsh: ed.inputl.c,v 3.66 2006/11/29 22:32:24 christos Exp $")
#include "ed.h"
#include "ed.defns.h" /* for the function names */
#include "tw.h" /* for twenex stuff */
-#define OKCMD (INBUFSIZE+INBUFSIZE)
+#define OKCMD INT_MAX
/* ed.inputl -- routines to get a single line from the input. */
@@ -48,18 +48,18 @@ extern int MapsAreInited;
static Char mismatch[] =
{'!', '^' , '\\', '-', '%', '\0', '"', '\'', '`', '\0' };
-static int Repair __P((void));
-static int GetNextCommand __P((KEYCMD *, Char *));
-static int SpellLine __P((int));
-static int CompleteLine __P((void));
-static void RunCommand __P((Char *));
-static void doeval1 __P((Char **));
+static int Repair (void);
+static int GetNextCommand (KEYCMD *, Char *);
+static int SpellLine (int);
+static int CompleteLine (void);
+static void RunCommand (Char *);
+static void doeval1 (Char **);
static int rotate = 0;
static int
-Repair()
+Repair(void)
{
if (NeedsRedraw) {
ClearLines();
@@ -75,7 +75,7 @@ Repair()
/* CCRETVAL */
int
-Inputl()
+Inputl(void)
{
CCRETVAL retval;
KEYCMD cmdnum = 0;
@@ -88,7 +88,6 @@ Inputl()
struct varent *matchbeep = adrof(STRmatchbeep);
struct varent *imode = adrof(STRinputmode);
Char *SaveChar, *CorrChar;
- Char Origin[INBUFSIZE], Change[INBUFSIZE];
int matchval; /* from tenematch() */
COMMAND fn;
int curlen = 0;
@@ -132,13 +131,20 @@ Inputl()
GettingInput = 1;
NeedsRedraw = 0;
-
- if (tellwhat) {
- copyn(InputBuf, WhichBuf, INBUFSIZE);
- LastChar = InputBuf + (LastWhich - WhichBuf);
- Cursor = InputBuf + (CursWhich - WhichBuf);
- tellwhat = 0;
- Hist_num = HistWhich;
+ tellwhat = 0;
+
+ if (RestoreSaved) {
+ copyn(InputBuf, SavedBuf.s, INBUFSIZE);/*FIXBUF*/
+ LastChar = InputBuf + LastSaved;
+ Cursor = InputBuf + CursSaved;
+ Hist_num = HistSaved;
+ HistSaved = 0;
+ RestoreSaved = 0;
+ }
+ if (HistSaved) {
+ Hist_num = HistSaved;
+ GetHistLine();
+ HistSaved = 0;
}
if (Expand) {
(void) e_up_hist(0);
@@ -156,7 +162,7 @@ Inputl()
xprintf("Cursor > InputLim\r\n");
if (LastChar > InputLim)
xprintf("LastChar > InputLim\r\n");
- if (InputLim != &InputBuf[INBUFSIZE - 2])
+ if (InputLim != &InputBuf[INBUFSIZE - 2])/*FIXBUF*/
xprintf("InputLim != &InputBuf[INBUFSIZE-2]\r\n");
if ((!DoingArg) && (Argument != 1))
xprintf("(!DoingArg) && (Argument != 1)\r\n");
@@ -209,12 +215,7 @@ Inputl()
case CC_WHICH: /* tell what this command does */
tellwhat = 1;
- copyn(WhichBuf, InputBuf, INBUFSIZE);
- LastWhich = WhichBuf + (LastChar - InputBuf);
- CursWhich = WhichBuf + (Cursor - InputBuf);
*LastChar++ = '\n'; /* for the benifit of CSH */
- HistWhich = Hist_num;
- Hist_num = 0; /* for the history commands */
num = (int) (LastChar - InputBuf); /* number characters read */
break;
@@ -224,36 +225,45 @@ Inputl()
matchval = 1;
if (crct && crct->vec != NULL && (!Strcmp(*(crct->vec), STRcmd) ||
!Strcmp(*(crct->vec), STRall))) {
+ Char *Origin;
+
PastBottom();
- copyn(Origin, InputBuf, INBUFSIZE);
+ Origin = Strsave(InputBuf);
+ cleanup_push(Origin, xfree);
SaveChar = LastChar;
if (SpellLine(!Strcmp(*(crct->vec), STRcmd)) == 1) {
+ Char *Change;
+
PastBottom();
- copyn(Change, InputBuf, INBUFSIZE);
+ Change = Strsave(InputBuf);
+ cleanup_push(Change, xfree);
*Strchr(Change, '\n') = '\0';
CorrChar = LastChar; /* Save the corrected end */
LastChar = InputBuf; /* Null the current line */
SoundBeep();
printprompt(2, short2str(Change));
+ cleanup_until(Change);
Refresh();
- if (read(SHIN, (char *) &tch, 1) < 0)
+ if (xread(SHIN, &tch, 1) < 0) {
#ifdef convex
/*
* need to print error message in case file
* is migrated
*/
- if (errno && errno != EINTR)
+ if (errno)
stderror(ERR_SYSTEM, progname, strerror(errno));
#else
+ cleanup_until(Origin);
break;
#endif
+ }
ch = tch;
if (ch == 'y' || ch == ' ') {
LastChar = CorrChar; /* Restore the corrected end */
xprintf(CGETS(6, 2, "yes\n"));
}
else {
- copyn(InputBuf, Origin, INBUFSIZE);
+ Strcpy(InputBuf, Origin);
LastChar = SaveChar;
if (ch == 'e') {
xprintf(CGETS(6, 3, "edit\n"));
@@ -263,6 +273,7 @@ Inputl()
ClearLines();
ClearDisp();
Refresh();
+ cleanup_until(Origin);
break;
}
else if (ch == 'a') {
@@ -271,12 +282,14 @@ Inputl()
Cursor = LastChar;
printprompt(0, NULL);
Refresh();
+ cleanup_until(Origin);
break;
}
xprintf(CGETS(6, 5, "no\n"));
}
flush();
}
+ cleanup_until(Origin);
} else if (crct && crct->vec != NULL &&
!Strcmp(*(crct->vec), STRcomplete)) {
if (LastChar > InputBuf && LastChar[-1] == '\n') {
@@ -427,6 +440,14 @@ Inputl()
if (autol && autol->vec != NULL &&
(Strcmp(*(autol->vec), STRambiguous) != 0 ||
expnum == Cursor - InputBuf)) {
+ if (adrof(STRhighlight) && MarkIsSet) {
+ /* clear highlighting before showing completions */
+ MarkIsSet = 0;
+ ClearLines();
+ ClearDisp();
+ Refresh();
+ MarkIsSet = 1;
+ }
PastBottom();
fn = (retval == CC_COMPLETE_ALL) ? LIST_ALL : LIST;
(void) tenematch(InputBuf, Cursor-InputBuf, fn);
@@ -526,6 +547,11 @@ Inputl()
case CC_ERROR:
default: /* functions we don't know about */
+ if (adrof(STRhighlight)) {
+ ClearLines();
+ ClearDisp();
+ Refresh();
+ }
DoingArg = 0;
Argument = 1;
SoundBeep();
@@ -542,8 +568,7 @@ Inputl()
}
void
-PushMacro(str)
- Char *str;
+PushMacro(Char *str)
{
if (str != NULL && MacroLvl + 1 < MAXMACROLEVELS) {
MacroLvl++;
@@ -555,72 +580,60 @@ PushMacro(str)
}
}
-/*
- * Like eval, only using the current file descriptors
- */
-static Char **gv = NULL, **gav = NULL;
+struct eval1_state
+{
+ Char **evalvec, *evalp;
+};
static void
-doeval1(v)
- Char **v;
+eval1_cleanup(void *xstate)
{
- Char **oevalvec;
- Char *oevalp;
- int my_reenter;
- Char **savegv;
- jmp_buf_t osetexit;
+ struct eval1_state *state;
- oevalvec = evalvec;
- oevalp = evalp;
- savegv = gv;
- gav = v;
+ state = xstate;
+ evalvec = state->evalvec;
+ evalp = state->evalp;
+ doneinp = 0;
+}
+/*
+ * Like eval, only using the current file descriptors
+ */
+static void
+doeval1(Char **v)
+{
+ struct eval1_state state;
+ Char **gv;
+ int gflag;
- gflag = 0, tglob(gav);
+ gflag = tglob(v);
if (gflag) {
- gv = gav = globall(gav);
- gargv = 0;
- if (gav == 0)
+ gv = v = globall(v, gflag);
+ if (v == 0)
stderror(ERR_NOMATCH);
- gav = copyblk(gav);
+ v = copyblk(v);
}
else {
gv = NULL;
- gav = copyblk(gav);
- trim(gav);
- }
-
- getexit(osetexit);
-
- /* PWP: setjmp/longjmp bugfix for optimizing compilers */
-#ifdef cray
- my_reenter = 1; /* assume non-zero return val */
- if (setexit() == 0) {
- my_reenter = 0; /* Oh well, we were wrong */
-#else /* !cray */
- if ((my_reenter = setexit()) == 0) {
-#endif /* cray */
- evalvec = gav;
- evalp = 0;
- process(0);
+ v = copyblk(v);
+ trim(v);
}
-
- evalvec = oevalvec;
- evalp = oevalp;
- doneinp = 0;
-
if (gv)
- blkfree(gv);
-
- gv = savegv;
- resexit(osetexit);
- if (my_reenter)
- stderror(ERR_SILENT);
+ cleanup_push(gv, blk_cleanup);
+
+ state.evalvec = evalvec;
+ state.evalp = evalp;
+ evalvec = v;
+ evalp = 0;
+ cleanup_push(&state, eval1_cleanup);
+ process(0);
+ cleanup_until(&state);
+ if (gv)
+ cleanup_until(gv);
}
static void
-RunCommand(str)
- Char *str;
+RunCommand(Char *str)
{
Char *cmd[2];
@@ -633,7 +646,7 @@ RunCommand(str)
GettingInput = 0;
doeval1(cmd);
-
+
(void) Rawmode();
GettingInput = 1;
@@ -644,9 +657,7 @@ RunCommand(str)
}
static int
-GetNextCommand(cmdnum, ch)
- KEYCMD *cmdnum;
- Char *ch;
+GetNextCommand(KEYCMD *cmdnum, Char *ch)
{
KEYCMD cmd = 0;
int num;
@@ -688,7 +699,7 @@ GetNextCommand(cmdnum, ch)
XmapVal val;
CStr cstr;
cstr.buf = ch;
- cstr.len = Strlen(ch);
+ cstr.len = 1;
switch (GetXkey(&cstr, &val)) {
case XK_CMD:
cmd = val.cmd;
@@ -722,8 +733,7 @@ UngetNextChar(Char cp)
}
int
-GetNextChar(cp)
- Char *cp;
+GetNextChar(Char *cp)
{
int num_read;
int tried = 0;
@@ -763,16 +773,13 @@ GetNextChar(cp)
#endif /* SIG_WINDOW */
cbp = 0;
for (;;) {
- while ((num_read = read(SHIN, cbuf + cbp, 1)) == -1) {
- if (errno == EINTR)
- continue;
+ while ((num_read = xread(SHIN, cbuf + cbp, 1)) == -1) {
if (!tried && fixio(SHIN, errno) != -1)
tried = 1;
else {
# ifdef convex
/* need to print error message in case the file is migrated */
- if (errno != EINTR)
- stderror(ERR_SYSTEM, progname, strerror(errno));
+ stderror(ERR_SYSTEM, progname, strerror(errno));
# endif /* convex */
# ifdef WINNT_NATIVE
__nt_want_vcode = 0;
@@ -781,13 +788,17 @@ GetNextChar(cp)
return -1;
}
}
- cbp++;
- if (normal_mbtowc(cp, cbuf, cbp) == -1) {
- reset_mbtowc();
- if (cbp < MB_LEN_MAX)
- continue; /* Maybe a partial character */
- /* And drop the following bytes, if any */
- *cp = (unsigned char)*cbuf | INVALID_BYTE;
+ if (AsciiOnly) {
+ *cp = (unsigned char)*cbuf;
+ } else {
+ cbp++;
+ if (normal_mbtowc(cp, cbuf, cbp) == -1) {
+ reset_mbtowc();
+ if (cbp < MB_CUR_MAX)
+ continue; /* Maybe a partial character */
+ /* And drop the following bytes, if any */
+ *cp = (unsigned char)*cbuf | INVALID_BYTE;
+ }
}
break;
}
@@ -810,8 +821,7 @@ GetNextChar(cp)
* 1: Something was corrected
*/
static int
-SpellLine(cmdonly)
- int cmdonly;
+SpellLine(int cmdonly)
{
int endflag, matchval;
Char *argptr, *OldCursor, *OldLastChar;
@@ -893,7 +903,7 @@ SpellLine(cmdonly)
* 2: Several commands matched
*/
static int
-CompleteLine()
+CompleteLine(void)
{
int endflag, tmatch;
Char *argptr, *OldCursor, *OldLastChar;
diff --git a/contrib/tcsh/ed.refresh.c b/contrib/tcsh/ed.refresh.c
index 46e7622..afba75e 100644
--- a/contrib/tcsh/ed.refresh.c
+++ b/contrib/tcsh/ed.refresh.c
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/ed.refresh.c,v 3.39 2005/02/15 21:09:02 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/ed.refresh.c,v 3.46 2006/08/23 15:03:14 christos Exp $ */
/*
* ed.refresh.c: Lower level screen refreshing functions
*/
@@ -32,7 +32,7 @@
*/
#include "sh.h"
-RCSID("$Id: ed.refresh.c,v 3.39 2005/02/15 21:09:02 christos Exp $")
+RCSID("$tcsh: ed.refresh.c,v 3.46 2006/08/23 15:03:14 christos Exp $")
#include "ed.h"
/* #define DEBUG_UPDATE */
@@ -45,37 +45,35 @@ Char *litptr;
static int vcursor_h, vcursor_v;
static int rprompt_h, rprompt_v;
-static int MakeLiteral __P((Char *, int, Char));
-static int Draw __P((Char *, int));
-static void Vdraw __P((Char, int));
-static void RefreshPromptpart __P((Char *));
-static void update_line __P((Char *, Char *, int));
-static void str_insert __P((Char *, int, int, Char *, int));
-static void str_delete __P((Char *, int, int, int));
-static void str_cp __P((Char *, Char *, int));
+static int MakeLiteral (Char *, int, Char);
+static int Draw (Char *, int);
+static void Vdraw (Char, int);
+static void RefreshPromptpart (Char *);
+static void update_line (Char *, Char *, int);
+static void str_insert (Char *, int, int, Char *, int);
+static void str_delete (Char *, int, int, int);
+static void str_cp (Char *, Char *, int);
#ifndef WINNT_NATIVE
static
#else
extern
#endif
- void PutPlusOne __P((Char, int));
-static void cpy_pad_spaces __P((Char *, Char *, int));
+ void PutPlusOne (Char, int);
+static void cpy_pad_spaces (Char *, Char *, int);
#if defined(DEBUG_UPDATE) || defined(DEBUG_REFRESH) || defined(DEBUG_LITERAL)
-static void dprintf __P((char *, ...));
+static void dprintf (char *, ...);
#ifdef DEBUG_UPDATE
-static void dprintstr __P((char *, const Char *, const Char *));
+static void dprintstr (char *, const Char *, const Char *);
static void
-dprintstr(str, f, t)
-char *str;
-const Char *f, *t;
+dprintstr(char *str, const Char *f, const Char *t)
{
dprintf("%s:\"", str);
while (f < t) {
- if (*f & ~ASCII)
+ if (ASC(*f) & ~ASCII)
dprintf("[%x]", *f++);
else
- dprintf("%c", *f++ & ASCII);
+ dprintf("%c", CTL_ESC(ASCII & ASC(*f++)));
}
dprintf("\"\r\n");
}
@@ -87,12 +85,7 @@ const Char *f, *t;
* debugging cause you'll mangle up the file descriptors!
*/
static void
-#ifdef PROTOTYPES
dprintf(char *fmt, ...)
-#else
-dprintf(va_list)
- va_dcl
-#endif /* __STDC__ */
{
static int fd = -1;
char *dtty;
@@ -100,16 +93,10 @@ dprintf(va_list)
if ((dtty = getenv("DEBUGTTY"))) {
int o;
va_list va;
-#ifdef PROTOTYPES
va_start(va, fmt);
-#else
- char *fmt;
- va_start(va);
- fmt = va_arg(va, char *);
-#endif /* __STDC__ */
if (fd == -1)
- fd = open(dtty, O_RDWR);
+ fd = xopen(dtty, O_RDWR);
o = SHOUT;
flush();
SHOUT = fd;
@@ -123,10 +110,7 @@ dprintf(va_list)
static int litlen = 0, litalloc = 0;
-static int MakeLiteral(str, len, addlit)
- Char *str;
- int len;
- Char addlit;
+static int MakeLiteral(Char *str, int len, Char addlit)
{
int i, addlitlen = 0;
Char *addlitptr = 0;
@@ -152,10 +136,7 @@ static int MakeLiteral(str, len, addlit)
int add = 256;
while (len + addlitlen + 1 + (LIT_FACTOR - 1) > add)
add *= 2;
- if (litptr)
- newlitptr = (Char *)xrealloc(litptr, (litalloc + add) * sizeof(Char));
- else
- newlitptr = (Char *)xmalloc((litalloc + add) * sizeof(Char));
+ newlitptr = xrealloc(litptr, (litalloc + add) * sizeof(Char));
if (!newlitptr)
return '?';
litptr = newlitptr;
@@ -179,16 +160,13 @@ static int MakeLiteral(str, len, addlit)
}
static int
-Draw(cp, nocomb) /* draw char at cp, expand tabs, ctl chars */
- Char *cp;
- int nocomb;
+Draw(Char *cp, int nocomb) /* draw char at cp, expand tabs, ctl chars */
{
- int l, w, i, lv, lh;
- Char ch, attr;
- NLSChar c;
+ int w, i, lv, lh;
+ Char c, attr;
attr = *cp & ~CHAR;
- l = NLSFrom(cp, NLSZEROT, &c);
+ c = *cp & CHAR;
w = NLSClassify(c, nocomb);
switch (w) {
case NLSCLASS_NL:
@@ -215,11 +193,10 @@ Draw(cp, nocomb) /* draw char at cp, expand tabs, ctl chars */
}
break;
case NLSCLASS_ILLEGAL:
- ch = *cp & CHAR;
Vdraw('\\' | attr, 1);
- Vdraw((((ch >> 6) & 7) + '0') | attr, 1);
- Vdraw((((ch >> 3) & 7) + '0') | attr, 1);
- Vdraw(((ch & 7) + '0') | attr, 1);
+ Vdraw((((c >> 6) & 7) + '0') | attr, 1);
+ Vdraw((((c >> 3) & 7) + '0') | attr, 1);
+ Vdraw(((c & 7) + '0') | attr, 1);
break;
case NLSCLASS_ILLEGAL2:
case NLSCLASS_ILLEGAL3:
@@ -245,32 +222,23 @@ Draw(cp, nocomb) /* draw char at cp, expand tabs, ctl chars */
break;
}
if (lv < 0) {
- int l2 = l;
- for (; l2-- > 0; cp++) {
- ch = *cp & CHAR;
- Vdraw('\\' | attr, 1);
- Vdraw((((ch >> 6) & 7) + '0') | attr, 1);
- Vdraw((((ch >> 3) & 7) + '0') | attr, 1);
- Vdraw(((ch & 7) + '0') | attr, 1);
- }
- return l;
+ Vdraw('\\' | attr, 1);
+ Vdraw((((c >> 6) & 7) + '0') | attr, 1);
+ Vdraw((((c >> 3) & 7) + '0') | attr, 1);
+ Vdraw(((c & 7) + '0') | attr, 1);
+ break;
}
- Vdisplay[lv][lh] = MakeLiteral(cp, l, Vdisplay[lv][lh]);
+ Vdisplay[lv][lh] = MakeLiteral(cp, 1, Vdisplay[lv][lh]);
break;
default:
- if (l > 1)
- Vdraw(MakeLiteral(cp, l, 0), w);
- else
- Vdraw(*cp, w);
+ Vdraw(*cp, w);
break;
}
- return l;
+ return 1;
}
static void
-Vdraw(c, width) /* draw char c onto V lines */
- Char c;
- int width;
+Vdraw(Char c, int width) /* draw char c onto V lines */
{
#ifdef DEBUG_REFRESH
# ifdef SHORT_STRINGS
@@ -284,7 +252,7 @@ Vdraw(c, width) /* draw char c onto V lines */
that "span line breaks". */
while (vcursor_h + width > TermH)
Vdraw(' ', 1);
- Vdisplay[vcursor_v][vcursor_h] = (Char) c;
+ Vdisplay[vcursor_v][vcursor_h] = c;
if (width)
vcursor_h++; /* advance to next place */
while (--width > 0)
@@ -308,23 +276,22 @@ Vdraw(c, width) /* draw char c onto V lines */
* draws a prompt element, expanding literals (we know it's ASCIZ)
*/
static void
-RefreshPromptpart(buf)
- Char *buf;
+RefreshPromptpart(Char *buf)
{
Char *cp;
- NLSChar c;
- int l, w;
+ int w;
+ if (buf == NULL)
+ return;
for (cp = buf; *cp; ) {
if (*cp & LITERAL) {
Char *litstart = cp;
while (*cp & LITERAL)
cp++;
if (*cp) {
- l = NLSFrom(cp, NLSZEROT, &c);
- w = NLSWidth(c);
- Vdraw(MakeLiteral(litstart, cp + l - litstart, 0), w);
- cp += l;
+ w = NLSWidth(*cp & CHAR);
+ Vdraw(MakeLiteral(litstart, cp + 1 - litstart, 0), w);
+ cp++;
}
else {
/*
@@ -352,7 +319,7 @@ static
int OldvcV = 0;
void
-Refresh()
+Refresh(void)
{
int cur_line;
Char *cp;
@@ -361,7 +328,7 @@ Refresh()
Char oldgetting;
#ifdef DEBUG_REFRESH
- dprintf("PromptBuf = :%s:\r\n", short2str(PromptBuf));
+ dprintf("Prompt = :%s:\r\n", short2str(Prompt));
dprintf("InputBuf = :%s:\r\n", short2str(InputBuf));
#endif /* DEBUG_REFRESH */
oldgetting = GettingInput;
@@ -370,14 +337,14 @@ Refresh()
/* reset the Vdraw cursor, temporarily draw rprompt to calculate its size */
vcursor_h = 0;
vcursor_v = 0;
- RefreshPromptpart(RPromptBuf);
+ RefreshPromptpart(RPrompt);
rprompt_h = vcursor_h;
rprompt_v = vcursor_v;
/* reset the Vdraw cursor, draw prompt */
vcursor_h = 0;
vcursor_v = 0;
- RefreshPromptpart(PromptBuf);
+ RefreshPromptpart(Prompt);
cur_h = -1; /* set flag in case I'm not set */
/* draw the current input buffer */
@@ -404,7 +371,7 @@ Refresh()
*/
while (--rhdiff > 0) /* pad out with spaces */
Vdraw(' ', 1);
- RefreshPromptpart(RPromptBuf);
+ RefreshPromptpart(RPrompt);
}
else {
rprompt_h = 0; /* flag "not using rprompt" */
@@ -463,7 +430,7 @@ Refresh()
}
#ifdef notdef
-GotoBottom()
+GotoBottom(void)
{ /* used to go to last used screen line */
MoveToLine(OldvcV);
}
@@ -471,7 +438,7 @@ GotoBottom()
#endif
void
-PastBottom()
+PastBottom(void)
{ /* used to go to last used screen line */
MoveToLine(OldvcV);
(void) putraw('\r');
@@ -484,11 +451,7 @@ PastBottom()
/* insert num characters of s into d (in front of the character) at dat,
maximum length of d is dlen */
static void
-str_insert(d, dat, dlen, s, num)
- Char *d;
- int dat, dlen;
- Char *s;
- int num;
+str_insert(Char *d, int dat, int dlen, Char *s, int num)
{
Char *a, *b;
@@ -530,9 +493,7 @@ str_insert(d, dat, dlen, s, num)
/* delete num characters d at dat, maximum length of d is dlen */
static void
-str_delete(d, dat, dlen, num)
- Char *d;
- int dat, dlen, num;
+str_delete(Char *d, int dat, int dlen, int num)
{
Char *a, *b;
@@ -563,9 +524,7 @@ str_delete(d, dat, dlen, num)
}
static void
-str_cp(a, b, n)
- Char *a, *b;
- int n;
+str_cp(Char *a, Char *b, int n)
{
while (n-- && *b)
*a++ = *b++;
@@ -597,9 +556,7 @@ new: eddie> Oh, my little buggy says to me, as lurgid as
#define MIN_END_KEEP 4
static void /* could be changed to make it smarter */
-update_line(old, new, cur_line)
- Char *old, *new;
- int cur_line;
+update_line(Char *old, Char *new, int cur_line)
{
Char *o, *n, *p, c;
Char *ofd, *ols, *oe, *nfd, *nls, *ne;
@@ -617,29 +574,32 @@ update_line(old, new, cur_line)
/*
* Find the end of both old and new
*/
- while (*o)
- o++;
+ o = Strend(o);
+
/*
* Remove any trailing blanks off of the end, being careful not to
* back up past the beginning.
*/
+ if (!(adrof(STRhighlight) && MarkIsSet)) {
while (ofd < o) {
if (o[-1] != ' ')
break;
o--;
}
+ }
oe = o;
*oe = (Char) 0;
-
- while (*n)
- n++;
+
+ n = Strend(n);
/* remove blanks from end of new */
+ if (!(adrof(STRhighlight) && MarkIsSet)) {
while (nfd < n) {
if (n[-1] != ' ')
break;
n--;
}
+ }
ne = n;
*ne = (Char) 0;
@@ -1133,9 +1093,7 @@ update_line(old, new, cur_line)
static void
-cpy_pad_spaces(dst, src, width)
- Char *dst, *src;
- int width;
+cpy_pad_spaces(Char *dst, Char *src, int width)
{
int i;
@@ -1153,25 +1111,23 @@ cpy_pad_spaces(dst, src, width)
}
void
-RefCursor()
+RefCursor(void)
{ /* only move to new cursor pos */
Char *cp;
- NLSChar c;
- int l, w, h, th, v;
+ int w, h, th, v;
/* first we must find where the cursor is... */
h = 0;
v = 0;
th = TermH; /* optimize for speed */
- for (cp = PromptBuf; *cp; ) { /* do prompt */
+ for (cp = Prompt; cp != NULL && *cp; ) { /* do prompt */
if (*cp & LITERAL) {
cp++;
continue;
}
- l = NLSFrom(cp, NLSZEROT, &c);
- w = NLSClassify(c, cp == PromptBuf);
- cp += l;
+ w = NLSClassify(*cp & CHAR, cp == Prompt);
+ cp++;
switch(w) {
case NLSCLASS_NL:
h = 0;
@@ -1202,9 +1158,8 @@ RefCursor()
}
for (cp = InputBuf; cp < Cursor;) { /* do input buffer to Cursor */
- l = NLSFrom(cp, Cursor - cp, &c);
- w = NLSClassify(c, cp == InputBuf);
- cp += l;
+ w = NLSClassify(*cp & CHAR, cp == InputBuf);
+ cp++;
switch(w) {
case NLSCLASS_NL:
h = 0;
@@ -1237,14 +1192,17 @@ RefCursor()
/* now go there */
MoveToLine(v);
MoveToChar(h);
+ if (adrof(STRhighlight) && MarkIsSet) {
+ ClearLines();
+ ClearDisp();
+ Refresh();
+ }
flush();
}
#ifndef WINTT_NATIVE
static void
-PutPlusOne(c, width)
- Char c;
- int width;
+PutPlusOne(Char c, int width)
{
while (width > 1 && CursorH + width > TermH)
PutPlusOne(' ', 1);
@@ -1280,9 +1238,8 @@ void
RefPlusOne(int l)
{ /* we added just one char, handle it fast.
* assumes that screen cursor == real cursor */
- Char *cp;
+ Char *cp, c;
int w;
- NLSChar c;
if (Cursor != LastChar) {
Refresh(); /* too hard to handle */
@@ -1293,7 +1250,7 @@ RefPlusOne(int l)
return;
}
cp = Cursor - l;
- NLSFrom(cp, (size_t)l, &c);
+ c = *cp & CHAR;
w = NLSClassify(c, cp == InputBuf);
switch(w) {
case NLSCLASS_CTRL:
@@ -1316,10 +1273,14 @@ RefPlusOne(int l)
PutPlusOne((c & 7) + '0', 1);
break;
case 1:
+ if (adrof(STRhighlight) && MarkIsSet)
+ StartHighlight();
if (l > 1)
PutPlusOne(MakeLiteral(cp, l, 0), 1);
else
PutPlusOne(*cp, 1);
+ if (adrof(STRhighlight) && MarkIsSet)
+ StopHighlight();
break;
default:
Refresh(); /* too hard to handle */
@@ -1331,7 +1292,7 @@ RefPlusOne(int l)
/* clear the screen buffers so that new new prompt starts fresh. */
void
-ClearDisp()
+ClearDisp(void)
{
int i;
@@ -1344,7 +1305,7 @@ ClearDisp()
}
void
-ClearLines()
+ClearLines(void)
{ /* Make sure all lines are *really* blank */
int i;
diff --git a/contrib/tcsh/ed.screen.c b/contrib/tcsh/ed.screen.c
index 9dd7e71..c0ede76 100644
--- a/contrib/tcsh/ed.screen.c
+++ b/contrib/tcsh/ed.screen.c
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/ed.screen.c,v 3.63 2005/01/18 20:43:30 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/ed.screen.c,v 3.75 2006/08/24 20:56:31 christos Exp $ */
/*
* ed.screen.c: Editor/termcap-curses interface
*/
@@ -32,7 +32,7 @@
*/
#include "sh.h"
-RCSID("$Id: ed.screen.c,v 3.63 2005/01/18 20:43:30 christos Exp $")
+RCSID("$tcsh: ed.screen.c,v 3.75 2006/08/24 20:56:31 christos Exp $")
#include "ed.h"
#include "tc.h"
@@ -53,7 +53,7 @@ RCSID("$Id: ed.screen.c,v 3.63 2005/01/18 20:43:30 christos Exp $")
#define Str(a) tstr[a].str
#define Val(a) tval[a].val
-static struct {
+static const struct {
const char *b_name;
speed_t b_rate;
} baud_rate[] = {
@@ -124,45 +124,47 @@ static struct {
{ NULL, 0 }
};
-#define T_al 0
-#define T_bl 1
-#define T_cd 2
-#define T_ce 3
-#define T_ch 4
-#define T_cl 5
-#define T_dc 6
-#define T_dl 7
-#define T_dm 8
-#define T_ed 9
-#define T_ei 10
-#define T_fs 11
-#define T_ho 12
-#define T_ic 13
-#define T_im 14
-#define T_ip 15
-#define T_kd 16
-#define T_kl 17
-#define T_kr 18
-#define T_ku 19
-#define T_md 20
-#define T_me 21
-#define T_nd 22
-#define T_se 23
-#define T_so 24
-#define T_ts 25
-#define T_up 26
-#define T_us 27
-#define T_ue 28
-#define T_vb 29
-#define T_DC 30
-#define T_DO 31
-#define T_IC 32
-#define T_LE 33
-#define T_RI 34
-#define T_UP 35
-#define T_kh 36
-#define T_at7 37
-#define T_str 38
+#define T_at7 0
+#define T_al 1
+#define T_bl 2
+#define T_cd 3
+#define T_ce 4
+#define T_ch 5
+#define T_cl 6
+#define T_dc 7
+#define T_dl 8
+#define T_dm 9
+#define T_ed 10
+#define T_ei 11
+#define T_fs 12
+#define T_ho 13
+#define T_ic 14
+#define T_im 15
+#define T_ip 16
+#define T_kd 17
+#define T_kh 18
+#define T_kl 19
+#define T_kr 20
+#define T_ku 21
+#define T_md 22
+#define T_me 23
+#define T_mr 24
+#define T_nd 25
+#define T_se 26
+#define T_so 27
+#define T_ts 28
+#define T_up 29
+#define T_us 30
+#define T_ue 31
+#define T_vb 32
+#define T_DC 33
+#define T_DO 34
+#define T_IC 35
+#define T_LE 36
+#define T_RI 37
+#define T_UP 38
+#define T_str 39
+
static struct termcapstr {
const char *name;
const char *long_name;
@@ -184,16 +186,16 @@ static struct termcapval {
} tval[T_val + 1];
void
-terminit()
+terminit(void)
{
#ifdef NLS_CATALOGS
int i;
for (i = 0; i < T_str + 1; i++)
- xfree((ptr_t) tstr[i].long_name);
+ xfree((ptr_t)(intptr_t)tstr[i].long_name);
for (i = 0; i < T_val + 1; i++)
- xfree((ptr_t) tval[i].long_name);
+ xfree((ptr_t)(intptr_t)tval[i].long_name);
#endif
tstr[T_al].name = "al";
@@ -305,10 +307,13 @@ terminit()
tstr[T_UP].long_name = CSAVS(4, 36, "cursor up multiple");
tstr[T_kh].name = "kh";
- tstr[T_kh].long_name = CSAVS(4, 37, "send cursor home");
+ tstr[T_kh].long_name = CSAVS(4, 43, "send cursor home");
tstr[T_at7].name = "@7";
- tstr[T_at7].long_name = CSAVS(4, 38, "send cursor end");
+ tstr[T_at7].long_name = CSAVS(4, 44, "send cursor end");
+
+ tstr[T_mr].name = "mr";
+ tstr[T_mr].long_name = CSAVS(4, 45, "begin reverse video");
tstr[T_str].name = NULL;
tstr[T_str].long_name = NULL;
@@ -351,149 +356,93 @@ terminit()
static int me_all = 0; /* does two or more of the attributes use me */
-static void ReBufferDisplay __P((void));
-static void TCalloc __P((struct termcapstr *, char *));
+static void ReBufferDisplay (void);
+static void TCset (struct termcapstr *, const char *);
static void
-TCalloc(t, cap)
- struct termcapstr *t;
- char *cap;
+TCset(struct termcapstr *t, const char *cap)
{
- static char termcap_alloc[TC_BUFSIZE];
- char termbuf[TC_BUFSIZE];
- struct termcapstr *ts;
- static int tloc = 0;
- int tlen, clen;
-
if (cap == NULL || *cap == '\0') {
+ xfree(t->str);
t->str = NULL;
- return;
- }
- else
- clen = strlen(cap);
-
- if (t->str == NULL)
- tlen = 0;
- else
- tlen = strlen(t->str);
-
- /*
- * New string is shorter; no need to allocate space
- */
- if (clen <= tlen) {
- (void) strcpy(t->str, cap);
- return;
- }
-
- /*
- * New string is longer; see if we have enough space to append
- */
- if (tloc + 3 < TC_BUFSIZE) {
- (void) strcpy(t->str = &termcap_alloc[tloc], cap);
- tloc += clen + 1; /* one for \0 */
- return;
- }
-
- /*
- * Compact our buffer; no need to check compaction, cause we know it
- * fits...
- */
- tlen = 0;
- for (ts = tstr; ts->name != NULL; ts++)
- if (t != ts && ts->str != NULL && ts->str[0] != '\0') {
- char *ptr;
+ } else {
+ size_t size;
- for (ptr = ts->str; *ptr != '\0'; termbuf[tlen++] = *ptr++)
- continue;
- termbuf[tlen++] = '\0';
- }
- (void) memmove((ptr_t) termcap_alloc, (ptr_t) termbuf, (size_t) TC_BUFSIZE);
- tloc = tlen;
- if (tloc + 3 >= TC_BUFSIZE) {
- stderror(ERR_NAME | ERR_TCNOSTR);
- return;
+ size = strlen(cap) + 1;
+ t->str = xrealloc(t->str, size);
+ memcpy(t->str, cap, size);
}
- (void) strcpy(t->str = &termcap_alloc[tloc], cap);
- tloc += clen + 1; /* one for \0 */
- return;
}
/*ARGSUSED*/
void
-TellTC()
+TellTC(void)
{
struct termcapstr *t;
- char *s;
+ char *first, *s;
xprintf(CGETS(7, 1, "\n\tTcsh thinks your terminal has the\n"));
xprintf(CGETS(7, 2, "\tfollowing characteristics:\n\n"));
xprintf(CGETS(7, 3, "\tIt has %d columns and %d lines\n"),
Val(T_co), Val(T_li));
s = strsave(T_HasMeta ? CGETS(7, 5, "a") : CGETS(7, 6, "no"));
+ cleanup_push(s, xfree);
+ first = s;
xprintf(CGETS(7, 4, "\tIt has %s meta key\n"), s);
- xfree(s);
s = strsave(T_Tabs ? "" : CGETS(7, 8, " not"));
+ cleanup_push(s, xfree);
xprintf(CGETS(7, 7, "\tIt can%s use tabs\n"), s);
- xfree(s);
s = strsave((T_Margin&MARGIN_AUTO) ?
CGETS(7, 10, "has") : CGETS(7, 11, "does not have"));
+ cleanup_push(s, xfree);
xprintf(CGETS(7, 9, "\tIt %s automatic margins\n"), s);
- xfree(s);
if (T_Margin & MARGIN_AUTO) {
s = strsave((T_Margin & MARGIN_MAGIC) ?
CGETS(7, 10, "has") : CGETS(7, 11, "does not have"));
+ cleanup_push(s, xfree);
xprintf(CGETS(7, 12, "\tIt %s magic margins\n"), s);
- xfree(s);
}
for (t = tstr; t->name != NULL; t++) {
s = strsave(t->str && *t->str ? t->str : CGETS(7, 13, "(empty)"));
+ cleanup_push(s, xfree);
xprintf("\t%36s (%s) == %s\n", t->long_name, t->name, s);
- xfree(s);
+ cleanup_until(s);
}
xputchar('\n');
+ cleanup_until(first);
}
static void
-ReBufferDisplay()
+ReBufferDisplay(void)
{
int i;
Char **b;
- Char **bufp;
b = Display;
Display = NULL;
- if (b != NULL) {
- for (bufp = b; *bufp != NULL; bufp++)
- xfree((ptr_t) * bufp);
- xfree((ptr_t) b);
- }
+ blkfree(b);
b = Vdisplay;
Vdisplay = NULL;
- if (b != NULL) {
- for (bufp = b; *bufp != NULL; bufp++)
- xfree((ptr_t) * bufp);
- xfree((ptr_t) b);
- }
+ blkfree(b);
TermH = Val(T_co);
- TermV = (INBUFSIZE * 4) / TermH + 1;
- b = (Char **) xmalloc((size_t) (sizeof(*b) * (TermV + 1)));
+ TermV = (INBUFSIZE * 4) / TermH + 1;/*FIXBUF*/
+ b = xmalloc(sizeof(*b) * (TermV + 1));
for (i = 0; i < TermV; i++)
- b[i] = (Char *) xmalloc((size_t) (sizeof(*b[i]) * (TermH + 1)));
+ b[i] = xmalloc(sizeof(*b[i]) * (TermH + 1));
b[TermV] = NULL;
Display = b;
- b = (Char **) xmalloc((size_t) (sizeof(*b) * (TermV + 1)));
+ b = xmalloc(sizeof(*b) * (TermV + 1));
for (i = 0; i < TermV; i++)
- b[i] = (Char *) xmalloc((size_t) (sizeof(*b[i]) * (TermH + 1)));
+ b[i] = xmalloc(sizeof(*b[i]) * (TermH + 1));
b[TermV] = NULL;
Vdisplay = b;
}
void
-SetTC(what, how)
- char *what, *how;
+SetTC(char *what, char *how)
{
struct termcapstr *ts;
struct termcapval *tv;
@@ -506,7 +455,7 @@ SetTC(what, how)
if (strcmp(ts->name, what) == 0)
break;
if (ts->name != NULL) {
- TCalloc(ts, how);
+ TCset(ts, how);
/*
* Reset variables
*/
@@ -542,10 +491,10 @@ SetTC(what, how)
stderror(ERR_SETTCUS, tv->name);
return;
}
- T_Tabs = (Char) Val(T_pt);
- T_HasMeta = (Char) Val(T_km);
- T_Margin = (Char) Val(T_am) ? MARGIN_AUTO : 0;
- T_Margin |= (Char) Val(T_xn) ? MARGIN_MAGIC : 0;
+ T_Tabs = Val(T_pt);
+ T_HasMeta = Val(T_km);
+ T_Margin = Val(T_am) ? MARGIN_AUTO : 0;
+ T_Margin |= Val(T_xn) ? MARGIN_MAGIC : 0;
if (tv == &tval[T_am] || tv == &tval[T_xn])
ChangeSize(Val(T_li), Val(T_co));
return;
@@ -568,33 +517,27 @@ SetTC(what, how)
* Print the termcap string out with variable substitution
*/
void
-EchoTC(v)
- Char **v;
+EchoTC(Char **v)
{
- char *cap, *scap, cv[BUFSIZE];
+ char *cap, *scap, *cv;
int arg_need, arg_cols, arg_rows;
int verbose = 0, silent = 0;
char *area;
- static const char *fmts = "%s\n", *fmtd = "%d\n";
+ static const char fmts[] = "%s\n", fmtd[] = "%d\n";
struct termcapstr *t;
char buf[TC_BUFSIZE];
+ Char **globbed;
area = buf;
setname("echotc");
- tglob(v);
- if (gflag) {
- v = globall(v);
- if (v == 0)
- stderror(ERR_NAME | ERR_NOMATCH);
- }
- else
- v = gargv = saveblk(v);
- trim(v);
+ v = glob_all_or_error(v);
+ globbed = v;
+ cleanup_push(globbed, blk_cleanup);
if (!*v || *v[0] == '\0')
- return;
+ goto end;
if (v[0][0] == '-') {
switch (v[0][1]) {
case 'v':
@@ -610,31 +553,28 @@ EchoTC(v)
v++;
}
if (!*v || *v[0] == '\0')
- return;
- (void) strcpy(cv, short2str(*v));
+ goto end;
+ cv = strsave(short2str(*v));
+ cleanup_push(cv, xfree);
if (strcmp(cv, "tabs") == 0) {
xprintf(fmts, T_Tabs ? CGETS(7, 14, "yes") :
CGETS(7, 15, "no"));
- flush();
- return;
+ goto end_flush;
}
else if (strcmp(cv, "meta") == 0) {
xprintf(fmts, Val(T_km) ? CGETS(7, 14, "yes") :
CGETS(7, 15, "no"));
- flush();
- return;
+ goto end_flush;
}
else if (strcmp(cv, "xn") == 0) {
xprintf(fmts, T_Margin & MARGIN_MAGIC ? CGETS(7, 14, "yes") :
CGETS(7, 15, "no"));
- flush();
- return;
+ goto end_flush;
}
else if (strcmp(cv, "am") == 0) {
xprintf(fmts, T_Margin & MARGIN_AUTO ? CGETS(7, 14, "yes") :
CGETS(7, 15, "no"));
- flush();
- return;
+ goto end_flush;
}
else if (strcmp(cv, "baud") == 0) {
int i;
@@ -642,22 +582,19 @@ EchoTC(v)
for (i = 0; baud_rate[i].b_name != NULL; i++)
if (T_Speed == baud_rate[i].b_rate) {
xprintf(fmts, baud_rate[i].b_name);
- flush();
- return;
+ goto end_flush;
}
xprintf(fmtd, 0);
- flush();
- return;
+ goto end_flush;
}
- else if (strcmp(cv, "rows") == 0 || strcmp(cv, "lines") == 0) {
+ else if (strcmp(cv, "rows") == 0 || strcmp(cv, "lines") == 0 ||
+ strcmp(cv, "li") == 0) {
xprintf(fmtd, Val(T_li));
- flush();
- return;
+ goto end_flush;
}
- else if (strcmp(cv, "cols") == 0) {
+ else if (strcmp(cv, "cols") == 0 || strcmp(cv, "co") == 0) {
xprintf(fmtd, Val(T_co));
- flush();
- return;
+ goto end_flush;
}
/*
@@ -674,10 +611,10 @@ EchoTC(v)
if (!scap || scap[0] == '\0') {
if (tgetflag(cv)) {
xprintf(CGETS(7, 14, "yes\n"));
- return;
+ goto end;
}
if (silent)
- return;
+ goto end;
else
stderror(ERR_NAME | ERR_TCCAP, cv);
}
@@ -718,7 +655,7 @@ EchoTC(v)
v++;
if (*v && *v[0]) {
if (silent)
- return;
+ goto end;
else
stderror(ERR_NAME | ERR_TCARGS, cv, arg_need);
}
@@ -733,7 +670,7 @@ EchoTC(v)
v++;
if (*v && *v[0]) {
if (silent)
- return;
+ goto end;
else
stderror(ERR_NAME | ERR_TCARGS, cv, arg_need);
}
@@ -748,7 +685,7 @@ EchoTC(v)
v++;
if (!*v || *v[0] == '\0') {
if (silent)
- return;
+ goto end;
else
stderror(ERR_NAME | ERR_TCNARGS, cv, 2);
}
@@ -756,7 +693,7 @@ EchoTC(v)
v++;
if (!*v || *v[0] == '\0') {
if (silent)
- return;
+ goto end;
else
stderror(ERR_NAME | ERR_TCNARGS, cv, 2);
}
@@ -764,18 +701,17 @@ EchoTC(v)
v++;
if (*v && *v[0]) {
if (silent)
- return;
+ goto end;
else
stderror(ERR_NAME | ERR_TCARGS, cv, arg_need);
}
(void) tputs(tgoto(scap, arg_cols, arg_rows), arg_rows, PUTRAW);
break;
}
+ end_flush:
flush();
- if (gargv) {
- blkfree(gargv);
- gargv = 0;
- }
+ end:
+ cleanup_until(globbed);
}
int GotTermCaps = 0;
@@ -802,7 +738,7 @@ static struct {
#define A_K_NKEYS 6
void
-ResetArrowKeys()
+ResetArrowKeys(void)
{
arrow[A_K_DN].fun.cmd = F_DOWN_HIST;
arrow[A_K_DN].type = XK_CMD;
@@ -824,7 +760,7 @@ ResetArrowKeys()
}
void
-DefaultArrowKeys()
+DefaultArrowKeys(void)
{
static Char strA[] = {033, '[', 'A', '\0'};
static Char strB[] = {033, '[', 'B', '\0'};
@@ -892,10 +828,7 @@ DefaultArrowKeys()
int
-SetArrowKeys(name, fun, type)
- CStr *name;
- XmapVal *fun;
- int type;
+SetArrowKeys(const CStr *name, XmapVal *fun, int type)
{
int i;
for (i = 0; i < A_K_NKEYS; i++)
@@ -908,8 +841,7 @@ SetArrowKeys(name, fun, type)
}
int
-IsArrowKey(name)
- Char *name;
+IsArrowKey(Char *name)
{
int i;
for (i = 0; i < A_K_NKEYS; i++)
@@ -919,8 +851,7 @@ IsArrowKey(name)
}
int
-ClearArrowKeys(name)
- CStr *name;
+ClearArrowKeys(const CStr *name)
{
int i;
for (i = 0; i < A_K_NKEYS; i++)
@@ -932,24 +863,19 @@ ClearArrowKeys(name)
}
void
-PrintArrowKeys(name)
- CStr *name;
+PrintArrowKeys(const CStr *name)
{
int i;
for (i = 0; i < A_K_NKEYS; i++)
if (name->len == 0 || Strcmp(name->buf, arrow[i].name) == 0)
- if (arrow[i].type != XK_NOD) {
- CStr cs;
- cs.buf = arrow[i].name;
- cs.len = Strlen(cs.buf);
- (void) printOne(&cs, &arrow[i].fun, arrow[i].type);
- }
+ if (arrow[i].type != XK_NOD)
+ printOne(arrow[i].name, &arrow[i].fun, arrow[i].type);
}
void
-BindArrowKeys()
+BindArrowKeys(void)
{
KEYCMD *map, *dmap;
int i, j;
@@ -1000,8 +926,7 @@ BindArrowKeys()
static Char cur_atr = 0; /* current attributes */
void
-SetAttributes(atr)
- Char atr;
+SetAttributes(Char atr)
{
atr &= ATTRIBUTES;
if (atr != cur_atr) {
@@ -1066,16 +991,32 @@ SetAttributes(atr)
}
}
+int highlighting = 0;
+
+void
+StartHighlight()
+{
+ (void) tputs(Str(T_mr), 1, PUTPURE);
+ highlighting = 1;
+}
+
+void
+StopHighlight()
+{
+ (void) tputs(Str(T_me), 1, PUTPURE);
+ highlighting = 0;
+}
+
/* PWP 6-27-88 -- if the tty driver thinks that we can tab, we ask termcap */
int
-CanWeTab()
+CanWeTab(void)
{
return (Val(T_pt));
}
+/* move to line <where> (first line == 0) as efficiently as possible; */
void
-MoveToLine(where) /* move to line <where> (first line == 0) */
- int where; /* as efficiently as possible; */
+MoveToLine(int where)
{
int del;
@@ -1132,8 +1073,7 @@ MoveToLine(where) /* move to line <where> (first line == 0) */
}
void
-MoveToChar(where) /* move to character position (where) */
- int where;
+MoveToChar(int where) /* move to character position (where) */
{ /* as efficiently as possible */
int del;
@@ -1207,10 +1147,10 @@ mc_again:
}
void
-so_write(cp, n)
- Char *cp;
- int n;
+so_write(Char *cp, int n)
{
+ int cur_pos, prompt_len = 0, region_start = 0, region_end = 0;
+
if (n <= 0)
return; /* catch bugs */
@@ -1222,7 +1162,37 @@ so_write(cp, n)
return;
}
+ if (adrof(STRhighlight)) {
+ /* find length of prompt */
+ Char *promptc;
+ for (promptc = Prompt; *promptc; promptc++);
+ prompt_len = promptc - Prompt;
+
+ /* find region start and end points */
+ if (IncMatchLen) {
+ region_start = (Cursor - InputBuf) + prompt_len;
+ region_end = region_start + IncMatchLen;
+ } else if (MarkIsSet) {
+ region_start = (min(Cursor, Mark) - InputBuf) + prompt_len;
+ region_end = (max(Cursor, Mark) - InputBuf) + prompt_len;
+ }
+ }
+
do {
+ if (adrof(STRhighlight)) {
+ cur_pos = CursorV * TermH + CursorH;
+ if (!highlighting &&
+ cur_pos >= region_start && cur_pos < region_end)
+ StartHighlight();
+ else if (highlighting && cur_pos >= region_end)
+ StopHighlight();
+
+ /* don't highlight over the cursor. the highlighting's reverse
+ * video would cancel it out. :P */
+ if (highlighting && cur_pos == (Cursor - InputBuf) + prompt_len)
+ StopHighlight();
+ }
+
if (*cp != CHAR_DBWIDTH) {
if (*cp & LITERAL) {
Char *d;
@@ -1239,15 +1209,18 @@ so_write(cp, n)
CursorH++;
} while (--n);
+ if (adrof(STRhighlight) && highlighting)
+ StopHighlight();
+
if (CursorH >= TermH) { /* wrap? */
if (T_Margin & MARGIN_AUTO) { /* yes */
CursorH = 0;
CursorV++;
if (T_Margin & MARGIN_MAGIC) {
/* force the wrap to avoid the "magic" situation */
- Char c;
- if ((c = Display[CursorV][CursorH]) != '\0') {
- so_write(&c, 1);
+ Char xc;
+ if ((xc = Display[CursorV][CursorH]) != '\0') {
+ so_write(&xc, 1);
while(Display[CursorV][CursorH] == CHAR_DBWIDTH)
CursorH++;
}
@@ -1264,8 +1237,7 @@ so_write(cp, n)
void
-DeleteChars(num) /* deletes <num> characters */
- int num;
+DeleteChars(int num) /* deletes <num> characters */
{
if (num <= 0)
return;
@@ -1303,10 +1275,10 @@ DeleteChars(num) /* deletes <num> characters */
(void) tputs(Str(T_ed), 1, PUTPURE);
}
+/* Puts terminal in insert character mode, or inserts num characters in the
+ line */
void
-Insert_write(cp, num) /* Puts terminal in insert character mode, */
- Char *cp;
- int num; /* or inserts num characters in the line */
+Insert_write(Char *cp, int num)
{
if (num <= 0)
return;
@@ -1358,9 +1330,9 @@ Insert_write(cp, num) /* Puts terminal in insert character mode, */
}
+/* clear to end of line. There are num characters to clear */
void
-ClearEOL(num) /* clear to end of line. There are num */
- int num; /* characters to clear */
+ClearEOL(int num)
{
int i;
@@ -1377,7 +1349,7 @@ ClearEOL(num) /* clear to end of line. There are num */
}
void
-ClearScreen()
+ClearScreen(void)
{ /* clear the whole screen and home */
if (GoodStr(T_cl))
/* send the clear screen code */
@@ -1394,7 +1366,7 @@ ClearScreen()
}
void
-SoundBeep()
+SoundBeep(void)
{ /* produce a sound */
beep_cmd ();
if (adrof(STRnobeep))
@@ -1410,7 +1382,7 @@ SoundBeep()
}
void
-ClearToBottom()
+ClearToBottom(void)
{ /* clear to the bottom of the screen */
if (GoodStr(T_cd))
(void) tputs(Str(T_cd), Val(T_li), PUTPURE);
@@ -1419,7 +1391,7 @@ ClearToBottom()
}
void
-GetTermCaps()
+GetTermCaps(void)
{ /* read in the needed terminal capabilites */
int i;
const char *ptr;
@@ -1430,17 +1402,14 @@ GetTermCaps()
#ifdef SIG_WINDOW
-# ifdef BSDSIGS
- sigmask_t omask;
-# endif /* BSDSIGS */
+ sigset_t oset, set;
int lins, cols;
/* don't want to confuse things here */
-# ifdef BSDSIGS
- omask = sigblock(sigmask(SIG_WINDOW)) & ~sigmask(SIG_WINDOW);
-# else /* BSDSIGS */
- (void) sighold(SIG_WINDOW);
-# endif /* BSDSIGS */
+ sigemptyset(&set);
+ sigaddset(&set, SIG_WINDOW);
+ (void)sigprocmask(SIG_BLOCK, &set, &oset);
+ cleanup_push(&oset, sigprocmask_cleanup);
#endif /* SIG_WINDOW */
area = buf;
@@ -1480,7 +1449,7 @@ GetTermCaps()
Val(T_co) = 80; /* do a dumb terminal */
Val(T_pt) = Val(T_km) = Val(T_li) = 0;
for (t = tstr; t->name != NULL; t++)
- TCalloc(t, NULL);
+ TCset(t, NULL);
}
else {
/* Can we tab */
@@ -1492,7 +1461,7 @@ GetTermCaps()
Val(T_co) = tgetnum("co");
Val(T_li) = tgetnum("li");
for (t = tstr; t->name != NULL; t++)
- TCalloc(t, tgetstr(t->name, &area));
+ TCset(t, tgetstr(t->name, &area));
}
if (Val(T_co) < 2)
Val(T_co) = 80; /* just in case */
@@ -1502,10 +1471,10 @@ GetTermCaps()
T_Cols = (Char) Val(T_co);
T_Lines = (Char) Val(T_li);
if (T_Tabs)
- T_Tabs = (Char) Val(T_pt);
- T_HasMeta = (Char) Val(T_km);
- T_Margin = (Char) Val(T_am) ? MARGIN_AUTO : 0;
- T_Margin |= (Char) Val(T_xn) ? MARGIN_MAGIC : 0;
+ T_Tabs = Val(T_pt);
+ T_HasMeta = Val(T_km);
+ T_Margin = Val(T_am) ? MARGIN_AUTO : 0;
+ T_Margin |= Val(T_xn) ? MARGIN_MAGIC : 0;
T_CanCEOL = GoodStr(T_ce);
T_CanDel = GoodStr(T_dc) || GoodStr(T_DC);
T_CanIns = GoodStr(T_im) || GoodStr(T_ic) || GoodStr(T_IC);
@@ -1538,11 +1507,7 @@ GetTermCaps()
(void) GetSize(&lins, &cols); /* get the correct window size */
ChangeSize(lins, cols);
-# ifdef BSDSIGS
- (void) sigsetmask(omask); /* can change it again */
-# else /* BSDSIGS */
- (void) sigrelse(SIG_WINDOW);
-# endif /* BSDSIGS */
+ cleanup_until(&oset); /* can change it again */
#else /* SIG_WINDOW */
ChangeSize(Val(T_li), Val(T_co));
#endif /* SIG_WINDOW */
@@ -1557,8 +1522,7 @@ GetTermCaps()
* is not a tty, but it will work in most cases.
*/
int
-GetSize(lins, cols)
- int *lins, *cols;
+GetSize(int *lins, int *cols)
{
*cols = Val(T_co);
*lins = Val(T_li);
@@ -1596,11 +1560,10 @@ GetSize(lins, cols)
return (Val(T_co) != *cols || Val(T_li) != *lins);
}
-#endif /* SIGWINDOW */
+#endif /* SIG_WINDOW */
void
-ChangeSize(lins, cols)
- int lins, cols;
+ChangeSize(int lins, int cols)
{
/*
* Just in case
@@ -1620,26 +1583,31 @@ ChangeSize(lins, cols)
* our only chance to get the window size right.
*/
if (Val(T_co) == cols && Val(T_li) == lins) {
- Char buf[10];
+ Char *p;
char *tptr;
if (getenv("COLUMNS")) {
- (void) Itoa(Val(T_co), buf, 0, 0);
- tsetenv(STRCOLUMNS, buf);
+ p = Itoa(Val(T_co), 0, 0);
+ cleanup_push(p, xfree);
+ tsetenv(STRCOLUMNS, p);
+ cleanup_until(p);
}
if (getenv("LINES")) {
- (void) Itoa(Val(T_li), buf, 0, 0);
- tsetenv(STRLINES, buf);
+ p = Itoa(Val(T_li), 0, 0);
+ cleanup_push(p, xfree);
+ tsetenv(STRLINES, p);
+ cleanup_until(p);
}
if ((tptr = getenv("TERMCAP")) != NULL) {
/* Leave 64 characters slop in case we enlarge the termcap string */
- Char termcap[1024+64], backup[1024+64], *ptr;
+ Char termcap[TC_BUFSIZE+64], backup[TC_BUFSIZE+64], *ptr;
+ Char buf[4];
ptr = str2short(tptr);
- (void) Strncpy(termcap, ptr, 1024);
- termcap[1023] = '\0';
+ (void) Strncpy(termcap, ptr, TC_BUFSIZE);
+ termcap[TC_BUFSIZE-1] = '\0';
/* update termcap string; first do columns */
buf[0] = 'c';
@@ -1653,8 +1621,9 @@ ChangeSize(lins, cols)
size_t len = (ptr - termcap) + Strlen(buf);
(void) Strncpy(backup, termcap, len);
backup[len] = '\0';
- (void) Itoa(Val(T_co), buf, 0, 0);
- (void) Strcat(backup + len, buf);
+ p = Itoa(Val(T_co), 0, 0);
+ (void) Strcat(backup + len, p);
+ xfree(p);
ptr = Strchr(ptr, ':');
(void) Strcat(backup, ptr);
}
@@ -1671,16 +1640,17 @@ ChangeSize(lins, cols)
size_t len = (ptr - backup) + Strlen(buf);
(void) Strncpy(termcap, backup, len);
termcap[len] = '\0';
- (void) Itoa(Val(T_li), buf, 0, 0);
- (void) Strcat(termcap, buf);
+ p = Itoa(Val(T_li), 0, 0);
+ (void) Strcat(termcap, p);
+ xfree(p);
ptr = Strchr(ptr, ':');
(void) Strcat(termcap, ptr);
}
/*
- * Chop the termcap string at 1024 characters to avoid core-dumps
- * in the termcap routines
+ * Chop the termcap string at TC_BUFSIZE-1 characters to avoid
+ * core-dumps in the termcap routines
*/
- termcap[1023] = '\0';
+ termcap[TC_BUFSIZE - 1] = '\0';
tsetenv(STRTERMCAP, termcap);
}
}
diff --git a/contrib/tcsh/ed.term.c b/contrib/tcsh/ed.term.c
index ae1169b..a235e11 100644
--- a/contrib/tcsh/ed.term.c
+++ b/contrib/tcsh/ed.term.c
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/ed.term.c,v 1.31 2004/11/23 02:10:48 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/ed.term.c,v 1.36 2006/03/02 18:46:44 christos Exp $ */
/*
* ed.term.c: Low level terminal interface
*/
@@ -33,7 +33,7 @@
#include "sh.h"
#ifndef WINNT_NATIVE
-RCSID("$Id: ed.term.c,v 1.31 2004/11/23 02:10:48 christos Exp $")
+RCSID("$tcsh: ed.term.c,v 1.36 2006/03/02 18:46:44 christos Exp $")
#include "ed.h"
@@ -84,7 +84,7 @@ ttyperm_t ttylist = {
}
};
-static struct tcshmodes {
+static const struct tcshmodes {
const char *m_name;
#ifdef SOLARIS2
unsigned long m_value;
@@ -568,33 +568,35 @@ static struct tcshmodes {
#endif
/* Retry a system call */
-static int count;
-#define RETRY(x) \
- for (count = 0;; count++) \
- if ((x) == -1) { \
- if (OKERROR(errno) || KLUDGE) \
- continue; \
- else \
- return -1; \
- } \
- else \
- break \
+#define RETRY(x) \
+do { \
+ int count; \
+ \
+ for (count = 0;; count++) \
+ if ((x) == -1) { \
+ if (OKERROR(errno) || KLUDGE) \
+ continue; \
+ else \
+ return -1; \
+ } \
+ else \
+ break; \
+} while (0)
/*ARGSUSED*/
void
-dosetty(v, t)
- Char **v;
- struct command *t;
+dosetty(Char **v, struct command *t)
{
- struct tcshmodes *m;
- char x, *d;
+ const struct tcshmodes *m;
+ char x, *d, *cmdname;
int aflag = 0;
Char *s;
int z = EX_IO;
- char cmdname[BUFSIZE];
USE(t);
- setname(strcpy(cmdname, short2str(*v++)));
+ cmdname = strsave(short2str(*v++));
+ cleanup_push(cmdname, xfree);
+ setname(cmdname);
while (v && *v && v[0][0] == '-' && v[0][2] == '\0')
switch (v[0][1]) {
@@ -615,7 +617,7 @@ dosetty(v, t)
z = QU_IO;
break;
default:
- stderror(ERR_NAME | ERR_SYSTEM, short2str(v[0]),
+ stderror(ERR_NAME | ERR_SYSTEM, short2str(v[0]),
CGETS(8, 1, "Unknown switch"));
break;
}
@@ -626,7 +628,7 @@ dosetty(v, t)
int len = 0, st = 0, cu;
for (m = modelist; m->m_name; m++) {
if (m->m_type != i) {
- xprintf("%s%s", i != -1 ? "\n" : "",
+ xprintf("%s%s", i != -1 ? "\n" : "",
ttylist[z][m->m_type].t_name);
i = m->m_type;
st = len = strlen(ttylist[z][m->m_type].t_name);
@@ -637,7 +639,7 @@ dosetty(v, t)
if (x != '\0' || aflag) {
cu = strlen(m->m_name) + (x != '\0') + 1;
- if (len + cu >= T_Cols) {
+ if (len + cu >= TermH) {
xprintf("\n%*s", st, "");
len = st + cu;
}
@@ -650,6 +652,7 @@ dosetty(v, t)
}
}
xputchar('\n');
+ cleanup_until(cmdname);
return;
}
while (v && (s = *v++)) {
@@ -684,12 +687,11 @@ dosetty(v, t)
break;
}
}
+ cleanup_until(cmdname);
} /* end dosetty */
int
-tty_getty(fd, td)
- int fd;
- ttydata_t *td;
+tty_getty(int fd, ttydata_t *td)
{
#ifdef POSIX
RETRY(tcgetattr(fd, &td->d_t));
@@ -720,12 +722,10 @@ tty_getty(fd, td)
}
int
-tty_setty(fd, td)
- int fd;
- ttydata_t *td;
+tty_setty(int fd, ttydata_t *td)
{
#ifdef POSIX
- RETRY(tcsetattr(fd, TCSADRAIN, &td->d_t));
+ RETRY(xtcsetattr(fd, TCSADRAIN, &td->d_t));
#else
# ifdef TERMIO
RETRY(ioctl(fd, TCSETAW, (ioctl_t) &td->d_t));
@@ -753,9 +753,7 @@ tty_setty(fd, td)
}
void
-tty_getchar(td, s)
- ttydata_t *td;
- unsigned char *s;
+tty_getchar(ttydata_t *td, unsigned char *s)
{
#ifdef TIOCGLTC
{
@@ -891,9 +889,7 @@ tty_getchar(td, s)
void
-tty_setchar(td, s)
- ttydata_t *td;
- unsigned char *s;
+tty_setchar(ttydata_t *td, unsigned char *s)
{
#ifdef TIOCGLTC
{
@@ -1030,8 +1026,7 @@ tty_setchar(td, s)
} /* tty_setchar */
speed_t
-tty_getspeed(td)
- ttydata_t *td;
+tty_getspeed(ttydata_t *td)
{
speed_t spd;
@@ -1054,8 +1049,7 @@ tty_getspeed(td)
} /* end tty_getspeed */
int
-tty_gettabs(td)
- ttydata_t *td;
+tty_gettabs(ttydata_t *td)
{
#if defined(POSIX) || defined(TERMIO)
return ((td->d_t.c_oflag & TAB3) == TAB3) ? 0 : 1;
@@ -1065,8 +1059,7 @@ tty_gettabs(td)
} /* end tty_gettabs */
int
-tty_geteightbit(td)
- ttydata_t *td;
+tty_geteightbit(ttydata_t *td)
{
#if defined(POSIX) || defined(TERMIO)
return (td->d_t.c_cflag & CSIZE) == CS8;
@@ -1076,8 +1069,7 @@ tty_geteightbit(td)
} /* end tty_geteightbit */
int
-tty_cooked_mode(td)
- ttydata_t *td;
+tty_cooked_mode(ttydata_t *td)
{
#if defined(POSIX) || defined(TERMIO)
return (td->d_t.c_lflag & ICANON);
@@ -1088,9 +1080,7 @@ tty_cooked_mode(td)
#ifdef _IBMR2
void
-tty_setdisc(fd, dis)
- int fd;
- int dis;
+tty_setdisc(int fd, int dis)
{
static int edit_discipline = 0;
static union txname tx_disc;
@@ -1124,8 +1114,7 @@ tty_setdisc(fd, dis)
#ifdef DEBUG_TTY
static void
-tty_printchar(s)
- unsigned char *s;
+tty_printchar(unsigned char *s)
{
struct tcshmodes *m;
int i;
@@ -1144,8 +1133,7 @@ tty_printchar(s)
#endif /* DEBUG_TTY */
#else /* WINNT_NATIVE */
int
-tty_cooked_mode(td)
- void *td;
+tty_cooked_mode(void *td)
{
return do_nt_check_cooked_mode();
}
diff --git a/contrib/tcsh/ed.term.h b/contrib/tcsh/ed.term.h
index 564b10b..c610130 100644
--- a/contrib/tcsh/ed.term.h
+++ b/contrib/tcsh/ed.term.h
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/ed.term.h,v 1.17 2004/12/25 21:15:06 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/ed.term.h,v 1.17 2004/12/25 21:15:06 christos Exp $ */
/*
* ed.term.h: Local terminal header
*/
diff --git a/contrib/tcsh/ed.xmap.c b/contrib/tcsh/ed.xmap.c
index 5d01ed6..866bc83 100644
--- a/contrib/tcsh/ed.xmap.c
+++ b/contrib/tcsh/ed.xmap.c
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/ed.xmap.c,v 3.28 2005/01/05 18:06:43 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/ed.xmap.c,v 3.36 2006/11/29 22:30:09 christos Exp $ */
/*
* ed.xmap.c: This module contains the procedures for maintaining
* the extended-key map.
@@ -88,7 +88,7 @@
*/
#include "sh.h"
-RCSID("$Id: ed.xmap.c,v 3.28 2005/01/05 18:06:43 christos Exp $")
+RCSID("$tcsh: ed.xmap.c,v 3.36 2006/11/29 22:30:09 christos Exp $")
#include "ed.h"
#include "ed.defns.h"
@@ -112,24 +112,22 @@ typedef struct Xmapnode {
} XmapNode;
static XmapNode *Xmap = NULL; /* the current Xmap */
-#define MAXXKEY 100 /* max length of a Xkey for print putposes */
-static Char printbuf[MAXXKEY]; /* buffer for printing */
/* Some declarations of procedures */
-static int TraverseMap __P((XmapNode *, CStr *, XmapVal *));
-static int TryNode __P((XmapNode *, CStr *, XmapVal *, int));
-static XmapNode *GetFreeNode __P((CStr *));
-static void PutFreeNode __P((XmapNode *));
-static int TryDeleteNode __P((XmapNode **, CStr *));
-static int Lookup __P((CStr *, XmapNode *, int));
-static int Enumerate __P((XmapNode *, int));
-static int unparsech __P((int, Char *));
+static int TraverseMap (XmapNode *, CStr *, XmapVal *);
+static int TryNode (XmapNode *, CStr *, XmapVal *, int);
+static XmapNode *GetFreeNode (CStr *);
+static void PutFreeNode (XmapNode *);
+static int TryDeleteNode (XmapNode **, CStr *);
+static int Lookup (struct Strbuf *, const CStr *,
+ const XmapNode *);
+static void Enumerate (struct Strbuf *, const XmapNode *);
+static void unparsech (struct Strbuf *, Char);
XmapVal *
-XmapCmd(cmd)
- int cmd;
+XmapCmd(int cmd)
{
static XmapVal xm;
xm.cmd = (KEYCMD) cmd;
@@ -137,8 +135,7 @@ XmapCmd(cmd)
}
XmapVal *
-XmapStr(str)
- CStr *str;
+XmapStr(CStr *str)
{
static XmapVal xm;
xm.str.len = str->len;
@@ -151,7 +148,7 @@ XmapStr(str)
* initializes Xmap with arrow keys
*/
void
-ResetXmap()
+ResetXmap(void)
{
PutFreeNode(Xmap);
Xmap = NULL;
@@ -165,9 +162,7 @@ ResetXmap()
* Calls the recursive function with entry point Xmap
*/
int
-GetXkey(ch, val)
- CStr *ch;
- XmapVal *val;
+GetXkey(CStr *ch, XmapVal *val)
{
return (TraverseMap(Xmap, ch, val));
}
@@ -177,10 +172,7 @@ GetXkey(ch, val)
* found. May read in more characters.
*/
static int
-TraverseMap(ptr, ch, val)
- XmapNode *ptr;
- CStr *ch;
- XmapVal *val;
+TraverseMap(XmapNode *ptr, CStr *ch, XmapVal *val)
{
Char tch;
@@ -218,10 +210,7 @@ TraverseMap(ptr, ch, val)
}
void
-AddXkey(Xkey, val, ntype)
- CStr *Xkey;
- XmapVal *val;
- int ntype;
+AddXkey(const CStr *Xkey, XmapVal *val, int ntype)
{
CStr cs;
cs.buf = Xkey->buf;
@@ -246,11 +235,7 @@ AddXkey(Xkey, val, ntype)
}
static int
-TryNode(ptr, str, val, ntype)
- XmapNode *ptr;
- CStr *str;
- XmapVal *val;
- int ntype;
+TryNode(XmapNode *ptr, CStr *str, XmapVal *val, int ntype)
{
/*
* Find a node that matches *string or allocate a new one
@@ -269,6 +254,8 @@ TryNode(ptr, str, val, ntype)
str->buf++;
str->len--;
if (str->len == 0) {
+ size_t len;
+
/* we're there */
if (ptr->next != NULL) {
PutFreeNode(ptr->next); /* lose longer Xkeys with this prefix */
@@ -278,8 +265,7 @@ TryNode(ptr, str, val, ntype)
switch (ptr->type) {
case XK_STR:
case XK_EXE:
- if (ptr->val.str.buf != NULL)
- xfree((ptr_t) ptr->val.str.buf);
+ xfree(ptr->val.str.buf);
ptr->val.str.len = 0;
break;
case XK_NOD:
@@ -296,11 +282,10 @@ TryNode(ptr, str, val, ntype)
break;
case XK_STR:
case XK_EXE:
- ptr->val.str.len = (val->str.len + 1) * sizeof(Char);
- ptr->val.str.buf = (Char *) xmalloc((size_t) ptr->val.str.len);
- (void) memmove((ptr_t) ptr->val.str.buf, (ptr_t) val->str.buf,
- (size_t) ptr->val.str.len);
ptr->val.str.len = val->str.len;
+ len = (val->str.len + 1) * sizeof(*ptr->val.str.buf);
+ ptr->val.str.buf = xmalloc(len);
+ (void) memcpy(ptr->val.str.buf, val->str.buf, len);
break;
default:
abort();
@@ -317,9 +302,7 @@ TryNode(ptr, str, val, ntype)
}
void
-ClearXkey(map, in)
- KEYCMD *map;
- CStr *in;
+ClearXkey(KEYCMD *map, const CStr *in)
{
unsigned char c = (unsigned char) *(in->buf);
if ((map[c] == F_XKEY) &&
@@ -329,10 +312,12 @@ ClearXkey(map, in)
}
int
-DeleteXkey(Xkey)
- CStr *Xkey;
+DeleteXkey(const CStr *Xkey)
{
- if (Xkey->len == 0) {
+ CStr s;
+
+ s = *Xkey;
+ if (s.len == 0) {
xprintf(CGETS(9, 3, "DeleteXkey: Null extended-key not allowed.\n"));
return (-1);
}
@@ -340,17 +325,15 @@ DeleteXkey(Xkey)
if (Xmap == NULL)
return (0);
- (void) TryDeleteNode(&Xmap, Xkey);
+ (void) TryDeleteNode(&Xmap, &s);
return (0);
}
+/* Destroys str */
static int
-TryDeleteNode(inptr, str)
- XmapNode **inptr;
- CStr *str;
+TryDeleteNode(XmapNode **inptr, CStr *str)
{
XmapNode *ptr;
- XmapNode *prev_ptr = NULL;
ptr = *inptr;
/*
@@ -364,7 +347,7 @@ TryDeleteNode(inptr, str)
break;
if (xm->sibling == NULL)
return (0);
- prev_ptr = xm;
+ inptr = &xm->sibling;
ptr = xm->sibling;
}
@@ -373,10 +356,7 @@ TryDeleteNode(inptr, str)
if (str->len == 0) {
/* we're there */
- if (prev_ptr == NULL)
- *inptr = ptr->sibling;
- else
- prev_ptr->sibling = ptr->sibling;
+ *inptr = ptr->sibling;
ptr->sibling = NULL;
PutFreeNode(ptr);
return (1);
@@ -384,10 +364,7 @@ TryDeleteNode(inptr, str)
else if (ptr->next != NULL && TryDeleteNode(&ptr->next, str) == 1) {
if (ptr->next != NULL)
return (0);
- if (prev_ptr == NULL)
- *inptr = ptr->sibling;
- else
- prev_ptr->sibling = ptr->sibling;
+ *inptr = ptr->sibling;
ptr->sibling = NULL;
PutFreeNode(ptr);
return (1);
@@ -401,8 +378,7 @@ TryDeleteNode(inptr, str)
* Puts a tree of nodes onto free list using free(3).
*/
static void
-PutFreeNode(ptr)
- XmapNode *ptr;
+PutFreeNode(XmapNode *ptr)
{
if (ptr == NULL)
return;
@@ -420,14 +396,13 @@ PutFreeNode(ptr)
break;
case XK_EXE:
case XK_STR:
- if (ptr->val.str.buf != NULL)
- xfree((ptr_t) ptr->val.str.buf);
+ xfree(ptr->val.str.buf);
break;
default:
abort();
break;
}
- xfree((ptr_t) ptr);
+ xfree(ptr);
}
@@ -435,12 +410,11 @@ PutFreeNode(ptr)
* Returns pointer to an XmapNode for ch.
*/
static XmapNode *
-GetFreeNode(ch)
- CStr *ch;
+GetFreeNode(CStr *ch)
{
XmapNode *ptr;
- ptr = (XmapNode *) xmalloc((size_t) sizeof(XmapNode));
+ ptr = xmalloc(sizeof(XmapNode));
ptr->ch = ch->buf[0];
ptr->type = XK_NOD;
ptr->val.str.buf = NULL;
@@ -456,9 +430,9 @@ GetFreeNode(ch)
* Print entire Xmap if null
*/
void
-PrintXkey(key)
- CStr *key;
+PrintXkey(const CStr *key)
{
+ struct Strbuf buf = Strbuf_INIT;
CStr cs;
if (key) {
@@ -473,11 +447,12 @@ PrintXkey(key)
if (Xmap == NULL && cs.len == 0)
return;
- printbuf[0] = '"';
- if (Lookup(&cs, Xmap, 1) <= -1)
+ Strbuf_append1(&buf, '"');
+ cleanup_push(&buf, Strbuf_cleanup);
+ if (Lookup(&buf, &cs, Xmap) <= -1)
/* key is not bound */
xprintf(CGETS(9, 4, "Unbound extended key \"%S\"\n"), cs.buf);
- return;
+ cleanup_until(&buf);
}
/* Lookup():
@@ -485,42 +460,34 @@ PrintXkey(key)
* Print if last node
*/
static int
-Lookup(str, ptr, cnt)
- CStr *str;
- XmapNode *ptr;
- int cnt;
+Lookup(struct Strbuf *buf, const CStr *str, const XmapNode *ptr)
{
- int ncnt;
-
if (ptr == NULL)
return (-1); /* cannot have null ptr */
if (str->len == 0) {
/* no more chars in string. Enumerate from here. */
- (void) Enumerate(ptr, cnt);
+ Enumerate(buf, ptr);
return (0);
}
else {
- /* If match put this char into printbuf. Recurse */
+ /* If match put this char into buf. Recurse */
if (ptr->ch == *(str->buf)) {
/* match found */
- ncnt = unparsech(cnt, &ptr->ch);
+ unparsech(buf, ptr->ch);
if (ptr->next != NULL) {
/* not yet at leaf */
CStr tstr;
tstr.buf = str->buf + 1;
tstr.len = str->len - 1;
- return (Lookup(&tstr, ptr->next, ncnt + 1));
+ return (Lookup(buf, &tstr, ptr->next));
}
else {
/* next node is null so key should be complete */
if (str->len == 1) {
- CStr pb;
- printbuf[ncnt + 1] = '"';
- printbuf[ncnt + 2] = '\0';
- pb.buf = printbuf;
- pb.len = ncnt + 2;
- (void) printOne(&pb, &ptr->val, ptr->type);
+ Strbuf_append1(buf, '"');
+ Strbuf_terminate(buf);
+ printOne(buf->s, &ptr->val, ptr->type);
return (0);
}
else
@@ -530,53 +497,41 @@ Lookup(str, ptr, cnt)
else {
/* no match found try sibling */
if (ptr->sibling)
- return (Lookup(str, ptr->sibling, cnt));
+ return (Lookup(buf, str, ptr->sibling));
else
return (-1);
}
}
}
-static int
-Enumerate(ptr, cnt)
- XmapNode *ptr;
- int cnt;
+static void
+Enumerate(struct Strbuf *buf, const XmapNode *ptr)
{
- int ncnt;
-
- if (cnt >= MAXXKEY - 5) { /* buffer too small */
- printbuf[++cnt] = '"';
- printbuf[++cnt] = '\0';
- xprintf(CGETS(9, 5,
- "Some extended keys too long for internal print buffer"));
- xprintf(" \"%S...\"\n", printbuf);
- return (0);
- }
+ size_t old_len;
if (ptr == NULL) {
#ifdef DEBUG_EDIT
xprintf(CGETS(9, 6, "Enumerate: BUG!! Null ptr passed\n!"));
#endif
- return (-1);
+ return;
}
- ncnt = unparsech(cnt, &ptr->ch); /* put this char at end of string */
+ old_len = buf->len;
+ unparsech(buf, ptr->ch); /* put this char at end of string */
if (ptr->next == NULL) {
- CStr pb;
/* print this Xkey and function */
- printbuf[++ncnt] = '"';
- printbuf[++ncnt] = '\0';
- pb.buf = printbuf;
- pb.len = ncnt;
- (void) printOne(&pb, &ptr->val, ptr->type);
+ Strbuf_append1(buf, '"');
+ Strbuf_terminate(buf);
+ printOne(buf->s, &ptr->val, ptr->type);
}
else
- (void) Enumerate(ptr->next, ncnt + 1);
+ Enumerate(buf, ptr->next);
/* go to sibling if there is one */
- if (ptr->sibling)
- (void) Enumerate(ptr->sibling, cnt);
- return (0);
+ if (ptr->sibling) {
+ buf->len = old_len;
+ Enumerate(buf, ptr->sibling);
+ }
}
@@ -584,24 +539,25 @@ Enumerate(ptr, cnt)
* Print the specified key and its associated
* function specified by val
*/
-int
-printOne(key, val, ntype)
- CStr *key;
- XmapVal *val;
- int ntype;
+void
+printOne(const Char *key, const XmapVal *val, int ntype)
{
struct KeyFuncs *fp;
- unsigned char unparsbuf[200];
static const char *fmt = "%s\n";
- xprintf("%-15S-> ", key->buf);
+ xprintf("%-15S-> ", key);
if (val != NULL)
switch (ntype) {
case XK_STR:
- case XK_EXE:
- xprintf(fmt, unparsestring(&val->str, unparsbuf,
- ntype == XK_STR ? STRQQ : STRBB));
+ case XK_EXE: {
+ unsigned char *p;
+
+ p = unparsestring(&val->str, ntype == XK_STR ? STRQQ : STRBB);
+ cleanup_push(p, xfree);
+ xprintf(fmt, p);
+ cleanup_until(p);
break;
+ }
case XK_CMD:
for (fp = FuncNames; fp->name; fp++)
if (val->cmd == fp->func)
@@ -612,72 +568,46 @@ printOne(key, val, ntype)
break;
}
else
- xprintf(fmt, key, CGETS(9, 7, "no input"));
- return (0);
+ xprintf(fmt, CGETS(9, 7, "no input"));
}
-static int
-unparsech(cnt, ch)
- int cnt;
- Char *ch;
+static void
+unparsech(struct Strbuf *buf, Char ch)
{
if (ch == 0) {
- printbuf[cnt++] = '^';
- printbuf[cnt] = '@';
- return cnt;
+ Strbuf_append1(buf, '^');
+ Strbuf_append1(buf, '@');
}
-
- if (Iscntrl(*ch)) {
-#ifdef IS_ASCII
- printbuf[cnt++] = '^';
- if (*ch == CTL_ESC('\177'))
- printbuf[cnt] = '?';
+ else if (Iscntrl(ch)) {
+ Strbuf_append1(buf, '^');
+ if (ch == CTL_ESC('\177'))
+ Strbuf_append1(buf, '?');
else
- printbuf[cnt] = *ch | 0100;
+#ifdef IS_ASCII
+ Strbuf_append1(buf, ch | 0100);
#else
- if (*ch == CTL_ESC('\177'))
- {
- printbuf[cnt++] = '^';
- printbuf[cnt] = '?';
- }
- else if (Isupper(_toebcdic[_toascii[*ch]|0100])
- || strchr("@[\\]^_", _toebcdic[_toascii[*ch]|0100]) != NULL)
- {
- printbuf[cnt++] = '^';
- printbuf[cnt] = _toebcdic[_toascii[*ch]|0100];
- }
- else
- {
- printbuf[cnt++] = '\\';
- printbuf[cnt++] = ((*ch >> 6) & 7) + '0';
- printbuf[cnt++] = ((*ch >> 3) & 7) + '0';
- printbuf[cnt] = (*ch & 7) + '0';
- }
+ Strbuf_append1(buf, _toebcdic[_toascii[ch]|0100]);
#endif
}
- else if (*ch == '^') {
- printbuf[cnt++] = '\\';
- printbuf[cnt] = '^';
- }
- else if (*ch == '\\') {
- printbuf[cnt++] = '\\';
- printbuf[cnt] = '\\';
- }
- else if (*ch == ' ' || (Isprint(*ch) && !Isspace(*ch))) {
- printbuf[cnt] = *ch;
+ else if (ch == '^') {
+ Strbuf_append1(buf, '\\');
+ Strbuf_append1(buf, '^');
+ } else if (ch == '\\') {
+ Strbuf_append1(buf, '\\');
+ Strbuf_append1(buf, '\\');
+ } else if (ch == ' ' || (Isprint(ch) && !Isspace(ch))) {
+ Strbuf_append1(buf, ch);
}
else {
- printbuf[cnt++] = '\\';
- printbuf[cnt++] = ((*ch >> 6) & 7) + '0';
- printbuf[cnt++] = ((*ch >> 3) & 7) + '0';
- printbuf[cnt] = (*ch & 7) + '0';
+ Strbuf_append1(buf, '\\');
+ Strbuf_append1(buf, ((ch >> 6) & 7) + '0');
+ Strbuf_append1(buf, ((ch >> 3) & 7) + '0');
+ Strbuf_append1(buf, (ch & 7) + '0');
}
- return cnt;
}
eChar
-parseescape(ptr)
- const Char **ptr;
+parseescape(const Char **ptr)
{
const Char *p;
Char c;
@@ -685,7 +615,7 @@ parseescape(ptr)
p = *ptr;
if ((p[1] & CHAR) == 0) {
- xprintf(CGETS(9, 8, "Something must follow: %c\n"), *p);
+ xprintf(CGETS(9, 8, "Something must follow: %c\n"), (char)*p);
return CHAR_ERR;
}
if ((*p & CHAR) == '\\') {
@@ -738,7 +668,7 @@ parseescape(ptr)
}
val = (val << 3) | (ch - '0');
}
- if ((val & 0xffffff00) != 0) {
+ if ((val & ~0xff) != 0) {
xprintf(CGETS(9, 9,
"Octal constant does not fit in a char.\n"));
return 0;
@@ -777,15 +707,14 @@ parseescape(ptr)
unsigned char *
-unparsestring(str, buf, sep)
- CStr *str;
- unsigned char *buf;
- Char *sep;
+unparsestring(const CStr *str, const Char *sep)
{
- unsigned char *b;
+ unsigned char *buf, *b;
Char p;
int l;
+ /* Worst-case is "\uuu" or result of wctomb() for each char from str */
+ buf = xmalloc((str->len + 1) * max(4, MB_LEN_MAX));
b = buf;
if (sep[0])
#ifndef WINNT_NATIVE
@@ -797,26 +726,14 @@ unparsestring(str, buf, sep)
for (l = 0; l < str->len; l++) {
p = str->buf[l];
if (Iscntrl(p)) {
-#ifdef IS_ASCII
*b++ = '^';
if (p == CTL_ESC('\177'))
*b++ = '?';
else
+#ifdef IS_ASCII
*b++ = (unsigned char) (p | 0100);
#else
- if (_toascii[p] == '\177' || Isupper(_toebcdic[_toascii[p]|0100])
- || strchr("@[\\]^_", _toebcdic[_toascii[p]|0100]) != NULL)
- {
- *b++ = '^';
- *b++ = (_toascii[p] == '\177') ? '?' : _toebcdic[_toascii[p]|0100];
- }
- else
- {
- *b++ = '\\';
- *b++ = ((p >> 6) & 7) + '0';
- *b++ = ((p >> 3) & 7) + '0';
- *b++ = (p & 7) + '0';
- }
+ *b++ = _toebcdic[_toascii[p]|0100];
#endif
}
else if (p == '^' || p == '\\') {
diff --git a/contrib/tcsh/eight-bit.me b/contrib/tcsh/eight-bit.me
index 466f011..0359d8b 100644
--- a/contrib/tcsh/eight-bit.me
+++ b/contrib/tcsh/eight-bit.me
@@ -1,4 +1,4 @@
-.\" $Id: eight-bit.me,v 3.1 1991/09/12 09:25:57 christos Exp $
+.\" $tcsh: eight-bit.me,v 3.2 2006/03/02 18:46:44 christos Exp $
How to use 8 bit characters
by
Johan Widen
diff --git a/contrib/tcsh/gethost.c b/contrib/tcsh/gethost.c
index 9152775..efc095b 100644
--- a/contrib/tcsh/gethost.c
+++ b/contrib/tcsh/gethost.c
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/gethost.c,v 1.10 2005/01/05 16:06:13 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/gethost.c,v 1.12 2006/03/02 18:46:44 christos Exp $ */
/*
* gethost.c: Create version file from prototype
*/
@@ -32,7 +32,7 @@
*/
#include "sh.h"
-RCSID("$Id: gethost.c,v 1.10 2005/01/05 16:06:13 christos Exp $")
+RCSID("$tcsh: gethost.c,v 1.12 2006/03/02 18:46:44 christos Exp $")
#ifdef SCO
# define perror __perror
@@ -89,17 +89,16 @@ static const char *keyword[] =
#define S_CODE 2
#define S_KEYWORD 3
-static int findtoken __P((char *));
-static char *gettoken __P((char **, char *));
+static int findtoken (char *);
+static char *gettoken (char **, char *);
-int main __P((int, char *[]));
+int main (int, char *[]);
/* findtoken():
* Return the token number of the given token
*/
static int
-findtoken(ptr)
- char *ptr;
+findtoken(char *ptr)
{
int i;
@@ -118,9 +117,7 @@ findtoken(ptr)
* Get : delimited token and remove leading/trailing blanks/newlines
*/
static char *
-gettoken(pptr, token)
- char **pptr;
- char *token;
+gettoken(char **pptr, char *token)
{
char *ptr = *pptr;
char *tok = token;
@@ -147,9 +144,7 @@ gettoken(pptr, token)
int
-main(argc, argv)
- int argc;
- char *argv[];
+main(int argc, char *argv[])
{
char line[INBUFSIZE];
char *pname;
diff --git a/contrib/tcsh/glob.c b/contrib/tcsh/glob.c
index b56e220..844ee36 100644
--- a/contrib/tcsh/glob.c
+++ b/contrib/tcsh/glob.c
@@ -63,7 +63,6 @@ static char sccsid[] = "@(#)glob.c 5.12 (Berkeley) 6/24/91";
#undef QUOTE
#undef TILDE
#undef META
-#undef CHAR
#undef ismeta
#undef Strchr
@@ -81,23 +80,22 @@ static char sccsid[] = "@(#)glob.c 5.12 (Berkeley) 6/24/91";
typedef unsigned short Char;
-static int glob1 __P((Char *, glob_t *, int));
-static int glob2 __P((Char *, Char *, Char *, glob_t *, int));
-static int glob3 __P((Char *, Char *, Char *, Char *,
- glob_t *, int));
-static int globextend __P((Char *, glob_t *));
-static int match __P((Char *, Char *, Char *, int));
-#ifndef __clipper__
-static int compare __P((const ptr_t, const ptr_t));
-#endif
-static DIR *Opendir __P((Char *));
+static int glob1 (Char *, glob_t *, int);
+static int glob2 (struct strbuf *, const Char *, glob_t *, int);
+static int glob3 (struct strbuf *, const Char *, const Char *,
+ glob_t *, int);
+static void globextend (const char *, glob_t *);
+static int match (const char *, const Char *, const Char *,
+ int);
+static int compare (const void *, const void *);
+static DIR *Opendir (const char *);
#ifdef S_IFLNK
-static int Lstat __P((Char *, struct stat *));
+static int Lstat (const char *, struct stat *);
#endif
-static int Stat __P((Char *, struct stat *sb));
-static Char *Strchr __P((Char *, int));
+static int Stat (const char *, struct stat *sb);
+static Char *Strchr (Char *, int);
#ifdef DEBUG
-static void qprintf __P((Char *));
+static void qprintf (const Char *);
#endif
#define DOLLAR '$'
@@ -120,7 +118,7 @@ static void qprintf __P((Char *));
#define M_MASK 0xffff
#define M_ASCII 0x00ff
-#define CHAR(c) ((c)&M_ASCII)
+#define LCHAR(c) ((c)&M_ASCII)
#define META(c) ((c)|M_META)
#define M_ALL META('*')
#define M_END META(']')
@@ -131,19 +129,11 @@ static void qprintf __P((Char *));
#define M_SET META('[')
#define ismeta(c) (((c)&M_META) != 0)
-#ifndef BUFSIZE
-#define GLOBBUFLEN MAXPATHLEN
-#else
-#define GLOBBUFLEN BUFSIZE
-#endif
-
int
-globcharcoll(c1, c2, cs)
- NLSChar c1, c2;
- int cs;
+globcharcoll(__Char c1, __Char c2, int cs)
{
-#if defined(NLS) && defined(LC_COLLATE) && !defined(NOSTRCOLL)
-# if defined(SHORT_STRINGS)
+#if defined(NLS) && defined(LC_COLLATE) && defined(HAVE_STRCOLL)
+# if defined(WIDE_STRINGS)
wchar_t s1[2], s2[2];
if (c1 == c2)
@@ -163,7 +153,7 @@ globcharcoll(c1, c2, cs)
s2[0] = c2;
s1[1] = s2[1] = '\0';
return wcscoll(s1, s2);
-# else /* not SHORT_STRINGS */
+# else /* not WIDE_STRINGS */
char s1[2], s2[2];
if (c1 == c2)
@@ -199,85 +189,56 @@ globcharcoll(c1, c2, cs)
*/
static DIR *
-Opendir(str)
- Char *str;
+Opendir(const char *str)
{
- char buf[GLOBBUFLEN];
- char *dc = buf;
#if defined(hpux) || defined(__hpux)
struct stat st;
#endif
if (!*str)
return (opendir("."));
- while ((*dc++ = *str++) != '\0')
- continue;
#if defined(hpux) || defined(__hpux)
/*
* Opendir on some device files hangs, so avoid it
*/
- if (stat(buf, &st) == -1 || !S_ISDIR(st.st_mode))
+ if (stat(str, &st) == -1 || !S_ISDIR(st.st_mode))
return NULL;
#endif
- return (opendir(buf));
+ return opendir(str);
}
#ifdef S_IFLNK
static int
-Lstat(fn, sb)
- Char *fn;
- struct stat *sb;
+Lstat(const char *fn, struct stat *sb)
{
- char buf[GLOBBUFLEN];
- char *dc = buf;
+ int st;
- while ((*dc++ = *fn++) != '\0')
- continue;
+ st = lstat(fn, sb);
# ifdef NAMEI_BUG
- {
- int st;
-
- st = lstat(buf, sb);
- if (*buf)
- dc--;
- return (*--dc == '/' && !S_ISDIR(sb->st_mode) ? -1 : st);
- }
-# else
- return (lstat(buf, sb));
+ if (*fn != 0 && strend(fn)[-1] == '/' && !S_ISDIR(sb->st_mode))
+ st = -1;
# endif /* NAMEI_BUG */
+ return st;
}
#else
#define Lstat Stat
#endif /* S_IFLNK */
static int
-Stat(fn, sb)
- Char *fn;
- struct stat *sb;
+Stat(const char *fn, struct stat *sb)
{
- char buf[GLOBBUFLEN];
- char *dc = buf;
+ int st;
- while ((*dc++ = *fn++) != '\0')
- continue;
+ st = stat(fn, sb);
#ifdef NAMEI_BUG
- {
- int st;
-
- st = stat(buf, sb);
- if (*buf)
- dc--;
- return (*--dc == '/' && !S_ISDIR(sb->st_mode) ? -1 : st);
- }
-#else
- return (stat(buf, sb));
+ if (*fn != 0 && strend(fn)[-1] == '/' && !S_ISDIR(sb->st_mode))
+ st = -1;
#endif /* NAMEI_BUG */
+ return st;
}
static Char *
-Strchr(str, ch)
- Char *str;
- int ch;
+Strchr(Char *str, int ch)
{
do
if (*str == ch)
@@ -288,10 +249,9 @@ Strchr(str, ch)
#ifdef DEBUG
static void
-qprintf(s)
-Char *s;
+qprintf(const Char *s)
{
- Char *p;
+ const Char *p;
for (p = s; *p; p++)
printf("%c", *p & 0xff);
@@ -306,16 +266,13 @@ Char *s;
#endif /* DEBUG */
static int
-compare(p, q)
- const ptr_t p, q;
+compare(const void *p, const void *q)
{
-#if defined(NLS) && !defined(NOSTRCOLL)
- errno = 0; /* strcoll sets errno, another brain-damage */
-
- return (strcoll(*(char **) p, *(char **) q));
+#if defined(NLS) && defined(HAVE_STRCOLL)
+ return (strcoll(*(char *const *) p, *(char *const *) q));
#else
- return (strcmp(*(char **) p, *(char **) q));
-#endif /* NLS && !NOSTRCOLL */
+ return (strcmp(*(char *const *) p, *(char *const *) q));
+#endif /* NLS && HAVE_STRCOLL */
}
/*
@@ -326,22 +283,14 @@ compare(p, q)
* to find no matches.
*/
int
-glob(pattern, flags, errfunc, pglob)
- const char *pattern;
- int flags;
- int (*errfunc) __P((const char *, int));
- glob_t *pglob;
+glob(const char *pattern, int flags, int (*errfunc) (const char *, int),
+ glob_t *pglob)
{
int err, oldpathc;
- Char *bufnext, *bufend, *compilebuf, m_not;
- const unsigned char *compilepat, *patnext;
+ Char *bufnext, m_not;
+ const unsigned char *patnext;
int c, not;
- Char *qpatnext;
-#ifdef WIDE_STRINGS
- Char patbuf[GLOBBUFLEN + MB_LEN_MAX + 1];
-#else
- Char patbuf[GLOBBUFLEN + 1];
-#endif
+ Char *qpatnext, *patbuf;
int no_match;
patnext = (const unsigned char *) pattern;
@@ -365,10 +314,8 @@ glob(pattern, flags, errfunc, pglob)
m_not = M_NOT;
}
+ patbuf = xmalloc((strlen(pattern) + 1) * sizeof(*patbuf));
bufnext = patbuf;
- bufend = bufnext + GLOBBUFLEN;
- compilebuf = bufnext;
- compilepat = patnext;
no_match = *patnext == not;
if (no_match)
@@ -376,7 +323,7 @@ glob(pattern, flags, errfunc, pglob)
if (flags & GLOB_QUOTE) {
/* Protect the quoted characters */
- while (bufnext < bufend && (c = *patnext++) != EOS) {
+ while ((c = *patnext++) != EOS) {
#ifdef WIDE_STRINGS
int len;
@@ -400,14 +347,13 @@ glob(pattern, flags, errfunc, pglob)
*bufnext++ = (Char) c;
}
}
- else
- while (bufnext < bufend && (c = *patnext++) != EOS)
+ else
+ while ((c = *patnext++) != EOS)
*bufnext++ = (Char) c;
*bufnext = EOS;
bufnext = patbuf;
qpatnext = patbuf;
- /* we don't need to check for buffer overflow any more */
while ((c = *qpatnext++) != EOS) {
switch (c) {
case LBRACKET:
@@ -427,11 +373,11 @@ glob(pattern, flags, errfunc, pglob)
*bufnext++ = m_not;
c = *qpatnext++;
do {
- *bufnext++ = CHAR(c);
+ *bufnext++ = LCHAR(c);
if (*qpatnext == RANGE &&
(c = qpatnext[1]) != RBRACKET) {
*bufnext++ = M_RNG;
- *bufnext++ = CHAR(c);
+ *bufnext++ = LCHAR(c);
qpatnext += 2;
}
} while ((c = *qpatnext++) != RBRACKET);
@@ -450,7 +396,7 @@ glob(pattern, flags, errfunc, pglob)
*bufnext++ = M_ALL;
break;
default:
- *bufnext++ = CHAR(c);
+ *bufnext++ = LCHAR(c);
break;
}
}
@@ -459,8 +405,10 @@ glob(pattern, flags, errfunc, pglob)
qprintf(patbuf);
#endif
- if ((err = glob1(patbuf, pglob, no_match)) != 0)
+ if ((err = glob1(patbuf, pglob, no_match)) != 0) {
+ xfree(patbuf);
return (err);
+ }
/*
* If there was no match we are going to append the pattern
@@ -471,50 +419,51 @@ glob(pattern, flags, errfunc, pglob)
if (pglob->gl_pathc == oldpathc &&
((flags & GLOB_NOCHECK) ||
((flags & GLOB_NOMAGIC) && !(pglob->gl_flags & GLOB_MAGCHAR)))) {
- if (!(flags & GLOB_QUOTE)) {
- Char *dp = compilebuf;
- const unsigned char *sp = compilepat;
-
- while ((*dp++ = *sp++) != '\0')
- continue;
- }
+ if (!(flags & GLOB_QUOTE))
+ globextend(pattern, pglob);
else {
- /*
- * copy pattern, interpreting quotes; this is slightly different
- * than the interpretation of quotes above -- which should prevail?
- */
- while (*compilepat != EOS) {
- if (*compilepat == QUOTE) {
- if (*++compilepat == EOS)
- --compilepat;
+ char *copy, *dest;
+ const char *src;
+
+ /* copy pattern, interpreting quotes */
+ copy = xmalloc(strlen(pattern) + 1);
+ dest = copy;
+ src = pattern;
+ while (*src != EOS) {
+ if (*src == QUOTE) {
+ if (*++src == EOS)
+ --src;
}
- *compilebuf++ = (unsigned char) *compilepat++;
+ *dest++ = *src++;
}
- *compilebuf = EOS;
+ *dest = EOS;
+ globextend(copy, pglob);
+ xfree(copy);
}
- return (globextend(patbuf, pglob));
+ xfree(patbuf);
+ return 0;
}
else if (!(flags & GLOB_NOSORT) && (pglob->gl_pathc != oldpathc))
- qsort((char *) (pglob->gl_pathv + pglob->gl_offs + oldpathc),
- pglob->gl_pathc - oldpathc, sizeof(char *),
- (int (*) __P((const void *, const void *))) compare);
+ qsort(pglob->gl_pathv + pglob->gl_offs + oldpathc,
+ pglob->gl_pathc - oldpathc, sizeof(char *), compare);
+ xfree(patbuf);
return (0);
}
static int
-glob1(pattern, pglob, no_match)
- Char *pattern;
- glob_t *pglob;
- int no_match;
+glob1(Char *pattern, glob_t *pglob, int no_match)
{
- Char pathbuf[GLOBBUFLEN + 1];
+ struct strbuf pathbuf = strbuf_INIT;
+ int err;
/*
* a null pathname is invalid -- POSIX 1003.1 sect. 2.4.
*/
if (*pattern == EOS)
return (0);
- return (glob2(pathbuf, pathbuf, pattern, pglob, no_match));
+ err = glob2(&pathbuf, pattern, pglob, no_match);
+ xfree(pathbuf.s);
+ return err;
}
/*
@@ -523,14 +472,12 @@ glob1(pattern, pglob, no_match)
* more meta characters.
*/
static int
-glob2(pathbuf, pathend, pattern, pglob, no_match)
- Char *pathbuf, *pathend, *pattern;
- glob_t *pglob;
- int no_match;
+glob2(struct strbuf *pathbuf, const Char *pattern, glob_t *pglob, int no_match)
{
struct stat sbuf;
int anymeta;
- Char *p, *q;
+ const Char *p;
+ size_t orig_len;
/*
* loop over pattern segments until end of pattern or until segment with
@@ -539,69 +486,67 @@ glob2(pathbuf, pathend, pattern, pglob, no_match)
anymeta = 0;
for (;;) {
if (*pattern == EOS) { /* end of pattern? */
- *pathend = EOS;
+ strbuf_terminate(pathbuf);
- if (Lstat(pathbuf, &sbuf))
+ if (Lstat(pathbuf->s, &sbuf))
return (0);
if (((pglob->gl_flags & GLOB_MARK) &&
- pathend[-1] != SEP) &&
+ pathbuf->s[pathbuf->len - 1] != SEP) &&
(S_ISDIR(sbuf.st_mode)
#ifdef S_IFLNK
|| (S_ISLNK(sbuf.st_mode) &&
- (Stat(pathbuf, &sbuf) == 0) &&
+ (Stat(pathbuf->s, &sbuf) == 0) &&
S_ISDIR(sbuf.st_mode))
#endif
)) {
- *pathend++ = SEP;
- *pathend = EOS;
+ strbuf_append1(pathbuf, SEP);
+ strbuf_terminate(pathbuf);
}
++pglob->gl_matchc;
- return (globextend(pathbuf, pglob));
+ globextend(pathbuf->s, pglob);
+ return 0;
}
- /* find end of next segment, copy tentatively to pathend */
- q = pathend;
+ /* find end of next segment, tentatively copy to pathbuf */
p = pattern;
+ orig_len = pathbuf->len;
while (*p != EOS && *p != SEP) {
if (ismeta(*p))
anymeta = 1;
- *q++ = *p++;
+ strbuf_append1(pathbuf, *p++);
}
if (!anymeta) { /* no expansion, do next segment */
- pathend = q;
pattern = p;
while (*pattern == SEP)
- *pathend++ = *pattern++;
+ strbuf_append1(pathbuf, *pattern++);
+ }
+ else { /* need expansion, recurse */
+ pathbuf->len = orig_len;
+ return (glob3(pathbuf, pattern, p, pglob, no_match));
}
- else /* need expansion, recurse */
- return (glob3(pathbuf, pathend, pattern, p, pglob, no_match));
}
/* NOTREACHED */
}
static int
-glob3(pathbuf, pathend, pattern, restpattern, pglob, no_match)
- Char *pathbuf, *pathend, *pattern, *restpattern;
- glob_t *pglob;
- int no_match;
+glob3(struct strbuf *pathbuf, const Char *pattern, const Char *restpattern,
+ glob_t *pglob, int no_match)
{
DIR *dirp;
struct dirent *dp;
int err;
Char m_not = (pglob->gl_flags & GLOB_ALTNOT) ? M_ALTNOT : M_NOT;
- char cpathbuf[GLOBBUFLEN], *ptr;;
+ size_t orig_len;
- *pathend = EOS;
+ strbuf_terminate(pathbuf);
errno = 0;
- if (!(dirp = Opendir(pathbuf))) {
+ if (!(dirp = Opendir(pathbuf->s))) {
/* todo: don't call for ENOENT or ENOTDIR? */
- for (ptr = cpathbuf; (*ptr++ = (char) *pathbuf++) != EOS;)
- continue;
- if ((pglob->gl_errfunc && (*pglob->gl_errfunc) (cpathbuf, errno)) ||
+ if ((pglob->gl_errfunc && (*pglob->gl_errfunc) (pathbuf->s, errno)) ||
(pglob->gl_flags & GLOB_ERR))
return (GLOB_ABEND);
else
@@ -610,27 +555,24 @@ glob3(pathbuf, pathend, pattern, restpattern, pglob, no_match)
err = 0;
+ orig_len = pathbuf->len;
/* search directory for matching names */
while ((dp = readdir(dirp)) != NULL) {
- unsigned char *sc;
- Char *dc;
-
/* initial DOT must be matched literally */
if (dp->d_name[0] == DOT && *pattern != DOT)
continue;
- for (sc = (unsigned char *) dp->d_name, dc = pathend;
- (*dc++ = *sc++) != '\0';)
+ pathbuf->len = orig_len;
+ strbuf_append(pathbuf, dp->d_name);
+ strbuf_terminate(pathbuf);
+ if (match(pathbuf->s + orig_len, pattern, restpattern, (int) m_not)
+ == no_match)
continue;
- if (match(pathend, pattern, restpattern, (int) m_not) == no_match) {
- *pathend = EOS;
- continue;
- }
- err = glob2(pathbuf, --dc, restpattern, pglob, no_match);
+ err = glob2(pathbuf, restpattern, pglob, no_match);
if (err)
break;
}
/* todo: check error from readdir? */
- (void) closedir(dirp);
+ closedir(dirp);
return (err);
}
@@ -649,23 +591,15 @@ glob3(pathbuf, pathend, pattern, restpattern, pglob, no_match)
* Either gl_pathc is zero and gl_pathv is NULL; or gl_pathc > 0 and
* gl_pathv points to (gl_offs + gl_pathc + 1) items.
*/
-static int
-globextend(path, pglob)
- Char *path;
- glob_t *pglob;
+static void
+globextend(const char *path, glob_t *pglob)
{
char **pathv;
int i;
- unsigned int newsize;
- char *copy;
- Char *p;
+ size_t newsize;
newsize = sizeof(*pathv) * (2 + pglob->gl_pathc + pglob->gl_offs);
- pathv = (char **) (pglob->gl_pathv ?
- xrealloc((ptr_t) pglob->gl_pathv, (size_t) newsize) :
- xmalloc((size_t) newsize));
- if (pathv == NULL)
- return (GLOB_NOSPACE);
+ pathv = xrealloc(pglob->gl_pathv, newsize);
if (pglob->gl_pathv == NULL && pglob->gl_offs > 0) {
/* first time around -- clear initial gl_offs items */
@@ -675,23 +609,12 @@ globextend(path, pglob)
}
pglob->gl_pathv = pathv;
- for (p = path; *p++;)
- continue;
- if ((copy = (char *) xmalloc((size_t) (p - path))) != NULL) {
- char *dc = copy;
- Char *sc = path;
-
- while ((*dc++ = *sc++) != '\0')
- continue;
- pathv[pglob->gl_offs + pglob->gl_pathc++] = copy;
- }
+ pathv[pglob->gl_offs + pglob->gl_pathc++] = strsave(path);
pathv[pglob->gl_offs + pglob->gl_pathc] = NULL;
- return ((copy == NULL) ? GLOB_NOSPACE : 0);
}
-
static size_t
-One_mbtowc(NLSChar *pwc, const Char *s, size_t n)
+One_Char_mbtowc(__Char *pwc, const Char *s, size_t n)
{
#ifdef WIDE_STRINGS
char buf[MB_LEN_MAX], *p;
@@ -699,11 +622,12 @@ One_mbtowc(NLSChar *pwc, const Char *s, size_t n)
if (n > MB_LEN_MAX)
n = MB_LEN_MAX;
p = buf;
- while (p < buf + n && (*p++ = CHAR(*s++)) != 0)
+ while (p < buf + n && (*p++ = LCHAR(*s++)) != 0)
;
return one_mbtowc(pwc, buf, n);
#else
- return NLSFrom(s, n, pwc);
+ *pwc = *s & CHAR;
+ return 1;
#endif
}
@@ -712,21 +636,18 @@ One_mbtowc(NLSChar *pwc, const Char *s, size_t n)
* pattern causes a recursion level.
*/
static int
-match(name, pat, patend, m_not)
- Char *name, *pat, *patend;
- int m_not;
+match(const char *name, const Char *pat, const Char *patend, int m_not)
{
int ok, negate_range;
- Char c, k;
+ Char c;
while (pat < patend) {
size_t lwk;
- NLSChar wc, wk;
+ __Char wc, wk;
- USE(k);
c = *pat; /* Only for M_MASK bits */
- pat += One_mbtowc(&wc, pat, MB_LEN_MAX);
- lwk = One_mbtowc(&wk, name, MB_LEN_MAX);
+ pat += One_Char_mbtowc(&wc, pat, MB_LEN_MAX);
+ lwk = one_mbtowc(&wk, name, MB_LEN_MAX);
switch (c & M_MASK) {
case M_ALL:
if (pat == patend)
@@ -737,7 +658,7 @@ match(name, pat, patend, m_not)
if (*name == EOS)
break;
name += lwk;
- lwk = One_mbtowc(&wk, name, MB_LEN_MAX);
+ lwk = one_mbtowc(&wk, name, MB_LEN_MAX);
}
return (0);
case M_ONE:
@@ -753,19 +674,19 @@ match(name, pat, patend, m_not)
if ((negate_range = ((*pat & M_MASK) == m_not)) != 0)
++pat;
while ((*pat & M_MASK) != M_END) {
- pat += One_mbtowc(&wc, pat, MB_LEN_MAX);
+ pat += One_Char_mbtowc(&wc, pat, MB_LEN_MAX);
if ((*pat & M_MASK) == M_RNG) {
- NLSChar wc2;
-
+ __Char wc2;
+
pat++;
- pat += One_mbtowc(&wc2, pat, MB_LEN_MAX);
+ pat += One_Char_mbtowc(&wc2, pat, MB_LEN_MAX);
if (globcharcoll(wc, wk, 0) <= 0 &&
globcharcoll(wk, wc2, 0) <= 0)
ok = 1;
} else if (wc == wk)
ok = 1;
}
- pat += One_mbtowc(&wc, pat, MB_LEN_MAX);
+ pat += One_Char_mbtowc(&wc, pat, MB_LEN_MAX);
if (ok == negate_range)
return (0);
break;
@@ -781,8 +702,7 @@ match(name, pat, patend, m_not)
/* free allocated data belonging to a glob_t structure */
void
-globfree(pglob)
- glob_t *pglob;
+globfree(glob_t *pglob)
{
int i;
char **pp;
@@ -791,7 +711,7 @@ globfree(pglob)
pp = pglob->gl_pathv + pglob->gl_offs;
for (i = pglob->gl_pathc; i--; ++pp)
if (*pp)
- xfree((ptr_t) *pp), *pp = NULL;
- xfree((ptr_t) pglob->gl_pathv), pglob->gl_pathv = NULL;
+ xfree(*pp), *pp = NULL;
+ xfree(pglob->gl_pathv), pglob->gl_pathv = NULL;
}
}
diff --git a/contrib/tcsh/glob.h b/contrib/tcsh/glob.h
index bb5bd3d..0a6fd39 100644
--- a/contrib/tcsh/glob.h
+++ b/contrib/tcsh/glob.h
@@ -44,18 +44,18 @@ typedef struct {
int gl_flags; /* Copy of flags parameter to glob. */
char **gl_pathv; /* List of paths matching pattern. */
/* Copy of errfunc parameter to glob. */
- int (*gl_errfunc) __P((const char *, int));
+ int (*gl_errfunc) (const char *, int);
/*
* Alternate filesystem access methods for glob; replacement
* versions of closedir(3), readdir(3), opendir(3), stat(2)
* and lstat(2).
*/
- void (*gl_closedir) __P((void *));
- struct dirent *(*gl_readdir) __P((void *));
- void *(*gl_opendir) __P((const char *));
- int (*gl_lstat) __P((const char *, struct stat *));
- int (*gl_stat) __P((const char *, struct stat *));
+ void (*gl_closedir) (void *);
+ struct dirent *(*gl_readdir) (void *);
+ void *(*gl_opendir) (const char *);
+ int (*gl_lstat) (const char *, struct stat *);
+ int (*gl_stat) (const char *, struct stat *);
} glob_t;
#define GLOB_APPEND 0x0001 /* Append to output from previous call. */
@@ -84,10 +84,8 @@ typedef struct {
#define GLOB_ABEND GLOB_ABORTED /* source compatibility */
/* #endif */
-#include "tc.nls.h"
-
-int glob __P((const char *, int, int (*)(const char *, int), glob_t *));
-void globfree __P((glob_t *));
-int globcharcoll __P((NLSChar, NLSChar, int));
+int glob (const char *, int, int (*)(const char *, int), glob_t *);
+void globfree (glob_t *);
+int globcharcoll (Char, Char, int);
#endif /* !_GLOB_H_ */
diff --git a/contrib/tcsh/host.defs b/contrib/tcsh/host.defs
index f56a955..60b18e8 100644
--- a/contrib/tcsh/host.defs
+++ b/contrib/tcsh/host.defs
@@ -1,5 +1,5 @@
newcode :
-/* $Header: /src/pub/tcsh/host.defs,v 1.40 2005/03/03 16:49:15 kim Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/host.defs,v 1.43 2006/03/02 18:46:44 christos Exp $ */
/*
* host.defs: Hosttype/Machtype etc.
*/
@@ -33,7 +33,7 @@ newcode :
*/
#include "sh.h"
-RCSID("$Id: host.defs,v 1.40 2005/03/03 16:49:15 kim Exp $")
+RCSID("$tcsh: host.defs,v 1.43 2006/03/02 18:46:44 christos Exp $")
endcode :
@@ -49,8 +49,7 @@ macro : M_intel : (defined(M_i386) || defined(M_i486) || defined(M_i586))
newdef : defined(ns32000)
newcode :
static char *
-isamultimax(flag)
- int flag;
+isamultimax(int flag)
{
if (access("/Umax.image", F_OK) == 0)
return "multimax";
@@ -73,7 +72,7 @@ newcode :
/* From: hpa@hook.eecs.nwu.edu (H. Peter Anvin) */
static char *
-getcray()
+getcray(void)
{
# ifdef MC_GET_SYSTEM /* If we have target() */
struct target data;
@@ -115,7 +114,7 @@ newcode :
/* From: fox@convex.com (David DeSimone) */
static char *
-getconvex()
+getconvex(void)
{
struct system_information sysinfo;
static char result[8];
@@ -172,7 +171,7 @@ enddef :
newcode :
void
-getmachine()
+getmachine(void)
{
const char *hosttype;
const char *ostype;
@@ -446,8 +445,7 @@ hosttype: defined(__x86_64__) : "x86_64-linux"
hosttype: defined(M_i586) : "i586-linux"
hosttype: defined(M_i486) : "i486-linux"
hosttype: defined(M_i386) : "i386-linux"
-ostype : !defined(PPC) : "linux"
-ostype : defined(PPC) : "mklinux"
+ostype : : "linux"
machtype: defined(__ia64__) : "ia64"
machtype: defined(__powerpc64__) : "powerpc64"
machtype: defined(__s390x__) : "s390x"
diff --git a/contrib/tcsh/imake.config b/contrib/tcsh/imake.config
index 4278a46..c8e6d10 100644
--- a/contrib/tcsh/imake.config
+++ b/contrib/tcsh/imake.config
@@ -1,5 +1,5 @@
/*
- * $Id: imake.config,v 1.4 1995/03/05 03:18:09 christos Exp $
+ * $tcsh: imake.config,v 1.5 2006/03/02 18:46:44 christos Exp $
*
* config.Imakefile for for tcsh 6.00
* Marc Horowitz, MIT SIPB
diff --git a/contrib/tcsh/ma.setp.c b/contrib/tcsh/ma.setp.c
index e55c41f..1036fa9 100644
--- a/contrib/tcsh/ma.setp.c
+++ b/contrib/tcsh/ma.setp.c
@@ -82,7 +82,7 @@
**********************************************************************
*/
#include "sh.h"
-RCSID("$Id: ma.setp.c,v 1.14 2004/08/04 17:12:28 christos Exp $")
+RCSID("$tcsh: ma.setp.c,v 1.18 2006/03/02 18:46:44 christos Exp $")
#ifdef MACH
@@ -132,29 +132,28 @@ static int eflag;
return(-1); \
}
-static int initpaths __P((char **));
-static void savepaths __P((char **));
-static void freepaths __P((void));
-static void rcmd __P((char *));
-static void icmd __P((char *, char *));
-static void iacmd __P((char *, char *));
-static void ibcmd __P((char *, char *));
-static void incmd __P((char *, int));
-static void insert __P((struct pelem *, int, char *));
-static void dcmd __P((char *));
-static void dncmd __P((int));
-static void delete __P((struct pelem *, int));
-static void ccmd __P((char *, char *));
-static void cncmd __P((char *, int));
-static void change __P((struct pelem *, int, char *));
-static int locate __P((struct pelem *, char *));
+static int initpaths (char **);
+static void savepaths (char **);
+static void freepaths (void);
+static void rcmd (char *);
+static void icmd (char *, char *);
+static void iacmd (char *, char *);
+static void ibcmd (char *, char *);
+static void incmd (char *, int);
+static void insert (struct pelem *, int, char *);
+static void dcmd (char *);
+static void dncmd (int);
+static void delete (struct pelem *, int);
+static void ccmd (char *, char *);
+static void cncmd (char *, int);
+static void change (struct pelem *, int, char *);
+static int locate (struct pelem *, char *);
int
-setpath(paths, cmds, localsyspath, dosuffix, printerrors)
-char **paths, **cmds, *localsyspath;
-int dosuffix, printerrors;
+setpath(char **paths, char **cmds, char *localsyspath, int dosuffix,
+ int printerrors)
{
char *cmd, *cmd1, *cmd2;
int ncmd;
@@ -230,8 +229,7 @@ int dosuffix, printerrors;
}
static int
-initpaths(paths)
-char **paths;
+initpaths(char **paths)
{
char *path, *val, *p, *q;
int i, done;
@@ -248,8 +246,8 @@ char **paths;
return(-1);
}
*val++ = '\0';
- pe = (struct pelem *)xmalloc((unsigned)(sizeof(struct pelem)));
- setzero((char *) pe, sizeof(struct pelem));
+ pe = xmalloc(sizeof(struct pelem));
+ setzero(pe, sizeof(struct pelem));
if (pathhead == NULL)
pathhead = pathend = pe;
else {
@@ -283,8 +281,7 @@ char **paths;
}
static void
-savepaths(paths)
-char **paths;
+savepaths(char **paths)
{
char *p, *q;
int npath, i, len;
@@ -312,7 +309,7 @@ char **paths;
}
static void
-freepaths()
+freepaths(void)
{
char *p;
int i;
@@ -345,13 +342,12 @@ freepaths()
***********************************************/
static void
-rcmd(localsyspath) /* reset path with localsyspath */
-char *localsyspath;
+rcmd(char *localsyspath) /* reset path with localsyspath */
{
int n, done;
char *new, *p;
struct pelem *pe;
- char newbuf[MAXPATHLEN+1];
+ char newbuf[MAXPATHLEN+1];/*FIXBUF*/
for (pe = pathhead; pe; pe = pe->pnext) {
new = newbuf;
@@ -389,13 +385,12 @@ char *localsyspath;
***********************************************/
static void
-icmd(path, localsyspath) /* insert path before localsyspath */
-char *path, *localsyspath;
+icmd(char *path, char *localsyspath) /* insert path before localsyspath */
{
int n;
char *new;
struct pelem *pe;
- char newbuf[MAXPATHLEN+1];
+ char newbuf[MAXPATHLEN+1];/*FIXBUF*/
for (pe = pathhead; pe; pe = pe->pnext) {
if (sflag)
@@ -414,8 +409,7 @@ char *path, *localsyspath;
}
static void
-iacmd(inpath, path) /* insert path after inpath */
-char *inpath, *path;
+iacmd(char *inpath, char *path) /* insert path after inpath */
{
int n;
struct pelem *pe;
@@ -431,8 +425,7 @@ char *inpath, *path;
}
static void
-ibcmd(inpath, path) /* insert path before inpath */
-char *inpath, *path;
+ibcmd(char *inpath, char *path) /* insert path before inpath */
{
int n;
struct pelem *pe;
@@ -448,9 +441,7 @@ char *inpath, *path;
}
static void
-incmd(path, n) /* insert path at position n */
-char *path;
-int n;
+incmd(char *path, int n) /* insert path at position n */
{
struct pelem *pe;
@@ -459,14 +450,11 @@ int n;
}
static void
-insert(pe, loc, key)
-struct pelem *pe;
-int loc;
-char *key;
+insert(struct pelem *pe, int loc, char *key)
{
int i;
char *new;
- char newbuf[2000];
+ char newbuf[2000];/*FIXBUF*/
if (sflag) { /* add suffix */
new = newbuf;
@@ -488,8 +476,7 @@ char *key;
***********************************************/
static void
-dcmd(path) /* delete path */
-char *path;
+dcmd(char *path) /* delete path */
{
int n;
struct pelem *pe;
@@ -505,8 +492,7 @@ char *path;
}
static void
-dncmd(n) /* delete at position n */
-int n;
+dncmd(int n) /* delete at position n */
{
struct pelem *pe;
@@ -521,9 +507,7 @@ int n;
}
static void
-delete(pe, n)
-struct pelem *pe;
-int n;
+delete(struct pelem *pe, int n)
{
int d;
@@ -538,8 +522,7 @@ int n;
***********************************************/
static void
-ccmd(inpath, path) /* change inpath to path */
-char *inpath, *path;
+ccmd(char *inpath, char *path) /* change inpath to path */
{
int n;
struct pelem *pe;
@@ -555,9 +538,7 @@ char *inpath, *path;
}
static void
-cncmd(path, n) /* change at position n to path */
-char *path;
-int n;
+cncmd(char *path, int n) /* change at position n to path */
{
struct pelem *pe;
@@ -572,13 +553,10 @@ int n;
}
static void
-change(pe, loc, key)
-struct pelem *pe;
-int loc;
-char *key;
+change(struct pelem *pe, int loc, char *key)
{
char *new;
- char newbuf[MAXPATHLEN+1];
+ char newbuf[MAXPATHLEN+1];/*FIXBUF*/
if (sflag) { /* append suffix */
new = newbuf;
@@ -596,13 +574,11 @@ char *key;
***************************************/
static int
-locate(pe, key)
-struct pelem *pe;
-char *key;
+locate(struct pelem *pe, char *key)
{
int i;
char *realkey;
- char keybuf[MAXPATHLEN+1];
+ char keybuf[MAXPATHLEN+1];/*FIXBUF*/
if (sflag) {
realkey = keybuf;
diff --git a/contrib/tcsh/mi.termios.c b/contrib/tcsh/mi.termios.c
index 87e375e..4025067 100644
--- a/contrib/tcsh/mi.termios.c
+++ b/contrib/tcsh/mi.termios.c
@@ -1,10 +1,10 @@
-/* $Header: /src/pub/tcsh/mi.termios.c,v 1.4 2000/07/04 19:38:14 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/mi.termios.c,v 1.5 2006/03/02 18:46:44 christos Exp $ */
/* termios.c - fake termios interface using sgtty interface
* by Magnus Doell and Bruce Evans.
*
*/
#include "sh.h"
-RCSID("$Id: mi.termios.c,v 1.4 2000/07/04 19:38:14 christos Exp $")
+RCSID("$tcsh: mi.termios.c,v 1.5 2006/03/02 18:46:44 christos Exp $")
#if defined(_MINIX) && !defined(_MINIX_VMD)
diff --git a/contrib/tcsh/mi.varargs.h b/contrib/tcsh/mi.varargs.h
index 7377075..0a9dfb5 100644
--- a/contrib/tcsh/mi.varargs.h
+++ b/contrib/tcsh/mi.varargs.h
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/mi.varargs.h,v 1.2 1996/04/26 19:18:39 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/mi.varargs.h,v 1.2 1996/04/26 19:18:39 christos Exp $ */
/*
* mi.varargs.h: Correct varargs for minix
*/
diff --git a/contrib/tcsh/nls/C/set1 b/contrib/tcsh/nls/C/set1
index 6053155..d63a046 100644
--- a/contrib/tcsh/nls/C/set1
+++ b/contrib/tcsh/nls/C/set1
@@ -1,4 +1,4 @@
-$ $Id: set1,v 1.5 1998/06/27 12:27:55 christos Exp $
+$ $tcsh: set1,v 1.6 2006/03/02 18:46:45 christos Exp $
$ Error messages
$set 1
1 Syntax Error
diff --git a/contrib/tcsh/nls/C/set10 b/contrib/tcsh/nls/C/set10
index 56a96b2..49648ec 100644
--- a/contrib/tcsh/nls/C/set10
+++ b/contrib/tcsh/nls/C/set10
@@ -1,4 +1,4 @@
-$ $Id: set10,v 1.2 1995/03/19 18:07:15 christos Exp $
+$ $tcsh: set10,v 1.3 2006/03/02 18:46:45 christos Exp $
$ ma.setp.c
$set 10
1 setpath: invalid command '%s'.\n
diff --git a/contrib/tcsh/nls/C/set11 b/contrib/tcsh/nls/C/set11
index 069ed41..8655001 100644
--- a/contrib/tcsh/nls/C/set11
+++ b/contrib/tcsh/nls/C/set11
@@ -1,4 +1,4 @@
-$ $Id: set11,v 1.3 2005/03/21 21:26:37 kim Exp $
+$ $tcsh: set11,v 1.4 2006/03/02 18:46:45 christos Exp $
$ sh.c
$set 11
1 Warning: no access to tty (%s).\n
diff --git a/contrib/tcsh/nls/C/set12 b/contrib/tcsh/nls/C/set12
index e0b44a7..31e9783 100644
--- a/contrib/tcsh/nls/C/set12
+++ b/contrib/tcsh/nls/C/set12
@@ -1,4 +1,4 @@
-$ $Id: set12,v 1.3 1996/04/26 20:31:52 christos Exp $
+$ $tcsh: set12,v 1.4 2006/03/02 18:46:45 christos Exp $
$ sh.dir.c
$set 12
1 %s: Trying to start from "%s"\n
diff --git a/contrib/tcsh/nls/C/set13 b/contrib/tcsh/nls/C/set13
index af1de4e..69a42d2 100644
--- a/contrib/tcsh/nls/C/set13
+++ b/contrib/tcsh/nls/C/set13
@@ -1,4 +1,4 @@
-$ $Id: set13,v 1.2 1995/03/19 18:07:15 christos Exp $
+$ $tcsh: set13,v 1.3 2006/03/02 18:46:45 christos Exp $
$ sh.exec.c
$set 13
1 hash=%-4d dir=%-2d prog=%s\n
diff --git a/contrib/tcsh/nls/C/set14 b/contrib/tcsh/nls/C/set14
index d1b86a8..dc39600 100644
--- a/contrib/tcsh/nls/C/set14
+++ b/contrib/tcsh/nls/C/set14
@@ -1,4 +1,4 @@
-$ $Id: set14,v 1.3 1998/11/24 18:18:06 christos Exp $
+$ $tcsh: set14,v 1.4 2006/03/02 18:46:45 christos Exp $
$ sh.file.c
$set 14
1 \nYikes!! Too many %s!!\n
diff --git a/contrib/tcsh/nls/C/set15 b/contrib/tcsh/nls/C/set15
index 1fb8912..7f51d77 100644
--- a/contrib/tcsh/nls/C/set15
+++ b/contrib/tcsh/nls/C/set15
@@ -1,4 +1,4 @@
-$ $Id: set15,v 1.3 1996/10/19 17:52:32 christos Exp $
+$ $tcsh: set15,v 1.4 2006/03/02 18:46:45 christos Exp $
$ sh.func.c
$set 15
1 %s: %s: Can't %s%s limit\n
diff --git a/contrib/tcsh/nls/C/set16 b/contrib/tcsh/nls/C/set16
index 67b1eb8..4c078f8 100644
--- a/contrib/tcsh/nls/C/set16
+++ b/contrib/tcsh/nls/C/set16
@@ -1,4 +1,4 @@
-$ $Id: set16,v 1.3 1996/04/26 20:31:55 christos Exp $
+$ $tcsh: set16,v 1.4 2006/03/02 18:46:45 christos Exp $
$ sh.lex.c
$set 16
1 Reset tty pgrp from %d to %d\n
diff --git a/contrib/tcsh/nls/C/set17 b/contrib/tcsh/nls/C/set17
index 0bef721..a7ed634 100644
--- a/contrib/tcsh/nls/C/set17
+++ b/contrib/tcsh/nls/C/set17
@@ -1,4 +1,4 @@
-$ $Id: set17,v 1.5 2003/02/08 20:03:26 christos Exp $
+$ $tcsh: set17,v 1.6 2006/03/02 18:46:45 christos Exp $
$ sh.proc.c
$set 17
1 BUG: waiting for background job!\n
diff --git a/contrib/tcsh/nls/C/set18 b/contrib/tcsh/nls/C/set18
index f00c4f6..7ef5f80 100644
--- a/contrib/tcsh/nls/C/set18
+++ b/contrib/tcsh/nls/C/set18
@@ -1,4 +1,4 @@
-$ $Id: set18,v 1.2 1995/03/19 18:07:15 christos Exp $
+$ $tcsh: set18,v 1.3 2006/03/02 18:46:45 christos Exp $
$ sh.set.c
$set 18
1 Warning: ridiculously long PATH truncated\n
diff --git a/contrib/tcsh/nls/C/set19 b/contrib/tcsh/nls/C/set19
index 15e17ee..1f10336 100644
--- a/contrib/tcsh/nls/C/set19
+++ b/contrib/tcsh/nls/C/set19
@@ -1,4 +1,4 @@
-$ $Id: set19,v 1.3 1996/04/26 20:31:58 christos Exp $
+$ $tcsh: set19,v 1.4 2006/03/02 18:46:45 christos Exp $
$ tc.alloc.c
$set 19
1 nbytes=%d: Out of memory\n
diff --git a/contrib/tcsh/nls/C/set2 b/contrib/tcsh/nls/C/set2
index 8fff30c..62df232 100644
--- a/contrib/tcsh/nls/C/set2
+++ b/contrib/tcsh/nls/C/set2
@@ -1,4 +1,4 @@
-$ $Id: set2,v 1.4 1998/10/25 15:12:38 christos Exp $
+$ $tcsh: set2,v 1.5 2006/03/02 18:46:45 christos Exp $
$ Signal names
$set 2
1 Null signal
diff --git a/contrib/tcsh/nls/C/set20 b/contrib/tcsh/nls/C/set20
index 1be2714..7fb4d66 100644
--- a/contrib/tcsh/nls/C/set20
+++ b/contrib/tcsh/nls/C/set20
@@ -1,4 +1,4 @@
-$ $Id: set20,v 1.2 1995/03/19 18:07:15 christos Exp $
+$ $tcsh: set20,v 1.3 2006/03/02 18:46:45 christos Exp $
$ tc.bind.c
$set 20
1 Invalid key name `%S'\n
diff --git a/contrib/tcsh/nls/C/set21 b/contrib/tcsh/nls/C/set21
index 9484ba0..5795061 100644
--- a/contrib/tcsh/nls/C/set21
+++ b/contrib/tcsh/nls/C/set21
@@ -1,4 +1,4 @@
-$ $Id: set21,v 1.2 1995/03/19 18:07:15 christos Exp $
+$ $tcsh: set21,v 1.3 2006/03/02 18:46:45 christos Exp $
$ tc.disc.c
$set 21
1 Couldn't get local chars.\n
diff --git a/contrib/tcsh/nls/C/set22 b/contrib/tcsh/nls/C/set22
index 6aa8a29..daf4ec1 100644
--- a/contrib/tcsh/nls/C/set22
+++ b/contrib/tcsh/nls/C/set22
@@ -1,4 +1,4 @@
-$ $Id: set22,v 1.2 1995/03/19 18:07:15 christos Exp $
+$ $tcsh: set22,v 1.3 2006/03/02 18:46:45 christos Exp $
$ tc.func.c
$set 22
1 %S: \t aliased to
diff --git a/contrib/tcsh/nls/C/set23 b/contrib/tcsh/nls/C/set23
index 4f8e560..176853d 100644
--- a/contrib/tcsh/nls/C/set23
+++ b/contrib/tcsh/nls/C/set23
@@ -1,4 +1,4 @@
-$ $Id: set23,v 1.3 1996/04/26 20:32:00 christos Exp $
+$ $tcsh: set23,v 1.4 2006/03/02 18:46:45 christos Exp $
$ tc.os.c
$set 23
1 Bad cpu/site name
diff --git a/contrib/tcsh/nls/C/set24 b/contrib/tcsh/nls/C/set24
index 2896947..1a45f01 100644
--- a/contrib/tcsh/nls/C/set24
+++ b/contrib/tcsh/nls/C/set24
@@ -1,4 +1,4 @@
-$ $Id: set24,v 1.2 1995/03/19 18:07:15 christos Exp $
+$ $tcsh: set24,v 1.3 2006/03/02 18:46:45 christos Exp $
$ tc.sched.c
$set 24
1 kludge
diff --git a/contrib/tcsh/nls/C/set25 b/contrib/tcsh/nls/C/set25
index 063e8d6..9e48309 100644
--- a/contrib/tcsh/nls/C/set25
+++ b/contrib/tcsh/nls/C/set25
@@ -1,4 +1,4 @@
-$ $Id: set25,v 1.2 1995/03/19 18:07:15 christos Exp $
+$ $tcsh: set25,v 1.3 2006/03/02 18:46:45 christos Exp $
$ tc.sig.c
$set 25
1 our wait %d\n
diff --git a/contrib/tcsh/nls/C/set26 b/contrib/tcsh/nls/C/set26
index aa854ad..5921cf7 100644
--- a/contrib/tcsh/nls/C/set26
+++ b/contrib/tcsh/nls/C/set26
@@ -1,4 +1,4 @@
-$ $Id: set26,v 1.2 1995/03/19 18:07:15 christos Exp $
+$ $tcsh: set26,v 1.3 2006/03/02 18:46:45 christos Exp $
$ tc.who.c
$set 26
1 cannot stat %s. Please "unset watch".\n
diff --git a/contrib/tcsh/nls/C/set27 b/contrib/tcsh/nls/C/set27
index 52664d9..3aea7b4 100644
--- a/contrib/tcsh/nls/C/set27
+++ b/contrib/tcsh/nls/C/set27
@@ -1,4 +1,4 @@
-$ $Id: set27,v 1.2 1995/03/19 18:07:15 christos Exp $
+$ $tcsh: set27,v 1.3 2006/03/02 18:46:45 christos Exp $
$ tw.comp.c
$set 27
1 command
diff --git a/contrib/tcsh/nls/C/set29 b/contrib/tcsh/nls/C/set29
index 040e881..b3c4f11 100644
--- a/contrib/tcsh/nls/C/set29
+++ b/contrib/tcsh/nls/C/set29
@@ -1,4 +1,4 @@
-$ $Id: set29,v 1.2 1995/03/19 18:07:15 christos Exp $
+$ $tcsh: set29,v 1.3 2006/03/02 18:46:45 christos Exp $
$ tw.help.c
$set 29
1 No help file for %S\n
diff --git a/contrib/tcsh/nls/C/set3 b/contrib/tcsh/nls/C/set3
index 7a46f5f..7841e25 100644
--- a/contrib/tcsh/nls/C/set3
+++ b/contrib/tcsh/nls/C/set3
@@ -1,4 +1,4 @@
-$ $Id: set3,v 1.4 2001/04/26 19:07:48 kim Exp $
+$ $tcsh: set3,v 1.6 2006/03/02 18:46:45 christos Exp $
$ Editor function descriptions
$set 3
1 Move back a character
@@ -122,3 +122,5 @@ $set 3
119 (WIN32 only) Convert each '/' in previous word to '\\\\'
120 (WIN32 only) Page visible console window up
121 (WIN32 only) Page visible console window down
+122 Execute command and keep current line
+123 Execute command and move to next history line
diff --git a/contrib/tcsh/nls/C/set30 b/contrib/tcsh/nls/C/set30
index b9e6216..99aa3ff 100644
--- a/contrib/tcsh/nls/C/set30
+++ b/contrib/tcsh/nls/C/set30
@@ -1,4 +1,4 @@
-$ $Id: set30,v 1.4 1996/10/19 17:52:34 christos Exp $
+$ $tcsh: set30,v 1.5 2006/03/02 18:46:45 christos Exp $
$ tw.parse.c
$set 30
1 starting_a_command %d\n
diff --git a/contrib/tcsh/nls/C/set31 b/contrib/tcsh/nls/C/set31
index 3641251..9a30f26 100644
--- a/contrib/tcsh/nls/C/set31
+++ b/contrib/tcsh/nls/C/set31
@@ -1,4 +1,4 @@
-$ $Id: set31,v 1.2 1995/03/19 18:07:15 christos Exp $
+$ $tcsh: set31,v 1.3 2006/03/02 18:46:45 christos Exp $
$ vms.termcap.c
$set 31
1 Can't open TERMCAP: [%s]\n
diff --git a/contrib/tcsh/nls/C/set4 b/contrib/tcsh/nls/C/set4
index a7d289c..69da635 100644
--- a/contrib/tcsh/nls/C/set4
+++ b/contrib/tcsh/nls/C/set4
@@ -1,4 +1,4 @@
-$ $Id: set4,v 1.2 1995/03/19 18:07:15 christos Exp $
+$ $tcsh: set4,v 1.3 2006/03/02 18:46:45 christos Exp $
$ Termcap strings
$set 4
1 add new blank line
diff --git a/contrib/tcsh/nls/C/set5 b/contrib/tcsh/nls/C/set5
index b684bb8..d06b29e 100644
--- a/contrib/tcsh/nls/C/set5
+++ b/contrib/tcsh/nls/C/set5
@@ -1,4 +1,4 @@
-$ $Id: set5,v 1.2 1995/03/19 18:07:15 christos Exp $
+$ $tcsh: set5,v 1.3 2006/03/02 18:46:45 christos Exp $
$ ed.chared.c
$set 5
1 Load average unavailable\n
diff --git a/contrib/tcsh/nls/C/set6 b/contrib/tcsh/nls/C/set6
index 03206ad..8046939 100644
--- a/contrib/tcsh/nls/C/set6
+++ b/contrib/tcsh/nls/C/set6
@@ -1,4 +1,4 @@
-$ $Id: set6,v 1.2 1995/03/19 18:07:15 christos Exp $
+$ $tcsh: set6,v 1.3 2006/03/02 18:46:45 christos Exp $
$ ed.inputl.c
$set 6
1 ERROR: illegal command from key 0%o\r\n
diff --git a/contrib/tcsh/nls/C/set7 b/contrib/tcsh/nls/C/set7
index 26e14132..8de5768 100644
--- a/contrib/tcsh/nls/C/set7
+++ b/contrib/tcsh/nls/C/set7
@@ -1,4 +1,4 @@
-$ $Id: set7,v 1.3 1996/04/26 20:32:04 christos Exp $
+$ $tcsh: set7,v 1.4 2006/03/02 18:46:45 christos Exp $
$ ed.screen.c
$set 7
1 \n\tTcsh thinks your terminal has the\n
diff --git a/contrib/tcsh/nls/C/set8 b/contrib/tcsh/nls/C/set8
index 36cb350..7003bdd 100644
--- a/contrib/tcsh/nls/C/set8
+++ b/contrib/tcsh/nls/C/set8
@@ -1,4 +1,4 @@
-$ $Id: set8,v 1.2 1995/03/19 18:07:15 christos Exp $
+$ $tcsh: set8,v 1.3 2006/03/02 18:46:45 christos Exp $
$ ed.term.c
$set 8
1 Unknown switch
diff --git a/contrib/tcsh/nls/C/set9 b/contrib/tcsh/nls/C/set9
index 72511b4..284411d 100644
--- a/contrib/tcsh/nls/C/set9
+++ b/contrib/tcsh/nls/C/set9
@@ -1,4 +1,4 @@
-$ $Id: set9,v 1.2 1995/03/19 18:07:15 christos Exp $
+$ $tcsh: set9,v 1.3 2006/03/02 18:46:45 christos Exp $
$ ed.xmap.c
$set 9
1 AddXkey: Null extended-key not allowed.\n
diff --git a/contrib/tcsh/nls/Makefile b/contrib/tcsh/nls/Makefile
index 57611b4..1bcb436 100644
--- a/contrib/tcsh/nls/Makefile
+++ b/contrib/tcsh/nls/Makefile
@@ -1,8 +1,9 @@
+# $tcsh: Makefile,v 1.14 2006/03/02 18:46:45 christos Exp $
SUBDIRS= C et finnish french german greek italian ja pl russian \
spanish ukrainian
#GENCAT= gencat --new
-#CHARSET= charset
+CHARSET= charset
GENCAT= gencat
catalogs:
diff --git a/contrib/tcsh/nls/et/set1 b/contrib/tcsh/nls/et/set1
index bd44bb3..03864df 100644
--- a/contrib/tcsh/nls/et/set1
+++ b/contrib/tcsh/nls/et/set1
@@ -1,4 +1,4 @@
-$ $Id: set1,v 1.2 2001/01/11 13:25:24 christos Exp $
+$ $tcsh: set1,v 1.3 2006/03/02 18:46:45 christos Exp $
$ Error messages
$set 1
1 Süntaksi viga
diff --git a/contrib/tcsh/nls/et/set10 b/contrib/tcsh/nls/et/set10
index 50b486a..d330cdb 100644
--- a/contrib/tcsh/nls/et/set10
+++ b/contrib/tcsh/nls/et/set10
@@ -1,4 +1,4 @@
-$ $Id: set10,v 1.1 2001/01/04 18:46:02 christos Exp $
+$ $tcsh: set10,v 1.2 2006/03/02 18:46:45 christos Exp $
$ ma.setp.c
$set 10
1 setpath: vigane käsk '%s'.\n
diff --git a/contrib/tcsh/nls/et/set11 b/contrib/tcsh/nls/et/set11
index 7328a0d..ca85161 100644
--- a/contrib/tcsh/nls/et/set11
+++ b/contrib/tcsh/nls/et/set11
@@ -1,4 +1,4 @@
-$ $Id: set11,v 1.1 2001/01/04 18:46:02 christos Exp $
+$ $tcsh: set11,v 1.2 2006/03/02 18:46:45 christos Exp $
$ sh.c
$set 11
1 Hoiatus: tty (%s) pole kättesaadav.\n
diff --git a/contrib/tcsh/nls/et/set12 b/contrib/tcsh/nls/et/set12
index de45948..9c6b1be9 100644
--- a/contrib/tcsh/nls/et/set12
+++ b/contrib/tcsh/nls/et/set12
@@ -1,4 +1,4 @@
-$ $Id: set12,v 1.1 2001/01/04 18:46:02 christos Exp $
+$ $tcsh: set12,v 1.2 2006/03/02 18:46:45 christos Exp $
$ sh.dir.c
$set 12
1 %s: Proovin startida kataloogist "%s"\n
diff --git a/contrib/tcsh/nls/et/set13 b/contrib/tcsh/nls/et/set13
index 02ff2bb..a71a9af 100644
--- a/contrib/tcsh/nls/et/set13
+++ b/contrib/tcsh/nls/et/set13
@@ -1,4 +1,4 @@
-$ $Id: set13,v 1.1 2001/01/04 18:46:02 christos Exp $
+$ $tcsh: set13,v 1.2 2006/03/02 18:46:45 christos Exp $
$ sh.exec.c
$set 13
1 hash=%-4d dir=%-2d prog=%s\n
diff --git a/contrib/tcsh/nls/et/set14 b/contrib/tcsh/nls/et/set14
index dedcc68..95b36c5 100644
--- a/contrib/tcsh/nls/et/set14
+++ b/contrib/tcsh/nls/et/set14
@@ -1,4 +1,4 @@
-$ $Id: set14,v 1.1 2001/01/04 18:46:03 christos Exp $
+$ $tcsh: set14,v 1.2 2006/03/02 18:46:45 christos Exp $
$ sh.file.c
$set 14
1 \nÄhh!! Liiga palju %s!!\n
diff --git a/contrib/tcsh/nls/et/set15 b/contrib/tcsh/nls/et/set15
index f638275..4f5561f 100644
--- a/contrib/tcsh/nls/et/set15
+++ b/contrib/tcsh/nls/et/set15
@@ -1,4 +1,4 @@
-$ $Id: set15,v 1.1 2001/01/04 18:46:03 christos Exp $
+$ $tcsh: set15,v 1.2 2006/03/02 18:46:45 christos Exp $
$ sh.func.c
$set 15
1 %s: %s: Ei õnnestu %s%s piirangut\n
diff --git a/contrib/tcsh/nls/et/set16 b/contrib/tcsh/nls/et/set16
index e2f26be..1596568 100644
--- a/contrib/tcsh/nls/et/set16
+++ b/contrib/tcsh/nls/et/set16
@@ -1,4 +1,4 @@
-$ $Id: set16,v 1.1 2001/01/04 18:46:03 christos Exp $
+$ $tcsh: set16,v 1.2 2006/03/02 18:46:45 christos Exp $
$ sh.lex.c
$set 16
1 Seadsin tty pgrp numbrilt %d numbrile %d\n
diff --git a/contrib/tcsh/nls/et/set17 b/contrib/tcsh/nls/et/set17
index ae536c3..e154d7b 100644
--- a/contrib/tcsh/nls/et/set17
+++ b/contrib/tcsh/nls/et/set17
@@ -1,4 +1,4 @@
-$ $Id: set17,v 1.2 2003/02/08 20:03:26 christos Exp $
+$ $tcsh: set17,v 1.3 2006/03/02 18:46:45 christos Exp $
$ sh.proc.c
$set 17
1 BUG: ootan taustatöö järel!\n
diff --git a/contrib/tcsh/nls/et/set18 b/contrib/tcsh/nls/et/set18
index b91a437..fc31346 100644
--- a/contrib/tcsh/nls/et/set18
+++ b/contrib/tcsh/nls/et/set18
@@ -1,4 +1,4 @@
-$ $Id: set18,v 1.1 2001/01/04 18:46:03 christos Exp $
+$ $tcsh: set18,v 1.2 2006/03/02 18:46:45 christos Exp $
$ sh.set.c
$set 18
1 Hoiatus: nõmedalt pikk PATH sai lühendatud\n
diff --git a/contrib/tcsh/nls/et/set19 b/contrib/tcsh/nls/et/set19
index 8891ab9..6f653d0 100644
--- a/contrib/tcsh/nls/et/set19
+++ b/contrib/tcsh/nls/et/set19
@@ -1,4 +1,4 @@
-$ $Id: set19,v 1.1 2001/01/04 18:46:03 christos Exp $
+$ $tcsh: set19,v 1.2 2006/03/02 18:46:45 christos Exp $
$ tc.alloc.c
$set 19
1 nbytes=%d: Mälu on otsas\n
diff --git a/contrib/tcsh/nls/et/set2 b/contrib/tcsh/nls/et/set2
index 691339f..ea1f4c9 100644
--- a/contrib/tcsh/nls/et/set2
+++ b/contrib/tcsh/nls/et/set2
@@ -1,4 +1,4 @@
-$ $Id: set2,v 1.1 2001/01/04 18:46:03 christos Exp $
+$ $tcsh: set2,v 1.2 2006/03/02 18:46:45 christos Exp $
$ Signal names
$set 2
1 Null signaal
diff --git a/contrib/tcsh/nls/et/set20 b/contrib/tcsh/nls/et/set20
index 0587f75..3ba741b 100644
--- a/contrib/tcsh/nls/et/set20
+++ b/contrib/tcsh/nls/et/set20
@@ -1,4 +1,4 @@
-$ $Id: set20,v 1.1 2001/01/04 18:46:03 christos Exp $
+$ $tcsh: set20,v 1.2 2006/03/02 18:46:45 christos Exp $
$ tc.bind.c
$set 20
1 Vigane klahvi nimi `%S'\n
diff --git a/contrib/tcsh/nls/et/set21 b/contrib/tcsh/nls/et/set21
index ba9a344..e435c1a 100644
--- a/contrib/tcsh/nls/et/set21
+++ b/contrib/tcsh/nls/et/set21
@@ -1,4 +1,4 @@
-$ $Id: set21,v 1.1 2001/01/04 18:46:03 christos Exp $
+$ $tcsh: set21,v 1.2 2006/03/02 18:46:45 christos Exp $
$ tc.disc.c
$set 21
1 Lokaalseid sümboleid ei õnnestu lugeda.\n
diff --git a/contrib/tcsh/nls/et/set22 b/contrib/tcsh/nls/et/set22
index 92e3f3a..e619e53 100644
--- a/contrib/tcsh/nls/et/set22
+++ b/contrib/tcsh/nls/et/set22
@@ -1,4 +1,4 @@
-$ $Id: set22,v 1.1 2001/01/04 18:46:04 christos Exp $
+$ $tcsh: set22,v 1.2 2006/03/02 18:46:45 christos Exp $
$ tc.func.c
$set 22
1 %S: \t on tegelikult
diff --git a/contrib/tcsh/nls/et/set23 b/contrib/tcsh/nls/et/set23
index eb0609d..72432d0 100644
--- a/contrib/tcsh/nls/et/set23
+++ b/contrib/tcsh/nls/et/set23
@@ -1,4 +1,4 @@
-$ $Id: set23,v 1.1 2001/01/04 18:46:04 christos Exp $
+$ $tcsh: set23,v 1.2 2006/03/02 18:46:45 christos Exp $
$ tc.os.c
$set 23
1 Vigane cpu/saidi nimi
diff --git a/contrib/tcsh/nls/et/set24 b/contrib/tcsh/nls/et/set24
index a7fb2de..4c3e637 100644
--- a/contrib/tcsh/nls/et/set24
+++ b/contrib/tcsh/nls/et/set24
@@ -1,4 +1,4 @@
-$ $Id: set24,v 1.1 2001/01/04 18:46:04 christos Exp $
+$ $tcsh: set24,v 1.2 2006/03/02 18:46:45 christos Exp $
$ tc.sched.c
$set 24
1 Häkk!
diff --git a/contrib/tcsh/nls/et/set25 b/contrib/tcsh/nls/et/set25
index a95f6f6..c35deb7 100644
--- a/contrib/tcsh/nls/et/set25
+++ b/contrib/tcsh/nls/et/set25
@@ -1,4 +1,4 @@
-$ $Id: set25,v 1.1 2001/01/04 18:46:04 christos Exp $
+$ $tcsh: set25,v 1.2 2006/03/02 18:46:45 christos Exp $
$ tc.sig.c
$set 25
1 our wait %d\n
diff --git a/contrib/tcsh/nls/et/set26 b/contrib/tcsh/nls/et/set26
index 729c776..e5b3967 100644
--- a/contrib/tcsh/nls/et/set26
+++ b/contrib/tcsh/nls/et/set26
@@ -1,4 +1,4 @@
-$ $Id: set26,v 1.1 2001/01/04 18:46:04 christos Exp $
+$ $tcsh: set26,v 1.2 2006/03/02 18:46:45 christos Exp $
$ tc.who.c
$set 26
1 Ei saa lugeda %s atribuute. Anna käsk "unset watch".\n
diff --git a/contrib/tcsh/nls/et/set27 b/contrib/tcsh/nls/et/set27
index 53828e4..57bd18f 100644
--- a/contrib/tcsh/nls/et/set27
+++ b/contrib/tcsh/nls/et/set27
@@ -1,4 +1,4 @@
-$ $Id: set27,v 1.1 2001/01/04 18:46:04 christos Exp $
+$ $tcsh: set27,v 1.2 2006/03/02 18:46:45 christos Exp $
$ tw.comp.c
$set 27
1 käsk
diff --git a/contrib/tcsh/nls/et/set29 b/contrib/tcsh/nls/et/set29
index 2ec61dd..8e0f6da 100644
--- a/contrib/tcsh/nls/et/set29
+++ b/contrib/tcsh/nls/et/set29
@@ -1,4 +1,4 @@
-$ $Id: set29,v 1.1 2001/01/04 18:46:04 christos Exp $
+$ $tcsh: set29,v 1.2 2006/03/02 18:46:45 christos Exp $
$ tw.help.c
$set 29
1 %S'ile pole abiteksti\n
diff --git a/contrib/tcsh/nls/et/set3 b/contrib/tcsh/nls/et/set3
index 170da71..4c06d39 100644
--- a/contrib/tcsh/nls/et/set3
+++ b/contrib/tcsh/nls/et/set3
@@ -1,4 +1,4 @@
-$ $Id: set3,v 1.2 2001/04/26 19:07:48 kim Exp $
+$ $tcsh: set3,v 1.3 2006/03/02 18:46:45 christos Exp $
$ Editor function descriptions
$set 3
1 Liigu sümbol tagasi
diff --git a/contrib/tcsh/nls/et/set30 b/contrib/tcsh/nls/et/set30
index 8438f46..f629dc8 100644
--- a/contrib/tcsh/nls/et/set30
+++ b/contrib/tcsh/nls/et/set30
@@ -1,4 +1,4 @@
-$ $Id: set30,v 1.1 2001/01/04 18:46:04 christos Exp $
+$ $tcsh: set30,v 1.2 2006/03/02 18:46:45 christos Exp $
$ tw.parse.c
$set 30
1 starting_a_command %d\n
diff --git a/contrib/tcsh/nls/et/set31 b/contrib/tcsh/nls/et/set31
index f701daa..500c1db 100644
--- a/contrib/tcsh/nls/et/set31
+++ b/contrib/tcsh/nls/et/set31
@@ -1,4 +1,4 @@
-$ $Id: set31,v 1.1 2001/01/04 18:46:04 christos Exp $
+$ $tcsh: set31,v 1.2 2006/03/02 18:46:45 christos Exp $
$ vms.termcap.c
$set 31
1 TERMCAP ei saa avada: [%s]\n
diff --git a/contrib/tcsh/nls/et/set4 b/contrib/tcsh/nls/et/set4
index cc9cb19..3ec5b44 100644
--- a/contrib/tcsh/nls/et/set4
+++ b/contrib/tcsh/nls/et/set4
@@ -1,4 +1,4 @@
-$ $Id: set4,v 1.1 2001/01/04 18:46:04 christos Exp $
+$ $tcsh: set4,v 1.2 2006/03/02 18:46:45 christos Exp $
$ Termcap strings
$set 4
1 lisa uus tühi rida
diff --git a/contrib/tcsh/nls/et/set5 b/contrib/tcsh/nls/et/set5
index 013f1b7..aecf6e8 100644
--- a/contrib/tcsh/nls/et/set5
+++ b/contrib/tcsh/nls/et/set5
@@ -1,4 +1,4 @@
-$ $Id: set5,v 1.1 2001/01/04 18:46:05 christos Exp $
+$ $tcsh: set5,v 1.2 2006/03/02 18:46:45 christos Exp $
$ ed.chared.c
$set 5
1 Tööjärjekorra koormuse info puudub\n
diff --git a/contrib/tcsh/nls/et/set6 b/contrib/tcsh/nls/et/set6
index c97d381..3b6c6cd 100644
--- a/contrib/tcsh/nls/et/set6
+++ b/contrib/tcsh/nls/et/set6
@@ -1,4 +1,4 @@
-$ $Id: set6,v 1.1 2001/01/04 18:46:05 christos Exp $
+$ $tcsh: set6,v 1.2 2006/03/02 18:46:45 christos Exp $
$ ed.inputl.c
$set 6
1 VIGA: vigane käsk klahvilt 0%o\r\n
diff --git a/contrib/tcsh/nls/et/set7 b/contrib/tcsh/nls/et/set7
index 32d3e63..f1da7b3 100644
--- a/contrib/tcsh/nls/et/set7
+++ b/contrib/tcsh/nls/et/set7
@@ -1,4 +1,4 @@
-$ $Id: set7,v 1.1 2001/01/04 18:46:05 christos Exp $
+$ $tcsh: set7,v 1.2 2006/03/02 18:46:45 christos Exp $
$ ed.screen.c
$set 7
1 \n\tTcsh arvab, et teie terminal omab\n
diff --git a/contrib/tcsh/nls/et/set8 b/contrib/tcsh/nls/et/set8
index dd44350..0ac4be4 100644
--- a/contrib/tcsh/nls/et/set8
+++ b/contrib/tcsh/nls/et/set8
@@ -1,4 +1,4 @@
-$ $Id: set8,v 1.1 2001/01/04 18:46:05 christos Exp $
+$ $tcsh: set8,v 1.2 2006/03/02 18:46:45 christos Exp $
$ ed.term.c
$set 8
1 Tundmatu võti
diff --git a/contrib/tcsh/nls/et/set9 b/contrib/tcsh/nls/et/set9
index 877460b..f8e157a 100644
--- a/contrib/tcsh/nls/et/set9
+++ b/contrib/tcsh/nls/et/set9
@@ -1,4 +1,4 @@
-$ $Id: set9,v 1.1 2001/01/04 18:46:05 christos Exp $
+$ $tcsh: set9,v 1.2 2006/03/02 18:46:45 christos Exp $
$ ed.xmap.c
$set 9
1 AddXkey: Null pikkusega laiend-klahv ei ole lubatud.\n
diff --git a/contrib/tcsh/nls/finnish/set1 b/contrib/tcsh/nls/finnish/set1
index c5e61cf..98c89b3 100644
--- a/contrib/tcsh/nls/finnish/set1
+++ b/contrib/tcsh/nls/finnish/set1
@@ -1,4 +1,4 @@
-$ $Id: set1,v 1.2 2001/09/03 02:13:26 kim Exp $
+$ $tcsh: set1,v 1.3 2006/03/02 18:46:46 christos Exp $
$ Error messages
$set 1
1 Kielioppivirhe
diff --git a/contrib/tcsh/nls/finnish/set10 b/contrib/tcsh/nls/finnish/set10
index 5aaae1e..7d1a72e 100644
--- a/contrib/tcsh/nls/finnish/set10
+++ b/contrib/tcsh/nls/finnish/set10
@@ -1,4 +1,4 @@
-$ $Id: set10,v 1.1 2000/01/14 22:57:31 christos Exp $
+$ $tcsh: set10,v 1.2 2006/03/02 18:46:46 christos Exp $
$ ma.setp.c
$set 10
1 setpath: Virheellinen komento '%s'.\n
diff --git a/contrib/tcsh/nls/finnish/set11 b/contrib/tcsh/nls/finnish/set11
index 31e1772..dc1617e 100644
--- a/contrib/tcsh/nls/finnish/set11
+++ b/contrib/tcsh/nls/finnish/set11
@@ -1,4 +1,4 @@
-$ $Id: set11,v 1.1 2000/01/14 22:57:32 christos Exp $
+$ $tcsh: set11,v 1.2 2006/03/02 18:46:46 christos Exp $
$ sh.c
$set 11
1 Varoitus: ei yhteyttä päätteeseen (%s).\n
diff --git a/contrib/tcsh/nls/finnish/set12 b/contrib/tcsh/nls/finnish/set12
index ca4b5b8..87bf07a 100644
--- a/contrib/tcsh/nls/finnish/set12
+++ b/contrib/tcsh/nls/finnish/set12
@@ -1,4 +1,4 @@
-$ $Id: set12,v 1.1 2000/01/14 22:57:32 christos Exp $
+$ $tcsh: set12,v 1.2 2006/03/02 18:46:46 christos Exp $
$ sh.dir.c
$set 12
1 %s: Yritetään käynnistää hakemistosta "%s"\n
diff --git a/contrib/tcsh/nls/finnish/set13 b/contrib/tcsh/nls/finnish/set13
index 66a688a..08a9f4c 100644
--- a/contrib/tcsh/nls/finnish/set13
+++ b/contrib/tcsh/nls/finnish/set13
@@ -1,4 +1,4 @@
-$ $Id: set13,v 1.1 2000/01/14 22:57:32 christos Exp $
+$ $tcsh: set13,v 1.2 2006/03/02 18:46:46 christos Exp $
$ sh.exec.c
$set 13
1 hash=%-4d dir=%-2d prog=%s\n
diff --git a/contrib/tcsh/nls/finnish/set14 b/contrib/tcsh/nls/finnish/set14
index 220bdc4..23fefed 100644
--- a/contrib/tcsh/nls/finnish/set14
+++ b/contrib/tcsh/nls/finnish/set14
@@ -1,4 +1,4 @@
-$ $Id: set14,v 1.2 2003/05/26 07:11:07 christos Exp $
+$ $tcsh: set14,v 1.3 2006/03/02 18:46:46 christos Exp $
$ sh.file.c
$set 14
1 \nAuts!! Liian monta %s!!\n
diff --git a/contrib/tcsh/nls/finnish/set15 b/contrib/tcsh/nls/finnish/set15
index 3312184..684a5dd 100644
--- a/contrib/tcsh/nls/finnish/set15
+++ b/contrib/tcsh/nls/finnish/set15
@@ -1,4 +1,4 @@
-$ $Id: set15,v 1.1 2000/01/14 22:57:32 christos Exp $
+$ $tcsh: set15,v 1.2 2006/03/02 18:46:46 christos Exp $
$ sh.func.c
$set 15
1 %s: %s: rajoitusta ei voida %s %s\n
diff --git a/contrib/tcsh/nls/finnish/set16 b/contrib/tcsh/nls/finnish/set16
index e3d2a03..4a61d02 100644
--- a/contrib/tcsh/nls/finnish/set16
+++ b/contrib/tcsh/nls/finnish/set16
@@ -1,4 +1,4 @@
-$ $Id: set16,v 1.1 2000/01/14 22:57:32 christos Exp $
+$ $tcsh: set16,v 1.2 2006/03/02 18:46:46 christos Exp $
$ sh.lex.c
$set 16
1 Päätteen prosessiryhmä vaihdettu arvosta %d %d:ksi.\n
diff --git a/contrib/tcsh/nls/finnish/set17 b/contrib/tcsh/nls/finnish/set17
index a737f40..4657343 100644
--- a/contrib/tcsh/nls/finnish/set17
+++ b/contrib/tcsh/nls/finnish/set17
@@ -1,4 +1,4 @@
-$ $Id: set17,v 1.2 2003/02/08 20:03:27 christos Exp $
+$ $tcsh: set17,v 1.3 2006/03/02 18:46:46 christos Exp $
$ sh.proc.c
$set 17
1 VIKA: taustatyötä!\n
diff --git a/contrib/tcsh/nls/finnish/set18 b/contrib/tcsh/nls/finnish/set18
index 06a88cb..d29d38d 100644
--- a/contrib/tcsh/nls/finnish/set18
+++ b/contrib/tcsh/nls/finnish/set18
@@ -1,4 +1,4 @@
-$ $Id: set18,v 1.1 2000/01/14 22:57:32 christos Exp $
+$ $tcsh: set18,v 1.2 2006/03/02 18:46:46 christos Exp $
$ sh.set.c
$set 18
1 Varoitus: Kohtuuttoman pitkä hakupolku (PATH) katkaistu.\n
diff --git a/contrib/tcsh/nls/finnish/set19 b/contrib/tcsh/nls/finnish/set19
index ad98544..8e6621f 100644
--- a/contrib/tcsh/nls/finnish/set19
+++ b/contrib/tcsh/nls/finnish/set19
@@ -1,4 +1,4 @@
-$ $Id: set19,v 1.1 2000/01/14 22:57:32 christos Exp $
+$ $tcsh: set19,v 1.2 2006/03/02 18:46:46 christos Exp $
$ tc.alloc.c
$set 19
1 nbytes=%d: Muisti loppu\n
diff --git a/contrib/tcsh/nls/finnish/set2 b/contrib/tcsh/nls/finnish/set2
index 0a306a7..e3bc86e 100644
--- a/contrib/tcsh/nls/finnish/set2
+++ b/contrib/tcsh/nls/finnish/set2
@@ -1,4 +1,4 @@
-$ $Id: set2,v 1.1 2000/01/14 22:57:32 christos Exp $
+$ $tcsh: set2,v 1.2 2006/03/02 18:46:46 christos Exp $
$ Signal names
$set 2
1 Null-signaali
diff --git a/contrib/tcsh/nls/finnish/set20 b/contrib/tcsh/nls/finnish/set20
index 94314db..4bbc86a 100644
--- a/contrib/tcsh/nls/finnish/set20
+++ b/contrib/tcsh/nls/finnish/set20
@@ -1,4 +1,4 @@
-$ $Id: set20,v 1.2 2001/09/03 02:14:04 kim Exp $
+$ $tcsh: set20,v 1.3 2006/03/02 18:46:46 christos Exp $
$ tc.bind.c
$set 20
1 Invalid key name `%S'\n
diff --git a/contrib/tcsh/nls/finnish/set21 b/contrib/tcsh/nls/finnish/set21
index 67fa0c0..7d42da1 100644
--- a/contrib/tcsh/nls/finnish/set21
+++ b/contrib/tcsh/nls/finnish/set21
@@ -1,4 +1,4 @@
-$ $Id: set21,v 1.1 2000/01/14 22:57:32 christos Exp $
+$ $tcsh: set21,v 1.2 2006/03/02 18:46:46 christos Exp $
$ tc.disc.c
$set 21
1 Couldn't get local chars.\n
diff --git a/contrib/tcsh/nls/finnish/set22 b/contrib/tcsh/nls/finnish/set22
index 7008372..f0b3abf 100644
--- a/contrib/tcsh/nls/finnish/set22
+++ b/contrib/tcsh/nls/finnish/set22
@@ -1,4 +1,4 @@
-$ $Id: set22,v 1.2 2001/04/26 19:06:01 kim Exp $
+$ $tcsh: set22,v 1.3 2006/03/02 18:46:46 christos Exp $
$ tc.func.c
$set 22
1 %S: \t on alias komennolle
diff --git a/contrib/tcsh/nls/finnish/set23 b/contrib/tcsh/nls/finnish/set23
index acf4ac1..0bf9797 100644
--- a/contrib/tcsh/nls/finnish/set23
+++ b/contrib/tcsh/nls/finnish/set23
@@ -1,4 +1,4 @@
-$ $Id: set23,v 1.1 2000/01/14 22:57:33 christos Exp $
+$ $tcsh: set23,v 1.2 2006/03/02 18:46:46 christos Exp $
$ tc.os.c
$set 23
1 Virheellinen solmun nimi
diff --git a/contrib/tcsh/nls/finnish/set24 b/contrib/tcsh/nls/finnish/set24
index 2d7904d..23f90fd 100644
--- a/contrib/tcsh/nls/finnish/set24
+++ b/contrib/tcsh/nls/finnish/set24
@@ -1,4 +1,4 @@
-$ $Id: set24,v 1.1 2000/01/14 22:57:33 christos Exp $
+$ $tcsh: set24,v 1.2 2006/03/02 18:46:46 christos Exp $
$ tc.sched.c
$set 24
1 jippo (kludge)
diff --git a/contrib/tcsh/nls/finnish/set25 b/contrib/tcsh/nls/finnish/set25
index 15fecd8..9e6a008 100644
--- a/contrib/tcsh/nls/finnish/set25
+++ b/contrib/tcsh/nls/finnish/set25
@@ -1,4 +1,4 @@
-$ $Id: set25,v 1.1 2000/01/14 22:57:33 christos Exp $
+$ $tcsh: set25,v 1.2 2006/03/02 18:46:46 christos Exp $
$ tc.sig.c
$set 25
1 our wait %d\n
diff --git a/contrib/tcsh/nls/finnish/set26 b/contrib/tcsh/nls/finnish/set26
index 5db9ffd..d20e9f7 100644
--- a/contrib/tcsh/nls/finnish/set26
+++ b/contrib/tcsh/nls/finnish/set26
@@ -1,4 +1,4 @@
-$ $Id: set26,v 1.1 2000/01/14 22:57:33 christos Exp $
+$ $tcsh: set26,v 1.2 2006/03/02 18:46:46 christos Exp $
$ tc.who.c
$set 26
1 Testaaminen ei onnistu: stat(%s). Ole hyvä ja suorita "unset watch".\n
diff --git a/contrib/tcsh/nls/finnish/set27 b/contrib/tcsh/nls/finnish/set27
index a99a18a..decc69a 100644
--- a/contrib/tcsh/nls/finnish/set27
+++ b/contrib/tcsh/nls/finnish/set27
@@ -1,4 +1,4 @@
-$ $Id: set27,v 1.1 2000/01/14 22:57:33 christos Exp $
+$ $tcsh: set27,v 1.2 2006/03/02 18:46:46 christos Exp $
$ tw.comp.c
$set 27
1 komento
diff --git a/contrib/tcsh/nls/finnish/set29 b/contrib/tcsh/nls/finnish/set29
index 65d943d..7ccd214 100644
--- a/contrib/tcsh/nls/finnish/set29
+++ b/contrib/tcsh/nls/finnish/set29
@@ -1,4 +1,4 @@
-$ $Id: set29,v 1.1 2000/01/14 22:57:33 christos Exp $
+$ $tcsh: set29,v 1.2 2006/03/02 18:46:46 christos Exp $
$ tw.help.c
$set 29
1 Ei löydy aputiedostoa komennolle %S\n
diff --git a/contrib/tcsh/nls/finnish/set3 b/contrib/tcsh/nls/finnish/set3
index b880518..3ce02ba 100644
--- a/contrib/tcsh/nls/finnish/set3
+++ b/contrib/tcsh/nls/finnish/set3
@@ -1,4 +1,4 @@
-$ $Id: set3,v 1.2 2001/04/26 19:07:49 kim Exp $
+$ $tcsh: set3,v 1.3 2006/03/02 18:46:46 christos Exp $
$ Editor function descriptions
$set 3
1 Siirry taaksepäin yksi merkki
diff --git a/contrib/tcsh/nls/finnish/set30 b/contrib/tcsh/nls/finnish/set30
index 6f61db5..5e8957b 100644
--- a/contrib/tcsh/nls/finnish/set30
+++ b/contrib/tcsh/nls/finnish/set30
@@ -1,4 +1,4 @@
-$ $Id: set30,v 1.2 2001/04/26 19:06:01 kim Exp $
+$ $tcsh: set30,v 1.3 2006/03/02 18:46:46 christos Exp $
$ tw.parse.c
$set 30
1 starting_a_command %d\n
diff --git a/contrib/tcsh/nls/finnish/set31 b/contrib/tcsh/nls/finnish/set31
index fa97487..e7b1414 100644
--- a/contrib/tcsh/nls/finnish/set31
+++ b/contrib/tcsh/nls/finnish/set31
@@ -1,4 +1,4 @@
-$ $Id: set31,v 1.1 2000/01/14 22:57:33 christos Exp $
+$ $tcsh: set31,v 1.2 2006/03/02 18:46:46 christos Exp $
$ vms.termcap.c
$set 31
1 Can't open TERMCAP: [%s]\n
diff --git a/contrib/tcsh/nls/finnish/set4 b/contrib/tcsh/nls/finnish/set4
index 518fbb1..7a86315 100644
--- a/contrib/tcsh/nls/finnish/set4
+++ b/contrib/tcsh/nls/finnish/set4
@@ -1,4 +1,4 @@
-$ $Id: set4,v 1.1 2000/01/14 22:57:33 christos Exp $
+$ $tcsh: set4,v 1.2 2006/03/02 18:46:46 christos Exp $
$ Termcap strings
$set 4
1 add new blank line
diff --git a/contrib/tcsh/nls/finnish/set5 b/contrib/tcsh/nls/finnish/set5
index 4aeba28..c584aab 100644
--- a/contrib/tcsh/nls/finnish/set5
+++ b/contrib/tcsh/nls/finnish/set5
@@ -1,4 +1,4 @@
-$ $Id: set5,v 1.1 2000/01/14 22:57:33 christos Exp $
+$ $tcsh: set5,v 1.2 2006/03/02 18:46:46 christos Exp $
$ ed.chared.c
$set 5
1 Kuormituskeskiarvoja ei ole saatavilla\n
diff --git a/contrib/tcsh/nls/finnish/set6 b/contrib/tcsh/nls/finnish/set6
index 83ba9ba..f26af6f 100644
--- a/contrib/tcsh/nls/finnish/set6
+++ b/contrib/tcsh/nls/finnish/set6
@@ -1,4 +1,4 @@
-$ $Id: set6,v 1.1 2000/01/14 22:57:34 christos Exp $
+$ $tcsh: set6,v 1.2 2006/03/02 18:46:46 christos Exp $
$ ed.inputl.c
$set 6
1 VIKA: Virheellinen komento näppäimeltä 0%o\r\n
diff --git a/contrib/tcsh/nls/finnish/set7 b/contrib/tcsh/nls/finnish/set7
index 6ac2a2f..954a75e 100644
--- a/contrib/tcsh/nls/finnish/set7
+++ b/contrib/tcsh/nls/finnish/set7
@@ -1,4 +1,4 @@
-$ $Id: set7,v 1.1 2000/01/14 22:57:34 christos Exp $
+$ $tcsh: set7,v 1.2 2006/03/02 18:46:46 christos Exp $
$ ed.screen.c
$set 7
1 \n\tTcsh:n mielestä päätteelläsi on\n
diff --git a/contrib/tcsh/nls/finnish/set8 b/contrib/tcsh/nls/finnish/set8
index abff0ad..ae231a8 100644
--- a/contrib/tcsh/nls/finnish/set8
+++ b/contrib/tcsh/nls/finnish/set8
@@ -1,4 +1,4 @@
-$ $Id: set8,v 1.1 2000/01/14 22:57:34 christos Exp $
+$ $tcsh: set8,v 1.2 2006/03/02 18:46:46 christos Exp $
$ ed.term.c
$set 8
1 Tuntematon valitsin
diff --git a/contrib/tcsh/nls/finnish/set9 b/contrib/tcsh/nls/finnish/set9
index 857dce9..befc4a8 100644
--- a/contrib/tcsh/nls/finnish/set9
+++ b/contrib/tcsh/nls/finnish/set9
@@ -1,4 +1,4 @@
-$ $Id: set9,v 1.1 2000/01/14 22:57:34 christos Exp $
+$ $tcsh: set9,v 1.2 2006/03/02 18:46:46 christos Exp $
$ ed.xmap.c
$set 9
1 AddXkey: Null extended-key not allowed.\n
diff --git a/contrib/tcsh/nls/french/set1 b/contrib/tcsh/nls/french/set1
index 9d8764ac..111cfed 100644
--- a/contrib/tcsh/nls/french/set1
+++ b/contrib/tcsh/nls/french/set1
@@ -1,4 +1,4 @@
-$ $Id: set1,v 1.3 1998/06/27 12:27:57 christos Exp $
+$ $tcsh: set1,v 1.4 2006/03/02 18:46:46 christos Exp $
$ Messages d 'erreur
$set 1
1 Erreur de syntaxe
diff --git a/contrib/tcsh/nls/french/set10 b/contrib/tcsh/nls/french/set10
index 191462a..8df42bd 100644
--- a/contrib/tcsh/nls/french/set10
+++ b/contrib/tcsh/nls/french/set10
@@ -1,4 +1,4 @@
-$ $Id: set10,v 1.1 1995/04/25 14:04:35 christos Exp $
+$ $tcsh: set10,v 1.2 2006/03/02 18:46:46 christos Exp $
$ ma.setp.c
$set 10
1 setpath: commande incorrecte '%s'.\n
diff --git a/contrib/tcsh/nls/french/set11 b/contrib/tcsh/nls/french/set11
index d5c4aa4..1f58163 100644
--- a/contrib/tcsh/nls/french/set11
+++ b/contrib/tcsh/nls/french/set11
@@ -1,4 +1,4 @@
-$ $Id: set11,v 1.2 2003/05/26 07:11:07 christos Exp $
+$ $tcsh: set11,v 1.3 2006/03/02 18:46:46 christos Exp $
$ sh.c
$set 11
1 Attention: pas d'accès au tty (%s).\n
diff --git a/contrib/tcsh/nls/french/set12 b/contrib/tcsh/nls/french/set12
index ccc1396..8b04a6a 100644
--- a/contrib/tcsh/nls/french/set12
+++ b/contrib/tcsh/nls/french/set12
@@ -1,4 +1,4 @@
-$ $Id: set12,v 1.2 1996/04/26 20:45:51 christos Exp $
+$ $tcsh: set12,v 1.3 2006/03/02 18:46:46 christos Exp $
$ sh.dir.c
$set 12
1 %s: Essaie de démarrer à partir de "%s"\n
diff --git a/contrib/tcsh/nls/french/set13 b/contrib/tcsh/nls/french/set13
index aeefa40..fd768ab 100644
--- a/contrib/tcsh/nls/french/set13
+++ b/contrib/tcsh/nls/french/set13
@@ -1,4 +1,4 @@
-$ $Id: set13,v 1.1 1995/04/25 14:04:35 christos Exp $
+$ $tcsh: set13,v 1.2 2006/03/02 18:46:46 christos Exp $
$ sh.exec.c
$set 13
1 hash=%-4d dir=%-2d prog=%s\n
diff --git a/contrib/tcsh/nls/french/set14 b/contrib/tcsh/nls/french/set14
index dd16890..a543a0b 100644
--- a/contrib/tcsh/nls/french/set14
+++ b/contrib/tcsh/nls/french/set14
@@ -1,4 +1,4 @@
-$ $Id: set14,v 1.1 1995/04/25 14:04:35 christos Exp $
+$ $tcsh: set14,v 1.2 2006/03/02 18:46:46 christos Exp $
$ sh.file.c
$set 14
1 \nTrop de %s !!\n
diff --git a/contrib/tcsh/nls/french/set15 b/contrib/tcsh/nls/french/set15
index 4a59b54..9d40044 100644
--- a/contrib/tcsh/nls/french/set15
+++ b/contrib/tcsh/nls/french/set15
@@ -1,4 +1,4 @@
-$ $Id: set15,v 1.1 1995/04/25 14:04:35 christos Exp $
+$ $tcsh: set15,v 1.2 2006/03/02 18:46:46 christos Exp $
$ sh.func.c
$set 15
1 %s: %s: ne peut %s la limite%s\n
diff --git a/contrib/tcsh/nls/french/set16 b/contrib/tcsh/nls/french/set16
index 0ce1081..e5a18c6 100644
--- a/contrib/tcsh/nls/french/set16
+++ b/contrib/tcsh/nls/french/set16
@@ -1,4 +1,4 @@
-$ $Id: set16,v 1.2 1996/04/26 20:45:55 christos Exp $
+$ $tcsh: set16,v 1.3 2006/03/02 18:46:46 christos Exp $
$ sh.lex.c
$set 16
1 Réinitialise le groupe de processus des terminaux de %d à %d\n
diff --git a/contrib/tcsh/nls/french/set17 b/contrib/tcsh/nls/french/set17
index 0f8c66f..ad57470 100644
--- a/contrib/tcsh/nls/french/set17
+++ b/contrib/tcsh/nls/french/set17
@@ -1,4 +1,4 @@
-$ $Id: set17,v 1.3 2003/02/08 20:03:27 christos Exp $
+$ $tcsh: set17,v 1.4 2006/03/02 18:46:46 christos Exp $
$ sh.proc.c
$set 17
1 BUG: attente de travail en tâche de fond !\n
diff --git a/contrib/tcsh/nls/french/set18 b/contrib/tcsh/nls/french/set18
index 0d6c50f..c0caa26 100644
--- a/contrib/tcsh/nls/french/set18
+++ b/contrib/tcsh/nls/french/set18
@@ -1,4 +1,4 @@
-$ $Id: set18,v 1.1 1995/04/25 14:04:35 christos Exp $
+$ $tcsh: set18,v 1.2 2006/03/02 18:46:46 christos Exp $
$ sh.set.c
$set 18
1 Attention: le PATH exagérément long est tronqué\n
diff --git a/contrib/tcsh/nls/french/set19 b/contrib/tcsh/nls/french/set19
index c24da8a..cafc960 100644
--- a/contrib/tcsh/nls/french/set19
+++ b/contrib/tcsh/nls/french/set19
@@ -1,4 +1,4 @@
-$ $Id: set19,v 1.2 1996/04/26 20:45:59 christos Exp $
+$ $tcsh: set19,v 1.3 2006/03/02 18:46:46 christos Exp $
$ tc.alloc.c
$set 19
1 nbytes=%d: Plus de mémoire\n
diff --git a/contrib/tcsh/nls/french/set2 b/contrib/tcsh/nls/french/set2
index e5bf617..c6b0eeb 100644
--- a/contrib/tcsh/nls/french/set2
+++ b/contrib/tcsh/nls/french/set2
@@ -1,4 +1,4 @@
-$ $Id: set2,v 1.2 1997/10/27 23:33:53 christos Exp $
+$ $tcsh: set2,v 1.3 2006/03/02 18:46:46 christos Exp $
$ Messages Signaux
$set 2
1 Signal nul
diff --git a/contrib/tcsh/nls/french/set20 b/contrib/tcsh/nls/french/set20
index 0f26862..2595d06 100644
--- a/contrib/tcsh/nls/french/set20
+++ b/contrib/tcsh/nls/french/set20
@@ -1,4 +1,4 @@
-$ $Id: set20,v 1.1 1995/04/25 14:04:35 christos Exp $
+$ $tcsh: set20,v 1.2 2006/03/02 18:46:46 christos Exp $
$ tc.bind.c
$set 20
1 Nom de touche incorrect `%S'\n
diff --git a/contrib/tcsh/nls/french/set21 b/contrib/tcsh/nls/french/set21
index 78c8c1a..670e9e5 100644
--- a/contrib/tcsh/nls/french/set21
+++ b/contrib/tcsh/nls/french/set21
@@ -1,4 +1,4 @@
-$ $Id: set21,v 1.1 1995/04/25 14:04:35 christos Exp $
+$ $tcsh: set21,v 1.2 2006/03/02 18:46:46 christos Exp $
$ tc.disc.c
$set 21
1 ne peut obtenir les caractères locaux.\n
diff --git a/contrib/tcsh/nls/french/set22 b/contrib/tcsh/nls/french/set22
index 94f4131..c59fe97 100644
--- a/contrib/tcsh/nls/french/set22
+++ b/contrib/tcsh/nls/french/set22
@@ -1,4 +1,4 @@
-$ $Id: set22,v 1.1 1995/04/25 14:04:35 christos Exp $
+$ $tcsh: set22,v 1.2 2006/03/02 18:46:46 christos Exp $
$ tc.func.c
$set 22
1 %S: \t a comme alias
diff --git a/contrib/tcsh/nls/french/set23 b/contrib/tcsh/nls/french/set23
index 187db0f..5fb6339 100644
--- a/contrib/tcsh/nls/french/set23
+++ b/contrib/tcsh/nls/french/set23
@@ -1,4 +1,4 @@
-$ $Id: set23,v 1.2 1996/04/26 20:46:04 christos Exp $
+$ $tcsh: set23,v 1.3 2006/03/02 18:46:46 christos Exp $
$ tc.os.c
$set 23
1 Mauvais nom de cpu/site
diff --git a/contrib/tcsh/nls/french/set24 b/contrib/tcsh/nls/french/set24
index 4c89c35..f97ef1c 100644
--- a/contrib/tcsh/nls/french/set24
+++ b/contrib/tcsh/nls/french/set24
@@ -1,4 +1,4 @@
-$ $Id: set24,v 1.1 1995/04/25 14:04:35 christos Exp $
+$ $tcsh: set24,v 1.2 2006/03/02 18:46:46 christos Exp $
$ tc.sched.c
$set 24
1 kludge
diff --git a/contrib/tcsh/nls/french/set25 b/contrib/tcsh/nls/french/set25
index f5efff5..7bf62ac 100644
--- a/contrib/tcsh/nls/french/set25
+++ b/contrib/tcsh/nls/french/set25
@@ -1,4 +1,4 @@
-$ $Id: set25,v 1.1 1995/04/25 14:04:35 christos Exp $
+$ $tcsh: set25,v 1.2 2006/03/02 18:46:46 christos Exp $
$ tc.sig.c
$set 25
1 notre attente %d\n
diff --git a/contrib/tcsh/nls/french/set26 b/contrib/tcsh/nls/french/set26
index c42cb3c..b5139e7 100644
--- a/contrib/tcsh/nls/french/set26
+++ b/contrib/tcsh/nls/french/set26
@@ -1,4 +1,4 @@
-$ $Id: set26,v 1.1 1995/04/25 14:04:35 christos Exp $
+$ $tcsh: set26,v 1.2 2006/03/02 18:46:46 christos Exp $
$ tc.who.c
$set 26
1 ne peut effectuer stat %s. S.V.P effectuez "unset watch".\n
diff --git a/contrib/tcsh/nls/french/set27 b/contrib/tcsh/nls/french/set27
index 3f29321..e86b26c 100644
--- a/contrib/tcsh/nls/french/set27
+++ b/contrib/tcsh/nls/french/set27
@@ -1,4 +1,4 @@
-$ $Id: set27,v 1.1 1995/04/25 14:04:35 christos Exp $
+$ $tcsh: set27,v 1.2 2006/03/02 18:46:46 christos Exp $
$ tw.comp.c
$set 27
1 commande
diff --git a/contrib/tcsh/nls/french/set29 b/contrib/tcsh/nls/french/set29
index 7309fe4..b90aeae 100644
--- a/contrib/tcsh/nls/french/set29
+++ b/contrib/tcsh/nls/french/set29
@@ -1,4 +1,4 @@
-$ $Id: set29,v 1.1 1995/04/25 14:04:35 christos Exp $
+$ $tcsh: set29,v 1.2 2006/03/02 18:46:46 christos Exp $
$ tw.help.c
$set 29
1 Pas de fichier d'aide pour %S\n
diff --git a/contrib/tcsh/nls/french/set3 b/contrib/tcsh/nls/french/set3
index 7e6c952..797524a 100644
--- a/contrib/tcsh/nls/french/set3
+++ b/contrib/tcsh/nls/french/set3
@@ -1,4 +1,4 @@
-$ $Id: set3,v 1.2 2001/04/26 19:07:49 kim Exp $
+$ $tcsh: set3,v 1.3 2006/03/02 18:46:46 christos Exp $
$ Description des fonctions éditeur
$set 3
1 Recule d'un caractère
diff --git a/contrib/tcsh/nls/french/set30 b/contrib/tcsh/nls/french/set30
index 27ab9c9..e35a39a 100644
--- a/contrib/tcsh/nls/french/set30
+++ b/contrib/tcsh/nls/french/set30
@@ -1,4 +1,4 @@
-$ $Id: set30,v 1.2 1996/04/26 20:46:09 christos Exp $
+$ $tcsh: set30,v 1.3 2006/03/02 18:46:46 christos Exp $
$ tw.parse.c
$set 30
1 démarre une commande %d\n
diff --git a/contrib/tcsh/nls/french/set31 b/contrib/tcsh/nls/french/set31
index 211c5bf..e63d2d4 100644
--- a/contrib/tcsh/nls/french/set31
+++ b/contrib/tcsh/nls/french/set31
@@ -1,4 +1,4 @@
-$ $Id: set31,v 1.1 1995/04/25 14:04:35 christos Exp $
+$ $tcsh: set31,v 1.2 2006/03/02 18:46:46 christos Exp $
$ vms.termcap.c
$set 31
1 Ne peut ouvrir TERMCAP: [%s]\n
diff --git a/contrib/tcsh/nls/french/set4 b/contrib/tcsh/nls/french/set4
index bff6be3..8e63fb1 100644
--- a/contrib/tcsh/nls/french/set4
+++ b/contrib/tcsh/nls/french/set4
@@ -1,4 +1,4 @@
-$ $Id: set4,v 1.1 1995/04/25 14:04:35 christos Exp $
+$ $tcsh: set4,v 1.2 2006/03/02 18:46:46 christos Exp $
$ Termcap strings
$set 4
1 ajoute une nouvelle ligne vide
diff --git a/contrib/tcsh/nls/french/set5 b/contrib/tcsh/nls/french/set5
index d2caaea..edf169c 100644
--- a/contrib/tcsh/nls/french/set5
+++ b/contrib/tcsh/nls/french/set5
@@ -1,4 +1,4 @@
-$ $Id: set5,v 1.1 1995/04/25 14:04:35 christos Exp $
+$ $tcsh: set5,v 1.2 2006/03/02 18:46:46 christos Exp $
$ ed.chared.c
$set 5
1 Charge moyenne indisponible\n
diff --git a/contrib/tcsh/nls/french/set6 b/contrib/tcsh/nls/french/set6
index f766687e..886832e 100644
--- a/contrib/tcsh/nls/french/set6
+++ b/contrib/tcsh/nls/french/set6
@@ -1,4 +1,4 @@
-$ $Id: set6,v 1.1 1995/04/25 14:04:35 christos Exp $
+$ $tcsh: set6,v 1.2 2006/03/02 18:46:46 christos Exp $
$ ed.inputl.c
$set 6
1 ERREUR: commande interdite de la touche 0%o\r\n
diff --git a/contrib/tcsh/nls/french/set7 b/contrib/tcsh/nls/french/set7
index 104eb4b..9971ea6 100644
--- a/contrib/tcsh/nls/french/set7
+++ b/contrib/tcsh/nls/french/set7
@@ -1,4 +1,4 @@
-$ $Id: set7,v 1.2 1996/04/26 20:46:12 christos Exp $
+$ $tcsh: set7,v 1.3 2006/03/02 18:46:46 christos Exp $
$ ed.screen.c
$set 7
1 \n\tTcsh a déterminé que votre terminal a les\n
diff --git a/contrib/tcsh/nls/french/set8 b/contrib/tcsh/nls/french/set8
index 3c089f8..4ab49b9 100644
--- a/contrib/tcsh/nls/french/set8
+++ b/contrib/tcsh/nls/french/set8
@@ -1,4 +1,4 @@
-$ $Id: set8,v 1.1 1995/04/25 14:04:35 christos Exp $
+$ $tcsh: set8,v 1.2 2006/03/02 18:46:46 christos Exp $
$ ed.term.c
$set 8
1 Sélecteur inconnu
diff --git a/contrib/tcsh/nls/french/set9 b/contrib/tcsh/nls/french/set9
index b776d6b..a47cf62 100644
--- a/contrib/tcsh/nls/french/set9
+++ b/contrib/tcsh/nls/french/set9
@@ -1,4 +1,4 @@
-$ $Id: set9,v 1.1 1995/04/25 14:04:35 christos Exp $
+$ $tcsh: set9,v 1.2 2006/03/02 18:46:46 christos Exp $
$ ed.xmap.c
$set 9
1 AddXkey: touche d'extension nulle pas autorisé.\n
diff --git a/contrib/tcsh/nls/german/set1 b/contrib/tcsh/nls/german/set1
index 616e5a1..e6f75ad 100644
--- a/contrib/tcsh/nls/german/set1
+++ b/contrib/tcsh/nls/german/set1
@@ -1,4 +1,4 @@
-$ $Id: set1,v 1.5 1998/06/27 12:27:59 christos Exp $
+$ $tcsh: set1,v 1.6 2006/03/02 18:46:46 christos Exp $
$ Error messages
$set 1
1 Syntaxfehler
diff --git a/contrib/tcsh/nls/german/set10 b/contrib/tcsh/nls/german/set10
index 27f8a66..185aa61 100644
--- a/contrib/tcsh/nls/german/set10
+++ b/contrib/tcsh/nls/german/set10
@@ -1,4 +1,4 @@
-$ $Id: set10,v 1.4 2001/04/26 19:09:18 kim Exp $
+$ $tcsh: set10,v 1.5 2006/03/02 18:46:46 christos Exp $
$ ma.setp.c
$set 10
1 setpath: ungültiger Befehl '%s'.\n
diff --git a/contrib/tcsh/nls/german/set11 b/contrib/tcsh/nls/german/set11
index 793e4d4..603eb51 100644
--- a/contrib/tcsh/nls/german/set11
+++ b/contrib/tcsh/nls/german/set11
@@ -1,4 +1,4 @@
-$ $Id: set11,v 1.4 1996/10/19 17:52:49 christos Exp $
+$ $tcsh: set11,v 1.5 2006/03/02 18:46:46 christos Exp $
$ sh.c
$set 11
1 Warnung: kein Zugriff auf Tty (%s).\n
diff --git a/contrib/tcsh/nls/german/set12 b/contrib/tcsh/nls/german/set12
index fefab67..101b178 100644
--- a/contrib/tcsh/nls/german/set12
+++ b/contrib/tcsh/nls/german/set12
@@ -1,4 +1,4 @@
-$ $Id: set12,v 1.3 1996/04/26 20:54:21 christos Exp $
+$ $tcsh: set12,v 1.4 2006/03/02 18:46:46 christos Exp $
$ sh.dir.c
$set 12
1 %s: Versuche von "%s" zu starten.\n
diff --git a/contrib/tcsh/nls/german/set13 b/contrib/tcsh/nls/german/set13
index e03203a..5da0fd2 100644
--- a/contrib/tcsh/nls/german/set13
+++ b/contrib/tcsh/nls/german/set13
@@ -1,4 +1,4 @@
-$ $Id: set13,v 1.2 1995/03/19 18:09:24 christos Exp $
+$ $tcsh: set13,v 1.3 2006/03/02 18:46:46 christos Exp $
$ sh.exec.c
$set 13
1 hash=%-4d dir=%-2d prog=%s\n
diff --git a/contrib/tcsh/nls/german/set14 b/contrib/tcsh/nls/german/set14
index e882877..e5b65df 100644
--- a/contrib/tcsh/nls/german/set14
+++ b/contrib/tcsh/nls/german/set14
@@ -1,4 +1,4 @@
-$ $Id: set14,v 1.3 1996/10/19 17:52:50 christos Exp $
+$ $tcsh: set14,v 1.4 2006/03/02 18:46:46 christos Exp $
$ sh.file.c
$set 14
1 \nAuweia!! Zu viele %s!!\n
diff --git a/contrib/tcsh/nls/german/set15 b/contrib/tcsh/nls/german/set15
index 3113808..bc215c8 100644
--- a/contrib/tcsh/nls/german/set15
+++ b/contrib/tcsh/nls/german/set15
@@ -1,4 +1,4 @@
-$ $Id: set15,v 1.3 1996/10/19 17:52:51 christos Exp $
+$ $tcsh: set15,v 1.4 2006/03/02 18:46:46 christos Exp $
$ sh.func.c
$set 15
1 %s: %s: Kann Begrenzung nicht %s%s\n
diff --git a/contrib/tcsh/nls/german/set16 b/contrib/tcsh/nls/german/set16
index e43d5a8..bc26108 100644
--- a/contrib/tcsh/nls/german/set16
+++ b/contrib/tcsh/nls/german/set16
@@ -1,4 +1,4 @@
-$ $Id: set16,v 1.2 1995/03/19 18:09:24 christos Exp $
+$ $tcsh: set16,v 1.3 2006/03/02 18:46:46 christos Exp $
$ sh.lex.c
$set 16
1 Setze Prozeßgruppe des Terminals von %d auf %d\n
diff --git a/contrib/tcsh/nls/german/set17 b/contrib/tcsh/nls/german/set17
index 5372392..e00de87 100644
--- a/contrib/tcsh/nls/german/set17
+++ b/contrib/tcsh/nls/german/set17
@@ -1,4 +1,4 @@
-$ $Id: set17,v 1.4 2003/02/08 20:03:27 christos Exp $
+$ $tcsh: set17,v 1.5 2006/03/02 18:46:46 christos Exp $
$ sh.proc.c
$set 17
1 FEHLER: Warte auf Hintergrund-Job!\n
diff --git a/contrib/tcsh/nls/german/set18 b/contrib/tcsh/nls/german/set18
index 016e670..40e56d8 100644
--- a/contrib/tcsh/nls/german/set18
+++ b/contrib/tcsh/nls/german/set18
@@ -1,4 +1,4 @@
-$ $Id: set18,v 1.2 1995/03/19 18:09:24 christos Exp $
+$ $tcsh: set18,v 1.3 2006/03/02 18:46:46 christos Exp $
$ sh.set.c
$set 18
1 Warnung: lächerlich langer PATH abgeschnitten\n
diff --git a/contrib/tcsh/nls/german/set19 b/contrib/tcsh/nls/german/set19
index 376ce30..d852451 100644
--- a/contrib/tcsh/nls/german/set19
+++ b/contrib/tcsh/nls/german/set19
@@ -1,4 +1,4 @@
-$ $Id: set19,v 1.2 1995/03/19 18:09:24 christos Exp $
+$ $tcsh: set19,v 1.3 2006/03/02 18:46:46 christos Exp $
$ tc.alloc.c
$set 19
1 nbytes=%d: Out of memory\n
diff --git a/contrib/tcsh/nls/german/set2 b/contrib/tcsh/nls/german/set2
index 08af0c7..6f36bc6 100644
--- a/contrib/tcsh/nls/german/set2
+++ b/contrib/tcsh/nls/german/set2
@@ -1,4 +1,4 @@
-$ $Id: set2,v 1.4 1997/10/27 23:33:55 christos Exp $
+$ $tcsh: set2,v 1.5 2006/03/02 18:46:46 christos Exp $
$ Signal names
$set 2
1 Null signal
diff --git a/contrib/tcsh/nls/german/set20 b/contrib/tcsh/nls/german/set20
index 8773671..638c00e 100644
--- a/contrib/tcsh/nls/german/set20
+++ b/contrib/tcsh/nls/german/set20
@@ -1,4 +1,4 @@
-$ $Id: set20,v 1.2 1995/03/19 18:09:24 christos Exp $
+$ $tcsh: set20,v 1.3 2006/03/02 18:46:46 christos Exp $
$ tc.bind.c
$set 20
1 Ungültiger Tastenname `%S'\n
diff --git a/contrib/tcsh/nls/german/set21 b/contrib/tcsh/nls/german/set21
index 509887f..32a2774 100644
--- a/contrib/tcsh/nls/german/set21
+++ b/contrib/tcsh/nls/german/set21
@@ -1,4 +1,4 @@
-$ $Id: set21,v 1.2 1995/03/19 18:09:24 christos Exp $
+$ $tcsh: set21,v 1.3 2006/03/02 18:46:46 christos Exp $
$ tc.disc.c
$set 21
1 Kann lokale Sonderzeichen nicht auslesen.\n
diff --git a/contrib/tcsh/nls/german/set22 b/contrib/tcsh/nls/german/set22
index d7521bd..0e93b38 100644
--- a/contrib/tcsh/nls/german/set22
+++ b/contrib/tcsh/nls/german/set22
@@ -1,4 +1,4 @@
-$ $Id: set22,v 1.2 1995/03/19 18:09:24 christos Exp $
+$ $tcsh: set22,v 1.3 2006/03/02 18:46:46 christos Exp $
$ tc.func.c
$set 22
1 %S: \t ein Alias für
diff --git a/contrib/tcsh/nls/german/set23 b/contrib/tcsh/nls/german/set23
index f2bd825..42a9cbd 100644
--- a/contrib/tcsh/nls/german/set23
+++ b/contrib/tcsh/nls/german/set23
@@ -1,4 +1,4 @@
-$ $Id: set23,v 1.3 1996/04/26 20:54:22 christos Exp $
+$ $tcsh: set23,v 1.4 2006/03/02 18:46:46 christos Exp $
$ tc.os.c
$set 23
1 Falscher Cpu/Site-Name
diff --git a/contrib/tcsh/nls/german/set24 b/contrib/tcsh/nls/german/set24
index 96ecbb4..dee8054 100644
--- a/contrib/tcsh/nls/german/set24
+++ b/contrib/tcsh/nls/german/set24
@@ -1,4 +1,4 @@
-$ $Id: set24,v 1.2 1995/03/19 18:09:24 christos Exp $
+$ $tcsh: set24,v 1.3 2006/03/02 18:46:46 christos Exp $
$ tc.sched.c
$set 24
1 Hack!
diff --git a/contrib/tcsh/nls/german/set25 b/contrib/tcsh/nls/german/set25
index 443104a..a034603 100644
--- a/contrib/tcsh/nls/german/set25
+++ b/contrib/tcsh/nls/german/set25
@@ -1,4 +1,4 @@
-$ $Id: set25,v 1.2 1995/03/19 18:09:24 christos Exp $
+$ $tcsh: set25,v 1.3 2006/03/02 18:46:46 christos Exp $
$ tc.sig.c
$set 25
1 unser wait %d\n
diff --git a/contrib/tcsh/nls/german/set26 b/contrib/tcsh/nls/german/set26
index 548b534..c9d1270 100644
--- a/contrib/tcsh/nls/german/set26
+++ b/contrib/tcsh/nls/german/set26
@@ -1,4 +1,4 @@
-$ $Id: set26,v 1.3 1996/10/19 17:52:52 christos Exp $
+$ $tcsh: set26,v 1.4 2006/03/02 18:46:46 christos Exp $
$ tc.who.c
$set 26
1 Kein Zugriff auf %s. Bitte "unset watch" eingeben.\n
diff --git a/contrib/tcsh/nls/german/set27 b/contrib/tcsh/nls/german/set27
index d5a6460..9ad802f 100644
--- a/contrib/tcsh/nls/german/set27
+++ b/contrib/tcsh/nls/german/set27
@@ -1,4 +1,4 @@
-$ $Id: set27,v 1.2 1995/03/19 18:09:24 christos Exp $
+$ $tcsh: set27,v 1.3 2006/03/02 18:46:46 christos Exp $
$ tw.comp.c
$set 27
1 Befehl
diff --git a/contrib/tcsh/nls/german/set29 b/contrib/tcsh/nls/german/set29
index 490b532..16ef38a 100644
--- a/contrib/tcsh/nls/german/set29
+++ b/contrib/tcsh/nls/german/set29
@@ -1,4 +1,4 @@
-$ $Id: set29,v 1.2 1995/03/19 18:09:24 christos Exp $
+$ $tcsh: set29,v 1.3 2006/03/02 18:46:46 christos Exp $
$ tw.help.c
$set 29
1 Keine Hilfe-Datei für %S\n
diff --git a/contrib/tcsh/nls/german/set3 b/contrib/tcsh/nls/german/set3
index 4368818..f2b642c 100644
--- a/contrib/tcsh/nls/german/set3
+++ b/contrib/tcsh/nls/german/set3
@@ -1,4 +1,4 @@
-$ $Id: set3,v 1.5 2001/04/26 19:07:50 kim Exp $
+$ $tcsh: set3,v 1.6 2006/03/02 18:46:46 christos Exp $
$ Editor function descriptions
$set 3
1 Ein Zeichen zurück
diff --git a/contrib/tcsh/nls/german/set30 b/contrib/tcsh/nls/german/set30
index 0657670..534886e 100644
--- a/contrib/tcsh/nls/german/set30
+++ b/contrib/tcsh/nls/german/set30
@@ -1,4 +1,4 @@
-$ $Id: set30,v 1.3 1996/04/26 20:54:24 christos Exp $
+$ $tcsh: set30,v 1.4 2006/03/02 18:46:46 christos Exp $
$ tw.parse.c
$set 30
1 Anfangsbefehl %d\n
diff --git a/contrib/tcsh/nls/german/set31 b/contrib/tcsh/nls/german/set31
index 88f3dcc..9532256 100644
--- a/contrib/tcsh/nls/german/set31
+++ b/contrib/tcsh/nls/german/set31
@@ -1,4 +1,4 @@
-$ $Id: set31,v 1.2 1995/03/19 18:09:24 christos Exp $
+$ $tcsh: set31,v 1.3 2006/03/02 18:46:46 christos Exp $
$ vms.termcap.c
$set 31
1 Kann TERMCAP nicht öffnen: [%s]\n
diff --git a/contrib/tcsh/nls/german/set4 b/contrib/tcsh/nls/german/set4
index c11e712..baee552 100644
--- a/contrib/tcsh/nls/german/set4
+++ b/contrib/tcsh/nls/german/set4
@@ -1,4 +1,4 @@
-$ $Id: set4,v 1.2 1995/03/19 18:09:24 christos Exp $
+$ $tcsh: set4,v 1.3 2006/03/02 18:46:46 christos Exp $
$ Termcap strings
$set 4
1 füge neue, leere Zeile hinzu
diff --git a/contrib/tcsh/nls/german/set5 b/contrib/tcsh/nls/german/set5
index 195c72e..2161749 100644
--- a/contrib/tcsh/nls/german/set5
+++ b/contrib/tcsh/nls/german/set5
@@ -1,4 +1,4 @@
-$ $Id: set5,v 1.2 1995/03/19 18:09:24 christos Exp $
+$ $tcsh: set5,v 1.3 2006/03/02 18:46:46 christos Exp $
$ ed.chared.c
$set 5
1 Durchschnittliche Last nicht verfügbar\n
diff --git a/contrib/tcsh/nls/german/set6 b/contrib/tcsh/nls/german/set6
index df99266..350b1d0 100644
--- a/contrib/tcsh/nls/german/set6
+++ b/contrib/tcsh/nls/german/set6
@@ -1,4 +1,4 @@
-$ $Id: set6,v 1.2 1995/03/19 18:09:24 christos Exp $
+$ $tcsh: set6,v 1.3 2006/03/02 18:46:46 christos Exp $
$ ed.inputl.c
$set 6
1 FEHLER: Illegaler Befehl von Taste 0%o\r\n
diff --git a/contrib/tcsh/nls/german/set7 b/contrib/tcsh/nls/german/set7
index 188bf64..8aee38d 100644
--- a/contrib/tcsh/nls/german/set7
+++ b/contrib/tcsh/nls/german/set7
@@ -1,4 +1,4 @@
-$ $Id: set7,v 1.4 1996/10/19 17:52:53 christos Exp $
+$ $tcsh: set7,v 1.5 2006/03/02 18:46:46 christos Exp $
$ ed.screen.c
$set 7
1 \n\tTcsh meint, Ihr Endgerät hat die\n
diff --git a/contrib/tcsh/nls/german/set8 b/contrib/tcsh/nls/german/set8
index ba7f030..4e09b22 100644
--- a/contrib/tcsh/nls/german/set8
+++ b/contrib/tcsh/nls/german/set8
@@ -1,4 +1,4 @@
-$ $Id: set8,v 1.2 1995/03/19 18:09:24 christos Exp $
+$ $tcsh: set8,v 1.3 2006/03/02 18:46:46 christos Exp $
$ ed.term.c
$set 8
1 Unbekannter Schalter
diff --git a/contrib/tcsh/nls/german/set9 b/contrib/tcsh/nls/german/set9
index b987d11..e8607a3 100644
--- a/contrib/tcsh/nls/german/set9
+++ b/contrib/tcsh/nls/german/set9
@@ -1,4 +1,4 @@
-$ $Id: set9,v 1.3 1996/10/19 17:52:54 christos Exp $
+$ $tcsh: set9,v 1.4 2006/03/02 18:46:46 christos Exp $
$ ed.xmap.c
$set 9
1 AddXkey: Null extended-key not allowed.\n
diff --git a/contrib/tcsh/nls/greek/set1 b/contrib/tcsh/nls/greek/set1
index 17c8573..3599c34 100644
--- a/contrib/tcsh/nls/greek/set1
+++ b/contrib/tcsh/nls/greek/set1
@@ -1,4 +1,4 @@
-$ $Id: set1,v 1.3 1998/09/18 15:31:57 christos Exp $
+$ $tcsh: set1,v 1.4 2006/03/02 18:46:46 christos Exp $
$ Error messages
$set 1
1 ËÜèïò óýíôáîç
diff --git a/contrib/tcsh/nls/greek/set10 b/contrib/tcsh/nls/greek/set10
index 33a00de..a215d49 100644
--- a/contrib/tcsh/nls/greek/set10
+++ b/contrib/tcsh/nls/greek/set10
@@ -1,4 +1,4 @@
-$ $Id: set10,v 1.2 1998/09/18 15:31:58 christos Exp $
+$ $tcsh: set10,v 1.3 2006/03/02 18:46:46 christos Exp $
$ ma.setp.c
$set 10
1 setpath: Üêõñç åíôïëÞ '%s'.\n
diff --git a/contrib/tcsh/nls/greek/set11 b/contrib/tcsh/nls/greek/set11
index 1ab3951..82c1888 100644
--- a/contrib/tcsh/nls/greek/set11
+++ b/contrib/tcsh/nls/greek/set11
@@ -1,4 +1,4 @@
-$ $Id: set11,v 1.1 1996/04/26 19:24:11 christos Exp $
+$ $tcsh: set11,v 1.2 2006/03/02 18:46:46 christos Exp $
$ sh.c
$set 11
1 Ðñïåéäïðïßçóç: äåí ìðïñþ íá ðñïóðåëÜóù ôï tty (%s).\n
diff --git a/contrib/tcsh/nls/greek/set12 b/contrib/tcsh/nls/greek/set12
index 09cfdc6..379ae78 100644
--- a/contrib/tcsh/nls/greek/set12
+++ b/contrib/tcsh/nls/greek/set12
@@ -1,4 +1,4 @@
-$ $Id: set12,v 1.2 1998/09/18 15:31:59 christos Exp $
+$ $tcsh: set12,v 1.3 2006/03/02 18:46:46 christos Exp $
$ sh.dir.c
$set 12
1 %s: ðñïóðáèþ íá áñ÷ßóù áðü ôï "%s"\n
diff --git a/contrib/tcsh/nls/greek/set13 b/contrib/tcsh/nls/greek/set13
index 6e6963a..9ec55e1 100644
--- a/contrib/tcsh/nls/greek/set13
+++ b/contrib/tcsh/nls/greek/set13
@@ -1,4 +1,4 @@
-$ $Id: set13,v 1.1 1996/04/26 19:24:15 christos Exp $
+$ $tcsh: set13,v 1.2 2006/03/02 18:46:46 christos Exp $
$ sh.exec.c
$set 13
1 hash=%-4d dir=%-2d prog=%s\n
diff --git a/contrib/tcsh/nls/greek/set14 b/contrib/tcsh/nls/greek/set14
index 282f639..0547940 100644
--- a/contrib/tcsh/nls/greek/set14
+++ b/contrib/tcsh/nls/greek/set14
@@ -1,4 +1,4 @@
-$ $Id: set14,v 1.2 1998/11/24 18:18:11 christos Exp $
+$ $tcsh: set14,v 1.3 2006/03/02 18:46:46 christos Exp $
$ sh.file.c
$set 14
1 \nÐööö!! ÕðåñâïëéêÜ ðïëëÜ %s!!\n
diff --git a/contrib/tcsh/nls/greek/set15 b/contrib/tcsh/nls/greek/set15
index f92fef4..ff17a6e 100644
--- a/contrib/tcsh/nls/greek/set15
+++ b/contrib/tcsh/nls/greek/set15
@@ -1,4 +1,4 @@
-$ $Id: set15,v 1.1 1996/04/26 19:24:18 christos Exp $
+$ $tcsh: set15,v 1.2 2006/03/02 18:46:46 christos Exp $
$ sh.func.c
$set 15
1 %s: %s: äå ìðïñþ íá %sôï%s üñéï\n
diff --git a/contrib/tcsh/nls/greek/set16 b/contrib/tcsh/nls/greek/set16
index 18d92e2..e4dcca8 100644
--- a/contrib/tcsh/nls/greek/set16
+++ b/contrib/tcsh/nls/greek/set16
@@ -1,4 +1,4 @@
-$ $Id: set16,v 1.2 1998/09/18 15:32:00 christos Exp $
+$ $tcsh: set16,v 1.3 2006/03/02 18:46:46 christos Exp $
$ sh.lex.c
$set 16
1 Ìçäåíéóìüò ôïõ ãêñïõð äéåñãáóéþí ôïõ tty áðü %d óå %d\n
diff --git a/contrib/tcsh/nls/greek/set17 b/contrib/tcsh/nls/greek/set17
index 9a6c9d1..4ac0106 100644
--- a/contrib/tcsh/nls/greek/set17
+++ b/contrib/tcsh/nls/greek/set17
@@ -1,4 +1,4 @@
-$ $Id: set17,v 1.2 2003/02/08 20:03:27 christos Exp $
+$ $tcsh: set17,v 1.3 2006/03/02 18:46:46 christos Exp $
$ sh.proc.c
$set 17
1 BUG: wait ãéÜ åñãáóßá ðïõ ôñÝ÷åé óôï ðáñáóêÞíéï!\n
diff --git a/contrib/tcsh/nls/greek/set18 b/contrib/tcsh/nls/greek/set18
index ad0a5e6..ffd82b6 100644
--- a/contrib/tcsh/nls/greek/set18
+++ b/contrib/tcsh/nls/greek/set18
@@ -1,4 +1,4 @@
-$ $Id: set18,v 1.1 1996/04/26 19:24:26 christos Exp $
+$ $tcsh: set18,v 1.2 2006/03/02 18:46:46 christos Exp $
$ sh.set.c
$set 18
1 Ðñïåéäïðïßçóç: PATH ìå ôåñÜóôéï ìÝãåèïò, ðåñéêüðçêå\n
diff --git a/contrib/tcsh/nls/greek/set19 b/contrib/tcsh/nls/greek/set19
index e1d1520..718b43f 100644
--- a/contrib/tcsh/nls/greek/set19
+++ b/contrib/tcsh/nls/greek/set19
@@ -1,4 +1,4 @@
-$ $Id: set19,v 1.1 1996/04/26 19:24:27 christos Exp $
+$ $tcsh: set19,v 1.2 2006/03/02 18:46:46 christos Exp $
$ tc.alloc.c
$set 19
1 nbytes=%d: ç ìíÞìç ôåëåßùóå\n
diff --git a/contrib/tcsh/nls/greek/set2 b/contrib/tcsh/nls/greek/set2
index 35a14b2..d54db2f 100644
--- a/contrib/tcsh/nls/greek/set2
+++ b/contrib/tcsh/nls/greek/set2
@@ -1,4 +1,4 @@
-$ $Id: set2,v 1.2 1997/10/27 23:33:56 christos Exp $
+$ $tcsh: set2,v 1.3 2006/03/02 18:46:46 christos Exp $
$ Signal names
$set 2
1 Ìçäåíéêü signal
diff --git a/contrib/tcsh/nls/greek/set20 b/contrib/tcsh/nls/greek/set20
index 9ff678d..077a3a0 100644
--- a/contrib/tcsh/nls/greek/set20
+++ b/contrib/tcsh/nls/greek/set20
@@ -1,4 +1,4 @@
-$ $Id: set20,v 1.3 1998/09/18 15:32:01 christos Exp $
+$ $tcsh: set20,v 1.4 2006/03/02 18:46:46 christos Exp $
$ tc.bind.c
$set 20
1 Áêõñï üíïìá ðëÞêôñïõ `%S'\n
diff --git a/contrib/tcsh/nls/greek/set21 b/contrib/tcsh/nls/greek/set21
index 0e2933f..3ef206b 100644
--- a/contrib/tcsh/nls/greek/set21
+++ b/contrib/tcsh/nls/greek/set21
@@ -1,4 +1,4 @@
-$ $Id: set21,v 1.1 1996/04/26 19:24:32 christos Exp $
+$ $tcsh: set21,v 1.2 2006/03/02 18:46:46 christos Exp $
$ tc.disc.c
$set 21
1 Äå ìðïñþ íá äéáâÜóù ôá local chars.\n
diff --git a/contrib/tcsh/nls/greek/set22 b/contrib/tcsh/nls/greek/set22
index 70d389a..2395031 100644
--- a/contrib/tcsh/nls/greek/set22
+++ b/contrib/tcsh/nls/greek/set22
@@ -1,4 +1,4 @@
-$ $Id: set22,v 1.1 1996/04/26 19:24:35 christos Exp $
+$ $tcsh: set22,v 1.2 2006/03/02 18:46:46 christos Exp $
$ tc.func.c
$set 22
1 %S: \t øåõäþíõìï ãéÜ ôï
diff --git a/contrib/tcsh/nls/greek/set23 b/contrib/tcsh/nls/greek/set23
index 4fb2998..813c2b1 100644
--- a/contrib/tcsh/nls/greek/set23
+++ b/contrib/tcsh/nls/greek/set23
@@ -1,4 +1,4 @@
-$ $Id: set23,v 1.2 1998/09/18 15:32:02 christos Exp $
+$ $tcsh: set23,v 1.3 2006/03/02 18:46:46 christos Exp $
$ tc.os.c
$set 23
1 Áêõñï üíïìá cpu/site
diff --git a/contrib/tcsh/nls/greek/set24 b/contrib/tcsh/nls/greek/set24
index f1a811b..f97ef1c 100644
--- a/contrib/tcsh/nls/greek/set24
+++ b/contrib/tcsh/nls/greek/set24
@@ -1,4 +1,4 @@
-$ $Id: set24,v 1.1 1996/04/26 19:24:44 christos Exp $
+$ $tcsh: set24,v 1.2 2006/03/02 18:46:46 christos Exp $
$ tc.sched.c
$set 24
1 kludge
diff --git a/contrib/tcsh/nls/greek/set25 b/contrib/tcsh/nls/greek/set25
index 316c20f..406d710 100644
--- a/contrib/tcsh/nls/greek/set25
+++ b/contrib/tcsh/nls/greek/set25
@@ -1,4 +1,4 @@
-$ $Id: set25,v 1.1 1996/04/26 19:24:47 christos Exp $
+$ $tcsh: set25,v 1.2 2006/03/02 18:46:46 christos Exp $
$ tc.sig.c
$set 25
1 our wait %d\n
diff --git a/contrib/tcsh/nls/greek/set26 b/contrib/tcsh/nls/greek/set26
index 4449a65..d081bbc 100644
--- a/contrib/tcsh/nls/greek/set26
+++ b/contrib/tcsh/nls/greek/set26
@@ -1,4 +1,4 @@
-$ $Id: set26,v 1.2 1998/09/18 15:32:02 christos Exp $
+$ $tcsh: set26,v 1.3 2006/03/02 18:46:46 christos Exp $
$ tc.who.c
$set 26
1 äå ìðïñþ íá êÜíù stat ôï %s. Ðáñáêáëþ äþóôå "unset watch".\n
diff --git a/contrib/tcsh/nls/greek/set27 b/contrib/tcsh/nls/greek/set27
index fba4644..4e91416 100644
--- a/contrib/tcsh/nls/greek/set27
+++ b/contrib/tcsh/nls/greek/set27
@@ -1,4 +1,4 @@
-$ $Id: set27,v 1.1 1996/04/26 19:24:51 christos Exp $
+$ $tcsh: set27,v 1.2 2006/03/02 18:46:46 christos Exp $
$ tw.comp.c
$set 27
1 åíôïëÞ
diff --git a/contrib/tcsh/nls/greek/set29 b/contrib/tcsh/nls/greek/set29
index 6f30288..cf0b9eb 100644
--- a/contrib/tcsh/nls/greek/set29
+++ b/contrib/tcsh/nls/greek/set29
@@ -1,4 +1,4 @@
-$ $Id: set29,v 1.1 1996/04/26 19:24:55 christos Exp $
+$ $tcsh: set29,v 1.2 2006/03/02 18:46:46 christos Exp $
$ tw.help.c
$set 29
1 Äåí õðÜñ÷åé áñ÷åßï ìå âïÞèåéá ãéÜ ôï %S\n
diff --git a/contrib/tcsh/nls/greek/set3 b/contrib/tcsh/nls/greek/set3
index 3a3f56a..b66cc1a 100644
--- a/contrib/tcsh/nls/greek/set3
+++ b/contrib/tcsh/nls/greek/set3
@@ -1,4 +1,4 @@
-$ $Id: set3,v 1.3 2001/04/26 19:07:50 kim Exp $
+$ $tcsh: set3,v 1.4 2006/03/02 18:46:46 christos Exp $
$ Editor function descriptions
$set 3
1 Ìåôáêßíçóç Ýíá ÷áñáêôÞñá üðéóèåí
diff --git a/contrib/tcsh/nls/greek/set30 b/contrib/tcsh/nls/greek/set30
index 121cfc3..473f331 100644
--- a/contrib/tcsh/nls/greek/set30
+++ b/contrib/tcsh/nls/greek/set30
@@ -1,4 +1,4 @@
-$ $Id: set30,v 1.1 1996/04/26 19:25:06 christos Exp $
+$ $tcsh: set30,v 1.2 2006/03/02 18:46:46 christos Exp $
$ tw.parse.c
$set 30
1 starting_a_command %d\n
diff --git a/contrib/tcsh/nls/greek/set31 b/contrib/tcsh/nls/greek/set31
index 95f3e0d..d23de88 100644
--- a/contrib/tcsh/nls/greek/set31
+++ b/contrib/tcsh/nls/greek/set31
@@ -1,4 +1,4 @@
-$ $Id: set31,v 1.1 1996/04/26 19:25:15 christos Exp $
+$ $tcsh: set31,v 1.2 2006/03/02 18:46:47 christos Exp $
$ vms.termcap.c
$set 31
1 Äå ìðïñþ íá áíïßîù ôï TERMCAP: [%s]\n
diff --git a/contrib/tcsh/nls/greek/set4 b/contrib/tcsh/nls/greek/set4
index b982ed1..84fbc92 100644
--- a/contrib/tcsh/nls/greek/set4
+++ b/contrib/tcsh/nls/greek/set4
@@ -1,4 +1,4 @@
-$ $Id: set4,v 1.2 1998/09/18 15:32:04 christos Exp $
+$ $tcsh: set4,v 1.3 2006/03/02 18:46:47 christos Exp $
$ Termcap strings
$set 4
1 ðñüóèåóç íÝáò êåíÞò ãñáììÞò
diff --git a/contrib/tcsh/nls/greek/set5 b/contrib/tcsh/nls/greek/set5
index 6d4834b..1125e85 100644
--- a/contrib/tcsh/nls/greek/set5
+++ b/contrib/tcsh/nls/greek/set5
@@ -1,4 +1,4 @@
-$ $Id: set5,v 1.1 1996/04/26 19:25:27 christos Exp $
+$ $tcsh: set5,v 1.2 2006/03/02 18:46:47 christos Exp $
$ ed.chared.c
$set 5
1 Ï ìÝóïò üñïò öïñôßïõ äåí åßíáé äéáèÝóéìïò\n
diff --git a/contrib/tcsh/nls/greek/set6 b/contrib/tcsh/nls/greek/set6
index 8d6da29..0a494c1 100644
--- a/contrib/tcsh/nls/greek/set6
+++ b/contrib/tcsh/nls/greek/set6
@@ -1,4 +1,4 @@
-$ $Id: set6,v 1.1 1996/04/26 19:25:29 christos Exp $
+$ $tcsh: set6,v 1.2 2006/03/02 18:46:47 christos Exp $
$ ed.inputl.c
$set 6
1 ÓÖÁËÌÁ: Üêõñç åíôïëÞ áðï ôï ðëÞêôñï 0%o\r\n
diff --git a/contrib/tcsh/nls/greek/set7 b/contrib/tcsh/nls/greek/set7
index 4eea77f..b88d2ff 100644
--- a/contrib/tcsh/nls/greek/set7
+++ b/contrib/tcsh/nls/greek/set7
@@ -1,4 +1,4 @@
-$ $Id: set7,v 1.2 1998/09/18 15:32:05 christos Exp $
+$ $tcsh: set7,v 1.3 2006/03/02 18:46:47 christos Exp $
$ ed.screen.c
$set 7
1 \n\tÔï %s îÝñåé ãéÜ ôï ôåñìáôéêü óáò ôá\n
diff --git a/contrib/tcsh/nls/greek/set8 b/contrib/tcsh/nls/greek/set8
index 376a8cd..23fb6c8 100644
--- a/contrib/tcsh/nls/greek/set8
+++ b/contrib/tcsh/nls/greek/set8
@@ -1,4 +1,4 @@
-$ $Id: set8,v 1.1 1996/04/26 19:25:32 christos Exp $
+$ $tcsh: set8,v 1.2 2006/03/02 18:46:47 christos Exp $
$ ed.term.c
$set 8
1 Áãíùóôï switch
diff --git a/contrib/tcsh/nls/greek/set9 b/contrib/tcsh/nls/greek/set9
index 1ec0731..9ed5f7c 100644
--- a/contrib/tcsh/nls/greek/set9
+++ b/contrib/tcsh/nls/greek/set9
@@ -1,4 +1,4 @@
-$ $Id: set9,v 1.2 1998/09/18 15:32:06 christos Exp $
+$ $tcsh: set9,v 1.3 2006/03/02 18:46:47 christos Exp $
$ ed.xmap.c
$set 9
1 AddXkey: äåí åðéôñÝðåôáé ìçäåíéêü extended-key.\n
diff --git a/contrib/tcsh/nls/italian/set1 b/contrib/tcsh/nls/italian/set1
index 0f772ec..de09941 100644
--- a/contrib/tcsh/nls/italian/set1
+++ b/contrib/tcsh/nls/italian/set1
@@ -1,4 +1,4 @@
-$ $Id: set1,v 1.1 1998/09/03 22:03:13 christos Exp $
+$ $tcsh: set1,v 1.2 2006/03/02 18:46:47 christos Exp $
$ Error messages
$set 1
1 Errore di Sintassi
diff --git a/contrib/tcsh/nls/italian/set10 b/contrib/tcsh/nls/italian/set10
index 1fcda24..531565b 100644
--- a/contrib/tcsh/nls/italian/set10
+++ b/contrib/tcsh/nls/italian/set10
@@ -1,4 +1,4 @@
-$ $Id: set10,v 1.1 1998/09/03 22:03:14 christos Exp $
+$ $tcsh: set10,v 1.2 2006/03/02 18:46:47 christos Exp $
$ ma.setp.c
$set 10
1 setpath: comando '%s' non valido.\n
diff --git a/contrib/tcsh/nls/italian/set11 b/contrib/tcsh/nls/italian/set11
index a558b2c..70a5192 100644
--- a/contrib/tcsh/nls/italian/set11
+++ b/contrib/tcsh/nls/italian/set11
@@ -1,4 +1,4 @@
-$ $Id: set11,v 1.1 1998/09/03 22:03:14 christos Exp $
+$ $tcsh: set11,v 1.2 2006/03/02 18:46:47 christos Exp $
$ sh.c
$set 11
1 Attenzione: accesso negato al terminale (%s).\n
diff --git a/contrib/tcsh/nls/italian/set12 b/contrib/tcsh/nls/italian/set12
index f07486b..5a3c19b 100644
--- a/contrib/tcsh/nls/italian/set12
+++ b/contrib/tcsh/nls/italian/set12
@@ -1,4 +1,4 @@
-$ $Id: set12,v 1.1 1998/09/03 22:03:16 christos Exp $
+$ $tcsh: set12,v 1.2 2006/03/02 18:46:47 christos Exp $
$ sh.dir.c
$set 12
1 %s: sto tentando di partire da "%s"\n
diff --git a/contrib/tcsh/nls/italian/set13 b/contrib/tcsh/nls/italian/set13
index 65b46bb..ed5f797 100644
--- a/contrib/tcsh/nls/italian/set13
+++ b/contrib/tcsh/nls/italian/set13
@@ -1,4 +1,4 @@
-$ $Id: set13,v 1.1 1998/09/03 22:03:17 christos Exp $
+$ $tcsh: set13,v 1.2 2006/03/02 18:46:47 christos Exp $
$ sh.exec.c
$set 13
1 hash=%-4d dir=%-2d prog=%s\n
diff --git a/contrib/tcsh/nls/italian/set14 b/contrib/tcsh/nls/italian/set14
index 0c95390..a3b3bc2 100644
--- a/contrib/tcsh/nls/italian/set14
+++ b/contrib/tcsh/nls/italian/set14
@@ -1,4 +1,4 @@
-$ $Id: set14,v 1.1 1998/09/03 22:03:18 christos Exp $
+$ $tcsh: set14,v 1.2 2006/03/02 18:46:47 christos Exp $
$ sh.file.c
$set 14
1 \nAccipicchia!! Troppi %s!!\n
diff --git a/contrib/tcsh/nls/italian/set15 b/contrib/tcsh/nls/italian/set15
index 8ed2234..3db0bc3 100644
--- a/contrib/tcsh/nls/italian/set15
+++ b/contrib/tcsh/nls/italian/set15
@@ -1,4 +1,4 @@
-$ $Id: set15,v 1.1 1998/09/03 22:03:18 christos Exp $
+$ $tcsh: set15,v 1.2 2006/03/02 18:46:47 christos Exp $
$ sh.func.c
$set 15
1 %s: %s: non si può %s il limite%s\n
diff --git a/contrib/tcsh/nls/italian/set16 b/contrib/tcsh/nls/italian/set16
index 1d11fbf..0ec4eaa 100644
--- a/contrib/tcsh/nls/italian/set16
+++ b/contrib/tcsh/nls/italian/set16
@@ -1,4 +1,4 @@
-$ $Id: set16,v 1.1 1998/09/03 22:03:19 christos Exp $
+$ $tcsh: set16,v 1.2 2006/03/02 18:46:47 christos Exp $
$ sh.lex.c
$set 16
1 Reinizializzato il gruppo di processi di terminale da %d a %d\n
diff --git a/contrib/tcsh/nls/italian/set17 b/contrib/tcsh/nls/italian/set17
index 12f0531..40e2868 100644
--- a/contrib/tcsh/nls/italian/set17
+++ b/contrib/tcsh/nls/italian/set17
@@ -1,4 +1,4 @@
-$ $Id: set17,v 1.2 2003/02/08 20:03:27 christos Exp $
+$ $tcsh: set17,v 1.3 2006/03/02 18:46:47 christos Exp $
$ sh.proc.c
$set 17
1 BACO: sto aspettando un lavoro in background!\n
diff --git a/contrib/tcsh/nls/italian/set18 b/contrib/tcsh/nls/italian/set18
index a8a80f2..83a612c 100644
--- a/contrib/tcsh/nls/italian/set18
+++ b/contrib/tcsh/nls/italian/set18
@@ -1,4 +1,4 @@
-$ $Id: set18,v 1.1 1998/09/03 22:03:21 christos Exp $
+$ $tcsh: set18,v 1.2 2006/03/02 18:46:47 christos Exp $
$ sh.set.c
$set 18
1 Attenzione: PATH indecorosamente lungo troncato\n
diff --git a/contrib/tcsh/nls/italian/set19 b/contrib/tcsh/nls/italian/set19
index caa052d..9226ef6 100644
--- a/contrib/tcsh/nls/italian/set19
+++ b/contrib/tcsh/nls/italian/set19
@@ -1,4 +1,4 @@
-$ $Id: set19,v 1.1 1998/09/03 22:03:21 christos Exp $
+$ $tcsh: set19,v 1.2 2006/03/02 18:46:47 christos Exp $
$ tc.alloc.c
$set 19
1 nbytes=%d: Memoria esaurita\n
diff --git a/contrib/tcsh/nls/italian/set2 b/contrib/tcsh/nls/italian/set2
index 07925f5..cbf9a05 100644
--- a/contrib/tcsh/nls/italian/set2
+++ b/contrib/tcsh/nls/italian/set2
@@ -1,4 +1,4 @@
-$ $Id: set2,v 1.1 1998/09/03 22:03:22 christos Exp $
+$ $tcsh: set2,v 1.2 2006/03/02 18:46:47 christos Exp $
$ Signal names
$set 2
1 Segnale nullo
diff --git a/contrib/tcsh/nls/italian/set20 b/contrib/tcsh/nls/italian/set20
index 25aadb7..5d33cca 100644
--- a/contrib/tcsh/nls/italian/set20
+++ b/contrib/tcsh/nls/italian/set20
@@ -1,4 +1,4 @@
-$ $Id: set20,v 1.1 1998/09/03 22:03:23 christos Exp $
+$ $tcsh: set20,v 1.2 2006/03/02 18:46:47 christos Exp $
$ tc.bind.c
$set 20
1 Nome di tasto non corretto `%S'\n
diff --git a/contrib/tcsh/nls/italian/set21 b/contrib/tcsh/nls/italian/set21
index 564e91a..9bc2e04 100644
--- a/contrib/tcsh/nls/italian/set21
+++ b/contrib/tcsh/nls/italian/set21
@@ -1,4 +1,4 @@
-$ $Id: set21,v 1.2 1998/09/09 10:30:21 christos Exp $
+$ $tcsh: set21,v 1.3 2006/03/02 18:46:47 christos Exp $
$ tc.disc.c
$set 21
1 Non si possono ottenere i caratteri locali\n
diff --git a/contrib/tcsh/nls/italian/set22 b/contrib/tcsh/nls/italian/set22
index 1187251..ab94433 100644
--- a/contrib/tcsh/nls/italian/set22
+++ b/contrib/tcsh/nls/italian/set22
@@ -1,4 +1,4 @@
-$ $Id: set22,v 1.1 1998/09/03 22:03:24 christos Exp $
+$ $tcsh: set22,v 1.2 2006/03/02 18:46:47 christos Exp $
$ tc.func.c
$set 22
1 %S: \t è un alias per
diff --git a/contrib/tcsh/nls/italian/set23 b/contrib/tcsh/nls/italian/set23
index 661e7e6..8b71649 100644
--- a/contrib/tcsh/nls/italian/set23
+++ b/contrib/tcsh/nls/italian/set23
@@ -1,4 +1,4 @@
-$ $Id: set23,v 1.1 1998/09/03 22:03:25 christos Exp $
+$ $tcsh: set23,v 1.2 2006/03/02 18:46:47 christos Exp $
$ tc.os.c
$set 23
1 Nome di cpu/macchina non corretto
diff --git a/contrib/tcsh/nls/italian/set24 b/contrib/tcsh/nls/italian/set24
index d74e532..95457cc 100644
--- a/contrib/tcsh/nls/italian/set24
+++ b/contrib/tcsh/nls/italian/set24
@@ -1,4 +1,4 @@
-$ $Id: set24,v 1.1 1998/09/03 22:03:26 christos Exp $
+$ $tcsh: set24,v 1.2 2006/03/02 18:46:47 christos Exp $
$ tc.sched.c
$set 24
1 accrocchio
diff --git a/contrib/tcsh/nls/italian/set25 b/contrib/tcsh/nls/italian/set25
index e20766a..2cc50a8 100644
--- a/contrib/tcsh/nls/italian/set25
+++ b/contrib/tcsh/nls/italian/set25
@@ -1,4 +1,4 @@
-$ $Id: set25,v 1.1 1998/09/03 22:03:27 christos Exp $
+$ $tcsh: set25,v 1.2 2006/03/02 18:46:47 christos Exp $
$ tc.sig.c
$set 25
1 ourwait %d\n
diff --git a/contrib/tcsh/nls/italian/set26 b/contrib/tcsh/nls/italian/set26
index f2ff82d..911cb6c 100644
--- a/contrib/tcsh/nls/italian/set26
+++ b/contrib/tcsh/nls/italian/set26
@@ -1,4 +1,4 @@
-$ $Id: set26,v 1.1 1998/09/03 22:03:28 christos Exp $
+$ $tcsh: set26,v 1.2 2006/03/02 18:46:47 christos Exp $
$ tc.who.c
$set 26
1 non posso usare stat per %s. Per pietà dai un "unset watch".\n
diff --git a/contrib/tcsh/nls/italian/set27 b/contrib/tcsh/nls/italian/set27
index 856c2cc..4a42895 100644
--- a/contrib/tcsh/nls/italian/set27
+++ b/contrib/tcsh/nls/italian/set27
@@ -1,4 +1,4 @@
-$ $Id: set27,v 1.1 1998/09/03 22:03:28 christos Exp $
+$ $tcsh: set27,v 1.2 2006/03/02 18:46:47 christos Exp $
$ tw.comp.c
$set 27
1 comando
diff --git a/contrib/tcsh/nls/italian/set29 b/contrib/tcsh/nls/italian/set29
index 5bf6016..9519a4d 100644
--- a/contrib/tcsh/nls/italian/set29
+++ b/contrib/tcsh/nls/italian/set29
@@ -1,4 +1,4 @@
-$ $Id: set29,v 1.1 1998/09/03 22:03:29 christos Exp $
+$ $tcsh: set29,v 1.2 2006/03/02 18:46:47 christos Exp $
$ tw.help.c
$set 29
1 Non esiste il file di aiuto per %S\n
diff --git a/contrib/tcsh/nls/italian/set3 b/contrib/tcsh/nls/italian/set3
index fdab68d..eaff36a 100644
--- a/contrib/tcsh/nls/italian/set3
+++ b/contrib/tcsh/nls/italian/set3
@@ -1,4 +1,4 @@
-$ $Id: set3,v 1.2 2001/04/26 19:07:51 kim Exp $
+$ $tcsh: set3,v 1.3 2006/03/02 18:46:47 christos Exp $
$ Editor function descriptions
$set 3
1 Retrocede di un carattere
diff --git a/contrib/tcsh/nls/italian/set30 b/contrib/tcsh/nls/italian/set30
index b5e7ee3..b118429 100644
--- a/contrib/tcsh/nls/italian/set30
+++ b/contrib/tcsh/nls/italian/set30
@@ -1,4 +1,4 @@
-$ $Id: set30,v 1.1 1998/09/03 22:03:31 christos Exp $
+$ $tcsh: set30,v 1.2 2006/03/02 18:46:47 christos Exp $
$ tw.parse.c
$set 30
1 inizio_il_comando %d\n
diff --git a/contrib/tcsh/nls/italian/set31 b/contrib/tcsh/nls/italian/set31
index 07cdef2..046f1ba 100644
--- a/contrib/tcsh/nls/italian/set31
+++ b/contrib/tcsh/nls/italian/set31
@@ -1,4 +1,4 @@
-$ $Id: set31,v 1.1 1998/09/03 22:03:31 christos Exp $
+$ $tcsh: set31,v 1.2 2006/03/02 18:46:47 christos Exp $
$ vms.termcap.c
$set 31
1 Non posso aprire il TERMCAP: [%s]\n
diff --git a/contrib/tcsh/nls/italian/set4 b/contrib/tcsh/nls/italian/set4
index fbd5604..5e96ba3 100644
--- a/contrib/tcsh/nls/italian/set4
+++ b/contrib/tcsh/nls/italian/set4
@@ -1,4 +1,4 @@
-$ $Id: set4,v 1.1 1998/09/03 22:03:32 christos Exp $
+$ $tcsh: set4,v 1.2 2006/03/02 18:46:47 christos Exp $
$ Termcap strings
$set 4
1 aggiunge una linea vuota
diff --git a/contrib/tcsh/nls/italian/set5 b/contrib/tcsh/nls/italian/set5
index 788d52c..40dcae8 100644
--- a/contrib/tcsh/nls/italian/set5
+++ b/contrib/tcsh/nls/italian/set5
@@ -1,4 +1,4 @@
-$ $Id: set5,v 1.1 1998/09/03 22:03:33 christos Exp $
+$ $tcsh: set5,v 1.2 2006/03/02 18:46:47 christos Exp $
$ ed.chared.c
$set 5
1 Media di carico non disponibile\n
diff --git a/contrib/tcsh/nls/italian/set6 b/contrib/tcsh/nls/italian/set6
index 6686b01..68994a6 100644
--- a/contrib/tcsh/nls/italian/set6
+++ b/contrib/tcsh/nls/italian/set6
@@ -1,4 +1,4 @@
-$ $Id: set6,v 1.1 1998/09/03 22:03:34 christos Exp $
+$ $tcsh: set6,v 1.2 2006/03/02 18:46:47 christos Exp $
$ ed.inputl.c
$set 6
1 ERRORE: comando illegale per il tasto 0%o\r\n
diff --git a/contrib/tcsh/nls/italian/set7 b/contrib/tcsh/nls/italian/set7
index f09b3dd..0e843a7 100644
--- a/contrib/tcsh/nls/italian/set7
+++ b/contrib/tcsh/nls/italian/set7
@@ -1,4 +1,4 @@
-$ $Id: set7,v 1.1 1998/09/03 22:03:34 christos Exp $
+$ $tcsh: set7,v 1.2 2006/03/02 18:46:47 christos Exp $
$ ed.screen.c
$set 7
1 \n\tLa tcsh ipotizza che il tuo terminale abbia\n
diff --git a/contrib/tcsh/nls/italian/set8 b/contrib/tcsh/nls/italian/set8
index ca5ce8d..f5b210b 100644
--- a/contrib/tcsh/nls/italian/set8
+++ b/contrib/tcsh/nls/italian/set8
@@ -1,4 +1,4 @@
-$ $Id: set8,v 1.1 1998/09/03 22:03:35 christos Exp $
+$ $tcsh: set8,v 1.2 2006/03/02 18:46:47 christos Exp $
$ ed.term.c
$set 8
1 Commutatore sconosciuto
diff --git a/contrib/tcsh/nls/italian/set9 b/contrib/tcsh/nls/italian/set9
index 745aad2..f4e50ff 100644
--- a/contrib/tcsh/nls/italian/set9
+++ b/contrib/tcsh/nls/italian/set9
@@ -1,4 +1,4 @@
-$ $Id: set9,v 1.1 1998/09/03 22:03:36 christos Exp $
+$ $tcsh: set9,v 1.2 2006/03/02 18:46:47 christos Exp $
$ ed.xmap.c
$set 9
1 AddXkey: tasto esteso nullo non ammesso.\n
diff --git a/contrib/tcsh/nls/ja/set1 b/contrib/tcsh/nls/ja/set1
index 0be6a77..c53da1d 100644
--- a/contrib/tcsh/nls/ja/set1
+++ b/contrib/tcsh/nls/ja/set1
@@ -1,4 +1,4 @@
-$ $Id: set1,v 1.4 2004/12/25 22:24:58 christos Exp $
+$ $tcsh: set1,v 1.5 2006/03/02 18:46:47 christos Exp $
$ Error messages
$set 1
1 ʸˡ¤¬´Ö°ã¤Ã¤Æ¤¤¤Þ¤¹
diff --git a/contrib/tcsh/nls/ja/set10 b/contrib/tcsh/nls/ja/set10
index d76ae2e..e09a8e5 100644
--- a/contrib/tcsh/nls/ja/set10
+++ b/contrib/tcsh/nls/ja/set10
@@ -1,4 +1,4 @@
-$ $Id: set10,v 1.1 1998/09/03 22:04:03 christos Exp $
+$ $tcsh: set10,v 1.2 2006/03/02 18:46:47 christos Exp $
$ ma.setp.c
$set 10
1 setpath: ¥³¥Þ¥ó¥É¤¬ÉÔÀµ¤Ç¤¹ '%s'.\n
diff --git a/contrib/tcsh/nls/ja/set11 b/contrib/tcsh/nls/ja/set11
index 1e619ba..bc00dbf 100644
--- a/contrib/tcsh/nls/ja/set11
+++ b/contrib/tcsh/nls/ja/set11
@@ -1,4 +1,4 @@
-$ $Id: set11,v 1.1 1998/09/03 22:04:04 christos Exp $
+$ $tcsh: set11,v 1.2 2006/03/02 18:46:47 christos Exp $
$ sh.c
$set 11
1 ·Ù¹ð: tty¤Ë¥¢¥¯¥»¥¹¤¬¤Ç¤­¤Þ¤»¤ó (%s).\n
diff --git a/contrib/tcsh/nls/ja/set12 b/contrib/tcsh/nls/ja/set12
index ef990cf..d3a3318 100644
--- a/contrib/tcsh/nls/ja/set12
+++ b/contrib/tcsh/nls/ja/set12
@@ -1,4 +1,4 @@
-$ $Id: set12,v 1.1 1998/09/03 22:04:05 christos Exp $
+$ $tcsh: set12,v 1.2 2006/03/02 18:46:47 christos Exp $
$ sh.dir.c
$set 12
1 %s: "%s"¤«¤é¤Î¼Â¹Ô¤ò»î¤·¤Þ¤¹\n
diff --git a/contrib/tcsh/nls/ja/set13 b/contrib/tcsh/nls/ja/set13
index 3f06441..cc8c20f 100644
--- a/contrib/tcsh/nls/ja/set13
+++ b/contrib/tcsh/nls/ja/set13
@@ -1,4 +1,4 @@
-$ $Id: set13,v 1.1 1998/09/03 22:04:05 christos Exp $
+$ $tcsh: set13,v 1.2 2006/03/02 18:46:47 christos Exp $
$ sh.exec.c
$set 13
1 hash=%-4d dir=%-2d prog=%s\n
diff --git a/contrib/tcsh/nls/ja/set15 b/contrib/tcsh/nls/ja/set15
index d0049cc..5cfb860 100644
--- a/contrib/tcsh/nls/ja/set15
+++ b/contrib/tcsh/nls/ja/set15
@@ -1,4 +1,4 @@
-$ $Id: set15,v 1.1 1998/09/03 22:04:06 christos Exp $
+$ $tcsh: set15,v 1.2 2006/03/02 18:46:47 christos Exp $
$ sh.func.c
$set 15
1 %s: %s: %s ½ÐÍè¤Þ¤»¤ó. (%s À©¸Â)\n
diff --git a/contrib/tcsh/nls/ja/set16 b/contrib/tcsh/nls/ja/set16
index 644e388..7edcc43 100644
--- a/contrib/tcsh/nls/ja/set16
+++ b/contrib/tcsh/nls/ja/set16
@@ -1,4 +1,4 @@
-$ $Id: set16,v 1.2 1998/09/09 10:30:26 christos Exp $
+$ $tcsh: set16,v 1.3 2006/03/02 18:46:47 christos Exp $
$ sh.lex.c
$set 16
1 tty pgrp ¤ò %d ¤«¤é %d¤ËºÆÀßÄꤷ¤Þ¤¹\n
diff --git a/contrib/tcsh/nls/ja/set17 b/contrib/tcsh/nls/ja/set17
index b0ad507..bf9de54 100644
--- a/contrib/tcsh/nls/ja/set17
+++ b/contrib/tcsh/nls/ja/set17
@@ -1,4 +1,4 @@
-$ $Id: set17,v 1.2 2003/02/08 20:03:28 christos Exp $
+$ $tcsh: set17,v 1.3 2006/03/02 18:46:47 christos Exp $
$ sh.proc.c
$set 17
1 ¾ã³²: ¥Ð¥Ã¥°¥°¥é¥¦¥ó¥É¥¸¥ç¥Ö¤òÂԤäƤ¤¤Þ¤¹\n
diff --git a/contrib/tcsh/nls/ja/set18 b/contrib/tcsh/nls/ja/set18
index 9f29795..b9364ac 100644
--- a/contrib/tcsh/nls/ja/set18
+++ b/contrib/tcsh/nls/ja/set18
@@ -1,4 +1,4 @@
-$ $Id: set18,v 1.1 1998/09/03 22:04:09 christos Exp $
+$ $tcsh: set18,v 1.2 2006/03/02 18:46:47 christos Exp $
$ sh.set.c
$set 18
1 ·Ù¹ð: ÉÔ¼«Á³¤ËŤ¤ PATH ¤ÏÀÚ¤ê¼Î¤Æ¤é¤ì¤Þ¤¹\n
diff --git a/contrib/tcsh/nls/ja/set2 b/contrib/tcsh/nls/ja/set2
index c1e5ea2..34e780c 100644
--- a/contrib/tcsh/nls/ja/set2
+++ b/contrib/tcsh/nls/ja/set2
@@ -1,4 +1,4 @@
-$ $Id: set2,v 1.1 1998/09/03 22:04:10 christos Exp $
+$ $tcsh: set2,v 1.2 2006/03/02 18:46:47 christos Exp $
$ Signal names
$set 2
1 ¥Ì¥ë¥·¥°¥Ê¥ë
diff --git a/contrib/tcsh/nls/ja/set21 b/contrib/tcsh/nls/ja/set21
index 29ae51c..9a7783e 100644
--- a/contrib/tcsh/nls/ja/set21
+++ b/contrib/tcsh/nls/ja/set21
@@ -1,4 +1,4 @@
-$ $Id: set21,v 1.1 1998/09/03 22:04:10 christos Exp $
+$ $tcsh: set21,v 1.2 2006/03/02 18:46:47 christos Exp $
$ tc.disc.c
$set 21
1 ¥í¡¼¥«¥ë¥­¥ã¥é¤ò¼èÆÀ¤Ç¤­¤Þ¤»¤ó.\n
diff --git a/contrib/tcsh/nls/ja/set24 b/contrib/tcsh/nls/ja/set24
index debb53f..0c3ca90 100644
--- a/contrib/tcsh/nls/ja/set24
+++ b/contrib/tcsh/nls/ja/set24
@@ -1,4 +1,4 @@
-$ $Id: set24,v 1.1 1998/09/03 22:04:11 christos Exp $
+$ $tcsh: set24,v 1.2 2006/03/02 18:46:47 christos Exp $
$ tc.sched.c
$set 24
1 kludge
diff --git a/contrib/tcsh/nls/ja/set29 b/contrib/tcsh/nls/ja/set29
index b67a7c7..9f67ef6 100644
--- a/contrib/tcsh/nls/ja/set29
+++ b/contrib/tcsh/nls/ja/set29
@@ -1,4 +1,4 @@
-$ $Id: set29,v 1.2 1999/05/11 13:08:30 christos Exp $
+$ $tcsh: set29,v 1.3 2006/03/02 18:46:47 christos Exp $
$ tw.help.c
$set 29
1 %S ÍѤΥإë¥×¥Õ¥¡¥¤¥ë¤¬¤¢¤ê¤Þ¤»¤ó\n
diff --git a/contrib/tcsh/nls/ja/set3 b/contrib/tcsh/nls/ja/set3
index 0db1726..cc3dc3b 100644
--- a/contrib/tcsh/nls/ja/set3
+++ b/contrib/tcsh/nls/ja/set3
@@ -1,4 +1,4 @@
-$ $Id: set3,v 1.4 2001/04/26 19:07:48 kim Exp $
+$ $tcsh: set3,v 1.4 2001/04/26 19:07:48 kim Exp $
$ Editor function descriptions
$set 3
1 1ʸ»úÌá¤ë
diff --git a/contrib/tcsh/nls/ja/set30 b/contrib/tcsh/nls/ja/set30
index d7ad9b2..d48bdc3 100644
--- a/contrib/tcsh/nls/ja/set30
+++ b/contrib/tcsh/nls/ja/set30
@@ -1,4 +1,4 @@
-$ $Id: set30,v 1.1 1998/09/03 22:04:13 christos Exp $
+$ $tcsh: set30,v 1.2 2006/03/02 18:46:47 christos Exp $
$ tw.parse.c
$set 30
1 ¥³¥Þ¥ó¥É³«»Ï %d\n
diff --git a/contrib/tcsh/nls/ja/set4 b/contrib/tcsh/nls/ja/set4
index 9c29143..3743178 100644
--- a/contrib/tcsh/nls/ja/set4
+++ b/contrib/tcsh/nls/ja/set4
@@ -1,18 +1,18 @@
-$ $Id: set4,v 1.2 1995/03/19 18:07:15 christos Exp $
+$ $tcsh: set4,v 1.2 1995/03/19 18:07:15 christos Exp $
$ Termcap strings
$set 4
-1 ¿·µ¬¶õ¹ÔÄɲÃ
-2 ²ÄÄ°À­¥Ù¥ë
-3 ºÇ²¼¹Ô¤Þ¤Ç¥¯¥ê¥¢
-4 ¹ÔËö¤Þ¤Ç¥¯¥ê¥¢
+1 ¶õ¹ÔÁÞÆþ
+2 ²ÄÄ°¥Ù¥ë
+3 ²èÌÌËö¤Þ¤Ç¾Ãµî
+4 ¹ÔËö¤Þ¤Ç¾Ãµî
5 ¥«¡¼¥½¥ë¿åÊ¿°ÜÆ°
-6 ²èÌÌ¥¯¥ê¥¢
+6 ²èÌ̾õî
7 1ʸ»úºï½ü
8 1¹Ôºï½ü
9 ºï½ü¥â¡¼¥É³«»Ï
10 ºï½ü¥â¡¼¥É½ªÎ»
11 ÁÞÆþ¥â¡¼¥É½ªÎ»
-12 cursor from status line
+12 ¥¹¥Æ¡¼¥¿¥¹¹Ô¤«¤é¥«¡¼¥½¥ë¤òÉüµ¢
13 ¥«¡¼¥½¥ë¤ò¥Û¡¼¥à°ÌÃÖ¤Ø
14 ʸ»úÁÞÆþ
15 ÁÞÆþ¥â¡¼¥É³«»Ï
@@ -21,16 +21,16 @@ $set 4
18 ¥«¡¼¥½¥ëº¸°ÜÆ°
19 ¥«¡¼¥½¥ë±¦°ÜÆ°
20 ¥«¡¼¥½¥ë¾å°ÜÆ°
-21 ¥Ü¡¼¥ë¥É³«»Ï
+21 ÂÀ»ú³«»Ï
22 °À­½ªÎ»
23 ʬ³ä¶Ø»ß¶õÇò
24 ¶¯Ä´½ªÎ»
25 ¶¯Ä´³«»Ï
-26 ¥«¡¼¥½¥ë¤ò¥¹¥Æ¥¤¥¿¥¹¹Ô¤Ø
+26 ¥«¡¼¥½¥ë¤ò¥¹¥Æ¡¼¥¿¥¹¹Ô¤Ø
27 ¥«¡¼¥½¥ë¤ò1¤Ä¾å¤Ø
28 ²¼Àþ³«»Ï
29 ²¼Àþ½ªÎ»
-30 »ë³ÐŪ¥Ù¥ë
+30 ²Ä»ë¥Ù¥ë
31 Ê£¿ôʸ»úºï½ü
32 ¥«¡¼¥½¥ë²¼°ÜÆ°(multiple)
33 Ê£¿ôʸ»úÁÞÆþ
diff --git a/contrib/tcsh/nls/ja/set5 b/contrib/tcsh/nls/ja/set5
index d6d5e80..9241818 100644
--- a/contrib/tcsh/nls/ja/set5
+++ b/contrib/tcsh/nls/ja/set5
@@ -1,4 +1,4 @@
-$ $Id: set5,v 1.1 1998/09/03 22:04:14 christos Exp $
+$ $tcsh: set5,v 1.2 2006/03/02 18:46:47 christos Exp $
$ ed.chared.c
$set 5
1 ¥·¥¹¥Æ¥àÉé²Ùɽ¼¨¤Ï»ÈÍѤǤ­¤Þ¤»¤ó\n
diff --git a/contrib/tcsh/nls/ja/set6 b/contrib/tcsh/nls/ja/set6
index 66dcbf6..203f664 100644
--- a/contrib/tcsh/nls/ja/set6
+++ b/contrib/tcsh/nls/ja/set6
@@ -1,4 +1,4 @@
-$ $Id: set6,v 1.1 1998/09/03 22:04:14 christos Exp $
+$ $tcsh: set6,v 1.2 2006/03/02 18:46:47 christos Exp $
$ ed.inputl.c
$set 6
1 ¥¨¥é¡¼: ÉÔÀµ¤Ê¥­¡¼¤«¤é¤Î¥³¥Þ¥ó¥É 0%o\r\n
diff --git a/contrib/tcsh/nls/ja/set7 b/contrib/tcsh/nls/ja/set7
index 3c01263..911ad75 100644
--- a/contrib/tcsh/nls/ja/set7
+++ b/contrib/tcsh/nls/ja/set7
@@ -1,4 +1,4 @@
-$ $Id: set7,v 1.1 2005/03/23 01:25:47 kim Exp $
+$ $tcsh: set7,v 1.2 2006/03/02 18:46:47 christos Exp $
$ ed.screen.c
$set 7
1 \n\tTcsh ¤Î¿ä¬¤Ç¤Ï¡¢¤¢¤Ê¤¿¤ÎüËö¤Ï\n
diff --git a/contrib/tcsh/nls/ja/set8 b/contrib/tcsh/nls/ja/set8
index b23588f..f979f4e 100644
--- a/contrib/tcsh/nls/ja/set8
+++ b/contrib/tcsh/nls/ja/set8
@@ -1,4 +1,4 @@
-$ $Id: set8,v 1.1 1998/09/03 22:04:16 christos Exp $
+$ $tcsh: set8,v 1.2 2006/03/02 18:46:47 christos Exp $
$ ed.term.c
$set 8
1 ÉÔÌÀ¤Êswitch
diff --git a/contrib/tcsh/nls/pl/set1 b/contrib/tcsh/nls/pl/set1
index 277a596..d9106f5 100644
--- a/contrib/tcsh/nls/pl/set1
+++ b/contrib/tcsh/nls/pl/set1
@@ -1,4 +1,4 @@
-$ $Id: set1,v 1.5 1998/06/27 12:27:55 christos Exp $
+$ $tcsh: set1,v 1.5 1998/06/27 12:27:55 christos Exp $
$ Error messages
$set 1
1 B³±d sk³adni
diff --git a/contrib/tcsh/nls/pl/set10 b/contrib/tcsh/nls/pl/set10
index 4283408..0c9dfb7 100644
--- a/contrib/tcsh/nls/pl/set10
+++ b/contrib/tcsh/nls/pl/set10
@@ -1,4 +1,4 @@
-$ $Id: set10,v 1.2 1995/03/19 18:07:15 christos Exp $
+$ $tcsh: set10,v 1.2 1995/03/19 18:07:15 christos Exp $
$ ma.setp.c
$set 10
1 setpath: nieprawid³owe polecenie '%s'.\n
diff --git a/contrib/tcsh/nls/pl/set11 b/contrib/tcsh/nls/pl/set11
index 97fac7d..aade2f9 100644
--- a/contrib/tcsh/nls/pl/set11
+++ b/contrib/tcsh/nls/pl/set11
@@ -1,4 +1,4 @@
-$ $Id: set11,v 1.2 1995/03/19 18:07:15 christos Exp $
+$ $tcsh: set11,v 1.2 1995/03/19 18:07:15 christos Exp $
$ sh.c
$set 11
1 Uwaga: brak dostêpu do tty (%s).\n
diff --git a/contrib/tcsh/nls/pl/set12 b/contrib/tcsh/nls/pl/set12
index f9f35ea..afbb146 100644
--- a/contrib/tcsh/nls/pl/set12
+++ b/contrib/tcsh/nls/pl/set12
@@ -1,4 +1,4 @@
-$ $Id: set12,v 1.3 1996/04/26 20:31:52 christos Exp $
+$ $tcsh: set12,v 1.3 1996/04/26 20:31:52 christos Exp $
$ sh.dir.c
$set 12
1 %s: Próbujê wystartowaæ z "%s"\n
diff --git a/contrib/tcsh/nls/pl/set13 b/contrib/tcsh/nls/pl/set13
index c3143b4..4d44a0b 100644
--- a/contrib/tcsh/nls/pl/set13
+++ b/contrib/tcsh/nls/pl/set13
@@ -1,4 +1,4 @@
-$ $Id: set13,v 1.2 1995/03/19 18:07:15 christos Exp $
+$ $tcsh: set13,v 1.2 1995/03/19 18:07:15 christos Exp $
$ sh.exec.c
$set 13
1 hash=%-4d dir=%-2d prog=%s\n
diff --git a/contrib/tcsh/nls/pl/set14 b/contrib/tcsh/nls/pl/set14
index d3dd53c..b456721 100644
--- a/contrib/tcsh/nls/pl/set14
+++ b/contrib/tcsh/nls/pl/set14
@@ -1,4 +1,4 @@
-$ $Id: set14,v 1.3 1998/11/24 18:18:06 christos Exp $
+$ $tcsh: set14,v 1.3 1998/11/24 18:18:06 christos Exp $
$ sh.file.c
$set 14
1 \nKurcze!! Zbyt wiele %s!!\n
diff --git a/contrib/tcsh/nls/pl/set15 b/contrib/tcsh/nls/pl/set15
index 51b62ac..8f04af3 100644
--- a/contrib/tcsh/nls/pl/set15
+++ b/contrib/tcsh/nls/pl/set15
@@ -1,4 +1,4 @@
-$ $Id: set15,v 1.3 1996/10/19 17:52:32 christos Exp $
+$ $tcsh: set15,v 1.3 1996/10/19 17:52:32 christos Exp $
$ sh.func.c
$set 15
1 %s: %s: Nie mogê limitowaæ %s%s\n
diff --git a/contrib/tcsh/nls/pl/set16 b/contrib/tcsh/nls/pl/set16
index 0d8197d..2d07f5f 100644
--- a/contrib/tcsh/nls/pl/set16
+++ b/contrib/tcsh/nls/pl/set16
@@ -1,4 +1,4 @@
-$ $Id: set16,v 1.3 1996/04/26 20:31:55 christos Exp $
+$ $tcsh: set16,v 1.3 1996/04/26 20:31:55 christos Exp $
$ sh.lex.c
$set 16
1 Reset tty pgrp from %d to %d\n
diff --git a/contrib/tcsh/nls/pl/set17 b/contrib/tcsh/nls/pl/set17
index 74ebbcb..e72adaa 100644
--- a/contrib/tcsh/nls/pl/set17
+++ b/contrib/tcsh/nls/pl/set17
@@ -1,4 +1,4 @@
-$ $Id: set17,v 1.3 1996/10/19 17:52:33 christos Exp $
+$ $tcsh: set17,v 1.3 1996/10/19 17:52:33 christos Exp $
$ sh.proc.c
$set 17
1 PLUSKWA: czekam na zadanie pracuj±ce w tle!\n
diff --git a/contrib/tcsh/nls/pl/set18 b/contrib/tcsh/nls/pl/set18
index 55671a7..02b3d75 100644
--- a/contrib/tcsh/nls/pl/set18
+++ b/contrib/tcsh/nls/pl/set18
@@ -1,4 +1,4 @@
-$ $Id: set18,v 1.2 1995/03/19 18:07:15 christos Exp $
+$ $tcsh: set18,v 1.2 1995/03/19 18:07:15 christos Exp $
$ sh.set.c
$set 18
1 Uwaga: ¶miesznie d³uga PATH zosta³a obciêta\n
diff --git a/contrib/tcsh/nls/pl/set19 b/contrib/tcsh/nls/pl/set19
index dff95c5..6170f4b 100644
--- a/contrib/tcsh/nls/pl/set19
+++ b/contrib/tcsh/nls/pl/set19
@@ -1,4 +1,4 @@
-$ $Id: set19,v 1.3 1996/04/26 20:31:58 christos Exp $
+$ $tcsh: set19,v 1.3 1996/04/26 20:31:58 christos Exp $
$ tc.alloc.c
$set 19
1 n-bajtów=%d: Brak pamiêci\n
diff --git a/contrib/tcsh/nls/pl/set2 b/contrib/tcsh/nls/pl/set2
index ae25b69..549c0b7 100644
--- a/contrib/tcsh/nls/pl/set2
+++ b/contrib/tcsh/nls/pl/set2
@@ -1,4 +1,4 @@
-$ $Id: set2,v 1.4 1998/10/25 15:12:38 christos Exp $
+$ $tcsh: set2,v 1.4 1998/10/25 15:12:38 christos Exp $
$ Signal names
$set 2
1 Pusty sygna³
diff --git a/contrib/tcsh/nls/pl/set20 b/contrib/tcsh/nls/pl/set20
index 1be2714..370e41a 100644
--- a/contrib/tcsh/nls/pl/set20
+++ b/contrib/tcsh/nls/pl/set20
@@ -1,4 +1,4 @@
-$ $Id: set20,v 1.2 1995/03/19 18:07:15 christos Exp $
+$ $tcsh: set20,v 1.2 1995/03/19 18:07:15 christos Exp $
$ tc.bind.c
$set 20
1 Invalid key name `%S'\n
diff --git a/contrib/tcsh/nls/pl/set21 b/contrib/tcsh/nls/pl/set21
index 9484ba0..bed58d2 100644
--- a/contrib/tcsh/nls/pl/set21
+++ b/contrib/tcsh/nls/pl/set21
@@ -1,4 +1,4 @@
-$ $Id: set21,v 1.2 1995/03/19 18:07:15 christos Exp $
+$ $tcsh: set21,v 1.2 1995/03/19 18:07:15 christos Exp $
$ tc.disc.c
$set 21
1 Couldn't get local chars.\n
diff --git a/contrib/tcsh/nls/pl/set22 b/contrib/tcsh/nls/pl/set22
index 6aa8a29..a4436bd 100644
--- a/contrib/tcsh/nls/pl/set22
+++ b/contrib/tcsh/nls/pl/set22
@@ -1,4 +1,4 @@
-$ $Id: set22,v 1.2 1995/03/19 18:07:15 christos Exp $
+$ $tcsh: set22,v 1.2 1995/03/19 18:07:15 christos Exp $
$ tc.func.c
$set 22
1 %S: \t aliased to
diff --git a/contrib/tcsh/nls/pl/set23 b/contrib/tcsh/nls/pl/set23
index b350f59..4f90b8f 100644
--- a/contrib/tcsh/nls/pl/set23
+++ b/contrib/tcsh/nls/pl/set23
@@ -1,4 +1,4 @@
-$ $Id: set23,v 1.3 1996/04/26 20:32:00 christos Exp $
+$ $tcsh: set23,v 1.3 1996/04/26 20:32:00 christos Exp $
$ tc.os.c
$set 23
1 Bad cpu/site name
diff --git a/contrib/tcsh/nls/pl/set24 b/contrib/tcsh/nls/pl/set24
index 2896947..4e8e6d3 100644
--- a/contrib/tcsh/nls/pl/set24
+++ b/contrib/tcsh/nls/pl/set24
@@ -1,4 +1,4 @@
-$ $Id: set24,v 1.2 1995/03/19 18:07:15 christos Exp $
+$ $tcsh: set24,v 1.2 1995/03/19 18:07:15 christos Exp $
$ tc.sched.c
$set 24
1 kludge
diff --git a/contrib/tcsh/nls/pl/set25 b/contrib/tcsh/nls/pl/set25
index 063e8d6..704b47d 100644
--- a/contrib/tcsh/nls/pl/set25
+++ b/contrib/tcsh/nls/pl/set25
@@ -1,4 +1,4 @@
-$ $Id: set25,v 1.2 1995/03/19 18:07:15 christos Exp $
+$ $tcsh: set25,v 1.2 1995/03/19 18:07:15 christos Exp $
$ tc.sig.c
$set 25
1 our wait %d\n
diff --git a/contrib/tcsh/nls/pl/set26 b/contrib/tcsh/nls/pl/set26
index aa854ad..40e95f8 100644
--- a/contrib/tcsh/nls/pl/set26
+++ b/contrib/tcsh/nls/pl/set26
@@ -1,4 +1,4 @@
-$ $Id: set26,v 1.2 1995/03/19 18:07:15 christos Exp $
+$ $tcsh: set26,v 1.2 1995/03/19 18:07:15 christos Exp $
$ tc.who.c
$set 26
1 cannot stat %s. Please "unset watch".\n
diff --git a/contrib/tcsh/nls/pl/set27 b/contrib/tcsh/nls/pl/set27
index 489f0de..2f44418 100644
--- a/contrib/tcsh/nls/pl/set27
+++ b/contrib/tcsh/nls/pl/set27
@@ -1,4 +1,4 @@
-$ $Id: set27,v 1.2 1995/03/19 18:07:15 christos Exp $
+$ $tcsh: set27,v 1.2 1995/03/19 18:07:15 christos Exp $
$ tw.comp.c
$set 27
1 polecenie
diff --git a/contrib/tcsh/nls/pl/set29 b/contrib/tcsh/nls/pl/set29
index 559bc5e..a9a0836 100644
--- a/contrib/tcsh/nls/pl/set29
+++ b/contrib/tcsh/nls/pl/set29
@@ -1,4 +1,4 @@
-$ $Id: set29,v 1.2 1995/03/19 18:07:15 christos Exp $
+$ $tcsh: set29,v 1.2 1995/03/19 18:07:15 christos Exp $
$ tw.help.c
$set 29
1 Brak pliku pomocy dla %S\n
diff --git a/contrib/tcsh/nls/pl/set3 b/contrib/tcsh/nls/pl/set3
index 6ab0639..0873bb9 100644
--- a/contrib/tcsh/nls/pl/set3
+++ b/contrib/tcsh/nls/pl/set3
@@ -1,4 +1,4 @@
-$ $Id: set3,v 1.3 1995/04/24 14:12:51 christos Exp $
+$ $tcsh: set3,v 1.3 1995/04/24 14:12:51 christos Exp $
$ Editor function descriptions
$set 3
1 Przejd¼ znak wstecz
diff --git a/contrib/tcsh/nls/pl/set30 b/contrib/tcsh/nls/pl/set30
index 2b7c32a..45145e0 100644
--- a/contrib/tcsh/nls/pl/set30
+++ b/contrib/tcsh/nls/pl/set30
@@ -1,4 +1,4 @@
-$ $Id: set30,v 1.4 1996/10/19 17:52:34 christos Exp $
+$ $tcsh: set30,v 1.4 1996/10/19 17:52:34 christos Exp $
$ tw.parse.c
$set 30
1 starting_a_command %d\n
diff --git a/contrib/tcsh/nls/pl/set31 b/contrib/tcsh/nls/pl/set31
index 029171e..89e9015 100644
--- a/contrib/tcsh/nls/pl/set31
+++ b/contrib/tcsh/nls/pl/set31
@@ -1,4 +1,4 @@
-$ $Id: set31,v 1.2 1995/03/19 18:07:15 christos Exp $
+$ $tcsh: set31,v 1.2 1995/03/19 18:07:15 christos Exp $
$ vms.termcap.c
$set 31
1 Nie mogê otworzyæ TERMCAP: [%s]\n
diff --git a/contrib/tcsh/nls/pl/set4 b/contrib/tcsh/nls/pl/set4
index a7d289c..997fed4 100644
--- a/contrib/tcsh/nls/pl/set4
+++ b/contrib/tcsh/nls/pl/set4
@@ -1,4 +1,4 @@
-$ $Id: set4,v 1.2 1995/03/19 18:07:15 christos Exp $
+$ $tcsh: set4,v 1.2 1995/03/19 18:07:15 christos Exp $
$ Termcap strings
$set 4
1 add new blank line
diff --git a/contrib/tcsh/nls/pl/set5 b/contrib/tcsh/nls/pl/set5
index c888b3e..9dbe6d2 100644
--- a/contrib/tcsh/nls/pl/set5
+++ b/contrib/tcsh/nls/pl/set5
@@ -1,4 +1,4 @@
-$ $Id: set5,v 1.2 1995/03/19 18:07:15 christos Exp $
+$ $tcsh: set5,v 1.2 1995/03/19 18:07:15 christos Exp $
$ ed.chared.c
$set 5
1 ¦rednie obci±¿enie niedostêpne\n
diff --git a/contrib/tcsh/nls/pl/set6 b/contrib/tcsh/nls/pl/set6
index ed9d982..bcbfcfb 100644
--- a/contrib/tcsh/nls/pl/set6
+++ b/contrib/tcsh/nls/pl/set6
@@ -1,4 +1,4 @@
-$ $Id: set6,v 1.2 1995/03/19 18:07:15 christos Exp $
+$ $tcsh: set6,v 1.2 1995/03/19 18:07:15 christos Exp $
$ ed.inputl.c
$set 6
1 ERROR: illegal command from key 0%o\r\n
diff --git a/contrib/tcsh/nls/pl/set7 b/contrib/tcsh/nls/pl/set7
index 26e14132..1bd60d0 100644
--- a/contrib/tcsh/nls/pl/set7
+++ b/contrib/tcsh/nls/pl/set7
@@ -1,4 +1,4 @@
-$ $Id: set7,v 1.3 1996/04/26 20:32:04 christos Exp $
+$ $tcsh: set7,v 1.3 1996/04/26 20:32:04 christos Exp $
$ ed.screen.c
$set 7
1 \n\tTcsh thinks your terminal has the\n
diff --git a/contrib/tcsh/nls/pl/set8 b/contrib/tcsh/nls/pl/set8
index bfda403..0686721 100644
--- a/contrib/tcsh/nls/pl/set8
+++ b/contrib/tcsh/nls/pl/set8
@@ -1,4 +1,4 @@
-$ $Id: set8,v 1.2 1995/03/19 18:07:15 christos Exp $
+$ $tcsh: set8,v 1.2 1995/03/19 18:07:15 christos Exp $
$ ed.term.c
$set 8
1 Nieprawid³owy prze³±cznik
diff --git a/contrib/tcsh/nls/pl/set9 b/contrib/tcsh/nls/pl/set9
index 72511b4..8e3aeec 100644
--- a/contrib/tcsh/nls/pl/set9
+++ b/contrib/tcsh/nls/pl/set9
@@ -1,4 +1,4 @@
-$ $Id: set9,v 1.2 1995/03/19 18:07:15 christos Exp $
+$ $tcsh: set9,v 1.2 1995/03/19 18:07:15 christos Exp $
$ ed.xmap.c
$set 9
1 AddXkey: Null extended-key not allowed.\n
diff --git a/contrib/tcsh/nls/russian/set1 b/contrib/tcsh/nls/russian/set1
index 416af77..7acaf44 100644
--- a/contrib/tcsh/nls/russian/set1
+++ b/contrib/tcsh/nls/russian/set1
@@ -1,4 +1,4 @@
-$ $Id: set1,v 1.3 2002/03/08 17:46:50 christos Exp $
+$ $tcsh: set1,v 1.4 2006/03/02 18:46:47 christos Exp $
$ Error messages
$set 1
1 óÉÎÔÁËÓÉÞÅÓËÁÑ ÏÛÉÂËÁ
diff --git a/contrib/tcsh/nls/russian/set10 b/contrib/tcsh/nls/russian/set10
index 4cf387e..273abd2 100644
--- a/contrib/tcsh/nls/russian/set10
+++ b/contrib/tcsh/nls/russian/set10
@@ -1,4 +1,4 @@
-$ $Id: set10,v 1.2 2002/03/08 17:46:50 christos Exp $
+$ $tcsh: set10,v 1.3 2006/03/02 18:46:47 christos Exp $
$ ma.setp.c
$set 10
1 setpath: ÎÅ×ÅÒÎÁÑ ËÏÍÁÎÄÁ '%s'.\n
diff --git a/contrib/tcsh/nls/russian/set11 b/contrib/tcsh/nls/russian/set11
index 164b2a0..b165bd7 100644
--- a/contrib/tcsh/nls/russian/set11
+++ b/contrib/tcsh/nls/russian/set11
@@ -1,4 +1,4 @@
-$ $Id: set11,v 1.1 2001/03/18 19:06:36 christos Exp $
+$ $tcsh: set11,v 1.2 2006/03/02 18:46:47 christos Exp $
$ sh.c
$set 11
1 ðÒÅÄÕÐÒÅÖÄÅÎÉÅ: ÎÅÔ ÄÏÓÔÕÐÁ Ë tty (%s).\n
diff --git a/contrib/tcsh/nls/russian/set12 b/contrib/tcsh/nls/russian/set12
index 29714f8..b676c6c 100644
--- a/contrib/tcsh/nls/russian/set12
+++ b/contrib/tcsh/nls/russian/set12
@@ -1,4 +1,4 @@
-$ $Id: set12,v 1.1 2001/03/18 19:06:36 christos Exp $
+$ $tcsh: set12,v 1.2 2006/03/02 18:46:47 christos Exp $
$ sh.dir.c
$set 12
1 %s: ðÙÔÁÀÓØ ÎÁÞÁÔØ Ó "%s"\n
diff --git a/contrib/tcsh/nls/russian/set13 b/contrib/tcsh/nls/russian/set13
index 7bb54d12..206ea89 100644
--- a/contrib/tcsh/nls/russian/set13
+++ b/contrib/tcsh/nls/russian/set13
@@ -1,4 +1,4 @@
-$ $Id: set13,v 1.2 2002/03/08 17:46:50 christos Exp $
+$ $tcsh: set13,v 1.3 2006/03/02 18:46:47 christos Exp $
$ sh.exec.c
$set 13
1 hash=%-4d dir=%-2d prog=%s\n
diff --git a/contrib/tcsh/nls/russian/set14 b/contrib/tcsh/nls/russian/set14
index 6014f28..d9632d8 100644
--- a/contrib/tcsh/nls/russian/set14
+++ b/contrib/tcsh/nls/russian/set14
@@ -1,4 +1,4 @@
-$ $Id: set14,v 1.1 2001/03/18 19:06:37 christos Exp $
+$ $tcsh: set14,v 1.2 2006/03/02 18:46:47 christos Exp $
$ sh.file.c
$set 14
1 \nYikes!! óÌÉÛËÏÍ ÍÎÏÇÏ %s!!\n
diff --git a/contrib/tcsh/nls/russian/set15 b/contrib/tcsh/nls/russian/set15
index d4847a4..60c2a36 100644
--- a/contrib/tcsh/nls/russian/set15
+++ b/contrib/tcsh/nls/russian/set15
@@ -1,4 +1,4 @@
-$ $Id: set15,v 1.1 2001/03/18 19:06:37 christos Exp $
+$ $tcsh: set15,v 1.2 2006/03/02 18:46:47 christos Exp $
$ sh.func.c
$set 15
1 %s: %s: îÅ ÍÏÇÕ %s%s ÐÒÅÄÅÌ\n
diff --git a/contrib/tcsh/nls/russian/set16 b/contrib/tcsh/nls/russian/set16
index cd03c74..877acbe 100644
--- a/contrib/tcsh/nls/russian/set16
+++ b/contrib/tcsh/nls/russian/set16
@@ -1,4 +1,4 @@
-$ $Id: set16,v 1.1 2001/03/18 19:06:37 christos Exp $
+$ $tcsh: set16,v 1.2 2006/03/02 18:46:47 christos Exp $
$ sh.lex.c
$set 16
1 Reset tty pgrp from %d to %d\n
diff --git a/contrib/tcsh/nls/russian/set17 b/contrib/tcsh/nls/russian/set17
index 162c0e5..8d7384da 100644
--- a/contrib/tcsh/nls/russian/set17
+++ b/contrib/tcsh/nls/russian/set17
@@ -1,4 +1,4 @@
-$ $Id: set17,v 1.3 2003/02/08 20:03:28 christos Exp $
+$ $tcsh: set17,v 1.4 2006/03/02 18:46:47 christos Exp $
$ sh.proc.c
$set 17
1 BUG: waiting for background job!\n
diff --git a/contrib/tcsh/nls/russian/set18 b/contrib/tcsh/nls/russian/set18
index 075aa75..277af0d 100644
--- a/contrib/tcsh/nls/russian/set18
+++ b/contrib/tcsh/nls/russian/set18
@@ -1,4 +1,4 @@
-$ $Id: set18,v 1.2 2002/03/08 17:46:50 christos Exp $
+$ $tcsh: set18,v 1.3 2006/03/02 18:46:47 christos Exp $
$ sh.set.c
$set 18
1 ðÒÅÄÕÐÒÅÖÄÅÎÉÅ: þÅÒÅÓÞÕÒ ÄÌÉÎÎÙÊ PATH ÏÂÒÅÚÁÎ\n
diff --git a/contrib/tcsh/nls/russian/set19 b/contrib/tcsh/nls/russian/set19
index 676d810..2824aba 100644
--- a/contrib/tcsh/nls/russian/set19
+++ b/contrib/tcsh/nls/russian/set19
@@ -1,4 +1,4 @@
-$ $Id: set19,v 1.2 2002/03/08 17:46:50 christos Exp $
+$ $tcsh: set19,v 1.3 2006/03/02 18:46:47 christos Exp $
$ tc.alloc.c
$set 19
1 nbytes=%d: îÅÔ ÐÁÍÑÔÉ\n
diff --git a/contrib/tcsh/nls/russian/set2 b/contrib/tcsh/nls/russian/set2
index 0fa8fba..1466e73 100644
--- a/contrib/tcsh/nls/russian/set2
+++ b/contrib/tcsh/nls/russian/set2
@@ -1,4 +1,4 @@
-$ $Id: set2,v 1.2 2002/03/08 17:46:50 christos Exp $
+$ $tcsh: set2,v 1.3 2006/03/02 18:46:47 christos Exp $
$ Signal names
$set 2
1 îÕÌÅ×ÏÊ ÓÉÇÎÁÌ
diff --git a/contrib/tcsh/nls/russian/set20 b/contrib/tcsh/nls/russian/set20
index 7835994..d8df302 100644
--- a/contrib/tcsh/nls/russian/set20
+++ b/contrib/tcsh/nls/russian/set20
@@ -1,4 +1,4 @@
-$ $Id: set20,v 1.4 2002/03/08 17:46:50 christos Exp $
+$ $tcsh: set20,v 1.5 2006/03/02 18:46:47 christos Exp $
$ tc.bind.c
$set 20
1 îÅ×ÅÒÎÏÅ ÉÍÑ ËÌÁ×ÉÛÉ `%S'\n
diff --git a/contrib/tcsh/nls/russian/set21 b/contrib/tcsh/nls/russian/set21
index 75533f8..38562a9 100644
--- a/contrib/tcsh/nls/russian/set21
+++ b/contrib/tcsh/nls/russian/set21
@@ -1,4 +1,4 @@
-$ $Id: set21,v 1.1 2001/03/18 19:06:39 christos Exp $
+$ $tcsh: set21,v 1.2 2006/03/02 18:46:47 christos Exp $
$ tc.disc.c
$set 21
1 Couldn't get local chars.\n
diff --git a/contrib/tcsh/nls/russian/set22 b/contrib/tcsh/nls/russian/set22
index b1d4e05..02b53f5 100644
--- a/contrib/tcsh/nls/russian/set22
+++ b/contrib/tcsh/nls/russian/set22
@@ -1,4 +1,4 @@
-$ $Id: set22,v 1.3 2002/03/08 17:46:50 christos Exp $
+$ $tcsh: set22,v 1.4 2006/03/02 18:46:47 christos Exp $
$ tc.func.c
$set 22
1 %S: \t ÐÅÒÅÏÐÒÅÄÅÌÅÎÏ ×
diff --git a/contrib/tcsh/nls/russian/set23 b/contrib/tcsh/nls/russian/set23
index 3134bb7..7d77ab8 100644
--- a/contrib/tcsh/nls/russian/set23
+++ b/contrib/tcsh/nls/russian/set23
@@ -1,4 +1,4 @@
-$ $Id: set23,v 1.2 2002/03/08 17:46:50 christos Exp $
+$ $tcsh: set23,v 1.3 2006/03/02 18:46:47 christos Exp $
$ tc.os.c
$set 23
1 Bad cpu/site name
diff --git a/contrib/tcsh/nls/russian/set24 b/contrib/tcsh/nls/russian/set24
index dffed27..0c3ca90 100644
--- a/contrib/tcsh/nls/russian/set24
+++ b/contrib/tcsh/nls/russian/set24
@@ -1,4 +1,4 @@
-$ $Id: set24,v 1.1 2001/03/18 19:06:40 christos Exp $
+$ $tcsh: set24,v 1.2 2006/03/02 18:46:47 christos Exp $
$ tc.sched.c
$set 24
1 kludge
diff --git a/contrib/tcsh/nls/russian/set25 b/contrib/tcsh/nls/russian/set25
index 481ecfd..ff9aab9 100644
--- a/contrib/tcsh/nls/russian/set25
+++ b/contrib/tcsh/nls/russian/set25
@@ -1,4 +1,4 @@
-$ $Id: set25,v 1.1 2001/03/18 19:06:40 christos Exp $
+$ $tcsh: set25,v 1.2 2006/03/02 18:46:47 christos Exp $
$ tc.sig.c
$set 25
1 our wait %d\n
diff --git a/contrib/tcsh/nls/russian/set26 b/contrib/tcsh/nls/russian/set26
index f351f29..5aefd22 100644
--- a/contrib/tcsh/nls/russian/set26
+++ b/contrib/tcsh/nls/russian/set26
@@ -1,4 +1,4 @@
-$ $Id: set26,v 1.2 2002/03/08 17:46:50 christos Exp $
+$ $tcsh: set26,v 1.3 2006/03/02 18:46:48 christos Exp $
$ tc.who.c
$set 26
1 ÎÅ ÍÏÇÕ ×ÙÐÏÌÎÉÔØ stat ÎÁ %s. ðÏÖÁÌÕÊÓÔÁ, ×ÙÐÏÌÎÉÔÅ "unset watch".\n
diff --git a/contrib/tcsh/nls/russian/set27 b/contrib/tcsh/nls/russian/set27
index 42de518..a995389 100644
--- a/contrib/tcsh/nls/russian/set27
+++ b/contrib/tcsh/nls/russian/set27
@@ -1,4 +1,4 @@
-$ $Id: set27,v 1.3 2002/03/08 17:46:50 christos Exp $
+$ $tcsh: set27,v 1.4 2006/03/02 18:46:48 christos Exp $
$ tw.comp.c
$set 27
1 ËÏÍÁÎÄÁ
diff --git a/contrib/tcsh/nls/russian/set29 b/contrib/tcsh/nls/russian/set29
index 66b554b..b7b4da9 100644
--- a/contrib/tcsh/nls/russian/set29
+++ b/contrib/tcsh/nls/russian/set29
@@ -1,4 +1,4 @@
-$ $Id: set29,v 1.1 2001/03/18 19:06:41 christos Exp $
+$ $tcsh: set29,v 1.2 2006/03/02 18:46:48 christos Exp $
$ tw.help.c
$set 29
1 ïÔÓÕÔÓÔ×ÕÅÔ ÆÁÊÌ ÐÏÍÏÝÉ ÄÌÑ %S\n
diff --git a/contrib/tcsh/nls/russian/set3 b/contrib/tcsh/nls/russian/set3
index 9442f1f..1eb6471 100644
--- a/contrib/tcsh/nls/russian/set3
+++ b/contrib/tcsh/nls/russian/set3
@@ -1,4 +1,4 @@
-$ $Id: set3,v 1.3 2002/03/08 17:46:50 christos Exp $
+$ $tcsh: set3,v 1.4 2006/03/02 18:46:48 christos Exp $
$ Editor function descriptions
$set 3
1 Move back a character
diff --git a/contrib/tcsh/nls/russian/set30 b/contrib/tcsh/nls/russian/set30
index 39e02fa..7ac5fe6 100644
--- a/contrib/tcsh/nls/russian/set30
+++ b/contrib/tcsh/nls/russian/set30
@@ -1,4 +1,4 @@
-$ $Id: set30,v 1.3 2003/05/26 07:11:07 christos Exp $
+$ $tcsh: set30,v 1.4 2006/03/02 18:46:48 christos Exp $
$ tw.parse.c
$set 30
1 starting_a_command %d\n
diff --git a/contrib/tcsh/nls/russian/set31 b/contrib/tcsh/nls/russian/set31
index 432810a..908cb02 100644
--- a/contrib/tcsh/nls/russian/set31
+++ b/contrib/tcsh/nls/russian/set31
@@ -1,4 +1,4 @@
-$ $Id: set31,v 1.2 2002/03/08 17:46:50 christos Exp $
+$ $tcsh: set31,v 1.3 2006/03/02 18:46:48 christos Exp $
$ vms.termcap.c
$set 31
1 îÅ ÍÏÇÕ ÏÔËÒÙÔØ TERMCAP: [%s]\n
diff --git a/contrib/tcsh/nls/russian/set4 b/contrib/tcsh/nls/russian/set4
index dd01982..58d8415 100644
--- a/contrib/tcsh/nls/russian/set4
+++ b/contrib/tcsh/nls/russian/set4
@@ -1,4 +1,4 @@
-$ $Id: set4,v 1.2 2002/03/08 17:46:50 christos Exp $
+$ $tcsh: set4,v 1.3 2006/03/02 18:46:48 christos Exp $
$ Termcap strings
$set 4
1 ÄÏÂÁ×ÉÔØ ÎÏ×ÕÀ ÐÕÓÔÕÀ ÓÔÒÏËÕ
diff --git a/contrib/tcsh/nls/russian/set5 b/contrib/tcsh/nls/russian/set5
index c237e84..6e48898 100644
--- a/contrib/tcsh/nls/russian/set5
+++ b/contrib/tcsh/nls/russian/set5
@@ -1,4 +1,4 @@
-$ $Id: set5,v 1.1 2001/03/18 19:06:43 christos Exp $
+$ $tcsh: set5,v 1.2 2006/03/02 18:46:48 christos Exp $
$ ed.chared.c
$set 5
1 óÒÅÄÎÑÑ ÚÁÇÒÕÚËÁ ÎÅÄÏÓÔÕÐÎÁ\n
diff --git a/contrib/tcsh/nls/russian/set6 b/contrib/tcsh/nls/russian/set6
index 2d05145..bffc35e 100644
--- a/contrib/tcsh/nls/russian/set6
+++ b/contrib/tcsh/nls/russian/set6
@@ -1,4 +1,4 @@
-$ $Id: set6,v 1.2 2002/03/08 17:46:50 christos Exp $
+$ $tcsh: set6,v 1.3 2006/03/02 18:46:48 christos Exp $
$ ed.inputl.c
$set 6
1 ïûéâëá: ÎÅ×ÅÒÎÁÑ ËÏÍÁÎÄÁ ËÌÀÞÁ 0%o\r\n
diff --git a/contrib/tcsh/nls/russian/set7 b/contrib/tcsh/nls/russian/set7
index d3788ae..7f7cbc7 100644
--- a/contrib/tcsh/nls/russian/set7
+++ b/contrib/tcsh/nls/russian/set7
@@ -1,4 +1,4 @@
-$ $Id: set7,v 1.2 2002/03/08 17:46:50 christos Exp $
+$ $tcsh: set7,v 1.3 2006/03/02 18:46:48 christos Exp $
$ ed.screen.c
$set 7
1 \n\tTcsh thinks your terminal has the\n
diff --git a/contrib/tcsh/nls/russian/set8 b/contrib/tcsh/nls/russian/set8
index bf5b6af..80bede0 100644
--- a/contrib/tcsh/nls/russian/set8
+++ b/contrib/tcsh/nls/russian/set8
@@ -1,4 +1,4 @@
-$ $Id: set8,v 1.1 2001/03/18 19:06:44 christos Exp $
+$ $tcsh: set8,v 1.2 2006/03/02 18:46:48 christos Exp $
$ ed.term.c
$set 8
1 îÅÉÚ×ÅÓÔÎÙÊ ÐÅÒÅËÌÀÞÁÔÅÌØ
diff --git a/contrib/tcsh/nls/russian/set9 b/contrib/tcsh/nls/russian/set9
index cc65c73..cef9379 100644
--- a/contrib/tcsh/nls/russian/set9
+++ b/contrib/tcsh/nls/russian/set9
@@ -1,4 +1,4 @@
-$ $Id: set9,v 1.2 2002/03/08 17:46:50 christos Exp $
+$ $tcsh: set9,v 1.3 2006/03/02 18:46:48 christos Exp $
$ ed.xmap.c
$set 9
1 AddXkey: Null extended-key not allowed.\n
diff --git a/contrib/tcsh/nls/spanish/set1 b/contrib/tcsh/nls/spanish/set1
index 8c1b663..0accb67 100644
--- a/contrib/tcsh/nls/spanish/set1
+++ b/contrib/tcsh/nls/spanish/set1
@@ -1,4 +1,4 @@
-$ $Id: set1,v 1.2 1998/06/27 12:28:02 christos Exp $
+$ $tcsh: set1,v 1.3 2006/03/02 18:46:48 christos Exp $
$ Mensajes de Error
$set 1
1 Error de sintaxis
diff --git a/contrib/tcsh/nls/spanish/set10 b/contrib/tcsh/nls/spanish/set10
index 867c794..8d5b057 100644
--- a/contrib/tcsh/nls/spanish/set10
+++ b/contrib/tcsh/nls/spanish/set10
@@ -1,4 +1,4 @@
-$ $Id: set10,v 1.1 1998/04/08 17:59:51 christos Exp $
+$ $tcsh: set10,v 1.2 2006/03/02 18:46:48 christos Exp $
$ ma.setp.c
$set 10
1 setpath: comando '%s' incorrecto.\n
diff --git a/contrib/tcsh/nls/spanish/set11 b/contrib/tcsh/nls/spanish/set11
index d54fddc..cb96ec8 100644
--- a/contrib/tcsh/nls/spanish/set11
+++ b/contrib/tcsh/nls/spanish/set11
@@ -1,4 +1,4 @@
-$ $Id: set11,v 1.1 1998/04/08 17:59:52 christos Exp $
+$ $tcsh: set11,v 1.2 2006/03/02 18:46:48 christos Exp $
$ sh.c
$set 11
1 Aviso: no se puede acceder a la tty (%s).\n
diff --git a/contrib/tcsh/nls/spanish/set12 b/contrib/tcsh/nls/spanish/set12
index 5e24d3b..06f43f4 100644
--- a/contrib/tcsh/nls/spanish/set12
+++ b/contrib/tcsh/nls/spanish/set12
@@ -1,4 +1,4 @@
-$ $Id: set12,v 1.1 1998/04/08 17:59:53 christos Exp $
+$ $tcsh: set12,v 1.2 2006/03/02 18:46:48 christos Exp $
$ sh.dir.c
$set 12
1 %s: Tratando de empezar desde "%s"\n
diff --git a/contrib/tcsh/nls/spanish/set13 b/contrib/tcsh/nls/spanish/set13
index 5a49329..12b32b0 100644
--- a/contrib/tcsh/nls/spanish/set13
+++ b/contrib/tcsh/nls/spanish/set13
@@ -1,4 +1,4 @@
-$ $Id: set13,v 1.1 1998/04/08 17:59:54 christos Exp $
+$ $tcsh: set13,v 1.2 2006/03/02 18:46:48 christos Exp $
$ sh.exec.c
$set 13
1 hash=%-4d dir=%-2d prog=%s\n
diff --git a/contrib/tcsh/nls/spanish/set14 b/contrib/tcsh/nls/spanish/set14
index 62db4cd..5bb621e 100644
--- a/contrib/tcsh/nls/spanish/set14
+++ b/contrib/tcsh/nls/spanish/set14
@@ -1,4 +1,4 @@
-$ $Id: set14,v 1.1 1998/04/08 17:59:55 christos Exp $
+$ $tcsh: set14,v 1.2 2006/03/02 18:46:48 christos Exp $
$ sh.file.c
$set 14
1 \n¡¡Qué asco!! ¡¡Hay demasiados %s!!\n
diff --git a/contrib/tcsh/nls/spanish/set15 b/contrib/tcsh/nls/spanish/set15
index 7408500..825af2e 100644
--- a/contrib/tcsh/nls/spanish/set15
+++ b/contrib/tcsh/nls/spanish/set15
@@ -1,4 +1,4 @@
-$ $Id: set15,v 1.1 1998/04/08 17:59:56 christos Exp $
+$ $tcsh: set15,v 1.2 2006/03/02 18:46:48 christos Exp $
$ sh.func.c
$set 15
1 %s: %s: No se puede %s el límite %s\n
diff --git a/contrib/tcsh/nls/spanish/set16 b/contrib/tcsh/nls/spanish/set16
index 58f8d5b..0482ffa 100644
--- a/contrib/tcsh/nls/spanish/set16
+++ b/contrib/tcsh/nls/spanish/set16
@@ -1,4 +1,4 @@
-$ $Id: set16,v 1.1 1998/04/08 17:59:56 christos Exp $
+$ $tcsh: set16,v 1.2 2006/03/02 18:46:48 christos Exp $
$ sh.lex.c
$set 16
1 Se ha reinicializado el grupo de procesos de las terminales de %d a %d\n
diff --git a/contrib/tcsh/nls/spanish/set17 b/contrib/tcsh/nls/spanish/set17
index ce9621a..02df187 100644
--- a/contrib/tcsh/nls/spanish/set17
+++ b/contrib/tcsh/nls/spanish/set17
@@ -1,4 +1,4 @@
-$ $Id: set17,v 1.2 2003/02/08 20:03:28 christos Exp $
+$ $tcsh: set17,v 1.3 2006/03/02 18:46:48 christos Exp $
$ sh.proc.c
$set 17
1 BUG: ¡en espera de un trabajo en segundo plano!\n
diff --git a/contrib/tcsh/nls/spanish/set18 b/contrib/tcsh/nls/spanish/set18
index 6db6343..b2d7736 100644
--- a/contrib/tcsh/nls/spanish/set18
+++ b/contrib/tcsh/nls/spanish/set18
@@ -1,4 +1,4 @@
-$ $Id: set18,v 1.1 1998/04/08 17:59:58 christos Exp $
+$ $tcsh: set18,v 1.2 2006/03/02 18:46:48 christos Exp $
$ sh.set.c
$set 18
1 Aviso: PATH de tamaño ridículo ha sido truncado\n
diff --git a/contrib/tcsh/nls/spanish/set19 b/contrib/tcsh/nls/spanish/set19
index 8424412..fdce85d 100644
--- a/contrib/tcsh/nls/spanish/set19
+++ b/contrib/tcsh/nls/spanish/set19
@@ -1,4 +1,4 @@
-$ $Id: set19,v 1.1 1998/04/08 17:59:59 christos Exp $
+$ $tcsh: set19,v 1.2 2006/03/02 18:46:48 christos Exp $
$ tc.alloc.c
$set 19
1 nbytes=%d: Se ha agotado la memoria\n
diff --git a/contrib/tcsh/nls/spanish/set2 b/contrib/tcsh/nls/spanish/set2
index a8761d0..b73c693 100644
--- a/contrib/tcsh/nls/spanish/set2
+++ b/contrib/tcsh/nls/spanish/set2
@@ -1,4 +1,4 @@
-$ $Id: set2,v 1.1 1998/04/08 17:59:59 christos Exp $
+$ $tcsh: set2,v 1.2 2006/03/02 18:46:48 christos Exp $
$ Nombres de señales
$set 2
1 Señal nula
diff --git a/contrib/tcsh/nls/spanish/set20 b/contrib/tcsh/nls/spanish/set20
index 3709ce4..9458fef 100644
--- a/contrib/tcsh/nls/spanish/set20
+++ b/contrib/tcsh/nls/spanish/set20
@@ -1,4 +1,4 @@
-$ $Id: set20,v 1.2 2001/04/26 19:09:19 kim Exp $
+$ $tcsh: set20,v 1.3 2006/03/02 18:46:48 christos Exp $
$ tc.bind.c
$set 20
1 Nombre de tecla no válido `%S'\n
diff --git a/contrib/tcsh/nls/spanish/set21 b/contrib/tcsh/nls/spanish/set21
index 5e4a734..706127b 100644
--- a/contrib/tcsh/nls/spanish/set21
+++ b/contrib/tcsh/nls/spanish/set21
@@ -1,4 +1,4 @@
-$ $Id: set21,v 1.1 1998/04/08 18:00:02 christos Exp $
+$ $tcsh: set21,v 1.2 2006/03/02 18:46:48 christos Exp $
$ tc.disc.c
$set 21
1 No he podido leer los caracteres locales.\n
diff --git a/contrib/tcsh/nls/spanish/set22 b/contrib/tcsh/nls/spanish/set22
index 268e307..fb311ae 100644
--- a/contrib/tcsh/nls/spanish/set22
+++ b/contrib/tcsh/nls/spanish/set22
@@ -1,4 +1,4 @@
-$ $Id: set22,v 1.1 1998/04/08 18:00:03 christos Exp $
+$ $tcsh: set22,v 1.2 2006/03/02 18:46:48 christos Exp $
$ tc.func.c
$set 22
1 %S: \t es un alias de
diff --git a/contrib/tcsh/nls/spanish/set23 b/contrib/tcsh/nls/spanish/set23
index 08eb8df..86a81e4 100644
--- a/contrib/tcsh/nls/spanish/set23
+++ b/contrib/tcsh/nls/spanish/set23
@@ -1,4 +1,4 @@
-$ $Id: set23,v 1.1 1998/04/08 18:00:03 christos Exp $
+$ $tcsh: set23,v 1.2 2006/03/02 18:46:48 christos Exp $
$ tc.os.c
$set 23
1 Nombre de cpu/máquina incorrecto
diff --git a/contrib/tcsh/nls/spanish/set24 b/contrib/tcsh/nls/spanish/set24
index 9da94ee..b12289d 100644
--- a/contrib/tcsh/nls/spanish/set24
+++ b/contrib/tcsh/nls/spanish/set24
@@ -1,4 +1,4 @@
-$ $Id: set24,v 1.1 1998/04/08 18:00:04 christos Exp $
+$ $tcsh: set24,v 1.2 2006/03/02 18:46:48 christos Exp $
$ tc.sched.c
$set 24
1 chapuza
diff --git a/contrib/tcsh/nls/spanish/set25 b/contrib/tcsh/nls/spanish/set25
index 2b96300..c81ef4a 100644
--- a/contrib/tcsh/nls/spanish/set25
+++ b/contrib/tcsh/nls/spanish/set25
@@ -1,4 +1,4 @@
-$ $Id: set25,v 1.1 1998/04/08 18:00:05 christos Exp $
+$ $tcsh: set25,v 1.2 2006/03/02 18:46:48 christos Exp $
$ tc.sig.c
$set 25
1 nuestro wait %d\n
diff --git a/contrib/tcsh/nls/spanish/set26 b/contrib/tcsh/nls/spanish/set26
index a4fed2c..74c990e 100644
--- a/contrib/tcsh/nls/spanish/set26
+++ b/contrib/tcsh/nls/spanish/set26
@@ -1,4 +1,4 @@
-$ $Id: set26,v 1.1 1998/04/08 18:00:06 christos Exp $
+$ $tcsh: set26,v 1.2 2006/03/02 18:46:48 christos Exp $
$ tc.who.c
$set 26
1 No se puede completar stat %s. Por favor, ejecute "unset watch".\n
diff --git a/contrib/tcsh/nls/spanish/set27 b/contrib/tcsh/nls/spanish/set27
index 8cc991e..6f75760 100644
--- a/contrib/tcsh/nls/spanish/set27
+++ b/contrib/tcsh/nls/spanish/set27
@@ -1,4 +1,4 @@
-$ $Id: set27,v 1.1 1998/04/08 18:00:07 christos Exp $
+$ $tcsh: set27,v 1.2 2006/03/02 18:46:48 christos Exp $
$ tw.comp.c
$set 27
1 comando
diff --git a/contrib/tcsh/nls/spanish/set29 b/contrib/tcsh/nls/spanish/set29
index 712d6b5..c7a4921 100644
--- a/contrib/tcsh/nls/spanish/set29
+++ b/contrib/tcsh/nls/spanish/set29
@@ -1,4 +1,4 @@
-$ $Id: set29,v 1.1 1998/04/08 18:00:07 christos Exp $
+$ $tcsh: set29,v 1.2 2006/03/02 18:46:48 christos Exp $
$ tw.help.c
$set 29
1 No hay archivo de ayuda sobre %S\n
diff --git a/contrib/tcsh/nls/spanish/set3 b/contrib/tcsh/nls/spanish/set3
index 196a8eb..2465dec 100644
--- a/contrib/tcsh/nls/spanish/set3
+++ b/contrib/tcsh/nls/spanish/set3
@@ -1,4 +1,4 @@
-$ $Id: set3,v 1.2 2001/04/26 19:07:51 kim Exp $
+$ $tcsh: set3,v 1.3 2006/03/02 18:46:48 christos Exp $
$ Descripción de las funciones de edición
$set 3
1 Retroceder un carácter
diff --git a/contrib/tcsh/nls/spanish/set30 b/contrib/tcsh/nls/spanish/set30
index d89e708..ea9e5be 100644
--- a/contrib/tcsh/nls/spanish/set30
+++ b/contrib/tcsh/nls/spanish/set30
@@ -1,4 +1,4 @@
-$ $Id: set30,v 1.1 1998/04/08 18:00:09 christos Exp $
+$ $tcsh: set30,v 1.2 2006/03/02 18:46:48 christos Exp $
$ tw.parse.c
$set 30
1 comienzo_de_comando %d\n
diff --git a/contrib/tcsh/nls/spanish/set31 b/contrib/tcsh/nls/spanish/set31
index 00cb295..52a50b9 100644
--- a/contrib/tcsh/nls/spanish/set31
+++ b/contrib/tcsh/nls/spanish/set31
@@ -1,4 +1,4 @@
-$ $Id: set31,v 1.1 1998/04/08 18:00:10 christos Exp $
+$ $tcsh: set31,v 1.2 2006/03/02 18:46:48 christos Exp $
$ vms.termcap.c
$set 31
1 No se puede abrir TERMCAP: [%s]\n
diff --git a/contrib/tcsh/nls/spanish/set4 b/contrib/tcsh/nls/spanish/set4
index 04c1766..1ca3b69 100644
--- a/contrib/tcsh/nls/spanish/set4
+++ b/contrib/tcsh/nls/spanish/set4
@@ -1,4 +1,4 @@
-$ $Id: set4,v 1.1 1998/04/08 18:00:11 christos Exp $
+$ $tcsh: set4,v 1.2 2006/03/02 18:46:48 christos Exp $
$ cadenas de Termcap
$set 4
1 añade una línea vacía
diff --git a/contrib/tcsh/nls/spanish/set5 b/contrib/tcsh/nls/spanish/set5
index ba7a18f..4ec38af 100644
--- a/contrib/tcsh/nls/spanish/set5
+++ b/contrib/tcsh/nls/spanish/set5
@@ -1,4 +1,4 @@
-$ $Id: set5,v 1.1 1998/04/08 18:00:11 christos Exp $
+$ $tcsh: set5,v 1.2 2006/03/02 18:46:48 christos Exp $
$ ed.chared.c
$set 5
1 No está disponible la carga media\n
diff --git a/contrib/tcsh/nls/spanish/set6 b/contrib/tcsh/nls/spanish/set6
index 134eceb..06ded32 100644
--- a/contrib/tcsh/nls/spanish/set6
+++ b/contrib/tcsh/nls/spanish/set6
@@ -1,4 +1,4 @@
-$ $Id: set6,v 1.1 1998/04/08 18:00:12 christos Exp $
+$ $tcsh: set6,v 1.2 2006/03/02 18:46:48 christos Exp $
$ ed.inputl.c
$set 6
1 ERROR: comando ilegal asignado a la tecla 0%o\r\n
diff --git a/contrib/tcsh/nls/spanish/set7 b/contrib/tcsh/nls/spanish/set7
index 7fe22f5..a50dbcd 100644
--- a/contrib/tcsh/nls/spanish/set7
+++ b/contrib/tcsh/nls/spanish/set7
@@ -1,4 +1,4 @@
-$ $Id: set7,v 1.1 1998/04/08 18:00:13 christos Exp $
+$ $tcsh: set7,v 1.2 2006/03/02 18:46:48 christos Exp $
$ ed.screen.c
$set 7
1 \n\tTcsh cree que su terminal tiene las\n
diff --git a/contrib/tcsh/nls/spanish/set8 b/contrib/tcsh/nls/spanish/set8
index b997466..abda415 100644
--- a/contrib/tcsh/nls/spanish/set8
+++ b/contrib/tcsh/nls/spanish/set8
@@ -1,4 +1,4 @@
-$ $Id: set8,v 1.1 1998/04/08 18:00:14 christos Exp $
+$ $tcsh: set8,v 1.2 2006/03/02 18:46:48 christos Exp $
$ ed.term.c
$set 8
1 Interruptor desconocido
diff --git a/contrib/tcsh/nls/spanish/set9 b/contrib/tcsh/nls/spanish/set9
index 14e4629..c94db08 100644
--- a/contrib/tcsh/nls/spanish/set9
+++ b/contrib/tcsh/nls/spanish/set9
@@ -1,4 +1,4 @@
-$ $Id: set9,v 1.1 1998/04/08 18:00:14 christos Exp $
+$ $tcsh: set9,v 1.2 2006/03/02 18:46:48 christos Exp $
$ ed.xmap.c
$set 9
1 AddXkey: No se permite una tecla extendida nula.\n
diff --git a/contrib/tcsh/nls/ukrainian/set1 b/contrib/tcsh/nls/ukrainian/set1
index edf93be..2a4aa95 100644
--- a/contrib/tcsh/nls/ukrainian/set1
+++ b/contrib/tcsh/nls/ukrainian/set1
@@ -1,4 +1,4 @@
-$ $Id: set1,v 1.2 2002/07/01 20:50:22 christos Exp $
+$ $tcsh: set1,v 1.3 2006/03/02 18:46:48 christos Exp $
$ Error messages
$set 1
1 óÉÎÔÁËÓÉÞÎÁ ÐÏÍÉÌËÁ
diff --git a/contrib/tcsh/nls/ukrainian/set10 b/contrib/tcsh/nls/ukrainian/set10
index 3b95c51..a406c51 100644
--- a/contrib/tcsh/nls/ukrainian/set10
+++ b/contrib/tcsh/nls/ukrainian/set10
@@ -1,4 +1,4 @@
-$ $Id: set10,v 1.2 2002/07/01 20:50:22 christos Exp $
+$ $tcsh: set10,v 1.3 2006/03/02 18:46:48 christos Exp $
$ ma.setp.c
$set 10
1 setpath: ÎÅצÒÎÁ ËÏÍÁÎÄÁ '%s'.\n
diff --git a/contrib/tcsh/nls/ukrainian/set11 b/contrib/tcsh/nls/ukrainian/set11
index d9bd51a..4fa15f6 100644
--- a/contrib/tcsh/nls/ukrainian/set11
+++ b/contrib/tcsh/nls/ukrainian/set11
@@ -1,4 +1,4 @@
-$ $Id: set11,v 1.2 2002/07/01 20:50:22 christos Exp $
+$ $tcsh: set11,v 1.3 2006/03/02 18:46:48 christos Exp $
$ sh.c
$set 11
1 õ×ÁÇÁ: ÎÅÍÁ¤ ÄÏÓÔÕÐÕ ÄÏ tty (%s).\n
diff --git a/contrib/tcsh/nls/ukrainian/set12 b/contrib/tcsh/nls/ukrainian/set12
index 595bd95..d55bcfa 100644
--- a/contrib/tcsh/nls/ukrainian/set12
+++ b/contrib/tcsh/nls/ukrainian/set12
@@ -1,4 +1,4 @@
-$ $Id: set12,v 1.2 2002/07/01 20:50:22 christos Exp $
+$ $tcsh: set12,v 1.3 2006/03/02 18:46:48 christos Exp $
$ sh.dir.c
$set 12
1 %s: óÐÒÏÂÕÀ ÐÏÞÁÔÉ Ú "%s"\n
diff --git a/contrib/tcsh/nls/ukrainian/set13 b/contrib/tcsh/nls/ukrainian/set13
index 6554966..a7f08b3 100644
--- a/contrib/tcsh/nls/ukrainian/set13
+++ b/contrib/tcsh/nls/ukrainian/set13
@@ -1,4 +1,4 @@
-$ $Id: set13,v 1.2 2002/07/01 20:50:22 christos Exp $
+$ $tcsh: set13,v 1.3 2006/03/02 18:46:48 christos Exp $
$ sh.exec.c
$set 13
1 ÈÅÛ=%-4d dir=%-2d prog=%s\n
diff --git a/contrib/tcsh/nls/ukrainian/set14 b/contrib/tcsh/nls/ukrainian/set14
index 5989b93..faa6ac6 100644
--- a/contrib/tcsh/nls/ukrainian/set14
+++ b/contrib/tcsh/nls/ukrainian/set14
@@ -1,4 +1,4 @@
-$ $Id: set14,v 1.2 2002/07/01 20:50:22 christos Exp $
+$ $tcsh: set14,v 1.3 2006/03/02 18:46:48 christos Exp $
$ sh.file.c
$set 14
1 \nïÊ!! úÁÂÁÇÁÔÏ %s!!\n
diff --git a/contrib/tcsh/nls/ukrainian/set15 b/contrib/tcsh/nls/ukrainian/set15
index ff2ab10..498362f 100644
--- a/contrib/tcsh/nls/ukrainian/set15
+++ b/contrib/tcsh/nls/ukrainian/set15
@@ -1,4 +1,4 @@
-$ $Id: set15,v 1.2 2002/07/01 20:50:22 christos Exp $
+$ $tcsh: set15,v 1.3 2006/03/02 18:46:48 christos Exp $
$ sh.func.c
$set 15
1 %s: %s: îÅ ÍÏÖÕ %s%s ̦ͦÔ\n
diff --git a/contrib/tcsh/nls/ukrainian/set16 b/contrib/tcsh/nls/ukrainian/set16
index fc0e609..f5cb670 100644
--- a/contrib/tcsh/nls/ukrainian/set16
+++ b/contrib/tcsh/nls/ukrainian/set16
@@ -1,4 +1,4 @@
-$ $Id: set16,v 1.2 2002/07/01 20:50:22 christos Exp $
+$ $tcsh: set16,v 1.3 2006/03/02 18:46:48 christos Exp $
$ sh.lex.c
$set 16
1 Reset tty pgrp from %d to %d\n
diff --git a/contrib/tcsh/nls/ukrainian/set17 b/contrib/tcsh/nls/ukrainian/set17
index a286b38..f790544 100644
--- a/contrib/tcsh/nls/ukrainian/set17
+++ b/contrib/tcsh/nls/ukrainian/set17
@@ -1,4 +1,4 @@
-$ $Id: set17,v 1.3 2003/02/08 20:03:28 christos Exp $
+$ $tcsh: set17,v 1.4 2006/03/02 18:46:48 christos Exp $
$ sh.proc.c
$set 17
1 ðïíéìëá: ÏÞ¦ËÕ×ÁÎÎÑ ÆÏÎÏ×ϧ ÚÁÄÁÞ¦!\n
diff --git a/contrib/tcsh/nls/ukrainian/set18 b/contrib/tcsh/nls/ukrainian/set18
index 53128aa..c3d82bf 100644
--- a/contrib/tcsh/nls/ukrainian/set18
+++ b/contrib/tcsh/nls/ukrainian/set18
@@ -1,4 +1,4 @@
-$ $Id: set18,v 1.2 2002/07/01 20:50:22 christos Exp $
+$ $tcsh: set18,v 1.3 2006/03/02 18:46:48 christos Exp $
$ sh.set.c
$set 18
1 õ×ÁÇÁ: ÚÁÄÏ×ÇÉÊ PATH ÏÂÒ¦ÚÁÎÏ\n
diff --git a/contrib/tcsh/nls/ukrainian/set19 b/contrib/tcsh/nls/ukrainian/set19
index 220b359..ae57dfa 100644
--- a/contrib/tcsh/nls/ukrainian/set19
+++ b/contrib/tcsh/nls/ukrainian/set19
@@ -1,4 +1,4 @@
-$ $Id: set19,v 1.2 2002/07/01 20:50:22 christos Exp $
+$ $tcsh: set19,v 1.3 2006/03/02 18:46:48 christos Exp $
$ tc.alloc.c
$set 19
1 nbytes=%d: íÁÌÏ ÐÁÍ'ÑÔ¦\n
diff --git a/contrib/tcsh/nls/ukrainian/set2 b/contrib/tcsh/nls/ukrainian/set2
index 2ecef12..b25777f 100644
--- a/contrib/tcsh/nls/ukrainian/set2
+++ b/contrib/tcsh/nls/ukrainian/set2
@@ -1,4 +1,4 @@
-$ $Id: set2,v 1.2 2002/07/01 20:50:22 christos Exp $
+$ $tcsh: set2,v 1.3 2006/03/02 18:46:48 christos Exp $
$ Signal names
$set 2
1 îÕÌØÏ×ÉÊ ÓÉÇÎÁÌ
diff --git a/contrib/tcsh/nls/ukrainian/set20 b/contrib/tcsh/nls/ukrainian/set20
index 7fd91c8..64be44e 100644
--- a/contrib/tcsh/nls/ukrainian/set20
+++ b/contrib/tcsh/nls/ukrainian/set20
@@ -1,4 +1,4 @@
-$ $Id: set20,v 1.2 2002/07/01 20:50:22 christos Exp $
+$ $tcsh: set20,v 1.3 2006/03/02 18:46:48 christos Exp $
$ tc.bind.c
$set 20
1 Invalid key name `%S'\n
diff --git a/contrib/tcsh/nls/ukrainian/set21 b/contrib/tcsh/nls/ukrainian/set21
index 4f6c139..8d6c3a8 100644
--- a/contrib/tcsh/nls/ukrainian/set21
+++ b/contrib/tcsh/nls/ukrainian/set21
@@ -1,4 +1,4 @@
-$ $Id: set21,v 1.2 2002/07/01 20:50:22 christos Exp $
+$ $tcsh: set21,v 1.3 2006/03/02 18:46:48 christos Exp $
$ tc.disc.c
$set 21
1 Couldn't get local chars.\n
diff --git a/contrib/tcsh/nls/ukrainian/set22 b/contrib/tcsh/nls/ukrainian/set22
index e0cb878..534298e 100644
--- a/contrib/tcsh/nls/ukrainian/set22
+++ b/contrib/tcsh/nls/ukrainian/set22
@@ -1,4 +1,4 @@
-$ $Id: set22,v 1.2 2002/07/01 20:50:22 christos Exp $
+$ $tcsh: set22,v 1.3 2006/03/02 18:46:48 christos Exp $
$ tc.func.c
$set 22
1 %S: \t ÐÅÒÅ×ÉÚÎÁÞÅÎÏ ÎÁ
diff --git a/contrib/tcsh/nls/ukrainian/set23 b/contrib/tcsh/nls/ukrainian/set23
index 4b8a543..f62702b 100644
--- a/contrib/tcsh/nls/ukrainian/set23
+++ b/contrib/tcsh/nls/ukrainian/set23
@@ -1,4 +1,4 @@
-$ $Id: set23,v 1.2 2002/07/01 20:50:22 christos Exp $
+$ $tcsh: set23,v 1.3 2006/03/02 18:46:48 christos Exp $
$ tc.os.c
$set 23
1 Bad cpu/site name
diff --git a/contrib/tcsh/nls/ukrainian/set24 b/contrib/tcsh/nls/ukrainian/set24
index d0460de..80482f6 100644
--- a/contrib/tcsh/nls/ukrainian/set24
+++ b/contrib/tcsh/nls/ukrainian/set24
@@ -1,4 +1,4 @@
-$ $Id: set24,v 1.2 2002/07/01 20:50:22 christos Exp $
+$ $tcsh: set24,v 1.3 2006/03/02 18:46:48 christos Exp $
$ tc.sched.c
$set 24
1 kludge
diff --git a/contrib/tcsh/nls/ukrainian/set25 b/contrib/tcsh/nls/ukrainian/set25
index 9b5a9e1..0769521 100644
--- a/contrib/tcsh/nls/ukrainian/set25
+++ b/contrib/tcsh/nls/ukrainian/set25
@@ -1,4 +1,4 @@
-$ $Id: set25,v 1.2 2002/07/01 20:50:22 christos Exp $
+$ $tcsh: set25,v 1.3 2006/03/02 18:46:48 christos Exp $
$ tc.sig.c
$set 25
1 our wait %d\n
diff --git a/contrib/tcsh/nls/ukrainian/set26 b/contrib/tcsh/nls/ukrainian/set26
index 4f8b7f5..4c28ab2 100644
--- a/contrib/tcsh/nls/ukrainian/set26
+++ b/contrib/tcsh/nls/ukrainian/set26
@@ -1,4 +1,4 @@
-$ $Id: set26,v 1.2 2002/07/01 20:50:22 christos Exp $
+$ $tcsh: set26,v 1.3 2006/03/02 18:46:48 christos Exp $
$ tc.who.c
$set 26
1 cannot stat %s. Please "unset watch".\n
diff --git a/contrib/tcsh/nls/ukrainian/set27 b/contrib/tcsh/nls/ukrainian/set27
index 4417820..2670e90 100644
--- a/contrib/tcsh/nls/ukrainian/set27
+++ b/contrib/tcsh/nls/ukrainian/set27
@@ -1,4 +1,4 @@
-$ $Id: set27,v 1.2 2002/07/01 20:50:22 christos Exp $
+$ $tcsh: set27,v 1.3 2006/03/02 18:46:48 christos Exp $
$ tw.comp.c
$set 27
1 ËÏÍÁÎÄÁ
diff --git a/contrib/tcsh/nls/ukrainian/set29 b/contrib/tcsh/nls/ukrainian/set29
index fa1902f..02c4746 100644
--- a/contrib/tcsh/nls/ukrainian/set29
+++ b/contrib/tcsh/nls/ukrainian/set29
@@ -1,4 +1,4 @@
-$ $Id: set29,v 1.2 2002/07/01 20:50:22 christos Exp $
+$ $tcsh: set29,v 1.3 2006/03/02 18:46:48 christos Exp $
$ tw.help.c
$set 29
1 ÷¦ÄÓÕÔÎ¦Ê ÆÁÊÌ ÄÏצÄËÉ ÄÌÑ %S\n
diff --git a/contrib/tcsh/nls/ukrainian/set3 b/contrib/tcsh/nls/ukrainian/set3
index af8f410..615c9d8 100644
--- a/contrib/tcsh/nls/ukrainian/set3
+++ b/contrib/tcsh/nls/ukrainian/set3
@@ -1,4 +1,4 @@
-$ $Id: set3,v 1.3 2002/07/01 20:50:22 christos Exp $
+$ $tcsh: set3,v 1.4 2006/03/02 18:46:48 christos Exp $
$ Editor function descriptions
$set 3
1 Move back a character
diff --git a/contrib/tcsh/nls/ukrainian/set30 b/contrib/tcsh/nls/ukrainian/set30
index 689f407..8b835de 100644
--- a/contrib/tcsh/nls/ukrainian/set30
+++ b/contrib/tcsh/nls/ukrainian/set30
@@ -1,4 +1,4 @@
-$ $Id: set30,v 1.2 2002/07/01 20:50:22 christos Exp $
+$ $tcsh: set30,v 1.3 2006/03/02 18:46:48 christos Exp $
$ tw.parse.c
$set 30
1 starting_a_command %d\n
diff --git a/contrib/tcsh/nls/ukrainian/set31 b/contrib/tcsh/nls/ukrainian/set31
index 1349b96..f0b8752 100644
--- a/contrib/tcsh/nls/ukrainian/set31
+++ b/contrib/tcsh/nls/ukrainian/set31
@@ -1,4 +1,4 @@
-$ $Id: set31,v 1.2 2002/07/01 20:50:22 christos Exp $
+$ $tcsh: set31,v 1.3 2006/03/02 18:46:48 christos Exp $
$ vms.termcap.c
$set 31
1 îÅ ÍÏÖÕ ×¦ÄËÒÉÔÉ TERMCAP: [%s]\n
diff --git a/contrib/tcsh/nls/ukrainian/set4 b/contrib/tcsh/nls/ukrainian/set4
index 868617a..a407091 100644
--- a/contrib/tcsh/nls/ukrainian/set4
+++ b/contrib/tcsh/nls/ukrainian/set4
@@ -1,4 +1,4 @@
-$ $Id: set4,v 1.2 2002/07/01 20:50:22 christos Exp $
+$ $tcsh: set4,v 1.3 2006/03/02 18:46:48 christos Exp $
$ Termcap strings
$set 4
1 add new blank line
diff --git a/contrib/tcsh/nls/ukrainian/set5 b/contrib/tcsh/nls/ukrainian/set5
index ca041e2..8540d1d 100644
--- a/contrib/tcsh/nls/ukrainian/set5
+++ b/contrib/tcsh/nls/ukrainian/set5
@@ -1,4 +1,4 @@
-$ $Id: set5,v 1.2 2002/07/01 20:50:22 christos Exp $
+$ $tcsh: set5,v 1.3 2006/03/02 18:46:48 christos Exp $
$ ed.chared.c
$set 5
1 îÅÄÏÓÔÕÐÎÅ ÚÎÁÞÅÎÎÑ: ÓÅÒÅÄΤ ÚÁ×ÁÎÔÁÖÅÎÎÑ\n
diff --git a/contrib/tcsh/nls/ukrainian/set6 b/contrib/tcsh/nls/ukrainian/set6
index 65be467..a86cef7 100644
--- a/contrib/tcsh/nls/ukrainian/set6
+++ b/contrib/tcsh/nls/ukrainian/set6
@@ -1,4 +1,4 @@
-$ $Id: set6,v 1.2 2002/07/01 20:50:22 christos Exp $
+$ $tcsh: set6,v 1.3 2006/03/02 18:46:48 christos Exp $
$ ed.inputl.c
$set 6
1 ERROR: illegal command from key 0%o\r\n
diff --git a/contrib/tcsh/nls/ukrainian/set7 b/contrib/tcsh/nls/ukrainian/set7
index 2c43d69..8a1bcbf 100644
--- a/contrib/tcsh/nls/ukrainian/set7
+++ b/contrib/tcsh/nls/ukrainian/set7
@@ -1,4 +1,4 @@
-$ $Id: set7,v 1.2 2002/07/01 20:50:22 christos Exp $
+$ $tcsh: set7,v 1.3 2006/03/02 18:46:48 christos Exp $
$ ed.screen.c
$set 7
1 \n\tTcsh thinks your terminal has the\n
diff --git a/contrib/tcsh/nls/ukrainian/set8 b/contrib/tcsh/nls/ukrainian/set8
index 4d7b8c2..693f9b0 100644
--- a/contrib/tcsh/nls/ukrainian/set8
+++ b/contrib/tcsh/nls/ukrainian/set8
@@ -1,4 +1,4 @@
-$ $Id: set8,v 1.2 2002/07/01 20:50:22 christos Exp $
+$ $tcsh: set8,v 1.3 2006/03/02 18:46:48 christos Exp $
$ ed.term.c
$set 8
1 îÅצÄÏÍÉÊ ÐÅÒÅÍÉËÁÞ
diff --git a/contrib/tcsh/nls/ukrainian/set9 b/contrib/tcsh/nls/ukrainian/set9
index 5b61468..97971f5 100644
--- a/contrib/tcsh/nls/ukrainian/set9
+++ b/contrib/tcsh/nls/ukrainian/set9
@@ -1,4 +1,4 @@
-$ $Id: set9,v 1.2 2002/07/01 20:50:22 christos Exp $
+$ $tcsh: set9,v 1.3 2006/03/02 18:46:48 christos Exp $
$ ed.xmap.c
$set 9
1 AddXkey: Null extended-key not allowed.\n
diff --git a/contrib/tcsh/patchlevel.h b/contrib/tcsh/patchlevel.h
index d25322c..f1c5a10 100644
--- a/contrib/tcsh/patchlevel.h
+++ b/contrib/tcsh/patchlevel.h
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/patchlevel.h,v 3.151 2005/03/25 17:36:08 kim Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/patchlevel.h,v 3.161 2007/03/03 20:01:26 christos Exp $ */
/*
* patchlevel.h: Our life story.
*/
@@ -7,8 +7,8 @@
#define ORIGIN "Astron"
#define REV 6
-#define VERS 14
+#define VERS 15
#define PATCHLEVEL 0
-#define DATE "2005-03-25"
+#define DATE "2007-03-03"
#endif /* _h_patchlevel */
diff --git a/contrib/tcsh/pathnames.h b/contrib/tcsh/pathnames.h
index 38027e8..80d86eb 100644
--- a/contrib/tcsh/pathnames.h
+++ b/contrib/tcsh/pathnames.h
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/pathnames.h,v 3.18 2002/03/08 17:36:46 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/pathnames.h,v 3.18 2002/03/08 17:36:46 christos Exp $ */
/*
* pathnames.h: Location of things to find
*/
diff --git a/contrib/tcsh/sh.c b/contrib/tcsh/sh.c
index 178b972..57b1bef 100644
--- a/contrib/tcsh/sh.c
+++ b/contrib/tcsh/sh.c
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/sh.c,v 3.123 2005/03/21 21:26:36 kim Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/sh.c,v 3.136 2007/02/22 21:57:37 christos Exp $ */
/*
* sh.c: Main shell routines
*/
@@ -39,7 +39,7 @@ char copyright[] =
All rights reserved.\n";
#endif /* not lint */
-RCSID("$Id: sh.c,v 3.123 2005/03/21 21:26:36 kim Exp $")
+RCSID("$tcsh: sh.c,v 3.136 2007/02/22 21:57:37 christos Exp $")
#include "tc.h"
#include "ed.h"
@@ -81,12 +81,9 @@ extern int NLSMapsAreInited;
jmp_buf_t reslab INIT_ZERO_STRUCT;
static const char tcshstr[] = "tcsh";
-#ifdef WINNT_NATIVE
-static const char tcshstr_nt[] = "tcsh.exe";
-#endif /* WINNT_NATIVE */
-signalfun_t parintr = 0; /* Parents interrupt catch */
-signalfun_t parterm = 0; /* Parents terminate catch */
+struct sigaction parintr; /* Parents interrupt catch */
+struct sigaction parterm; /* Parents terminate catch */
#ifdef TESLA
int do_logout = 0;
@@ -103,14 +100,7 @@ static Char INVCHAR;
Char *INVPTR = &INVCHAR;
Char **INVPPTR = &INVPTR;
-static int nofile = 0;
-static int reenter = 0;
-static int nverbose = 0;
-static int nexececho = 0;
-static int quitit = 0;
-static int rdirs = 0;
-int fast = 0;
-static int batch = 0;
+static int fast = 0;
static int mflag = 0;
static int prompt = 1;
int enterhist = 0;
@@ -123,7 +113,6 @@ int exitset = 0;
static time_t chktim; /* Time mail last checked */
char *progname;
int tcsh;
-extern char **environ;
/*
* This preserves the input state of the shell. It is used by
@@ -146,54 +135,48 @@ struct saved_state {
int onelflg;
int enterhist;
Char **argv;
+ Char **av;
Char HIST;
int cantell;
struct Bin B;
- /* These keep signal state and setjump state */
-#ifdef BSDSIGS
- sigmask_t mask;
-#endif
- jmp_buf_t oldexit;
- int reenter;
};
-static int srccat __P((Char *, Char *));
+static int srccat (Char *, Char *);
#ifndef WINNT_NATIVE
-static int srcfile __P((const char *, int, int, Char **));
+static int srcfile (const char *, int, int, Char **);
#else
-int srcfile __P((const char *, int, int, Char **));
+int srcfile (const char *, int, int, Char **);
#endif /*WINNT_NATIVE*/
-static RETSIGTYPE phup __P((int));
-static void srcunit __P((int, int, int, Char **));
-static void mailchk __P((void));
+static void srcunit (int, int, int, Char **);
+static void mailchk (void);
#ifndef _PATH_DEFPATH
-static Char **defaultpath __P((void));
+static Char **defaultpath (void);
#endif
-static void record __P((void));
-static void st_save __P((struct saved_state *, int, int,
- Char **, Char **));
-static void st_restore __P((struct saved_state *, Char **));
+static void record (void);
+static void st_save (struct saved_state *, int, int,
+ Char **, Char **);
+static void st_restore (void *);
- int main __P((int, char **));
+ int main (int, char **);
int
-main(argc, argv)
- int argc;
- char **argv;
+main(int argc, char **argv)
{
+ int batch = 0;
+ volatile int nexececho = 0;
+ int nofile = 0;
+ volatile int nverbose = 0;
+ volatile int rdirs = 0;
+ int quitit = 0;
Char *cp;
#ifdef AUTOLOGOUT
Char *cp2;
#endif
char *tcp, *ttyn;
- int f;
+ int f, reenter;
char **tempv;
int osetintr;
- signalfun_t oparintr;
-
-#ifdef BSDSIGS
- sigvec_t osv;
-#endif /* BSDSIGS */
+ struct sigaction oparintr;
#ifdef WINNT_NATIVE
nt_init();
@@ -211,7 +194,7 @@ main(argc, argv)
nlsinit();
#ifdef MALLOC_TRACE
- mal_setstatsfile(fdopen(dmove(open("/tmp/tcsh.trace",
+ mal_setstatsfile(fdopen(dmove(xopen("/tmp/tcsh.trace",
O_WRONLY|O_CREAT|O_LARGEFILE, 0666), 25), "w"));
mal_trace(1);
#endif /* MALLOC_TRACE */
@@ -239,11 +222,11 @@ main(argc, argv)
*/
{
do
- if ((f = open(_PATH_DEVNULL, O_RDONLY|O_LARGEFILE)) == -1 &&
- (f = open("/", O_RDONLY|O_LARGEFILE)) == -1)
+ if ((f = xopen(_PATH_DEVNULL, O_RDONLY|O_LARGEFILE)) == -1 &&
+ (f = xopen("/", O_RDONLY|O_LARGEFILE)) == -1)
exit(1);
while (f < 3);
- (void) close(f);
+ xclose(f);
}
#ifdef O_TEXT
@@ -295,7 +278,7 @@ main(argc, argv)
bslash_quote = 0; /* PWP: do tcsh-style backslash quoting? */
/* Default history size to 100 */
- set(STRhistory, SAVE("100"), VAR_READWRITE);
+ setcopy(STRhistory, str2short("100"), VAR_READWRITE);
tempv = argv;
ffile = SAVE(tempv[0]);
@@ -322,22 +305,21 @@ main(argc, argv)
#endif /* _VMS_POSIX */
if (loginsh && **tempv != '-') {
+ char *argv0;
+
/*
* Mangle the argv space
*/
tempv[1][0] = '\0';
tempv[1][1] = '\0';
tempv[1] = NULL;
- for (tcp = *tempv; *tcp++;)
- continue;
- for (tcp--; tcp >= *tempv; tcp--)
- tcp[1] = tcp[0];
- *++tcp = '-';
+ argv0 = strspl("-", *tempv);
+ *tempv = argv0;
argc--;
}
if (loginsh) {
(void) time(&chktim);
- set(STRloginsh, Strsave(STRNULL), VAR_READWRITE);
+ setNS(STRloginsh);
}
AsciiOnly = 1;
@@ -360,7 +342,7 @@ main(argc, argv)
{
int k;
- for (k = 0200; k <= 0377 && !Isprint(k); k++)
+ for (k = 0200; k <= 0377 && !Isprint(CTL_ESC(k)); k++)
continue;
AsciiOnly = MB_CUR_MAX == 1 && k > 0377;
}
@@ -398,9 +380,9 @@ main(argc, argv)
* 2. reenable the control terminal
*/
if (loginsh && isatty(SHIN)) {
- ttyn = (char *) ttyname(SHIN);
- (void) close(SHIN);
- SHIN = open(ttyn, O_RDWR|O_LARGEFILE);
+ ttyn = ttyname(SHIN);
+ xclose(SHIN);
+ SHIN = xopen(ttyn, O_RDWR|O_LARGEFILE);
shpgrp = getpid();
(void) ioctl (SHIN, TIOCSPGRP, (ioctl_t) &shpgrp);
(void) setpgid(0, shpgrp);
@@ -424,12 +406,12 @@ main(argc, argv)
* utmp, so we keep it too.
*/
if (strncmp(ttyn, "/dev/", 5) == 0)
- set(STRtty, cp = SAVE(ttyn + 5), VAR_READWRITE);
+ setv(STRtty, cp = SAVE(ttyn + 5), VAR_READWRITE);
else
- set(STRtty, cp = SAVE(ttyn), VAR_READWRITE);
+ setv(STRtty, cp = SAVE(ttyn), VAR_READWRITE);
}
else
- set(STRtty, cp = SAVE(""), VAR_READWRITE);
+ setv(STRtty, cp = SAVE(""), VAR_READWRITE);
/*
* Initialize the shell variables. ARGV and PROMPT are initialized later.
* STATUS is also munged in several places. CHILD is munged when
@@ -463,14 +445,13 @@ main(argc, argv)
*/
#ifdef AUTOLOGOUT
# ifdef convex
- if (uid == 0) {
+ if (uid == 0)
/* root always has a 15 minute autologout */
- set(STRautologout, Strsave(STRrootdefautologout), VAR_READWRITE);
- }
+ setcopy(STRautologout, STRrootdefautologout, VAR_READWRITE);
else
if (loginsh)
/* users get autologout set to 0 */
- set(STRautologout, Strsave(STR0), VAR_READWRITE);
+ setcopy(STRautologout, STR0, VAR_READWRITE);
# else /* convex */
if (loginsh || (uid == 0)) {
if (*cp) {
@@ -484,8 +465,7 @@ main(argc, argv)
((Strncmp(cp, STRpts, 3) == 0) && cp[3] == '/'))) {
if (getenv("DISPLAY") == NULL) {
/* NOT on X window shells */
- set(STRautologout, Strsave(STRdefautologout),
- VAR_READWRITE);
+ setcopy(STRautologout, STRdefautologout, VAR_READWRITE);
}
}
}
@@ -493,9 +473,9 @@ main(argc, argv)
# endif /* convex */
#endif /* AUTOLOGOUT */
- (void) sigset(SIGALRM, alrmcatch);
+ sigset_interrupting(SIGALRM, queue_alrmcatch);
- set(STRstatus, Strsave(STR0), VAR_READWRITE);
+ setcopy(STRstatus, STR0, VAR_READWRITE);
/*
* get and set machine specific environment variables
@@ -509,42 +489,32 @@ main(argc, argv)
#if ECHO_STYLE != BSD_ECHO
if (tcsh) {
# if ECHO_STYLE == NONE_ECHO
- set(STRecho_style, Strsave(STRnone), VAR_READWRITE);
+ setcopy(STRecho_style, STRnone, VAR_READWRITE);
# endif /* ECHO_STYLE == NONE_ECHO */
# if ECHO_STYLE == SYSV_ECHO
- set(STRecho_style, Strsave(STRsysv), VAR_READWRITE);
+ setcopy(STRecho_style, STRsysv, VAR_READWRITE);
# endif /* ECHO_STYLE == SYSV_ECHO */
# if ECHO_STYLE == BOTH_ECHO
- set(STRecho_style, Strsave(STRboth), VAR_READWRITE);
+ setcopy(STRecho_style, STRboth, VAR_READWRITE);
# endif /* ECHO_STYLE == BOTH_ECHO */
} else
#endif /* ECHO_STYLE != BSD_ECHO */
- set(STRecho_style, Strsave(STRbsd), VAR_READWRITE);
+ setcopy(STRecho_style, STRbsd, VAR_READWRITE);
/*
* increment the shell level.
*/
shlvl(1);
- if ((tcp = getenv("HOME")) != NULL) {
- if (strlen(tcp) >= MAXPATHLEN) {
- struct passwd *pw;
- if ((pw = getpwuid(getuid())) != NULL)
- cp = quote(SAVE(pw->pw_dir));
- else {
- tcp[MAXPATHLEN-1] = '\0';
- cp = quote(SAVE(tcp));
- }
- } else {
- cp = quote(SAVE(tcp));
- }
- } else
+ if ((tcp = getenv("HOME")) != NULL)
+ cp = quote(SAVE(tcp));
+ else
cp = NULL;
if (cp == NULL)
fast = 1; /* No home -> can't read scripts */
else
- set(STRhome, cp, VAR_READWRITE);
+ setv(STRhome, cp, VAR_READWRITE);
dinit(cp); /* dinit thinks that HOME == cwd in a login
* shell */
@@ -554,7 +524,6 @@ main(argc, argv)
*/
{
char *cln, *cus, *cgr;
- Char buff[BUFSIZE];
struct passwd *pw;
struct group *gr;
@@ -562,26 +531,23 @@ main(argc, argv)
#ifdef apollo
int oid = getoid();
- (void) Itoa(oid, buff, 0, 0);
- set(STRoid, Strsave(buff), VAR_READWRITE);
+ setv(STRoid, Itoa(oid, 0, 0), VAR_READWRITE);
#endif /* apollo */
- (void) Itoa(uid, buff, 0, 0);
- set(STRuid, Strsave(buff), VAR_READWRITE);
+ setv(STRuid, Itoa(uid, 0, 0), VAR_READWRITE);
- (void) Itoa(gid, buff, 0, 0);
- set(STRgid, Strsave(buff), VAR_READWRITE);
+ setv(STRgid, Itoa(gid, 0, 0), VAR_READWRITE);
cln = getenv("LOGNAME");
cus = getenv("USER");
if (cus != NULL)
- set(STRuser, quote(SAVE(cus)), VAR_READWRITE);
+ setv(STRuser, quote(SAVE(cus)), VAR_READWRITE);
else if (cln != NULL)
- set(STRuser, quote(SAVE(cln)), VAR_READWRITE);
- else if ((pw = getpwuid(uid)) == NULL)
- set(STRuser, SAVE("unknown"), VAR_READWRITE);
+ setv(STRuser, quote(SAVE(cln)), VAR_READWRITE);
+ else if ((pw = xgetpwuid(uid)) == NULL)
+ setcopy(STRuser, str2short("unknown"), VAR_READWRITE);
else
- set(STRuser, SAVE(pw->pw_name), VAR_READWRITE);
+ setcopy(STRuser, str2short(pw->pw_name), VAR_READWRITE);
if (cln == NULL)
tsetenv(STRLOGNAME, varval(STRuser));
if (cus == NULL)
@@ -589,11 +555,11 @@ main(argc, argv)
cgr = getenv("GROUP");
if (cgr != NULL)
- set(STRgroup, quote(SAVE(cgr)), VAR_READWRITE);
- else if ((gr = getgrgid(gid)) == NULL)
- set(STRgroup, SAVE("unknown"), VAR_READWRITE);
+ setv(STRgroup, quote(SAVE(cgr)), VAR_READWRITE);
+ else if ((gr = xgetgrgid(gid)) == NULL)
+ setcopy(STRgroup, str2short("unknown"), VAR_READWRITE);
else
- set(STRgroup, SAVE(gr->gr_name), VAR_READWRITE);
+ setcopy(STRgroup, str2short(gr->gr_name), VAR_READWRITE);
if (cgr == NULL)
tsetenv(STRKGROUP, varval(STRgroup));
}
@@ -648,7 +614,7 @@ main(argc, argv)
* if noediting is set, we switch on editing if $TERM is changed.
*/
if ((tcp = getenv("TERM")) != NULL) {
- set(STRterm, quote(SAVE(tcp)), VAR_READWRITE);
+ setv(STRterm, quote(SAVE(tcp)), VAR_READWRITE);
noediting = strcmp(tcp, "unknown") == 0 || strcmp(tcp, "dumb") == 0 ||
strcmp(tcp, "network") == 0;
editing = strcmp(tcp, "emacs") != 0 && strcmp(tcp, "wm") != 0 &&
@@ -664,24 +630,24 @@ main(argc, argv)
* need a value. Making it 'emacs' might be confusing.
*/
if (editing)
- set(STRedit, Strsave(STRNULL), VAR_READWRITE);
+ setNS(STRedit);
/*
* still more mutability: make the complete routine automatically add the
* suffix of file names...
*/
- set(STRaddsuffix, Strsave(STRNULL), VAR_READWRITE);
+ setNS(STRaddsuffix);
/*
* Compatibility with tcsh >= 6.12 by default
*/
- set(STRcsubstnonl, Strsave(STRNULL), VAR_READWRITE);
+ setNS(STRcsubstnonl);
/*
* Random default kill ring size
*/
- set(STRkillring, SAVE("30"), VAR_READWRITE);
+ setcopy(STRkillring, str2short("30"), VAR_READWRITE);
/*
* Re-initialize path if set in environment
@@ -709,20 +675,26 @@ main(argc, argv)
* default isn't appropriate (sg).
*/
- int sh_len = 0;
+ size_t sh_len = 0;
if ((tcp = getenv("SHELL")) != NULL) {
sh_len = strlen(tcp);
if ((sh_len >= 5 && strcmp(tcp + (sh_len - 5), "/tcsh") == 0) ||
(!tcsh && sh_len >= 4 && strcmp(tcp + (sh_len - 4), "/csh") == 0))
- set(STRshell, quote(SAVE(tcp)), VAR_READWRITE);
+ setv(STRshell, quote(SAVE(tcp)), VAR_READWRITE);
else
sh_len = 0;
}
if (sh_len == 0)
- set(STRshell, Strsave(STR_SHELLPATH), VAR_READWRITE);
+ setcopy(STRshell, STR_SHELLPATH, VAR_READWRITE);
}
+#ifdef _OSD_POSIX /* BS2000 needs this variable set to "SHELL" */
+ if ((tcp = getenv("PROGRAM_ENVIRONMENT")) == NULL)
+ tcp = "SHELL";
+ tsetenv(STRPROGRAM_ENVIRONMENT, quote(str2short(tcp)));
+#endif /* _OSD_POSIX */
+
#ifdef COLOR_LS_F
if ((tcp = getenv("LS_COLORS")) != NULL)
parseLS_COLORS(str2short(tcp));
@@ -731,10 +703,18 @@ main(argc, argv)
doldol = putn((int) getpid()); /* For $$ */
#ifdef WINNT_NATIVE
{
- char *strtmp1, strtmp2[MAXPATHLEN];
- if ((strtmp1 = getenv("TMP")) != NULL)
- wsprintf(strtmp2, "%s/%s", strtmp1, "sh");
- shtemp = Strspl(SAVE(strtmp2), doldol); /* For << */
+ char *tmp;
+ Char *tmp2;
+ if ((tmp = getenv("TMP")) != NULL) {
+ tmp = xasprintf("%s/%s", tmp, "sh");
+ tmp2 = SAVE(tmp);
+ xfree(tmp);
+ }
+ else {
+ tmp2 = SAVE("");
+ }
+ shtemp = Strspl(tmp2, doldol); /* For << */
+ xfree(tmp2);
}
#else /* !WINNT_NATIVE */
shtemp = Strspl(STRtmpsh, doldol); /* For << */
@@ -746,33 +726,8 @@ main(argc, argv)
* be either. Our children inherit termination from our parent. We catch it
* only if we are the login shell.
*/
-#ifdef BSDSIGS
- /*
- * PURIFY-2 claims that osv does not get
- * initialized after the sigvec call
- */
- setzero((char*) &osv, sizeof(osv));
- /* parents interruptibility */
- (void) mysigvec(SIGINT, NULL, &osv);
- parintr = (signalfun_t) osv.sv_handler;
- (void) mysigvec(SIGTERM, NULL, &osv);
- parterm = (signalfun_t) osv.sv_handler;
-#else /* BSDSIGS */
- parintr = signal(SIGINT, SIG_IGN); /* parents interruptibility */
- (void) sigset(SIGINT, parintr); /* ... restore */
-
-# ifdef COHERENT
- if (loginsh) /* it seems that SIGTERM is always set to SIG_IGN by */
- /* init/getty so it should be set to SIG_DFL - there may be */
- /* a better fix for this. */
- parterm = SIG_DFL;
- else
-# else /* !COHERENT */
- parterm = signal(SIGTERM, SIG_IGN); /* parents terminability */
-# endif /* COHERENT */
- (void) sigset(SIGTERM, parterm); /* ... restore */
-
-#endif /* BSDSIGS */
+ sigaction(SIGINT, NULL, &parintr);
+ sigaction(SIGTERM, NULL, &parterm);
#ifdef TCF
@@ -857,7 +812,7 @@ main(argc, argv)
* we put the command into a variable
*/
if (arginp != NULL)
- set(STRcommand, quote(Strsave(arginp)), VAR_READWRITE);
+ setv(STRcommand, quote(Strsave(arginp)), VAR_READWRITE);
/*
* * Give an error on -c arguments that end in * backslash to
@@ -866,7 +821,7 @@ main(argc, argv)
{
int count;
- cp = arginp + Strlen(arginp);
+ cp = Strend(arginp);
count = 0;
while (cp > arginp && *--cp == '\\')
++count;
@@ -950,7 +905,7 @@ main(argc, argv)
setNS(STRecho); /* NOW! */
break;
- case 'F': /* Undocumented flag */
+ case 'F':
/*
* This will cause children to be created using fork instead of
* vfork.
@@ -984,7 +939,7 @@ main(argc, argv)
* read commands.
*/
if (nofile == 0 && argc > 0) {
- nofile = open(tempv[0], O_RDONLY|O_LARGEFILE);
+ nofile = xopen(tempv[0], O_RDONLY|O_LARGEFILE);
if (nofile < 0) {
child = 1; /* So this ... */
/* ... doesn't return */
@@ -993,8 +948,7 @@ main(argc, argv)
#ifdef O_TEXT
setmode(nofile, O_TEXT);
#endif
- if (ffile != NULL)
- xfree((ptr_t) ffile);
+ xfree(ffile);
dolzero = 1;
ffile = SAVE(tempv[0]);
/*
@@ -1072,12 +1026,12 @@ main(argc, argv)
*/
if (prompt) {
if (tcsh)
- set(STRprompt, Strsave(STRdeftcshprompt), VAR_READWRITE);
+ setcopy(STRprompt, STRdeftcshprompt, VAR_READWRITE);
else
- set(STRprompt, Strsave(STRdefcshprompt), VAR_READWRITE);
+ setcopy(STRprompt, STRdefcshprompt, VAR_READWRITE);
/* that's a meta-questionmark */
- set(STRprompt2, Strsave(STRmquestion), VAR_READWRITE);
- set(STRprompt3, Strsave(STRKCORRECT), VAR_READWRITE);
+ setcopy(STRprompt2, STRmquestion, VAR_READWRITE);
+ setcopy(STRprompt3, STRKCORRECT, VAR_READWRITE);
}
/*
@@ -1087,12 +1041,13 @@ main(argc, argv)
shpgrp = mygetpgrp();
opgrp = tpgrp = -1;
if (setintr) {
- signalfun_t osig;
+ struct sigaction osig;
+
**argv = '-';
if (!quitit) /* Wary! */
(void) signal(SIGQUIT, SIG_IGN);
- (void) sigset(SIGINT, pintr);
- (void) sighold(SIGINT);
+ pintr_disabled = 1;
+ sigset_interrupting(SIGINT, queue_pintr);
(void) signal(SIGTERM, SIG_IGN);
/*
@@ -1106,18 +1061,21 @@ main(argc, argv)
* We also only setup the handlers for shells that are trully
* interactive.
*/
- osig = signal(SIGHUP, phup); /* exit processing on HUP */
- if (!loginsh && osig == SIG_IGN)
- (void) signal(SIGHUP, osig);
+ sigaction(SIGHUP, NULL, &osig);
+ if (loginsh || osig.sa_handler != SIG_IGN)
+ /* exit processing on HUP */
+ sigset_interrupting(SIGHUP, queue_phup);
#ifdef SIGXCPU
- osig = signal(SIGXCPU, phup); /* exit processing on XCPU */
- if (!loginsh && osig == SIG_IGN)
- (void) signal(SIGXCPU, osig);
+ sigaction(SIGXCPU, NULL, &osig);
+ if (loginsh || osig.sa_handler != SIG_IGN)
+ /* exit processing on XCPU */
+ sigset_interrupting(SIGXCPU, queue_phup);
#endif
#ifdef SIGXFSZ
- osig = signal(SIGXFSZ, phup); /* exit processing on XFSZ */
- if (!loginsh && osig == SIG_IGN)
- (void) signal(SIGXFSZ, osig);
+ sigaction(SIGXFSZ, NULL, &osig);
+ if (loginsh || osig.sa_handler != SIG_IGN)
+ /* exit processing on XFSZ */
+ sigset_interrupting(SIGXFSZ, queue_phup);
#endif
if (quitit == 0 && arginp == 0) {
@@ -1155,9 +1113,12 @@ main(argc, argv)
retry:
if ((tpgrp = tcgetpgrp(f)) != -1) {
if (tpgrp != shpgrp) {
- signalfun_t old = signal(SIGTTIN, SIG_DFL);
+ struct sigaction old;
+
+ sigaction(SIGTTIN, NULL, &old);
+ signal(SIGTTIN, SIG_DFL);
(void) kill(0, SIGTTIN);
- (void) signal(SIGTTIN, old);
+ sigaction(SIGTTIN, &old, NULL);
goto retry;
}
/*
@@ -1216,7 +1177,7 @@ main(argc, argv)
}
if (tpgrp == -1) {
notty:
- xprintf(CGETS(11, 1, "Warning: no access to tty (%s).\n"),
+ xprintf(CGETS(11, 1, "Warning: no access to tty (%s).\n"),
strerror(errno));
xprintf(CGETS(11, 2, "Thus no job control in this shell.\n"));
/*
@@ -1232,7 +1193,7 @@ main(argc, argv)
#endif /* BSDJOBS */
}
}
- if ((setintr == 0) && (parintr == SIG_DFL))
+ if (setintr == 0 && parintr.sa_handler == SIG_DFL)
setintr = 1;
/*
@@ -1242,25 +1203,7 @@ main(argc, argv)
*
* David Dawes (dawes@physics.su.oz.au) Sept 1991
*/
-
-#if SYSVREL > 3
- {
- struct sigaction act;
- act.sa_handler=pchild;
- (void) sigemptyset(&(act.sa_mask)); /* Don't block any extra sigs
- * when the handler is called
- */
- act.sa_flags=0; /* want behaviour of sigset() without
- * SA_NOCLDSTOP
- */
-
- if ((sigaction(SIGCHLD,&act,(struct sigaction *)NULL)) == -1)
- stderror(ERR_SYSTEM, "sigaction", strerror(errno));
- }
-#else /* SYSVREL <= 3 */
- (void) sigset(SIGCHLD, pchild); /* while signals not ready */
-#endif /* SYSVREL <= 3 */
-
+ sigset_interrupting(SIGCHLD, queue_pchild);
if (intty && !arginp)
(void) ed_Setup(editing);/* Get the tty state, and set defaults */
@@ -1272,23 +1215,25 @@ main(argc, argv)
*/
osetintr = setintr;
oparintr = parintr;
- reenter = setexit(); /* PWP */
+ (void)cleanup_push_mark(); /* There is no outer handler */
+ if (setexit() != 0) /* PWP */
+ reenter = 1;
+ else
+ reenter = 0;
exitset++;
haderr = 0; /* In case second time through */
if (!fast && reenter == 0) {
/* Will have varval(STRhome) here because set fast if don't */
{
-#ifdef BSDSIGS
- sigmask_t omask = sigblock(sigmask(SIGINT));
-#else
- (void) sighold(SIGINT);
-#endif
- setintr = 0;
- parintr = SIG_IGN; /* onintr in /etc/ files has no effect */
+ pintr_disabled++;
+ cleanup_push(&pintr_disabled, disabled_cleanup);
+ setintr = 0;/*FIXRESET:cleanup*/
+ /* onintr in /etc/ files has no effect */
+ parintr.sa_handler = SIG_IGN;/*FIXRESET: cleanup*/
#ifdef LOGINFIRST
#ifdef _PATH_DOTLOGIN
if (loginsh)
- (void) srcfile(_PATH_DOTLOGIN, 0, 0, NULL);
+ (void) srcfile(_PATH_DOTLOGIN, 0, 0, NULL);
#endif
#endif
@@ -1303,11 +1248,7 @@ main(argc, argv)
(void) srcfile(_PATH_DOTLOGIN, 0, 0, NULL);
#endif
#endif
-#ifdef BSDSIGS
- (void) sigsetmask(omask);
-#else
- (void) sigrelse(SIGINT);
-#endif
+ cleanup_until(&pintr_disabled);
setintr = osetintr;
parintr = oparintr;
}
@@ -1319,7 +1260,7 @@ main(argc, argv)
if (!srccat(varval(STRhome), STRsldottcshrc))
(void) srccat(varval(STRhome), STRsldotcshrc);
- if (!fast && !arginp && !onelflg && !havhash)
+ if (!arginp && !onelflg && !havhash)
dohash(NULL,NULL);
/*
@@ -1330,12 +1271,13 @@ main(argc, argv)
if (loginsh)
(void) srccat(varval(STRhome), STRsldotlogin);
#endif
- if (!fast && (loginsh || rdirs))
+ if (loginsh || rdirs)
loaddirs(NULL);
}
/* Reset interrupt flag */
setintr = osetintr;
parintr = oparintr;
+ exitset--;
/* Initing AFTER .cshrc is the Right Way */
if (intty && !arginp) { /* PWP setup stuff */
@@ -1367,7 +1309,7 @@ main(argc, argv)
if (intty) {
if (loginsh) {
xprintf("logout\n");
- (void) close(SHIN);
+ xclose(SHIN);
child = 1;
#ifdef TESLA
do_logout = 1;
@@ -1384,7 +1326,7 @@ main(argc, argv)
}
void
-untty()
+untty(void)
{
#ifdef BSDJOBS
if (tpgrp > 0 && opgrp != shpgrp) {
@@ -1396,10 +1338,9 @@ untty()
}
void
-importpath(cp)
- Char *cp;
+importpath(Char *cp)
{
- int i = 0;
+ size_t i = 0;
Char *dp;
Char **pv;
int c;
@@ -1411,7 +1352,7 @@ importpath(cp)
* i+2 where i is the number of colons in the path. There are i+1
* directories in the path plus we need room for a zero terminator.
*/
- pv = (Char **) xcalloc((size_t) (i + 2), sizeof(Char *));
+ pv = xcalloc(i + 2, sizeof(Char *));
dp = cp;
i = 0;
if (*dp)
@@ -1433,15 +1374,17 @@ importpath(cp)
dp++;
}
pv[i] = 0;
+ cleanup_push(pv, blk_cleanup);
setq(STRpath, pv, &shvhed, VAR_READWRITE);
+ cleanup_ignore(pv);
+ cleanup_until(pv);
}
/*
* Source to the file which is the catenation of the argument names.
*/
static int
-srccat(cp, dp)
- Char *cp, *dp;
+srccat(Char *cp, Char *dp)
{
if (cp[0] == '/' && cp[1] == '\0')
return srcfile(short2str(dp), (mflag ? 0 : 1), 0, NULL);
@@ -1451,18 +1394,17 @@ srccat(cp, dp)
int rv;
#ifdef WINNT_NATIVE
- ep = cp;
- while(*ep)
- ep++;
- if (ep[-1] == '/' && dp[0] == '/') /* silly win95 */
+ ep = Strend(cp);
+ if (ep != cp && ep[-1] == '/' && dp[0] == '/') /* silly win95 */
dp++;
#endif /* WINNT_NATIVE */
ep = Strspl(cp, dp);
+ cleanup_push(ep, xfree);
ptr = short2str(ep);
rv = srcfile(ptr, (mflag ? 0 : 1), 0, NULL);
- xfree((ptr_t) ep);
+ cleanup_until(ep);
return rv;
}
}
@@ -1475,20 +1417,19 @@ static int
#else
int
#endif /*WINNT_NATIVE*/
-srcfile(f, onlyown, flag, av)
- const char *f;
- int onlyown;
- int flag;
- Char **av;
+srcfile(const char *f, int onlyown, int flag, Char **av)
{
int unit;
- if ((unit = open(f, O_RDONLY|O_LARGEFILE)) == -1)
+ if ((unit = xopen(f, O_RDONLY|O_LARGEFILE)) == -1)
return 0;
#ifdef O_TEXT
setmode(unit, O_TEXT);
#endif
+ cleanup_push(&unit, open_cleanup);
unit = dmove(unit, -1);
+ cleanup_ignore(&unit);
+ cleanup_until(&unit);
(void) close_on_exec(unit, 1);
srcunit(unit, onlyown, flag, av);
@@ -1501,10 +1442,7 @@ srcfile(f, onlyown, flag, av)
* fd.
*/
static void
-st_save(st, unit, hflg, al, av)
- struct saved_state *st;
- int unit, hflg;
- Char **al, **av;
+st_save(struct saved_state *st, int unit, int hflg, Char **al, Char **av)
{
st->insource = insource;
st->SHIN = SHIN;
@@ -1574,6 +1512,7 @@ st_save(st, unit, hflg, al, av)
}
else
st->argv = NULL;
+ st->av = av;
SHIN = unit; /* Do this first */
@@ -1604,10 +1543,11 @@ st_save(st, unit, hflg, al, av)
* Restore the shell to a saved state
*/
static void
-st_restore(st, av)
- struct saved_state *st;
- Char **av;
+st_restore(void *xst)
{
+ struct saved_state *st;
+
+ st = xst;
if (st->SHIN == -1)
return;
@@ -1620,21 +1560,21 @@ st_restore(st, av)
fblocks = 0;
fbuf = NULL;
for (i = 0; i < nfblocks; i++)
- xfree((ptr_t) nfbuf[i]);
- xfree((ptr_t) nfbuf);
+ xfree(nfbuf[i]);
+ xfree(nfbuf);
}
cpybin(B, st->B);
- (void) close(SHIN);
+ xclose(SHIN);
insource = st->insource;
SHIN = st->SHIN;
if (st->OLDSTD != -1)
- (void)close(OLDSTD), OLDSTD = st->OLDSTD;
+ xclose(OLDSTD), OLDSTD = st->OLDSTD;
if (st->SHOUT != -1)
- (void)close(SHOUT), SHOUT = st->SHOUT;
+ xclose(SHOUT), SHOUT = st->SHOUT;
if (st->SHDIAG != -1)
- (void)close(SHDIAG), SHDIAG = st->SHDIAG;
+ xclose(SHDIAG), SHDIAG = st->SHDIAG;
arginp = st->arginp;
onelflg = st->onelflg;
evalp = st->evalp;
@@ -1651,7 +1591,7 @@ st_restore(st, av)
if (st->argv != NULL)
setq(STRargv, st->argv, &shvhed, VAR_READWRITE);
- else if (av != NULL && *av != NULL && adrof(STRargv) != NULL)
+ else if (st->av != NULL && *st->av != NULL && adrof(STRargv) != NULL)
unsetv(STRargv);
}
@@ -1660,13 +1600,10 @@ st_restore(st, av)
* we don't chance it. This occurs on ".cshrc"s and the like.
*/
static void
-srcunit(unit, onlyown, hflg, av)
- int unit;
- int onlyown;
- int hflg;
- Char **av;
+srcunit(int unit, int onlyown, int hflg, Char **av)
{
struct saved_state st;
+
st.SHIN = -1; /* st_restore checks this */
if (unit < 0)
@@ -1676,19 +1613,17 @@ srcunit(unit, onlyown, hflg, av)
struct stat stb;
if (fstat(unit, &stb) < 0) {
- (void) close(unit);
+ xclose(unit);
return;
}
}
- getexit(st.oldexit);
-
- if (setintr)
-#ifdef BSDSIGS
- st.mask = sigblock(sigmask(SIGINT));
-#else
- (void) sighold(SIGINT);
-#endif
+ /* Does nothing before st_save() because st.SHIN == -1 */
+ cleanup_push(&st, st_restore);
+ if (setintr) {
+ pintr_disabled++;
+ cleanup_push(&pintr_disabled, disabled_cleanup);
+ }
/* Save the current state and move us to a new state */
st_save(&st, unit, hflg, NULL, av);
@@ -1697,87 +1632,64 @@ srcunit(unit, onlyown, hflg, av)
* Now if we are allowing commands to be interrupted, we let ourselves be
* interrupted.
*/
- if (setintr)
-#ifdef BSDSIGS
- (void) sigsetmask(st.mask);
-#else
- (void) sigrelse(SIGINT);
-#endif
-
- /*
- * Bugfix for running out of memory by: Jak Kirman
- * <jak%cs.brown.edu@RELAY.CS.NET>. Solution: pay attention to what
- * setexit() is returning because reenter _may_ be in a register, and
- * thus restored to 0 on a longjump(). (PWP: insert flames about
- * compiler-dependant code here) PWP: THANKS LOTS !!!
- *
- * PWP: think of this as like a LISP (unwind-protect ...)
- * thanks to Diana Smetters for pointing out how this _should_ be written
- */
-#ifdef cray
- st.reenter = 1; /* assume non-zero return val */
- if (setexit() == 0) {
- st.reenter = 0; /* Oh well, we were wrong */
-#else
- if ((st.reenter = setexit()) == 0) {
-#endif
- process(0); /* 0 -> blow away on errors */
+ if (setintr) {
+ cleanup_until(&pintr_disabled);
+ pintr_disabled++;
+ cleanup_push(&pintr_disabled, disabled_cleanup);
}
- if (setintr)
-#ifdef BSDSIGS
- (void) sigsetmask(st.mask);
-#else
- (void) sigrelse(SIGINT);
-#endif
+ process(0); /* 0 -> blow away on errors */
/* Restore the old state */
- st_restore(&st, av);
- resexit(st.oldexit);
- /*
- * If process reset() (effectively an unwind) then we must also unwind.
- */
- if (st.reenter)
- stderror(ERR_SILENT);
+ cleanup_until(&st);
}
/*ARGSUSED*/
void
-goodbye(v, c)
- Char **v;
- struct command *c;
+goodbye(Char **v, struct command *c)
{
USE(v);
USE(c);
record();
if (loginsh) {
- (void) sigset(SIGQUIT, SIG_IGN);
- (void) sigset(SIGINT, SIG_IGN);
- (void) sigset(SIGTERM, SIG_IGN);
- (void) sigset(SIGHUP, SIG_IGN);
+ size_t omark;
+ sigset_t set;
+
+ signal(SIGQUIT, SIG_IGN);
+ sigaddset(&set, SIGQUIT);
+ sigprocmask(SIG_UNBLOCK, &set, NULL);
+ signal(SIGINT, SIG_IGN);
+ sigaddset(&set, SIGINT);
+ signal(SIGTERM, SIG_IGN);
+ sigaddset(&set, SIGTERM);
+ signal(SIGHUP, SIG_IGN);
+ sigaddset(&set, SIGHUP);
+ sigprocmask(SIG_UNBLOCK, &set, NULL);
+ phup_disabled = 1;
setintr = 0; /* No interrupts after "logout" */
/* Trap errors inside .logout */
- reenter = setexit();
- if (reenter != 0)
- exitstat();
- if (!(adrof(STRlogout)))
- set(STRlogout, Strsave(STRnormal), VAR_READWRITE);
+ omark = cleanup_push_mark();
+ if (setexit() == 0) {
+ if (!(adrof(STRlogout)))
+ setcopy(STRlogout, STRnormal, VAR_READWRITE);
#ifdef _PATH_DOTLOGOUT
- (void) srcfile(_PATH_DOTLOGOUT, 0, 0, NULL);
+ (void) srcfile(_PATH_DOTLOGOUT, 0, 0, NULL);
#endif
- if (adrof(STRhome))
- (void) srccat(varval(STRhome), STRsldtlogout);
+ if (adrof(STRhome))
+ (void) srccat(varval(STRhome), STRsldtlogout);
#ifdef TESLA
- do_logout = 1;
+ do_logout = 1;
#endif /* TESLA */
+ }
+ cleanup_pop_mark(omark);
}
exitstat();
}
void
-exitstat()
+exitstat(void)
{
#ifdef PROF
monitor(0);
@@ -1795,28 +1707,11 @@ exitstat()
/*
* in the event of a HUP we want to save the history
*/
-static RETSIGTYPE
-phup(snum)
-int snum;
+void
+phup(void)
{
- /*
- * There is no return from here,
- * so we are not going to release SIGHUP
- * anymore
- */
-#ifdef UNRELSIGS
- if (snum)
- (void) sigset(snum, SIG_IGN);
-#else
-# ifdef BSDSIGS
- (void) sigblock(sigmask(SIGHUP));
-# else
- (void) sighold(SIGHUP);
-# endif /* BSDSIGS */
-#endif /* UNRELSIGS */
-
if (loginsh) {
- set(STRlogout, Strsave(STRhangup), VAR_READWRITE);
+ setcopy(STRlogout, STRhangup, VAR_READWRITE);
#ifdef _PATH_DOTLOGOUT
(void) srcfile(_PATH_DOTLOGOUT, 0, 0, NULL);
#endif
@@ -1863,7 +1758,7 @@ int snum;
}
#endif /* POSIXJOBS */
- xexit(snum);
+ xexit(SIGHUP);
}
static Char *jobargv[2] = {STRjobs, 0};
@@ -1875,39 +1770,19 @@ static Char *jobargv[2] = {STRjobs, 0};
* and finally go through the normal error mechanism, which
* gets a chance to make the shell go away.
*/
-int just_signaled; /* bugfix by Michael Bloom (mg@ttidca.TTI.COM) */
+int just_signaled; /* bugfix by Michael Bloom (mg@ttidca.TTI.COM) */
-RETSIGTYPE
-pintr(snum)
-int snum;
+void
+pintr(void)
{
- USE(snum);
-#ifdef UNRELSIGS
- if (snum)
- (void) sigset(snum, pintr);
-#endif /* UNRELSIGS */
just_signaled = 1;
pintr1(1);
}
void
-pintr1(wantnl)
- int wantnl;
+pintr1(int wantnl)
{
- Char **v;
-#ifdef BSDSIGS
- sigmask_t omask;
-#endif
-
-#ifdef BSDSIGS
- omask = sigblock((sigmask_t) 0);
-#endif
if (setintr) {
-#ifdef BSDSIGS
- (void) sigsetmask(omask & ~sigmask(SIGINT));
-#else
- (void) sigrelse(SIGINT);
-#endif
if (pjobs) {
pjobs = 0;
xputchar('\n');
@@ -1925,13 +1800,6 @@ pintr1(wantnl)
(void) Cookedmode();
GettingInput = 0;
}
-#ifdef BSDSIGS
- (void) sigsetmask(omask & ~sigmask(SIGCHLD));
-#else
- if (setintr)
- (void) sighold(SIGINT);
- (void) sigrelse(SIGCHLD);
-#endif
drainoline();
#ifdef HAVE_GETPWENT
(void) endpwent();
@@ -1944,11 +1812,6 @@ pintr1(wantnl)
*/
if (gointr) {
gotolab(gointr);
- timflg = 0;
- if ((v = pargv) != 0)
- pargv = 0, blkfree(v);
- if ((v = gargv) != 0)
- gargv = 0, blkfree(v);
reset();
}
else if (intty && wantnl) {
@@ -1985,60 +1848,30 @@ pintr1(wantnl)
* Note that if catch is not set then we will unwind on any error.
* If an end-of-file occurs, we return.
*/
-static struct command *savet = NULL;
void
-process(catch)
- int catch;
+process(int catch)
{
jmp_buf_t osetexit;
/* PWP: This might get nuked my longjmp so don't make it a register var */
- struct command *t = savet;
+ size_t omark;
- savet = NULL;
getexit(osetexit);
+ omark = cleanup_push_mark();
+ exitset++;
for (;;) {
+ struct command *t;
+ int hadhist, old_pintr_disabled;
+ (void) setexit();
pendjob();
- /* This was leaking memory badly, particularly when sourcing
- * files, etc.. For whatever reason we were arriving here with
- * allocated pointers still active, and the code was simply
- * overwriting them. I can't say I fully understand the
- * control flow here, but according to Purify this particular
- * leak has been plugged, and I haven't noticed any ill
- * effects.. (sg)
- */
- if (paraml.next && paraml.next != &paraml)
- freelex(&paraml);
-
- paraml.next = paraml.prev = &paraml;
- paraml.word = STRNULL;
- (void) setexit();
justpr = enterhist; /* execute if not entering history */
- /*
- * Interruptible during interactive reads
- */
- if (setintr)
-#ifdef BSDSIGS
- (void) sigsetmask(sigblock((sigmask_t) 0) & ~sigmask(SIGINT));
-#else
- (void) sigrelse(SIGINT);
-#endif
-
-
- /*
- * For the sake of reset()
- */
- freelex(&paraml);
- if (savet)
- freesyn(savet), savet = NULL;
-
if (haderr) {
if (!catch) {
/* unwind */
doneinp = 0;
- savet = t;
+ cleanup_pop_mark(omark);
resexit(osetexit);
reset();
}
@@ -2072,7 +1905,7 @@ process(catch)
#ifndef HAVENOUTMP
watch_login(0);
#endif /* !HAVENOUTMP */
- sched_run(0);
+ sched_run();
period_cmd();
precmd();
/*
@@ -2086,16 +1919,26 @@ process(catch)
setalarm(1);
}
if (seterr) {
- xfree((ptr_t) seterr);
+ xfree(seterr);
seterr = NULL;
}
/*
+ * Interruptible during interactive reads
+ */
+ if (setintr)
+ pintr_push_enable(&old_pintr_disabled);
+ hadhist = lex(&paraml);
+ if (setintr)
+ cleanup_until(&old_pintr_disabled);
+ cleanup_push(&paraml, lex_cleanup);
+
+ /*
* Echo not only on VERBOSE, but also with history expansion. If there
* is a lexical error then we forego history echo.
*/
- if ((lex(&paraml) && !seterr && intty && !tellwhat && !Expand &&
- !whyles) || adrof(STRverbose)) {
+ if ((hadhist && !seterr && intty && !tellwhat && !Expand && !whyles) ||
+ adrof(STRverbose)) {
int odidfds = didfds;
haderr = 1;
didfds = 0;
@@ -2105,16 +1948,7 @@ process(catch)
didfds = odidfds;
}
(void) alarm(0); /* Autologout OFF */
-
- /*
- * The parser may lose space if interrupted.
- */
- if (setintr)
-#ifdef BSDSIGS
- (void) sigblock(sigmask(SIGINT));
-#else
- (void) sighold(SIGINT);
-#endif
+ alrmcatch_disabled = 1;
/*
* Save input text on the history list if reading in old history, or it
@@ -2140,14 +1974,14 @@ process(catch)
* should go
*/
if (justpr)
- reset();
+ goto cmd_done;
/*
* If had a tellwhat from twenex() then do
*/
if (tellwhat) {
(void) tellmewhat(&paraml, NULL);
- reset();
+ goto cmd_done;
}
alias(&paraml);
@@ -2168,7 +2002,8 @@ process(catch)
/*
* Parse the words of the input into a parse tree.
*/
- savet = syntax(paraml.next, &paraml, 0);
+ t = syntax(paraml.next, &paraml, 0);
+ cleanup_push(t, syntax_cleanup);
if (seterr)
stderror(ERR_OLD);
@@ -2177,33 +2012,32 @@ process(catch)
* Execute the parse tree From: Michael Schroeder
* <mlschroe@immd4.informatik.uni-erlangen.de> was execute(t, tpgrp);
*/
- execute(savet, (tpgrp > 0 ? tpgrp : -1), NULL, NULL, TRUE);
+ execute(t, (tpgrp > 0 ? tpgrp : -1), NULL, NULL, TRUE);
/*
* Made it!
*/
- freelex(&paraml);
- freesyn(savet), savet = NULL;
#ifdef SIG_WINDOW
if (windowchg || (catch && intty && !whyles && !tellwhat)) {
(void) check_window_size(0); /* for window systems */
}
#endif /* SIG_WINDOW */
- set(STR_, Strsave(InputBuf), VAR_READWRITE | VAR_NOGLOB);
+ setcopy(STR_, InputBuf, VAR_READWRITE | VAR_NOGLOB);
+ cmd_done:
+ cleanup_until(&paraml);
}
- savet = t;
+ exitset--;
+ cleanup_pop_mark(omark);
resexit(osetexit);
}
/*ARGSUSED*/
void
-dosource(t, c)
- Char **t;
- struct command *c;
+dosource(Char **t, struct command *c)
{
Char *f;
int hflg = 0;
- char buf[BUFSIZE];
+ char *file;
USE(c);
t++;
@@ -2219,19 +2053,13 @@ dosource(t, c)
}
f = globone(*t++, G_ERROR);
- (void) strcpy(buf, short2str(f));
- xfree((ptr_t) f);
- gflag = 0, tglob(t);
- if (gflag) {
- t = globall(t);
- if (t == 0)
- stderror(ERR_NAME | ERR_NOMATCH);
- } else {
- t = saveblk(t);
- trim(t);
- }
- if ((!srcfile(buf, 0, hflg, t)) && (!hflg) && (!bequiet))
- stderror(ERR_SYSTEM, buf, strerror(errno));
+ file = strsave(short2str(f));
+ cleanup_push(file, xfree);
+ xfree(f);
+ t = glob_all_or_error(t);
+ if ((!srcfile(file, 0, hflg, t)) && (!hflg) && (!bequiet))
+ stderror(ERR_SYSTEM, file, strerror(errno));
+ cleanup_until(file);
}
/*
@@ -2254,7 +2082,7 @@ dosource(t, c)
*/
static void
-mailchk()
+mailchk(void)
{
struct varent *v;
Char **vp;
@@ -2288,10 +2116,10 @@ mailchk()
if (S_ISDIR(stb.st_mode)) {
DIR *mailbox;
int mailcount = 0;
- char tempfilename[MAXPATHLEN];
+ char *tempfilename;
struct stat stc;
- xsnprintf(tempfilename, MAXPATHLEN, "%s/new", filename);
+ tempfilename = xasprintf("%s/new", filename);
if (stat(tempfilename, &stc) != -1 && S_ISDIR(stc.st_mode)) {
/*
@@ -2307,10 +2135,14 @@ mailchk()
mboxdir = tempfilename;
}
- if (stb.st_mtime <= chktim + 1 || (loginsh && !new))
+ if (stb.st_mtime <= chktim + 1 || (loginsh && !new)) {
+ xfree(tempfilename);
continue;
+ }
- if ((mailbox = opendir(mboxdir)) == NULL)
+ mailbox = opendir(mboxdir);
+ xfree(tempfilename);
+ if (mailbox == NULL)
continue;
/* skip . and .. */
@@ -2338,11 +2170,12 @@ mailchk()
(loginsh && !new))
continue;
type = strsave(new ? CGETS(11, 6, "new ") : "");
+ cleanup_push(type, xfree);
if (cnt == 1)
xprintf(CGETS(11, 5, "You have %smail.\n"), type);
else
xprintf(CGETS(11, 7, "You have %smail in %s.\n"), type, filename);
- xfree(type);
+ cleanup_until(type);
}
}
chktim = t;
@@ -2352,11 +2185,10 @@ mailchk()
* Extract a home directory from the password file
* The argument points to a buffer where the name of the
* user whose home directory is sought is currently.
- * We write the home directory of the user back there.
+ * We return home directory of the user, or NULL.
*/
-int
-gethdir(home)
- Char *home;
+Char *
+gethdir(const Char *home)
{
Char *h;
@@ -2364,23 +2196,19 @@ gethdir(home)
* Is it us?
*/
if (*home == '\0') {
- if ((h = varval(STRhome)) != STRNULL) {
- (void) Strcpy(home, h);
- return 0;
- }
+ if ((h = varval(STRhome)) != STRNULL)
+ return Strsave(h);
else
- return 1;
+ return NULL;
}
/*
* Look in the cache
*/
if ((h = gettilde(home)) == NULL)
- return 1;
- else {
- (void) Strcpy(home, h);
- return 0;
- }
+ return NULL;
+ else
+ return Strsave(h);
}
/*
@@ -2388,7 +2216,7 @@ gethdir(home)
* resting places, closing all other units.
*/
void
-initdesc()
+initdesc(void)
{
#ifdef NLS_BUGS
#ifdef NLS_CATALOGS
@@ -2417,11 +2245,10 @@ initdesc()
void
#ifdef PROF
-done(i)
+done(int i)
#else
-xexit(i)
+xexit(int i)
#endif
- int i;
{
#ifdef TESLA
if (loginsh && do_logout) {
@@ -2477,13 +2304,13 @@ xexit(i)
#ifndef _PATH_DEFPATH
static Char **
-defaultpath()
+defaultpath(void)
{
char *ptr;
Char **blk, **blkp;
struct stat stb;
- blkp = blk = (Char **) xmalloc((size_t) sizeof(Char *) * 10);
+ blkp = blk = xmalloc(sizeof(Char *) * 10);
#ifndef NODOT
# ifndef DOTLAST
@@ -2528,7 +2355,7 @@ defaultpath()
#endif
static void
-record()
+record(void)
{
if (!fast) {
recdirs(NULL, adrof(STRsavedirs) != NULL);
diff --git a/contrib/tcsh/sh.char.c b/contrib/tcsh/sh.char.c
index 6fb51d1..ee93c4f 100644
--- a/contrib/tcsh/sh.char.c
+++ b/contrib/tcsh/sh.char.c
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/sh.char.c,v 3.18 2002/07/01 20:50:21 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/sh.char.c,v 3.19 2006/03/02 18:46:44 christos Exp $ */
/*
* sh.char.c: Character classification tables
*/
@@ -32,7 +32,7 @@
*/
#include "sh.h"
-RCSID("$Id: sh.char.c,v 3.18 2002/07/01 20:50:21 christos Exp $")
+RCSID("$tcsh: sh.char.c,v 3.19 2006/03/02 18:46:44 christos Exp $")
#include "sh.char.h"
diff --git a/contrib/tcsh/sh.char.h b/contrib/tcsh/sh.char.h
index a4b20b1..de2b5c0 100644
--- a/contrib/tcsh/sh.char.h
+++ b/contrib/tcsh/sh.char.h
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/sh.char.h,v 3.26 2005/03/03 16:49:15 kim Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/sh.char.h,v 3.32 2006/09/26 16:44:37 christos Exp $ */
/*
* sh.char.h: Table for spotting special characters quickly
* Makes for very obscure but efficient coding.
@@ -37,7 +37,7 @@
# include <appkit/NXCType.h>
#else
# include <ctype.h>
-# ifdef SHORT_STRINGS
+# ifdef WIDE_STRINGS
# ifdef HAVE_WCTYPE_H
# include <wctype.h>
# else
@@ -90,8 +90,8 @@ extern tcshuc _cmap_lower[], _cmap_upper[];
#define _PUN 0x8000 /* punctuation */
#ifdef IS_ASCII
-# define ASC(ch) ch
-# define CTL_ESC(ch) ch
+# define ASC(ch) (ch)
+# define CTL_ESC(ch) (ch)
#else
# ifdef _OSD_POSIX
/* "BS2000 OSD" is a POSIX on a main frame using a EBCDIC char set */
@@ -103,30 +103,33 @@ extern tcshuc _cmap_lower[], _cmap_upper[];
extern unsigned short _toebcdic[256];
/* mainly for comparisons if (ASC(ch)=='\177')... */
-# define ASC(ch) _toascii[(tcshuc)ch]
+# define ASC(ch) _toascii[(tcshuc)(ch)]
/* Literal escapes ('\010') must be mapped to EBCDIC,
* for C-Escapes ('\b'), the compiler already does it.
*/
-# define CTL_ESC(ch) _toebcdic[(tcshuc)ch]
+# define CTL_ESC(ch) _toebcdic[(tcshuc)(ch)]
#endif /*IS_ASCII*/
#ifdef WIDE_STRINGS
# define cmap(c, bits) \
- (((c) & QUOTE) || (c) >= 0x0080 ? 0 : (_cmap[(tcshuc)ASC(c)] & (bits)))
+ (((c) < 0) ? 0 : \
+ ((c) & QUOTE) || (c) >= 0x0080 ? 0 : (_cmap[(tcshuc)ASC(c)] & (bits)))
#elif defined(SHORT_STRINGS) && defined(KANJI)
# define cmap(c, bits) \
- ((((c) & QUOTE) || ((ASC(c) & 0x80) && adrof(STRnokanji))) ? \
+ (((c) < 0) ? 0 : \
+ (((c) & QUOTE) || ((ASC(c) & 0x80) && adrof(STRnokanji))) ? \
0 : (_cmap[(tcshuc)ASC(c)] & (bits)))
#else /* SHORT_STRINGS && KANJI */
# define cmap(c, bits) \
- (((c) & QUOTE) ? 0 : (_cmap[(tcshuc)ASC(c)] & (bits)))
+ (((c) < 0) ? 0 : \
+ ((c) & QUOTE) ? 0 : (_cmap[(tcshuc)ASC(c)] & (bits)))
#endif /* SHORT_STRINGS && KANJI */
-#define isglob(c) cmap(c, _GLOB)
-#define isspc(c) cmap(c, _SP)
-#define ismeta(c) cmap(c, _META)
-#define iscmdmeta(c) cmap(c, _CMD)
+#define isglob(c) cmap((c), _GLOB)
+#define isspc(c) cmap((c), _SP)
+#define ismeta(c) cmap((c), _META)
+#define iscmdmeta(c) cmap((c), _CMD)
#ifdef WIDE_STRINGS
#define letter(c) (((c) & QUOTE) ? 0 : \
(iswalpha((tcshuc) (c)) || (c) == '_'))
@@ -242,36 +245,28 @@ extern tcshuc _cmap_lower[], _cmap_upper[];
# endif /* WINNT_NATIVE */
# endif /* !NeXT */
#else /* !NLS */
-# define Isspace(c) cmap(c, _SP|_NL)
-# define Isdigit(c) cmap(c, _DIG)
-# define Isalpha(c) (cmap(c,_LET) && !(((c) & META) && AsciiOnly))
-# define Islower(c) (cmap(c,_DOW) && !(((c) & META) && AsciiOnly))
-# define Isupper(c) (cmap(c, _UP) && !(((c) & META) && AsciiOnly))
+# define Isspace(c) cmap((c), _SP|_NL)
+# define Isdigit(c) cmap((c), _DIG)
+# define Isalpha(c) (cmap((c),_LET) && !(((c) & META) && AsciiOnly))
+# define Islower(c) (cmap((c),_DOW) && !(((c) & META) && AsciiOnly))
+# define Isupper(c) (cmap((c), _UP) && !(((c) & META) && AsciiOnly))
# define Tolower(c) (_cmap_lower[ASC(c)])
# define Toupper(c) (_cmap_upper[ASC(c)])
-# define Isxdigit(c) cmap(c, _XD)
-# define Isalnum(c) (cmap(c, _DIG|_LET) && !(((Char)(c) & META) && AsciiOnly))
+# define Isxdigit(c) cmap((c), _XD)
+# define Isalnum(c) (cmap((c), _DIG|_LET) && !(((Char)(c) & META) && AsciiOnly))
#if defined(DSPMBYTE)
-# define IscntrlM(c) (cmap(c,_CTR) && !(((c) & META) && AsciiOnly))
+# define IscntrlM(c) (cmap((c),_CTR) && !(((c) & META) && AsciiOnly))
# define Iscntrl(c) ( (IscntrlM(c)) && !(_enable_mbdisp&&(IsmbyteU((c)))) )
-# define IsprintM(c) (!cmap(c,_CTR) && !(((c) & META) && AsciiOnly))
+# define IsprintM(c) (!cmap((c),_CTR) && !(((c) & META) && AsciiOnly))
# define Isprint(c) ( (IsprintM(c)) || (_enable_mbdisp&&(IsmbyteU((c)))) )
#else
-# define Iscntrl(c) (cmap(c,_CTR) && !(((c) & META) && AsciiOnly))
-# define Isprint(c) (!cmap(c,_CTR) && !(((c) & META) && AsciiOnly))
+# define Iscntrl(c) (cmap((c),_CTR) && !(((c) & META) && AsciiOnly))
+# define Isprint(c) (!cmap((c),_CTR) && !(((c) & META) && AsciiOnly))
#endif /* !defined(DSPMBYTE) */
-# define Ispunct(c) (cmap(c,_PUN) && !(((c) & META) && AsciiOnly))
+# define Ispunct(c) (cmap((c),_PUN) && !(((c) & META) && AsciiOnly))
#endif /* !NLS */
-#if defined (SHORT_STRINGS) && defined (NLS)
-# define Iswcntrl(c) (((c) & QUOTE) ? 0 : iswcntrl(c))
-# define Iswprint(c) (((c) & QUOTE) ? 0 : iswprint(c))
-#else
-# define Iswcntrl(c) Iscntrl(c)
-# define Iswprint(c) Isprint(c)
-#endif
-
#if defined(DSPMBYTE)
# define Ismbyte1(c) ((_mbmap[(c) & 0377] & _MB1) ? 1 : 0)
# define Ismbyte2(c) ((_mbmap[(c) & 0377] & _MB2) ? 1 : 0)
diff --git a/contrib/tcsh/sh.decls.h b/contrib/tcsh/sh.decls.h
index b2dec32..41cddba 100644
--- a/contrib/tcsh/sh.decls.h
+++ b/contrib/tcsh/sh.decls.h
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/sh.decls.h,v 3.46 2005/03/03 17:04:01 kim Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/sh.decls.h,v 3.53 2006/08/24 20:56:31 christos Exp $ */
/*
* sh.decls.h External declarations from sh*.c
*/
@@ -36,359 +36,397 @@
/*
* sh.c
*/
-extern int gethdir __P((Char *));
-extern void dosource __P((Char **, struct command *));
-extern void exitstat __P((void));
-extern void goodbye __P((Char **, struct command *));
-extern void importpath __P((Char *));
-extern void initdesc __P((void));
-extern RETSIGTYPE pintr __P((int));
-extern void pintr1 __P((int));
-extern void process __P((int));
-extern void untty __P((void));
+extern Char *gethdir (const Char *);
+extern void dosource (Char **, struct command *);
+extern void exitstat (void);
+extern void goodbye (Char **, struct command *);
+extern void importpath (Char *);
+extern void initdesc (void);
+extern void pintr (void);
+extern void pintr1 (int);
+extern void phup (void);
+extern void process (int);
+extern void untty (void);
#ifdef PROF
-extern void done __P((int));
+extern void done (int);
#else
-extern void xexit __P((int));
+extern void xexit (int);
#endif
/*
* sh.dir.c
*/
-extern void dinit __P((Char *));
-extern void dodirs __P((Char **, struct command *));
-extern Char *dcanon __P((Char *, Char *));
-extern void dtildepr __P((Char *));
-extern void dtilde __P((void));
-extern void dochngd __P((Char **, struct command *));
-extern Char *dnormalize __P((Char *, int));
-extern void dopushd __P((Char **, struct command *));
-extern void dopopd __P((Char **, struct command *));
-extern void dfree __P((struct directory *));
-extern void dsetstack __P((void));
-extern int getstakd __P((Char *, int));
-extern void recdirs __P((Char *, int));
-extern void loaddirs __P((Char *));
+extern void dinit (Char *);
+extern void dodirs (Char **, struct command *);
+extern Char *dcanon (Char *, Char *);
+extern void dtildepr (Char *);
+extern void dtilde (void);
+extern void dochngd (Char **, struct command *);
+extern Char *dnormalize (const Char *, int);
+extern void dopushd (Char **, struct command *);
+extern void dopopd (Char **, struct command *);
+extern void dfree (struct directory *);
+extern void dsetstack (void);
+extern const Char *getstakd (int);
+extern void recdirs (Char *, int);
+extern void loaddirs (Char *);
/*
* sh.dol.c
*/
-extern void Dfix __P((struct command *));
-extern Char *Dfix1 __P((Char *));
-extern void heredoc __P((Char *));
+extern void Dfix (struct command *);
+extern Char *Dfix1 (Char *);
+extern void heredoc (Char *);
/*
* sh.err.c
*/
-extern void errinit __P((void));
-extern void seterror __P((unsigned int, ...));
-extern void stderror __P((unsigned int, ...));
+extern void reset (void);
+extern void cleanup_push_internal(void *, void (*fn) (void *)
+#ifdef CLEANUP_DEBUG
+ , const char *, size_t
+#define cleanup_push(v, f) cleanup_push_internal(v, f, __FILE__, __LINE__)
+#else
+#define cleanup_push(v, f) cleanup_push_internal(v, f)
+#endif
+);
+extern void cleanup_ignore(void *);
+extern void cleanup_until (void *);
+extern void cleanup_until_mark(void);
+extern size_t cleanup_push_mark(void);
+extern void cleanup_pop_mark(size_t);
+extern void open_cleanup(void *);
+extern void opendir_cleanup(void *);
+extern void sigint_cleanup(void *);
+extern void sigprocmask_cleanup(void *);
+extern void xfree_indirect(void *);
+extern void errinit (void);
+extern void seterror (unsigned int, ...);
+extern void stderror (unsigned int, ...);
/*
* sh.exec.c
*/
-extern void doexec __P((struct command *, int));
-extern void dohash __P((Char **, struct command *));
-extern void dounhash __P((Char **, struct command *));
-extern void execash __P((Char **, struct command *));
-extern void hashstat __P((Char **, struct command *));
-extern void xechoit __P((Char **));
-extern int executable __P((Char *, Char *, int));
-extern int tellmewhat __P((struct wordent *, Char *));
-extern void dowhere __P((Char **, struct command *));
-extern int find_cmd __P((Char *, int));
+extern void doexec (struct command *, int);
+extern void dohash (Char **, struct command *);
+extern void dounhash (Char **, struct command *);
+extern void execash (Char **, struct command *);
+extern void hashstat (Char **, struct command *);
+extern void xechoit (Char **);
+extern int executable (const Char *, const Char *, int);
+extern int tellmewhat (struct wordent *, Char **);
+extern void dowhere (Char **, struct command *);
+extern int find_cmd (Char *, int);
/*
* sh.exp.c
*/
-extern Char *filetest __P((Char *, Char ***, int));
-extern int expr __P((Char ***));
-extern int exp0 __P((Char ***, int));
+extern Char *filetest (Char *, Char ***, int);
+extern int expr (Char ***);
+extern int exp0 (Char ***, int);
/*
* sh.file.c
*/
#if defined(FILEC) && defined(TIOCSTI)
-extern int tenex __P((Char *, int));
+extern size_t tenex (Char *, size_t);
#endif
/*
* sh.func.c
*/
-extern void tsetenv __P((const Char *, const Char *));
-extern void Unsetenv __P((Char *));
-extern void doalias __P((Char **, struct command *));
-extern void dobreak __P((Char **, struct command *));
-extern void docontin __P((Char **, struct command *));
-extern void doecho __P((Char **, struct command *));
-extern void doelse __P((Char **, struct command *));
-extern void doend __P((Char **, struct command *));
-extern void doeval __P((Char **, struct command *));
-extern void doexit __P((Char **, struct command *));
-extern void doforeach __P((Char **, struct command *));
-extern void doglob __P((Char **, struct command *));
-extern void dogoto __P((Char **, struct command *));
-extern void doif __P((Char **, struct command *));
-extern void dolimit __P((Char **, struct command *));
-extern void dologin __P((Char **, struct command *));
-extern void dologout __P((Char **, struct command *));
+extern void tsetenv (const Char *, const Char *);
+extern void Unsetenv (Char *);
+extern void doalias (Char **, struct command *);
+extern void dobreak (Char **, struct command *);
+extern void docontin (Char **, struct command *);
+extern void doecho (Char **, struct command *);
+extern void doelse (Char **, struct command *);
+extern void doend (Char **, struct command *);
+extern void doeval (Char **, struct command *);
+extern void doexit (Char **, struct command *);
+extern void doforeach (Char **, struct command *);
+extern void doglob (Char **, struct command *);
+extern void dogoto (Char **, struct command *);
+extern void doif (Char **, struct command *);
+extern void dolimit (Char **, struct command *);
+extern void dologin (Char **, struct command *);
+extern void dologout (Char **, struct command *);
#ifdef NEWGRP
-extern void donewgrp __P((Char **, struct command *));
+extern void donewgrp (Char **, struct command *);
#endif
-extern void donohup __P((Char **, struct command *));
-extern void dohup __P((Char **, struct command *));
-extern void doonintr __P((Char **, struct command *));
-extern void doprintenv __P((Char **, struct command *));
-extern void dorepeat __P((Char **, struct command *));
-extern void dofiletest __P((Char **, struct command *));
-extern void dosetenv __P((Char **, struct command *));
-extern void dosuspend __P((Char **, struct command *));
-extern void doswbrk __P((Char **, struct command *));
-extern void doswitch __P((Char **, struct command *));
-extern void doumask __P((Char **, struct command *));
-extern void dounlimit __P((Char **, struct command *));
-extern void dounsetenv __P((Char **, struct command *));
-extern void dowhile __P((Char **, struct command *));
-extern void dozip __P((Char **, struct command *));
-extern void func __P((struct command *,
- struct biltins *));
-extern void gotolab __P((Char *));
-extern struct biltins *isbfunc __P((struct command *));
-extern void prvars __P((void));
-extern int srchx __P((Char *));
-extern void unalias __P((Char **, struct command *));
-extern void wfree __P((void));
-extern void dobuiltins __P((Char **, struct command *));
-extern void reexecute __P((struct command *));
+extern void donohup (Char **, struct command *);
+extern void dohup (Char **, struct command *);
+extern void doonintr (Char **, struct command *);
+extern void doprintenv (Char **, struct command *);
+extern void dorepeat (Char **, struct command *);
+extern void dofiletest (Char **, struct command *);
+extern void dosetenv (Char **, struct command *);
+extern void dosuspend (Char **, struct command *);
+extern void doswbrk (Char **, struct command *);
+extern void doswitch (Char **, struct command *);
+extern void doumask (Char **, struct command *);
+extern void dounlimit (Char **, struct command *);
+extern void dounsetenv (Char **, struct command *);
+extern void dowhile (Char **, struct command *);
+extern void dozip (Char **, struct command *);
+extern void func (struct command *,
+ const struct biltins *);
+extern void gotolab (Char *);
+extern const struct biltins *isbfunc (struct command *);
+extern void prvars (void);
+extern int srchx (Char *);
+extern void unalias (Char **, struct command *);
+extern void wfree (void);
+extern void dobuiltins (Char **, struct command *);
+extern void reexecute (struct command *);
/*
* sh.glob.c
*/
-extern Char *globequal __P((Char *, Char *));
-extern Char **dobackp __P((Char *, int));
-extern void Gcat __P((Char *, Char *));
-extern Char *globone __P((Char *, int));
-extern int Gmatch __P((Char *, Char *));
-extern int Gnmatch __P((Char *, Char *, Char **));
-extern void ginit __P((void));
-extern Char **globall __P((Char **));
-extern void rscan __P((Char **, void (*)(Char)));
-extern void tglob __P((Char **));
-extern void trim __P((Char **));
-#if defined(FILEC) && defined(TIOCSTI)
-extern int sortscmp __P((Char **, Char **));
-#endif
+extern Char *globequal (Char *);
+extern Char **dobackp (Char *, int);
+extern Char *globone (Char *, int);
+extern int Gmatch (const Char *, const Char *);
+extern int Gnmatch (const Char *, const Char *,
+ const Char **);
+extern Char **globall (Char **, int);
+extern Char **glob_all_or_error(Char **);
+extern void rscan (Char **, void (*)(Char));
+extern int tglob (Char **);
+extern void trim (Char **);
-#ifndef WINNT_NATIVE
-#ifdef NLS_CATALOGS
-#ifdef HAVE_ICONV
-extern char *iconv_catgets __P((nl_catd, int, int, const char *));
+#if !defined(WINNT_NATIVE) && defined(NLS_CATALOGS)
+extern char *xcatgets (nl_catd, int, int, const char *);
+#if defined(HAVE_ICONV) && defined(HAVE_NL_LANGINFO)
+extern char *iconv_catgets (nl_catd, int, int, const char *);
#endif
#endif
-#endif
-extern void nlsinit __P((void));
-extern void nlsclose __P((void));
-extern int t_pmatch __P((Char *, Char *, Char **, int));
+extern void nlsinit (void);
+extern void nlsclose (void);
+extern int t_pmatch (const Char *, const Char *,
+ const Char **, int);
/*
* sh.hist.c
*/
-extern void dohist __P((Char **, struct command *));
-extern struct Hist *enthist __P((int, struct wordent *, int, int));
-extern void savehist __P((struct wordent *, int));
-extern void fmthist __P((int, ptr_t, char *, size_t));
-extern void rechist __P((Char *, int));
-extern void loadhist __P((Char *, int));
+extern void dohist (Char **, struct command *);
+extern struct Hist *enthist (int, struct wordent *, int, int);
+extern void savehist (struct wordent *, int);
+extern char *fmthist (int, ptr_t);
+extern void rechist (Char *, int);
+extern void loadhist (Char *, int);
/*
* sh.init.c
*/
-extern void mesginit __P((void));
+extern void mesginit (void);
/*
* sh.lex.c
*/
-extern void addla __P((Char *));
-extern void bseek __P((struct Ain *));
-extern void btell __P((struct Ain *));
-extern void btoeof __P((void));
-extern void copylex __P((struct wordent *,
- struct wordent *));
-extern Char *domod __P((Char *, Char));
-extern void freelex __P((struct wordent *));
-extern int lex __P((struct wordent *));
-extern void prlex __P((struct wordent *));
-extern eChar readc __P((int));
-extern void settell __P((void));
-extern void unreadc __P((Char));
+extern void addla (Char *);
+extern void bseek (struct Ain *);
+extern void btell (struct Ain *);
+extern void btoeof (void);
+extern void copylex (struct wordent *, struct wordent *);
+extern Char *domod (Char *, Char);
+extern void freelex (struct wordent *);
+extern int lex (struct wordent *);
+extern void lex_cleanup (void *);
+extern void prlex (struct wordent *);
+extern eChar readc (int);
+extern void settell (void);
+extern void unreadc (Char);
/*
* sh.misc.c
*/
-extern int any __P((const char *, Char));
-extern Char **blkcpy __P((Char **, Char **));
-extern void blkfree __P((Char **));
-extern int blklen __P((Char **));
-extern void blkpr __P((Char **));
-extern void blkexpand __P((Char **, Char *));
-extern Char **blkspl __P((Char **, Char **));
-extern void closem __P((void));
+extern int any (const char *, Char);
+extern Char **blkcpy (Char **, Char **);
+extern void blkfree (Char **);
+extern void blk_cleanup (void *);
+extern void blk_indirect_cleanup(void *);
+extern int blklen (Char **);
+extern void blkpr (Char *const *);
+extern Char *blkexpand (Char *const *);
+extern Char **blkspl (Char **, Char **);
+extern void closem (void);
#ifndef CLOSE_ON_EXEC
-extern void closech __P((void));
+extern void closech (void);
#endif /* !CLOSE_ON_EXEC */
-extern Char **copyblk __P((Char **));
-extern int dcopy __P((int, int));
-extern int dmove __P((int, int));
-extern void donefds __P((void));
-extern Char lastchr __P((Char *));
-extern void lshift __P((Char **, int));
-extern int number __P((Char *));
-extern int prefix __P((const Char *, const Char *));
-extern Char **saveblk __P((Char **));
-extern void setzero __P((char *, int));
-extern Char *strip __P((Char *));
-extern Char *quote __P((Char *));
-extern Char *quote_meta __P((Char *, const Char *));
-extern char *strsave __P((const char *));
-extern void udvar __P((Char *));
+extern Char **copyblk (Char **);
+extern int dcopy (int, int);
+extern int dmove (int, int);
+extern void donefds (void);
+extern Char lastchr (Char *);
+extern void lshift (Char **, int);
+extern int number (Char *);
+extern int prefix (const Char *, const Char *);
+extern Char **saveblk (Char **);
+extern void setzero (void *, size_t);
+extern Char *strip (Char *);
+extern Char *quote (Char *);
+extern const Char *quote_meta (struct Strbuf *, const Char *);
+extern char *strnsave (const char *, size_t);
+extern char *strsave (const char *);
+extern void udvar (Char *);
#ifndef POSIX
-extern char *strstr __P((const char *, const char *));
+extern char *strstr (const char *, const char *);
#endif /* !POSIX */
-#ifndef SHORT_STRINGS
-extern char *strspl __P((const char *, const char *));
-extern char *strend __P((char *));
-#endif /* SHORT_STRINGS */
+extern char *strspl (const char *, const char *);
+extern char *strend (const char *);
+extern char *areadlink (const char *);
+extern void xclose (int);
+extern void xclosedir (DIR *);
+extern int xcreat (const char *, mode_t);
+extern struct group *xgetgrgid (gid_t);
+extern struct passwd *xgetpwnam (const char *);
+extern struct passwd *xgetpwuid (uid_t);
+extern int xopen (const char *, int, ...);
+extern ssize_t xread (int, void *, size_t);
+extern int xtcsetattr (int, int, const struct termios *);
+extern ssize_t xwrite (int, const void *, size_t);
/*
* sh.parse.c
*/
-extern void alias __P((struct wordent *));
-extern void freesyn __P((struct command *));
-extern struct command *syntax __P((struct wordent *,
- struct wordent *, int));
+extern void alias (struct wordent *);
+extern void freesyn (struct command *);
+extern struct command *syntax (const struct wordent *,
+ const struct wordent *, int);
+extern void syntax_cleanup(void *);
/*
* sh.print.c
*/
-extern void drainoline __P((void));
-extern void flush __P((void));
+extern void drainoline (void);
+extern void flush (void);
#ifdef BSDTIMES
-extern void pcsecs __P((unsigned long));
+extern void pcsecs (unsigned long);
#else /* !BSDTIMES */
# ifdef POSIX
-extern void pcsecs __P((clock_t));
+extern void pcsecs (clock_t);
# else /* !POSIX */
-extern void pcsecs __P((time_t));
+extern void pcsecs (time_t);
# endif /* !POSIX */
#endif /* BSDTIMES */
#ifdef BSDLIMIT
-extern void psecs __P((unsigned long));
+extern void psecs (unsigned long);
#endif /* BSDLIMIT */
-extern int putpure __P((int));
-extern int putraw __P((int));
-extern void xputchar __P((int));
+extern int putpure (int);
+extern int putraw (int);
+extern void xputchar (int);
#ifdef WIDE_STRINGS
-extern void putwraw __P((Char));
-extern void xputwchar __P((Char));
+extern void putwraw (Char);
+extern void xputwchar (Char);
#else
# define putwraw(C) putraw(C)
# define xputwchar(C) xputchar(C)
#endif
+extern void output_raw_restore(void *);
/*
* sh.proc.c
*/
-extern void dobg __P((Char **, struct command *));
-extern void dobg1 __P((Char **, struct command *));
-extern void dofg __P((Char **, struct command *));
-extern void dofg1 __P((Char **, struct command *));
-extern void dojobs __P((Char **, struct command *));
-extern void dokill __P((Char **, struct command *));
-extern void donotify __P((Char **, struct command *));
-extern void dostop __P((Char **, struct command *));
-extern void dowait __P((Char **, struct command *));
-extern void palloc __P((int, struct command *));
-extern void panystop __P((int));
-extern RETSIGTYPE pchild __P((int));
-extern void pendjob __P((void));
-extern int pfork __P((struct command *, int));
-extern void pgetty __P((int, int));
-extern void pjwait __P((struct process *));
-extern void pnote __P((void));
-extern void prestjob __P((void));
-extern void psavejob __P((void));
-extern int pstart __P((struct process *, int));
-extern void pwait __P((void));
-extern struct process *pfind __P((Char *));
+extern void dobg (Char **, struct command *);
+extern void dobg1 (Char **, struct command *);
+extern void dofg (Char **, struct command *);
+extern void dofg1 (Char **, struct command *);
+extern void dojobs (Char **, struct command *);
+extern void dokill (Char **, struct command *);
+extern void donotify (Char **, struct command *);
+extern void dostop (Char **, struct command *);
+extern void dowait (Char **, struct command *);
+extern void palloc (pid_t, struct command *);
+extern void panystop (int);
+extern void pchild (void);
+extern void pendjob (void);
+extern pid_t pfork (struct command *, int);
+extern void pgetty (int, pid_t);
+extern void pjwait (struct process *);
+extern void pnote (void);
+extern void psavejob (void);
+extern void psavejob_cleanup(void *);
+extern int pstart (struct process *, int);
+extern void pwait (void);
+extern struct process *pfind (Char *);
/*
* sh.sem.c
*/
-extern void execute __P((struct command *, int, int *,
- int *, int));
-extern void mypipe __P((int *));
+extern void execute (struct command *, int, int *,
+ int *, int);
+extern void mypipe (int *);
/*
* sh.set.c
*/
-extern struct varent *adrof1 __P((Char *, struct varent *));
-extern void doset __P((Char **, struct command *));
-extern void dolet __P((Char **, struct command *));
-extern Char *putn __P((int));
-extern int getn __P((Char *));
-extern Char *value1 __P((Char *, struct varent *));
-extern void set __P((Char *, Char *, int));
-extern void set1 __P((Char *, Char **, struct varent *,
- int));
-extern void setq __P((Char *, Char **, struct varent *,
- int));
-extern void unset __P((Char **, struct command *));
-extern void unset1 __P((Char *[], struct varent *));
-extern void unsetv __P((Char *));
-extern void setNS __P((Char *));
-extern void shift __P((Char **, struct command *));
-extern void plist __P((struct varent *, int));
-extern Char *unparse __P((struct command *));
+extern struct varent *adrof1 (const Char *, struct varent *);
+extern void doset (Char **, struct command *);
+extern void dolet (Char **, struct command *);
+extern Char *putn (int);
+extern int getn (Char *);
+extern Char *value1 (Char *, struct varent *);
+extern void setcopy (const Char *, const Char *, int);
+extern void setv (const Char *, Char *, int);
+extern void set1 (const Char *, Char **,
+ struct varent *, int);
+extern void setq (const Char *, Char **,
+ struct varent *, int);
+extern void unset (Char **, struct command *);
+extern void unset1 (Char *[], struct varent *);
+extern void unsetv (Char *);
+extern void setNS (Char *);
+extern void shift (Char **, struct command *);
+extern void plist (struct varent *, int);
+extern Char *unparse (struct command *);
#if defined(DSPMBYTE)
-extern void update_dspmbyte_vars __P((void));
-extern void autoset_dspmbyte __P((Char *));
+extern void update_dspmbyte_vars (void);
+extern void autoset_dspmbyte (const Char *);
#endif
/*
* sh.time.c
*/
-extern void donice __P((Char **, struct command *));
-extern void dotime __P((Char **, struct command *));
+extern void donice (Char **, struct command *);
+extern void dotime (Char **, struct command *);
#ifdef BSDTIMES
-extern void prusage __P((struct sysrusage *,
- struct sysrusage *,
- timeval_t *, timeval_t *));
-extern void ruadd __P((struct sysrusage *,
- struct sysrusage *));
+extern void prusage (struct sysrusage *,
+ struct sysrusage *,
+ timeval_t *, timeval_t *);
+extern void ruadd (struct sysrusage *,
+ struct sysrusage *);
#else /* BSDTIMES */
# ifdef _SEQUENT_
-extern void prusage __P((struct process_stats *,
- struct process_stats *,
- timeval_t *, timeval_t *));
-extern void ruadd __P((struct process_stats *,
- struct process_stats *));
+extern void prusage (struct process_stats *,
+ struct process_stats *,
+ timeval_t *, timeval_t *);
+extern void ruadd (struct process_stats *,
+ struct process_stats *);
# else /* !_SEQUENT_ */
# ifdef POSIX
-extern void prusage __P((struct tms *, struct tms *,
- clock_t, clock_t));
+extern void prusage (struct tms *, struct tms *,
+ clock_t, clock_t);
# else /* !POSIX */
-extern void prusage __P((struct tms *, struct tms *,
- time_t, time_t));
+extern void prusage (struct tms *, struct tms *,
+ time_t, time_t);
# endif /* !POSIX */
# endif /* !_SEQUENT_ */
#endif /* BSDTIMES */
-extern void settimes __P((void));
+extern void settimes (void);
#if defined(BSDTIMES) || defined(_SEQUENT_)
-extern void tvsub __P((struct timeval *,
- struct timeval *,
- struct timeval *));
+extern void tvsub (struct timeval *,
+ struct timeval *,
+ struct timeval *);
#endif /* BSDTIMES || _SEQUENT_ */
+/*
+ * tw.parse.c
+ */
+extern void copyn (Char *, const Char *, size_t);
+extern void catn (Char *, const Char *, int);
+
#endif /* _h_sh_decls */
diff --git a/contrib/tcsh/sh.dir.c b/contrib/tcsh/sh.dir.c
index fdd85b7..3fd8d70 100644
--- a/contrib/tcsh/sh.dir.c
+++ b/contrib/tcsh/sh.dir.c
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/sh.dir.c,v 3.66 2005/03/03 16:40:53 kim Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/sh.dir.c,v 3.79 2006/09/25 18:17:26 christos Exp $ */
/*
* sh.dir.c: Directory manipulation functions
*/
@@ -33,32 +33,62 @@
#include "sh.h"
#include "ed.h"
-RCSID("$Id: sh.dir.c,v 3.66 2005/03/03 16:40:53 kim Exp $")
+RCSID("$tcsh: sh.dir.c,v 3.79 2006/09/25 18:17:26 christos Exp $")
/*
* C Shell - directory management
*/
-static void dstart __P((const char *));
-static struct directory *dfind __P((Char *));
-static Char *dfollow __P((Char *));
-static void printdirs __P((int));
-static Char *dgoto __P((Char *));
-static void dnewcwd __P((struct directory *, int));
-static void dset __P((Char *));
-static void dextract __P((struct directory *));
-static int skipargs __P((Char ***, const char *,
- const char *));
-static void dgetstack __P((void));
+static Char *agetcwd (void);
+static void dstart (const char *);
+static struct directory *dfind (Char *);
+static Char *dfollow (Char *);
+static void printdirs (int);
+static Char *dgoto (Char *);
+static void dnewcwd (struct directory *, int);
+static void dset (Char *);
+static void dextract (struct directory *);
+static int skipargs (Char ***, const char *,
+ const char *);
+static void dgetstack (void);
static struct directory dhead INIT_ZERO_STRUCT; /* "head" of loop */
static int printd; /* force name to be printed */
int bequiet = 0; /* do not print dir stack -strike */
+static Char *
+agetcwd(void)
+{
+ char *buf;
+ Char *cwd;
+ size_t len;
+
+ len = MAXPATHLEN;
+ buf = xmalloc(len);
+ while (getcwd(buf, len) == NULL) {
+ int err;
+
+ err = errno;
+ if (err != ERANGE) {
+ xfree(buf);
+ errno = err;
+ return NULL;
+ }
+ len *= 2;
+ buf = xrealloc(buf, len);
+ }
+ if (*buf == '\0') {
+ xfree(buf);
+ return NULL;
+ }
+ cwd = SAVE(buf);
+ xfree(buf);
+ return cwd;
+}
+
static void
-dstart(from)
- const char *from;
+dstart(const char *from)
{
xprintf(CGETS(12, 1, "%s: Trying to start from \"%s\"\n"), progname, from);
}
@@ -67,22 +97,19 @@ dstart(from)
* dinit - initialize current working directory
*/
void
-dinit(hp)
- Char *hp;
+dinit(Char *hp)
{
- char *tcp;
- Char *cp;
+ Char *cp, *tcp;
struct directory *dp;
- char path[MAXPATHLEN];
/* Don't believe the login shell home, because it may be a symlink */
- tcp = (char *) getcwd(path, sizeof(path));
- if (tcp == NULL || *tcp == '\0') {
+ tcp = agetcwd();
+ if (tcp == NULL) {
xprintf("%s: %s\n", progname, strerror(errno));
if (hp && *hp) {
- tcp = short2str(hp);
- dstart(tcp);
- if (chdir(tcp) == -1)
+ char *xcp = short2str(hp);
+ dstart(xcp);
+ if (chdir(xcp) == -1)
cp = NULL;
else
cp = Strsave(hp);
@@ -100,12 +127,13 @@ dinit(hp)
else {
#ifdef S_IFLNK
struct stat swd, shp;
+ int swd_ok;
+ swd_ok = stat(short2str(tcp), &swd) == 0;
/*
* See if $HOME is the working directory we got and use that
*/
- if (hp && *hp &&
- stat(tcp, &swd) != -1 && stat(short2str(hp), &shp) != -1 &&
+ if (swd_ok && hp && *hp && stat(short2str(hp), &shp) != -1 &&
DEV_DEV_COMPARE(swd.st_dev, shp.st_dev) &&
swd.st_ino == shp.st_ino)
cp = Strsave(hp);
@@ -115,40 +143,46 @@ dinit(hp)
/*
* use PWD if we have it (for subshells)
*/
- if ((cwd = getenv("PWD")) != NULL) {
- if (stat(cwd, &shp) != -1 &&
+ if (swd_ok && (cwd = getenv("PWD")) != NULL) {
+ if (stat(cwd, &shp) != -1 &&
DEV_DEV_COMPARE(swd.st_dev, shp.st_dev) &&
- swd.st_ino == shp.st_ino)
- tcp = cwd;
+ swd.st_ino == shp.st_ino) {
+ tcp = SAVE(cwd);
+ cleanup_push(tcp, xfree);
+ }
}
- cp = dcanon(SAVE(tcp), STRNULL);
+ cleanup_push(tcp, xfree);
+ cp = dcanon(tcp, STRNULL);
+ cleanup_ignore(tcp);
+ cleanup_until(tcp);
}
#else /* S_IFLNK */
- cp = dcanon(SAVE(tcp), STRNULL);
+ cleanup_push(tcp, xfree);
+ cp = dcanon(tcp, STRNULL);
+ cleanup_ignore(tcp);
+ cleanup_until(tcp);
#endif /* S_IFLNK */
}
- dp = (struct directory *) xcalloc(sizeof(struct directory), 1);
+ dp = xcalloc(sizeof(struct directory), 1);
dp->di_name = cp;
dp->di_count = 0;
dhead.di_next = dhead.di_prev = dp;
dp->di_next = dp->di_prev = &dhead;
printd = 0;
dnewcwd(dp, 0);
- set(STRdirstack, Strsave(dp->di_name), VAR_READWRITE|VAR_NOGLOB);
+ setcopy(STRdirstack, dp->di_name, VAR_READWRITE|VAR_NOGLOB);
}
static void
-dset(dp)
-Char *dp;
+dset(Char *dp)
{
/*
* Don't call set() directly cause if the directory contains ` or
* other junk characters glob will fail.
*/
- set(STRowd, Strsave(varval(STRcwd)), VAR_READWRITE|VAR_NOGLOB);
- set(STRcwd, Strsave(dp), VAR_READWRITE|VAR_NOGLOB);
-
+ setcopy(STRowd, varval(STRcwd), VAR_READWRITE|VAR_NOGLOB);
+ setcopy(STRcwd, dp, VAR_READWRITE|VAR_NOGLOB);
tsetenv(STRPWD, dp);
}
@@ -162,10 +196,7 @@ Char *dp;
#define DIR_OLD 0x80 /* - */
static int
-skipargs(v, dstr, str)
- Char ***v;
- const char *dstr;
- const char *str;
+skipargs(Char ***v, const char *dstr, const char *str)
{
Char **n = *v, *s;
@@ -175,15 +206,12 @@ skipargs(v, dstr, str)
dflag |= DIR_OLD;
else {
char *p;
- while (loop && *s != '\0') /* examine flags */
+ while (*s != '\0') /* examine flags */
{
if ((p = strchr(dstr, *s++)) != NULL)
dflag |= (1 << (p - dstr));
- else {
+ else
stderror(ERR_DIRUS, short2str(**v), dstr, str);
- loop = 0; /* break from both loops */
- break;
- }
}
}
if (*n && (dflag & DIR_OLD))
@@ -200,11 +228,9 @@ skipargs(v, dstr, str)
*/
/*ARGSUSED*/
void
-dodirs(v, c)
- Char **v;
- struct command *c;
+dodirs(Char **v, struct command *c)
{
- static char flags[] = "plvnSLc";
+ static const char flags[] = "plvnSLc";
int dflag = skipargs(&v, flags, "");
USE(c);
@@ -234,8 +260,7 @@ dodirs(v, c)
}
static void
-printdirs(dflag)
- int dflag;
+printdirs(int dflag)
{
struct directory *dp;
Char *s, *user;
@@ -259,7 +284,7 @@ printdirs(dflag)
len = (int) (Strlen(s) + 1);
cur += len;
- if ((dflag & DIR_LINE) && cur >= T_Cols - 1 && len < T_Cols) {
+ if ((dflag & DIR_LINE) && cur >= TermH - 1 && len < TermH) {
xputchar('\n');
cur = len;
}
@@ -272,8 +297,7 @@ printdirs(dflag)
}
void
-dtildepr(dir)
- Char *dir;
+dtildepr(Char *dir)
{
Char* user;
if ((user = getusername(&dir)) != NULL)
@@ -283,7 +307,7 @@ dtildepr(dir)
}
void
-dtilde()
+dtilde(void)
{
struct directory *d = dcwd;
@@ -307,9 +331,7 @@ dtilde()
* Otherwise, a copy is made and sent back.
*/
Char *
-dnormalize(cp, expnd)
- Char *cp;
- int expnd;
+dnormalize(const Char *cp, int expnd)
{
/* return true if dp is of the form "../xxx" or "/../xxx" */
@@ -318,34 +340,44 @@ dnormalize(cp, expnd)
#ifdef S_IFLNK
if (expnd) {
+ struct Strbuf buf = Strbuf_INIT;
int dotdot = 0;
- Char *dp, *cwd, *start = cp, buf[MAXPATHLEN];
- struct stat sb;
-# ifdef apollo
+ Char *dp, *cwd;
+ const Char *start = cp;
+# ifdef HAVE_SLASHSLASH
int slashslash;
-# endif /* apollo */
+# endif /* HAVE_SLASHSLASH */
/*
* count the number of "../xxx" or "xxx/../xxx" in the path
*/
- for (dp=start; *dp && *(dp+1); dp++)
- if (IS_DOTDOT(start, dp))
+ for ( ; *cp && *(cp + 1); cp++)
+ if (IS_DOTDOT(start, cp))
dotdot++;
+
/*
* if none, we are done.
*/
if (dotdot == 0)
- return (Strsave(cp));
-
+ return (Strsave(start));
+
+# ifdef notdef
+ struct stat sb;
/*
+ * We disable this test because:
+ * cd /tmp; mkdir dir1 dir2; cd dir2; ln -s /tmp/dir1; cd dir1;
+ * echo ../../dir1 does not expand. We had enabled this before
+ * because it was bothering people with expansions in compilation
+ * lines like -I../../foo. Maybe we need some kind of finer grain
+ * control?
+ *
* If the path doesn't exist, we are done too.
*/
- if (lstat(short2str(cp), &sb) != 0 && errno == ENOENT)
- return (Strsave(cp));
-
+ if (lstat(short2str(start), &sb) != 0 && errno == ENOENT)
+ return (Strsave(start));
+# endif
- cwd = (Char *) xmalloc((size_t) (((int) Strlen(dcwd->di_name) + 3) *
- sizeof(Char)));
+ cwd = xmalloc((Strlen(dcwd->di_name) + 3) * sizeof(Char));
(void) Strcpy(cwd, dcwd->di_name);
/*
@@ -354,24 +386,24 @@ dnormalize(cp, expnd)
*/
if (ABSOLUTEP(start))
*cwd = '\0';
-# ifdef apollo
+# ifdef HAVE_SLASHSLASH
slashslash = cwd[0] == '/' && cwd[1] == '/';
-# endif /* apollo */
+# endif /* HAVE_SLASHSLASH */
/*
* Ignore . and count ..'s
*/
- for (;;) {
+ cp = start;
+ do {
dotdot = 0;
- buf[0] = '\0';
- dp = buf;
+ buf.len = 0;
while (*cp)
if (IS_DOT(start, cp)) {
if (*++cp)
cp++;
}
else if (IS_DOTDOT(start, cp)) {
- if (buf[0])
+ if (buf.len != 0)
break; /* finish analyzing .././../xxx/[..] */
dotdot++;
cp += 2;
@@ -379,15 +411,15 @@ dnormalize(cp, expnd)
cp++;
}
else
- *dp++ = *cp++;
+ Strbuf_append1(&buf, *cp++);
- *dp = '\0';
+ Strbuf_terminate(&buf);
while (dotdot > 0)
if ((dp = Strrchr(cwd, '/')) != NULL) {
-# ifdef apollo
+# ifdef HAVE_SLASHSLASH
if (dp == &cwd[1])
slashslash = 1;
-# endif /* apollo */
+# endif /* HAVE_SLASHSLASH */
*dp = '\0';
dotdot--;
}
@@ -396,29 +428,38 @@ dnormalize(cp, expnd)
if (!*cwd) { /* too many ..'s, starts with "/" */
cwd[0] = '/';
-# ifdef apollo
- cwd[1] = '/';
+# ifdef HAVE_SLASHSLASH
+ /*
+ * Only append another slash, if already the former cwd
+ * was in a double-slash path.
+ */
+ cwd[1] = slashslash ? '/' : '\0';
cwd[2] = '\0';
-# else /* !apollo */
+# else /* !HAVE_SLASHSLASH */
cwd[1] = '\0';
-# endif /* apollo */
+# endif /* HAVE_SLASHSLASH */
}
-# ifdef apollo
+# ifdef HAVE_SLASHSLASH
else if (slashslash && cwd[1] == '\0') {
cwd[1] = '/';
cwd[2] = '\0';
}
-# endif /* apollo */
-
- if (buf[0]) {
- if ((TRM(cwd[(dotdot = (int) Strlen(cwd)) - 1])) != '/')
- cwd[dotdot++] = '/';
- cwd[dotdot] = '\0';
- dp = Strspl(cwd, TRM(buf[0]) == '/' ? &buf[1] : buf);
- xfree((ptr_t) cwd);
+# endif /* HAVE_SLASHSLASH */
+
+ if (buf.len != 0) {
+ size_t i;
+
+ i = Strlen(cwd);
+ if (TRM(cwd[i - 1]) != '/') {
+ cwd[i++] = '/';
+ cwd[i] = '\0';
+ }
+ dp = Strspl(cwd, TRM(buf.s[0]) == '/' ? &buf.s[1] : buf.s);
+ xfree(cwd);
cwd = dp;
- if ((TRM(cwd[(dotdot = (int) Strlen(cwd)) - 1])) == '/')
- cwd[--dotdot] = '\0';
+ i = Strlen(cwd) - 1;
+ if (TRM(cwd[i]) == '/')
+ cwd[i] = '\0';
}
/* Reduction of ".." following the stuff we collected in buf
* only makes sense if the directory item in buf really exists.
@@ -428,13 +469,13 @@ dnormalize(cp, expnd)
if (cwd[0]) {
struct stat exists;
if (0 != stat(short2str(cwd), &exists)) {
- xfree((ptr_t) cwd);
+ xfree(buf.s);
+ xfree(cwd);
return Strsave(start);
}
}
- if (!*cp)
- break;
- }
+ } while (*cp != '\0');
+ xfree(buf.s);
return cwd;
}
#endif /* S_IFLNK */
@@ -447,9 +488,7 @@ dnormalize(cp, expnd)
*/
/*ARGSUSED*/
void
-dochngd(v, c)
- Char **v;
- struct command *c;
+dochngd(Char **v, struct command *c)
{
Char *cp;
struct directory *dp;
@@ -486,7 +525,7 @@ dochngd(v, c)
else
if ((cp = dfollow(cp)) == NULL)
return;
- dp = (struct directory *) xcalloc(sizeof(struct directory), 1);
+ dp = xcalloc(sizeof(struct directory), 1);
dp->di_name = cp;
dp->di_count = 0;
dp->di_next = dcwd->di_next;
@@ -498,32 +537,27 @@ dochngd(v, c)
}
static Char *
-dgoto(cp)
- Char *cp;
+dgoto(Char *cp)
{
- Char *dp;
+ Char *dp, *ret;
if (!ABSOLUTEP(cp))
{
Char *p, *q;
- int cwdlen;
+ size_t cwdlen;
- for (p = dcwd->di_name; *p++;)
- continue;
- if ((cwdlen = (int) (p - dcwd->di_name - 1)) == 1) /* root */
+ cwdlen = Strlen(dcwd->di_name);
+ if (cwdlen == 1) /* root */
cwdlen = 0;
- for (p = cp; *p++;)
- continue;
- dp = (Char *) xmalloc((size_t)((cwdlen + (p - cp) + 1) * sizeof(Char)));
+ dp = xmalloc((cwdlen + Strlen(cp) + 2) * sizeof(Char));
for (p = dp, q = dcwd->di_name; (*p++ = *q++) != '\0';)
continue;
if (cwdlen)
p[-1] = '/';
else
p--; /* don't add a / after root */
- for (q = cp; (*p++ = *q++) != '\0';)
- continue;
- xfree((ptr_t) cp);
+ Strcpy(p, cp);
+ xfree(cp);
cp = dp;
dp += cwdlen;
}
@@ -531,114 +565,127 @@ dgoto(cp)
dp = cp;
#if defined(WINNT_NATIVE)
- cp = SAVE(getcwd(NULL, 0));
+ return agetcwd();
#elif defined(__CYGWIN__)
- if (ABSOLUTEP(cp) && cp[1] == ':') /* Only DOS paths are treated that way */
- cp = SAVE(getcwd(NULL, 0));
- else
- cp = dcanon(cp, dp);
+ if (ABSOLUTEP(cp) && cp[1] == ':') { /* Only DOS paths are treated that way */
+ return agetcwd();
+ } else {
+ cleanup_push(cp, xfree);
+ ret = dcanon(cp, dp);
+ cleanup_ignore(cp);
+ cleanup_until(cp);
+ }
#else /* !WINNT_NATIVE */
- cp = dcanon(cp, dp);
+ cleanup_push(cp, xfree);
+ ret = dcanon(cp, dp);
+ cleanup_ignore(cp);
+ cleanup_until(cp);
#endif /* WINNT_NATIVE */
- return cp;
+ return ret;
}
/*
* dfollow - change to arg directory; fall back on cdpath if not valid
*/
static Char *
-dfollow(cp)
- Char *cp;
+dfollow(Char *cp)
{
Char *dp;
struct varent *c;
- char ebuf[MAXPATHLEN];
int serrno;
cp = globone(cp, G_ERROR);
+ cleanup_push(cp, xfree);
#ifdef apollo
if (Strchr(cp, '`')) {
- char *dptr, *ptr;
+ char *dptr;
if (chdir(dptr = short2str(cp)) < 0)
stderror(ERR_SYSTEM, dptr, strerror(errno));
- else if ((ptr = getcwd(ebuf, sizeof(ebuf))) && *ptr != '\0') {
- xfree((ptr_t) cp);
- cp = Strsave(str2short(ptr));
- return dgoto(cp);
+ dp = agetcwd();
+ cleanup_push(dp, xfree);
+ if (dp != NULL) {
+ cleanup_until(cp);
+ return dgoto(dp);
}
- else
- stderror(ERR_SYSTEM, dptr, ebuf);
+ else
+ stderror(ERR_SYSTEM, dptr, strerror(errno));
}
#endif /* apollo */
-
- (void) strncpy(ebuf, short2str(cp), MAXPATHLEN);
- ebuf[MAXPATHLEN-1] = '\0';
+
/*
* if we are ignoring symlinks, try to fix relatives now.
* if we are expading symlinks, it should be done by now.
*/
dp = dnormalize(cp, symlinks == SYM_IGNORE);
if (chdir(short2str(dp)) >= 0) {
- xfree((ptr_t) cp);
+ cleanup_until(cp);
return dgoto(dp);
}
else {
- xfree((ptr_t) dp);
- if (chdir(short2str(cp)) >= 0)
+ xfree(dp);
+ if (chdir(short2str(cp)) >= 0) {
+ cleanup_ignore(cp);
+ cleanup_until(cp);
return dgoto(cp);
- else if (errno != ENOENT && errno != ENOTDIR)
- stderror(ERR_SYSTEM, ebuf, strerror(errno));
+ }
+ else if (errno != ENOENT && errno != ENOTDIR) {
+ int err;
+
+ err = errno;
+ stderror(ERR_SYSTEM, short2str(cp), strerror(err));
+ }
serrno = errno;
}
if (cp[0] != '/' && !prefix(STRdotsl, cp) && !prefix(STRdotdotsl, cp)
&& (c = adrof(STRcdpath)) && c->vec != NULL) {
+ struct Strbuf buf = Strbuf_INIT;
Char **cdp;
- Char *p;
- Char buf[MAXPATHLEN];
for (cdp = c->vec; *cdp; cdp++) {
- for (dp = buf, p = *cdp; (*dp++ = *p++) != '\0';)
- continue;
- dp[-1] = '/';
- for (p = cp; (*dp++ = *p++) != '\0';)
- continue;
+ buf.len = 0;
+ Strbuf_append(&buf, *cdp);
+ Strbuf_append1(&buf, '/');
+ Strbuf_append(&buf, cp);
+ Strbuf_terminate(&buf);
/*
* We always want to fix the directory here
* If we are normalizing symlinks
*/
- dp = dnormalize(buf, symlinks == SYM_IGNORE ||
- symlinks == SYM_EXPAND);
+ dp = dnormalize(buf.s, symlinks == SYM_IGNORE ||
+ symlinks == SYM_EXPAND);
if (chdir(short2str(dp)) >= 0) {
printd = 1;
- xfree((ptr_t) cp);
+ xfree(buf.s);
+ cleanup_until(cp);
return dgoto(dp);
}
else if (chdir(short2str(cp)) >= 0) {
printd = 1;
- xfree((ptr_t) dp);
+ xfree(dp);
+ xfree(buf.s);
+ cleanup_ignore(cp);
+ cleanup_until(cp);
return dgoto(cp);
}
}
+ xfree(buf.s);
}
dp = varval(cp);
if ((dp[0] == '/' || dp[0] == '.') && chdir(short2str(dp)) >= 0) {
- xfree((ptr_t) cp);
+ cleanup_until(cp);
cp = Strsave(dp);
printd = 1;
return dgoto(cp);
}
- xfree((ptr_t) cp);
/*
* on login source of ~/.cshdirs, errors are eaten. the dir stack is all
* directories we could get to.
*/
- if (!bequiet) {
- stderror(ERR_SYSTEM, ebuf, strerror(serrno));
- return (NULL);
- }
- else
- return (NULL);
+ if (!bequiet)
+ stderror(ERR_SYSTEM, short2str(cp), strerror(serrno));
+ cleanup_until(cp);
+ return (NULL);
}
@@ -649,9 +696,7 @@ dfollow(cp)
*/
/*ARGSUSED*/
void
-dopushd(v, c)
- Char **v;
- struct command *c;
+dopushd(Char **v, struct command *c)
{
struct directory *dp;
Char *cp;
@@ -667,10 +712,9 @@ dopushd(v, c)
stderror(ERR_NAME | ERR_NOHOMEDIR);
if (chdir(short2str(cp)) < 0)
stderror(ERR_NAME | ERR_CANTCHANGE);
- cp = Strsave(cp); /* hmmm... PWP */
if ((cp = dfollow(cp)) == NULL)
return;
- dp = (struct directory *) xcalloc(sizeof(struct directory), 1);
+ dp = xcalloc(sizeof(struct directory), 1);
dp->di_name = cp;
dp->di_count = 0;
dp->di_prev = dcwd;
@@ -716,7 +760,7 @@ dopushd(v, c)
if ((ccp = dfollow(cp)) == NULL)
return;
- dp = (struct directory *) xcalloc(sizeof(struct directory), 1);
+ dp = xcalloc(sizeof(struct directory), 1);
dp->di_name = ccp;
dp->di_count = 0;
dp->di_prev = dcwd;
@@ -731,8 +775,7 @@ dopushd(v, c)
* dfind - find a directory if specified by numeric (+n) argument
*/
static struct directory *
-dfind(cp)
- Char *cp;
+dfind(Char *cp)
{
struct directory *dp;
int i;
@@ -762,9 +805,7 @@ dfind(cp)
*/
/*ARGSUSED*/
void
-dopopd(v, c)
- Char **v;
- struct command *c;
+dopopd(Char **v, struct command *c)
{
Char *cp;
struct directory *dp, *p = NULL;
@@ -795,29 +836,28 @@ dopopd(v, c)
}
dp->di_prev->di_next = dp->di_next;
dp->di_next->di_prev = dp->di_prev;
+ dfree(dp);
if (dp == dcwd) {
- dnewcwd(p, dflag);
+ dnewcwd(p, dflag);
}
else {
printdirs(dflag);
}
- dfree(dp);
}
/*
* dfree - free the directory (or keep it if it still has ref count)
*/
void
-dfree(dp)
- struct directory *dp;
+dfree(struct directory *dp)
{
if (dp->di_count != 0) {
dp->di_next = dp->di_prev = 0;
}
else {
- xfree((ptr_t) dp->di_name);
- xfree((ptr_t) dp);
+ xfree(dp->di_name);
+ xfree(dp);
}
}
@@ -827,29 +867,23 @@ dfree(dp)
* constructed (always have ..'s, directories have links)
*/
Char *
-dcanon(cp, p)
- Char *cp, *p;
+dcanon(Char *cp, Char *p)
{
Char *sp;
Char *p1, *p2; /* general purpose */
int slash;
-#ifdef apollo
+#ifdef HAVE_SLASHSLASH
int slashslash;
-#endif /* apollo */
+#endif /* HAVE_SLASHSLASH */
size_t clen;
#ifdef S_IFLNK /* if we have symlinks */
- Char mlink[MAXPATHLEN];
- char tlink[MAXPATHLEN];
- int cc;
- Char *newcp;
+ Char *mlink, *newcp;
+ char *tlink;
+ size_t cc;
#endif /* S_IFLNK */
- /*
- * if the path given is too long truncate it!
- */
- if ((clen = Strlen(cp)) >= MAXPATHLEN)
- cp[clen = MAXPATHLEN - 1] = '\0';
+ clen = Strlen(cp);
/*
* christos: if the path given does not start with a slash prepend cwd. If
@@ -857,33 +891,33 @@ dcanon(cp, p)
* correct it.
*/
if (!ABSOLUTEP(cp)) {
- Char tmpdir[MAXPATHLEN];
+ Char *tmpdir;
size_t len;
p1 = varval(STRcwd);
if (p1 == STRNULL || !ABSOLUTEP(p1)) {
- char *tmp = (char *)getcwd((char *)tmpdir, sizeof(tmpdir));
- if (tmp == NULL || *tmp == '\0') {
+ Char *new_cwd = agetcwd();
+
+ if (new_cwd == NULL) {
xprintf("%s: %s\n", progname, strerror(errno));
- set(STRcwd, SAVE("/"), VAR_READWRITE|VAR_NOGLOB);
- } else {
- set(STRcwd, SAVE(tmp), VAR_READWRITE|VAR_NOGLOB);
+ setcopy(STRcwd, str2short("/"), VAR_READWRITE|VAR_NOGLOB);
}
+ else
+ setv(STRcwd, new_cwd, VAR_READWRITE|VAR_NOGLOB);
p1 = varval(STRcwd);
}
len = Strlen(p1);
- if (len + clen + 1 >= MAXPATHLEN)
- cp[MAXPATHLEN - (len + 1)] = '\0';
+ tmpdir = xmalloc((len + clen + 2) * sizeof (*tmpdir));
(void) Strcpy(tmpdir, p1);
(void) Strcat(tmpdir, STRslash);
(void) Strcat(tmpdir, cp);
- xfree((ptr_t) cp);
- cp = p = Strsave(tmpdir);
+ xfree(cp);
+ cp = p = tmpdir;
}
-#ifdef apollo
+#ifdef HAVE_SLASHSLASH
slashslash = (cp[0] == '/' && cp[1] == '/');
-#endif /* apollo */
+#endif /* HAVE_SLASHSLASH */
while (*p) { /* for each component */
sp = p; /* save slash address */
@@ -902,10 +936,10 @@ dcanon(cp, p)
break;
}
-#ifdef apollo
+#ifdef HAVE_SLASHSLASH
if (&cp[1] == sp && sp[0] == '.' && sp[1] == '.' && sp[2] == '\0')
slashslash = 1;
-#endif /* apollo */
+#endif /* HAVE_SLASHSLASH */
if (*sp == '\0') { /* if component is null */
if (--sp == cp) /* if path is one char (i.e. /) */
break;
@@ -933,12 +967,9 @@ dcanon(cp, p)
*--sp = 0; /* form the pathname for readlink */
#ifdef S_IFLNK /* if we have symlinks */
if (sp != cp && /* symlinks != SYM_IGNORE && */
- (cc = readlink(short2str(cp), tlink,
- sizeof(tlink) - 1)) >= 0) {
- tlink[cc] = '\0';
- (void) Strncpy(mlink, str2short(tlink),
- sizeof(mlink) / sizeof(Char));
- mlink[sizeof(mlink) / sizeof(Char) - 1] = '\0';
+ (tlink = areadlink(short2str(cp))) != NULL) {
+ mlink = str2short(tlink);
+ xfree(tlink);
if (slash)
*p = '/';
@@ -946,11 +977,6 @@ dcanon(cp, p)
* Point p to the '/' in "/..", and restore the '/'.
*/
*(p = sp) = '/';
- /*
- * find length of p
- */
- for (p1 = p; *p1++;)
- continue;
if (*mlink != '/') {
/*
* Relative path, expand it between the "yyy/" and the
@@ -963,9 +989,8 @@ dcanon(cp, p)
/*
* New length is "yyy/" + mlink + "/.." and rest
*/
- p1 = newcp = (Char *) xmalloc((size_t)
- (((sp - cp) + cc + (p1 - p)) *
- sizeof(Char)));
+ p1 = newcp = xmalloc(((sp - cp) + Strlen(mlink) +
+ Strlen(p) + 1) * sizeof(Char));
/*
* Copy new path into newcp
*/
@@ -981,28 +1006,17 @@ dcanon(cp, p)
p = sp - cp - 1 + newcp;
}
else {
- /*
- * New length is mlink + "/.." and rest
- */
- p1 = newcp = (Char *) xmalloc((size_t)
- ((cc + (p1 - p)) * sizeof(Char)));
- /*
- * Copy new path into newcp
- */
- for (p2 = mlink; (*p1++ = *p2++) != '\0';)
- continue;
- for (p1--, p2 = p; (*p1++ = *p2++) != '\0';)
- continue;
+ newcp = Strspl(mlink, p);
/*
* Restart canonicalization at beginning
*/
p = newcp;
}
- xfree((ptr_t) cp);
+ xfree(cp);
cp = newcp;
-#ifdef apollo
+#ifdef HAVE_SLASHSLASH
slashslash = (cp[0] == '/' && cp[1] == '/');
-#endif /* apollo */
+#endif /* HAVE_SLASHSLASH */
continue; /* canonicalize the link */
}
#endif /* S_IFLNK */
@@ -1024,12 +1038,9 @@ dcanon(cp, p)
#ifdef S_IFLNK /* if we have symlinks */
if (sp != cp && symlinks == SYM_CHASE &&
- (cc = readlink(short2str(cp), tlink,
- sizeof(tlink) - 1)) >= 0) {
- tlink[cc] = '\0';
- (void) Strncpy(mlink, str2short(tlink),
- sizeof(mlink) / sizeof(Char));
- mlink[sizeof(mlink) / sizeof(Char) - 1] = '\0';
+ (tlink = areadlink(short2str(cp))) != NULL) {
+ mlink = str2short(tlink);
+ xfree(tlink);
/*
* restore the '/'.
@@ -1042,11 +1053,6 @@ dcanon(cp, p)
*/
sp = p;
- /*
- * find length of p
- */
- for (p1 = p; *p1++;)
- continue;
if (*mlink != '/') {
/*
* Relative path, expand it between the "yyy/" and the
@@ -1060,9 +1066,8 @@ dcanon(cp, p)
/*
* New length is "yyy/" + mlink + "/.." and rest
*/
- p1 = newcp = (Char *) xmalloc((size_t)
- (((sp - cp) + cc + (p1 - p))
- * sizeof(Char)));
+ p1 = newcp = xmalloc(((sp - cp) + Strlen(mlink) +
+ Strlen(p) + 1) * sizeof(Char));
/*
* Copy new path into newcp
*/
@@ -1078,28 +1083,17 @@ dcanon(cp, p)
p = sp - cp - 1 + newcp;
}
else {
- /*
- * New length is mlink + the rest
- */
- p1 = newcp = (Char *) xmalloc((size_t)
- ((cc + (p1 - p)) * sizeof(Char)));
- /*
- * Copy new path into newcp
- */
- for (p2 = mlink; (*p1++ = *p2++) != '\0';)
- continue;
- for (p1--, p2 = p; (*p1++ = *p2++) != '\0';)
- continue;
+ newcp = Strspl(mlink, p);
/*
* Restart canonicalization at beginning
*/
p = newcp;
}
- xfree((ptr_t) cp);
+ xfree(cp);
cp = newcp;
-#ifdef apollo
+#ifdef HAVE_SLASHSLASH
slashslash = (cp[0] == '/' && cp[1] == '/');
-#endif /* apollo */
+#endif /* HAVE_SLASHSLASH */
continue; /* canonicalize the mlink */
}
#endif /* S_IFLNK */
@@ -1113,17 +1107,18 @@ dcanon(cp, p)
*/
#ifdef S_IFLNK
p1 = varval(STRhome);
- cc = (int) Strlen(p1);
+ cc = Strlen(p1);
/*
* See if we're not in a subdir of STRhome
*/
- if (p1 && *p1 == '/' && (Strncmp(p1, cp, (size_t) cc) != 0 ||
+ if (p1 && *p1 == '/' && (Strncmp(p1, cp, cc) != 0 ||
(cp[cc] != '/' && cp[cc] != '\0'))) {
static ino_t home_ino = (ino_t) -1;
static dev_t home_dev = (dev_t) -1;
static Char *home_ptr = NULL;
struct stat statbuf;
int found;
+ Char *copy;
/*
* Get dev and ino of STRhome
@@ -1137,8 +1132,7 @@ dcanon(cp, p)
/*
* Start comparing dev & ino backwards
*/
- p2 = Strncpy(mlink, cp, sizeof(mlink) / sizeof(Char));
- mlink[sizeof(mlink) / sizeof(Char) - 1] = '\0';
+ p2 = copy = Strsave(cp);
found = 0;
while (*p2 && stat(short2str(p2), &statbuf) != -1) {
if (DEV_DEV_COMPARE(statbuf.st_dev, home_dev) &&
@@ -1157,25 +1151,28 @@ dcanon(cp, p)
* Use STRhome to make '~' work
*/
newcp = Strspl(p1, cp + Strlen(p2));
- xfree((ptr_t) cp);
+ xfree(cp);
cp = newcp;
}
+ xfree(copy);
}
#endif /* S_IFLNK */
-#ifdef apollo
+#ifdef HAVE_SLASHSLASH
if (slashslash) {
if (cp[1] != '/') {
- p = (Char *) xmalloc((size_t) (Strlen(cp) + 2) * sizeof(Char));
+ p = xmalloc((Strlen(cp) + 2) * sizeof(Char));
*p = '/';
(void) Strcpy(&p[1], cp);
- xfree((ptr_t) cp);
+ xfree(cp);
cp = p;
}
}
- if (cp[1] == '/' && cp[2] == '/')
- (void) Strcpy(&cp[1], &cp[2]);
-#endif /* apollo */
+ if (cp[1] == '/' && cp[2] == '/') {
+ for (p1 = &cp[1], p2 = &cp[2]; (*p1++ = *p2++) != '\0';)
+ continue;
+ }
+#endif /* HAVE_SLASHSLASH */
return cp;
}
@@ -1184,9 +1181,7 @@ dcanon(cp, p)
* dnewcwd - make a new directory in the loop the current one
*/
static void
-dnewcwd(dp, dflag)
- struct directory *dp;
- int dflag;
+dnewcwd(struct directory *dp, int dflag)
{
int print;
@@ -1217,7 +1212,7 @@ dnewcwd(dp, dflag)
}
void
-dsetstack()
+dsetstack(void)
{
Char **cp;
struct varent *vp;
@@ -1240,7 +1235,7 @@ dsetstack()
/* put back the stack */
for (cp = vp->vec; cp && *cp && **cp; cp++) {
- dp = (struct directory *) xcalloc(sizeof(struct directory), 1);
+ dp = xcalloc(sizeof(struct directory), 1);
dp->di_name = Strsave(*cp);
dp->di_count = 0;
dp->di_prev = dcwd;
@@ -1252,7 +1247,7 @@ dsetstack()
}
static void
-dgetstack()
+dgetstack(void)
{
int i = 0;
Char **dblk, **dbp;
@@ -1261,13 +1256,16 @@ dgetstack()
if (adrof(STRdirstack) == NULL)
return;
- for (dn = dhead.di_prev; dn != &dhead; dn = dn->di_prev, i++)
+ for (dn = dhead.di_prev; dn != &dhead; dn = dn->di_prev, i++)
continue;
- dbp = dblk = (Char**) xmalloc((size_t) (i + 1) * sizeof(Char *));
- for (dn = dhead.di_prev; dn != &dhead; dn = dn->di_prev, dbp++)
+ dbp = dblk = xmalloc((i + 1) * sizeof(Char *));
+ for (dn = dhead.di_prev; dn != &dhead; dn = dn->di_prev, dbp++)
*dbp = Strsave(dn->di_name);
*dbp = NULL;
+ cleanup_push(dblk, blk_cleanup);
setq(STRdirstack, dblk, &shvhed, VAR_READWRITE);
+ cleanup_ignore(dblk);
+ cleanup_until(dblk);
}
/*
@@ -1275,10 +1273,8 @@ dgetstack()
* Support routine for the stack hack. Finds nth directory in
* the directory stack, or finds last directory in stack.
*/
-int
-getstakd(s, cnt)
- Char *s;
- int cnt;
+const Char *
+getstakd(int cnt)
{
struct directory *dp;
@@ -1294,12 +1290,10 @@ getstakd(s, cnt)
if (dp == &dhead)
dp = dp->di_prev;
if (dp == dcwd)
- return (0);
+ return NULL;
}
}
- (void) Strncpy(s, dp->di_name, BUFSIZE);
- s[BUFSIZE - 1] = '\0';
- return (1);
+ return dp->di_name;
}
/*
@@ -1310,8 +1304,7 @@ getstakd(s, cnt)
* position, and pushes it onto the top.
*/
static void
-dextract(dp)
- struct directory *dp;
+dextract(struct directory *dp)
{
if (dp == dcwd)
return;
@@ -1323,21 +1316,28 @@ dextract(dp)
dcwd->di_next = dp;
}
+static void
+bequiet_cleanup(void *dummy)
+{
+ USE(dummy);
+ bequiet = 0;
+}
+
void
-loaddirs(fname)
- Char *fname;
+loaddirs(Char *fname)
{
static Char *loaddirs_cmd[] = { STRsource, NULL, NULL };
bequiet = 1;
- if (fname)
+ cleanup_push(&bequiet, bequiet_cleanup);
+ if (fname)
loaddirs_cmd[1] = fname;
else if ((fname = varval(STRdirsfile)) != STRNULL)
loaddirs_cmd[1] = fname;
else
loaddirs_cmd[1] = STRtildotdirs;
- dosource(loaddirs_cmd, (struct command *)0);
- bequiet = 0;
+ dosource(loaddirs_cmd, NULL);
+ cleanup_until(&bequiet);
}
/*
@@ -1348,16 +1348,14 @@ loaddirs(fname)
* -strike
*/
void
-recdirs(fname, def)
- Char *fname;
- int def;
+recdirs(Char *fname, int def)
{
int fp, ftmp, oldidfds;
int cdflag = 0;
struct directory *dp;
unsigned int num;
Char *snum;
- Char qname[MAXPATHLEN*2];
+ struct Strbuf qname = Strbuf_INIT;
if (fname == NULL && !def)
return;
@@ -1370,9 +1368,10 @@ recdirs(fname, def)
}
else
fname = globone(fname, G_ERROR);
-
- if ((fp = creat(short2str(fname), 0600)) == -1) {
- xfree((ptr_t) fname);
+ cleanup_push(fname, xfree);
+
+ if ((fp = xcreat(short2str(fname), 0600)) == -1) {
+ cleanup_until(fname);
return;
}
@@ -1386,6 +1385,7 @@ recdirs(fname, def)
ftmp = SHOUT;
SHOUT = fp;
+ cleanup_push(&qname, Strbuf_cleanup);
dp = dcwd->di_next;
do {
if (dp == &dhead)
@@ -1393,18 +1393,18 @@ recdirs(fname, def)
if (cdflag == 0) {
cdflag = 1;
- xprintf("cd %S\n", quote_meta(qname, dp->di_name));
+ xprintf("cd %S\n", quote_meta(&qname, dp->di_name));
}
else
- xprintf("pushd %S\n", quote_meta(qname, dp->di_name));
+ xprintf("pushd %S\n", quote_meta(&qname, dp->di_name));
if (num-- == 0)
break;
} while ((dp = dp->di_next) != dcwd->di_next);
- (void) close(fp);
+ xclose(fp);
SHOUT = ftmp;
didfds = oldidfds;
- xfree((ptr_t) fname);
+ cleanup_until(fname);
}
diff --git a/contrib/tcsh/sh.dir.h b/contrib/tcsh/sh.dir.h
index 6f76f49..121cf19 100644
--- a/contrib/tcsh/sh.dir.h
+++ b/contrib/tcsh/sh.dir.h
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/sh.dir.h,v 3.6 2002/03/08 17:36:46 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/sh.dir.h,v 3.6 2002/03/08 17:36:46 christos Exp $ */
/*
* sh.dir.h: Directory data structures and globals
*/
diff --git a/contrib/tcsh/sh.dol.c b/contrib/tcsh/sh.dol.c
index f5ee7eb..73ac3b2 100644
--- a/contrib/tcsh/sh.dol.c
+++ b/contrib/tcsh/sh.dol.c
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/sh.dol.c,v 3.55 2004/12/25 21:15:06 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/sh.dol.c,v 3.70 2006/09/14 18:30:16 christos Exp $ */
/*
* sh.dol.c: Variable substitutions
*/
@@ -32,7 +32,7 @@
*/
#include "sh.h"
-RCSID("$Id: sh.dol.c,v 3.55 2004/12/25 21:15:06 christos Exp $")
+RCSID("$tcsh: sh.dol.c,v 3.70 2006/09/14 18:30:16 christos Exp $")
/*
* C shell
@@ -49,7 +49,7 @@ RCSID("$Id: sh.dol.c,v 3.55 2004/12/25 21:15:06 christos Exp $")
static Char Dpeekc; /* Peek for DgetC */
static eChar Dpeekrd; /* Peek for Dreadc */
-static Char *Dcp, **Dvp; /* Input vector for Dreadc */
+static Char *Dcp, *const *Dvp; /* Input vector for Dreadc */
#define DEOF CHAR_ERR
@@ -63,41 +63,31 @@ static Char *Dcp, **Dvp; /* Input vector for Dreadc */
* words within this expansion, the count of remaining words, and the
* information about any : modifier which is being applied.
*/
-#define MAXWLEN (BUFSIZE - 4)
-#ifndef COMPAT
-#define MAXMOD MAXWLEN /* This cannot overflow */
-#endif /* COMPAT */
static Char *dolp; /* Remaining chars from this word */
static Char **dolnxt; /* Further words */
static int dolcnt; /* Count of further words */
-#ifdef COMPAT
-static Char dolmod; /* : modifier character */
-#else
-static Char dolmod[MAXMOD]; /* : modifier character */
-static int dolnmod; /* Number of modifiers */
-#endif /* COMPAT */
-static int dolmcnt; /* :gx -> 10000, else 1 */
-static int dolwcnt; /* :ax -> 10000, else 1 */
-
-static void Dfix2 __P((Char **));
-static Char *Dpack __P((Char *, Char *));
-static int Dword __P((void));
-static void dolerror __P((Char *));
-static eChar DgetC __P((int));
-static void Dgetdol __P((void));
-static void fixDolMod __P((void));
-static void setDolp __P((Char *));
-static void unDredc __P((eChar));
-static eChar Dredc __P((void));
-static void Dtestq __P((Char));
+static struct Strbuf dolmod; /* = Strbuf_INIT; : modifier characters */
+static int dolmcnt; /* :gx -> INT_MAX, else 1 */
+static int dol_flag_a; /* :ax -> 1, else 0 */
+
+static Char **Dfix2 (Char *const *);
+static int Dpack (struct Strbuf *);
+static int Dword (struct blk_buf *);
+static void dolerror (Char *);
+static eChar DgetC (int);
+static void Dgetdol (void);
+static void fixDolMod (void);
+static void setDolp (Char *);
+static void unDredc (eChar);
+static eChar Dredc (void);
+static void Dtestq (Char);
/*
* Fix up the $ expansions and quotations in the
* argument list to command t.
*/
void
-Dfix(t)
- struct command *t;
+Dfix(struct command *t)
{
Char **pp;
Char *p;
@@ -108,10 +98,11 @@ Dfix(t)
for (pp = t->t_dcom; (p = *pp++) != NULL;) {
for (; *p; p++) {
if (cmap(*p, _DOL | QUOTES)) { /* $, \, ', ", ` */
- Dfix2(t->t_dcom); /* found one */
+ Char **expanded;
+
+ expanded = Dfix2(t->t_dcom); /* found one */
blkfree(t->t_dcom);
- t->t_dcom = gargv;
- gargv = 0;
+ t->t_dcom = expanded;
return;
}
}
@@ -122,52 +113,54 @@ Dfix(t)
* $ substitute one word, for i/o redirection
*/
Char *
-Dfix1(cp)
- Char *cp;
+Dfix1(Char *cp)
{
- Char *Dv[2];
+ Char *Dv[2], **expanded;
if (noexec)
return (0);
Dv[0] = cp;
Dv[1] = NULL;
- Dfix2(Dv);
- if (gargc != 1) {
+ expanded = Dfix2(Dv);
+ if (expanded[0] == NULL || expanded[1] != NULL) {
+ blkfree(expanded);
setname(short2str(cp));
stderror(ERR_NAME | ERR_AMBIG);
}
- cp = Strsave(gargv[0]);
- blkfree(gargv), gargv = 0;
+ cp = Strsave(expanded[0]);
+ blkfree(expanded);
return (cp);
}
/*
* Subroutine to do actual fixing after state initialization.
*/
-static void
-Dfix2(v)
- Char **v;
+static Char **
+Dfix2(Char *const *v)
{
- ginit(); /* Initialize glob's area pointers */
+ struct blk_buf bb = BLK_BUF_INIT;
+
Dvp = v;
Dcp = STRNULL; /* Setup input vector for Dreadc */
unDgetC(0);
unDredc(0); /* Clear out any old peeks (at error) */
dolp = 0;
dolcnt = 0; /* Clear out residual $ expands (...) */
- while (Dword())
+ cleanup_push(&bb, bb_cleanup);
+ while (Dword(&bb))
continue;
+ cleanup_ignore(&bb);
+ cleanup_until(&bb);
+ return bb_finish(&bb);
}
/*
* Pack up more characters in this word
*/
-static Char *
-Dpack(wbuf, wp)
- Char *wbuf, *wp;
+static int
+Dpack(struct Strbuf *wbuf)
{
eChar c;
- int i = MAXWLEN - (int) (wp - wbuf);
for (;;) {
c = DgetC(DODOL);
@@ -175,9 +168,7 @@ Dpack(wbuf, wp)
c = DgetC(0);
if (c == DEOF) {
unDredc(c);
- *wp = 0;
- Gcat(STRNULL, wbuf);
- return (NULL);
+ return 1;
}
if (c == '\n')
c = ' ';
@@ -186,21 +177,15 @@ Dpack(wbuf, wp)
}
if (c == DEOF) {
unDredc(c);
- *wp = 0;
- Gcat(STRNULL, wbuf);
- return (NULL);
+ return 1;
}
if (cmap(c, _SP | _NL | _QF | _QB)) { /* sp \t\n'"` */
unDgetC(c);
if (cmap(c, QUOTES))
- return (wp);
- *wp++ = 0;
- Gcat(STRNULL, wbuf);
- return (NULL);
+ return 0;
+ return 1;
}
- if (--i <= 0)
- stderror(ERR_WTOOLONG);
- *wp++ = (Char) c;
+ Strbuf_append1(wbuf, (Char) c);
}
}
@@ -211,40 +196,37 @@ Dpack(wbuf, wp)
* Rather, DgetC will return a DEOF when we hit the end-of-input.
*/
static int
-Dword()
+Dword(struct blk_buf *bb)
{
eChar c, c1;
- Char wbuf[BUFSIZE];
- Char *wp = wbuf;
- int i = MAXWLEN;
+ struct Strbuf wbuf = Strbuf_INIT;
int dolflg;
- int sofar = 0, done = 0;
+ int sofar = 0;
- while (!done) {
- done = 1;
+ cleanup_push(&wbuf, Strbuf_cleanup);
+ for (;;) {
c = DgetC(DODOL);
switch (c) {
case DEOF:
- if (sofar == 0)
+ if (sofar == 0) {
+ cleanup_until(&wbuf);
return (0);
+ }
/* finish this word and catch the code above the next time */
unDredc(c);
/*FALLTHROUGH*/
case '\n':
- *wp = 0;
- Gcat(STRNULL, wbuf);
- return (1);
+ goto end;
case ' ':
case '\t':
- done = 0;
- break;
+ continue;
case '`':
/* We preserve ` quotations which are done yet later */
- *wp++ = (Char) c, --i;
+ Strbuf_append1(&wbuf, (Char) c);
/*FALLTHROUGH*/
case '\'':
case '"':
@@ -261,12 +243,9 @@ Dword()
if (c == '\n' || c == DEOF)
stderror(ERR_UNMATCHED, (int)c1);
if ((c & (QUOTE | TRIM)) == ('\n' | QUOTE)) {
- if ((wp[-1] & TRIM) == '\\')
- --wp;
- ++i;
+ if (wbuf.len != 0 && (wbuf.s[wbuf.len - 1] & TRIM) == '\\')
+ wbuf.len--;
}
- if (--i <= 0)
- stderror(ERR_WTOOLONG);
switch (c1) {
case '"':
@@ -274,17 +253,17 @@ Dword()
* Leave any `s alone for later. Other chars are all
* quoted, thus `...` can tell it was within "...".
*/
- *wp++ = c == '`' ? '`' : c | QUOTE;
+ Strbuf_append1(&wbuf, c == '`' ? '`' : c | QUOTE);
break;
case '\'':
/* Prevent all further interpretation */
- *wp++ = c | QUOTE;
+ Strbuf_append1(&wbuf, c | QUOTE);
break;
case '`':
/* Leave all text alone for later */
- *wp++ = (Char) c;
+ Strbuf_append1(&wbuf, (Char) c);
break;
default:
@@ -292,63 +271,33 @@ Dword()
}
}
if (c1 == '`')
- *wp++ = '`' /* i--; eliminated */;
+ Strbuf_append1(&wbuf, '`');
sofar = 1;
- if ((wp = Dpack(wbuf, wp)) == NULL)
- return (1);
- else {
-#ifdef masscomp
- /*
- * Avoid a nasty message from the RTU 4.1A & RTU 5.0 compiler concerning
- * the "overuse of registers". According to the compiler release notes,
- * incorrect code may be produced unless the offending expression is
- * rewritten. Therefore, we can't just ignore it, DAS DEC-90.
- */
- i = MAXWLEN;
- i -= (int) (wp - wbuf);
-#else /* !masscomp */
- i = MAXWLEN - (int) (wp - wbuf);
-#endif /* masscomp */
- done = 0;
- }
- break;
+ if (Dpack(&wbuf) != 0)
+ goto end;
+ continue;
case '\\':
c = DgetC(0); /* No $ subst! */
- if (c == '\n' || c == DEOF) {
- done = 0;
- break;
- }
+ if (c == '\n' || c == DEOF)
+ continue;
c |= QUOTE;
break;
default:
break;
}
- if (done) {
- unDgetC(c);
- sofar = 1;
- if ((wp = Dpack(wbuf, wp)) == NULL)
- return (1);
- else {
-#ifdef masscomp
- /*
- * Avoid a nasty message from the RTU 4.1A & RTU 5.0 compiler concerning
- * the "overuse of registers". According to the compiler release notes,
- * incorrect code may be produced unless the offending expression is
- * rewritten. Therefore, we can't just ignore it, DAS DEC-90.
- */
- i = MAXWLEN;
- i -= (int) (wp - wbuf);
-#else /* !masscomp */
- i = MAXWLEN - (int) (wp - wbuf);
-#endif /* masscomp */
- done = 0;
- }
- }
+ unDgetC(c);
+ sofar = 1;
+ if (Dpack(&wbuf) != 0)
+ goto end;
}
- /* Really NOTREACHED */
- return (0);
+
+ end:
+ cleanup_ignore(&wbuf);
+ cleanup_until(&wbuf);
+ bb_append(bb, Strbuf_finish(&wbuf));
+ return 1;
}
@@ -358,8 +307,7 @@ Dword()
* QUOTEd so that it will not be recognized above.
*/
static eChar
-DgetC(flag)
- int flag;
+DgetC(int flag)
{
Char c;
@@ -368,12 +316,8 @@ top:
Dpeekc = 0;
return (c);
}
- if (lap) {
- c = *lap++ & (QUOTE | TRIM);
- if (c == 0) {
- lap = 0;
- goto top;
- }
+ if (lap < labuf.len) {
+ c = labuf.s[lap++] & (QUOTE | TRIM);
quotspec:
if (cmap(c, QUOTES))
return (c | QUOTE);
@@ -407,8 +351,7 @@ static struct varent nulargv = {nulvec, STRargv, VAR_READWRITE,
{ NULL, NULL, NULL }, 0 };
static void
-dolerror(s)
- Char *s;
+dolerror(Char *s)
{
setname(short2str(s));
stderror(ERR_NAME | ERR_RANGE);
@@ -419,23 +362,23 @@ dolerror(s)
* Ugh.
*/
static void
-Dgetdol()
+Dgetdol(void)
{
Char *np;
struct varent *vp = NULL;
- Char name[4 * MAXVARLEN + 1];
+ struct Strbuf name = Strbuf_INIT;
eChar c, sc;
int subscr = 0, lwb = 1, upb = 0;
int dimen = 0, bitset = 0, length = 0;
- Char wbuf[BUFSIZE];
static Char *dolbang = NULL;
-#ifdef COMPAT
- dolmod = dolmcnt = dolwcnt = 0;
-#else
- dolnmod = dolmcnt = dolwcnt = 0;
-#endif /* COMPAT */
+ cleanup_push(&name, Strbuf_cleanup);
+ dolmod.len = dolmcnt = dol_flag_a = 0;
c = sc = DgetC(0);
+ if (c == DEOF) {
+ stderror(ERR_SYNTAX);
+ return;
+ }
if (c == '{')
c = DgetC(0); /* sc is { to take } later */
if ((c & TRIM) == '#')
@@ -450,110 +393,91 @@ Dgetdol()
if (dimen || bitset || length)
stderror(ERR_SYNTAX);
if (backpid != 0) {
- if (dolbang)
- xfree((ptr_t) dolbang);
+ xfree(dolbang);
setDolp(dolbang = putn(backpid));
}
+ cleanup_until(&name);
goto eatbrac;
case '$':
if (dimen || bitset || length)
stderror(ERR_SYNTAX);
setDolp(doldol);
+ cleanup_until(&name);
goto eatbrac;
-#ifdef COHERENT
- /* Coherent compiler doesn't allow case-labels that are not
- constant-expressions */
-#ifdef WIDE_STRINGS
- case 0x4000003C: /* Does Coherent have 32-bit int at all? */
-#elif defined (SHORT_STRINGS)
- case 0100074:
-#else /* !SHORT_STRINGS */
- case 0274:
-#endif
-#else /* !COHERENT */
- case '<'|QUOTE:
-#endif
+ case '<'|QUOTE: {
+ static struct Strbuf wbuf; /* = Strbuf_INIT; */
+
if (bitset)
stderror(ERR_NOTALLOWED, "$?<");
if (dimen)
stderror(ERR_NOTALLOWED, "$#<");
if (length)
stderror(ERR_NOTALLOWED, "$%<");
+ wbuf.len = 0;
{
char cbuf[MB_LEN_MAX];
size_t cbp = 0;
+ int old_pintr_disabled;
-#ifdef BSDSIGS
- sigmask_t omask = sigsetmask(sigblock(0) & ~sigmask(SIGINT));
-#else /* !BSDSIGS */
- (void) sigrelse(SIGINT);
-#endif /* BSDSIGS */
- np = wbuf;
- while (force_read(OLDSTD, cbuf + cbp++, 1) == 1) {
+ for (;;) {
int len;
+ ssize_t res;
+ Char wc;
- len = normal_mbtowc(np, cbuf, cbp);
+ pintr_push_enable(&old_pintr_disabled);
+ res = force_read(OLDSTD, cbuf + cbp, 1);
+ cleanup_until(&old_pintr_disabled);
+ if (res != 1)
+ break;
+ cbp++;
+ len = normal_mbtowc(&wc, cbuf, cbp);
if (len == -1) {
reset_mbtowc();
if (cbp < MB_LEN_MAX)
continue; /* Maybe a partial character */
- *np = (unsigned char)*cbuf | INVALID_BYTE;
+ wc = (unsigned char)*cbuf | INVALID_BYTE;
}
if (len <= 0)
len = 1;
if (cbp != (size_t)len)
memmove(cbuf, cbuf + len, cbp - len);
cbp -= len;
- if (np >= &wbuf[BUFSIZE - 1])
- stderror(ERR_LTOOLONG);
- if (*np == '\n')
+ if (wc == '\n')
break;
- np++;
+ Strbuf_append1(&wbuf, wc);
}
while (cbp != 0) {
- *np = (unsigned char)*cbuf;
- if (np >= &wbuf[BUFSIZE - 1])
- stderror(ERR_LTOOLONG);
- if (*np == '\n')
+ int len;
+ Char wc;
+
+ len = normal_mbtowc(&wc, cbuf, cbp);
+ if (len == -1) {
+ reset_mbtowc();
+ wc = (unsigned char)*cbuf | INVALID_BYTE;
+ }
+ if (len <= 0)
+ len = 1;
+ if (cbp != (size_t)len)
+ memmove(cbuf, cbuf + len, cbp - len);
+ cbp -= len;
+ if (wc == '\n')
break;
- np++;
- cbp--;
- memmove(cbuf, cbuf + 1, cbp);
+ Strbuf_append1(&wbuf, wc);
}
- *np = 0;
-#ifdef BSDSIGS
- (void) sigsetmask(omask);
-#else /* !BSDSIGS */
- (void) sighold(SIGINT);
-#endif /* BSDSIGS */
+ Strbuf_terminate(&wbuf);
}
-#ifdef COMPAT
- /*
- * KLUDGE: dolmod is set here because it will cause setDolp to call
- * domod and thus to copy wbuf. Otherwise setDolp would use it
- * directly. If we saved it ourselves, no one would know when to free
- * it. The actual function of the 'q' causes filename expansion not to
- * be done on the interpolated value.
- */
- /*
- * If we do that, then other modifiers don't work.
- * in addition, let the user specify :q if wanted
- * [christos]
- */
-/*old*/ dolmod = 'q';
-/*new*/ dolmod[dolnmod++] = 'q';
- dolmcnt = 10000;
-#endif /* COMPAT */
-
fixDolMod();
- setDolp(wbuf);
+ setDolp(wbuf.s); /* Kept allocated until next $< expansion */
+ cleanup_until(&name);
goto eatbrac;
+ }
case '*':
- (void) Strcpy(name, STRargv);
+ Strbuf_append(&name, STRargv);
+ Strbuf_terminate(&name);
vp = adrof(STRargv);
subscr = -1; /* Prevent eating [...] */
break;
@@ -563,7 +487,8 @@ Dgetdol()
np = dimen ? STRargv : (bitset ? STRstatus : NULL);
if (np) {
bitset = 0;
- (void) Strcpy(name, np);
+ Strbuf_append(&name, np);
+ Strbuf_terminate(&name);
vp = adrof(np);
subscr = -1; /* Prevent eating [...] */
unDredc(c);
@@ -574,7 +499,6 @@ Dgetdol()
/*NOTREACHED*/
default:
- np = name;
if (Isdigit(c)) {
if (dimen)
stderror(ERR_NOTALLOWED, "$#<num>");
@@ -582,28 +506,27 @@ Dgetdol()
do {
subscr = subscr * 10 + c - '0';
c = DgetC(0);
- } while (Isdigit(c));
+ } while (c != DEOF && Isdigit(c));
unDredc(c);
if (subscr < 0)
stderror(ERR_RANGE);
if (subscr == 0) {
if (bitset) {
dolp = dolzero ? STR1 : STR0;
+ cleanup_until(&name);
goto eatbrac;
}
if (ffile == 0)
stderror(ERR_DOLZERO);
if (length) {
- Char *cp;
- length = NLSChars(ffile);
- cp = putn(length);
- addla(cp);
- xfree((ptr_t) cp);
+ length = Strlen(ffile);
+ addla(putn(length));
}
else {
fixDolMod();
setDolp(ffile);
}
+ cleanup_until(&name);
goto eatbrac;
}
#if 0
@@ -615,15 +538,17 @@ Dgetdol()
vp = adrof(STRargv);
if (vp == 0) {
vp = &nulargv;
+ cleanup_until(&name);
goto eatmod;
}
break;
}
- if (!alnum(c)) {
+ if (c == DEOF || !alnum(c)) {
np = dimen ? STRargv : (bitset ? STRstatus : NULL);
if (np) {
bitset = 0;
- (void) Strcpy(name, np);
+ Strbuf_append(&name, np);
+ Strbuf_terminate(&name);
vp = adrof(np);
subscr = -1; /* Prevent eating [...] */
unDredc(c);
@@ -633,46 +558,52 @@ Dgetdol()
stderror(ERR_VARALNUM);
}
for (;;) {
- *np++ = (Char) c;
+ Strbuf_append1(&name, (Char) c);
c = DgetC(0);
- if (!alnum(c))
+ if (c == DEOF || !alnum(c))
break;
- if (np >= &name[MAXVARLEN])
- stderror(ERR_VARTOOLONG);
}
- *np++ = 0;
+ Strbuf_terminate(&name);
unDredc(c);
- vp = adrof(name);
+ vp = adrof(name.s);
}
if (bitset) {
- dolp = (vp || getenv(short2str(name))) ? STR1 : STR0;
+ dolp = (vp || getenv(short2str(name.s))) ? STR1 : STR0;
+ cleanup_until(&name);
goto eatbrac;
}
if (vp == NULL || vp->vec == NULL) {
- np = str2short(getenv(short2str(name)));
+ np = str2short(getenv(short2str(name.s)));
if (np) {
+ static Char *env_val; /* = NULL; */
+
+ cleanup_until(&name);
fixDolMod();
- setDolp(np);
+ xfree(env_val);
+ env_val = Strsave(np);
+ setDolp(env_val);
goto eatbrac;
}
- udvar(name);
+ udvar(name.s);
/* NOTREACHED */
}
+ cleanup_until(&name);
c = DgetC(0);
upb = blklen(vp->vec);
if (dimen == 0 && subscr == 0 && c == '[') {
- np = name;
+ name = Strbuf_init;
+ cleanup_push(&name, Strbuf_cleanup);
+ np = name.s;
for (;;) {
c = DgetC(DODOL); /* Allow $ expand within [ ] */
if (c == ']')
break;
if (c == '\n' || c == DEOF)
stderror(ERR_INCBR);
- if (np >= &name[sizeof(name) / sizeof(Char) - 2])
- stderror(ERR_VARTOOLONG);
- *np++ = (Char) c;
+ Strbuf_append1(&name, (Char) c);
}
- *np = 0, np = name;
+ Strbuf_terminate(&name);
+ np = name.s;
if (dolp || dolcnt) /* $ exp must end before ] */
stderror(ERR_EXPORD);
if (!*np)
@@ -683,6 +614,7 @@ Dgetdol()
for (i = 0; Isdigit(*np); i = i * 10 + *np++ - '0')
continue;
if ((i < 0 || i > upb) && !any("-*", *np)) {
+ cleanup_until(&name);
dolerror(vp->v_name);
return;
}
@@ -703,6 +635,7 @@ Dgetdol()
while (Isdigit(*np))
i = i * 10 + *np++ - '0';
if (i < 0 || i > upb) {
+ cleanup_until(&name);
dolerror(vp->v_name);
return;
}
@@ -714,6 +647,7 @@ Dgetdol()
}
if (lwb == 0) {
if (upb != 0) {
+ cleanup_until(&name);
dolerror(vp->v_name);
return;
}
@@ -721,6 +655,7 @@ Dgetdol()
}
if (*np)
stderror(ERR_SYNTAX);
+ cleanup_until(&name);
}
else {
if (subscr > 0) {
@@ -732,35 +667,26 @@ Dgetdol()
unDredc(c);
}
if (dimen) {
- Char *cp = putn(upb - lwb + 1);
-
/* this is a kludge. It prevents Dgetdol() from */
/* pushing erroneous ${#<error> values into the labuf. */
if (sc == '{') {
c = Dredc();
if (c != '}')
- {
- xfree((ptr_t) cp);
stderror(ERR_MISSING, '}');
- return;
- }
unDredc(c);
}
- addla(cp);
- xfree((ptr_t) cp);
+ addla(putn(upb - lwb + 1));
}
else if (length) {
int i;
- Char *cp;
+
for (i = lwb - 1, length = 0; i < upb; i++)
- length += NLSChars(vp->vec[i]);
+ length += Strlen(vp->vec[i]);
#ifdef notdef
/* We don't want that, since we can always compute it by adding $#xxx */
length += i - 1; /* Add the number of spaces in */
#endif
- cp = putn(length);
- addla(cp);
- xfree((ptr_t) cp);
+ addla(putn(length));
}
else {
eatmod:
@@ -777,45 +703,43 @@ eatbrac:
}
static void
-fixDolMod()
+fixDolMod(void)
{
eChar c;
c = DgetC(0);
if (c == ':') {
-#ifndef COMPAT
do {
-#endif /* COMPAT */
- c = DgetC(0), dolmcnt = 1, dolwcnt = 1;
+ c = DgetC(0), dolmcnt = 1, dol_flag_a = 0;
if (c == 'g' || c == 'a') {
if (c == 'g')
- dolmcnt = 10000;
+ dolmcnt = INT_MAX;
else
- dolwcnt = 10000;
+ dol_flag_a = 1;
c = DgetC(0);
}
- if ((c == 'g' && dolmcnt != 10000) ||
- (c == 'a' && dolwcnt != 10000)) {
+ if ((c == 'g' && dolmcnt != INT_MAX) ||
+ (c == 'a' && dol_flag_a == 0)) {
if (c == 'g')
- dolmcnt = 10000;
+ dolmcnt = INT_MAX;
else
- dolwcnt = 10000;
- c = DgetC(0);
+ dol_flag_a = 1;
+ c = DgetC(0);
}
if (c == 's') { /* [eichin:19910926.0755EST] */
int delimcnt = 2;
eChar delim = DgetC(0);
- dolmod[dolnmod++] = (Char) c;
- dolmod[dolnmod++] = (Char) delim;
-
- if (!delim || letter(delim)
+ Strbuf_append1(&dolmod, (Char) c);
+ Strbuf_append1(&dolmod, (Char) delim);
+
+ if (delim == DEOF || !delim || letter(delim)
|| Isdigit(delim) || any(" \t\n", delim)) {
seterror(ERR_BADSUBST);
break;
}
while ((c = DgetC(0)) != DEOF) {
- dolmod[dolnmod++] = (Char) c;
+ Strbuf_append1(&dolmod, (Char) c);
if(c == delim) delimcnt--;
if(!delimcnt) break;
}
@@ -827,148 +751,110 @@ fixDolMod()
}
if (!any("luhtrqxes", c))
stderror(ERR_BADMOD, (int)c);
-#ifndef COMPAT
- dolmod[dolnmod++] = (Char) c;
-#else
- dolmod = (Char) c;
-#endif /* COMPAT */
+ Strbuf_append1(&dolmod, (Char) c);
if (c == 'q')
- dolmcnt = 10000;
-#ifndef COMPAT
+ dolmcnt = INT_MAX;
}
while ((c = DgetC(0)) == ':');
unDredc(c);
-#endif /* COMPAT */
}
else
unDredc(c);
}
static void
-setDolp(cp)
- Char *cp;
+setDolp(Char *cp)
{
Char *dp;
-#ifndef COMPAT
- int i;
-#endif /* COMPAT */
-
-#ifdef COMPAT
- if (dolmod == 0 || dolmcnt == 0) {
-#else
- if (dolnmod == 0 || dolmcnt == 0) {
-#endif /* COMPAT */
- for (dp = cp; *dp; dp++) {
- if (NLSSize(dp, -1) != 1) {
- addla(cp);
- return;
- }
- }
+ size_t i;
+
+ if (dolmod.len == 0 || dolmcnt == 0) {
dolp = cp;
return;
}
-#ifdef COMPAT
- dp = domod(cp, dolmod);
-#else
- dp = cp = Strsave(cp);
- for (i = 0; i < dolnmod; i++) {
+ cp = Strsave(cp);
+ for (i = 0; i < dolmod.len; i++) {
+ int didmod = 0;
+
/* handle s// [eichin:19910926.0510EST] */
- if(dolmod[i] == 's') {
+ if(dolmod.s[i] == 's') {
Char delim;
Char *lhsub, *rhsub, *np;
size_t lhlen = 0, rhlen = 0;
- int didmod = 0;
-
- delim = dolmod[++i];
+
+ delim = dolmod.s[++i];
if (!delim || letter(delim)
|| Isdigit(delim) || any(" \t\n", delim)) {
seterror(ERR_BADSUBST);
break;
}
- lhsub = &dolmod[++i];
- while(dolmod[i] != delim && dolmod[++i]) {
+ lhsub = &dolmod.s[++i];
+ while(dolmod.s[i] != delim && dolmod.s[++i]) {
lhlen++;
}
- dolmod[i] = 0;
- rhsub = &dolmod[++i];
- while(dolmod[i] != delim && dolmod[++i]) {
+ dolmod.s[i] = 0;
+ rhsub = &dolmod.s[++i];
+ while(dolmod.s[i] != delim && dolmod.s[++i]) {
rhlen++;
}
- dolmod[i] = 0;
+ dolmod.s[i] = 0;
+ strip(lhsub);
+ strip(cp);
+ dp = cp;
do {
- strip(lhsub);
- strip(cp);
- dp = Strstr(cp, lhsub);
+ dp = Strstr(dp, lhsub);
if (dp) {
- np = (Char *) xmalloc((size_t)
- ((Strlen(cp) + 1 - lhlen + rhlen) *
- sizeof(Char)));
- (void) Strncpy(np, cp, (size_t) (dp - cp));
- (void) Strcpy(np + (dp - cp), rhsub);
- (void) Strcpy(np + (dp - cp) + rhlen, dp + lhlen);
-
- xfree((ptr_t) cp);
- dp = cp = np;
+ ptrdiff_t diff = dp - cp;
+ np = xmalloc((Strlen(cp) + 1 - lhlen + rhlen) *
+ sizeof(Char));
+ (void) Strncpy(np, cp, diff);
+ (void) Strcpy(np + diff, rhsub);
+ (void) Strcpy(np + diff + rhlen, dp + lhlen);
+
+ dp = np + diff + 1;
+ xfree(cp);
+ cp = np;
didmod = 1;
} else {
/* should this do a seterror? */
break;
}
}
- while (dolwcnt == 10000);
+ while (dol_flag_a != 0);
/*
* restore dolmod for additional words
*/
- dolmod[i] = rhsub[-1] = (Char) delim;
- if (didmod)
- dolmcnt--;
-#ifdef notdef
- else
- break;
-#endif
+ dolmod.s[i] = rhsub[-1] = (Char) delim;
} else {
- int didmod = 0;
do {
- if ((dp = domod(cp, dolmod[i])) != NULL) {
+ if ((dp = domod(cp, dolmod.s[i])) != NULL) {
didmod = 1;
if (Strcmp(cp, dp) == 0) {
- xfree((ptr_t) cp);
+ xfree(cp);
cp = dp;
break;
}
else {
- xfree((ptr_t) cp);
+ xfree(cp);
cp = dp;
}
}
else
break;
}
- while (dolwcnt == 10000);
- dp = cp;
- if (didmod)
- dolmcnt--;
+ while (dol_flag_a != 0);
+ }
+ if (didmod && dolmcnt != INT_MAX)
+ dolmcnt--;
#ifdef notdef
- else
- break;
+ else
+ break;
#endif
- }
}
-#endif /* COMPAT */
-
- if (dp) {
-#ifdef COMPAT
- dolmcnt--;
-#endif /* COMPAT */
- addla(dp);
- xfree((ptr_t) dp);
- }
-#ifndef COMPAT
- else
- addla(cp);
-#endif /* COMPAT */
+
+ addla(cp);
dolp = STRNULL;
if (seterr)
@@ -976,15 +862,14 @@ setDolp(cp)
}
static void
-unDredc(c)
- eChar c;
+unDredc(eChar c)
{
Dpeekrd = c;
}
static eChar
-Dredc()
+Dredc(void)
{
Char c;
@@ -1002,28 +887,36 @@ Dredc()
return (' ');
}
+static int gflag;
+
static void
-Dtestq(c)
- Char c;
+Dtestq(Char c)
{
if (cmap(c, QUOTES))
gflag = 1;
}
+static void
+inheredoc_cleanup(void *dummy)
+{
+ USE(dummy);
+ inheredoc = 0;
+}
+
/*
* Form a shell temporary file (in unit 0) from the words
* of the shell input up to EOF or a line the same as "term".
* Unit 0 should have been closed before this call.
*/
void
-heredoc(term)
- Char *term;
+heredoc(Char *term)
{
eChar c;
Char *Dv[2];
- Char obuf[BUFSIZE + 1], lbuf[BUFSIZE], mbuf[BUFSIZE];
- int ocnt, lcnt, mcnt;
+ struct Strbuf lbuf = Strbuf_INIT, mbuf = Strbuf_INIT;
+ Char obuf[BUFSIZE + 1];
+#define OBUF_END (obuf + sizeof(obuf) / sizeof (*obuf) - 1)
Char *lbp, *obp, *mbp;
Char **vp;
int quoted;
@@ -1036,24 +929,28 @@ again:
tmp = short2str(shtemp);
#ifndef O_CREAT
# define O_CREAT 0
- if (creat(tmp, 0600) < 0)
+ if (xcreat(tmp, 0600) < 0)
stderror(ERR_SYSTEM, tmp, strerror(errno));
#endif
- (void) close(0);
+ xclose(0);
#ifndef O_TEMPORARY
# define O_TEMPORARY 0
#endif
#ifndef O_EXCL
# define O_EXCL 0
#endif
- if (open(tmp, O_RDWR|O_CREAT|O_EXCL|O_TEMPORARY|O_LARGEFILE, 0600) == -1) {
+ if (xopen(tmp, O_RDWR|O_CREAT|O_EXCL|O_TEMPORARY|O_LARGEFILE, 0600) ==
+ -1) {
int oerrno = errno;
#ifndef WINNT_NATIVE
if (errno == EEXIST) {
if (unlink(tmp) == -1) {
(void) gettimeofday(&tv, NULL);
- shtemp = Strspl(STRtmpsh, putn((((int)tv.tv_sec) ^
- ((int)tv.tv_usec) ^ ((int)getpid())) & 0x00ffffff));
+ xfree(shtemp);
+ mbp = putn((((int)tv.tv_sec) ^
+ ((int)tv.tv_usec) ^ ((int)getpid())) & 0x00ffffff);
+ shtemp = Strspl(STRtmpsh, mbp);
+ xfree(mbp);
}
goto again;
}
@@ -1069,10 +966,10 @@ again:
trim(Dv);
rscan(Dv, Dtestq);
quoted = gflag;
- ocnt = BUFSIZE;
obp = obuf;
obuf[BUFSIZE] = 0;
inheredoc = 1;
+ cleanup_push(&inheredoc, inheredoc_cleanup);
#ifdef WINNT_NATIVE
__dup_stdin = 1;
#endif /* WINNT_NATIVE */
@@ -1082,51 +979,42 @@ again:
#ifdef O_BINARY
setmode(0, O_BINARY);
#endif
+ cleanup_push(&lbuf, Strbuf_cleanup);
+ cleanup_push(&mbuf, Strbuf_cleanup);
for (;;) {
+ Char **words;
+
/*
* Read up a line
*/
- lbp = lbuf;
- lcnt = BUFSIZE - 4;
+ lbuf.len = 0;
for (;;) {
c = readc(1); /* 1 -> Want EOF returns */
if (c == CHAR_ERR || c == '\n')
break;
- if ((c &= TRIM) != 0) {
- *lbp++ = (Char) c;
- if (--lcnt < 0) {
- setname("<<");
- stderror(ERR_NAME | ERR_OVERFLOW);
- }
- }
+ if ((c &= TRIM) != 0)
+ Strbuf_append1(&lbuf, (Char) c);
}
- *lbp = 0;
+ Strbuf_terminate(&lbuf);
/*
* Check for EOF or compare to terminator -- before expansion
*/
- if (c == CHAR_ERR || eq(lbuf, term)) {
- *obp = 0;
- tmp = short2str(obuf);
- (void) write(0, tmp, strlen (tmp));
- (void) lseek(0, (off_t) 0, L_SET);
- inheredoc = 0;
- return;
- }
+ if (c == CHAR_ERR || eq(lbuf.s, term))
+ break;
/*
* If term was quoted or -n just pass it on
*/
if (quoted || noexec) {
- *lbp++ = '\n';
- *lbp = 0;
- for (lbp = lbuf; (c = *lbp++) != 0;) {
+ Strbuf_append1(&lbuf, '\n');
+ Strbuf_terminate(&lbuf);
+ for (lbp = lbuf.s; (c = *lbp++) != 0;) {
*obp++ = (Char) c;
- if (--ocnt == 0) {
+ if (obp == OBUF_END) {
tmp = short2str(obuf);
- (void) write(0, tmp, strlen (tmp));
+ (void) xwrite(0, tmp, strlen (tmp));
obp = obuf;
- ocnt = BUFSIZE;
}
}
continue;
@@ -1136,10 +1024,9 @@ again:
* Term wasn't quoted so variable and then command expand the input
* line
*/
- Dcp = lbuf;
+ Dcp = lbuf.s;
Dvp = Dv + 1;
- mbp = mbuf;
- mcnt = BUFSIZE - 4;
+ mbuf.len = 0;
for (;;) {
c = DgetC(DODOL);
if (c == DEOF)
@@ -1154,29 +1041,25 @@ again:
else
c |= QUOTE;
}
- *mbp++ = (Char) c;
- if (--mcnt == 0) {
- setname("<<");
- stderror(ERR_NAME | ERR_OVERFLOW);
- }
+ Strbuf_append1(&mbuf, (Char) c);
}
- *mbp++ = 0;
+ Strbuf_terminate(&mbuf);
/*
* If any ` in line do command substitution
*/
- mbp = mbuf;
+ mbp = mbuf.s;
if (Strchr(mbp, '`') != NULL) {
/*
* 1 arg to dobackp causes substitution to be literal. Words are
* broken only at newlines so that all blanks and tabs are
* preserved. Blank lines (null words) are not discarded.
*/
- vp = dobackp(mbuf, 1);
+ words = dobackp(mbp, 1);
}
else
/* Setup trivial vector similar to return of dobackp */
- Dv[0] = mbp, Dv[1] = NULL, vp = Dv;
+ Dv[0] = mbp, Dv[1] = NULL, words = Dv;
/*
* Resurrect the words from the command substitution each separated by
@@ -1184,25 +1067,28 @@ again:
* will have been discarded, but we put a newline after the last word
* because this represents the newline after the last input line!
*/
- for (; *vp; vp++) {
+ for (vp= words; *vp; vp++) {
for (mbp = *vp; *mbp; mbp++) {
*obp++ = *mbp & TRIM;
- if (--ocnt == 0) {
+ if (obp == OBUF_END) {
tmp = short2str(obuf);
- (void) write(0, tmp, strlen (tmp));
+ (void) xwrite(0, tmp, strlen (tmp));
obp = obuf;
- ocnt = BUFSIZE;
}
}
*obp++ = '\n';
- if (--ocnt == 0) {
+ if (obp == OBUF_END) {
tmp = short2str(obuf);
- (void) write(0, tmp, strlen (tmp));
+ (void) xwrite(0, tmp, strlen (tmp));
obp = obuf;
- ocnt = BUFSIZE;
}
}
- if (pargv)
- blkfree(pargv), pargv = 0;
+ if (words != Dv)
+ blkfree(words);
}
+ *obp = 0;
+ tmp = short2str(obuf);
+ (void) xwrite(0, tmp, strlen (tmp));
+ (void) lseek(0, (off_t) 0, L_SET);
+ cleanup_until(&inheredoc);
}
diff --git a/contrib/tcsh/sh.err.c b/contrib/tcsh/sh.err.c
index d111f30..4da927c 100644
--- a/contrib/tcsh/sh.err.c
+++ b/contrib/tcsh/sh.err.c
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/sh.err.c,v 3.39 2005/01/18 20:43:30 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/sh.err.c,v 3.48 2006/03/02 18:46:44 christos Exp $ */
/*
* sh.err.c: Error printing routines.
*/
@@ -32,8 +32,9 @@
*/
#define _h_sh_err /* Don't redefine the errors */
#include "sh.h"
+#include <assert.h>
-RCSID("$Id: sh.err.c,v 3.39 2005/01/18 20:43:30 christos Exp $")
+RCSID("$tcsh: sh.err.c,v 3.48 2006/03/02 18:46:44 christos Exp $")
/*
* C Shell
@@ -194,13 +195,13 @@ static const char *elst[NO_ERRORS] INIT_ZERO_STRUCT;
* Init the elst depending on the locale
*/
void
-errinit()
+errinit(void)
{
#ifdef NLS_CATALOGS
- int i;
+ size_t i;
for (i = 0; i < NO_ERRORS; i++)
- xfree((ptr_t) elst[i]);
+ xfree((char *)(intptr_t)elst[i]);
# if defined(__FreeBSD__) || defined(hpux)
# define NLS_MAXSET 30
for (i = 1; i <= NLS_MAXSET; i++)
@@ -364,6 +365,170 @@ errinit()
elst[ERR_BADJOB] = CSAVS(1, 136, "No such job (badjob)");
elst[ERR_BADCOLORVAR] = CSAVS(1, 137, "Unknown colorls variable `%c%c'");
}
+
+/* Cleanup data. */
+struct cleanup_entry
+{
+ void *var;
+ void (*fn) (void *);
+#ifdef CLEANUP_DEBUG
+ const char *file;
+ size_t line;
+#endif
+};
+
+static struct cleanup_entry *cleanup_stack; /* = NULL; */
+static size_t cleanup_sp; /* = 0; Next free entry */
+static size_t cleanup_mark; /* = 0; Last entry to handle before unwinding */
+static size_t cleanup_stack_size; /* = 0 */
+
+/* fn() will be run with all signals blocked, so it should not do anything
+ risky. */
+void
+cleanup_push_internal(void *var, void (*fn) (void *)
+#ifdef CLEANUP_DEBUG
+ , const char *file, size_t line
+#endif
+)
+{
+ struct cleanup_entry *ce;
+
+ if (cleanup_sp == cleanup_stack_size) {
+ if (cleanup_stack_size == 0)
+ cleanup_stack_size = 64; /* Arbitrary */
+ else
+ cleanup_stack_size *= 2;
+ cleanup_stack = xrealloc(cleanup_stack,
+ cleanup_stack_size * sizeof (*cleanup_stack));
+ }
+ ce = cleanup_stack + cleanup_sp;
+ ce->var = var;
+ ce->fn = fn;
+#ifdef CLEANUP_DEBUG
+ ce->file = file;
+ ce->line = line;
+#endif
+ cleanup_sp++;
+}
+
+static void
+cleanup_ignore_fn(void *dummy)
+{
+ USE(dummy);
+}
+
+void
+cleanup_ignore(void *var)
+{
+ struct cleanup_entry *ce;
+
+ ce = cleanup_stack + cleanup_sp;
+ while (ce != cleanup_stack) {
+ ce--;
+ if (ce->var == var) {
+ ce->fn = cleanup_ignore_fn;
+ return;
+ }
+ }
+ abort();
+}
+
+void
+cleanup_until(void *last_var)
+{
+ while (cleanup_sp != 0) {
+ struct cleanup_entry ce;
+
+ cleanup_sp--;
+ ce = cleanup_stack[cleanup_sp];
+ ce.fn(ce.var);
+ if (ce.var == last_var)
+ return;
+ }
+ abort();
+}
+
+void
+cleanup_until_mark(void)
+{
+ while (cleanup_sp > cleanup_mark) {
+ struct cleanup_entry ce;
+
+ cleanup_sp--;
+ ce = cleanup_stack[cleanup_sp];
+ ce.fn(ce.var);
+ }
+}
+
+size_t
+cleanup_push_mark(void)
+{
+ size_t old_mark;
+
+ old_mark = cleanup_mark;
+ cleanup_mark = cleanup_sp;
+ return old_mark;
+}
+
+void
+cleanup_pop_mark(size_t mark)
+{
+ assert (mark <= cleanup_sp);
+ cleanup_mark = mark;
+}
+
+void
+sigint_cleanup(void *xsa)
+{
+ const struct sigaction *sa;
+
+ sa = xsa;
+ sigaction(SIGINT, sa, NULL);
+}
+
+void
+sigprocmask_cleanup(void *xmask)
+{
+ sigset_t *mask;
+
+ mask = xmask;
+ sigprocmask(SIG_SETMASK, mask, NULL);
+}
+
+void
+open_cleanup(void *xptr)
+{
+ int *ptr;
+
+ ptr = xptr;
+ xclose(*ptr);
+}
+
+void
+opendir_cleanup(void *xdir)
+{
+ DIR *dir;
+
+ dir = xdir;
+ xclosedir(dir);
+}
+
+void
+xfree_indirect(void *xptr)
+{
+ void **ptr; /* This is actually type punning :( */
+
+ ptr = xptr;
+ xfree(*ptr);
+}
+
+void
+reset(void)
+{
+ cleanup_until_mark();
+ _reset();
+}
+
/*
* The parser and scanner set up errors for later by calling seterr,
* which sets the variable err as a side effect; later to be tested,
@@ -371,31 +536,16 @@ errinit()
*/
void
/*VARARGS1*/
-#ifdef PROTOTYPES
seterror(unsigned int id, ...)
-#else
-seterror(va_alist)
- va_dcl
-#endif
{
-
if (seterr == 0) {
va_list va;
- char berr[BUFSIZE];
-#ifdef PROTOTYPES
- va_start(va, id);
-#else
- unsigned int id;
- va_start(va);
- id = va_arg(va, unsigned int);
-#endif
+ va_start(va, id);
if (id >= sizeof(elst) / sizeof(elst[0]))
id = ERR_INVALID;
- xvsnprintf(berr, sizeof(berr), elst[id], va);
+ seterr = xvasprintf(elst[id], va);
va_end(va);
-
- seterr = strsave(berr);
}
}
@@ -419,26 +569,13 @@ seterror(va_alist)
*/
void
/*VARARGS*/
-#ifdef PROTOTYPES
stderror(unsigned int id, ...)
-#else
-stderror(va_alist)
- va_dcl
-#endif
{
va_list va;
- Char **v;
int flags;
int vareturn;
-#ifdef PROTOTYPES
va_start(va, id);
-#else
- unsigned int id;
-
- va_start(va);
- id = va_arg(va, unsigned int);
-#endif
/*
* Reset don't free flag for buggy os's
@@ -462,21 +599,19 @@ stderror(va_alist)
* form of) diagnostic output. If didfds then output will go to 1/2
* else to FSHOUT/FSHDIAG. See flush in sh.print.c.
*/
- flush();
+ flush();/*FIXRESET*/
haderr = 1; /* Now to diagnostic output */
- timflg = 0; /* This isn't otherwise reset */
-
if (!(flags & ERR_SILENT)) {
if (flags & ERR_NAME)
- xprintf("%s: ", bname);
+ xprintf("%s: ", bname);/*FIXRESET*/
if ((flags & ERR_OLD)) {
/* Old error. */
- xprintf("%s.\n", seterr);
- } else {
- xvprintf(elst[id], va);
- xprintf(".\n");
- }
+ xprintf("%s.\n", seterr);/*FIXRESET*/
+ } else {
+ xvprintf(elst[id], va);/*FIXRESET*/
+ xprintf(".\n");/*FIXRESET*/
+ }
}
} else {
vareturn = 1; /* Return immediately after va_end */
@@ -486,16 +621,10 @@ stderror(va_alist)
return;
if (seterr) {
- xfree((ptr_t) seterr);
+ xfree(seterr);
seterr = NULL;
}
- if ((v = pargv) != 0)
- pargv = 0, blkfree(v);
- if ((v = gargv) != 0)
- gargv = 0, blkfree(v);
-
- inheredoc = 0; /* Not anymore in a heredoc */
didfds = 0; /* Forget about 0,1,2 */
/*
* Go away if -e or we are a child shell
@@ -509,7 +638,7 @@ stderror(va_alist)
*/
btoeof();
- set(STRstatus, Strsave(STR1), VAR_READWRITE);
+ setcopy(STRstatus, STR1, VAR_READWRITE);/*FIXRESET*/
#ifdef BSDJOBS
if (tpgrp > 0)
(void) tcsetpgrp(FSHTTY, tpgrp);
diff --git a/contrib/tcsh/sh.exec.c b/contrib/tcsh/sh.exec.c
index 913c95c..d5a80fe 100644
--- a/contrib/tcsh/sh.exec.c
+++ b/contrib/tcsh/sh.exec.c
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/sh.exec.c,v 3.63 2004/11/23 02:10:48 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/sh.exec.c,v 3.73 2006/08/24 20:56:31 christos Exp $ */
/*
* sh.exec.c: Search, find, and execute a command!
*/
@@ -32,7 +32,7 @@
*/
#include "sh.h"
-RCSID("$Id: sh.exec.c,v 3.63 2004/11/23 02:10:48 christos Exp $")
+RCSID("$tcsh: sh.exec.c,v 3.73 2006/08/24 20:56:31 christos Exp $")
#include "tc.h"
#include "tw.h"
@@ -141,19 +141,17 @@ static int hits, misses;
/* Dummy search path for just absolute search when no path */
static Char *justabs[] = {STRNULL, 0};
-static void pexerr __P((void));
-static void texec __P((Char *, Char **));
-int hashname __P((Char *));
-static int iscommand __P((Char *));
+static void pexerr (void);
+static void texec (Char *, Char **);
+int hashname (Char *);
+static int iscommand (Char *);
void
-doexec(t, do_glob)
- struct command *t;
- int do_glob;
+doexec(struct command *t, int do_glob)
{
Char *dp, **pv, **av, *sav;
struct varent *v;
- int slash;
+ int slash, gflag;
int hashval, i;
Char *blk[2];
@@ -166,17 +164,17 @@ doexec(t, do_glob)
blk[1] = 0;
gflag = 0;
if (do_glob)
- tglob(blk);
+ gflag = tglob(blk);
if (gflag) {
- pv = globall(blk);
+ pv = globall(blk, gflag);
if (pv == 0) {
setname(short2str(blk[0]));
stderror(ERR_NAME | ERR_NOMATCH);
}
- gargv = 0;
}
else
pv = saveblk(blk);
+ cleanup_push(pv, blk_cleanup);
trim(pv);
@@ -187,10 +185,8 @@ doexec(t, do_glob)
#endif /* VFORK */
v = adrof(STRpath);
- if (v == 0 && expath[0] != '/' && expath[0] != '.') {
- blkfree(pv);
+ if (v == 0 && expath[0] != '/' && expath[0] != '.')
pexerr();
- }
slash = any(short2str(expath), '/');
/*
@@ -199,23 +195,23 @@ doexec(t, do_glob)
gflag = 0;
av = &t->t_dcom[1];
if (do_glob)
- tglob(av);
+ gflag = tglob(av);
if (gflag) {
- av = globall(av);
+ av = globall(av, gflag);
if (av == 0) {
- blkfree(pv);
setname(short2str(expath));
stderror(ERR_NAME | ERR_NOMATCH);
}
- gargv = 0;
}
else
av = saveblk(av);
blkfree(t->t_dcom);
+ cleanup_ignore(pv);
+ cleanup_until(pv);
t->t_dcom = blkspl(pv, av);
- xfree((ptr_t) pv);
- xfree((ptr_t) av);
+ xfree(pv);
+ xfree(av);
av = t->t_dcom;
trim(av);
@@ -242,12 +238,15 @@ doexec(t, do_glob)
* We must do this AFTER any possible forking (like `foo` in glob) so that
* this shell can still do subprocesses.
*/
-#ifdef BSDSIGS
- (void) sigsetmask((sigmask_t) 0);
-#else /* BSDSIGS */
- (void) sigrelse(SIGINT);
- (void) sigrelse(SIGCHLD);
-#endif /* BSDSIGS */
+ {
+ sigset_t set;
+ sigemptyset(&set);
+ sigaddset(&set, SIGINT);
+ sigaddset(&set, SIGCHLD);
+ sigprocmask(SIG_UNBLOCK, &set, NULL);
+ }
+ pintr_disabled = 0;
+ pchild_disabled = 0;
/*
* If no path, no words in path, or a / in the filename then restrict the
@@ -258,7 +257,9 @@ doexec(t, do_glob)
else
pv = v->vec;
sav = Strspl(STRslash, *av);/* / command name for postpending */
-#ifdef VFORK
+#ifndef VFORK
+ cleanup_push(sav, xfree);
+#else /* VFORK */
Vsav = sav;
#endif /* VFORK */
hashval = havhash ? hashname(*av) : 0;
@@ -285,63 +286,22 @@ doexec(t, do_glob)
#endif /* FASTHASH */
}
if (pv[0][0] == 0 || eq(pv[0], STRdot)) /* don't make ./xxx */
- {
-
-#ifdef COHERENT
- if (t->t_dflg & F_AMPERSAND) {
-# ifdef JOBDEBUG
- xprintf("set SIGINT to SIG_IGN\n");
- xprintf("set SIGQUIT to SIG_DFL\n");
-# endif /* JOBDEBUG */
- (void) signal(SIGINT,SIG_IGN); /* may not be necessary */
- (void) signal(SIGQUIT,SIG_DFL);
- }
-
- if (gointr && eq(gointr, STRminus)) {
-# ifdef JOBDEBUG
- xprintf("set SIGINT to SIG_IGN\n");
- xprintf("set SIGQUIT to SIG_IGN\n");
-# endif /* JOBDEBUG */
- (void) signal(SIGINT,SIG_IGN); /* may not be necessary */
- (void) signal(SIGQUIT,SIG_IGN);
- }
-#endif /* COHERENT */
-
texec(*av, av);
-}
else {
dp = Strspl(*pv, sav);
-#ifdef VFORK
+#ifndef VFORK
+ cleanup_push(dp, xfree);
+#else /* VFORK */
Vdp = dp;
#endif /* VFORK */
-#ifdef COHERENT
- if ((t->t_dflg & F_AMPERSAND)) {
-# ifdef JOBDEBUG
- xprintf("set SIGINT to SIG_IGN\n");
-# endif /* JOBDEBUG */
- /*
- * this is necessary on Coherent or all background
- * jobs are killed by CTRL-C
- * (there must be a better fix for this)
- */
- (void) signal(SIGINT,SIG_IGN);
- }
- if (gointr && eq(gointr,STRminus)) {
-# ifdef JOBDEBUG
- xprintf("set SIGINT to SIG_IGN\n");
- xprintf("set SIGQUIT to SIG_IGN\n");
-# endif /* JOBDEBUG */
- (void) signal(SIGINT,SIG_IGN); /* may not be necessary */
- (void) signal(SIGQUIT,SIG_IGN);
- }
-#endif /* COHERENT */
-
texec(dp, av);
-#ifdef VFORK
+#ifndef VFORK
+ cleanup_until(dp);
+#else /* VFORK */
Vdp = 0;
+ xfree(dp);
#endif /* VFORK */
- xfree((ptr_t) dp);
}
#ifdef VFORK
misses++;
@@ -352,14 +312,18 @@ cont:
} while (*pv);
#ifdef VFORK
hits--;
+#endif /* VFORK */
+#ifndef VFORK
+ cleanup_until(sav);
+#else /* VFORK */
Vsav = 0;
+ xfree(sav);
#endif /* VFORK */
- xfree((ptr_t) sav);
pexerr();
}
static void
-pexerr()
+pexerr(void)
{
/* Couldn't find the damn thing */
if (expath) {
@@ -367,7 +331,7 @@ pexerr()
#ifdef VFORK
Vexpath = 0;
#endif /* VFORK */
- xfree((ptr_t) expath);
+ xfree(expath);
expath = 0;
}
else
@@ -383,9 +347,7 @@ pexerr()
* Also do shell scripts here.
*/
static void
-texec(sf, st)
- Char *sf;
- Char **st;
+texec(Char *sf, Char **st)
{
char **t;
char *f;
@@ -438,25 +400,32 @@ texec(sf, st)
* From: casper@fwi.uva.nl (Casper H.S. Dik) If we could not execute
* it, don't feed it to the shell if it looks like a binary!
*/
- if ((fd = open(f, O_RDONLY|O_LARGEFILE)) != -1) {
+ if ((fd = xopen(f, O_RDONLY|O_LARGEFILE)) != -1) {
int nread;
#ifdef O_TEXT
setmode(fd, O_TEXT);
#endif
- if ((nread = read(fd, (char *) pref, 2)) == 2) {
+ if ((nread = xread(fd, pref, 2)) == 2) {
if (!isprint((unsigned char)pref[0]) &&
(pref[0] != '\n' && pref[0] != '\t')) {
- (void) close(fd);
+ int err;
+
+ err = errno;
+ xclose(fd);
/*
* We *know* what ENOEXEC means.
*/
- stderror(ERR_ARCH, f, strerror(errno));
+ stderror(ERR_ARCH, f, strerror(err));
}
}
- else if (nread < 0 && errno != EINTR) {
+ else if (nread < 0) {
#ifdef convex
+ int err;
+
+ err = errno;
+ xclose(fd);
/* need to print error incase the file is migrated */
- stderror(ERR_SYSTEM, f, strerror(errno));
+ stderror(ERR_SYSTEM, f, strerror(err));
#endif
}
#ifdef _PATH_BSHELL
@@ -496,7 +465,7 @@ texec(sf, st)
}
#endif /* HASHBANG */
if (fd != -1)
- (void) close(fd);
+ xclose(fd);
st0 = st[0];
st[0] = sf;
@@ -507,7 +476,7 @@ texec(sf, st)
/* The order for the conversions is significant */
t = short2blk(st);
f = short2str(sf);
- xfree((ptr_t) st);
+ xfree(st);
blkfree((Char **) vp);
#ifdef VFORK
Vt = t;
@@ -540,8 +509,7 @@ texec(sf, st)
default:
if (exerr == 0) {
exerr = strerror(errno);
- if (expath)
- xfree((ptr_t) expath);
+ xfree(expath);
expath = Strsave(sf);
#ifdef VFORK
Vexpath = expath;
@@ -551,24 +519,47 @@ texec(sf, st)
}
}
-/*ARGSUSED*/
-void
-execash(t, kp)
- Char **t;
- struct command *kp;
+struct execash_state
{
- int saveIN, saveOUT, saveDIAG, saveSTD;
- int oSHIN;
- int oSHOUT;
- int oSHDIAG;
- int oOLDSTD;
- jmp_buf_t osetexit;
- int my_reenter;
- int odidfds;
+ int saveIN, saveOUT, saveDIAG, saveSTD;
+ int SHIN, SHOUT, SHDIAG, OLDSTD;
+ int didfds;
#ifndef CLOSE_ON_EXEC
- int odidcch;
+ int didcch;
+#endif
+ struct sigaction sigint, sigquit, sigterm;
+};
+
+static void
+execash_cleanup(void *xstate)
+{
+ struct execash_state *state;
+
+ state = xstate;
+ sigaction(SIGINT, &state->sigint, NULL);
+ sigaction(SIGQUIT, &state->sigquit, NULL);
+ sigaction(SIGTERM, &state->sigterm, NULL);
+
+ doneinp = 0;
+#ifndef CLOSE_ON_EXEC
+ didcch = state->didcch;
#endif /* CLOSE_ON_EXEC */
- signalfun_t osigint, osigquit, osigterm;
+ didfds = state->didfds;
+ xclose(SHIN);
+ xclose(SHOUT);
+ xclose(SHDIAG);
+ xclose(OLDSTD);
+ close_on_exec(SHIN = dmove(state->saveIN, state->SHIN), 1);
+ close_on_exec(SHOUT = dmove(state->saveOUT, state->SHOUT), 1);
+ close_on_exec(SHDIAG = dmove(state->saveDIAG, state->SHDIAG), 1);
+ close_on_exec(OLDSTD = dmove(state->saveSTD, state->OLDSTD), 1);
+}
+
+/*ARGSUSED*/
+void
+execash(Char **t, struct command *kp)
+{
+ struct execash_state state;
USE(t);
if (chkstop == 0 && setintr)
@@ -580,79 +571,49 @@ execash(t, kp)
rechist(NULL, adrof(STRsavehist) != NULL);
- osigint = signal(SIGINT, parintr);
- osigquit = signal(SIGQUIT, parintr);
- osigterm = signal(SIGTERM, parterm);
+ sigaction(SIGINT, &parintr, &state.sigint);
+ sigaction(SIGQUIT, &parintr, &state.sigquit);
+ sigaction(SIGTERM, &parterm, &state.sigterm);
- odidfds = didfds;
+ state.didfds = didfds;
#ifndef CLOSE_ON_EXEC
- odidcch = didcch;
+ state.didcch = didcch;
#endif /* CLOSE_ON_EXEC */
- oSHIN = SHIN;
- oSHOUT = SHOUT;
- oSHDIAG = SHDIAG;
- oOLDSTD = OLDSTD;
-
- (void)close_on_exec (saveIN = dcopy(SHIN, -1), 1);
- (void)close_on_exec (saveOUT = dcopy(SHOUT, -1), 1);
- (void)close_on_exec (saveDIAG = dcopy(SHDIAG, -1), 1);
- (void)close_on_exec (saveSTD = dcopy(OLDSTD, -1), 1);
-
+ state.SHIN = SHIN;
+ state.SHOUT = SHOUT;
+ state.SHDIAG = SHDIAG;
+ state.OLDSTD = OLDSTD;
+
+ (void)close_on_exec (state.saveIN = dcopy(SHIN, -1), 1);
+ (void)close_on_exec (state.saveOUT = dcopy(SHOUT, -1), 1);
+ (void)close_on_exec (state.saveDIAG = dcopy(SHDIAG, -1), 1);
+ (void)close_on_exec (state.saveSTD = dcopy(OLDSTD, -1), 1);
+
lshift(kp->t_dcom, 1);
- getexit(osetexit);
-
- /* PWP: setjmp/longjmp bugfix for optimizing compilers */
-#ifdef cray
- my_reenter = 1; /* assume non-zero return val */
- if (setexit() == 0) {
- my_reenter = 0; /* Oh well, we were wrong */
-#else /* !cray */
- if ((my_reenter = setexit()) == 0) {
-#endif /* cray */
- (void)close_on_exec (SHIN = dcopy(0, -1), 1);
- (void)close_on_exec (SHOUT = dcopy(1, -1), 1);
- (void)close_on_exec (SHDIAG = dcopy(2, -1), 1);
+ (void)close_on_exec (SHIN = dcopy(0, -1), 1);
+ (void)close_on_exec (SHOUT = dcopy(1, -1), 1);
+ (void)close_on_exec (SHDIAG = dcopy(2, -1), 1);
#ifndef CLOSE_ON_EXEC
- didcch = 0;
+ didcch = 0;
#endif /* CLOSE_ON_EXEC */
- didfds = 0;
- /*
- * Decrement the shell level
- */
- shlvl(-1);
+ didfds = 0;
+ cleanup_push(&state, execash_cleanup);
+
+ /*
+ * Decrement the shell level
+ */
+ shlvl(-1);
#ifdef WINNT_NATIVE
- __nt_really_exec=1;
+ __nt_really_exec=1;
#endif /* WINNT_NATIVE */
- doexec(kp, 1);
- }
-
- (void) sigset(SIGINT, osigint);
- (void) sigset(SIGQUIT, osigquit);
- (void) sigset(SIGTERM, osigterm);
+ doexec(kp, 1);
- doneinp = 0;
-#ifndef CLOSE_ON_EXEC
- didcch = odidcch;
-#endif /* CLOSE_ON_EXEC */
- didfds = odidfds;
- (void) close(SHIN);
- (void) close(SHOUT);
- (void) close(SHDIAG);
- (void) close(OLDSTD);
- (void)close_on_exec(SHIN = dmove(saveIN, oSHIN), 1);
- (void)close_on_exec(SHOUT = dmove(saveOUT, oSHOUT), 1);
- (void)close_on_exec(SHDIAG = dmove(saveDIAG, oSHDIAG), 1);
- (void)close_on_exec(OLDSTD = dmove(saveSTD, oOLDSTD), 1);
-
- resexit(osetexit);
- if (my_reenter)
- stderror(ERR_SILENT);
+ cleanup_until(&state);
}
void
-xechoit(t)
- Char **t;
+xechoit(Char **t)
{
if (adrof(STRecho)) {
int odidfds = didfds;
@@ -668,9 +629,7 @@ xechoit(t)
/*ARGSUSED*/
void
-dohash(vv, c)
- Char **vv;
- struct command *c;
+dohash(Char **vv, struct command *c)
{
#ifdef COMMENT
struct stat stb;
@@ -723,11 +682,9 @@ dohash(vv, c)
hashlength = uhashlength;
else
hashlength = hashwidth * (8*64);/* "average" files per dir in path */
-
- if (xhash)
- xfree((ptr_t) xhash);
- xhash = (unsigned long *) xcalloc((size_t) (hashlength * hashwidth),
- (size_t) 1);
+
+ xfree(xhash);
+ xhash = xcalloc(hashlength * hashwidth, 1);
#endif /* FASTHASH */
(void) getusername(NULL); /* flush the tilde cashe */
@@ -741,10 +698,11 @@ dohash(vv, c)
dirp = opendir(short2str(*pv));
if (dirp == NULL)
continue;
+ cleanup_push(dirp, opendir_cleanup);
#ifdef COMMENT /* this isn't needed. opendir won't open
* non-dirs */
if (fstat(dirp->dd_fd, &stb) < 0 || !S_ISDIR(stb.st_mode)) {
- (void) closedir(dirp);
+ cleanup_until(dirp);
continue;
}
#endif
@@ -766,16 +724,17 @@ dohash(vv, c)
* the file with the .exe, .com, .bat extension
*/
{
- size_t ext = strlen(dp->d_name) - 4;
+ ssize_t ext = strlen(dp->d_name) - 4;
if ((ext > 0) && (strcasecmp(&dp->d_name[ext], ".exe") == 0 ||
strcasecmp(&dp->d_name[ext], ".bat") == 0 ||
- strcasecmp(&dp->d_name[ext], ".com") == 0))
- {
- dp->d_name[ext] = '\0';
-#if defined(__CYGWIN__)
- strlwr(dp->d_name);
+ strcasecmp(&dp->d_name[ext], ".com") == 0)) {
+#ifdef __CYGWIN__
+ /* Also store the variation with extension. */
+ hashval = hashname(str2short(dp->d_name));
+ bis(hashval, i);
#endif /* __CYGWIN__ */
- }
+ dp->d_name[ext] = '\0';
+ }
}
#endif /* _UWIN || __CYGWIN__ */
# ifdef FASTHASH
@@ -791,32 +750,26 @@ dohash(vv, c)
/* tw_add_comm_name (dp->d_name); */
#endif /* WINNT_NATIVE */
}
- (void) closedir(dirp);
+ cleanup_until(dirp);
}
}
/*ARGSUSED*/
void
-dounhash(v, c)
- Char **v;
- struct command *c;
+dounhash(Char **v, struct command *c)
{
USE(c);
USE(v);
havhash = 0;
#ifdef FASTHASH
- if (xhash) {
- xfree((ptr_t) xhash);
- xhash = NULL;
- }
+ xfree(xhash);
+ xhash = NULL;
#endif /* FASTHASH */
}
/*ARGSUSED*/
void
-hashstat(v, c)
- Char **v;
- struct command *c;
+hashstat(Char **v, struct command *c)
{
USE(c);
USE(v);
@@ -839,8 +792,7 @@ hashstat(v, c)
* Hash a command name.
*/
int
-hashname(cp)
- Char *cp;
+hashname(Char *cp)
{
unsigned long h;
@@ -850,8 +802,7 @@ hashname(cp)
}
static int
-iscommand(name)
- Char *name;
+iscommand(Char *name)
{
Char **pv;
Char *sav;
@@ -880,13 +831,13 @@ iscommand(name)
}
if (pv[0][0] == 0 || eq(pv[0], STRdot)) { /* don't make ./xxx */
if (executable(NULL, name, 0)) {
- xfree((ptr_t) sav);
+ xfree(sav);
return i + 1;
}
}
else {
if (executable(*pv, sav, 0)) {
- xfree((ptr_t) sav);
+ xfree(sav);
return i + 1;
}
}
@@ -894,7 +845,7 @@ cont:
pv++;
i++;
} while (*pv);
- xfree((ptr_t) sav);
+ xfree(sav);
return 0;
}
@@ -916,23 +867,21 @@ cont:
* This is a bit kludgy, but in the name of optimization...
*/
int
-executable(dir, name, dir_ok)
- Char *dir, *name;
- int dir_ok;
+executable(const Char *dir, const Char *name, int dir_ok)
{
struct stat stbuf;
- Char path[MAXPATHLEN + 1];
char *strname;
- (void) memset(path, 0, sizeof(path));
if (dir && *dir) {
- copyn(path, dir, MAXPATHLEN);
- catn(path, name, MAXPATHLEN);
+ Char *path;
+
+ path = Strspl(dir, name);
strname = short2str(path);
+ xfree(path);
}
else
strname = short2str(name);
-
+
return (stat(strname, &stbuf) != -1 &&
((dir_ok && S_ISDIR(stbuf.st_mode)) ||
(S_ISREG(stbuf.st_mode) &&
@@ -943,16 +892,29 @@ executable(dir, name, dir_ok)
}
#endif /*!WINNT_NATIVE*/
+struct tellmewhat_s0_cleanup
+{
+ Char **dest, *val;
+};
+
+static void
+tellmewhat_s0_cleanup(void *xstate)
+{
+ struct tellmewhat_s0_cleanup *state;
+
+ state = xstate;
+ *state->dest = state->val;
+}
+
int
-tellmewhat(lexp, str)
- struct wordent *lexp;
- Char *str;
+tellmewhat(struct wordent *lexp, Char **str)
{
+ struct tellmewhat_s0_cleanup s0;
int i;
- struct biltins *bptr;
+ const struct biltins *bptr;
struct wordent *sp = lexp->next;
int aliased = 0, found;
- Char *s0, *s1, *s2, *cmd;
+ Char *s1, *s2, *cmd;
Char qc;
if (adrof1(sp->word, &aliases)) {
@@ -961,7 +923,9 @@ tellmewhat(lexp, str)
aliased = 1;
}
- s0 = sp->word; /* to get the memory freeing right... */
+ s0.dest = &sp->word; /* to get the memory freeing right... */
+ s0.val = sp->word;
+ cleanup_push(&s0, tellmewhat_s0_cleanup);
/* handle quoted alias hack */
if ((*(sp->word) & (QUOTE | TRIM)) == QUOTE)
@@ -997,9 +961,9 @@ tellmewhat(lexp, str)
sp->word);
flush();
}
- else
- (void) Strcpy(str, sp->word);
- sp->word = s0; /* we save and then restore this */
+ else
+ *str = Strsave(sp->word);
+ cleanup_until(&s0);
return TRUE;
}
}
@@ -1013,15 +977,16 @@ tellmewhat(lexp, str)
sp->word);
flush();
}
- else
- (void) Strcpy(str, sp->word);
- sp->word = s0; /* we save and then restore this */
+ else
+ *str = Strsave(sp->word);
+ cleanup_until(&s0);
return TRUE;
}
}
#endif /* WINNT_NATIVE*/
sp->word = cmd = globone(sp->word, G_IGNORE);
+ cleanup_push(cmd, xfree);
if ((i = iscommand(sp->word)) != 0) {
Char **pv;
@@ -1034,13 +999,13 @@ tellmewhat(lexp, str)
else
pv = v->vec;
- while (--i)
- pv++;
+ pv += i - 1;
if (pv[0][0] == 0 || eq(pv[0], STRdot)) {
if (!slash) {
sp->word = Strspl(STRdotsl, sp->word);
+ cleanup_push(sp->word, xfree);
prlex(lexp);
- xfree((ptr_t) sp->word);
+ cleanup_until(sp->word);
}
else
prlex(lexp);
@@ -1048,12 +1013,13 @@ tellmewhat(lexp, str)
else {
s1 = Strspl(*pv, STRslash);
sp->word = Strspl(s1, sp->word);
- xfree((ptr_t) s1);
+ xfree(s1);
+ cleanup_push(sp->word, xfree);
if (str == NULL)
prlex(lexp);
else
- (void) Strcpy(str, sp->word);
- xfree((ptr_t) sp->word);
+ *str = Strsave(sp->word);
+ cleanup_until(sp->word);
}
found = 1;
}
@@ -1065,11 +1031,10 @@ tellmewhat(lexp, str)
flush();
}
else
- (void) Strcpy(str, sp->word);
+ *str = Strsave(sp->word);
found = 0;
}
- sp->word = s0; /* we save and then restore this */
- xfree((ptr_t) cmd);
+ cleanup_until(&s0);
return found;
}
@@ -1083,9 +1048,7 @@ tellmewhat(lexp, str)
/*ARGSUSED*/
void
-dowhere(v, c)
- Char **v;
- struct command *c;
+dowhere(Char **v, struct command *c)
{
int found = 1;
USE(c);
@@ -1093,16 +1056,14 @@ dowhere(v, c)
found &= find_cmd(*v, 1);
/* Make status nonzero if any command is not found. */
if (!found)
- set(STRstatus, Strsave(STR1), VAR_READWRITE);
+ setcopy(STRstatus, STR1, VAR_READWRITE);
}
int
-find_cmd(cmd, prt)
- Char *cmd;
- int prt;
+find_cmd(Char *cmd, int prt)
{
struct varent *var;
- struct biltins *bptr;
+ const struct biltins *bptr;
Char **pv;
Char *sv;
int hashval, i, ex, rval = 0;
@@ -1155,6 +1116,7 @@ find_cmd(cmd, prt)
hashval = havhash ? hashname(cmd) : 0;
sv = Strspl(STRslash, cmd);
+ cleanup_push(sv, xfree);
for (pv = var->vec, i = 0; pv && *pv; pv++, i++) {
if (havhash && !eq(*pv, STRdot)) {
@@ -1184,7 +1146,7 @@ find_cmd(cmd, prt)
return rval;
}
}
- xfree((ptr_t) sv);
+ cleanup_until(sv);
return rval;
}
#ifdef WINNT_NATIVE
diff --git a/contrib/tcsh/sh.exp.c b/contrib/tcsh/sh.exp.c
index 12ee56f..e242676 100644
--- a/contrib/tcsh/sh.exp.c
+++ b/contrib/tcsh/sh.exp.c
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/sh.exp.c,v 3.45 2005/01/18 20:24:50 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/sh.exp.c,v 3.51 2006/05/13 21:25:20 christos Exp $ */
/*
* sh.exp.c: Expression evaluations
*/
@@ -32,7 +32,7 @@
*/
#include "sh.h"
-RCSID("$Id: sh.exp.c,v 3.45 2005/01/18 20:24:50 christos Exp $")
+RCSID("$tcsh: sh.exp.c,v 3.51 2006/05/13 21:25:20 christos Exp $")
#include "tw.h"
@@ -57,26 +57,29 @@ RCSID("$Id: sh.exp.c,v 3.45 2005/01/18 20:24:50 christos Exp $")
#define EQMATCH 7
#define NOTEQMATCH 8
-static int sh_access __P((Char *, int));
-static int exp1 __P((Char ***, int));
-static int exp2x __P((Char ***, int));
-static int exp2a __P((Char ***, int));
-static int exp2b __P((Char ***, int));
-static int exp2c __P((Char ***, int));
-static Char *exp3 __P((Char ***, int));
-static Char *exp3a __P((Char ***, int));
-static Char *exp4 __P((Char ***, int));
-static Char *exp5 __P((Char ***, int));
-static Char *exp6 __P((Char ***, int));
-static void evalav __P((Char **));
-static int isa __P((Char *, int));
-static int egetn __P((Char *));
+static int sh_access (const Char *, int);
+static int exp1 (Char ***, int);
+static int exp2x (Char ***, int);
+static int exp2a (Char ***, int);
+static int exp2b (Char ***, int);
+static int exp2c (Char ***, int);
+static Char *exp3 (Char ***, int);
+static Char *exp3a (Char ***, int);
+static Char *exp4 (Char ***, int);
+static Char *exp5 (Char ***, int);
+static Char *exp6 (Char ***, int);
+static void evalav (Char **);
+static int isa (Char *, int);
+static int egetn (Char *);
#ifdef EDEBUG
-static void etracc __P((char *, Char *, Char ***));
-static void etraci __P((char *, int, Char ***));
-#endif /* EDEBUG */
+static void etracc (char *, Char *, Char ***);
+static void etraci (char *, int, Char ***);
+#else /* !EDEBUG */
+#define etracc(A, B, C) ((void)0)
+#define etraci(A, B, C) ((void)0)
+#endif /* !EDEBUG */
/*
@@ -84,9 +87,7 @@ static void etraci __P((char *, int, Char ***));
* From Beto Appleton (beto@aixwiz.aix.ibm.com)
*/
static int
-sh_access(fname, mode)
- Char *fname;
- int mode;
+sh_access(const Char *fname, int mode)
{
#if defined(POSIX) && !defined(USE_ACCESS)
struct stat statb;
@@ -166,7 +167,7 @@ sh_access(fname, mode)
n = getgroups(0, (GETGROUPS_T *) NULL);
if (n > 0) {
- groups = xmalloc((size_t) (n * sizeof(*groups)));
+ groups = xmalloc(n * sizeof(*groups));
n = getgroups((int) n, groups);
while (--n >= 0)
if (groups[n] == statb.st_gid) {
@@ -185,147 +186,112 @@ sh_access(fname, mode)
}
int
-expr(vp)
- Char ***vp;
+expr(Char ***vp)
{
return (exp0(vp, 0));
}
int
-exp0(vp, ignore)
- Char ***vp;
- int ignore;
+exp0(Char ***vp, int ignore)
{
int p1 = exp1(vp, ignore);
-#ifdef EDEBUG
etraci("exp0 p1", p1, vp);
-#endif /* EDEBUG */
if (**vp && eq(**vp, STRor2)) {
int p2;
(*vp)++;
p2 = exp0(vp, (ignore & TEXP_IGNORE) || p1);
-#ifdef EDEBUG
etraci("exp0 p2", p2, vp);
-#endif /* EDEBUG */
return (p1 || p2);
}
return (p1);
}
static int
-exp1(vp, ignore)
- Char ***vp;
- int ignore;
+exp1(Char ***vp, int ignore)
{
int p1 = exp2x(vp, ignore);
-#ifdef EDEBUG
etraci("exp1 p1", p1, vp);
-#endif /* EDEBUG */
if (**vp && eq(**vp, STRand2)) {
int p2;
(*vp)++;
p2 = exp1(vp, (ignore & TEXP_IGNORE) || !p1);
-#ifdef EDEBUG
etraci("exp1 p2", p2, vp);
-#endif /* EDEBUG */
return (p1 && p2);
}
return (p1);
}
static int
-exp2x(vp, ignore)
- Char ***vp;
- int ignore;
+exp2x(Char ***vp, int ignore)
{
int p1 = exp2a(vp, ignore);
-#ifdef EDEBUG
etraci("exp3 p1", p1, vp);
-#endif /* EDEBUG */
if (**vp && eq(**vp, STRor)) {
int p2;
(*vp)++;
p2 = exp2x(vp, ignore);
-#ifdef EDEBUG
etraci("exp3 p2", p2, vp);
-#endif /* EDEBUG */
return (p1 | p2);
}
return (p1);
}
static int
-exp2a(vp, ignore)
- Char ***vp;
- int ignore;
+exp2a(Char ***vp, int ignore)
{
int p1 = exp2b(vp, ignore);
-#ifdef EDEBUG
etraci("exp2a p1", p1, vp);
-#endif /* EDEBUG */
if (**vp && eq(**vp, STRcaret)) {
int p2;
(*vp)++;
p2 = exp2a(vp, ignore);
-#ifdef EDEBUG
etraci("exp2a p2", p2, vp);
-#endif /* EDEBUG */
return (p1 ^ p2);
}
return (p1);
}
static int
-exp2b(vp, ignore)
- Char ***vp;
- int ignore;
+exp2b(Char ***vp, int ignore)
{
int p1 = exp2c(vp, ignore);
-#ifdef EDEBUG
etraci("exp2b p1", p1, vp);
-#endif /* EDEBUG */
if (**vp && eq(**vp, STRand)) {
int p2;
(*vp)++;
p2 = exp2b(vp, ignore);
-#ifdef EDEBUG
etraci("exp2b p2", p2, vp);
-#endif /* EDEBUG */
return (p1 & p2);
}
return (p1);
}
static int
-exp2c(vp, ignore)
- Char ***vp;
- int ignore;
+exp2c(Char ***vp, int ignore)
{
Char *p1 = exp3(vp, ignore);
Char *p2;
int i;
-#ifdef EDEBUG
+ cleanup_push(p1, xfree);
etracc("exp2c p1", p1, vp);
-#endif /* EDEBUG */
if ((i = isa(**vp, EQOP)) != 0) {
(*vp)++;
if (i == EQMATCH || i == NOTEQMATCH)
ignore |= TEXP_NOGLOB;
p2 = exp3(vp, ignore);
-#ifdef EDEBUG
+ cleanup_push(p2, xfree);
etracc("exp2c p2", p2, vp);
-#endif /* EDEBUG */
if (!(ignore & TEXP_IGNORE))
switch (i) {
@@ -345,35 +311,30 @@ exp2c(vp, ignore)
i = !Gmatch(p1, p2);
break;
}
- xfree((ptr_t) p1);
- xfree((ptr_t) p2);
+ cleanup_until(p1);
return (i);
}
i = egetn(p1);
- xfree((ptr_t) p1);
+ cleanup_until(p1);
return (i);
}
static Char *
-exp3(vp, ignore)
- Char ***vp;
- int ignore;
+exp3(Char ***vp, int ignore)
{
Char *p1, *p2;
int i;
p1 = exp3a(vp, ignore);
-#ifdef EDEBUG
etracc("exp3 p1", p1, vp);
-#endif /* EDEBUG */
if ((i = isa(**vp, RELOP)) != 0) {
(*vp)++;
if (**vp && eq(**vp, STRequal))
i |= 1, (*vp)++;
+ cleanup_push(p1, xfree);
p2 = exp3(vp, ignore);
-#ifdef EDEBUG
+ cleanup_push(p2, xfree);
etracc("exp3 p2", p2, vp);
-#endif /* EDEBUG */
if (!(ignore & TEXP_IGNORE))
switch (i) {
@@ -393,62 +354,53 @@ exp3(vp, ignore)
i = egetn(p1) <= egetn(p2);
break;
}
- xfree((ptr_t) p1);
- xfree((ptr_t) p2);
+ cleanup_until(p1);
return (putn(i));
}
return (p1);
}
static Char *
-exp3a(vp, ignore)
- Char ***vp;
- int ignore;
+exp3a(Char ***vp, int ignore)
{
- Char *p1, *p2, *op;
+ Char *p1, *p2;
+ const Char *op;
int i;
p1 = exp4(vp, ignore);
-#ifdef EDEBUG
etracc("exp3a p1", p1, vp);
-#endif /* EDEBUG */
op = **vp;
if (op && any("<>", op[0]) && op[0] == op[1]) {
(*vp)++;
+ cleanup_push(p1, xfree);
p2 = exp3a(vp, ignore);
-#ifdef EDEBUG
+ cleanup_push(p2, xfree);
etracc("exp3a p2", p2, vp);
-#endif /* EDEBUG */
if (op[0] == '<')
i = egetn(p1) << egetn(p2);
else
i = egetn(p1) >> egetn(p2);
- xfree((ptr_t) p1);
- xfree((ptr_t) p2);
+ cleanup_until(p1);
return (putn(i));
}
return (p1);
}
static Char *
-exp4(vp, ignore)
- Char ***vp;
- int ignore;
+exp4(Char ***vp, int ignore)
{
Char *p1, *p2;
int i = 0;
p1 = exp5(vp, ignore);
-#ifdef EDEBUG
etracc("exp4 p1", p1, vp);
-#endif /* EDEBUG */
if (isa(**vp, ADDOP)) {
- Char *op = *(*vp)++;
+ const Char *op = *(*vp)++;
+ cleanup_push(p1, xfree);
p2 = exp4(vp, ignore);
-#ifdef EDEBUG
+ cleanup_push(p2, xfree);
etracc("exp4 p2", p2, vp);
-#endif /* EDEBUG */
if (!(ignore & TEXP_IGNORE))
switch (op[0]) {
@@ -460,39 +412,36 @@ exp4(vp, ignore)
i = egetn(p1) - egetn(p2);
break;
}
- xfree((ptr_t) p1);
- xfree((ptr_t) p2);
+ cleanup_until(p1);
return (putn(i));
}
return (p1);
}
static Char *
-exp5(vp, ignore)
- Char ***vp;
- int ignore;
+exp5(Char ***vp, int ignore)
{
Char *p1, *p2;
int i = 0;
p1 = exp6(vp, ignore);
-#ifdef EDEBUG
etracc("exp5 p1", p1, vp);
-#endif /* EDEBUG */
if (isa(**vp, MULOP)) {
- Char *op = *(*vp)++;
- if ((ignore & TEXP_NOGLOB) != 0)
- /*
+ const Char *op = *(*vp)++;
+ if ((ignore & TEXP_NOGLOB) != 0) {
+ /*
* We are just trying to get the right side of
- * a =~ or !~ operator
+ * a =~ or !~ operator
*/
+ xfree(p1);
return Strsave(op);
+ }
+ cleanup_push(p1, xfree);
p2 = exp5(vp, ignore);
-#ifdef EDEBUG
+ cleanup_push(p2, xfree);
etracc("exp5 p2", p2, vp);
-#endif /* EDEBUG */
if (!(ignore & TEXP_IGNORE))
switch (op[0]) {
@@ -514,17 +463,14 @@ exp5(vp, ignore)
i = egetn(p1) % i;
break;
}
- xfree((ptr_t) p1);
- xfree((ptr_t) p2);
+ cleanup_until(p1);
return (putn(i));
}
return (p1);
}
static Char *
-exp6(vp, ignore)
- Char ***vp;
- int ignore;
+exp6(Char ***vp, int ignore)
{
int ccode, i = 0;
Char *cp;
@@ -534,30 +480,26 @@ exp6(vp, ignore)
if (eq(**vp, STRbang)) {
(*vp)++;
cp = exp6(vp, ignore);
-#ifdef EDEBUG
+ cleanup_push(cp, xfree);
etracc("exp6 ! cp", cp, vp);
-#endif /* EDEBUG */
i = egetn(cp);
- xfree((ptr_t) cp);
+ cleanup_until(cp);
return (putn(!i));
}
if (eq(**vp, STRtilde)) {
(*vp)++;
cp = exp6(vp, ignore);
-#ifdef EDEBUG
+ cleanup_push(cp, xfree);
etracc("exp6 ~ cp", cp, vp);
-#endif /* EDEBUG */
i = egetn(cp);
- xfree((ptr_t) cp);
+ cleanup_until(cp);
return (putn(~i));
}
if (eq(**vp, STRLparen)) {
(*vp)++;
ccode = exp0(vp, ignore);
-#ifdef EDEBUG
etraci("exp6 () ccode", ccode, vp);
-#endif /* EDEBUG */
- if (*vp == 0 || **vp == 0 || ***vp != ')')
+ if (**vp == 0 || ***vp != ')')
stderror(ERR_NAME | ERR_EXPRESSION);
(*vp)++;
return (putn(ccode));
@@ -584,16 +526,15 @@ exp6(vp, ignore)
if (ignore & TEXP_IGNORE)
return (Strsave(STRNULL));
psavejob();
+ cleanup_push(&faket, psavejob_cleanup); /* faket is only a marker */
if (pfork(&faket, -1) == 0) {
*--(*vp) = 0;
evalav(v);
exitstat();
}
pwait();
- prestjob();
-#ifdef EDEBUG
+ cleanup_until(&faket);
etraci("exp6 {} status", egetn(varval(STRstatus)), vp);
-#endif /* EDEBUG */
return (putn(egetn(varval(STRstatus)) == 0));
}
if (isa(**vp, ANYOP))
@@ -607,9 +548,7 @@ exp6(vp, ignore)
#define FILEVALS "ZAMCDIUGNFPL"
if (*cp == '-' && (any(FILETESTS, cp[1]) || any(FILEVALS, cp[1])))
return(filetest(cp, vp, ignore));
-#ifdef EDEBUG
etracc("exp6 default", cp, vp);
-#endif /* EDEBUG */
return (ignore & TEXP_NOGLOB ? Strsave(cp) : globone(cp, G_APPEND));
}
@@ -619,9 +558,7 @@ exp6(vp, ignore)
* From: John Rowe <rowe@excc.exeter.ac.uk>
*/
Char *
-filetest(cp, vp, ignore)
- Char *cp, ***vp;
- int ignore;
+filetest(Char *cp, Char ***vp, int ignore)
{
#ifdef convex
struct cvxstat stb, *st = NULL;
@@ -696,6 +633,7 @@ filetest(cp, vp, ignore)
if (ignore & TEXP_IGNORE)
return (Strsave(STRNULL));
ep = globone(dp, G_APPEND);
+ cleanup_push(ep, xfree);
ft = &cp[1];
do
switch (*ft) {
@@ -732,7 +670,7 @@ filetest(cp, vp, ignore)
if (!lst) {
lst = &lstb;
if (TCSH_LSTAT(short2str(ep), lst) == -1) {
- xfree((ptr_t) ep);
+ cleanup_until(ep);
return (Strsave(errval));
}
}
@@ -747,7 +685,7 @@ filetest(cp, vp, ignore)
if (!st) {
st = &stb;
if (TCSH_STAT(short2str(ep), st) == -1) {
- xfree((ptr_t) ep);
+ cleanup_until(ep);
return (Strsave(errval));
}
}
@@ -876,12 +814,12 @@ filetest(cp, vp, ignore)
case 'F':
strdev = putn( (int) st->st_dev);
strino = putn( (int) st->st_ino);
- strF = (Char *) xmalloc((size_t) (2 + Strlen(strdev) +
- Strlen(strino)) * sizeof(Char));
+ strF = xmalloc((2 + Strlen(strdev) + Strlen(strino))
+ * sizeof(Char));
(void) Strcat(Strcat(Strcpy(strF, strdev), STRcolon), strino);
- xfree((ptr_t) strdev);
- xfree((ptr_t) strino);
- xfree((ptr_t) ep);
+ xfree(strdev);
+ xfree(strino);
+ cleanup_until(ep);
return(strF);
case 'L':
@@ -891,23 +829,10 @@ filetest(cp, vp, ignore)
}
#ifdef S_ISLNK
filnam = short2str(ep);
-#ifdef PATH_MAX
-# define MY_PATH_MAX PATH_MAX
-#else /* !PATH_MAX */
-/*
- * I can't think of any more sensible alterative; readlink doesn't give
- * us an errno if the buffer isn't large enough :-(
- */
-# define MY_PATH_MAX 2048
-#endif /* PATH_MAX */
- i = readlink(filnam, string = (char *)
- xmalloc((size_t) (1 + MY_PATH_MAX) * sizeof(char)),
- MY_PATH_MAX);
- if (i >= 0 && i <= MY_PATH_MAX)
- string[i] = '\0'; /* readlink does not null terminate */
- strF = (i < 0) ? errval : str2short(string);
- xfree((ptr_t) string);
- xfree((ptr_t) ep);
+ string = areadlink(filnam);
+ strF = string == NULL ? errval : str2short(string);
+ xfree(string);
+ cleanup_until(ep);
return(Strsave(strF));
#else /* !S_ISLNK */
@@ -927,20 +852,20 @@ filetest(cp, vp, ignore)
((S_IRWXU|S_IRWXG|S_IRWXO|S_ISUID|S_ISGID) & st->st_mode));
if (altout && *string != '0')
*--string = '0';
- xfree((ptr_t) ep);
+ cleanup_until(ep);
return(Strsave(str2short(string)));
case 'U':
- if (altout && (pw = getpwuid(st->st_uid))) {
- xfree((ptr_t) ep);
+ if (altout && (pw = xgetpwuid(st->st_uid))) {
+ cleanup_until(ep);
return(Strsave(str2short(pw->pw_name)));
}
i = (int) st->st_uid;
break;
case 'G':
- if ( altout && (gr = getgrgid(st->st_gid))) {
- xfree((ptr_t) ep);
+ if (altout && (gr = xgetgrgid(st->st_gid))) {
+ cleanup_until(ep);
return(Strsave(str2short(gr->gr_name)));
}
i = (int) st->st_gid;
@@ -957,7 +882,7 @@ filetest(cp, vp, ignore)
strF = str2short(ctime(&footime));
if ((str = Strchr(strF, '\n')) != NULL)
*str = (Char) '\0';
- xfree((ptr_t) ep);
+ cleanup_until(ep);
return(Strsave(strF));
}
i = (int) footime;
@@ -966,29 +891,25 @@ filetest(cp, vp, ignore)
}
}
while (*++ft && i);
-#ifdef EDEBUG
etraci("exp6 -? i", i, vp);
-#endif /* EDEBUG */
- xfree((ptr_t) ep);
+ cleanup_until(ep);
return (putn(i));
}
static void
-evalav(v)
- Char **v;
+evalav(Char **v)
{
struct wordent paraml1;
struct wordent *hp = &paraml1;
struct command *t;
struct wordent *wdp = hp;
- set(STRstatus, Strsave(STR0), VAR_READWRITE);
+ setcopy(STRstatus, STR0, VAR_READWRITE);
hp->prev = hp->next = hp;
hp->word = STRNULL;
while (*v) {
- struct wordent *new =
- (struct wordent *) xcalloc(1, sizeof *wdp);
+ struct wordent *new = xcalloc(1, sizeof *wdp);
new->prev = wdp;
new->next = hp;
@@ -997,18 +918,18 @@ evalav(v)
wdp->word = Strsave(*v++);
}
hp->prev = wdp;
+ cleanup_push(&paraml1, lex_cleanup);
alias(&paraml1);
t = syntax(paraml1.next, &paraml1, 0);
+ cleanup_push(t, syntax_cleanup);
if (seterr)
stderror(ERR_OLD);
execute(t, -1, NULL, NULL, TRUE);
- freelex(&paraml1), freesyn(t);
+ cleanup_until(&paraml1);
}
static int
-isa(cp, what)
- Char *cp;
- int what;
+isa(Char *cp, int what)
{
if (cp == 0)
return ((what & RESTOP) != 0);
@@ -1057,8 +978,7 @@ isa(cp, what)
}
static int
-egetn(cp)
- Char *cp;
+egetn(Char *cp)
{
if (*cp && *cp != '-' && !Isdigit(*cp))
stderror(ERR_NAME | ERR_EXPRESSION);
@@ -1069,20 +989,14 @@ egetn(cp)
#ifdef EDEBUG
static void
-etraci(str, i, vp)
- char *str;
- int i;
- Char ***vp;
+etraci(char *str, int i, Char ***vp)
{
xprintf("%s=%d\t", str, i);
blkpr(*vp);
xputchar('\n');
}
static void
-etracc(str, cp, vp)
- char *str;
- Char *cp;
- Char ***vp;
+etracc(char *str, Char *cp, Char ***vp)
{
xprintf("%s=%s\t", str, cp);
blkpr(*vp);
diff --git a/contrib/tcsh/sh.file.c b/contrib/tcsh/sh.file.c
index 2412197..6955358 100644
--- a/contrib/tcsh/sh.file.c
+++ b/contrib/tcsh/sh.file.c
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/sh.file.c,v 3.28 2005/01/05 16:06:13 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/sh.file.c,v 3.35 2006/08/23 15:03:14 christos Exp $ */
/*
* sh.file.c: File completion for csh. This file is not used in tcsh.
*/
@@ -33,7 +33,7 @@
#include "sh.h"
#include "ed.h"
-RCSID("$Id: sh.file.c,v 3.28 2005/01/05 16:06:13 christos Exp $")
+RCSID("$tcsh: sh.file.c,v 3.35 2006/08/23 15:03:14 christos Exp $")
#if defined(FILEC) && defined(TIOCSTI)
@@ -59,26 +59,23 @@ typedef enum {
LIST, RECOGNIZE
} COMMAND;
-static void setup_tty __P((int));
-static void back_to_col_1 __P((void));
-static void pushback __P((Char *));
-static void catn __P((Char *, Char *, int));
-static void copyn __P((Char *, Char *, int));
-static int filetype __P((Char *, Char *));
-static void print_by_column __P((Char *, Char *[], size_t));
-static Char *tilde __P((Char *, Char *));
-static void retype __P((void));
-static void beep __P((void));
-static void print_recognized_stuff __P((Char *));
-static void extract_dir_and_name __P((Char *, Char *, Char *));
-static Char *getitem __P((DIR *, int));
-static void free_items __P((Char **, size_t));
-static int tsearch __P((Char *, COMMAND, int));
-static int compare __P((const ptr_t, const ptr_t));
-static int recognize __P((Char *, Char *, int, size_t));
-static int is_prefix __P((Char *, Char *));
-static int is_suffix __P((Char *, Char *));
-static int ignored __P((Char *));
+static void setup_tty (int);
+static void back_to_col_1 (void);
+static void pushback (const Char *);
+static int filetype (const Char *, const Char *);
+static void print_by_column (const Char *, Char *[], size_t);
+static Char *tilde (const Char *);
+static void retype (void);
+static void beep (void);
+static void print_recognized_stuff (const Char *);
+static void extract_dir_and_name (const Char *, Char **, const Char **);
+static Char *getitem (DIR *, int);
+static size_t tsearch (Char *, COMMAND, size_t);
+static int compare (const void *, const void *);
+static int recognize (Char **, Char *, size_t, size_t);
+static int is_prefix (const Char *, const Char *);
+static int is_suffix (const Char *, const Char *);
+static int ignored (const Char *);
/*
@@ -89,8 +86,7 @@ static int ignored __P((Char *));
int filec = 0;
static void
-setup_tty(on)
- int on;
+setup_tty(int on)
{
#ifdef TERMIO
# ifdef POSIX
@@ -131,7 +127,7 @@ setup_tty(on)
# endif /* POSIX */
}
# ifdef POSIX
- (void) tcsetattr(SHIN, on, &tchars);
+ (void) xtcsetattr(SHIN, on, &tchars);
# else
(void) ioctl(SHIN, on, (ioctl_t) &tchars);
# endif /* POSIX */
@@ -164,7 +160,7 @@ setup_tty(on)
* Move back to beginning of current line
*/
static void
-back_to_col_1()
+back_to_col_1(void)
{
#ifdef TERMIO
# ifdef POSIX
@@ -176,11 +172,8 @@ back_to_col_1()
struct sgttyb tty, tty_normal;
#endif /* TERMIO */
-# ifdef BSDSIGS
- sigmask_t omask = sigblock(sigmask(SIGINT));
-# else
- (void) sighold(SIGINT);
-# endif /* BSDSIGS */
+ pintr_disabled++;
+ cleanup_push(&pintr_disabled, disabled_cleanup);
#ifdef TERMIO
# ifdef POSIX
@@ -192,13 +185,13 @@ back_to_col_1()
tty.c_iflag &= ~INLCR;
tty.c_oflag &= ~ONLCR;
# ifdef POSIX
- (void) tcsetattr(SHOUT, TCSANOW, &tty);
+ (void) xtcsetattr(SHOUT, TCSANOW, &tty);
# else
(void) ioctl(SHOUT, TCSETAW, (ioctl_t) &tty);
# endif /* POSIX */
- (void) write(SHOUT, "\r", 1);
+ (void) xwrite(SHOUT, "\r", 1);
# ifdef POSIX
- (void) tcsetattr(SHOUT, TCSANOW, &tty_normal);
+ (void) xtcsetattr(SHOUT, TCSANOW, &tty_normal);
# else
(void) ioctl(SHOUT, TCSETAW, (ioctl_t) &tty_normal);
# endif /* POSIX */
@@ -207,25 +200,20 @@ back_to_col_1()
tty_normal = tty;
tty.sg_flags &= ~CRMOD;
(void) ioctl(SHIN, TIOCSETN, (ioctl_t) & tty);
- (void) write(SHOUT, "\r", 1);
+ (void) xwrite(SHOUT, "\r", 1);
(void) ioctl(SHIN, TIOCSETN, (ioctl_t) & tty_normal);
#endif /* TERMIO */
-# ifdef BSDSIGS
- (void) sigsetmask(omask);
-# else
- (void) sigrelse(SIGINT);
-# endif /* BSDISGS */
+ cleanup_until(&pintr_disabled);
}
/*
* Push string contents back into tty queue
*/
static void
-pushback(string)
- Char *string;
+pushback(const Char *string)
{
- Char *p;
+ const Char *p;
#ifdef TERMIO
# ifdef POSIX
struct termios tty, tty_normal;
@@ -236,11 +224,8 @@ pushback(string)
struct sgttyb tty, tty_normal;
#endif /* TERMIO */
-#ifdef BSDSIGS
- sigmask_t omask = sigblock(sigmask(SIGINT));
-#else
- (void) sighold(SIGINT);
-#endif /* BSDSIGS */
+ pintr_disabled++;
+ cleanup_push(&pintr_disabled, disabled_cleanup);
#ifdef TERMIO
# ifdef POSIX
@@ -251,7 +236,7 @@ pushback(string)
tty_normal = tty;
tty.c_lflag &= ~(ECHOKE | ECHO | ECHOE | ECHOK | ECHONL | ECHOPRT | ECHOCTL);
# ifdef POSIX
- (void) tcsetattr(SHOUT, TCSANOW, &tty);
+ (void) xtcsetattr(SHOUT, TCSANOW, &tty);
# else
(void) ioctl(SHOUT, TCSETAW, (ioctl_t) &tty);
# endif /* POSIX */
@@ -265,7 +250,7 @@ pushback(string)
(void) ioctl(SHOUT, TIOCSTI, (ioctl_t) &buf[i]);
}
# ifdef POSIX
- (void) tcsetattr(SHOUT, TCSANOW, &tty_normal);
+ (void) xtcsetattr(SHOUT, TCSANOW, &tty_normal);
# else
(void) ioctl(SHOUT, TCSETAW, (ioctl_t) &tty_normal);
# endif /* POSIX */
@@ -280,61 +265,26 @@ pushback(string)
(void) ioctl(SHOUT, TIOCSETN, (ioctl_t) & tty_normal);
#endif /* TERMIO */
-# ifdef BSDSIGS
- (void) sigsetmask(omask);
-# else
- (void) sigrelse(SIGINT);
-# endif /* BSDISGS */
-}
-
-/*
- * Concatenate src onto tail of des.
- * Des is a string whose maximum length is count.
- * Always null terminate.
- */
-static void
-catn(des, src, count)
- Char *des, *src;
- int count;
-{
- while (--count >= 0 && *des)
- des++;
- while (--count >= 0)
- if ((*des++ = *src++) == 0)
- return;
- *des = '\0';
-}
-
-/*
- * Like strncpy but always leave room for trailing \0
- * and always null terminate.
- */
-static void
-copyn(des, src, count)
- Char *des, *src;
- int count;
-{
- while (--count >= 0)
- if ((*des++ = *src++) == 0)
- return;
- *des = '\0';
+ cleanup_until(&pintr_disabled);
}
static int
-filetype(dir, file)
- Char *dir, *file;
+filetype(const Char *dir, const Char *file)
{
- Char path[MAXPATHLEN];
+ Char *path;
+ char *spath;
struct stat statb;
- catn(Strcpy(path, dir), file, sizeof(path) / sizeof(Char));
- if (lstat(short2str(path), &statb) == 0) {
+ path = Strspl(dir, file);
+ spath = short2str(path);
+ xfree(path);
+ if (lstat(spath, &statb) == 0) {
switch (statb.st_mode & S_IFMT) {
case S_IFDIR:
return ('/');
case S_IFLNK:
- if (stat(short2str(path), &statb) == 0 && /* follow it out */
+ if (stat(spath, &statb) == 0 && /* follow it out */
S_ISDIR(statb.st_mode))
return ('>');
else
@@ -351,16 +301,13 @@ filetype(dir, file)
return (' ');
}
-static struct winsize win;
-
/*
* Print sorted down columns
*/
static void
-print_by_column(dir, items, count)
- Char *dir, *items[];
- size_t count;
+print_by_column(const Char *dir, Char *items[], size_t count)
{
+ struct winsize win;
size_t i;
int rows, r, c, maxwidth = 0, columns;
@@ -400,35 +347,37 @@ print_by_column(dir, items, count)
* home_directory_of_person/mumble
*/
static Char *
-tilde(new, old)
- Char *new, *old;
+tilde(const Char *old)
{
- Char *o, *p;
+ const Char *o, *home;
struct passwd *pw;
- static Char person[40];
if (old[0] != '~')
- return (Strcpy(new, old));
+ return (Strsave(old));
+ old++;
- for (p = person, o = &old[1]; *o && *o != '/'; *p++ = *o++);
- *p = '\0';
- if (person[0] == '\0')
- (void) Strcpy(new, varval(STRhome));
+ for (o = old; *o != '\0' && *o != '/'; o++)
+ ;
+ if (o == old)
+ home = varval(STRhome);
else {
- pw = getpwnam(short2str(person));
+ Char *person;
+
+ person = Strnsave(old, o - old);
+ pw = xgetpwnam(short2str(person));
+ xfree(person);
if (pw == NULL)
return (NULL);
- (void) Strcpy(new, str2short(pw->pw_dir));
+ home = str2short(pw->pw_dir);
}
- (void) Strcat(new, o);
- return (new);
+ return Strspl(home, o);
}
/*
* Cause pending line to be printed
*/
static void
-retype()
+retype(void)
{
#ifdef TERMIO
# ifdef POSIX
@@ -444,7 +393,7 @@ retype()
tty.c_lflag |= PENDIN;
# ifdef POSIX
- (void) tcsetattr(SHOUT, TCSANOW, &tty);
+ (void) xtcsetattr(SHOUT, TCSANOW, &tty);
# else
(void) ioctl(SHOUT, TCSETAW, (ioctl_t) &tty);
# endif /* POSIX */
@@ -456,15 +405,15 @@ retype()
}
static void
-beep()
+beep(void)
{
if (adrof(STRnobeep) == 0)
#ifdef IS_ASCII
- (void) write(SHOUT, "\007", 1);
+ (void) xwrite(SHOUT, "\007", 1);
#else
{
unsigned char beep_ch = CTL_ESC('\007');
- (void) write(SHOUT, &beep_ch, 1);
+ (void) xwrite(SHOUT, &beep_ch, 1);
}
#endif
}
@@ -474,8 +423,7 @@ beep()
* print the recognized part of the string
*/
static void
-print_recognized_stuff(recognized_part)
- Char *recognized_part;
+print_recognized_stuff(const Char *recognized_part)
{
/* An optimized erasing of that silly ^[ */
(void) putraw('\b');
@@ -507,26 +455,21 @@ print_recognized_stuff(recognized_part)
* Should leave final slash (/) at end of dir.
*/
static void
-extract_dir_and_name(path, dir, name)
- Char *path, *dir, *name;
+extract_dir_and_name(const Char *path, Char **dir, const Char **name)
{
- Char *p;
+ const Char *p;
p = Strrchr(path, '/');
- if (p == NULL) {
- copyn(name, path, MAXNAMLEN);
- dir[0] = '\0';
- }
- else {
- copyn(name, ++p, MAXNAMLEN);
- copyn(dir, path, p - path);
- }
+ if (p == NULL)
+ p = path;
+ else
+ p++;
+ *name = p;
+ *dir = Strnsave(path, p - path);
}
static Char *
-getitem(dir_fd, looking_for_lognames)
- DIR *dir_fd;
- int looking_for_lognames;
+getitem(DIR *dir_fd, int looking_for_lognames)
{
struct passwd *pw;
struct dirent *dirp;
@@ -545,102 +488,64 @@ getitem(dir_fd, looking_for_lognames)
return (NULL);
}
-static void
-free_items(items, numitems)
- Char **items;
- size_t numitems;
-{
- size_t i;
-
- for (i = 0; i < numitems; i++)
- xfree((ptr_t) items[i]);
- xfree((ptr_t) items);
-}
-
-#ifdef BSDSIGS
-# define FREE_ITEMS(items, numitems) { \
- sigmask_t omask;\
-\
- omask = sigblock(sigmask(SIGINT));\
- free_items(items, numitems);\
- (void) sigsetmask(omask);\
-}
-#else
-# define FREE_ITEMS(items, numitems) { \
- (void) sighold(SIGINT);\
- free_items(items, numitems);\
- (void) sigrelse(SIGINT);\
-}
-#endif /* BSDSIGS */
-
/*
* Perform a RECOGNIZE or LIST command on string "word".
*/
-static int
-tsearch(word, command, max_word_length)
- Char *word;
- int max_word_length;
- COMMAND command;
+static size_t
+tsearch(Char *word, COMMAND command, size_t max_word_length)
{
DIR *dir_fd;
int ignoring = TRUE, nignored = 0;
- int name_length, looking_for_lognames;
- Char tilded_dir[MAXPATHLEN + 1], dir[MAXPATHLEN + 1];
- Char name[MAXNAMLEN + 1], extended_name[MAXNAMLEN + 1];
- Char *item;
- Char **items = NULL;
- size_t numitems = 0, maxitems = 0;
+ int looking_for_lognames;
+ Char *tilded_dir = NULL, *dir = NULL;
+ Char *extended_name = NULL;
+ const Char *name;
+ Char *item;
+ struct blk_buf items = BLK_BUF_INIT;
+ size_t name_length;
looking_for_lognames = (*word == '~') && (Strchr(word, '/') == NULL);
if (looking_for_lognames) {
#ifdef HAVE_GETPWENT
(void) setpwent();
#endif
- copyn(name, &word[1], MAXNAMLEN); /* name sans ~ */
+ name = word + 1; /* name sans ~ */
dir_fd = NULL;
+ cleanup_push(dir, xfree);
}
else {
- extract_dir_and_name(word, dir, name);
- if (tilde(tilded_dir, dir) == 0)
- return (0);
+ extract_dir_and_name(word, &dir, &name);
+ cleanup_push(dir, xfree);
+ tilded_dir = tilde(dir);
+ if (tilded_dir == NULL)
+ goto end;
+ cleanup_push(tilded_dir, xfree);
dir_fd = opendir(*tilded_dir ? short2str(tilded_dir) : ".");
if (dir_fd == NULL)
- return (0);
+ goto end;
}
-again: /* search for matches */
name_length = Strlen(name);
- for (numitems = 0;
- (item = getitem(dir_fd, looking_for_lognames)) != NULL;) {
+ cleanup_push(&extended_name, xfree_indirect);
+ cleanup_push(&items, bb_cleanup);
+again: /* search for matches */
+ while ((item = getitem(dir_fd, looking_for_lognames)) != NULL) {
if (!is_prefix(name, item))
continue;
/* Don't match . files on null prefix match */
if (name_length == 0 && item[0] == '.' &&
!looking_for_lognames)
continue;
- if (command == LIST) {
- if (numitems >= maxitems) {
- maxitems += 1024;
- if (items == NULL)
- items = (Char **) xmalloc(sizeof(*items) * maxitems);
- else
- items = (Char **) xrealloc((ptr_t) items,
- sizeof(*items) * maxitems);
- }
- items[numitems] = (Char *) xmalloc((size_t) (Strlen(item) + 1) *
- sizeof(Char));
- copyn(items[numitems], item, MAXNAMLEN);
- numitems++;
- }
+ if (command == LIST)
+ bb_append(&items, Strsave(item));
else { /* RECOGNIZE command */
if (ignoring && ignored(item))
nignored++;
- else if (recognize(extended_name,
- item, name_length, ++numitems))
+ else if (recognize(&extended_name, item, name_length, ++items.len))
break;
}
}
- if (ignoring && numitems == 0 && nignored > 0) {
+ if (ignoring && items.len == 0 && nignored > 0) {
ignoring = FALSE;
nignored = 0;
if (looking_for_lognames) {
@@ -657,51 +562,47 @@ again: /* search for matches */
(void) endpwent();
#endif
} else
- (void) closedir(dir_fd);
- if (numitems == 0)
- return (0);
- if (command == RECOGNIZE) {
- if (looking_for_lognames)
- copyn(word, STRtilde, 1);
- else
- /* put back dir part */
- copyn(word, dir, max_word_length);
- /* add extended name */
- catn(word, extended_name, max_word_length);
- return (numitems);
- }
- else { /* LIST */
- qsort((ptr_t) items, numitems, sizeof(items[0]),
- (int (*) __P((const void *, const void *))) compare);
- print_by_column(looking_for_lognames ? NULL : tilded_dir,
- items, numitems);
- if (items != NULL)
- FREE_ITEMS(items, numitems);
+ xclosedir(dir_fd);
+ if (items.len != 0) {
+ if (command == RECOGNIZE) {
+ if (looking_for_lognames)
+ copyn(word, STRtilde, 2);/*FIXBUF, sort of */
+ else
+ /* put back dir part */
+ copyn(word, dir, max_word_length);/*FIXBUF*/
+ /* add extended name */
+ catn(word, extended_name, max_word_length);/*FIXBUF*/
+ }
+ else { /* LIST */
+ qsort(items.vec, items.len, sizeof(items.vec[0]), compare);
+ print_by_column(looking_for_lognames ? NULL : tilded_dir,
+ items.vec, items.len);
+ }
}
- return (0);
+ end:
+ cleanup_until(dir);
+ return items.len;
}
static int
-compare(p, q)
- const ptr_t p, q;
+compare(const void *p, const void *q)
{
#ifdef WIDE_STRINGS
errno = 0;
- return (wcscoll(*(Char **) p, *(Char **) q));
+ return (wcscoll(*(Char *const *) p, *(Char *const *) q));
#else
char *p1, *q1;
int res;
- p1 = strsave(short2str(*(Char **) p));
- q1 = strsave(short2str(*(Char **) q));
-# if defined(NLS) && !defined(NOSTRCOLL)
- errno = 0; /* strcoll sets errno, another brain-damage */
+ p1 = strsave(short2str(*(Char *const *) p));
+ q1 = strsave(short2str(*(Char *const *) q));
+# if defined(NLS) && defined(HAVE_STRCOLL)
res = strcoll(p1, q1);
# else
res = strcmp(p1, q1);
-# endif /* NLS && !NOSTRCOLL */
+# endif /* NLS && HAVE_STRCOLL */
xfree (p1);
xfree (q1);
return res;
@@ -717,18 +618,16 @@ compare(p, q)
* If we shorten it back to the prefix length, stop searching.
*/
static int
-recognize(extended_name, item, name_length, numitems)
- Char *extended_name, *item;
- int name_length;
- size_t numitems;
+recognize(Char **extended_name, Char *item, size_t name_length,
+ size_t numitems)
{
if (numitems == 1) /* 1st match */
- copyn(extended_name, item, MAXNAMLEN);
+ *extended_name = Strsave(item);
else { /* 2nd & subsequent matches */
Char *x, *ent;
- int len = 0;
+ size_t len = 0;
- x = extended_name;
+ x = *extended_name;
for (ent = item; *x && *x == *ent++; x++, len++);
*x = '\0'; /* Shorten at 1st Char diff */
if (len == name_length) /* Ambiguous to prefix? */
@@ -743,8 +642,7 @@ recognize(extended_name, item, name_length, numitems)
* it matches anything.
*/
static int
-is_prefix(check, template)
- Char *check, *template;
+is_prefix(const Char *check, const Char *template)
{
do
if (*check == 0)
@@ -758,10 +656,9 @@ is_prefix(check, template)
* end of check, I.e., are it's suffix.
*/
static int
-is_suffix(check, template)
- Char *check, *template;
+is_suffix(const Char *check, const Char *template)
{
- Char *c, *t;
+ const Char *c, *t;
for (c = check; *c++;);
for (t = template; *t++;);
@@ -773,30 +670,36 @@ is_suffix(check, template)
}
}
-int
-tenex(inputline, inputline_size)
- Char *inputline;
- int inputline_size;
+static void
+setup_tty_cleanup(void *dummy)
{
- int numitems, num_read;
- char tinputline[BUFSIZE + 1];
+ USE(dummy);
+ setup_tty(OFF);
+}
+size_t
+tenex(Char *inputline, size_t inputline_size)
+{
+ size_t numitems;
+ ssize_t num_read;
+ char tinputline[BUFSIZE + 1];/*FIXBUF*/
setup_tty(ON);
+ cleanup_push(&num_read, setup_tty_cleanup); /* num_read is only a marker */
- while ((num_read = read(SHIN, tinputline, BUFSIZE)) > 0) {
- static Char delims[] = {' ', '\'', '"', '\t', ';', '&', '<',
+ while ((num_read = xread(SHIN, tinputline, BUFSIZE)) > 0) {/*FIXBUF*/
+ static const Char delims[] = {' ', '\'', '"', '\t', ';', '&', '<',
'>', '(', ')', '|', '^', '%', '\0'};
Char *str_end, *word_start, last_Char, should_retype;
- int space_left;
+ size_t space_left;
COMMAND command;
tinputline[num_read] = 0;
- Strcpy(inputline, str2short(tinputline));
+ Strcpy(inputline, str2short(tinputline));/*FIXBUF*/
num_read = Strlen(inputline);
- last_Char = inputline[num_read - 1] & ASCII;
+ last_Char = CTL_ESC(ASC(inputline[num_read - 1]) & ASCII);
- if (last_Char == '\n' || num_read == inputline_size)
+ if (last_Char == '\n' || (size_t)num_read == inputline_size)
break;
command = (last_Char == ESC) ? RECOGNIZE : LIST;
if (command == LIST)
@@ -840,13 +743,12 @@ tenex(inputline, inputline_size)
if (should_retype)
retype();
}
- setup_tty(OFF);
+ cleanup_until(&num_read);
return (num_read);
}
static int
-ignored(item)
- Char *item;
+ignored(const Char *item)
{
struct varent *vp;
Char **cp;
diff --git a/contrib/tcsh/sh.func.c b/contrib/tcsh/sh.func.c
index b77dcca..92e2447 100644
--- a/contrib/tcsh/sh.func.c
+++ b/contrib/tcsh/sh.func.c
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/sh.func.c,v 3.126 2005/03/20 06:35:48 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/sh.func.c,v 3.143 2006/08/24 20:56:31 christos Exp $ */
/*
* sh.func.c: csh builtin functions
*/
@@ -32,7 +32,7 @@
*/
#include "sh.h"
-RCSID("$Id: sh.func.c,v 3.126 2005/03/20 06:35:48 christos Exp $")
+RCSID("$tcsh: sh.func.c,v 3.143 2006/08/24 20:56:31 christos Exp $")
#include "ed.h"
#include "tw.h"
@@ -41,18 +41,14 @@ RCSID("$Id: sh.func.c,v 3.126 2005/03/20 06:35:48 christos Exp $")
#include "nt.const.h"
#endif /* WINNT_NATIVE */
-#ifdef NLS_CATALOGS
-#ifdef HAVE_ICONV
+#if defined (NLS_CATALOGS) && defined(HAVE_ICONV) && defined(HAVE_NL_LANGINFO)
#include <langinfo.h>
static iconv_t catgets_iconv; /* Or (iconv_t)-1 */
#endif
-#endif
/*
* C shell
*/
-extern int just_signaled;
-extern char **environ;
extern int MapsAreInited;
extern int NLSMapsAreInited;
@@ -60,23 +56,22 @@ extern int GotTermCaps;
static int zlast = -1;
-static void islogin __P((void));
-static void preread __P((void));
-static void doagain __P((void));
-static const char *isrchx __P((int));
-static void search __P((int, int, Char *));
-static int getword __P((Char *));
-static void toend __P((void));
-static void xecho __P((int, Char **));
-static int islocale_var __P((Char *));
-static void wpfree __P((struct whyle *));
-
-struct biltins *
-isbfunc(t)
- struct command *t;
+static void islogin (void);
+static void preread (void);
+static void doagain (void);
+static const char *isrchx (int);
+static void search (int, int, Char *);
+static int getword (struct Strbuf *);
+static void toend (void);
+static void xecho (int, Char **);
+static int islocale_var (Char *);
+static void wpfree (struct whyle *);
+
+const struct biltins *
+isbfunc(struct command *t)
{
Char *cp = t->t_dcom[0];
- struct biltins *bp, *bp1, *bp2;
+ const struct biltins *bp, *bp1, *bp2;
static struct biltins label = {"", dozip, 0, 0};
static struct biltins foregnd = {"%job", dofg1, 0, 0};
static struct biltins backgnd = {"%job &", dobg1, 0, 0};
@@ -136,9 +131,7 @@ isbfunc(t)
}
void
-func(t, bp)
- struct command *t;
- struct biltins *bp;
+func(struct command *t, const struct biltins *bp)
{
int i;
@@ -154,62 +147,39 @@ func(t, bp)
/*ARGSUSED*/
void
-doonintr(v, c)
- Char **v;
- struct command *c;
+doonintr(Char **v, struct command *c)
{
Char *cp;
Char *vv = v[1];
USE(c);
- if (parintr == SIG_IGN)
+ if (parintr.sa_handler == SIG_IGN)
return;
if (setintr && intty)
stderror(ERR_NAME | ERR_TERMINAL);
cp = gointr;
gointr = 0;
- xfree((ptr_t) cp);
+ xfree(cp);
if (vv == 0) {
-#ifdef BSDSIGS
- if (setintr) {
- (void) sigblock(sigmask(SIGINT));
- (void) signal(SIGINT, pintr);
- }
- else
- (void) signal(SIGINT, SIG_DFL);
-#else /* !BSDSIGS */
- if (setintr) {
- (void) sighold(SIGINT);
- (void) sigset(SIGINT, pintr);
- }
+ if (setintr)
+ sigset_interrupting(SIGINT, queue_pintr);
else
- (void) sigset(SIGINT, SIG_DFL);
-#endif /* BSDSIGS */
+ (void) signal(SIGINT, SIG_DFL);
gointr = 0;
}
else if (eq((vv = strip(vv)), STRminus)) {
-#ifdef BSDSIGS
(void) signal(SIGINT, SIG_IGN);
-#else /* !BSDSIGS */
- (void) sigset(SIGINT, SIG_IGN);
-#endif /* BSDSIGS */
gointr = Strsave(STRminus);
}
else {
gointr = Strsave(vv);
-#ifdef BSDSIGS
- (void) signal(SIGINT, pintr);
-#else /* !BSDSIGS */
- (void) sigset(SIGINT, pintr);
-#endif /* BSDSIGS */
+ sigset_interrupting(SIGINT, queue_pintr);
}
}
/*ARGSUSED*/
void
-donohup(v, c)
- Char **v;
- struct command *c;
+donohup(Char **v, struct command *c)
{
USE(c);
USE(v);
@@ -217,6 +187,7 @@ donohup(v, c)
stderror(ERR_NAME | ERR_TERMINAL);
if (setintr == 0) {
(void) signal(SIGHUP, SIG_IGN);
+ phup_disabled = 1;
#ifdef CC
submit(getpid());
#endif /* CC */
@@ -225,9 +196,7 @@ donohup(v, c)
/*ARGSUSED*/
void
-dohup(v, c)
- Char **v;
- struct command *c;
+dohup(Char **v, struct command *c)
{
USE(c);
USE(v);
@@ -240,9 +209,7 @@ dohup(v, c)
/*ARGSUSED*/
void
-dozip(v, c)
- Char **v;
- struct command *c;
+dozip(Char **v, struct command *c)
{
USE(c);
USE(v);
@@ -250,53 +217,41 @@ dozip(v, c)
/*ARGSUSED*/
void
-dofiletest(v, c)
- Char **v;
- struct command *c;
+dofiletest(Char **v, struct command *c)
{
- Char **fileptr, *ftest, *res;
+ Char **globbed, **fileptr, *ftest, *res;
USE(c);
if (*(ftest = *++v) != '-')
stderror(ERR_NAME | ERR_FILEINQ);
++v;
- gflag = 0;
- tglob(v);
- if (gflag) {
- v = globall(v);
- if (v == 0)
- stderror(ERR_NAME | ERR_NOMATCH);
- }
- else
- v = gargv = saveblk(v);
- trim(v);
+ v = glob_all_or_error(v);
+ globbed = v;
+ cleanup_push(globbed, blk_cleanup);
while (*(fileptr = v++) != '\0') {
- xprintf("%S", res = filetest(ftest, &fileptr, 0));
- xfree((ptr_t) res);
+ res = filetest(ftest, &fileptr, 0);
+ cleanup_push(res, xfree);
+ xprintf("%S", res);
+ cleanup_until(res);
if (*v)
xprintf(" ");
}
xprintf("\n");
- if (gargv) {
- blkfree(gargv);
- gargv = 0;
- }
+ cleanup_until(globbed);
}
void
-prvars()
+prvars(void)
{
plist(&shvhed, VAR_ALL);
}
/*ARGSUSED*/
void
-doalias(v, c)
- Char **v;
- struct command *c;
+doalias(Char **v, struct command *c)
{
struct varent *vp;
Char *p;
@@ -323,9 +278,7 @@ doalias(v, c)
/*ARGSUSED*/
void
-unalias(v, c)
- Char **v;
- struct command *c;
+unalias(Char **v, struct command *c)
{
USE(c);
unset1(v, &aliases);
@@ -334,9 +287,7 @@ unalias(v, c)
/*ARGSUSED*/
void
-dologout(v, c)
- Char **v;
- struct command *c;
+dologout(Char **v, struct command *c)
{
USE(c);
USE(v);
@@ -346,22 +297,22 @@ dologout(v, c)
/*ARGSUSED*/
void
-dologin(v, c)
- Char **v;
- struct command *c;
+dologin(Char **v, struct command *c)
{
#ifdef WINNT_NATIVE
USE(c);
USE(v);
#else /* !WINNT_NATIVE */
char **p = short2blk(v);
+
USE(c);
+ cleanup_push((Char **)p, blk_cleanup);
islogin();
rechist(NULL, adrof(STRsavehist) != NULL);
- (void) signal(SIGTERM, parterm);
+ sigaction(SIGTERM, &parterm, NULL);
(void) execv(_PATH_BIN_LOGIN, p);
(void) execv(_PATH_USRBIN_LOGIN, p);
- blkfree((Char **) p);
+ cleanup_until((Char **)p);
untty();
xexit(1);
#endif /* !WINNT_NATIVE */
@@ -371,14 +322,12 @@ dologin(v, c)
#ifdef NEWGRP
/*ARGSUSED*/
void
-donewgrp(v, c)
- Char **v;
- struct command *c;
+donewgrp(Char **v, struct command *c)
{
char **p;
if (chkstop == 0 && setintr)
panystop(0);
- (void) signal(SIGTERM, parterm);
+ sigaction(SIGTERM, &parterm, NULL);
p = short2blk(v);
/*
* From Beto Appleton (beto@aixwiz.austin.ibm.com)
@@ -393,7 +342,7 @@ donewgrp(v, c)
#endif /* NEWGRP */
static void
-islogin()
+islogin(void)
{
if (chkstop == 0 && setintr)
panystop(0);
@@ -403,15 +352,13 @@ islogin()
}
void
-doif(v, kp)
- Char **v;
- struct command *kp;
+doif(Char **v, struct command *kp)
{
int i;
Char **vv;
v++;
- i = expr(&v);
+ i = noexec ? 1 : expr(&v);
vv = v;
if (*vv == NULL)
stderror(ERR_NAME | ERR_EMPTYIF);
@@ -443,8 +390,7 @@ doif(v, kp)
* to redo i/o redirection, which is already set up.
*/
void
-reexecute(kp)
- struct command *kp;
+reexecute(struct command *kp)
{
kp->t_dflg &= F_SAVE;
kp->t_dflg |= F_REPEAT;
@@ -458,31 +404,30 @@ reexecute(kp)
/*ARGSUSED*/
void
-doelse (v, c)
- Char **v;
- struct command *c;
+doelse (Char **v, struct command *c)
{
USE(c);
USE(v);
- search(TC_ELSE, 0, NULL);
+ if (!noexec)
+ search(TC_ELSE, 0, NULL);
}
/*ARGSUSED*/
void
-dogoto(v, c)
- Char **v;
- struct command *c;
+dogoto(Char **v, struct command *c)
{
Char *lp;
USE(c);
- gotolab(lp = globone(v[1], G_ERROR));
- xfree((ptr_t) lp);
+ lp = globone(v[1], G_ERROR);
+ cleanup_push(lp, xfree);
+ if (!noexec)
+ gotolab(lp);
+ cleanup_until(lp);
}
void
-gotolab(lab)
- Char *lab;
+gotolab(Char *lab)
{
struct whyle *wp;
/*
@@ -507,9 +452,7 @@ gotolab(lab)
/*ARGSUSED*/
void
-doswitch(v, c)
- Char **v;
- struct command *c;
+doswitch(Char **v, struct command *c)
{
Char *cp, *lp;
@@ -522,29 +465,28 @@ doswitch(v, c)
v--;
if (*v)
stderror(ERR_SYNTAX);
- search(TC_SWITCH, 0, lp = globone(cp, G_ERROR));
- xfree((ptr_t) lp);
+ lp = globone(cp, G_ERROR);
+ cleanup_push(lp, xfree);
+ if (!noexec)
+ search(TC_SWITCH, 0, lp);
+ cleanup_until(lp);
}
/*ARGSUSED*/
void
-dobreak(v, c)
- Char **v;
- struct command *c;
+dobreak(Char **v, struct command *c)
{
USE(v);
USE(c);
- if (whyles)
- toend();
- else
+ if (whyles == NULL)
stderror(ERR_NAME | ERR_NOTWHILE);
+ if (!noexec)
+ toend();
}
/*ARGSUSED*/
void
-doexit(v, c)
- Char **v;
- struct command *c;
+doexit(Char **v, struct command *c)
{
USE(c);
@@ -555,7 +497,7 @@ doexit(v, c)
*/
v++;
if (*v) {
- set(STRstatus, putn(expr(&v)), VAR_READWRITE);
+ setv(STRstatus, putn(expr(&v)), VAR_READWRITE);
if (*v)
stderror(ERR_NAME | ERR_EXPRESSION);
}
@@ -564,17 +506,16 @@ doexit(v, c)
if (intty)
#endif
/* Always close, why only on ttys? */
- (void) close(SHIN);
+ xclose(SHIN);
}
/*ARGSUSED*/
void
-doforeach(v, c)
- Char **v;
- struct command *c;
+doforeach(Char **v, struct command *c)
{
Char *cp, *sp;
struct whyle *nwp;
+ int gflag;
USE(c);
v++;
@@ -585,25 +526,22 @@ doforeach(v, c)
cp++;
if (*cp)
stderror(ERR_NAME | ERR_VARALNUM);
- if ((cp - sp) > MAXVARLEN)
- stderror(ERR_NAME | ERR_VARTOOLONG);
cp = *v++;
if (v[0][0] != '(' || v[blklen(v) - 1][0] != ')')
stderror(ERR_NAME | ERR_NOPAREN);
v++;
- gflag = 0, tglob(v);
+ gflag = tglob(v);
if (gflag) {
- v = globall(v);
- if (v == 0)
+ v = globall(v, gflag);
+ if (v == 0 && !noexec)
stderror(ERR_NAME | ERR_NOMATCH);
}
else {
- v = gargv = saveblk(v);
+ v = saveblk(v);
trim(v);
}
- nwp = (struct whyle *) xcalloc(1, sizeof *nwp);
+ nwp = xcalloc(1, sizeof *nwp);
nwp->w_fe = nwp->w_fe0 = v;
- gargv = 0;
btell(&nwp->w_start);
nwp->w_fename = Strsave(cp);
nwp->w_next = whyles;
@@ -615,14 +553,13 @@ doforeach(v, c)
zlast = TC_FOREACH;
if (intty)
preread();
- doagain();
+ if (!noexec)
+ doagain();
}
/*ARGSUSED*/
void
-dowhile(v, c)
- Char **v;
- struct command *c;
+dowhile(Char **v, struct command *c)
{
int status;
int again = whyles != 0 &&
@@ -635,15 +572,16 @@ dowhile(v, c)
* Implement prereading here also, taking care not to evaluate the
* expression before the loop has been read up from a terminal.
*/
- if (intty && !again)
+ if (noexec)
+ status = 0;
+ else if (intty && !again)
status = !exp0(&v, 1);
else
status = !expr(&v);
- if (*v)
+ if (*v && !noexec)
stderror(ERR_NAME | ERR_EXPRESSION);
if (!again) {
- struct whyle *nwp =
- (struct whyle *) xcalloc(1, sizeof(*nwp));
+ struct whyle *nwp = xcalloc(1, sizeof(*nwp));
nwp->w_start = lineloc;
nwp->w_end.type = TCSH_F_SEEK;
@@ -666,54 +604,46 @@ dowhile(v, c)
}
static void
-preread()
+preread(void)
{
+ int old_pintr_disabled;
+
whyles->w_end.type = TCSH_I_SEEK;
if (setintr)
-#ifdef BSDSIGS
- (void) sigsetmask(sigblock((sigmask_t) 0) & ~sigmask(SIGINT));
-#else /* !BSDSIGS */
- (void) sigrelse (SIGINT);
-#endif /* BSDSIGS */
+ pintr_push_enable(&old_pintr_disabled);
search(TC_BREAK, 0, NULL); /* read the expression in */
if (setintr)
-#ifdef BSDSIGS
- (void) sigblock(sigmask(SIGINT));
-#else /* !BSDSIGS */
- (void) sighold(SIGINT);
-#endif /* BSDSIGS */
+ cleanup_until(&old_pintr_disabled);
btell(&whyles->w_end);
}
/*ARGSUSED*/
void
-doend(v, c)
- Char **v;
- struct command *c;
+doend(Char **v, struct command *c)
{
USE(v);
USE(c);
if (!whyles)
stderror(ERR_NAME | ERR_NOTWHILE);
btell(&whyles->w_end);
- doagain();
+ if (!noexec)
+ doagain();
}
/*ARGSUSED*/
void
-docontin(v, c)
- Char **v;
- struct command *c;
+docontin(Char **v, struct command *c)
{
USE(v);
USE(c);
if (!whyles)
stderror(ERR_NAME | ERR_NOTWHILE);
- doagain();
+ if (!noexec)
+ doagain();
}
static void
-doagain()
+doagain(void)
{
/* Repeating a while is simple */
if (whyles->w_fename == 0) {
@@ -729,65 +659,51 @@ doagain()
dobreak(NULL, NULL);
return;
}
- set(whyles->w_fename, quote(Strsave(*whyles->w_fe++)), VAR_READWRITE);
+ setv(whyles->w_fename, quote(Strsave(*whyles->w_fe++)), VAR_READWRITE);
bseek(&whyles->w_start);
}
void
-dorepeat(v, kp)
- Char **v;
- struct command *kp;
+dorepeat(Char **v, struct command *kp)
{
int i = 1;
-#ifdef BSDSIGS
- sigmask_t omask = 0;
-#endif /* BSDSIGS */
-
do {
i *= getn(v[1]);
lshift(v, 2);
} while (v[0] != NULL && Strcmp(v[0], STRrepeat) == 0);
+ if (noexec)
+ i = 1;
- if (setintr)
-#ifdef BSDSIGS
- omask = sigblock(sigmask(SIGINT)) & ~sigmask(SIGINT);
-#else /* !BSDSIGS */
- (void) sighold(SIGINT);
-#endif /* BSDSIGS */
+ if (setintr) {
+ pintr_disabled++;
+ cleanup_push(&pintr_disabled, disabled_cleanup);
+ }
while (i > 0) {
- if (setintr)
-#ifdef BSDSIGS
- (void) sigsetmask(omask);
-#else /* !BSDSIGS */
- (void) sigrelse (SIGINT);
-#endif /* BSDSIGS */
+ if (setintr && pintr_disabled == 1) {
+ cleanup_until(&pintr_disabled);
+ pintr_disabled++;
+ cleanup_push(&pintr_disabled, disabled_cleanup);
+ }
reexecute(kp);
--i;
}
+ cleanup_until(&pintr_disabled);
donefds();
- if (setintr)
-#ifdef BSDSIGS
- (void) sigsetmask(omask);
-#else /* !BSDSIGS */
- (void) sigrelse (SIGINT);
-#endif /* BSDSIGS */
}
/*ARGSUSED*/
void
-doswbrk(v, c)
- Char **v;
- struct command *c;
+doswbrk(Char **v, struct command *c)
{
USE(v);
USE(c);
- search(TC_BRKSW, 0, NULL);
+ if (!noexec)
+ search(TC_BRKSW, 0, NULL);
}
int
-srchx(cp)
- Char *cp;
+srchx(Char *cp)
{
struct srch *sp, *sp1, *sp2;
int i;
@@ -816,8 +732,7 @@ srchx(cp)
}
static const char *
-isrchx(n)
- int n;
+isrchx(int n)
{
struct srch *sp, *sp2;
@@ -828,22 +743,18 @@ isrchx(n)
}
-static Char Stype;
+static int Stype;
static Char *Sgoal;
static void
-search(type, level, goal)
- int type;
- int level;
- Char *goal;
+search(int type, int level, Char *goal)
{
- Char wordbuf[BUFSIZE];
- Char *aword = wordbuf;
+ struct Strbuf word = Strbuf_INIT;
Char *cp;
struct whyle *wp;
int wlevel = 0;
- Stype = (Char) type;
+ Stype = type;
Sgoal = goal;
if (type == TC_GOTO) {
struct Ain a;
@@ -851,24 +762,25 @@ search(type, level, goal)
a.f_seek = 0;
bseek(&a);
}
+ cleanup_push(&word, Strbuf_cleanup);
do {
if (intty && fseekp == feobp && aret == TCSH_F_SEEK)
printprompt(1, isrchx(type == TC_BREAK ? zlast : type));
/* xprintf("? "), flush(); */
- aword[0] = 0;
- (void) getword(aword);
- switch (srchx(aword)) {
+ (void) getword(&word);
+ Strbuf_terminate(&word);
+ switch (srchx(word.s)) {
case TC_ELSE:
if (level == 0 && type == TC_IF)
- return;
+ goto end;
break;
case TC_IF:
- while (getword(aword))
+ while (getword(&word))
continue;
if ((type == TC_IF || type == TC_ELSE) &&
- eq(aword, STRthen))
+ eq(word.s, STRthen))
level++;
break;
@@ -910,31 +822,32 @@ search(type, level, goal)
break;
case TC_LABEL:
- if (type == TC_GOTO && getword(aword) && eq(aword, goal))
+ if (type == TC_GOTO && getword(&word) && eq(word.s, goal))
level = -1;
break;
default:
if (type != TC_GOTO && (type != TC_SWITCH || level != 0))
break;
- if (lastchr(aword) != ':')
+ if (word.len == 0 || word.s[word.len - 1] != ':')
break;
- aword[Strlen(aword) - 1] = 0;
- if ((type == TC_GOTO && eq(aword, goal)) ||
- (type == TC_SWITCH && eq(aword, STRdefault)))
+ word.s[--word.len] = 0;
+ if ((type == TC_GOTO && eq(word.s, goal)) ||
+ (type == TC_SWITCH && eq(word.s, STRdefault)))
level = -1;
break;
case TC_CASE:
if (type != TC_SWITCH || level != 0)
break;
- (void) getword(aword);
- if (lastchr(aword) == ':')
- aword[Strlen(aword) - 1] = 0;
- cp = strip(Dfix1(aword));
+ (void) getword(&word);
+ if (word.len != 0 && word.s[word.len - 1] == ':')
+ word.s[--word.len] = 0;
+ cp = strip(Dfix1(word.s));
+ cleanup_push(cp, xfree);
if (Gmatch(goal, cp))
level = -1;
- xfree((ptr_t) cp);
+ cleanup_until(cp);
break;
case TC_DEFAULT:
@@ -944,15 +857,18 @@ search(type, level, goal)
}
(void) getword(NULL);
} while (level >= 0);
+ end:
+ cleanup_until(&word);
}
static int
-getword(wp)
- Char *wp;
+getword(struct Strbuf *wp)
{
int found = 0, first;
eChar c, d;
+ if (wp)
+ wp->len = 0;
c = readc(1);
d = 0;
do {
@@ -984,16 +900,11 @@ getword(wp)
}
if (c == CHAR_ERR)
goto past;
- if (wp) {
- *wp++ = (Char) c;
- *wp = '\0';
- }
+ if (wp)
+ Strbuf_append1(wp, (Char) c);
if (!first && !d && c == '(') {
- if (wp) {
- unreadc(c);
- *--wp = '\0';
- return found;
- }
+ if (wp)
+ goto past_word_end;
else
break;
}
@@ -1001,9 +912,12 @@ getword(wp)
} while ((d || (c != ' ' && c != '\t')) && c != '\n');
} while (wp == 0);
+ past_word_end:
unreadc(c);
- if (found)
- *--wp = '\0';
+ if (found) {
+ wp->len--;
+ Strbuf_terminate(wp);
+ }
return (found);
@@ -1040,7 +954,7 @@ past:
}
static void
-toend()
+toend(void)
{
if (whyles->w_end.type == TCSH_F_SEEK && whyles->w_end.f_seek == 0) {
search(TC_BREAK, 0, NULL);
@@ -1054,18 +968,16 @@ toend()
}
static void
-wpfree(wp)
- struct whyle *wp;
+wpfree(struct whyle *wp)
{
if (wp->w_fe0)
blkfree(wp->w_fe0);
- if (wp->w_fename)
- xfree((ptr_t) wp->w_fename);
- xfree((ptr_t) wp);
+ xfree(wp->w_fename);
+ xfree(wp);
}
void
-wfree()
+wfree(void)
{
struct Ain o;
struct whyle *nwp;
@@ -1074,13 +986,13 @@ wfree()
#endif
#ifdef FDEBUG
- static char foo[] = "IAFE";
+ static const char foo[] = "IAFE";
#endif /* FDEBUG */
btell(&o);
#ifdef FDEBUG
- xprintf("o->type %c o->a_seek %d o->f_seek %d\n",
+ xprintf("o->type %c o->a_seek %d o->f_seek %d\n",
foo[o.type + 1], o.a_seek, o.f_seek);
#endif /* FDEBUG */
@@ -1089,10 +1001,10 @@ wfree()
nwp = wp->w_next;
#ifdef FDEBUG
- xprintf("start->type %c start->a_seek %d start->f_seek %d\n",
+ xprintf("start->type %c start->a_seek %d start->f_seek %d\n",
foo[wp->w_start.type+1],
wp->w_start.a_seek, wp->w_start.f_seek);
- xprintf("end->type %c end->a_seek %d end->f_seek %d\n",
+ xprintf("end->type %c end->a_seek %d end->f_seek %d\n",
foo[wp->w_end.type + 1], wp->w_end.a_seek, wp->w_end.f_seek);
#endif /* FDEBUG */
@@ -1119,9 +1031,7 @@ wfree()
/*ARGSUSED*/
void
-doecho(v, c)
- Char **v;
- struct command *c;
+doecho(Char **v, struct command *c)
{
USE(c);
xecho(' ', v);
@@ -1129,9 +1039,7 @@ doecho(v, c)
/*ARGSUSED*/
void
-doglob(v, c)
- Char **v;
- struct command *c;
+doglob(Char **v, struct command *c)
{
USE(c);
xecho(0, v);
@@ -1139,21 +1047,11 @@ doglob(v, c)
}
static void
-xecho(sep, v)
- int sep;
- Char **v;
+xecho(int sep, Char **v)
{
- Char *cp;
+ Char *cp, **globbed = NULL;
int nonl = 0;
-#ifdef ECHO_STYLE
int echo_style = ECHO_STYLE;
-#else /* !ECHO_STYLE */
-# if SYSVREL > 0
- int echo_style = SYSV_ECHO;
-# else /* SYSVREL == 0 */
- int echo_style = BSD_ECHO;
-# endif /* SYSVREL */
-#endif /* ECHO_STYLE */
struct varent *vp;
if ((vp = adrof(STRecho_style)) != NULL && vp->vec != NULL &&
@@ -1168,25 +1066,20 @@ xecho(sep, v)
echo_style = NONE_ECHO;
}
- if (setintr)
-#ifdef BSDSIGS
- (void) sigsetmask(sigblock((sigmask_t) 0) & ~sigmask(SIGINT));
-#else /* !BSDSIGS */
- (void) sigrelse (SIGINT);
-#endif /* BSDSIGS */
v++;
if (*v == 0)
goto done;
- gflag = 0, tglob(v);
- if (gflag) {
- v = globall(v);
- if (v == 0)
- stderror(ERR_NAME | ERR_NOMATCH);
- }
- else {
- v = gargv = saveblk(v);
- trim(v);
- }
+ if (setintr) {
+ int old_pintr_disabled;
+ pintr_push_enable(&old_pintr_disabled);
+ v = glob_all_or_error(v);
+ cleanup_until(&old_pintr_disabled);
+ } else {
+ v = glob_all_or_error(v);
+ }
+ globbed = v;
+ if (globbed != NULL)
+ cleanup_push(globbed, blk_cleanup);
if ((echo_style & BSD_ECHO) != 0 && sep == ' ' && *v && eq(*v, STRmn))
nonl++, v++;
@@ -1194,6 +1087,12 @@ xecho(sep, v)
while ((cp = *v++) != 0) {
Char c;
+ if (setintr) {
+ int old_pintr_disabled;
+
+ pintr_push_enable(&old_pintr_disabled);
+ cleanup_until(&old_pintr_disabled);
+ }
while ((c = *cp++) != 0) {
if ((echo_style & SYSV_ECHO) != 0 && c == '\\') {
switch (c = *cp++) {
@@ -1210,7 +1109,7 @@ xecho(sep, v)
#if 0 /* Windows does not understand \e */
c = '\e';
#else
- c = '\033';
+ c = CTL_ESC('\033');
#endif
break;
case 'f':
@@ -1260,20 +1159,13 @@ done:
xputchar('\n');
else
flush();
- if (setintr)
-#ifdef BSDSIGS
- (void) sigblock(sigmask(SIGINT));
-#else /* !BSDSIGS */
- (void) sighold(SIGINT);
-#endif /* BSDSIGS */
- if (gargv)
- blkfree(gargv), gargv = 0;
+ if (globbed != NULL)
+ cleanup_until(globbed);
}
/* check whether an environment variable should invoke 'set_locale()' */
static int
-islocale_var(var)
- Char *var;
+islocale_var(Char *var)
{
static Char *locale_vars[] = {
STRLANG, STRLC_ALL, STRLC_CTYPE, STRLC_NUMERIC,
@@ -1287,38 +1179,48 @@ islocale_var(var)
return 0;
}
+static void
+xlate_cr_cleanup(void *dummy)
+{
+ USE(dummy);
+ xlate_cr = 0;
+}
+
/*ARGSUSED*/
void
-doprintenv(v, c)
- Char **v;
- struct command *c;
+doprintenv(Char **v, struct command *c)
{
Char *e;
USE(c);
- if (setintr)
-#ifdef BSDSIGS
- (void) sigsetmask(sigblock((sigmask_t) 0) & ~sigmask(SIGINT));
-#else /* !BSDSIGS */
- (void) sigrelse (SIGINT);
-#endif /* BSDSIGS */
-
v++;
if (*v == 0) {
Char **ep;
xlate_cr = 1;
- for (ep = STR_environ; *ep; ep++)
+ cleanup_push(&xlate_cr, xlate_cr_cleanup);
+ for (ep = STR_environ; *ep; ep++) {
+ if (setintr) {
+ int old_pintr_disabled;
+
+ pintr_push_enable(&old_pintr_disabled);
+ cleanup_until(&old_pintr_disabled);
+ }
xprintf("%S\n", *ep);
- xlate_cr = 0;
+ }
+ cleanup_until(&xlate_cr);
}
else if ((e = tgetenv(*v)) != NULL) {
+ int old_output_raw;
+
+ old_output_raw = output_raw;
output_raw = 1;
+ cleanup_push(&old_output_raw, output_raw_restore);
xprintf("%S\n", e);
- output_raw = 0;
+ cleanup_until(&old_output_raw);
}
else
- set(STRstatus, Strsave(STR1), VAR_READWRITE);
+ setcopy(STRstatus, STR1, VAR_READWRITE);
}
/* from "Karl Berry." <karl%mote.umb.edu@relay.cs.net> -- for NeXT things
@@ -1326,9 +1228,7 @@ doprintenv(v, c)
/*ARGSUSED*/
void
-dosetenv(v, c)
- Char **v;
- struct command *c;
+dosetenv(Char **v, struct command *c)
{
Char *vp, *lp;
@@ -1349,18 +1249,20 @@ dosetenv(v, c)
if ((lp = *v++) == 0)
lp = STRNULL;
- tsetenv(vp, lp = globone(lp, G_APPEND));
+ lp = globone(lp, G_APPEND);
+ cleanup_push(lp, xfree);
+ tsetenv(vp, lp);
if (eq(vp, STRKPATH)) {
- importpath(lp);
+ importpath(lp);
dohash(NULL, NULL);
- xfree((ptr_t) lp);
+ cleanup_until(lp);
return;
}
#ifdef apollo
if (eq(vp, STRSYSTYPE)) {
dohash(NULL, NULL);
- xfree((ptr_t) lp);
+ cleanup_until(lp);
return;
}
#endif /* apollo */
@@ -1401,7 +1303,7 @@ dosetenv(v, c)
fix_strcoll_bug();
# endif /* STRCOLLBUG */
tw_cmd_free(); /* since the collation sequence has changed */
- for (k = 0200; k <= 0377 && !Isprint(k); k++)
+ for (k = 0200; k <= 0377 && !Isprint(CTL_ESC(k)); k++)
continue;
AsciiOnly = MB_CUR_MAX == 1 && k > 0377;
#else /* !NLS */
@@ -1411,7 +1313,7 @@ dosetenv(v, c)
ed_Init();
if (MapsAreInited && !NLSMapsAreInited)
ed_InitNLSMaps();
- xfree((ptr_t) lp);
+ cleanup_until(lp);
return;
}
@@ -1427,24 +1329,27 @@ dosetenv(v, c)
MapsAreInited = 0;
NLSMapsAreInited = 0;
ed_InitMaps();
- xfree((ptr_t) lp);
+ cleanup_until(lp);
return;
}
#ifdef WINNT_NATIVE
if (eq(vp, STRtcshlang)) {
nlsinit();
- xfree((ptr_t) lp);
+ cleanup_until(lp);
return;
}
#endif /* WINNT_NATIVE */
if (eq(vp, STRKTERM)) {
char *t;
- set(STRterm, quote(lp), VAR_READWRITE); /* lp memory used here */
+
+ setv(STRterm, quote(lp), VAR_READWRITE); /* lp memory used here */
+ cleanup_ignore(lp);
+ cleanup_until(lp);
t = short2str(lp);
if (noediting && strcmp(t, "unknown") != 0 && strcmp(t,"dumb") != 0) {
editing = 1;
noediting = 0;
- set(STRedit, Strsave(STRNULL), VAR_READWRITE);
+ setNS(STRedit);
}
GotTermCaps = 0;
ed_Init();
@@ -1452,11 +1357,17 @@ dosetenv(v, c)
}
if (eq(vp, STRKHOME)) {
+ Char *canon;
/*
* convert to canonical pathname (possibly resolving symlinks)
*/
- lp = dcanon(lp, lp);
- set(STRhome, quote(lp), VAR_READWRITE); /* cp memory used here */
+ canon = dcanon(lp, lp);
+ cleanup_ignore(lp);
+ cleanup_until(lp);
+ cleanup_push(canon, xfree);
+ setv(STRhome, quote(canon), VAR_READWRITE); /* lp memory used here */
+ cleanup_ignore(canon);
+ cleanup_until(canon);
/* fix directory stack for new tilde home */
dtilde();
@@ -1464,24 +1375,30 @@ dosetenv(v, c)
}
if (eq(vp, STRKSHLVL)) {
- /* lp memory used here */
- set(STRshlvl, quote(lp), VAR_READWRITE);
+ setv(STRshlvl, quote(lp), VAR_READWRITE); /* lp memory used here */
+ cleanup_ignore(lp);
+ cleanup_until(lp);
return;
}
if (eq(vp, STRKUSER)) {
- set(STRuser, quote(lp), VAR_READWRITE); /* lp memory used here */
+ setv(STRuser, quote(lp), VAR_READWRITE); /* lp memory used here */
+ cleanup_ignore(lp);
+ cleanup_until(lp);
return;
}
if (eq(vp, STRKGROUP)) {
- set(STRgroup, quote(lp), VAR_READWRITE); /* lp memory used here */
+ setv(STRgroup, quote(lp), VAR_READWRITE); /* lp memory used here */
+ cleanup_ignore(lp);
+ cleanup_until(lp);
return;
}
#ifdef COLOR_LS_F
if (eq(vp, STRLS_COLORS)) {
parseLS_COLORS(lp);
+ cleanup_until(lp);
return;
}
#endif /* COLOR_LS_F */
@@ -1492,7 +1409,7 @@ dosetenv(v, c)
*/
if ((eq(lp, STRNULL) && (eq(vp, STRLINES) || eq(vp, STRCOLUMNS))) ||
eq(vp, STRTERMCAP)) {
- xfree((ptr_t) lp);
+ cleanup_until(lp);
check_window_size(1);
return;
}
@@ -1504,27 +1421,22 @@ dosetenv(v, c)
#if 0
GotTermCaps = 0;
#endif
- xfree((ptr_t) lp);
+ cleanup_until(lp);
ed_Init();
return;
}
#endif /* SIG_WINDOW */
- xfree((ptr_t) lp);
+ cleanup_until(lp);
}
/*ARGSUSED*/
void
-dounsetenv(v, c)
- Char **v;
- struct command *c;
+dounsetenv(Char **v, struct command *c)
{
- Char **ep, *p, *n;
+ Char **ep, *p, *n, *name;
int i, maxi;
- static Char *name = NULL;
USE(c);
- if (name)
- xfree((ptr_t) name);
/*
* Find the longest environment variable
*/
@@ -1535,7 +1447,8 @@ dounsetenv(v, c)
maxi = i;
}
- name = (Char *) xmalloc((size_t) ((maxi + 1) * sizeof(Char)));
+ name = xmalloc((maxi + 1) * sizeof(Char));
+ cleanup_push(name, xfree);
while (++v && *v)
for (maxi = 1; maxi;)
@@ -1577,7 +1490,7 @@ dounsetenv(v, c)
(void) setlocale(LC_COLLATE, "");
# endif
# ifdef LC_CTYPE
- (void) setlocale(LC_CTYPE, ""); /* for iscntrl */
+ (void) setlocale(LC_CTYPE, ""); /* for iscntrl */
# endif /* LC_CTYPE */
# ifdef NLS_CATALOGS
# ifdef LC_MESSAGES
@@ -1593,7 +1506,7 @@ dounsetenv(v, c)
fix_strcoll_bug();
# endif /* STRCOLLBUG */
tw_cmd_free();/* since the collation sequence has changed */
- for (k = 0200; k <= 0377 && !Isprint(k); k++)
+ for (k = 0200; k <= 0377 && !Isprint(CTL_ESC(k)); k++)
continue;
AsciiOnly = MB_CUR_MAX == 1 && k > 0377;
#else /* !NLS */
@@ -1627,12 +1540,11 @@ dounsetenv(v, c)
*/
break;
}
- xfree((ptr_t) name); name = NULL;
+ cleanup_until(name);
}
void
-tsetenv(name, val)
- const Char *name, *val;
+tsetenv(const Char *name, const Char *val)
{
#ifdef SETENV_IN_LIB
/*
@@ -1642,13 +1554,13 @@ tsetenv(name, val)
* it is not needed anymore.
*/
#undef setenv
- char nameBuf[BUFSIZE];
- char *cname = short2str(name);
+ char *cname;
- if (cname == NULL)
+ if (name == NULL)
return;
- (void) strcpy(nameBuf, cname);
- setenv(nameBuf, short2str(val), 1);
+ cname = strsave(short2str(name));
+ setenv(cname, short2str(val), 1);
+ xfree(cname);
#else /* !SETENV_IN_LIB */
Char **ep = STR_environ;
const Char *ccp;
@@ -1657,7 +1569,7 @@ tsetenv(name, val)
Char **oep = ep;
#ifdef WINNT_NATIVE
- nt_set_env(name,val);
+ nt_set_env(name,val);
#endif /* WINNT_NATIVE */
for (; *ep; ep++) {
#ifdef WINNT_NATIVE
@@ -1670,27 +1582,26 @@ tsetenv(name, val)
if (*ccp != 0 || *dp != '=')
continue;
cp = Strspl(STRequal, val);
- xfree((ptr_t) * ep);
+ xfree(*ep);
*ep = strip(Strspl(name, cp));
- xfree((ptr_t) cp);
+ xfree(cp);
blkfree((Char **) environ);
environ = short2blk(STR_environ);
return;
}
cp = Strspl(name, STRequal);
blk[0] = strip(Strspl(cp, val));
- xfree((ptr_t) cp);
+ xfree(cp);
blk[1] = 0;
STR_environ = blkspl(STR_environ, blk);
blkfree((Char **) environ);
environ = short2blk(STR_environ);
- xfree((ptr_t) oep);
+ xfree(oep);
#endif /* SETENV_IN_LIB */
}
void
-Unsetenv(name)
- Char *name;
+Unsetenv(Char *name)
{
Char **ep = STR_environ;
Char *cp, *dp;
@@ -1710,17 +1621,15 @@ Unsetenv(name)
blkfree((Char **) environ);
environ = short2blk(STR_environ);
*ep = cp;
- xfree((ptr_t) cp);
- xfree((ptr_t) oep);
+ xfree(cp);
+ xfree(oep);
return;
}
}
/*ARGSUSED*/
void
-doumask(v, c)
- Char **v;
- struct command *c;
+doumask(Char **v, struct command *c)
{
Char *cp = v[1];
int i;
@@ -1890,16 +1799,15 @@ struct limits limits[] =
{ -1, NULL, 0, NULL }
};
-static struct limits *findlim __P((Char *));
-static RLIM_TYPE getval __P((struct limits *, Char **));
-static void limtail __P((Char *, const char *));
-static void plim __P((struct limits *, int));
-static int setlim __P((struct limits *, int, RLIM_TYPE));
+static struct limits *findlim (Char *);
+static RLIM_TYPE getval (struct limits *, Char **);
+static void limtail (Char *, const char *);
+static void plim (struct limits *, int);
+static int setlim (struct limits *, int, RLIM_TYPE);
#ifdef convex
static RLIM_TYPE
-restrict_limit(value)
- double value;
+restrict_limit(double value)
{
/*
* is f too large to cope with? return the maximum or minimum int
@@ -1917,12 +1825,11 @@ restrict_limit(value)
static struct limits *
-findlim(cp)
- Char *cp;
+findlim(Char *cp)
{
struct limits *lp, *res;
- res = (struct limits *) NULL;
+ res = NULL;
for (lp = limits; lp->limconst >= 0; lp++)
if (prefix(cp, str2short(lp->limname))) {
if (res)
@@ -1938,9 +1845,7 @@ findlim(cp)
/*ARGSUSED*/
void
-dolimit(v, c)
- Char **v;
- struct command *c;
+dolimit(Char **v, struct command *c)
{
struct limits *lp;
RLIM_TYPE limit;
@@ -1968,9 +1873,7 @@ dolimit(v, c)
}
static RLIM_TYPE
-getval(lp, v)
- struct limits *lp;
- Char **v;
+getval(struct limits *lp, Char **v)
{
float f;
Char *cp = *v++;
@@ -2068,9 +1971,7 @@ badscal:
}
static void
-limtail(cp, str)
- Char *cp;
- const char *str;
+limtail(Char *cp, const char *str)
{
const char *sp;
@@ -2084,9 +1985,7 @@ limtail(cp, str)
/*ARGSUSED*/
static void
-plim(lp, hard)
- struct limits *lp;
- int hard;
+plim(struct limits *lp, int hard)
{
# ifdef BSDLIMIT
struct rlimit rlim;
@@ -2131,7 +2030,7 @@ plim(lp, hard)
# endif
# ifdef RLIMIT_CPU
if (lp->limconst == RLIMIT_CPU)
- psecs((long) limit);
+ psecs(limit);
else
# endif /* RLIMIT_CPU */
xprintf("%ld %s", (long) (limit / xdiv), lp->limscale);
@@ -2140,9 +2039,7 @@ plim(lp, hard)
/*ARGSUSED*/
void
-dounlimit(v, c)
- Char **v;
- struct command *c;
+dounlimit(Char **v, struct command *c)
{
struct limits *lp;
int lerr = 0;
@@ -2182,10 +2079,7 @@ dounlimit(v, c)
}
static int
-setlim(lp, hard, limit)
- struct limits *lp;
- int hard;
- RLIM_TYPE limit;
+setlim(struct limits *lp, int hard, RLIM_TYPE limit)
{
# ifdef BSDLIMIT
struct rlimit rlim;
@@ -2223,11 +2117,12 @@ setlim(lp, hard, limit)
err = errno;
op = strsave(limit == RLIM_INFINITY ? CGETS(15, 2, "remove") :
CGETS(15, 3, "set"));
+ cleanup_push(op, xfree);
type = strsave(hard ? CGETS(15, 4, " hard") : "");
+ cleanup_push(type, xfree);
xprintf(CGETS(15, 1, "%s: %s: Can't %s%s limit (%s)\n"), bname,
lp->limname, op, type, strerror(err));
- xfree(type);
- xfree(op);
+ cleanup_until(op);
return (-1);
}
return (0);
@@ -2237,14 +2132,11 @@ setlim(lp, hard, limit)
/*ARGSUSED*/
void
-dosuspend(v, c)
- Char **v;
- struct command *c;
+dosuspend(Char **v, struct command *c)
{
#ifdef BSDJOBS
int ctpgrp;
-
- signalfun_t old;
+ struct sigaction old;
#endif /* BSDJOBS */
USE(c);
@@ -2255,10 +2147,11 @@ dosuspend(v, c)
untty();
#ifdef BSDJOBS
- old = signal(SIGTSTP, SIG_DFL);
+ sigaction(SIGTSTP, NULL, &old);
+ signal(SIGTSTP, SIG_DFL);
(void) kill(0, SIGTSTP);
/* the shell stops here */
- (void) signal(SIGTSTP, old);
+ sigaction(SIGTSTP, &old, NULL);
#else /* !BSDJOBS */
stderror(ERR_JOBCONTROL);
#endif /* BSDJOBS */
@@ -2270,9 +2163,10 @@ retry:
if (ctpgrp == -1)
stderror(ERR_SYSTEM, "tcgetpgrp", strerror(errno));
if (ctpgrp != opgrp) {
- old = signal(SIGTTIN, SIG_DFL);
+ sigaction(SIGTTIN, NULL, &old);
+ signal(SIGTTIN, SIG_DFL);
(void) kill(0, SIGTTIN);
- (void) signal(SIGTTIN, old);
+ sigaction(SIGTTIN, &old, NULL);
goto retry;
}
(void) setpgid(0, shpgrp);
@@ -2295,125 +2189,122 @@ retry:
* pgrp, with no way for the shell to get them going again. -IAN!
*/
-static Char **gv = NULL, **gav = NULL;
-
-/*ARGSUSED*/
-void
-doeval(v, c)
- Char **v;
- struct command *c;
+struct doeval_state
{
- Char **oevalvec;
- Char *oevalp;
- int odidfds;
+ Char **evalvec, *evalp;
+ int didfds;
#ifndef CLOSE_ON_EXEC
- int odidcch;
-#endif /* CLOSE_ON_EXEC */
- jmp_buf_t osetexit;
- int my_reenter;
- Char **savegv;
- int saveIN, saveOUT, saveDIAG;
- int oSHIN, oSHOUT, oSHDIAG;
+ int didcch;
+#endif
+ int saveIN, saveOUT, saveDIAG;
+ int SHIN, SHOUT, SHDIAG;
+};
- USE(c);
- oevalvec = evalvec;
- oevalp = evalp;
- odidfds = didfds;
+static void
+doeval_cleanup(void *xstate)
+{
+ struct doeval_state *state;
+
+ state = xstate;
+ evalvec = state->evalvec;
+ evalp = state->evalp;
+ doneinp = 0;
#ifndef CLOSE_ON_EXEC
- odidcch = didcch;
+ didcch = state->didcch;
#endif /* CLOSE_ON_EXEC */
- oSHIN = SHIN;
- oSHOUT = SHOUT;
- oSHDIAG = SHDIAG;
+ didfds = state->didfds;
+ xclose(SHIN);
+ xclose(SHOUT);
+ xclose(SHDIAG);
+ close_on_exec(SHIN = dmove(state->saveIN, state->SHIN), 1);
+ close_on_exec(SHOUT = dmove(state->saveOUT, state->SHOUT), 1);
+ close_on_exec(SHDIAG = dmove(state->saveDIAG, state->SHDIAG), 1);
+}
- savegv = gv;
- gav = v;
+/*ARGSUSED*/
+void
+doeval(Char **v, struct command *c)
+{
+ struct doeval_state state;
+ int gflag;
+ Char **gv;
- gav++;
- if (*gav == 0)
+ USE(c);
+ v++;
+ if (*v == 0)
return;
- gflag = 0, tglob(gav);
+ gflag = tglob(v);
if (gflag) {
- gv = gav = globall(gav);
- gargv = 0;
- if (gav == 0)
+ gv = v = globall(v, gflag);
+ if (v == 0)
stderror(ERR_NOMATCH);
- gav = copyblk(gav);
+ cleanup_push(gv, blk_cleanup);
+ v = copyblk(v);
}
else {
gv = NULL;
- gav = copyblk(gav);
- trim(gav);
- }
-
- (void)close_on_exec(saveIN = dcopy(SHIN, -1), 1);
- (void)close_on_exec(saveOUT = dcopy(SHOUT, -1), 1);
- (void)close_on_exec(saveDIAG = dcopy(SHDIAG, -1), 1);
-
- getexit(osetexit);
-
- /* PWP: setjmp/longjmp bugfix for optimizing compilers */
-#ifdef cray
- my_reenter = 1; /* assume non-zero return val */
- if (setexit() == 0) {
- my_reenter = 0; /* Oh well, we were wrong */
-#else /* !cray */
- if ((my_reenter = setexit()) == 0) {
-#endif /* cray */
- evalvec = gav;
- evalp = 0;
- (void)close_on_exec(SHIN = dcopy(0, -1), 1);
- (void)close_on_exec(SHOUT = dcopy(1, -1), 1);
- (void)close_on_exec(SHDIAG = dcopy(2, -1), 1);
+ v = copyblk(v);
+ trim(v);
+ }
+
+ state.evalvec = evalvec;
+ state.evalp = evalp;
+ state.didfds = didfds;
#ifndef CLOSE_ON_EXEC
- didcch = 0;
+ state.didcch = didcch;
#endif /* CLOSE_ON_EXEC */
- didfds = 0;
- process(0);
- }
+ state.SHIN = SHIN;
+ state.SHOUT = SHOUT;
+ state.SHDIAG = SHDIAG;
- evalvec = oevalvec;
- evalp = oevalp;
- doneinp = 0;
+ (void)close_on_exec(state.saveIN = dcopy(SHIN, -1), 1);
+ (void)close_on_exec(state.saveOUT = dcopy(SHOUT, -1), 1);
+ (void)close_on_exec(state.saveDIAG = dcopy(SHDIAG, -1), 1);
+
+ cleanup_push(&state, doeval_cleanup);
+
+ evalvec = v;
+ evalp = 0;
+ (void)close_on_exec(SHIN = dcopy(0, -1), 1);
+ (void)close_on_exec(SHOUT = dcopy(1, -1), 1);
+ (void)close_on_exec(SHDIAG = dcopy(2, -1), 1);
#ifndef CLOSE_ON_EXEC
- didcch = odidcch;
+ didcch = 0;
#endif /* CLOSE_ON_EXEC */
- didfds = odidfds;
- (void) close(SHIN);
- (void) close(SHOUT);
- (void) close(SHDIAG);
- (void)close_on_exec (SHIN = dmove(saveIN, oSHIN), 1);
- (void)close_on_exec (SHOUT = dmove(saveOUT, oSHOUT), 1);
- (void)close_on_exec (SHDIAG = dmove(saveDIAG, oSHDIAG), 1);
+ didfds = 0;
+ process(0);
- if (gv)
- blkfree(gv);
+ cleanup_until(&state);
- gv = savegv;
- resexit(osetexit);
- if (my_reenter)
- stderror(ERR_SILENT);
+ if (gv)
+ cleanup_until(gv);
}
/*************************************************************************/
/* print list of builtin commands */
+static void
+lbuffed_cleanup (void *dummy)
+{
+ USE(dummy);
+ lbuffed = 1;
+}
+
/*ARGSUSED*/
void
-dobuiltins(v, c)
-Char **v;
-struct command *c;
+dobuiltins(Char **v, struct command *c)
{
/* would use print_by_column() in tw.parse.c but that assumes
* we have an array of Char * to pass.. (sg)
*/
- struct biltins *b;
+ const struct biltins *b;
int row, col, columns, rows;
unsigned int w, maxwidth;
USE(c);
USE(v);
lbuffed = 0; /* turn off line buffering */
+ cleanup_push(&lbuffed, lbuffed_cleanup);
/* find widest string */
for (maxwidth = 0, b = bfunc; b < &bfunc[nbfunc]; ++b)
@@ -2450,30 +2341,37 @@ struct command *c;
xputchar('\n');
#endif /* WINNT_NATIVE */
- lbuffed = 1; /* turn back on line buffering */
+ cleanup_until(&lbuffed); /* turn back on line buffering */
flush();
}
#ifdef NLS_CATALOGS
-#ifdef HAVE_ICONV
char *
-iconv_catgets(ctd, set_id, msg_id, s)
-nl_catd ctd;
-int set_id, msg_id;
-const char *s;
+xcatgets(nl_catd ctd, int set_id, int msg_id, const char *s)
+{
+ char *res;
+
+ errno = 0;
+ while ((res = catgets(ctd, set_id, msg_id, s)) == s && errno == EINTR) {
+ handle_pending_signals();
+ errno = 0;
+ }
+ return res;
+}
+
+
+# if defined(HAVE_ICONV) && defined(HAVE_NL_LANGINFO)
+char *
+iconv_catgets(nl_catd ctd, int set_id, int msg_id, const char *s)
{
static char *buf = NULL;
static size_t buf_size = 0;
char *orig, *dest, *p;
-#ifdef __NetBSD__
- const char *src;
-#else
- char *src;
-#endif
+ ICONV_CONST char *src;
size_t src_size, dest_size;
- orig = catgets(ctd, set_id, msg_id, s);
+ orig = xcatgets(ctd, set_id, msg_id, s);
if (catgets_iconv == (iconv_t)-1 || orig == s)
return orig;
src = orig;
@@ -2501,24 +2399,27 @@ const char *s;
}
return buf;
}
-#endif
-#endif
+# endif /* HAVE_ICONV && HAVE_NL_LANGINFO */
+#endif /* NLS_CATALOGS */
void
-nlsinit()
+nlsinit(void)
{
#ifdef NLS_CATALOGS
- char catalog[ 256 ] = { 't', 'c', 's', 'h', '\0' };
+ static const char default_catalog[] = "tcsh";
+
+ char *catalog = (char *)(intptr_t)default_catalog;
if (adrof(STRcatalog) != NULL)
- xsnprintf((char *)catalog, sizeof(catalog), "tcsh.%s",
- short2str(varval(STRcatalog)));
+ catalog = xasprintf("tcsh.%s", short2str(varval(STRcatalog)));
catd = catopen(catalog, MCLoadBySet);
-#ifdef HAVE_ICONV
- /* catgets (), not CGETS, the charset name should be in ASCII anyway. */
+ if (catalog != default_catalog)
+ xfree(catalog);
+#if defined(HAVE_ICONV) && defined(HAVE_NL_LANGINFO)
+ /* xcatgets (), not CGETS, the charset name should be in ASCII anyway. */
catgets_iconv = iconv_open (nl_langinfo (CODESET),
- catgets(catd, 255, 1, "ASCII"));
-#endif /* HAVE_ICONV */
+ xcatgets(catd, 255, 1, "ASCII"));
+#endif /* HAVE_ICONV && HAVE_NL_LANGINFO */
#endif /* NLS_CATALOGS */
#ifdef WINNT_NATIVE
nls_dll_init();
@@ -2531,15 +2432,26 @@ nlsinit()
}
void
-nlsclose()
+nlsclose(void)
{
#ifdef NLS_CATALOGS
-#ifdef HAVE_ICONV
+#if defined(HAVE_ICONV) && defined(HAVE_NL_LANGINFO)
if (catgets_iconv != (iconv_t)-1) {
iconv_close(catgets_iconv);
catgets_iconv = (iconv_t)-1;
}
-#endif /* HAVE_ICONV */
- catclose(catd);
+#endif /* HAVE_ICONV && HAVE_NL_LANGINFO */
+ if (catd != (nl_catd)-1) {
+ /*
+ * catclose can call other functions which can call longjmp
+ * making us re-enter this code. Prevent infinite recursion
+ * by resetting catd. Problem reported and solved by:
+ * Gerhard Niklasch
+ */
+ nl_catd oldcatd = catd;
+ catd = (nl_catd)-1;
+ while (catclose(oldcatd) == -1 && errno == EINTR)
+ handle_pending_signals();
+ }
#endif /* NLS_CATALOGS */
}
diff --git a/contrib/tcsh/sh.glob.c b/contrib/tcsh/sh.glob.c
index 2002ae6..a7215f3 100644
--- a/contrib/tcsh/sh.glob.c
+++ b/contrib/tcsh/sh.glob.c
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/sh.glob.c,v 3.62 2004/12/25 21:15:07 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/sh.glob.c,v 3.74 2006/10/14 17:57:21 christos Exp $ */
/*
* sh.glob.c: Regular expression expansion
*/
@@ -32,16 +32,13 @@
*/
#include "sh.h"
-RCSID("$Id: sh.glob.c,v 3.62 2004/12/25 21:15:07 christos Exp $")
+RCSID("$tcsh: sh.glob.c,v 3.74 2006/10/14 17:57:21 christos Exp $")
#include "tc.h"
#include "tw.h"
#include "glob.h"
-static int noglob;
-static int pargsiz, gargsiz;
-
/*
* Values for gflag
*/
@@ -50,7 +47,6 @@ static int pargsiz, gargsiz;
#define G_CSH 2 /* string contains ~`{ characters */
#define GLOBSPACE 100 /* Alloc increment */
-#define LONGBSIZE 10240 /* Backquote expansion buffer size */
#define LBRC '{'
@@ -59,11 +55,6 @@ static int pargsiz, gargsiz;
#define RBRK ']'
#define EOS '\0'
-Char **gargv = NULL;
-int gargc = 0;
-Char **pargv = NULL;
-static int pargc = 0;
-
/*
* globbing is now done in two stages. In the first pass we expand
* csh globbing idioms ~`{ and then we proceed doing the normal
@@ -73,64 +64,53 @@ static int pargc = 0;
* handled in glob() which is part of the 4.4BSD libc.
*
*/
-static Char *globtilde __P((Char **, Char *));
-static Char *handleone __P((Char *, Char **, int));
-static Char **libglob __P((Char **));
-static Char **globexpand __P((Char **));
-static int globbrace __P((Char *, Char *, Char ***));
-static void expbrace __P((Char ***, Char ***, int));
-static void pword __P((int));
-static void psave __P((Char));
-static void backeval __P((Char *, int));
-
+static Char *globtilde (Char *);
+static Char *handleone (Char *, Char **, int);
+static Char **libglob (Char **);
+static Char **globexpand (Char **, int);
+static int globbrace (const Char *, Char ***);
+static void expbrace (Char ***, Char ***, int);
+static void pword (struct blk_buf *, struct Strbuf *);
+static void backeval (struct blk_buf *, struct Strbuf *, Char *,
+ int);
static Char *
-globtilde(nv, s)
- Char **nv, *s;
+globtilde(Char *s)
{
- Char gbuf[BUFSIZE], *gstart, *b, *u, *e;
-#ifdef apollo
- int slash;
-#endif
+ Char *name, *u, *home, *res;
- gstart = gbuf;
- *gstart++ = *s++;
u = s;
- for (b = gstart, e = &gbuf[BUFSIZE - 1];
- *s && *s != '/' && *s != ':' && b < e;
- *b++ = *s++)
+ for (s++; *s && *s != '/' && *s != ':'; s++)
continue;
- *b = EOS;
- if (gethdir(gstart)) {
- if (adrof(STRnonomatch))
- return (--u);
- blkfree(nv);
- if (*gstart)
- stderror(ERR_UNKUSER, short2str(gstart));
+ name = Strnsave(u + 1, s - (u + 1));
+ cleanup_push(name, xfree);
+ home = gethdir(name);
+ if (home == NULL) {
+ if (adrof(STRnonomatch)) {
+ cleanup_until(name);
+ return u;
+ }
+ if (*name)
+ stderror(ERR_UNKUSER, short2str(name));
else
stderror(ERR_NOHOME);
}
- b = &gstart[Strlen(gstart)];
-#ifdef apollo
- slash = gstart[0] == '/' && gstart[1] == '\0';
-#endif
- while (*s)
- *b++ = *s++;
- *b = EOS;
- --u;
- xfree((ptr_t) u);
-#ifdef apollo
- if (slash && gstart[1] == '/')
- gstart++;
-#endif
- return (Strsave(gstart));
+ cleanup_until(name);
+ if (home[0] == '/' && home[1] == '\0' && s[0] == '/')
+ res = Strsave(s);
+ else
+ res = Strspl(home, s);
+ xfree(home);
+ xfree(u);
+ return res;
}
+/* Returns a newly allocated string, old or NULL */
Char *
-globequal(new, old)
- Char *new, *old;
+globequal(Char *old)
{
int dig;
- Char *b, *d;
+ const Char *dir;
+ Char *b;
/*
* kfk - 17 Jan 1984 - stack hack allows user to get at arbitrary dir names
@@ -138,6 +118,11 @@ globequal(new, old)
*/
if (old[1] == '-' && (old[2] == '\0' || old[2] == '/')) {
/* =- */
+ const Char *olddir = varval (STRowd);
+
+ if (olddir && *olddir &&
+ !dcwd->di_next->di_name && !dcwd->di_prev->di_name)
+ return Strspl(olddir, &old[2]);
dig = -1;
b = &old[2];
}
@@ -154,35 +139,25 @@ globequal(new, old)
/* =foobar */
return old;
- if (!getstakd(new, dig))
+ dir = getstakd(dig);
+ if (dir == NULL)
return NULL;
-
- /* Copy the rest of the string */
- for (d = &new[Strlen(new)];
- d < &new[BUFSIZE - 1] && (*d++ = *b++) != '\0';)
- continue;
- *d = '\0';
-
- return new;
+ return Strspl(dir, b);
}
static int
-globbrace(s, p, bl)
- Char *s, *p, ***bl;
+globbrace(const Char *s, Char ***bl)
{
- int i, len;
- Char *pm, *pe, *lm, *pl;
- Char **nv, **vl;
- Char gbuf[BUFSIZE];
- int size = GLOBSPACE;
-
- nv = vl = (Char **) xmalloc((size_t) (sizeof(Char *) * size));
- *vl = NULL;
+ struct Strbuf gbuf = Strbuf_INIT;
+ struct blk_buf bb = BLK_BUF_INIT;
+ int i;
+ const Char *p, *pm, *pe, *pl;
+ size_t prefix_len;
- len = 0;
/* copy part up to the brace */
- for (lm = gbuf, p = s; *p != LBRC; *lm++ = *p++)
- continue;
+ for (p = s; *p != LBRC; p++)
+ ;
+ prefix_len = p - s;
/* check for balanced braces */
for (i = 0, pe = ++p; *pe; pe++)
@@ -190,10 +165,8 @@ globbrace(s, p, bl)
/* Ignore everything between [] */
for (++pe; *pe != RBRK && *pe != EOS; pe++)
continue;
- if (*pe == EOS) {
- blkfree(nv);
+ if (*pe == EOS)
return (-RBRK);
- }
}
else if (*pe == LBRC)
i++;
@@ -203,10 +176,10 @@ globbrace(s, p, bl)
i--;
}
- if (i != 0 || *pe == '\0') {
- blkfree(nv);
+ if (i != 0 || *pe == '\0')
return (-RBRC);
- }
+
+ Strbuf_appendn(&gbuf, s, prefix_len);
for (i = 0, pl = pm = p; pm <= pe; pm++)
switch (*pm) {
@@ -214,8 +187,8 @@ globbrace(s, p, bl)
for (++pm; *pm != RBRK && *pm != EOS; pm++)
continue;
if (*pm == EOS) {
- *vl = NULL;
- blkfree(nv);
+ bb_cleanup(&bb);
+ xfree(gbuf.s);
return (-RBRK);
}
break;
@@ -232,36 +205,25 @@ globbrace(s, p, bl)
if (i && *pm == ',')
break;
else {
- Char savec = *pm;
-
- *pm = EOS;
- (void) Strcpy(lm, pl);
- (void) Strcat(gbuf, pe + 1);
- *pm = savec;
- *vl++ = Strsave(gbuf);
- len++;
+ gbuf.len = prefix_len;
+ Strbuf_appendn(&gbuf, pl, pm - pl);
+ Strbuf_append(&gbuf, pe + 1);
+ Strbuf_terminate(&gbuf);
+ bb_append(&bb, Strsave(gbuf.s));
pl = pm + 1;
- if (vl == &nv[size]) {
- size += GLOBSPACE;
- nv = (Char **) xrealloc((ptr_t) nv,
- (size_t) (size * sizeof(Char *)));
- vl = &nv[size - GLOBSPACE];
- }
}
break;
default:
break;
}
- *vl = NULL;
- *bl = nv;
- return (len);
+ *bl = bb_finish(&bb);
+ xfree(gbuf.s);
+ return bb.len;
}
static void
-expbrace(nvp, elp, size)
- Char ***nvp, ***elp;
- int size;
+expbrace(Char ***nvp, Char ***elp, int size)
{
Char **vl, **el, **nv, *s;
@@ -269,38 +231,34 @@ expbrace(nvp, elp, size)
if (elp != NULL)
el = *elp;
else
- for (el = vl; *el; el++)
- continue;
+ el = vl + blklen(vl);
for (s = *vl; s; s = *++vl) {
- Char *b;
Char **vp, **bp;
/* leave {} untouched for find */
if (s[0] == '{' && (s[1] == '\0' || (s[1] == '}' && s[2] == '\0')))
continue;
- if ((b = Strchr(s, '{')) != NULL) {
- Char **bl;
+ if (Strchr(s, '{') != NULL) {
+ Char **bl = NULL;
int len;
- if ((len = globbrace(s, b, &bl)) < 0) {
- xfree((ptr_t) nv);
+ if ((len = globbrace(s, &bl)) < 0)
stderror(ERR_MISSING, -len);
- }
- xfree((ptr_t) s);
+ xfree(s);
if (len == 1) {
*vl-- = *bl;
- xfree((ptr_t) bl);
+ xfree(bl);
continue;
}
if (&el[len] >= &nv[size]) {
- int l, e;
- l = (int) (&el[len] - &nv[size]);
+ size_t l, e;
+ l = &el[len] - &nv[size];
size += GLOBSPACE > l ? GLOBSPACE : l;
- l = (int) (vl - nv);
- e = (int) (el - nv);
- nv = (Char **) xrealloc((ptr_t) nv,
- (size_t) (size * sizeof(Char *)));
+ l = vl - nv;
+ e = el - nv;
+ nv = xrealloc(nv, size * sizeof(Char *));
+ *nvp = nv; /* To keep cleanups working */
vl = nv + l;
el = nv + e;
}
@@ -325,26 +283,26 @@ expbrace(nvp, elp, size)
vp++;
for (bp = bl + 1; *bp; *vp++ = *bp++)
continue;
- xfree((ptr_t) bl);
+ xfree(bl);
}
}
if (elp != NULL)
*elp = el;
- *nvp = nv;
}
static Char **
-globexpand(v)
- Char **v;
+globexpand(Char **v, int noglob)
{
Char *s;
- Char **nv, **vl, **el;
+ Char ***fnv, **vl, **el;
int size = GLOBSPACE;
- nv = vl = (Char **) xmalloc((size_t) (sizeof(Char *) * size));
+ fnv = xmalloc(sizeof(Char ***));
+ *fnv = vl = xmalloc(sizeof(Char *) * size);
*vl = NULL;
+ cleanup_push(fnv, blk_indirect_cleanup);
/*
* Step 1: expand backquotes.
@@ -352,70 +310,65 @@ globexpand(v)
while ((s = *v++) != '\0') {
if (Strchr(s, '`')) {
int i;
+ Char **expanded;
- (void) dobackp(s, 0);
- for (i = 0; i < pargc; i++) {
- *vl++ = pargv[i];
- if (vl == &nv[size]) {
+ expanded = dobackp(s, 0);
+ for (i = 0; expanded[i] != NULL; i++) {
+ *vl++ = expanded[i];
+ if (vl == &(*fnv)[size]) {
size += GLOBSPACE;
- nv = (Char **) xrealloc((ptr_t) nv,
- (size_t) (size * sizeof(Char *)));
- vl = &nv[size - GLOBSPACE];
+ *fnv = xrealloc(*fnv, size * sizeof(Char *));
+ vl = &(*fnv)[size - GLOBSPACE];
}
}
- xfree((ptr_t) pargv);
- pargv = NULL;
+ xfree(expanded);
}
else {
*vl++ = Strsave(s);
- if (vl == &nv[size]) {
+ if (vl == &(*fnv)[size]) {
size += GLOBSPACE;
- nv = (Char **) xrealloc((ptr_t) nv,
- (size_t) (size * sizeof(Char *)));
- vl = &nv[size - GLOBSPACE];
+ *fnv = xrealloc(*fnv, size * sizeof(Char *));
+ vl = &(*fnv)[size - GLOBSPACE];
}
}
+ *vl = NULL;
}
- *vl = NULL;
if (noglob)
- return (nv);
+ goto done;
/*
* Step 2: expand braces
*/
el = vl;
- expbrace(&nv, &el, size);
+ expbrace(fnv, &el, size);
/*
* Step 3: expand ~ =
*/
- vl = nv;
+ vl = *fnv;
for (s = *vl; s; s = *++vl)
switch (*s) {
- Char gp[BUFSIZE], *ns;
+ Char *ns;
case '~':
- *vl = globtilde(nv, s);
+ *vl = globtilde(s);
break;
case '=':
- if ((ns = globequal(gp, s)) == NULL) {
- if (!adrof(STRnonomatch)) {
- /* Error */
- blkfree(nv);
- stderror(ERR_DEEP);
- }
+ if ((ns = globequal(s)) == NULL) {
+ if (!adrof(STRnonomatch))
+ stderror(ERR_DEEP); /* Error */
}
if (ns && ns != s) {
/* Expansion succeeded */
- xfree((ptr_t) s);
- *vl = Strsave(gp);
+ xfree(s);
+ *vl = ns;
}
break;
default:
break;
}
- vl = nv;
+ vl = *fnv;
/*
* Step 4: expand .. if the variable symlinks==expand is set
@@ -423,22 +376,22 @@ globexpand(v)
if (symlinks == SYM_EXPAND) {
for (s = *vl; s; s = *++vl) {
*vl = dnormalize(s, 1);
- xfree((ptr_t) s);
+ xfree(s);
}
}
- vl = nv;
- return (vl);
+ done:
+ cleanup_ignore(fnv);
+ cleanup_until(fnv);
+ vl = *fnv;
+ xfree(fnv);
+ return vl;
}
static Char *
-handleone(str, vl, action)
- Char *str, **vl;
- int action;
+handleone(Char *str, Char **vl, int action)
{
-
- Char **vlp = vl;
- int chars;
+ size_t chars;
Char **t, *p, *strp;
switch (action) {
@@ -449,11 +402,10 @@ handleone(str, vl, action)
break;
case G_APPEND:
chars = 0;
- for (t = vlp; (p = *t++) != '\0'; chars++)
- while (*p++)
- chars++;
- str = (Char *)xmalloc((size_t)(chars * sizeof(Char)));
- for (t = vlp, strp = str; (p = *t++) != '\0'; chars++) {
+ for (t = vl; (p = *t++) != NULL; chars++)
+ chars += Strlen(p);
+ str = xmalloc(chars * sizeof(Char));
+ for (t = vl, strp = str; (p = *t++) != '\0'; chars++) {
while (*p)
*strp++ = *p++ & TRIM;
*strp++ = ' ';
@@ -462,7 +414,7 @@ handleone(str, vl, action)
blkfree(vl);
break;
case G_IGNORE:
- str = Strsave(strip(*vlp));
+ str = Strsave(strip(*vl));
blkfree(vl);
break;
default:
@@ -472,8 +424,7 @@ handleone(str, vl, action)
}
static Char **
-libglob(vl)
- Char **vl;
+libglob(Char **vl)
{
int gflgs = GLOB_QUOTE | GLOB_NOMAGIC | GLOB_ALTNOT;
glob_t globv;
@@ -519,20 +470,15 @@ libglob(vl)
}
Char *
-globone(str, action)
- Char *str;
- int action;
+globone(Char *str, int action)
{
-
Char *v[2], **vl, **vo;
- int gflg;
+ int gflg, noglob;
noglob = adrof(STRnoglob) != 0;
- gflag = 0;
v[0] = str;
v[1] = 0;
- tglob(v);
- gflg = gflag;
+ gflg = tglob(v);
if (gflg == G_NONE)
return (strip(Strsave(str)));
@@ -540,20 +486,12 @@ globone(str, action)
/*
* Expand back-quote, tilde and brace
*/
- vo = globexpand(v);
+ vo = globexpand(v, noglob);
if (noglob || (gflg & G_GLOB) == 0) {
- if (vo[0] == NULL) {
- xfree((ptr_t) vo);
- return (Strsave(STRNULL));
- }
- if (vo[1] != NULL)
- return (handleone(str, vo, action));
- else {
- str = strip(vo[0]);
- xfree((ptr_t) vo);
- return (str);
- }
+ vl = vo;
+ goto result;
}
+ cleanup_push(vo, blk_cleanup);
}
else if (noglob || (gflg & G_GLOB) == 0)
return (strip(Strsave(str)));
@@ -561,37 +499,38 @@ globone(str, action)
vo = v;
vl = libglob(vo);
- if ((gflg & G_CSH) && vl != vo)
- blkfree(vo);
+ if (gflg & G_CSH) {
+ if (vl != vo)
+ cleanup_until(vo);
+ else
+ cleanup_ignore(vo);
+ }
if (vl == NULL) {
setname(short2str(str));
stderror(ERR_NAME | ERR_NOMATCH);
}
+ result:
if (vl[0] == NULL) {
- xfree((ptr_t) vl);
+ xfree(vl);
return (Strsave(STRNULL));
}
if (vl[1])
return (handleone(str, vl, action));
else {
str = strip(*vl);
- xfree((ptr_t) vl);
+ xfree(vl);
return (str);
}
}
Char **
-globall(v)
- Char **v;
+globall(Char **v, int gflg)
{
Char **vl, **vo;
- int gflg = gflag;
+ int noglob;
- if (!v || !v[0]) {
- gargv = saveblk(v);
- gargc = blklen(gargv);
- return (gargv);
- }
+ if (!v || !v[0])
+ return saveblk(v);
noglob = adrof(STRnoglob) != 0;
@@ -599,35 +538,42 @@ globall(v)
/*
* Expand back-quote, tilde and brace
*/
- vl = vo = globexpand(v);
+ vl = vo = globexpand(v, noglob);
else
vl = vo = saveblk(v);
if (!noglob && (gflg & G_GLOB)) {
+ cleanup_push(vo, blk_cleanup);
vl = libglob(vo);
- if (vl != vo)
- blkfree(vo);
+ if (vl == vo)
+ cleanup_ignore(vo);
+ cleanup_until(vo);
}
else
trim(vl);
- gargc = vl ? blklen(vl) : 0;
- return (gargv = vl);
+ return vl;
}
-void
-ginit()
+Char **
+glob_all_or_error(Char **v)
{
- gargsiz = GLOBSPACE;
- gargv = (Char **) xmalloc((size_t) (sizeof(Char *) * gargsiz));
- gargv[0] = 0;
- gargc = 0;
+ int gflag;
+
+ gflag = tglob(v);
+ if (gflag) {
+ v = globall(v, gflag);
+ if (v == NULL)
+ stderror(ERR_NAME | ERR_NOMATCH);
+ } else {
+ v = saveblk(v);
+ trim(v);
+ }
+ return v;
}
void
-rscan(t, f)
- Char **t;
- void (*f) __P((Char));
+rscan(Char **t, void (*f) (Char))
{
Char *p;
@@ -637,8 +583,7 @@ rscan(t, f)
}
void
-trim(t)
- Char **t;
+trim(Char **t)
{
Char *p;
@@ -647,33 +592,28 @@ trim(t)
*p++ &= TRIM;
}
-void
-tglob(t)
- Char **t;
+int
+tglob(Char **t)
{
- Char *p, *c;
+ int gflag;
+ const Char *p;
+ gflag = 0;
while ((p = *t++) != '\0') {
if (*p == '~' || *p == '=')
gflag |= G_CSH;
else if (*p == '{' &&
(p[1] == '\0' || (p[1] == '}' && p[2] == '\0')))
continue;
- /*
- * The following line used to be *(c = p++), but hp broke their
- * optimizer in 9.01, so we break the assignment into two pieces
- * The careful reader here will note that *most* compiler workarounds
- * in tcsh are either for apollo/DomainOS or hpux. Is it a coincidence?
- */
- while ( *(c = p) != '\0') {
- p++;
- if (*c == '`') {
+ while (*p != '\0') {
+ if (*p == '`') {
gflag |= G_CSH;
#ifdef notdef
/*
* We do want to expand echo `echo '*'`, so we don't\
* use this piece of code anymore.
*/
+ p++;
while (*p && *p != '`')
if (*p++ == '\\') {
if (*p) /* Quoted chars */
@@ -681,21 +621,21 @@ tglob(t)
else
break;
}
- if (*p) /* The matching ` */
- p++;
- else
+ if (!*p) /* The matching ` */
break;
#endif
}
- else if (*c == '{')
+ else if (*p == '{')
gflag |= G_CSH;
- else if (isglob(*c))
+ else if (isglob(*p))
gflag |= G_GLOB;
else if (symlinks == SYM_EXPAND &&
- *p && ISDOTDOT(c) && (c == *(t-1) || *(c-1) == '/') )
+ p[1] && ISDOTDOT(p) && (p == *(t-1) || *(p-1) == '/') )
gflag |= G_CSH;
+ p++;
}
}
+ return gflag;
}
/*
@@ -704,34 +644,20 @@ tglob(t)
* words only at newlines.
*/
Char **
-dobackp(cp, literal)
- Char *cp;
- int literal;
+dobackp(Char *cp, int literal)
{
- Char *lp, *rp;
- Char *ep, word[LONGBSIZE];
+ struct Strbuf word = Strbuf_INIT;
+ struct blk_buf bb = BLK_BUF_INIT;
+ Char *lp, *rp, *ep;
- if (pargv) {
-#ifdef notdef
- abort();
-#endif
- blkfree(pargv);
- }
- pargsiz = GLOBSPACE;
- pargv = (Char **) xmalloc((size_t) (sizeof(Char *) * pargsiz));
- pargv[0] = NULL;
- pargcp = pargs = word;
- pargc = 0;
- pnleft = LONGBSIZE - 4;
+ cleanup_push(&bb, bb_cleanup);
+ cleanup_push(&word, Strbuf_cleanup);
for (;;) {
- for (lp = cp; *lp != '`'; lp++) {
- if (*lp == 0) {
- if (pargcp != pargs)
- pword(LONGBSIZE);
- return (pargv);
- }
- psave(*lp);
- }
+ for (lp = cp; *lp != '\0' && *lp != '`'; lp++)
+ ;
+ Strbuf_appendn(&word, cp, lp - cp);
+ if (*lp == 0)
+ break;
lp++;
for (rp = lp; *rp && *rp != '`'; rp++)
if (*rp == '\\') {
@@ -739,20 +665,26 @@ dobackp(cp, literal)
if (!*rp)
goto oops;
}
- if (!*rp)
- oops: stderror(ERR_UNMATCHED, '`');
- ep = Strsave(lp);
- ep[rp - lp] = 0;
- backeval(ep, literal);
+ if (!*rp) {
+ oops:
+ stderror(ERR_UNMATCHED, '`');
+ }
+ ep = Strnsave(lp, rp - lp);
+ cleanup_push(ep, xfree);
+ backeval(&bb, &word, ep, literal);
+ cleanup_until(ep);
cp = rp + 1;
}
+ if (word.len != 0)
+ pword(&bb, &word);
+ cleanup_ignore(&bb);
+ cleanup_until(&bb);
+ return bb_finish(&bb);
}
static void
-backeval(cp, literal)
- Char *cp;
- int literal;
+backeval(struct blk_buf *bb, struct Strbuf *word, Char *cp, int literal)
{
int icnt;
Char c, *ip;
@@ -782,6 +714,7 @@ backeval(cp, literal)
* we are sure to fork here.
*/
psavejob();
+ cleanup_push(&faket, psavejob_cleanup); /* faket is only a marker */
/*
* It would be nicer if we could integrate this redirection more with the
@@ -789,22 +722,18 @@ backeval(cp, literal)
* was piped out.
*/
mypipe(pvec);
+ cleanup_push(&pvec[0], open_cleanup);
+ cleanup_push(&pvec[1], open_cleanup);
if (pfork(&faket, -1) == 0) {
jmp_buf_t osetexit;
- struct command *volatile t;
+ struct command *t;
+ size_t omark;
- (void) close(pvec[0]);
+ xclose(pvec[0]);
(void) dmove(pvec[1], 1);
(void) dmove(SHDIAG, 2);
initdesc();
closem();
- /*
- * Bugfix for nested backquotes by Michael Greim <greim@sbsvax.UUCP>,
- * posted to comp.bugs.4bsd 12 Sep. 1989.
- */
- if (pargv) /* mg, 21.dec.88 */
- blkfree(pargv), pargv = 0, pargsiz = 0;
- /* mg, 21.dec.88 */
arginp = cp;
for (arginp = cp; *cp; cp++) {
*cp &= TRIM;
@@ -821,60 +750,48 @@ backeval(cp, literal)
alvecp = NULL;
evalp = NULL;
- t = NULL;
+ omark = cleanup_push_mark();
getexit(osetexit);
for (;;) {
-
- if (paraml.next && paraml.next != &paraml)
- freelex(&paraml);
-
- paraml.next = paraml.prev = &paraml;
- paraml.word = STRNULL;
(void) setexit();
justpr = 0;
- /*
- * For the sake of reset()
- */
- freelex(&paraml);
- if (t)
- freesyn(t), t = NULL;
-
if (haderr) {
/* unwind */
doneinp = 0;
+ cleanup_pop_mark(omark);
resexit(osetexit);
reset();
}
if (seterr) {
- xfree((ptr_t) seterr);
+ xfree(seterr);
seterr = NULL;
}
(void) lex(&paraml);
+ cleanup_push(&paraml, lex_cleanup);
if (seterr)
stderror(ERR_OLD);
alias(&paraml);
t = syntax(paraml.next, &paraml, 0);
+ cleanup_push(t, syntax_cleanup);
if (seterr)
stderror(ERR_OLD);
#ifdef SIGTSTP
- (void) sigignore(SIGTSTP);
+ signal(SIGTSTP, SIG_IGN);
#endif
#ifdef SIGTTIN
- (void) sigignore(SIGTTIN);
+ signal(SIGTTIN, SIG_IGN);
#endif
#ifdef SIGTTOU
- (void) sigignore(SIGTTOU);
+ signal(SIGTTOU, SIG_IGN);
#endif
execute(t, -1, NULL, NULL, TRUE);
- freelex(&paraml);
- freesyn(t), t = NULL;
+ cleanup_until(&paraml);
}
}
- xfree((ptr_t) cp);
- (void) close(pvec[1]);
+ cleanup_until(&pvec[1]);
c = 0;
ip = NULL;
do {
@@ -887,9 +804,7 @@ backeval(cp, literal)
int i, eof;
ip = ibuf;
- do
- icnt = read(pvec[0], tmp, tibuf + BUFSIZE - tmp);
- while (icnt == -1 && errno == EINTR);
+ icnt = xread(pvec[0], tmp, tibuf + BUFSIZE - tmp);
eof = 0;
if (icnt <= 0) {
if (tmp == tibuf)
@@ -942,7 +857,7 @@ backeval(cp, literal)
if (!quoted && (c == ' ' || c == '\t'))
break;
cnt++;
- psave(c | quoted);
+ Strbuf_append1(word, c | quoted);
}
/*
* Unless at end-of-file, we will form a new word here if there were
@@ -951,53 +866,36 @@ backeval(cp, literal)
* would lose blank lines.
*/
if (c != 0 && (cnt || literal))
- pword(BUFSIZE);
+ pword(bb, word);
hadnl = 0;
} while (c > 0);
eof:
- (void) close(pvec[0]);
+ cleanup_until(&pvec[0]);
pwait();
- prestjob();
+ cleanup_until(&faket); /* psavejob_cleanup(); */
}
static void
-psave(c)
- Char c;
+pword(struct blk_buf *bb, struct Strbuf *word)
{
- if (--pnleft <= 0)
- stderror(ERR_WTOOLONG);
- *pargcp++ = (Char) c;
-}
+ Char *s;
-static void
-pword(bufsiz)
- int bufsiz;
-{
- psave(0);
- if (pargc == pargsiz - 1) {
- pargsiz += GLOBSPACE;
- pargv = (Char **) xrealloc((ptr_t) pargv,
- (size_t) (pargsiz * sizeof(Char *)));
- }
- NLSQuote(pargs);
- pargv[pargc++] = Strsave(pargs);
- pargv[pargc] = NULL;
- pargcp = pargs;
- pnleft = bufsiz - 4;
+ s = Strbuf_finish(word);
+ bb_append(bb, s);
+ *word = Strbuf_init;
}
int
-Gmatch(string, pattern)
- Char *string, *pattern;
+Gmatch(const Char *string, const Char *pattern)
{
return Gnmatch(string, pattern, NULL);
}
-int
-Gnmatch(string, pattern, endstr)
- Char *string, *pattern, **endstr;
+int
+Gnmatch(const Char *string, const Char *pattern, const Char **endstr)
{
- Char **blk, **p, *tstring = string;
+ Char ***fblk, **p;
+ const Char *tstring = string;
int gpol = 1, gres = 0;
if (*pattern == '^') {
@@ -1005,30 +903,33 @@ Gnmatch(string, pattern, endstr)
pattern++;
}
- blk = (Char **) xmalloc((size_t) (GLOBSPACE * sizeof(Char *)));
- blk[0] = Strsave(pattern);
- blk[1] = NULL;
+ fblk = xmalloc(sizeof(Char ***));
+ *fblk = xmalloc(GLOBSPACE * sizeof(Char *));
+ (*fblk)[0] = Strsave(pattern);
+ (*fblk)[1] = NULL;
- expbrace(&blk, NULL, GLOBSPACE);
+ cleanup_push(fblk, blk_indirect_cleanup);
+ expbrace(fblk, NULL, GLOBSPACE);
if (endstr == NULL)
/* Exact matches only */
- for (p = blk; *p; p++)
+ for (p = *fblk; *p; p++)
gres |= t_pmatch(string, *p, &tstring, 1) == 2 ? 1 : 0;
else {
+ const Char *end;
+
/* partial matches */
- int minc = 0x7fffffff;
- for (p = blk; *p; p++)
+ end = Strend(string);
+ for (p = *fblk; *p; p++)
if (t_pmatch(string, *p, &tstring, 1) != 0) {
- int t = (int) (tstring - string);
gres |= 1;
- if (minc == -1 || minc > t)
- minc = t;
+ if (end > tstring)
+ end = tstring;
}
- *endstr = string + minc;
+ *endstr = end;
}
- blkfree(blk);
+ cleanup_until(fblk);
return(gres == gpol);
}
@@ -1039,22 +940,15 @@ Gnmatch(string, pattern, endstr)
* *estr will point to the end of the longest exact or substring match.
*/
int
-t_pmatch(string, pattern, estr, cs)
- Char *string, *pattern, **estr;
- int cs;
+t_pmatch(const Char *string, const Char *pattern, const Char **estr, int cs)
{
- NLSChar stringc, patternc, rangec;
+ Char stringc, patternc, rangec;
int match, negate_range;
- Char *oestr, *pestr, *nstring;
+ const Char *pestr, *nstring;
for (nstring = string;; string = nstring) {
- stringc = *nstring++;
- TRIM_AND_EXTEND(nstring, stringc);
- /*
- * apollo compiler bug: switch (patternc = *pattern++) dies
- */
- patternc = *pattern++;
- TRIM_AND_EXTEND(pattern, patternc);
+ stringc = *nstring++ & TRIM;
+ patternc = *pattern++ & TRIM;
switch (patternc) {
case '\0':
*estr = string;
@@ -1062,15 +956,12 @@ t_pmatch(string, pattern, estr, cs)
case '?':
if (stringc == 0)
return (0);
- *estr = string;
break;
case '*':
if (!*pattern) {
- while (*string) string++;
- *estr = string;
+ *estr = Strend(string);
return (2);
}
- oestr = *estr;
pestr = NULL;
for (;;) {
@@ -1078,44 +969,38 @@ t_pmatch(string, pattern, estr, cs)
case 0:
break;
case 1:
- pestr = *estr;
+ pestr = *estr;/*FIXME: does not guarantee longest match */
break;
case 2:
return 2;
default:
abort(); /* Cannot happen */
}
- *estr = string;
- stringc = *string++;
+ stringc = *string++ & TRIM;
if (!stringc)
break;
- TRIM_AND_EXTEND(string, stringc);
}
if (pestr) {
*estr = pestr;
return 1;
}
- else {
- *estr = oestr;
+ else
return 0;
- }
case '[':
match = 0;
if ((negate_range = (*pattern == '^')) != 0)
pattern++;
- while ((rangec = *pattern++) != '\0') {
+ while ((rangec = *pattern++ & TRIM) != '\0') {
if (rangec == ']')
break;
if (match)
continue;
- TRIM_AND_EXTEND(pattern, rangec);
if (*pattern == '-' && pattern[1] != ']') {
- NLSChar rangec2;
+ Char rangec2;
pattern++;
- rangec2 = *pattern++;
- TRIM_AND_EXTEND(pattern, rangec2);
+ rangec2 = *pattern++ & TRIM;
match = (globcharcoll(stringc, rangec2, 0) <= 0 &&
globcharcoll(rangec, stringc, 0) <= 0);
}
@@ -1128,64 +1013,12 @@ t_pmatch(string, pattern, estr, cs)
return (0);
if (match == negate_range)
return (0);
- *estr = string;
break;
default:
- TRIM_AND_EXTEND(pattern, patternc);
if (cs ? patternc != stringc
-#if defined (NLS) && defined (SHORT_STRINGS)
- : towlower(patternc) != towlower(stringc))
-#else
: Tolower(patternc) != Tolower(stringc))
-#endif
return (0);
- *estr = string;
break;
}
}
}
-
-void
-Gcat(s1, s2)
- Char *s1, *s2;
-{
- Char *p, *q;
- int n;
-
- for (p = s1; *p++;)
- continue;
- for (q = s2; *q++;)
- continue;
- n = (int) ((p - s1) + (q - s2) - 1);
- if (++gargc >= gargsiz) {
- gargsiz += GLOBSPACE;
- gargv = (Char **) xrealloc((ptr_t) gargv,
- (size_t) (gargsiz * sizeof(Char *)));
- }
- gargv[gargc] = 0;
- p = gargv[gargc - 1] = (Char *) xmalloc((size_t) (n * sizeof(Char)));
- for (q = s1; (*p++ = *q++) != '\0';)
- continue;
- for (p--, q = s2; (*p++ = *q++) != '\0';)
- continue;
-}
-
-#if defined(FILEC) && defined(TIOCSTI)
-int
-sortscmp(a, b)
- Char **a, **b;
-{
- if (!a) /* check for NULL */
- return (b ? 1 : 0);
- if (!b)
- return (-1);
-
- if (!*a) /* check for NULL */
- return (*b ? 1 : 0);
- if (!*b)
- return (-1);
-
- return (int) collate(*a, *b);
-}
-
-#endif
diff --git a/contrib/tcsh/sh.h b/contrib/tcsh/sh.h
index 92c2f95..6bd594e 100644
--- a/contrib/tcsh/sh.h
+++ b/contrib/tcsh/sh.h
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/sh.h,v 3.133 2005/03/25 18:46:41 kim Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/sh.h,v 3.146 2006/07/03 22:59:01 mitr Exp $ */
/*
* sh.h: Catch it all globals and includes file!
*/
@@ -36,6 +36,7 @@
#include "config.h"
#include <stddef.h>
+#include <signal.h>
#ifdef HAVE_ICONV
# include <iconv.h>
@@ -72,7 +73,7 @@ typedef unsigned long intptr_t;
#ifndef WINNT_NATIVE
# define INIT_ZERO
# define INIT_ZERO_STRUCT
-# define force_read read
+# define force_read xread
#endif /*!WINNT_NATIVE */
/*
* Sanity
@@ -85,13 +86,9 @@ typedef unsigned long intptr_t;
# define BSDJOBS
#endif
-#if defined(POSIXSIGS) && !defined(BSDSIGS)
-# define BSDSIGS
-#endif
-
#ifdef SHORT_STRINGS
-#include <wchar.h>
# ifdef WIDE_STRINGS
+#include <wchar.h>
typedef wchar_t Char;
typedef unsigned long uChar;
typedef wint_t eChar; /* Can contain any Char value or CHAR_ERR */
@@ -115,12 +112,6 @@ typedef int eChar;
#define normal_mbtowc(PWC, S, N) ((void)(N), *(PWC) = (unsigned char)*(S), 1)
#define reset_mbtowc() ((void)0)
# define SAVE(a) (strsave(a))
-#endif
-#if SIZEOF_WCHAR_T >= 4
-typedef wchar_t NLSChar;
-#else
-/* Assumes sizeof (int) >= 4, unlike some parts of tcsh */
-typedef int NLSChar;
#endif
/* Elide unused argument warnings */
@@ -312,8 +303,8 @@ typedef int NLSChar;
# undef calloc
# undef realloc
# endif /* glibc || sgi */
-# include <limits.h>
#endif /* POSIX && !WINNT_NATIVE */
+#include <limits.h>
#if SYSVREL > 0 || defined(_IBMR2) || defined(_MINIX) || defined(linux) || defined(__GNU__) || defined(__GLIBC__)
# if !defined(pyr) && !defined(stellar)
@@ -328,7 +319,7 @@ typedef int NLSChar;
* versions of DECOSF1 will get TIOCGWINSZ. This might break older versions...
*/
#if !((defined(SUNOS4) || defined(_MINIX) /* || defined(DECOSF1) */) && defined(TERMIO))
-# if !defined(COHERENT) && !defined(_VMS_POSIX) && !defined(WINNT_NATIVE)
+# if !defined(_VMS_POSIX) && !defined(WINNT_NATIVE)
# include <sys/ioctl.h>
# endif
#endif
@@ -342,9 +333,9 @@ typedef int NLSChar;
# include <sys/filio.h>
#endif /* (!FIOCLEX && SUNOS4) || (SYSVREL == 4 && !_SEQUENT_ && !SCO && !_SX ) */
-#if !defined(_MINIX) && !defined(COHERENT) && !defined(supermax) && !defined(WINNT_NATIVE) && !defined(IRIS4D)
+#if !defined(_MINIX) && !defined(supermax) && !defined(WINNT_NATIVE) && !defined(IRIS4D)
# include <sys/file.h>
-#endif /* !_MINIX && !COHERENT && !supermax && !WINNT_NATIVE && !defined(IRIS4D) */
+#endif /* !_MINIX && !supermax && !WINNT_NATIVE && !defined(IRIS4D) */
#if !defined(O_RDONLY) || !defined(O_NDELAY)
# include <fcntl.h>
@@ -357,15 +348,7 @@ typedef int NLSChar;
#include <setjmp.h>
-#if defined(PROTOTYPES)
-# include <stdarg.h>
-#else
-#ifdef _MINIX
-# include "mi.varargs.h"
-#else
-# include <varargs.h>
-#endif /* _MINIX */
-#endif
+#include <stdarg.h>
#ifdef HAVE_DIRENT_H
# include <dirent.h>
@@ -380,9 +363,9 @@ typedef int NLSChar;
#ifndef HAVE_STRUCT_DIRENT_D_INO
# define d_ino d_fileno
#endif
-#if defined(hpux) || defined(sgi) || defined(OREO) || defined(COHERENT)
+#if defined(hpux) || defined(sgi) || defined(OREO)
# include <stdio.h> /* So the fgetpwent() prototypes work */
-#endif /* hpux || sgi || OREO || COHERENT */
+#endif /* hpux || sgi || OREO */
#ifndef WINNT_NATIVE
#include <pwd.h>
#include <grp.h>
@@ -420,27 +403,15 @@ typedef int NLSChar;
# if (defined(_SS_SIZE) || defined(_SS_MAXSIZE)) && defined(HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY)
# if !defined(__APPLE__) /* Damnit, where is getnameinfo() folks? */
# if !defined(sgi)
-# define INET6
+# if !defined(__CYGWIN__)
+# define INET6
+# endif /* __CYGWIN__ */
# endif /* sgi */
# endif /* __APPLE__ */
# endif
# include <sys/uio.h> /* For struct iovec */
#endif /* REMOTEHOST */
-/*
- * ANSIisms... These must be *after* the system include and
- * *before* our includes, so that BSDreno has time to define __P
- */
-#undef __P
-#ifndef __P
-# if defined(PROTOTYPES)
-# define __P(a) a
-# else
-# define __P(a) ()
-# endif
-#endif
-
-
#ifdef PURIFY
/* exit normally, allowing purify to trace leaks */
# define _exit exit
@@ -471,18 +442,14 @@ typedef void pret_t;
#include "sh.types.h"
-#ifndef __NetBSD__ /* XXX */
-#ifndef WINNT_NATIVE
+#if !HAVE_DECL_GETPGRP
# ifndef GETPGRP_VOID
-extern pid_t getpgrp __P((int));
+extern pid_t getpgrp (int);
# else
-extern pid_t getpgrp __P((void));
+extern pid_t getpgrp (void);
# endif
-#endif /* !WINNT_NATIVE */
#endif
-typedef RETSIGTYPE (*signalfun_t) __P((int));
-
#ifndef lint
typedef ptr_t memalign_t;
#else
@@ -501,29 +468,17 @@ typedef union {
# define calloc lint_calloc
#endif
-#ifdef MDEBUG
-extern memalign_t DebugMalloc __P((unsigned, char *, int));
-extern memalign_t DebugRealloc __P((ptr_t, unsigned, char *, int));
-extern memalign_t DebugCalloc __P((unsigned, unsigned, char *, int));
-extern void DebugFree __P((ptr_t, char *, int));
-# define xmalloc(i) DebugMalloc(i, __FILE__, __LINE__)
-# define xrealloc(p, i)((p) ? DebugRealloc(p, i, __FILE__, __LINE__) : \
- DebugMalloc(i, __FILE__, __LINE__))
-# define xcalloc(n, s) DebugCalloc(n, s, __FILE__, __LINE__)
-# define xfree(p) if (p) DebugFree(p, __FILE__, __LINE__)
+#ifdef SYSMALLOC
+# define xmalloc(i) smalloc(i)
+# define xrealloc(p, i) srealloc(p, i)
+# define xcalloc(n, s) scalloc(n, s)
+# define xfree sfree
#else
-# ifdef SYSMALLOC
-# define xmalloc(i) smalloc(i)
-# define xrealloc(p, i) srealloc(p, i)
-# define xcalloc(n, s) scalloc(n, s)
-# define xfree(p) sfree(p)
-# else
-# define xmalloc(i) malloc(i)
-# define xrealloc(p, i) realloc(p, i)
-# define xcalloc(n, s) calloc(n, s)
-# define xfree(p) free(p)
-# endif /* SYSMALLOC */
-#endif /* MDEBUG */
+# define xmalloc(i) malloc(i)
+# define xrealloc(p, i) realloc(p, i)
+# define xcalloc(n, s) calloc(n, s)
+# define xfree free
+#endif /* SYSMALLOC */
#include "sh.char.h"
#include "sh.err.h"
#include "sh.dir.h"
@@ -542,10 +497,6 @@ extern void DebugFree __P((ptr_t, char *, int));
* April, 1980
*/
-#if !defined(MAXNAMLEN) && defined(_D_NAME_MAX)
-# define MAXNAMLEN _D_NAME_MAX
-#endif /* MAXNAMLEN */
-
#ifdef HESIOD
# include <hesiod.h>
#endif /* HESIOD */
@@ -555,7 +506,9 @@ extern void DebugFree __P((ptr_t, char *, int));
#endif /* REMOTEHOST */
#ifndef MAXHOSTNAMELEN
-# if defined(SCO) && (SYSVREL > 3)
+# ifdef HOST_NAME_MAX
+# define MAXHOSTNAMELEN (HOST_NAME_MAX + 1)
+# elif defined(SCO) && (SYSVREL > 3)
# include <sys/socket.h>
# else
# define MAXHOSTNAMELEN 256
@@ -595,7 +548,6 @@ EXTERN int neednote IZERO; /* Need to pnotify() */
EXTERN int noexec IZERO; /* Don't execute, just syntax check */
EXTERN int pjobs IZERO; /* want to print jobs if interrupted */
EXTERN int setintr IZERO; /* Set interrupts on/off -> Wait intr... */
-EXTERN int timflg IZERO; /* Time the next waited for command */
EXTERN int havhash IZERO; /* path hashing is available */
EXTERN int editing IZERO; /* doing filename expansion and line editing */
EXTERN int noediting IZERO; /* initial $term defaulted to noedit */
@@ -607,7 +559,8 @@ EXTERN int is2atty IZERO; /* is file descriptor 2 a tty (didfds mode) */
EXTERN int arun IZERO; /* Currently running multi-line-aliases */
EXTERN int implicit_cd IZERO;/* implicit cd enabled?(1=enabled,2=verbose) */
EXTERN int inheredoc IZERO; /* Currently parsing a heredoc */
-EXTERN int windowchg IZERO; /* We received a window change event */
+/* We received a window change event */
+EXTERN volatile sig_atomic_t windowchg IZERO;
#if defined(KANJI) && defined(SHORT_STRINGS) && defined(DSPMBYTE)
EXTERN int dspmbyte_ls;
#endif
@@ -625,7 +578,8 @@ extern char *seterr; /* Error message from scanner/parser */
extern int errno; /* Error from C library routines */
#endif
extern int exitset;
-EXTERN Char *shtemp IZERO; /* Temp name for << shell files in /tmp */
+/* Temp name for << shell files in /tmp, for xfree() */
+EXTERN Char *shtemp IZERO;
#ifdef BSDTIMES
EXTERN struct timeval time0; /* Time at which the shell started */
@@ -643,7 +597,7 @@ EXTERN clock_t clk_tck;
# endif /* POSIX */
EXTERN struct tms shtimes; /* shell and child times for process timing */
# endif /* _SEQUENT_ */
-EXTERN long seconds0;
+EXTERN time_t seconds0;
#endif /* BSDTIMES */
#ifndef HZ
@@ -654,7 +608,7 @@ EXTERN long seconds0;
* Miscellany
*/
EXTERN Char *doldol; /* Character pid for $$ */
-EXTERN int backpid; /* pid of the last background job */
+EXTERN pid_t backpid; /* pid of the last background job */
/*
* Ideally these should be uid_t, gid_t, pid_t. I cannot do that right now
@@ -669,12 +623,8 @@ EXTERN pid_t opgrp, /* Initial pgrp and tty pgrp */
tpgrp; /* Terminal process group */
/* If tpgrp is -1, leave tty alone! */
-EXTERN Char PromptBuf[INBUFSIZE*2]; /* buffer for the actual printed prompt.
- * this must be large enough to contain
- * the input line and the prompt, in
- * case a correction occurred...
- */
-EXTERN Char RPromptBuf[INBUFSIZE]; /* buffer for right-hand side prompt */
+EXTERN Char *Prompt; /* The actual printed prompt or NULL */
+EXTERN Char *RPrompt; /* Right-hand side prompt or NULL */
/*
* To be able to redirect i/o for builtins easily, the shell moves the i/o
@@ -706,49 +656,27 @@ EXTERN int OLDSTD IZERO; /* Old standard input (def for cmds) */
* Because of source commands and .cshrc we need nested error catches.
*/
-#ifdef NO_STRUCT_ASSIGNMENT
-
-# ifdef SIGSETJMP
- typedef sigjmp_buf jmp_buf_t;
- /* bugfix by Jak Kirman @ Brown U.: remove the (void) cast here, see sh.c */
-# define setexit() sigsetjmp(reslab)
-# define reset() siglongjmp(reslab, 1)
-# else
- typedef jmp_buf jmp_buf_t;
- /* bugfix by Jak Kirman @ Brown U.: remove the (void) cast here, see sh.c */
-# define setexit() setjmp(reslab)
-# define reset() longjmp(reslab, 1)
-# endif
-# define getexit(a) (void) memmove((ptr_t)&(a), (ptr_t)&reslab, sizeof(reslab))
-# define resexit(a) (void) memmove((ptr_t)&reslab, (ptr_t)&(a), sizeof(reslab))
-
-# define cpybin(a, b) (void) memmove((ptr_t)&(a), (ptr_t)&(b), sizeof(Bin))
-
-#else
-
-# ifdef SIGSETJMP
+#ifdef SIGSETJMP
typedef struct { sigjmp_buf j; } jmp_buf_t;
-# define setexit() sigsetjmp(reslab.j)
-# define reset() siglongjmp(reslab.j, 1)
-# else
+# define setexit() sigsetjmp(reslab.j)
+# define _reset() siglongjmp(reslab.j, 1)
+#else
typedef struct { jmp_buf j; } jmp_buf_t;
-# define setexit() setjmp(reslab.j)
-# define reset() longjmp(reslab.j, 1)
-# endif
-
-# define getexit(a) (void) ((a) = reslab)
-# define resexit(a) (void) (reslab = (a))
+# define setexit() setjmp(reslab.j)
+# define _reset() longjmp(reslab.j, 1)
+#endif
-# define cpybin(a, b) (void) ((a) = (b))
+#define getexit(a) (void) ((a) = reslab)
+#define resexit(a) (void) (reslab = (a))
-#endif /* NO_STRUCT_ASSIGNMENT */
+#define cpybin(a, b) (void) ((a) = (b))
extern jmp_buf_t reslab;
EXTERN Char *gointr; /* Label for an onintr transfer */
-extern signalfun_t parintr; /* Parents interrupt catch */
-extern signalfun_t parterm; /* Parents terminate catch */
+extern struct sigaction parintr; /* Parents interrupt catch */
+extern struct sigaction parterm; /* Parents terminate catch */
/*
* Lexical definitions.
@@ -790,7 +718,7 @@ extern signalfun_t parterm; /* Parents terminate catch */
# define ATTRIBUTES 0200 /* The bits used for attributes */
# define INVALID_BYTE 0
# define CHAR 0000177 /* Mask to mask out the character */
-#endif
+#endif
#define CHAR_DBWIDTH (LITERAL|(LITERAL-1))
EXTERN int AsciiOnly; /* If set only 7 bits expected in characters */
@@ -801,6 +729,13 @@ EXTERN int AsciiOnly; /* If set only 7 bits expected in characters */
* exactly one if the input is seekable and tell is available.
* In other cases, the shell buffers enough blocks to keep all loops
* in the buffer.
+ *
+ * If (WIDE_STRINGS && cantell), fbobp is always a byte offset, but
+ * (fseekp - fbobp) and (feobp - fbobp) are character offsets (usable for
+ * fbuf indexing).
+ *
+ * If (!cantell), all offsets are character offsets; if (!WIDE_STRINGS), there
+ * is no difference between byte and character offsets.
*/
EXTERN struct Bin {
off_t Bfseekp; /* Seek pointer, generally != lseek() value */
@@ -824,7 +759,7 @@ struct Ain {
#define TCSH_F_SEEK 2 /* File seek */
#define TCSH_E_SEEK 3 /* Eval seek */
union {
- off_t _f_seek;
+ off_t _f_seek; /* A byte offset if (cantell) */
Char* _c_seek;
} fc;
#define f_seek fc._f_seek
@@ -883,7 +818,8 @@ struct wordent {
* process id's from `$$', and modified variable values (from qualifiers
* during expansion in sh.dol.c) here.
*/
-EXTERN Char *lap;
+extern struct Strbuf labuf;
+EXTERN size_t lap; /* N/A if == labuf.len, index into labuf.s otherwise */
/*
* Parser structure
@@ -979,10 +915,10 @@ struct command {
/* Avoid hpux ansi mode spurious warnings */
typedef void (*bfunc_t) ();
#else
-typedef void (*bfunc_t) __P((Char **, struct command *));
+typedef void (*bfunc_t) (Char **, struct command *);
#endif /* hpux && __STDC__ && !__GNUC__ */
-extern struct biltins {
+extern const struct biltins {
const char *bname;
bfunc_t bfunct;
int minargs, maxargs;
@@ -1051,22 +987,19 @@ EXTERN Char **alvec IZERO_STRUCT,
/*
* Filename/command name expansion variables
*/
-EXTERN int gflag; /* After tglob -> is globbing needed? */
-
-#define MAXVARLEN 256 /* Maximum number of char in a variable name */
#ifdef __CYGWIN__
# undef MAXPATHLEN
#endif /* __CYGWIN__ */
#ifndef MAXPATHLEN
-# define MAXPATHLEN 2048
+# ifdef PATH_MAX
+# define MAXPATHLEN PATH_MAX
+# else
+# define MAXPATHLEN 2048
+# endif
#endif /* MAXPATHLEN */
-#ifndef MAXNAMLEN
-# define MAXNAMLEN 512
-#endif /* MAXNAMLEN */
-
#ifndef HAVENOLIMIT
/*
* resource limits
@@ -1080,20 +1013,6 @@ extern struct limits {
#endif /* !HAVENOLIMIT */
/*
- * Variables for filename expansion
- */
-extern Char **gargv; /* Pointer to the (stack) arglist */
-extern int gargc; /* Number args in gargv */
-
-/*
- * Variables for command expansion.
- */
-extern Char **pargv; /* Pointer to the argv list space */
-EXTERN Char *pargs; /* Pointer to start current word */
-EXTERN long pnleft; /* Number of chars left in pargs */
-EXTERN Char *pargcp; /* Current index into pargs */
-
-/*
* History list
*
* Each history list entry contains an embedded wordlist
@@ -1152,6 +1071,7 @@ EXTERN Char PRCHROOT; /* Prompt symbol for root */
#define Strcasecmp(a, b) strcasecmp(a, b)
#define Strspl(a, b) strspl(a, b)
+#define Strnsave(a, b) strnsave(a, b)
#define Strsave(a) strsave(a)
#define Strend(a) strend(a)
#define Strstr(a, b) strstr(a, b)
@@ -1159,7 +1079,7 @@ EXTERN Char PRCHROOT; /* Prompt symbol for root */
#define str2short(a) (a)
#define blk2short(a) saveblk(a)
#define short2blk(a) saveblk(a)
-#define short2str(a) strip(a)
+#define short2str(a) caching_strip(a)
#else
#ifdef WIDE_STRINGS
#define Strchr(a, b) wcschr(a, b)
@@ -1185,6 +1105,7 @@ EXTERN Char PRCHROOT; /* Prompt symbol for root */
#define Strcasecmp(a, b) s_strcasecmp(a, b)
#define Strspl(a, b) s_strspl(a, b)
+#define Strnsave(a, b) s_strnsave(a, b)
#define Strsave(a) s_strsave(a)
#define Strend(a) s_strend(a)
#define Strstr(a, b) s_strstr(a, b)
@@ -1248,6 +1169,9 @@ extern int use_fork;
#endif
extern int tellwhat;
extern int NoNLSRebind;
+#if !HAVE_DECL_ENVIRON
+extern char **environ;
+#endif
#include "tc.h"
@@ -1266,9 +1190,9 @@ extern int NoNLSRebind;
* This does not link right now...
*/
typedef void *nl_catd;
- extern const char * catgets __P((nl_catd, int, int, const char *));
- nl_catd catopen __P((const char *, int));
- int catclose __P((nl_catd));
+ extern const char * catgets (nl_catd, int, int, const char *);
+ nl_catd catopen (const char *, int);
+ int catclose (nl_catd);
# else
# ifdef __uxps__
# define gettxt gettxt_ds
@@ -1282,10 +1206,10 @@ extern int NoNLSRebind;
# define MCLoadBySet 0
# endif
EXTERN nl_catd catd;
-# ifdef HAVE_ICONV
+# if defined(HAVE_ICONV) && defined(HAVE_NL_LANGINFO)
# define CGETS(b, c, d) iconv_catgets(catd, b, c, d)
# else
-# define CGETS(b, c, d) catgets(catd, b, c, d)
+# define CGETS(b, c, d) xcatgets(catd, b, c, d)
# endif
# define CSAVS(b, c, d) strsave(CGETS(b, c, d))
# else
diff --git a/contrib/tcsh/sh.hist.c b/contrib/tcsh/sh.hist.c
index a108747..72b376a 100644
--- a/contrib/tcsh/sh.hist.c
+++ b/contrib/tcsh/sh.hist.c
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/sh.hist.c,v 3.33 2004/12/25 21:15:07 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/sh.hist.c,v 3.40 2007/03/01 17:14:51 christos Exp $ */
/*
* sh.hist.c: Shell history expansions and substitutions
*/
@@ -32,18 +32,18 @@
*/
#include "sh.h"
-RCSID("$Id: sh.hist.c,v 3.33 2004/12/25 21:15:07 christos Exp $")
+RCSID("$tcsh: sh.hist.c,v 3.40 2007/03/01 17:14:51 christos Exp $")
#include "tc.h"
extern int histvalid;
-extern Char histline[];
+extern struct Strbuf histline;
Char HistLit = 0;
-static int heq __P((struct wordent *, struct wordent *));
-static void hfree __P((struct Hist *));
-static void dohist1 __P((struct Hist *, int *, int));
-static void phist __P((struct Hist *, int));
+static int heq (const struct wordent *, const struct wordent *);
+static void hfree (struct Hist *);
+static void dohist1 (struct Hist *, int *, int);
+static void phist (struct Hist *, int);
#define HIST_ONLY 0x01
#define HIST_SAVE 0x02
@@ -58,9 +58,7 @@ static void phist __P((struct Hist *, int));
*/
void
-savehist(sp, mflg)
- struct wordent *sp;
- int mflg;
+savehist(struct wordent *sp, int mflg)
{
struct Hist *hp, *np;
int histlen = 0;
@@ -70,16 +68,12 @@ savehist(sp, mflg)
if (sp && sp->next->word[0] == '\n')
return;
cp = varval(STRhistory);
- if (*cp) {
- Char *p = cp;
-
- while (*p) {
- if (!Isdigit(*p)) {
- histlen = 0;
- break;
- }
- histlen = histlen * 10 + *p++ - '0';
+ while (*cp) {
+ if (!Isdigit(*cp)) {
+ histlen = 0;
+ break;
}
+ histlen = histlen * 10 + *cp++ - '0';
}
if (sp)
(void) enthist(++eventno, sp, 1, mflg);
@@ -91,10 +85,9 @@ savehist(sp, mflg)
}
static int
-heq(a0, b0)
- struct wordent *a0, *b0;
+heq(const struct wordent *a0, const struct wordent *b0)
{
- struct wordent *a = a0->next, *b = b0->next;
+ const struct wordent *a = a0->next, *b = b0->next;
for (;;) {
if (Strcmp(a->word, b->word) != 0)
@@ -110,16 +103,12 @@ heq(a0, b0)
struct Hist *
-enthist(event, lp, docopy, mflg)
- int event;
- struct wordent *lp;
- int docopy;
- int mflg;
+enthist(int event, struct wordent *lp, int docopy, int mflg)
{
struct Hist *p = NULL, *pp = &Histlist;
int n, r;
struct Hist *np;
- Char *dp;
+ const Char *dp;
if ((dp = varval(STRhistdup)) != STRNULL) {
if (eq(dp, STRerase)) {
@@ -152,10 +141,10 @@ enthist(event, lp, docopy, mflg)
}
}
- np = p ? p : (struct Hist *) xmalloc((size_t) sizeof(*np));
+ np = p ? p : xmalloc(sizeof(*np));
/* Pick up timestamp set by lex() in Htime if reading saved history */
- if (Htime != (time_t) 0) {
+ if (Htime != 0) {
np->Htime = Htime;
Htime = 0;
}
@@ -169,7 +158,7 @@ enthist(event, lp, docopy, mflg)
if (docopy) {
copylex(&np->Hlex, lp);
if (histvalid)
- np->histline = Strsave(histline);
+ np->histline = Strsave(histline.s);
else
np->histline = NULL;
}
@@ -208,34 +197,25 @@ enthist(event, lp, docopy, mflg)
}
static void
-hfree(hp)
- struct Hist *hp;
+hfree(struct Hist *hp)
{
freelex(&hp->Hlex);
if (hp->histline)
- xfree((ptr_t) hp->histline);
- xfree((ptr_t) hp);
+ xfree(hp->histline);
+ xfree(hp);
}
/*ARGSUSED*/
void
-dohist(vp, c)
- Char **vp;
- struct command *c;
+dohist(Char **vp, struct command *c)
{
int n, hflg = 0;
USE(c);
if (getn(varval(STRhistory)) == 0)
return;
- if (setintr)
-#ifdef BSDSIGS
- (void) sigsetmask(sigblock((sigmask_t) 0) & ~sigmask(SIGINT));
-#else
- (void) sigrelse(SIGINT);
-#endif
while (*++vp && **vp == '-') {
Char *vp2 = *vp;
@@ -274,30 +254,32 @@ dohist(vp, c)
hp->Hnext = np->Hnext, hfree(np);
}
- if (hflg & (HIST_LOAD | HIST_MERGE)) {
+ if (hflg & (HIST_LOAD | HIST_MERGE))
loadhist(*vp, (hflg & HIST_MERGE) ? 1 : 0);
- return;
- }
- else if (hflg & HIST_SAVE) {
+ else if (hflg & HIST_SAVE)
rechist(*vp, 1);
- return;
- }
- if (*vp)
- n = getn(*vp);
else {
- n = getn(varval(STRhistory));
+ if (*vp)
+ n = getn(*vp);
+ else {
+ n = getn(varval(STRhistory));
+ }
+ dohist1(Histlist.Hnext, &n, hflg);
}
- dohist1(Histlist.Hnext, &n, hflg);
}
static void
-dohist1(hp, np, hflg)
- struct Hist *hp;
- int *np, hflg;
+dohist1(struct Hist *hp, int *np, int hflg)
{
int print = (*np) > 0;
for (; hp != 0; hp = hp->Hnext) {
+ if (setintr) {
+ int old_pintr_disabled;
+
+ pintr_push_enable(&old_pintr_disabled);
+ cleanup_until(&old_pintr_disabled);
+ }
(*np)--;
if ((hflg & HIST_REV) == 0) {
dohist1(hp->Hnext, np, hflg);
@@ -311,93 +293,86 @@ dohist1(hp, np, hflg)
}
static void
-phist(hp, hflg)
- struct Hist *hp;
- int hflg;
+phist(struct Hist *hp, int hflg)
{
if (hflg & HIST_ONLY) {
+ int old_output_raw;
+
/*
* Control characters have to be written as is (output_raw).
* This way one can preserve special characters (like tab) in
* the history file.
* From: mveksler@vnet.ibm.com (Veksler Michael)
*/
- output_raw= 1;
+ old_output_raw = output_raw;
+ output_raw = 1;
+ cleanup_push(&old_output_raw, output_raw_restore);
if (hflg & HIST_TIME)
/*
* Make file entry with history time in format:
* "+NNNNNNNNNN" (10 digits, left padded with ascii '0')
*/
- xprintf("#+%010lu\n", hp->Htime);
+ xprintf("#+%010lu\n", (unsigned long)hp->Htime);
if (HistLit && hp->histline)
xprintf("%S\n", hp->histline);
else
prlex(&hp->Hlex);
- output_raw= 0;
+ cleanup_until(&old_output_raw);
}
else {
Char *cp = str2short("%h\t%T\t%R\n");
- Char buf[INBUFSIZE];
+ Char *p;
struct varent *vp = adrof(STRhistory);
if (vp && vp->vec != NULL && vp->vec[0] && vp->vec[1])
cp = vp->vec[1];
- tprintf(FMT_HISTORY, buf, cp, INBUFSIZE, NULL, hp->Htime, (ptr_t) hp);
- for (cp = buf; *cp;)
+ p = tprintf(FMT_HISTORY, cp, NULL, hp->Htime, hp);
+ cleanup_push(p, xfree);
+ for (cp = p; *cp;)
xputwchar(*cp++);
+ cleanup_until(p);
}
}
-void
-fmthist(fmt, ptr, buf, bufsiz)
- int fmt;
- ptr_t ptr;
- char *buf;
- size_t bufsiz;
+char *
+fmthist(int fmt, ptr_t ptr)
{
- struct Hist *hp = (struct Hist *) ptr;
+ struct Hist *hp = ptr;
+ char *buf;
+
switch (fmt) {
case 'h':
- (void) xsnprintf(buf, bufsiz, "%6d", hp->Hnum);
- break;
+ return xasprintf("%6d", hp->Hnum);
case 'R':
if (HistLit && hp->histline)
- (void) xsnprintf(buf, bufsiz, "%S", hp->histline);
+ return xasprintf("%S", hp->histline);
else {
- Char ibuf[INBUFSIZE], *ip;
+ Char *istr, *ip;
char *p;
- (void) sprlex(ibuf, sizeof(ibuf) / sizeof(Char), &hp->Hlex);
- p = buf;
- ip = ibuf;
- do {
- char xbuf[MB_LEN_MAX];
- size_t len;
-
- len = one_wctomb(xbuf, CHAR & *ip);
- if ((size_t)((p - buf) + len) >= bufsiz)
- break;
- memcpy(p, xbuf, len);
- p += len;
- } while ((CHAR & *ip++) != 0);
- if (p <= buf + bufsiz - 1)
- *p = '\0';
+
+ istr = sprlex(&hp->Hlex);
+ buf = xmalloc(Strlen(istr) * MB_LEN_MAX + 1);
+
+ for (p = buf, ip = istr; *ip != '\0'; ip++)
+ p += one_wctomb(p, CHAR & *ip);
+
+ *p = '\0';
+ xfree(istr);
+ return buf;
}
- break;
default:
+ buf = xmalloc(1);
buf[0] = '\0';
- break;
+ return buf;
}
-
}
void
-rechist(fname, ref)
- Char *fname;
- int ref;
+rechist(Char *fname, int ref)
{
Char *snum;
int fp, ftmp, oldidfds;
@@ -423,10 +398,11 @@ rechist(fname, ref)
}
else
fname = globone(fname, G_ERROR);
+ cleanup_push(fname, xfree);
/*
* The 'savehist merge' feature is intended for an environment
- * with numerous shells beeing in simultaneous use. Imagine
+ * with numerous shells being in simultaneous use. Imagine
* any kind of window system. All these shells 'share' the same
* ~/.history file for recording their command line history.
* Currently the automatic merge can only succeed when the shells
@@ -448,26 +424,25 @@ rechist(fname, ref)
if ((shist = adrof(STRsavehist)) != NULL && shist->vec != NULL)
if (shist->vec[1] && eq(shist->vec[1], STRmerge))
loadhist(fname, 1);
- fp = creat(short2str(fname), 0600);
+ fp = xcreat(short2str(fname), 0600);
if (fp == -1) {
didfds = oldidfds;
+ cleanup_until(fname);
return;
}
ftmp = SHOUT;
SHOUT = fp;
dumphist[2] = snum;
dohist(dumphist, NULL);
- (void) close(fp);
+ xclose(fp);
SHOUT = ftmp;
didfds = oldidfds;
- xfree((ptr_t) fname);
+ cleanup_until(fname);
}
void
-loadhist(fname, mflg)
- Char *fname;
- int mflg;
+loadhist(Char *fname, int mflg)
{
static Char *loadhist_cmd[] = {STRsource, NULL, NULL, NULL};
loadhist_cmd[1] = mflg ? STRmm : STRmh;
diff --git a/contrib/tcsh/sh.init.c b/contrib/tcsh/sh.init.c
index 0612cd9..aacff5b 100644
--- a/contrib/tcsh/sh.init.c
+++ b/contrib/tcsh/sh.init.c
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/sh.init.c,v 3.55 2005/01/18 20:43:31 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/sh.init.c,v 3.63 2006/08/23 01:49:32 mitr Exp $ */
/*
* sh.init.c: Function and signal tables
*/
@@ -32,7 +32,7 @@
*/
#include "sh.h"
-RCSID("$Id: sh.init.c,v 3.55 2005/01/18 20:43:31 christos Exp $")
+RCSID("$tcsh: sh.init.c,v 3.63 2006/08/23 01:49:32 mitr Exp $")
#include "ed.h"
#include "tw.h"
@@ -41,23 +41,17 @@ RCSID("$Id: sh.init.c,v 3.55 2005/01/18 20:43:31 christos Exp $")
* C shell
*/
-#define INF 0x7fffffff
+#define INF INT_MAX
-struct biltins bfunc[] = {
+const struct biltins bfunc[] = {
{ ":", dozip, 0, INF },
{ "@", dolet, 0, INF },
{ "alias", doalias, 0, INF },
-#ifdef OBSOLETE
- { "aliases", doaliases, 0, 1, },
-#endif /* OBSOLETE */
{ "alloc", showall, 0, 1 },
#if defined(_CX_UX)
{ "att", doatt, 0, INF },
#endif /* _CX_UX */
{ "bg", dobg, 0, INF },
-#ifdef OBSOLETE
- { "bind", dobind, 0, 2 },
-#endif /* OBSOLETE */
{ "bindkey", dobindkey, 0, 8 },
{ "break", dobreak, 0, 0 },
{ "breaksw", doswbrk, 0, 0 },
@@ -232,14 +226,14 @@ struct mesg mesg[NUMSIG]; /* Arrays start at [0] so we initialize from */
/* 0 to 32 or 64, the max real signal number */
void
-mesginit()
+mesginit(void)
{
#ifdef NLS_CATALOGS
int i;
for (i = 0; i < NUMSIG; i++) {
- xfree((ptr_t) mesg[i].pname);
+ xfree((char *)(intptr_t)mesg[i].pname);
mesg[i].pname = NULL;
}
#endif /* NLS_CATALOGS */
@@ -758,17 +752,20 @@ mesginit()
mesg[SIGRTMIN].pname = CSAVS(2, 68, "First Realtime Signal");
}
- if (mesg[SIGRTMIN+1].pname == NULL) {
+ if (SIGRTMIN + 1 < SIGRTMAX && SIGRTMIN + 1 < NUMSIG &&
+ mesg[SIGRTMIN+1].pname == NULL) {
mesg[SIGRTMIN+1].iname = "RTMIN+1";
mesg[SIGRTMIN+1].pname = CSAVS(2, 69, "Second Realtime Signal");
}
- if (mesg[SIGRTMIN+2].pname == NULL) {
+ if (SIGRTMIN + 2 < SIGRTMAX && SIGRTMIN + 2 < NUMSIG &&
+ mesg[SIGRTMIN+2].pname == NULL) {
mesg[SIGRTMIN+2].iname = "RTMIN+2";
mesg[SIGRTMIN+2].pname = CSAVS(2, 70, "Third Realtime Signal");
}
- if (mesg[SIGRTMIN+3].pname == NULL) {
+ if (SIGRTMIN + 3 < SIGRTMAX && SIGRTMIN + 3 < NUMSIG &&
+ mesg[SIGRTMIN+3].pname == NULL) {
mesg[SIGRTMIN+3].iname = "RTMIN+3";
mesg[SIGRTMIN+3].pname = CSAVS(2, 71, "Fourth Realtime Signal");
}
@@ -779,26 +776,26 @@ mesginit()
/*
* Cannot do this at compile time; Solaris2 uses _sysconf for these
*/
- if (SIGRTMAX > 0 && SIGRTMAX < NUMSIG) {
- if (mesg[SIGRTMAX-3].pname == NULL) {
+ if (SIGRTMAX > 0 && SIGRTMAX < NUMSIG) {
+ if (SIGRTMAX - 3 > SIGRTMIN && mesg[SIGRTMAX-3].pname == NULL) {
mesg[SIGRTMAX-3].iname = "RTMAX-3";
mesg[SIGRTMAX-3].pname = CSAVS(2, 72,
"Fourth Last Realtime Signal");
}
- if (mesg[SIGRTMAX-2].pname == NULL) {
+ if (SIGRTMAX - 2 > SIGRTMIN && mesg[SIGRTMAX-2].pname == NULL) {
mesg[SIGRTMAX-2].iname = "RTMAX-2";
mesg[SIGRTMAX-2].pname = CSAVS(2, 73,
"Third Last Realtime Signal");
}
- if (mesg[SIGRTMAX-1].pname == NULL) {
+ if (SIGRTMAX - 1 > SIGRTMIN && mesg[SIGRTMAX-1].pname == NULL) {
mesg[SIGRTMAX-1].iname = "RTMAX-1";
mesg[SIGRTMAX-1].pname = CSAVS(2, 74,
"Second Last Realtime Signal");
}
- if (mesg[SIGRTMAX].pname == NULL) {
+ if (SIGRTMAX > SIGRTMIN && mesg[SIGRTMAX].pname == NULL) {
mesg[SIGRTMAX].iname = "RTMAX";
mesg[SIGRTMAX].pname = CSAVS(2, 75,
"Last Realtime Signal");
diff --git a/contrib/tcsh/sh.lex.c b/contrib/tcsh/sh.lex.c
index e18728f..0cccf47 100644
--- a/contrib/tcsh/sh.lex.c
+++ b/contrib/tcsh/sh.lex.c
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/sh.lex.c,v 3.62 2004/12/25 21:15:07 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/sh.lex.c,v 3.77 2006/09/27 17:01:06 mitr Exp $ */
/*
* sh.lex.c: Lexical analysis into tokens
*/
@@ -32,7 +32,7 @@
*/
#include "sh.h"
-RCSID("$Id: sh.lex.c,v 3.62 2004/12/25 21:15:07 christos Exp $")
+RCSID("$tcsh: sh.lex.c,v 3.77 2006/09/27 17:01:06 mitr Exp $")
#include "ed.h"
@@ -44,27 +44,29 @@ RCSID("$Id: sh.lex.c,v 3.62 2004/12/25 21:15:07 christos Exp $")
* C shell
*/
+#define FLAG_G 1
+#define FLAG_A 2
/*
* These lexical routines read input and form lists of words.
* There is some involved processing here, because of the complications
* of input buffering, and especially because of history substitution.
*/
-static Char *word __P((int));
-static eChar getC1 __P((int));
-static void getdol __P((void));
-static void getexcl __P((Char));
-static struct Hist *findev __P((Char *, int));
-static void setexclp __P((Char *));
-static eChar bgetc __P((void));
-static void balloc __P((int));
-static void bfree __P((void));
-static struct wordent *gethent __P((Char));
-static int matchs __P((Char *, Char *));
-static int getsel __P((int *, int *, int));
-static struct wordent *getsub __P((struct wordent *));
-static Char *subword __P((Char *, Char, int *));
-static struct wordent *dosub __P((Char, struct wordent *, int));
-static ssize_t wide_read __P((int, Char *, size_t, int));
+static Char *word (int);
+static eChar getC1 (int);
+static void getdol (void);
+static void getexcl (Char);
+static struct Hist *findev (Char *, int);
+static void setexclp (Char *);
+static eChar bgetc (void);
+static void balloc (int);
+static void bfree (void);
+static struct wordent *gethent (Char);
+static int matchs (const Char *, const Char *);
+static int getsel (int *, int *, int);
+static struct wordent *getsub (struct wordent *);
+static Char *subword (Char *, Char, int *, size_t *);
+static struct wordent *dosub (Char, struct wordent *, int);
+static ssize_t wide_read (int, Char *, size_t, int);
/*
* Peekc is a peek character for getC, peekread for readc.
@@ -105,7 +107,7 @@ int aret = TCSH_F_SEEK;
* process id's from `$$', and modified variable values (from qualifiers
* during expansion in sh.dol.c) here.
*/
-static Char labuf[BUFSIZE];
+struct Strbuf labuf; /* = Strbuf_INIT; */
/*
* Lex returns to its caller not only a wordlist (as a "var" parameter)
@@ -121,11 +123,9 @@ static int hadhist = 0;
*/
int hleft;
-Char histline[BUFSIZE + 2]; /* last line input */
+struct Strbuf histline; /* = Strbuf_INIT; last line input */
- /* The +2 is to fool hp's optimizer */
int histvalid = 0; /* is histline valid */
-static Char *histlinep = NULL; /* current pointer into histline */
static Char getCtmp;
@@ -137,33 +137,22 @@ static Char getCtmp;
* if reading saved history (sg)
*/
time_t Htime = (time_t)0;
-static time_t a2time_t __P((Char *));
+static time_t a2time_t (Char *);
/*
* special parsing rules apply for source -h
*/
extern int enterhist;
-/*
- * for history event processing
- * in the command 'echo !?foo?:1 !$' we want the !$ to expand from the line
- * 'foo' was found instead of the last command
- */
-static int uselastevent = 1;
-
int
-lex(hp)
- struct wordent *hp;
+lex(struct wordent *hp)
{
struct wordent *wdp;
eChar c;
int parsehtime = enterhist;
-
- uselastevent = 1;
histvalid = 0;
- histlinep = histline;
- *histlinep = '\0';
+ histline.len = 0;
btell(&lineloc);
hp->next = hp->prev = hp;
@@ -177,6 +166,7 @@ lex(hp)
getexcl(c);
else
unreadc(c);
+ cleanup_push(hp, lex_cleanup);
wdp = hp;
/*
* The following loop is written so that the links needed by freelex will
@@ -185,8 +175,8 @@ lex(hp)
do {
struct wordent *new;
- new = (struct wordent *) xmalloc((size_t) sizeof(*wdp));
- new->word = STRNULL;
+ new = xmalloc(sizeof(*new));
+ new->word = NULL;
new->prev = wdp;
new->next = hp;
wdp->next = new;
@@ -195,22 +185,18 @@ lex(hp)
wdp->word = word(parsehtime);
parsehtime = 0;
} while (wdp->word[0] != '\n');
- if (histlinep < histline + BUFSIZE) {
- *histlinep = '\0';
- if (histlinep > histline && histlinep[-1] == '\n')
- histlinep[-1] = '\0';
- histvalid = 1;
- }
- else {
- histline[BUFSIZE - 1] = '\0';
- }
+ cleanup_ignore(hp);
+ cleanup_until(hp);
+ Strbuf_terminate(&histline);
+ if (histline.len != 0 && histline.s[histline.len - 1] == '\n')
+ histline.s[histline.len - 1] = '\0';
+ histvalid = 1;
return (hadhist);
}
static time_t
-a2time_t(wordx)
- Char *wordx;
+a2time_t(Char *wordx)
{
/* Attempt to distinguish timestamps from other possible entries.
* Format: "+NNNNNNNNNN" (10 digits, left padded with ascii '0') */
@@ -222,8 +208,7 @@ a2time_t(wordx)
if (!wordx || *(s = wordx) != '+')
return (time_t)0;
- for (++s, ret = 0, ct = 0; *s; ++s, ++ct)
- {
+ for (++s, ret = 0, ct = 0; *s; ++s, ++ct) {
if (!isdigit((unsigned char)*s))
return (time_t)0;
ret = ret * 10 + (time_t)((unsigned char)*s - '0');
@@ -236,8 +221,7 @@ a2time_t(wordx)
}
void
-prlex(sp0)
- struct wordent *sp0;
+prlex(struct wordent *sp0)
{
struct wordent *sp = sp0->next;
@@ -252,9 +236,7 @@ prlex(sp0)
}
void
-copylex(hp, fp)
- struct wordent *hp;
- struct wordent *fp;
+copylex(struct wordent *hp, struct wordent *fp)
{
struct wordent *wdp;
@@ -262,9 +244,9 @@ copylex(hp, fp)
fp = fp->next;
do {
struct wordent *new;
-
- new = (struct wordent *) xmalloc((size_t) sizeof(*wdp));
- new->word = STRNULL;
+
+ new = xmalloc(sizeof(*new));
+ new->word = NULL;
new->prev = wdp;
new->next = hp;
wdp->next = new;
@@ -276,35 +258,38 @@ copylex(hp, fp)
}
void
-freelex(vp)
- struct wordent *vp;
+freelex(struct wordent *vp)
{
struct wordent *fp;
while (vp->next != vp) {
fp = vp->next;
vp->next = fp->next;
- if (fp->word != STRNULL)
- xfree((ptr_t) fp->word);
- xfree((ptr_t) fp);
+ xfree(fp->word);
+ xfree(fp);
}
vp->prev = vp;
}
+void
+lex_cleanup(void *xvp)
+{
+ struct wordent *vp;
+
+ vp = xvp;
+ freelex(vp);
+}
+
static Char *
-word(parsehtime)
- int parsehtime;
+word(int parsehtime)
{
eChar c, c1;
- Char *wp, *unfinished = 0;
- Char wbuf[BUFSIZE];
+ struct Strbuf wbuf = Strbuf_INIT;
Char hbuf[12];
int h;
int dolflg;
- int i;
- wp = wbuf;
- i = BUFSIZE - 4;
+ cleanup_push(&wbuf, Strbuf_cleanup);
loop:
while ((c = getC(DOALL)) == ' ' || c == '\t')
continue;
@@ -314,10 +299,10 @@ loop:
case '|':
case '<':
case '>':
- *wp++ = c;
+ Strbuf_append1(&wbuf, c);
c1 = getC(DOALL);
if (c1 == c)
- *wp++ = c1;
+ Strbuf_append1(&wbuf, c1);
else
ungetC(c1);
goto ret;
@@ -345,7 +330,7 @@ loop:
case '(':
case ')':
case '\n':
- *wp++ = c;
+ Strbuf_append1(&wbuf, c);
goto ret;
case '\\':
@@ -356,7 +341,7 @@ loop:
goto loop;
}
if (c != (eChar)HIST)
- *wp++ = '\\', --i;
+ Strbuf_append1(&wbuf, '\\');
c |= QUOTE;
default:
break;
@@ -412,7 +397,7 @@ loop:
break;
}
if (c != (eChar)HIST)
- *wp++ = '\\', --i;
+ Strbuf_append1(&wbuf, '\\');
c |= QUOTE;
}
else if (cmap(c, _QF | _QB)) { /* '"` */
@@ -424,35 +409,17 @@ loop:
break;
}
}
- if (--i > 0) {
- *wp++ = c;
- c = getC(dolflg);
- if (!unfinished)
- unfinished = wp - 1;
- switch (NLSFinished(unfinished, wp - unfinished, c)) {
- case 1:
- case 0:
- c |= QUOTE;
- break;
- default:
- unfinished = 0;
- break;
- }
- }
- else {
- seterror(ERR_WTOOLONG);
- wp = &wbuf[1];
- break;
- }
+ Strbuf_append1(&wbuf, c);
+ c = getC(dolflg);
}
ret:
- *wp = 0;
- return (Strsave(wbuf));
+ cleanup_ignore(&wbuf);
+ cleanup_until(&wbuf);
+ return Strbuf_finish(&wbuf);
}
static eChar
-getC1(flag)
- int flag;
+getC1(int flag)
{
eChar c;
@@ -461,14 +428,11 @@ getC1(flag)
peekc = 0;
return (c);
}
- if (lap) {
- if ((c = *lap++) == 0)
- lap = 0;
- else {
- if (cmap(c, _META | _QF | _QB))
- c |= QUOTE;
- return (c);
- }
+ if (lap < labuf.len) {
+ c = labuf.s[lap++];
+ if (cmap(c, _META | _QF | _QB))
+ c |= QUOTE;
+ return (c);
}
if ((c = peekd) != 0) {
peekd = 0;
@@ -511,26 +475,26 @@ getC1(flag)
}
static void
-getdol()
+getdol(void)
{
- Char *np, *ep;
- Char name[4 * MAXVARLEN + 1];
+ struct Strbuf name = Strbuf_INIT;
eChar c;
eChar sc;
- int special = 0, toolong;
+ int special = 0;
- np = name, *np++ = '$';
c = sc = getC(DOEXCL);
if (any("\t \n", c)) {
ungetD(c);
ungetC('$' | QUOTE);
return;
}
+ cleanup_push(&name, Strbuf_cleanup);
+ Strbuf_append1(&name, '$');
if (c == '{')
- *np++ = (Char) c, c = getC(DOEXCL);
+ Strbuf_append1(&name, c), c = getC(DOEXCL);
if (c == '#' || c == '?' || c == '%')
- special++, *np++ = (Char) c, c = getC(DOEXCL);
- *np++ = (Char) c;
+ special++, Strbuf_append1(&name, c), c = getC(DOEXCL);
+ Strbuf_append1(&name, c);
switch (c) {
case '<':
@@ -538,61 +502,41 @@ getdol()
case '!':
if (special)
seterror(ERR_SPDOLLT);
- *np = 0;
- addla(name);
- return;
+ goto end;
case '\n':
ungetD(c);
- np--;
+ name.len--;
if (!special)
seterror(ERR_NEWLINE);
- *np = 0;
- addla(name);
- return;
+ goto end;
case '*':
if (special)
seterror(ERR_SPSTAR);
- *np = 0;
- addla(name);
- return;
+ goto end;
default:
- toolong = 0;
if (Isdigit(c)) {
#ifdef notdef
/* let $?0 pass for now */
if (special) {
seterror(ERR_DIGIT);
- *np = 0;
- addla(name);
- return;
+ goto end;
}
#endif
- /* we know that np < &name[4] */
- ep = &np[MAXVARLEN];
while ((c = getC(DOEXCL)) != 0) {
if (!Isdigit(c))
break;
- if (np < ep)
- *np++ = (Char) c;
- else
- toolong = 1;
+ Strbuf_append1(&name, c);
}
}
else if (letter(c)) {
- /* we know that np < &name[4] */
- ep = &np[MAXVARLEN];
- toolong = 0;
while ((c = getC(DOEXCL)) != 0) {
/* Bugfix for ${v123x} from Chris Torek, DAS DEC-90. */
if (!letter(c) && !Isdigit(c))
break;
- if (np < ep)
- *np++ = (Char) c;
- else
- toolong = 1;
+ Strbuf_append1(&name, c);
}
}
else {
@@ -600,26 +544,14 @@ getdol()
seterror(ERR_VARILL);
else {
ungetD(c);
- --np;
+ name.len--;
}
- *np = 0;
- addla(name);
- return;
- }
- if (toolong) {
- seterror(ERR_VARTOOLONG);
- *np = 0;
- addla(name);
- return;
+ goto end;
}
break;
}
if (c == '[') {
- *np++ = (Char) c;
- /*
- * Name up to here is a max of MAXVARLEN + 8.
- */
- ep = &np[2 * MAXVARLEN + 8];
+ Strbuf_append1(&name, c);
do {
/*
* Michael Greim: Allow $ expansion to take place in selector
@@ -628,26 +560,14 @@ getdol()
c = getC(DOEXCL | DODOL);
if (c == '\n') {
ungetD(c);
- np--;
+ name.len--;
seterror(ERR_NLINDEX);
- *np = 0;
- addla(name);
- return;
+ goto end;
}
- if (np < ep)
- *np++ = (Char) c;
+ Strbuf_append1(&name, c);
} while (c != ']');
- *np = '\0';
- if (np >= ep) {
- seterror(ERR_SELOVFL);
- addla(name);
- return;
- }
c = getC(DOEXCL);
}
- /*
- * Name up to here is a max of 2 * MAXVARLEN + 8.
- */
if (c == ':') {
/*
* if the :g modifier is followed by a newline, then error right away!
@@ -656,38 +576,36 @@ getdol()
int gmodflag = 0, amodflag = 0;
-#ifndef COMPAT
do {
-#endif /* COMPAT */
- *np++ = (Char) c, c = getC(DOEXCL);
+ Strbuf_append1(&name, c), c = getC(DOEXCL);
if (c == 'g' || c == 'a') {
if (c == 'g')
gmodflag++;
else
amodflag++;
- *np++ = (Char) c; c = getC(DOEXCL);
+ Strbuf_append1(&name, c); c = getC(DOEXCL);
}
if ((c == 'g' && !gmodflag) || (c == 'a' && !amodflag)) {
if (c == 'g')
gmodflag++;
else
amodflag++;
- *np++ = (Char) c; c = getC(DOEXCL);
+ Strbuf_append1(&name, c); c = getC(DOEXCL);
}
- *np++ = (Char) c;
+ Strbuf_append1(&name, c);
/* scan s// [eichin:19910926.0512EST] */
if (c == 's') {
int delimcnt = 2;
eChar delim = getC(0);
- *np++ = (Char) delim;
-
+
+ Strbuf_append1(&name, delim);
if (!delim || letter(delim)
|| Isdigit(delim) || any(" \t\n", delim)) {
seterror(ERR_BADSUBST);
break;
- }
+ }
while ((c = getC(0)) != CHAR_ERR) {
- *np++ = (Char) c;
+ Strbuf_append1(&name, c);
if(c == delim) delimcnt--;
if(!delimcnt) break;
}
@@ -701,15 +619,11 @@ getdol()
if ((amodflag || gmodflag) && c == '\n')
stderror(ERR_VARSYN); /* strike */
seterror(ERR_BADMOD, c);
- *np = 0;
- addla(name);
- return;
+ goto end;
}
-#ifndef COMPAT
}
while ((c = getC(DOEXCL)) == ':');
ungetD(c);
-#endif /* COMPAT */
}
else
ungetD(c);
@@ -718,45 +632,40 @@ getdol()
if (c != '}') {
ungetD(c);
seterror(ERR_MISSING, '}');
- *np = 0;
- addla(name);
- return;
+ goto end;
}
- *np++ = (Char) c;
+ Strbuf_append1(&name, c);
}
- *np = 0;
- addla(name);
- return;
+ end:
+ cleanup_ignore(&name);
+ cleanup_until(&name);
+ addla(Strbuf_finish(&name));
}
+/* xfree()'s its argument */
void
-addla(cp)
- Char *cp;
+addla(Char *cp)
{
- Char buf[BUFSIZE];
-
- if (Strlen(cp) + (lap ? Strlen(lap) : 0) >=
- (sizeof(labuf) - 4) / sizeof(Char)) {
- seterror(ERR_EXPOVFL);
- return;
- }
- if (lap)
- (void) Strcpy(buf, lap);
- (void) Strcpy(labuf, cp);
- NLSQuote(labuf);
- if (lap)
- (void) Strcat(labuf, buf);
- lap = labuf;
+ static struct Strbuf buf; /* = Strbuf_INIT; */
+
+ buf.len = 0;
+ Strbuf_appendn(&buf, labuf.s + lap, labuf.len - lap);
+ labuf.len = 0;
+ Strbuf_append(&labuf, cp);
+ Strbuf_terminate(&labuf);
+ Strbuf_appendn(&labuf, buf.s, buf.len);
+ xfree(cp);
+ lap = 0;
}
-static Char lhsb[32];
-static Char slhs[32];
-static Char rhsb[64];
+/* left-hand side of last :s or search string of last ?event? */
+static struct Strbuf lhsb; /* = Strbuf_INIT; */
+static struct Strbuf slhs; /* = Strbuf_INIT; left-hand side of last :s */
+static struct Strbuf rhsb; /* = Strbuf_INIT; right-hand side of last :s */
static int quesarg;
static void
-getexcl(sc)
- Char sc;
+getexcl(Char sc)
{
struct wordent *hp, *ip;
int left, right, dol;
@@ -771,12 +680,7 @@ getexcl(sc)
}
quesarg = -1;
- if (uselastevent) {
- uselastevent = 0;
- lastev = eventno;
- }
- else
- lastev = eventno;
+ lastev = eventno;
hp = gethent(sc);
if (hp == 0)
return;
@@ -838,28 +742,19 @@ subst:
}
static struct wordent *
-getsub(en)
- struct wordent *en;
+getsub(struct wordent *en)
{
- Char *cp;
eChar delim;
eChar c;
eChar sc;
int global;
- Char orhsb[sizeof(rhsb) / sizeof(Char)];
-#ifndef COMPAT
do {
-#endif /* COMPAT */
exclnxt = 0;
global = 0;
sc = c = getC(0);
- if (c == 'g' || c == 'a') {
- global |= (c == 'g') ? 1 : 2;
- sc = c = getC(0);
- }
- if (((c =='g') && !(global & 1)) || ((c == 'a') && !(global & 2))) {
- global |= (c == 'g') ? 1 : 2;
+ while (c == 'g' || c == 'a') {
+ global |= (c == 'g') ? FLAG_G : FLAG_A;
sc = c = getC(0);
}
@@ -870,7 +765,7 @@ getsub(en)
case 'x':
case 'q':
- global |= 1;
+ global |= FLAG_G;
/*FALLTHROUGH*/
case 'h':
@@ -882,16 +777,18 @@ getsub(en)
break;
case '&':
- if (slhs[0] == 0) {
+ if (slhs.len == 0) {
seterror(ERR_NOSUBST);
return (en);
}
- (void) Strcpy(lhsb, slhs);
+ lhsb.len = 0;
+ Strbuf_append(&lhsb, slhs.s);
+ Strbuf_terminate(&lhsb);
break;
#ifdef notdef
case '~':
- if (lhsb[0] == 0)
+ if (lhsb.len == 0)
goto badlhs;
break;
#endif
@@ -900,11 +797,12 @@ getsub(en)
delim = getC(0);
if (letter(delim) || Isdigit(delim) || any(" \t\n", delim)) {
unreadc(delim);
- lhsb[0] = 0;
+ lhsb.len = 0;
seterror(ERR_BADSUBST);
return (en);
}
- cp = lhsb;
+ Strbuf_terminate(&lhsb);
+ lhsb.len = 0;
for (;;) {
c = getC(0);
if (c == '\n') {
@@ -913,26 +811,21 @@ getsub(en)
}
if (c == delim)
break;
- if (cp > &lhsb[sizeof(lhsb) / sizeof(Char) - 2]) {
- lhsb[0] = 0;
- seterror(ERR_BADSUBST);
- return (en);
- }
if (c == '\\') {
c = getC(0);
if (c != delim && c != '\\')
- *cp++ = '\\';
+ Strbuf_append1(&lhsb, '\\');
}
- *cp++ = (Char) c;
+ Strbuf_append1(&lhsb, c);
}
- if (cp != lhsb)
- *cp++ = 0;
- else if (lhsb[0] == 0) {
+ if (lhsb.len != 0)
+ Strbuf_terminate(&lhsb);
+ else if (lhsb.s[0] == 0) {
seterror(ERR_LHS);
return (en);
- }
- cp = rhsb;
- (void) Strcpy(orhsb, cp);
+ } else
+ lhsb.len = Strlen(lhsb.s); /* lhsb.s wasn't changed */
+ rhsb.len = 0;
for (;;) {
c = getC(0);
if (c == '\n') {
@@ -941,28 +834,14 @@ getsub(en)
}
if (c == delim)
break;
-#ifdef notdef
- if (c == '~') {
- if (&cp[Strlen(orhsb)] > &rhsb[sizeof(rhsb) /
- sizeof(Char) - 2])
- goto toorhs;
- (void) Strcpy(cp, orhsb);
- cp = Strend(cp);
- continue;
- }
-#endif
- if (cp > &rhsb[sizeof(rhsb) / sizeof(Char) - 2]) {
- seterror(ERR_RHSLONG);
- return (en);
- }
if (c == '\\') {
c = getC(0);
if (c != delim /* && c != '~' */ )
- *cp++ = '\\';
+ Strbuf_append1(&rhsb, '\\');
}
- *cp++ = (Char) c;
+ Strbuf_append1(&rhsb, c);
}
- *cp++ = 0;
+ Strbuf_terminate(&rhsb);
break;
default:
@@ -971,14 +850,14 @@ getsub(en)
seterror(ERR_BADBANGMOD, (int)c);
return (en);
}
- (void) Strcpy(slhs, lhsb);
+ slhs.len = 0;
+ Strbuf_append(&slhs, lhsb.s);
+ Strbuf_terminate(&slhs);
if (exclc)
en = dosub(sc, en, global);
-#ifndef COMPAT
}
while ((c = getC(0)) == ':');
unreadc(c);
-#endif /* COMPAT */
return (en);
}
@@ -994,10 +873,7 @@ getsub(en)
#define HIST_PURGE -50000000
static struct wordent *
-dosub(sc, en, global)
- Char sc;
- struct wordent *en;
- int global;
+dosub(Char sc, struct wordent *en, int global)
{
struct wordent lexi;
int didsub = 0, didone = 0;
@@ -1008,8 +884,7 @@ dosub(sc, en, global)
wdp = hp;
while (--i >= 0) {
- struct wordent *new =
- (struct wordent *) xcalloc(1, sizeof *wdp);
+ struct wordent *new = xcalloc(1, sizeof *wdp);
new->word = 0;
new->prev = wdp;
@@ -1020,20 +895,23 @@ dosub(sc, en, global)
if (en->word) {
Char *tword, *otword;
- if ((global & 1) || didsub == 0) {
- tword = subword(en->word, sc, &didone);
+ if ((global & FLAG_G) || didsub == 0) {
+ size_t pos;
+
+ pos = 0;
+ tword = subword(en->word, sc, &didone, &pos);
if (didone)
didsub = 1;
- if (global & 2) {
+ if (global & FLAG_A) {
while (didone && tword != STRNULL) {
otword = tword;
- tword = subword(otword, sc, &didone);
+ tword = subword(otword, sc, &didone, &pos);
if (Strcmp(tword, otword) == 0) {
- xfree((ptr_t) otword);
+ xfree(otword);
break;
}
else
- xfree((ptr_t) otword);
+ xfree(otword);
}
}
}
@@ -1053,17 +931,16 @@ dosub(sc, en, global)
return &(hst->Hlex);
}
+/* Return a newly allocated result of one modification of CP using the
+ operation TYPE. Set ADID to 1 if a modification was performed.
+ If TYPE == 's', perform substitutions only from *START_POS on and set
+ *START_POS to the position of next substitution attempt. */
static Char *
-subword(cp, type, adid)
- Char *cp;
- Char type;
- int *adid;
+subword(Char *cp, Char type, int *adid, size_t *start_pos)
{
- Char wbuf[BUFSIZE];
- Char *wp, *mp, *np;
- int i;
+ Char *wp;
+ const Char *mp, *np;
- *adid = 0;
switch (type) {
case 'r':
@@ -1075,19 +952,20 @@ subword(cp, type, adid)
case 'u':
case 'l':
wp = domod(cp, type);
- if (wp == 0)
+ if (wp == 0) {
+ *adid = 0;
return (Strsave(cp));
+ }
*adid = 1;
return (wp);
default:
- wp = wbuf;
- i = BUFSIZE - 4;
- for (mp = cp; *mp; mp++)
- if (matchs(mp, lhsb)) {
- for (np = cp; np < mp;)
- *wp++ = *np++, --i;
- for (np = rhsb; *np; np++)
+ for (mp = cp + *start_pos; *mp; mp++) {
+ if (matchs(mp, lhsb.s)) {
+ struct Strbuf wbuf = Strbuf_INIT;
+
+ Strbuf_appendn(&wbuf, cp, mp - cp);
+ for (np = rhsb.s; *np; np++)
switch (*np) {
case '\\':
@@ -1096,43 +974,26 @@ subword(cp, type, adid)
/* fall into ... */
default:
- if (--i < 0) {
- seterror(ERR_SUBOVFL);
- return (STRNULL);
- }
- *wp++ = *np;
+ Strbuf_append1(&wbuf, *np);
continue;
case '&':
- i -= Strlen(lhsb);
- if (i < 0) {
- seterror(ERR_SUBOVFL);
- return (STRNULL);
- }
- *wp = 0;
- (void) Strcat(wp, lhsb);
- wp = Strend(wp);
+ Strbuf_append(&wbuf, lhsb.s);
continue;
}
- mp += Strlen(lhsb);
- i -= Strlen(mp);
- if (i < 0) {
- seterror(ERR_SUBOVFL);
- return (STRNULL);
- }
- *wp = 0;
- (void) Strcat(wp, mp);
+ *start_pos = wbuf.len;
+ Strbuf_append(&wbuf, mp + lhsb.len);
*adid = 1;
- return (Strsave(wbuf));
+ return Strbuf_finish(&wbuf);
}
+ }
+ *adid = 0;
return (Strsave(cp));
}
}
Char *
-domod(cp, type)
- Char *cp;
- Char type;
+domod(Char *cp, Char type)
{
Char *wp, *xp;
int c;
@@ -1159,11 +1020,9 @@ domod(cp, type)
case 't':
if (!any(short2str(cp), '/'))
return (type == 't' ? Strsave(cp) : 0);
- wp = Strend(cp);
- while (*--wp != '/')
- continue;
+ wp = Strrchr(cp, '/');
if (type == 'h')
- xp = Strsave(cp), xp[wp - cp] = 0;
+ xp = Strnsave(cp, wp - cp);
else
xp = Strsave(wp + 1);
return (xp);
@@ -1176,7 +1035,7 @@ domod(cp, type)
if (type == 'e')
xp = Strsave(wp + 1);
else
- xp = Strsave(cp), xp[wp - cp] = 0;
+ xp = Strnsave(cp, wp - cp);
return (xp);
}
return (Strsave(type == 'e' ? STRNULL : cp));
@@ -1187,8 +1046,7 @@ domod(cp, type)
}
static int
-matchs(str, pat)
- Char *str, *pat;
+matchs(const Char *str, const Char *pat)
{
while (*str && *pat && *str == *pat)
str++, pat++;
@@ -1196,9 +1054,7 @@ matchs(str, pat)
}
static int
-getsel(al, ar, dol)
- int *al, *ar;
- int dol;
+getsel(int *al, int *ar, int dol)
{
eChar c = getC(0);
int i;
@@ -1282,8 +1138,7 @@ getsel(al, ar, dol)
}
static struct wordent *
-gethent(sc)
- Char sc;
+gethent(Char sc)
{
struct Hist *hp;
Char *np;
@@ -1331,46 +1186,46 @@ gethent(sc)
ungetC(HIST);
return (0);
}
- np = lhsb;
+ Strbuf_terminate(&lhsb);
+ lhsb.len = 0;
event = 0;
while (!cmap(c, _ESC | _META | _QF | _QB) && !any("^*-%${}:#", c)) {
if (event != -1 && Isdigit(c))
event = event * 10 + c - '0';
else
event = -1;
- if (np < &lhsb[sizeof(lhsb) / sizeof(Char) - 2])
- *np++ = (Char) c;
+ Strbuf_append1(&lhsb, c);
c = getC(0);
}
unreadc(c);
- if (np == lhsb) {
+ if (lhsb.len == 0) {
+ lhsb.len = Strlen(lhsb.s); /* lhsb.s wasn't changed */
ungetC(HIST);
return (0);
}
- *np++ = 0;
+ Strbuf_terminate(&lhsb);
if (event != -1) {
/*
* History had only digits
*/
if (back)
- event = eventno + (alhistp == 0) - (event ? event : 0);
+ event = eventno + (alhistp == 0) - event;
break;
}
if (back) {
- event = sizeof(lhsb) / sizeof(lhsb[0]);
- np = &lhsb[--event];
- *np-- = '\0';
- for (event--; np > lhsb; *np-- = lhsb[--event])
- continue;
- *np = '-';
+ Strbuf_append1(&lhsb, '\0'); /* Allocate space */
+ Strbuf_terminate(&lhsb);
+ memmove(lhsb.s + 1, lhsb.s, (lhsb.len - 1) * sizeof (*lhsb.s));
+ lhsb.s[0] = '-';
}
- hp = findev(lhsb, 0);
+ hp = findev(lhsb.s, 0);
if (hp)
lastev = hp->Hnum;
return (&hp->Hlex);
case '?':
- np = lhsb;
+ Strbuf_terminate(&lhsb);
+ lhsb.len = 0;
for (;;) {
c = getC(0);
if (c == '\n') {
@@ -1379,18 +1234,18 @@ gethent(sc)
}
if (c == '?')
break;
- if (np < &lhsb[sizeof(lhsb) / sizeof(Char) - 2])
- *np++ = (Char) c;
+ Strbuf_append1(&lhsb, c);
}
- if (np == lhsb) {
- if (lhsb[0] == 0) {
+ if (lhsb.len == 0) {
+ lhsb.len = Strlen(lhsb.s); /* lhsb.s wasn't changed */
+ if (lhsb.len == 0) {
seterror(ERR_NOSEARCH);
return (0);
}
}
else
- *np++ = 0;
- hp = findev(lhsb, 1);
+ Strbuf_terminate(&lhsb);
+ hp = findev(lhsb.s, 1);
if (hp)
lastev = hp->Hnum;
return (&hp->Hlex);
@@ -1404,13 +1259,12 @@ gethent(sc)
}
np = putn(event);
seterror(ERR_NOEVENT, short2str(np));
+ xfree(np);
return (0);
}
static struct Hist *
-findev(cp, anyarg)
- Char *cp;
- int anyarg;
+findev(Char *cp, int anyarg)
{
struct Hist *hp;
@@ -1460,8 +1314,7 @@ findev(cp, anyarg)
static void
-setexclp(cp)
- Char *cp;
+setexclp(Char *cp)
{
if (cp && cp[0] == '\n')
return;
@@ -1469,15 +1322,13 @@ setexclp(cp)
}
void
-unreadc(c)
- Char c;
+unreadc(Char c)
{
peekread = (Char) c;
}
eChar
-readc(wanteof)
- int wanteof;
+readc(int wanteof)
{
eChar c;
static int sincereal; /* Number of real EOFs we've seen */
@@ -1593,7 +1444,7 @@ reread:
#endif /* !WINNT_NATIVE */
{
#ifdef BSDJOBS
- int ctpgrp;
+ pid_t ctpgrp;
#endif /* BSDJOBS */
if (numeof != 0 && ++sincereal >= numeof) /* Too many EOFs? Bye! */
@@ -1606,7 +1457,7 @@ reread:
# ifdef _SEQUENT_
if (ctpgrp)
# endif /* _SEQUENT */
- (void) killpg((pid_t) ctpgrp, SIGHUP);
+ (void) killpg(ctpgrp, SIGHUP);
# ifdef notdef
/*
* With the walking process group fix, this message
@@ -1614,7 +1465,7 @@ reread:
* changes, the shell needs to adjust. Well too bad.
*/
xprintf(CGETS(16, 1, "Reset tty pgrp from %d to %d\n"),
- ctpgrp, tpgrp);
+ (int)ctpgrp, (int)tpgrp);
# endif /* notdef */
goto reread;
}
@@ -1646,7 +1497,7 @@ reread:
"\nUse \"exit\" to leave %s.\n"),
progname);
}
- reset();
+ reset();
} else {
/* If we don't have ignoreeof set, just fall through */
; /* EMPTY */
@@ -1660,88 +1511,90 @@ reread:
if (c == '\n' && onelflg)
onelflg--;
} while (c == 0);
- if (histlinep < histline + BUFSIZE)
- *histlinep++ = (Char) c;
+ Strbuf_append1(&histline, c);
return (c);
}
static void
-balloc(buf)
- int buf;
+balloc(int buf)
{
Char **nfbuf;
while (buf >= fblocks) {
- nfbuf = (Char **) xcalloc((size_t) (fblocks + 2),
- sizeof(Char **));
+ nfbuf = xcalloc(fblocks + 2, sizeof(Char **));
if (fbuf) {
(void) blkcpy(nfbuf, fbuf);
- xfree((ptr_t) fbuf);
+ xfree(fbuf);
}
fbuf = nfbuf;
- fbuf[fblocks] = (Char *) xcalloc(BUFSIZE, sizeof(Char));
+ fbuf[fblocks] = xcalloc(BUFSIZE, sizeof(Char));
fblocks++;
}
}
static ssize_t
-wide_read(fildes, buf, nchars, use_fclens)
- int fildes;
- Char *buf;
- size_t nchars;
- int use_fclens;
+wide_read(int fildes, Char *buf, size_t nchars, int use_fclens)
{
char cbuf[BUFSIZE + 1];
- ssize_t res, r;
+ ssize_t res, r = 0;
size_t partial;
-
- assert (nchars <= sizeof(cbuf)/sizeof(*cbuf));
+ int err;
+
+ if (nchars == 0)
+ return 0;
+ assert (nchars <= sizeof(cbuf) / sizeof(*cbuf));
USE(use_fclens);
res = 0;
partial = 0;
do {
size_t i;
+ size_t len = nchars > partial ? nchars - partial : 1;
+
+ if (partial + len >= sizeof(cbuf) / sizeof(*cbuf))
+ break;
- do
- r = read(fildes, cbuf + partial,
- nchars > partial ? nchars - partial : 1);
- while (partial != 0 && r < 0 && errno == EINTR);
+ r = xread(fildes, cbuf + partial, len);
+
if (partial == 0 && r <= 0)
break;
partial += r;
i = 0;
- while (i < partial) {
- int len;
+ while (i < partial && nchars != 0) {
+ int tlen;
- len = normal_mbtowc(buf + res, cbuf + i, partial - i);
- if (len == -1) {
+ tlen = normal_mbtowc(buf + res, cbuf + i, partial - i);
+ if (tlen == -1) {
reset_mbtowc();
- if (partial < MB_LEN_MAX && r > 0)
+ if ((partial - i) < MB_LEN_MAX && r > 0)
/* Maybe a partial character and there is still a chance
to read more */
break;
buf[res] = (unsigned char)cbuf[i] | INVALID_BYTE;
}
- if (len <= 0)
- len = 1;
+ if (tlen <= 0)
+ tlen = 1;
#ifdef WIDE_STRINGS
if (use_fclens)
- fclens[res] = len;
+ fclens[res] = tlen;
#endif
- i += len;
+ i += tlen;
res++;
nchars--;
}
if (i != partial)
memmove(cbuf, cbuf + i, partial - i);
partial -= i;
- } while (partial != 0);
- /* Throwing away possible partial multibyte characters on error */
+ } while (partial != 0 && nchars > 0);
+ /* Throwing away possible partial multibyte characters on error if the
+ stream is not seekable */
+ err = errno;
+ lseek(fildes, -(off_t)partial, L_INCR);
+ errno = err;
return res != 0 ? res : r;
}
static eChar
-bgetc()
+bgetc(void)
{
Char ch;
int c, off, buf;
@@ -1753,10 +1606,17 @@ bgetc()
(void) lseek(SHIN, fseekp, L_SET);
}
if (fseekp == feobp) {
+#ifdef WIDE_STRINGS
+ off_t bytes;
+ size_t i;
+
+ bytes = fbobp;
+ for (i = 0; i < (size_t)(feobp - fbobp); i++)
+ bytes += fclens[i];
+ fseekp = feobp = bytes;
+#endif
fbobp = feobp;
- do
- c = wide_read(SHIN, fbuf[0], BUFSIZE, 1);
- while (c < 0 && errno == EINTR);
+ c = wide_read(SHIN, fbuf[0], BUFSIZE, 1);
#ifdef convex
if (c < 0)
stderror(ERR_SYSTEM, progname, strerror(errno));
@@ -1797,9 +1657,8 @@ bgetc()
roomleft = BUFSIZE - off;
if (roomleft > numleft)
roomleft = numleft;
- (void) memmove((ptr_t) (fbuf[buf] + off),
- (ptr_t) (InputBuf + c - numleft),
- (size_t) (roomleft * sizeof(Char)));
+ (void) memcpy(fbuf[buf] + off, InputBuf + c - numleft,
+ roomleft * sizeof(Char));
numleft -= roomleft;
feobp += roomleft;
}
@@ -1808,7 +1667,7 @@ bgetc()
buf = (int) feobp / BUFSIZE;
balloc(buf);
roomleft = BUFSIZE - off;
- c = wide_read(SHIN, fbuf[buf] + off, (size_t) roomleft, 0);
+ c = wide_read(SHIN, fbuf[buf] + off, roomleft, 0);
if (c > 0)
feobp += c;
}
@@ -1832,7 +1691,7 @@ bgetc()
}
static void
-bfree()
+bfree(void)
{
int sb, i;
@@ -1843,7 +1702,7 @@ bfree()
sb = (int) (fseekp - 1) / BUFSIZE;
if (sb > 0) {
for (i = 0; i < sb; i++)
- xfree((ptr_t) fbuf[i]);
+ xfree(fbuf[i]);
(void) blkcpy(fbuf, &fbuf[sb]);
fseekp -= BUFSIZE * sb;
feobp -= BUFSIZE * sb;
@@ -1852,8 +1711,7 @@ bfree()
}
void
-bseek(l)
- struct Ain *l;
+bseek(struct Ain *l)
{
switch (aret = l->type) {
case TCSH_E_SEEK:
@@ -1877,12 +1735,12 @@ bseek(l)
fseekp = l->f_seek;
#ifdef WIDE_STRINGS
if (cantell) {
- if (fseekp >= fbobp) {
+ if (fseekp >= fbobp && feobp >= fbobp) {
size_t i;
off_t o;
o = fbobp;
- for (i = 0; i < feobp - fbobp; i++) {
+ for (i = 0; i < (size_t)(feobp - fbobp); i++) {
if (fseekp == o) {
fseekp = fbobp + i;
return;
@@ -1906,8 +1764,7 @@ bseek(l)
/* any similarity to bell telephone is purely accidental */
void
-btell(l)
-struct Ain *l;
+btell(struct Ain *l)
{
switch (l->type = aret) {
case TCSH_E_SEEK:
@@ -1926,11 +1783,11 @@ struct Ain *l;
return;
case TCSH_F_SEEK:
#ifdef WIDE_STRINGS
- if (cantell && fseekp >= fbobp && fseekp < feobp) {
+ if (cantell && fseekp >= fbobp && fseekp <= feobp) {
size_t i;
-
+
l->f_seek = fbobp;
- for (i = 0; i < fseekp - fbobp; i++)
+ for (i = 0; i < (size_t)(fseekp - fbobp); i++)
l->f_seek += fclens[i];
} else
#endif
@@ -1948,7 +1805,7 @@ struct Ain *l;
}
void
-btoeof()
+btoeof(void)
{
(void) lseek(SHIN, (off_t) 0, L_XTND);
aret = TCSH_F_SEEK;
@@ -1962,7 +1819,7 @@ btoeof()
}
void
-settell()
+settell(void)
{
off_t x;
cantell = 0;
@@ -1970,9 +1827,9 @@ settell()
return;
if ((x = lseek(SHIN, (off_t) 0, L_INCR)) == -1)
return;
- fbuf = (Char **) xcalloc(2, sizeof(Char **));
+ fbuf = xcalloc(2, sizeof(Char **));
fblocks = 1;
- fbuf[0] = (Char *) xcalloc(BUFSIZE, sizeof(Char));
+ fbuf[0] = xcalloc(BUFSIZE, sizeof(Char));
fseekp = fbobp = feobp = x;
cantell = 1;
}
diff --git a/contrib/tcsh/sh.misc.c b/contrib/tcsh/sh.misc.c
index ae9f04d..7c4094f 100644
--- a/contrib/tcsh/sh.misc.c
+++ b/contrib/tcsh/sh.misc.c
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/sh.misc.c,v 3.34 2005/01/18 20:24:50 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/sh.misc.c,v 3.45 2006/10/14 17:57:21 christos Exp $ */
/*
* sh.misc.c: Miscelaneous functions
*/
@@ -32,20 +32,19 @@
*/
#include "sh.h"
-RCSID("$Id: sh.misc.c,v 3.34 2005/01/18 20:24:50 christos Exp $")
+RCSID("$tcsh: sh.misc.c,v 3.45 2006/10/14 17:57:21 christos Exp $")
-static int renum __P((int, int));
-static Char **blkend __P((Char **));
-static Char **blkcat __P((Char **, Char **));
+static int renum (int, int);
+static Char **blkend (Char **);
+static Char **blkcat (Char **, Char **);
+static int xdup2 (int, int);
/*
* C Shell
*/
int
-any(s, c)
- const char *s;
- Char c;
+any(const char *s, Char c)
{
if (!s)
return (0); /* Check for nil pointer */
@@ -56,36 +55,38 @@ any(s, c)
}
void
-setzero(cp, i)
- char *cp;
- int i;
+setzero(void *p, size_t size)
{
- if (i != 0)
- do
- *cp++ = 0;
- while (--i);
+ memset(p, 0, size);
+}
+
+char *
+strnsave(const char *s, size_t len)
+{
+ char *r;
+
+ r = xmalloc(len + 1);
+ memcpy(r, s, len);
+ r[len] = '\0';
+ return r;
}
char *
-strsave(s)
- const char *s;
+strsave(const char *s)
{
- char *n, *r;
- const char *p;
+ char *r;
+ size_t size;
if (s == NULL)
s = "";
- for (p = s; *p++ != '\0';)
- continue;
- r = n = (char *) xmalloc((size_t)((((const char *) p) - s) * sizeof(char)));
- while ((*n++ = *s++) != '\0')
- continue;
+ size = strlen(s) + 1;
+ r = xmalloc(size);
+ memcpy(r, s, size);
return (r);
}
static Char **
-blkend(up)
- Char **up;
+blkend(Char **up)
{
while (*up)
@@ -95,8 +96,7 @@ blkend(up)
void
-blkpr(av)
- Char **av;
+blkpr(Char *const *av)
{
for (; *av; av++) {
@@ -106,22 +106,21 @@ blkpr(av)
}
}
-void
-blkexpand(av, str)
- Char **av;
- Char *str;
+Char *
+blkexpand(Char *const *av)
{
- *str = '\0';
+ struct Strbuf buf = Strbuf_INIT;
+
for (; *av; av++) {
- (void) Strcat(str, *av);
+ Strbuf_append(&buf, *av);
if (av[1])
- (void) Strcat(str, STRspace);
+ Strbuf_append1(&buf, ' ');
}
+ return Strbuf_finish(&buf);
}
int
-blklen(av)
- Char **av;
+blklen(Char **av)
{
int i = 0;
@@ -131,9 +130,7 @@ blklen(av)
}
Char **
-blkcpy(oav, bv)
- Char **oav;
- Char **bv;
+blkcpy(Char **oav, Char **bv)
{
Char **av = oav;
@@ -143,8 +140,7 @@ blkcpy(oav, bv)
}
static Char **
-blkcat(up, vp)
- Char **up, **vp;
+blkcat(Char **up, Char **vp)
{
(void) blkcpy(blkend(up), vp);
@@ -152,25 +148,42 @@ blkcat(up, vp)
}
void
-blkfree(av0)
- Char **av0;
+blkfree(Char **av0)
{
Char **av = av0;
if (!av0)
return;
for (; *av; av++)
- xfree((ptr_t) * av);
- xfree((ptr_t) av0);
+ xfree(*av);
+ xfree(av0);
+}
+
+void
+blk_cleanup(void *ptr)
+{
+ blkfree(ptr);
+}
+
+void
+blk_indirect_cleanup(void *xptr)
+{
+ Char ***ptr;
+
+ ptr = xptr;
+ blkfree(*ptr);
+ xfree(ptr);
}
Char **
-saveblk(v)
- Char **v;
+saveblk(Char **v)
{
- Char **newv =
- (Char **) xcalloc((size_t) (blklen(v) + 1), sizeof(Char **));
- Char **onewv = newv;
+ Char **newv, **onewv;
+
+ if (v == NULL)
+ return NULL;
+
+ onewv = newv = xcalloc(blklen(v) + 1, sizeof(Char **));
while (*v)
*newv++ = Strsave(*v++);
@@ -179,8 +192,7 @@ saveblk(v)
#ifndef HAVE_STRSTR
char *
-strstr(s, t)
- const char *s, *t;
+strstr(const char *s, const char *t)
{
do {
const char *ss = s;
@@ -188,17 +200,15 @@ strstr(s, t)
do
if (*tt == '\0')
- return ((char *) s);
+ return (s);
while (*ss++ == *tt++);
} while (*s++ != '\0');
return (NULL);
}
#endif /* !HAVE_STRSTR */
-#ifndef SHORT_STRINGS
char *
-strspl(cp, dp)
- const char *cp, *dp;
+strspl(const char *cp, const char *dp)
{
char *ep;
size_t cl, dl;
@@ -209,29 +219,23 @@ strspl(cp, dp)
dp = "";
cl = strlen(cp);
dl = strlen(dp);
- ep = (char *) xmalloc((cl + dl + 1) * sizeof(char));
+ ep = xmalloc((cl + dl + 1) * sizeof(char));
memcpy(ep, cp, cl);
memcpy(ep + cl, dp, dl + 1);
return (ep);
}
-#endif /* !SHORT_STRINGS */
-
Char **
-blkspl(up, vp)
- Char **up, **vp;
+blkspl(Char **up, Char **vp)
{
- Char **wp =
- (Char **) xcalloc((size_t) (blklen(up) + blklen(vp) + 1),
- sizeof(Char **));
+ Char **wp = xcalloc(blklen(up) + blklen(vp) + 1, sizeof(Char **));
(void) blkcpy(wp, up);
return (blkcat(wp, vp));
}
Char
-lastchr(cp)
- Char *cp;
+lastchr(Char *cp)
{
if (!cp)
@@ -248,9 +252,9 @@ lastchr(cp)
* any units which may have been left open accidentally.
*/
void
-closem()
+closem(void)
{
- int f;
+ int f, num_files;
#ifdef NLS_BUGS
#ifdef NLS_CATALOGS
@@ -261,7 +265,8 @@ closem()
/* suggested by Justin Bur; thanks to Karl Kleinpaste */
fix_yp_bugs();
#endif /* YPBUGS */
- for (f = 0; f < NOFILE; f++)
+ num_files = NOFILE;
+ for (f = 0; f < num_files; f++)
if (f != SHIN && f != SHOUT && f != SHDIAG && f != OLDSTD &&
f != FSHTTY
#ifdef MALLOC_TRACE
@@ -269,10 +274,10 @@ closem()
#endif /* MALLOC_TRACE */
)
{
- (void) close(f);
+ xclose(f);
#ifdef NISPLUS
if(f < 3)
- (void) open(_PATH_DEVNULL, O_RDONLY|O_LARGEFILE);
+ (void) xopen(_PATH_DEVNULL, O_RDONLY|O_LARGEFILE);
#endif /* NISPLUS */
}
#ifdef NLS_BUGS
@@ -290,9 +295,9 @@ closem()
* shell fd's being in units 16-19 which are closed automatically!
*/
void
-closech()
+closech(void)
{
- int f;
+ int f, num_files;
if (didcch)
return;
@@ -303,23 +308,24 @@ closech()
OLDSTD = 0;
isoutatty = isatty(SHOUT);
isdiagatty = isatty(SHDIAG);
- for (f = 3; f < NOFILE; f++)
- (void) close(f);
+ num_files = NOFILE;
+ for (f = 3; f < num_files; f++)
+ xclose(f);
}
#endif /* CLOSE_ON_EXEC */
void
-donefds()
+donefds(void)
{
- (void) close(0);
- (void) close(1);
- (void) close(2);
+ xclose(0);
+ xclose(1);
+ xclose(2);
didfds = 0;
#ifdef NISPLUS
{
- int fd = open(_PATH_DEVNULL, O_RDONLY|O_LARGEFILE);
+ int fd = xopen(_PATH_DEVNULL, O_RDONLY|O_LARGEFILE);
(void)dcopy(fd, 1);
(void)dcopy(fd, 2);
(void)dmove(fd, 0);
@@ -333,47 +339,44 @@ donefds()
* i.e. to a unit > FSAFE. This also happens in dcopy.
*/
int
-dmove(i, j)
- int i, j;
+dmove(int i, int j)
{
if (i == j || i < 0)
return (i);
#ifdef HAVE_DUP2
if (j >= 0) {
- (void) dup2(i, j);
+ (void) xdup2(i, j);
if (j != i)
- (void) close(i);
+ xclose(i);
return (j);
}
#endif
j = dcopy(i, j);
if (j != i)
- (void) close(i);
+ xclose(i);
return (j);
}
int
-dcopy(i, j)
- int i, j;
+dcopy(int i, int j)
{
if (i == j || i < 0 || (j < 0 && i > FSAFE))
return (i);
if (j >= 0) {
#ifdef HAVE_DUP2
- (void) dup2(i, j);
+ (void) xdup2(i, j);
return (j);
#else
- (void) close(j);
+ xclose(j);
#endif
}
return (renum(i, j));
}
static int
-renum(i, j)
- int i, j;
+renum(int i, int j)
{
int k = dup(i);
@@ -383,7 +386,7 @@ renum(i, j)
return (k);
if (k != j) {
j = renum(k, j);
- (void) close(k);
+ xclose(k);
return (j);
}
return (k);
@@ -395,20 +398,17 @@ renum(i, j)
* as well as by commands like "repeat".
*/
void
-lshift(v, c)
- Char **v;
- int c;
+lshift(Char **v, int c)
{
Char **u;
for (u = v; *u && --c >= 0; u++)
- xfree((ptr_t) *u);
+ xfree(*u);
(void) blkcpy(v, u);
}
int
-number(cp)
- Char *cp;
+number(Char *cp)
{
if (!cp)
return (0);
@@ -424,32 +424,25 @@ number(cp)
}
Char **
-copyblk(v)
- Char **v;
+copyblk(Char **v)
{
- Char **nv =
- (Char **) xcalloc((size_t) (blklen(v) + 1), sizeof(Char **));
+ Char **nv = xcalloc(blklen(v) + 1, sizeof(Char **));
return (blkcpy(nv, v));
}
-#ifndef SHORT_STRINGS
char *
-strend(cp)
- char *cp;
+strend(const char *cp)
{
if (!cp)
- return (cp);
+ return ((char *)(intptr_t)cp);
while (*cp)
cp++;
- return (cp);
+ return ((char *)(intptr_t)cp);
}
-#endif /* SHORT_STRINGS */
-
Char *
-strip(cp)
- Char *cp;
+strip(Char *cp)
{
Char *dp = cp;
@@ -461,8 +454,7 @@ strip(cp)
}
Char *
-quote(cp)
- Char *cp;
+quote(Char *cp)
{
Char *dp = cp;
@@ -473,33 +465,28 @@ quote(cp)
return (cp);
}
-Char *
-quote_meta(d, s)
- Char *d;
- const Char *s;
+const Char *
+quote_meta(struct Strbuf *buf, const Char *s)
{
- Char *r = d;
+ buf->len = 0;
while (*s != '\0') {
if (cmap(*s, _META | _DOL | _QF | _QB | _ESC | _GLOB))
- *d++ = '\\';
- *d++ = *s++;
+ Strbuf_append1(buf, '\\');
+ Strbuf_append1(buf, *s++);
}
- *d = '\0';
- return r;
+ Strbuf_terminate(buf);
+ return buf->s;
}
void
-udvar(name)
- Char *name;
+udvar(Char *name)
{
-
setname(short2str(name));
stderror(ERR_NAME | ERR_UNDVAR);
}
int
-prefix(sub, str)
- const Char *sub, *str;
+prefix(const Char *sub, const Char *str)
{
for (;;) {
@@ -511,3 +498,169 @@ prefix(sub, str)
return (0);
}
}
+#ifndef WINNT_NATIVE
+char *
+areadlink(const char *path)
+{
+ char *buf;
+ size_t size;
+ ssize_t res;
+
+ size = MAXPATHLEN + 1;
+ buf = xmalloc(size);
+ while ((size_t)(res = readlink(path, buf, size)) == size) {
+ size *= 2;
+ buf = xrealloc(buf, size);
+ }
+ if (res == -1) {
+ int err;
+
+ err = errno;
+ xfree(buf);
+ errno = err;
+ return NULL;
+ }
+ buf[res] = '\0';
+ return xrealloc(buf, res + 1);
+}
+#endif /*!WINNT_NATIVE*/
+
+void
+xclose(int fildes)
+{
+ if (fildes < 0)
+ return;
+ while (close(fildes) == -1 && errno == EINTR)
+ handle_pending_signals();
+}
+
+void
+xclosedir(DIR *dirp)
+{
+ while (closedir(dirp) == -1 && errno == EINTR)
+ handle_pending_signals();
+}
+
+int
+xcreat(const char *path, mode_t mode)
+{
+ int res;
+
+ while ((res = creat(path, mode)) == -1 && errno == EINTR)
+ handle_pending_signals();
+ return res;
+}
+
+#ifdef HAVE_DUP2
+static int
+xdup2(int fildes, int fildes2)
+{
+ int res;
+
+ while ((res = dup2(fildes, fildes2)) == -1 && errno == EINTR)
+ handle_pending_signals();
+ return res;
+}
+#endif
+
+struct group *
+xgetgrgid(gid_t xgid)
+{
+ struct group *res;
+
+ errno = 0;
+ while ((res = getgrgid(xgid)) == NULL && errno == EINTR) {
+ handle_pending_signals();
+ errno = 0;
+ }
+ return res;
+}
+
+struct passwd *
+xgetpwnam(const char *name)
+{
+ struct passwd *res;
+
+ errno = 0;
+ while ((res = getpwnam(name)) == NULL && errno == EINTR) {
+ handle_pending_signals();
+ errno = 0;
+ }
+ return res;
+}
+
+struct passwd *
+xgetpwuid(uid_t xuid)
+{
+ struct passwd *res;
+
+ errno = 0;
+ while ((res = getpwuid(xuid)) == NULL && errno == EINTR) {
+ handle_pending_signals();
+ errno = 0;
+ }
+ return res;
+}
+
+int
+xopen(const char *path, int oflag, ...)
+{
+ int res;
+
+ if ((oflag & O_CREAT) == 0) {
+ while ((res = open(path, oflag)) == -1 && errno == EINTR)
+ handle_pending_signals();
+ } else {
+ va_list ap;
+ mode_t mode;
+
+ va_start(ap, oflag);
+ /* "int" should actually be "mode_t after default argument
+ promotions". "int" is the best guess we have, "mode_t" used to be
+ "unsigned short", which we obviously can't use. */
+ mode = va_arg(ap, int);
+ va_end(ap);
+ while ((res = open(path, oflag, mode)) == -1 && errno == EINTR)
+ handle_pending_signals();
+ }
+ return res;
+}
+
+ssize_t
+xread(int fildes, void *buf, size_t nbyte)
+{
+ ssize_t res;
+
+ /* This is where we will be blocked most of the time, so handle signals
+ that didn't interrupt any system call. */
+ do
+ handle_pending_signals();
+ while ((res = read(fildes, buf, nbyte)) == -1 && errno == EINTR);
+ return res;
+}
+
+#ifdef POSIX
+int
+xtcsetattr(int fildes, int optional_actions, const struct termios *termios_p)
+{
+ int res;
+
+ while ((res = tcsetattr(fildes, optional_actions, termios_p)) == -1 &&
+ errno == EINTR)
+ handle_pending_signals();
+ return res;
+}
+#endif
+
+ssize_t
+xwrite(int fildes, const void *buf, size_t nbyte)
+{
+ ssize_t res;
+
+ /* This is where we will be blocked most of the time, so handle signals
+ that didn't interrupt any system call. */
+ do
+ handle_pending_signals();
+ while ((res = write(fildes, buf, nbyte)) == -1 && errno == EINTR);
+ return res;
+}
diff --git a/contrib/tcsh/sh.parse.c b/contrib/tcsh/sh.parse.c
index 74f82a1..2ef20c4 100644
--- a/contrib/tcsh/sh.parse.c
+++ b/contrib/tcsh/sh.parse.c
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/sh.parse.c,v 3.13 2004/11/23 02:10:49 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/sh.parse.c,v 3.18 2006/03/02 18:46:44 christos Exp $ */
/*
* sh.parse.c: Interpret a list of tokens
*/
@@ -32,21 +32,21 @@
*/
#include "sh.h"
-RCSID("$Id: sh.parse.c,v 3.13 2004/11/23 02:10:49 christos Exp $")
+RCSID("$tcsh: sh.parse.c,v 3.18 2006/03/02 18:46:44 christos Exp $")
/*
* C shell
*/
-static void asyntax __P((struct wordent *, struct wordent *));
-static void asyn0 __P((struct wordent *, struct wordent *));
-static void asyn3 __P((struct wordent *, struct wordent *));
-static struct wordent *freenod __P((struct wordent *, struct wordent *));
-static struct command *syn0 __P((struct wordent *, struct wordent *, int));
-static struct command *syn1 __P((struct wordent *, struct wordent *, int));
-static struct command *syn1a __P((struct wordent *, struct wordent *, int));
-static struct command *syn1b __P((struct wordent *, struct wordent *, int));
-static struct command *syn2 __P((struct wordent *, struct wordent *, int));
-static struct command *syn3 __P((struct wordent *, struct wordent *, int));
+static int asyntax (struct wordent *, struct wordent *);
+static int asyn0 (struct wordent *, struct wordent *);
+static int asyn3 (struct wordent *, struct wordent *);
+static struct wordent *freenod (struct wordent *, struct wordent *);
+static struct command *syn0 (const struct wordent *, const struct wordent *, int);
+static struct command *syn1 (const struct wordent *, const struct wordent *, int);
+static struct command *syn1a (const struct wordent *, const struct wordent *, int);
+static struct command *syn1b (const struct wordent *, const struct wordent *, int);
+static struct command *syn2 (const struct wordent *, const struct wordent *, int);
+static struct command *syn3 (const struct wordent *, const struct wordent *, int);
#define ALEFT 51 /* max of 50 alias expansions */
#define HLEFT 11 /* max of 10 history expansions */
@@ -56,45 +56,33 @@ static struct command *syn3 __P((struct wordent *, struct wordent *, int));
* If word 0 of a command has an alias, do it.
* Repeat a maximum of 50 times.
*/
-static int aleft;
extern int hleft;
void
-alias(lexp)
- struct wordent *lexp;
+alias(struct wordent *lexp)
{
- jmp_buf_t osetexit;
+ int aleft;
aleft = ALEFT;
hleft = HLEFT;
- getexit(osetexit);
- (void) setexit();
- if (haderr) {
- resexit(osetexit);
- reset();
- }
- if (--aleft == 0)
- stderror(ERR_ALIASLOOP);
- asyntax(lexp->next, lexp);
- resexit(osetexit);
+ do {
+ if (--aleft == 0)
+ stderror(ERR_ALIASLOOP);
+ } while (asyntax(lexp->next, lexp) != 0);
}
-static void
-asyntax(p1, p2)
- struct wordent *p1, *p2;
+static int
+asyntax(struct wordent *p1, struct wordent *p2)
{
- while (p1 != p2)
- if (any(";&\n", p1->word[0]))
- p1 = p1->next;
- else {
- asyn0(p1, p2);
- return;
- }
+ while (p1 != p2) {
+ if (!any(";&\n", p1->word[0]))
+ return asyn0(p1, p2);
+ p1 = p1->next;
+ }
+ return 0;
}
-static void
-asyn0(p1, p2)
- struct wordent *p1;
- struct wordent *p2;
+static int
+asyn0(struct wordent *p1, struct wordent *p2)
{
struct wordent *p;
int l = 0;
@@ -123,46 +111,53 @@ asyn0(p1, p2)
case '\n':
if (l != 0)
continue;
- asyn3(p1, p);
- asyntax(p->next, p2);
- return;
+ if (asyn3(p1, p) != 0)
+ return 1;
+ return asyntax(p->next, p2);
default:
break;
}
if (l == 0)
- asyn3(p1, p2);
+ return asyn3(p1, p2);
+ return 0;
}
static void
-asyn3(p1, p2)
- struct wordent *p1;
- struct wordent *p2;
+alvec_cleanup(void *dummy)
+{
+ USE(dummy);
+ alhistp = NULL;
+ alhistt = NULL;
+ alvec = NULL;
+}
+
+static int
+asyn3(struct wordent *p1, struct wordent *p2)
{
struct varent *ap;
struct wordent alout;
int redid;
if (p1 == p2)
- return;
+ return 0;
if (p1->word[0] == '(') {
for (p2 = p2->prev; p2->word[0] != ')'; p2 = p2->prev)
if (p2 == p1)
- return;
+ return 0;
if (p2 == p1->next)
- return;
- asyn0(p1->next, p2);
- return;
+ return 0;
+ return asyn0(p1->next, p2);
}
ap = adrof1(p1->word, &aliases);
if (ap == 0)
- return;
+ return 0;
alhistp = p1->prev;
alhistt = p2;
alvec = ap->vec;
+ cleanup_push(&alvec, alvec_cleanup);
redid = lex(&alout);
- alhistp = alhistt = 0;
- alvec = 0;
+ cleanup_until(&alvec);
if (seterr) {
freelex(&alout);
stderror(ERR_OLD);
@@ -171,7 +166,7 @@ asyn3(p1, p2)
Char *cp = alout.next->word;
alout.next->word = Strspl(STRQNULL, cp);
- xfree((ptr_t) cp);
+ xfree(cp);
}
p1 = freenod(p1, redid ? p2 : p1->next);
if (alout.next != &alout) {
@@ -179,22 +174,21 @@ asyn3(p1, p2)
alout.prev->prev->next = p1->next;
alout.next->prev = p1;
p1->next = alout.next;
- xfree((ptr_t) alout.prev->word);
- xfree((ptr_t) (alout.prev));
+ xfree(alout.prev->word);
+ xfree(alout.prev);
}
- reset(); /* throw! */
+ return 1;
}
static struct wordent *
-freenod(p1, p2)
- struct wordent *p1, *p2;
+freenod(struct wordent *p1, struct wordent *p2)
{
struct wordent *retp = p1->prev;
while (p1 != p2) {
- xfree((ptr_t) p1->word);
+ xfree(p1->word);
p1 = p1->next;
- xfree((ptr_t) (p1->prev));
+ xfree(p1->prev);
}
retp->next = p2;
p2->prev = retp;
@@ -212,9 +206,7 @@ freenod(p1, p2)
* syn0
*/
struct command *
-syntax(p1, p2, flags)
- struct wordent *p1, *p2;
- int flags;
+syntax(const struct wordent *p1, const struct wordent *p2, int flags)
{
while (p1 != p2)
@@ -231,11 +223,9 @@ syntax(p1, p2, flags)
* syn1 & syntax
*/
static struct command *
-syn0(p1, p2, flags)
- struct wordent *p1, *p2;
- int flags;
+syn0(const struct wordent *p1, const struct wordent *p2, int flags)
{
- struct wordent *p;
+ const struct wordent *p;
struct command *t, *t1;
int l;
@@ -272,7 +262,7 @@ syn0(p1, p2, flags)
if (t1->t_dtyp == NODE_LIST ||
t1->t_dtyp == NODE_AND ||
t1->t_dtyp == NODE_OR) {
- t = (struct command *) xcalloc(1, sizeof(*t));
+ t = xcalloc(1, sizeof(*t));
t->t_dtyp = NODE_PAREN;
t->t_dflg = F_AMPERSAND | F_NOINTERRUPT;
t->t_dspr = t1;
@@ -280,7 +270,7 @@ syn0(p1, p2, flags)
}
else
t1->t_dflg |= F_AMPERSAND | F_NOINTERRUPT;
- t = (struct command *) xcalloc(1, sizeof(*t));
+ t = xcalloc(1, sizeof(*t));
t->t_dtyp = NODE_LIST;
t->t_dflg = 0;
t->t_dcar = t1;
@@ -301,11 +291,9 @@ syn0(p1, p2, flags)
* syn1a ; syntax
*/
static struct command *
-syn1(p1, p2, flags)
- struct wordent *p1, *p2;
- int flags;
+syn1(const struct wordent *p1, const struct wordent *p2, int flags)
{
- struct wordent *p;
+ const struct wordent *p;
struct command *t;
int l;
@@ -325,7 +313,7 @@ syn1(p1, p2, flags)
case '\n':
if (l != 0)
break;
- t = (struct command *) xcalloc(1, sizeof(*t));
+ t = xcalloc(1, sizeof(*t));
t->t_dtyp = NODE_LIST;
t->t_dcar = syn1a(p1, p, flags);
t->t_dcdr = syntax(p->next, p2, flags);
@@ -345,11 +333,9 @@ syn1(p1, p2, flags)
* syn1b || syn1a
*/
static struct command *
-syn1a(p1, p2, flags)
- struct wordent *p1, *p2;
- int flags;
+syn1a(const struct wordent *p1, const struct wordent *p2, int flags)
{
- struct wordent *p;
+ const struct wordent *p;
struct command *t;
int l = 0;
@@ -368,7 +354,7 @@ syn1a(p1, p2, flags)
if (p->word[1] != '|')
continue;
if (l == 0) {
- t = (struct command *) xcalloc(1, sizeof(*t));
+ t = xcalloc(1, sizeof(*t));
t->t_dtyp = NODE_OR;
t->t_dcar = syn1b(p1, p, flags);
t->t_dcdr = syn1a(p->next, p2, flags);
@@ -389,11 +375,9 @@ syn1a(p1, p2, flags)
* syn2 && syn1b
*/
static struct command *
-syn1b(p1, p2, flags)
- struct wordent *p1, *p2;
- int flags;
+syn1b(const struct wordent *p1, const struct wordent *p2, int flags)
{
- struct wordent *p;
+ const struct wordent *p;
struct command *t;
int l = 0;
@@ -410,7 +394,7 @@ syn1b(p1, p2, flags)
case '&':
if (p->word[1] == '&' && l == 0) {
- t = (struct command *) xcalloc(1, sizeof(*t));
+ t = xcalloc(1, sizeof(*t));
t->t_dtyp = NODE_AND;
t->t_dcar = syn2(p1, p, flags);
t->t_dcdr = syn1b(p->next, p2, flags);
@@ -432,11 +416,9 @@ syn1b(p1, p2, flags)
* syn3 |& syn2
*/
static struct command *
-syn2(p1, p2, flags)
- struct wordent *p1, *p2;
- int flags;
+syn2(const struct wordent *p1, const struct wordent *p2, int flags)
{
- struct wordent *p, *pn;
+ const struct wordent *p, *pn;
struct command *t;
int l = 0;
int f;
@@ -455,7 +437,7 @@ syn2(p1, p2, flags)
case '|':
if (l != 0)
continue;
- t = (struct command *) xcalloc(1, sizeof(*t));
+ t = xcalloc(1, sizeof(*t));
f = flags | P_OUT;
pn = p->next;
if (pn != p2 && pn->word[0] == '&') {
@@ -475,7 +457,7 @@ syn2(p1, p2, flags)
return (syn3(p1, p2, flags));
}
-static char RELPAR[] = {'<', '>', '(', ')', '\0'};
+static const char RELPAR[] = {'<', '>', '(', ')', '\0'};
/*
* syn3
@@ -486,12 +468,10 @@ static char RELPAR[] = {'<', '>', '(', ')', '\0'};
* KEYWORD = (@ exit foreach if set switch test while)
*/
static struct command *
-syn3(p1, p2, flags)
- struct wordent *p1, *p2;
- int flags;
+syn3(const struct wordent *p1, const struct wordent *p2, int flags)
{
- struct wordent *p;
- struct wordent *lp, *rp;
+ const struct wordent *p;
+ const struct wordent *lp, *rp;
struct command *t;
int l;
Char **av;
@@ -561,8 +541,8 @@ again:
}
if (n < 0)
n = 0;
- t = (struct command *) xcalloc(1, sizeof(*t));
- av = (Char **) xcalloc((size_t) (n + 1), sizeof(Char **));
+ t = xcalloc(1, sizeof(*t));
+ av = xcalloc(n + 1, sizeof(Char **));
t->t_dcom = av;
n = 0;
if (p2->word[0] == ')')
@@ -667,8 +647,7 @@ again:
}
void
-freesyn(t)
- struct command *t;
+freesyn(struct command *t)
{
Char **v;
@@ -678,15 +657,15 @@ freesyn(t)
case NODE_COMMAND:
for (v = t->t_dcom; *v; v++)
- xfree((ptr_t) * v);
- xfree((ptr_t) (t->t_dcom));
- xfree((ptr_t) t->t_dlef);
- xfree((ptr_t) t->t_drit);
+ xfree(*v);
+ xfree(t->t_dcom);
+ xfree(t->t_dlef);
+ xfree(t->t_drit);
break;
case NODE_PAREN:
freesyn(t->t_dspr);
- xfree((ptr_t) t->t_dlef);
- xfree((ptr_t) t->t_drit);
+ xfree(t->t_dlef);
+ xfree(t->t_drit);
break;
case NODE_AND:
@@ -698,5 +677,14 @@ freesyn(t)
default:
break;
}
- xfree((ptr_t) t);
+ xfree(t);
+}
+
+void
+syntax_cleanup(void *xt)
+{
+ struct command *t;
+
+ t = xt;
+ freesyn(t);
}
diff --git a/contrib/tcsh/sh.print.c b/contrib/tcsh/sh.print.c
index d7bde3a..4fc79cf 100644
--- a/contrib/tcsh/sh.print.c
+++ b/contrib/tcsh/sh.print.c
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/sh.print.c,v 3.28 2005/03/03 17:19:35 kim Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/sh.print.c,v 3.33 2006/08/23 15:03:14 christos Exp $ */
/*
* sh.print.c: Primitive Output routines.
*/
@@ -32,7 +32,7 @@
*/
#include "sh.h"
-RCSID("$Id: sh.print.c,v 3.28 2005/03/03 17:19:35 kim Exp $")
+RCSID("$tcsh: sh.print.c,v 3.33 2006/08/23 15:03:14 christos Exp $")
#include "ed.h"
@@ -40,7 +40,7 @@ extern int Tty_eight_bit;
int lbuffed = 1; /* true if line buffered */
-static void p2dig __P((unsigned int));
+static void p2dig (unsigned int);
/*
* C Shell
@@ -48,8 +48,7 @@ static void p2dig __P((unsigned int));
#if defined(BSDLIMIT) || defined(RLIMIT_CPU)
void
-psecs(l)
- unsigned long l;
+psecs(unsigned long l)
{
int i;
@@ -70,15 +69,14 @@ minsec:
#endif
-void
-pcsecs(l) /* PWP: print mm:ss.dd, l is in sec*100 */
+void /* PWP: print mm:ss.dd, l is in sec*100 */
#ifdef BSDTIMES
- unsigned long l;
+pcsecs(unsigned long l)
#else /* BSDTIMES */
# ifndef POSIX
- time_t l;
+pcsecs(time_t l)
# else /* POSIX */
- clock_t l;
+pcsecs(clock_t l)
# endif /* POSIX */
#endif /* BSDTIMES */
{
@@ -102,8 +100,7 @@ minsec:
}
static void
-p2dig(i)
- unsigned int i;
+p2dig(unsigned i)
{
xprintf("%u%u", i / 10, i % 10);
@@ -114,6 +111,16 @@ char *linp = linbuf;
int output_raw = 0; /* PWP */
int xlate_cr = 0; /* HE */
+/* For cleanup_push() */
+void
+output_raw_restore(void *xorig)
+{
+ int *orig;
+
+ orig = xorig;
+ output_raw = *orig;
+}
+
#ifdef WIDE_STRINGS
void
putwraw(Char c)
@@ -139,37 +146,29 @@ xputwchar(Char c)
#endif
void
-xputchar(c)
- int c;
+xputchar(int c)
{
- int atr = 0;
+ int atr;
- atr |= c & ATTRIBUTES & TRIM;
+ atr = c & ATTRIBUTES & TRIM;
c &= CHAR | QUOTE;
if (!output_raw && (c & QUOTE) == 0) {
- if (iscntrl(c) && (c < 0x80 || MB_CUR_MAX == 1)) {
+ if (iscntrl(c) && (ASC(c) < 0x80 || MB_CUR_MAX == 1)) {
+ if (c != '\t' && c != '\n'
#ifdef COLORCAT
- if (c != '\t' && c != '\n' && !(adrof(STRcolorcat) && c=='\033') && (xlate_cr || c != '\r'))
-#else
- if (c != '\t' && c != '\n' && (xlate_cr || c != '\r'))
+ && !(adrof(STRcolorcat) && c == CTL_ESC('\033'))
#endif
+ && (xlate_cr || c != '\r'))
{
xputchar('^' | atr);
-#ifdef IS_ASCII
- if (c == 0177)
- c = '?';
- else
- c |= 0100;
-#else
if (c == CTL_ESC('\177'))
c = '?';
else
- c =_toebcdic[_toascii[c]|0100];
-#endif
-
+ /* Note: for IS_ASCII, this compiles to: c = c | 0100 */
+ c = CTL_ESC(ASC(c)|0100);
}
}
- else if (!isprint(c) && (c < 0x80 || MB_CUR_MAX == 1)) {
+ else if (!isprint(c) && (ASC(c) < 0x80 || MB_CUR_MAX == 1)) {
xputchar('\\' | atr);
xputchar((((c >> 6) & 7) + '0') | atr);
xputchar((((c >> 3) & 7) + '0') | atr);
@@ -189,8 +188,7 @@ xputchar(c)
}
int
-putraw(c)
- int c;
+putraw(int c)
{
if (haderr ? (didfds ? is2atty : isdiagatty) :
(didfds ? is1atty : isoutatty)) {
@@ -205,8 +203,7 @@ putraw(c)
}
int
-putpure(c)
- int c;
+putpure(int c)
{
c &= CHAR;
@@ -217,17 +214,16 @@ putpure(c)
}
void
-drainoline()
+drainoline(void)
{
linp = linbuf;
}
void
-flush()
+flush(void)
{
int unit;
static int interrupted = 0;
- size_t sz;
/* int lmode; */
@@ -237,7 +233,7 @@ flush()
return;
if (interrupted) {
interrupted = 0;
- linp = linbuf; /* avoid resursion as stderror calls flush */
+ linp = linbuf; /* avoid recursion as stderror calls flush */
stderror(ERR_SILENT);
}
interrupted = 1;
@@ -251,12 +247,11 @@ flush()
lmode & LFLUSHO) {
lmode = LFLUSHO;
(void) ioctl(unit, TIOCLBIC, (ioclt_t) & lmode);
- (void) write(unit, "\n", 1);
+ (void) xwrite(unit, "\n", 1);
}
#endif
#endif
- sz = (size_t) (linp - linbuf);
- if (write(unit, linbuf, sz) == -1)
+ if (xwrite(unit, linbuf, linp - linbuf) == -1)
switch (errno) {
#ifdef EIO
/* We lost our tty */
diff --git a/contrib/tcsh/sh.proc.c b/contrib/tcsh/sh.proc.c
index 62b75af..bf6fb3a 100644
--- a/contrib/tcsh/sh.proc.c
+++ b/contrib/tcsh/sh.proc.c
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/sh.proc.c,v 3.90 2005/03/03 19:57:07 kim Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/sh.proc.c,v 3.104 2006/09/27 16:59:04 mitr Exp $ */
/*
* sh.proc.c: Job manipulations
*/
@@ -32,7 +32,7 @@
*/
#include "sh.h"
-RCSID("$Id: sh.proc.c,v 3.90 2005/03/03 19:57:07 kim Exp $")
+RCSID("$tcsh: sh.proc.c,v 3.104 2006/09/27 16:59:04 mitr Exp $")
#include "ed.h"
#include "tc.h"
@@ -77,6 +77,14 @@ RCSID("$Id: sh.proc.c,v 3.90 2005/03/03 19:57:07 kim Exp $")
# endif /* !BSDWAIT */
#endif /* !WCOREDUMP */
+#ifndef JOBDEBUG
+# define jobdebug_xprintf(x) (void)0
+# define jobdebug_flush() (void)0
+#else
+# define jobdebug_xprintf(s) xprintf s
+# define jobdebug_flush() flush()
+#endif
+
/*
* C Shell - functions that manage processes, handling hanging, termination
*/
@@ -106,38 +114,40 @@ static struct tms zru = {0L, 0L, 0L, 0L}, lru = {0L, 0L, 0L, 0L};
# endif /* !_SEQUENT_ */
#endif /* !BSDTIMES */
+#ifndef BSDTIMES
+static int timesdone; /* shtimes buffer full ? */
+#endif /* BSDTIMES */
+
#ifndef RUSAGE_CHILDREN
# define RUSAGE_CHILDREN -1
#endif /* RUSAGE_CHILDREN */
-static void pflushall __P((void));
-static void pflush __P((struct process *));
-static void pfree __P((struct process *));
-static void pclrcurr __P((struct process *));
-static void padd __P((struct command *));
-static int pprint __P((struct process *, int));
-static void ptprint __P((struct process *));
-static void pads __P((Char *));
-static void pkill __P((Char **, int));
-static struct process *pgetcurr __P((struct process *));
-static void okpcntl __P((void));
-static void setttypgrp __P((int));
+static void pflushall (void);
+static void pflush (struct process *);
+static void pfree (struct process *);
+static void pclrcurr (struct process *);
+static void padd (struct command *);
+static int pprint (struct process *, int);
+static void ptprint (struct process *);
+static void pads (Char *);
+static void pkill (Char **, int);
+static struct process *pgetcurr (struct process *);
+static void okpcntl (void);
+static void setttypgrp (int);
/*
- * pchild - called at interrupt level by the SIGCHLD signal
+ * pchild - call queued by the SIGCHLD signal
* indicating that at least one child has terminated or stopped
* thus at least one wait system call will definitely return a
* childs status. Top level routines (like pwait) must be sure
* to mask interrupts when playing with the proclist data structures!
*/
-RETSIGTYPE
-/*ARGSUSED*/
-pchild(snum)
-int snum;
+void
+pchild(void)
{
struct process *pp;
struct process *fp;
- int pid;
+ pid_t pid;
#ifdef BSDWAIT
union wait w;
#else /* !BSDWAIT */
@@ -161,33 +171,13 @@ int snum;
# endif /* !_SEQUENT_ */
#endif /* !BSDTIMES */
- USE(snum);
-#ifdef JOBDEBUG
- xprintf("pchild()\n");
-#endif /* JOBDEBUG */
-
-/* Christos on where the signal(SIGCHLD, pchild) shoud be:
- *
- * I think that it should go *after* the wait, unlike most signal handlers.
- *
- * In release two (for which I have manuals), it says that wait will remove
- * the first child from the queue of dead children.
- * All the rest of the children that die while in the signal handler of the
- * SIGC(H)LD, will be placed in the queue. If signal is called to re-establish
- * the signal handler, and there are items in the queue, the process will
- * receive another SIGC(H)LD before signal returns. BTW this is from the
- * manual page on comp-sim... Maybe it is not applicable to the hp's, but
- * I read on the news in comp.unix.wizards or comp.unix.questions yesterday
- * that another person was claiming the the signal() call should be after
- * the wait().
- */
+ jobdebug_xprintf(("pchild()\n"));
loop:
+ jobdebug_xprintf(("Waiting...\n"));
+ jobdebug_flush();
errno = 0; /* reset, just in case */
-#ifdef JOBDEBUG
- xprintf("Waiting...\n");
- flush();
-#endif /* JOBDEBUG */
+
#ifndef WINNT_NATIVE
# ifdef BSDJOBS
# ifdef BSDTIMES
@@ -197,7 +187,7 @@ loop:
(setintr && (intty || insource) ? WNOHANG | WUNTRACED : WNOHANG), &ru);
# else
/* both a wait3 and rusage */
-# if !defined(BSDWAIT) || defined(NeXT) || defined(MACH) || defined(linux) || defined(__GNU__) || defined(__GLIBC__) || (defined(IRIS4D) && (__STDC__ || defined(PROTOTYPES)) && SYSVREL <= 3) || defined(__lucid) || defined(__osf__)
+# if !defined(BSDWAIT) || defined(NeXT) || defined(MACH) || defined(linux) || defined(__GNU__) || defined(__GLIBC__) || (defined(IRIS4D) && SYSVREL <= 3) || defined(__lucid) || defined(__osf__)
pid = wait3(&w,
(setintr && (intty || insource) ? WNOHANG | WUNTRACED : WNOHANG), &ru);
# else /* BSDWAIT */
@@ -235,7 +225,7 @@ loop:
# else /* !BSDTIMES */
# ifdef ODT /* For Sco Unix 3.2.0 or ODT 1.0 */
# define HAVEwait3
- pid = waitpid(-1, &w,
+ pid = waitpid(-1, &w,
(setintr && (intty || insource) ? WNOHANG | WUNTRACED : WNOHANG));
# endif /* ODT */
# if defined(aiws) || defined(uts)
@@ -244,50 +234,35 @@ loop:
(setintr && (intty || insource) ? WNOHANG | WUNTRACED : WNOHANG), 0);
# endif /* aiws || uts */
# ifndef HAVEwait3
-# ifdef UNRELSIGS
+# ifndef BSDWAIT
/* no wait3, therefore no rusage */
/* on Sys V, this may hang. I hope it's not going to be a problem */
-# ifdef _MINIX
- pid = wait(&w);
-# else /* !_MINIX */
- pid = ourwait(&w.w_status);
-# endif /* _MINIX */
-# else /* !UNRELSIGS */
+ pid = wait(&w);
+# else /* BSDWAIT */
/*
* XXX: for greater than 3 we should use waitpid().
* but then again, SVR4 falls into the POSIX/BSDJOBS category.
*/
- pid = wait(&w.w_status);
-# endif /* !UNRELSIGS */
+ pid = wait(&w.w_status);
+# endif /* BSDWAIT */
# endif /* !HAVEwait3 */
# endif /* !BSDTIMES */
-# ifndef BSDSIGS
- (void) sigset(SIGCHLD, pchild);
-# endif /* !BSDSIGS */
# endif /* !BSDJOBS */
#else /* WINNT_NATIVE */
- {
- extern int insource;
- pid = waitpid(-1, &w,
+ pid = waitpid(-1, &w,
(setintr && (intty || insource) ? WNOHANG | WUNTRACED : WNOHANG));
- }
#endif /* WINNT_NATIVE */
-#ifdef JOBDEBUG
- xprintf("parent %d pid %d, retval %x termsig %x retcode %x\n",
- getpid(), pid, w, WTERMSIG(w), WEXITSTATUS(w));
- flush();
-#endif /* JOBDEBUG */
+ jobdebug_xprintf(("parent %d pid %d, retval %x termsig %x retcode %x\n",
+ (int)getpid(), (int)pid, w, WTERMSIG(w),
+ WEXITSTATUS(w)));
+ jobdebug_flush();
if ((pid == 0) || (pid == -1)) {
-#ifdef JOBDEBUG
- xprintf("errno == %d\n", errno);
-#endif /* JOBDEBUG */
- if (errno == EINTR) {
- errno = 0;
+ handle_pending_signals();
+ jobdebug_xprintf(("errno == %d\n", errno));
+ if (errno == EINTR)
goto loop;
- }
- pnoprocesses = pid == -1;
goto end;
}
for (pp = proclist.p_next; pp != NULL; pp = pp->p_next)
@@ -312,12 +287,7 @@ found:
# ifdef _SEQUENT_
(void) get_process_stats(&pp->p_etime, PS_SELF, NULL, NULL);
# else /* !_SEQUENT_ */
-# ifndef COHERENT
pp->p_etime = times(&proctimes);
-# else /* COHERENT */
- pp->p_etime = HZ * time(NULL);
- times(&proctimes);
-# endif /* COHERENT */
# endif /* !_SEQUENT_ */
#else /* BSDTIMES */
(void) gettimeofday(&pp->p_etime, NULL);
@@ -399,11 +369,8 @@ found:
!eq(dcwd->di_name, fp->p_cwd->di_name))) {
/* PWP: print a newline after ^C */
if (jobflags & PINTERRUPTED) {
-#ifdef SHORT_STRINGS
- xputchar('\r' | QUOTE), xputchar('\n');
-#else /* !SHORT_STRINGS */
- xprintf("\215\n"); /* \215 is a quoted ^M */
-#endif /* !SHORT_STRINGS */
+ xputchar('\r' | QUOTE);
+ xputchar('\n');
}
#ifdef notdef
else if ((jobflags & (PTIME|PSTOPPED)) == PTIME)
@@ -413,38 +380,33 @@ found:
}
else {
if (jobflags & PNOTIFY || adrof(STRnotify)) {
-#ifdef SHORT_STRINGS
- xputchar('\r' | QUOTE), xputchar('\n');
-#else /* !SHORT_STRINGS */
- xprintf("\215\n"); /* \215 is a quoted ^M */
-#endif /* !SHORT_STRINGS */
+ xputchar('\r' | QUOTE);
+ xputchar('\n');
(void) pprint(pp, NUMBER | NAME | REASON);
if ((jobflags & PSTOPPED) == 0)
pflush(pp);
- {
- if (GettingInput) {
- errno = 0;
- (void) Rawmode();
+ if (GettingInput) {
+ errno = 0;
+ (void) Rawmode();
#ifdef notdef
- /*
- * don't really want to do that, because it
- * will erase our message in case of multi-line
- * input
- */
- ClearLines();
+ /*
+ * don't really want to do that, because it
+ * will erase our message in case of multi-line
+ * input
+ */
+ ClearLines();
#endif /* notdef */
- ClearDisp();
- Refresh();
- }
+ ClearDisp();
+ Refresh();
}
}
else {
fp->p_flags |= PNEEDNOTE;
- neednote++;
+ neednote = 1;
}
}
}
-#if defined(BSDJOBS) || defined(HAVEwait3)
+#if defined(BSDJOBS) || defined(HAVEwait3) ||defined(WINNT_NATIVE)
goto loop;
#endif /* BSDJOBS || HAVEwait3 */
end:
@@ -452,45 +414,34 @@ found:
}
void
-pnote()
+pnote(void)
{
struct process *pp;
int flags;
-#ifdef BSDSIGS
- sigmask_t omask;
-#endif /* BSDSIGS */
neednote = 0;
for (pp = proclist.p_next; pp != NULL; pp = pp->p_next) {
if (pp->p_flags & PNEEDNOTE) {
-#ifdef BSDSIGS
- omask = sigblock(sigmask(SIGCHLD));
-#else /* !BSDSIGS */
- (void) sighold(SIGCHLD);
-#endif /* !BSDSIGS */
+ pchild_disabled++;
+ cleanup_push(&pchild_disabled, disabled_cleanup);
pp->p_flags &= ~PNEEDNOTE;
flags = pprint(pp, NUMBER | NAME | REASON);
if ((flags & (PRUNNING | PSTOPPED)) == 0)
pflush(pp);
-#ifdef BSDSIGS
- (void) sigsetmask(omask);
-#else /* !BSDSIGS */
- (void) sigrelse(SIGCHLD);
-#endif /* !BSDSIGS */
+ cleanup_until(&pchild_disabled);
}
}
}
static void
-pfree(pp)
- struct process *pp;
+pfree(struct process *pp)
{
- xfree((ptr_t) pp->p_command);
+ xfree(pp->p_command);
if (pp->p_cwd && --pp->p_cwd->di_count == 0)
if (pp->p_cwd->di_next == 0)
dfree(pp->p_cwd);
- xfree((ptr_t) pp);
+ xfree(pp);
}
@@ -499,36 +450,19 @@ pfree(pp)
* of current and previous job indicators.
*/
void
-pwait()
+pwait(void)
{
struct process *fp, *pp;
-#ifdef BSDSIGS
- sigmask_t omask;
-#endif /* BSDSIGS */
/*
* Here's where dead procs get flushed.
*/
-#ifdef BSDSIGS
- omask = sigblock(sigmask(SIGCHLD));
-#else /* !BSDSIGS */
- (void) sighold(SIGCHLD);
-#endif /* !BSDSIGS */
for (pp = (fp = &proclist)->p_next; pp != NULL; pp = (fp = pp)->p_next)
if (pp->p_procid == 0) {
fp->p_next = pp->p_next;
pfree(pp);
pp = fp;
}
-#ifdef BSDSIGS
- (void) sigsetmask(omask);
-#else /* !BSDSIGS */
- (void) sigrelse(SIGCHLD);
-# ifdef notdef
- if (setintr)
- sigignore(SIGINT);
-# endif /* notdef */
-#endif /* !BSDSIGS */
pjwait(pcurrjob);
}
@@ -538,70 +472,47 @@ pwait()
* It is assumed to be in the foreground state (PFOREGND)
*/
void
-pjwait(pp)
- struct process *pp;
+pjwait(struct process *pp)
{
struct process *fp;
int jobflags, reason;
-#ifdef BSDSIGS
- sigmask_t omask;
-#endif /* BSDSIGS */
-#ifdef UNRELSIGS
- signalfun_t inthandler;
-#endif /* UNRELSIGS */
+ sigset_t oset, set, pause_mask;
+ Char *reason_str;
+
while (pp->p_procid != pp->p_jobid)
pp = pp->p_friends;
fp = pp;
do {
if ((fp->p_flags & (PFOREGND | PRUNNING)) == PRUNNING)
- xprintf(CGETS(17, 1, "BUG: waiting for background job!\n"));
+ xprintf(CGETS(17, 1, "BUG: waiting for background job!\n"));
} while ((fp = fp->p_friends) != pp);
/*
* Now keep pausing as long as we are not interrupted (SIGINT), and the
* target process, or any of its friends, are running
*/
fp = pp;
-#ifdef BSDSIGS
- omask = sigblock(sigmask(SIGCHLD));
-#endif /* BSDSIGS */
-#ifdef UNRELSIGS
- if (setintr)
- inthandler = signal(SIGINT, SIG_IGN);
-#endif /* UNRELSIGS */
+ sigemptyset(&set);
+ sigaddset(&set, SIGINT);
+ sigaddset(&set, SIGCHLD);
+ (void)sigprocmask(SIG_BLOCK, &set, &oset);
+ cleanup_push(&oset, sigprocmask_cleanup);
+ pause_mask = oset;
+ sigdelset(&pause_mask, SIGCHLD);
for (;;) {
-#ifndef BSDSIGS
- (void) sighold(SIGCHLD);
-#endif /* !BSDSIGS */
+ handle_pending_signals();
jobflags = 0;
do
jobflags |= fp->p_flags;
while ((fp = (fp->p_friends)) != pp);
if ((jobflags & PRUNNING) == 0)
break;
-#ifdef JOBDEBUG
- xprintf("%d starting to sigpause for SIGCHLD on %d\n",
- getpid(), fp->p_procid);
-#endif /* JOBDEBUG */
-#ifdef BSDSIGS
- /* (void) sigpause(sigblock((sigmask_t) 0) &~ sigmask(SIGCHLD)); */
- (void) sigpause(omask & ~sigmask(SIGCHLD));
-#else /* !BSDSIGS */
- (void) sigpause(SIGCHLD);
-#endif /* !BSDSIGS */
+ jobdebug_xprintf(("%d starting to sigsuspend for SIGCHLD on %d\n",
+ getpid(), fp->p_procid));
+ sigsuspend(&pause_mask);
}
-#ifdef JOBDEBUG
- xprintf("%d returned from sigpause loop\n", getpid());
-#endif /* JOBDEBUG */
-#ifdef BSDSIGS
- (void) sigsetmask(omask);
-#else /* !BSDSIGS */
- (void) sigrelse(SIGCHLD);
-#endif /* !BSDSIGS */
-#ifdef UNRELSIGS
- if (setintr)
- (void) signal(SIGINT, inthandler);
-#endif /* UNRELSIGS */
+ cleanup_until(&oset);
+ jobdebug_xprintf(("%d returned from sigsuspend loop\n", getpid()));
#ifdef BSDJOBS
if (tpgrp > 0) /* get tty back */
(void) tcsetpgrp(FSHTTY, tpgrp);
@@ -650,7 +561,11 @@ pjwait(pp)
if ((reason != 0) && (adrof(STRprintexitvalue)) &&
(pp->p_flags & PBACKQ) == 0)
xprintf(CGETS(17, 2, "Exit %d\n"), reason);
- set(STRstatus, putn(reason), VAR_READWRITE);
+ reason_str = putn(reason);
+ cleanup_push(reason_str, xfree);
+ setv(STRstatus, reason_str, VAR_READWRITE);
+ cleanup_ignore(reason_str);
+ cleanup_until(reason_str);
if (reason && exiterr)
exitstat();
pflush(pp);
@@ -662,42 +577,27 @@ pjwait(pp)
/*ARGSUSED*/
void
-dowait(v, c)
- Char **v;
- struct command *c;
+dowait(Char **v, struct command *c)
{
struct process *pp;
-#ifdef BSDSIGS
- sigmask_t omask;
-#endif /* BSDSIGS */
+ sigset_t pause_mask;
USE(c);
USE(v);
pjobs++;
-#ifdef BSDSIGS
- omask = sigblock(sigmask(SIGCHLD));
-loop:
-#else /* !BSDSIGS */
+ sigprocmask(SIG_BLOCK, NULL, &pause_mask);
+ sigdelset(&pause_mask, SIGCHLD);
if (setintr)
- (void) sigrelse(SIGINT);
+ sigdelset(&pause_mask, SIGINT);
loop:
- (void) sighold(SIGCHLD);
-#endif /* !BSDSIGS */
for (pp = proclist.p_next; pp; pp = pp->p_next)
if (pp->p_procid && /* pp->p_procid == pp->p_jobid && */
pp->p_flags & PRUNNING) {
-#ifdef BSDSIGS
- (void) sigpause((sigmask_t) 0);
-#else /* !BSDSIGS */
- (void) sigpause(SIGCHLD);
-#endif /* !BSDSIGS */
+ handle_pending_signals();
+ sigsuspend(&pause_mask);
+ handle_pending_signals();
goto loop;
}
-#ifdef BSDSIGS
- (void) sigsetmask(omask);
-#else /* !BSDSIGS */
- (void) sigrelse(SIGCHLD);
-#endif /* !BSDSIGS */
pjobs = 0;
}
@@ -705,7 +605,7 @@ loop:
* pflushall - flush all jobs from list (e.g. at fork())
*/
static void
-pflushall()
+pflushall(void)
{
struct process *pp;
@@ -720,8 +620,7 @@ pflushall()
* space is not done here since pflush is called at interrupt level.
*/
static void
-pflush(pp)
- struct process *pp;
+pflush(struct process *pp)
{
struct process *np;
int idx;
@@ -754,8 +653,7 @@ pflush(pp)
* pp MUST be the job leader
*/
static void
-pclrcurr(pp)
- struct process *pp;
+pclrcurr(struct process *pp)
{
if (pp == pcurrent) {
if (pprevious != NULL) {
@@ -773,15 +671,14 @@ pclrcurr(pp)
/* +4 here is 1 for '\0', 1 ea for << >& >> */
static Char command[PMAXLEN + 4];
-static int cmdlen;
+static size_t cmdlen;
static Char *cmdp;
/* GrP
* unparse - Export padd() functionality
*/
Char *
-unparse(t)
- struct command *t;
+unparse(struct command *t)
{
cmdp = command;
cmdlen = 0;
@@ -796,14 +693,12 @@ unparse(t)
* an important assumption is made that the process is running.
*/
void
-palloc(pid, t)
- int pid;
- struct command *t;
+palloc(pid_t pid, struct command *t)
{
struct process *pp;
int i;
- pp = (struct process *) xcalloc(1, (size_t) sizeof(struct process));
+ pp = xcalloc(1, sizeof(struct process));
pp->p_procid = pid;
pp->p_flags = ((t->t_dflg & F_AMPERSAND) ? 0 : PFOREGND) | PRUNNING;
if (t->t_dflg & F_TIME)
@@ -872,20 +767,14 @@ palloc(pid, t)
{
struct tms tmptimes;
-# ifndef COHERENT
pp->p_btime = times(&tmptimes);
-# else /* !COHERENT */
- pp->p_btime = HZ * time(NULL);
- times(&tmptimes);
-# endif /* !COHERENT */
}
# endif /* !_SEQUENT_ */
#endif /* !BSDTIMES */
}
static void
-padd(t)
- struct command *t;
+padd(struct command *t)
{
Char **argp;
@@ -948,10 +837,9 @@ padd(t)
}
static void
-pads(cp)
- Char *cp;
+pads(Char *cp)
{
- int i;
+ size_t i;
/*
* Avoid the Quoted Space alias hack! Reported by:
@@ -960,7 +848,7 @@ pads(cp)
if (cp[0] == STRQNULL[0])
cp++;
- i = (int) Strlen(cp);
+ i = Strlen(cp);
if (cmdlen >= PMAXLEN)
return;
@@ -981,19 +869,16 @@ pads(cp)
* and `` in globbing.
*/
void
-psavejob()
+psavejob(void)
{
pholdjob = pcurrjob;
pcurrjob = NULL;
}
-/*
- * prestjob - opposite of psavejob. This may be missed if we are interrupted
- * somewhere, but pendjob cleans up anyway.
- */
void
-prestjob()
+psavejob_cleanup(void *dummy)
{
+ USE(dummy);
pcurrjob = pholdjob;
pholdjob = NULL;
}
@@ -1003,7 +888,7 @@ prestjob()
* or is about to begin.
*/
void
-pendjob()
+pendjob(void)
{
struct process *pp, *tp;
@@ -1034,9 +919,7 @@ pendjob()
*/
static int
-pprint(pp, flag)
- struct process *pp;
- int flag;
+pprint(struct process *pp, int flag)
{
int status, reason;
struct process *tp;
@@ -1076,9 +959,9 @@ pprint(pp, flag)
* we can search for the next one downstream later.
*/
}
- pcond = (int) (tp != pp || (inpipe && tp == pp));
+ pcond = (tp != pp || (inpipe && tp == pp));
#else /* !BACKPIPE */
- pcond = (int) (tp != pp);
+ pcond = (tp != pp);
#endif /* BACKPIPE */
jobflags |= pp->p_flags;
@@ -1106,10 +989,6 @@ pprint(pp, flag)
xprintf(" ");
}
if (flag & FANCY) {
-#ifdef TCF
- extern char *sitename();
-
-#endif /* TCF */
xprintf("%5d ", pp->p_procid);
#ifdef TCF
xprintf("%11s ", sitename(pp->p_procid));
@@ -1143,7 +1022,7 @@ pprint(pp, flag)
case PSIGNALED:
/*
* tell what happened to the background job
- * From: Michael Schroeder
+ * From: Michael Schroeder
* <mlschroe@immd4.informatik.uni-erlangen.de>
*/
if ((flag & REASON)
@@ -1151,15 +1030,20 @@ pprint(pp, flag)
&& reason != SIGINT
&& (reason != SIGPIPE
|| (pp->p_flags & PPOU) == 0))) {
- const char *ptr;
- char buf[1024];
-
- if ((ptr = mesg[pp->p_reason & ASCII].pname) == NULL) {
- xsnprintf(buf, sizeof(buf), "%s %d",
- CGETS(17, 5, "Signal"), pp->p_reason & ASCII);
- ptr = buf;
+ char *ptr;
+ int free_ptr;
+
+ free_ptr = 0;
+ ptr = (char *)(intptr_t)mesg[pp->p_reason & 0177].pname;
+ if (ptr == NULL) {
+ ptr = xasprintf("%s %d", CGETS(17, 5, "Signal"),
+ pp->p_reason & 0177);
+ cleanup_push(ptr, xfree);
+ free_ptr = 1;
}
xprintf(format, ptr);
+ if (free_ptr != 0)
+ cleanup_until(ptr);
}
else
reason = -1;
@@ -1279,8 +1163,7 @@ prcomd:
((tvp)->tv_sec cmp (uvp)->tv_sec))
static void
-ptprint(tp)
- struct process *tp;
+ptprint(struct process *tp)
{
#ifdef BSDTIMES
struct timeval tetime, diff;
@@ -1360,9 +1243,7 @@ ptprint(tp)
*/
/*ARGSUSED*/
void
-dojobs(v, c)
- Char **v;
- struct command *c;
+dojobs(Char **v, struct command *c)
{
struct process *pp;
int flag = NUMBER | NAME | REASON;
@@ -1391,9 +1272,7 @@ dojobs(v, c)
*/
/*ARGSUSED*/
void
-dofg(v, c)
- Char **v;
- struct command *c;
+dofg(Char **v, struct command *c)
{
struct process *pp;
@@ -1407,12 +1286,6 @@ dofg(v, c)
stderror(ERR_NAME|ERR_BADJOB, pp->p_command, strerror(errno));
continue;
}
-#ifndef BSDSIGS
-# ifdef notdef
- if (setintr)
- sigignore(SIGINT);
-# endif
-#endif /* !BSDSIGS */
pjwait(pp);
} while (*v && *++v);
}
@@ -1422,9 +1295,7 @@ dofg(v, c)
*/
/*ARGSUSED*/
void
-dofg1(v, c)
- Char **v;
- struct command *c;
+dofg1(Char **v, struct command *c)
{
struct process *pp;
@@ -1436,12 +1307,6 @@ dofg1(v, c)
stderror(ERR_NAME|ERR_BADJOB, pp->p_command, strerror(errno));
return;
}
-#ifndef BSDSIGS
-# ifdef notdef
- if (setintr)
- sigignore(SIGINT);
-# endif
-#endif /* !BSDSIGS */
pjwait(pp);
}
@@ -1450,9 +1315,7 @@ dofg1(v, c)
*/
/*ARGSUSED*/
void
-dobg(v, c)
- Char **v;
- struct command *c;
+dobg(Char **v, struct command *c)
{
struct process *pp;
@@ -1473,9 +1336,7 @@ dobg(v, c)
*/
/*ARGSUSED*/
void
-dobg1(v, c)
- Char **v;
- struct command *c;
+dobg1(Char **v, struct command *c)
{
struct process *pp;
@@ -1492,9 +1353,7 @@ dobg1(v, c)
*/
/*ARGSUSED*/
void
-dostop(v, c)
- Char **v;
- struct command *c;
+dostop(Char **v, struct command *c)
{
USE(c);
#ifdef BSDJOBS
@@ -1507,9 +1366,7 @@ dostop(v, c)
*/
/*ARGSUSED*/
void
-dokill(v, c)
- Char **v;
- struct command *c;
+dokill(Char **v, struct command *c)
{
int signum, len = 0;
const char *name;
@@ -1522,7 +1379,7 @@ dokill(v, c)
for (signum = 0; signum <= nsig; signum++) {
if ((name = mesg[signum].iname) != NULL) {
len += strlen(name) + 1;
- if (len >= T_Cols - 1) {
+ if (len >= TermH - 1) {
xputchar('\n');
len = strlen(name) + 1;
}
@@ -1564,44 +1421,28 @@ gotsig:
}
static void
-pkill(v, signum)
- Char **v;
- int signum;
+pkill(Char **v, int signum)
{
struct process *pp, *np;
int jobflags = 0, err1 = 0;
pid_t pid;
-#ifdef BSDSIGS
- sigmask_t omask;
-#endif /* BSDSIGS */
- Char *cp, **vp;
+ Char *cp, **vp, **globbed;
-#ifdef BSDSIGS
- omask = sigmask(SIGCHLD);
- if (setintr)
- omask |= sigmask(SIGINT);
- omask = sigblock(omask) & ~omask;
-#else /* !BSDSIGS */
- if (setintr)
- (void) sighold(SIGINT);
- (void) sighold(SIGCHLD);
-#endif /* !BSDSIGS */
+ pchild_disabled++;
+ cleanup_push(&pchild_disabled, disabled_cleanup);
+ if (setintr) {
+ pintr_disabled++;
+ cleanup_push(&pintr_disabled, disabled_cleanup);
+ }
/* Avoid globbing %?x patterns */
for (vp = v; vp && *vp; vp++)
if (**vp == '%')
(void) quote(*vp);
- gflag = 0, tglob(v);
- if (gflag) {
- v = globall(v);
- if (v == 0)
- stderror(ERR_NAME | ERR_NOMATCH);
- }
- else {
- v = gargv = saveblk(v);
- trim(v);
- }
+ v = glob_all_or_error(v);
+ globbed = v;
+ cleanup_push(globbed, blk_cleanup);
while (v && (cp = *v)) {
@@ -1675,15 +1516,7 @@ pkill(v, signum)
cont:
v++;
}
- if (gargv)
- blkfree(gargv), gargv = 0;
-#ifdef BSDSIGS
- (void) sigsetmask(omask);
-#else /* !BSDSIGS */
- (void) sigrelse(SIGCHLD);
- if (setintr)
- (void) sigrelse(SIGINT);
-#endif /* !BSDSIGS */
+ cleanup_until(&pchild_disabled);
if (err1)
stderror(ERR_SILENT);
}
@@ -1692,23 +1525,15 @@ cont:
* pstart - start the job in foreground/background
*/
int
-pstart(pp, foregnd)
- struct process *pp;
- int foregnd;
+pstart(struct process *pp, int foregnd)
{
int rv = 0;
struct process *np;
-#ifdef BSDSIGS
- sigmask_t omask;
-#endif /* BSDSIGS */
/* We don't use jobflags in this function right now (see below) */
/* long jobflags = 0; */
-#ifdef BSDSIGS
- omask = sigblock(sigmask(SIGCHLD));
-#else /* !BSDSIGS */
- (void) sighold(SIGCHLD);
-#endif
+ pchild_disabled++;
+ cleanup_push(&pchild_disabled, disabled_cleanup);
np = pp;
do {
/* We don't use jobflags in this function right now (see below) */
@@ -1743,7 +1568,7 @@ pstart(pp, foregnd)
* 4. pchild() calls wait3(WNOHANG) which returns 0.
* The child process is NOT ready to be waited for at this time.
* pchild() returns without picking-up the correct status
- * for the child process which generated the SIGCHILD.
+ * for the child process which generated the SIGCHLD.
* 5. CONSEQUENCE : csh is UNaware that the process is stopped
* 6. THIS LINE HAS BEEN COMMENTED OUT : if (jobflags&PSTOPPED)
* (beto@aixwiz.austin.ibm.com - aug/03/91)
@@ -1758,17 +1583,12 @@ pstart(pp, foregnd)
if (rv != -1)
rv = killpg(pp->p_jobid, SIGCONT);
#endif /* BSDJOBS */
-#ifdef BSDSIGS
- (void) sigsetmask(omask);
-#else /* !BSDSIGS */
- (void) sigrelse(SIGCHLD);
-#endif /* !BSDSIGS */
+ cleanup_until(&pchild_disabled);
return rv != -1;
}
void
-panystop(neednl)
- int neednl;
+panystop(int neednl)
{
struct process *pp;
@@ -1779,8 +1599,7 @@ panystop(neednl)
}
struct process *
-pfind(cp)
- Char *cp;
+pfind(Char *cp)
{
struct process *pp, *np;
@@ -1834,8 +1653,7 @@ pfind(cp)
* pgetcurr - find most recent job that is not pp, preferably stopped
*/
static struct process *
-pgetcurr(pp)
- struct process *pp;
+pgetcurr(struct process *pp)
{
struct process *np;
struct process *xp = NULL;
@@ -1856,9 +1674,7 @@ pgetcurr(pp)
*/
/*ARGSUSED*/
void
-donotify(v, c)
- Char **v;
- struct command *c;
+donotify(Char **v, struct command *c)
{
struct process *pp;
@@ -1867,6 +1683,14 @@ donotify(v, c)
pp->p_flags |= PNOTIFY;
}
+#ifdef SIGSYNCH
+static void
+synch_handler(int sno)
+{
+ USE(sno);
+}
+#endif /* SIGSYNCH */
+
/*
* Do the fork and whatever should be done in the child side that
* should not be done if we are not forking at all (like for simple builtin's)
@@ -1879,20 +1703,14 @@ donotify(v, c)
* It is usually just the value of tpgrp.
*/
-int
-pfork(t, wanttty)
- struct command *t; /* command we are forking for */
- int wanttty;
+pid_t
+pfork(struct command *t, int wanttty)
{
- int pid;
+ pid_t pid;
int ignint = 0;
- int pgrp;
-#ifdef BSDSIGS
- sigmask_t omask = 0;
-#endif /* BSDSIGS */
+ pid_t pgrp;
#ifdef SIGSYNCH
- sigvec_t osv;
- static sigvec_t nsv = {synch_handler, (sigset_t) ~0, 0};
+ struct sigaction osa, nsa;
#endif /* SIGSYNCH */
/*
@@ -1907,43 +1725,33 @@ pfork(t, wanttty)
ignint = (tpgrp == -1 && (t->t_dflg & F_NOINTERRUPT))
|| (gointr && eq(gointr, STRminus));
-#ifdef COHERENT
- ignint |= gointr && eq(gointr, STRminus);
-#endif /* COHERENT */
-
/*
* Check for maximum nesting of 16 processes to avoid Forking loops
*/
if (child == 16)
stderror(ERR_NESTING, 16);
#ifdef SIGSYNCH
- if (mysigvec(SIGSYNCH, &nsv, &osv))
- stderror(ERR_SYSTEM, "pfork: sigvec set", strerror(errno));
+ nsa.sa_handler = synch_handler;
+ sigfillset(&nsa.sa_mask);
+ nsa.sa_flags = SA_RESTART;
+ if (sigaction(SIGSYNCH, &nsa, &osa))
+ stderror(ERR_SYSTEM, "pfork: sigaction set", strerror(errno));
#endif /* SIGSYNCH */
/*
- * Hold SIGCHLD until we have the process installed in our table.
+ * Hold pchild() until we have the process installed in our table.
*/
if (wanttty < 0) {
-#ifdef BSDSIGS
- omask = sigblock(sigmask(SIGCHLD));
-#else /* !BSDSIGS */
- (void) sighold(SIGCHLD);
-#endif /* !BSDSIGS */
+ pchild_disabled++;
+ cleanup_push(&pchild_disabled, disabled_cleanup);
}
while ((pid = fork()) == -1)
if (setintr == 0)
(void) sleep(FORKSLEEP);
- else {
- if (wanttty < 0)
-#ifdef BSDSIGS
- (void) sigsetmask(omask);
-#else /* !BSDSIGS */
- (void) sigrelse(SIGCHLD);
- (void) sigrelse(SIGINT);
-#endif /* !BSDSIGS */
+ else
stderror(ERR_NOPROC);
- }
if (pid == 0) {
+ (void)cleanup_push_mark(); /* Never to be popped */
+ pchild_disabled = 0;
settimes();
pgrp = pcurrjob ? pcurrjob->p_jobid : getpid();
pflushall();
@@ -1954,10 +1762,6 @@ pfork(t, wanttty)
child++;
if (setintr) {
setintr = 0; /* until I think otherwise */
-#ifndef BSDSIGS
- if (wanttty < 0)
- (void) sigrelse(SIGCHLD);
-#endif /* !BSDSIGS */
/*
* Children just get blown away on SIGINT, SIGQUIT unless "onintr
* -" seen.
@@ -1972,14 +1776,14 @@ pfork(t, wanttty)
(void) signal(SIGTTOU, SIG_DFL);
}
#endif /* BSDJOBS */
- (void) signal(SIGTERM, parterm);
+ sigaction(SIGTERM, &parterm, NULL);
}
else if (tpgrp == -1 && (t->t_dflg & F_NOINTERRUPT)) {
(void) signal(SIGINT, SIG_IGN);
(void) signal(SIGQUIT, SIG_IGN);
}
#ifdef OREO
- sigignore(SIGIO); /* ignore SIGIO in child too */
+ signal(SIGIO, SIG_IGN); /* ignore SIGIO in child too */
#endif /* OREO */
pgetty(wanttty, pgrp);
@@ -1994,7 +1798,7 @@ pfork(t, wanttty)
int nval = SIGN_EXTEND_CHAR(t->t_nice);
#ifdef HAVE_SETPRIORITY
if (setpriority(PRIO_PROCESS, 0, nval) == -1 && errno)
- stderror(ERR_SYSTEM, "setpriority", strerror(errno));
+ stderror(ERR_SYSTEM, "setpriority", strerror(errno));
#else /* !HAVE_SETPRIORITY */
(void) nice(nval);
#endif /* !HAVE_SETPRIORITY */
@@ -2036,6 +1840,9 @@ pfork(t, wanttty)
#endif /* POSIXJOBS */
palloc(pid, t);
#ifdef SIGSYNCH
+ {
+ sigset_t pause_mask;
+
/*
* rfw 8/89 Wait for child to own terminal. Solves half of ugly
* synchronization problem. With this change, we know that the only
@@ -2044,25 +1851,25 @@ pfork(t, wanttty)
* either have exited or not yet started to run. Two uglies become
* one.
*/
- (void) sigpause(omask & ~SYNCHMASK);
- if (mysigvec(SIGSYNCH, &osv, NULL))
- stderror(ERR_SYSTEM, "pfork parent: sigvec restore",
- strerror(errno));
+ sigprocmask(SIG_BLOCK, NULL, &pause);
+ sigdelset(&pause_mask, SIGCHLD);
+ sigdelset(&pause_mask, SIGSYNCH);
+ sigsuspend(&pause_mask);
+ handle_pending_signals();
+ if (sigaction(SIGSYNCH, &osa, NULL))
+ stderror(ERR_SYSTEM, "pfork parent: sigaction restore",
+ strerror(errno));
+ }
#endif /* SIGSYNCH */
- if (wanttty < 0) {
-#ifdef BSDSIGS
- (void) sigsetmask(omask);
-#else /* !BSDSIGS */
- (void) sigrelse(SIGCHLD);
-#endif /* !BSDSIGS */
- }
+ if (wanttty < 0)
+ cleanup_until(&pchild_disabled);
}
return (pid);
}
static void
-okpcntl()
+okpcntl(void)
{
if (tpgrp == -1)
stderror(ERR_JOBCONTROL);
@@ -2072,8 +1879,7 @@ okpcntl()
static void
-setttypgrp(pgrp)
- int pgrp;
+setttypgrp(int pgrp)
{
/*
* If we are piping out a builtin, eg. 'echo | more' things can go
@@ -2090,15 +1896,18 @@ setttypgrp(pgrp)
*/
if (tcgetpgrp(FSHTTY) != pgrp) {
#ifdef POSIXJOBS
+ struct sigaction old;
+
/*
* tcsetpgrp will set SIGTTOU to all the the processes in
* the background according to POSIX... We ignore this here.
*/
- signalfun_t old = sigset(SIGTTOU, SIG_IGN);
+ sigaction(SIGTTOU, NULL, &old);
+ signal(SIGTTOU, SIG_IGN);
#endif
(void) tcsetpgrp(FSHTTY, pgrp);
# ifdef POSIXJOBS
- (void) sigset(SIGTTOU, old);
+ sigaction(SIGTTOU, &old, NULL);
# endif
}
@@ -2114,32 +1923,28 @@ setttypgrp(pgrp)
* I am open to suggestions how to fix that.
*/
void
-pgetty(wanttty, pgrp)
- int wanttty, pgrp;
+pgetty(int wanttty, pid_t pgrp)
{
#ifdef BSDJOBS
-# if defined(BSDSIGS) && defined(POSIXJOBS)
- sigmask_t omask = 0;
-# endif /* BSDSIGS && POSIXJOBS */
-
-# ifdef JOBDEBUG
- xprintf("wanttty %d pid %d opgrp%d pgrp %d tpgrp %d\n",
- wanttty, getpid(), pgrp, mygetpgrp(), tcgetpgrp(FSHTTY));
-# endif /* JOBDEBUG */
+# ifdef POSIXJOBS
+ sigset_t oset, set;
+# endif /* POSIXJOBS */
+
+ jobdebug_xprintf(("wanttty %d pid %d opgrp%d pgrp %d tpgrp %d\n",
+ wanttty, (int)getpid(), (int)pgrp, (int)mygetpgrp(),
+ (int)tcgetpgrp(FSHTTY)));
# ifdef POSIXJOBS
/*
* christos: I am blocking the tty signals till I've set things
* correctly....
*/
- if (wanttty > 0)
-# ifdef BSDSIGS
- omask = sigblock(sigmask(SIGTSTP)|sigmask(SIGTTIN));
-# else /* !BSDSIGS */
- {
- (void) sighold(SIGTSTP);
- (void) sighold(SIGTTIN);
+ if (wanttty > 0) {
+ sigemptyset(&set);
+ sigaddset(&set, SIGTSTP);
+ sigaddset(&set, SIGTTIN);
+ (void)sigprocmask(SIG_BLOCK, &set, &oset);
+ cleanup_push(&oset, sigprocmask_cleanup);
}
-# endif /* !BSDSIGS */
# endif /* POSIXJOBS */
# ifndef POSIXJOBS
@@ -2171,20 +1976,14 @@ pgetty(wanttty, pgrp)
}
# ifdef POSIXJOBS
- if (wanttty > 0)
+ if (wanttty > 0) {
setttypgrp(pgrp);
-# ifdef BSDSIGS
- (void) sigsetmask(omask);
-# else /* BSDSIGS */
- (void) sigrelse(SIGTSTP);
- (void) sigrelse(SIGTTIN);
-# endif /* !BSDSIGS */
+ cleanup_until(&oset);
+ }
# endif /* POSIXJOBS */
-# ifdef JOBDEBUG
- xprintf("wanttty %d pid %d pgrp %d tpgrp %d\n",
- wanttty, getpid(), mygetpgrp(), tcgetpgrp(FSHTTY));
-# endif /* JOBDEBUG */
+ jobdebug_xprintf(("wanttty %d pid %d pgrp %d tpgrp %d\n",
+ wanttty, getpid(), mygetpgrp(), tcgetpgrp(FSHTTY)));
if (tpgrp > 0)
tpgrp = 0; /* gave tty away */
diff --git a/contrib/tcsh/sh.proc.h b/contrib/tcsh/sh.proc.h
index 863db94..90b5e04 100644
--- a/contrib/tcsh/sh.proc.h
+++ b/contrib/tcsh/sh.proc.h
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/sh.proc.h,v 3.11 2004/11/23 02:10:49 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/sh.proc.h,v 3.12 2006/01/12 19:55:38 christos Exp $ */
/*
* sh.proc.h: Process data structures and variables
*/
@@ -116,7 +116,6 @@ struct process {
#define AREASON 0200
EXTERN struct process proclist IZERO_STRUCT;/* list head of all processes */
-EXTERN int pnoprocesses IZERO; /* pchild found nothing to wait for */
EXTERN struct process *pholdjob IZERO; /* one level stack of current jobs */
@@ -126,8 +125,4 @@ EXTERN struct process *pprevious IZERO; /* previous job in table */
EXTERN int pmaxindex IZERO; /* current maximum job index */
-#ifndef BSDTIMES
-EXTERN int timesdone; /* shtimes buffer full ? */
-#endif /* BSDTIMES */
-
#endif /* _h_sh_proc */
diff --git a/contrib/tcsh/sh.sem.c b/contrib/tcsh/sh.sem.c
index 97d10e0..0ae1502 100644
--- a/contrib/tcsh/sh.sem.c
+++ b/contrib/tcsh/sh.sem.c
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/sh.sem.c,v 3.69 2005/01/18 20:24:51 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/sh.sem.c,v 3.78 2006/10/14 17:23:39 christos Exp $ */
/*
* sh.sem.c: I/O redirections and job forking. A touchy issue!
* Most stuff with builtins is incorrect
@@ -33,7 +33,7 @@
*/
#include "sh.h"
-RCSID("$Id: sh.sem.c,v 3.69 2005/01/18 20:24:51 christos Exp $")
+RCSID("$tcsh: sh.sem.c,v 3.78 2006/10/14 17:23:39 christos Exp $")
#include "tc.h"
#include "tw.h"
@@ -56,11 +56,11 @@ RCSID("$Id: sh.sem.c,v 3.69 2005/01/18 20:24:51 christos Exp $")
#endif /* __sparc__ || sparc */
#ifdef VFORK
-static RETSIGTYPE vffree __P((int));
+static void vffree (int);
#endif
-static Char *splicepipe __P((struct command *, Char *));
-static void doio __P((struct command *, int *, int *));
-static void chkclob __P((char *));
+static Char *splicepipe (struct command *, Char *);
+static void doio (struct command *, int *, int *);
+static void chkclob (const char *);
/*
* C shell
@@ -84,19 +84,15 @@ static void chkclob __P((char *));
/*VARARGS 1*/
void
-execute(t, wanttty, pipein, pipeout, do_glob)
- struct command *t;
- int wanttty;
- int *pipein, *pipeout;
- int do_glob;
+execute(struct command *t, volatile int wanttty, int *pipein, int *pipeout,
+ int do_glob)
{
int forked = 0;
- struct biltins *bifunc;
- int pid = 0;
+ const struct biltins * volatile bifunc;
+ pid_t pid = 0;
int pv[2];
-#ifdef BSDSIGS
- static sigmask_t csigmask;
-#endif /* BSDSIGS */
+ sigset_t set;
+ static sigset_t csigset;
#ifdef VFORK
static int onosigchld = 0;
#endif /* VFORK */
@@ -131,47 +127,56 @@ execute(t, wanttty, pipein, pipeout, do_glob)
*/
if (implicit_cd && (intty || intact) && t->t_dcom && t->t_dcom[0] &&
t->t_dcom[0][0] && (blklen(t->t_dcom) == 1) && !noexec) {
- Char sCName[MAXPATHLEN];
- Char *pCN;
+ Char *sCName;
struct stat stbuf;
char *pathname;
- dollar(sCName, t->t_dcom[0]);
- pCN = sCName;
- if (pCN[0] == '~') {
- Char sCPath[MAXPATHLEN];
- Char *pCP = sCPath;
-
- ++pCN;
- while (*pCN && *pCN != '/')
- *pCP++ = *pCN++;
- *pCP = 0;
- if (sCPath[0])
- gethdir(sCPath);
- else
- (void) Strcpy(sCPath, varval(STRhome));
- catn(sCPath, pCN, MAXPATHLEN);
- (void) Strcpy(sCName, sCPath);
+ sCName = dollar(t->t_dcom[0]);
+ if (sCName != NULL && sCName[0] == '~') {
+ struct Strbuf buf = Strbuf_INIT;
+ const Char *name_end;
+
+ for (name_end = sCName + 1; *name_end != '\0' && *name_end != '/';
+ name_end++)
+ continue;
+ if (name_end != sCName + 1) {
+ Char *name, *home;
+
+ name = Strnsave(sCName + 1, name_end - (sCName + 1));
+ home = gethdir(name);
+ if (home != NULL) {
+ Strbuf_append(&buf, home);
+ xfree(home);
+ } else
+ Strbuf_append(&buf, name);
+ xfree(name);
+ } else
+ Strbuf_append(&buf, varval(STRhome));
+ Strbuf_append(&buf, name_end);
+ xfree(sCName);
+ sCName = Strbuf_finish(&buf);
}
-
+
pathname = short2str(sCName);
+ xfree(sCName);
/* if this is a dir, tack a "cd" on as the first arg */
- if ((stat(pathname, &stbuf) != -1 && S_ISDIR(stbuf.st_mode))
+ if (pathname != NULL &&
+ ((stat(pathname, &stbuf) != -1 && S_ISDIR(stbuf.st_mode))
#ifdef WINNT_NATIVE
- || (pathname[0] && pathname[1] == ':' && pathname[2] == '\0')
+ || (pathname[0] && pathname[1] == ':' && pathname[2] == '\0')
#endif /* WINNT_NATIVE */
- ) {
+ )) {
Char *vCD[2];
Char **ot_dcom = t->t_dcom;
vCD[0] = Strsave(STRcd);
vCD[1] = NULL;
t->t_dcom = blkspl(vCD, ot_dcom);
+ xfree(ot_dcom);
if (implicit_cd > 1) {
blkpr(t->t_dcom);
xputchar( '\n' );
}
- xfree((ptr_t) ot_dcom);
}
}
@@ -185,7 +190,8 @@ execute(t, wanttty, pipein, pipeout, do_glob)
case NODE_COMMAND:
if ((t->t_dcom[0][0] & (QUOTE | TRIM)) == QUOTE)
- (void) Strcpy(t->t_dcom[0], t->t_dcom[0] + 1);
+ memmove(t->t_dcom[0], t->t_dcom[0] + 1,
+ (Strlen(t->t_dcom[0] + 1) + 1) * sizeof (*t->t_dcom[0]));
if ((t->t_dflg & F_REPEAT) == 0)
Dfix(t); /* $ " ' \ */
if (t->t_dcom[0] == 0) {
@@ -206,13 +212,13 @@ execute(t, wanttty, pipein, pipeout, do_glob)
* If noexec then this is all we do.
*/
if (t->t_dflg & F_READ) {
- (void) close(0);
+ xclose(0);
heredoc(t->t_dlef);
if (noexec)
- (void) close(0);
+ xclose(0);
}
- set(STRstatus, Strsave(STR0), VAR_READWRITE);
+ setcopy(STRstatus, STR0, VAR_READWRITE);
/*
* This mess is the necessary kludge to handle the prefix builtins:
@@ -287,10 +293,12 @@ execute(t, wanttty, pipein, pipeout, do_glob)
* Check if we have a builtin function and remember which one.
*/
bifunc = isbfunc(t);
- if (noexec && bifunc) {
+ if (noexec) {
/*
* Continue for builtins that are part of the scripting language
*/
+ if (bifunc == NULL)
+ break;
if (bifunc->bfunct != (bfunc_t)dobreak &&
bifunc->bfunct != (bfunc_t)docontin &&
bifunc->bfunct != (bfunc_t)doelse &&
@@ -320,8 +328,10 @@ execute(t, wanttty, pipein, pipeout, do_glob)
*/
if (t->t_dtyp == NODE_COMMAND && !bifunc && !noexec && intty) {
Char *cmd = unparse(t);
+
+ cleanup_push(cmd, xfree);
job_cmd(cmd);
- xfree(cmd);
+ cleanup_until(cmd);
}
/*
@@ -366,22 +376,16 @@ execute(t, wanttty, pipein, pipeout, do_glob)
* not die before we can set the process group
*/
if (wanttty >= 0 && !nosigchld) {
-#ifdef BSDSIGS
- csigmask = sigblock(sigmask(SIGCHLD));
-#else /* !BSDSIGS */
- (void) sighold(SIGCHLD);
-#endif /* BSDSIGS */
+ sigemptyset(&set);
+ sigaddset(&set, SIGCHLD);
+ (void)sigprocmask(SIG_BLOCK, &set, &csigset);
nosigchld = 1;
}
pid = pfork(t, wanttty);
if (pid == 0 && nosigchld) {
-#ifdef BSDSIGS
- (void) sigsetmask(csigmask);
-#else /* !BSDSIGS */
- (void) sigrelse(SIGCHLD);
-#endif /* BSDSIGS */
+ sigprocmask(SIG_SETMASK, &csigset, NULL);
nosigchld = 0;
}
else if (pid != 0 && (t->t_dflg & F_AMPERSAND))
@@ -393,13 +397,10 @@ execute(t, wanttty, pipein, pipeout, do_glob)
int ochild, osetintr, ohaderr, odidfds;
int oSHIN, oSHOUT, oSHDIAG, oOLDSTD, otpgrp;
int oisoutatty, oisdiagatty;
-
+ sigset_t oset, ocsigset;
# ifndef CLOSE_ON_EXEC
int odidcch;
# endif /* !CLOSE_ON_EXEC */
-# ifdef BSDSIGS
- sigmask_t omask, ocsigmask;
-# endif /* BSDSIGS */
/*
* Prepare for the vfork by saving everything that the child
@@ -415,24 +416,20 @@ execute(t, wanttty, pipein, pipeout, do_glob)
* Gilbrech - 11/22/87)
*/
# ifdef SAVESIGVEC
- sigvec_t savesv[NSIGSAVED];
- sigmask_t savesm;
+ struct sigaction savesv[NSIGSAVED];
+ sigset_t savesm;
# endif /* SAVESIGVEC */
if (wanttty >= 0 && !nosigchld && !noexec) {
-# ifdef BSDSIGS
- csigmask = sigblock(sigmask(SIGCHLD));
-# else /* !BSDSIGS */
- (void) sighold(SIGCHLD);
-# endif /* BSDSIGS */
+ sigemptyset(&set);
+ sigaddset(&set, SIGCHLD);
+ (void)sigprocmask(SIG_BLOCK, &set, &csigset);
nosigchld = 1;
}
-# ifdef BSDSIGS
- omask = sigblock(sigmask(SIGCHLD)|sigmask(SIGINT));
-# else /* !BSDSIGS */
- (void) sighold(SIGCHLD);
- (void) sighold(SIGINT);
-# endif /* BSDSIGS */
+ sigemptyset(&set);
+ sigaddset(&set, SIGCHLD);
+ sigaddset(&set, SIGINT);
+ (void)sigprocmask(SIG_BLOCK, &set, &oset);
ochild = child;
osetintr = setintr;
ohaderr = haderr;
@@ -447,15 +444,13 @@ execute(t, wanttty, pipein, pipeout, do_glob)
otpgrp = tpgrp;
oisoutatty = isoutatty;
oisdiagatty = isdiagatty;
-# ifdef BSDSIGS
- ocsigmask = csigmask;
-# endif /* BSDSIGS */
+ ocsigset = csigset;
onosigchld = nosigchld;
Vsav = Vdp = 0;
Vexpath = 0;
Vt = 0;
# ifdef SAVESIGVEC
- savesm = savesigvec(savesv);
+ savesigvec(savesv, savesm);
# endif /* SAVESIGVEC */
if (use_fork)
pid = fork();
@@ -463,15 +458,10 @@ execute(t, wanttty, pipein, pipeout, do_glob)
pid = vfork();
if (pid < 0) {
-# ifdef BSDSIGS
-# ifdef SAVESIGVEC
+# ifdef SAVESIGVEC
restoresigvec(savesv, savesm);
-# endif /* SAVESIGVEC */
- (void) sigsetmask(omask);
-# else /* !BSDSIGS */
- (void) sigrelse(SIGCHLD);
- (void) sigrelse(SIGINT);
-# endif /* BSDSIGS */
+# endif /* SAVESIGVEC */
+ sigprocmask(SIG_SETMASK, &oset, NULL);
stderror(ERR_NOPROC);
}
forked++;
@@ -493,38 +483,27 @@ execute(t, wanttty, pipein, pipeout, do_glob)
tpgrp = otpgrp;
isoutatty = oisoutatty;
isdiagatty = oisdiagatty;
-# ifdef BSDSIGS
- csigmask = ocsigmask;
-# endif /* BSDSIGS */
+ csigset = ocsigset;
nosigchld = onosigchld;
- xfree((ptr_t) Vsav);
+ xfree(Vsav);
Vsav = 0;
- xfree((ptr_t) Vdp);
+ xfree(Vdp);
Vdp = 0;
- xfree((ptr_t) Vexpath);
+ xfree(Vexpath);
Vexpath = 0;
- blkfree((Char **) Vt);
+ blk_cleanup(Vt);
Vt = 0;
/* this is from pfork() */
palloc(pid, t);
-# ifdef BSDSIGS
- (void) sigsetmask(omask);
-# else /* !BSDSIGS */
- (void) sigrelse(SIGCHLD);
- (void) sigrelse(SIGINT);
-# endif /* BSDSIGS */
+ sigprocmask(SIG_SETMASK, &oset, NULL);
}
else { /* child */
/* this is from pfork() */
- int pgrp;
+ pid_t pgrp;
int ignint = 0;
if (nosigchld) {
-# ifdef BSDSIGS
- (void) sigsetmask(csigmask);
-# else /* !BSDSIGS */
- (void) sigrelse(SIGCHLD);
-# endif /* BSDSIGS */
+ sigprocmask(SIG_SETMASK, &csigset, NULL);
nosigchld = 0;
}
@@ -548,7 +527,7 @@ execute(t, wanttty, pipein, pipeout, do_glob)
(void) signal(SIGQUIT, SIG_IGN);
}
else {
- (void) signal(SIGINT, vffree);
+ (void) signal(SIGINT, vffree);
(void) signal(SIGQUIT, SIG_DFL);
}
# ifdef BSDJOBS
@@ -559,7 +538,7 @@ execute(t, wanttty, pipein, pipeout, do_glob)
}
# endif /* BSDJOBS */
- (void) signal(SIGTERM, parterm);
+ sigaction(SIGTERM, &parterm, NULL);
}
else if (tpgrp == -1 &&
(t->t_dflg & F_NOINTERRUPT)) {
@@ -603,26 +582,22 @@ execute(t, wanttty, pipein, pipeout, do_glob)
*/
#ifdef BACKPIPE
if (didfds == 0 && t->t_dflg & F_PIPEOUT) {
- (void) close(pipeout[0]);
- (void) close(pipeout[1]);
+ xclose(pipeout[0]);
+ xclose(pipeout[1]);
}
if ((t->t_dflg & F_PIPEIN) != 0)
break;
#else /* !BACKPIPE */
if (didfds == 0 && t->t_dflg & F_PIPEIN) {
- (void) close(pipein[0]);
- (void) close(pipein[1]);
+ xclose(pipein[0]);
+ xclose(pipein[1]);
}
if ((t->t_dflg & F_PIPEOUT) != 0)
break;
#endif /* BACKPIPE */
if (nosigchld) {
-#ifdef BSDSIGS
- (void) sigsetmask(csigmask);
-#else /* !BSDSIGS */
- (void) sigrelse(SIGCHLD);
-#endif /* BSDSIGS */
+ sigprocmask(SIG_SETMASK, &csigset, NULL);
nosigchld = 0;
}
if ((t->t_dflg & F_AMPERSAND) == 0)
@@ -633,13 +608,13 @@ execute(t, wanttty, pipein, pipeout, do_glob)
doio(t, pipein, pipeout);
#ifdef BACKPIPE
if (t->t_dflg & F_PIPEIN) {
- (void) close(pipein[0]);
- (void) close(pipein[1]);
+ xclose(pipein[0]);
+ xclose(pipein[1]);
}
#else /* !BACKPIPE */
if (t->t_dflg & F_PIPEOUT) {
- (void) close(pipeout[0]);
- (void) close(pipeout[1]);
+ xclose(pipeout[0]);
+ xclose(pipeout[1]);
}
#endif /* BACKPIPE */
/*
@@ -671,7 +646,7 @@ execute(t, wanttty, pipein, pipeout, do_glob)
isoutatty = isatty(SHOUT);
(void)close_on_exec(SHDIAG = dcopy(2, FSHDIAG), 1);
isdiagatty = isatty(SHDIAG);
- (void) close(SHIN);
+ xclose(SHIN);
SHIN = -1;
#ifndef CLOSE_ON_EXEC
didcch = 0;
@@ -754,23 +729,11 @@ execute(t, wanttty, pipein, pipeout, do_glob)
}
#ifdef VFORK
-static RETSIGTYPE
+static void
/*ARGSUSED*/
-vffree(snum)
-int snum;
+vffree(int snum)
{
- Char **v;
-
USE(snum);
- if ((v = gargv) != 0) {
- gargv = 0;
- xfree((ptr_t) v);
- }
-
- if ((v = pargv) != 0) {
- pargv = 0;
- xfree((ptr_t) v);
- }
_exit(1);
}
@@ -792,43 +755,42 @@ int snum;
* code is present and the user can choose it by setting noambiguous
*/
static Char *
-splicepipe(t, cp)
- struct command *t;
- Char *cp; /* word after < or > */
+splicepipe(struct command *t, Char *cp)
{
Char *blk[2];
if (adrof(STRnoambiguous)) {
Char **pv;
+ int gflag;
blk[0] = Dfix1(cp); /* expand $ */
blk[1] = NULL;
- gflag = 0, tglob(blk);
+ gflag = tglob(blk);
if (gflag) {
- pv = globall(blk);
+ pv = globall(blk, gflag);
if (pv == NULL) {
setname(short2str(blk[0]));
- xfree((ptr_t) blk[0]);
+ xfree(blk[0]);
stderror(ERR_NAME | ERR_NOMATCH);
}
- gargv = NULL;
if (pv[1] != NULL) { /* we need to fix the command vector */
Char **av = blkspl(t->t_dcom, &pv[1]);
- xfree((ptr_t) t->t_dcom);
+ xfree(t->t_dcom);
t->t_dcom = av;
}
- xfree((ptr_t) blk[0]);
+ xfree(blk[0]);
blk[0] = pv[0];
- xfree((ptr_t) pv);
+ xfree(pv);
}
}
else {
- Char buf[BUFSIZE];
+ Char *buf;
- (void) Strcpy(buf, blk[1] = Dfix1(cp));
- xfree((ptr_t) blk[1]);
+ buf = Dfix1(cp);
+ cleanup_push(buf, xfree);
blk[0] = globone(buf, G_ERROR);
+ cleanup_until(buf);
}
return(blk[0]);
}
@@ -838,9 +800,7 @@ splicepipe(t, cp)
* We may or maynot be forked here.
*/
static void
-doio(t, pipein, pipeout)
- struct command *t;
- int *pipein, *pipeout;
+doio(struct command *t, int *pipein, int *pipeout)
{
int fd;
Char *cp;
@@ -850,7 +810,7 @@ doio(t, pipein, pipeout)
return;
if ((flags & F_READ) == 0) {/* F_READ already done */
if (t->t_dlef) {
- char tmp[MAXPATHLEN+1];
+ char *tmp;
/*
* so < /dev/std{in,out,err} work
@@ -859,11 +819,12 @@ doio(t, pipein, pipeout)
(void) dcopy(SHOUT, 1);
(void) dcopy(SHDIAG, 2);
cp = splicepipe(t, t->t_dlef);
- (void) strncpy(tmp, short2str(cp), MAXPATHLEN);
- tmp[MAXPATHLEN] = '\0';
- xfree((ptr_t) cp);
- if ((fd = open(tmp, O_RDONLY|O_LARGEFILE)) < 0)
+ tmp = strsave(short2str(cp));
+ xfree(cp);
+ cleanup_push(tmp, xfree);
+ if ((fd = xopen(tmp, O_RDONLY|O_LARGEFILE)) < 0)
stderror(ERR_SYSTEM, tmp, strerror(errno));
+ cleanup_until(tmp);
/* allow input files larger than 2Gb */
#ifndef WINNT_NATIVE
(void) fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_LARGEFILE);
@@ -871,17 +832,17 @@ doio(t, pipein, pipeout)
(void) dmove(fd, 0);
}
else if (flags & F_PIPEIN) {
- (void) close(0);
+ xclose(0);
(void) dup(pipein[0]);
- (void) close(pipein[0]);
- (void) close(pipein[1]);
+ xclose(pipein[0]);
+ xclose(pipein[1]);
}
else if ((flags & F_NOINTERRUPT) && tpgrp == -1) {
- (void) close(0);
- (void) open(_PATH_DEVNULL, O_RDONLY|O_LARGEFILE);
+ xclose(0);
+ (void) xopen(_PATH_DEVNULL, O_RDONLY|O_LARGEFILE);
}
else {
- (void) close(0);
+ xclose(0);
(void) dup(OLDSTD);
#if defined(CLOSE_ON_EXEC) && defined(CLEX_DUPS)
/*
@@ -895,12 +856,12 @@ doio(t, pipein, pipeout)
}
}
if (t->t_drit) {
- char tmp[MAXPATHLEN+1];
+ char *tmp;
cp = splicepipe(t, t->t_drit);
- (void) strncpy(tmp, short2str(cp), MAXPATHLEN);
- tmp[MAXPATHLEN] = '\0';
- xfree((ptr_t) cp);
+ tmp = strsave(short2str(cp));
+ xfree(cp);
+ cleanup_push(tmp, xfree);
/*
* so > /dev/std{out,err} work
*/
@@ -908,9 +869,9 @@ doio(t, pipein, pipeout)
(void) dcopy(SHDIAG, 2);
if ((flags & F_APPEND) != 0) {
#ifdef O_APPEND
- fd = open(tmp, O_WRONLY|O_APPEND|O_LARGEFILE);
+ fd = xopen(tmp, O_WRONLY|O_APPEND|O_LARGEFILE);
#else /* !O_APPEND */
- fd = open(tmp, O_WRONLY|O_LARGEFILE);
+ fd = xopen(tmp, O_WRONLY|O_LARGEFILE);
(void) lseek(fd, (off_t) 0, L_XTND);
#endif /* O_APPEND */
}
@@ -922,23 +883,24 @@ doio(t, pipein, pipeout)
stderror(ERR_SYSTEM, tmp, strerror(errno));
chkclob(tmp);
}
- if ((fd = creat(tmp, 0666)) < 0)
+ if ((fd = xcreat(tmp, 0666)) < 0)
stderror(ERR_SYSTEM, tmp, strerror(errno));
/* allow input files larger than 2Gb */
#ifndef WINNT_NATIVE
(void) fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_LARGEFILE);
#endif /*!WINNT_NATIVE*/
}
+ cleanup_until(tmp);
(void) dmove(fd, 1);
is1atty = isatty(1);
}
else if (flags & F_PIPEOUT) {
- (void) close(1);
+ xclose(1);
(void) dup(pipeout[1]);
is1atty = 0;
}
else {
- (void) close(1);
+ xclose(1);
(void) dup(SHOUT);
is1atty = isoutatty;
# if defined(CLOSE_ON_EXEC) && defined(CLEX_DUPS)
@@ -946,7 +908,7 @@ doio(t, pipein, pipeout)
# endif /* CLOSE_ON_EXEC && CLEX_DUPS */
}
- (void) close(2);
+ xclose(2);
if (flags & F_STDERR) {
(void) dup(1);
is2atty = is1atty;
@@ -962,8 +924,7 @@ doio(t, pipein, pipeout)
}
void
-mypipe(pv)
- int *pv;
+mypipe(int *pv)
{
if (pipe(pv) < 0)
@@ -972,13 +933,16 @@ mypipe(pv)
(void)close_on_exec(pv[1] = dmove(pv[1], -1), 1);
if (pv[0] >= 0 && pv[1] >= 0)
return;
+ if (pv[0] >= 0)
+ xclose(pv[0]);
+ if (pv[1] >= 0)
+ xclose(pv[1]);
oops:
stderror(ERR_PIPE);
}
static void
-chkclob(cp)
- char *cp;
+chkclob(const char *cp)
{
struct stat stb;
diff --git a/contrib/tcsh/sh.set.c b/contrib/tcsh/sh.set.c
index 568024f..8253e02 100644
--- a/contrib/tcsh/sh.set.c
+++ b/contrib/tcsh/sh.set.c
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/sh.set.c,v 3.61 2005/03/03 16:57:02 kim Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/sh.set.c,v 3.70 2006/08/24 20:56:31 christos Exp $ */
/*
* sh.set.c: Setting and Clearing of variables
*/
@@ -32,7 +32,7 @@
*/
#include "sh.h"
-RCSID("$Id: sh.set.c,v 3.61 2005/03/03 16:57:02 kim Exp $")
+RCSID("$tcsh: sh.set.c,v 3.70 2006/08/24 20:56:31 christos Exp $")
#include "ed.h"
#include "tw.h"
@@ -44,29 +44,33 @@ RCSID("$Id: sh.set.c,v 3.61 2005/03/03 16:57:02 kim Exp $")
extern int GotTermCaps;
int numeof = 0;
-static void update_vars __P((Char *));
-static Char *getinx __P((Char *, int *));
-static void asx __P((Char *, int, Char *));
-static struct varent *getvx __P((Char *, int));
-static Char *xset __P((Char *, Char ***));
-static Char *operate __P((int, Char *, Char *));
-static void putn1 __P((int));
-static struct varent *madrof __P((Char *, struct varent *));
-static void unsetv1 __P((struct varent *));
-static void exportpath __P((Char **));
-static void balance __P((struct varent *, int, int));
+static void update_vars (Char *);
+static Char *getinx (Char *, int *);
+static void asx (Char *, int, Char *);
+static struct varent *getvx (Char *, int);
+static Char *xset (Char *, Char ***);
+static Char *operate (int, Char *, Char *);
+static void putn1 (unsigned);
+static struct varent *madrof (Char *, struct varent *);
+static void unsetv1 (struct varent *);
+static void exportpath (Char **);
+static void balance (struct varent *, int, int);
/*
* C Shell
*/
static void
-update_vars(vp)
- Char *vp;
+update_vars(Char *vp)
{
if (eq(vp, STRpath)) {
- exportpath(adrof(STRpath)->vec);
- dohash(NULL, NULL);
+ struct varent *p = adrof(STRpath);
+ if (p == NULL)
+ stderror(ERR_NAME | ERR_UNDVAR);
+ else {
+ exportpath(p->vec);
+ dohash(NULL, NULL);
+ }
}
else if (eq(vp, STRhistchars)) {
Char *pn = varval(vp);
@@ -121,27 +125,31 @@ update_vars(vp)
Strcmp(cp, STRunknown) != 0 && Strcmp(cp, STRdumb) != 0) {
editing = 1;
noediting = 0;
- set(STRedit, Strsave(STRNULL), VAR_READWRITE);
+ setNS(STRedit);
}
ed_Init(); /* reset the editor */
}
else if (eq(vp, STRhome)) {
- Char *cp;
+ Char *cp, *canon;
cp = Strsave(varval(vp)); /* get the old value back */
+ cleanup_push(cp, xfree);
/*
* convert to cononical pathname (possibly resolving symlinks)
*/
- cp = dcanon(cp, cp);
+ canon = dcanon(cp, cp);
+ cleanup_ignore(cp);
+ cleanup_until(cp);
+ cleanup_push(canon, xfree);
- set(vp, Strsave(cp), VAR_READWRITE); /* have to save the new val */
+ setcopy(vp, canon, VAR_READWRITE); /* have to save the new val */
/* and now mirror home with HOME */
- tsetenv(STRKHOME, cp);
+ tsetenv(STRKHOME, canon);
/* fix directory stack for new tilde home */
dtilde();
- xfree((ptr_t) cp);
+ cleanup_until(canon);
}
else if (eq(vp, STRedit)) {
editing = 1;
@@ -208,9 +216,7 @@ update_vars(vp)
/*ARGSUSED*/
void
-doset(v, c)
- Char **v;
- struct command *c;
+doset(Char **v, struct command *c)
{
Char *p;
Char *vp, op;
@@ -258,10 +264,6 @@ doset(v, c)
continue;
if (vp == p || !letter(*vp))
stderror(ERR_NAME | ERR_VARBEGIN);
- if ((p - vp) > MAXVARLEN) {
- stderror(ERR_NAME | ERR_VARTOOLONG);
- return;
- }
if (*p == '[') {
hadsub++;
p = getinx(p, &subscr);
@@ -302,18 +304,23 @@ doset(v, c)
*e = p;
v = e + 1;
}
- else if (hadsub)
- asx(vp, subscr, Strsave(p));
+ else if (hadsub) {
+ Char *copy;
+
+ copy = Strsave(p);
+ cleanup_push(copy, xfree);
+ asx(vp, subscr, copy);
+ cleanup_ignore(copy);
+ cleanup_until(copy);
+ }
else
- set(vp, Strsave(p), flags);
+ setv(vp, Strsave(p), flags);
update_vars(vp);
} while ((p = *v++) != NULL);
}
static Char *
-getinx(cp, ip)
- Char *cp;
- int *ip;
+getinx(Char *cp, int *ip)
{
*ip = 0;
*cp++ = 0;
@@ -325,23 +332,21 @@ getinx(cp, ip)
}
static void
-asx(vp, subscr, p)
- Char *vp;
- int subscr;
- Char *p;
+asx(Char *vp, int subscr, Char *p)
{
struct varent *v = getvx(vp, subscr);
+ Char *prev;
if (v->v_flags & VAR_READONLY)
stderror(ERR_READONLY|ERR_NAME, v->v_name);
- xfree((ptr_t) v->vec[subscr - 1]);
+ prev = v->vec[subscr - 1];
+ cleanup_push(prev, xfree);
v->vec[subscr - 1] = globone(p, G_APPEND);
+ cleanup_until(prev);
}
static struct varent *
-getvx(vp, subscr)
- Char *vp;
- int subscr;
+getvx(Char *vp, int subscr)
{
struct varent *v = adrof(vp);
@@ -354,9 +359,7 @@ getvx(vp, subscr)
/*ARGSUSED*/
void
-dolet(v, dummy)
- Char **v;
- struct command *dummy;
+dolet(Char **v, struct command *dummy)
{
Char *p;
Char *vp, c, op;
@@ -378,8 +381,6 @@ dolet(v, dummy)
continue;
if (vp == p || !letter(*vp))
stderror(ERR_NAME | ERR_VARBEGIN);
- if ((p - vp) > MAXVARLEN)
- stderror(ERR_NAME | ERR_VARTOOLONG);
if (*p == '[') {
hadsub++;
p = getinx(p, &subscr);
@@ -399,6 +400,7 @@ dolet(v, dummy)
stderror(ERR_NAME | ERR_ASSIGN);
vp = Strsave(vp);
+ cleanup_push(vp, xfree);
if (op == '=') {
c = '=';
p = xset(p, &v);
@@ -414,7 +416,6 @@ dolet(v, dummy)
if (any("<>", op)) {
if (c != op)
stderror(ERR_NAME | ERR_UNKNOWNOP);
- c = *p++;
stderror(ERR_NAME | ERR_SYNTAX);
}
if (c != '=')
@@ -422,45 +423,54 @@ dolet(v, dummy)
p = xset(p, &v);
}
}
+ cleanup_push(p, xfree);
if (op == '=') {
if (hadsub)
asx(vp, subscr, p);
else
- set(vp, p, VAR_READWRITE);
+ setv(vp, p, VAR_READWRITE);
+ cleanup_ignore(p);
}
else if (hadsub) {
struct varent *gv = getvx(vp, subscr);
+ Char *val;
- asx(vp, subscr, operate(op, gv->vec[subscr - 1], p));
+ val = operate(op, gv->vec[subscr - 1], p);
+ cleanup_push(val, xfree);
+ asx(vp, subscr, val);
+ cleanup_ignore(val);
+ cleanup_until(val);
+ }
+ else {
+ Char *val;
+
+ val = operate(op, varval(vp), p);
+ cleanup_push(val, xfree);
+ setv(vp, val, VAR_READWRITE);
+ cleanup_ignore(val);
+ cleanup_until(val);
}
- else
- set(vp, operate(op, varval(vp), p), VAR_READWRITE);
update_vars(vp);
- xfree((ptr_t) vp);
- if (c != '=')
- xfree((ptr_t) p);
+ cleanup_until(vp);
} while ((p = *v++) != NULL);
}
static Char *
-xset(cp, vp)
- Char *cp, ***vp;
+xset(Char *cp, Char ***vp)
{
Char *dp;
if (*cp) {
dp = Strsave(cp);
--(*vp);
- xfree((ptr_t) ** vp);
+ xfree(** vp);
**vp = dp;
}
return (putn(expr(vp)));
}
static Char *
-operate(op, vp, p)
- int op;
- Char *vp, *p;
+operate(int op, Char *vp, Char *p)
{
Char opr[2];
Char *vec[5];
@@ -471,7 +481,7 @@ operate(op, vp, p)
if (op != '=') {
if (*vp)
*v++ = vp;
- opr[0] = (Char) op;
+ opr[0] = op;
opr[1] = 0;
*v++ = opr;
if (op == '<' || op == '>')
@@ -485,43 +495,25 @@ operate(op, vp, p)
return (putn(i));
}
-static Char *putp, nbuf[50];
+static Char *putp;
Char *
-putn(n)
- int n;
+putn(int n)
{
- int num;
+ Char nbuf[(CHAR_BIT * sizeof (n) + 2) / 3 + 2]; /* Enough even for octal */
putp = nbuf;
if (n < 0) {
n = -n;
*putp++ = '-';
}
- num = 2; /* confuse lint */
- if (sizeof(int) == num && ((unsigned int) n) == 0x8000) {
- *putp++ = '3';
- n = 2768;
-#ifdef pdp11
- }
-#else /* !pdp11 */
- }
- else {
- num = 4; /* confuse lint */
- if (sizeof(int) == num && ((unsigned int) n) == 0x80000000) {
- *putp++ = '2';
- n = 147483648;
- }
- }
-#endif /* pdp11 */
putn1(n);
*putp = 0;
return (Strsave(nbuf));
}
static void
-putn1(n)
- int n;
+putn1(unsigned n)
{
if (n > 9)
putn1(n / 10);
@@ -529,8 +521,7 @@ putn1(n)
}
int
-getn(cp)
- Char *cp;
+getn(Char *cp)
{
int n;
int sign;
@@ -556,9 +547,7 @@ getn(cp)
}
Char *
-value1(var, head)
- Char *var;
- struct varent *head;
+value1(Char *var, struct varent *head)
{
struct varent *vp;
@@ -571,9 +560,7 @@ value1(var, head)
}
static struct varent *
-madrof(pat, vp)
- Char *pat;
- struct varent *vp;
+madrof(Char *pat, struct varent *vp)
{
struct varent *vp1;
@@ -587,9 +574,7 @@ madrof(pat, vp)
}
struct varent *
-adrof1(name, v)
- Char *name;
- struct varent *v;
+adrof1(const Char *name, struct varent *v)
{
int cmp;
@@ -603,15 +588,25 @@ adrof1(name, v)
return v;
}
+void
+setcopy(const Char *var, const Char *val, int flags)
+{
+ Char *copy;
+
+ copy = Strsave(val);
+ cleanup_push(copy, xfree);
+ setv(var, copy, flags);
+ cleanup_ignore(copy);
+ cleanup_until(copy);
+}
+
/*
* The caller is responsible for putting value in a safe place
*/
void
-set(var, val, flags)
- Char *var, *val;
- int flags;
+setv(const Char *var, Char *val, int flags)
{
- Char **vec = (Char **) xmalloc((size_t) (2 * sizeof(Char **)));
+ Char **vec = xmalloc(2 * sizeof(Char **));
vec[0] = val;
vec[1] = 0;
@@ -619,25 +614,21 @@ set(var, val, flags)
}
void
-set1(var, vec, head, flags)
- Char *var, **vec;
- struct varent *head;
- int flags;
+set1(const Char *var, Char **vec, struct varent *head, int flags)
{
Char **oldv = vec;
if ((flags & VAR_NOGLOB) == 0) {
- gflag = 0;
- tglob(oldv);
+ int gflag;
+
+ gflag = tglob(oldv);
if (gflag) {
- vec = globall(oldv);
+ vec = globall(oldv, gflag);
if (vec == 0) {
blkfree(oldv);
stderror(ERR_NAME | ERR_NOMATCH);
- return;
}
blkfree(oldv);
- gargv = 0;
}
}
/*
@@ -662,7 +653,7 @@ set1(var, vec, head, flags)
for (j = 0; j < i; j++)
/* If have earlier identical item, remove i'th item */
if (vec[i] && vec[j] && Strcmp(vec[j], vec[i]) == 0) {
- free(vec[i]);
+ xfree(vec[i]);
vec[i] = NULL;
break;
}
@@ -673,7 +664,7 @@ set1(var, vec, head, flags)
/* If have later identical item, remove i'th item */
if (vec[i] && vec[j] && Strcmp(vec[j], vec[i]) == 0) {
/* remove identical item (the first) */
- free(vec[i]);
+ xfree(vec[i]);
vec[i] = NULL;
}
}
@@ -694,10 +685,7 @@ set1(var, vec, head, flags)
void
-setq(name, vec, p, flags)
- Char *name, **vec;
- struct varent *p;
- int flags;
+setq(const Char *name, Char **vec, struct varent *p, int flags)
{
struct varent *c;
int f;
@@ -716,7 +704,7 @@ setq(name, vec, p, flags)
p = c;
f = f > 0;
}
- p->v_link[f] = c = (struct varent *) xmalloc((size_t)sizeof(struct varent));
+ p->v_link[f] = c = xmalloc(sizeof(struct varent));
c->v_name = Strsave(name);
c->v_flags = flags;
c->v_bal = 0;
@@ -728,9 +716,7 @@ setq(name, vec, p, flags)
/*ARGSUSED*/
void
-unset(v, c)
- Char **v;
- struct command *c;
+unset(Char **v, struct command *c)
{
int did_roe, did_edit;
@@ -788,9 +774,7 @@ unset(v, c)
}
void
-unset1(v, head)
- Char *v[];
- struct varent *head;
+unset1(Char *v[], struct varent *head)
{
struct varent *vp;
int cnt;
@@ -808,8 +792,7 @@ unset1(v, head)
}
void
-unsetv(var)
- Char *var;
+unsetv(Char *var)
{
struct varent *vp;
@@ -819,8 +802,7 @@ unsetv(var)
}
static void
-unsetv1(p)
- struct varent *p;
+unsetv1(struct varent *p)
{
struct varent *c, *pp;
int f;
@@ -829,7 +811,7 @@ unsetv1(p)
* Free associated memory first to avoid complications.
*/
blkfree(p->vec);
- xfree((ptr_t) p->v_name);
+ xfree(p->v_name);
/*
* If p is missing one child, then we can move the other into where p is.
* Otherwise, we find the predecessor of p, which is guaranteed to have no
@@ -859,22 +841,19 @@ unsetv1(p)
/*
* Free the deleted node, and rebalance.
*/
- xfree((ptr_t) p);
+ xfree(p);
balance(pp, f, 1);
}
void
-setNS(cp)
- Char *cp;
+setNS(Char *cp)
{
- set(cp, Strsave(STRNULL), VAR_READWRITE);
+ setcopy(cp, STRNULL, VAR_READWRITE);
}
/*ARGSUSED*/
void
-shift(v, c)
- Char **v;
- struct command *c;
+shift(Char **v, struct command *c)
{
struct varent *argv;
Char *name;
@@ -895,35 +874,23 @@ shift(v, c)
update_vars(name);
}
-static Char STRsep[2] = { PATHSEP, '\0' };
-
static void
-exportpath(val)
- Char **val;
+exportpath(Char **val)
{
- Char *exppath;
- size_t exppath_size = BUFSIZE;
- exppath = (Char *)xmalloc(sizeof(Char)*exppath_size);
+ struct Strbuf buf = Strbuf_INIT;
+ Char *exppath;
- exppath[0] = 0;
if (val)
while (*val) {
- while (Strlen(*val) + Strlen(exppath) + 2 > exppath_size) {
- if ((exppath
- = (Char *)xrealloc(exppath, sizeof(Char)*(exppath_size *= 2)))
- == NULL) {
- xprintf(CGETS(18, 1,
- "Warning: ridiculously long PATH truncated\n"));
- break;
- }
- }
- (void) Strcat(exppath, *val++);
+ Strbuf_append(&buf, *val++);
if (*val == 0 || eq(*val, STRRparen))
- break;
- (void) Strcat(exppath, STRsep);
- }
- tsetenv(STRKPATH, exppath);
- free(exppath);
+ break;
+ Strbuf_append1(&buf, PATHSEP);
+ }
+ exppath = Strbuf_finish(&buf);
+ cleanup_push(exppath, xfree);
+ tsetenv(STRKPATH, exppath);
+ cleanup_until(exppath);
}
#ifndef lint
@@ -947,14 +914,12 @@ exportpath(val)
(p) = t)
#else
static struct varent *
-rleft(p)
- struct varent *p;
+rleft(struct varent *p)
{
return (p);
}
static struct varent *
-rright(p)
- struct varent *p;
+rright(struct varent *p)
{
return (p);
}
@@ -968,9 +933,7 @@ rright(p)
* D == 1 means we've just done a delete, otherwise an insert.
*/
static void
-balance(p, f, d)
- struct varent *p;
- int f, d;
+balance(struct varent *p, int f, int d)
{
struct varent *pp;
@@ -999,7 +962,7 @@ balance(p, f, d)
break;
case 1: /* was already right heavy */
switch (p->v_right->v_bal) {
- case 1: /* sigle rotate */
+ case 1: /* single rotate */
pp->v_link[ff] = rleft(p);
p->v_left->v_bal = 0;
p->v_bal = 0;
@@ -1041,7 +1004,7 @@ balance(p, f, d)
p->v_right->v_bal = 0;
p->v_bal = 0;
break;
- case 0: /* signle rotate */
+ case 0: /* single rotate */
pp->v_link[ff] = rright(p);
p->v_right->v_bal = -1;
p->v_bal = 1;
@@ -1073,27 +1036,24 @@ balance(p, f, d)
}
void
-plist(p, what)
- struct varent *p;
- int what;
+plist(struct varent *p, int what)
{
struct varent *c;
int len;
- if (setintr)
-#ifdef BSDSIGS
- (void) sigsetmask(sigblock((sigmask_t) 0) & ~sigmask(SIGINT));
-#else /* !BSDSIGS */
- (void) sigrelse(SIGINT);
-#endif /* BSDSIGS */
-
for (;;) {
while (p->v_left)
p = p->v_left;
x:
if (p->v_parent == 0) /* is it the header? */
- return;
+ break;
if ((p->v_flags & what) != 0) {
+ if (setintr) {
+ int old_pintr_disabled;
+
+ pintr_push_enable(&old_pintr_disabled);
+ cleanup_until(&old_pintr_disabled);
+ }
len = blklen(p->vec);
xprintf("%S\t", p->v_name);
if (len != 1)
@@ -1119,7 +1079,7 @@ x:
extern int dspmbyte_ls;
void
-update_dspmbyte_vars()
+update_dspmbyte_vars(void)
{
int lp, iskcode;
Char *dstr1;
@@ -1222,11 +1182,10 @@ update_dspmbyte_vars()
#ifdef MBYTEDEBUG /* Sorry, use for beta testing */
{
Char mbmapstr[300];
- for (lp = 0; lp < 256; lp++) {
+ for (lp = 0; lp < 256; lp++)
mbmapstr[lp] = _mbmap[lp] + '0';
- mbmapstr[lp+1] = 0;
- }
- set(STRmbytemap, Strsave(mbmapstr), VAR_READWRITE);
+ mbmapstr[lp] = 0;
+ setcopy(STRmbytemap, mbmapstr, VAR_READWRITE);
}
#endif /* MBYTEMAP */
}
@@ -1234,11 +1193,10 @@ update_dspmbyte_vars()
/* dspkanji/dspmbyte autosetting */
/* PATCH IDEA FROM Issei.Suzuki VERY THANKS */
void
-autoset_dspmbyte(pcp)
- Char *pcp;
+autoset_dspmbyte(const Char *pcp)
{
int i;
- struct dspm_autoset_Table {
+ static const struct dspm_autoset_Table {
Char *n;
Char *v;
} dspmt[] = {
@@ -1257,8 +1215,8 @@ autoset_dspmbyte(pcp)
{ STRstarutfstar8, STRutf8 },
{ NULL, NULL }
};
-#ifdef HAVE_NL_LANGINFO
- struct dspm_autoset_Table dspmc[] = {
+#if defined(HAVE_NL_LANGINFO) && defined(CODESET)
+ static const struct dspm_autoset_Table dspmc[] = {
{ STRstarutfstar8, STRutf8 },
{ STReuc, STReuc },
{ STRGB2312, STReuc },
@@ -1270,9 +1228,9 @@ autoset_dspmbyte(pcp)
codeset = str2short(nl_langinfo(CODESET));
if (*codeset != '\0') {
for (i = 0; dspmc[i].n; i++) {
- Char *estr;
+ const Char *estr;
if (dspmc[i].n[0] && t_pmatch(pcp, dspmc[i].n, &estr, 0) > 0) {
- set(CHECK_MBYTEVAR, Strsave(dspmc[i].v), VAR_READWRITE);
+ setcopy(CHECK_MBYTEVAR, dspmc[i].v, VAR_READWRITE);
update_dspmbyte_vars();
return;
}
@@ -1284,9 +1242,9 @@ autoset_dspmbyte(pcp)
return;
for (i = 0; dspmt[i].n; i++) {
- Char *estr;
+ const Char *estr;
if (dspmt[i].n[0] && t_pmatch(pcp, dspmt[i].n, &estr, 0) > 0) {
- set(CHECK_MBYTEVAR, Strsave(dspmt[i].v), VAR_READWRITE);
+ setcopy(CHECK_MBYTEVAR, dspmt[i].v, VAR_READWRITE);
update_dspmbyte_vars();
break;
}
diff --git a/contrib/tcsh/sh.time.c b/contrib/tcsh/sh.time.c
index f599a59..f8ff370 100644
--- a/contrib/tcsh/sh.time.c
+++ b/contrib/tcsh/sh.time.c
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/sh.time.c,v 3.28 2005/03/03 16:49:16 kim Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/sh.time.c,v 3.33 2006/03/02 18:46:44 christos Exp $ */
/*
* sh.time.c: Shell time keeping and printing.
*/
@@ -32,7 +32,7 @@
*/
#include "sh.h"
-RCSID("$Id: sh.time.c,v 3.28 2005/03/03 16:49:16 kim Exp $")
+RCSID("$tcsh: sh.time.c,v 3.33 2006/03/02 18:46:44 christos Exp $")
#ifdef SUNOS4
# include <machine/param.h>
@@ -52,17 +52,17 @@ struct tms times0;
#if !defined(BSDTIMES) && !defined(_SEQUENT_)
# ifdef POSIX
-static void pdtimet __P((clock_t, clock_t));
+static void pdtimet (clock_t, clock_t);
# else /* ! POSIX */
-static void pdtimet __P((time_t, time_t));
+static void pdtimet (time_t, time_t);
# endif /* ! POSIX */
#else /* BSDTIMES || _SEQUENT_ */
-static void tvadd __P((timeval_t *, timeval_t *));
-static void pdeltat __P((timeval_t *, timeval_t *));
+static void tvadd (timeval_t *, timeval_t *);
+static void pdeltat (timeval_t *, timeval_t *);
#endif /* BSDTIMES || _SEQUENT_ */
void
-settimes()
+settimes(void)
{
#ifdef BSDTIMES
struct sysrusage ruch;
@@ -83,12 +83,7 @@ settimes()
ruadd(&ru0, &ruch);
# else /* _SEQUENT_ */
seconds0 = time(NULL);
-# ifndef COHERENT
time0 = times(&times0);
-# else /* !COHERENT */
- time0 = HZ * seconds0;
- times(&times0);
-# endif /* !COHERENT */
times0.tms_stime += times0.tms_cstime;
times0.tms_utime += times0.tms_cutime;
times0.tms_cstime = 0;
@@ -103,9 +98,7 @@ settimes()
*/
/*ARGSUSED*/
void
-dotime(v, c)
- Char **v;
- struct command *c;
+dotime(Char **v, struct command *c)
{
#ifdef BSDTIMES
timeval_t timedol;
@@ -137,12 +130,7 @@ dotime(v, c)
struct tms times_dol;
-#ifndef COHERENT
timedol = times(&times_dol);
-#else
- timedol = HZ * time(NULL);
- times(&times_dol);
-#endif
times_dol.tms_stime += times_dol.tms_cstime;
times_dol.tms_utime += times_dol.tms_cutime;
times_dol.tms_cstime = 0;
@@ -159,9 +147,7 @@ dotime(v, c)
*/
/*ARGSUSED*/
void
-donice(v, c)
- Char **v;
- struct command *c;
+donice(Char **v, struct command *c)
{
Char *cp;
int nval = 0;
@@ -182,8 +168,7 @@ donice(v, c)
#ifdef BSDTIMES
void
-ruadd(ru, ru2)
- struct sysrusage *ru, *ru2;
+ruadd(struct sysrusage *ru, struct sysrusage *ru2)
{
tvadd(&ru->ru_utime, &ru2->ru_utime);
tvadd(&ru->ru_stime, &ru2->ru_stime);
@@ -218,8 +203,7 @@ ruadd(ru, ru2)
#else /* BSDTIMES */
# ifdef _SEQUENT_
void
-ruadd(ru, ru2)
- struct process_stats *ru, *ru2;
+ruadd(struct process_stats *ru, struct process_stats *ru2)
{
tvadd(&ru->ps_utime, &ru2->ps_utime);
tvadd(&ru->ps_stime, &ru2->ps_stime);
@@ -290,28 +274,21 @@ ruadd(ru, ru2)
#endif /* SUNOS4 */
void
-prusage(r0, r1, e, b)
- struct sysrusage *r0, *r1;
- timeval_t *e, *b;
+prusage(struct sysrusage *r0, struct sysrusage *r1, timeval_t *e, timeval_t *b)
#else /* BSDTIMES */
# ifdef _SEQUENT_
void
-prusage(r0, r1, e, b)
- struct process_stats *r0, *r1;
- timeval_t *e, *b;
+prusage(struct process_stats *r0, struct process_stats *r1, timeval_t e,
+ timeval_t b)
# else /* _SEQUENT_ */
-void
-prusage(bs, es, e, b)
- struct tms *bs, *es;
-
# ifndef POSIX
- time_t e, b;
-
+void
+prusage(struct tms *bs, struct tms *es, time_t e, time_t b)
# else /* POSIX */
- clock_t e, b;
-
+void
+prusage(struct tms *bs, struct tms *es, clock_t e, clock_t b)
# endif /* POSIX */
# endif /* _SEQUENT_ */
#endif /* BSDTIMES */
@@ -477,7 +454,6 @@ prusage(bs, es, e, b)
(long long)r0->ru_ixrss) /
(long long)t);
xprintf("%lu", (unsigned long)memtmp);
-
break;
case 'D': /* (average) unshared data size */
@@ -706,8 +682,7 @@ prusage(bs, es, e, b)
#if defined(BSDTIMES) || defined(_SEQUENT_)
static void
-pdeltat(t1, t0)
- timeval_t *t1, *t0;
+pdeltat(timeval_t *t1, timeval_t *t0)
{
timeval_t td;
@@ -716,8 +691,7 @@ pdeltat(t1, t0)
}
static void
-tvadd(tsum, t0)
- timeval_t *tsum, *t0;
+tvadd(timeval_t *tsum, timeval_t *t0)
{
tsum->tv_sec += t0->tv_sec;
@@ -727,8 +701,7 @@ tvadd(tsum, t0)
}
void
-tvsub(tdiff, t1, t0)
- timeval_t *tdiff, *t1, *t0;
+tvsub(timeval_t *tdiff, timeval_t *t1, timeval_t *t0)
{
tdiff->tv_sec = t1->tv_sec - t0->tv_sec;
@@ -739,12 +712,11 @@ tvsub(tdiff, t1, t0)
#else /* !BSDTIMES && !_SEQUENT_ */
static void
-pdtimet(eval, bval)
#ifndef POSIX
- time_t eval, bval;
+pdtimet(time_t eval, time_t bval)
#else /* POSIX */
- clock_t eval, bval;
+pdtimet(clock_t eval, clock_t bval)
#endif /* POSIX */
{
diff --git a/contrib/tcsh/sh.types.h b/contrib/tcsh/sh.types.h
index 0868560..58bc70a 100644
--- a/contrib/tcsh/sh.types.h
+++ b/contrib/tcsh/sh.types.h
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/sh.types.h,v 3.42 2005/03/03 19:57:07 kim Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/sh.types.h,v 3.43 2006/01/12 19:55:38 christos Exp $ */
/* sh.types.h: Do the necessary typedefs for each system.
* Up till now I avoided making this into a separate file
* But I just wanted to eliminate the whole mess from sh.h
@@ -46,10 +46,6 @@
*** LynxOS 2.1
***/
#ifdef Lynx
-# ifndef _SIGMASK_T
-# define _SIGMASK_T
- typedef long sigmask_t;
-# endif /* _SIGMASK_T */
# ifndef _PID_T
# define _PID_T
# endif /* _PID_T */
@@ -69,11 +65,6 @@
*** Suns running sunos3.x - sunos4.1.x
***/
#if (defined(sun) || defined(__sun__)) && SYSVREL == 0
-/* This used to be long, but lint dissagrees... */
-# ifndef _SIGMASK_T
-# define _SIGMASK_T
- typedef int sigmask_t;
-# endif /* _SIGMASK_T */
# ifndef _PTR_T
# define _PTR_T
# ifdef __GNUC__
@@ -113,11 +104,6 @@
typedef long pid_t;
# endif /* _PID_T */
-# ifndef _SIGMASK_T
-# define _SIGMASK_T
- typedef long sigmask_t;
-# endif /* _SIGMASK_T */
-
# ifndef _SPEED_T
/* I thought POSIX was supposed to protect all typedefs! */
# define _SPEED_T
@@ -126,8 +112,6 @@
# if HPUXVERSION < 1100 /* XXX: Not true for 11.0 */
extern uid_t getuid(), geteuid();
extern gid_t getgid(), getegid();
-extern sigmask_t sigblock();
-extern sigmask_t sigsetmask();
extern pid_t getpid();
extern pid_t fork();
extern void perror();
@@ -139,15 +123,13 @@ extern unsigned int alarm();
extern unsigned int sleep();
# endif /* HPUXVERSION < 1100 */
# if HPUXVERSION < 800 /* XXX: Not true for 8.0 */
-extern void sigpause();
-extern sigmask_t sigspace();
extern char *sbrk();
# endif /* HPUXVERSION < 800 */
#endif /* __hpux */
-#if (defined(_MINIX) && !defined(_MINIX_VMD)) || defined(__EMX__) || defined(COHERENT)
+#if (defined(_MINIX) && !defined(_MINIX_VMD)) || defined(__EMX__)
typedef char * caddr_t;
-#endif /* (_MINIX && !_MINIX_VMD) || __EMX__ || COHERENT */
+#endif /* (_MINIX && !_MINIX_VMD) || __EMX__ */
/***
*** hp9000s500 running hpux-5.2
@@ -407,11 +389,6 @@ typedef char * caddr_t;
typedef void * ptr_t;
#endif /* _PTR_T */
-#ifndef _SIGMASK_T
-# define _SIGMASK_T
- typedef int sigmask_t;
-#endif /* _SIGMASK_T */
-
#ifndef _IOCTL_T
# define _IOCTL_T
typedef void * ioctl_t; /* Third arg of ioctl */
diff --git a/contrib/tcsh/snames.h b/contrib/tcsh/snames.h
index 0eefa25..976d2dd 100644
--- a/contrib/tcsh/snames.h
+++ b/contrib/tcsh/snames.h
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/snames.h,v 1.3 1996/04/26 19:20:31 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/snames.h,v 1.3 1996/04/26 19:20:31 christos Exp $ */
/*
* snames.h: Short names for old compilers
*/
diff --git a/contrib/tcsh/tc.alloc.c b/contrib/tcsh/tc.alloc.c
index d9c9205..53546fe 100644
--- a/contrib/tcsh/tc.alloc.c
+++ b/contrib/tcsh/tc.alloc.c
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/tc.alloc.c,v 3.39 2005/01/05 16:06:14 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/tc.alloc.c,v 3.46 2006/03/02 18:46:44 christos Exp $ */
/*
* tc.alloc.c (Caltech) 2/21/82
* Chris Kingsley, kingsley@cit-20.
@@ -40,7 +40,10 @@
*/
#include "sh.h"
-RCSID("$Id: tc.alloc.c,v 3.39 2005/01/05 16:06:14 christos Exp $")
+RCSID("$tcsh: tc.alloc.c,v 3.46 2006/03/02 18:46:44 christos Exp $")
+
+#define RCHECK
+#define DEBUG
static char *memtop = NULL; /* PWP: top of current memory */
static char *membot = NULL; /* PWP: bottom of allocatable memory */
@@ -54,10 +57,18 @@ int dont_free = 0;
# define realloc frealloc
#endif /* WINNT_NATIVE */
-#ifndef SYSMALLOC
+#if !defined(DEBUG) || defined(SYSMALLOC)
+static void
+out_of_memory (void)
+{
+ static const char msg[] = "Out of memory\n";
+
+ write(didfds ? 2 : SHDIAG, msg, strlen(msg));
+ _exit(1);
+}
+#endif
-#undef RCHECK
-#undef DEBUG
+#ifndef SYSMALLOC
#ifdef SX
extern void* sbrk();
@@ -134,8 +145,8 @@ static union overhead *nextf[NBUCKETS] IZERO_STRUCT;
static U_int nmalloc[NBUCKETS] IZERO_STRUCT;
#ifndef lint
-static int findbucket __P((union overhead *, int));
-static void morecore __P((int));
+static int findbucket (union overhead *, int);
+static void morecore (int);
#endif
@@ -143,21 +154,20 @@ static void morecore __P((int));
# define CHECK(a, str, p) \
if (a) { \
xprintf(str, p); \
- xprintf(" (memtop = %lx membot = %lx)\n", memtop, membot); \
+ xprintf(" (memtop = %p membot = %p)\n", memtop, membot); \
abort(); \
}
#else
# define CHECK(a, str, p) \
if (a) { \
xprintf(str, p); \
- xprintf(" (memtop = %lx membot = %lx)\n", memtop, membot); \
+ xprintf(" (memtop = %p membot = %p)\n", memtop, membot); \
return; \
}
#endif
memalign_t
-malloc(nbytes)
- size_t nbytes;
+malloc(size_t nbytes)
{
#ifndef lint
union overhead *p;
@@ -193,13 +203,13 @@ malloc(nbytes)
*/
if (nextf[bucket] == NULL)
morecore(bucket);
- if ((p = (union overhead *) nextf[bucket]) == NULL) {
+ if ((p = nextf[bucket]) == NULL) {
child++;
#ifndef DEBUG
- stderror(ERR_NOMEM);
+ out_of_memory();
#else
showall(NULL, NULL);
- xprintf(CGETS(19, 1, "nbytes=%d: Out of memory\n"), nbytes);
+ xprintf(CGETS(19, 1, "nbytes=%zu: Out of memory\n"), nbytes);
abort();
#endif
/* fool lint */
@@ -232,8 +242,7 @@ malloc(nbytes)
* Allocate more memory to the indicated bucket.
*/
static void
-morecore(bucket)
- int bucket;
+morecore(int bucket)
{
union overhead *op;
int rnu; /* 2^rnu bytes will be requested */
@@ -251,14 +260,14 @@ morecore(bucket)
if (membot == NULL)
membot = memtop;
if ((long) op & 0x3ff) {
- memtop = (char *) sbrk((int) (1024 - ((long) op & 0x3ff)));
+ memtop = sbrk((int) (1024 - ((long) op & 0x3ff)));
memtop += (long) (1024 - ((long) op & 0x3ff));
}
/* take 2k unless the block is bigger than that */
rnu = (bucket <= 8) ? 11 : bucket + 3;
nblks = 1 << (rnu - (bucket + 3)); /* how many blocks to get */
- memtop = (char *) sbrk(1 << rnu); /* PWP */
+ memtop = sbrk(1 << rnu); /* PWP */
op = (union overhead *) memtop;
/* no more room! */
if ((long) op == -1)
@@ -287,8 +296,7 @@ morecore(bucket)
#endif
void
-free(cp)
- ptr_t cp;
+free(ptr_t cp)
{
#ifndef lint
int size;
@@ -301,22 +309,22 @@ free(cp)
if (cp == NULL || dont_free)
return;
CHECK(!memtop || !membot,
- CGETS(19, 2, "free(%lx) called before any allocations."), cp);
+ CGETS(19, 2, "free(%p) called before any allocations."), cp);
CHECK(cp > (ptr_t) memtop,
- CGETS(19, 3, "free(%lx) above top of memory."), cp);
+ CGETS(19, 3, "free(%p) above top of memory."), cp);
CHECK(cp < (ptr_t) membot,
- CGETS(19, 4, "free(%lx) below bottom of memory."), cp);
+ CGETS(19, 4, "free(%p) below bottom of memory."), cp);
op = (union overhead *) (((caddr_t) cp) - MEMALIGN(sizeof(union overhead)));
CHECK(op->ov_magic != MAGIC,
- CGETS(19, 5, "free(%lx) bad block."), cp);
+ CGETS(19, 5, "free(%p) bad block."), cp);
#ifdef RCHECK
if (op->ov_index <= 13)
CHECK(*(U_int *) ((caddr_t) op + op->ov_size + 1 - RSLOP) != RMAGIC,
- CGETS(19, 6, "free(%lx) bad range check."), cp);
+ CGETS(19, 6, "free(%p) bad range check."), cp);
#endif
CHECK(op->ov_index >= NBUCKETS,
- CGETS(19, 7, "free(%lx) bad block index."), cp);
+ CGETS(19, 7, "free(%p) bad block index."), cp);
size = op->ov_index;
op->ov_next = nextf[size];
nextf[size] = op;
@@ -330,20 +338,16 @@ free(cp)
}
memalign_t
-calloc(i, j)
- size_t i, j;
+calloc(size_t i, size_t j)
{
#ifndef lint
- char *cp, *scp;
+ char *cp;
i *= j;
- scp = cp = (char *) xmalloc((size_t) i);
- if (i != 0)
- do
- *cp++ = 0;
- while (--i);
+ cp = xmalloc(i);
+ memset(cp, 0, i);
- return ((memalign_t) scp);
+ return ((memalign_t) cp);
#else
if (i && j)
return ((memalign_t) 0);
@@ -369,9 +373,7 @@ static int realloc_srchlen = 4;
#endif /* lint */
memalign_t
-realloc(cp, nbytes)
- ptr_t cp;
- size_t nbytes;
+realloc(ptr_t cp, size_t nbytes)
{
#ifndef lint
U_int onb;
@@ -423,8 +425,7 @@ realloc(cp, nbytes)
* smaller of the old and new size
*/
onb = (1 << (i + 3)) - MEMALIGN(sizeof(union overhead)) - RSLOP;
- (void) memmove((ptr_t) res, (ptr_t) cp,
- (size_t) (onb < nbytes ? onb : nbytes));
+ (void) memmove(res, cp, onb < nbytes ? onb : nbytes);
}
if (was_alloced)
free(cp);
@@ -446,9 +447,7 @@ realloc(cp, nbytes)
* Return bucket number, or -1 if not found.
*/
static int
-findbucket(freep, srchlen)
- union overhead *freep;
- int srchlen;
+findbucket(union overhead *freep, int srchlen)
{
union overhead *p;
size_t i;
@@ -483,8 +482,7 @@ findbucket(freep, srchlen)
** Also we call our error routine if we run out of memory.
**/
memalign_t
-smalloc(n)
- size_t n;
+smalloc(size_t n)
{
ptr_t ptr;
@@ -492,26 +490,22 @@ smalloc(n)
#ifdef HAVE_SBRK
if (membot == NULL)
- membot = (char*) sbrk(0);
+ membot = sbrk(0);
#endif /* HAVE_SBRK */
- if ((ptr = malloc(n)) == (ptr_t) 0) {
- child++;
- stderror(ERR_NOMEM);
- }
+ if ((ptr = malloc(n)) == NULL)
+ out_of_memory();
#ifndef HAVE_SBRK
if (memtop < ((char *) ptr) + n)
memtop = ((char *) ptr) + n;
if (membot == NULL)
- membot = (char*) ptr;
+ membot = ptr;
#endif /* !HAVE_SBRK */
return ((memalign_t) ptr);
}
memalign_t
-srealloc(p, n)
- ptr_t p;
- size_t n;
+srealloc(ptr_t p, size_t n)
{
ptr_t ptr;
@@ -519,27 +513,23 @@ srealloc(p, n)
#ifdef HAVE_SBRK
if (membot == NULL)
- membot = (char*) sbrk(0);
+ membot = sbrk(0);
#endif /* HAVE_SBRK */
- if ((ptr = (p ? realloc(p, n) : malloc(n))) == (ptr_t) 0) {
- child++;
- stderror(ERR_NOMEM);
- }
+ if ((ptr = (p ? realloc(p, n) : malloc(n))) == NULL)
+ out_of_memory();
#ifndef HAVE_SBRK
if (memtop < ((char *) ptr) + n)
memtop = ((char *) ptr) + n;
if (membot == NULL)
- membot = (char*) ptr;
+ membot = ptr;
#endif /* !HAVE_SBRK */
return ((memalign_t) ptr);
}
memalign_t
-scalloc(s, n)
- size_t s, n;
+scalloc(size_t s, size_t n)
{
- char *sptr;
ptr_t ptr;
n *= s;
@@ -547,33 +537,26 @@ scalloc(s, n)
#ifdef HAVE_SBRK
if (membot == NULL)
- membot = (char*) sbrk(0);
+ membot = sbrk(0);
#endif /* HAVE_SBRK */
- if ((ptr = malloc(n)) == (ptr_t) 0) {
- child++;
- stderror(ERR_NOMEM);
- }
+ if ((ptr = malloc(n)) == NULL)
+ out_of_memory();
- sptr = (char *) ptr;
- if (n != 0)
- do
- *sptr++ = 0;
- while (--n);
+ memset (ptr, 0, n);
#ifndef HAVE_SBRK
if (memtop < ((char *) ptr) + n)
memtop = ((char *) ptr) + n;
if (membot == NULL)
- membot = (char*) ptr;
+ membot = ptr;
#endif /* !HAVE_SBRK */
return ((memalign_t) ptr);
}
void
-sfree(p)
- ptr_t p;
+sfree(ptr_t p)
{
if (p && !dont_free)
free(p);
@@ -590,9 +573,7 @@ sfree(p)
*/
/*ARGSUSED*/
void
-showall(v, c)
- Char **v;
- struct command *c;
+showall(Char **v, struct command *c)
{
#ifndef SYSMALLOC
size_t i, j;
@@ -603,12 +584,12 @@ showall(v, c)
for (i = 0; i < NBUCKETS; i++) {
for (j = 0, p = nextf[i]; p; p = p->ov_next, j++)
continue;
- xprintf(" %4d", j);
+ xprintf(" %4zd", j);
totfree += j * (1 << (i + 3));
}
xprintf(CGETS(19, 9, "\nused:\t"));
for (i = 0; i < NBUCKETS; i++) {
- xprintf(" %4u", nmalloc[i]);
+ xprintf(" %4d", nmalloc[i]);
totused += nmalloc[i] * (1 << (i + 3));
}
xprintf(CGETS(19, 10, "\n\tTotal in use: %d, total free: %d\n"),
@@ -619,7 +600,7 @@ showall(v, c)
(unsigned long) sbrk(0));
#else
#ifdef HAVE_SBRK
- memtop = (char *) sbrk(0);
+ memtop = sbrk(0);
#endif /* HAVE_SBRK */
xprintf(CGETS(19, 12, "Allocated memory from 0x%lx to 0x%lx (%ld).\n"),
(unsigned long) membot, (unsigned long) memtop,
diff --git a/contrib/tcsh/tc.bind.c b/contrib/tcsh/tc.bind.c
index 8d3ef40..45c58d9 100644
--- a/contrib/tcsh/tc.bind.c
+++ b/contrib/tcsh/tc.bind.c
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/tc.bind.c,v 3.39 2005/03/25 18:46:41 kim Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/tc.bind.c,v 3.44 2006/03/02 18:46:44 christos Exp $ */
/*
* tc.bind.c: Key binding functions
*/
@@ -32,28 +32,20 @@
*/
#include "sh.h"
-RCSID("$Id: tc.bind.c,v 3.39 2005/03/25 18:46:41 kim Exp $")
+RCSID("$tcsh: tc.bind.c,v 3.44 2006/03/02 18:46:44 christos Exp $")
#include "ed.h"
#include "ed.defns.h"
-#ifdef OBSOLETE
-static int tocontrol __P((int));
-static char *unparsekey __P((int));
-static KEYCMD getkeycmd __P((Char **));
-static int parsekey __P((Char **));
-static void pkeys __P((int, int));
-#endif /* OBSOLETE */
-
-static void printkey __P((KEYCMD *, CStr *));
-static KEYCMD parsecmd __P((Char *));
-static void bad_spec __P((Char *));
-static CStr *parsestring __P((Char *, CStr *));
-static CStr *parsebind __P((Char *, CStr *));
-static void print_all_keys __P((void));
-static void printkeys __P((KEYCMD *, int, int));
-static void bindkey_usage __P((void));
-static void list_functions __P((void));
+static void printkey (const KEYCMD *, CStr *);
+static KEYCMD parsecmd (Char *);
+static void bad_spec (const Char *);
+static CStr *parsestring (const Char *, CStr *);
+static CStr *parsebind (const Char *, CStr *);
+static void print_all_keys (void);
+static void printkeys (KEYCMD *, int, int);
+static void bindkey_usage (void);
+static void list_functions (void);
extern int MapsAreInited;
@@ -62,9 +54,7 @@ extern int MapsAreInited;
/*ARGSUSED*/
void
-dobindkey(v, c)
- Char **v;
- struct command *c;
+dobindkey(Char **v, struct command *c)
{
KEYCMD *map;
int ntype, no, removeb, key, bindk;
@@ -73,13 +63,7 @@ dobindkey(v, c)
KEYCMD cmd;
CStr in;
CStr out;
- Char inbuf[200];
- Char outbuf[200];
uChar ch;
- in.buf = inbuf;
- out.buf = outbuf;
- in.len = 0;
- out.len = 0;
USE(c);
if (!MapsAreInited)
@@ -144,7 +128,7 @@ dobindkey(v, c)
if (key) {
if (!IsArrowKey(v[no]))
xprintf(CGETS(20, 1, "Invalid key name `%S'\n"), v[no]);
- in.buf = v[no++];
+ in.buf = Strsave(v[no++]);
in.len = Strlen(in.buf);
}
else {
@@ -157,21 +141,21 @@ dobindkey(v, c)
return;
}
}
+ cleanup_push(in.buf, xfree);
#ifndef WINNT_NATIVE
if (in.buf[0] > 0xFF) {
bad_spec(in.buf);
+ cleanup_until(in.buf);
return;
}
#endif
ch = (uChar) in.buf[0];
if (removeb) {
- if (key) {
+ if (key)
(void) ClearArrowKeys(&in);
- return;
- }
- if (in.len > 1) {
+ else if (in.len > 1) {
(void) DeleteXkey(&in);
}
else if (map[ch] == F_XKEY) {
@@ -181,6 +165,7 @@ dobindkey(v, c)
else {
map[ch] = F_UNASSIGNED;
}
+ cleanup_until(in.buf);
return;
}
if (!v[no]) {
@@ -188,28 +173,37 @@ dobindkey(v, c)
PrintArrowKeys(&in);
else
printkey(map, &in);
+ cleanup_until(in.buf);
return;
}
if (v[no + 1]) {
bindkey_usage();
+ cleanup_until(in.buf);
return;
}
switch (ntype) {
case XK_STR:
case XK_EXE:
- if (parsestring(v[no], &out) == NULL)
+ if (parsestring(v[no], &out) == NULL) {
+ cleanup_until(in.buf);
return;
+ }
+ cleanup_push(out.buf, xfree);
if (key) {
if (SetArrowKeys(&in, XmapStr(&out), ntype) == -1)
xprintf(CGETS(20, 2, "Bad key name: %S\n"), in.buf);
+ else
+ cleanup_ignore(out.buf);
}
else
AddXkey(&in, XmapStr(&out), ntype);
map[ch] = F_XKEY;
break;
case XK_CMD:
- if ((cmd = parsecmd(v[no])) == 0)
+ if ((cmd = parsecmd(v[no])) == 0) {
+ cleanup_until(in.buf);
return;
+ }
if (key)
(void) SetArrowKeys(&in, XmapCmd((int) cmd), ntype);
else {
@@ -227,33 +221,34 @@ dobindkey(v, c)
abort();
break;
}
+ cleanup_until(in.buf);
if (key)
BindArrowKeys();
}
static void
-printkey(map, in)
- KEYCMD *map;
- CStr *in;
+printkey(const KEYCMD *map, CStr *in)
{
- unsigned char outbuf[100];
struct KeyFuncs *fp;
if (in->len < 2) {
- (void) unparsestring(in, outbuf, STRQQ);
+ unsigned char *unparsed;
+
+ unparsed = unparsestring(in, STRQQ);
+ cleanup_push(unparsed, xfree);
for (fp = FuncNames; fp->name; fp++) {
if (fp->func == map[(uChar) *(in->buf)]) {
- xprintf("%s\t->\t%s\n", outbuf, fp->name);
+ xprintf("%s\t->\t%s\n", unparsed, fp->name);
}
}
+ cleanup_until(unparsed);
}
- else
+ else
PrintXkey(in);
}
static KEYCMD
-parsecmd(str)
- Char *str;
+parsecmd(Char *str)
{
struct KeyFuncs *fp;
@@ -268,35 +263,31 @@ parsecmd(str)
static void
-bad_spec(str)
- Char *str;
+bad_spec(const Char *str)
{
xprintf(CGETS(20, 4, "Bad key spec %S\n"), str);
}
static CStr *
-parsebind(s, str)
- Char *s;
- CStr *str;
+parsebind(const Char *s, CStr *str)
{
- Char *b = str->buf;
+ struct Strbuf b = Strbuf_INIT;
+ cleanup_push(&b, Strbuf_cleanup);
if (Iscntrl(*s)) {
- *b++ = *s;
- *b = '\0';
- str->len = (int) (b - str->buf);
- return str;
+ Strbuf_append1(&b, *s);
+ goto end;
}
switch (*s) {
case '^':
s++;
#ifdef IS_ASCII
- *b++ = (*s == '?') ? '\177' : ((*s & CHAR) & 0237);
+ Strbuf_append1(&b, (*s == '?') ? '\177' : ((*s & CHAR) & 0237));
#else
- *b++ = (*s == '?') ? CTL_ESC('\177') : _toebcdic[_toascii[*s & CHAR] & 0237];
+ Strbuf_append1(&b, (*s == '?') ? CTL_ESC('\177')
+ : _toebcdic[_toascii[*s & CHAR] & 0237]);
#endif
- *b = '\0';
break;
case 'F':
@@ -306,50 +297,44 @@ parsebind(s, str)
#ifdef WINNT_NATIVE
case 'N':
#endif /* WINNT_NATIVE */
- if (s[1] != '-' || s[2] == '\0') {
- bad_spec(s);
- return NULL;
- }
+ if (s[1] != '-' || s[2] == '\0')
+ goto bad_spec;
s += 2;
switch (s[-2]) {
case 'F': case 'f': /* Turn into ^[str */
- *b++ = CTL_ESC('\033');
- while ((*b++ = *s++) != '\0')
- continue;
- b--;
+ Strbuf_append1(&b, CTL_ESC('\033'));
+ Strbuf_append(&b, s);
break;
case 'C': case 'c': /* Turn into ^c */
#ifdef IS_ASCII
- *b++ = (*s == '?') ? '\177' : ((*s & CHAR) & 0237);
+ Strbuf_append1(&b, (*s == '?') ? '\177' : ((*s & CHAR) & 0237));
#else
- *b++ = (*s == '?') ? CTL_ESC('\177') : _toebcdic[_toascii[*s & CHAR] & 0237];
+ Strbuf_append1(&b, (*s == '?') ? CTL_ESC('\177')
+ : _toebcdic[_toascii[*s & CHAR] & 0237]);
#endif
- *b = '\0';
break;
case 'X' : case 'x': /* Turn into ^Xc */
#ifdef IS_ASCII
- *b++ = 'X' & 0237;
+ Strbuf_append1(&b, 'X' & 0237);
#else
- *b++ = _toebcdic[_toascii['X'] & 0237];
+ Strbuf_append1(&b, _toebcdic[_toascii['X'] & 0237]);
#endif
- *b++ = *s;
- *b = '\0';
+ Strbuf_append1(&b, *s);
break;
case 'M' : case 'm': /* Turn into 0x80|c */
if (!NoNLSRebind) {
- *b++ = CTL_ESC('\033');
- *b++ = *s;
+ Strbuf_append1(&b, CTL_ESC('\033'));
+ Strbuf_append1(&b, *s);
} else {
#ifdef IS_ASCII
- *b++ = *s | 0x80;
+ Strbuf_append1(&b, *s | 0x80);
#else
- *b++ = _toebcdic[_toascii[*s] | 0x80];
+ Strbuf_append1(&b, _toebcdic[_toascii[*s] | 0x80]);
#endif
}
- *b = '\0';
break;
#ifdef WINNT_NATIVE
case 'N' : case 'n': /* NT */
@@ -358,7 +343,7 @@ parsebind(s, str)
bnt = nt_translate_bindkey(s);
if (bnt != 0)
- *b++ = bnt;
+ Strbuf_append1(&b, bnt);
else
bad_spec(s);
}
@@ -367,53 +352,62 @@ parsebind(s, str)
default:
abort();
- /*NOTREACHED*/
- return NULL;
}
break;
default:
- bad_spec(s);
- return NULL;
+ goto bad_spec;
}
- str->len = (int) (b - str->buf);
+ end:
+ cleanup_ignore(&b);
+ cleanup_until(&b);
+ Strbuf_terminate(&b);
+ str->buf = xrealloc(b.s, (b.len + 1) * sizeof (*str->buf));
+ str->len = b.len;
return str;
+
+ bad_spec:
+ bad_spec(s);
+ cleanup_until(&b);
+ return NULL;
}
static CStr *
-parsestring(str, buf)
- Char *str;
- CStr *buf;
+parsestring(const Char *str, CStr *buf)
{
- Char *b;
+ struct Strbuf b = Strbuf_INIT;
const Char *p;
eChar es;
- b = buf->buf;
if (*str == 0) {
xprintf(CGETS(20, 5, "Null string specification\n"));
return NULL;
}
+ cleanup_push(&b, Strbuf_cleanup);
for (p = str; *p != 0; p++) {
if ((*p & CHAR) == '\\' || (*p & CHAR) == '^') {
- if ((es = parseescape(&p)) == CHAR_ERR)
+ if ((es = parseescape(&p)) == CHAR_ERR) {
+ cleanup_until(&b);
return 0;
- else
- *b++ = (Char) es;
+ } else
+ Strbuf_append1(&b, es);
}
else
- *b++ = *p & CHAR;
+ Strbuf_append1(&b, *p & CHAR);
}
- *b = 0;
- buf->len = (int) (b - buf->buf);
+ cleanup_ignore(&b);
+ cleanup_until(&b);
+ Strbuf_terminate(&b);
+ buf->buf = xrealloc(b.s, (b.len + 1) * sizeof (*buf->buf));
+ buf->len = b.len;
return buf;
}
static void
-print_all_keys()
+print_all_keys(void)
{
int prev, i;
CStr nilstr;
@@ -447,14 +441,12 @@ print_all_keys()
}
static void
-printkeys(map, first, last)
- KEYCMD *map;
- int first, last;
+printkeys(KEYCMD *map, int first, int last)
{
struct KeyFuncs *fp;
Char firstbuf[2], lastbuf[2];
CStr fb, lb;
- unsigned char unparsbuf[10], extrabuf[10];
+ unsigned char *unparsed;
fb.buf = firstbuf;
lb.buf = lastbuf;
@@ -465,41 +457,40 @@ printkeys(map, first, last)
fb.len = 1;
lb.len = 1;
+ unparsed = unparsestring(&fb, STRQQ);
+ cleanup_push(unparsed, xfree);
if (map[first] == F_UNASSIGNED) {
if (first == last)
- xprintf(CGETS(20, 10, "%-15s-> is undefined\n"),
- unparsestring(&fb, unparsbuf, STRQQ));
+ xprintf(CGETS(20, 10, "%-15s-> is undefined\n"), unparsed);
+ cleanup_until(unparsed);
return;
}
for (fp = FuncNames; fp->name; fp++) {
if (fp->func == map[first]) {
- if (first == last) {
- xprintf("%-15s-> %s\n",
- unparsestring(&fb, unparsbuf, STRQQ), fp->name);
- }
+ if (first == last)
+ xprintf("%-15s-> %s\n", unparsed, fp->name);
else {
- xprintf("%-4s to %-7s-> %s\n",
- unparsestring(&fb, unparsbuf, STRQQ),
- unparsestring(&lb, extrabuf, STRQQ), fp->name);
+ unsigned char *p;
+
+ p = unparsestring(&lb, STRQQ);
+ cleanup_push(p, xfree);
+ xprintf("%-4s to %-7s-> %s\n", unparsed, p, fp->name);
}
+ cleanup_until(unparsed);
return;
}
}
- if (map == CcKeyMap) {
- xprintf(CGETS(20, 11, "BUG!!! %s isn't bound to anything.\n"),
- unparsestring(&fb, unparsbuf, STRQQ));
+ xprintf(CGETS(20, 11, "BUG!!! %s isn't bound to anything.\n"), unparsed);
+ if (map == CcKeyMap)
xprintf("CcKeyMap[%d] == %d\n", first, CcKeyMap[first]);
- }
- else {
- xprintf(CGETS(20, 11, "BUG!!! %s isn't bound to anything.\n"),
- unparsestring(&fb, unparsbuf, STRQQ));
+ else
xprintf("CcAltMap[%d] == %d\n", first, CcAltMap[first]);
- }
+ cleanup_until(unparsed);
}
static void
-bindkey_usage()
+bindkey_usage(void)
{
xprintf(CGETS(20, 12,
"Usage: bindkey [options] [--] [KEY [COMMAND]]\n"));
@@ -535,7 +526,7 @@ bindkey_usage()
}
static void
-list_functions()
+list_functions(void)
{
struct KeyFuncs *fp;
@@ -543,533 +534,3 @@ list_functions()
xprintf("%s\n %s\n", fp->name, fp->desc);
}
}
-
-#ifdef OBSOLETE
-
-/*
- * Unfortunately the apollo optimizer does not like & operations
- * with 0377, and produces illegal instructions. So we make it
- * an unsigned char, and hope for the best.
- * Of-course the compiler is smart enough to produce bad assembly
- * language instructions, but dumb when it comes to fold the constant :-)
- */
-#ifdef apollo
-static unsigned char APOLLO_0377 = 0377;
-#else /* sane */
-# define APOLLO_0377 0377
-#endif /* apollo */
-
-static int
-tocontrol(c)
- int c;
-{
- c &= CHAR;
- if (Islower(c))
- c = Toupper(c);
- else if (c == ' ')
- c = '@';
- if (c == '?')
- c = CTL_ESC('\177');
- else
-#ifdef IS_ASCII
- c &= 037;
-#else
- /* EBCDIC: simulate ASCII-behavior by transforming to ASCII and back */
- c = _toebcdic[_toascii[c] & 037];
-#endif
- return (c);
-}
-
-static char *
-unparsekey(c) /* 'c' -> "c", '^C' -> "^" + "C" */
- int c;
-{
- char *cp;
- static char tmp[10];
-
- cp = tmp;
-
- if (c & 0400) {
- *cp++ = 'A';
- *cp++ = '-';
- c &= APOLLO_0377;
- }
- if ((c & META) && !(Isprint(c) || (Iscntrl(c) && Isprint(c | 0100)))) {
- *cp++ = 'M';
- *cp++ = '-';
- c &= ASCII;
- }
- if (Isprint(c)) {
- *cp++ = (char) c;
- *cp = '\0';
- return (tmp);
- }
- switch (c) {
- case ' ':
- (void) strcpy(cp, "Spc");
- return (tmp);
- case '\n':
- (void) strcpy(cp, "Lfd");
- return (tmp);
- case '\r':
- (void) strcpy(cp, "Ret");
- return (tmp);
- case '\t':
- (void) strcpy(cp, "Tab");
- return (tmp);
-#ifdef IS_ASCII
- case '\033':
- (void) strcpy(cp, "Esc");
- return (tmp);
- case '\177':
- (void) strcpy(cp, "Del");
- return (tmp);
- default:
- *cp++ = '^';
- if (c == '\177') {
- *cp++ = '?';
- }
- else {
- *cp++ = c | 0100;
- }
- *cp = '\0';
- return (tmp);
-#else /* IS_ASCII */
- default:
- if (*cp == CTL_ESC('\033')) {
- (void) strcpy(cp, "Esc");
- return (tmp);
- }
- else if (*cp == CTL_ESC('\177')) {
- (void) strcpy(cp, "Del");
- return (tmp);
- }
- else if (Isupper(_toebcdic[_toascii[c]|0100])
- || strchr("@[\\]^_", _toebcdic[_toascii[c]|0100]) != NULL) {
- *cp++ = '^';
- *cp++ = _toebcdic[_toascii[c]|0100]
- }
- else {
- xsnprintf(cp, 3, "\\%3.3o", c);
- cp += 4;
- }
-#endif /* IS_ASCII */
- }
-}
-
-static KEYCMD
-getkeycmd(sp)
- Char **sp;
-{
- Char *s = *sp;
- char c;
- KEYCMD keycmd = F_UNASSIGNED;
- KEYCMD *map;
- int meta = 0;
- Char *ret_sp = s;
-
- map = CcKeyMap;
-
- while (*s) {
- if (*s == '^' && s[1]) {
- s++;
- c = tocontrol(*s++);
- }
- else
- c = *s++;
-
- if (*s == '\0')
- break;
-
- switch (map[c | meta]) {
- case F_METANEXT:
- meta = META;
- keycmd = F_METANEXT;
- ret_sp = s;
- break;
-
- case F_XKEY:
- keycmd = F_XKEY;
- ret_sp = s;
- /* FALLTHROUGH */
-
- default:
- *sp = ret_sp;
- return (keycmd);
-
- }
- }
- *sp = ret_sp;
- return (keycmd);
-}
-
-static int
-parsekey(sp)
- Char **sp; /* Return position of first unparsed character
- * for return value -2 (xkeynext) */
-{
- int c, meta = 0, control = 0, ctrlx = 0;
- Char *s = *sp;
- KEYCMD keycmd;
-
- if (s == NULL) {
- xprintf(CGETS(20, 27, "bad key specification -- null string\n"));
- return -1;
- }
- if (*s == 0) {
- xprintf(CGETS(20, 28, "bad key specification -- empty string\n"));
- return -1;
- }
-
- (void) strip(s); /* trim to 7 bits. */
-
- if (s[1] == 0) /* single char */
- return (s[0] & APOLLO_0377);
-
- if ((s[0] == 'F' || s[0] == 'f') && s[1] == '-') {
- if (s[2] == 0) {
- xprintf(CGETS(20, 29,
- "Bad function-key specification. Null key not allowed\n"));
- return (-1);
- }
- *sp = s + 2;
- return (-2);
- }
-
- if (s[0] == '0' && s[1] == 'x') { /* if 0xn, then assume number */
- c = 0;
- for (s += 2; *s; s++) { /* convert to hex; skip the first 0 */
- c *= 16;
- if (!Isxdigit(*s)) {
- xprintf(CGETS(20, 30,
- "bad key specification -- malformed hex number\n"));
- return -1; /* error */
- }
- if (Isdigit(*s))
- c += *s - '0';
- else if (*s >= 'a' && *s <= 'f')
- c += *s - 'a' + 0xA;
- else if (*s >= 'F' && *s <= 'F')
- c += *s - 'A' + 0xA;
- }
- }
- else if (s[0] == '0' && Isdigit(s[1])) { /* if 0n, then assume number */
- c = 0;
- for (s++; *s; s++) { /* convert to octal; skip the first 0 */
- if (!Isdigit(*s) || *s == '8' || *s == '9') {
- xprintf(CGETS(20, 31,
- "bad key specification -- malformed octal number\n"));
- return -1; /* error */
- }
- c = (c * 8) + *s - '0';
- }
- }
- else if (Isdigit(s[0]) && Isdigit(s[1])) { /* decimal number */
- c = 0;
- for (; *s; s++) { /* convert to octal; skip the first 0 */
- if (!Isdigit(*s)) {
- xprintf(CGETS(20, 32,
- "bad key specification -- malformed decimal number\n"));
- return -1; /* error */
- }
- c = (c * 10) + *s - '0';
- }
- }
- else {
- keycmd = getkeycmd(&s);
-
- if ((s[0] == 'X' || s[0] == 'x') && s[1] == '-') { /* X- */
- ctrlx++;
- s += 2;
- keycmd = getkeycmd(&s);
- }
- if ((*s == 'm' || *s == 'M') && s[1] == '-') { /* meta */
- meta++;
- s += 2;
- keycmd = getkeycmd(&s);
- }
- else if (keycmd == F_METANEXT && *s) { /* meta */
- meta++;
- keycmd = getkeycmd(&s);
- }
- if (*s == '^' && s[1]) {
- control++;
- s++;
- keycmd = getkeycmd(&s);
- }
- else if ((*s == 'c' || *s == 'C') && s[1] == '-') { /* control */
- control++;
- s += 2;
- keycmd = getkeycmd(&s);
- }
-
- if (keycmd == F_XKEY) {
- if (*s == 0) {
- xprintf(CGETS(20, 33,
- "Bad function-key specification.\n"));
- xprintf(CGETS(20, 34, "Null key not allowed\n"));
- return (-1);
- }
- *sp = s;
- return (-2);
- }
-
- if (s[1] != 0) { /* if symbolic name */
- char *ts;
-
- ts = short2str(s);
- if (!strcmp(ts, "space") || !strcmp(ts, "Spc"))
- c = ' ';
- else if (!strcmp(ts, "return") || !strcmp(ts, "Ret"))
- c = '\r';
- else if (!strcmp(ts, "newline") || !strcmp(ts, "Lfd"))
- c = '\n';
- else if (!strcmp(ts, "linefeed"))
- c = '\n';
- else if (!strcmp(ts, "tab"))
- c = '\t';
- else if (!strcmp(ts, "escape") || !strcmp(ts, "Esc"))
- c = CTL_ESC('\033');
- else if (!strcmp(ts, "backspace"))
- c = '\b';
- else if (!strcmp(ts, "delete"))
- c = CTL_ESC('\177');
- else {
- xprintf(CGETS(20, 35,
- "bad key specification -- unknown name \"%S\"\n"), s);
- return -1; /* error */
- }
- }
- else
- c = *s; /* just a single char */
-
- if (control)
- c = tocontrol(c);
- if (meta)
- c |= META;
- if (ctrlx)
- c |= 0400;
- }
- return (c & 0777);
-}
-
-
-/*ARGSUSED*/
-void
-dobind(v, dummy)
- Char **v;
- struct command *dummy;
-{
- int c;
- struct KeyFuncs *fp;
- int i, prev;
- Char *p, *l;
- CStr cstr;
- Char buf[1000];
-
- USE(dummy);
- /*
- * Assume at this point that i'm given 2 or 3 args - 'bind', the f-name,
- * and the key; or 'bind' key to print the func for that key.
- */
-
- if (!MapsAreInited)
- ed_InitMaps();
-
- if (v[1] && v[2] && v[3]) {
- xprintf(CGETS(20, 36,
- "usage: bind [KEY | COMMAND KEY | \"emacs\" | \"vi\" | \"-a\"]\n"));
- return;
- }
-
- if (v[1] && v[2]) { /* if bind FUNCTION KEY */
- for (fp = FuncNames; fp->name; fp++) {
- if (strcmp(short2str(v[1]), fp->name) == 0) {
- Char *s = v[2];
-
- if ((c = parsekey(&s)) == -1)
- return;
- if (c == -2) { /* extended key */
- for (i = 0; i < 256; i++) {
- if (i != CTL_ESC('\033') && (CcKeyMap[i] == F_XKEY ||
- CcAltMap[i] == F_XKEY)) {
- p = buf;
-#ifdef IS_ASCII
- if (i > 0177) {
- *p++ = 033;
- *p++ = i & ASCII;
- }
- else {
- *p++ = (Char) i;
- }
-#else
- *p++ = (Char) i;
-#endif
- for (l = s; *l != 0; l++) {
- *p++ = *l;
- }
- *p = 0;
- cstr.buf = buf;
- cstr.len = Strlen(buf);
- AddXkey(&cstr, XmapCmd(fp->func), XK_CMD);
- }
- }
- return;
- }
- if (c & 0400) {
- if (VImode) {
- CcAltMap[c & APOLLO_0377] = fp->func;
- /* bind the vi cmd mode key */
- if (c & META) {
- buf[0] = CTL_ESC('\033');
- buf[1] = c & ASCII;
- buf[2] = 0;
- cstr.buf = buf;
- cstr.len = Strlen(buf);
- AddXkey(&cstr, XmapCmd(fp->func), XK_CMD);
- }
- }
- else {
- buf[0] = CTL_ESC('\030'); /* ^X */
- buf[1] = c & APOLLO_0377;
- buf[2] = 0;
- cstr.buf = buf;
- cstr.len = Strlen(buf);
- AddXkey(&cstr, XmapCmd(fp->func), XK_CMD);
- CcKeyMap[CTL_ESC('\030')] = F_XKEY;
- }
- }
- else {
- CcKeyMap[c] = fp->func; /* bind the key */
- if (c & META) {
- buf[0] = CTL_ESC('\033');
- buf[1] = c & ASCII;
- buf[2] = 0;
- cstr.buf = buf;
- cstr.len = Strlen(buf);
- AddXkey(&cstr, XmapCmd(fp->func), XK_CMD);
- }
- }
- return;
- }
- }
- stderror(ERR_NAME | ERR_STRING, CGETS(20, 37, "Invalid function"));
- }
- else if (v[1]) {
- char *cv = short2str(v[1]);
-
- if (strcmp(cv, "list") == 0) {
- for (fp = FuncNames; fp->name; fp++) {
- xprintf("%s\n", fp->name);
- }
- return;
- }
- if ((strcmp(cv, "emacs") == 0) ||
-#ifndef VIDEFAULT
- (strcmp(cv, "defaults") == 0) ||
- (strcmp(cv, "default") == 0) ||
-#endif
- (strcmp(cv, "mg") == 0) ||
- (strcmp(cv, "gnumacs") == 0)) {
- /* reset keys to default */
- ed_InitEmacsMaps();
-#ifdef VIDEFAULT
- }
- else if ((strcmp(cv, "vi") == 0)
- || (strcmp(cv, "default") == 0)
- || (strcmp(cv, "defaults") == 0)) {
-#else
- }
- else if (strcmp(cv, "vi") == 0) {
-#endif
- ed_InitVIMaps();
- }
- else { /* want to know what this key does */
- Char *s = v[1];
-
- if ((c = parsekey(&s)) == -1)
- return;
- if (c == -2) { /* extended key */
- cstr.buf = s;
- cstr.len = Strlen(s);
- PrintXkey(&cstr);
- return;
- }
- pkeys(c, c); /* must be regular key */
- }
- }
- else { /* list all the bindings */
- prev = 0;
- for (i = 0; i < 256; i++) {
- if (CcKeyMap[prev] == CcKeyMap[i])
- continue;
- pkeys(prev, i - 1);
- prev = i;
- }
- pkeys(prev, i - 1);
- prev = 0;
- for (i = 256; i < 512; i++) {
- if (CcAltMap[prev & APOLLO_0377] == CcAltMap[i & APOLLO_0377])
- continue;
- pkeys(prev, i - 1);
- prev = i;
- }
- pkeys(prev, i - 1);
- cstr.buf = NULL;
- cstr.len = 0;
- PrintXkey(&cstr); /* print all Xkey bindings */
- }
- return;
-}
-
-static void
-pkeys(first, last)
- int first, last;
-{
- struct KeyFuncs *fp;
- KEYCMD *map;
- int mask;
- char buf[8];
-
- if (last & 0400) {
- map = CcAltMap;
- first &= APOLLO_0377;
- last &= APOLLO_0377;
- mask = 0400;
- }
- else {
- map = CcKeyMap;
- mask = 0;
- }
- if (map[first] == F_UNASSIGNED) {
- if (first == last)
- xprintf(CGETS(20, 38, " %s\t\tis undefined\n"),
- unparsekey(first | mask));
- return;
- }
-
- for (fp = FuncNames; fp->name; fp++) {
- if (fp->func == map[first]) {
- if (first == last)
- xprintf(" %s\t\t%s\n",
- unparsekey((first & APOLLO_0377) | mask), fp->name);
- else {
- (void) strcpy(buf, unparsekey((first & APOLLO_0377) | mask));
- xprintf(" %s..%s\t\t%s\n", buf,
- unparsekey((last & APOLLO_0377) | mask), fp->name);
- }
- return;
- }
- }
- if (map == CcKeyMap) {
- xprintf(CGETS(20, 11, "BUG!!! %s isn't bound to anything.\n"),
- unparsekey(first));
- xprintf("CcKeyMap[%d] == %d\n", first, CcKeyMap[first]);
- }
- else {
- xprintf(CGETS(20, 11, "BUG!!! %s isn't bound to anything.\n"),
- unparsekey(first & 0400));
- xprintf("CcAltMap[%d] == %d\n", first, CcAltMap[first]);
- }
-}
-#endif /* OBSOLETE */
diff --git a/contrib/tcsh/tc.const.c b/contrib/tcsh/tc.const.c
index 625bacd..e7c92f4 100644
--- a/contrib/tcsh/tc.const.c
+++ b/contrib/tcsh/tc.const.c
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/tc.const.c,v 3.81 2004/12/25 21:15:08 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/tc.const.c,v 3.84 2006/10/29 19:02:17 christos Exp $ */
/*
* sh.const.c: String constants for tcsh.
*/
@@ -32,7 +32,7 @@
*/
#include "sh.h"
-RCSID("$Id: tc.const.c,v 3.81 2004/12/25 21:15:08 christos Exp $")
+RCSID("$tcsh: tc.const.c,v 3.84 2006/10/29 19:02:17 christos Exp $")
Char STRlogout[] = { 'l', 'o', 'g', 'o', 'u', 't', '\0' };
Char STRautologout[] = { 'a', 'u', 't', 'o', 'l', 'o', 'g', 'o', 'u', 't',
@@ -395,6 +395,7 @@ Char STRnotunique[] = { 'n', 'o', 't', 'u', 'n', 'i', 'q', 'u', 'e', '\0' };
Char STRret[] = { '\n', '\0' };
Char STRnobeep[] = { 'n', 'o', 'b', 'e', 'e', 'p', '\0' };
Char STRnoding[] = { 'n', 'o', 'd', 'i', 'n', 'g', '\0' };
+Char STRpadhour[] = { 'p', 'a', 'd', 'h', 'o', 'u', 'r', '\0' };
Char STRnoambiguous[] = { 'n', 'o', 'a', 'm', 'b', 'i', 'g', 'u', 'o', 'u',
's', '\0' };
Char STRvisiblebell[] = { 'v', 'i', 's', 'i', 'b', 'l', 'e', 'b', 'e', 'l',
@@ -419,6 +420,7 @@ Char STRwho[] = { 'w', 'h', 'o', '\0' };
Char STRsched[] = { 's', 'c', 'h', 'e', 'd', '\0' };
Char STRrmstar[] = { 'r', 'm', 's', 't', 'a', 'r', '\0' };
Char STRrm[] = { 'r', 'm', '\0' };
+Char STRhighlight[] = { 'h', 'i', 'g', 'h', 'l', 'i', 'g', 'h', 't', '\0' };
Char STRimplicitcd[] = { 'i', 'm', 'p', 'l', 'i', 'c', 'i', 't',
'c', 'd', '\0' };
@@ -447,6 +449,10 @@ Char STRCOLUMNS[] = { 'C', 'O', 'L', 'U', 'M', 'N', 'S', '\0'};
Char STRTERMCAP[] = { 'T', 'E', 'R', 'M', 'C', 'A', 'P', '\0'};
#endif /* SIG_WINDOW || _VMS_POSIX */
+#if defined (_OSD_POSIX) /* BS2000 needs this variable set to "SHELL" */
+Char STRPROGRAM_ENVIRONMENT[] = { 'P', 'R', 'O', 'G', 'R', 'A', 'M', '_', 'E', 'N', 'V', 'I', 'R', 'O', 'N', 'M', 'E', 'N', 'T', '\0'};
+#endif /* _OSD_POSIX */
+
#ifdef WARP
Char STRwarp[] = { 'w', 'a', 'r', 'p', '\0' };
#endif /* WARP */
diff --git a/contrib/tcsh/tc.decls.h b/contrib/tcsh/tc.decls.h
index 6bac4b4..1da345d 100644
--- a/contrib/tcsh/tc.decls.h
+++ b/contrib/tcsh/tc.decls.h
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/tc.decls.h,v 3.57 2005/01/18 20:24:51 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/tc.decls.h,v 3.63 2006/02/14 14:07:36 christos Exp $ */
/*
* tc.decls.h: Function declarations from all the tcsh modules
*/
@@ -33,84 +33,86 @@
#ifndef _h_tc_decls
#define _h_tc_decls
+struct blk_buf;
+struct strbuf;
+struct Strbuf;
+
/*
* tc.alloc.c
*/
#ifndef SYSMALLOC
#ifndef WINNT_NATIVE
-extern void free __P((ptr_t));
-extern memalign_t malloc __P((size_t));
-extern memalign_t realloc __P((ptr_t, size_t));
-extern memalign_t calloc __P((size_t, size_t));
+#ifndef __linux__
+extern void free (ptr_t);
+extern memalign_t malloc (size_t);
+extern memalign_t realloc (ptr_t, size_t);
+extern memalign_t calloc (size_t, size_t);
+#endif
#endif /* !WINNT_NATIVE */
#else /* SYSMALLOC */
-extern void sfree __P((ptr_t));
-extern memalign_t smalloc __P((size_t));
-extern memalign_t srealloc __P((ptr_t, size_t));
-extern memalign_t scalloc __P((size_t, size_t));
+extern void sfree (ptr_t);
+extern memalign_t smalloc (size_t);
+extern memalign_t srealloc (ptr_t, size_t);
+extern memalign_t scalloc (size_t, size_t);
#endif /* SYSMALLOC */
-extern void showall __P((Char **, struct command *));
+extern void showall (Char **, struct command *);
/*
* tc.bind.c
*/
-extern void dobindkey __P((Char **, struct command *));
-#ifdef OBSOLETE
-extern void dobind __P((Char **, struct command *));
-#endif /* OBSOLETE */
+extern void dobindkey (Char **, struct command *);
/*
* tc.defs.c:
*/
-extern void getmachine __P((void));
+extern void getmachine (void);
/*
* tc.disc.c
*/
-extern int setdisc __P((int));
-extern int resetdisc __P((int));
+extern int setdisc (int);
+extern int resetdisc (int);
/*
* tc.func.c
*/
-extern Char *expand_lex __P((Char *, size_t, struct wordent *,
- int, int));
-extern Char *sprlex __P((Char *, size_t, struct wordent *));
-extern Char *Itoa __P((int, Char *, int, int));
-extern void dolist __P((Char **, struct command *));
-extern void dotermname __P((Char **, struct command *));
-extern void dotelltc __P((Char **, struct command *));
-extern void doechotc __P((Char **, struct command *));
-extern void dosettc __P((Char **, struct command *));
-extern int cmd_expand __P((Char *, Char *));
-extern void dowhich __P((Char **, struct command *));
-extern struct process *find_stop_ed __P((void));
-extern void fg_proc_entry __P((struct process *));
-extern RETSIGTYPE alrmcatch __P((int));
-extern void precmd __P((void));
-extern void postcmd __P((void));
-extern void cwd_cmd __P((void));
-extern void beep_cmd __P((void));
-extern void period_cmd __P((void));
-extern void job_cmd __P((Char *));
-extern void aliasrun __P((int, Char *, Char *));
-extern void setalarm __P((int));
-extern void rmstar __P((struct wordent *));
-extern void continue_jobs __P((struct wordent *));
-extern Char *gettilde __P((Char *));
-extern Char *getusername __P((Char **));
+extern Char *expand_lex (const struct wordent *, int, int);
+extern Char *sprlex (const struct wordent *);
+extern Char *Itoa (int, size_t, Char);
+extern void dolist (Char **, struct command *);
+extern void dotermname (Char **, struct command *);
+extern void dotelltc (Char **, struct command *);
+extern void doechotc (Char **, struct command *);
+extern void dosettc (Char **, struct command *);
+extern int cmd_expand (Char *, Char **);
+extern void dowhich (Char **, struct command *);
+extern struct process *find_stop_ed (void);
+extern void fg_proc_entry (struct process *);
+extern void alrmcatch (void);
+extern void precmd (void);
+extern void postcmd (void);
+extern void cwd_cmd (void);
+extern void beep_cmd (void);
+extern void period_cmd (void);
+extern void job_cmd (Char *);
+extern void aliasrun (int, Char *, Char *);
+extern void setalarm (int);
+extern void rmstar (struct wordent *);
+extern void continue_jobs (struct wordent *);
+extern Char *gettilde (const Char *);
+extern Char *getusername (Char **);
#ifdef OBSOLETE
-extern void doaliases __P((Char **, struct command *));
+extern void doaliases (Char **, struct command *);
#endif /* OBSOLETE */
-extern void shlvl __P((int));
-extern int fixio __P((int, int));
-extern int collate __P((const Char *, const Char *));
+extern void shlvl (int);
+extern int fixio (int, int);
+extern int collate (const Char *, const Char *);
#ifdef HASHBANG
-extern int hashbang __P((int, Char ***));
+extern int hashbang (int, Char ***);
#endif /* HASHBANG */
#ifdef REMOTEHOST
-extern void remotehost __P((void));
+extern void remotehost (void);
#endif /* REMOTEHOST */
@@ -118,48 +120,48 @@ extern void remotehost __P((void));
* tc.os.c
*/
#ifdef MACH
-extern void dosetpath __P((Char **, struct command *));
+extern void dosetpath (Char **, struct command *);
#endif /* MACH */
#ifdef TCF
-extern void dogetxvers __P((Char **, struct command *));
-extern void dosetxvers __P((Char **, struct command *));
-extern void dogetspath __P((Char **, struct command *));
-extern void dosetspath __P((Char **, struct command *));
-extern char *sitename __P((pid_t));
-extern void domigrate __P((Char **, struct command *));
+extern void dogetxvers (Char **, struct command *);
+extern void dosetxvers (Char **, struct command *);
+extern void dogetspath (Char **, struct command *);
+extern void dosetspath (Char **, struct command *);
+extern char *sitename (pid_t);
+extern void domigrate (Char **, struct command *);
#endif /* TCF */
#ifdef WARP
-extern void dowarp __P((Char **, struct command *));
+extern void dowarp (Char **, struct command *);
#endif /* WARP */
#if defined(_CRAY) && !defined(_CRAYMPP)
-extern void dodmmode __P((Char **, struct command *));
+extern void dodmmode (Char **, struct command *);
#endif /* _CRAY && !_CRAYMPP */
#if defined(masscomp) || defined(hcx)
-extern void douniverse __P((Char **, struct command *));
+extern void douniverse (Char **, struct command *);
#endif /* masscomp */
#if defined(_OSD_POSIX) /* BS2000 */
-extern void dobs2cmd __P((Char **, struct command *));
+extern void dobs2cmd (Char **, struct command *);
#endif /* _OSD_POSIX */
#if defined(hcx)
-extern void doatt __P((Char **, struct command *));
-extern void doucb __P((Char **, struct command *));
+extern void doatt (Char **, struct command *);
+extern void doucb (Char **, struct command *);
#endif /* hcx */
#ifdef _SEQUENT_
-extern void pr_stat_sub __P((struct process_stats *,
- struct process_stats *,
- struct process_stats *));
+extern void pr_stat_sub (struct process_stats *,
+ struct process_stats *,
+ struct process_stats *);
#endif /* _SEQUENT_ */
#ifdef NEEDtcgetpgrp
-extern int xtcgetpgrp __P((int));
-extern int xtcsetpgrp __P((int, int));
+extern pid_t xtcgetpgrp (int);
+extern int xtcsetpgrp (int, int);
# undef tcgetpgrp
# define tcgetpgrp(a) xtcgetpgrp(a)
# undef tcsetpgrp
@@ -167,181 +169,168 @@ extern int xtcsetpgrp __P((int, int));
#endif /* NEEDtcgetpgrp */
#ifdef YPBUGS
-extern void fix_yp_bugs __P((void));
+extern void fix_yp_bugs (void);
#endif /* YPBUGS */
#ifdef STRCOLLBUG
-extern void fix_strcoll_bug __P((void));
+extern void fix_strcoll_bug (void);
#endif /* STRCOLLBUG */
-extern void osinit __P((void));
+extern void osinit (void);
#ifndef HAVE_MEMMOVE
-extern ptr_t xmemmove __P((ptr_t, const ptr_t, size_t));
+extern void *xmemmove (void *, const void *, size_t);
# define memmove(a, b, c) xmemmove(a, b, c)
#endif /* !HAVE_MEMMOVE */
#ifndef HAVE_MEMSET
-extern ptr_t xmemset __P((ptr_t, int, size_t));
+extern void *xmemset (void *, int, size_t);
# define memset(a, b, c) xmemset(a, b, c)
#endif /* !HAVE_MEMSET */
#ifndef HAVE_GETCWD
-extern char *xgetcwd __P((char *, size_t));
+extern char *xgetcwd (char *, size_t);
# undef getcwd
# define getcwd(a, b) xgetcwd(a, b)
#endif /* !HAVE_GETCWD */
#ifndef HAVE_GETHOSTNAME
-extern int xgethostname __P((char *, int));
+extern int xgethostname (char *, int);
# undef gethostname
# define gethostname(a, b) xgethostname(a, b)
#endif /* !HAVE_GETHOSTNAME */
#ifndef HAVE_NICE
-extern int xnice __P((int));
+extern int xnice (int);
# undef nice
# define nice(a) xnice(a)
#endif /* !HAVE_NICE */
#ifndef HAVE_STRERROR
-extern char *xstrerror __P((int));
+extern char *xstrerror (int);
# undef strerror
# define strerror(a) xstrerror(a)
#endif /* !HAVE_STRERROR */
#ifdef apollo
-extern void doinlib __P((Char **, struct command *));
-extern void dover __P((Char **, struct command *));
-extern void dorootnode __P((Char **, struct command *));
-extern int getv __P((Char *));
+extern void doinlib (Char **, struct command *);
+extern void dover (Char **, struct command *);
+extern void dorootnode (Char **, struct command *);
+extern int getv (Char *);
#endif /* apollo */
/*
* tc.printf.h
*/
-extern pret_t xprintf __P((const char *, ...));
-extern pret_t xsnprintf __P((char *, size_t, const char *, ...));
-extern pret_t xvprintf __P((const char *, va_list));
-extern pret_t xvsnprintf __P((char *, size_t, const char *,
- va_list));
+#ifndef __GNUC__
+#define __attribute__(a)
+#endif
+extern pret_t xprintf (const char *, ...)
+ __attribute__((__format__(__printf__, 1, 2)));
+extern pret_t xsnprintf (char *, size_t, const char *, ...)
+ __attribute__((__format__(__printf__, 3, 4)));
+extern char *xasprintf (const char *, ...)
+ __attribute__((__format__(__printf__, 1, 2)));
+extern pret_t xvprintf (const char *, va_list)
+ __attribute__((__format__(__printf__, 1, 0)));
+extern pret_t xvsnprintf (char *, size_t, const char *, va_list)
+ __attribute__((__format__(__printf__, 3, 0)));
+extern char *xvasprintf (const char *, va_list)
+ __attribute__((__format__(__printf__, 1, 0)));
/*
* tc.prompt.c
*/
-extern void dateinit __P((void));
-extern void printprompt __P((int, const char *));
-extern Char *expdollar __P((Char **, const Char **, size_t *,
- int));
-extern void tprintf __P((int, Char *, const Char *, size_t,
- const char *, time_t, ptr_t));
+extern void dateinit (void);
+extern void printprompt (int, const char *);
+extern int expdollar (struct Strbuf *, const Char **, Char);
+extern Char *tprintf (int, const Char *, const char *,
+ time_t, ptr_t);
/*
* tc.sched.c
*/
-extern time_t sched_next __P((void));
-extern void dosched __P((Char **, struct command *));
-extern void sched_run __P((int));
-
-/*
- * tc.sig.c
- */
-#ifndef BSDSIGS
-# ifdef UNRELSIGS
-# ifdef COHERENT
-extern RETSIGTYPE (*xsignal __P((int, RETSIGTYPE (*)(int)))) ();
-# define signal(x,y) xsignal(x,y)
-# endif /* COHERENT */
-extern RETSIGTYPE (*xsigset __P((int, RETSIGTYPE (*)(int)))) ();
-# define sigset(x,y) xsigset(x,y)
-extern void xsigrelse __P((int));
-# define sigrelse(x) xsigrelse(x)
-extern void xsighold __P((int));
-# define sighold(x) xsighold(x)
-extern void xsigignore __P((int));
-# define sigignore(x) xsigignore(x)
-extern void xsigpause __P((int));
-# define sigpause(x) xsigpause(x)
-extern pid_t ourwait __P((int *));
-# endif /* UNRELSIGS */
-# ifdef SXA
-extern void sigpause __P((int));
-# endif /* SXA */
-#endif /* !BSDSIGS */
-
-#ifdef NEEDsignal
-extern RETSIGTYPE (*xsignal __P((int, RETSIGTYPE (*)(int)))) ();
-# define signal(a, b) xsignal(a, b)
-#endif /* NEEDsignal */
-#if defined(_SEQUENT_) || ((SYSVREL > 3 || defined(_DGUX_SOURCE)) && defined(POSIXSIGS)) || ((defined(_AIX) || defined(__CYGWIN__)) && defined(POSIXSIGS)) || defined(WINNT_NATIVE)
-extern sigmask_t sigsetmask __P((sigmask_t));
-# if !defined(DGUX) || (defined(DGUX) && defined(__ix86))
-extern sigmask_t sigblock __P((sigmask_t));
-# endif /* !DGUX */
-extern void bsd_sigpause __P((sigmask_t));
-extern RETSIGTYPE (*bsd_signal __P((int, RETSIGTYPE (*)(int)))) __P((int));
-#endif /* _SEQUENT_ */
-#ifdef SIGSYNCH
-extern RETSIGTYPE synch_handler __P((int));
-#endif /* SIGSYNCH */
-
+extern time_t sched_next (void);
+extern void dosched (Char **, struct command *);
+extern void sched_run (void);
/*
* tc.str.c:
*/
#ifdef WIDE_STRINGS
-extern size_t one_mbtowc __P((wchar_t *, const char *, size_t));
-extern size_t one_wctomb __P((char *, wchar_t));
+extern size_t one_mbtowc (wchar_t *, const char *, size_t);
+extern size_t one_wctomb (char *, wchar_t);
+extern int rt_mbtowc (wchar_t *, const char *, size_t);
#else
#define one_mbtowc(PWC, S, N) \
((void)(N), *(PWC) = (unsigned char)*(S), (size_t)1)
#define one_wctomb(S, WCHAR) (*(S) = (WCHAR), (size_t)1)
#endif
#ifdef SHORT_STRINGS
-extern int rt_mbtowc __P((wchar_t *, const char *, size_t));
-extern Char *s_strchr __P((const Char *, int));
-extern Char *s_strrchr __P((const Char *, int));
-extern Char *s_strcat __P((Char *, const Char *));
+extern Char *s_strchr (const Char *, int);
+extern Char *s_strrchr (const Char *, int);
+extern Char *s_strcat (Char *, const Char *);
# ifdef NOTUSED
-extern Char *s_strncat __P((Char *, const Char *, size_t));
+extern Char *s_strncat (Char *, const Char *, size_t);
# endif /* NOTUSED */
-extern Char *s_strcpy __P((Char *, const Char *));
-extern Char *s_strncpy __P((Char *, const Char *, size_t));
-extern Char *s_strspl __P((const Char *, const Char *));
-extern size_t s_strlen __P((const Char *));
-extern int s_strcmp __P((const Char *, const Char *));
-extern int s_strncmp __P((const Char *, const Char *,
- size_t));
-extern int s_strcasecmp __P((const Char *, const Char *));
-extern Char *s_strsave __P((const Char *));
-extern Char *s_strend __P((const Char *));
-extern Char *s_strstr __P((const Char *, const Char *));
-extern Char *str2short __P((const char *));
-extern Char **blk2short __P((char **));
-extern char *short2str __P((const Char *));
-extern char **short2blk __P((Char **));
-#endif /* SHORT_STRINGS */
-extern char *short2qstr __P((const Char *));
+extern Char *s_strcpy (Char *, const Char *);
+extern Char *s_strncpy (Char *, const Char *, size_t);
+extern Char *s_strspl (const Char *, const Char *);
+extern size_t s_strlen (const Char *);
+extern int s_strcmp (const Char *, const Char *);
+extern int s_strncmp (const Char *, const Char *, size_t);
+extern int s_strcasecmp (const Char *, const Char *);
+extern Char *s_strnsave (const Char *, size_t);
+extern Char *s_strsave (const Char *);
+extern Char *s_strend (const Char *);
+extern Char *s_strstr (const Char *, const Char *);
+extern Char *str2short (const char *);
+extern Char **blk2short (char **);
+extern char *short2str (const Char *);
+extern char **short2blk (Char **);
+#else /* !SHORT_STRINGS */
+extern char *caching_strip (const char *);
+#endif
+extern char *short2qstr (const Char *);
+
+extern void bb_append (struct blk_buf *, Char *);
+extern void bb_cleanup (void *);
+extern Char **bb_finish (struct blk_buf *);
+
+extern void strbuf_terminate(struct strbuf *);
+extern void strbuf_append1(struct strbuf *, char);
+extern void strbuf_appendn(struct strbuf *, const char *,
+ size_t);
+extern void strbuf_append (struct strbuf *, const char *);
+extern char *strbuf_finish (struct strbuf *);
+extern void strbuf_cleanup(void *);
+extern void Strbuf_terminate(struct Strbuf *);
+extern void Strbuf_append1(struct Strbuf *, Char);
+extern void Strbuf_appendn(struct Strbuf *, const Char *,
+ size_t);
+extern void Strbuf_append (struct Strbuf *, const Char *);
+extern Char *Strbuf_finish (struct Strbuf *);
+extern void Strbuf_cleanup(void *);
/*
* tc.vers.c:
*/
-extern void fix_version __P((void));
+extern void fix_version (void);
/*
* tc.who.c
*/
#if defined (HAVE_UTMP_H) || defined (HAVE_UTMPX_H) || defined (WINNT_NATIVE)
-extern void initwatch __P((void));
-extern void resetwatch __P((void));
-extern void watch_login __P((int));
-extern const char *who_info __P((ptr_t, int, char *, size_t));
-extern void dolog __P((Char **, struct command *));
+extern void initwatch (void);
+extern void resetwatch (void);
+extern void watch_login (int);
+extern char *who_info (ptr_t, int);
+extern void dolog (Char **, struct command *);
# ifdef HAVE_STRUCT_UTMP_UT_HOST
-extern char *utmphost __P((void));
-extern size_t utmphostsize __P((void));
+extern char *utmphost (void);
+extern size_t utmphostsize (void);
# endif /* HAVE_STRUCT_UTMP_UT_HOST */
#else
# define HAVENOUTMP
diff --git a/contrib/tcsh/tc.disc.c b/contrib/tcsh/tc.disc.c
index 32d30a4..30f46c4 100644
--- a/contrib/tcsh/tc.disc.c
+++ b/contrib/tcsh/tc.disc.c
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/tc.disc.c,v 3.15 2004/11/23 02:10:49 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/tc.disc.c,v 3.17 2006/03/02 18:46:45 christos Exp $ */
/*
* tc.disc.c: Functions to set/clear line disciplines
*
@@ -33,7 +33,7 @@
*/
#include "sh.h"
-RCSID("$Id: tc.disc.c,v 3.15 2004/11/23 02:10:49 christos Exp $")
+RCSID("$tcsh: tc.disc.c,v 3.17 2006/03/02 18:46:45 christos Exp $")
#ifdef OREO
#include <compat.h>
@@ -63,8 +63,7 @@ static int oldisc;
int
/*ARGSUSED*/
-setdisc(f)
-int f;
+setdisc(int f)
{
#ifdef IRIS4D
# ifndef POSIX
@@ -174,8 +173,7 @@ int f;
int
/*ARGSUSED*/
-resetdisc(f)
-int f;
+resetdisc(int f)
{
if (add_discipline) {
add_discipline = 0;
diff --git a/contrib/tcsh/tc.func.c b/contrib/tcsh/tc.func.c
index 4f19102..e2db430 100644
--- a/contrib/tcsh/tc.func.c
+++ b/contrib/tcsh/tc.func.c
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/tc.func.c,v 3.119 2005/03/06 03:57:10 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/tc.func.c,v 3.136 2006/09/01 12:51:35 christos Exp $ */
/*
* tc.func.c: New tcsh builtins.
*/
@@ -32,7 +32,7 @@
*/
#include "sh.h"
-RCSID("$Id: tc.func.c,v 3.119 2005/03/06 03:57:10 christos Exp $")
+RCSID("$tcsh: tc.func.c,v 3.136 2006/09/01 12:51:35 christos Exp $")
#include "ed.h"
#include "ed.defns.h" /* for the function names */
@@ -40,17 +40,14 @@ RCSID("$Id: tc.func.c,v 3.119 2005/03/06 03:57:10 christos Exp $")
#include "tc.h"
#ifdef WINNT_NATIVE
#include "nt.const.h"
+#else /* WINNT_NATIVE */
+#include <sys/wait.h>
#endif /* WINNT_NATIVE */
#ifdef AFS
-#define PASSMAX 16
#include <afs/stds.h>
#include <afs/kautils.h>
long ka_UserAuthenticateGeneral();
-#else
-#ifndef PASSMAX
-#define PASSMAX 8
-#endif
#endif /* AFS */
#ifdef TESLA
@@ -64,22 +61,21 @@ static int postcmd_active = 0;
static int periodic_active = 0;
static int cwdcmd_active = 0; /* PWP: for cwd_cmd */
static int beepcmd_active = 0;
-static signalfun_t alm_fun = NULL;
+static void (*alm_fun)(void) = NULL;
-static void auto_logout __P((int));
-static char *xgetpass __P((const char *));
-static void auto_lock __P((int));
+static void auto_logout (void);
+static char *xgetpass (const char *);
+static void auto_lock (void);
#ifdef BSDJOBS
-static void insert __P((struct wordent *, int));
-static void insert_we __P((struct wordent *, struct wordent *));
-static int inlist __P((Char *, Char *));
+static void insert (struct wordent *, int);
+static void insert_we (struct wordent *, struct wordent *);
+static int inlist (Char *, Char *);
#endif /* BSDJOBS */
-struct tildecache;
-static int tildecompare __P((struct tildecache *, struct tildecache *));
-static Char *gethomedir __P((Char *));
+static int tildecompare (const void *, const void *);
+static Char *gethomedir (const Char *);
#ifdef REMOTEHOST
-static RETSIGTYPE palarm __P((int));
-static void getremotehost __P((void));
+static void palarm (int);
+static void getremotehost (int);
#endif /* REMOTEHOST */
/*
@@ -87,69 +83,35 @@ static void getremotehost __P((void));
*/
/*
- * expand_lex: Take the given lex and put an expanded version of it in
- * the string buf. First guy in lex list is ignored; last guy is ^J
- * which we ignore. Only take lex'es from position 'from' to position
- * 'to' inclusive
+ * expand_lex: Take the given lex and return an expanded version of it.
+ * First guy in lex list is ignored; last guy is ^J which we ignore.
+ * Only take lex'es from position 'from' to position 'to' inclusive
*
* Note: csh sometimes sets bit 8 in characters which causes all kinds
* of problems if we don't mask it here. Note: excl's in lexes have been
* un-back-slashed and must be re-back-slashed
*
- * (PWP: NOTE: this returns a pointer to the END of the string expanded
- * (in other words, where the NUL is).)
*/
/* PWP: this is a combination of the old sprlex() and the expand_lex from
the magic-space stuff */
Char *
-expand_lex(buf, bufsiz, sp0, from, to)
- Char *buf;
- size_t bufsiz;
- struct wordent *sp0;
- int from, to;
+expand_lex(const struct wordent *sp0, int from, int to)
{
- struct wordent *sp;
- Char *s, *d, *e;
+ struct Strbuf buf = Strbuf_INIT;
+ const struct wordent *sp;
+ Char *s;
Char prev_c;
int i;
- /*
- * Make sure we have enough space to expand into. E.g. we may have
- * "a|b" turn to "a | b" (from 3 to 5 characters) which is the worst
- * case scenario (even "a>&! b" turns into "a > & ! b", i.e. 6 to 9
- * characters -- am I missing any other cases?).
- */
- bufsiz = bufsiz / 2;
-
- buf[0] = '\0';
prev_c = '\0';
- d = buf;
- e = &buf[bufsiz]; /* for bounds checking */
- if (!sp0)
- return (buf); /* null lex */
- if ((sp = sp0->next) == sp0)
- return (buf); /* nada */
- if (sp == (sp0 = sp0->prev))
- return (buf); /* nada */
+ if (!sp0 || (sp = sp0->next) == sp0 || sp == (sp0 = sp0->prev))
+ return Strbuf_finish(&buf); /* null lex */
- for (i = 0; i < NCARGS; i++) {
+ for (i = 0; ; i++) {
if ((i >= from) && (i <= to)) { /* if in range */
- for (s = sp->word; *s && d < e; s++) {
-
- if (s[1] & QUOTE) {
- int l = NLSSize(s, -1);
- if (l > 1) {
- while (l-- > 0) {
- if (d < e)
- *d++ = (*s & TRIM);
- prev_c = *s++;
- }
- s--;
- continue;
- }
- }
+ for (s = sp->word; *s; s++) {
/*
* bugfix by Michael Bloom: anything but the current history
* character {(PWP) and backslash} seem to be dealt with
@@ -160,44 +122,32 @@ expand_lex(buf, bufsiz, sp0, from, to)
(((*s & TRIM) == '\'') && (prev_c != '\\')) ||
(((*s & TRIM) == '\"') && (prev_c != '\\')) ||
(((*s & TRIM) == '\\') && (prev_c != '\\')))) {
- *d++ = '\\';
+ Strbuf_append1(&buf, '\\');
}
- if (d < e)
- *d++ = (*s & TRIM);
+ Strbuf_append1(&buf, *s & TRIM);
prev_c = *s;
}
- if (d < e)
- *d++ = ' ';
+ Strbuf_append1(&buf, ' ');
}
sp = sp->next;
if (sp == sp0)
break;
}
- if (d > buf)
- d--; /* get rid of trailing space */
+ if (buf.len != 0)
+ buf.len--; /* get rid of trailing space */
- return (d);
+ return Strbuf_finish(&buf);
}
Char *
-sprlex(buf, bufsiz, sp0)
- Char *buf;
- size_t bufsiz;
- struct wordent *sp0;
+sprlex(const struct wordent *sp0)
{
- Char *cp;
-
- cp = expand_lex(buf, bufsiz, sp0, 0, NCARGS);
- *cp = '\0';
- return (buf);
+ return expand_lex(sp0, 0, INT_MAX);
}
Char *
-Itoa(n, s, min_digits, attributes)
- int n;
- Char *s;
- int min_digits, attributes;
+Itoa(int n, size_t min_digits, Char attributes)
{
/*
* The array size here is derived from
@@ -209,19 +159,16 @@ Itoa(n, s, min_digits, attributes)
#ifndef CHAR_BIT
# define CHAR_BIT 8
#endif
- Char buf[CHAR_BIT * sizeof(int) / 3 + 1];
- Char *p;
+ Char buf[CHAR_BIT * sizeof(int) / 3 + 1], *res, *p, *s;
unsigned int un; /* handle most negative # too */
int pad = (min_digits != 0);
- if ((int)(sizeof(buf) - 1) < min_digits)
+ if (sizeof(buf) - 1 < min_digits)
min_digits = sizeof(buf) - 1;
un = n;
- if (n < 0) {
+ if (n < 0)
un = -n;
- *s++ = '-';
- }
p = buf;
do {
@@ -229,38 +176,39 @@ Itoa(n, s, min_digits, attributes)
un /= 10;
} while ((pad && --min_digits > 0) || un != 0);
+ res = xmalloc((p - buf + 2) * sizeof(*res));
+ s = res;
+ if (n < 0)
+ *s++ = '-';
while (p > buf)
*s++ = *--p | attributes;
*s = '\0';
- return s;
+ return res;
}
/*ARGSUSED*/
void
-dolist(v, c)
- Char **v;
- struct command *c;
+dolist(Char **v, struct command *c)
{
+ Char **globbed;
int i, k;
struct stat st;
USE(c);
if (*++v == NULL) {
- (void) t_search(STRNULL, NULL, LIST, 0, TW_ZERO, 0, STRNULL, 0);
+ struct Strbuf word = Strbuf_INIT;
+
+ Strbuf_terminate(&word);
+ cleanup_push(&word, Strbuf_cleanup);
+ (void) t_search(&word, LIST, TW_ZERO, 0, STRNULL, 0);
+ cleanup_until(&word);
return;
}
- gflag = 0;
- tglob(v);
- if (gflag) {
- v = globall(v);
- if (v == 0)
- stderror(ERR_NAME | ERR_NOMATCH);
- }
- else
- v = gargv = saveblk(v);
- trim(v);
+ v = glob_all_or_error(v);
+ globbed = v;
+ cleanup_push(globbed, blk_cleanup);
for (k = 0; v[k] != NULL && v[k][0] != '-'; k++)
continue;
if (v[k]) {
@@ -273,16 +221,12 @@ dolist(v, c)
Char *cp;
struct varent *vp;
-#ifdef BSDSIGS
- sigmask_t omask = 0;
-
- if (setintr)
- omask = sigblock(sigmask(SIGINT)) & ~sigmask(SIGINT);
-#else /* !BSDSIGS */
- (void) sighold(SIGINT);
-#endif /* BSDSIGS */
+ if (setintr) {
+ pintr_disabled++;
+ cleanup_push(&pintr_disabled, disabled_cleanup);
+ }
if (seterr) {
- xfree((ptr_t) seterr);
+ xfree(seterr);
seterr = NULL;
}
@@ -313,19 +257,19 @@ dolist(v, c)
cmd.word = STRNULL;
lastword = &cmd;
- nextword = (struct wordent *) xcalloc(1, sizeof cmd);
+ nextword = xcalloc(1, sizeof cmd);
nextword->word = Strsave(lspath);
lastword->next = nextword;
nextword->prev = lastword;
lastword = nextword;
- nextword = (struct wordent *) xcalloc(1, sizeof cmd);
+ nextword = xcalloc(1, sizeof cmd);
nextword->word = Strsave(STRmCF);
lastword->next = nextword;
nextword->prev = lastword;
#if defined(KANJI) && defined(SHORT_STRINGS) && defined(DSPMBYTE)
if (dspmbyte_ls) {
lastword = nextword;
- nextword = (struct wordent *) xcalloc(1, sizeof cmd);
+ nextword = xcalloc(1, sizeof cmd);
nextword->word = Strsave(STRmmliteral);
lastword->next = nextword;
nextword->prev = lastword;
@@ -334,7 +278,7 @@ dolist(v, c)
#ifdef COLOR_LS_F
if (color_context_ls) {
lastword = nextword;
- nextword = (struct wordent *) xcalloc(1, sizeof cmd);
+ nextword = xcalloc(1, sizeof cmd);
nextword->word = Strsave(STRmmcolormauto);
lastword->next = nextword;
nextword->prev = lastword;
@@ -342,7 +286,7 @@ dolist(v, c)
#endif /* COLOR_LS_F */
lastword = nextword;
for (cp = *v; cp; cp = *++v) {
- nextword = (struct wordent *) xcalloc(1, sizeof cmd);
+ nextword = xcalloc(1, sizeof cmd);
nextword->word = quote(Strsave(cp));
lastword->next = nextword;
nextword->prev = lastword;
@@ -350,9 +294,11 @@ dolist(v, c)
}
lastword->next = &cmd;
cmd.prev = lastword;
+ cleanup_push(&cmd, lex_cleanup);
/* build a syntax tree for the command. */
t = syntax(cmd.next, &cmd, 0);
+ cleanup_push(t, syntax_cleanup);
if (seterr)
stderror(ERR_OLD);
/* expand aliases like process() does */
@@ -360,32 +306,34 @@ dolist(v, c)
/* execute the parse tree. */
execute(t, tpgrp > 0 ? tpgrp : -1, NULL, NULL, FALSE);
/* done. free the lex list and parse tree. */
- freelex(&cmd), freesyn(t);
+ cleanup_until(&cmd);
if (setintr)
-#ifdef BSDSIGS
- (void) sigsetmask(omask);
-#else /* !BSDSIGS */
- (void) sigrelse(SIGINT);
-#endif /* BSDSIGS */
+ cleanup_until(&pintr_disabled);
}
else {
- Char *dp, *tmp, buf[MAXPATHLEN];
+ Char *dp, *tmp;
+ struct Strbuf buf = Strbuf_INIT;
+ cleanup_push(&buf, Strbuf_cleanup);
for (k = 0, i = 0; v[k] != NULL; k++) {
tmp = dnormalize(v[k], symlinks == SYM_IGNORE);
- dp = &tmp[Strlen(tmp) - 1];
+ cleanup_push(tmp, xfree);
+ dp = Strend(tmp) - 1;
if (*dp == '/' && dp != tmp)
#ifdef apollo
if (dp != &tmp[1])
#endif /* apollo */
*dp = '\0';
- if (stat(short2str(tmp), &st) == -1) {
+ if (stat(short2str(tmp), &st) == -1) {
+ int err;
+
+ err = errno;
if (k != i) {
if (i != 0)
xputchar('\n');
print_by_column(STRNULL, &v[i], k - i, FALSE);
}
- xprintf("%S: %s.\n", tmp, strerror(errno));
+ xprintf("%S: %s.\n", tmp, strerror(err));
i = k + 1;
}
else if (S_ISDIR(st.st_mode)) {
@@ -399,22 +347,26 @@ dolist(v, c)
if (k != 0 && v[1] != NULL)
xputchar('\n');
xprintf("%S:\n", tmp);
- for (cp = tmp, dp = buf; *cp; *dp++ = (*cp++ | QUOTE))
- continue;
+ buf.len = 0;
+ for (cp = tmp; *cp; cp++)
+ Strbuf_append1(&buf, (*cp | QUOTE));
+ Strbuf_terminate(&buf);
+ dp = &buf.s[buf.len - 1];
if (
#ifdef WINNT_NATIVE
- (dp[-1] != (Char) (':' | QUOTE)) &&
+ (*dp != (Char) (':' | QUOTE)) &&
#endif /* WINNT_NATIVE */
- (dp[-1] != (Char) ('/' | QUOTE)))
- *dp++ = '/';
- else
- dp[-1] &= TRIM;
- *dp = '\0';
- (void) t_search(buf, NULL, LIST, 0, TW_ZERO, 0, STRNULL, 0);
+ (*dp != (Char) ('/' | QUOTE))) {
+ Strbuf_append1(&buf, '/');
+ Strbuf_terminate(&buf);
+ } else
+ *dp &= TRIM;
+ (void) t_search(&buf, LIST, TW_ZERO, 0, STRNULL, 0);
i = k + 1;
}
- xfree((ptr_t) tmp);
+ cleanup_until(tmp);
}
+ cleanup_until(&buf);
if (k != i) {
if (i != 0)
xputchar('\n');
@@ -422,19 +374,14 @@ dolist(v, c)
}
}
- if (gargv) {
- blkfree(gargv);
- gargv = 0;
- }
+ cleanup_until(globbed);
}
extern int GotTermCaps;
/*ARGSUSED*/
void
-dotelltc(v, c)
- Char **v;
- struct command *c;
+dotelltc(Char **v, struct command *c)
{
USE(v);
USE(c);
@@ -445,9 +392,7 @@ dotelltc(v, c)
/*ARGSUSED*/
void
-doechotc(v, c)
- Char **v;
- struct command *c;
+doechotc(Char **v, struct command *c)
{
USE(c);
if (!GotTermCaps)
@@ -457,19 +402,20 @@ doechotc(v, c)
/*ARGSUSED*/
void
-dosettc(v, c)
- Char **v;
- struct command *c;
+dosettc(Char **v, struct command *c)
{
- char tv[2][BUFSIZE];
+ char *tv[2];
USE(c);
if (!GotTermCaps)
GetTermCaps();
- (void) strcpy(tv[0], short2str(v[1]));
- (void) strcpy(tv[1], short2str(v[2]));
+ tv[0] = strsave(short2str(v[1]));
+ cleanup_push(tv[0], xfree);
+ tv[1] = strsave(short2str(v[2]));
+ cleanup_push(tv[1], xfree);
SetTC(tv[0], tv[1]);
+ cleanup_until(tv[0]);
}
/* The dowhich() is by:
@@ -481,9 +427,7 @@ dosettc(v, c)
* Thanks!!
*/
int
-cmd_expand(cmd, str)
- Char *cmd;
- Char *str;
+cmd_expand(Char *cmd, Char **str)
{
struct wordent lexp[3];
struct varent *vp;
@@ -506,8 +450,8 @@ cmd_expand(cmd, str)
blkpr(vp->vec);
xputchar('\n');
}
- else
- blkexpand(vp->vec, str);
+ else
+ *str = blkexpand(vp->vec);
}
else {
lexp[1].word = cmd;
@@ -519,54 +463,35 @@ cmd_expand(cmd, str)
/*ARGSUSED*/
void
-dowhich(v, c)
- Char **v;
- struct command *c;
+dowhich(Char **v, struct command *c)
{
int rv = TRUE;
USE(c);
-#ifdef notdef
- /*
+ /*
* We don't want to glob dowhich args because we lose quoteing
* E.g. which \ls if ls is aliased will not work correctly if
* we glob here.
*/
- gflag = 0, tglob(v);
- if (gflag) {
- v = globall(v);
- if (v == 0)
- stderror(ERR_NAME | ERR_NOMATCH);
- }
- else {
- v = gargv = saveblk(v);
- trim(v);
- }
-#endif
while (*++v)
rv &= cmd_expand(*v, NULL);
if (!rv)
- set(STRstatus, Strsave(STR1), VAR_READWRITE);
-
-#ifdef notdef
- /* Again look at the comment above; since we don't glob, we don't free */
- if (gargv)
- blkfree(gargv), gargv = 0;
-#endif
+ setcopy(STRstatus, STR1, VAR_READWRITE);
}
/* PWP: a hack to start up your stopped editor on a single keystroke */
/* jbs - fixed hack so it worked :-) 3/28/89 */
struct process *
-find_stop_ed()
+find_stop_ed(void)
{
struct process *pp, *retp;
const char *ep, *vp;
char *cp, *p;
- int epl, vpl, pstatus;
+ size_t epl, vpl;
+ int pstatus;
if ((ep = getenv("EDITOR")) != NULL) { /* if we have a value */
if ((p = strrchr(ep, '/')) != NULL) /* if it has a path */
@@ -616,8 +541,8 @@ find_stop_ed()
cp = p; /* else we get all of it */
/* if we find either in the current name, fg it */
- if (strncmp(ep, cp, (size_t) epl) == 0 ||
- strncmp(vp, cp, (size_t) vpl) == 0) {
+ if (strncmp(ep, cp, epl) == 0 ||
+ strncmp(vp, cp, vpl) == 0) {
/*
* If there is a choice, then choose the current process if
@@ -635,31 +560,26 @@ find_stop_ed()
}
void
-fg_proc_entry(pp)
- struct process *pp;
+fg_proc_entry(struct process *pp)
{
-#ifdef BSDSIGS
- sigmask_t omask;
-#endif
jmp_buf_t osetexit;
int ohaderr;
Char oGettingInput;
+ size_t omark;
getexit(osetexit);
-#ifdef BSDSIGS
- omask = sigblock(sigmask(SIGINT));
-#else
- (void) sighold(SIGINT);
-#endif
+ pintr_disabled++;
oGettingInput = GettingInput;
GettingInput = 0;
ohaderr = haderr; /* we need to ignore setting of haderr due to
* process getting stopped by a signal */
+ omark = cleanup_push_mark();
if (setexit() == 0) { /* come back here after pjwait */
pendjob();
(void) alarm(0); /* No autologout */
+ alrmcatch_disabled = 1;
if (!pstart(pp, 1)) {
pp->p_procid = 0;
stderror(ERR_BADJOB, pp->p_command, strerror(errno));
@@ -667,53 +587,61 @@ fg_proc_entry(pp)
pjwait(pp);
}
setalarm(1); /* Autologout back on */
+ cleanup_pop_mark(omark);
resexit(osetexit);
haderr = ohaderr;
GettingInput = oGettingInput;
-#ifdef BSDSIGS
- (void) sigsetmask(omask);
-#else /* !BSDSIGS */
- (void) sigrelse(SIGINT);
-#endif /* BSDSIGS */
-
+ disabled_cleanup(&pintr_disabled);
}
static char *
-xgetpass(prm)
- const char *prm;
+xgetpass(const char *prm)
{
- static char pass[PASSMAX + 1];
- int fd, i;
- signalfun_t sigint;
+ static struct strbuf pass; /* = strbuf_INIT; */
+ int fd;
+ sigset_t oset, set;
+ struct sigaction sa, osa;
+
+ sa.sa_handler = SIG_IGN;
+ sigemptyset(&sa.sa_mask);
+ sa.sa_flags = 0;
+ (void)sigaction(SIGINT, &sa, &osa);
+
+ sigemptyset(&set);
+ sigaddset(&set, SIGINT);
+ (void)sigprocmask(SIG_UNBLOCK, &set, &oset);
- sigint = (signalfun_t) sigset(SIGINT, SIG_IGN);
+ cleanup_push(&osa, sigint_cleanup);
+ cleanup_push(&oset, sigprocmask_cleanup);
(void) Rawmode(); /* Make sure, cause we want echo off */
- if ((fd = open("/dev/tty", O_RDWR|O_LARGEFILE)) == -1)
+ fd = xopen("/dev/tty", O_RDWR|O_LARGEFILE);
+ if (fd == -1)
fd = SHIN;
+ else
+ cleanup_push(&fd, open_cleanup);
xprintf("%s", prm); flush();
- for (i = 0;;) {
- if (read(fd, &pass[i], 1) < 1 || pass[i] == '\n')
+ pass.len = 0;
+ for (;;) {
+ char c;
+
+ if (xread(fd, &c, 1) < 1 || c == '\n')
break;
- if (i < PASSMAX)
- i++;
+ strbuf_append1(&pass, c);
}
-
- pass[i] = '\0';
+ strbuf_terminate(&pass);
- if (fd != SHIN)
- (void) close(fd);
- (void) sigset(SIGINT, sigint);
+ cleanup_until(&sa);
- return(pass);
+ return pass.s;
}
-
+
#ifndef NO_CRYPT
-#ifndef __STDC__
- extern char *crypt __P(());
+#if !HAVE_DECL_CRYPT
+ extern char *crypt ();
#endif
-#ifdef __linux__
+#ifdef HAVE_CRYPT_H
#include <crypt.h>
#endif
#endif
@@ -728,8 +656,7 @@ xgetpass(prm)
*/
/*ARGSUSED*/
static void
-auto_lock(n)
- int n;
+auto_lock(void)
{
#ifndef NO_CRYPT
@@ -739,14 +666,14 @@ auto_lock(n)
#undef XCRYPT
-#if defined(HAVE_AUTH_H)
+#if defined(HAVE_AUTH_H) && defined(HAVE_GETAUTHUID)
struct authorization *apw;
- extern char *crypt16 __P((const char *, const char *));
+ extern char *crypt16 (const char *, const char *);
# define XCRYPT(a, b) crypt16(a, b)
- if ((pw = getpwuid(euid)) != NULL && /* effective user passwd */
+ if ((pw = xgetpwuid(euid)) != NULL && /* effective user passwd */
(apw = getauthuid(euid)) != NULL) /* enhanced ultrix passwd */
srpp = apw->a_password;
@@ -756,34 +683,35 @@ auto_lock(n)
# define XCRYPT(a, b) crypt(a, b)
- if ((pw = getpwuid(euid)) != NULL && /* effective user passwd */
- (spw = getspnam(pw->pw_name)) != NULL) /* shadowed passwd */
- srpp = spw->sp_pwdp;
+ if ((pw = xgetpwuid(euid)) != NULL) { /* effective user passwd */
+ errno = 0;
+ while ((spw = getspnam(pw->pw_name)) == NULL && errno == EINTR) {
+ handle_pending_signals();
+ errno = 0;
+ }
+ if (spw != NULL) /* shadowed passwd */
+ srpp = spw->sp_pwdp;
+ }
#else
#define XCRYPT(a, b) crypt(a, b)
#if !defined(__MVS__)
- if ((pw = getpwuid(euid)) != NULL) /* effective user passwd */
+ if ((pw = xgetpwuid(euid)) != NULL) /* effective user passwd */
srpp = pw->pw_passwd;
#endif /* !MVS */
#endif
if (srpp == NULL) {
- auto_logout(0);
+ auto_logout();
/*NOTREACHED*/
return;
}
setalarm(0); /* Not for locking any more */
-#ifdef BSDSIGS
- (void) sigsetmask(sigblock(0) & ~(sigmask(SIGALRM)));
-#else /* !BSDSIGS */
- (void) sigrelse(SIGALRM);
-#endif /* BSDSIGS */
- xputchar('\n');
+ xputchar('\n');
for (i = 0; i < 5; i++) {
const char *crpp;
char *pp;
@@ -797,7 +725,7 @@ auto_lock(n)
if ((afsname = getenv("AFSUSER")) == NULL)
afsname = pw->pw_name;
#endif
- pp = xgetpass("Password:");
+ pp = xgetpass("Password:");
crpp = XCRYPT(pp, srpp);
if ((strcmp(crpp, srpp) == 0)
@@ -813,11 +741,11 @@ auto_lock(n)
== 0)
#endif /* AFS */
) {
- (void) memset(pp, 0, PASSMAX);
+ (void) memset(pp, 0, strlen(pp));
if (GettingInput && !just_signaled) {
(void) Rawmode();
- ClearLines();
- ClearDisp();
+ ClearLines();
+ ClearDisp();
Refresh();
}
just_signaled = 0;
@@ -826,22 +754,19 @@ auto_lock(n)
xprintf(CGETS(22, 2, "\nIncorrect passwd for %s\n"), pw->pw_name);
}
#endif /* NO_CRYPT */
- auto_logout(0);
- USE(n);
+ auto_logout();
}
static void
-auto_logout(n)
- int n;
+auto_logout(void)
{
- USE(n);
xprintf("auto-logout\n");
/* Don't leave the tty in raw mode */
if (editing)
(void) Cookedmode();
- (void) close(SHIN);
- set(STRlogout, Strsave(STRautomatic), VAR_READWRITE);
+ xclose(SHIN);
+ setcopy(STRlogout, STRautomatic, VAR_READWRITE);
child = 1;
#ifdef TESLA
do_logout = 1;
@@ -850,19 +775,10 @@ auto_logout(n)
goodbye(NULL, NULL);
}
-RETSIGTYPE
-/*ARGSUSED*/
-alrmcatch(snum)
-int snum;
+void
+alrmcatch(void)
{
- USE(snum);
-#ifdef UNRELSIGS
- if (snum)
- (void) sigset(SIGALRM, alrmcatch);
-#endif /* UNRELSIGS */
-
- (*alm_fun)(0);
-
+ (*alm_fun)();
setalarm(1);
}
@@ -876,15 +792,10 @@ int snum;
* one's current directory just before each command.
*/
void
-precmd()
+precmd(void)
{
-#ifdef BSDSIGS
- sigmask_t omask;
-
- omask = sigblock(sigmask(SIGINT));
-#else /* !BSDSIGS */
- (void) sighold(SIGINT);
-#endif /* BSDSIGS */
+ pintr_disabled++;
+ cleanup_push(&pintr_disabled, disabled_cleanup);
if (precmd_active) { /* an error must have been caught */
aliasrun(2, STRunalias, STRprecmd);
xprintf(CGETS(22, 3, "Faulty alias 'precmd' removed.\n"));
@@ -895,23 +806,14 @@ precmd()
aliasrun(1, STRprecmd, NULL);
leave:
precmd_active = 0;
-#ifdef BSDSIGS
- (void) sigsetmask(omask);
-#else /* !BSDSIGS */
- (void) sigrelse(SIGINT);
-#endif /* BSDSIGS */
+ cleanup_until(&pintr_disabled);
}
void
-postcmd()
+postcmd(void)
{
-#ifdef BSDSIGS
- sigmask_t omask;
-
- omask = sigblock(sigmask(SIGINT));
-#else /* !BSDSIGS */
- (void) sighold(SIGINT);
-#endif /* BSDSIGS */
+ pintr_disabled++;
+ cleanup_push(&pintr_disabled, disabled_cleanup);
if (postcmd_active) { /* an error must have been caught */
aliasrun(2, STRunalias, STRpostcmd);
xprintf(CGETS(22, 3, "Faulty alias 'postcmd' removed.\n"));
@@ -922,11 +824,7 @@ postcmd()
aliasrun(1, STRpostcmd, NULL);
leave:
postcmd_active = 0;
-#ifdef BSDSIGS
- (void) sigsetmask(omask);
-#else /* !BSDSIGS */
- (void) sigrelse(SIGINT);
-#endif /* BSDSIGS */
+ cleanup_until(&pintr_disabled);
}
/*
@@ -936,15 +834,10 @@ leave:
* space.
*/
void
-cwd_cmd()
+cwd_cmd(void)
{
-#ifdef BSDSIGS
- sigmask_t omask;
-
- omask = sigblock(sigmask(SIGINT));
-#else /* !BSDSIGS */
- (void) sighold(SIGINT);
-#endif /* BSDSIGS */
+ pintr_disabled++;
+ cleanup_push(&pintr_disabled, disabled_cleanup);
if (cwdcmd_active) { /* an error must have been caught */
aliasrun(2, STRunalias, STRcwdcmd);
xprintf(CGETS(22, 4, "Faulty alias 'cwdcmd' removed.\n"));
@@ -955,11 +848,7 @@ cwd_cmd()
aliasrun(1, STRcwdcmd, NULL);
leave:
cwdcmd_active = 0;
-#ifdef BSDSIGS
- (void) sigsetmask(omask);
-#else /* !BSDSIGS */
- (void) sigrelse(SIGINT);
-#endif /* BSDSIGS */
+ cleanup_until(&pintr_disabled);
}
/*
@@ -967,15 +856,10 @@ leave:
* to beep the terminal bell. Useful for playing nice sounds instead.
*/
void
-beep_cmd()
+beep_cmd(void)
{
-#ifdef BSDSIGS
- sigmask_t omask;
-
- omask = sigblock(sigmask(SIGINT));
-#else /* !BSDSIGS */
- (void) sighold(SIGINT);
-#endif /* BSDSIGS */
+ pintr_disabled++;
+ cleanup_push(&pintr_disabled, disabled_cleanup);
if (beepcmd_active) { /* an error must have been caught */
aliasrun(2, STRunalias, STRbeepcmd);
xprintf(CGETS(22, 5, "Faulty alias 'beepcmd' removed.\n"));
@@ -986,11 +870,7 @@ beep_cmd()
aliasrun(1, STRbeepcmd, NULL);
}
beepcmd_active = 0;
-#ifdef BSDSIGS
- (void) sigsetmask(omask);
-#else /* !BSDSIGS */
- (void) sigrelse(SIGINT);
-#endif /* BSDSIGS */
+ cleanup_until(&pintr_disabled);
}
@@ -1000,17 +880,13 @@ beep_cmd()
* $tperiod minutes. Useful for occasional checking of msgs and such.
*/
void
-period_cmd()
+period_cmd(void)
{
Char *vp;
time_t t, interval;
-#ifdef BSDSIGS
- sigmask_t omask;
- omask = sigblock(sigmask(SIGINT));
-#else /* !BSDSIGS */
- (void) sighold(SIGINT);
-#endif /* BSDSIGS */
+ pintr_disabled++;
+ cleanup_push(&pintr_disabled, disabled_cleanup);
if (periodic_active) { /* an error must have been caught */
aliasrun(2, STRunalias, STRperiodic);
xprintf(CGETS(22, 6, "Faulty alias 'periodic' removed.\n"));
@@ -1032,11 +908,7 @@ period_cmd()
}
leave:
periodic_active = 0;
-#ifdef BSDSIGS
- (void) sigsetmask(omask);
-#else /* !BSDSIGS */
- (void) sigrelse(SIGINT);
-#endif /* BSDSIGS */
+ cleanup_until(&pintr_disabled);
}
@@ -1049,16 +921,10 @@ leave:
* Cloned from cwd_cmd().
*/
void
-job_cmd(args)
- Char *args;
+job_cmd(Char *args)
{
-#ifdef BSDSIGS
- sigmask_t omask;
-
- omask = sigblock(sigmask(SIGINT));
-#else /* !BSDSIGS */
- (void) sighold(SIGINT);
-#endif /* BSDSIGS */
+ pintr_disabled++;
+ cleanup_push(&pintr_disabled, disabled_cleanup);
if (jobcmd_active) { /* an error must have been caught */
aliasrun(2, STRunalias, STRjobcmd);
xprintf(CGETS(22, 14, "Faulty alias 'jobcmd' removed.\n"));
@@ -1072,11 +938,7 @@ job_cmd(args)
}
leave:
jobcmd_active = 0;
-#ifdef BSDSIGS
- (void) sigsetmask(omask);
-#else /* !BSDSIGS */
- (void) sigrelse(SIGINT);
-#endif /* BSDSIGS */
+ cleanup_until(&pintr_disabled);
}
@@ -1086,22 +948,21 @@ leave:
* This code is based on the mainline of process().
*/
void
-aliasrun(cnt, s1, s2)
- int cnt;
- Char *s1, *s2;
+aliasrun(int cnt, Char *s1, Char *s2)
{
struct wordent w, *new1, *new2; /* for holding alias name */
struct command *t = NULL;
jmp_buf_t osetexit;
int status;
+ size_t omark;
getexit(osetexit);
if (seterr) {
- xfree((ptr_t) seterr);
+ xfree(seterr);
seterr = NULL; /* don't repeatedly print err msg. */
}
w.word = STRNULL;
- new1 = (struct wordent *) xcalloc(1, sizeof w);
+ new1 = xcalloc(1, sizeof w);
new1->word = Strsave(s1);
if (cnt == 1) {
/* build a lex list with one word. */
@@ -1110,12 +971,13 @@ aliasrun(cnt, s1, s2)
}
else {
/* build a lex list with two words. */
- new2 = (struct wordent *) xcalloc(1, sizeof w);
+ new2 = xcalloc(1, sizeof w);
new2->word = Strsave(s2);
w.next = new2->prev = new1;
new1->next = w.prev = new2;
new1->prev = new2->next = &w;
}
+ cleanup_push(&w, lex_cleanup);
/* Save the old status */
status = getn(varval(STRstatus));
@@ -1124,13 +986,15 @@ aliasrun(cnt, s1, s2)
alias(&w);
/* build a syntax tree for the command. */
t = syntax(w.next, &w, 0);
+ cleanup_push(t, syntax_cleanup);
if (seterr)
stderror(ERR_OLD);
psavejob();
-
+ cleanup_push(&cnt, psavejob_cleanup); /* cnt is used only as a marker */
/* catch any errors here */
+ omark = cleanup_push_mark();
if (setexit() == 0)
/* execute the parse tree. */
/*
@@ -1138,8 +1002,9 @@ aliasrun(cnt, s1, s2)
* was execute(t, tpgrp);
*/
execute(t, tpgrp > 0 ? tpgrp : -1, NULL, NULL, TRUE);
- /* done. free the lex list and parse tree. */
- freelex(&w), freesyn(t);
+ /* reset the error catcher to the old place */
+ cleanup_pop_mark(omark);
+ resexit(osetexit);
if (haderr) {
haderr = 0;
/*
@@ -1167,17 +1032,14 @@ aliasrun(cnt, s1, s2)
period_cmd();
#endif /* notdef */
}
- /* reset the error catcher to the old place */
- resexit(osetexit);
- prestjob();
+ cleanup_until(&w);
pendjob();
/* Restore status */
- set(STRstatus, putn(status), VAR_READWRITE);
+ setv(STRstatus, putn(status), VAR_READWRITE);
}
void
-setalarm(lck)
- int lck;
+setalarm(int lck)
{
struct varent *vp;
Char *cp;
@@ -1224,14 +1086,14 @@ setalarm(lck)
alm_fun = sched_run;
}
}
+ alrmcatch_disabled = 0;
(void) alarm(alrm_time); /* Autologout ON */
}
#undef RMDEBUG /* For now... */
void
-rmstar(cp)
- struct wordent *cp;
+rmstar(struct wordent *cp)
{
struct wordent *we, *args;
struct wordent *tmp, *del;
@@ -1295,18 +1157,18 @@ rmstar(cp)
*tmp->word != ';' && tmp != cp;) {
tmp->prev->next = tmp->next;
tmp->next->prev = tmp->prev;
- xfree((ptr_t) tmp->word);
+ xfree(tmp->word);
del = tmp;
tmp = tmp->next;
- xfree((ptr_t) del);
+ xfree(del);
}
if (*tmp->word == ';') {
tmp->prev->next = tmp->next;
tmp->next->prev = tmp->prev;
- xfree((ptr_t) tmp->word);
+ xfree(tmp->word);
del = tmp;
tmp = tmp->next;
- xfree((ptr_t) del);
+ xfree(del);
}
we = tmp;
continue;
@@ -1337,8 +1199,7 @@ rmstar(cp)
#undef CNDEBUG /* For now */
void
-continue_jobs(cp)
- struct wordent *cp;
+continue_jobs(struct wordent *cp)
{
struct wordent *we;
struct process *pp, *np;
@@ -1409,29 +1270,27 @@ continue_jobs(cp)
/* The actual "aliasing" of for backgrounds() is done here
with the aid of insert_we(). */
static void
-insert(pl, file_args)
- struct wordent *pl;
- int file_args;
+insert(struct wordent *pl, int file_args)
{
struct wordent *now, *last;
Char *cmd, *bcmd, *cp1, *cp2;
- int cmd_len;
+ size_t cmd_len;
Char *upause = STRunderpause;
- int p_len = (int) Strlen(upause);
+ size_t p_len = Strlen(upause);
- cmd_len = (int) Strlen(pl->word);
- cmd = (Char *) xcalloc(1, (size_t) ((cmd_len + 1) * sizeof(Char)));
+ cmd_len = Strlen(pl->word);
+ cmd = xcalloc(1, (cmd_len + 1) * sizeof(Char));
(void) Strcpy(cmd, pl->word);
/* Do insertions at beginning, first replace command word */
if (file_args) {
now = pl;
- xfree((ptr_t) now->word);
- now->word = (Char *) xcalloc(1, (size_t) (5 * sizeof(Char)));
+ xfree(now->word);
+ now->word = xcalloc(1, 5 * sizeof(Char));
(void) Strcpy(now->word, STRecho);
- now = (struct wordent *) xcalloc(1, (size_t) sizeof(struct wordent));
- now->word = (Char *) xcalloc(1, (size_t) (6 * sizeof(Char)));
+ now = xcalloc(1, sizeof(struct wordent));
+ now->word = xcalloc(1, 6 * sizeof(Char));
(void) Strcpy(now->word, STRbackqpwd);
insert_we(now, pl);
@@ -1439,18 +1298,18 @@ insert(pl, file_args)
last = last->next)
continue;
- now = (struct wordent *) xcalloc(1, (size_t) sizeof(struct wordent));
- now->word = (Char *) xcalloc(1, (size_t) (2 * sizeof(Char)));
+ now = xcalloc(1, sizeof(struct wordent));
+ now->word = xcalloc(1, 2 * sizeof(Char));
(void) Strcpy(now->word, STRgt);
insert_we(now, last->prev);
- now = (struct wordent *) xcalloc(1, (size_t) sizeof(struct wordent));
- now->word = (Char *) xcalloc(1, (size_t) (2 * sizeof(Char)));
+ now = xcalloc(1, sizeof(struct wordent));
+ now->word = xcalloc(1, 2 * sizeof(Char));
(void) Strcpy(now->word, STRbang);
insert_we(now, last->prev);
- now = (struct wordent *) xcalloc(1, (size_t) sizeof(struct wordent));
- now->word = (Char *) xcalloc(1, (size_t) cmd_len + p_len + 4);
+ now = xcalloc(1, sizeof(struct wordent));
+ now->word = xcalloc(1, (cmd_len + p_len + 4) * sizeof(Char));
cp1 = now->word;
cp2 = cmd;
*cp1++ = '~';
@@ -1464,17 +1323,14 @@ insert(pl, file_args)
continue;
insert_we(now, last->prev);
- now = (struct wordent *) xcalloc(1, (size_t) sizeof(struct wordent));
- now->word = (Char *) xcalloc(1, (size_t) (2 * sizeof(Char)));
+ now = xcalloc(1, sizeof(struct wordent));
+ now->word = xcalloc(1, 2 * sizeof(Char));
(void) Strcpy(now->word, STRsemi);
insert_we(now, last->prev);
- bcmd = (Char *) xcalloc(1, (size_t) ((cmd_len + 2) * sizeof(Char)));
- cp1 = bcmd;
- cp2 = cmd;
- *cp1++ = '%';
- while ((*cp1++ = *cp2++) != '\0')
- continue;
- now = (struct wordent *) xcalloc(1, (size_t) (sizeof(struct wordent)));
+ bcmd = xcalloc(1, (cmd_len + 2) * sizeof(Char));
+ *bcmd = '%';
+ Strcpy(bcmd + 1, cmd);
+ now = xcalloc(1, sizeof(struct wordent));
now->word = bcmd;
insert_we(now, last->prev);
}
@@ -1482,29 +1338,24 @@ insert(pl, file_args)
struct wordent *del;
now = pl;
- xfree((ptr_t) now->word);
- now->word = (Char *) xcalloc(1,
- (size_t) ((cmd_len + 2) * sizeof(Char)));
- cp1 = now->word;
- cp2 = cmd;
- *cp1++ = '%';
- while ((*cp1++ = *cp2++) != '\0')
- continue;
+ xfree(now->word);
+ now->word = xcalloc(1, (cmd_len + 2) * sizeof(Char));
+ *now->word = '%';
+ Strcpy(now->word + 1, cmd);
for (now = now->next;
*now->word != '\n' && *now->word != ';' && now != pl;) {
now->prev->next = now->next;
now->next->prev = now->prev;
- xfree((ptr_t) now->word);
+ xfree(now->word);
del = now;
now = now->next;
- xfree((ptr_t) del);
+ xfree(del);
}
}
}
static void
-insert_we(new, where)
- struct wordent *new, *where;
+insert_we(struct wordent *new, struct wordent *where)
{
new->prev = where;
@@ -1514,8 +1365,7 @@ insert_we(new, where)
}
static int
-inlist(list, name)
- Char *list, *name;
+inlist(Char *list, Char *name)
{
Char *l, *n;
@@ -1555,23 +1405,25 @@ inlist(list, name)
static struct tildecache {
Char *user;
Char *home;
- int hlen;
+ size_t hlen;
} *tcache = NULL;
#define TILINCR 10
-int tlength = 0;
-static int tsize = TILINCR;
+size_t tlength = 0;
+static size_t tsize = TILINCR;
static int
-tildecompare(p1, p2)
- struct tildecache *p1, *p2;
+tildecompare(const void *xp1, const void *xp2)
{
+ const struct tildecache *p1, *p2;
+
+ p1 = xp1;
+ p2 = xp2;
return Strcmp(p1->user, p2->user);
}
static Char *
-gethomedir(us)
- Char *us;
+gethomedir(const Char *us)
{
struct passwd *pp;
#ifdef HESIOD
@@ -1579,7 +1431,7 @@ gethomedir(us)
Char *rp;
#endif /* HESIOD */
- pp = getpwnam(short2str(us));
+ pp = xgetpwnam(short2str(us));
#ifdef YPBUGS
fix_yp_bugs();
#endif /* YPBUGS */
@@ -1624,7 +1476,7 @@ gethomedir(us)
#if 0
/* Don't return if root */
if (rp != NULL && rp[0] == '/' && rp[1] == '\0') {
- xfree((ptr_t)rp);
+ xfree(rp);
rp = NULL;
}
#endif
@@ -1635,8 +1487,7 @@ gethomedir(us)
}
Char *
-gettilde(us)
- Char *us;
+gettilde(const Char *us)
{
struct tildecache *bp1, *bp2, *bp;
Char *hd;
@@ -1646,8 +1497,7 @@ gettilde(us)
return NULL;
if (tcache == NULL)
- tcache = (struct tildecache *) xmalloc((size_t) (TILINCR *
- sizeof(struct tildecache)));
+ tcache = xmalloc(TILINCR * sizeof(struct tildecache));
/*
* Binary search
*/
@@ -1674,16 +1524,13 @@ gettilde(us)
*/
tcache[tlength].user = Strsave(us);
tcache[tlength].home = hd;
- tcache[tlength++].hlen = (int) Strlen(hd);
+ tcache[tlength++].hlen = Strlen(hd);
- qsort((ptr_t) tcache, (size_t) tlength, sizeof(struct tildecache),
- (int (*) __P((const void *, const void *))) tildecompare);
+ qsort(tcache, tlength, sizeof(struct tildecache), tildecompare);
if (tlength == tsize) {
tsize += TILINCR;
- tcache = (struct tildecache *) xrealloc((ptr_t) tcache,
- (size_t) (tsize *
- sizeof(struct tildecache)));
+ tcache = xrealloc(tcache, tsize * sizeof(struct tildecache));
}
return (hd);
}
@@ -1696,139 +1543,44 @@ gettilde(us)
* If we are passed a null pointer, then we flush the cache.
*/
Char *
-getusername(hm)
- Char **hm;
+getusername(Char **hm)
{
Char *h, *p;
- int i, j;
+ size_t i, j;
if (hm == NULL) {
for (i = 0; i < tlength; i++) {
- xfree((ptr_t) tcache[i].home);
- xfree((ptr_t) tcache[i].user);
+ xfree(tcache[i].home);
+ xfree(tcache[i].user);
}
- xfree((ptr_t) tcache);
+ xfree(tcache);
tlength = 0;
tsize = TILINCR;
tcache = NULL;
return NULL;
}
+ p = *hm;
if (((h = varval(STRhome)) != STRNULL) &&
- (Strncmp(p = *hm, h, (size_t) (j = (int) Strlen(h))) == 0) &&
+ (Strncmp(p, h, j = Strlen(h)) == 0) &&
(p[j] == '/' || p[j] == '\0')) {
*hm = &p[j];
return STRNULL;
}
for (i = 0; i < tlength; i++)
- if ((Strncmp(p = *hm, tcache[i].home, (size_t)
- (j = tcache[i].hlen)) == 0) && (p[j] == '/' || p[j] == '\0')) {
+ if ((Strncmp(p, tcache[i].home, (j = tcache[i].hlen)) == 0) &&
+ (p[j] == '/' || p[j] == '\0')) {
*hm = &p[j];
return tcache[i].user;
}
return NULL;
}
-#ifdef OBSOLETE
-/*
- * PWP: read a bunch of aliases out of a file QUICKLY. The format
- * is almost the same as the result of saying "alias > FILE", except
- * that saying "aliases > FILE" does not expand non-letters to printable
- * sequences.
- */
-/*ARGSUSED*/
-void
-doaliases(v, c)
- Char **v;
- struct command *c;
-{
- jmp_buf_t oldexit;
- Char **vec, *lp;
- int fd;
- Char buf[BUFSIZE], line[BUFSIZE];
- char tbuf[BUFSIZE + 1], *tmp;
- extern int output_raw; /* PWP: in sh.print.c */
-
- USE(c);
- v++;
- if (*v == 0) {
- output_raw = 1;
- plist(&aliases, VAR_ALL);
- output_raw = 0;
- return;
- }
-
- gflag = 0, tglob(v);
- if (gflag) {
- v = globall(v);
- if (v == 0)
- stderror(ERR_NAME | ERR_NOMATCH);
- }
- else {
- v = gargv = saveblk(v);
- trim(v);
- }
-
- if ((fd = open(tmp = short2str(*v), O_RDONLY|O_LARGEFILE)) < 0)
- stderror(ERR_NAME | ERR_SYSTEM, tmp, strerror(errno));
-
- getexit(oldexit);
- if (setexit() == 0) {
- for (;;) {
- Char *p = NULL;
- int n = 0;
- lp = line;
- for (;;) {
- if (n <= 0) {
- int i;
-
- if ((n = read(fd, tbuf, BUFSIZE)) <= 0) {
-#ifdef convex
- stderror(ERR_SYSTEM, progname, strerror(errno));
-#endif /* convex */
- goto eof;
- }
- for (i = 0; i < n; i++)
- buf[i] = (Char) tbuf[i];
- p = buf;
- }
- n--;
- if ((*lp++ = *p++) == '\n') {
- lp[-1] = '\0';
- break;
- }
- }
- for (lp = line; *lp; lp++) {
- if (isspc(*lp)) {
- *lp++ = '\0';
- while (isspc(*lp))
- lp++;
- vec = (Char **) xmalloc((size_t)
- (2 * sizeof(Char **)));
- vec[0] = Strsave(lp);
- vec[1] = NULL;
- setq(strip(line), vec, &aliases, VAR_READWRITE);
- break;
- }
- }
- }
- }
-
-eof:
- (void) close(fd);
- tw_cmd_free();
- if (gargv)
- blkfree(gargv), gargv = 0;
- resexit(oldexit);
-}
-#endif /* OBSOLETE */
-
/*
* set the shell-level var to 1 or apply change to it.
*/
void
-shlvl(val)
- int val;
+shlvl(int val)
{
char *cp;
@@ -1845,16 +1597,19 @@ shlvl(val)
Unsetenv(STRKSHLVL);
}
else {
- Char buff[BUFSIZE];
-
- (void) Itoa(val, buff, 0, 0);
- set(STRshlvl, Strsave(buff), VAR_READWRITE);
- tsetenv(STRKSHLVL, buff);
+ Char *p;
+
+ p = Itoa(val, 0, 0);
+ cleanup_push(p, xfree);
+ setv(STRshlvl, p, VAR_READWRITE);
+ cleanup_ignore(p);
+ cleanup_until(p);
+ tsetenv(STRKSHLVL, p);
}
}
else {
- set(STRshlvl, SAVE("1"), VAR_READWRITE);
- tsetenv(STRKSHLVL, str2short("1"));
+ setcopy(STRshlvl, STR1, VAR_READWRITE);
+ tsetenv(STRKSHLVL, STR1);
}
}
@@ -1863,8 +1618,7 @@ shlvl(val)
* Try to recover from a read error
*/
int
-fixio(fd, e)
- int fd, e;
+fixio(int fd, int e)
{
switch (e) {
case -1: /* Make sure that the code is reachable */
@@ -1955,9 +1709,7 @@ fixio(fd, e)
* String collation
*/
int
-collate(a, b)
- const Char *a;
- const Char *b;
+collate(const Char *a, const Char *b)
{
int rv;
#ifdef SHORT_STRINGS
@@ -1969,7 +1721,7 @@ collate(a, b)
char *sb = strip(strsave(b));
#endif /* SHORT_STRINGS */
-#if defined(NLS) && !defined(NOSTRCOLL)
+#if defined(NLS) && defined(HAVE_STRCOLL)
errno = 0; /* strcoll sets errno, another brain-damage */
rv = strcoll(sa, sb);
@@ -1980,16 +1732,16 @@ collate(a, b)
* only documented valid errno value for strcoll [EINVAL]
*/
if (errno == EINVAL) {
- xfree((ptr_t) sa);
- xfree((ptr_t) sb);
+ xfree(sa);
+ xfree(sb);
stderror(ERR_SYSTEM, "strcoll", strerror(errno));
}
#else
rv = strcmp(sa, sb);
-#endif /* NLS && !NOSTRCOLL */
+#endif /* NLS && HAVE_STRCOLL */
- xfree((ptr_t) sa);
- xfree((ptr_t) sb);
+ xfree(sa);
+ xfree(sb);
return rv;
}
@@ -2001,27 +1753,23 @@ collate(a, b)
* If it is, splice the header into the argument list and retry.
*/
#define HACKBUFSZ 1024 /* Max chars in #! vector */
-#define HACKVECSZ 128 /* Max words in #! vector */
int
-hashbang(fd, vp)
- int fd;
- Char ***vp;
+hashbang(int fd, Char ***vp)
{
- unsigned char lbuf[HACKBUFSZ];
- char *sargv[HACKVECSZ];
- unsigned char *p, *ws;
- int sargc = 0;
+ struct blk_buf sarg = BLK_BUF_INIT;
+ char lbuf[HACKBUFSZ], *p, *ws;
#ifdef WINNT_NATIVE
int fw = 0; /* found at least one word */
- int first_word = 0;
+ int first_word = 1;
+ char *real;
#endif /* WINNT_NATIVE */
- if (read(fd, (char *) lbuf, HACKBUFSZ) <= 0)
+ if (xread(fd, lbuf, HACKBUFSZ) <= 0)
return -1;
ws = 0; /* word started = 0 */
- for (p = lbuf; p < &lbuf[HACKBUFSZ]; )
+ for (p = lbuf; p < &lbuf[HACKBUFSZ]; ) {
switch (*p) {
case ' ':
case '\t':
@@ -2030,27 +1778,23 @@ hashbang(fd, vp)
#endif /* WINNT_NATIVE */
if (ws) { /* a blank after a word.. save it */
*p = '\0';
-#ifndef WINNT_NATIVE
- if (sargc < HACKVECSZ - 1)
- sargv[sargc++] = ws;
- ws = NULL;
-#else /* WINNT_NATIVE */
- if (sargc < HACKVECSZ - 1) {
- sargv[sargc] = first_word ? NULL: hb_subst(ws);
- if (sargv[sargc] == NULL)
- sargv[sargc] = ws;
- sargc++;
+#ifdef WINNT_NATIVE
+ if (first_word) {
+ real = hb_subst(ws);
+ if (real != NULL)
+ ws = real;
}
- ws = NULL;
fw = 1;
- first_word = 1;
+ first_word = 0;
#endif /* WINNT_NATIVE */
+ bb_append(&sarg, SAVE(ws));
+ ws = NULL;
}
p++;
continue;
case '\0': /* Whoa!! what the hell happened */
- return -1;
+ goto err;
case '\n': /* The end of the line. */
if (
@@ -2059,26 +1803,23 @@ hashbang(fd, vp)
#endif /* WINNT_NATIVE */
ws) { /* terminate the last word */
*p = '\0';
-#ifndef WINNT_NATIVE
- if (sargc < HACKVECSZ - 1)
- sargv[sargc++] = ws;
-#else /* WINNT_NATIVE */
- if (sargc < HACKVECSZ - 1) { /* deal with the 1-word case */
- sargv[sargc] = first_word? NULL : hb_subst(ws);
- if (sargv[sargc] == NULL)
- sargv[sargc] = ws;
- sargc++;
+#ifdef WINNT_NATIVE
+ /* deal with the 1-word case */
+ if (first_word) {
+ real = hb_subst(ws);
+ if (real != NULL)
+ ws = real;
}
#endif /* !WINNT_NATIVE */
+ if (ws)
+ bb_append(&sarg, SAVE(ws));
}
- sargv[sargc] = NULL;
- ws = NULL;
- if (sargc > 0) {
- *vp = blk2short(sargv);
+ if (sarg.len > 0) {
+ *vp = bb_finish(&sarg);
return 0;
}
else
- return -1;
+ goto err;
default:
if (!ws) /* Start a new word? */
@@ -2086,42 +1827,34 @@ hashbang(fd, vp)
p++;
break;
}
+ }
+ err:
+ bb_cleanup(&sarg);
return -1;
}
#endif /* HASHBANG */
#ifdef REMOTEHOST
-static RETSIGTYPE
-palarm(snum)
- int snum;
+static void
+palarm(int snum)
{
USE(snum);
-#ifdef UNRELSIGS
- if (snum)
- (void) sigset(snum, SIG_IGN);
-#endif /* UNRELSIGS */
- (void) alarm(0);
- reset();
+ _exit(1);
}
-
static void
-getremotehost()
+getremotehost(int dest_fd)
{
const char *host = NULL;
#ifdef INET6
struct sockaddr_storage saddr;
- socklen_t len = sizeof(struct sockaddr_storage);
static char hbuf[NI_MAXHOST];
#else
struct hostent* hp;
struct sockaddr_in saddr;
- socklen_t len = sizeof(struct sockaddr_in);
-#endif
-#ifdef HAVE_STRUCT_UTMP_UT_HOST
- char *sptr = NULL;
#endif
+ socklen_t len = sizeof(saddr);
#ifdef INET6
if (getpeername(SHIN, (struct sockaddr *) &saddr, &len) != -1 &&
@@ -2153,6 +1886,7 @@ getremotehost()
/* Avoid empty names and local X displays */
if (name != NULL && *name != '\0' && *name != ':') {
struct in_addr addr;
+ char *sptr;
/* Look for host:display.screen */
/*
@@ -2174,7 +1908,7 @@ getremotehost()
if (sptr != name) {
#ifdef INET6
char *s, *domain;
- char dbuf[MAXHOSTNAMELEN], cbuf[MAXHOSTNAMELEN];
+ char dbuf[MAXHOSTNAMELEN];
struct addrinfo hints, *res = NULL;
memset(&hints, 0, sizeof(hints));
@@ -2185,19 +1919,19 @@ getremotehost()
{
if (getaddrinfo(name, NULL, &hints, &res) != 0)
res = NULL;
- } else if (gethostname(dbuf, sizeof(dbuf) - 1) == 0 &&
- (domain = strchr(dbuf, '.')) != NULL) {
+ } else if (gethostname(dbuf, sizeof(dbuf)) == 0 &&
+ (dbuf[sizeof(dbuf)-1] = '\0', /*FIXME: ugly*/
+ (domain = strchr(dbuf, '.')) != NULL)) {
for (s = strchr(name, '.');
s != NULL; s = strchr(s + 1, '.')) {
if (*(s + 1) != '\0' &&
(ptr = strstr(domain, s)) != NULL) {
- len = s - name;
- if (len + strlen(ptr) >= sizeof(cbuf))
- break;
- strncpy(cbuf, name, len);
- strcpy(cbuf + len, ptr);
+ char *cbuf;
+
+ cbuf = strspl(name, ptr);
if (getaddrinfo(cbuf, NULL, &hints, &res) != 0)
res = NULL;
+ xfree(cbuf);
break;
}
}
@@ -2228,37 +1962,79 @@ getremotehost()
}
#endif
- if (host)
- tsetenv(STRREMOTEHOST, str2short(host));
+ if (host) {
+ size_t left;
-#ifdef HAVE_STRUCT_UTMP_UT_HOST
- if (sptr)
- *sptr = ':';
-#endif
-}
+ left = strlen(host);
+ while (left != 0) {
+ ssize_t res;
+ res = xwrite(dest_fd, host, left);
+ if (res < 0)
+ _exit(1);
+ host += res;
+ left -= res;
+ }
+ }
+ _exit(0);
+}
/*
* From: <lesv@ppvku.ericsson.se> (Lennart Svensson)
*/
-void
-remotehost()
+void
+remotehost(void)
{
- /* Don't get stuck if the resolver does not work! */
- signalfun_t osig = sigset(SIGALRM, palarm);
-
- jmp_buf_t osetexit;
- getexit(osetexit);
-
- (void) alarm(2);
-
- if (setexit() == 0)
- getremotehost();
-
- resexit(osetexit);
-
- (void) alarm(0);
- (void) sigset(SIGALRM, osig);
+ struct sigaction sa;
+ struct strbuf hostname = strbuf_INIT;
+ int fds[2], wait_options, status;
+ pid_t pid, wait_res;
+
+ sa.sa_handler = SIG_DFL; /* Make sure a zombie is created */
+ sigemptyset(&sa.sa_mask);
+ sa.sa_flags = 0;
+ sigaction(SIGCHLD, &sa, NULL);
+ mypipe(fds);
+ pid = fork();
+ if (pid == 0) {
+ sigset_t set;
+ xclose(fds[0]);
+ /* Don't get stuck if the resolver does not work! */
+ signal(SIGALRM, palarm);
+ sigemptyset(&set);
+ sigaddset(&set, SIGALRM);
+ (void)sigprocmask(SIG_UNBLOCK, &set, NULL);
+ (void)alarm(2);
+ getremotehost(fds[1]);
+ /*NOTREACHED*/
+ }
+ xclose(fds[1]);
+ for (;;) {
+ char buf[BUFSIZE];
+ ssize_t res;
+
+ res = xread(fds[0], buf, sizeof(buf));
+ if (res == -1) {
+ hostname.len = 0;
+ wait_options = WNOHANG;
+ goto done;
+ }
+ if (res == 0)
+ break;
+ strbuf_appendn(&hostname, buf, res);
+ }
+ wait_options = 0;
+ done:
+ xclose(fds[0]);
+ while ((wait_res = waitpid(pid, &status, wait_options)) == -1
+ && errno == EINTR)
+ handle_pending_signals();
+ cleanup_push(&hostname, strbuf_cleanup);
+ if (wait_res == pid && WIFEXITED(status) && WEXITSTATUS(status) == 0) {
+ strbuf_terminate(&hostname);
+ tsetenv(STRREMOTEHOST, str2short(hostname.s));
+ }
+ cleanup_until(&hostname);
#ifdef YPBUGS
/* From: casper@fwi.uva.nl (Casper H.S. Dik), for Solaris 2.3 */
@@ -2277,9 +2053,7 @@ remotehost()
* platforms
*/
void
-dotermname(v, c)
- Char **v;
- struct command *c;
+dotermname(Char **v, struct command *c)
{
char *termtype;
/*
@@ -2294,7 +2068,7 @@ dotermname(v, c)
/* no luck - the user didn't provide one and none is
* specified in the environment
*/
- set(STRstatus, Strsave(STR1), VAR_READWRITE);
+ setcopy(STRstatus, STR1, VAR_READWRITE);
return;
}
@@ -2307,9 +2081,8 @@ dotermname(v, c)
*/
if (tgetent(termcap_buffer, termtype) == 1) {
xprintf("%s\n", termtype);
- set(STRstatus, Strsave(STR0), VAR_READWRITE);
- } else {
- set(STRstatus, Strsave(STR1), VAR_READWRITE);
- }
+ setcopy(STRstatus, STR0, VAR_READWRITE);
+ } else
+ setcopy(STRstatus, STR1, VAR_READWRITE);
}
#endif /* WINNT_NATIVE */
diff --git a/contrib/tcsh/tc.h b/contrib/tcsh/tc.h
index 67e46e7..99a643f 100644
--- a/contrib/tcsh/tc.h
+++ b/contrib/tcsh/tc.h
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/tc.h,v 3.6 2004/08/04 17:12:31 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/tc.h,v 3.8 2006/01/12 19:55:38 christos Exp $ */
/*
* tc.h: Tcsh includes
*/
@@ -41,11 +41,40 @@
#include "tc.sig.h"
#include "tc.decls.h"
-extern int tlength;
+extern size_t tlength;
#define FMT_PROMPT 0
#define FMT_WHO 1
#define FMT_HISTORY 2
#define FMT_SCHED 3
+struct strbuf {
+ char *s;
+ size_t len; /* Valid characters */
+ size_t size; /* Allocated characters */
+};
+
+struct Strbuf {
+ Char *s;
+ size_t len; /* Valid characters */
+ size_t size; /* Allocated characters */
+};
+
+/* We don't have explicit initializers for variables with static storage
+ duration, so these values should be equivalent to default initialization. */
+#define strbuf_INIT { NULL, 0, 0 }
+#define Strbuf_INIT { NULL, 0, 0 }
+extern const struct strbuf strbuf_init;
+extern const struct Strbuf Strbuf_init;
+
+/* A string vector in progress */
+struct blk_buf
+{
+ Char **vec;
+ size_t len; /* Valid strings */
+ size_t size; /* Allocated space for string pointers */
+};
+
+#define BLK_BUF_INIT { NULL, 0, 0 }
+
#endif /* _h_tc */
diff --git a/contrib/tcsh/tc.nls.c b/contrib/tcsh/tc.nls.c
index 3b1209e..5a75f68 100644
--- a/contrib/tcsh/tc.nls.c
+++ b/contrib/tcsh/tc.nls.c
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/tc.nls.c,v 3.6 2005/02/15 21:09:02 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/tc.nls.c,v 3.21 2006/09/26 16:45:30 christos Exp $ */
/*
* tc.nls.c: NLS handling
*/
@@ -32,30 +32,49 @@
*/
#include "sh.h"
-RCSID("$Id: tc.nls.c,v 3.6 2005/02/15 21:09:02 christos Exp $")
+RCSID("$tcsh: tc.nls.c,v 3.21 2006/09/26 16:45:30 christos Exp $")
-#ifdef SHORT_STRINGS
+#ifdef WIDE_STRINGS
int
-NLSWidth(c)
- NLSChar c;
+NLSWidth(Char c)
{
# ifdef HAVE_WCWIDTH
- int l;
- if (c & NLS_ILLEGAL)
+ int l;
+ if (c & INVALID_BYTE)
return 1;
l = wcwidth(c);
return l >= 0 ? l : 0;
# else
- return c != 0;
+ return iswprint(c) != 0;
# endif
}
+
+int
+NLSStringWidth(const Char *s)
+{
+ int w = 0, l;
+ Char c;
+
+ while (*s) {
+ c = *s++;
+#ifdef HAVE_WCWIDTH
+ if ((l = wcwidth(c)) < 0)
+ l = 2;
+#else
+ l = iswprint(c) != 0;
+#endif
+ w += l;
+ }
+ return w;
+}
#endif
-#if defined (WIDE_STRINGS) || !defined (SHORT_STRINGS)
Char *
-NLSChangeCase(Char *p, int mode)
+NLSChangeCase(const Char *p, int mode)
{
- Char c, *op = p, *n, c2 = 0;
+ Char c, *n, c2 = 0;
+ const Char *op = p;
+
for (; (c = *p) != 0; p++) {
if (mode == 0 && Islower(c)) {
c2 = Toupper(c);
@@ -73,231 +92,27 @@ NLSChangeCase(Char *p, int mode)
}
int
-NLSExtend(Char *from, int max, int num)
-{
- (void)from;
- num = abs (num);
- if (num > max)
- num = max;
- return num;
-}
-#endif
-
-#ifdef WIDE_STRINGS
-
-int
-NLSStringWidth(Char *s)
-{
- int w = 0;
- while (*s)
- w += wcwidth(*s++);
- return w;
-}
-
-#elif defined (SHORT_STRINGS)
-
-int
-NLSFrom(const Char *p, size_t l, NLSChar *cp)
-{
- size_t i;
- int len;
- wchar_t c;
- char b[MB_LEN_MAX];
-
- if (l == NLSZEROT) {
- for (i = 0; i < MB_CUR_MAX && *p; i++)
- b[i] = p[i] & CHAR;
- } else {
- for (i = 0; i < MB_CUR_MAX && i < l; i++)
- b[i] = p[i] & CHAR;
- }
- mbtowc(0, 0, 0);
- len = rt_mbtowc(&c, b, i);
- if (len <= 0) {
- if (cp)
- *cp = *p ? *p | NLS_ILLEGAL : 0;
- return 1;
- }
- if (cp)
- *cp = (int)c;
- return len;
-}
-
-int
-NLSFinished(Char *p, size_t l, eChar extra)
-{
- size_t i, r;
- wchar_t c;
- char b[MB_LEN_MAX + 1], back[MB_LEN_MAX];
- mbstate_t state;
- for (i = 0; i < MB_CUR_MAX && i < l; i++)
- b[i] = p[i];
- if (extra != CHAR_ERR)
- b[i++] = extra;
- memset(&state, 0, sizeof(state));
- r = mbrtowc((wchar_t *)&c, b, i, (mbstate_t *)&state);
- if (r == (size_t)-2)
- return 0;
- if (r == (size_t)-1 || (size_t)wctomb(back, c) != r ||
- memcmp(b, back, r) != 0)
- return -1;
- return r == i ? 1 : 2;
-}
-
-int
-NLSChars(Char *s)
-{
- int l;
- for (l = 0; *s; l++)
- s += NLSSize(s, -1);
- return l;
-}
-
-int
-NLSStringWidth(Char *s)
-{
- int w = 0;
- NLSChar c;
- while (*s) {
- s += NLSFrom(s, NLSZEROT, &c);
- w += NLSWidth(c);
- }
- return w;
-}
-
-int
-NLSTo(Char *p, NLSChar c)
-{
- char b[MB_LEN_MAX];
- int i, j;
-
- if (c & NLS_ILLEGAL) {
- if (p)
- *p = c;
- return 1;
- }
- i = wctomb(b, (wchar_t)c);
- if (i == -1)
- return 0;
- if (p)
- for (j = 0; j < i; j++)
- p[j] = b[j];
- return i;
-}
-
-
-int
-NLSExtend(Char *from, int max, int num)
-{
- int l, n, i;
- Char *p;
-
- if (num == 0)
- return 0;
- if (num > 0) {
- n = 0;
- while (num > 0 && max > 0) {
- l = NLSSize(from, max);
- n += l;
- from += l;
- max -= l;
- num--;
- }
- return n;
- }
- from -= max;
- p = from;
- i = max;
- n = 0;
- while (i > 0) {
- l = NLSSize(p, i);
- p += l;
- i -= l;
- n++;
- }
- if (n >= -num)
- n += num;
- else
- n = 0;
- i = max;
- while (n > 0) {
- l = NLSSize(from, max);
- from += l;
- max -= l;
- i -= l;
- n--;
- }
- return i;
-}
-
-void
-NLSQuote(Char *cp)
-{
- int l;
- while (*cp) {
- l = NLSSize(cp, -1);
- cp++;
- while (l-- > 1)
- *cp++ |= QUOTE;
- }
-}
-
-Char *
-NLSChangeCase(Char *p, int mode)
-{
- Char *n, *op = p;
- NLSChar c, c2 = 0;
- int l, l2;
-
- while (*p) {
- l = NLSFrom(p, NLSZEROT, &c);
- if (mode == 0 && iswlower((wint_t)c)) {
- c2 = (int)towupper((wint_t)c);
- break;
- } else if (mode && iswupper((wint_t)c)) {
- c2 = (int)towlower((wint_t)c);
- break;
- }
- p += l;
- }
- if (!*p)
- return 0;
- l2 = NLSTo((Char *)0, c2);
- n = (Char *)xmalloc((size_t)((op - p + l2 + Strlen(p + l) + 1) * sizeof(Char)));
- if (p != op)
- memcpy(n, op, (p - op) * sizeof(Char));
- NLSTo(n + (p - op), c2);
- memcpy(n + (p - op + l2), p + l, (Strlen(p + l) + 1) * sizeof(Char));
- return n;
-}
-#endif
-
-int
-NLSClassify(c, nocomb)
- NLSChar c;
- int nocomb;
+NLSClassify(Char c, int nocomb)
{
int w;
- if (c & NLS_ILLEGAL)
+ if (c & INVALID_BYTE)
return NLSCLASS_ILLEGAL;
w = NLSWidth(c);
- if (w > 0 || (Iswprint(c) && !nocomb))
+ if ((w > 0 && !(Iscntrl(c) && (c & CHAR) < 0x100)) || (Isprint(c) && !nocomb))
return w;
- if (Iswcntrl(c) && c < 0x100) {
+ if (Iscntrl(c) && (c & CHAR) < 0x100) {
if (c == '\n')
return NLSCLASS_NL;
if (c == '\t')
return NLSCLASS_TAB;
-#ifndef ASCII
- if (!Isupper(_toebcdic[_toascii[c]|0100]) && !strchr("@[\\]^_", _toebcdic[_toascii[c]|0100]))
- return NLSCLASS_ILLEGAL;
-#endif
return NLSCLASS_CTRL;
}
+#ifdef WIDE_STRINGS
if (c >= 0x1000000)
return NLSCLASS_ILLEGAL4;
if (c >= 0x10000)
return NLSCLASS_ILLEGAL3;
+#endif
if (c >= 0x100)
return NLSCLASS_ILLEGAL2;
return NLSCLASS_ILLEGAL;
diff --git a/contrib/tcsh/tc.nls.h b/contrib/tcsh/tc.nls.h
index 355f60f..d681a9e 100644
--- a/contrib/tcsh/tc.nls.h
+++ b/contrib/tcsh/tc.nls.h
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/tc.nls.h,v 3.9 2005/03/03 15:52:20 kim Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/tc.nls.h,v 3.13 2006/02/14 14:07:36 christos Exp $ */
/*
* tc.nls.h: NLS support
*
@@ -36,55 +36,16 @@
#include "sh.h"
-#define NLSZEROT ((size_t)-1)
-
#ifdef WIDE_STRINGS
-
-# define NLSSize(s, l) 1
-# define NLSFrom(s, l, cp) (USE (l), (*(cp) = *(s) & CHAR), 1)
-# define NLSFinished(s, l, c) (l != 0 && c != CHAR_ERR ? 2 : 1)
-# define NLSChars(s) Strlen(s)
-# define NLSQuote(s)
-# define TRIM_AND_EXTEND(s, c) (c &= TRIM)
-
-extern int NLSWidth __P((NLSChar));
-extern int NLSStringWidth __P((Char *));
-
-#define NLS_ILLEGAL INVALID_BYTE
-
+extern int NLSWidth(Char);
+extern int NLSStringWidth (const Char *);
#else
-# ifdef SHORT_STRINGS
-
-extern int NLSFrom __P((const Char *, size_t, NLSChar *));
-extern int NLSFinished __P((Char *, size_t, eChar));
-extern int NLSChars __P((Char *));
-extern int NLSStringWidth __P((Char *));
-extern int NLSWidth __P((NLSChar));
-extern int NLSTo __P((Char *, NLSChar));
-extern void NLSQuote __P((Char *));
-
-#define NLSSize(s, l) NLSFrom(s, l, (NLSChar *)0)
-#define TRIM_AND_EXTEND(s, c) (s += NLSFrom(s - 1, NLSZEROT, &c) - 1)
-#define NLS_ILLEGAL 0x40000000
-
-
-# else
-# define NLSSize(s, l) 1
-# define NLSFrom(s, l, cp) (USE (l), (*(cp) = *(s) & CHAR), 1)
-# define NLSFinished(s, l, c) (l != 0 && c != CHAR_ERR ? 2 : 1)
-# define NLSChars(s) Strlen(s)
-# define NLSStringWidth(s) Strlen(s)
-# define NLSWidth(c) 1
-# define NLSQuote(s)
-
-# define TRIM_AND_EXTEND(s, c) (c &= TRIM)
-# define NLS_ILLEGAL 0x40000000
-# endif
+# define NLSStringWidth(s) Strlen(s)
+# define NLSWidth(c) 1
#endif
-extern int NLSExtend __P((Char *, int, int));
-extern Char *NLSChangeCase __P((Char *, int));
-extern int NLSClassify __P((NLSChar, int));
+extern Char *NLSChangeCase (const Char *, int);
+extern int NLSClassify (Char, int);
#define NLSCLASS_CTRL (-1)
#define NLSCLASS_TAB (-2)
diff --git a/contrib/tcsh/tc.os.c b/contrib/tcsh/tc.os.c
index fce0110..7738321 100644
--- a/contrib/tcsh/tc.os.c
+++ b/contrib/tcsh/tc.os.c
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/tc.os.c,v 3.58 2005/01/18 20:24:51 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/tc.os.c,v 3.69 2006/08/24 20:56:31 christos Exp $ */
/*
* tc.os.c: OS Dependent builtin functions
*/
@@ -32,7 +32,7 @@
*/
#include "sh.h"
-RCSID("$Id: tc.os.c,v 3.58 2005/01/18 20:24:51 christos Exp $")
+RCSID("$tcsh: tc.os.c,v 3.69 2006/08/24 20:56:31 christos Exp $")
#include "tw.h"
#include "ed.h"
@@ -78,19 +78,17 @@ static Char *syspaths[] = {STRKPATH, STRCPATH, STRLPATH, STRMPATH,
/*ARGSUSED*/
void
-dosetpath(arglist, c)
- Char **arglist;
- struct command *c;
+dosetpath(Char **arglist, struct command *c)
{
extern char *getenv();
- sigmask_t omask;
Char **pathvars, **cmdargs;
char **spaths, **cpaths, **cmds;
char *tcp;
unsigned int npaths, ncmds;
int i, sysflag;
- omask = sigsetmask(sigmask(SIGINT));
+ pintr_disabled++;
+ cleanup_push(&pintr_disabled, disabled_cleanup);
/*
* setpath(3) uses stdio and we want 0, 1, 2 to work...
@@ -121,20 +119,20 @@ dosetpath(arglist, c)
/* note that npaths != 0 */
- spaths = (char **) xmalloc((size_t) npaths * sizeof *spaths);
- setzero((char *) spaths, npaths * sizeof *spaths);
- cpaths = (char **) xmalloc((size_t) (npaths + 1) * sizeof *cpaths);
- setzero((char *) cpaths, (npaths + 1) * sizeof *cpaths);
- cmds = (char **) xmalloc((size_t) (ncmds + 1) * sizeof *cmds);
- setzero((char *) cmds, (ncmds + 1) * sizeof *cmds);
+ spaths = xmalloc(npaths * sizeof *spaths);
+ setzero(spaths, npaths * sizeof *spaths);
+ cpaths = xmalloc((npaths + 1) * sizeof *cpaths);
+ setzero(cpaths, (npaths + 1) * sizeof *cpaths);
+ cmds = xmalloc((ncmds + 1) * sizeof *cmds);
+ setzero(cmds, (ncmds + 1) * sizeof *cmds);
for (i = 0; i < npaths; i++) {
char *val = getenv(short2str(pathvars[i]));
if (val == NULL)
val = "";
- spaths[i] = (char *) xmalloc((size_t) (Strlen(pathvars[i]) +
- strlen(val) + 2) * sizeof **spaths);
+ spaths[i] = xmalloc((Strlen(pathvars[i]) + strlen(val) + 2) *
+ sizeof **spaths);
(void) strcpy(spaths[i], short2str(pathvars[i]));
(void) strcat(spaths[i], "=");
(void) strcat(spaths[i], val);
@@ -142,12 +140,11 @@ dosetpath(arglist, c)
}
for (i = 0; i < ncmds; i++) {
- Char *val = globone(cmdargs[i], G_ERROR);
+ Char *val = globone(cmdargs[i], G_ERROR);/*FIXRESET*/
if (val == NULL)
goto abortpath;
- cmds[i] = (char *) xmalloc((size_t) Strlen(val) + 1);
- (void) strcpy(cmds[i], short2str(val));
+ cmds[i] = strsave(short2str(val));
}
@@ -155,20 +152,17 @@ dosetpath(arglist, c)
abortpath:
if (spaths) {
for (i = 0; i < npaths; i++)
- if (spaths[i])
- xfree((ptr_t) spaths[i]);
- xfree((ptr_t) spaths);
+ xfree(spaths[i]);
+ xfree(spaths);
}
- if (cpaths)
- xfree((ptr_t) cpaths);
+ xfree(cpaths);
if (cmds) {
for (i = 0; i < ncmds; i++)
- if (cmds[i])
- xfree((ptr_t) cmds[i]);
- xfree((ptr_t) cmds);
+ xfree(cmds[i]);
+ xfree(cmds);
}
- (void) sigsetmask(omask);
+ cleanup_until(&pintr_disabled);
donefds();
return;
}
@@ -181,16 +175,16 @@ abortpath:
if (val && *val == '=') {
*val++ = '\0';
- tsetenv(name, val);
+ tsetenv(name, val);/*FIXRESET*/
if (Strcmp(name, STRKPATH) == 0) {
- importpath(val);
+ importpath(val);/*FIXRESET*/
if (havhash)
- dohash(NULL, NULL);
+ dohash(NULL, NULL);/*FIXRESET*/
}
*--val = '=';
}
}
- (void) sigsetmask(omask);
+ cleanup_until(&pintr_disabled);
donefds();
}
#endif /* MACH */
@@ -201,9 +195,7 @@ abortpath:
#ifdef TCF
/* ARGSUSED */
void
-dogetxvers(v, c)
- Char **v;
- struct command *c;
+dogetxvers(Char **v, struct command *c)
{
char xvers[MAXPATHLEN];
@@ -215,9 +207,7 @@ dogetxvers(v, c)
/*ARGSUSED*/
void
-dosetxvers(v, c)
- Char **v;
- struct command *c;
+dosetxvers(Char **v, struct command *c)
{
char *xvers;
@@ -270,8 +260,7 @@ static struct xc_cpu_t {
* our local hack table, stolen from x.out.h
*/
static char *
-getxcode(xcid)
- short xcid;
+getxcode(short xcid)
{
int i;
@@ -282,8 +271,7 @@ getxcode(xcid)
}
static short
-getxid(xcname)
- char *xcname;
+getxid(char *xcname)
{
int i;
@@ -296,9 +284,7 @@ getxid(xcname)
/*ARGSUSED*/
void
-dogetspath(v, c)
- Char **v;
- struct command *c;
+dogetspath(Char **v, struct command *c)
{
int i, j;
sitepath_t p[MAXSITE];
@@ -342,9 +328,7 @@ dogetspath(v, c)
/*ARGSUSED*/
void
-dosetspath(v, c)
- Char **v;
- struct command *c;
+dosetspath(Char **v, struct command *c)
{
int i;
short j;
@@ -388,8 +372,7 @@ dosetspath(v, c)
* Return the site name where the process is running
*/
char *
-sitename(pid)
- pid_t pid;
+sitename(pid_t pid)
{
siteno_t ss;
struct sf *st;
@@ -401,16 +384,14 @@ sitename(pid)
}
static int
-migratepid(pid, new_site)
- pid_t pid;
- siteno_t new_site;
+migratepid(pit_t pid, siteno_t new_site)
{
struct sf *st;
int need_local;
need_local = (pid == 0) || (pid == getpid());
- if (kill3((pid_t) pid, SIGMIGRATE, new_site) < 0) {
+ if (kill3(pid, SIGMIGRATE, new_site) < 0) {
xprintf("%d: %s\n", pid, strerror(errno));
return (-1);
}
@@ -435,9 +416,7 @@ migratepid(pid, new_site)
/*ARGSUSED*/
void
-domigrate(v, c)
- Char **v;
- struct command *c;
+domigrate(Char **v, struct command *c)
{
struct sf *st;
char *s;
@@ -446,18 +425,13 @@ domigrate(v, c)
int err1 = 0;
int pid = 0;
siteno_t new_site = 0;
- sigmask_t omask;
-#ifdef BSDSIGS
- omask = sigmask(SIGCHLD);
- if (setintr)
- omask |= sigmask(SIGINT);
- omask = sigblock(omask) & ~omask;
-#else
- if (setintr)
- (void) sighold(SIGINT);
- (void) sighold(SIGCHLD);
-#endif /* BSDSIGS */
+ pchild_disabled++;
+ cleanup_push(&pchild_disabled, disabled_cleanup);
+ if (setintr) {
+ pintr_disabled++;
+ cleanup_push(&pintr_disabled, disabled_cleanup);
+ }
++v;
if (*v[0] == '-') {
@@ -470,6 +444,7 @@ domigrate(v, c)
*/
dont_free = 1;
if ((st = sfname(s)) == NULL) {
+ dont_free = 0;
setname(s);
stderror(ERR_NAME | ERR_STRING, CGETS(23, 7, "Site not found"));
}
@@ -483,21 +458,16 @@ domigrate(v, c)
err1++;
}
else {
- gflag = 0, tglob(v);
- if (gflag) {
- v = globall(v);
- if (v == 0)
- stderror(ERR_NAME | ERR_NOMATCH);
- }
- else {
- v = gargv = saveblk(v);
- trim(v);
- }
+ Char **globbed;
+
+ v = glob_all_or_error(v);
+ globbed = v;
+ cleanup_push(globbed, blk_cleanup);
while (v && (cp = *v)) {
if (*cp == '%') {
pp = pfind(cp);
- if (kill3((pid_t) - pp->p_jobid, SIGMIGRATE, new_site) < 0) {
+ if (kill3(- pp->p_jobid, SIGMIGRATE, new_site) < 0) {
xprintf("%S: %s\n", cp, strerror(errno));
err1++;
}
@@ -511,18 +481,11 @@ domigrate(v, c)
}
v++;
}
- if (gargv)
- blkfree(gargv), gargv = 0;
+ cleanup_until(globbed);
}
done:
-#ifdef BSDSIGS
- (void) sigsetmask(omask);
-#else
- (void) sigrelse(SIGCHLD);
- if (setintr)
- (void) sigrelse(SIGINT);
-#endif /* BSDSIGS */
+ cleanup_until(&pchild_disabled);
if (err1)
stderror(ERR_SILENT);
}
@@ -534,9 +497,7 @@ done:
***/
#if defined(_CRAY) && !defined(_CRAYMPP)
void
-dodmmode(v, c)
- Char **v;
- struct command *c;
+dodmmode(Char **v, struct command *c)
{
Char *cp = v[1];
@@ -551,7 +512,7 @@ dodmmode(v, c)
}
else {
if (cp[1] != '\0')
- stderror(ERR_NAME | ERR_STRING,
+ stderror(ERR_NAME | ERR_STRING,
CGETS(23, 30, "Too many arguments"));
else
switch(*cp) {
@@ -562,7 +523,7 @@ dodmmode(v, c)
dmmode(1);
break;
default:
- stderror(ERR_NAME | ERR_STRING,
+ stderror(ERR_NAME | ERR_STRING,
CGETS(23, 31, "Invalid argument"));
}
}
@@ -583,31 +544,33 @@ dodmmode(v, c)
static jmp_buf sigsys_buf;
-static RETSIGTYPE
-catch_sigsys()
+static void
+catch_sigsys(void)
{
+ sigset_t set;
+ sigemptyset(&set, SIGSYS);
+ (void)sigprocmask(SIG_UNBLOCK, &set, NULL);
longjmp(sigsys_buf, 1);
}
/*ARGSUSED*/
void
-dowarp(v, c)
- Char **v;
- struct command *c;
+dowarp(Char **v, struct command *c)
{
int warp, oldwarp;
struct warpent *we;
- void (*old_sigsys_handler) () = 0;
+ volatile struct sigaction old_sigsys_handler;
char *newwarp;
if (setjmp(sigsys_buf)) {
- signal(SIGSYS, old_sigsys_handler);
- stderror(ERR_NAME | ERR_STRING,
+ sigaction(SIGSYS, &old_sigsys_handler, NULL);
+ stderror(ERR_NAME | ERR_STRING,
CGETS(23, 8, "You're trapped in a universe you never made"));
return;
}
- old_sigsys_handler = signal(SIGSYS, catch_sigsys);
+ sigaction(SIGSYS, NULL, &old_sigsys_handler);
+ signal(SIGSYS, catch_sigsys);
warp = getwarp();
@@ -640,8 +603,7 @@ dowarp(v, c)
stderror(ERR_NAME | ERR_STRING, CGETS(23, 11, "Setwarp failed"));
}
}
- signal(SIGSYS, old_sigsys_handler);
- return;
+ sigaction(SIGSYS, &old_sigsys_handler, NULL);
}
#endif /* WARP */
@@ -650,18 +612,22 @@ dowarp(v, c)
***/
/* Added, DAS DEC-90. */
#if defined(masscomp) || defined(_CX_UX)
+static void
+setuniverse_cleanup(void *xbuf)
+{
+ char *buf;
+
+ buf = xbuf;
+ setuniverse(buf);
+}
+
/*ARGSUSED*/
void
-douniverse(v, c)
- Char **v;
- struct command *c;
+douniverse(Char **v, struct command *c)
{
Char *cp = v[1];
Char *cp2; /* dunno how many elements v comes in with */
char ubuf[100];
-#ifdef BSDSIGS
- sigmask_t omask = 0;
-#endif /* BSDSIGS */
if (cp == 0) {
(void) getuniverse(ubuf);
@@ -676,22 +642,17 @@ douniverse(v, c)
else {
(void) getuniverse(ubuf);
if (*cp == '\0' || setuniverse(short2str(cp)) != 0)
- stderror(ERR_NAME | ERR_STRING, CGETS(23, 12, "Illegal universe"));
- if (setintr)
-#ifdef BSDSIGS
- omask = sigblock(sigmask(SIGINT)) & ~sigmask(SIGINT);
-#else /* !BSDSIGS */
- (void) sighold(SIGINT);
-#endif /* BSDSIGS */
+ stderror(ERR_NAME | ERR_STRING, CGETS(23, 12, "Illegal universe"));
+ cleanup_push(ubuf, setuniverse_cleanup);
+ if (setintr) {
+ pintr_disabled++;
+ cleanup_push(&pintr_disabled, disabled_cleanup);
+ }
lshift(v, 2);
if (setintr)
-#ifdef BSDSIGS
- (void) sigsetmask(omask);
-#else /* !BSDSIGS */
- (void) sigrelse (SIGINT);
-#endif /* BSDSIGS */
+ cleanup_until(&pintr_disabled);
reexecute(c);
- (void) setuniverse(ubuf);
+ cleanup_until(ubuf);
}
}
}
@@ -798,44 +759,33 @@ bs2cmdlist(char *str)
}
/*ARGSUSED*/
void
-dobs2cmd(v, c)
- Char **v;
- struct command *c;
+dobs2cmd(Char **v, struct command *c)
{
- Char *cp;
+ Char *cp, **globbed;
int i = 0, len = 0;
char *cmd = NULL;
int pvec[2];
struct command faket;
Char *fakecom[2];
char tibuf[BUFSIZE];
- int icnt;
+ int icnt, old_pintr_disabled;
static const Char STRbs2cmd[] = { 'b','s','2','c','m','d','\0' };
- if (setintr)
-#ifdef BSDSIGS
- (void) sigsetmask(sigblock((sigmask_t) 0) & ~sigmask(SIGINT));
-#else /* !BSDSIGS */
- (void) sigrelse (SIGINT);
-#endif /* BSDSIGS */
v++;
- gflag = 0, tglob(v);
- if (gflag) {
- v = globall(v);
- if (v == 0)
- stderror(ERR_NAME | ERR_NOMATCH);
- }
- else {
- v = gargv = saveblk(v);
- trim(v);
- }
+ if (setintr)
+ pintr_push_enable(&old_pintr_disabled);
+ v = glob_all_or_error(v);
+ if (setintr)
+ cleanup_until(&old_pintr_disabled);
+ globbed = v;
+ cleanup_push(globbed, blk_cleanup);
/* First round: count the string lengths */
for (i=0; v[i]; ++i) {
- len += s_strlen(v[i]) + (v[i+1] != NULL);
+ len += Strlen(v[i]) + (v[i+1] != NULL);
}
- cmd = xmalloc(len+1); /* 1 for the final '\0' */
+ cmd = xmalloc(len+1); /* 1 for the final '\0' *//* FIXME: memory leak? */
/* 2nd round: fill cmd buffer */
i = 0;
@@ -857,122 +807,113 @@ dobs2cmd(v, c)
faket.t_drit = 0;
faket.t_dspr = 0;
faket.t_dcom = fakecom;
- fakecom[0] = STRbs2cmd;
+ fakecom[0] = (Char *)STRbs2cmd;
fakecom[1] = 0;
mypipe(pvec);
+ cleanup_push(&pvec[0], open_cleanup);
+ cleanup_push(&pvec[1], open_cleanup);
if (pfork(&faket, -1) == 0) {
+ sigset_t set;
/* child */
- (void) close(pvec[0]);
+ xclose(pvec[0]);
(void) dmove(pvec[1], 1);
(void) dmove(SHDIAG, 2);
initdesc();
-/* closem();*/
+ sigemptyset(&set);
+ sigaddset(&set, SIGINT);
+ (void)sigprocmask(SIG_UNBLOCK, &set, NULL);
#ifdef SIGTSTP
- (void) sigignore(SIGTSTP);
+ signal(SIGTSTP, SIG_IGN);
#endif
#ifdef SIGTTIN
- (void) sigignore(SIGTTIN);
+ signal(SIGTTIN, SIG_IGN);
#endif
#ifdef SIGTTOU
- (void) sigignore(SIGTTOU);
+ signal(SIGTTOU, SIG_IGN);
#endif
xexit(bs2cmdlist(cmd));
}
- (void) close(pvec[1]);
+ cleanup_until(&pvec[1]);
for(;;) {
- do
- icnt = read(pvec[0], tibuf, BUFSIZE);
- while (icnt == -1 && errno == EINTR);
+ int old_pintr_disabled;
+
+ if (setintr)
+ pintr_push_enable(&old_pintr_disabled);
+ icnt = xread(pvec[0], tibuf, sizeof(tibuf));
+ if (setintr)
+ cleanup_until(&old_pintr_disabled);
if (icnt <= 0)
break;
for (i = 0; i < icnt; i++)
xputchar((unsigned char) tibuf[i]);
}
- (void) close(pvec[0]);
+ cleanup_until(&pvec[0]);
pwait();
flush();
- if (setintr)
-#ifdef BSDSIGS
- (void) sigblock(sigmask(SIGINT));
-#else /* !BSDSIGS */
- (void) sighold(SIGINT);
-#endif /* BSDSIGS */
- if (gargv)
- blkfree(gargv), gargv = 0;
+ cleanup_until(globbed);
}
#endif /* _OSD_POSIX */
#if defined(_CX_UX)
+static void
+setuniverse_cleanup(void *xbuf)
+{
+ char *buf;
+
+ buf = xbuf;
+ setuniverse(buf);
+}
+
/*ARGSUSED*/
void
-doatt(v, c)
- Char **v;
- struct command *c;
+doatt(Char **v, struct command *c)
{
Char *cp = v[1];
char ubuf[100];
-#ifdef BSDSIGS
- sigmask_t omask = 0;
-#endif /* BSDSIGS */
if (cp == 0)
(void) setuniverse("att");
else {
(void) getuniverse(ubuf);
(void) setuniverse("att");
- if (setintr)
-#ifdef BSDSIGS
- omask = sigblock(sigmask(SIGINT)) & ~sigmask(SIGINT);
-#else /* !BSDSIGS */
- (void) sighold(SIGINT);
-#endif /* BSDSIGS */
+ cleanup_push(ubuf, setuniverse_cleanup);
+ if (setintr) {
+ pintr_disabled++;
+ cleanup_push(&pintr_disabled, disabled_cleanup);
+ }
lshift(v, 1);
if (setintr)
-#ifdef BSDSIGS
- (void) sigsetmask(omask);
-#else /* !BSDSIGS */
- (void) sigrelse (SIGINT);
-#endif /* BSDSIGS */
+ cleanup_until(&pintr_disabled);
reexecute(c);
- (void) setuniverse(ubuf);
+ cleanup_until(ubuf);
}
}
/*ARGSUSED*/
void
-doucb(v, c)
- Char **v;
- struct command *c;
+doucb(Char **v, struct command *c)
{
Char *cp = v[1];
char ubuf[100];
-#ifdef BSDSIGS
- sigmask_t omask = 0;
-#endif /* BSDSIGS */
if (cp == 0)
(void) setuniverse("ucb");
else {
(void) getuniverse(ubuf);
(void) setuniverse("ucb");
- if (setintr)
-#ifdef BSDSIGS
- omask = sigblock(sigmask(SIGINT)) & ~sigmask(SIGINT);
-#else /* !BSDSIGS */
- (void) sighold(SIGINT);
-#endif /* BSDSIGS */
+ cleanup_push(ubuf, setuniverse_cleanup);
+ if (setintr) {
+ pintr_disabled++;
+ cleanup_push(&pintr_disabled, disabled_cleanup);
+ }
lshift(v, 1);
if (setintr)
-#ifdef BSDSIGS
- (void) sigsetmask(omask);
-#else /* !BSDSIGS */
- (void) sigrelse (SIGINT);
-#endif /* BSDSIGS */
+ cleanup_until(&pintr_disabled);
reexecute(c);
- (void) setuniverse(ubuf);
+ cleanup_until(ubuf);
}
}
#endif /* _CX_UX */
@@ -982,8 +923,8 @@ doucb(v, c)
* Compute the difference in process stats.
*/
void
-pr_stat_sub(p2, p1, pr)
- struct process_stats *p2, *p1, *pr;
+pr_stat_sub(struct process_stats *p2, struct process_stats *p1,
+ struct process_stats *pr)
{
pr->ps_utime.tv_sec = p2->ps_utime.tv_sec - p1->ps_utime.tv_sec;
pr->ps_utime.tv_usec = p2->ps_utime.tv_usec - p1->ps_utime.tv_usec;
@@ -1022,13 +963,10 @@ pr_stat_sub(p2, p1, pr)
#ifndef HAVE_MEMSET
/* This is a replacement for a missing memset function */
-ptr_t xmemset(loc, value, len)
- ptr_t loc;
- int len;
- size_t value;
+void *xmemset(void *loc, int value, size_t len)
{
- char *ptr = (char *) loc;
-
+ char *ptr = loc;
+
while (len--)
*ptr++ = value;
return loc;
@@ -1042,14 +980,11 @@ ptr_t xmemset(loc, value, len)
* Unlike memcpy(), it handles overlaps between source and
* destination memory
*/
-ptr_t
-xmemmove(vdst, vsrc, len)
- ptr_t vdst;
- const ptr_t vsrc;
- size_t len;
+void *
+xmemmove(void *vdst, const void *vsrc, size_t len)
{
- const char *src = (const char *) vsrc;
- char *dst = (char *) vdst;
+ const char *src = vsrc;
+ char *dst = vdst;
if (src == dst)
return vdst;
@@ -1071,9 +1006,8 @@ xmemmove(vdst, vsrc, len)
#ifndef WINNT_NATIVE
#ifdef NEEDtcgetpgrp
-int
-xtcgetpgrp(fd)
- int fd;
+pid_t
+xtcgetpgrp(int fd)
{
int pgrp;
@@ -1090,8 +1024,7 @@ xtcgetpgrp(fd)
* this out.
*/
int
-xtcsetpgrp(fd, pgrp)
- int fd, pgrp;
+xtcsetpgrp(int fd, int pgrp)
{
return ioctl(fd, TIOCSPGRP, (ioctl_t) &pgrp);
}
@@ -1102,18 +1035,18 @@ xtcsetpgrp(fd, pgrp)
#ifdef YPBUGS
void
-fix_yp_bugs()
+fix_yp_bugs(void)
{
char *mydomain;
- extern int yp_get_default_domain __P((char **));
+ extern int yp_get_default_domain (char **);
/*
* PWP: The previous version assumed that yp domain was the same as the
* internet name domain. This isn't allways true. (Thanks to Mat Landau
* <mlandau@bbn.com> for the original version of this.)
*/
if (yp_get_default_domain(&mydomain) == 0) { /* if we got a name */
- extern void yp_unbind __P((const char *));
+ extern void yp_unbind (const char *);
yp_unbind(mydomain);
}
@@ -1123,9 +1056,9 @@ fix_yp_bugs()
#ifdef STRCOLLBUG
void
-fix_strcoll_bug()
+fix_strcoll_bug(void)
{
-#if defined(NLS) && !defined(NOSTRCOLL)
+#if defined(NLS) && defined(HAVE_STRCOLL)
/*
* SunOS4 checks the file descriptor from openlocale() for <= 0
* instead of == -1. Someone should tell sun that file descriptor 0
@@ -1143,12 +1076,12 @@ fix_strcoll_bug()
static char *root = "/";
if (!didfds)
- fd = open(root, O_RDONLY|O_LARGEFILE);
+ fd = xopen(root, O_RDONLY|O_LARGEFILE);
(void) strcoll(root, root);
if (fd != -1)
- (void) close(fd);
+ xclose(fd);
#endif
}
#endif /* STRCOLLBUG */
@@ -1159,18 +1092,18 @@ fix_strcoll_bug()
#endif /* OREO */
void
-osinit()
+osinit(void)
{
#ifdef OREO
set42sig();
setcompat(getcompat() & ~COMPAT_EXEC);
- sigignore(SIGIO); /* ignore SIGIO */
+ signal(SIGIO, SIG_IGN); /* ignore SIGIO */
#endif /* OREO */
#ifdef aiws
{
struct sigstack inst;
- inst.ss_sp = (char *) xmalloc((size_t) 4192) + 4192;
+ inst.ss_sp = xmalloc(4192) + 4192;
inst.ss_onstack = 0;
sigstack(&inst, NULL);
}
@@ -1190,17 +1123,18 @@ osinit()
}
#ifndef HAVE_STRERROR
+extern int sys_nerr;
+extern char *sys_errlist[];
char *
-xstrerror(i)
- int i;
+xstrerror(int i)
{
- static char errbuf[128];
-
if (i >= 0 && i < sys_nerr) {
return sys_errlist[i];
} else {
- (void) xsnprintf(errbuf, sizeof(errbuf),
- CGETS(23, 13, "Unknown Error: %d"), i);
+ static char *errbuf; /* = NULL; */
+
+ xfree(errbuf);
+ errbuf = xasprintf(CGETS(23, 13, "Unknown Error: %d"), i);
return errbuf;
}
}
@@ -1212,9 +1146,7 @@ xstrerror(i)
# endif /* !_MINIX && !__EMX__ && !WINNT_NATIVE */
int
-xgethostname(name, namlen)
- char *name;
- int namlen;
+xgethostname(char *name, int namlen)
{
# if !defined(_MINIX) && !defined(__EMX__) && !defined(WINNT_NATIVE)
int i, retval;
@@ -1255,8 +1187,7 @@ xgethostname(name, namlen)
# include <lib.h>
# endif /* _MINIX && NICE */
int
-xnice(incr)
- int incr;
+xnice(int incr)
{
#if defined(_MINIX) && defined(NICE)
return callm1(MM, NICE, incr, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR);
@@ -1267,7 +1198,7 @@ xnice(incr)
#endif /* !HAVE_NICE */
#ifndef HAVE_GETCWD
-static char *strnrcpy __P((char *, char *, size_t));
+static char *strnrcpy (char *, char *, size_t);
/* xgetcwd():
* Return the pathname of the current directory, or return
@@ -1286,11 +1217,9 @@ static char *strnrcpy __P((char *, char *, size_t));
* without "." and ".." !!!
*/
char *
-xgetcwd(pathname, pathlen)
- char *pathname;
- size_t pathlen;
+xgetcwd(char *pathname, size_t pathlen)
{
- char pathbuf[MAXNAMLEN]; /* temporary pathname buffer */
+ char pathbuf[MAXPATHLEN]; /* temporary pathname buffer */
char *pnptr = &pathbuf[(sizeof pathbuf)-1]; /* pathname pointer */
dev_t rdev; /* root device number */
DIR *dirp = NULL; /* directory stream */
@@ -1339,7 +1268,7 @@ xgetcwd(pathname, pathlen)
} while (dd.st_ino != d.st_ino ||
dd.st_dev != d.st_dev ||
dd.st_size != d.st_size);
- (void) closedir(dirp);
+ closedir(dirp);
dirp = NULL;
pnptr = strnrcpy(dirp->d_name, pnptr, pnptr - pathbuf);
pnptr = strnrcpy("/", pnptr, pnptr - pathbuf);
@@ -1370,9 +1299,7 @@ fail:
char *
-xgetcwd(pathname, pathlen)
- char *pathname;
- size_t pathlen;
+xgetcwd(char *pathname, size_t pathlen)
{
DIR *dp;
struct dirent *d;
@@ -1472,7 +1399,7 @@ xgetcwd(pathname, pathlen)
(void) xsnprintf(pathname, pathlen, CGETS(23, 27,
"getcwd: Cannot find \".\" in \"..\" (%s)"),
strerror(save_errno ? save_errno : ENOENT));
- (void) closedir(dp);
+ closedir(dp);
return NULL;
}
else
@@ -1482,7 +1409,7 @@ xgetcwd(pathname, pathlen)
pathptr = strnrcpy(pathptr, "/", pathptr - pathbuf);
nextpathptr = strnrcpy(nextpathptr, "../", nextpathptr - nextpathbuf);
*cur_name_add = '\0';
- (void) closedir(dp);
+ closedir(dp);
}
} /* end getcwd */
# endif /* hp9000s500 */
@@ -1491,9 +1418,7 @@ xgetcwd(pathname, pathlen)
* Like strncpy, going backwards and returning the new pointer
*/
static char *
-strnrcpy(ptr, str, siz)
- char *ptr, *str;
- size_t siz;
+strnrcpy(char *ptr, char *str, size_t siz)
{
int len = strlen(str);
if (siz == 0)
@@ -1516,10 +1441,9 @@ strnrcpy(ptr, str, siz)
static char *
-apperr(st)
- status_$t *st;
+apperr(status_$t *st)
{
- static char buf[BUFSIZE];
+ static char *buf; /* = NULL */
short e_subl, e_modl, e_codel;
error_$string_t e_sub, e_mod, e_code;
@@ -1527,14 +1451,14 @@ apperr(st)
e_sub[e_subl] = '\0';
e_code[e_codel] = '\0';
e_mod[e_modl] = '\0';
- (void) xsnprintf(buf, sizeof(buf), "%s (%s/%s)", e_code, e_sub, e_mod);
+ xfree(buf);
+ buf = xasprintf("%s (%s/%s)", e_code, e_sub, e_mod);
return(buf);
}
static int
-llib(s)
- Char *s;
+llib(Char *s)
{
short len = Strlen(s);
status_$t st;
@@ -1547,31 +1471,22 @@ llib(s)
/*ARGSUSED*/
void
-doinlib(v, c)
- Char **v;
- struct command *c;
+doinlib(Char **v, struct command *c)
{
+ Char **globbed;
+
setname(short2str(*v++));
- gflag = 0, tglob(v);
- if (gflag) {
- v = globall(v);
- if (v == 0)
- stderror(ERR_NAME | ERR_NOMATCH);
- }
- else {
- v = gargv = saveblk(v);
- trim(v);
- }
+ v = glob_all_or_error(v);
+ globbed = v;
+ cleanup_push(globbed, blk_cleanup);
while (v && *v)
llib(*v++);
- if (gargv)
- blkfree(gargv), gargv = 0;
+ cleanup_until(globbed);
}
int
-getv(v)
- Char *v;
+getv(Char *v)
{
if (eq(v, STRbsd43))
return(1);
@@ -1586,9 +1501,7 @@ getv(v)
/*ARGSUSED*/
void
-dover(v, c)
- Char **v;
- struct command *c;
+dover(Char **v, struct command *c)
{
Char *p;
@@ -1619,9 +1532,7 @@ typedef short enum {
/*ARGSUSED*/
void
-dorootnode(v, c)
- Char **v;
- struct command *c;
+dorootnode(Char **v, struct command *c)
{
name_$dir_type_t dirtype = name_$node_dir_type;
uid_$t uid;
@@ -1645,7 +1556,7 @@ dorootnode(v, c)
}
int
-isapad()
+isapad(void)
{
static int res = -1;
static status_$t st;
diff --git a/contrib/tcsh/tc.os.h b/contrib/tcsh/tc.os.h
index 9aa8725..df8f747 100644
--- a/contrib/tcsh/tc.os.h
+++ b/contrib/tcsh/tc.os.h
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/tc.os.h,v 3.97 2005/03/03 22:32:01 kim Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/tc.os.h,v 3.101 2006/02/14 00:52:52 christos Exp $ */
/*
* tc.os.h: Shell os dependent defines
*/
@@ -88,22 +88,6 @@
# endif /* POSIX */
#endif /* OREO */
-#ifndef NCARGS
-# ifdef _SC_ARG_MAX
-# define NCARGS sysconf(_SC_ARG_MAX)
-# else /* !_SC_ARG_MAX */
-# ifdef ARG_MAX
-# define NCARGS ARG_MAX
-# else /* !ARG_MAX */
-# ifdef _MINIX
-# define NCARGS 80
-# else /* !_MINIX */
-# define NCARGS 1024
-# endif /* _MINIX */
-# endif /* ARG_MAX */
-# endif /* _SC_ARG_MAX */
-#endif /* NCARGS */
-
#ifdef convex
# include <sys/dmon.h>
#endif /* convex */
@@ -454,7 +438,7 @@ typedef struct timeval timeval_t;
#endif /* NeXT */
#if defined(HAVE_GETHOSTNAME) && !HAVE_DECL_GETHOSTNAME
-extern int gethostname __P((char *, int));
+extern int gethostname (char *, int);
#endif
#ifndef GETPGRP_VOID
@@ -474,12 +458,12 @@ extern char *ttyname();
# if defined(SUNOS4)
# ifndef toupper
-extern int toupper __P((int));
+extern int toupper (int);
# endif /* toupper */
# ifndef tolower
-extern int tolower __P((int));
+extern int tolower (int);
# endif /* tolower */
-extern caddr_t sbrk __P((int));
+extern caddr_t sbrk (int);
# else /* !SUNOS4 */
# ifndef WINNT_NATIVE
# ifdef hpux
@@ -492,19 +476,6 @@ extern void qsort();
extern void perror();
#endif
-# ifdef BSDSIGS
-# if !defined(_AIX370) && !defined(MACH) && !defined(NeXT) && !defined(_AIXPS2) && !defined(ardent) && !defined(SUNOS4) && !defined(HPBSD) && !defined(__MACHTEN__)
-# if (!defined(apollo) || !defined(__STDC__)) && !defined(__DGUX__) && !defined(fps500)
-extern RETSIGTYPE sigvec();
-#ifndef _CX_UX
-extern void sigpause();
-#endif /* _CX_UX */
-# endif /* (!apollo || !__STDC__) && !__DGUX__ && !fps500 */
-# endif /* _AIX370 || MACH || NeXT || _AIXPS2 || ardent || SUNOS4 || HPBSD */
-extern sigmask_t sigblock();
-extern sigmask_t sigsetmask();
-# endif /* BSDSIGS */
-
# ifdef BSD
extern uid_t getuid(), geteuid();
extern gid_t getgid(), getegid();
@@ -535,9 +506,9 @@ extern struct passwd *getpwuid(), *getpwnam(), *getpwent();
# ifdef HAVE_SHADOW_H
extern struct spwd *getspnam(), *getspent();
# endif /* HAVE_SHADOW_H */
-# ifdef HAVE_AUTH_H
+# if defined(HAVE_AUTH_H) && defined(HAVE_GETAUTHUID)
extern struct authorization *getauthuid();
-# endif /* HAVE_AUTH_H */
+# endif /* HAVE_AUTH_H && HAVE_GETAUTHUID */
# endif /* __STDC__ */
# ifndef getcwd
@@ -564,21 +535,21 @@ extern char *ttyname();
/*
* Somehow these are missing
*/
-extern int ioctl __P((int, int, ...));
-extern int readlink __P((const char *, char *, size_t));
-extern void setgrent __P((void));
-extern void endgrent __P((void));
+extern int ioctl (int, int, ...);
+extern int readlink (const char *, char *, size_t);
+extern void setgrent (void);
+extern void endgrent (void);
# ifdef REMOTEHOST
# ifndef _SOCKLEN_T /* Avoid Solaris 2.7 bogosity. */
struct sockaddr;
-extern int getpeername __P((int, struct sockaddr *, int *));
+extern int getpeername (int, struct sockaddr *, int *);
# endif /* _SOCKLEN_T */
# endif /* REMOTEHOST */
#endif /* SUNOS4 && __GNUC__ == 2 */
#if (defined(BSD) && !defined(BSD4_4)) || defined(SUNOS4)
# if defined(__alpha) && defined(__osf__) && DECOSF1 < 200
-extern void bcopy __P((const void *, void *, size_t));
+extern void bcopy (const void *, void *, size_t);
# define memmove(a, b, c) (bcopy((char *) (b), (char *) (a), (int) (c)), a)
# endif /* __alpha && __osf__ && DECOSF1 < 200 */
#endif /* (BSD && !BSD4_4) || SUNOS4 */
@@ -594,25 +565,33 @@ extern void bcopy __P((const void *, void *, size_t));
# if !defined(__sgi) && !defined(_OSD_POSIX) && !defined(__MVS__)
# ifndef _SOCKLEN_T /* Avoid Solaris 2.7 bogosity. */
struct sockaddr;
-extern int getpeername __P((int, struct sockaddr *, int *));
+extern int getpeername (int, struct sockaddr *, int *);
# endif /* _SOCKLEN_T */
# endif /* !__sgi && !_OSD_POSIX && !__MVS__ */
# endif /* REMOTEHOST */
# ifndef BSDTIMES
-extern int getrlimit __P((int, struct rlimit *));
-extern int setrlimit __P((int, const struct rlimit *));
+extern int getrlimit (int, struct rlimit *);
+extern int setrlimit (int, const struct rlimit *);
# endif /* !BSDTIMES */
# if defined(SOLARIS2)
-extern char *strerror __P((int));
+extern char *strerror (int);
# endif /* SOLARIS2 */
#endif /* SYSVREL == 4 */
#if defined(__alpha) && defined(__osf__) && DECOSF1 < 200
/* These are ok for 1.3, but conflict with the header files for 2.0 */
-extern char *sbrk __P((ssize_t));
-extern int ioctl __P((int, unsigned long, char *));
-extern pid_t vfork __P((void));
-extern int killpg __P((pid_t, int));
+extern char *sbrk (ssize_t);
+extern int ioctl (int, unsigned long, char *);
+extern pid_t vfork (void);
+extern int killpg (pid_t, int);
#endif /* __osf__ && __alpha && DECOSF1 < 200 */
+#ifndef va_copy
+# ifdef __va_copy
+# define va_copy(DEST, SRC) __va_copy(DEST, SRC)
+# else
+# define va_copy(DEST, SRC) memcpy(&(DEST), &(SRC), sizeof(va_list))
+# endif
+#endif
+
#endif /* _h_tc_os */
diff --git a/contrib/tcsh/tc.printf.c b/contrib/tcsh/tc.printf.c
index e07a5af..8db69d5 100644
--- a/contrib/tcsh/tc.printf.c
+++ b/contrib/tcsh/tc.printf.c
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/tc.printf.c,v 3.27 2005/01/05 16:06:15 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/tc.printf.c,v 3.35 2006/03/02 18:46:45 christos Exp $ */
/*
* tc.printf.c: A public-domain, minimal printf/sprintf routine that prints
* through the putchar() routine. Feel free to use for
@@ -34,31 +34,27 @@
*/
#include "sh.h"
-RCSID("$Id: tc.printf.c,v 3.27 2005/01/05 16:06:15 christos Exp $")
+RCSID("$tcsh: tc.printf.c,v 3.35 2006/03/02 18:46:45 christos Exp $")
#ifdef lint
#undef va_arg
#define va_arg(a, b) (a ? (b) 0 : (b) 0)
#endif
-#define INF 32766 /* should be bigger than any field to print */
+#define INF INT_MAX /* should be bigger than any field to print */
-static char buf[128];
static char snil[] = "(nil)";
-static void xaddchar __P((int));
-static void doprnt __P((void (*) __P((int)), const char *, va_list));
+static void xaddchar (int);
+static void doprnt (void (*) (int), const char *, va_list);
static void
-doprnt(addchar, sfmt, ap)
- void (*addchar) __P((int));
- const char *sfmt;
- va_list ap;
+doprnt(void (*addchar) (int), const char *sfmt, va_list ap)
{
char *bp;
const char *f;
#ifdef SHORT_STRINGS
- Char *Bp;
+ const Char *Bp;
#endif /* SHORT_STRINGS */
#ifdef HAVE_LONG_LONG
long long l;
@@ -67,10 +63,12 @@ doprnt(addchar, sfmt, ap)
long l;
unsigned long u;
#endif
+ char buf[(CHAR_BIT * sizeof (l) + 2) / 3 + 1]; /* Octal: 3 bits per char */
int i;
int fmt;
unsigned char pad = ' ';
- int flush_left = 0, f_width = 0, prec = INF, hash = 0, do_long = 0;
+ int flush_left = 0, f_width = 0, prec = INF, hash = 0;
+ int do_long = 0, do_size_t = 0;
int sign = 0;
int attributes = 0;
@@ -78,7 +76,7 @@ doprnt(addchar, sfmt, ap)
f = sfmt;
for (; *f; f++) {
if (*f != '%') { /* then just out the char */
- (*addchar) ((int) (((unsigned char)*f) | attributes));
+ (*addchar) (((unsigned char)*f) | attributes);
}
else {
f++; /* skip the % */
@@ -129,6 +127,10 @@ doprnt(addchar, sfmt, ap)
f++;
}
}
+ if (*f == 'z') { /* size_t format */
+ do_size_t++;
+ f++;
+ }
fmt = (unsigned char) *f;
if (fmt != 'S' && fmt != 'Q' && isupper(fmt)) {
@@ -140,7 +142,10 @@ doprnt(addchar, sfmt, ap)
case 'd':
switch (do_long) {
case 0:
- l = (long) (va_arg(ap, int));
+ if (do_size_t)
+ l = (long) (va_arg(ap, size_t));
+ else
+ l = (long) (va_arg(ap, int));
break;
case 1:
#ifndef HAVE_LONG_LONG
@@ -167,12 +172,12 @@ doprnt(addchar, sfmt, ap)
f_width = f_width - (int) (bp - buf);
if (!flush_left)
while (f_width-- > 0)
- (*addchar) ((int) (pad | attributes));
+ (*addchar) (pad | attributes);
for (bp--; bp >= buf; bp--)
- (*addchar) ((int) (((unsigned char) *bp) | attributes));
+ (*addchar) (((unsigned char) *bp) | attributes);
if (flush_left)
while (f_width-- > 0)
- (*addchar) ((int) (' ' | attributes));
+ (*addchar) (' ' | attributes);
break;
case 'p':
@@ -185,7 +190,10 @@ doprnt(addchar, sfmt, ap)
case 'u':
switch (do_long) {
case 0:
- u = (unsigned long) (va_arg(ap, unsigned int));
+ if (do_size_t)
+ u = va_arg(ap, size_t);
+ else
+ u = va_arg(ap, unsigned int);
break;
case 1:
#ifndef HAVE_LONG_LONG
@@ -227,18 +235,18 @@ doprnt(addchar, sfmt, ap)
i = f_width - (int) (bp - buf);
if (!flush_left)
while (i-- > 0)
- (*addchar) ((int) (pad | attributes));
+ (*addchar) (pad | attributes);
for (bp--; bp >= buf; bp--)
- (*addchar) ((int) (((unsigned char) *bp) | attributes));
+ (*addchar) (((unsigned char) *bp) | attributes);
if (flush_left)
while (i-- > 0)
- (*addchar) ((int) (' ' | attributes));
+ (*addchar) (' ' | attributes);
break;
case 'c':
i = va_arg(ap, int);
- (*addchar) ((int) (i | attributes));
+ (*addchar) (i | attributes);
break;
case 'S':
@@ -258,16 +266,16 @@ doprnt(addchar, sfmt, ap)
size_t pos, len;
if (fmt == 'Q' && *Bp & QUOTE)
- (*addchar) ((int) ('\\' | attributes));
+ (*addchar) ('\\' | attributes);
len = one_wctomb(cbuf, *Bp & CHAR);
for (pos = 0; pos < len; pos++)
- (*addchar) ((int) ((unsigned char)cbuf[pos]
- | attributes | (*Bp & ATTRIBUTES)));
+ (*addchar) ((unsigned char)cbuf[pos] | attributes
+ | (*Bp & ATTRIBUTES));
Bp++;
}
if (flush_left)
while (f_width-- > 0)
- (*addchar) ((int) (' ' | attributes));
+ (*addchar) (' ' | attributes);
break;
#endif /* SHORT_STRINGS */
@@ -277,20 +285,19 @@ doprnt(addchar, sfmt, ap)
lcase_s:
if (!bp)
bp = snil;
- f_width = f_width - strlen((char *) bp);
+ f_width = f_width - strlen(bp);
if (!flush_left)
while (f_width-- > 0)
- (*addchar) ((int) (pad | attributes));
+ (*addchar) (pad | attributes);
for (i = 0; *bp && i < prec; i++) {
if (fmt == 'q' && *bp & QUOTE)
- (*addchar) ((int) ('\\' | attributes));
- (*addchar) ((int) (((unsigned char) *bp & TRIM) |
- attributes));
+ (*addchar) ('\\' | attributes);
+ (*addchar) (((unsigned char) *bp & TRIM) | attributes);
bp++;
}
if (flush_left)
while (f_width-- > 0)
- (*addchar) ((int) (' ' | attributes));
+ (*addchar) (' ' | attributes);
break;
case 'a':
@@ -298,13 +305,14 @@ lcase_s:
break;
case '%':
- (*addchar) ((int) ('%' | attributes));
+ (*addchar) ('%' | attributes);
break;
default:
break;
}
- flush_left = 0, f_width = 0, prec = INF, hash = 0, do_long = 0;
+ flush_left = 0, f_width = 0, prec = INF, hash = 0;
+ do_size_t = 0, do_long = 0;
sign = 0;
pad = ' ';
}
@@ -314,8 +322,7 @@ lcase_s:
static char *xstring, *xestring;
static void
-xaddchar(c)
- int c;
+xaddchar(int c)
{
if (xestring == xstring)
*xstring = '\0';
@@ -326,25 +333,10 @@ xaddchar(c)
pret_t
/*VARARGS*/
-#ifdef PROTOTYPES
xsnprintf(char *str, size_t size, const char *fmt, ...)
-#else
-xsnprintf(va_alist)
- va_dcl
-#endif
{
va_list va;
-#ifdef PROTOTYPES
va_start(va, fmt);
-#else
- char *str, *fmt;
- size_t size;
-
- va_start(va);
- str = va_arg(va, char *);
- size = va_arg(va, size_t);
- fmt = va_arg(va, char *);
-#endif
xstring = str;
xestring = str + size - 1;
@@ -358,22 +350,10 @@ xsnprintf(va_alist)
pret_t
/*VARARGS*/
-#ifdef PROTOTYPES
xprintf(const char *fmt, ...)
-#else
-xprintf(va_alist)
- va_dcl
-#endif
{
va_list va;
-#ifdef PROTOTYPES
va_start(va, fmt);
-#else
- char *fmt;
-
- va_start(va);
- fmt = va_arg(va, char *);
-#endif
doprnt(xputchar, fmt, va);
va_end(va);
#ifdef PURIFY
@@ -383,9 +363,7 @@ xprintf(va_alist)
pret_t
-xvprintf(fmt, va)
- const char *fmt;
- va_list va;
+xvprintf(const char *fmt, va_list va)
{
doprnt(xputchar, fmt, va);
#ifdef PURIFY
@@ -394,11 +372,7 @@ xvprintf(fmt, va)
}
pret_t
-xvsnprintf(str, size, fmt, va)
- char *str;
- size_t size;
- const char *fmt;
- va_list va;
+xvsnprintf(char *str, size_t size, const char *fmt, va_list va)
{
xstring = str;
xestring = str + size - 1;
@@ -409,6 +383,42 @@ xvsnprintf(str, size, fmt, va)
#endif
}
+char *
+xvasprintf(const char *fmt, va_list va)
+{
+ size_t size;
+ char *buf;
+
+ buf = NULL;
+ size = 2048; /* Arbitrary */
+ for (;;) {
+ va_list copy;
+
+ buf = xrealloc(buf, size);
+ xstring = buf;
+ xestring = buf + size - 1;
+ va_copy(copy, va);
+ doprnt(xaddchar, fmt, copy);
+ va_end(copy);
+ if (xstring < xestring)
+ break;
+ size *= 2;
+ }
+ *xstring++ = '\0';
+ return xrealloc(buf, xstring - buf);
+}
+
+char *
+xasprintf(const char *fmt, ...)
+{
+ va_list va;
+ char *ret;
+
+ va_start (va, fmt);
+ ret = xvasprintf(fmt, va);
+ va_end(va);
+ return ret;
+}
#ifdef PURIFY
@@ -423,34 +433,17 @@ xvsnprintf(str, size, fmt, va)
#define FILE int
#endif
int
-#ifdef PROTOTYPES
fprintf(FILE *fp, const char* fmt, ...)
-#else
-fprintf(va_alist)
- va_dcl
-#endif
{
va_list va;
-#ifdef PROTOTYPES
va_start(va, fmt);
-#else
- FILE *fp;
- const char *fmt;
-
- va_start(va);
- fp = va_arg(va, FILE *);
- fmt = va_arg(va, const char *);
-#endif
doprnt(xputchar, fmt, va);
va_end(va);
return 1;
}
int
-vfprintf(fp, fmt, va)
- FILE *fp;
- const char *fmt;
- va_list va;
+vfprintf(FILE *fp, const char *fmt, va_list va)
{
doprnt(xputchar, fmt, va);
return 1;
diff --git a/contrib/tcsh/tc.prompt.c b/contrib/tcsh/tc.prompt.c
index 147b809..f63fdf0 100644
--- a/contrib/tcsh/tc.prompt.c
+++ b/contrib/tcsh/tc.prompt.c
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/tc.prompt.c,v 3.53 2005/01/05 18:06:43 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/tc.prompt.c,v 3.67 2006/11/17 16:26:58 christos Exp $ */
/*
* tc.prompt.c: Prompt printing stuff
*/
@@ -32,7 +32,7 @@
*/
#include "sh.h"
-RCSID("$Id: tc.prompt.c,v 3.53 2005/01/05 18:06:43 christos Exp $")
+RCSID("$tcsh: tc.prompt.c,v 3.67 2006/11/17 16:26:58 christos Exp $")
#include "ed.h"
#include "tw.h"
@@ -52,7 +52,7 @@ static const char *month_list[12];
static const char *day_list[7];
void
-dateinit()
+dateinit(void)
{
#ifdef notyet
int i;
@@ -108,14 +108,12 @@ dateinit()
}
void
-printprompt(promptno, str)
- int promptno;
- const char *str;
+printprompt(int promptno, const char *str)
{
- static Char *ocp = NULL;
+ static const Char *ocp = NULL;
static const char *ostr = NULL;
time_t lclock = time(NULL);
- Char *cp;
+ const Char *cp;
switch (promptno) {
default:
@@ -143,22 +141,24 @@ printprompt(promptno, str)
ostr = str;
}
- PromptBuf[0] = '\0';
- tprintf(FMT_PROMPT, PromptBuf, cp, 2 * INBUFSIZE - 2, str, lclock, NULL);
+ xfree(Prompt);
+ Prompt = NULL;
+ Prompt = tprintf(FMT_PROMPT, cp, str, lclock, NULL);
if (!editing) {
- for (cp = PromptBuf; *cp ; )
+ for (cp = Prompt; *cp ; )
(void) putwraw(*cp++);
SetAttributes(0);
flush();
}
- RPromptBuf[0] = '\0';
+ xfree(RPrompt);
+ RPrompt = NULL;
if (promptno == 0) { /* determine rprompt if using main prompt */
cp = varval(STRrprompt);
- tprintf(FMT_PROMPT, RPromptBuf, cp, INBUFSIZE - 2, NULL, lclock, NULL);
+ RPrompt = tprintf(FMT_PROMPT, cp, NULL, lclock, NULL);
/* if not editing, put rprompt after prompt */
- if (!editing && RPromptBuf[0] != '\0') {
- for (cp = RPromptBuf; *cp ; )
+ if (!editing && RPrompt[0] != '\0') {
+ for (cp = RPrompt; *cp ; )
(void) putwraw(*cp++);
SetAttributes(0);
putraw(' ');
@@ -167,83 +167,70 @@ printprompt(promptno, str)
}
}
-void
-tprintf(what, buf, fmt, siz, str, tim, info)
- int what;
- Char *buf;
- const Char *fmt;
- size_t siz;
- const char *str;
- time_t tim;
- ptr_t info;
+static void
+tprintf_append_mbs(struct Strbuf *buf, const char *mbs, Char attributes)
+{
+ while (*mbs != 0) {
+ Char wc;
+
+ mbs += one_mbtowc(&wc, mbs, MB_LEN_MAX);
+ Strbuf_append1(buf, wc | attributes);
+ }
+}
+
+Char *
+tprintf(int what, const Char *fmt, const char *str, time_t tim, ptr_t info)
{
+ struct Strbuf buf = Strbuf_INIT;
Char *z, *q;
Char attributes = 0;
static int print_prompt_did_ding = 0;
- Char buff[BUFSIZE];
- /* Need to be unsigned to avoid sign extension */
- const unsigned char *cz;
- unsigned char cbuff[BUFSIZE];
+ char *cz;
- Char *p = buf;
- Char *ep = &p[siz];
+ Char *p;
const Char *cp = fmt;
Char Scp;
struct tm *t = localtime(&tim);
/* prompt stuff */
- static Char *olddir = NULL, *olduser = NULL;
+ static Char *olduser = NULL;
int updirs;
- size_t pdirs, sz;
- int l;
+ size_t pdirs;
+ cleanup_push(&buf, Strbuf_cleanup);
for (; *cp; cp++) {
- if (p >= ep)
- break;
- l = NLSSize(cp, -1);
- if (l > 1) {
- while (l--)
- *p++ = attributes | *cp++;
- cp--;
- continue;
- }
if ((*cp == '%') && ! (cp[1] == '\0')) {
cp++;
switch (*cp) {
case 'R':
if (what == FMT_HISTORY) {
- fmthist('R', info, (char *) cbuff, sizeof(cbuff));
- cz = cbuff;
- } else
- cz = (const unsigned char *) str;
- if (cz != NULL)
- for (; *cz && p < ep; p++) {
- cz += one_mbtowc(p, (const char *)cz, MB_LEN_MAX);
- *p |= attributes;
- }
+ cz = fmthist('R', info);
+ tprintf_append_mbs(&buf, cz, attributes);
+ xfree(cz);
+ } else {
+ if (str != NULL)
+ tprintf_append_mbs(&buf, str, attributes);
+ }
break;
case '#':
- *p++ = attributes | ((uid == 0) ? PRCHROOT : PRCH);
+ Strbuf_append1(&buf,
+ attributes | ((uid == 0) ? PRCHROOT : PRCH));
break;
case '!':
case 'h':
switch (what) {
case FMT_HISTORY:
- fmthist('h', info, (char *) cbuff, sizeof(cbuff));
+ cz = fmthist('h', info);
break;
case FMT_SCHED:
- (void) xsnprintf((char *) cbuff, sizeof(cbuff), "%d",
- *(int *)info);
+ cz = xasprintf("%d", *(int *)info);
break;
default:
- (void) xsnprintf((char *) cbuff, sizeof(cbuff), "%d",
- eventno + 1);
+ cz = xasprintf("%d", eventno + 1);
break;
}
- for (cz = cbuff; *cz && p < ep; p++) {
- cz += one_mbtowc(p, (const char *)cz, MB_LEN_MAX);
- *p |= attributes;
- }
+ tprintf_append_mbs(&buf, cz, attributes);
+ xfree(cz);
break;
case 'T': /* 24 hour format */
case '@':
@@ -254,8 +241,6 @@ tprintf(what, buf, fmt, siz, str, tim, info)
char ampm = 'a';
int hr = t->tm_hour;
- if (p >= ep - 10) break;
-
/* addition by Hans J. Albertsson */
/* and another adapted from Justin Bur */
if (adrof(STRampm) || (*cp != 'T' && *cp != 'P')) {
@@ -273,25 +258,33 @@ tprintf(what, buf, fmt, siz, str, tim, info)
what != FMT_PROMPT || adrof(STRnoding)) {
if (t->tm_min)
print_prompt_did_ding = 0;
- p = Itoa(hr, p, 0, attributes);
- *p++ = attributes | ':';
- p = Itoa(t->tm_min, p, 2, attributes);
+ /*
+ * Pad hour to 2 characters if padhour is set,
+ * by ADAM David Alan Martin
+ */
+ p = Itoa(hr, adrof(STRpadhour) ? 2 : 0, attributes);
+ Strbuf_append(&buf, p);
+ xfree(p);
+ Strbuf_append1(&buf, attributes | ':');
+ p = Itoa(t->tm_min, 2, attributes);
+ Strbuf_append(&buf, p);
+ xfree(p);
if (*cp == 'p' || *cp == 'P') {
- *p++ = attributes | ':';
- p = Itoa(t->tm_sec, p, 2, attributes);
+ Strbuf_append1(&buf, attributes | ':');
+ p = Itoa(t->tm_sec, 2, attributes);
+ Strbuf_append(&buf, p);
+ xfree(p);
}
if (adrof(STRampm) || (*cp != 'T' && *cp != 'P')) {
- *p++ = attributes | ampm;
- *p++ = attributes | 'm';
+ Strbuf_append1(&buf, attributes | ampm);
+ Strbuf_append1(&buf, attributes | 'm');
}
}
else { /* we need to ding */
- int i = 0;
+ size_t i;
- (void) Strcpy(buff, STRDING);
- while (buff[i]) {
- *p++ = attributes | buff[i++];
- }
+ for (i = 0; STRDING[i] != 0; i++)
+ Strbuf_append1(&buf, attributes | STRDING[i]);
print_prompt_did_ding = 1;
}
}
@@ -300,38 +293,40 @@ tprintf(what, buf, fmt, siz, str, tim, info)
case 'M':
#ifndef HAVENOUTMP
if (what == FMT_WHO)
- cz = (const unsigned char *) who_info(info, 'M',
- (char *) cbuff, sizeof(cbuff));
+ cz = who_info(info, 'M');
else
#endif /* HAVENOUTMP */
- cz = (const unsigned char *) getenv("HOST");
+ cz = getenv("HOST");
/*
* Bug pointed out by Laurent Dami <dami@cui.unige.ch>: don't
* derefrence that NULL (if HOST is not set)...
*/
if (cz != NULL)
- for (; *cz && p < ep; p++) {
- cz += one_mbtowc(p, (const char *)cz, MB_LEN_MAX);
- *p |= attributes;
- }
+ tprintf_append_mbs(&buf, cz, attributes);
+ if (what == FMT_WHO)
+ xfree(cz);
break;
- case 'm':
+ case 'm': {
+ char *scz = NULL;
#ifndef HAVENOUTMP
if (what == FMT_WHO)
- cz = (const unsigned char *) who_info(info, 'm',
- (char *) cbuff, sizeof(cbuff));
- else
+ scz = cz = who_info(info, 'm');
+ else
#endif /* HAVENOUTMP */
- cz = (const unsigned char *) getenv("HOST");
+ cz = getenv("HOST");
if (cz != NULL)
- for (; *cz && (what == FMT_WHO || *cz != '.') && p < ep;
- p++) {
- cz += one_mbtowc(p, (const char *)cz, MB_LEN_MAX);
- *p |= attributes;
+ while (*cz != 0 && (what == FMT_WHO || *cz != '.')) {
+ Char wc;
+
+ cz += one_mbtowc(&wc, cz, MB_LEN_MAX);
+ Strbuf_append1(&buf, wc | attributes);
}
+ if (scz)
+ xfree(scz);
break;
+ }
/* lukem: new directory prompt code */
case '~':
@@ -347,6 +342,8 @@ tprintf(what, buf, fmt, siz, str, tim, info)
/* show ~ whenever possible - a la dirs */
if (Scp == '~' || Scp == '.' ) {
+ static Char *olddir = NULL;
+
if (tlength == 0 || olddir != z) {
olddir = z; /* have we changed dir? */
olduser = getusername(&olddir);
@@ -362,16 +359,16 @@ tprintf(what, buf, fmt, siz, str, tim, info)
#ifdef WINNT_NATIVE
Char *oldz = z;
if (z[1] == ':') {
- *p++ = attributes | *z++;
- *p++ = attributes | *z++;
+ Strbuf_append1(&buf, attributes | *z++);
+ Strbuf_append1(&buf, attributes | *z++);
+ }
+ if (*z == '/' && z[1] == '/') {
+ Strbuf_append1(&buf, attributes | *z++);
+ Strbuf_append1(&buf, attributes | *z++);
+ do {
+ Strbuf_append1(&buf, attributes | *z++);
+ } while(*z != '/');
}
- if (*z == '/' && z[1] == '/') {
- *p++ = attributes | *z++;
- *p++ = attributes | *z++;
- do {
- *p++ = attributes | *z++;
- }while(*z != '/');
- }
#endif /* WINNT_NATIVE */
q = z;
while (*z) /* calc # of /'s */
@@ -387,7 +384,7 @@ tprintf(what, buf, fmt, siz, str, tim, info)
* //machine/share/folder => //machine:folder
*/
if (oldz[0] == '/' && oldz[1] == '/' && updirs > 1)
- *p++ = attributes | ':';
+ Strbuf_append1(&buf, attributes | ':');
#endif /* WINNT_NATIVE */
if ((Scp == 'C' && *q != '/'))
updirs++;
@@ -417,103 +414,90 @@ tprintf(what, buf, fmt, siz, str, tim, info)
/* print ~[user] */
if ((olduser) && ((Scp == '~') ||
(Scp == '.' && (pdirs || (!pdirs && updirs <= 0))) )) {
- *p++ = attributes | '~';
- if (p >= ep) break;
- for (q = olduser; *q; *p++ = attributes | *q++)
- if (p >= ep) break;
+ Strbuf_append1(&buf, attributes | '~');
+ for (q = olduser; *q; q++)
+ Strbuf_append1(&buf, attributes | *q);
}
/* RWM - tell you how many dirs we've ignored */
/* and add '/' at front of this */
if (updirs > 0 && pdirs) {
- if (p >= ep - 5) break;
if (adrof(STRellipsis)) {
- *p++ = attributes | '.';
- *p++ = attributes | '.';
- *p++ = attributes | '.';
+ Strbuf_append1(&buf, attributes | '.');
+ Strbuf_append1(&buf, attributes | '.');
+ Strbuf_append1(&buf, attributes | '.');
} else {
- *p++ = attributes | '/';
- *p++ = attributes | '<';
+ Strbuf_append1(&buf, attributes | '/');
+ Strbuf_append1(&buf, attributes | '<');
if (updirs > 9) {
- *p++ = attributes | '9';
- *p++ = attributes | '+';
+ Strbuf_append1(&buf, attributes | '9');
+ Strbuf_append1(&buf, attributes | '+');
} else
- *p++ = attributes | ('0' + updirs);
- *p++ = attributes | '>';
+ Strbuf_append1(&buf, attributes | ('0' + updirs));
+ Strbuf_append1(&buf, attributes | '>');
}
}
-
- for (; *z ; *p++ = attributes | *z++)
- if (p >= ep) break;
+
+ while (*z)
+ Strbuf_append1(&buf, attributes | *z++);
break;
/* lukem: end of new directory prompt code */
case 'n':
#ifndef HAVENOUTMP
if (what == FMT_WHO) {
- cz = (const unsigned char *) who_info(info, 'n',
- (char *) cbuff, sizeof(cbuff));
- for (; *cz && p < ep; p++) {
- cz += one_mbtowc(p, (const char *)cz, MB_LEN_MAX);
- *p |= attributes;
- }
+ cz = who_info(info, 'n');
+ tprintf_append_mbs(&buf, cz, attributes);
+ xfree(cz);
}
else
#endif /* HAVENOUTMP */
{
if ((z = varval(STRuser)) != STRNULL)
- for (; *z; *p++ = attributes | *z++)
- if (p >= ep) break;
+ while (*z)
+ Strbuf_append1(&buf, attributes | *z++);
}
break;
case 'l':
#ifndef HAVENOUTMP
if (what == FMT_WHO) {
- cz = (const unsigned char *) who_info(info, 'l',
- (char *) cbuff, sizeof(cbuff));
- for (; *cz && p < ep; p++) {
- cz += one_mbtowc(p, (const char *)cz, MB_LEN_MAX);
- *p |= attributes;
- }
+ cz = who_info(info, 'l');
+ tprintf_append_mbs(&buf, cz, attributes);
+ xfree(cz);
}
else
#endif /* HAVENOUTMP */
{
if ((z = varval(STRtty)) != STRNULL)
- for (; *z; *p++ = attributes | *z++)
- if (p >= ep) break;
+ while (*z)
+ Strbuf_append1(&buf, attributes | *z++);
}
break;
case 'd':
- for (cz = (const unsigned char *) day_list[t->tm_wday];
- *cz && p < ep; p++) {
- cz += one_mbtowc(p, (const char *)cz, MB_LEN_MAX);
- *p |= attributes;
- }
+ tprintf_append_mbs(&buf, day_list[t->tm_wday], attributes);
break;
case 'D':
- if (p >= ep - 3) break;
- p = Itoa(t->tm_mday, p, 2, attributes);
+ p = Itoa(t->tm_mday, 2, attributes);
+ Strbuf_append(&buf, p);
+ xfree(p);
break;
case 'w':
- if (p >= ep - 5) break;
- for (cz = (const unsigned char *) month_list[t->tm_mon];
- *cz && p < ep; p++) {
- cz += one_mbtowc(p, (const char *)cz, MB_LEN_MAX);
- *p |= attributes;
- }
+ tprintf_append_mbs(&buf, month_list[t->tm_mon], attributes);
break;
case 'W':
- if (p >= ep - 3) break;
- p = Itoa(t->tm_mon + 1, p, 2, attributes);
+ p = Itoa(t->tm_mon + 1, 2, attributes);
+ Strbuf_append(&buf, p);
+ xfree(p);
break;
case 'y':
- if (p >= ep - 3) break;
- p = Itoa(t->tm_year % 100, p, 2, attributes);
+ p = Itoa(t->tm_year % 100, 2, attributes);
+ Strbuf_append(&buf, p);
+ xfree(p);
break;
case 'Y':
- if (p >= ep - 5) break;
- p = Itoa(t->tm_year + 1900, p, 4, attributes);
+ p = Itoa(t->tm_year + 1900, 4, attributes);
+ Strbuf_append(&buf, p);
+ xfree(p);
break;
case 'S': /* start standout */
attributes |= STANDOUT;
@@ -539,30 +523,28 @@ tprintf(what, buf, fmt, siz, str, tim, info)
case 'j':
{
- Char xbuf[128], *ebuf, *xq;
int njobs = -1;
struct process *pp;
+
for (pp = proclist.p_next; pp; pp = pp->p_next)
njobs++;
- /* make sure we have space */
- ebuf = Itoa(njobs, buf, 1, attributes);
- for (xq = xbuf; xq < ebuf; *p++ = *xq++)
- if (p >= ep) break;
+ p = Itoa(njobs, 1, attributes);
+ Strbuf_append(&buf, p);
+ xfree(p);
break;
}
case '?':
if ((z = varval(STRstatus)) != STRNULL)
- for (; *z; *p++ = attributes | *z++)
- if (p >= ep) break;
+ while (*z)
+ Strbuf_append1(&buf, attributes | *z++);
break;
case '$':
- sz = ep - p;
- (void) expdollar(&p, &cp, &sz, attributes);
- /* cp should point the last char of currnet % sequence */
+ expdollar(&buf, &cp, attributes);
+ /* cp should point the last char of current % sequence */
cp--;
break;
case '%':
- *p++ = attributes | '%';
+ Strbuf_append1(&buf, attributes | '%');
break;
case '{': /* literal characters start */
#if LITERAL == 0
@@ -570,7 +552,7 @@ tprintf(what, buf, fmt, siz, str, tim, info)
* No literal capability, so skip all chars in the literal
* string
*/
- while (*cp != '\0' && (*cp != '%' || cp[1] != '}'))
+ while (*cp != '\0' && (cp[-1] != '%' || *cp != '}'))
cp++;
#endif /* LITERAL == 0 */
attributes |= LITERAL;
@@ -581,64 +563,56 @@ tprintf(what, buf, fmt, siz, str, tim, info)
default:
#ifndef HAVENOUTMP
if (*cp == 'a' && what == FMT_WHO) {
- cz = (const unsigned char *) who_info(info, 'a',
- (char *) cbuff, sizeof(cbuff));
- for (; *cz && p < ep; p++) {
- cz += one_mbtowc(p, (const char *)cz, MB_LEN_MAX);
- *p |= attributes;
- }
+ cz = who_info(info, 'a');
+ tprintf_append_mbs(&buf, cz, attributes);
+ xfree(cz);
}
- else
+ else
#endif /* HAVENOUTMP */
{
- if (p >= ep - 3) break;
- *p++ = attributes | '%';
- *p++ = attributes | *cp;
+ Strbuf_append1(&buf, attributes | '%');
+ Strbuf_append1(&buf, attributes | *cp);
}
break;
}
}
- else if (*cp == '\\' || *cp == '^')
- *p++ = attributes | parseescape(&cp);
+ else if (*cp == '\\' || *cp == '^')
+ Strbuf_append1(&buf, attributes | parseescape(&cp));
else if (*cp == HIST) { /* EGS: handle '!'s in prompts */
- if (what == FMT_HISTORY)
- fmthist('h', info, (char *) cbuff, sizeof(cbuff));
+ if (what == FMT_HISTORY)
+ cz = fmthist('h', info);
else
- (void) xsnprintf((char *) cbuff, sizeof(cbuff), "%d", eventno + 1);
- for (cz = cbuff; *cz && p < ep; p++) {
- cz += one_mbtowc(p, (const char *)cz, MB_LEN_MAX);
- *p |= attributes;
- }
+ cz = xasprintf("%d", eventno + 1);
+ tprintf_append_mbs(&buf, cz, attributes);
+ xfree(cz);
}
- else
- *p++ = attributes | *cp; /* normal character */
+ else
+ Strbuf_append1(&buf, attributes | *cp); /* normal character */
}
- *p = '\0';
+ cleanup_ignore(&buf);
+ cleanup_until(&buf);
+ return Strbuf_finish(&buf);
}
-Char *
-expdollar(dstp, srcp, spp, attr)
- Char **dstp;
- const Char **srcp;
- size_t *spp;
- int attr;
+int
+expdollar(struct Strbuf *buf, const Char **srcp, Char attr)
{
struct varent *vp;
- Char var[MAXVARLEN];
const Char *src = *srcp;
- Char *val;
- Char *dst = *dstp;
- int i, curly = 0;
+ Char *var, *val;
+ size_t i;
+ int curly = 0;
/* found a variable, expand it */
- for (i = 0; i < MAXVARLEN; i++) {
+ var = xmalloc((Strlen(src) + 1) * sizeof (*var));
+ for (i = 0; ; i++) {
var[i] = *++src & TRIM;
if (i == 0 && var[i] == '{') {
curly = 1;
var[i] = *++src & TRIM;
}
- if (!alnum(var[i])) {
-
+ if (!alnum(var[i]) && var[i] != '_') {
+
var[i] = '\0';
break;
}
@@ -647,31 +621,29 @@ expdollar(dstp, srcp, spp, attr)
src++;
vp = adrof(var);
- val = (!vp) ? tgetenv(var) : NULL;
if (vp && vp->vec) {
for (i = 0; vp->vec[i] != NULL; i++) {
- for (val = vp->vec[i]; *spp > 0 && *val; (*spp)--)
- *dst++ = *val++ | attr;
- if (vp->vec[i+1] && *spp > 0) {
- *dst++ = ' ' | attr;
- (*spp)--;
- }
+ for (val = vp->vec[i]; *val; val++)
+ if (*val != '\n' && *val != '\r')
+ Strbuf_append1(buf, *val | attr);
+ if (vp->vec[i+1])
+ Strbuf_append1(buf, ' ' | attr);
}
}
- else if (val) {
- for (; *spp > 0 && *val; (*spp)--)
- *dst++ = *val++ | attr;
- }
else {
- **dstp = '\0';
- *srcp = src;
- return NULL;
+ val = (!vp) ? tgetenv(var) : NULL;
+ if (val) {
+ for (; *val; val++)
+ if (*val != '\n' && *val != '\r')
+ Strbuf_append1(buf, *val | attr);
+ } else {
+ *srcp = src;
+ xfree(var);
+ return 0;
+ }
}
- *dst = '\0';
- val = *dstp;
*srcp = src;
- *dstp = dst;
-
- return val;
+ xfree(var);
+ return 1;
}
diff --git a/contrib/tcsh/tc.sched.c b/contrib/tcsh/tc.sched.c
index ce0b797..98c68b9 100644
--- a/contrib/tcsh/tc.sched.c
+++ b/contrib/tcsh/tc.sched.c
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/tc.sched.c,v 3.21 2004/11/23 02:10:50 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/tc.sched.c,v 3.25 2006/03/02 18:46:45 christos Exp $ */
/*
* tc.sched.c: Scheduled command execution
*
@@ -34,7 +34,7 @@
*/
#include "sh.h"
-RCSID("$Id: tc.sched.c,v 3.21 2004/11/23 02:10:50 christos Exp $")
+RCSID("$tcsh: tc.sched.c,v 3.25 2006/03/02 18:46:45 christos Exp $")
#include "ed.h"
#include "tw.h"
@@ -51,7 +51,7 @@ static struct sched_event *sched_ptr = NULL;
time_t
-sched_next()
+sched_next(void)
{
if (sched_ptr)
return (sched_ptr->t_when);
@@ -60,11 +60,9 @@ sched_next()
/*ARGSUSED*/
void
-dosched(v, c)
- Char **v;
- struct command *c;
+dosched(Char **v, struct command *c)
{
- struct sched_event *tp, *tp1, *tp2;
+ struct sched_event *tp, **pp;
time_t cur_time;
int count, hours, minutes, dif_hour, dif_min;
Char *cp;
@@ -83,17 +81,21 @@ dosched(v, c)
v++;
cp = *v++;
if (cp == NULL) {
- Char *fmt;
+ const Char *fmt;
if ((fmt = varval(STRsched)) == STRNULL)
fmt = str2short("%h\t%T\t%R\n");
/* print list of scheduled events */
for (count = 1, tp = sched_ptr; tp; count++, tp = tp->t_next) {
- Char buf[BUFSIZE], sbuf[BUFSIZE];
- blkexpand(tp->t_lex, buf);
- tprintf(FMT_SCHED, sbuf, fmt, sizeof(sbuf),
- short2str(buf), tp->t_when, (ptr_t) &count);
- for (cp = sbuf; *cp;)
+ Char *buf, *str;
+
+ buf = blkexpand(tp->t_lex);
+ cleanup_push(buf, xfree);
+ str = tprintf(FMT_SCHED, fmt, short2str(buf), tp->t_when, &count);
+ cleanup_until(buf);
+ cleanup_push(str, xfree);
+ for (cp = str; *cp;)
xputwchar(*cp++);
+ cleanup_until(str);
}
return;
}
@@ -107,24 +109,21 @@ dosched(v, c)
count = atoi(short2str(++cp));
if (count <= 0)
stderror(ERR_SCHEDUSAGE);
+ pp = &sched_ptr;
tp = sched_ptr;
- tp1 = 0;
while (--count) {
if (tp->t_next == 0)
break;
else {
- tp1 = tp;
+ pp = &tp->t_next;
tp = tp->t_next;
}
}
if (count)
stderror(ERR_SCHEDEV);
- if (tp1 == 0)
- sched_ptr = tp->t_next;
- else
- tp1->t_next = tp->t_next;
+ *pp = tp->t_next;
blkfree(tp->t_lex);
- xfree((ptr_t) tp);
+ xfree(tp);
return;
}
@@ -167,55 +166,37 @@ dosched(v, c)
dif_hour = 23;
}
}
- tp = (struct sched_event *) xcalloc(1, sizeof *tp);
+ tp = xcalloc(1, sizeof *tp);
#ifdef _SX
tp->t_when = cur_time - ltp->tm_sec + dif_hour * 3600 + dif_min * 60;
-#else /* _SX */
+#else /* _SX */
tp->t_when = cur_time - ltp->tm_sec + dif_hour * 3600L + dif_min * 60L;
#endif /* _SX */
/* use of tm_sec: get to beginning of minute. */
- if (!sched_ptr || tp->t_when < sched_ptr->t_when) {
- tp->t_next = sched_ptr;
- sched_ptr = tp;
- }
- else {
- tp1 = sched_ptr->t_next;
- tp2 = sched_ptr;
- while (tp1 && tp->t_when >= tp1->t_when) {
- tp2 = tp1;
- tp1 = tp1->t_next;
- }
- tp->t_next = tp1;
- tp2->t_next = tp;
- }
+ for (pp = &sched_ptr; *pp != NULL && tp->t_when >= (*pp)->t_when;
+ pp = &(*pp)->t_next)
+ ;
+ tp->t_next = *pp;
+ *pp = tp;
tp->t_lex = saveblk(v);
}
/*
* Execute scheduled events
*/
-/*ARGSUSED*/
void
-sched_run(n)
- int n;
+sched_run(void)
{
time_t cur_time;
- struct sched_event *tp, *tp1;
+ struct sched_event *tp;
struct wordent cmd, *nextword, *lastword;
struct command *t;
Char **v, *cp;
-#ifdef BSDSIGS
- sigmask_t omask;
-
- omask = sigblock(sigmask(SIGINT)) & ~sigmask(SIGINT);
-#else
- (void) sighold(SIGINT);
-#endif
- USE(n);
+ pintr_disabled++;
+ cleanup_push(&pintr_disabled, disabled_cleanup);
(void) time(&cur_time);
- tp = sched_ptr;
/* bugfix by: Justin Bur at Universite de Montreal */
/*
@@ -223,28 +204,24 @@ sched_run(n)
* each prompt (in sh.c). But it is, to catch missed alarms. Someone
* ought to fix it all up. -jbb
*/
- if (!(tp && tp->t_when < cur_time)) {
-#ifdef BSDSIGS
- (void) sigsetmask(omask);
-#else
- (void) sigrelse(SIGINT);
-#endif
+ if (!(sched_ptr && sched_ptr->t_when < cur_time)) {
+ cleanup_until(&pintr_disabled);
return;
}
if (GettingInput)
(void) Cookedmode();
- while (tp && tp->t_when < cur_time) {
+ while ((tp = sched_ptr) != NULL && tp->t_when < cur_time) {
if (seterr) {
- xfree((ptr_t) seterr);
+ xfree(seterr);
seterr = NULL;
}
cmd.word = STRNULL;
lastword = &cmd;
v = tp->t_lex;
for (cp = *v; cp; cp = *++v) {
- nextword = (struct wordent *) xcalloc(1, sizeof cmd);
+ nextword = xcalloc(1, sizeof cmd);
nextword->word = Strsave(cp);
lastword->next = nextword;
nextword->prev = lastword;
@@ -252,21 +229,22 @@ sched_run(n)
}
lastword->next = &cmd;
cmd.prev = lastword;
- tp1 = tp;
- sched_ptr = tp = tp1->t_next; /* looping termination cond: */
- blkfree(tp1->t_lex); /* straighten out in case of */
- xfree((ptr_t) tp1); /* command blow-up. */
+ sched_ptr = tp->t_next; /* looping termination cond: */
+ blkfree(tp->t_lex); /* straighten out in case of */
+ xfree(tp); /* command blow-up. */
+ cleanup_push(&cmd, lex_cleanup);
/* expand aliases like process() does. */
alias(&cmd);
/* build a syntax tree for the command. */
t = syntax(cmd.next, &cmd, 0);
+ cleanup_push(t, syntax_cleanup);
if (seterr)
stderror(ERR_OLD);
/* execute the parse tree. */
execute(t, -1, NULL, NULL, TRUE);
/* done. free the lex list and parse tree. */
- freelex(&cmd), freesyn(t);
+ cleanup_until(&cmd);
}
if (GettingInput && !just_signaled) { /* PWP */
(void) Rawmode();
@@ -276,9 +254,5 @@ sched_run(n)
}
just_signaled = 0;
-#ifdef BSDSIGS
- (void) sigsetmask(omask);
-#else
- (void) sigrelse(SIGINT);
-#endif
+ cleanup_until(&pintr_disabled);
}
diff --git a/contrib/tcsh/tc.sig.c b/contrib/tcsh/tc.sig.c
index 95838b3..343754f 100644
--- a/contrib/tcsh/tc.sig.c
+++ b/contrib/tcsh/tc.sig.c
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/tc.sig.c,v 3.29 2005/01/18 20:24:51 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/tc.sig.c,v 3.36 2006/08/24 20:56:31 christos Exp $ */
/*
* tc.sig.c: Signal routine emulations
*/
@@ -32,377 +32,108 @@
*/
#include "sh.h"
-RCSID("$Id: tc.sig.c,v 3.29 2005/01/18 20:24:51 christos Exp $")
+RCSID("$tcsh: tc.sig.c,v 3.36 2006/08/24 20:56:31 christos Exp $")
#include "tc.wait.h"
-#ifndef BSDSIGS
-
-/* this stack is used to queue signals
- * we can handle up to MAX_CHLD outstanding children now;
- */
-#define MAX_CHLD 50
-
-# ifdef UNRELSIGS
-static struct mysigstack {
- int s_w; /* wait report */
- int s_errno; /* errno returned; */
- pid_t s_pid; /* pid returned */
-} stk[MAX_CHLD];
-static int stk_ptr = -1;
-
-
-/* queue child signals
- */
-static RETSIGTYPE
-sig_ch_queue()
-{
-# ifdef JOBDEBUG
- xprintf("queue SIGCHLD\n");
- flush();
-# endif /* JOBDEBUG */
- stk_ptr++;
- stk[stk_ptr].s_pid = (pid_t) wait(&stk[stk_ptr].s_w);
- stk[stk_ptr].s_errno = errno;
- (void) signal(SIGCHLD, sig_ch_queue);
-}
-
-/* process all awaiting child signals
- */
-static RETSIGTYPE
-sig_ch_rel()
-{
- while (stk_ptr > -1)
- pchild(SIGCHLD);
-# ifdef JOBDEBUG
- xprintf("signal(SIGCHLD, pchild);\n");
-# endif /* JOBDEBUG */
- (void) signal(SIGCHLD, pchild);
-}
-
-
-/* libc.a contains these functions in SYSVREL >= 3. */
-RETSIGTYPE
-(*xsigset(a, b)) ()
- int a;
- signalfun_t b;
-{
- return (signal(a, b));
-}
-
-/* release signal
- * release all queued signals and
- * set the default signal handler
- */
-void
-sigrelse(what)
- int what;
-{
- if (what == SIGCHLD)
- sig_ch_rel();
-
-# ifdef COHERENT
- (void) signal(what, what == SIGINT ? pintr : SIG_DFL);
-# endif /* COHERENT */
-}
-
-/* hold signal
- * only works with child and interrupt
- */
void
-xsighold(what)
- int what;
-{
- if (what == SIGCHLD)
- (void) signal(SIGCHLD, sig_ch_queue);
-
-# ifdef COHERENT
- (void) signal(what, SIG_IGN);
-# endif /* COHERENT */
+sigset_interrupting(int sig, void (*fn) (int))
+{
+ struct sigaction act;
+
+ act.sa_handler = fn;
+ sigemptyset(&act.sa_mask);
+ act.sa_flags = 0;
+ if (sigaction(sig, &act, NULL) == 0) {
+ sigset_t set;
+ sigemptyset(&set);
+ sigaddset(&set, sig);
+ sigprocmask(SIG_UNBLOCK, &set, NULL);
+ }
}
-/* ignore signal
- */
-void
-xsigignore(a)
- int a;
-{
- (void) signal(a, SIG_IGN);
-}
+static volatile sig_atomic_t alrmcatch_pending; /* = 0; */
+static volatile sig_atomic_t pchild_pending; /* = 0; */
+static volatile sig_atomic_t phup_pending; /* = 0; */
+static volatile sig_atomic_t pintr_pending; /* = 0; */
+int alrmcatch_disabled; /* = 0; */
+int phup_disabled; /* = 0; */
+int pchild_disabled; /* = 0; */
+int pintr_disabled; /* = 0; */
-/* atomically release one signal
- */
void
-xsigpause(what)
- int what;
-{
- /* From: Jim Mattson <mattson%cs@ucsd.edu> */
- if (what == SIGCHLD)
- pchild(SIGCHLD);
-}
-
-
-/* return either awaiting processes or do a wait now
- */
-pid_t
-ourwait(w)
- int *w;
+handle_pending_signals(void)
{
- pid_t pid;
-
-# ifdef JOBDEBUG
- xprintf(CGETS(25, 1, "our wait %d\n"), stk_ptr);
- flush();
-# endif /* JOBDEBUG */
-
- if (stk_ptr == -1) {
- /* stack empty return signal from stack */
- pid = (pid_t) wait(w);
-# ifdef JOBDEBUG
- xprintf("signal(SIGCHLD, pchild);\n");
-# endif /* JOBDEBUG */
- (void) signal(SIGCHLD, pchild);
- return (pid);
+ if (!phup_disabled && phup_pending) {
+ phup_pending = 0;
+ phup();
}
- else {
- /* return signal from stack */
- errno = stk[stk_ptr].s_errno;
- *w = stk[stk_ptr].s_w;
- stk_ptr--;
- return (stk[stk_ptr + 1].s_pid);
+ if (!pintr_disabled && pintr_pending) {
+ pintr_pending = 0;
+ pintr();
+ }
+ if (!pchild_disabled && pchild_pending) {
+ pchild_pending = 0;
+ pchild();
+ }
+ if (!alrmcatch_disabled && alrmcatch_pending) {
+ alrmcatch_pending = 0;
+ alrmcatch();
}
-} /* end ourwait */
-
-# ifdef COHERENT
-# undef signal
-RETSIGTYPE
-(*xsignal(a, b)) ()
- int a;
- signalfun_t b;
-{
- if (a == SIGCHLD)
- return SIG_DFL;
- else
- return (signal(a, b));
}
-# endif /* COHERENT */
-# endif /* UNRELSIGS */
-
-# ifdef SXA
-/*
- * SX/A is SYSVREL3 but does not have sys5-sigpause().
- * I've heard that sigpause() is not defined in SYSVREL3.
- */
-/* This is not need if you make tcsh by BSD option's cc. */
void
-sigpause(what)
+queue_alrmcatch(int sig)
{
- if (what == SIGCHLD) {
- (void) bsd_sigpause(bsd_sigblock((sigmask_t) 0) & ~sigmask(SIGBSDCHLD));
- }
- else if (what == 0) {
- pause();
- }
- else {
- xprintf("sigpause(%d)\n", what);
- pause();
- }
+ USE(sig);
+ alrmcatch_pending = 1;
}
-# endif /* SXA */
-#endif /* !BSDSIGS */
-
-#ifdef NEEDsignal
-/* turn into bsd signals */
-RETSIGTYPE
-(*xsignal(s, a)) ()
- int s;
- signalfun_t a;
+void
+queue_pchild(int sig)
{
- sigvec_t osv, sv;
-
- (void) mysigvec(s, NULL, &osv);
- sv = osv;
- sv.sv_handler = a;
-#ifdef SIG_STK
- sv.sv_onstack = SIG_STK;
-#endif /* SIG_STK */
-#ifdef SV_BSDSIG
- sv.sv_flags = SV_BSDSIG;
-#endif /* SV_BSDSIG */
-
- if (mysigvec(s, &sv, NULL) < 0)
- return (BADSIG);
- return (osv.sv_handler);
+ USE(sig);
+ pchild_pending = 1;
}
-#endif /* NEEDsignal */
-
-#ifdef POSIXSIGS
-/*
- * Support for signals.
- */
-
-extern int errno;
-
-/* Set and test a bit. Bits numbered 1 to 32 */
-
-#define SETBIT(x, y) x |= sigmask(y)
-#define ISSET(x, y) ((x & sigmask(y)) != 0)
-
-#ifdef DEBUG
-# define SHOW_SIGNALS 1 /* to assist in debugging signals */
-#endif /* DEBUG */
-
-#ifdef SHOW_SIGNALS
-char *show_sig_mask();
-#endif /* SHOW_SIGNALS */
-
-#ifndef __PARAGON__
-/*
- * sigsetmask(mask)
- *
- * Set a new signal mask. Return old mask.
- */
-sigmask_t
-sigsetmask(mask)
- sigmask_t mask;
+void
+queue_phup(int sig)
{
- sigset_t set, oset;
- int m;
- int i;
-
- (void) sigemptyset(&set);
- (void) sigemptyset(&oset);
-
- for (i = 1; i <= MAXSIG; i++)
- if (ISSET(mask, i))
- (void) sigaddset(&set, i);
-
- if ((sigprocmask(SIG_SETMASK, &set, &oset)) == -1) {
- xprintf("sigsetmask(0x%x) - sigprocmask failed, errno %d",
- mask, errno);
- }
-
- m = 0;
- for (i = 1; i <= MAXSIG; i++)
- if (sigismember(&oset, i) == 1)
- SETBIT(m, i);
-
- return (m);
+ USE(sig);
+ phup_pending = 1;
}
-#endif /* __PARAGON__ */
-#ifndef __DGUX__
-/*
- * sigblock(mask)
- *
- * Add "mask" set of signals to the present signal mask.
- * Return old mask.
- */
-sigmask_t
-sigblock(mask)
- sigmask_t mask;
+void
+queue_pintr(int sig)
{
- sigset_t set, oset;
- int m;
- int i;
-
- (void) sigemptyset(&set);
- (void) sigemptyset(&oset);
-
- /* Get present set of signals. */
- if ((sigprocmask(SIG_SETMASK, NULL, &set)) == -1)
- stderror(ERR_SYSTEM, "sigprocmask", strerror(errno));
-
- /* Add in signals from mask. */
- for (i = 1; i <= MAXSIG; i++)
- if (ISSET(mask, i))
- (void) sigaddset(&set, i);
-
- if ((sigprocmask(SIG_SETMASK, &set, &oset)) == -1)
- stderror(ERR_SYSTEM, "sigprocmask", strerror(errno));
-
- /* Return old mask to user. */
- m = 0;
- for (i = 1; i <= MAXSIG; i++)
- if (sigismember(&oset, i) == 1)
- SETBIT(m, i);
-
- return (m);
+ USE(sig);
+ pintr_pending = 1;
}
-#endif /* __DGUX__ */
-
-/*
- * bsd_sigpause(mask)
- *
- * Set new signal mask and wait for signal;
- * Old mask is restored on signal.
- */
void
-bsd_sigpause(mask)
- sigmask_t mask;
+disabled_cleanup(void *xdisabled)
{
- sigset_t set;
- int i;
+ int *disabled;
- (void) sigemptyset(&set);
-
- for (i = 1; i <= MAXSIG; i++)
- if (ISSET(mask, i))
- (void) sigaddset(&set, i);
- (void) sigsuspend(&set);
+ disabled = xdisabled;
+ if (--*disabled == 0)
+ handle_pending_signals();
}
-/*
- * bsd_signal(sig, func)
- *
- * Emulate bsd style signal()
- */
-RETSIGTYPE (*bsd_signal(sig, func)) ()
- int sig;
- signalfun_t func;
+void
+pintr_disabled_restore(void *xold)
{
- struct sigaction act, oact;
- sigset_t set;
- signalfun_t r_func;
-
- if (sig < 0 || sig > MAXSIG) {
- xprintf(CGETS(25, 2,
- "error: bsd_signal(%d) signal out of range\n"), sig);
- return((signalfun_t) SIG_IGN);
- }
+ int *old;
- (void) sigemptyset(&set);
-
- act.sa_handler = (signalfun_t) func; /* user function */
- act.sa_mask = set; /* signal mask */
- act.sa_flags = 0; /* no special actions */
-
- if (sigaction(sig, &act, &oact)) {
- xprintf(CGETS(25, 3,
- "error: bsd_signal(%d) - sigaction failed, errno %d\n"),
- sig, errno);
- return((signalfun_t) SIG_IGN);
- }
-
- r_func = (signalfun_t) oact.sa_handler;
- return(r_func);
+ old = xold;
+ pintr_disabled = *old;
}
-#endif /* POSIXSIG */
-
-#ifdef SIGSYNCH
-static long Synch_Cnt = 0;
-
-RETSIGTYPE
-synch_handler(sno)
-int sno;
+void
+pintr_push_enable(int *saved)
{
- if (sno != SIGSYNCH)
- abort();
- Synch_Cnt++;
+ *saved = pintr_disabled;
+ pintr_disabled = 0;
+ cleanup_push(saved, pintr_disabled_restore);
+ handle_pending_signals();
}
-#endif /* SIGSYNCH */
diff --git a/contrib/tcsh/tc.sig.h b/contrib/tcsh/tc.sig.h
index 2a6637e..3578181 100644
--- a/contrib/tcsh/tc.sig.h
+++ b/contrib/tcsh/tc.sig.h
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/tc.sig.h,v 3.28 2005/01/18 20:24:51 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/tc.sig.h,v 3.32 2006/03/11 15:32:00 mitr Exp $ */
/*
* tc.sig.h: Signal handling
*
@@ -43,55 +43,9 @@
# include <sys/signal.h>
#endif /* SYSVREL > 0 */
-#if defined(__APPLE__) || defined(SUNOS4) || defined(DGUX) || defined(hp800) || (SYSVREL > 3 && defined(POSIXSIGS) && defined(VFORK))
+#if defined(__APPLE__) || defined(SUNOS4) || defined(DGUX) || defined(hp800) || (SYSVREL > 3 && defined(VFORK))
# define SAVESIGVEC
-#endif /* SUNOS4 || DGUX || hp800 || SVR4 & POSIXSIGS & VFORK */
-
-#if (SYSVREL > 0 && SYSVREL < 3 && !defined(BSDSIGS)) || defined(_MINIX) || defined(COHERENT)
-/*
- * If we have unreliable signals...
- */
-# define UNRELSIGS
-#endif /* SYSVREL > 0 && SYSVREL < 3 && !BSDSIGS || _MINIX || COHERENT */
-
-#ifdef BSDSIGS
-/*
- * sigvec is not the same everywhere
- */
-# if defined(_SEQUENT_) || (defined(_POSIX_SOURCE) && !defined(hpux))
-# define HAVE_SIGVEC
-# define mysigvec(a, b, c) sigaction(a, b, c)
-typedef struct sigaction sigvec_t;
-/* eliminate compiler warnings since these are defined in signal.h */
-# undef sv_handler
-# undef sv_flags
-# define sv_handler sa_handler
-# define sv_flags sa_flags
-# endif /* _SEQUENT || (_POSIX_SOURCE && !hpux) */
-
-# ifdef hpux
-# define HAVE_SIGVEC
-# define mysigvec(a, b, c) sigvector(a, b, c)
-typedef struct sigvec sigvec_t;
-# define NEEDsignal
-# endif /* hpux */
-
-# ifndef HAVE_SIGVEC
-# ifdef POSIXSIGS
-# define mysigvec(a, b, c) sigaction(a, b, c)
-typedef struct sigaction sigvec_t;
-# undef sv_handler
-# undef sv_flags
-# define sv_handler sa_handler
-# define sv_flags sa_flags
-# else /* BSDSIGS */
-# define mysigvec(a, b, c) sigvec(a, b, c)
-typedef struct sigvec sigvec_t;
-# endif /* POSIXSIGS */
-# endif /* HAVE_SIGVEC */
-
-# undef HAVE_SIGVEC
-#endif /* BSDSIGS */
+#endif /* SUNOS4 || DGUX || hp800 || SVR4 & VFORK */
#if SYSVREL > 0
# ifdef BSDJOBS
@@ -124,6 +78,11 @@ typedef struct sigvec sigvec_t;
# define killpg(a, b) kill(-(a), (b))
#endif /* atp _VMS_POSIX */
+#ifdef aiws
+# undef killpg
+# define killpg(a, b) kill(-getpgrp(a), b)
+#endif /* aiws */
+
#if !defined(NSIG) && defined(SIGMAX)
# define NSIG (SIGMAX+1)
#endif /* !NSIG && SIGMAX */
@@ -140,35 +99,6 @@ typedef struct sigvec sigvec_t;
# define MAXSIG NSIG
#endif /* !MAXSIG && NSIG */
-#ifdef BSDSIGS
-/*
- * For 4.2bsd signals.
- */
-# ifdef sigmask
-# undef sigmask
-# endif /* sigmask */
-# define sigmask(s) (1 << ((s)-1))
-# ifdef POSIXSIGS
-# define sigpause(a) (void) bsd_sigpause(a)
-# ifdef WINNT_NATIVE
-# undef signal
-# endif /* WINNT_NATIVE */
-# define signal(a, b) bsd_signal(a, b)
-# endif /* POSIXSIGS */
-# ifndef _SEQUENT_
-# define sighold(s) sigblock(sigmask(s))
-# define sigignore(s) signal(s, SIG_IGN)
-# define sigset(s, a) signal(s, a)
-# endif /* !_SEQUENT_ */
-# ifdef aiws
-# define sigrelse(a) sigsetmask(sigblock(0) & ~sigmask(a))
-# undef killpg
-# define killpg(a, b) kill(-getpgrp(a), b)
-# define NEEDsignal
-# endif /* aiws */
-#endif /* BSDSIGS */
-
-
/*
* We choose a define for the window signal if it exists..
*/
@@ -180,19 +110,6 @@ typedef struct sigvec sigvec_t;
# endif /* SIGWINDOW */
#endif /* SIGWINCH */
-#ifdef convex
-# ifdef notdef
-/* Does not seem to work right... Christos */
-# define SIGSYNCH 0
-# endif
-# ifdef SIGSYNCH
-# define SYNCHMASK (sigmask(SIGCHLD)|sigmask(SIGSYNCH))
-# else
-# define SYNCHMASK (sigmask(SIGCHLD))
-# endif
-extern RETSIGTYPE synch_handler();
-#endif /* convex */
-
#ifdef SAVESIGVEC
# define NSIGSAVED 7
/*
@@ -201,28 +118,56 @@ extern RETSIGTYPE synch_handler();
* nice, since it can make the compiler put some things that we want saved
* into registers - christos
*/
-# define savesigvec(sv) \
- ((void) mysigvec(SIGINT, (sigvec_t *) 0, &(sv)[0]), \
- (void) mysigvec(SIGQUIT, (sigvec_t *) 0, &(sv)[1]), \
- (void) mysigvec(SIGTSTP, (sigvec_t *) 0, &(sv)[2]), \
- (void) mysigvec(SIGTTIN, (sigvec_t *) 0, &(sv)[3]), \
- (void) mysigvec(SIGTTOU, (sigvec_t *) 0, &(sv)[4]), \
- (void) mysigvec(SIGTERM, (sigvec_t *) 0, &(sv)[5]), \
- (void) mysigvec(SIGHUP, (sigvec_t *) 0, &(sv)[6]), \
- sigblock(sigmask(SIGINT) | sigmask(SIGQUIT) | \
- sigmask(SIGTSTP) | sigmask(SIGTTIN) | \
- sigmask(SIGTTOU) | sigmask(SIGTERM) | \
- sigmask(SIGHUP)))
-
-# define restoresigvec(sv, sm) \
- (void) ((void) mysigvec(SIGINT, &(sv)[0], (sigvec_t *) 0), \
- (void) mysigvec(SIGQUIT, &(sv)[1], (sigvec_t *) 0), \
- (void) mysigvec(SIGTSTP, &(sv)[2], (sigvec_t *) 0), \
- (void) mysigvec(SIGTTIN, &(sv)[3], (sigvec_t *) 0), \
- (void) mysigvec(SIGTTOU, &(sv)[4], (sigvec_t *) 0), \
- (void) mysigvec(SIGTERM, &(sv)[5], (sigvec_t *) 0), \
- (void) mysigvec(SIGHUP, &(sv)[6], (sigvec_t *) 0), \
- (void) sigsetmask(sm))
+# define savesigvec(sv, sm) \
+ do { \
+ sigset_t m__; \
+ \
+ sigaction(SIGINT, NULL, &(sv)[0]); \
+ sigaction(SIGQUIT, NULL, &(sv)[1]); \
+ sigaction(SIGTSTP, NULL, &(sv)[2]); \
+ sigaction(SIGTTIN, NULL, &(sv)[3]); \
+ sigaction(SIGTTOU, NULL, &(sv)[4]); \
+ sigaction(SIGTERM, NULL, &(sv)[5]); \
+ sigaction(SIGHUP, NULL, &(sv)[6]); \
+ sigemptyset(&m__); \
+ sigaddset(&m__, SIGINT); \
+ sigaddset(&m__, SIGQUIT); \
+ sigaddset(&m__, SIGTSTP); \
+ sigaddset(&m__, SIGTTIN); \
+ sigaddset(&m__, SIGTTOU); \
+ sigaddset(&m__, SIGTERM); \
+ sigaddset(&m__, SIGHUP); \
+ sigprocmask(SIG_BLOCK, &m__, &sm); \
+ } while (0)
+
+# define restoresigvec(sv, sm) \
+ do { \
+ sigaction(SIGINT, &(sv)[0], NULL); \
+ sigaction(SIGQUIT, &(sv)[1], NULL); \
+ sigaction(SIGTSTP, &(sv)[2], NULL); \
+ sigaction(SIGTTIN, &(sv)[3], NULL); \
+ sigaction(SIGTTOU, &(sv)[4], NULL); \
+ sigaction(SIGTERM, &(sv)[5], NULL); \
+ sigaction(SIGHUP, &(sv)[6], NULL); \
+ sigprocmask(SIG_SETMASK, &sm, NULL); \
+ } while (0)
# endif /* SAVESIGVEC */
+extern int alrmcatch_disabled;
+extern int pchild_disabled;
+extern int phup_disabled;
+extern int pintr_disabled;
+
+extern void sigset_interrupting(int, void (*) (int));
+extern void handle_pending_signals(void);
+
+extern void queue_alrmcatch(int);
+extern void queue_pchild(int);
+extern void queue_phup(int);
+extern void queue_pintr(int);
+
+extern void disabled_cleanup(void *);
+extern void pintr_disabled_restore(void *);
+extern void pintr_push_enable(int *);
+
#endif /* _h_tc_sig */
diff --git a/contrib/tcsh/tc.str.c b/contrib/tcsh/tc.str.c
index 27c4463..b94671e 100644
--- a/contrib/tcsh/tc.str.c
+++ b/contrib/tcsh/tc.str.c
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/tc.str.c,v 3.19 2005/01/06 16:56:26 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/tc.str.c,v 3.26 2006/03/02 18:46:45 christos Exp $ */
/*
* tc.str.c: Short string package
* This has been a lesson of how to write buggy code!
@@ -35,7 +35,7 @@
#include <limits.h>
-RCSID("$Id: tc.str.c,v 3.19 2005/01/06 16:56:26 christos Exp $")
+RCSID("$tcsh: tc.str.c,v 3.26 2006/03/02 18:46:45 christos Exp $")
#define MALLOC_INCR 128
#ifdef WIDE_STRINGS
@@ -77,9 +77,7 @@ one_wctomb(char *s, wchar_t wchar)
}
return len;
}
-#endif
-
-#ifdef SHORT_STRINGS
+
int
rt_mbtowc(wchar_t *pwc, const char *s, size_t n)
{
@@ -91,10 +89,11 @@ rt_mbtowc(wchar_t *pwc, const char *s, size_t n)
ret = -1;
return ret;
}
+#endif
+#ifdef SHORT_STRINGS
Char **
-blk2short(src)
- char **src;
+blk2short(char **src)
{
size_t n;
Char **sdst, **dst;
@@ -104,7 +103,7 @@ blk2short(src)
*/
for (n = 0; src[n] != NULL; n++)
continue;
- sdst = dst = (Char **) xmalloc((size_t) ((n + 1) * sizeof(Char *)));
+ sdst = dst = xmalloc((n + 1) * sizeof(Char *));
for (; *src != NULL; src++)
*dst++ = SAVE(*src);
@@ -113,8 +112,7 @@ blk2short(src)
}
char **
-short2blk(src)
- Char **src;
+short2blk(Char **src)
{
size_t n;
char **sdst, **dst;
@@ -124,7 +122,7 @@ short2blk(src)
*/
for (n = 0; src[n] != NULL; n++)
continue;
- sdst = dst = (char **) xmalloc((size_t) ((n + 1) * sizeof(char *)));
+ sdst = dst = xmalloc((n + 1) * sizeof(char *));
for (; *src != NULL; src++)
*dst++ = strsave(short2str(*src));
@@ -133,41 +131,26 @@ short2blk(src)
}
Char *
-str2short(src)
- const char *src;
+str2short(const char *src)
{
- static Char *sdst;
- static size_t dstsize = 0;
- Char *dst, *edst;
+ static struct Strbuf buf; /* = Strbuf_INIT; */
if (src == NULL)
return (NULL);
- if (sdst == (NULL)) {
- dstsize = MALLOC_INCR;
- sdst = (Char *) xmalloc((size_t) (dstsize * sizeof(Char)));
- }
+ buf.len = 0;
+ while (*src) {
+ Char wc;
- dst = sdst;
- edst = &dst[dstsize];
- while ((unsigned char) *src) {
- src += one_mbtowc(dst, src, MB_LEN_MAX);
- dst++;
- if (dst == edst) {
- dstsize += MALLOC_INCR;
- sdst = (Char *) xrealloc((ptr_t) sdst,
- (size_t) (dstsize * sizeof(Char)));
- edst = &sdst[dstsize];
- dst = &edst[-MALLOC_INCR];
- }
+ src += one_mbtowc(&wc, src, MB_LEN_MAX);
+ Strbuf_append1(&buf, wc);
}
- *dst = 0;
- return (sdst);
+ Strbuf_terminate(&buf);
+ return buf.s;
}
char *
-short2str(src)
- const Char *src;
+short2str(const Char *src)
{
static char *sdst = NULL;
static size_t dstsize = 0;
@@ -178,8 +161,7 @@ short2str(src)
if (sdst == NULL) {
dstsize = MALLOC_INCR;
- sdst = (char *) xmalloc((size_t) ((dstsize + MALLOC_SURPLUS)
- * sizeof(char)));
+ sdst = xmalloc((dstsize + MALLOC_SURPLUS) * sizeof(char));
}
dst = sdst;
edst = &dst[dstsize];
@@ -188,9 +170,7 @@ short2str(src)
src++;
if (dst >= edst) {
dstsize += MALLOC_INCR;
- sdst = (char *) xrealloc((ptr_t) sdst,
- (size_t) ((dstsize + MALLOC_SURPLUS)
- * sizeof(char)));
+ sdst = xrealloc(sdst, (dstsize + MALLOC_SURPLUS) * sizeof(char));
edst = &sdst[dstsize];
dst = &edst[-MALLOC_INCR];
}
@@ -201,9 +181,7 @@ short2str(src)
#ifndef WIDE_STRINGS
Char *
-s_strcpy(dst, src)
- Char *dst;
- const Char *src;
+s_strcpy(Char *dst, const Char *src)
{
Char *sdst;
@@ -214,10 +192,7 @@ s_strcpy(dst, src)
}
Char *
-s_strncpy(dst, src, n)
- Char *dst;
- const Char *src;
- size_t n;
+s_strncpy(Char *dst, const Char *src, size_t n)
{
Char *sdst;
@@ -236,27 +211,15 @@ s_strncpy(dst, src, n)
}
Char *
-s_strcat(dst, src)
- Char *dst;
- const Char *src;
+s_strcat(Char *dst, const Char *src)
{
- Char *sdst;
-
- sdst = dst;
- while (*dst++)
- continue;
- --dst;
- while ((*dst++ = *src++) != '\0')
- continue;
- return (sdst);
+ Strcpy(Strend(dst), src);
+ return dst;
}
#ifdef NOTUSED
Char *
-s_strncat(dst, src, n)
- Char *dst;
- const Char *src;
- size_t n;
+s_strncat(Char *dst, const Char *src, size_t n)
{
Char *sdst;
@@ -265,9 +228,8 @@ s_strncat(dst, src, n)
sdst = dst;
- while (*dst++)
- continue;
- --dst;
+ while (*dst)
+ dst++;
do
if ((*dst++ = *src++) == '\0')
@@ -282,9 +244,7 @@ s_strncat(dst, src, n)
#endif
Char *
-s_strchr(str, ch)
- const Char *str;
- int ch;
+s_strchr(const Char *str, int ch)
{
do
if (*str == ch)
@@ -294,9 +254,7 @@ s_strchr(str, ch)
}
Char *
-s_strrchr(str, ch)
- const Char *str;
- int ch;
+s_strrchr(const Char *str, int ch)
{
const Char *rstr;
@@ -309,8 +267,7 @@ s_strrchr(str, ch)
}
size_t
-s_strlen(str)
- const Char *str;
+s_strlen(const Char *str)
{
size_t n;
@@ -320,8 +277,7 @@ s_strlen(str)
}
int
-s_strcmp(str1, str2)
- const Char *str1, *str2;
+s_strcmp(const Char *str1, const Char *str2)
{
for (; *str1 && *str1 == *str2; str1++, str2++)
continue;
@@ -341,9 +297,7 @@ s_strcmp(str1, str2)
}
int
-s_strncmp(str1, str2, n)
- const Char *str1, *str2;
- size_t n;
+s_strncmp(const Char *str1, const Char *str2, size_t n)
{
if (n == 0)
return (0);
@@ -370,8 +324,7 @@ s_strncmp(str1, str2, n)
#endif /* not WIDE_STRINGS */
int
-s_strcasecmp(str1, str2)
- const Char *str1, *str2;
+s_strcasecmp(const Char *str1, const Char *str2)
{
#ifdef WIDE_STRINGS
wchar_t l1 = 0, l2 = 0;
@@ -405,51 +358,54 @@ s_strcasecmp(str1, str2)
}
Char *
-s_strsave(s)
- const Char *s;
+s_strnsave(const Char *s, size_t len)
+{
+ Char *n;
+
+ n = xmalloc((len + 1) * sizeof (*n));
+ memcpy(n, s, len * sizeof (*n));
+ n[len] = '\0';
+ return n;
+}
+
+Char *
+s_strsave(const Char *s)
{
Char *n;
- Char *p;
+ size_t size;
- if (s == 0)
+ if (s == NULL)
s = STRNULL;
- for (p = (Char *)(intptr_t)s; *p++;)
- continue;
- n = p = (Char *) xmalloc((size_t)
- ((((const Char *) p) - s) * sizeof(Char)));
- while ((*p++ = *s++) != '\0')
- continue;
+ size = (Strlen(s) + 1) * sizeof(*n);
+ n = xmalloc(size);
+ memcpy(n, s, size);
return (n);
}
Char *
-s_strspl(cp, dp)
- const Char *cp, *dp;
+s_strspl(const Char *cp, const Char *dp)
{
- Char *ep;
- Char *p, *q;
+ Char *res, *ep;
+ const Char *p, *q;
if (!cp)
cp = STRNULL;
if (!dp)
dp = STRNULL;
- for (p = (Char *)(intptr_t) cp; *p++;)
+ for (p = cp; *p++;)
continue;
- for (q = (Char *)(intptr_t) dp; *q++;)
+ for (q = dp; *q++;)
continue;
- ep = (Char *) xmalloc((size_t)
- (((((const Char *) p) - cp) +
- (((const Char *) q) - dp) - 1) * sizeof(Char)));
- for (p = ep, q = (Char*)(intptr_t) cp; (*p++ = *q++) != '\0';)
+ res = xmalloc(((p - cp) + (q - dp) - 1) * sizeof(Char));
+ for (ep = res, q = cp; (*ep++ = *q++) != '\0';)
continue;
- for (p--, q = (Char *)(intptr_t) dp; (*p++ = *q++) != '\0';)
+ for (ep--, q = dp; (*ep++ = *q++) != '\0';)
continue;
- return (ep);
+ return (res);
}
Char *
-s_strend(cp)
- const Char *cp;
+s_strend(const Char *cp)
{
if (!cp)
return ((Char *)(intptr_t) cp);
@@ -459,8 +415,7 @@ s_strend(cp)
}
Char *
-s_strstr(s, t)
- const Char *s, *t;
+s_strstr(const Char *s, const Char *t)
{
do {
const Char *ss = s;
@@ -474,11 +429,29 @@ s_strstr(s, t)
return (NULL);
}
-#endif /* SHORT_STRINGS */
+#else /* !SHORT_STRINGS */
+char *
+caching_strip(const char *s)
+{
+ static char *buf = NULL;
+ static size_t buf_size = 0;
+ size_t size;
+
+ if (s == NULL)
+ return NULL;
+ size = strlen(s) + 1;
+ if (buf_size < size) {
+ buf = xrealloc(buf, size);
+ buf_size = size;
+ }
+ memcpy(buf, s, size);
+ strip(buf);
+ return buf;
+}
+#endif
char *
-short2qstr(src)
- const Char *src;
+short2qstr(const Char *src)
{
static char *sdst = NULL;
static size_t dstsize = 0;
@@ -489,8 +462,7 @@ short2qstr(src)
if (sdst == NULL) {
dstsize = MALLOC_INCR;
- sdst = (char *) xmalloc((size_t) ((dstsize + MALLOC_SURPLUS)
- * sizeof(char)));
+ sdst = xmalloc((dstsize + MALLOC_SURPLUS) * sizeof(char));
}
dst = sdst;
edst = &dst[dstsize];
@@ -499,9 +471,8 @@ short2qstr(src)
*dst++ = '\\';
if (dst == edst) {
dstsize += MALLOC_INCR;
- sdst = (char *) xrealloc((ptr_t) sdst,
- (size_t) ((dstsize + MALLOC_SURPLUS)
- * sizeof(char)));
+ sdst = xrealloc(sdst,
+ (dstsize + MALLOC_SURPLUS) * sizeof(char));
edst = &sdst[dstsize];
dst = &edst[-MALLOC_INCR];
}
@@ -510,9 +481,7 @@ short2qstr(src)
src++;
if (dst >= edst) {
dstsize += MALLOC_INCR;
- sdst = (char *) xrealloc((ptr_t) sdst,
- (size_t) ((dstsize + MALLOC_SURPLUS)
- * sizeof(char)));
+ sdst = xrealloc(sdst, (dstsize + MALLOC_SURPLUS) * sizeof(char));
edst = &sdst[dstsize];
dst = &edst[-MALLOC_INCR];
}
@@ -520,3 +489,111 @@ short2qstr(src)
*dst = 0;
return (sdst);
}
+
+static void
+bb_store(struct blk_buf *bb, Char *str)
+{
+ if (bb->len == bb->size) { /* Keep space for terminating NULL */
+ if (bb->size == 0)
+ bb->size = 16; /* Arbitrary */
+ else
+ bb->size *= 2;
+ bb->vec = xrealloc(bb->vec, bb->size * sizeof (*bb->vec));
+ }
+ bb->vec[bb->len] = str;
+}
+
+void
+bb_append(struct blk_buf *bb, Char *str)
+{
+ bb_store(bb, str);
+ bb->len++;
+}
+
+void
+bb_cleanup(void *xbb)
+{
+ struct blk_buf *bb;
+ size_t i;
+
+ bb = xbb;
+ for (i = 0; i < bb->len; i++)
+ xfree(bb->vec[i]);
+ xfree(bb->vec);
+}
+
+Char **
+bb_finish(struct blk_buf *bb)
+{
+ bb_store(bb, NULL);
+ return xrealloc(bb->vec, (bb->len + 1) * sizeof (*bb->vec));
+}
+
+#define DO_STRBUF(STRBUF, CHAR, STRLEN) \
+static void \
+STRBUF##_store1(struct STRBUF *buf, CHAR c) \
+{ \
+ if (buf->size == buf->len) { \
+ if (buf->size == 0) \
+ buf->size = 64; /* Arbitrary */ \
+ else \
+ buf->size *= 2; \
+ buf->s = xrealloc(buf->s, buf->size * sizeof(*buf->s)); \
+ } \
+ buf->s[buf->len] = c; \
+} \
+ \
+/* Like strbuf_append1(buf, '\0'), but don't advance len */ \
+void \
+STRBUF##_terminate(struct STRBUF *buf) \
+{ \
+ STRBUF##_store1(buf, '\0'); \
+} \
+ \
+void \
+STRBUF##_append1(struct STRBUF *buf, CHAR c) \
+{ \
+ STRBUF##_store1(buf, c); \
+ buf->len++; \
+} \
+ \
+void \
+STRBUF##_appendn(struct STRBUF *buf, const CHAR *s, size_t len) \
+{ \
+ if (buf->size < buf->len + len) { \
+ if (buf->size == 0) \
+ buf->size = 64; /* Arbitrary */ \
+ while (buf->size < buf->len + len) \
+ buf->size *= 2; \
+ buf->s = xrealloc(buf->s, buf->size * sizeof(*buf->s)); \
+ } \
+ memcpy(buf->s + buf->len, s, len * sizeof(*buf->s)); \
+ buf->len += len; \
+} \
+ \
+void \
+STRBUF##_append(struct STRBUF *buf, const CHAR *s) \
+{ \
+ STRBUF##_appendn(buf, s, STRLEN(s)); \
+} \
+ \
+CHAR * \
+STRBUF##_finish(struct STRBUF *buf) \
+{ \
+ STRBUF##_append1(buf, 0); \
+ return xrealloc(buf->s, buf->len * sizeof(*buf->s)); \
+} \
+ \
+void \
+STRBUF##_cleanup(void *xbuf) \
+{ \
+ struct STRBUF *buf; \
+ \
+ buf = xbuf; \
+ xfree(buf->s); \
+} \
+ \
+const struct STRBUF STRBUF##_init /* = STRBUF##_INIT; */
+
+DO_STRBUF(strbuf, char, strlen);
+DO_STRBUF(Strbuf, Char, Strlen);
diff --git a/contrib/tcsh/tc.vers.c b/contrib/tcsh/tc.vers.c
index 1ed2160..b93e176 100644
--- a/contrib/tcsh/tc.vers.c
+++ b/contrib/tcsh/tc.vers.c
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/tc.vers.c,v 3.50 2004/08/04 17:12:31 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/tc.vers.c,v 3.54 2006/03/02 18:46:45 christos Exp $ */
/*
* tc.vers.c: Version dependent stuff
*/
@@ -33,7 +33,7 @@
#include "sh.h"
#include "tw.h"
-RCSID("$Id: tc.vers.c,v 3.50 2004/08/04 17:12:31 christos Exp $")
+RCSID("$tcsh: tc.vers.c,v 3.54 2006/03/02 18:46:45 christos Exp $")
#include "patchlevel.h"
@@ -43,7 +43,7 @@ RCSID("$Id: tc.vers.c,v 3.50 2004/08/04 17:12:31 christos Exp $")
* options that might affect the user.
*/
void
-fix_version()
+fix_version(void)
{
#ifdef WIDE_STRINGS
# define SSSTR "wide"
@@ -146,10 +146,10 @@ fix_version()
#ifndef LOCALSTR
# define LOCALSTR ""
#endif /* LOCALSTR */
- char version[BUFSIZE];
- Char *machtype = tgetenv(STRMACHTYPE);
- Char *vendor = tgetenv(STRVENDOR);
- Char *ostype = tgetenv(STROSTYPE);
+ char *version;
+ const Char *machtype = tgetenv(STRMACHTYPE);
+ const Char *vendor = tgetenv(STRVENDOR);
+ const Char *ostype = tgetenv(STROSTYPE);
if (vendor == NULL)
vendor = STRunknown;
@@ -159,14 +159,17 @@ fix_version()
ostype = STRunknown;
- (void) xsnprintf(version, sizeof(version),
+ version = xasprintf(
"tcsh %d.%.2d.%.2d (%s) %s (%S-%S-%S) options %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
REV, VERS, PATCHLEVEL, ORIGIN, DATE, machtype, vendor, ostype,
SSSTR, NLSSTR, LFSTR, DLSTR, VISTR, DTRSTR, BYESTR,
ALSTR, KANSTR, SMSTR, HBSTR, NGSTR, RHSTR, AFSSTR, NDSTR,
COLORSTR, DSPMSTR, CCATSTR, FILECSTR, LOCALSTR);
- set(STRversion, SAVE(version), VAR_READWRITE);
- (void) xsnprintf(version, sizeof(version), "%d.%.2d.%.2d",
- REV, VERS, PATCHLEVEL);
- set(STRtcsh, SAVE(version), VAR_READWRITE);
+ cleanup_push(version, xfree);
+ setcopy(STRversion, str2short(version), VAR_READWRITE);
+ cleanup_until(version);
+ version = xasprintf("%d.%.2d.%.2d", REV, VERS, PATCHLEVEL);
+ cleanup_push(version, xfree);
+ setcopy(STRtcsh, str2short(version), VAR_READWRITE);
+ cleanup_until(version);
}
diff --git a/contrib/tcsh/tc.wait.h b/contrib/tcsh/tc.wait.h
index b601705..4bda506 100644
--- a/contrib/tcsh/tc.wait.h
+++ b/contrib/tcsh/tc.wait.h
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/tc.wait.h,v 3.14 2004/12/25 21:15:08 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/tc.wait.h,v 3.14 2004/12/25 21:15:08 christos Exp $ */
/*
* tc.wait.h: <sys/wait.h> for machines that don't have it or have it and
* is incorrect.
diff --git a/contrib/tcsh/tc.who.c b/contrib/tcsh/tc.who.c
index c3d00b5..2aa0686 100644
--- a/contrib/tcsh/tc.who.c
+++ b/contrib/tcsh/tc.who.c
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/tc.who.c,v 3.44 2005/03/03 23:44:45 kim Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/tc.who.c,v 3.51 2006/03/03 22:08:45 amold Exp $ */
/*
* tc.who.c: Watch logins and logouts...
*/
@@ -32,7 +32,7 @@
*/
#include "sh.h"
-RCSID("$Id: tc.who.c,v 3.44 2005/03/03 23:44:45 kim Exp $")
+RCSID("$tcsh: tc.who.c,v 3.51 2006/03/03 22:08:45 amold Exp $")
#include "tc.h"
@@ -135,9 +135,9 @@ static struct who whohead, whotail;
static time_t watch_period = 0;
static time_t stlast = 0;
#ifdef WHODEBUG
-static void debugwholist __P((struct who *, struct who *));
+static void debugwholist (struct who *, struct who *);
#endif
-static void print_who __P((struct who *));
+static void print_who (struct who *);
#define ONLINE 01
@@ -145,6 +145,7 @@ static void print_who __P((struct who *));
#define CHANGED 04
#define STMASK 07
#define ANNOUNCE 010
+#define CLEARED 020
/*
* Karl Kleinpaste, 26 Jan 1984.
@@ -153,7 +154,7 @@ static void print_who __P((struct who *));
* when doing pointer-chase searches.
*/
void
-initwatch()
+initwatch(void)
{
whohead.who_next = &whotail;
whotail.who_prev = &whohead;
@@ -164,7 +165,7 @@ initwatch()
}
void
-resetwatch()
+resetwatch(void)
{
watch_period = 0;
stlast = 0;
@@ -175,8 +176,7 @@ resetwatch()
* Watch /etc/utmp for login/logout changes.
*/
void
-watch_login(force)
- int force;
+watch_login(int force)
{
int comp = -1, alldone;
int firsttime = stlast == 1;
@@ -185,9 +185,6 @@ watch_login(force)
#else
int utmpfd;
#endif
-#ifdef BSDSIGS
- sigmask_t omask;
-#endif /* BSDSIGS */
struct utmp utmp;
struct who *wp, *wpnew;
struct varent *v;
@@ -206,19 +203,12 @@ watch_login(force)
#endif /* WINNT_NATIVE */
/* stop SIGINT, lest our login list get trashed. */
-#ifdef BSDSIGS
- omask = sigblock(sigmask(SIGINT));
-#else
- (void) sighold(SIGINT);
-#endif
+ pintr_disabled++;
+ cleanup_push(&pintr_disabled, disabled_cleanup);
v = adrof(STRwatch);
if ((v == NULL || v->vec == NULL) && !force) {
-#ifdef BSDSIGS
- (void) sigsetmask(omask);
-#else
- (void) sigrelse(SIGINT);
-#endif
+ cleanup_until(&pintr_disabled);
return; /* no names to watch */
}
if (!force) {
@@ -236,7 +226,7 @@ watch_login(force)
* before we are due -amol 6/5/97
*/
if (!ncbs_posted) {
- unsigned long tdiff = t - watch_period;
+ time_t tdiff = t - watch_period;
if (!watch_period || ((tdiff > 0) && (tdiff > (interval - 90)))) {
start_ncbs(vp);
ncbs_posted = 1;
@@ -244,11 +234,7 @@ watch_login(force)
}
#endif /* WINNT_NATIVE */
if (t - watch_period < interval) {
-#ifdef BSDSIGS
- (void) sigsetmask(omask);
-#else
- (void) sigrelse(SIGINT);
-#endif
+ cleanup_until(&pintr_disabled);
return; /* not long enough yet... */
}
watch_period = t;
@@ -265,47 +251,34 @@ watch_login(force)
xprintf(CGETS(26, 1,
"cannot stat %s. Please \"unset watch\".\n"),
TCSH_PATH_UTMP);
-# ifdef BSDSIGS
- (void) sigsetmask(omask);
-# else
- (void) sigrelse(SIGINT);
-# endif
+ cleanup_until(&pintr_disabled);
return;
}
if (stlast == sta.st_mtime) {
-# ifdef BSDSIGS
- (void) sigsetmask(omask);
-# else
- (void) sigrelse(SIGINT);
-# endif
+ cleanup_until(&pintr_disabled);
return;
}
stlast = sta.st_mtime;
#ifdef HAVE_GETUTENT
setutent();
#else
- if ((utmpfd = open(TCSH_PATH_UTMP, O_RDONLY|O_LARGEFILE)) < 0) {
+ if ((utmpfd = xopen(TCSH_PATH_UTMP, O_RDONLY|O_LARGEFILE)) < 0) {
if (!force)
xprintf(CGETS(26, 2,
"%s cannot be opened. Please \"unset watch\".\n"),
TCSH_PATH_UTMP);
-# ifdef BSDSIGS
- (void) sigsetmask(omask);
-# else
- (void) sigrelse(SIGINT);
-# endif
+ cleanup_until(&pintr_disabled);
return;
}
+ cleanup_push(&utmpfd, open_cleanup);
#endif
/*
* xterm clears the entire utmp entry - mark everyone on the status list
* OFFLINE or we won't notice X "logouts"
*/
- for (wp = whohead.who_next; wp->who_next != NULL; wp = wp->who_next) {
- wp->who_status = OFFLINE;
- wp->who_time = 0;
- }
+ for (wp = whohead.who_next; wp->who_next != NULL; wp = wp->who_next)
+ wp->who_status = OFFLINE | CLEARED;
/*
* Read in the utmp file, sort the entries, and update existing entries or
@@ -315,7 +288,7 @@ watch_login(force)
while ((uptr = getutent()) != NULL) {
memcpy(&utmp, uptr, sizeof (utmp));
#else
- while (read(utmpfd, (char *) &utmp, sizeof utmp) == sizeof utmp) {
+ while (xread(utmpfd, &utmp, sizeof utmp) == sizeof utmp) {
#endif
# ifdef DEAD_PROCESS
@@ -340,6 +313,8 @@ watch_login(force)
wp = wp->who_next;/* find that tty! */
if (wp->who_next && comp == 0) { /* found the tty... */
+ if (utmp.ut_time < wp->who_time)
+ continue;
# ifdef DEAD_PROCESS
if (utmp.ut_type == DEAD_PROCESS) {
wp->who_time = utmp.ut_time;
@@ -354,7 +329,7 @@ watch_login(force)
else if (strncmp(utmp.ut_name, wp->who_name, UTNAMLEN) == 0) {
/* someone is logged in */
wp->who_time = utmp.ut_time;
- wp->who_status = 0; /* same guy */
+ wp->who_status = ONLINE | ANNOUNCE; /* same guy */
}
else {
(void) strncpy(wp->who_new, utmp.ut_name, UTNAMLEN);
@@ -377,7 +352,7 @@ watch_login(force)
}
}
else { /* new tty in utmp */
- wpnew = (struct who *) xcalloc(1, sizeof *wpnew);
+ wpnew = xcalloc(1, sizeof *wpnew);
(void) strncpy(wpnew->who_tty, utmp.ut_line, UTLINLEN);
# ifdef HAVE_STRUCT_UTMP_UT_HOST
# ifdef _SEQUENT_
@@ -415,15 +390,17 @@ watch_login(force)
#ifdef HAVE_GETUTENT
endutent();
#else
- (void) close(utmpfd);
+ cleanup_until(&utmpfd);
#endif
# if defined(HAVE_STRUCT_UTMP_UT_HOST) && defined(_SEQUENT_)
endutent();
# endif
#endif /* !WINNT_NATIVE */
- if (force || vp == NULL)
+ if (force || vp == NULL) {
+ cleanup_until(&pintr_disabled);
return;
+ }
/*
* The state of all logins is now known, so we can search the user's list
@@ -447,8 +424,10 @@ watch_login(force)
/* already printed or not right one to print */
- if (wp->who_time == 0)/* utmp entry was cleared */
+ if (wp->who_status & CLEARED) {/* utmp entry was cleared */
wp->who_time = watch_period;
+ wp->who_status &= ~CLEARED;
+ }
if ((wp->who_status & OFFLINE) &&
(wp->who_name[0] != '\0')) {
@@ -474,17 +453,12 @@ watch_login(force)
}
}
}
-#ifdef BSDSIGS
- (void) sigsetmask(omask);
-#else
- (void) sigrelse(SIGINT);
-#endif
+ cleanup_until(&pintr_disabled);
}
#ifdef WHODEBUG
static void
-debugwholist(new, wp)
- struct who *new, *wp;
+debugwholist(struct who *new, struct who *wp)
{
struct who *a;
@@ -518,8 +492,7 @@ debugwholist(new, wp)
static void
-print_who(wp)
- struct who *wp;
+print_who(struct who *wp)
{
#ifdef HAVE_STRUCT_UTMP_UT_HOST
Char *cp = str2short(CGETS(26, 7, "%n has %a %l from %m."));
@@ -527,28 +500,27 @@ print_who(wp)
Char *cp = str2short(CGETS(26, 8, "%n has %a %l."));
#endif /* HAVE_STRUCT_UTMP_UT_HOST */
struct varent *vp = adrof(STRwho);
- Char buf[BUFSIZE];
+ Char *str;
if (vp && vp->vec && vp->vec[0])
cp = vp->vec[0];
- tprintf(FMT_WHO, buf, cp, BUFSIZE, NULL, wp->who_time, (ptr_t) wp);
- for (cp = buf; *cp;)
+ str = tprintf(FMT_WHO, cp, NULL, wp->who_time, wp);
+ cleanup_push(str, xfree);
+ for (cp = str; *cp;)
xputwchar(*cp++);
+ cleanup_until(str);
xputchar('\n');
} /* end print_who */
-const char *
-who_info(ptr, c, wbuf, wbufsiz)
- ptr_t ptr;
- int c;
- char *wbuf;
- size_t wbufsiz;
+char *
+who_info(ptr_t ptr, int c)
{
- struct who *wp = (struct who *) ptr;
+ struct who *wp = ptr;
+ char *wbuf;
#ifdef HAVE_STRUCT_UTMP_UT_HOST
- char *wb = wbuf;
+ char *wb;
int flg;
char *pb;
#endif /* HAVE_STRUCT_UTMP_UT_HOST */
@@ -558,9 +530,9 @@ who_info(ptr, c, wbuf, wbufsiz)
switch (wp->who_status & STMASK) {
case ONLINE:
case CHANGED:
- return wp->who_new;
+ return strsave(wp->who_new);
case OFFLINE:
- return wp->who_name;
+ return strsave(wp->who_name);
default:
break;
}
@@ -569,13 +541,11 @@ who_info(ptr, c, wbuf, wbufsiz)
case 'a':
switch (wp->who_status & STMASK) {
case ONLINE:
- return CGETS(26, 9, "logged on");
+ return strsave(CGETS(26, 9, "logged on"));
case OFFLINE:
- return CGETS(26, 10, "logged off");
+ return strsave(CGETS(26, 10, "logged off"));
case CHANGED:
- xsnprintf(wbuf, wbufsiz, CGETS(26, 11, "replaced %s on"),
- wp->who_name);
- return wbuf;
+ return xasprintf(CGETS(26, 11, "replaced %s on"), wp->who_name);
default:
break;
}
@@ -584,12 +554,14 @@ who_info(ptr, c, wbuf, wbufsiz)
#ifdef HAVE_STRUCT_UTMP_UT_HOST
case 'm':
if (wp->who_host[0] == '\0')
- return CGETS(26, 12, "local");
+ return strsave(CGETS(26, 12, "local"));
else {
+ pb = wp->who_host;
+ wbuf = xmalloc(strlen(pb) + 1);
+ wb = wbuf;
/* the ':' stuff is for <host>:<display>.<screen> */
- for (pb = wp->who_host,
- flg = isdigit((unsigned char)*pb) ? '\0' : '.';
- *pb != '\0' && (*pb != flg || ((pb = strchr(pb, ':')) != 0));
+ for (flg = isdigit((unsigned char)*pb) ? '\0' : '.';
+ *pb != '\0' && (*pb != flg || ((pb = strchr(pb, ':')) != 0));
pb++) {
if (*pb == ':')
flg = '\0';
@@ -602,9 +574,12 @@ who_info(ptr, c, wbuf, wbufsiz)
case 'M':
if (wp->who_host[0] == '\0')
- return CGETS(26, 12, "local");
+ return strsave(CGETS(26, 12, "local"));
else {
- for (pb = wp->who_host; *pb != '\0'; pb++)
+ pb = wp->who_host;
+ wbuf = xmalloc(strlen(pb) + 1);
+ wb = wbuf;
+ for (; *pb != '\0'; pb++)
*wb++ = isupper((unsigned char)*pb) ?
tolower((unsigned char)*pb) : *pb;
*wb = '\0';
@@ -613,9 +588,10 @@ who_info(ptr, c, wbuf, wbufsiz)
#endif /* HAVE_STRUCT_UTMP_UT_HOST */
case 'l':
- return wp->who_tty;
+ return strsave(wp->who_tty);
default:
+ wbuf = xmalloc(3);
wbuf[0] = '%';
wbuf[1] = (char) c;
wbuf[2] = '\0';
@@ -626,9 +602,7 @@ who_info(ptr, c, wbuf, wbufsiz)
void
/*ARGSUSED*/
-dolog(v, c)
-Char **v;
-struct command *c;
+dolog(Char **v, struct command *c)
{
struct who *wp;
struct varent *vp;
@@ -648,13 +622,13 @@ struct command *c;
# ifdef HAVE_STRUCT_UTMP_UT_HOST
size_t
-utmphostsize()
+utmphostsize(void)
{
return UTHOSTLEN;
}
char *
-utmphost()
+utmphost(void)
{
char *tty = short2str(varval(STRtty));
struct who *wp;
@@ -706,7 +680,7 @@ void add_to_who_list(name, mach_nm)
}
}
else {
- wpnew = (struct who *) xcalloc(1, sizeof *wpnew);
+ wpnew = xcalloc(1, sizeof *wpnew);
(void) strncpy(wpnew->who_tty, mach_nm, UTLINLEN);
wpnew->who_time = 0;
if (*name == '\0')
diff --git a/contrib/tcsh/tcsh.man b/contrib/tcsh/tcsh.man
index 45ac135..0c9c3b6 100644
--- a/contrib/tcsh/tcsh.man
+++ b/contrib/tcsh/tcsh.man
@@ -72,7 +72,7 @@
.\" used here if you can. In particular, please don't use nroff commands
.\" which aren't already used herein.
.\"
-.TH TCSH 1 "25 March 2005" "Astron 6.14.00"
+.TH TCSH 1 "3 March 2007" "Astron 6.15.00"
.SH NAME
tcsh \- C shell with file name completion and command line editing
.SH SYNOPSIS
@@ -129,10 +129,11 @@ The shell exits if any invoked command terminates abnormally or
yields a non-zero exit status.
.TP 4
.B \-f
-The shell ignores \fI~/.tcshrc\fR, and thus starts faster.
+The shell does not load any resource or startup files, or perform any
+command hashing, and thus starts faster.
.TP 4
.B \-F
-The shell uses \fIfork\fR(2) instead of \fIvfork\fR(2) to spawn processes. (Convex/OS only) (+)
+The shell uses \fIfork\fR(2) instead of \fIvfork\fR(2) to spawn processes. (+)
.TP 4
.B \-i
The shell is interactive and prompts for its top-level input, even if
@@ -940,7 +941,7 @@ Even in braces, history substitutions do not nest.
letter `d' appended to it, \fItcsh\fR expands it to the last event beginning
with `3d'; only completely numeric arguments are treated as event numbers.
This makes it possible to recall events beginning with numbers.
-To expand `!3d' as in \fIcsh\fR(1) say `!\\3d'.
+To expand `!3d' as in \fIcsh\fR(1) say `!{3}d'.
.PP
To select words from an event we can follow the event specification by a `:'
and a designator for the desired words. The words of an input line are
@@ -1037,7 +1038,7 @@ Any character may be used as the delimiter in place of `/';
a `\\' can be used to quote the delimiter inside \fIl\fR and \fIr\fR.
The character `&' in the \fIr\fR is replaced by \fIl\fR; `\\' also quotes `&'.
If \fIl\fR is empty (``''), the \fIl\fR from a previous substitution or the
-\fIs\fR from a previous `?\fIs\fR?' event specification is used.
+\fIs\fR from a previous search or event number in event specification is used.
The trailing delimiter may be omitted if it is immediately followed by a newline.
.TP 8
&
@@ -1049,9 +1050,8 @@ Apply the following modifier once to each word.
a (+)
Apply the following modifier as many times as possible to a single word.
`a' and `g' can be used together to apply a modifier globally.
-In the current implementation, using the `a' and `s' modifiers together can
-lead to an infinite loop. For example, `:as/f/ff/' will never terminate.
-This behavior might change in the future.
+With the `s' modifier, only the patterns contained in the original word are
+substituted, not patterns that contain any substitution result.
.TP 8
p
Print the new command line but do not execute it.
@@ -1205,10 +1205,10 @@ $\fIname\fR
${\fIname\fR}
Substitutes the words of the value of variable \fIname\fR, each separated
by a blank. Braces insulate \fIname\fR from following characters which would
-otherwise be part of it. Shell variables have names consisting of up to 20
+otherwise be part of it. Shell variables have names consisting of
letters and digits starting with a letter. The underscore character is
considered a letter. If \fIname\fR is not a shell variable, but is set in the
-environment, then that value is returned (but `:' modifiers and the other forms
+environment, then that value is returned (but some of the other forms
given below are not available in this case).
.PP
$\fIname\fR[\fIselector\fR]
@@ -1470,16 +1470,28 @@ used to prevent \fIcd\fR from affecting the current shell.
When a command to be executed is found not to be a builtin command the shell
attempts to execute the command via \fIexecve\fR(2). Each word in the variable
\fBpath\fR names a directory in which the shell will look for the
-command. If it is given neither a \fB\-c\fR nor a \fB\-t\fR option, the shell
+command. If the shell is not given a \fB\-f\fR option, the shell
hashes the names in these directories into an internal table so that it will
try an \fIexecve\fR(2) in only a directory where there is a possibility that the
command resides there. This greatly speeds command location when a large
-number of directories are present in the search path. If this mechanism has
-been turned off (via \fIunhash\fR), if the shell was given a \fB\-c\fR or
-\fB\-t\fR argument or in any case for each directory component of \fBpath\fR
-which does not begin with a `/', the shell concatenates the current working
-directory with the given command name to form a path name of a file which it
-then attempts to execute.
+number of directories are present in the search path. This hashing mechanism is
+not used:
+.TP 4
+.B 1.
+If hashing is turned explicitly off via \fIunhash\fR.
+.TP 4
+.B 2.
+If the shell was given a \fB\-f\fR argument.
+.TP 4
+.B 3.
+For each directory component of \fBpath\fR which does not begin with a `/'.
+.TP 4
+.B 4.
+If the command contains a `/'.
+.PP
+In the above four cases the shell concatenates each component of the path
+vector with the given command name to form a path name of a file which it
+then attempts to execute it. If execution is successful, the search stops.
.PP
If the file has execute permissions but is not an executable to the system
(i.e., it is neither an executable binary nor a script that specifies its
@@ -1610,7 +1622,7 @@ operand is matched. This reduces the need for use of the \fIswitch\fR
builtin command in shell scripts when all that is really needed is
pattern matching.
.PP
-Strings which begin with `0' are considered octal numbers. Null or
+Null or
missing arguments are considered `0'. The results of all expressions are
strings, which represent decimal numbers. It is important to note that
no two components of an expression can appear in the same word; except
@@ -2678,7 +2690,7 @@ Executes the specified command in place of the current shell.
.B exit \fR[\fIexpr\fR]
The shell exits either with the value of the specified \fIexpr\fR
(an expression, as described under \fBExpressions\fR)
-or, without \fIexpr\fR, with the value of the \fBstatus\fR variable.
+or, without \fIexpr\fR, with the value 0.
.TP 8
.B fg \fR[\fB%\fIjob\fR ...]
Brings the specified jobs (or, without arguments, the current job)
@@ -2717,7 +2729,7 @@ Prints the system execution path. (TCF only)
Prints the experimental version prefix. (TCF only)
.TP 8
.B glob \fIwordlist
-Like \fIecho\fR, but no `\\' escapes are recognized and words are
+Like \fIecho\fR, but the `-n' parameter is not recognized and words are
delimited by null characters in the output. Useful for
programs which wish to use the shell to filename expand a list of words.
.TP 8
@@ -3523,7 +3535,7 @@ startup; they do not change thereafter unless changed by the user. The shell
updates \fBcwd\fR, \fBdirstack\fR, \fBowd\fR and \fBstatus\fR when necessary,
and sets \fBlogout\fR on logout.
.PP
-The shell synchronizes \fBafsuser\fR, \fBgroup\fR, \fBhome\fR, \fBpath\fR, \fBshlvl\fR,
+The shell synchronizes \fBgroup\fR, \fBhome\fR, \fBpath\fR, \fBshlvl\fR,
\fBterm\fR and \fBuser\fR with the environment variables of the same names:
whenever the environment variable changes the shell changes the corresponding
shell variable to match (unless the shell variable is read-only) and vice
@@ -3769,6 +3781,15 @@ The user's real group ID.
.B group \fR(+)
The user's group name.
.TP 8
+.B highlight
+If set, the incremental search match (in \fIi-search-back\fR and
+\fIi-search-fwd\fR) and the region between the mark and the cursor are
+highlighted in reverse video.
+
+Highlighting requires more frequent terminal writes, which introduces extra
+overhead. If you care about terminal performance, you may want to leave this
+unset.
+.TP 8
.B histchars
A string value determining the characters used in \fBHistory
substitution\fR (q.v.). The first character of its value is used as
@@ -3971,6 +3992,10 @@ The user's real organization ID. (Domain/OS only)
The old working directory, equivalent to the `\-' used by \fIcd\fR and \fIpushd\fR.
See also the \fBcwd\fR and \fBdirstack\fR shell variables.
.TP 8
+.B padhour
+If set, enable the printing of padding '0' for hours, in 24 and 12 hour
+formats. E.G.: 07:45:42 vs. 7:45:42
+.TP 8
.B path
A list of directories in which to look for executable commands.
A null word specifies the current directory.
@@ -5051,7 +5076,7 @@ pipe(2), setrlimit(2), sigvec(2), stat(2), umask(2), vfork(2), wait(2),
malloc(3), setlocale(3), tty(4), a.out(5), termcap(5), environ(7),
termio(7), Introduction to the C Shell
.SH VERSION
-This manual documents tcsh 6.14.00 (Astron) 2005-03-25.
+This manual documents tcsh 6.15.00 (Astron) 2007-03-03.
.SH AUTHORS
.PD 0
.TP 2
diff --git a/contrib/tcsh/tcsh.man2html b/contrib/tcsh/tcsh.man2html
index e843563..8a0cefd 100644
--- a/contrib/tcsh/tcsh.man2html
+++ b/contrib/tcsh/tcsh.man2html
@@ -1,5 +1,5 @@
: # -*- perl -*-
-# $Id: tcsh.man2html,v 1.13 2005/03/25 17:36:08 kim Exp $
+# $tcsh: tcsh.man2html,v 1.14 2006/03/02 18:46:45 christos Exp $
# tcsh.man2html, Dave Schweisguth <dcs@proton.chem.yale.edu>
#
diff --git a/contrib/tcsh/termcap.vms b/contrib/tcsh/termcap.vms
index a56bc15..5e7d25b 100644
--- a/contrib/tcsh/termcap.vms
+++ b/contrib/tcsh/termcap.vms
@@ -1,4 +1,4 @@
-# $Id: termcap.vms,v 1.2 1992/10/27 16:18:15 christos Exp $
+# $tcsh: termcap.vms,v 1.3 2006/03/02 18:46:45 christos Exp $
# posix /etc/termcap 1992
#
# Minimal termcap for VMS/POSIX
diff --git a/contrib/tcsh/tw.color.c b/contrib/tcsh/tw.color.c
index a610da1..3c6b57f 100644
--- a/contrib/tcsh/tw.color.c
+++ b/contrib/tcsh/tw.color.c
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/tw.color.c,v 1.18 2005/03/03 16:40:53 kim Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/tw.color.c,v 1.24 2006/03/02 18:46:45 christos Exp $ */
/*
* tw.color.c: builtin color ls-F
*/
@@ -32,7 +32,7 @@
*/
#include "sh.h"
-RCSID("$Id: tw.color.c,v 1.18 2005/03/03 16:40:53 kim Exp $")
+RCSID("$tcsh: tw.color.c,v 1.24 2006/03/02 18:46:45 christos Exp $")
#include "tw.h"
#include "ed.h"
@@ -41,8 +41,8 @@ RCSID("$Id: tw.color.c,v 1.18 2005/03/03 16:40:53 kim Exp $")
#ifdef COLOR_LS_F
typedef struct {
- const char *s;
- int len;
+ const char *s;
+ size_t len;
} Str;
@@ -56,8 +56,8 @@ typedef struct {
typedef struct {
const char suffix;
const char *variable;
- Str color;
- Str defaultcolor;
+ Str color;
+ Str defaultcolor;
} Variable;
static Variable variables[] = {
@@ -80,6 +80,11 @@ static Variable variables[] = {
#endif
VAR(NOS, "rc", "m"), /* Right code */
VAR(NOS, "ec", ""), /* End code (replaces lc+no+rc) */
+ VAR(NOS, "su", ""), /* Setuid file (u+s) */
+ VAR(NOS, "sg", ""), /* Setgid file (g+s) */
+ VAR(NOS, "tw", ""), /* Sticky and other writable dir (+t,o+w) */
+ VAR(NOS, "ow", ""), /* Other writable dir (o+w) but not sticky */
+ VAR(NOS, "st", ""), /* Sticky dir (+t) but not other writable */
};
enum FileType {
@@ -90,8 +95,8 @@ enum FileType {
#define nvariables (sizeof(variables)/sizeof(variables[0]))
typedef struct {
- Str extension; /* file extension */
- Str color; /* color string */
+ Str extension; /* file extension */
+ Str color; /* color string */
} Extension;
static Extension *extensions = NULL;
@@ -99,16 +104,16 @@ static size_t nextensions = 0;
static char *colors = NULL;
int color_context_ls = FALSE; /* do colored ls */
-static int color_context_lsmF = FALSE; /* do colored ls-F */
+static int color_context_lsmF = FALSE; /* do colored ls-F */
-static int getstring __P((char **, const Char **, Str *, int));
-static void put_color __P((Str *));
-static void print_color __P((Char *, size_t, Char));
+static int getstring (char **, const Char **, Str *, int);
+static void put_color (const Str *);
+static void print_color (const Char *, size_t, Char);
/* set_color_context():
*/
void
-set_color_context()
+set_color_context(void)
{
struct varent *vp = adrof(STRcolor);
@@ -134,12 +139,8 @@ set_color_context()
/* getstring():
*/
-static int
-getstring(dp, sp, pd, f)
- char **dp; /* dest buffer */
- const Char **sp; /* source buffer */
- Str *pd; /* pointer to dest buffer */
- int f; /* final character */
+static int
+getstring(char **dp, const Char **sp, Str *pd, int f)
{
const Char *s = *sp;
char *d = *dp;
@@ -156,7 +157,7 @@ getstring(dp, sp, pd, f)
}
pd->s = *dp;
- pd->len = (int) (d - *dp);
+ pd->len = d - *dp;
*sp = s;
*dp = d;
return *s == (Char)f;
@@ -167,20 +168,19 @@ getstring(dp, sp, pd, f)
* Parse the LS_COLORS environment variable
*/
void
-parseLS_COLORS(value)
- Char *value; /* LS_COLOR variable's value */
+parseLS_COLORS(const Char *value)
{
size_t i, len;
- const Char *v; /* pointer in value */
+ const Char *v; /* pointer in value */
char *c; /* pointer in colors */
Extension *volatile e; /* pointer in extensions */
jmp_buf_t osetexit;
+ size_t omark;
(void) &e;
/* init */
- if (extensions)
- xfree((ptr_t) extensions);
+ xfree(extensions);
for (i = 0; i < nvariables; i++)
variables[i].color = variables[i].defaultcolor;
colors = NULL;
@@ -196,7 +196,7 @@ parseLS_COLORS(value)
for (v = value; *v; v++)
if ((*v & CHAR) == ':')
i++;
- extensions = (Extension *) xmalloc((size_t) (len + i * sizeof(Extension)));
+ extensions = xmalloc(len + i * sizeof(Extension));
colors = i * sizeof(Extension) + (char *)extensions;
nextensions = 0;
@@ -207,10 +207,11 @@ parseLS_COLORS(value)
/* Prevent from crashing if unknown parameters are given. */
+ omark = cleanup_push_mark();
getexit(osetexit);
if (setexit() == 0) {
-
+
/* parse */
while (*v) {
switch (*v & CHAR) {
@@ -250,51 +251,48 @@ parseLS_COLORS(value)
}
}
+ cleanup_pop_mark(omark);
resexit(osetexit);
- nextensions = (int) (e - extensions);
+ nextensions = e - extensions;
}
-
/* put_color():
*/
static void
-put_color(color)
- Str *color;
+put_color(const Str *color)
{
size_t i;
- const char *c = color->s;
- int original_output_raw = output_raw;
+ const char *c = color->s;
+ int original_output_raw = output_raw;
output_raw = TRUE;
+ cleanup_push(&original_output_raw, output_raw_restore);
for (i = color->len; 0 < i; i--)
xputchar(*c++);
- output_raw = original_output_raw;
+ cleanup_until(&original_output_raw);
}
/* print_color():
*/
static void
-print_color(fname, len, suffix)
- Char *fname;
- size_t len;
- Char suffix;
+print_color(const Char *fname, size_t len, Char suffix)
{
size_t i;
char *filename = short2str(fname);
char *last = filename + len;
- Str *color = &variables[VFile].color;
+ Str *color = &variables[VFile].color;
switch (suffix) {
case '>': /* File is a symbolic link pointing to
* a directory */
- color = &variables[VDir].color;
- break;
+ color = &variables[VDir].color;
+ break;
case '+': /* File is a hidden directory [aix] or
* context dependent [hpux] */
case ':': /* File is network special [hpux] */
- break;
+ break;
default:
for (i = 0; i < nvariables; i++)
if (variables[i].suffix != NOS &&
@@ -304,9 +302,10 @@ print_color(fname, len, suffix)
}
if (i == nvariables) {
for (i = 0; i < nextensions; i++)
- if (strncmp(last - extensions[i].extension.len,
- extensions[i].extension.s,
- extensions[i].extension.len) == 0) {
+ if (len >= extensions[i].extension.len
+ && strncmp(last - extensions[i].extension.len,
+ extensions[i].extension.s,
+ extensions[i].extension.len) == 0) {
color = &extensions[i].color;
break;
}
@@ -323,10 +322,7 @@ print_color(fname, len, suffix)
/* print_with_color():
*/
void
-print_with_color(filename, len, suffix)
- Char *filename;
- size_t len;
- Char suffix;
+print_with_color(const Char *filename, size_t len, Char suffix)
{
if (color_context_lsmF &&
(haderr ? (didfds ? is2atty : isdiagatty) :
diff --git a/contrib/tcsh/tw.comp.c b/contrib/tcsh/tw.comp.c
index 4199721..30285af 100644
--- a/contrib/tcsh/tw.comp.c
+++ b/contrib/tcsh/tw.comp.c
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/tw.comp.c,v 1.37 2004/11/23 02:10:50 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/tw.comp.c,v 1.41 2006/03/02 18:46:45 christos Exp $ */
/*
* tw.comp.c: File completion builtin
*/
@@ -32,7 +32,7 @@
*/
#include "sh.h"
-RCSID("$Id: tw.comp.c,v 1.37 2004/11/23 02:10:50 christos Exp $")
+RCSID("$tcsh: tw.comp.c,v 1.41 2006/03/02 18:46:45 christos Exp $")
#include "tw.h"
#include "ed.h"
@@ -41,24 +41,22 @@ RCSID("$Id: tw.comp.c,v 1.37 2004/11/23 02:10:50 christos Exp $")
/* #define TDEBUG */
struct varent completions;
-static int tw_result __P((Char *, Char **));
-static Char **tw_find __P((Char *, struct varent *, int));
-static Char *tw_tok __P((Char *));
-static int tw_pos __P((Char *, int));
-static void tw_pr __P((Char **));
-static int tw_match __P((Char *, Char *));
-static void tw_prlist __P((struct varent *));
-static Char *tw_dollar __P((Char *,Char **, int, Char *,
- Char, const char *));
+static int tw_result (const Char *, Char **);
+static Char **tw_find (Char *, struct varent *, int);
+static Char *tw_tok (Char *);
+static int tw_pos (Char *, int);
+static void tw_pr (Char **);
+static int tw_match (const Char *, const Char *);
+static void tw_prlist (struct varent *);
+static const Char *tw_dollar (const Char *,Char **, size_t, Char **,
+ Char, const char *);
/* docomplete():
* Add or list completions in the completion list
*/
/*ARGSUSED*/
void
-docomplete(v, t)
- Char **v;
- struct command *t;
+docomplete(Char **v, struct command *t)
{
struct varent *vp;
Char *p;
@@ -93,9 +91,7 @@ docomplete(v, t)
*/
/*ARGSUSED*/
void
-douncomplete(v, t)
- Char **v;
- struct command *t;
+douncomplete(Char **v, struct command *t)
{
USE(t);
unset1(v, &completions);
@@ -106,24 +102,22 @@ douncomplete(v, t)
* Pretty print a list of variables
*/
static void
-tw_prlist(p)
- struct varent *p;
+tw_prlist(struct varent *p)
{
struct varent *c;
- if (setintr)
-#ifdef BSDSIGS
- (void) sigsetmask(sigblock((sigmask_t) 0) & ~sigmask(SIGINT));
-#else /* BSDSIGS */
- (void) sigrelse(SIGINT);
-#endif /* BSDSIGS */
-
for (;;) {
while (p->v_left)
p = p->v_left;
x:
if (p->v_parent == 0) /* is it the header? */
- return;
+ break;
+ if (setintr) {
+ int old_pintr_disabled;
+
+ pintr_push_enable(&old_pintr_disabled);
+ cleanup_until(&old_pintr_disabled);
+ }
xprintf("%s\t", short2str(p->v_name));
if (p->vec)
tw_pr(p->vec);
@@ -146,8 +140,7 @@ x:
* a completion argument and collapsing multiple spaces to one.
*/
static void
-tw_pr(cmp)
- Char **cmp;
+tw_pr(Char **cmp)
{
int sp, osp;
Char *ptr;
@@ -173,10 +166,7 @@ tw_pr(cmp)
* For commands we only look at names that start with -
*/
static Char **
-tw_find(nam, vp, cmd)
- Char *nam;
- struct varent *vp;
- int cmd;
+tw_find(Char *nam, struct varent *vp, int cmd)
{
Char **rv;
@@ -201,9 +191,7 @@ tw_find(nam, vp, cmd)
* Return true if the position is within the specified range
*/
static int
-tw_pos(ran, wno)
- Char *ran;
- int wno;
+tw_pos(Char *ran, int wno)
{
Char *p;
@@ -224,7 +212,6 @@ tw_pos(ran, wno)
return getn(ran) <= wno;
else /* range = <number> - <number> */
return (getn(ran) <= wno) && (wno <= getn(p));
-
} /* end tw_pos */
@@ -232,8 +219,7 @@ tw_pos(ran, wno)
* Return the next word from string, unquoteing it.
*/
static Char *
-tw_tok(str)
- Char *str;
+tw_tok(Char *str)
{
static Char *bf = NULL;
@@ -262,10 +248,9 @@ tw_tok(str)
* in a prefix of the string.
*/
static int
-tw_match(str, pat)
- Char *str, *pat;
+tw_match(const Char *str, const Char *pat)
{
- Char *estr;
+ const Char *estr;
int rv = Gnmatch(str, pat, &estr);
#ifdef TDEBUG
xprintf("Gnmatch(%s, ", short2str(str));
@@ -281,14 +266,14 @@ tw_match(str, pat)
* string
*/
static int
-tw_result(act, pat)
- Char *act, **pat;
+tw_result(const Char *act, Char **pat)
{
int looking;
static Char* res = NULL;
+ Char *p;
if (res != NULL)
- xfree((ptr_t) res), res = NULL;
+ xfree(res), res = NULL;
switch (act[0] & ~QUOTE) {
case 'X':
@@ -365,15 +350,15 @@ tw_result(act, pat)
case '(':
*pat = res = Strsave(&act[1]);
- if ((act = Strchr(res, ')')) != NULL)
- *act = '\0';
+ if ((p = Strchr(res, ')')) != NULL)
+ *p = '\0';
(void) strip(res);
return TW_WORDLIST;
case '`':
res = Strsave(act);
- if ((act = Strchr(&res[1], '`')) != NULL)
- *++act = '\0';
+ if ((p = Strchr(&res[1], '`')) != NULL)
+ *++p = '\0';
if (didfds == 0) {
/*
@@ -385,10 +370,10 @@ tw_result(act, pat)
(void) dcopy(SHOUT, 1);
(void) dcopy(SHDIAG, 2);
}
- if ((act = globone(res, G_APPEND)) != NULL) {
- xfree((ptr_t) res), res = NULL;
- *pat = res = Strsave(act);
- xfree((ptr_t) act);
+ if ((p = globone(res, G_APPEND)) != NULL) {
+ xfree(res), res = NULL;
+ *pat = res = Strsave(p);
+ xfree(p);
return TW_WORDLIST;
}
return TW_ZERO;
@@ -412,22 +397,20 @@ tw_result(act, pat)
return TW_ZERO;
}
} /* end tw_result */
-
+
/* tw_dollar():
* Expand $<n> args in buffer
*/
-static Char *
-tw_dollar(str, wl, nwl, buffer, sep, msg)
- Char *str, **wl;
- int nwl;
- Char *buffer;
- Char sep;
- const char *msg;
+static const Char *
+tw_dollar(const Char *str, Char **wl, size_t nwl, Char **result, Char sep,
+ const char *msg)
{
- Char *sp, *bp = buffer, *ebp = &buffer[MAXPATHLEN];
+ struct Strbuf buf = Strbuf_INIT;
+ Char *res;
+ const Char *sp;
- for (sp = str; *sp && *sp != sep && bp < ebp;)
+ for (sp = str; *sp && *sp != sep;)
if (sp[0] == '$' && sp[1] == ':' && Isdigit(sp[sp[2] == '-' ? 3 : 2])) {
int num, neg = 0;
sp += 2;
@@ -439,26 +422,25 @@ tw_dollar(str, wl, nwl, buffer, sep, msg)
continue;
if (neg)
num = nwl - num - 1;
- if (num >= 0 && num < nwl) {
- Char *ptr;
- for (ptr = wl[num]; *ptr && bp < ebp - 1; *bp++ = *ptr++)
- continue;
-
- }
+ if (num >= 0 && (size_t)num < nwl)
+ Strbuf_append(&buf, wl[num]);
}
else
- *bp++ = *sp++;
+ Strbuf_append1(&buf, *sp++);
- *bp = '\0';
+ res = Strbuf_finish(&buf);
- if (*sp++ == sep)
+ if (*sp++ == sep) {
+ *result = res;
return sp;
+ }
+ xfree(res);
/* Truncates data if WIDE_STRINGS */
stderror(ERR_COMPMIS, (int)sep, msg, short2str(str));
return --sp;
} /* end tw_dollar */
-
+
/* tw_complete():
* Return the appropriate completion for the command
@@ -471,38 +453,48 @@ tw_dollar(str, wl, nwl, buffer, sep, msg)
* N/<pattern>/<completion>/[<suffix>/] next-next word
*/
int
-tw_complete(line, word, pat, looking, suf)
- Char *line, **word, **pat;
- int looking, *suf;
+tw_complete(const Char *line, Char **word, Char **pat, int looking, eChar *suf)
{
- Char buf[MAXPATHLEN + 1], **vec, *ptr;
- Char *wl[MAXPATHLEN/6];
+ Char *buf, **vec, **wl;
static Char nomatch[2] = { (Char) ~0, 0x00 };
- int wordno, n;
+ const Char *ptr;
+ size_t wordno;
+ int n;
- copyn(buf, line, MAXPATHLEN);
+ buf = Strsave(line);
+ cleanup_push(buf, xfree);
+ /* Single-character words, empty current word, terminating NULL */
+ wl = xmalloc(((Strlen(line) + 1) / 2 + 2) * sizeof (*wl));
+ cleanup_push(wl, xfree);
/* find the command */
- if ((wl[0] = tw_tok(buf)) == NULL || wl[0] == INVPTR)
+ if ((wl[0] = tw_tok(buf)) == NULL || wl[0] == INVPTR) {
+ cleanup_until(buf);
return TW_ZERO;
+ }
/*
* look for hardwired command completions using a globbing
* search and for arguments using a normal search.
*/
- if ((vec = tw_find(wl[0], &completions, (looking == TW_COMMAND))) == NULL)
+ if ((vec = tw_find(wl[0], &completions, (looking == TW_COMMAND)))
+ == NULL) {
+ cleanup_until(buf);
return looking;
+ }
/* tokenize the line one more time :-( */
for (wordno = 1; (wl[wordno] = tw_tok(NULL)) != NULL &&
wl[wordno] != INVPTR; wordno++)
continue;
- if (wl[wordno] == INVPTR) /* Found a meta character */
+ if (wl[wordno] == INVPTR) { /* Found a meta character */
+ cleanup_until(buf);
return TW_ZERO; /* de-activate completions */
+ }
#ifdef TDEBUG
{
- int i;
+ size_t i;
for (i = 0; i < wordno; i++)
xprintf("'%s' ", short2str(wl[i]));
xprintf("\n");
@@ -519,19 +511,19 @@ tw_complete(line, word, pat, looking, suf)
#ifdef TDEBUG
xprintf("\r\n");
- xprintf(" w#: %d\n", wordno);
+ xprintf(" w#: %lu\n", (unsigned long)wordno);
xprintf("line: %s\n", short2str(line));
xprintf(" cmd: %s\n", short2str(wl[0]));
xprintf("word: %s\n", short2str(*word));
- xprintf("last: %s\n", wordno - 2 >= 0 ? short2str(wl[wordno-2]) : "n/a");
- xprintf("this: %s\n", wordno - 1 >= 0 ? short2str(wl[wordno-1]) : "n/a");
+ xprintf("last: %s\n", wordno >= 2 ? short2str(wl[wordno-2]) : "n/a");
+ xprintf("this: %s\n", wordno >= 1 ? short2str(wl[wordno-1]) : "n/a");
#endif /* TDEBUG */
for (;vec != NULL && (ptr = vec[0]) != NULL; vec++) {
- Char ran[MAXPATHLEN+1],/* The pattern or range X/<range>/XXXX/ */
- com[MAXPATHLEN+1],/* The completion X/XXXXX/<completion>/ */
+ Char *ran, /* The pattern or range X/<range>/XXXX/ */
+ *com, /* The completion X/XXXXX/<completion>/ */
*pos = NULL; /* scratch pointer */
- int cmd;
+ int cmd, res;
Char sep; /* the command and separator characters */
if (ptr[0] == '\0')
@@ -543,14 +535,14 @@ tw_complete(line, word, pat, looking, suf)
switch (cmd = ptr[0]) {
case 'N':
- pos = (wordno - 3 < 0) ? nomatch : wl[wordno - 3];
+ pos = (wordno < 3) ? nomatch : wl[wordno - 3];
break;
case 'n':
- pos = (wordno - 2 < 0) ? nomatch : wl[wordno - 2];
+ pos = (wordno < 2) ? nomatch : wl[wordno - 2];
break;
case 'c':
case 'C':
- pos = (wordno - 1 < 0) ? nomatch : wl[wordno - 1];
+ pos = (wordno < 1) ? nomatch : wl[wordno - 1];
break;
case 'p':
break;
@@ -566,8 +558,9 @@ tw_complete(line, word, pat, looking, suf)
return TW_ZERO;
}
- ptr = tw_dollar(&ptr[2], wl, wordno, ran, sep,
+ ptr = tw_dollar(&ptr[2], wl, wordno, &ran, sep,
CGETS(27, 3, "pattern"));
+ cleanup_push(ran, xfree);
if (ran[0] == '\0') /* check for empty pattern (disallowed) */
{
stderror(ERR_COMPINC, cmd == 'p' ? CGETS(27, 4, "range") :
@@ -575,11 +568,13 @@ tw_complete(line, word, pat, looking, suf)
return TW_ZERO;
}
- ptr = tw_dollar(ptr, wl, wordno, com, sep, CGETS(27, 5, "completion"));
+ ptr = tw_dollar(ptr, wl, wordno, &com, sep,
+ CGETS(27, 5, "completion"));
+ cleanup_push(com, xfree);
if (*ptr != '\0') {
if (*ptr == sep)
- *suf = ~0;
+ *suf = CHAR_ERR;
else
*suf = *ptr;
}
@@ -595,11 +590,11 @@ tw_complete(line, word, pat, looking, suf)
case 0:
xprintf("*auto suffix*\n");
break;
- case ~0:
+ case CHAR_ERR:
xprintf("*no suffix*\n");
break;
default:
- xprintf("%c\n", *suf);
+ xprintf("%c\n", (int)*suf);
break;
}
#endif /* TDEBUG */
@@ -607,12 +602,15 @@ tw_complete(line, word, pat, looking, suf)
switch (cmd) {
case 'p': /* positional completion */
#ifdef TDEBUG
- xprintf("p: tw_pos(%s, %d) = ", short2str(ran), wordno - 1);
+ xprintf("p: tw_pos(%s, %lu) = ", short2str(ran),
+ (unsigned long)wordno - 1);
xprintf("%d\n", tw_pos(ran, wordno - 1));
#endif /* TDEBUG */
- if (!tw_pos(ran, wordno - 1))
+ if (!tw_pos(ran, wordno - 1)) {
+ cleanup_until(ran);
continue;
- return tw_result(com, pat);
+ }
+ break;
case 'N': /* match with the next-next word */
case 'n': /* match with the next word */
@@ -621,16 +619,22 @@ tw_complete(line, word, pat, looking, suf)
#ifdef TDEBUG
xprintf("%c: ", cmd);
#endif /* TDEBUG */
- if ((n = tw_match(pos, ran)) < 0)
+ if ((n = tw_match(pos, ran)) < 0) {
+ cleanup_until(ran);
continue;
+ }
if (cmd == 'c')
*word += n;
- return tw_result(com, pat);
+ break;
default:
- return TW_ZERO; /* Cannot happen */
+ abort(); /* Cannot happen */
}
+ res = tw_result(com, pat);
+ cleanup_until(buf);
+ return res;
}
+ cleanup_until(buf);
*suf = '\0';
return TW_ZERO;
} /* end tw_complete */
diff --git a/contrib/tcsh/tw.decls.h b/contrib/tcsh/tw.decls.h
index 2cec283..912b40e 100644
--- a/contrib/tcsh/tw.decls.h
+++ b/contrib/tcsh/tw.decls.h
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/tw.decls.h,v 3.20 2004/08/08 06:42:29 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/tw.decls.h,v 3.22 2006/01/12 18:15:25 christos Exp $ */
/*
* tw.decls.h: Tenex external declarations
*/
@@ -36,89 +36,95 @@
/*
* tw.help.c
*/
-extern void do_help __P((Char *));
+extern void do_help (const Char *);
/*
* tw.parse.c
*/
-extern Char *dollar __P((Char *, const Char *));
+extern Char *dollar (const Char *);
#ifndef __MVS__
-extern int tenematch __P((Char *, int, COMMAND));
-extern int t_search __P((Char *, Char *, COMMAND,
- int, int, int, Char *,
- int));
+extern int tenematch (Char *, int, COMMAND);
+extern int t_search (struct Strbuf *, COMMAND, int,
+ int, Char *, eChar);
#endif
-extern int starting_a_command __P((Char *, Char *));
-extern void copyn __P((Char *, Char *, int));
-extern void catn __P((Char *, const Char *, int));
-extern int fcompare __P((Char **, Char **));
-extern void print_by_column __P((Char *, Char *[], int,
- int));
-extern int StrQcmp __P((const Char *, const Char *));
-extern Char *tgetenv __P((Char *));
+extern int starting_a_command (Char *, Char *);
+extern int fcompare (const void *, const void *);
+extern void print_by_column (Char *, Char *[], int, int);
+extern int StrQcmp (const Char *, const Char *);
+extern Char *tgetenv (Char *);
/*
* tw.init.c
*/
-extern void tw_alias_start __P((DIR *, Char *));
-extern void tw_cmd_start __P((DIR *, Char *));
-extern void tw_logname_start __P((DIR *, Char *));
-extern void tw_var_start __P((DIR *, Char *));
-extern void tw_complete_start __P((DIR *, Char *));
-extern void tw_file_start __P((DIR *, Char *));
-extern void tw_vl_start __P((DIR *, Char *));
-extern void tw_wl_start __P((DIR *, Char *));
-extern void tw_bind_start __P((DIR *, Char *));
-extern void tw_limit_start __P((DIR *, Char *));
-extern void tw_sig_start __P((DIR *, Char *));
-extern void tw_job_start __P((DIR *, Char *));
-extern void tw_grpname_start __P((DIR *, Char *));
-extern Char *tw_cmd_next __P((Char *, int *));
-extern Char *tw_logname_next __P((Char *, int *));
-extern Char *tw_shvar_next __P((Char *, int *));
-extern Char *tw_envvar_next __P((Char *, int *));
-extern Char *tw_var_next __P((Char *, int *));
-extern Char *tw_file_next __P((Char *, int *));
-extern Char *tw_wl_next __P((Char *, int *));
-extern Char *tw_bind_next __P((Char *, int *));
-extern Char *tw_limit_next __P((Char *, int *));
-extern Char *tw_sig_next __P((Char *, int *));
-extern Char *tw_job_next __P((Char *, int *));
-extern Char *tw_grpname_next __P((Char *, int *));
-extern void tw_dir_end __P((void));
-extern void tw_cmd_free __P((void));
-extern void tw_logname_end __P((void));
-extern void tw_grpname_end __P((void));
-extern Char *tw_item_add __P((int));
-extern Char **tw_item_get __P((void));
-extern void tw_item_free __P((void));
-extern Char *tw_item_find __P((Char *));
+extern void tw_alias_start (DIR *, const Char *);
+extern void tw_cmd_start (DIR *, const Char *);
+extern void tw_logname_start (DIR *, const Char *);
+extern void tw_var_start (DIR *, const Char *);
+extern void tw_complete_start (DIR *, const Char *);
+extern void tw_file_start (DIR *, const Char *);
+extern void tw_vl_start (DIR *, const Char *);
+extern void tw_wl_start (DIR *, const Char *);
+extern void tw_bind_start (DIR *, const Char *);
+extern void tw_limit_start (DIR *, const Char *);
+extern void tw_sig_start (DIR *, const Char *);
+extern void tw_job_start (DIR *, const Char *);
+extern void tw_grpname_start (DIR *, const Char *);
+extern int tw_cmd_next (struct Strbuf *,
+ struct Strbuf *, int *);
+extern int tw_logname_next (struct Strbuf *,
+ struct Strbuf *, int *);
+extern int tw_shvar_next (struct Strbuf *,
+ struct Strbuf *, int *);
+extern int tw_envvar_next (struct Strbuf *,
+ struct Strbuf *, int *);
+extern int tw_var_next (struct Strbuf *,
+ struct Strbuf *, int *);
+extern int tw_file_next (struct Strbuf *,
+ struct Strbuf *, int *);
+extern int tw_wl_next (struct Strbuf *,
+ struct Strbuf *, int *);
+extern int tw_bind_next (struct Strbuf *,
+ struct Strbuf *, int *);
+extern int tw_limit_next (struct Strbuf *,
+ struct Strbuf *, int *);
+extern int tw_sig_next (struct Strbuf *,
+ struct Strbuf *, int *);
+extern int tw_job_next (struct Strbuf *,
+ struct Strbuf *, int *);
+extern int tw_grpname_next (struct Strbuf *,
+ struct Strbuf *, int *);
+extern void tw_dir_end (void);
+extern void tw_cmd_free (void);
+extern void tw_logname_end (void);
+extern void tw_grpname_end (void);
+extern void tw_item_add (const struct Strbuf *);
+extern Char **tw_item_get (void);
+extern void tw_item_free (void);
+extern Char *tw_item_find (Char *);
/*
* tw.spell.c
*/
-extern int spell_me __P((Char *, int, int,
- Char *, int));
-extern int spdir __P((Char *, Char *, Char *,
- Char *));
-extern int spdist __P((Char *, Char *));
+extern int spell_me (struct Strbuf *, int, Char *,
+ eChar);
+extern int spdir (struct Strbuf *, const Char *,
+ const Char *, Char *);
+extern int spdist (const Char *, const Char *);
/*
* tw.comp.c
*/
-extern void docomplete __P((Char **,
- struct command *));
-extern void douncomplete __P((Char **,
- struct command *));
-extern int tw_complete __P((Char *, Char **,
- Char **, int, int *));
+extern void docomplete (Char **, struct command *);
+extern void douncomplete (Char **, struct command *);
+extern int tw_complete (const Char *, Char **,
+ Char **, int, eChar *);
#ifdef COLOR_LS_F
/*
* tw.color.c
*/
-extern void set_color_context __P((void));
-extern void print_with_color __P((Char *, size_t, Char));
-extern void parseLS_COLORS __P((Char *));
+extern void set_color_context (void);
+extern void print_with_color (const Char *, size_t, Char);
+extern void parseLS_COLORS (const Char *);
#endif /* COLOR_LS_F */
#endif /* _h_tw_decls */
diff --git a/contrib/tcsh/tw.h b/contrib/tcsh/tw.h
index c9c4468..5b2e661 100644
--- a/contrib/tcsh/tw.h
+++ b/contrib/tcsh/tw.h
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/tw.h,v 3.24 2004/11/23 02:10:50 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/tw.h,v 3.25 2006/01/12 18:15:25 christos Exp $ */
/*
* tw.h: TwENEX functions headers
*/
@@ -73,9 +73,7 @@
#endif
#define ON 1
#define OFF 0
-#define FILSIZ BUFSIZE /* Max reasonable file name length */
#define ESC CTL_ESC('\033')
-#define equal(a, b) (strcmp(a, b) == 0)
#define is_set(var) adrof(var)
#define ismetahash(a) (ismeta(a) && (a) != '#')
diff --git a/contrib/tcsh/tw.help.c b/contrib/tcsh/tw.help.c
index ea99a94..2199bbd 100644
--- a/contrib/tcsh/tw.help.c
+++ b/contrib/tcsh/tw.help.c
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/tw.help.c,v 3.21 2005/01/18 20:24:51 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/tw.help.c,v 3.27 2006/08/24 20:56:31 christos Exp $ */
/* tw.help.c: actually look up and print documentation on a file.
* Look down the path for an appropriate file, then print it.
* Note that the printing is NOT PAGED. This is because the
@@ -35,72 +35,77 @@
*/
#include "sh.h"
-RCSID("$Id: tw.help.c,v 3.21 2005/01/18 20:24:51 christos Exp $")
+RCSID("$tcsh: tw.help.c,v 3.27 2006/08/24 20:56:31 christos Exp $")
#include "tw.h"
#include "tc.h"
static int f = -1;
-static RETSIGTYPE cleanf __P((int));
-static Char *skipslist __P((Char *));
-static void nextslist __P((Char *, Char *));
+static void cleanf (int);
+static Char *skipslist (Char *);
+static void nextslist (const Char *, Char *);
-static const char *h_ext[] = {
+static const char *const h_ext[] = {
".help", ".1", ".8", ".6", "", NULL
};
void
-do_help(command)
- Char *command;
+do_help(const Char *command)
{
- Char name[FILSIZ + 1];
- Char *cmd_p, *ep;
- const char **sp;
-
- signalfun_t orig_intr;
- Char curdir[MAXPATHLEN]; /* Current directory being looked at */
- Char *hpath; /* The environment parameter */
- Char full[MAXPATHLEN];
- char buf[512]; /* full path name and buffer for read */
- int len; /* length of read buffer */
- Char *thpath;
-
+ Char *name, *cmd_p;
/* trim off the whitespace at the beginning */
- for (cmd_p = command; *cmd_p == ' ' || *cmd_p == '\t'; cmd_p++)
- continue;
-
+ while (*command == ' ' || *command == '\t')
+ command++;
+
/* copy the string to a safe place */
- copyn(name, cmd_p, FILSIZ + 1);
+ name = Strsave(command);
+ cleanup_push(name, xfree);
/* trim off the whitespace that may be at the end */
- for (cmd_p = name;
+ for (cmd_p = name;
*cmd_p != ' ' && *cmd_p != '\t' && *cmd_p != '\0'; cmd_p++)
continue;
*cmd_p = '\0';
/* if nothing left, return */
- if (*name == '\0')
+ if (*name == '\0') {
+ cleanup_until(name);
return;
+ }
if (adrof1(STRhelpcommand, &aliases)) { /* if we have an alias */
jmp_buf_t osetexit;
+ size_t omark;
getexit(osetexit); /* make sure to come back here */
+ omark = cleanup_push_mark();
if (setexit() == 0)
aliasrun(2, STRhelpcommand, name); /* then use it. */
+ cleanup_pop_mark(omark);
resexit(osetexit); /* and finish up */
}
else { /* else cat something to them */
+ Char *thpath, *hpath; /* The environment parameter */
+ Char *curdir; /* Current directory being looked at */
+ struct Strbuf full = Strbuf_INIT;
+
/* got is, now "cat" the file based on the path $HPATH */
hpath = str2short(getenv(SEARCHLIST));
if (hpath == NULL)
hpath = str2short(DEFAULTLIST);
thpath = hpath = Strsave(hpath);
+ cleanup_push(thpath, xfree);
+ curdir = xmalloc((Strlen(thpath) + 1) * sizeof (*curdir));
+ cleanup_push(curdir, xfree);
+ cleanup_push(&full, Strbuf_cleanup);
for (;;) {
+ const char *const *sp;
+ size_t ep;
+
if (!*hpath) {
xprintf(CGETS(29, 1, "No help file for %S\n"), name);
break;
@@ -113,48 +118,55 @@ do_help(command)
* /bar/foo.1, /bar/foo.8, then finally /bar/foo.6. This is so
* that you don't spit a binary at the tty when $HPATH == $PATH.
*/
- copyn(full, curdir, (int) (sizeof(full) / sizeof(Char)));
- catn(full, STRslash, (int) (sizeof(full) / sizeof(Char)));
- catn(full, name, (int) (sizeof(full) / sizeof(Char)));
- ep = &full[Strlen(full)];
+ full.len = 0;
+ Strbuf_append(&full, curdir);
+ Strbuf_append(&full, STRslash);
+ Strbuf_append(&full, name);
+ ep = full.len;
for (sp = h_ext; *sp; sp++) {
- *ep = '\0';
- catn(full, str2short(*sp), (int) (sizeof(full) / sizeof(Char)));
- if ((f = open(short2str(full), O_RDONLY|O_LARGEFILE)) != -1)
+ full.len = ep;
+ Strbuf_append(&full, str2short(*sp));
+ Strbuf_terminate(&full);
+ if ((f = xopen(short2str(full.s), O_RDONLY|O_LARGEFILE)) != -1)
break;
}
if (f != -1) {
+ unsigned char buf[512];
+ sigset_t oset, set;
+ struct sigaction osa, sa;
+ ssize_t len;
+
/* so cat it to the terminal */
- orig_intr = (signalfun_t) sigset(SIGINT, cleanf);
- while (f != -1 && (len = read(f, (char *) buf, 512)) > 0)
- (void) write(SHOUT, (char *) buf, (size_t) len);
+ cleanup_push(&f, open_cleanup);
+ sa.sa_handler = cleanf;
+ sigemptyset(&sa.sa_mask);
+ sa.sa_flags = 0;
+ (void)sigaction(SIGINT, &sa, &osa);
+ cleanup_push(&osa, sigint_cleanup);
+ (void)sigprocmask(SIG_UNBLOCK, &set, &oset);
+ cleanup_push(&oset, sigprocmask_cleanup);
+ while ((len = xread(f, buf, sizeof(buf))) > 0)
+ (void) xwrite(SHOUT, buf, len);
+ cleanup_until(&f);
#ifdef convex
/* print error in case file is migrated */
if (len == -1)
stderror(ERR_SYSTEM, progname, strerror(errno));
#endif /* convex */
- (void) sigset(SIGINT, orig_intr);
- if (f != -1)
- (void) close(f);
break;
}
}
- xfree((ptr_t) thpath);
}
+ cleanup_until(name);
}
-static RETSIGTYPE
+static void
/*ARGSUSED*/
-cleanf(snum)
-int snum;
+cleanf(int snum)
{
USE(snum);
-#ifdef UNRELSIGS
- if (snum)
- (void) sigset(SIGINT, cleanf);
-#endif /* UNRELSIGS */
if (f != -1)
- (void) close(f);
+ xclose(f);
f = -1;
}
@@ -169,9 +181,7 @@ int snum;
*/
static void
-nextslist(sl, np)
- Char *sl;
- Char *np;
+nextslist(const Char *sl, Char *np)
{
if (!*sl)
*np = '\000';
@@ -191,8 +201,7 @@ nextslist(sl, np)
*/
static Char *
-skipslist(sl)
- Char *sl;
+skipslist(Char *sl)
{
while (*sl && *sl++ != ':')
continue;
diff --git a/contrib/tcsh/tw.init.c b/contrib/tcsh/tw.init.c
index 30dce51..29f5586 100644
--- a/contrib/tcsh/tw.init.c
+++ b/contrib/tcsh/tw.init.c
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/tw.init.c,v 3.34 2005/01/05 16:06:15 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/tw.init.c,v 3.39 2006/03/02 18:46:45 christos Exp $ */
/*
* tw.init.c: Handle lists of things to complete
*/
@@ -32,7 +32,7 @@
*/
#include "sh.h"
-RCSID("$Id: tw.init.c,v 3.34 2005/01/05 16:06:15 christos Exp $")
+RCSID("$tcsh: tw.init.c,v 3.39 2006/03/02 18:46:45 christos Exp $")
#include "tw.h"
#include "ed.h"
@@ -44,7 +44,7 @@ RCSID("$Id: tw.init.c,v 3.34 2005/01/05 16:06:15 christos Exp $")
typedef struct {
Char **list, /* List of command names */
*buff; /* Space holding command names */
- int nlist, /* Number of items */
+ size_t nlist, /* Number of items */
nbuff, /* Current space in name buf */
tlist, /* Total space in list */
tbuff; /* Total space in name buf */
@@ -53,14 +53,13 @@ typedef struct {
static struct varent *tw_vptr = NULL; /* Current shell variable */
static Char **tw_env = NULL; /* Current environment variable */
-static Char *tw_word; /* Current word pointer */
+static const Char *tw_word; /* Current word pointer */
static struct KeyFuncs *tw_bind = NULL; /* List of the bindings */
#ifndef HAVENOLIMIT
static struct limits *tw_limit = NULL; /* List of the resource limits */
#endif /* HAVENOLIMIT */
static int tw_index = 0; /* signal and job index */
static DIR *tw_dir_fd = NULL; /* Current directory descriptor */
-static Char tw_retname[MAXPATHLEN+1]; /* Return buffer */
static int tw_cmd_got = 0; /* What we need to do */
static stringlist_t tw_cmd = { NULL, NULL, 0, 0, 0, 0 };
static stringlist_t tw_item = { NULL, NULL, 0, 0, 0, 0 };
@@ -71,21 +70,12 @@ static stringlist_t tw_item = { NULL, NULL, 0, 0, 0, 0 };
#define TW_FL_REL 0x10
static struct { /* Current element pointer */
- int cur; /* Current element number */
+ size_t cur; /* Current element number */
Char **pathv; /* Current element in path */
DIR *dfd; /* Current directory descriptor */
} tw_cmd_state;
-#ifdef BSDSIGS
-static sigmask_t tw_omask;
-# define TW_HOLD() tw_omask = sigblock(sigmask(SIGINT))
-# define TW_RELS() (void) sigsetmask(tw_omask)
-#else /* !BSDSIGS */
-# define TW_HOLD() (void) sighold(SIGINT)
-# define TW_RELS() (void) sigrelse(SIGINT)
-#endif /* BSDSIGS */
-
#define SETDIR(dfd) \
{ \
tw_dir_fd = dfd; \
@@ -95,59 +85,51 @@ static sigmask_t tw_omask;
#define CLRDIR(dfd) \
if (dfd != NULL) { \
- TW_HOLD(); \
- (void) closedir(dfd); \
+ pintr_disabled++; \
+ xclosedir(dfd); \
dfd = NULL; \
- TW_RELS(); \
+ disabled_cleanup(&pintr_disabled); \
}
-static Char *tw_str_add __P((stringlist_t *, int));
-static void tw_str_free __P((stringlist_t *));
-static Char *tw_dir_next __P((DIR *));
-static void tw_cmd_add __P((const Char *name));
-static void tw_cmd_cmd __P((void));
-static void tw_cmd_builtin __P((void));
-static void tw_cmd_alias __P((void));
-static void tw_cmd_sort __P((void));
-static void tw_vptr_start __P((struct varent *));
+static Char *tw_str_add (stringlist_t *, size_t);
+static void tw_str_free (stringlist_t *);
+static int tw_dir_next (struct Strbuf *, DIR *);
+static void tw_cmd_add (const Char *name);
+static void tw_cmd_cmd (void);
+static void tw_cmd_builtin (void);
+static void tw_cmd_alias (void);
+static void tw_cmd_sort (void);
+static void tw_vptr_start (struct varent *);
/* tw_str_add():
* Add an item to the string list
*/
static Char *
-tw_str_add(sl, len)
- stringlist_t *sl;
- int len;
+tw_str_add(stringlist_t *sl, size_t len)
{
Char *ptr;
if (sl->tlist <= sl->nlist) {
- TW_HOLD();
+ pintr_disabled++;
sl->tlist += TW_INCR;
- sl->list = sl->list ?
- (Char **) xrealloc((ptr_t) sl->list,
- (size_t) (sl->tlist * sizeof(Char *))) :
- (Char **) xmalloc((size_t) (sl->tlist * sizeof(Char *)));
- TW_RELS();
+ sl->list = xrealloc(sl->list, sl->tlist * sizeof(Char *));
+ disabled_cleanup(&pintr_disabled);
}
if (sl->tbuff <= sl->nbuff + len) {
- int i;
- ptr = sl->buff;
+ size_t i;
- TW_HOLD();
+ ptr = sl->buff;
+ pintr_disabled++;
sl->tbuff += TW_INCR + len;
- sl->buff = sl->buff ?
- (Char *) xrealloc((ptr_t) sl->buff,
- (size_t) (sl->tbuff * sizeof(Char))) :
- (Char *) xmalloc((size_t) (sl->tbuff * sizeof(Char)));
+ sl->buff = xrealloc(sl->buff, sl->tbuff * sizeof(Char));
/* Re-thread the new pointer list, if changed */
if (ptr != NULL && ptr != sl->buff) {
intptr_t offs = sl->buff - ptr;
for (i = 0; i < sl->nlist; i++)
sl->list[i] += offs;
}
- TW_RELS();
+ disabled_cleanup(&pintr_disabled);
}
ptr = sl->list[sl->nlist++] = &sl->buff[sl->nbuff];
sl->nbuff += len;
@@ -159,38 +141,36 @@ tw_str_add(sl, len)
* Free a stringlist
*/
static void
-tw_str_free(sl)
- stringlist_t *sl;
+tw_str_free(stringlist_t *sl)
{
- TW_HOLD();
+ pintr_disabled++;
if (sl->list) {
- xfree((ptr_t) sl->list);
+ xfree(sl->list);
sl->list = NULL;
sl->tlist = sl->nlist = 0;
}
if (sl->buff) {
- xfree((ptr_t) sl->buff);
+ xfree(sl->buff);
sl->buff = NULL;
sl->tbuff = sl->nbuff = 0;
}
- TW_RELS();
+ disabled_cleanup(&pintr_disabled);
} /* end tw_str_free */
-static Char *
-tw_dir_next(dfd)
- DIR *dfd;
+static int
+tw_dir_next(struct Strbuf *res, DIR *dfd)
{
struct dirent *dirp;
if (dfd == NULL)
- return NULL;
+ return 0;
if ((dirp = readdir(dfd)) != NULL) {
- (void) Strcpy(tw_retname, str2short(dirp->d_name));
- return (tw_retname);
+ Strbuf_append(res, str2short(dirp->d_name));
+ return 1;
}
- return NULL;
+ return 0;
} /* end tw_dir_next */
@@ -198,12 +178,11 @@ tw_dir_next(dfd)
* Add the name to the command list
*/
static void
-tw_cmd_add(name)
- const Char *name;
+tw_cmd_add(const Char *name)
{
- int len;
+ size_t len;
- len = (int) Strlen(name) + 2;
+ len = Strlen(name) + 2;
(void) Strcpy(tw_str_add(&tw_cmd, len), name);
} /* end tw_cmd_add */
@@ -212,7 +191,7 @@ tw_cmd_add(name)
* Free the command list
*/
void
-tw_cmd_free()
+tw_cmd_free(void)
{
CLRDIR(tw_dir_fd)
tw_str_free(&tw_cmd);
@@ -223,7 +202,7 @@ tw_cmd_free()
* Add system commands to the command list
*/
static void
-tw_cmd_cmd()
+tw_cmd_cmd(void)
{
DIR *dirp;
struct dirent *dp;
@@ -231,7 +210,7 @@ tw_cmd_cmd()
Char **pv;
struct varent *v = adrof(STRpath);
struct varent *recexec = adrof(STRrecognize_only_executables);
- int len;
+ size_t len;
if (v == NULL || v->vec == NULL) /* if no path */
@@ -246,34 +225,35 @@ tw_cmd_cmd()
if ((dirp = opendir(short2str(*pv))) == NULL)
continue;
- if (recexec)
+ cleanup_push(dirp, opendir_cleanup);
+ if (recexec) {
dir = Strspl(*pv, STRslash);
+ cleanup_push(dir, xfree);
+ }
while ((dp = readdir(dirp)) != NULL) {
#if defined(_UWIN) || defined(__CYGWIN__)
/* Turn foo.{exe,com,bat} into foo since UWIN's readdir returns
* the file with the .exe, .com, .bat extension
*/
- size_t ext = strlen(dp->d_name) - 4;
- if ((ext > 0) && (strcmp(&dp->d_name[ext], ".exe") == 0 ||
- strcmp(&dp->d_name[ext], ".bat") == 0 ||
- strcmp(&dp->d_name[ext], ".com") == 0))
- dp->d_name[ext] = '\0';
+ len = strlen(dp->d_name);
+ if (len > 4 && (strcmp(&dp->d_name[len - 4], ".exe") == 0 ||
+ strcmp(&dp->d_name[len - 4], ".bat") == 0 ||
+ strcmp(&dp->d_name[len - 4], ".com") == 0))
+ dp->d_name[len - 4] = '\0';
#endif /* _UWIN || __CYGWIN__ */
/* the call to executable() may make this a bit slow */
name = str2short(dp->d_name);
if (dp->d_ino == 0 || (recexec && !executable(dir, name, 0)))
continue;
- len = (int) Strlen(name) + 2;
+ len = Strlen(name);
if (name[0] == '#' || /* emacs temp files */
name[0] == '.' || /* .files */
- name[len - 3] == '~' || /* emacs backups */
- name[len - 3] == '%') /* textedit backups */
+ name[len - 1] == '~' || /* emacs backups */
+ name[len - 1] == '%') /* textedit backups */
continue; /* Ignore! */
tw_cmd_add(name);
}
- (void) closedir(dirp);
- if (recexec)
- xfree((ptr_t) dir);
+ cleanup_until(dirp);
}
} /* end tw_cmd_cmd */
@@ -282,9 +262,9 @@ tw_cmd_cmd()
* Add builtins to the command list
*/
static void
-tw_cmd_builtin()
+tw_cmd_builtin(void)
{
- struct biltins *bptr;
+ const struct biltins *bptr;
for (bptr = bfunc; bptr < &bfunc[nbfunc]; bptr++)
if (bptr->bname)
@@ -301,7 +281,7 @@ tw_cmd_builtin()
* Add aliases to the command list
*/
static void
-tw_cmd_alias()
+tw_cmd_alias(void)
{
struct varent *p;
struct varent *c;
@@ -332,17 +312,16 @@ x:
* Sort the command list removing duplicate elements
*/
static void
-tw_cmd_sort()
+tw_cmd_sort(void)
{
- int fwd, i;
+ size_t fwd, i;
- TW_HOLD();
+ pintr_disabled++;
/* sort the list. */
- qsort((ptr_t) tw_cmd.list, (size_t) tw_cmd.nlist, sizeof(Char *),
- (int (*) __P((const void *, const void *))) fcompare);
+ qsort(tw_cmd.list, tw_cmd.nlist, sizeof(Char *), fcompare);
/* get rid of multiple entries */
- for (i = 0, fwd = 0; i < tw_cmd.nlist - 1; i++) {
+ for (i = 0, fwd = 0; i + 1 < tw_cmd.nlist; i++) {
if (Strcmp(tw_cmd.list[i], tw_cmd.list[i + 1]) == 0) /* garbage */
fwd++; /* increase the forward ref. count */
else if (fwd)
@@ -352,7 +331,7 @@ tw_cmd_sort()
if (fwd)
tw_cmd.list[i - fwd] = tw_cmd.list[i];
tw_cmd.nlist -= fwd;
- TW_RELS();
+ disabled_cleanup(&pintr_disabled);
} /* end tw_cmd_sort */
@@ -362,9 +341,7 @@ tw_cmd_sort()
*/
/*ARGSUSED*/
void
-tw_cmd_start(dfd, pat)
- DIR *dfd;
- Char *pat;
+tw_cmd_start(DIR *dfd, const Char *pat)
{
static Char *defpath[] = { STRNULL, 0 };
USE(pat);
@@ -407,49 +384,52 @@ tw_cmd_start(dfd, pat)
* Return the next element in the command list or
* Look for commands in the relative path components
*/
-Char *
-tw_cmd_next(dir, flags)
- Char *dir;
- int *flags;
+int
+tw_cmd_next(struct Strbuf *res, struct Strbuf *dir, int *flags)
{
- Char *ptr = NULL;
+ int ret = 0;
+ Char *ptr;
if (tw_cmd_state.cur < tw_cmd.nlist) {
*flags = TW_DIR_OK;
- return tw_cmd.list[tw_cmd_state.cur++];
+ Strbuf_append(res, tw_cmd.list[tw_cmd_state.cur++]);
+ return 1;
}
/*
* We need to process relatives in the path.
*/
- while (((tw_cmd_state.dfd == NULL) ||
- ((ptr = tw_dir_next(tw_cmd_state.dfd)) == NULL)) &&
- (*tw_cmd_state.pathv != NULL)) {
+ while ((tw_cmd_state.dfd == NULL ||
+ (ret = tw_dir_next(res, tw_cmd_state.dfd)) == 0) &&
+ *tw_cmd_state.pathv != NULL) {
CLRDIR(tw_cmd_state.dfd)
while (*tw_cmd_state.pathv && tw_cmd_state.pathv[0][0] == '/')
tw_cmd_state.pathv++;
if ((ptr = *tw_cmd_state.pathv) != 0) {
+ Strbuf_append(res, ptr);
+ ret = 1;
/*
* We complete directories only on '.' should that
* be changed?
*/
+ dir->len = 0;
if (ptr[0] == '\0' || (ptr[0] == '.' && ptr[1] == '\0')) {
- *dir = '\0';
tw_cmd_state.dfd = opendir(".");
- *flags = TW_DIR_OK | TW_EXEC_CHK;
+ *flags = TW_DIR_OK | TW_EXEC_CHK;
}
else {
- copyn(dir, *tw_cmd_state.pathv, FILSIZ);
- catn(dir, STRslash, FILSIZ);
+ Strbuf_append(dir, *tw_cmd_state.pathv);
+ Strbuf_append1(dir, '/');
tw_cmd_state.dfd = opendir(short2str(*tw_cmd_state.pathv));
*flags = TW_EXEC_CHK;
}
+ Strbuf_terminate(dir);
tw_cmd_state.pathv++;
}
}
- return ptr;
+ return ret;
} /* end tw_cmd_next */
@@ -457,8 +437,7 @@ tw_cmd_next(dir, flags)
* Find the first variable in the variable list
*/
static void
-tw_vptr_start(c)
- struct varent *c;
+tw_vptr_start(struct varent *c)
{
tw_vptr = c; /* start at beginning of variable list */
@@ -489,21 +468,18 @@ x:
* Return the next shell variable
*/
/*ARGSUSED*/
-Char *
-tw_shvar_next(dir, flags)
- Char *dir;
- int *flags;
+int
+tw_shvar_next(struct Strbuf *res, struct Strbuf *dir, int *flags)
{
struct varent *p;
struct varent *c;
- Char *cp;
USE(flags);
USE(dir);
if ((p = tw_vptr) == NULL)
- return (NULL); /* just in case */
+ return 0; /* just in case */
- cp = p->v_name; /* we know that this name is here now */
+ Strbuf_append(res, p->v_name); /* we know that this name is here now */
/* now find the next one */
for (;;) {
@@ -520,11 +496,11 @@ tw_shvar_next(dir, flags)
}
if (p->v_parent == 0) { /* is it the header? */
tw_vptr = NULL;
- return (cp);
+ return 1;
}
if (p->v_name) {
tw_vptr = p; /* save state for the next call */
- return (cp);
+ return 1;
}
}
} /* end tw_shvar_next */
@@ -534,23 +510,20 @@ tw_shvar_next(dir, flags)
* Return the next environment variable
*/
/*ARGSUSED*/
-Char *
-tw_envvar_next(dir, flags)
- Char *dir;
- int *flags;
+int
+tw_envvar_next(struct Strbuf *res, struct Strbuf *dir, int *flags)
{
- Char *ps, *pd;
+ const Char *ps;
USE(flags);
USE(dir);
if (tw_env == NULL || *tw_env == NULL)
- return (NULL);
- for (ps = *tw_env, pd = tw_retname;
- *ps && *ps != '=' && pd <= &tw_retname[MAXPATHLEN]; *pd++ = *ps++)
+ return 0;
+ for (ps = *tw_env; *ps && *ps != '='; ps++)
continue;
- *pd = '\0';
+ Strbuf_appendn(res, *tw_env, ps - *tw_env);
tw_env++;
- return (tw_retname);
+ return 1;
} /* end tw_envvar_next */
@@ -559,9 +532,7 @@ tw_envvar_next(dir, flags)
*/
/*ARGSUSED*/
void
-tw_var_start(dfd, pat)
- DIR *dfd;
- Char *pat;
+tw_var_start(DIR *dfd, const Char *pat)
{
USE(pat);
SETDIR(dfd)
@@ -575,9 +546,7 @@ tw_var_start(dfd, pat)
*/
/*ARGSUSED*/
void
-tw_alias_start(dfd, pat)
- DIR *dfd;
- Char *pat;
+tw_alias_start(DIR *dfd, const Char *pat)
{
USE(pat);
SETDIR(dfd)
@@ -591,9 +560,7 @@ tw_alias_start(dfd, pat)
*/
/*ARGSUSED*/
void
-tw_complete_start(dfd, pat)
- DIR *dfd;
- Char *pat;
+tw_complete_start(DIR *dfd, const Char *pat)
{
USE(pat);
SETDIR(dfd)
@@ -605,18 +572,16 @@ tw_complete_start(dfd, pat)
/* tw_var_next():
* Return the next shell or environment variable
*/
-Char *
-tw_var_next(dir, flags)
- Char *dir;
- int *flags;
+int
+tw_var_next(struct Strbuf *res, struct Strbuf *dir, int *flags)
{
- Char *ptr = NULL;
+ int ret = 0;
if (tw_vptr)
- ptr = tw_shvar_next(dir, flags);
- if (!ptr && tw_env)
- ptr = tw_envvar_next(dir, flags);
- return ptr;
+ ret = tw_shvar_next(res, dir, flags);
+ if (ret == 0 && tw_env)
+ ret = tw_envvar_next(res, dir, flags);
+ return ret;
} /* end tw_var_next */
@@ -625,9 +590,7 @@ tw_var_next(dir, flags)
*/
/*ARGSUSED*/
void
-tw_logname_start(dfd, pat)
- DIR *dfd;
- Char *pat;
+tw_logname_start(DIR *dfd, const Char *pat)
{
USE(pat);
SETDIR(dfd)
@@ -641,13 +604,11 @@ tw_logname_start(dfd, pat)
* Return the next entry from the passwd file
*/
/*ARGSUSED*/
-Char *
-tw_logname_next(dir, flags)
- Char *dir;
- int *flags;
+int
+tw_logname_next(struct Strbuf *res, struct Strbuf *dir, int *flags)
{
- static Char retname[MAXPATHLEN];
struct passwd *pw;
+
/*
* We don't want to get interrupted inside getpwent()
* because the yellow pages code is not interruptible,
@@ -656,22 +617,22 @@ tw_logname_next(dir, flags)
*/
USE(flags);
USE(dir);
- TW_HOLD();
+ pintr_disabled++;
#ifdef HAVE_GETPWENT
pw = getpwent();
#else
pw = NULL;
#endif
- TW_RELS();
+ disabled_cleanup(&pintr_disabled);
if (pw == NULL) {
#ifdef YPBUGS
fix_yp_bugs();
#endif
- return (NULL);
+ return 0;
}
- (void) Strcpy(retname, str2short(pw->pw_name));
- return (retname);
+ Strbuf_append(res, str2short(pw->pw_name));
+ return 1;
} /* end tw_logname_next */
@@ -679,7 +640,7 @@ tw_logname_next(dir, flags)
* Close the passwd file to finish the logname list
*/
void
-tw_logname_end()
+tw_logname_end(void)
{
#ifdef YPBUGS
fix_yp_bugs();
@@ -695,9 +656,7 @@ tw_logname_end()
*/
/*ARGSUSED*/
void
-tw_grpname_start(dfd, pat)
- DIR *dfd;
- Char *pat;
+tw_grpname_start(DIR *dfd, const Char *pat)
{
USE(pat);
SETDIR(dfd)
@@ -711,13 +670,11 @@ tw_grpname_start(dfd, pat)
* Return the next entry from the group file
*/
/*ARGSUSED*/
-Char *
-tw_grpname_next(dir, flags)
- Char *dir;
- int *flags;
+int
+tw_grpname_next(struct Strbuf *res, struct Strbuf *dir, int *flags)
{
- static Char retname[MAXPATHLEN];
struct group *gr;
+
/*
* We don't want to get interrupted inside getgrent()
* because the yellow pages code is not interruptible,
@@ -726,22 +683,26 @@ tw_grpname_next(dir, flags)
*/
USE(flags);
USE(dir);
- TW_HOLD();
+ pintr_disabled++;
#if !defined(_VMS_POSIX) && !defined(_OSD_POSIX) && !defined(WINNT_NATIVE)
- gr = (struct group *) getgrent();
+ errno = 0;
+ while ((gr = getgrent()) == NULL && errno == EINTR) {
+ handle_pending_signals();
+ errno = 0;
+ }
#else /* _VMS_POSIX || _OSD_POSIX || WINNT_NATIVE */
gr = NULL;
#endif /* !_VMS_POSIX && !_OSD_POSIX && !WINNT_NATIVE */
- TW_RELS();
+ disabled_cleanup(&pintr_disabled);
if (gr == NULL) {
#ifdef YPBUGS
fix_yp_bugs();
#endif
- return (NULL);
+ return 0;
}
- (void) Strcpy(retname, str2short(gr->gr_name));
- return (retname);
+ Strbuf_append(res, str2short(gr->gr_name));
+ return 1;
} /* end tw_grpname_next */
@@ -749,7 +710,7 @@ tw_grpname_next(dir, flags)
* Close the group file to finish the groupname list
*/
void
-tw_grpname_end()
+tw_grpname_end(void)
{
#ifdef YPBUGS
fix_yp_bugs();
@@ -764,9 +725,7 @@ tw_grpname_end()
*/
/*ARGSUSED*/
void
-tw_file_start(dfd, pat)
- DIR *dfd;
- Char *pat;
+tw_file_start(DIR *dfd, const Char *pat)
{
struct varent *vp;
USE(pat);
@@ -779,27 +738,27 @@ tw_file_start(dfd, pat)
/* tw_file_next():
* Return the next file in the directory
*/
-Char *
-tw_file_next(dir, flags)
- Char *dir;
- int *flags;
+int
+tw_file_next(struct Strbuf *res, struct Strbuf *dir, int *flags)
{
- Char *ptr = tw_dir_next(tw_dir_fd);
- if (ptr == NULL && (*flags & TW_DIR_OK) != 0) {
+ int ret = tw_dir_next(res, tw_dir_fd);
+ if (ret == 0 && (*flags & TW_DIR_OK) != 0) {
CLRDIR(tw_dir_fd)
while (tw_env && *tw_env)
if ((tw_dir_fd = opendir(short2str(*tw_env))) != NULL)
break;
else
tw_env++;
-
+
if (tw_dir_fd) {
- copyn(dir, *tw_env++, MAXPATHLEN);
- catn(dir, STRslash, MAXPATHLEN);
- ptr = tw_dir_next(tw_dir_fd);
+ dir->len = 0;
+ Strbuf_append(dir, *tw_env++);
+ Strbuf_append1(dir, '/');
+ Strbuf_terminate(dir);
+ ret = tw_dir_next(res, tw_dir_fd);
}
}
- return ptr;
+ return ret;
} /* end tw_file_next */
@@ -807,7 +766,7 @@ tw_file_next(dir, flags)
* Clear directory related lists
*/
void
-tw_dir_end()
+tw_dir_end(void)
{
CLRDIR(tw_dir_fd)
CLRDIR(tw_cmd_state.dfd)
@@ -818,7 +777,7 @@ tw_dir_end()
* Free the item list
*/
void
-tw_item_free()
+tw_item_free(void)
{
tw_str_free(&tw_item);
} /* end tw_item_free */
@@ -828,20 +787,22 @@ tw_item_free()
* Return the list of items
*/
Char **
-tw_item_get()
+tw_item_get(void)
{
return tw_item.list;
} /* end tw_item_get */
/* tw_item_add():
- * Return a new item
+ * Return a new item for a Strbuf_terminate()'d s
*/
-Char *
-tw_item_add(len)
- int len;
+void
+tw_item_add(const struct Strbuf *s)
{
- return tw_str_add(&tw_item, len);
+ Char *p;
+
+ p = tw_str_add(&tw_item, s->len + 1);
+ Strcpy(p, s->s);
} /* tw_item_add */
@@ -850,10 +811,9 @@ tw_item_add(len)
* end return it.
*/
Char *
-tw_item_find(str)
- Char *str;
+tw_item_find(Char *str)
{
- int i;
+ size_t i;
if (tw_item.list == NULL || str == NULL)
return NULL;
@@ -869,9 +829,7 @@ tw_item_find(str)
* Initialize a variable list
*/
void
-tw_vl_start(dfd, pat)
- DIR *dfd;
- Char *pat;
+tw_vl_start(DIR *dfd, const Char *pat)
{
SETDIR(dfd)
if ((tw_vptr = adrof(pat)) != NULL) {
@@ -887,9 +845,7 @@ tw_vl_start(dfd, pat)
* Initialize a word list
*/
void
-tw_wl_start(dfd, pat)
- DIR *dfd;
- Char *pat;
+tw_wl_start(DIR *dfd, const Char *pat)
{
SETDIR(dfd);
tw_word = pat;
@@ -900,22 +856,26 @@ tw_wl_start(dfd, pat)
* Return the next word from the word list
*/
/*ARGSUSED*/
-Char *
-tw_wl_next(dir, flags)
- Char *dir;
- int *flags;
+int
+tw_wl_next(struct Strbuf *res, struct Strbuf *dir, int *flags)
{
+ const Char *p;
+
+ USE(dir);
USE(flags);
if (tw_word == NULL || tw_word[0] == '\0')
- return NULL;
-
+ return 0;
+
while (*tw_word && Isspace(*tw_word)) tw_word++;
- for (dir = tw_word; *tw_word && !Isspace(*tw_word); tw_word++)
+ for (p = tw_word; *tw_word && !Isspace(*tw_word); tw_word++)
continue;
+ if (tw_word == p)
+ return 0;
+ Strbuf_appendn(res, p, tw_word - p);
if (*tw_word)
- *tw_word++ = '\0';
- return *dir ? dir : NULL;
+ tw_word++;
+ return 1;
} /* end tw_wl_next */
@@ -924,9 +884,7 @@ tw_wl_next(dir, flags)
*/
/*ARGSUSED*/
void
-tw_bind_start(dfd, pat)
- DIR *dfd;
- Char *pat;
+tw_bind_start(DIR *dfd, const Char *pat)
{
USE(pat);
SETDIR(dfd)
@@ -938,21 +896,20 @@ tw_bind_start(dfd, pat)
* Begin the list of the shell bindings
*/
/*ARGSUSED*/
-Char *
-tw_bind_next(dir, flags)
- Char *dir;
- int *flags;
+int
+tw_bind_next(struct Strbuf *res, struct Strbuf *dir, int *flags)
{
- const char *ptr;
+ USE(dir);
USE(flags);
if (tw_bind && tw_bind->name) {
- for (ptr = tw_bind->name, dir = tw_retname;
- (*dir++ = (Char) *ptr++) != '\0';)
- continue;
+ const char *ptr;
+
+ for (ptr = tw_bind->name; *ptr != '\0'; ptr++)
+ Strbuf_append1(res, *ptr);
tw_bind++;
- return(tw_retname);
+ return 1;
}
- return NULL;
+ return 0;
} /* end tw_bind_next */
@@ -961,9 +918,7 @@ tw_bind_next(dir, flags)
*/
/*ARGSUSED*/
void
-tw_limit_start(dfd, pat)
- DIR *dfd;
- Char *pat;
+tw_limit_start(DIR *dfd, const Char *pat)
{
USE(pat);
SETDIR(dfd)
@@ -977,23 +932,22 @@ tw_limit_start(dfd, pat)
* Begin the list of the shell limitings
*/
/*ARGSUSED*/
-Char *
-tw_limit_next(dir, flags)
- Char *dir;
- int *flags;
+int
+tw_limit_next(struct Strbuf *res, struct Strbuf *dir, int *flags)
{
+ USE(dir);
+ USE(flags);
#ifndef HAVENOLIMIT
- const char *ptr;
if (tw_limit && tw_limit->limname) {
- for (ptr = tw_limit->limname, dir = tw_retname;
- (*dir++ = (Char) *ptr++) != '\0';)
- continue;
+ const char *ptr;
+
+ for (ptr = tw_limit->limname; *ptr != '\0'; ptr++)
+ Strbuf_append1(res, *ptr);
tw_limit++;
- return(tw_retname);
+ return 1;
}
#endif /* ! HAVENOLIMIT */
- USE(flags);
- return NULL;
+ return 0;
} /* end tw_limit_next */
@@ -1002,9 +956,7 @@ tw_limit_next(dir, flags)
*/
/*ARGSUSED*/
void
-tw_sig_start(dfd, pat)
- DIR *dfd;
- Char *pat;
+tw_sig_start(DIR *dfd, const Char *pat)
{
USE(pat);
SETDIR(dfd)
@@ -1016,25 +968,23 @@ tw_sig_start(dfd, pat)
* Begin the list of the shell sigings
*/
/*ARGSUSED*/
-Char *
-tw_sig_next(dir, flags)
- Char *dir;
- int *flags;
+int
+tw_sig_next(struct Strbuf *res, struct Strbuf *dir, int *flags)
{
- const char *ptr;
+ USE(dir);
USE(flags);
for (;tw_index < nsig; tw_index++) {
+ const char *ptr;
if (mesg[tw_index].iname == NULL)
continue;
- for (ptr = mesg[tw_index].iname, dir = tw_retname;
- (*dir++ = (Char) *ptr++) != '\0';)
- continue;
+ for (ptr = mesg[tw_index].iname; *ptr != '\0'; ptr++)
+ Strbuf_append1(res, *ptr);
tw_index++;
- return(tw_retname);
+ return 1;
}
- return NULL;
+ return 0;
} /* end tw_sig_next */
@@ -1043,9 +993,7 @@ tw_sig_next(dir, flags)
*/
/*ARGSUSED*/
void
-tw_job_start(dfd, pat)
- DIR *dfd;
- Char *pat;
+tw_job_start(DIR *dfd, const Char *pat)
{
USE(pat);
SETDIR(dfd)
@@ -1057,14 +1005,12 @@ tw_job_start(dfd, pat)
* Begin the list of the shell jobings
*/
/*ARGSUSED*/
-Char *
-tw_job_next(dir, flags)
- Char *dir;
- int *flags;
+int
+tw_job_next(struct Strbuf *res, struct Strbuf *dir, int *flags)
{
- Char *ptr;
struct process *j;
+ USE(dir);
USE(flags);
for (;tw_index <= pmaxindex; tw_index++) {
for (j = proclist.p_next; j != NULL; j = j->p_next)
@@ -1072,11 +1018,9 @@ tw_job_next(dir, flags)
break;
if (j == NULL)
continue;
- for (ptr = j->p_command, dir = tw_retname; (*dir++ = *ptr++) != '\0';)
- continue;
- *dir = '\0';
+ Strbuf_append(res, j->p_command);
tw_index++;
- return(tw_retname);
+ return 1;
}
- return NULL;
+ return 0;
} /* end tw_job_next */
diff --git a/contrib/tcsh/tw.parse.c b/contrib/tcsh/tw.parse.c
index ed9df76..97cabce 100644
--- a/contrib/tcsh/tw.parse.c
+++ b/contrib/tcsh/tw.parse.c
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/tw.parse.c,v 3.105 2005/03/03 16:40:53 kim Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/tw.parse.c,v 3.123 2007/03/01 21:21:42 corinna Exp $ */
/*
* tw.parse.c: Everyone has taken a shot in this futile effort to
* lexically analyze a csh line... Well we cannot good
@@ -35,12 +35,14 @@
*/
#include "sh.h"
-RCSID("$Id: tw.parse.c,v 3.105 2005/03/03 16:40:53 kim Exp $")
+RCSID("$tcsh: tw.parse.c,v 3.123 2007/03/01 21:21:42 corinna Exp $")
#include "tw.h"
#include "ed.h"
#include "tc.h"
+#include <assert.h>
+
#ifdef WINNT_NATIVE
#include "nt.const.h"
#endif /* WINNT_NATIVE */
@@ -55,7 +57,7 @@ RCSID("$Id: tw.parse.c,v 3.105 2005/03/03 16:40:53 kim Exp $")
/* TW_COMPLETION, TW_ALIAS, TW_SHELLVAR, TW_ENVVAR, */
/* TW_BINDING, TW_WORDLIST, TW_LIMIT, TW_SIGNAL */
/* TW_JOB, TW_EXPLAIN, TW_TEXT, TW_GRPNAME */
-static void (*tw_start_entry[]) __P((DIR *, Char *)) = {
+static void (*const tw_start_entry[]) (DIR *, const Char *) = {
tw_file_start, tw_cmd_start, tw_var_start, tw_logname_start,
tw_file_start, tw_file_start, tw_vl_start, tw_logname_start,
tw_complete_start, tw_alias_start, tw_var_start, tw_var_start,
@@ -63,7 +65,8 @@ static void (*tw_start_entry[]) __P((DIR *, Char *)) = {
tw_job_start, tw_file_start, tw_file_start, tw_grpname_start
};
-static Char * (*tw_next_entry[]) __P((Char *, int *)) = {
+static int (*const tw_next_entry[]) (struct Strbuf *, struct Strbuf *,
+ int *) = {
tw_file_next, tw_cmd_next, tw_var_next, tw_logname_next,
tw_file_next, tw_file_next, tw_var_next, tw_logname_next,
tw_var_next, tw_var_next, tw_shvar_next, tw_envvar_next,
@@ -71,7 +74,7 @@ static Char * (*tw_next_entry[]) __P((Char *, int *)) = {
tw_job_next, tw_file_next, tw_file_next, tw_grpname_next
};
-static void (*tw_end_entry[]) __P((void)) = {
+static void (*const tw_end_entry[]) (void) = {
tw_dir_end, tw_dir_end, tw_dir_end, tw_logname_end,
tw_dir_end, tw_dir_end, tw_dir_end, tw_logname_end,
tw_dir_end, tw_dir_end, tw_dir_end, tw_dir_end,
@@ -97,37 +100,37 @@ int InsideCompletion = 0;
/* do the expand or list on the command line -- SHOULD BE REPLACED */
-static void extract_dir_and_name __P((Char *, Char *, Char *));
-static int insert_meta __P((Char *, Char *, Char *, int));
-static Char *tilde __P((Char *, Char *));
-#ifndef __MVS__
-static int expand_dir __P((Char *, Char *, DIR **, COMMAND));
-#endif
-static int nostat __P((Char *));
-static Char filetype __P((Char *, Char *));
-static int t_glob __P((Char ***, int));
-static int c_glob __P((Char ***));
-static int is_prefix __P((Char *, Char *));
-static int is_prefixmatch __P((Char *, Char *, int));
-static int is_suffix __P((Char *, Char *));
-static int recognize __P((Char *, Char *, int, int, int,
- int));
-static int ignored __P((Char *));
-static int isadirectory __P((Char *, Char *));
-#ifndef __MVS__
-static int tw_collect_items __P((COMMAND, int, Char *, Char *,
- Char *, Char *, int));
-static int tw_collect __P((COMMAND, int, Char *, Char *,
- Char **, Char *, int, DIR *));
-#endif
-static Char tw_suffix __P((int, Char *, Char *, Char *,
- Char *));
-static void tw_fixword __P((int, Char *, Char *, Char *, int));
-static void tw_list_items __P((int, int, int));
-static void add_scroll_tab __P((Char *));
-static void choose_scroll_tab __P((Char **, int));
-static void free_scroll_tab __P((void));
-static int find_rows __P((Char *[], int, int));
+static void extract_dir_and_name (const Char *, struct Strbuf *,
+ Char **);
+static int insert_meta (const Char *, const Char *,
+ const Char *, int);
+static int tilde (struct Strbuf *, Char *);
+static int expand_dir (const Char *, struct Strbuf *, DIR **,
+ COMMAND);
+static int nostat (Char *);
+static Char filetype (Char *, Char *);
+static int t_glob (Char ***, int);
+static int c_glob (Char ***);
+static int is_prefix (Char *, Char *);
+static int is_prefixmatch (Char *, Char *, int);
+static int is_suffix (Char *, Char *);
+static int recognize (struct Strbuf *, const Char *, size_t,
+ int, int, int);
+static int ignored (Char *);
+static int isadirectory (const Char *, const Char *);
+static int tw_collect_items (COMMAND, int, struct Strbuf *,
+ struct Strbuf *, Char *, const Char *,
+ int);
+static int tw_collect (COMMAND, int, struct Strbuf *,
+ struct Strbuf *, Char *, Char *, int,
+ DIR *);
+static Char tw_suffix (int, const Char *, Char *);
+static void tw_fixword (int, struct Strbuf *, Char *, Char *);
+static void tw_list_items (int, int, int);
+static void add_scroll_tab (Char *);
+static void choose_scroll_tab (struct Strbuf *, int);
+static void free_scroll_tab (void);
+static int find_rows (Char *[], int, int);
#ifdef notdef
/*
@@ -140,8 +143,6 @@ static int find_rows __P((Char *[], int, int));
((c[3] == ' ' || (c)[3] == '\t'))))
#endif
-#define QLINESIZE (INBUFSIZE + 1)
-
/* TRUE if character must be quoted */
#define tricky(w) (cmap(w, _META | _DOL | _QF | _QB | _ESC | _GLOB) && w != '#')
/* TRUE if double quotes don't protect character */
@@ -155,29 +156,24 @@ static int find_rows __P((Char *[], int, int));
* < 0: Error (incl spelling correction impossible)
*/
int
-tenematch(inputline, num_read, command)
- Char *inputline; /* match string prefix */
- int num_read; /* # actually in inputline */
- COMMAND command; /* LIST or RECOGNIZE or PRINT_HELP */
-
+tenematch(Char *inputline, int num_read, COMMAND command)
{
- Char qline[QLINESIZE];
+ struct Strbuf qline = Strbuf_INIT;
Char qu = 0, *pat = STRNULL;
- Char *str_end, *cp, *wp, *wordp;
- Char *cmd_start, *word_start, *word;
- Char *ocmd_start = NULL, *oword_start = NULL, *oword = NULL;
- int suf = 0;
- int space_left;
+ size_t wp, word, wordp, cmd_start, oword = 0, ocmd_start = 0;
+ Char *str_end, *cp;
+ Char *word_start;
+ Char *oword_start = NULL;
+ eChar suf = 0;
int looking; /* what we are looking for */
int search_ret; /* what search returned for debugging */
int backq = 0;
- if (num_read > QLINESIZE - 1)
- return -1;
str_end = &inputline[num_read];
+ cleanup_push(&qline, Strbuf_cleanup);
word_start = inputline;
- word = cmd_start = wp = qline;
+ word = cmd_start = 0;
for (cp = inputline; cp < str_end; cp++) {
if (!cmap(qu, _ESC)) {
if (cmap(*cp, _QF|_ESC)) {
@@ -192,49 +188,37 @@ tenematch(inputline, num_read, command)
oword_start = word_start;
oword = word;
word_start = cp + 1;
- word = cmd_start = wp + 1;
+ word = cmd_start = qline.len + 1;
}
else {
cmd_start = ocmd_start;
word_start = oword_start;
word = oword;
}
- *wp++ = *cp;
+ Strbuf_append1(&qline, *cp);
continue;
}
}
if (iscmdmeta(*cp))
- cmd_start = wp + 1;
+ cmd_start = qline.len + 1;
/* Don't quote '/' to make the recognize stuff work easily */
/* Don't quote '$' in double quotes */
if (cmap(*cp, _ESC) && cp < str_end - 1 && cp[1] == HIST)
- *wp = *++cp | QUOTE;
+ Strbuf_append1(&qline, *++cp | QUOTE);
else if (qu && (tricky(*cp) || *cp == '~') && !(qu == '\"' && tricky_dq(*cp)))
- *wp = *cp | QUOTE;
+ Strbuf_append1(&qline, *cp | QUOTE);
else
- *wp = *cp;
- if (ismetahash(*wp) /* || isaset(cmd_start, wp + 1) */)
- word = wp + 1, word_start = cp + 1;
- wp++;
+ Strbuf_append1(&qline, *cp);
+ if (ismetahash(qline.s[qline.len - 1])
+ /* || isaset(qline.s + cmd_start, qline.s + qline.len) */)
+ word = qline.len, word_start = cp + 1;
if (cmap(qu, _ESC))
qu = 0;
}
- *wp = 0;
-
-#ifdef masscomp
- /*
- * Avoid a nasty message from the RTU 4.1A & RTU 5.0 compiler concerning
- * the "overuse of registers". According to the compiler release notes,
- * incorrect code may be produced unless the offending expression is
- * rewritten. Therefore, we can't just ignore it, DAS DEC-90.
- */
- space_left = QLINESIZE - 1;
- space_left -= word - qline;
-#else
- space_left = QLINESIZE - 1 - (int) (word - qline);
-#endif
+ Strbuf_terminate(&qline);
+ wp = qline.len;
/*
* SPECIAL HARDCODED COMPLETIONS:
@@ -242,52 +226,62 @@ tenematch(inputline, num_read, command)
* everything else -> TW_ZERO
*
*/
- looking = starting_a_command(word - 1, qline) ?
+ looking = starting_a_command(qline.s + word - 1, qline.s) ?
TW_COMMAND : TW_ZERO;
wordp = word;
#ifdef TDEBUG
- xprintf(CGETS(30, 1, "starting_a_command %d\n"), looking);
- xprintf("\ncmd_start:%S:\n", cmd_start);
- xprintf("qline:%S:\n", qline);
- xprintf("qline:");
- for (wp = qline; *wp; wp++)
- xprintf("%c", *wp & QUOTE ? '-' : ' ');
- xprintf(":\n");
- xprintf("word:%S:\n", word);
- xprintf("word:");
- /* Must be last, so wp is still pointing to the end of word */
- for (wp = word; *wp; wp++)
- xprintf("%c", *wp & QUOTE ? '-' : ' ');
- xprintf(":\n");
+ {
+ const Char *p;
+
+ xprintf(CGETS(30, 1, "starting_a_command %d\n"), looking);
+ xprintf("\ncmd_start:%S:\n", qline.s + cmd_start);
+ xprintf("qline:%S:\n", qline.s);
+ xprintf("qline:");
+ for (p = qline.s; *p; p++)
+ xprintf("%c", *p & QUOTE ? '-' : ' ');
+ xprintf(":\n");
+ xprintf("word:%S:\n", qline.s + word);
+ xprintf("word:");
+ for (p = qline.s + word; *p; p++)
+ xprintf("%c", *p & QUOTE ? '-' : ' ');
+ xprintf(":\n");
+ }
#endif
if ((looking == TW_COMMAND || looking == TW_ZERO) &&
(command == RECOGNIZE || command == LIST || command == SPELL ||
command == RECOGNIZE_SCROLL)) {
+ Char *p;
+
#ifdef TDEBUG
xprintf(CGETS(30, 2, "complete %d "), looking);
#endif
- looking = tw_complete(cmd_start, &wordp, &pat, looking, &suf);
+ p = qline.s + wordp;
+ looking = tw_complete(qline.s + cmd_start, &p, &pat, looking, &suf);
+ wordp = p - qline.s;
#ifdef TDEBUG
xprintf(CGETS(30, 3, "complete %d %S\n"), looking, pat);
#endif
}
switch (command) {
- Char buffer[FILSIZ + 1], *bptr;
- Char *slshp;
+ Char *bptr;
Char *items[2], **ptr;
int i, count;
case RECOGNIZE:
case RECOGNIZE_SCROLL:
- case RECOGNIZE_ALL:
+ case RECOGNIZE_ALL: {
+ struct Strbuf wordbuf = Strbuf_INIT;
+ Char *slshp;
+
if (adrof(STRautocorrect)) {
- if ((slshp = Strrchr(wordp, '/')) != NULL && slshp[1] != '\0') {
+ if ((slshp = Strrchr(qline.s + wordp, '/')) != NULL &&
+ slshp[1] != '\0') {
SearchNoDirErr = 1;
- for (bptr = wordp; bptr < slshp; bptr++) {
+ for (bptr = qline.s + wordp; bptr < slshp; bptr++) {
/*
* do not try to correct spelling of words containing
* globbing characters
@@ -301,59 +295,90 @@ tenematch(inputline, num_read, command)
}
else
slshp = STRNULL;
- search_ret = t_search(wordp, wp, command, space_left, looking, 1,
- pat, suf);
+ Strbuf_append(&wordbuf, qline.s + wordp);
+ Strbuf_terminate(&wordbuf);
+ cleanup_push(&wordbuf, Strbuf_cleanup);
+ search_ret = t_search(&wordbuf, command, looking, 1, pat, suf);
+ qline.len = wordp;
+ Strbuf_append(&qline, wordbuf.s);
+ Strbuf_terminate(&qline);
+ cleanup_until(&wordbuf);
SearchNoDirErr = 0;
if (search_ret == -2) {
- Char rword[FILSIZ + 1];
+ Char *rword;
- (void) Strcpy(rword, slshp);
+ rword = Strsave(slshp);
+ cleanup_push(rword, xfree);
if (slshp != STRNULL)
*slshp = '\0';
- search_ret = spell_me(wordp, QLINESIZE - (wordp - qline), looking,
- pat, suf);
+ wordbuf = Strbuf_init;
+ Strbuf_append(&wordbuf, qline.s + wordp);
+ Strbuf_terminate(&wordbuf);
+ cleanup_push(&wordbuf, Strbuf_cleanup);
+ search_ret = spell_me(&wordbuf, looking, pat, suf);
if (search_ret == 1) {
- (void) Strcat(wordp, rword);
- wp = wordp + (int) Strlen(wordp);
- search_ret = t_search(wordp, wp, command, space_left,
- looking, 1, pat, suf);
+ Strbuf_append(&wordbuf, rword);
+ Strbuf_terminate(&wordbuf);
+ wp = wordp + wordbuf.len;
+ search_ret = t_search(&wordbuf, command, looking, 1, pat, suf);
}
+ qline.len = wordp;
+ Strbuf_append(&qline, wordbuf.s);
+ Strbuf_terminate(&qline);
+ cleanup_until(rword);
}
- if (*wp && insert_meta(word_start, str_end, word, !qu) < 0)
- return -1; /* error inserting */
- return search_ret;
+ if (qline.s[wp] != '\0' &&
+ insert_meta(word_start, str_end, qline.s + word, !qu) < 0)
+ goto err; /* error inserting */
+ break;
+ }
+
+ case SPELL: {
+ struct Strbuf wordbuf = Strbuf_INIT;
- case SPELL:
for (bptr = word_start; bptr < str_end; bptr++) {
/*
* do not try to correct spelling of words containing globbing
* characters
*/
- if (isglob(*bptr))
- return 0;
+ if (isglob(*bptr)) {
+ search_ret = 0;
+ goto end;
+ }
}
- search_ret = spell_me(wordp, QLINESIZE - (wordp - qline), looking,
- pat, suf);
+ Strbuf_append(&wordbuf, qline.s + wordp);
+ Strbuf_terminate(&wordbuf);
+ cleanup_push(&wordbuf, Strbuf_cleanup);
+ search_ret = spell_me(&wordbuf, looking, pat, suf);
+ qline.len = wordp;
+ Strbuf_append(&qline, wordbuf.s);
+ Strbuf_terminate(&qline);
+ cleanup_until(&wordbuf);
if (search_ret == 1) {
- if (insert_meta(word_start, str_end, word, !qu) < 0)
- return -1; /* error inserting */
+ if (insert_meta(word_start, str_end, qline.s + word, !qu) < 0)
+ goto err; /* error inserting */
}
- return search_ret;
+ break;
+ }
case PRINT_HELP:
- do_help(cmd_start);
- return 1;
+ do_help(qline.s + cmd_start);
+ search_ret = 1;
+ break;
case GLOB:
case GLOB_EXPAND:
- (void) Strncpy(buffer, wordp, FILSIZ + 1);
- items[0] = buffer;
+ items[0] = Strsave(qline.s + wordp);
items[1] = NULL;
+ cleanup_push(items[0], xfree);
ptr = items;
- count = (looking == TW_COMMAND && Strchr(wordp, '/') == 0) ?
- c_glob(&ptr) :
+ count = (looking == TW_COMMAND && Strchr(qline.s + wordp, '/') == 0) ?
+ c_glob(&ptr) :
t_glob(&ptr, looking == TW_COMMAND);
+ cleanup_until(items[0]);
+ if (ptr != items)
+ cleanup_push(ptr, blk_cleanup);
if (count > 0) {
if (command == GLOB)
print_by_column(STRNULL, ptr, count, 0);
@@ -364,52 +389,92 @@ tenematch(inputline, num_read, command)
(void) quote(ptr[i]);
if (insert_meta(0, 0, ptr[i], 0) < 0 ||
InsertStr(STRspace) < 0) {
- blkfree(ptr);
- return -1; /* error inserting */
+ if (ptr != items)
+ cleanup_until(ptr);
+ goto err; /* error inserting */
}
}
}
- blkfree(ptr);
}
- return count;
+ if (ptr != items)
+ cleanup_until(ptr);
+ search_ret = count;
+ break;
case VARS_EXPAND:
- if (dollar(buffer, word)) {
- if (insert_meta(word_start, str_end, buffer, !qu) < 0)
- return -1; /* error inserting */
- return 1;
+ bptr = dollar(qline.s + word);
+ if (bptr != NULL) {
+ if (insert_meta(word_start, str_end, bptr, !qu) < 0) {
+ xfree(bptr);
+ goto err; /* error inserting */
+ }
+ xfree(bptr);
+ search_ret = 1;
+ break;
}
- return 0;
+ search_ret = 0;
+ break;
case PATH_NORMALIZE:
- if ((bptr = dnormalize(wordp, symlinks == SYM_IGNORE ||
- symlinks == SYM_EXPAND)) != NULL) {
- (void) Strcpy(buffer, bptr);
- xfree((ptr_t) bptr);
- if (insert_meta(word_start, str_end, buffer, !qu) < 0)
- return -1; /* error inserting */
- return 1;
+ if ((bptr = dnormalize(qline.s + wordp, symlinks == SYM_IGNORE ||
+ symlinks == SYM_EXPAND)) != NULL) {
+ if (insert_meta(word_start, str_end, bptr, !qu) < 0) {
+ xfree(bptr);
+ goto err; /* error inserting */
+ }
+ xfree(bptr);
+ search_ret = 1;
+ break;
}
- return 0;
+ search_ret = 0;
+ break;
- case COMMAND_NORMALIZE:
- if (!cmd_expand(wordp, buffer))
- return 0;
- if (insert_meta(word_start, str_end, buffer, !qu) < 0)
- return -1; /* error inserting */
- return 1;
+ case COMMAND_NORMALIZE: {
+ Char *p;
+ int found;
+
+ found = !cmd_expand(qline.s + wordp, &p);
+
+ if (!found) {
+ xfree(p);
+ search_ret = 0;
+ break;
+ }
+ if (insert_meta(word_start, str_end, p, !qu) < 0) {
+ xfree(p);
+ goto err; /* error inserting */
+ }
+ xfree(p);
+ search_ret = 1;
+ break;
+ }
case LIST:
- case LIST_ALL:
- search_ret = t_search(wordp, wp, LIST, space_left, looking, 1,
- pat, suf);
- return search_ret;
+ case LIST_ALL: {
+ struct Strbuf wordbuf = Strbuf_INIT;
+
+ Strbuf_append(&wordbuf, qline.s + wordp);
+ Strbuf_terminate(&wordbuf);
+ cleanup_push(&wordbuf, Strbuf_cleanup);
+ search_ret = t_search(&wordbuf, LIST, looking, 1, pat, suf);
+ qline.len = wordp;
+ Strbuf_append(&qline, wordbuf.s);
+ Strbuf_terminate(&qline);
+ cleanup_until(&wordbuf);
+ break;
+ }
default:
xprintf(CGETS(30, 4, "%s: Internal match error.\n"), progname);
- return 1;
-
+ search_ret = 1;
}
+ end:
+ cleanup_until(&qline);
+ return search_ret;
+
+ err:
+ cleanup_until(&qline);
+ return -1;
} /* end tenematch */
@@ -417,21 +482,23 @@ tenematch(inputline, num_read, command)
* Return a list of files that match the pattern
*/
static int
-t_glob(v, cmd)
- Char ***v;
- int cmd;
+t_glob(Char ***v, int cmd)
{
jmp_buf_t osetexit;
+ int gflag;
if (**v == 0)
return (0);
- gflag = 0, tglob(*v);
+ gflag = tglob(*v);
if (gflag) {
+ size_t omark;
+
getexit(osetexit); /* make sure to come back here */
+ omark = cleanup_push_mark();
if (setexit() == 0)
- *v = globall(*v);
+ *v = globall(*v, gflag);
+ cleanup_pop_mark(omark);
resexit(osetexit);
- gargv = 0;
if (haderr) {
haderr = 0;
NeedsRedraw = 1;
@@ -445,25 +512,23 @@ t_glob(v, cmd)
if (cmd) {
Char **av = *v, *p;
- int fwd, i, ac = gargc;
+ int fwd, i;
- for (i = 0, fwd = 0; i < ac; i++)
+ for (i = 0, fwd = 0; av[i] != NULL; i++)
if (!executable(NULL, av[i], 0)) {
fwd++;
p = av[i];
av[i] = NULL;
- xfree((ptr_t) p);
+ xfree(p);
}
else if (fwd)
av[i - fwd] = av[i];
if (fwd)
av[i - fwd] = av[i];
- gargc -= fwd;
- av[gargc] = NULL;
}
- return (gargc);
+ return blklen(*v);
} /* end t_glob */
@@ -471,36 +536,32 @@ t_glob(v, cmd)
* Return a list of commands that match the pattern
*/
static int
-c_glob(v)
- Char ***v;
+c_glob(Char ***v)
{
- Char *pat = **v, *cmd, **av;
- Char dir[MAXPATHLEN+1];
- int flag, at, ac;
+ struct blk_buf av = BLK_BUF_INIT;
+ struct Strbuf cmd = Strbuf_INIT, dir = Strbuf_INIT;
+ Char *pat = **v;
+ int flag;
if (pat == NULL)
return (0);
- ac = 0;
- at = 10;
- av = (Char **) xmalloc((size_t) (at * sizeof(Char *)));
- av[ac] = NULL;
+ cleanup_push(&av, bb_cleanup);
+ cleanup_push(&cmd, Strbuf_cleanup);
+ cleanup_push(&dir, Strbuf_cleanup);
tw_cmd_start(NULL, NULL);
- while ((cmd = tw_cmd_next(dir, &flag)) != NULL)
- if (Gmatch(cmd, pat)) {
- if (ac + 1 >= at) {
- at += 10;
- av = (Char **) xrealloc((ptr_t) av,
- (size_t) (at * sizeof(Char *)));
- }
- av[ac++] = Strsave(cmd);
- av[ac] = NULL;
- }
+ while (cmd.len = 0, tw_cmd_next(&cmd, &dir, &flag) != 0) {
+ Strbuf_terminate(&cmd);
+ if (Gmatch(cmd.s, pat))
+ bb_append(&av, Strsave(cmd.s));
+ }
tw_dir_end();
- *v = av;
+ *v = bb_finish(&av);
+ cleanup_ignore(&av);
+ cleanup_until(&av);
- return (ac);
+ return av.len;
} /* end c_glob */
@@ -514,29 +575,25 @@ c_glob(v)
* change quote type only if necessary.
*/
static int
-insert_meta(cp, cpend, word, closequotes)
- Char *cp;
- Char *cpend;
- Char *word;
- int closequotes;
+insert_meta(const Char *cp, const Char *cpend, const Char *word,
+ int closequotes)
{
- Char buffer[2 * FILSIZ + 1], *bptr, *wptr;
+ struct Strbuf buffer = Strbuf_INIT;
+ Char *bptr;
+ const Char *wptr;
int in_sync = (cp != NULL);
Char qu = 0;
int ndel = (int) (cp ? cpend - cp : 0);
Char w, wq;
- int l;
+ int res;
- for (bptr = buffer, wptr = word;;) {
- if (bptr > buffer + 2 * FILSIZ - 5)
- break;
-
+ for (wptr = word;;) {
if (cp >= cpend)
in_sync = 0;
if (in_sync && !cmap(qu, _ESC) && cmap(*cp, _QF|_ESC))
if (qu == 0 || qu == *cp) {
qu ^= *cp;
- *bptr++ = *cp++;
+ Strbuf_append1(&buffer, *cp++);
continue;
}
w = *wptr;
@@ -553,62 +610,58 @@ insert_meta(cp, cpend, word, closequotes)
/* We have to unquote the character */
in_sync = 0;
if (cmap(qu, _ESC))
- bptr[-1] = w;
+ buffer.s[buffer.len - 1] = w;
else {
- *bptr++ = (Char) qu;
- *bptr++ = w;
+ Strbuf_append1(&buffer, qu);
+ Strbuf_append1(&buffer, w);
if (wptr[1] == 0)
qu = 0;
else
- *bptr++ = (Char) qu;
+ Strbuf_append1(&buffer, qu);
}
} else if (qu && w == qu) {
in_sync = 0;
- if (bptr > buffer && bptr[-1] == qu) {
+ if (buffer.len != 0 && buffer.s[buffer.len - 1] == qu) {
/* User misunderstanding :) */
- bptr[-1] = '\\';
- *bptr++ = w;
+ buffer.s[buffer.len - 1] = '\\';
+ Strbuf_append1(&buffer, w);
qu = 0;
} else {
- *bptr++ = (Char) qu;
- *bptr++ = '\\';
- *bptr++ = w;
- *bptr++ = (Char) qu;
+ Strbuf_append1(&buffer, qu);
+ Strbuf_append1(&buffer, '\\');
+ Strbuf_append1(&buffer, w);
+ Strbuf_append1(&buffer, qu);
}
}
else if (wq && qu == '\"' && tricky_dq(w)) {
in_sync = 0;
- *bptr++ = (Char) qu;
- *bptr++ = '\\';
- *bptr++ = w;
- *bptr++ = (Char) qu;
- } else if (wq && ((!qu && (tricky(w) || (w == HISTSUB && bptr == buffer))) || (!cmap(qu, _ESC) && w == HIST))) {
+ Strbuf_append1(&buffer, qu);
+ Strbuf_append1(&buffer, '\\');
+ Strbuf_append1(&buffer, w);
+ Strbuf_append1(&buffer, qu);
+ } else if (wq &&
+ ((!qu && (tricky(w) || (w == HISTSUB && buffer.len == 0))) ||
+ (!cmap(qu, _ESC) && w == HIST))) {
in_sync = 0;
- *bptr++ = '\\';
- *bptr++ = w;
+ Strbuf_append1(&buffer, '\\');
+ Strbuf_append1(&buffer, w);
} else {
if (in_sync && *cp++ != w)
in_sync = 0;
- *bptr++ = w;
- l = NLSSize(wptr, -1);
- while (--l > 0) {
- wptr++;
- w = *wptr & ~QUOTE;
- if (in_sync && *cp++ != w)
- in_sync = 0;
- *bptr++ = w;
- }
+ Strbuf_append1(&buffer, w);
}
wptr++;
if (cmap(qu, _ESC))
qu = 0;
}
if (closequotes && qu && !cmap(qu, _ESC))
- *bptr++ = (Char) qu;
- *bptr = '\0';
+ Strbuf_append1(&buffer, w);
+ bptr = Strbuf_finish(&buffer);
if (ndel)
DeleteBack(ndel);
- return InsertStr(buffer);
+ res = InsertStr(bptr);
+ xfree(bptr);
+ return res;
} /* end insert_meta */
@@ -619,8 +672,7 @@ insert_meta(cp, cpend, word, closequotes)
* it matches anything
*/
static int
-is_prefix(check, template)
- Char *check, *template;
+is_prefix(Char *check, Char *template)
{
for (; *check; check++, template++)
if ((*check & TRIM) != (*template & TRIM))
@@ -636,9 +688,7 @@ is_prefix(check, template)
* and matches on shortening of commands
*/
static int
-is_prefixmatch(check, template, igncase)
- Char *check, *template;
- int igncase;
+is_prefixmatch(Char *check, Char *template, int igncase)
{
Char MCH1, MCH2;
@@ -679,15 +729,12 @@ is_prefixmatch(check, template, igncase)
* end of check, I.e., are it's suffix.
*/
static int
-is_suffix(check, template)
- Char *check, *template;
+is_suffix(Char *check, Char *template)
{
Char *t, *c;
- for (t = template; *t++;)
- continue;
- for (c = check; *c++;)
- continue;
+ t = Strend(template);
+ c = Strend(check);
for (;;) {
if (t == template)
return 1;
@@ -701,8 +748,7 @@ is_suffix(check, template)
* Return true if this is an ignored item
*/
static int
-ignored(item)
- Char *item;
+ignored(Char *item)
{
struct varent *vp;
Char **cp;
@@ -721,8 +767,7 @@ ignored(item)
* return true if the command starting at wordstart is a command
*/
int
-starting_a_command(wordstart, inputline)
- Char *wordstart, *inputline;
+starting_a_command(Char *wordstart, Char *inputline)
{
Char *ptr, *ncmdstart;
int count, bsl;
@@ -805,23 +850,26 @@ starting_a_command(wordstart, inputline)
* If we shorten it back to the prefix length, stop searching.
*/
static int
-recognize(exp_name, item, name_length, numitems, enhanced, igncase)
- Char *exp_name, *item;
- int name_length, numitems, enhanced, igncase;
+recognize(struct Strbuf *exp_name, const Char *item, size_t name_length,
+ int numitems, int enhanced, int igncase)
{
Char MCH1, MCH2;
- Char *x, *ent;
- int len = 0;
+ Char *x;
+ const Char *ent;
+ size_t len = 0;
if (numitems == 1) { /* 1st match */
- copyn(exp_name, item, MAXNAMLEN);
+ exp_name->len = 0;
+ Strbuf_append(exp_name, item);
+ Strbuf_terminate(exp_name);
return (0);
}
if (!enhanced && !igncase) {
- for (x = exp_name, ent = item; *x && (*x & TRIM) == (*ent & TRIM); x++, ent++)
+ for (x = exp_name->s, ent = item; *x && (*x & TRIM) == (*ent & TRIM);
+ x++, ent++)
len++;
} else {
- for (x = exp_name, ent = item; *x; x++, ent++) {
+ for (x = exp_name->s, ent = item; *x; x++, ent++) {
MCH1 = *x & TRIM;
MCH2 = *ent & TRIM;
MCH1 = Isupper(MCH1) ? Tolower(MCH1) : MCH1;
@@ -831,9 +879,10 @@ recognize(exp_name, item, name_length, numitems, enhanced, igncase)
len++;
}
if (*x || !*ent) /* Shorter or exact match */
- copyn(exp_name, item, MAXNAMLEN);
+ memcpy(exp_name->s, item, len * sizeof(*exp_name->s));
}
*x = '\0'; /* Shorten at 1st char diff */
+ exp_name->len = x - exp_name->s;
if (!(match_unique_match || is_set(STRrecexact) || (enhanced && *ent)) && len == name_length) /* Ambiguous to prefix? */
return (-1); /* So stop now and save time */
return (0);
@@ -850,18 +899,15 @@ recognize(exp_name, item, name_length, numitems, enhanced, igncase)
* It returns the -number of ignored items.
*/
static int
-tw_collect_items(command, looking, exp_dir, exp_name, target, pat, flags)
- COMMAND command;
- int looking;
- Char *exp_dir, *exp_name, *target, *pat;
- int flags;
-
+tw_collect_items(COMMAND command, int looking, struct Strbuf *exp_dir,
+ struct Strbuf *exp_name, Char *target, const Char *pat,
+ int flags)
{
int done = FALSE; /* Search is done */
int showdots; /* Style to show dot files */
int nignored = 0; /* Number of fignored items */
int numitems = 0; /* Number of matched items */
- int name_length = (int) Strlen(target); /* Length of prefix (file name) */
+ size_t name_length = Strlen(target); /* Length of prefix (file name) */
int exec_check = flags & TW_EXEC_CHK;/* need to check executability */
int dir_check = flags & TW_DIR_CHK; /* Need to check for directories */
int text_check = flags & TW_TEXT_CHK;/* Need to check for non-directories */
@@ -869,10 +915,10 @@ tw_collect_items(command, looking, exp_dir, exp_name, target, pat, flags)
int gpat = flags & TW_PAT_OK; /* Match against a pattern */
int ignoring = flags & TW_IGN_OK; /* Use fignore? */
int d = 4, nd; /* Spelling distance */
- Char *item, *ptr;
- Char buf[MAXPATHLEN+1];
+ Char *ptr;
struct varent *vp;
- int len, enhanced = 0;
+ struct Strbuf buf = Strbuf_INIT, item = Strbuf_INIT;
+ int enhanced = 0;
int cnt = 0;
int igncase = 0;
@@ -893,9 +939,14 @@ tw_collect_items(command, looking, exp_dir, exp_name, target, pat, flags)
break;
}
- while (!done && (item = (*tw_next_entry[looking])(exp_dir, &flags))) {
+ cleanup_push(&item, Strbuf_cleanup);
+ cleanup_push(&buf, Strbuf_cleanup);
+ while (!done &&
+ (item.len = 0,
+ tw_next_entry[looking](&item, exp_dir, &flags) != 0)) {
+ Strbuf_terminate(&item);
#ifdef TDEBUG
- xprintf("item = %S\n", item);
+ xprintf("item = %S\n", item.s);
#endif
switch (looking) {
case TW_FILE:
@@ -904,28 +955,33 @@ tw_collect_items(command, looking, exp_dir, exp_name, target, pat, flags)
/*
* Don't match . files on null prefix match
*/
- if (showdots == DOT_NOT && (ISDOT(item) || ISDOTDOT(item)))
+ if (showdots == DOT_NOT && (ISDOT(item.s) || ISDOTDOT(item.s)))
done = TRUE;
- if (name_length == 0 && item[0] == '.' && showdots == DOT_NONE)
+ if (name_length == 0 && item.s[0] == '.' && showdots == DOT_NONE)
done = TRUE;
break;
case TW_COMMAND:
#if defined(_UWIN) || defined(__CYGWIN__)
- /* Turn foo.{exe,com,bat} into foo since UWIN's readdir returns
- * the file with the .exe, .com, .bat extension
+ /*
+ * Turn foo.{exe,com,bat,cmd} into foo since UWIN's readdir returns
+ * the file with the .exe, .com, .bat, .cmd extension
*/
{
- size_t ext = strlen((char *)item) - 4;
- if ((ext > 0) && (strcasecmp((char *)&item[ext], ".exe") == 0 ||
- strcasecmp((char *)&item[ext], ".bat") == 0 ||
- strcasecmp((char *)&item[ext], ".com") == 0))
- {
- item[ext] = '\0';
-#if defined(__CYGWIN__)
- strlwr((char *)item);
-#endif /* __CYGWIN__ */
- }
+ static const char *rext[] = { ".exe", ".bat", ".com", ".cmd" };
+ size_t exti = Strlen(item.s);
+
+ if (exti > 4) {
+ char *ext = short2str(&item.s[exti -= 4]);
+ size_t i;
+
+ for (i = 0; i < sizeof(rext) / sizeof(rext[0]); i++)
+ if (strcasecmp(ext, rext[i]) == 0) {
+ item.len = exti;
+ Strbuf_terminate(&item);
+ break;
+ }
+ }
}
#endif /* _UWIN || __CYGWIN__ */
exec_check = flags & TW_EXEC_CHK;
@@ -945,29 +1001,33 @@ tw_collect_items(command, looking, exp_dir, exp_name, target, pat, flags)
case SPELL: /* correct the spelling of the last bit */
if (name_length == 0) {/* zero-length word can't be misspelled */
- exp_name[0] = '\0';/* (not trying is important for ~) */
+ exp_name->len = 0; /* (not trying is important for ~) */
+ Strbuf_terminate(exp_name);
d = 0;
done = TRUE;
break;
}
- if (gpat && !Gmatch(item, pat))
+ if (gpat && !Gmatch(item.s, pat))
break;
/*
* Swapped the order of the spdist() arguments as suggested
* by eeide@asylum.cs.utah.edu (Eric Eide)
*/
- nd = spdist(target, item); /* test the item against original */
+ nd = spdist(target, item.s); /* test the item against original */
if (nd <= d && nd != 4) {
- if (!(exec_check && !executable(exp_dir, item, dir_ok))) {
- (void) Strcpy(exp_name, item);
+ if (!(exec_check && !executable(exp_dir->s, item.s, dir_ok))) {
+ exp_name->len = 0;
+ Strbuf_append(exp_name, item.s);
+ Strbuf_terminate(exp_name);
d = nd;
if (d == 0) /* if found it exactly */
done = TRUE;
}
}
else if (nd == 4) {
- if (spdir(exp_name, exp_dir, item, target)) {
- if (exec_check && !executable(exp_dir, exp_name, dir_ok))
+ if (spdir(exp_name, exp_dir->s, item.s, target)) {
+ if (exec_check &&
+ !executable(exp_dir->s, exp_name->s, dir_ok))
break;
#ifdef notdef
/*
@@ -998,28 +1058,28 @@ tw_collect_items(command, looking, exp_dir, exp_name, target, pat, flags)
}
if (enhanced || igncase) {
- if (!is_prefixmatch(target, item, igncase))
+ if (!is_prefixmatch(target, item.s, igncase))
break;
} else {
- if (!is_prefix(target, item))
+ if (!is_prefix(target, item.s))
break;
}
- if (exec_check && !executable(exp_dir, item, dir_ok))
+ if (exec_check && !executable(exp_dir->s, item.s, dir_ok))
break;
- if (dir_check && !isadirectory(exp_dir, item))
+ if (dir_check && !isadirectory(exp_dir->s, item.s))
break;
- if (text_check && isadirectory(exp_dir, item))
+ if (text_check && isadirectory(exp_dir->s, item.s))
break;
/*
* Only pattern match directories if we're checking
* for directories.
*/
- if (gpat && !Gmatch(item, pat) &&
- (dir_check || !isadirectory(exp_dir, item)))
+ if (gpat && !Gmatch(item.s, pat) &&
+ (dir_check || !isadirectory(exp_dir->s, item.s)))
break;
/*
@@ -1028,34 +1088,31 @@ tw_collect_items(command, looking, exp_dir, exp_name, target, pat, flags)
*/
if (looking == TW_COMMAND || looking == TW_LOGNAME
|| looking == TW_USER || command == LIST) {
- copyn(buf, item, MAXPATHLEN);
- len = (int) Strlen(buf);
+ buf.len = 0;
+ Strbuf_append(&buf, item.s);
switch (looking) {
case TW_COMMAND:
if (!(dir_ok && exec_check))
break;
- if (filetype(exp_dir, item) == '/') {
- buf[len++] = '/';
- buf[len] = '\0';
- }
+ if (filetype(exp_dir->s, item.s) == '/')
+ Strbuf_append1(&buf, '/');
break;
case TW_FILE:
case TW_DIRECTORY:
- buf[len++] = filetype(exp_dir, item);
- buf[len] = '\0';
+ Strbuf_append1(&buf, filetype(exp_dir->s, item.s));
break;
default:
break;
}
+ Strbuf_terminate(&buf);
if ((looking == TW_COMMAND || looking == TW_USER
- || looking == TW_LOGNAME) && tw_item_find(buf))
+ || looking == TW_LOGNAME) && tw_item_find(buf.s))
break;
else {
/* maximum length 1 (NULL) + 1 (~ or $) + 1 (filetype) */
- ptr = tw_item_add(len + 3);
- copyn(ptr, buf, MAXPATHLEN);
+ tw_item_add(&buf);
if (command == LIST)
numitems++;
}
@@ -1063,30 +1120,35 @@ tw_collect_items(command, looking, exp_dir, exp_name, target, pat, flags)
if (command == RECOGNIZE || command == RECOGNIZE_ALL ||
command == RECOGNIZE_SCROLL) {
- if (ignoring && ignored(item)) {
+ if (ignoring && ignored(item.s)) {
nignored++;
break;
- }
+ }
else if (command == RECOGNIZE_SCROLL) {
- add_scroll_tab(item);
+ add_scroll_tab(item.s);
cnt++;
}
-
+
if (match_unique_match || is_set(STRrecexact)) {
- if (StrQcmp(target, item) == 0) { /* EXACT match */
- copyn(exp_name, item, MAXNAMLEN);
+ if (StrQcmp(target, item.s) == 0) { /* EXACT match */
+ exp_name->len = 0;
+ Strbuf_append(exp_name, item.s);
+ Strbuf_terminate(exp_name);
numitems = 1; /* fake into expanding */
non_unique_match = TRUE;
done = TRUE;
break;
}
}
- if (recognize(exp_name, item, name_length, ++numitems,
- enhanced, igncase))
+ if (recognize(exp_name, item.s, name_length, ++numitems,
+ enhanced, igncase))
if (command != RECOGNIZE_SCROLL)
done = TRUE;
- if (enhanced && (int)Strlen(exp_name) < name_length)
- copyn(exp_name, target, MAXNAMLEN);
+ if (enhanced && exp_name->len < name_length) {
+ exp_name->len = 0;
+ Strbuf_append(exp_name, target);
+ Strbuf_terminate(exp_name);
+ }
}
break;
@@ -1094,10 +1156,10 @@ tw_collect_items(command, looking, exp_dir, exp_name, target, pat, flags)
break;
}
#ifdef TDEBUG
- xprintf("done item = %S\n", item);
+ xprintf("done item = %S\n", item.s);
#endif
}
-
+ cleanup_until(&item);
if (command == RECOGNIZE_SCROLL) {
if ((cnt <= curchoice) || (curchoice == -1)) {
@@ -1107,7 +1169,7 @@ tw_collect_items(command, looking, exp_dir, exp_name, target, pat, flags)
} else if (numitems > 1) {
if (curchoice < -1)
curchoice = cnt - 1;
- choose_scroll_tab(&exp_name, cnt);
+ choose_scroll_tab(exp_name, cnt);
numitems = 1;
}
}
@@ -1128,15 +1190,12 @@ tw_collect_items(command, looking, exp_dir, exp_name, target, pat, flags)
* Find and return the appropriate suffix character
*/
/*ARGSUSED*/
-static Char
-tw_suffix(looking, exp_dir, exp_name, target, name)
- int looking;
- Char *exp_dir, *exp_name, *target, *name;
-{
+static Char
+tw_suffix(int looking, const Char *exp_dir, Char *exp_name)
+{
Char *ptr;
struct varent *vp;
- USE(name);
(void) strip(exp_name);
switch (looking) {
@@ -1156,8 +1215,6 @@ tw_suffix(looking, exp_dir, exp_name, target, name)
else if ((ptr = tgetenv(exp_name)) == NULL || *ptr == '\0')
return ' ';
- *--target = '\0';
-
return isadirectory(exp_dir, ptr) ? '/' : ' ';
@@ -1193,38 +1250,38 @@ tw_suffix(looking, exp_dir, exp_name, target, name)
* Repair a word after a spalling or a recognizwe
*/
static void
-tw_fixword(looking, word, dir, exp_name, max_word_length)
- int looking;
- Char *word, *dir, *exp_name;
- int max_word_length;
+tw_fixword(int looking, struct Strbuf *word, Char *dir, Char *exp_name)
{
Char *ptr;
switch (looking) {
case TW_LOGNAME:
- copyn(word, STRtilde, 1);
+ word->len = 0;
+ Strbuf_append1(word, '~');
break;
-
+
case TW_VARIABLE:
- if ((ptr = Strrchr(word, '$')) != NULL)
- *++ptr = '\0'; /* Delete after the dollar */
- else
- word[0] = '\0';
+ if ((ptr = Strrchr(word->s, '$')) != NULL) {
+ word->len = ptr + 1 - word->s; /* Delete after the dollar */
+ } else
+ word->len = 0;
break;
case TW_DIRECTORY:
case TW_FILE:
case TW_TEXT:
- copyn(word, dir, max_word_length); /* put back dir part */
+ word->len = 0;
+ Strbuf_append(word, dir); /* put back dir part */
break;
default:
- word[0] = '\0';
+ word->len = 0;
break;
}
(void) quote(exp_name);
- catn(word, exp_name, max_word_length); /* add extended name */
+ Strbuf_append(word, exp_name); /* add extended name */
+ Strbuf_terminate(word);
} /* end tw_fixword */
@@ -1237,69 +1294,52 @@ tw_fixword(looking, word, dir, exp_name, max_word_length)
* 2. Retries if we had no matches, but there were ignored matches
*/
static int
-tw_collect(command, looking, exp_dir, exp_name, target, pat, flags, dir_fd)
- COMMAND command;
- int looking;
- Char *exp_dir, *exp_name, **target, *pat;
- int flags;
- DIR *dir_fd;
+tw_collect(COMMAND command, int looking, struct Strbuf *exp_dir,
+ struct Strbuf *exp_name, Char *target, Char *pat, int flags,
+ DIR *dir_fd)
{
- static int ni; /* static so we don't get clobbered */
+ volatile int ni;
jmp_buf_t osetexit;
#ifdef TDEBUG
- xprintf("target = %S\n", *target);
+ xprintf("target = %S\n", target);
#endif
ni = 0;
getexit(osetexit);
for (;;) {
+ volatile size_t omark;
+
(*tw_start_entry[looking])(dir_fd, pat);
InsideCompletion = 1;
if (setexit()) {
- /* interrupted, clean up */
+ cleanup_pop_mark(omark);
resexit(osetexit);
- InsideCompletion = 0;
+ /* interrupted, clean up */
haderr = 0;
-
-#if defined(SOLARIS2) && defined(i386) && !defined(__GNUC__)
- /* Compiler bug? (from PWP) */
- if ((looking == TW_LOGNAME) || (looking == TW_USER))
- tw_logname_end();
- else
- if (looking == TW_GRPNAME)
- tw_grpname_end();
- else
- tw_dir_end();
-#else /* !(SOLARIS2 && i386 && !__GNUC__) */
- (*tw_end_entry[looking])();
-#endif /* !(SOLARIS2 && i386 && !__GNUC__) */
-
- /* flag error */
- return(-1);
+ ni = -1; /* flag error */
+ break;
}
- if ((ni = tw_collect_items(command, looking, exp_dir, exp_name,
- *target, pat,
- ni >= 0 ? flags :
- flags & ~TW_IGN_OK)) >= 0) {
- resexit(osetexit);
- InsideCompletion = 0;
-
+ omark = cleanup_push_mark();
+ ni = tw_collect_items(command, looking, exp_dir, exp_name, target, pat,
+ ni >= 0 ? flags : flags & ~TW_IGN_OK);
+ cleanup_pop_mark(omark);
+ resexit(osetexit);
+ if (ni >= 0)
+ break;
+ }
+ InsideCompletion = 0;
#if defined(SOLARIS2) && defined(i386) && !defined(__GNUC__)
- /* Compiler bug? (from PWP) */
- if ((looking == TW_LOGNAME) || (looking == TW_USER))
- tw_logname_end();
- else
- if (looking == TW_GRPNAME)
- tw_grpname_end();
- else
- tw_dir_end();
+ /* Compiler bug? (from PWP) */
+ if ((looking == TW_LOGNAME) || (looking == TW_USER))
+ tw_logname_end();
+ else if (looking == TW_GRPNAME)
+ tw_grpname_end();
+ else
+ tw_dir_end();
#else /* !(SOLARIS2 && i386 && !__GNUC__) */
- (*tw_end_entry[looking])();
+ (*tw_end_entry[looking])();
#endif /* !(SOLARIS2 && i386 && !__GNUC__) */
-
- return(ni);
- }
- }
+ return(ni);
} /* end tw_collect */
@@ -1312,8 +1352,7 @@ tw_collect(command, looking, exp_dir, exp_name, target, pat, flags, dir_fd)
* (by default interpreted as 'items', for backwards compatibility)
*/
static void
-tw_list_items(looking, numitems, list_max)
- int looking, numitems, list_max;
+tw_list_items(int looking, int numitems, int list_max)
{
Char *ptr;
int max_items = 0;
@@ -1372,14 +1411,15 @@ tw_list_items(looking, numitems, list_max)
}
sname = strsave(name);
+ cleanup_push(sname, xfree);
xprintf(CGETS(30, 7, "There are %d %s, list them anyway? [n/y] "),
maxs, sname);
- xfree(sname);
+ cleanup_until(sname);
flush();
/* We should be in Rawmode here, so no \n to catch */
- (void) read(SHIN, &tc, 1);
+ (void) xread(SHIN, &tc, 1);
xprintf("%c\r\n", tc); /* echo the char, do a newline */
- /*
+ /*
* Perhaps we should use the yesexpr from the
* actual locale
*/
@@ -1388,8 +1428,7 @@ tw_list_items(looking, numitems, list_max)
}
if (looking != TW_SIGNAL)
- qsort((ptr_t) tw_item_get(), (size_t) numitems, sizeof(Char *),
- (int (*) __P((const void *, const void *))) fcompare);
+ qsort(tw_item_get(), numitems, sizeof(Char *), fcompare);
if (looking != TW_JOB)
print_by_column(STRNULL, tw_item_get(), numitems, TRUE);
else {
@@ -1420,25 +1459,19 @@ tw_list_items(looking, numitems, list_max)
*/
/*ARGSUSED*/
int
-t_search(word, wp, command, max_word_length, looking, list_max, pat, suf)
- Char *word, *wp; /* original end-of-word */
- COMMAND command;
- int max_word_length, looking, list_max;
- Char *pat;
- int suf;
+t_search(struct Strbuf *word, COMMAND command, int looking, int list_max,
+ Char *pat, eChar suf)
{
int numitems, /* Number of items matched */
flags = 0, /* search flags */
gpat = pat[0] != '\0', /* Glob pattern search */
- nd; /* Normalized directory return */
- Char exp_dir[FILSIZ + 1], /* dir after ~ expansion */
- dir[FILSIZ + 1], /* /x/y/z/ part in /x/y/z/f */
- exp_name[MAXNAMLEN + 1], /* the recognized (extended) */
- name[MAXNAMLEN + 1], /* f part in /d/d/d/f name */
+ res; /* Return value */
+ struct Strbuf exp_dir = Strbuf_INIT;/* dir after ~ expansion */
+ struct Strbuf dir = Strbuf_INIT; /* /x/y/z/ part in /x/y/z/f */
+ struct Strbuf exp_name = Strbuf_INIT;/* the recognized (extended) */
+ Char *name, /* f part in /d/d/d/f name */
*target; /* Target to expand/correct/list */
- DIR *dir_fd = NULL;
-
- USE(wp);
+ DIR *dir_fd = NULL;
/*
* bugfix by Marty Grossman (grossman@CC5.BBN.COM): directory listing can
@@ -1448,7 +1481,9 @@ t_search(word, wp, command, max_word_length, looking, list_max, pat, suf)
non_unique_match = FALSE; /* See the recexact code below */
- extract_dir_and_name(word, dir, name);
+ extract_dir_and_name(word->s, &dir, &name);
+ cleanup_push(&dir, Strbuf_cleanup);
+ cleanup_push(&name, xfree_indirect);
/*
* SPECIAL HARDCODED COMPLETIONS:
@@ -1456,7 +1491,7 @@ t_search(word, wp, command, max_word_length, looking, list_max, pat, suf)
* ~user -> TW_LOGNAME
*
*/
- if ((*word == '~') && (Strchr(word, '/') == NULL)) {
+ if ((*word->s == '~') && (Strchr(word->s, '/') == NULL)) {
looking = TW_LOGNAME;
target = name;
gpat = 0; /* Override pattern mechanism */
@@ -1475,32 +1510,35 @@ t_search(word, wp, command, max_word_length, looking, list_max, pat, suf)
*/
if (looking & TW_PATH) {
gpat = 0; /* pattern holds the pathname to be used */
- copyn(exp_dir, pat, MAXNAMLEN);
- if (exp_dir[Strlen(exp_dir) - 1] != '/')
- catn(exp_dir, STRslash, MAXNAMLEN);
- catn(exp_dir, dir, MAXNAMLEN);
+ Strbuf_append(&exp_dir, pat);
+ if (exp_dir.len != 0 && exp_dir.s[exp_dir.len - 1] != '/')
+ Strbuf_append1(&exp_dir, '/');
+ Strbuf_append(&exp_dir, dir.s);
}
- else
- exp_dir[0] = '\0';
+ Strbuf_terminate(&exp_dir);
+ cleanup_push(&exp_dir, Strbuf_cleanup);
switch (looking & ~TW_PATH) {
case TW_NONE:
- return -1;
+ res = -1;
+ goto err_dir;
case TW_ZERO:
looking = TW_FILE;
break;
case TW_COMMAND:
- if (Strchr(word, '/') || (looking & TW_PATH)) {
+ if (Strchr(word->s, '/') || (looking & TW_PATH)) {
looking = TW_FILE;
flags |= TW_EXEC_CHK;
flags |= TW_DIR_OK;
}
#ifdef notdef
/* PWP: don't even bother when doing ALL of the commands */
- if (looking == TW_COMMAND && (*word == '\0'))
- return (-1);
+ if (looking == TW_COMMAND && word->len == 0) {
+ res = -1;
+ goto err_dir;
+ }
#endif
break;
@@ -1517,7 +1555,8 @@ t_search(word, wp, command, max_word_length, looking, list_max, pat, suf)
xputchar('\r');
xputchar('\n');
}
- return 2;
+ res = 2;
+ goto err_dir;
default:
break;
@@ -1533,6 +1572,8 @@ t_search(word, wp, command, max_word_length, looking, list_max, pat, suf)
#endif
switch (looking) {
+ Char *user_name;
+
case TW_ALIAS:
case TW_SHELLVAR:
case TW_ENVVAR:
@@ -1546,8 +1587,8 @@ t_search(word, wp, command, max_word_length, looking, list_max, pat, suf)
case TW_VARIABLE:
- if ((nd = expand_dir(dir, exp_dir, &dir_fd, command)) != 0)
- return nd;
+ if ((res = expand_dir(dir.s, &exp_dir, &dir_fd, command)) != 0)
+ goto err_dir;
break;
case TW_DIRECTORY:
@@ -1568,48 +1609,54 @@ t_search(word, wp, command, max_word_length, looking, list_max, pat, suf)
* from a user-interface point of view, since it does not
* immediately obey addsuffix
*/
- if ((nd = expand_dir(dir, exp_dir, &dir_fd, command)) != 0)
- return nd;
- if (isadirectory(exp_dir, name)) {
- if (exp_dir[0] != '\0' || name[0] != '\0') {
- catn(dir, name, MAXNAMLEN);
- if (dir[Strlen(dir) - 1] != '/')
- catn(dir, STRslash, MAXNAMLEN);
- if ((nd = expand_dir(dir, exp_dir, &dir_fd, command)) != 0)
- return nd;
- if (word[Strlen(word) - 1] != '/')
- catn(word, STRslash, MAXNAMLEN);
+ if ((res = expand_dir(dir.s, &exp_dir, &dir_fd, command)) != 0)
+ goto err_dir;
+ if (isadirectory(exp_dir.s, name)) {
+ if (exp_dir.len != 0 || name[0] != '\0') {
+ Strbuf_append(&dir, name);
+ if (dir.s[dir.len - 1] != '/')
+ Strbuf_append1(&dir, '/');
+ Strbuf_terminate(&dir);
+ if ((res = expand_dir(dir.s, &exp_dir, &dir_fd, command)) != 0)
+ goto err_dir;
+ if (word->len != 0 && word->s[word->len - 1] != '/') {
+ Strbuf_append1(word, '/');
+ Strbuf_terminate(word);
+ }
name[0] = '\0';
}
}
#endif
- if ((nd = expand_dir(dir, exp_dir, &dir_fd, command)) != 0)
- return nd;
+ if ((res = expand_dir(dir.s, &exp_dir, &dir_fd, command)) != 0)
+ goto err_dir;
break;
case TW_TEXT:
flags |= TW_TEXT_CHK;
/*FALLTHROUGH*/
case TW_FILE:
- if ((nd = expand_dir(dir, exp_dir, &dir_fd, command)) != 0)
- return nd;
+ if ((res = expand_dir(dir.s, &exp_dir, &dir_fd, command)) != 0)
+ goto err_dir;
break;
case TW_PATH | TW_TEXT:
case TW_PATH | TW_FILE:
case TW_PATH | TW_DIRECTORY:
case TW_PATH | TW_COMMAND:
- if ((dir_fd = opendir(short2str(exp_dir))) == NULL) {
+ if ((dir_fd = opendir(short2str(exp_dir.s))) == NULL) {
if (command == RECOGNIZE)
xprintf("\n");
- xprintf("%S: %s", exp_dir, strerror(errno));
+ xprintf("%S: %s", exp_dir.s, strerror(errno));
if (command != RECOGNIZE)
xprintf("\n");
NeedsRedraw = 1;
- return -1;
+ res = -1;
+ goto err_dir;
+ }
+ if (exp_dir.len != 0 && exp_dir.s[exp_dir.len - 1] != '/') {
+ Strbuf_append1(&exp_dir, '/');
+ Strbuf_terminate(&exp_dir);
}
- if (exp_dir[Strlen(exp_dir) - 1] != '/')
- catn(exp_dir, STRslash, MAXNAMLEN);
looking &= ~TW_PATH;
@@ -1626,7 +1673,8 @@ t_search(word, wp, command, max_word_length, looking, list_max, pat, suf)
break;
case TW_COMMAND:
- copyn(target, word, MAXNAMLEN); /* so it can match things */
+ xfree(name);
+ target = name = Strsave(word->s); /* so it can match things */
break;
default:
@@ -1636,28 +1684,32 @@ t_search(word, wp, command, max_word_length, looking, list_max, pat, suf)
break;
case TW_LOGNAME:
- word++;
+ user_name = word->s + 1;
+ goto do_user;
+
/*FALLTHROUGH*/
case TW_USER:
+ user_name = word->s;
+ do_user:
/*
* Check if the spelling was already correct
* From: Rob McMahon <cudcv@cu.warwick.ac.uk>
*/
- if (command == SPELL && getpwnam(short2str(word)) != NULL) {
+ if (command == SPELL && xgetpwnam(short2str(user_name)) != NULL) {
#ifdef YPBUGS
fix_yp_bugs();
#endif /* YPBUGS */
- return (0);
+ res = 0;
+ goto err_dir;
}
- copyn(name, word, MAXNAMLEN); /* name sans ~ */
- if (looking == TW_LOGNAME)
- word--;
+ xfree(name);
+ target = name = Strsave(user_name);
break;
case TW_COMMAND:
case TW_VARLIST:
case TW_WORDLIST:
- copyn(target, word, MAXNAMLEN); /* so it can match things */
+ target = name = Strsave(word->s); /* so it can match things */
break;
default:
@@ -1665,56 +1717,63 @@ t_search(word, wp, command, max_word_length, looking, list_max, pat, suf)
"\n%s internal error: I don't know what I'm looking for!\n"),
progname);
NeedsRedraw = 1;
- return (-1);
+ res = -1;
+ goto err_dir;
}
- numitems = tw_collect(command, looking, exp_dir, exp_name,
- &target, pat, flags, dir_fd);
+ cleanup_push(&exp_name, Strbuf_cleanup);
+ numitems = tw_collect(command, looking, &exp_dir, &exp_name, target, pat,
+ flags, dir_fd);
if (numitems == -1)
- return -1;
+ goto end;
switch (command) {
case RECOGNIZE:
case RECOGNIZE_ALL:
case RECOGNIZE_SCROLL:
if (numitems <= 0)
- return (numitems);
+ break;
- tw_fixword(looking, word, dir, exp_name, max_word_length);
+ Strbuf_terminate(&exp_name);
+ tw_fixword(looking, word, dir.s, exp_name.s);
if (!match_unique_match && is_set(STRaddsuffix) && numitems == 1) {
- Char suffix[2];
-
- suffix[1] = '\0';
switch (suf) {
case 0: /* Automatic suffix */
- suffix[0] = tw_suffix(looking, exp_dir, exp_name, target, name);
+ Strbuf_append1(word,
+ tw_suffix(looking, exp_dir.s, exp_name.s));
break;
- case -1: /* No suffix */
- return numitems;
+ case CHAR_ERR: /* No suffix */
+ break;
default: /* completion specified suffix */
- suffix[0] = (Char) suf;
+ Strbuf_append1(word, suf);
break;
}
- catn(word, suffix, max_word_length);
+ Strbuf_terminate(word);
}
- return numitems;
+ break;
case LIST:
tw_list_items(looking, numitems, list_max);
tw_item_free();
- return (numitems);
+ break;
case SPELL:
- tw_fixword(looking, word, dir, exp_name, max_word_length);
- return (numitems);
+ Strbuf_terminate(&exp_name);
+ tw_fixword(looking, word, dir.s, exp_name.s);
+ break;
default:
xprintf("Bad tw_command\n");
- return (0);
+ numitems = 0;
}
+ end:
+ res = numitems;
+ err_dir:
+ cleanup_until(&dir);
+ return res;
} /* end t_search */
@@ -1723,8 +1782,7 @@ t_search(word, wp, command, max_word_length, looking, list_max, pat, suf)
* Should leave final slash (/) at end of dir.
*/
static void
-extract_dir_and_name(path, dir, name)
- Char *path, *dir, *name;
+extract_dir_and_name(const Char *path, struct Strbuf *dir, Char **name)
{
Char *p;
@@ -1733,15 +1791,14 @@ extract_dir_and_name(path, dir, name)
if (p == NULL)
p = Strrchr(path, ':');
#endif /* WINNT_NATIVE */
- if (p == NULL) {
- copyn(name, path, MAXNAMLEN);
- dir[0] = '\0';
- }
+ if (p == NULL)
+ *name = Strsave(path);
else {
p++;
- copyn(name, p, MAXNAMLEN);
- copyn(dir, path, p - path);
+ *name = Strsave(p);
+ Strbuf_appendn(dir, path, p - path);
}
+ Strbuf_terminate(dir);
} /* end extract_dir_and_name */
@@ -1750,24 +1807,21 @@ extract_dir_and_name(path, dir, name)
* to "/value_of_old1/value_of_old2/old3/"
*/
Char *
-dollar(new, old)
- Char *new;
- const Char *old;
+dollar(const Char *old)
{
- Char *p;
- size_t space;
+ struct Strbuf buf = Strbuf_INIT;
- for (space = FILSIZ, p = new; *old && space > 0;)
- if (*old != '$') {
- *p++ = *old++;
- space--;
- }
+ while (*old) {
+ if (*old != '$')
+ Strbuf_append1(&buf, *old++);
else {
- if (expdollar(&p, &old, &space, QUOTE) == NULL)
+ if (expdollar(&buf, &old, QUOTE) == 0) {
+ xfree(buf.s);
return NULL;
+ }
}
- *p = '\0';
- return (new);
+ }
+ return Strbuf_finish(&buf);
} /* end dollar */
@@ -1775,44 +1829,55 @@ dollar(new, old)
* expand ~person/foo to home_directory_of_person/foo
* or =<stack-entry> to <dir in stack entry>
*/
-static Char *
-tilde(new, old)
- Char *new, *old;
+static int
+tilde(struct Strbuf *new, Char *old)
{
Char *o, *p;
+ new->len = 0;
switch (old[0]) {
- case '~':
- for (p = new, o = &old[1]; *o && *o != '/'; *p++ = *o++)
+ case '~': {
+ Char *name, *home;
+
+ old++;
+ for (o = old; *o && *o != '/'; o++)
continue;
- *p = '\0';
- if (gethdir(new)) {
- new[0] = '\0';
- return NULL;
- }
-#ifdef apollo
- /* Special case: if the home directory expands to "/", we do
+ name = Strnsave(old, o - old);
+ home = gethdir(name);
+ xfree(name);
+ if (home == NULL)
+ goto err;
+ Strbuf_append(new, home);
+ xfree(home);
+ /* If the home directory expands to "/", we do
* not want to create "//" by appending a slash from o.
*/
- if (new[0] == '/' && new[1] == '\0' && *o == '/')
+ if (new->s[0] == '/' && new->len == 1 && *o == '/')
++o;
-#endif /* apollo */
- (void) Strcat(new, o);
- return new;
+ Strbuf_append(new, o);
+ break;
+ }
case '=':
- if ((p = globequal(new, old)) == NULL) {
- *new = '\0';
- return NULL;
+ if ((p = globequal(old)) == NULL)
+ goto err;
+ if (p != old) {
+ Strbuf_append(new, p);
+ xfree(p);
+ break;
}
- if (p == new)
- return new;
/*FALLTHROUGH*/
default:
- (void) Strcpy(new, old);
- return new;
+ Strbuf_append(new, old);
+ break;
}
+ Strbuf_terminate(new);
+ return 0;
+
+ err:
+ Strbuf_terminate(new);
+ return -1;
} /* end tilde */
@@ -1821,58 +1886,51 @@ tilde(new, old)
* Optionally normalize the path given
*/
static int
-expand_dir(dir, edir, dfd, cmd)
- Char *dir, *edir;
- DIR **dfd;
- COMMAND cmd;
+expand_dir(const Char *dir, struct Strbuf *edir, DIR **dfd, COMMAND cmd)
{
Char *nd = NULL;
- Char tdir[MAXPATHLEN + 1];
-
- if ((dollar(tdir, dir) == 0) ||
- (tilde(edir, tdir) == 0) ||
- !(nd = dnormalize(*edir ? edir : STRdot, symlinks == SYM_IGNORE ||
- symlinks == SYM_EXPAND)) ||
+ Char *tdir;
+
+ tdir = dollar(dir);
+ cleanup_push(tdir, xfree);
+ if (tdir == NULL ||
+ (tilde(edir, tdir) != 0) ||
+ !(nd = dnormalize(edir->len ? edir->s : STRdot,
+ symlinks == SYM_IGNORE || symlinks == SYM_EXPAND)) ||
((*dfd = opendir(short2str(nd))) == NULL)) {
- xfree((ptr_t) nd);
- if (cmd == SPELL || SearchNoDirErr)
+ xfree(nd);
+ if (cmd == SPELL || SearchNoDirErr) {
+ cleanup_until(tdir);
return (-2);
+ }
/*
* From: Amos Shapira <amoss@cs.huji.ac.il>
* Print a better message when completion fails
*/
- xprintf("\n%S %s\n",
- *edir ? edir :
- (*tdir ? tdir : dir),
+ xprintf("\n%S %s\n", edir->len ? edir->s : (tdir ? tdir : dir),
(errno == ENOTDIR ? CGETS(30, 10, "not a directory") :
(errno == ENOENT ? CGETS(30, 11, "not found") :
CGETS(30, 12, "unreadable"))));
NeedsRedraw = 1;
+ cleanup_until(tdir);
return (-1);
}
+ cleanup_until(tdir);
if (nd) {
if (*dir != '\0') {
- Char *s, *d, *p;
+ int slash;
/*
* Copy and append a / if there was one
*/
- for (p = edir; *p; p++)
- continue;
- if (*--p == '/') {
- for (p = nd; *p; p++)
- continue;
- if (*--p != '/')
- p = NULL;
- }
- for (d = edir, s = nd; (*d++ = *s++) != '\0';)
- continue;
- if (!p) {
- *d-- = '\0';
- *d = '/';
- }
+ slash = edir->len != 0 && edir->s[edir->len - 1] == '/';
+ edir->len = 0;
+ Strbuf_append(edir, nd);
+ if (slash != 0 && edir->s[edir->len - 1] != '/')
+ Strbuf_append1(edir, '/');
+ Strbuf_terminate(edir);
}
- xfree((ptr_t) nd);
+ xfree(nd);
}
return 0;
} /* end expand_dir */
@@ -1885,8 +1943,7 @@ expand_dir(dir, edir, dfd, cmd)
* or very large directories.
*/
static int
-nostat(dir)
- Char *dir;
+nostat(Char *dir)
{
struct varent *vp;
Char **cp;
@@ -1908,29 +1965,20 @@ nostat(dir)
* symbology from 4.3 ls command.
*/
static Char
-filetype(dir, file)
- Char *dir, *file;
+filetype(Char *dir, Char *file)
{
if (dir) {
- Char path[512];
+ Char *path;
char *ptr;
struct stat statb;
-#ifdef S_ISCDF
- /*
- * From: veals@crchh84d.bnr.ca (Percy Veals)
- * An extra stat is required for HPUX CDF files.
- */
- struct stat hpstatb;
-#endif /* S_ISCDF */
if (nostat(dir)) return(' ');
- (void) Strcpy(path, dir);
- catn(path, file, (int) (sizeof(path) / sizeof(Char)));
+ path = Strspl(dir, file);
+ ptr = short2str(path);
+ xfree(path);
- if (lstat(ptr = short2str(path), &statb) != -1)
- /* see above #define of lstat */
- {
+ if (lstat(ptr, &statb) != -1) {
#ifdef S_ISLNK
if (S_ISLNK(statb.st_mode)) { /* Symbolic link */
if (adrof(STRlistlinks)) {
@@ -1957,11 +2005,19 @@ filetype(dir, file)
if (S_ISHIDDEN(statb.st_mode)) /* Hidden Directory [aix] */
return ('+');
#endif
-#ifdef S_ISCDF
- (void) strcat(ptr, "+"); /* Must append a '+' and re-stat(). */
- if ((stat(ptr, &hpstatb) != -1) && S_ISCDF(hpstatb.st_mode))
- return ('+'); /* Context Dependent Files [hpux] */
-#endif
+#ifdef S_ISCDF
+ {
+ struct stat hpstatb;
+ char *p2;
+
+ p2 = strspl(ptr, "+"); /* Must append a '+' and re-stat(). */
+ if ((stat(p2, &hpstatb) != -1) && S_ISCDF(hpstatb.st_mode)) {
+ xfree(p2);
+ return ('+'); /* Context Dependent Files [hpux] */
+ }
+ xfree(p2);
+ }
+#endif
#ifdef S_ISNWK
if (S_ISNWK(statb.st_mode)) /* Network Special [hpux] */
return (':');
@@ -1990,17 +2046,19 @@ filetype(dir, file)
* Return trus if the file is a directory
*/
static int
-isadirectory(dir, file) /* return 1 if dir/file is a directory */
- Char *dir, *file; /* uses stat rather than lstat to get dest. */
+isadirectory(const Char *dir, const Char *file)
+ /* return 1 if dir/file is a directory */
+ /* uses stat rather than lstat to get dest. */
{
if (dir) {
- Char path[MAXPATHLEN];
+ Char *path;
+ char *cpath;
struct stat statb;
- (void) Strcpy(path, dir);
- catn(path, file, (int) (sizeof(path) / sizeof(Char)));
- if (stat(short2str(path), &statb) >= 0) { /* resolve through
- * symlink */
+ path = Strspl(dir, file);
+ cpath = short2str(path);
+ xfree(path);
+ if (stat(cpath, &statb) >= 0) { /* resolve through symlink */
#ifdef S_ISSOCK
if (S_ISSOCK(statb.st_mode)) /* Socket */
return 0;
@@ -2022,9 +2080,7 @@ isadirectory(dir, file) /* return 1 if dir/file is a directory */
* Return how many rows needed to print sorted down columns
*/
static int
-find_rows(items, count, no_file_suffix)
- Char *items[];
- int count, no_file_suffix;
+find_rows(Char *items[], int count, int no_file_suffix)
{
int i, columns, rows;
unsigned int maxwidth = 0;
@@ -2048,12 +2104,11 @@ find_rows(items, count, no_file_suffix)
*
*/
void
-print_by_column(dir, items, count, no_file_suffix)
- Char *dir, *items[];
- int count, no_file_suffix;
+print_by_column(Char *dir, Char *items[], int count, int no_file_suffix)
{
int i, r, c, columns, rows;
- unsigned int w, wx, maxwidth = 0;
+ size_t w;
+ unsigned int wx, maxwidth = 0;
Char *val;
int across;
@@ -2080,7 +2135,7 @@ print_by_column(dir, items, count, no_file_suffix)
if (i < count) {
wx = 0;
- w = (unsigned int) Strlen(items[i]);
+ w = Strlen(items[i]);
#ifdef COLOR_LS_F
if (no_file_suffix) {
@@ -2088,6 +2143,7 @@ print_by_column(dir, items, count, no_file_suffix)
Char f = items[i][w - 1];
items[i][w - 1] = 0;
print_with_color(items[i], w - 1, f);
+ items[i][w - 1] = f;
}
else {
/* Print filename followed by '/' or '*' or ' ' */
@@ -2101,14 +2157,13 @@ print_by_column(dir, items, count, no_file_suffix)
}
else {
/* Print filename followed by '/' or '*' or ' ' */
- xprintf("%-S%c", items[i],
- filetype(dir, items[i]));
+ xprintf("%-S%c", items[i], filetype(dir, items[i]));
wx++;
}
#endif /* COLOR_LS_F */
if (c < (columns - 1)) { /* Not last column? */
- w = (unsigned int) NLSStringWidth(items[i]) + wx;
+ w = NLSStringWidth(items[i]) + wx;
for (; w < maxwidth; w++)
xputchar(' ');
}
@@ -2130,8 +2185,7 @@ print_by_column(dir, items, count, no_file_suffix)
* Compare strings ignoring the quoting chars
*/
int
-StrQcmp(str1, str2)
- const Char *str1, *str2;
+StrQcmp(const Char *str1, const Char *str2)
{
for (; *str1 && samecase(*str1 & TRIM) == samecase(*str2 & TRIM);
str1++, str2++)
@@ -2153,13 +2207,14 @@ StrQcmp(str1, str2)
/* fcompare():
- * Comparison routine for qsort
+ * Comparison routine for qsort, (Char **, Char **)
*/
int
-fcompare(file1, file2)
- Char **file1, **file2;
+fcompare(const void *xfile1, const void *xfile2)
{
- return (int) collate(*file1, *file2);
+ const Char *const *file1 = xfile1, *const *file2 = xfile2;
+
+ return collate(*file1, *file2);
} /* end fcompare */
@@ -2169,14 +2224,11 @@ fcompare(file1, file2)
* Always null terminate.
*/
void
-catn(des, src, count)
- Char *des;
- const Char *src;
- int count;
+catn(Char *des, const Char *src, int count)
{
- while (--count >= 0 && *des)
+ while (*des && --count > 0)
des++;
- while (--count >= 0)
+ while (--count > 0)
if ((*des++ = *src++) == 0)
return;
*des = '\0';
@@ -2188,11 +2240,9 @@ catn(des, src, count)
* and always null terminate.
*/
void
-copyn(des, src, count)
- Char *des, *src;
- int count;
+copyn(Char *des, const Char *src, size_t count)
{
- while (--count >= 0)
+ while (--count != 0)
if ((*des++ = *src++) == 0)
return;
*des = '\0';
@@ -2201,11 +2251,9 @@ copyn(des, src, count)
/* tgetenv():
* like it's normal string counter-part
- * [apollo uses that in tc.os.c, so it cannot be static]
*/
Char *
-tgetenv(str)
- Char *str;
+tgetenv(Char *str)
{
Char **var;
size_t len;
@@ -2232,48 +2280,46 @@ tgetenv(str)
struct scroll_tab_list *scroll_tab = 0;
static void
-add_scroll_tab(item)
- Char *item;
+add_scroll_tab(Char *item)
{
struct scroll_tab_list *new_scroll;
- new_scroll = (struct scroll_tab_list *) xmalloc((size_t)
- sizeof(struct scroll_tab_list));
+ new_scroll = xmalloc(sizeof(struct scroll_tab_list));
new_scroll->element = Strsave(item);
new_scroll->next = scroll_tab;
scroll_tab = new_scroll;
}
static void
-choose_scroll_tab(exp_name, cnt)
- Char **exp_name;
- int cnt;
+choose_scroll_tab(struct Strbuf *exp_name, int cnt)
{
struct scroll_tab_list *loop;
int tmp = cnt;
Char **ptr;
- ptr = (Char **) xmalloc((size_t) sizeof(Char *) * cnt);
+ ptr = xmalloc(sizeof(Char *) * cnt);
+ cleanup_push(ptr, xfree);
for(loop = scroll_tab; loop && (tmp >= 0); loop = loop->next)
ptr[--tmp] = loop->element;
- qsort((ptr_t) ptr, (size_t) cnt, sizeof(Char *),
- (int (*) __P((const void *, const void *))) fcompare);
-
- copyn(*exp_name, ptr[curchoice], (int) Strlen(ptr[curchoice]));
- xfree((ptr_t) ptr);
+ qsort(ptr, cnt, sizeof(Char *), fcompare);
+
+ exp_name->len = 0;
+ Strbuf_append(exp_name, ptr[curchoice]);
+ Strbuf_terminate(exp_name);
+ cleanup_until(ptr);
}
static void
-free_scroll_tab()
+free_scroll_tab(void)
{
struct scroll_tab_list *loop;
while(scroll_tab) {
loop = scroll_tab;
scroll_tab = scroll_tab->next;
- xfree((ptr_t) loop->element);
- xfree((ptr_t) loop);
+ xfree(loop->element);
+ xfree(loop);
}
}
diff --git a/contrib/tcsh/tw.spell.c b/contrib/tcsh/tw.spell.c
index 65efded..4754108 100644
--- a/contrib/tcsh/tw.spell.c
+++ b/contrib/tcsh/tw.spell.c
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/tw.spell.c,v 3.17 2004/11/23 02:10:50 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/tw.spell.c,v 3.21 2006/03/02 18:46:45 christos Exp $ */
/*
* tw.spell.c: Spell check words
*/
@@ -32,62 +32,59 @@
*/
#include "sh.h"
-RCSID("$Id: tw.spell.c,v 3.17 2004/11/23 02:10:50 christos Exp $")
+RCSID("$tcsh: tw.spell.c,v 3.21 2006/03/02 18:46:45 christos Exp $")
#include "tw.h"
/* spell_me : return corrrectly spelled filename. From K&P spname */
int
-spell_me(oldname, oldsize, looking, pat, suf)
- Char *oldname;
- int oldsize, looking;
- Char *pat;
- int suf;
+spell_me(struct Strbuf *oldname, int looking, Char *pat, eChar suf)
{
- /* The +1 is to fool hp's optimizer */
- Char guess[FILSIZ + 1], newname[FILSIZ + 1];
- Char *new = newname, *old = oldname;
- Char *p, *cp, *ws;
+ struct Strbuf guess = Strbuf_INIT, newname = Strbuf_INIT;
+ const Char *old = oldname->s;
+ size_t ws;
int foundslash = 0;
int retval;
+ cleanup_push(&guess, Strbuf_cleanup);
+ cleanup_push(&newname, Strbuf_cleanup);
for (;;) {
while (*old == '/') { /* skip '/' */
- *new++ = *old++;
+ Strbuf_append1(&newname, *old++);
foundslash = 1;
}
/* do not try to correct spelling of single letter words */
if (*old != '\0' && old[1] == '\0')
- *new++ = *old++;
- *new = '\0';
+ Strbuf_append1(&newname, *old++);
+ Strbuf_terminate(&newname);
if (*old == '\0') {
- retval = (StrQcmp(oldname, newname) != 0);
- copyn(oldname, newname, oldsize); /* shove it back. */
+ retval = (StrQcmp(oldname->s, newname.s) != 0);
+ cleanup_ignore(&newname);
+ xfree(oldname->s);
+ *oldname = newname; /* shove it back. */
+ cleanup_until(&guess);
return retval;
}
- p = guess; /* start at beginning of buf */
- if (newname[0]) /* add current dir if any */
- for (cp = newname; *cp; cp++)
- if (p < guess + FILSIZ)
- *p++ = *cp;
- ws = p;
+ guess.len = 0; /* start at beginning of buf */
+ Strbuf_append(&guess, newname.s); /* add current dir if any */
+ ws = guess.len;
for (; *old != '/' && *old != '\0'; old++)/* add current file name */
- if (p < guess + FILSIZ)
- *p++ = *old;
- *p = '\0'; /* terminate it */
+ Strbuf_append1(&guess, *old);
+ Strbuf_terminate(&guess);
/*
* Don't tell t_search we're looking for cmd if no '/' in the name so
* far but there are later - or it will look for *all* commands
*/
/* (*should* say "looking for directory" whenever '/' is next...) */
- retval = t_search(guess, p, SPELL, FILSIZ,
+ retval = t_search(&guess, SPELL,
looking == TW_COMMAND && (foundslash || *old != '/') ?
TW_COMMAND : looking, 1, pat, suf);
- if (retval >= 4 || retval < 0)
+ if (retval >= 4 || retval < 0) {
+ cleanup_until(&guess);
return -1; /* hopeless */
- for (p = ws; (*new = *p++) != '\0'; new++)
- continue;
+ }
+ Strbuf_append(&newname, guess.s + ws);
}
/*NOTREACHED*/
#ifdef notdef
@@ -110,8 +107,7 @@ spell_me(oldname, oldsize, looking, pat, suf)
*/
int
-spdist(s, t)
- Char *s, *t;
+spdist(const Char *s, const Char *t)
{
for (; (*s & TRIM) == (*t & TRIM); t++, s++)
if (*t == '\0')
@@ -133,15 +129,11 @@ spdist(s, t)
}
int
-spdir(extended_name, tilded_dir, item, name)
- Char *extended_name;
- Char *tilded_dir;
- Char *item;
- Char *name;
+spdir(struct Strbuf *extended_name, const Char *tilded_dir, const Char *item,
+ Char *name)
{
- Char path[MAXPATHLEN + 1];
- Char *s;
- Char oldch;
+ Char *path, *s, oldch;
+ char *p;
if (ISDOT(item) || ISDOTDOT(item))
return 0;
@@ -151,12 +143,18 @@ spdir(extended_name, tilded_dir, item, name)
if (*s == 0 || s[1] == 0 || *item != 0)
return 0;
+ path = xmalloc((Strlen(tilded_dir) + Strlen(name) + 1) * sizeof (*path));
(void) Strcpy(path, tilded_dir);
oldch = *s;
*s = '/';
- catn(path, name, (int) (sizeof(path) / sizeof(Char)));
- if (access(short2str(path), F_OK) == 0) {
- (void) Strcpy(extended_name, name);
+ Strcat(path, name);
+ p = short2str(path);
+ xfree(path);
+ if (access(p, F_OK) == 0) {
+ extended_name->len = 0;
+ Strbuf_append(extended_name, name);
+ Strbuf_terminate(extended_name);
+ /* FIXME: *s = oldch? */
return 1;
}
*s = oldch;
diff --git a/contrib/tcsh/vms.termcap.c b/contrib/tcsh/vms.termcap.c
index 7876690..58ce7e8 100644
--- a/contrib/tcsh/vms.termcap.c
+++ b/contrib/tcsh/vms.termcap.c
@@ -1,4 +1,4 @@
-/* $Header: /src/pub/tcsh/vms.termcap.c,v 1.8 2005/03/03 16:49:16 kim Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/vms.termcap.c,v 1.11 2006/03/02 18:46:45 christos Exp $ */
/*
* termcap.c 1.1 20/7/87 agc Joypace Ltd
*
@@ -9,7 +9,7 @@
* A public domain implementation of the termcap(3) routines.
*/
#include "sh.h"
-RCSID("$Id: vms.termcap.c,v 1.8 2005/03/03 16:49:16 kim Exp $")
+RCSID("$tcsh: vms.termcap.c,v 1.11 2006/03/02 18:46:45 christos Exp $")
#if defined(_VMS_POSIX) || defined(_OSD_POSIX)
/* efth 1988-Apr-29
@@ -45,16 +45,14 @@ extern FILE *fopen(); /* old fopen */
*/
int
-tgetent(bp, name)
-char *bp;
-char *name;
+tgetent(char *bp, char *name)
{
FILE *fp;
char *termfile;
char *cp,
*ptr, /* temporary pointer */
- tmp[1024]; /* buffer for terminal name */
- short len = strlen(name);
+ tmp[1024]; /* buffer for terminal name *//*FIXBUF*/
+ size_t len = strlen(name);
capab = bp;
@@ -79,7 +77,7 @@ char *name;
and then append the next line. */
while (*(cp = &bp[strlen(bp) - 2]) == '\\')
fgets(cp, 1024, fp);
-
+
/* Skip over any spaces or tabs */
for (++cp ; ISSPACE(*cp) ; cp++);
@@ -120,7 +118,6 @@ sscanf to look at aliases. These are delimited by '|'. */
sleep(1);
#endif /* DEBUG */
return(0);
-
}
/*
@@ -128,8 +125,7 @@ sscanf to look at aliases. These are delimited by '|'. */
* to id. Returns the value, -1 if invalid.
*/
int
-tgetnum(id)
-char *id;
+tgetnum(char *id)
{
char *cp;
int ret;
@@ -162,8 +158,7 @@ char *id;
* present.
*/
int
-tgetflag(id)
-char *id;
+tgetflag(char *id)
{
char *cp;
@@ -188,9 +183,7 @@ char *id;
* etc. Returns the string, or NULL if it can't do it.
*/
char *
-tgetstr(id, area)
-char *id;
-char **area;
+tgetstr(char *id, char **area)
{
char *cp;
char *ret;
@@ -268,10 +261,7 @@ char **area;
* Returns "OOPS" if something's gone wrong, or the string otherwise.
*/
char *
-tgoto(cm, destcol, destline)
-char *cm;
-int destcol;
-int destline;
+tgoto(char *cm, int destcol, int destline)
{
char *rp;
static char ret[24];
@@ -324,10 +314,7 @@ int destline;
* terminal that needs padding at the moment...
*/
int
-tputs(cp, affcnt, outc)
-char *cp;
-int affcnt;
-int (*outc)();
+tputs(char *cp, int affcnt, int (*outc)())
{
unsigned long delay = 0;
OpenPOWER on IntegriCloud