Browse Source

Plan 9 from Bell Labs 2005-09-01

David du Colombier 16 years ago
parent
commit
2f21373f3d
55 changed files with 7104 additions and 1644 deletions
  1. 59 50
      dist/replica/_plan9.db
  2. 58 56
      dist/replica/plan9.db
  3. 60 0
      dist/replica/plan9.log
  4. 1 1
      sys/man/2/setjmp
  5. 22 25
      sys/man/8/ppp
  6. 41 31
      sys/src/9/port/chan.c
  7. 1 1
      sys/src/cmd/ip/ppp/ipaux.c
  8. 4 4
      sys/src/cmd/ip/ppp/ppp.c
  9. 5 5
      sys/src/cmd/ip/pppoe.c
  10. 16 6
      sys/src/cmd/seq.c
  11. 1 2
      sys/src/cmd/spin/README
  12. 56 20
      sys/src/cmd/spin/dstep.c
  13. 94 16
      sys/src/cmd/spin/flow.c
  14. 92 36
      sys/src/cmd/spin/guided.c
  15. 177 67
      sys/src/cmd/spin/main.c
  16. 28 15
      sys/src/cmd/spin/mesg.c
  17. 2 0
      sys/src/cmd/spin/mkfile
  18. 344 103
      sys/src/cmd/spin/pangen1.c
  19. 1110 30
      sys/src/cmd/spin/pangen1.h
  20. 279 112
      sys/src/cmd/spin/pangen2.c
  21. 116 115
      sys/src/cmd/spin/pangen2.h
  22. 22 18
      sys/src/cmd/spin/pangen3.c
  23. 106 85
      sys/src/cmd/spin/pangen3.h
  24. 42 37
      sys/src/cmd/spin/pangen4.c
  25. 19 19
      sys/src/cmd/spin/pangen4.h
  26. 100 115
      sys/src/cmd/spin/pangen5.c
  27. 14 13
      sys/src/cmd/spin/pangen5.h
  28. 2357 0
      sys/src/cmd/spin/pangen6.c
  29. 32 19
      sys/src/cmd/spin/pc_zpp.c
  30. 42 31
      sys/src/cmd/spin/ps_msc.c
  31. 140 0
      sys/src/cmd/spin/reprosrc.c
  32. 73 23
      sys/src/cmd/spin/run.c
  33. 171 79
      sys/src/cmd/spin/sched.c
  34. 89 38
      sys/src/cmd/spin/spin.h
  35. 101 24
      sys/src/cmd/spin/spin.y
  36. 781 43
      sys/src/cmd/spin/spinlex.c
  37. 55 15
      sys/src/cmd/spin/structs.c
  38. 25 19
      sys/src/cmd/spin/sym.c
  39. 8 6
      sys/src/cmd/spin/tl.h
  40. 40 48
      sys/src/cmd/spin/tl_buchi.c
  41. 11 7
      sys/src/cmd/spin/tl_cache.c
  42. 18 16
      sys/src/cmd/spin/tl_lex.c
  43. 22 20
      sys/src/cmd/spin/tl_main.c
  44. 8 6
      sys/src/cmd/spin/tl_mem.c
  45. 24 10
      sys/src/cmd/spin/tl_parse.c
  46. 12 25
      sys/src/cmd/spin/tl_rewrt.c
  47. 28 37
      sys/src/cmd/spin/tl_trans.c
  48. 27 28
      sys/src/cmd/spin/vars.c
  49. 1 1
      sys/src/cmd/spin/version.h
  50. 15 1
      sys/src/cmd/tar.c
  51. 3 2
      sys/src/cmd/tcs/utf.c
  52. 2 2
      sys/src/cmd/unix/spin/readme
  53. BIN
      sys/src/cmd/unix/spin/spin334.tar.gz
  54. BIN
      sys/src/cmd/unix/spin/spin425.tar.gz
  55. 150 162
      sys/src/games/memo.c

+ 59 - 50
dist/replica/_plan9.db

@@ -414,7 +414,7 @@
 386/bin/tail - 775 sys sys 1125346016 66169
 386/bin/tar - 775 sys sys 1120014538 96347
 386/bin/tbl - 775 sys sys 1125346017 113167
-386/bin/tcs - 775 sys sys 1115950118 256588
+386/bin/tcs - 775 sys sys 1125501123 256580
 386/bin/tee - 775 sys sys 1115950118 38428
 386/bin/telco - 775 sys sys 1115950118 103315
 386/bin/telnet - 775 sys sys 1125346017 80355
@@ -7513,7 +7513,7 @@ sys/man/2/seek - 664 sys sys 944959696 671
 sys/man/2/segattach - 664 sys sys 1015091526 4304
 sys/man/2/segbrk - 664 sys sys 944959696 825
 sys/man/2/segflush - 664 sys sys 944959695 944
-sys/man/2/setjmp - 664 sys sys 944959696 1856
+sys/man/2/setjmp - 664 sys sys 1125540984 1857
 sys/man/2/sin - 664 sys sys 944959694 967
 sys/man/2/sinh - 664 sys sys 944959694 360
 sys/man/2/sleep - 664 sys sys 944959694 984
@@ -7705,7 +7705,7 @@ sys/man/8/pem - 664 sys sys 1060263669 1189
 sys/man/8/ping - 664 sys sys 1084473185 3436
 sys/man/8/plan9.ini - 664 sys sys 1117814755 21579
 sys/man/8/pop3 - 664 sys sys 1063854676 2720
-sys/man/8/ppp - 664 sys sys 1096036494 4424
+sys/man/8/ppp - 664 sys sys 1125530075 4414
 sys/man/8/prep - 664 sys sys 1079705872 13820
 sys/man/8/qer - 664 sys sys 1067723129 4909
 sys/man/8/reboot - 664 sys sys 969499895 414
@@ -8039,7 +8039,7 @@ sys/src/9/port/alloc.c - 664 sys sys 1102093389 5645
 sys/src/9/port/allocb.c - 664 sys sys 1123676437 3340
 sys/src/9/port/auth.c - 664 sys sys 1123647282 2392
 sys/src/9/port/cache.c - 664 sys sys 1055688274 9241
-sys/src/9/port/chan.c - 664 sys sys 1123647283 29928
+sys/src/9/port/chan.c - 664 sys sys 1125517669 30203
 sys/src/9/port/cis.c - 664 sys sys 1099761153 9248
 sys/src/9/port/debugalloc.c - 664 sys sys 1014931171 10402
 sys/src/9/port/dev.c - 664 sys sys 1077896125 8247
@@ -11976,17 +11976,17 @@ sys/src/cmd/ip/ppp/compress.c - 664 sys sys 1072729513 11774
 sys/src/cmd/ip/ppp/doclient - 775 sys sys 944961007 50
 sys/src/cmd/ip/ppp/doserve - 775 sys sys 944961009 91
 sys/src/cmd/ip/ppp/dotest - 775 sys sys 944961006 152
-sys/src/cmd/ip/ppp/ipaux.c - 664 sys sys 1015090266 2326
+sys/src/cmd/ip/ppp/ipaux.c - 664 sys sys 1125529107 2328
 sys/src/cmd/ip/ppp/mkfile - 664 sys sys 1063897576 352
 sys/src/cmd/ip/ppp/mppc.c - 664 sys sys 1015090267 16624
-sys/src/cmd/ip/ppp/ppp.c - 664 sys sys 1125316087 59889
+sys/src/cmd/ip/ppp/ppp.c - 664 sys sys 1125530039 59897
 sys/src/cmd/ip/ppp/ppp.h - 664 sys sys 1091904423 8284
 sys/src/cmd/ip/ppp/testppp.c - 664 sys sys 1045505281 3011
 sys/src/cmd/ip/ppp/thw.c - 664 sys sys 1015090268 5962
 sys/src/cmd/ip/ppp/thwack.c - 664 sys sys 1015090268 8004
 sys/src/cmd/ip/ppp/thwack.h - 664 sys sys 964662210 2052
 sys/src/cmd/ip/ppp/unthwack.c - 664 sys sys 1015090268 5883
-sys/src/cmd/ip/pppoe.c - 664 sys sys 1050360937 12507
+sys/src/cmd/ip/pppoe.c - 664 sys sys 1125530113 12516
 sys/src/cmd/ip/pptp.c - 664 sys sys 1050360938 16575
 sys/src/cmd/ip/pptpd.c - 664 sys sys 1015701128 23548
 sys/src/cmd/ip/rarpd.c - 664 sys sys 1084470989 3389
@@ -12803,7 +12803,7 @@ sys/src/cmd/scuzz/scsireq.h - 664 sys sys 1113741890 5929
 sys/src/cmd/scuzz/scuzz.c - 664 sys sys 1121977163 37610
 sys/src/cmd/scuzz/sense.c - 664 sys sys 969510790 3901
 sys/src/cmd/sed.c - 664 sys sys 1100962924 27001
-sys/src/cmd/seq.c - 664 sys sys 1063854922 1484
+sys/src/cmd/seq.c - 664 sys sys 1125529033 1683
 sys/src/cmd/sh.C - 664 sys sys 1055701754 10303
 sys/src/cmd/sha1sum.c - 664 sys sys 1014926229 1017
 sys/src/cmd/size.c - 664 sys sys 944961619 717
@@ -12830,43 +12830,45 @@ sys/src/cmd/spell/spell.rc - 775 sys sys 964457135 312
 sys/src/cmd/spell/sprog.c - 664 sys sys 964540731 23030
 sys/src/cmd/spell/stop - 664 sys sys 944961232 18702
 sys/src/cmd/spin - 20000000775 sys sys 953242990 0
-sys/src/cmd/spin/README - 664 sys sys 953242984 344
-sys/src/cmd/spin/dstep.c - 664 sys sys 953242984 8805
-sys/src/cmd/spin/flow.c - 664 sys sys 953242984 15478
-sys/src/cmd/spin/guided.c - 664 sys sys 953242984 5899
-sys/src/cmd/spin/main.c - 664 sys sys 953242984 18700
-sys/src/cmd/spin/mesg.c - 664 sys sys 953242985 13596
-sys/src/cmd/spin/mkfile - 664 sys sys 953242985 669
-sys/src/cmd/spin/pangen1.c - 664 sys sys 953242985 23759
-sys/src/cmd/spin/pangen1.h - 664 sys sys 953242985 94543
-sys/src/cmd/spin/pangen2.c - 664 sys sys 956275776 66265
-sys/src/cmd/spin/pangen2.h - 664 sys sys 953242986 23128
-sys/src/cmd/spin/pangen3.c - 664 sys sys 953242986 8872
-sys/src/cmd/spin/pangen3.h - 664 sys sys 956275777 22057
-sys/src/cmd/spin/pangen4.c - 664 sys sys 953242986 8217
-sys/src/cmd/spin/pangen4.h - 664 sys sys 953242986 18957
-sys/src/cmd/spin/pangen5.c - 664 sys sys 953242986 16614
-sys/src/cmd/spin/pangen5.h - 664 sys sys 953242986 10852
-sys/src/cmd/spin/pc_zpp.c - 664 sys sys 956275778 8265
-sys/src/cmd/spin/ps_msc.c - 664 sys sys 953242987 11458
-sys/src/cmd/spin/run.c - 664 sys sys 953242987 13173
-sys/src/cmd/spin/sched.c - 664 sys sys 953242987 19359
-sys/src/cmd/spin/spin.h - 664 sys sys 953242987 10807
-sys/src/cmd/spin/spin.y - 664 sys sys 953242987 16731
-sys/src/cmd/spin/spinlex.c - 664 sys sys 953242987 13809
-sys/src/cmd/spin/structs.c - 664 sys sys 953242988 13364
-sys/src/cmd/spin/sym.c - 664 sys sys 953242988 11763
-sys/src/cmd/spin/tl.h - 664 sys sys 953242988 3254
-sys/src/cmd/spin/tl_buchi.c - 664 sys sys 953242988 13164
-sys/src/cmd/spin/tl_cache.c - 664 sys sys 953242988 5732
-sys/src/cmd/spin/tl_lex.c - 664 sys sys 953242988 3132
-sys/src/cmd/spin/tl_main.c - 664 sys sys 953242988 4331
-sys/src/cmd/spin/tl_mem.c - 664 sys sys 953242988 2592
-sys/src/cmd/spin/tl_parse.c - 664 sys sys 953242989 8007
-sys/src/cmd/spin/tl_rewrt.c - 664 sys sys 953242989 6257
-sys/src/cmd/spin/tl_trans.c - 664 sys sys 953242990 16758
-sys/src/cmd/spin/vars.c - 664 sys sys 953242990 8412
-sys/src/cmd/spin/version.h - 664 sys sys 956275780 54
+sys/src/cmd/spin/README - 664 sys sys 1125514858 311
+sys/src/cmd/spin/dstep.c - 664 sys sys 1125514858 9958
+sys/src/cmd/spin/flow.c - 664 sys sys 1125514858 17345
+sys/src/cmd/spin/guided.c - 664 sys sys 1125514858 6948
+sys/src/cmd/spin/main.c - 664 sys sys 1125514858 21713
+sys/src/cmd/spin/mesg.c - 664 sys sys 1125514858 13722
+sys/src/cmd/spin/mkfile - 664 sys sys 1125514859 696
+sys/src/cmd/spin/pangen1.c - 664 sys sys 1125514859 29801
+sys/src/cmd/spin/pangen1.h - 664 sys sys 1125514859 134192
+sys/src/cmd/spin/pangen2.c - 664 sys sys 1125514859 74348
+sys/src/cmd/spin/pangen2.h - 664 sys sys 1125514860 23109
+sys/src/cmd/spin/pangen3.c - 664 sys sys 1125514860 8941
+sys/src/cmd/spin/pangen3.h - 664 sys sys 1125514860 22484
+sys/src/cmd/spin/pangen4.c - 664 sys sys 1125514860 8180
+sys/src/cmd/spin/pangen4.h - 664 sys sys 1125514860 19033
+sys/src/cmd/spin/pangen5.c - 664 sys sys 1125514860 16851
+sys/src/cmd/spin/pangen5.h - 664 sys sys 1125514861 11145
+sys/src/cmd/spin/pangen6.c - 664 sys sys 1125514861 48633
+sys/src/cmd/spin/pc_zpp.c - 664 sys sys 1125514861 8737
+sys/src/cmd/spin/ps_msc.c - 664 sys sys 1125514861 11872
+sys/src/cmd/spin/reprosrc.c - 664 sys sys 1125514861 2978
+sys/src/cmd/spin/run.c - 664 sys sys 1125514862 14405
+sys/src/cmd/spin/sched.c - 664 sys sys 1125514862 21096
+sys/src/cmd/spin/spin.h - 664 sys sys 1125514862 12286
+sys/src/cmd/spin/spin.y - 664 sys sys 1125514862 18876
+sys/src/cmd/spin/spinlex.c - 664 sys sys 1125514862 30767
+sys/src/cmd/spin/structs.c - 664 sys sys 1125514863 14150
+sys/src/cmd/spin/sym.c - 664 sys sys 1125514863 11863
+sys/src/cmd/spin/tl.h - 664 sys sys 1125514863 3332
+sys/src/cmd/spin/tl_buchi.c - 664 sys sys 1125514863 13080
+sys/src/cmd/spin/tl_cache.c - 664 sys sys 1125514863 5831
+sys/src/cmd/spin/tl_lex.c - 664 sys sys 1125514863 3243
+sys/src/cmd/spin/tl_main.c - 664 sys sys 1125514863 4412
+sys/src/cmd/spin/tl_mem.c - 664 sys sys 1125514864 2670
+sys/src/cmd/spin/tl_parse.c - 664 sys sys 1125514864 8257
+sys/src/cmd/spin/tl_rewrt.c - 664 sys sys 1125514864 5962
+sys/src/cmd/spin/tl_trans.c - 664 sys sys 1125514864 16758
+sys/src/cmd/spin/vars.c - 664 sys sys 1125514864 8393
+sys/src/cmd/spin/version.h - 664 sys sys 1125514864 53
 sys/src/cmd/split.c - 664 sys sys 1116770353 3225
 sys/src/cmd/srv.c - 664 sys sys 1074452607 3885
 sys/src/cmd/srvfs.c - 664 sys sys 1116770384 1702
@@ -12923,7 +12925,7 @@ sys/src/cmd/tapefs/v10fs.c - 664 sys sys 1014926385 3754
 sys/src/cmd/tapefs/v6fs.c - 664 sys sys 1014926385 3971
 sys/src/cmd/tapefs/zip.h - 664 sys sys 1097914153 1428
 sys/src/cmd/tapefs/zipfs.c - 664 sys sys 1097900277 6803
-sys/src/cmd/tar.c - 664 sys sys 1119986000 21041
+sys/src/cmd/tar.c - 664 sys sys 1125515072 21269
 sys/src/cmd/tbl - 20000000775 sys sys 954038038 0
 sys/src/cmd/tbl/mkfile - 664 sys sys 944961243 268
 sys/src/cmd/tbl/t.h - 664 sys sys 944961244 3987
@@ -12991,7 +12993,7 @@ sys/src/cmd/tcs/kuten212.h - 664 sys sys 944961287 94
 sys/src/cmd/tcs/mkfile - 664 sys sys 1036724422 532
 sys/src/cmd/tcs/plan9.h - 664 sys sys 944961287 751
 sys/src/cmd/tcs/tcs.c - 664 sys sys 1044661975 51805
-sys/src/cmd/tcs/utf.c - 664 sys sys 1044661976 7951
+sys/src/cmd/tcs/utf.c - 664 sys sys 1125501123 7962
 sys/src/cmd/tee.c - 664 sys sys 954970286 1062
 sys/src/cmd/telco - 20000000775 sys sys 1015701205 0
 sys/src/cmd/telco/mkfile - 664 sys sys 944961290 201
@@ -13242,8 +13244,8 @@ sys/src/cmd/unix/netkey.c - 664 sys sys 1045152984 21761
 sys/src/cmd/unix/sam - 20000000775 sys sys 954263160 0
 sys/src/cmd/unix/sam/README - 664 sys sys 1110289373 306
 sys/src/cmd/unix/spin - 20000000775 sys sys 956275829 0
-sys/src/cmd/unix/spin/readme - 664 sys sys 956275829 271
-sys/src/cmd/unix/spin/spin334.tar.gz - 664 sys sys 956275830 264112
+sys/src/cmd/unix/spin/readme - 664 sys sys 1125514575 247
+sys/src/cmd/unix/spin/spin425.tar.gz - 664 sys sys 1125514573 330078
 sys/src/cmd/unix/tcs.shar.Z - 664 sys sys 944961315 312440
 sys/src/cmd/unix/u9fs - 20000000775 sys sys 1015092354 0
 sys/src/cmd/unix/u9fs/authnone.c - 664 sys sys 1015092351 321
@@ -13783,7 +13785,7 @@ sys/src/games/mahjongg/level.c - 664 sys sys 1095792293 2522
 sys/src/games/mahjongg/mahjongg.c - 664 sys sys 1095792293 3452
 sys/src/games/mahjongg/mahjongg.h - 664 sys sys 1095792293 1606
 sys/src/games/mahjongg/mkfile - 664 sys sys 1095792293 230
-sys/src/games/memo.c - 664 sys sys 1110436470 6837
+sys/src/games/memo.c - 664 sys sys 1125514848 6321
 sys/src/games/mkfile - 664 sys sys 1118672535 567
 sys/src/games/music - 20000000775 sys sys 1103793915 0
 sys/src/games/music/Readme - 664 sys sys 1103793914 488
@@ -14959,3 +14961,10 @@ usr/glenda/lib/profile - 664 glenda glenda 1105128663 890
 usr/glenda/readme.acme - 664 glenda glenda 1019860628 4753
 usr/glenda/readme.rio - 664 glenda glenda 1019860628 6370
 usr/glenda/tmp - 20000000775 glenda glenda 1018802620 0
+386/bin/games/memo - 775 sys sys 1125544173 156892
+386/bin/seq - 775 sys sys 1125544174 38396
+386/bin/spin - 775 sys sys 1125544175 758333
+386/bin/ip/ppp - 775 sys sys 1125544173 218875
+386/bin/ip/pppoe - 775 sys sys 1125544173 77548
+386/bin/tar - 775 sys sys 1125544175 96517
+386/bin/tcs - 775 sys sys 1125544176 256580

+ 58 - 56
dist/replica/plan9.db

@@ -252,7 +252,7 @@
 386/bin/games/jukebox - 775 sys sys 1105589128 264821
 386/bin/games/jukefs - 775 sys sys 1105589129 165320
 386/bin/games/mahjongg - 775 sys sys 1125345978 164288
-386/bin/games/memo - 775 sys sys 1115950076 157374
+386/bin/games/memo - 775 sys sys 1125544173 156892
 386/bin/games/playlistfs - 775 sys sys 1105589129 148484
 386/bin/games/sokoban - 775 sys sys 1125345978 163379
 386/bin/games/sudoku - 775 sys sys 1117249746 171666
@@ -296,8 +296,8 @@
 386/bin/ip/imap4d - 775 sys sys 1125345987 236488
 386/bin/ip/ipconfig - 775 sys sys 1125345988 137742
 386/bin/ip/ping - 775 sys sys 1116126319 77010
-386/bin/ip/ppp - 775 sys sys 1125345988 218875
-386/bin/ip/pppoe - 775 sys sys 1116126319 77535
+386/bin/ip/ppp - 775 sys sys 1125544173 218875
+386/bin/ip/pppoe - 775 sys sys 1125544173 77548
 386/bin/ip/pptp - 775 sys sys 1116126320 126658
 386/bin/ip/pptpd - 775 sys sys 1125345988 125824
 386/bin/ip/rarpd - 775 sys sys 1125345990 111572
@@ -389,7 +389,7 @@
 386/bin/scp - 775 sys sys 1119496657 151927
 386/bin/scuzz - 775 sys sys 1125346011 111604
 386/bin/sed - 775 sys sys 1125346011 89514
-386/bin/seq - 775 sys sys 1115950111 38206
+386/bin/seq - 775 sys sys 1125544174 38396
 386/bin/sha1sum - 775 sys sys 1115950111 61133
 386/bin/size - 775 sys sys 1119496658 76974
 386/bin/sleep - 775 sys sys 1085077097 3413
@@ -398,7 +398,7 @@
 386/bin/sniffer - 775 sys sys 1038443185 99028
 386/bin/snoopy - 775 sys sys 1125346014 157537
 386/bin/sort - 775 sys sys 1125346014 82276
-386/bin/spin - 775 sys sys 1116903736 655162
+386/bin/spin - 775 sys sys 1125544175 758333
 386/bin/split - 775 sys sys 1125346015 75635
 386/bin/srv - 775 sys sys 1115950113 82387
 386/bin/srvfs - 775 sys sys 1116903736 40065
@@ -412,9 +412,9 @@
 386/bin/swap - 775 sys sys 1115950116 62094
 386/bin/syscall - 775 sys sys 1115950116 73536
 386/bin/tail - 775 sys sys 1125346016 66169
-386/bin/tar - 775 sys sys 1120014538 96347
+386/bin/tar - 775 sys sys 1125544175 96517
 386/bin/tbl - 775 sys sys 1125346017 113167
-386/bin/tcs - 775 sys sys 1115950118 256588
+386/bin/tcs - 775 sys sys 1125544176 256580
 386/bin/tee - 775 sys sys 1115950118 38428
 386/bin/telco - 775 sys sys 1115950118 103315
 386/bin/telnet - 775 sys sys 1125346017 80355
@@ -7513,7 +7513,7 @@ sys/man/2/seek - 664 sys sys 944959696 671
 sys/man/2/segattach - 664 sys sys 1015091526 4304
 sys/man/2/segbrk - 664 sys sys 944959696 825
 sys/man/2/segflush - 664 sys sys 944959695 944
-sys/man/2/setjmp - 664 sys sys 944959696 1856
+sys/man/2/setjmp - 664 sys sys 1125540984 1857
 sys/man/2/sin - 664 sys sys 944959694 967
 sys/man/2/sinh - 664 sys sys 944959694 360
 sys/man/2/sleep - 664 sys sys 944959694 984
@@ -7705,7 +7705,7 @@ sys/man/8/pem - 664 sys sys 1060263669 1189
 sys/man/8/ping - 664 sys sys 1084473185 3436
 sys/man/8/plan9.ini - 664 sys sys 1117814755 21579
 sys/man/8/pop3 - 664 sys sys 1063854676 2720
-sys/man/8/ppp - 664 sys sys 1096036494 4424
+sys/man/8/ppp - 664 sys sys 1125530075 4414
 sys/man/8/prep - 664 sys sys 1079705872 13820
 sys/man/8/qer - 664 sys sys 1067723129 4909
 sys/man/8/reboot - 664 sys sys 969499895 414
@@ -8039,7 +8039,7 @@ sys/src/9/port/alloc.c - 664 sys sys 1102093389 5645
 sys/src/9/port/allocb.c - 664 sys sys 1123676437 3340
 sys/src/9/port/auth.c - 664 sys sys 1123647282 2392
 sys/src/9/port/cache.c - 664 sys sys 1055688274 9241
-sys/src/9/port/chan.c - 664 sys sys 1123647283 29928
+sys/src/9/port/chan.c - 664 sys sys 1125517669 30203
 sys/src/9/port/cis.c - 664 sys sys 1099761153 9248
 sys/src/9/port/debugalloc.c - 664 sys sys 1014931171 10402
 sys/src/9/port/dev.c - 664 sys sys 1077896125 8247
@@ -11976,17 +11976,17 @@ sys/src/cmd/ip/ppp/compress.c - 664 sys sys 1072729513 11774
 sys/src/cmd/ip/ppp/doclient - 775 sys sys 944961007 50
 sys/src/cmd/ip/ppp/doserve - 775 sys sys 944961009 91
 sys/src/cmd/ip/ppp/dotest - 775 sys sys 944961006 152
-sys/src/cmd/ip/ppp/ipaux.c - 664 sys sys 1015090266 2326
+sys/src/cmd/ip/ppp/ipaux.c - 664 sys sys 1125529107 2328
 sys/src/cmd/ip/ppp/mkfile - 664 sys sys 1063897576 352
 sys/src/cmd/ip/ppp/mppc.c - 664 sys sys 1015090267 16624
-sys/src/cmd/ip/ppp/ppp.c - 664 sys sys 1125316087 59889
+sys/src/cmd/ip/ppp/ppp.c - 664 sys sys 1125530039 59897
 sys/src/cmd/ip/ppp/ppp.h - 664 sys sys 1091904423 8284
 sys/src/cmd/ip/ppp/testppp.c - 664 sys sys 1045505281 3011
 sys/src/cmd/ip/ppp/thw.c - 664 sys sys 1015090268 5962
 sys/src/cmd/ip/ppp/thwack.c - 664 sys sys 1015090268 8004
 sys/src/cmd/ip/ppp/thwack.h - 664 sys sys 964662210 2052
 sys/src/cmd/ip/ppp/unthwack.c - 664 sys sys 1015090268 5883
-sys/src/cmd/ip/pppoe.c - 664 sys sys 1050360937 12507
+sys/src/cmd/ip/pppoe.c - 664 sys sys 1125530113 12516
 sys/src/cmd/ip/pptp.c - 664 sys sys 1050360938 16575
 sys/src/cmd/ip/pptpd.c - 664 sys sys 1015701128 23548
 sys/src/cmd/ip/rarpd.c - 664 sys sys 1084470989 3389
@@ -12803,7 +12803,7 @@ sys/src/cmd/scuzz/scsireq.h - 664 sys sys 1113741890 5929
 sys/src/cmd/scuzz/scuzz.c - 664 sys sys 1121977163 37610
 sys/src/cmd/scuzz/sense.c - 664 sys sys 969510790 3901
 sys/src/cmd/sed.c - 664 sys sys 1100962924 27001
-sys/src/cmd/seq.c - 664 sys sys 1063854922 1484
+sys/src/cmd/seq.c - 664 sys sys 1125529033 1683
 sys/src/cmd/sh.C - 664 sys sys 1055701754 10303
 sys/src/cmd/sha1sum.c - 664 sys sys 1014926229 1017
 sys/src/cmd/size.c - 664 sys sys 944961619 717
@@ -12830,43 +12830,45 @@ sys/src/cmd/spell/spell.rc - 775 sys sys 964457135 312
 sys/src/cmd/spell/sprog.c - 664 sys sys 964540731 23030
 sys/src/cmd/spell/stop - 664 sys sys 944961232 18702
 sys/src/cmd/spin - 20000000775 sys sys 953242990 0
-sys/src/cmd/spin/README - 664 sys sys 953242984 344
-sys/src/cmd/spin/dstep.c - 664 sys sys 953242984 8805
-sys/src/cmd/spin/flow.c - 664 sys sys 953242984 15478
-sys/src/cmd/spin/guided.c - 664 sys sys 953242984 5899
-sys/src/cmd/spin/main.c - 664 sys sys 953242984 18700
-sys/src/cmd/spin/mesg.c - 664 sys sys 953242985 13596
-sys/src/cmd/spin/mkfile - 664 sys sys 953242985 669
-sys/src/cmd/spin/pangen1.c - 664 sys sys 953242985 23759
-sys/src/cmd/spin/pangen1.h - 664 sys sys 953242985 94543
-sys/src/cmd/spin/pangen2.c - 664 sys sys 956275776 66265
-sys/src/cmd/spin/pangen2.h - 664 sys sys 953242986 23128
-sys/src/cmd/spin/pangen3.c - 664 sys sys 953242986 8872
-sys/src/cmd/spin/pangen3.h - 664 sys sys 956275777 22057
-sys/src/cmd/spin/pangen4.c - 664 sys sys 953242986 8217
-sys/src/cmd/spin/pangen4.h - 664 sys sys 953242986 18957
-sys/src/cmd/spin/pangen5.c - 664 sys sys 953242986 16614
-sys/src/cmd/spin/pangen5.h - 664 sys sys 953242986 10852
-sys/src/cmd/spin/pc_zpp.c - 664 sys sys 956275778 8265
-sys/src/cmd/spin/ps_msc.c - 664 sys sys 953242987 11458
-sys/src/cmd/spin/run.c - 664 sys sys 953242987 13173
-sys/src/cmd/spin/sched.c - 664 sys sys 953242987 19359
-sys/src/cmd/spin/spin.h - 664 sys sys 953242987 10807
-sys/src/cmd/spin/spin.y - 664 sys sys 953242987 16731
-sys/src/cmd/spin/spinlex.c - 664 sys sys 953242987 13809
-sys/src/cmd/spin/structs.c - 664 sys sys 953242988 13364
-sys/src/cmd/spin/sym.c - 664 sys sys 953242988 11763
-sys/src/cmd/spin/tl.h - 664 sys sys 953242988 3254
-sys/src/cmd/spin/tl_buchi.c - 664 sys sys 953242988 13164
-sys/src/cmd/spin/tl_cache.c - 664 sys sys 953242988 5732
-sys/src/cmd/spin/tl_lex.c - 664 sys sys 953242988 3132
-sys/src/cmd/spin/tl_main.c - 664 sys sys 953242988 4331
-sys/src/cmd/spin/tl_mem.c - 664 sys sys 953242988 2592
-sys/src/cmd/spin/tl_parse.c - 664 sys sys 953242989 8007
-sys/src/cmd/spin/tl_rewrt.c - 664 sys sys 953242989 6257
-sys/src/cmd/spin/tl_trans.c - 664 sys sys 953242990 16758
-sys/src/cmd/spin/vars.c - 664 sys sys 953242990 8412
-sys/src/cmd/spin/version.h - 664 sys sys 956275780 54
+sys/src/cmd/spin/README - 664 sys sys 1125514858 311
+sys/src/cmd/spin/dstep.c - 664 sys sys 1125514858 9958
+sys/src/cmd/spin/flow.c - 664 sys sys 1125514858 17345
+sys/src/cmd/spin/guided.c - 664 sys sys 1125514858 6948
+sys/src/cmd/spin/main.c - 664 sys sys 1125514858 21713
+sys/src/cmd/spin/mesg.c - 664 sys sys 1125514858 13722
+sys/src/cmd/spin/mkfile - 664 sys sys 1125514859 696
+sys/src/cmd/spin/pangen1.c - 664 sys sys 1125514859 29801
+sys/src/cmd/spin/pangen1.h - 664 sys sys 1125514859 134192
+sys/src/cmd/spin/pangen2.c - 664 sys sys 1125514859 74348
+sys/src/cmd/spin/pangen2.h - 664 sys sys 1125514860 23109
+sys/src/cmd/spin/pangen3.c - 664 sys sys 1125514860 8941
+sys/src/cmd/spin/pangen3.h - 664 sys sys 1125514860 22484
+sys/src/cmd/spin/pangen4.c - 664 sys sys 1125514860 8180
+sys/src/cmd/spin/pangen4.h - 664 sys sys 1125514860 19033
+sys/src/cmd/spin/pangen5.c - 664 sys sys 1125514860 16851
+sys/src/cmd/spin/pangen5.h - 664 sys sys 1125514861 11145
+sys/src/cmd/spin/pangen6.c - 664 sys sys 1125514861 48633
+sys/src/cmd/spin/pc_zpp.c - 664 sys sys 1125514861 8737
+sys/src/cmd/spin/ps_msc.c - 664 sys sys 1125514861 11872
+sys/src/cmd/spin/reprosrc.c - 664 sys sys 1125514861 2978
+sys/src/cmd/spin/run.c - 664 sys sys 1125514862 14405
+sys/src/cmd/spin/sched.c - 664 sys sys 1125514862 21096
+sys/src/cmd/spin/spin.h - 664 sys sys 1125514862 12286
+sys/src/cmd/spin/spin.y - 664 sys sys 1125514862 18876
+sys/src/cmd/spin/spinlex.c - 664 sys sys 1125514862 30767
+sys/src/cmd/spin/structs.c - 664 sys sys 1125514863 14150
+sys/src/cmd/spin/sym.c - 664 sys sys 1125514863 11863
+sys/src/cmd/spin/tl.h - 664 sys sys 1125514863 3332
+sys/src/cmd/spin/tl_buchi.c - 664 sys sys 1125514863 13080
+sys/src/cmd/spin/tl_cache.c - 664 sys sys 1125514863 5831
+sys/src/cmd/spin/tl_lex.c - 664 sys sys 1125514863 3243
+sys/src/cmd/spin/tl_main.c - 664 sys sys 1125514863 4412
+sys/src/cmd/spin/tl_mem.c - 664 sys sys 1125514864 2670
+sys/src/cmd/spin/tl_parse.c - 664 sys sys 1125514864 8257
+sys/src/cmd/spin/tl_rewrt.c - 664 sys sys 1125514864 5962
+sys/src/cmd/spin/tl_trans.c - 664 sys sys 1125514864 16758
+sys/src/cmd/spin/vars.c - 664 sys sys 1125514864 8393
+sys/src/cmd/spin/version.h - 664 sys sys 1125514864 53
 sys/src/cmd/split.c - 664 sys sys 1116770353 3225
 sys/src/cmd/srv.c - 664 sys sys 1074452607 3885
 sys/src/cmd/srvfs.c - 664 sys sys 1116770384 1702
@@ -12923,7 +12925,7 @@ sys/src/cmd/tapefs/v10fs.c - 664 sys sys 1014926385 3754
 sys/src/cmd/tapefs/v6fs.c - 664 sys sys 1014926385 3971
 sys/src/cmd/tapefs/zip.h - 664 sys sys 1097914153 1428
 sys/src/cmd/tapefs/zipfs.c - 664 sys sys 1097900277 6803
-sys/src/cmd/tar.c - 664 sys sys 1119986000 21041
+sys/src/cmd/tar.c - 664 sys sys 1125515072 21269
 sys/src/cmd/tbl - 20000000775 sys sys 954038038 0
 sys/src/cmd/tbl/mkfile - 664 sys sys 944961243 268
 sys/src/cmd/tbl/t.h - 664 sys sys 944961244 3987
@@ -12991,7 +12993,7 @@ sys/src/cmd/tcs/kuten212.h - 664 sys sys 944961287 94
 sys/src/cmd/tcs/mkfile - 664 sys sys 1036724422 532
 sys/src/cmd/tcs/plan9.h - 664 sys sys 944961287 751
 sys/src/cmd/tcs/tcs.c - 664 sys sys 1044661975 51805
-sys/src/cmd/tcs/utf.c - 664 sys sys 1044661976 7951
+sys/src/cmd/tcs/utf.c - 664 sys sys 1125501123 7962
 sys/src/cmd/tee.c - 664 sys sys 954970286 1062
 sys/src/cmd/telco - 20000000775 sys sys 1015701205 0
 sys/src/cmd/telco/mkfile - 664 sys sys 944961290 201
@@ -13242,8 +13244,8 @@ sys/src/cmd/unix/netkey.c - 664 sys sys 1045152984 21761
 sys/src/cmd/unix/sam - 20000000775 sys sys 954263160 0
 sys/src/cmd/unix/sam/README - 664 sys sys 1110289373 306
 sys/src/cmd/unix/spin - 20000000775 sys sys 956275829 0
-sys/src/cmd/unix/spin/readme - 664 sys sys 956275829 271
-sys/src/cmd/unix/spin/spin334.tar.gz - 664 sys sys 956275830 264112
+sys/src/cmd/unix/spin/readme - 664 sys sys 1125514575 247
+sys/src/cmd/unix/spin/spin425.tar.gz - 664 sys sys 1125514573 330078
 sys/src/cmd/unix/tcs.shar.Z - 664 sys sys 944961315 312440
 sys/src/cmd/unix/u9fs - 20000000775 sys sys 1015092354 0
 sys/src/cmd/unix/u9fs/authnone.c - 664 sys sys 1015092351 321
@@ -13783,7 +13785,7 @@ sys/src/games/mahjongg/level.c - 664 sys sys 1095792293 2522
 sys/src/games/mahjongg/mahjongg.c - 664 sys sys 1095792293 3452
 sys/src/games/mahjongg/mahjongg.h - 664 sys sys 1095792293 1606
 sys/src/games/mahjongg/mkfile - 664 sys sys 1095792293 230
-sys/src/games/memo.c - 664 sys sys 1110436470 6837
+sys/src/games/memo.c - 664 sys sys 1125514848 6321
 sys/src/games/mkfile - 664 sys sys 1118672535 567
 sys/src/games/music - 20000000775 sys sys 1103793915 0
 sys/src/games/music/Readme - 664 sys sys 1103793914 488

+ 60 - 0
dist/replica/plan9.log

@@ -21155,3 +21155,63 @@
 1125347550 230 c acme/bin/386/News - 775 sys sys 1125346044 128804
 1125347550 231 c acme/bin/386/Wiki - 775 sys sys 1125346044 127380
 1125347550 232 c acme/bin/386/spout - 775 sys sys 1125346044 61608
+1125502264 0 c 386/bin/tcs - 775 sys sys 1125501123 256580
+1125502264 1 c sys/src/cmd/tcs/utf.c - 664 sys sys 1125501123 7962
+1125514868 0 c sys/src/cmd/spin/README - 664 sys sys 1125514858 311
+1125514868 1 c sys/src/cmd/spin/dstep.c - 664 sys sys 1125514858 9958
+1125514868 2 c sys/src/cmd/spin/flow.c - 664 sys sys 1125514858 17345
+1125514868 3 c sys/src/cmd/spin/guided.c - 664 sys sys 1125514858 6948
+1125514868 4 c sys/src/cmd/spin/main.c - 664 sys sys 1125514858 21713
+1125514868 5 c sys/src/cmd/spin/mesg.c - 664 sys sys 1125514858 13722
+1125514868 6 c sys/src/cmd/spin/mkfile - 664 sys sys 1125514859 696
+1125514868 7 c sys/src/cmd/spin/pangen1.c - 664 sys sys 1125514859 29801
+1125514868 8 c sys/src/cmd/spin/pangen1.h - 664 sys sys 1125514859 134192
+1125514868 9 c sys/src/cmd/spin/pangen2.c - 664 sys sys 1125514859 74348
+1125514868 10 c sys/src/cmd/spin/pangen2.h - 664 sys sys 1125514860 23109
+1125514868 11 c sys/src/cmd/spin/pangen3.c - 664 sys sys 1125514860 8941
+1125514868 12 c sys/src/cmd/spin/pangen3.h - 664 sys sys 1125514860 22484
+1125514868 13 c sys/src/cmd/spin/pangen4.c - 664 sys sys 1125514860 8180
+1125514868 14 c sys/src/cmd/spin/pangen4.h - 664 sys sys 1125514860 19033
+1125514868 15 c sys/src/cmd/spin/pangen5.c - 664 sys sys 1125514860 16851
+1125514868 16 c sys/src/cmd/spin/pangen5.h - 664 sys sys 1125514861 11145
+1125514868 17 a sys/src/cmd/spin/pangen6.c - 664 sys sys 1125514861 48633
+1125514868 18 c sys/src/cmd/spin/pc_zpp.c - 664 sys sys 1125514861 8737
+1125514868 19 c sys/src/cmd/spin/ps_msc.c - 664 sys sys 1125514861 11872
+1125514868 20 a sys/src/cmd/spin/reprosrc.c - 664 sys sys 1125514861 2978
+1125514868 21 c sys/src/cmd/spin/run.c - 664 sys sys 1125514862 14405
+1125514868 22 c sys/src/cmd/spin/sched.c - 664 sys sys 1125514862 21096
+1125514868 23 c sys/src/cmd/spin/spin.h - 664 sys sys 1125514862 12286
+1125514868 24 c sys/src/cmd/spin/spin.y - 664 sys sys 1125514862 18876
+1125514868 25 c sys/src/cmd/spin/spinlex.c - 664 sys sys 1125514862 30767
+1125514868 26 c sys/src/cmd/spin/structs.c - 664 sys sys 1125514863 14150
+1125514868 27 c sys/src/cmd/spin/sym.c - 664 sys sys 1125514863 11863
+1125514868 28 c sys/src/cmd/spin/tl.h - 664 sys sys 1125514863 3332
+1125514868 29 c sys/src/cmd/spin/tl_buchi.c - 664 sys sys 1125514863 13080
+1125514868 30 c sys/src/cmd/spin/tl_cache.c - 664 sys sys 1125514863 5831
+1125514868 31 c sys/src/cmd/spin/tl_lex.c - 664 sys sys 1125514863 3243
+1125514868 32 c sys/src/cmd/spin/tl_main.c - 664 sys sys 1125514863 4412
+1125514868 33 c sys/src/cmd/spin/tl_mem.c - 664 sys sys 1125514864 2670
+1125514868 34 c sys/src/cmd/spin/tl_parse.c - 664 sys sys 1125514864 8257
+1125514868 35 c sys/src/cmd/spin/tl_rewrt.c - 664 sys sys 1125514864 5962
+1125514868 36 c sys/src/cmd/spin/tl_trans.c - 664 sys sys 1125514864 16758
+1125514868 37 c sys/src/cmd/spin/vars.c - 664 sys sys 1125514864 8393
+1125514868 38 c sys/src/cmd/spin/version.h - 664 sys sys 1125514864 53
+1125514868 39 c sys/src/cmd/unix/spin/readme - 664 sys sys 1125514575 247
+1125514868 40 a sys/src/cmd/unix/spin/spin425.tar.gz - 664 sys sys 1125514573 330078
+1125514868 41 c sys/src/games/memo.c - 664 sys sys 1125514848 6321
+1125514868 42 d sys/src/cmd/unix/spin/spin334.tar.gz - 664 sys sys 956275830 0
+1125516669 0 c sys/src/cmd/tar.c - 664 sys sys 1125515072 21269
+1125518469 0 c sys/src/9/port/chan.c - 664 sys sys 1125517669 30203
+1125529271 0 c sys/src/cmd/ip/ppp/ipaux.c - 664 sys sys 1125529107 2328
+1125529271 1 c sys/src/cmd/seq.c - 664 sys sys 1125529033 1683
+1125531072 0 c sys/man/8/ppp - 664 sys sys 1125530075 4414
+1125531072 1 c sys/src/cmd/ip/ppp/ppp.c - 664 sys sys 1125530039 59897
+1125531072 2 c sys/src/cmd/ip/pppoe.c - 664 sys sys 1125530113 12516
+1125541873 0 c sys/man/2/setjmp - 664 sys sys 1125540984 1857
+1125545475 0 c 386/bin/games/memo - 775 sys sys 1125544173 156892
+1125545475 1 c 386/bin/seq - 775 sys sys 1125544174 38396
+1125545475 2 c 386/bin/spin - 775 sys sys 1125544175 758333
+1125545475 3 c 386/bin/ip/ppp - 775 sys sys 1125544173 218875
+1125545475 4 c 386/bin/ip/pppoe - 775 sys sys 1125544173 77548
+1125545475 5 c 386/bin/tar - 775 sys sys 1125544175 96517
+1125545475 6 c 386/bin/tcs - 775 sys sys 1125544176 256580

+ 1 - 1
sys/man/2/setjmp

@@ -81,7 +81,7 @@ setlabel(void)
 {
 	label[JMPBUFPC] = ((ulong)f+JMPBUFDPC);
 	/* -2 leaves room for old pc and new pc in frame */
-	label[JMPBUFSP =
+	label[JMPBUFSP] =
 	        (ulong)(&stack[NSTACK-2*sizeof(ulong*)]);
 }
 .EE

+ 22 - 25
sys/man/8/ppp

@@ -34,7 +34,19 @@ ppp, pppoe, pptp, pptpd \- point to point protocol
 .PP
 .B ip/pppoe
 [
-.B -dP
+.B -Pd
+]
+[
+.B -A
+.I acname
+]
+[
+.B -S
+.I srvname
+]
+[
+.B -k
+.I keyspec
 ]
 [
 .B -m
@@ -44,7 +56,9 @@ ppp, pppoe, pptp, pptpd \- point to point protocol
 .B -x
 .I pppnetmntpt
 ]
-.I etherdir
+[
+.I ether
+]
 .PP
 .B ip/pptp
 [
@@ -180,7 +194,9 @@ the ethernet device mounted at
 .I etherdir
 (default
 .BR /net/ether0 ).
-The options are:
+The 
+.I pppoe -specific
+options are:
 .TP
 .B A
 insist on an access concentrator named
@@ -198,30 +214,11 @@ and pass
 .B -d
 to 
 .I ppp
-.TP
-.B m
-pass
-.B -m
-.I mtu
-to 
-.IR ppp ,
-default 1492
-.TP
-.B k
-pass
-.B -k
-.I keyspec
-to
-.I ppp
-.TP
-.B x
-pass
-.B -x
-.I pppnetmntpt
-to 
-.I ppp
 .PD
 .PP
+The other options are relayed to 
+.IR ppp .
+.PP
 .I Pptp
 is a client for a PPTP encrypted tunnel.
 .I Server

+ 41 - 31
sys/src/9/port/chan.c

@@ -77,11 +77,13 @@ typedef struct Elemlist Elemlist;
 
 struct Elemlist
 {
+	char	*aname;	/* original name */
 	char	*name;	/* copy of name, so '/' can be overwritten */
 	int	nelems;
 	char	**elems;
 	int	*off;
 	int	mustbedir;
+	int	nerror;
 };
 
 #define SEP(c) ((c) == 0 || (c) == '/')
@@ -897,7 +899,7 @@ walk(Chan **cp, char **names, int nnames, int nomount, int *nerror)
 	cclose(*cp);
 	*cp = c;
 	if(nerror)
-		*nerror = 0;
+		*nerror = nhave;
 	return 0;
 }
 
@@ -1015,6 +1017,7 @@ parsename(char *name, Elemlist *e)
 		*slash++ = '\0';
 		name = slash;
 	}
+	e->off[e->nelems] = name - e->name;
 }
 
 void*
@@ -1030,21 +1033,24 @@ memrchr(void *va, int c, long n)
 }
 
 void
-nameerror(char *name, char *error)
+namelenerror(char *aname, int len, char *err)
 {
-	int len;
-	char tmperr[ERRMAX], *p;
+	char *name;
 
-	strcpy(tmperr, error);	/* error might be in genbuf or tmperr */
-	len = strlen(name);
-	if(len < ERRMAX/3 || (p=strrchr(name, '/'))==nil || p==name)
-		snprint(up->genbuf, sizeof up->genbuf, "%s", name);
+	if(len < ERRMAX/3 || (name=memrchr(aname, '/', len))==nil || name==aname)
+		snprint(up->genbuf, sizeof up->genbuf, "%.*s", len, aname);
 	else
-		snprint(up->genbuf, sizeof up->genbuf, "...%s", p);
-	snprint(up->errstr, ERRMAX, "%#q %s", up->genbuf, tmperr);
+		snprint(up->genbuf, sizeof up->genbuf, "...%.*s", (int)(len-(name-aname)), name);
+	snprint(up->errstr, ERRMAX, "%#q %s", up->genbuf, err);
 	nexterror();
 }
 
+void
+nameerror(char *name, char *err)
+{
+	namelenerror(name, strlen(name), err);
+}
+
 /*
  * Turn a name into a channel.
  * &name[0] is known to be a valid address.  It may be a kernel address.
@@ -1064,7 +1070,7 @@ nameerror(char *name, char *error)
 Chan*
 namec(char *aname, int amode, int omode, ulong perm)
 {
-	int n, t, nomount, npath;
+	int n, t, nomount;
 	Chan *c, *cnew;
 	Cname *cname;
 	Elemlist e;
@@ -1073,14 +1079,14 @@ namec(char *aname, int amode, int omode, ulong perm)
 	char *createerr, tmperrbuf[ERRMAX];
 	char *name;
 
-	name = aname;
-	if(name[0] == '\0')
+	if(aname[0] == '\0')
 		error("empty file name");
-	name = validnamedup(name, 1);
+	aname = validnamedup(aname, 1);
 	if(waserror()){
-		free(name);
+		free(aname);
 		nexterror();
 	}
+	name = aname;
 
 	/*
 	 * Find the starting off point (the current slash, the root of
@@ -1134,17 +1140,24 @@ namec(char *aname, int amode, int omode, ulong perm)
 		break;
 	}
 
+	e.aname = aname;
 	e.name = nil;
 	e.elems = nil;
 	e.off = nil;
 	e.nelems = 0;
+	e.nerror = 0;
 	if(waserror()){
 		cclose(c);
 		free(e.name);
 		free(e.elems);
 		free(e.off);
-//dumpmount();
-		nexterror();
+		/*
+		 * Prepare nice error, showing first e.nerror elements of name.
+		 */
+		if(e.nerror == 0)
+			nexterror();
+		strcpy(tmperrbuf, up->errstr);
+		namelenerror(aname, (name-aname)+e.off[e.nerror], tmperrbuf);
 	}
 
 	/*
@@ -1158,8 +1171,8 @@ namec(char *aname, int amode, int omode, ulong perm)
 	if(amode == Acreate){
 		/* perm must have DMDIR if last element is / or /. */
 		if(e.mustbedir && !(perm&DMDIR)){
-			npath = e.nelems;
-			nameerror(aname, "create without DMDIR");
+			e.nerror = e.nelems;
+			error("create without DMDIR");
 		}
 
 		/* don't try to walk the last path element just yet. */
@@ -1168,23 +1181,19 @@ namec(char *aname, int amode, int omode, ulong perm)
 		e.nelems--;
 	}
 
-	if(walk(&c, e.elems, e.nelems, nomount, &npath) < 0){
-		if(npath < 0 || npath > e.nelems){
-			print("namec %s walk error npath=%d\n", aname, npath);
-			nexterror();
+	if(walk(&c, e.elems, e.nelems, nomount, &e.nerror) < 0){
+		if(e.nerror < 0 || e.nerror > e.nelems){
+			print("namec %s walk error nerror=%d\n", aname, e.nerror);
+			e.nerror = 0;
 		}
-		nameerror(aname, up->errstr);
+		nexterror();
 	}
 
-	if(e.mustbedir && !(c->qid.type&QTDIR)){
-		npath = e.nelems;
-		nameerror(aname, "not a directory");
-	}
+	if(e.mustbedir && !(c->qid.type&QTDIR))
+		error("not a directory");
 
-	if(amode == Aopen && (omode&3) == OEXEC && (c->qid.type&QTDIR)){
-		npath = e.nelems;
+	if(amode == Aopen && (omode&3) == OEXEC && (c->qid.type&QTDIR))
 		error("cannot exec directory");
-	}
 
 	switch(amode){
 	case Abind:
@@ -1276,6 +1285,7 @@ if(c->umh != nil){
 		 * If omode&OEXCL is set, just give up.
 		 */
 		e.nelems++;
+		e.nerror++;
 		if(walk(&c, e.elems+e.nelems-1, 1, nomount, nil) == 0){
 			if(omode&OEXCL)
 				error(Eexist);

+ 1 - 1
sys/src/cmd/ip/ppp/ipaux.c

@@ -19,7 +19,7 @@ ptclbsum(uchar *addr, int len)
 	mdsum = 0;
 
 	x = 0;
-	if((ulong)addr & 1) {
+	if((uintptr)addr & 1) {
 		if(len) {
 			hisum += addr[0];
 			len--;

+ 4 - 4
sys/src/cmd/ip/ppp/ppp.c

@@ -2892,13 +2892,13 @@ putndb(PPP *ppp, char *net)
 	p = seprint(p, e, "ip=%I ipmask=255.255.255.255 ipgw=%I\n", ppp->local,
 			ppp->remote);
 	if(validv4(ppp->dns[0]))
-		p = seprint(p, e, "\tdns=%I", ppp->dns[0]);
+		p = seprint(p, e, "\tdns=%I\n", ppp->dns[0]);
 	if(validv4(ppp->dns[1]))
-		p = seprint(p, e, "\tdns=%I", ppp->dns[1]);
+		p = seprint(p, e, "\tdns=%I\n", ppp->dns[1]);
 	if(validv4(ppp->wins[0]))
-		p = seprint(p, e, "\twins=%I", ppp->wins[0]);
+		p = seprint(p, e, "\twins=%I\n", ppp->wins[0]);
 	if(validv4(ppp->wins[1]))
-		p = seprint(p, e, "\twins=%I", ppp->wins[1]);
+		p = seprint(p, e, "\twins=%I\n", ppp->wins[1]);
 	seprint(file, file+sizeof file, "%s/ndb", net);
 	fd = open(file, OWRITE);
 	if(fd < 0)

+ 5 - 5
sys/src/cmd/ip/pppoe.c

@@ -17,7 +17,7 @@ void execppp(int);
 int alarmed;
 int debug;
 int sessid;
-char *namesecret;
+char *keyspec;
 int primary;
 char *pppnetmtpt;
 char *acname;
@@ -32,7 +32,7 @@ int mtu = 1492;
 void
 usage(void)
 {
-	fprint(2, "usage: pppoe [-Pd] [-S srvname] [-s name:pass] [-x pppnet] ether0\n");
+	fprint(2, "usage: pppoe [-Pd] [-A acname] [-S srvname] [-k keyspec] [-m mtu] [-x pppnet] [ether0]\n");
 	exits("usage");
 }
 
@@ -73,7 +73,7 @@ main(int argc, char **argv)
 		mtu = atoi(EARGF(usage()));
 		break;
 	case 'k':
-		namesecret = EARGF(usage());
+		keyspec = EARGF(usage());
 		break;
 	case 'x':
 		pppnetmtpt = EARGF(usage());
@@ -522,9 +522,9 @@ execppp(int fd)
 		argv[argc++] = "-x";
 		argv[argc++] = pppnetmtpt;
 	}
-	if(namesecret){
+	if(keyspec){
 		argv[argc++] = "-k";
-		argv[argc++] = namesecret;
+		argv[argc++] = keyspec;
 	}
 	argv[argc] = nil;
 

+ 16 - 6
sys/src/cmd/seq.c

@@ -81,12 +81,22 @@ main(int argc, char *argv[]){
 	}
 	if(!format)
 		buildfmt();
-	for(val = min; val <= max; val += incr){
-		n = sprint(buf, format, val);
-		if(constant)
-			for(j=0; buf[j]==' '; j++)
-				buf[j] ='0';
-		write(1, buf, n);
+	if(incr > 0){
+		for(val = min; val <= max; val += incr){
+			n = sprint(buf, format, val);
+			if(constant)
+				for(j=0; buf[j]==' '; j++)
+					buf[j] ='0';
+			write(1, buf, n);
+		}
+	}else{
+		for(val = min; val >= max; val += incr){
+			n = sprint(buf, format, val);
+			if(constant)
+				for(j=0; buf[j]==' '; j++)
+					buf[j] ='0';
+			write(1, buf, n);
+		}
 	}
 	exits(0);
 }

+ 1 - 2
sys/src/cmd/spin/README

@@ -1,12 +1,11 @@
 the latest version of spin is always
 available via:
-	http://cm.bell-labs.com/cm/cs/what/spin/
+	http://spinroot.com/spin/whatispin.html
 
 to make the sources compile with the mkfile on plan 9
 the following changes were made:
 
 	omitted memory.h from spin.h
-	omitted malloc.h from ps_msc.c
 	changed /lib/cpp to /bin/cpp in main.c
 	simplified non_fatal() in main.c to remove
 	use of yychar

+ 56 - 20
sys/src/cmd/spin/dstep.c

@@ -1,14 +1,13 @@
 /***** spin: dstep.c *****/
 
-/* Copyright (c) 1991-2000 by Lucent Technologies - Bell Laboratories     */
+/* Copyright (c) 1989-2003 by Lucent Technologies, Bell Laboratories.     */
 /* All Rights Reserved.  This software is for educational purposes only.  */
-/* Permission is given to distribute this code provided that this intro-  */
-/* ductory message is not removed and no monies are exchanged.            */
-/* No guarantee is expressed or implied by the distribution of this code. */
-/* Software written by Gerard J. Holzmann as part of the book:            */
-/* `Design and Validation of Computer Protocols,' ISBN 0-13-539925-4,     */
-/* Prentice Hall, Englewood Cliffs, NJ, 07632.                            */
-/* Send bug-reports and/or questions to: gerard@research.bell-labs.com    */
+/* No guarantee whatsoever is expressed or implied by the distribution of */
+/* this code.  Permission is given to distribute this code provided that  */
+/* this introductory message is not removed and no monies are exchanged.  */
+/* Software written by Gerard J. Holzmann.  For tool documentation see:   */
+/*             http://spinroot.com/                                       */
+/* Send all bug-reports and/or questions to: bugs@spinroot.com            */
 
 #include "spin.h"
 #ifdef PC
@@ -26,7 +25,7 @@ static int	Tj=0, Jt=0, LastGoto=0;
 static int	Tojump[MAXDSTEP], Jumpto[MAXDSTEP], Special[MAXDSTEP];
 static void	putCode(FILE *, Element *, Element *, Element *, int);
 
-extern int	Pid, claimnr;
+extern int	Pid, claimnr, separate, OkBreak;
 
 static void
 Sourced(int n, int special)
@@ -57,7 +56,7 @@ Dested(int n)
 
 static void
 Mopup(FILE *fd)
-{	int i, j; extern int OkBreak;
+{	int i, j;
 
 	for (i = 0; i < Jt; i++)
 	{	for (j = 0; j < Tj; j++)
@@ -172,10 +171,21 @@ CollectGuards(FILE *fd, Element *e, int inh)
 			fprintf(fd, "(1 /* else */)");
 			break;
 		case 'R':
+			if (inh++ > 0) fprintf(fd, " || ");
+			fprintf(fd, "("); TestOnly=1;
+			putstmnt(fd, ee->n, ee->seqno);
+			fprintf(fd, ")"); TestOnly=0;
+			break;
 		case 'r':
+			if (inh++ > 0) fprintf(fd, " || ");
+			fprintf(fd, "("); TestOnly=1;
+			putstmnt(fd, ee->n, ee->seqno);
+			fprintf(fd, ")"); TestOnly=0;
+			break;
 		case 's':
 			if (inh++ > 0) fprintf(fd, " || ");
 			fprintf(fd, "("); TestOnly=1;
+/* 4.2.1 */		if (Pid != claimnr) fprintf(fd, "(boq == -1) && ");
 			putstmnt(fd, ee->n, ee->seqno);
 			fprintf(fd, ")"); TestOnly=0;
 			break;
@@ -194,7 +204,7 @@ CollectGuards(FILE *fd, Element *e, int inh)
 }
 
 int
-putcode(FILE *fd, Sequence *s, Element *nxt, int justguards, int ln)
+putcode(FILE *fd, Sequence *s, Element *nxt, int justguards, int ln, int seqno)
 {	int isg=0; char buf[64];
 
 	NextLab[0] = "continue";
@@ -203,13 +213,13 @@ putcode(FILE *fd, Sequence *s, Element *nxt, int justguards, int ln)
 	switch (s->frst->n->ntyp) {
 	case UNLESS:
 		non_fatal("'unless' inside d_step - ignored", (char *) 0);
-		return putcode(fd, s->frst->n->sl->this, nxt, 0, ln);
+		return putcode(fd, s->frst->n->sl->this, nxt, 0, ln, seqno);
 	case NON_ATOMIC:
-		(void) putcode(fd, s->frst->n->sl->this, ZE, 1, ln);
+		(void) putcode(fd, s->frst->n->sl->this, ZE, 1, ln, seqno);
 		break;
 	case IF:
 		fprintf(fd, "if (!(");
-		if (!CollectGuards(fd, s->frst, 0))
+		if (!CollectGuards(fd, s->frst, 0))	/* what about boq? */
 			fprintf(fd, "1");
 		fprintf(fd, "))\n\t\t\tcontinue;");
 		isg = 1;
@@ -224,12 +234,24 @@ putcode(FILE *fd, Sequence *s, Element *nxt, int justguards, int ln)
 		}
 		break;
 	case 'R': /* <- can't really happen (it's part of a 'c') */
+		fprintf(fd, "if (!("); TestOnly=1;
+		putstmnt(fd, s->frst->n, s->frst->seqno);
+		fprintf(fd, "))\n\t\t\tcontinue;"); TestOnly=0;
+		break;
 	case 'r':
-	case 's':
 		fprintf(fd, "if (!("); TestOnly=1;
 		putstmnt(fd, s->frst->n, s->frst->seqno);
 		fprintf(fd, "))\n\t\t\tcontinue;"); TestOnly=0;
 		break;
+	case 's':
+		fprintf(fd, "if (");
+#if 1
+/* 4.2.1 */	if (Pid != claimnr) fprintf(fd, "(boq != -1) || ");
+#endif
+		fprintf(fd, "!("); TestOnly=1;
+		putstmnt(fd, s->frst->n, s->frst->seqno);
+		fprintf(fd, "))\n\t\t\tcontinue;"); TestOnly=0;
+		break;
 	case 'c':
 		fprintf(fd, "if (!(");
 		if (Pid != claimnr) fprintf(fd, "boq == -1 && ");
@@ -237,26 +259,40 @@ putcode(FILE *fd, Sequence *s, Element *nxt, int justguards, int ln)
 		putstmnt(fd, s->frst->n->lft, s->frst->seqno);
 		fprintf(fd, "))\n\t\t\tcontinue;"); TestOnly=0;
 		break;
+	case ELSE:
+		fprintf(fd, "if (boq != -1 || (");
+		if (separate != 2) fprintf(fd, "trpt->");
+		fprintf(fd, "o_pm&1))\n\t\t\tcontinue;");
+		break;
 	case ASGN:	/* new 3.0.8 */
 		fprintf(fd, "IfNotBlocked");
 		break;
 	}
 	if (justguards) return 0;
 
-	fprintf(fd, "\n\t\tsv_save((char *)&now);\n");
-
+	fprintf(fd, "\n\t\tsv_save();\n\t\t");
+#if 1
+	fprintf(fd, "reached[%d][%d] = 1;\n\t\t", Pid, seqno);
+	fprintf(fd, "reached[%d][t->st] = 1;\n\t\t", Pid);	/* true next state */
+	fprintf(fd, "reached[%d][tt] = 1;\n", Pid);		/* true current state */
+#endif
 	sprintf(buf, "Uerror(\"block in d_step seq, line %d\")", ln);
 	NextLab[0] = buf;
 	putCode(fd, s->frst, s->extent, nxt, isg);
 
 	if (nxt)
-	{	if (FirstTime(nxt->Seqno)
+	{	extern Symbol *Fname;
+		extern int lineno;
+
+		if (FirstTime(nxt->Seqno)
 		&& (!(nxt->status & DONE2) || !(nxt->status & D_ATOM)))
 		{	fprintf(fd, "S_%.3d_0: /* 1 */\n", nxt->Seqno);
 			nxt->status |= DONE2;
 			LastGoto = 0;
 		}
 		Sourced(nxt->Seqno, 1);
+		lineno = ln;
+		Fname = nxt->n->fn;	
 		Mopup(fd);
 	}
 	unskip(s->frst->seqno);
@@ -299,7 +335,7 @@ putCode(FILE *fd, Element *f, Element *last, Element *next, int isguard)
 				if (LastGoto) break;
 				if (e->nxt)
 				{	i = target( huntele(e->nxt,
-						e->status))->Seqno;
+						e->status, -1))->Seqno;
 					fprintf(fd, "\t\tgoto S_%.3d_0;	", i);
 					fprintf(fd, "/* 'break' */\n");
 					Dested(i);
@@ -316,7 +352,7 @@ putCode(FILE *fd, Element *f, Element *last, Element *next, int isguard)
 			case GOTO:
 				if (LastGoto) break;
 				i = huntele( get_lab(e->n,1),
-					e->status)->Seqno;
+					e->status, -1)->Seqno;
 				fprintf(fd, "\t\tgoto S_%.3d_0;	", i);
 				fprintf(fd, "/* 'goto' */\n");
 				Dested(i);

+ 94 - 16
sys/src/cmd/spin/flow.c

@@ -1,14 +1,13 @@
 /***** spin: flow.c *****/
 
-/* Copyright (c) 1991-2000 by Lucent Technologies - Bell Laboratories     */
+/* Copyright (c) 1989-2003 by Lucent Technologies, Bell Laboratories.     */
 /* All Rights Reserved.  This software is for educational purposes only.  */
-/* Permission is given to distribute this code provided that this intro-  */
-/* ductory message is not removed and no monies are exchanged.            */
-/* No guarantee is expressed or implied by the distribution of this code. */
-/* Software written by Gerard J. Holzmann as part of the book:            */
-/* `Design and Validation of Computer Protocols,' ISBN 0-13-539925-4,     */
-/* Prentice Hall, Englewood Cliffs, NJ, 07632.                            */
-/* Send bug-reports and/or questions to: gerard@research.bell-labs.com    */
+/* No guarantee whatsoever is expressed or implied by the distribution of */
+/* this code.  Permission is given to distribute this code provided that  */
+/* this introductory message is not removed and no monies are exchanged.  */
+/* Software written by Gerard J. Holzmann.  For tool documentation see:   */
+/*             http://spinroot.com/                                       */
+/* Send all bug-reports and/or questions to: bugs@spinroot.com            */
 
 #include "spin.h"
 #ifdef PC
@@ -97,6 +96,7 @@ int
 is_skip(Lextok *n)
 {
 	return (n->ntyp == PRINT
+	||	n->ntyp == PRINTM
 	||	(n->ntyp == 'c'
 		&& n->lft
 		&& n->lft->ntyp == CONST
@@ -113,15 +113,19 @@ check_sequence(Sequence *s)
 	{	n = e->n;
 		if (is_skip(n) && !has_lab(e, 0))
 		{	cnt++;
-			if (cnt > 1 && n->ntyp != PRINT)
+			if (cnt > 1
+			&&  n->ntyp != PRINT
+			&&  n->ntyp != PRINTM)
 			{	if (verbose&32)
 					printf("spin: line %d %s, redundant skip\n",
 						n->ln, n->fn->name);
-				if (le)
+				if (e != s->frst
+				&&  e != s->last
+				&&  e != s->extent)
 				{	e->status |= DONE;	/* not unreachable */
 					le->nxt = e->nxt;	/* remove it */
 					e = le;
-				} /* else, can't happen */
+				}
 			}
 		} else
 			cnt = 0;
@@ -309,6 +313,45 @@ has_chanref(Lextok *n)
 	return has_chanref(n->rgt);
 }
 
+void
+loose_ends(void)	/* properly tie-up ends of sub-sequences */
+{	Element *e, *f;
+
+	for (e = Al_El; e; e = e->Nxt)
+	{	if (!e->n
+		||  !e->nxt)
+			continue;
+		switch (e->n->ntyp) {
+		case ATOMIC:
+		case NON_ATOMIC:
+		case D_STEP:
+			f = e->nxt;
+			while (f && f->n->ntyp == '.')
+				f = f->nxt;
+			if (0) printf("link %d, {%d .. %d} -> %d (ntyp=%d) was %d\n",
+				e->seqno,
+				e->n->sl->this->frst->seqno,
+				e->n->sl->this->last->seqno,
+				f?f->seqno:-1, f?f->n->ntyp:-1,
+				e->n->sl->this->last->nxt?e->n->sl->this->last->nxt->seqno:-1);
+			if (!e->n->sl->this->last->nxt)
+				e->n->sl->this->last->nxt = f;
+			else
+			{	if (e->n->sl->this->last->nxt->n->ntyp != GOTO)
+				{	if (!f || e->n->sl->this->last->nxt->seqno != f->seqno)
+					non_fatal("unexpected: loose ends", (char *)0);
+				} else
+					e->n->sl->this->last = e->n->sl->this->last->nxt;
+				/*
+				 * fix_dest can push a goto into the nxt position
+				 * in that case the goto wins and f is not needed
+				 * but the last fields needs adjusting
+				 */
+			}
+			break;
+	}	}
+}
+
 static Element *
 if_seq(Lextok *n)
 {	int	tok = n->ntyp;
@@ -547,6 +590,7 @@ get_lab(Lextok *n, int md)
 	for (l = labtab; l; l = l->nxt)
 		if (s == l->s)
 			return (l->e);
+
 	lineno = n->ln;
 	Fname = n->fn;
 	if (md) fatal("undefined label %s", s->name);
@@ -586,12 +630,19 @@ mov_lab(Symbol *z, Element *e, Element *y)
 }
 
 void
-fix_dest(Symbol *c, Symbol *a)	/* label, proctype */
+fix_dest(Symbol *c, Symbol *a)		/* c:label name, a:proctype name */
 {	Label *l; extern Symbol *context;
 
+#if 0
+	printf("ref to label '%s' in proctype '%s', search:\n",
+		c->name, a->name);
+	for (l = labtab; l; l = l->nxt)
+		printf("	%s in	%s\n", l->s->name, l->c->name);
+#endif
+
 	for (l = labtab; l; l = l->nxt)
 	{	if (strcmp(c->name, l->s->name) == 0
-		&&  strcmp(a->name, l->c->name) == 0)
+		&&  strcmp(a->name, l->c->name) == 0)	/* ? */
 			break;
 	}
 	if (!l)
@@ -622,6 +673,10 @@ fix_dest(Symbol *c, Symbol *a)	/* label, proctype */
 		l->e->nxt = y;		/* append the goto  */
 	}
 	l->e->status |= CHECK2;	/* treat as if global */
+	if (l->e->status & (ATOM | L_ATOM | D_ATOM))
+	{	non_fatal("cannot reference label inside atomic or d_step (%s)",
+			c->name);
+	}
 }
 
 int
@@ -660,10 +715,28 @@ break_dest(void)
 
 void
 make_atomic(Sequence *s, int added)
-{
+{	Element *f;
+
 	walk_atomic(s->frst, s->last, added);
-	s->last->status &= ~ATOM;
-	s->last->status |= L_ATOM;
+
+	f = s->last;
+	switch (f->n->ntyp) {	/* is last step basic stmnt or sequence ? */
+	case NON_ATOMIC:
+	case ATOMIC:
+		/* redo and search for the last step of that sequence */
+		make_atomic(f->n->sl->this, added);
+		break;
+
+	case UNLESS:
+		/* escapes are folded into main sequence */
+		make_atomic(f->sub->this, added);
+		break;
+
+	default:
+		f->status &= ~ATOM;
+		f->status |= L_ATOM;
+		break;
+	}
 }
 
 static void
@@ -699,6 +772,11 @@ mknonat:		f->n->ntyp = NON_ATOMIC; /* can jump here */
 			h = f->n->sl;
 			walk_atomic(h->this->frst, h->this->last, added);
 			break;
+		case UNLESS:
+			if (added)
+			{ printf("spin: error, line %3d %s, unless in d_step (ignored)\n",
+			 	 f->n->ln, f->n->fn->name);
+			}
 		}
 		for (h = f->sub; h; h = h->nxt)
 			walk_atomic(h->this->frst, h->this->last, added);

+ 92 - 36
sys/src/cmd/spin/guided.c

@@ -1,14 +1,13 @@
 /***** spin: guided.c *****/
 
-/* Copyright (c) 1991-2000 by Lucent Technologies - Bell Laboratories     */
+/* Copyright (c) 1989-2003 by Lucent Technologies, Bell Laboratories.     */
 /* All Rights Reserved.  This software is for educational purposes only.  */
-/* Permission is given to distribute this code provided that this intro-  */
-/* ductory message is not removed and no monies are exchanged.            */
-/* No guarantee is expressed or implied by the distribution of this code. */
-/* Software written by Gerard J. Holzmann as part of the book:            */
-/* `Design and Validation of Computer Protocols,' ISBN 0-13-539925-4,     */
-/* Prentice Hall, Englewood Cliffs, NJ, 07632.                            */
-/* Send bug-reports and/or questions to: gerard@research.bell-labs.com    */
+/* No guarantee whatsoever is expressed or implied by the distribution of */
+/* this code.  Permission is given to distribute this code provided that  */
+/* this introductory message is not removed and no monies are exchanged.  */
+/* Software written by Gerard J. Holzmann.  For tool documentation see:   */
+/*             http://spinroot.com/                                       */
+/* Send all bug-reports and/or questions to: bugs@spinroot.com            */
 
 #include "spin.h"
 #include <sys/types.h>
@@ -22,8 +21,8 @@
 extern RunList	*run, *X;
 extern Element	*Al_El;
 extern Symbol	*Fname, *oFname;
-extern int	verbose, lineno, xspin, jumpsteps, depth, merger;
-extern int	nproc, nstop, Tval, Rvous, m_loss, ntrail, columns;
+extern int	verbose, lineno, xspin, jumpsteps, depth, merger, cutoff;
+extern int	nproc, nstop, Tval, ntrail, columns;
 extern short	Have_claim, Skip_claim;
 extern void ana_src(int, int);
 
@@ -60,35 +59,74 @@ hookup(void)
 {	Element *e;
 
 	for (e = Al_El; e; e = e->Nxt)
-		if (e->n && e->n->ntyp == ATOMIC
-		||  e->n && e->n->ntyp == NON_ATOMIC
-		||  e->n && e->n->ntyp == D_STEP)
+		if (e->n
+		&& (e->n->ntyp == ATOMIC
+		||  e->n->ntyp == NON_ATOMIC
+		||  e->n->ntyp == D_STEP))
 			(void) huntstart(e);
 }
 
+int
+not_claim(void)
+{
+	return (!Have_claim || !X || X->pid != 0);
+}
+
 void
 match_trail(void)
 {	int i, a, nst;
 	Element *dothis;
-	RunList *oX;
-	char snap[256];
+	char snap[512], *q;
+
+	/*
+	 * if source model name is leader.pml
+	 * look for the trail file under these names:
+	 *	leader.pml.trail
+	 *	leader.pml.tra
+	 *	leader.trail
+	 *	leader.tra
+	 */
 
 	if (ntrail)
 		sprintf(snap, "%s%d.trail", oFname->name, ntrail);
 	else
 		sprintf(snap, "%s.trail", oFname->name);
-	if (!(fd = fopen(snap, "r")))
-	{	snap[strlen(snap)-2] = '\0';	/* .tra on some pc's */
-		if (!(fd = fopen(snap, "r")))
-		{	printf("spin: cannot find trail file\n");
+
+	if ((fd = fopen(snap, "r")) == NULL)
+	{	snap[strlen(snap)-2] = '\0';	/* .tra */
+		if ((fd = fopen(snap, "r")) == NULL)
+		{	if ((q = strchr(oFname->name, '.')) != NULL)
+			{	*q = '\0';
+				if (ntrail)
+					sprintf(snap, "%s%d.trail",
+						oFname->name, ntrail);
+				else
+					sprintf(snap, "%s.trail",
+						oFname->name);
+				*q = '.';
+
+				if ((fd = fopen(snap, "r")) != NULL)
+					goto okay;
+
+				snap[strlen(snap)-2] = '\0';	/* last try */
+				if ((fd = fopen(snap, "r")) != NULL)
+					goto okay;
+			}
+			printf("spin: cannot find trail file\n");
 			alldone(1);
 	}	}
-			
+okay:		
 	if (xspin == 0 && newer(oFname->name, snap))
 	printf("spin: warning, \"%s\" is newer than %s\n",
 		oFname->name, snap);
 
-	Tval = m_loss = 1; /* timeouts and losses may be part of trail */
+	Tval = 1;
+
+	/*
+	 * sets Tval because timeouts may be part of trail
+	 * this used to also set m_loss to 1, but that is
+	 * better handled with the runtime -m flag
+	 */
 
 	hookup();
 
@@ -104,6 +142,13 @@ match_trail(void)
 			}
 			continue;
 		}
+
+		if (cutoff > 0 && depth >= cutoff)
+		{	printf("-------------\n");
+			printf("depth-limit (-u%d steps) reached\n", cutoff);
+			break;
+		}
+
 		if (Skip_claim && pno == 0) continue;
 
 		for (dothis = Al_El; dothis; dothis = dothis->Nxt)
@@ -112,10 +157,12 @@ match_trail(void)
 		}
 		if (!dothis)
 		{	printf("%3d: proc %d, no matching stmnt %d\n",
-				depth, pno, nst);
+				depth, pno - Have_claim, nst);
 			lost_trail();
 		}
+
 		i = nproc - nstop + Skip_claim;
+
 		if (dothis->n->ntyp == '@')
 		{	if (pno == i-1)
 			{	run = run->nxt;
@@ -125,15 +172,19 @@ match_trail(void)
 					{	dotag(stdout, "<end>\n");
 						continue;
 					}
+					if (Have_claim && pno == 0)
+					printf("%3d: claim terminates\n",
+						depth);
+					else
 					printf("%3d: proc %d terminates\n",
-						depth, pno);
+						depth, pno - Have_claim);
 				}
 				continue;
 			}
 			if (pno <= 1) continue;	/* init dies before never */
 			printf("%3d: stop error, ", depth);
 			printf("proc %d (i=%d) trans %d, %c\n",
-				pno, i, nst, dothis->n->ntyp);
+				pno - Have_claim, i, nst, dothis->n->ntyp);
 			lost_trail();
 		}
 		for (X = run; X; X = X->nxt)
@@ -141,20 +192,20 @@ match_trail(void)
 				break;
 		}
 		if (!X)
-		{	printf("%3d: no process %d ", depth, pno);
+		{	printf("%3d: no process %d ", depth, pno - Have_claim);
 			printf("(state %d)\n", nst);
 			lost_trail();
 		}
 		X->pc  = dothis;
 		lineno = dothis->n->ln;
 		Fname  = dothis->n->fn;
-		oX = X;	/* a rendezvous could change it */
+
 		if (dothis->n->ntyp == D_STEP)
 		{	Element *g, *og = dothis;
 			do {
 				g = eval_sub(og);
 				if (g && depth >= jumpsteps
-				&& ((verbose&32) || (verbose&4)))
+				&& ((verbose&32) || ((verbose&4) && not_claim())))
 				{	if (columns != 2)
 					{	p_talk(og, 1);
 		
@@ -171,18 +222,19 @@ match_trail(void)
 				}
 				og = g;
 			} while (g && g != dothis->nxt);
-			X->pc = g?huntele(g, 0):g;
+			X->pc = g?huntele(g, 0, -1):g;
 		} else
 		{
-keepgoing:		X->pc = eval_sub(dothis);
-			X->pc = huntele(X->pc, 0);
-			if (dothis->merge_start)
+keepgoing:		if (dothis->merge_start)
 				a = dothis->merge_start;
 			else
 				a = dothis->merge;
 
+			X->pc = eval_sub(dothis);
+			if (X->pc) X->pc = huntele(X->pc, 0, a);
+
 			if (depth >= jumpsteps
-			&& ((verbose&32) || (verbose&4)))
+			&& ((verbose&32) || ((verbose&4) && not_claim())))	/* -v or -p */
 			{	if (columns != 2)
 				{	p_talk(dothis, 1);
 	
@@ -201,12 +253,17 @@ keepgoing:		X->pc = eval_sub(dothis);
 				if (verbose&1) dumpglobals();
 				if (verbose&2) dumplocal(X);
 				if (xspin) printf("\n");
+
+				if (!X->pc)
+				{	X->pc = dothis;
+					printf("\ttransition failed\n");
+					a = 0;	/* avoid inf loop */
+				}
 			}
 			if (a && X->pc && X->pc->seqno != a)
 			{	dothis = X->pc;
 				goto keepgoing;
-			}
-		}
+		}	}
 
 		if (Have_claim && X && X->pid == 0
 		&&  dothis && dothis->n
@@ -221,8 +278,7 @@ keepgoing:		X->pc = eval_sub(dothis);
 				printf("Never claim moves to line %d\t[", lastclaim);
 				comment(stdout, dothis->n, 0);
 				printf("]\n");
-			}
-	}	}
+	}	}	}
 	printf("spin: trail ends after %d steps\n", depth);
 	wrapup(0);
 }

+ 177 - 67
sys/src/cmd/spin/main.c

@@ -1,14 +1,13 @@
 /***** spin: main.c *****/
 
-/* Copyright (c) 1991-2000 by Lucent Technologies - Bell Laboratories     */
+/* Copyright (c) 1989-2003 by Lucent Technologies, Bell Laboratories.     */
 /* All Rights Reserved.  This software is for educational purposes only.  */
-/* Permission is given to distribute this code provided that this intro-  */
-/* ductory message is not removed and no monies are exchanged.            */
-/* No guarantee is expressed or implied by the distribution of this code. */
-/* Software written by Gerard J. Holzmann as part of the book:            */
-/* `Design and Validation of Computer Protocols,' ISBN 0-13-539925-4,     */
-/* Prentice Hall, Englewood Cliffs, NJ, 07632.                            */
-/* Send bug-reports and/or questions to: gerard@research.bell-labs.com    */
+/* No guarantee whatsoever is expressed or implied by the distribution of */
+/* this code.  Permission is given to distribute this code provided that  */
+/* this introductory message is not removed and no monies are exchanged.  */
+/* Software written by Gerard J. Holzmann.  For tool documentation see:   */
+/*             http://spinroot.com/                                       */
+/* Send all bug-reports and/or questions to: bugs@spinroot.com            */
 
 #include <stdlib.h>
 #include "spin.h"
@@ -19,6 +18,9 @@
 #ifdef PC
 #include <io.h>
 #include "y_tab.h"
+
+extern int unlink(const char *);
+
 #else
 #include <unistd.h>
 #include "y.tab.h"
@@ -28,18 +30,26 @@ extern int	DstepStart, lineno, tl_terse;
 extern FILE	*yyin, *yyout, *tl_out;
 extern Symbol	*context;
 extern char	*claimproc;
+extern void	repro_src(void);
 extern void	qhide(int);
 
 Symbol	*Fname, *oFname;
 
-int	Etimeouts=0;	/* nr timeouts in program */
-int	Ntimeouts=0;	/* nr timeouts in never claim */
-int	analyze=0, columns=0, dumptab=0, has_remote=0;
-int	interactive=0, jumpsteps=0, m_loss=0, nr_errs=0;
-int	s_trail=0, ntrail=0, verbose=0, xspin=0, no_print=0, no_wrapup = 0, Caccess=0;
-int	limited_vis=0, like_java=0;
-int	dataflow = 1, merger = 1, deadvar = 1, rvopt = 0, ccache = 1;
-int	separate = 0;	/* separate compilation option */
+int	Etimeouts;	/* nr timeouts in program */
+int	Ntimeouts;	/* nr timeouts in never claim */
+int	analyze, columns, dumptab, has_remote, has_remvar;
+int	interactive, jumpsteps, m_loss, nr_errs, cutoff;
+int	s_trail, ntrail, verbose, xspin, notabs, rvopt;
+int	no_print, no_wrapup, Caccess, limited_vis, like_java;
+int	separate;	/* separate compilation */
+int	export_ast;	/* pangen5.c */
+int	inlineonly;	/* show inlined code */
+int	seedy;		/* be verbose about chosen seed */
+
+int	dataflow = 1, merger = 1, deadvar = 1, ccache = 1;
+
+static int preprocessonly, SeedUsed;
+
 #if 0
 meaning of flags on verbose:
 	1	-g global variable values
@@ -51,8 +61,6 @@ meaning of flags on verbose:
 	64	-w very verbose
 #endif
 
-static Element	*Same;
-static int	IsAsgn = 0, OrIsAsgn = 0;
 static char	Operator[] = "operator: ";
 static char	Keyword[]  = "keyword: ";
 static char	Function[] = "function-name: ";
@@ -68,27 +76,35 @@ static void	explain(int);
 		/* OS2:		"spin -Picc -E/Pd+ -E/Q+"    */
 		/* Visual C++:	"spin -PCL  -E/E             */
 #ifdef PC
-#define CPP	"cpp"		/*  or specify a full path    */
+#define CPP	"gcc -E -x c"	/* most systems have gcc anyway */
+				/* else use "cpp" */
 #else
 #ifdef SOLARIS
 #define CPP	"/usr/ccs/lib/cpp"
 #else
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__OpenBSD__)
 #define CPP	"cpp"
 #else
-#define CPP	"/bin/cpp"
+#define CPP	"/bin/cpp"	/* classic Unix systems */
 #endif
 #endif
 #endif
 
 #endif
 static char	*PreProc = CPP;
+extern int	depth; /* at least some steps were made */
 
 void
 alldone(int estatus)
 {
-	if (strlen(out1) > 0)
+	if (preprocessonly == 0
+	&&  strlen(out1) > 0)
 		(void) unlink((const char *)out1);
+
+	if (seedy && !analyze && !export_ast
+	&& !s_trail && !preprocessonly && depth > 0)
+		printf("seed used: %d\n", SeedUsed);
+
 	if (xspin && (analyze || s_trail))
 	{	if (estatus)
 			printf("spin: %d error(s) - aborting\n",
@@ -101,10 +117,10 @@ alldone(int estatus)
 
 void
 preprocess(char *a, char *b, int a_tmp)
-{	char precmd[128], cmd[256]; int i;
+{	char precmd[512], cmd[1024]; int i;
 #ifdef PC
 	extern int try_zpp(char *, char *);
-	if (try_zpp(a, b)) goto out;
+	if (PreCnt == 0 && try_zpp(a, b)) goto out;
 #endif
 	strcpy(precmd, PreProc);
 	for (i = 1; i <= PreCnt; i++)
@@ -115,9 +131,13 @@ preprocess(char *a, char *b, int a_tmp)
 	if (system((const char *)cmd))
 	{	(void) unlink((const char *) b);
 		if (a_tmp) (void) unlink((const char *) a);
-		alldone(1); /* failed */
+		fprintf(stdout, "spin: preprocessing failed\n");	/* 4.1.2 was stderr */
+		alldone(1); /* no return, error exit */
 	}
-out:	if (a_tmp) (void) unlink((const char *) a);
+#ifdef PC
+out:
+#endif
+	if (a_tmp) (void) unlink((const char *) a);
 }
 
 FILE *
@@ -142,10 +162,11 @@ usage(void)
 {
 	printf("use: spin [-option] ... [-option] file\n");
 	printf("\tNote: file must always be the last argument\n");
+	printf("\t-A apply slicing algorithm\n");
 	printf("\t-a generate a verifier in pan.c\n");
 	printf("\t-B no final state details in simulations\n");
 	printf("\t-b don't execute printfs in simulation\n");
-	printf("\t-C print channel access info (structview)\n");
+	printf("\t-C print channel access info (combine with -g etc.)\n");
 	printf("\t-c columnated -s -r simulation output\n");
 	printf("\t-d produce symbol-table information\n");
 	printf("\t-Dyyy pass -Dyyy to the preprocessor\n");
@@ -155,7 +176,9 @@ usage(void)
 	printf("\t-F file  like -f, but with the LTL ");
 	printf("formula stored in a 1-line file\n");
 	printf("\t-g print all global variables\n");
+	printf("\t-h  at end of run, print value of seed for random nr generator used\n");
 	printf("\t-i interactive (random simulation)\n");
+	printf("\t-I show result of inlining and preprocessing\n");
 	printf("\t-J reverse eval order of nested unlesses\n");
 	printf("\t-jN skip the first N steps ");
 	printf("in simulation trail\n");
@@ -165,16 +188,20 @@ usage(void)
 	printf("\t-N file use never claim stored in file\n");
 	printf("\t-nN seed for random nr generator\n");
 	printf("\t-o1 turn off dataflow-optimizations in verifier\n");
-	printf("\t-o2 turn off dead variables elimination in verifier\n");
+	printf("\t-o2 don't hide write-only variables in verifier\n");
 	printf("\t-o3 turn off statement merging in verifier\n");
 	printf("\t-Pxxx use xxx for preprocessing\n");
 	printf("\t-p print all statements\n");
 	printf("\t-qN suppress io for queue N in printouts\n");
 	printf("\t-r print receive events\n");
+	printf("\t-S1 and -S2 separate pan source for claim and model\n");
 	printf("\t-s print send events\n");
+	printf("\t-T do not indent printf output\n");
+	printf("\t-t[N] follow [Nth] simulation trail\n");
+	printf("\t-Uyyy pass -Uyyy to the preprocessor\n");
+	printf("\t-uN stop a simulation run after N steps\n");
 	printf("\t-v verbose, more warnings\n");
 	printf("\t-w very verbose (when combined with -l or -g)\n");
-	printf("\t-t[N] follow [Nth] simulation trail\n");
 	printf("\t-[XYZ] reserved for use by xspin interface\n");
 	printf("\t-V print version number and exit\n");
 	alldone(1);
@@ -226,9 +253,34 @@ optimizations(char nr)
 	}
 }
 
+#if 0
+static int
+Rename(const char *old, char *new)
+{	FILE *fo, *fn;
+	char buf[1024];
+
+	if ((fo = fopen(old, "r")) == NULL)
+	{	printf("spin: cannot open %s\n", old);
+		return 1;
+	}
+	if ((fn = fopen(new, "w")) == NULL)
+	{	printf("spin: cannot create %s\n", new);
+		fclose(fo);
+		return 2;
+	}
+	while (fgets(buf, 1024, fo))
+		fputs(buf, fn);
+
+	fclose(fo);
+	fclose(fn);
+
+	return 0;	/* success */
+}
+#endif
+
 int
 main(int argc, char *argv[])
-{	Symbol *s; int preprocessonly = 0;
+{	Symbol *s;
 	int T = (int) time((time_t *)0);
 	int usedopts = 0;
 	extern void ana_src(int, int);
@@ -244,14 +296,15 @@ main(int argc, char *argv[])
 		/* generate code for separate compilation: S1 or S2 */
 		case 'S': separate = atoi(&argv[1][2]);
 			  /* fall through */
-
 		case 'a': analyze  = 1; break;
+
+		case 'A': export_ast = 1; break;
 		case 'B': no_wrapup = 1; break;
 		case 'b': no_print = 1; break;
 		case 'C': Caccess = 1; break;
 		case 'c': columns = 1; break;
 		case 'D': PreArg[++PreCnt] = (char *) &argv[1][0];
-			  break;
+			  break;	/* define */
 		case 'd': dumptab =  1; break;
 		case 'E': PreArg[++PreCnt] = (char *) &argv[1][2];
 			  break;
@@ -260,7 +313,9 @@ main(int argc, char *argv[])
 		case 'f': add_ltl = (char **) argv;
 			  argc--; argv++; break;
 		case 'g': verbose +=  1; break;
+		case 'h': seedy = 1; break;
 		case 'i': interactive = 1; break;
+		case 'I': inlineonly = 1; break;
 		case 'J': like_java = 1; break;
 		case 'j': jumpsteps = atoi(&argv[1][2]); break;
 		case 'l': verbose +=  2; break;
@@ -278,16 +333,20 @@ main(int argc, char *argv[])
 			  break;
 		case 'r': verbose +=  8; break;
 		case 's': verbose += 16; break;
+		case 'T': notabs = 1; break;
 		case 't': s_trail  =  1;
 			  if (isdigit(argv[1][2]))
 				ntrail = atoi(&argv[1][2]);
 			  break;
+		case 'U': PreArg[++PreCnt] = (char *) &argv[1][0];
+			  break;	/* undefine */
+		case 'u': cutoff = atoi(&argv[1][2]); break;	/* new 3.4.14 */
 		case 'v': verbose += 32; break;
 		case 'V': printf("%s\n", Version);
 			  alldone(0);
 			  break;
 		case 'w': verbose += 64; break;
-		case 'X': xspin = 1;
+		case 'X': xspin = notabs = 1;
 #ifndef PC
 			  signal(SIGPIPE, alldone); /* not posix... */
 #endif
@@ -316,20 +375,13 @@ main(int argc, char *argv[])
 	}
 	if (argc > 1)
 	{	char cmd[128], out2[64];
-#ifdef PC
-		strcpy(out1, "_tmp1_");
-		strcpy(out2, "_tmp2_");
-#else
-		/* extern char *tmpnam(char *);  in stdio.h */
+
+		/* must remain in current dir */
+		strcpy(out1, "pan.pre");
+
 		if (add_ltl || nvr_file)
-		{	/* must remain in current dir */
-			strcpy(out1, "_tmp1_");
-			strcpy(out2, "_tmp2_");
-		} else
-		{	(void) tmpnam(out1);
-			(void) tmpnam(out2);
-		}
-#endif
+			strcpy(out2, "pan.___");
+
 		if (add_ltl)
 		{	tl_out = cpyfile(argv[1], out2);
 			nr_errs = tl_main(2, add_ltl);	/* in tl_main.c */
@@ -353,13 +405,8 @@ main(int argc, char *argv[])
 			preprocess(argv[1], out1, 0);
 
 		if (preprocessonly)
-		{	(void) unlink("pan.pre"); /* remove old version */
-			if (rename((const char *) out1, "pan.pre") != 0)
-			{	printf("spin: rename %s failed\n", out1);
-				alldone(1);
-			}
 			alldone(0);
-		}
+
 		if (!(yyin = fopen(out1, "r")))
 		{	printf("spin: cannot open %s\n", out1);
 			alldone(1);
@@ -372,7 +419,7 @@ main(int argc, char *argv[])
 			strcpy(cmd, argv[1]);
 		oFname = Fname = lookup(cmd);
 		if (oFname->name[0] == '\"')
-		{	int i = strlen(oFname->name);
+		{	int i = (int) strlen(oFname->name);
 			oFname->name[i-1] = '\0';
 			oFname = lookup(&oFname->name[1]);
 		}
@@ -401,19 +448,30 @@ main(int argc, char *argv[])
 	if (columns == 2 && limited_vis)
 		verbose += (1+4);
 	Srand(T);	/* defined in run.c */
-	s = lookup("_");	s->type = PREDEF; /* a write only global var */
+	SeedUsed = T;
+	s = lookup("_");	s->type = PREDEF; /* write-only global var */
 	s = lookup("_p");	s->type = PREDEF;
 	s = lookup("_pid");	s->type = PREDEF;
 	s = lookup("_last");	s->type = PREDEF;
 	s = lookup("_nr_pr");	s->type = PREDEF; /* new 3.3.10 */
+
 	yyparse();
 	fclose(yyin);
+	loose_ends();
+
+	if (inlineonly)
+	{	repro_src();
+		return 0;
+	}
+
 	chanaccess();
-	if (!s_trail && (dataflow || merger))
-		ana_src(dataflow, merger);
-	sched();
-	alldone(nr_errs);
-	return 0;	/* can't get here */
+	if (!Caccess)
+	{	if (!s_trail && (dataflow || merger))
+			ana_src(dataflow, merger);
+		sched();
+		alldone(nr_errs);
+	}
+	return 0;
 }
 
 int
@@ -463,7 +521,7 @@ emalloc(int n)
 }
 
 void
-trapwonly(Lextok *n, char *s)
+trapwonly(Lextok *n, char *unused)
 {	extern int realread;
 	short i = (n->sym)?n->sym->type:0;
 
@@ -502,6 +560,7 @@ setaccess(Symbol *sp, Symbol *what, int cnt, int t)
 Lextok *
 nn(Lextok *s, int t, Lextok *ll, Lextok *rl)
 {	Lextok *n = (Lextok *) emalloc(sizeof(Lextok));
+	static int warn_nn = 0;
 
 	n->ntyp = (short) t;
 	if (s && s->fn)
@@ -558,6 +617,9 @@ nn(Lextok *s, int t, Lextok *ll, Lextok *rl)
 			}	}
 			forbidden = 0;
 			break;
+		case 'c':
+			AST_track(n, 0);	/* register as a slice criterion */
+			/* fall thru */
 		default:
 			forbidden = 0;
 			break;
@@ -566,27 +628,62 @@ nn(Lextok *s, int t, Lextok *ll, Lextok *rl)
 		{	printf("spin: never, saw "); explain(t); printf("\n");
 			fatal("incompatible with separate compilation",(char *)0);
 		}
-	} else if (t == ENABLED || t == PC_VAL)
-	{	printf("spin: Warning, using %s outside never-claim\n",
+	} else if ((t == ENABLED || t == PC_VAL) && !(warn_nn&t))
+	{	printf("spin: Warning, using %s outside never claim\n",
 			(t == ENABLED)?"enabled()":"pc_value()");
+		warn_nn |= t;
 	} else if (t == NONPROGRESS)
-	{	fatal("spin: Error, using np_ outside never-claim\n", (char *)0);
+	{	fatal("spin: Error, using np_ outside never claim\n", (char *)0);
 	}
 	return n;
 }
 
 Lextok *
-rem_lab(Symbol *a, Lextok *b, Symbol *c)
+rem_lab(Symbol *a, Lextok *b, Symbol *c)	/* proctype name, pid, label name */
 {	Lextok *tmp1, *tmp2, *tmp3;
 
 	has_remote++;
-	fix_dest(c, a);	/* in case target is jump */
+	c->type = LABEL;	/* refered to in global context here */
+	fix_dest(c, a);		/* in case target of rem_lab is jump */
 	tmp1 = nn(ZN, '?',   b, ZN); tmp1->sym = a;
 	tmp1 = nn(ZN, 'p', tmp1, ZN);
 	tmp1->sym = lookup("_p");
 	tmp2 = nn(ZN, NAME,  ZN, ZN); tmp2->sym = a;
 	tmp3 = nn(ZN, 'q', tmp2, ZN); tmp3->sym = c;
 	return nn(ZN, EQ, tmp1, tmp3);
+#if 0
+	      .---------------EQ-------.
+	     /                          \
+	   'p' -sym-> _p               'q' -sym-> c (label name)
+	   /                           /
+	 '?' -sym-> a (proctype)     NAME -sym-> a (proctype name)
+	 / 
+	b (pid expr)
+#endif
+}
+
+Lextok *
+rem_var(Symbol *a, Lextok *b, Symbol *c, Lextok *ndx)
+{	Lextok *tmp1;
+
+	has_remote++;
+	has_remvar++;
+	dataflow = 0;	/* turn off dead variable resets 4.2.5 */
+	tmp1 = nn(ZN, '?', b, ZN); tmp1->sym = a;
+	tmp1 = nn(ZN, 'p', tmp1, ndx);
+	tmp1->sym = c;
+	return tmp1;
+#if 0
+	cannot refer to struct elements
+	only to scalars and arrays
+
+	    'p' -sym-> c (variable name)
+	    / \______  possible arrayindex on c
+	   /
+	 '?' -sym-> a (proctype)
+	 / 
+	b (pid expr)
+#endif
 }
 
 static void
@@ -594,8 +691,8 @@ explain(int n)
 {	FILE *fd = stdout;
 	switch (n) {
 	default:	if (n > 0 && n < 256)
-				fprintf(fd, "%c' = '", n);
-			fprintf(fd, "%d", n);
+				fprintf(fd, "'%c' = '", n);
+			fprintf(fd, "%d'", n);
 			break;
 	case '\b':	fprintf(fd, "\\b"); break;
 	case '\t':	fprintf(fd, "\\t"); break;
@@ -614,10 +711,16 @@ explain(int n)
 	case ASSERT:	fprintf(fd, "%sassert",	Function); break;
 	case ATOMIC:	fprintf(fd, "%satomic",	Keyword); break;
 	case BREAK:	fprintf(fd, "%sbreak",	Keyword); break;
+	case C_CODE:	fprintf(fd, "%sc_code",	Keyword); break;
+	case C_DECL:	fprintf(fd, "%sc_decl",	Keyword); break;
+	case C_EXPR:	fprintf(fd, "%sc_expr",	Keyword); break;
+	case C_STATE:	fprintf(fd, "%sc_state",Keyword); break;
+	case C_TRACK:	fprintf(fd, "%sc_track",Keyword); break;
 	case CLAIM:	fprintf(fd, "%snever",	Keyword); break;
 	case CONST:	fprintf(fd, "a constant"); break;
 	case DECR:	fprintf(fd, "%s--",	Operator); break;
 	case D_STEP:	fprintf(fd, "%sd_step",	Keyword); break;
+	case D_PROCTYPE: fprintf(fd, "%sd_proctype", Keyword); break;
 	case DO:	fprintf(fd, "%sdo",	Keyword); break;
 	case DOT:	fprintf(fd, "."); break;
 	case ELSE:	fprintf(fd, "%selse",	Keyword); break;
@@ -630,11 +733,13 @@ explain(int n)
 	case GE:	fprintf(fd, "%s>=",	Operator); break;
 	case GOTO:	fprintf(fd, "%sgoto",	Keyword); break;
 	case GT:	fprintf(fd, "%s>",	Operator); break;
+	case HIDDEN:	fprintf(fd, "%shidden",	Keyword); break;
 	case IF:	fprintf(fd, "%sif",	Keyword); break;
 	case INCR:	fprintf(fd, "%s++",	Operator); break;
 	case INAME:	fprintf(fd, "inline name"); break;
 	case INLINE:	fprintf(fd, "%sinline",	Keyword); break;
 	case INIT:	fprintf(fd, "%sinit",	Keyword); break;
+	case ISLOCAL:	fprintf(fd, "%slocal",  Keyword); break;
 	case LABEL:	fprintf(fd, "a label-name"); break;
 	case LE:	fprintf(fd, "%s<=",	Operator); break;
 	case LEN:	fprintf(fd, "%slen",	Function); break;
@@ -655,15 +760,20 @@ explain(int n)
 	case PC_VAL:	fprintf(fd, "%spc_value",Function); break;
 	case PNAME:	fprintf(fd, "process name"); break;
 	case PRINT:	fprintf(fd, "%sprintf",	Function); break;
+	case PRINTM:	fprintf(fd, "%sprintm",	Function); break;
+	case PRIORITY:	fprintf(fd, "%spriority", Keyword); break;
 	case PROCTYPE:	fprintf(fd, "%sproctype",Keyword); break;
+	case PROVIDED:	fprintf(fd, "%sprovided",Keyword); break;
 	case RCV:	fprintf(fd, "%s?",	Operator); break;
 	case R_RCV:	fprintf(fd, "%s??",	Operator); break;
 	case RSHIFT:	fprintf(fd, "%s>>",	Operator); break;
 	case RUN:	fprintf(fd, "%srun",	Operator); break;
 	case SEP:	fprintf(fd, "token: ::"); break;
 	case SEMI:	fprintf(fd, ";"); break;
+	case SHOW:	fprintf(fd, "%sshow", Keyword); break;
 	case SND:	fprintf(fd, "%s!",	Operator); break;
 	case STRING:	fprintf(fd, "a string"); break;
+	case TRACE:	fprintf(fd, "%strace", Keyword); break;
 	case TIMEOUT:	fprintf(fd, "%stimeout",Keyword); break;
 	case TYPE:	fprintf(fd, "data typename"); break;
 	case TYPEDEF:	fprintf(fd, "%stypedef",Keyword); break;

+ 28 - 15
sys/src/cmd/spin/mesg.c

@@ -1,14 +1,13 @@
 /***** spin: mesg.c *****/
 
-/* Copyright (c) 1991-2000 by Lucent Technologies - Bell Laboratories     */
+/* Copyright (c) 1989-2003 by Lucent Technologies, Bell Laboratories.     */
 /* All Rights Reserved.  This software is for educational purposes only.  */
-/* Permission is given to distribute this code provided that this intro-  */
-/* ductory message is not removed and no monies are exchanged.            */
-/* No guarantee is expressed or implied by the distribution of this code. */
-/* Software written by Gerard J. Holzmann as part of the book:            */
-/* `Design and Validation of Computer Protocols,' ISBN 0-13-539925-4,     */
-/* Prentice Hall, Englewood Cliffs, NJ, 07632.                            */
-/* Send bug-reports and/or questions to: gerard@research.bell-labs.com    */
+/* No guarantee whatsoever is expressed or implied by the distribution of */
+/* this code.  Permission is given to distribute this code provided that  */
+/* this introductory message is not removed and no monies are exchanged.  */
+/* Software written by Gerard J. Holzmann.  For tool documentation see:   */
+/*             http://spinroot.com/                                       */
+/* Send all bug-reports and/or questions to: bugs@spinroot.com            */
 
 #include "spin.h"
 #ifdef PC
@@ -17,7 +16,9 @@
 #include "y.tab.h"
 #endif
 
+#ifndef MAXQ
 #define MAXQ	2500		/* default max # queues  */
+#endif
 
 extern RunList	*X;
 extern Symbol	*Fname;
@@ -58,7 +59,7 @@ int
 qmake(Symbol *s)
 {	Lextok *m;
 	Queue *q;
-	int i; extern int analyze;
+	int i;
 
 	if (!s->ini)
 		return 0;
@@ -370,10 +371,13 @@ s_snd(Queue *q, Lextok *n)
 				||  strcmp(m->lft->sym->name, "_") != 0)
 					i = eval(m->lft);
 				else	i = 0;
+
+				if (verbose&8)
 				sr_talk(n_rem,i,"Recv ","<-",j,q_rem);
 			}
+			if (verbose&8)
 			for (i = j; i < q->nflds; i++)
-			sr_talk(n_rem, 0, "Recv ", "<-", j, q_rem);
+				sr_talk(n_rem, 0, "Recv ", "<-", j, q_rem);
 			if (columns == 2)
 				putarrow(depth, depth);
 		}
@@ -385,7 +389,7 @@ s_snd(Queue *q, Lextok *n)
 
 void
 channm(Lextok *n)
-{	char lbuf[256];
+{	char lbuf[512];
 
 	if (n->sym->type == CHAN)
 		strcat(Buf, n->sym->name);
@@ -397,6 +401,7 @@ channm(Lextok *n)
 			r = findloc(r);
 		ini_struct(r);
 		printf("%s", r->name);
+		strcpy(lbuf, "");
 		struct_name(n->lft, r, 1, lbuf);
 		strcat(Buf, lbuf);
 	} else
@@ -409,8 +414,7 @@ channm(Lextok *n)
 
 static void
 difcolumns(Lextok *n, char *tr, int v, int j, Queue *q)
-{	int cnt = 1; extern int pno;
-	Lextok *nn = ZN;
+{	extern int pno;
 
 	if (j == 0)
 	{	Buf[0] = '\0';
@@ -534,7 +538,7 @@ sr_talk(Lextok *n, int v, char *tr, char *a, int j, Queue *q)
 void
 sr_buf(int v, int j)
 {	int cnt = 1; Lextok *n;
-	char lbuf[128];
+	char lbuf[256];
 
 	for (n = Mtype; n && j; n = n->rgt, cnt++)
 		if (cnt == v)
@@ -594,7 +598,16 @@ nochan_manip(Lextok *p, Lextok *n, int d)
 {	int e = 1;
 
 	if (d == 0 && p->sym && p->sym->type == CHAN)
-		setaccess(p->sym, ZS, 0, 'L');
+	{	setaccess(p->sym, ZS, 0, 'L');
+
+		if (n && n->ntyp == CONST)
+			fatal("invalid asgn to chan", (char *) 0);
+
+		if (n && n->sym && n->sym->type == CHAN)
+		{	setaccess(n->sym, ZS, 0, 'V');
+			return;
+		}	
+	}
 
 	if (!n || n->ntyp == LEN || n->ntyp == RUN)
 		return;

+ 2 - 0
sys/src/cmd/spin/mkfile

@@ -13,8 +13,10 @@ SPIN_OS=\
 	pangen3.$O\
 	pangen4.$O\
 	pangen5.$O\
+	pangen6.$O\
 	pc_zpp.$O\
 	ps_msc.$O\
+	reprosrc.$O\
 	run.$O\
 	sched.$O\
 	spinlex.$O\

+ 344 - 103
sys/src/cmd/spin/pangen1.c

@@ -1,14 +1,13 @@
 /***** spin: pangen1.c *****/
 
-/* Copyright (c) 1991-2000 by Lucent Technologies - Bell Laboratories     */
+/* Copyright (c) 1989-2003 by Lucent Technologies, Bell Laboratories.     */
 /* All Rights Reserved.  This software is for educational purposes only.  */
-/* Permission is given to distribute this code provided that this intro-  */
-/* ductory message is not removed and no monies are exchanged.            */
-/* No guarantee is expressed or implied by the distribution of this code. */
-/* Software written by Gerard J. Holzmann as part of the book:            */
-/* `Design and Validation of Computer Protocols,' ISBN 0-13-539925-4,     */
-/* Prentice Hall, Englewood Cliffs, NJ, 07632.                            */
-/* Send bug-reports and/or questions to: gerard@research.bell-labs.com    */
+/* No guarantee whatsoever is expressed or implied by the distribution of */
+/* this code.  Permission is given to distribute this code provided that  */
+/* this introductory message is not removed and no monies are exchanged.  */
+/* Software written by Gerard J. Holzmann.  For tool documentation see:   */
+/*             http://spinroot.com/                                       */
+/* Send all bug-reports and/or questions to: bugs@spinroot.com            */
 
 #include "spin.h"
 #ifdef PC
@@ -29,7 +28,9 @@ extern int	lineno, verbose, Pid, separate;
 extern int	nrRdy, nqs, mst, Mpars, claimnr, eventmapnr;
 extern short	has_sorted, has_random, has_provided;
 
-int	Npars=0, u_sync=0, u_async=0;
+int	Npars=0, u_sync=0, u_async=0, hastrack = 1;
+short	has_io = 0;
+short	has_state=0;	/* code contains c_state */
 
 static Symbol	*LstSet=ZS;
 static int	acceptors=0, progressors=0, nBits=0;
@@ -56,7 +57,10 @@ void
 genheader(void)
 {	ProcList *p; int i;
 
-	if (separate == 2) goto here;
+	if (separate == 2)
+	{	putunames(th);
+		goto here;
+	}
 
 	fprintf(th, "#define SYNC	%d\n", u_sync);
 	fprintf(th, "#define ASYNC	%d\n\n", u_async);
@@ -82,29 +86,39 @@ here:
 
 	ntimes(th, 0, 1, Head0);
 
-	if (separate == 2)
-	{	ntimes(th, 0, 1, Head1);
-		LstSet = ZS;
-		(void) doglobal("", PUTV);
-		fprintf(th, "	uchar sv[VECTORSZ];\n");
-		fprintf(th, "} State;\n\n");
-	} else
-	{
+	if (separate != 2)
+	{	extern void c_add_stack(FILE *);
+
 		ntimes(th, 0, 1, Header);
-		ntimes(th, 0, 1, Head1);
+		c_add_stack(th);
+		ntimes(th, 0, 1, Header0);
+	}
+	ntimes(th, 0, 1, Head1);
 
-		LstSet = ZS;
-		(void) doglobal("", PUTV);
-		fprintf(th, "	uchar sv[VECTORSZ];\n");
-		fprintf(th, "} State;\n\n");
+	LstSet = ZS;
+	(void) doglobal("", PUTV);
+
+	hastrack = c_add_sv(th);
+
+	fprintf(th, "	uchar sv[VECTORSZ];\n");
+	fprintf(th, "} State");
+#ifdef SOLARIS
+	fprintf(th,"\n#ifdef GCC\n");
+	fprintf(th, "\t__attribute__ ((aligned(8)))");
+	fprintf(th, "\n#endif\n\t");
+#endif
+	fprintf(th, ";\n\n");
+
+	fprintf(th, "#define HAS_TRACK	%d\n", hastrack);
+
+	if (separate != 2)
 		dohidden();
-	}
 }
 
 void
 genaddproc(void)
 {	ProcList *p;
-	int i;
+	int i = 0;
 
 	if (separate ==2) goto shortcut;
 
@@ -117,7 +131,7 @@ genaddproc(void)
 	ntimes(tc, 0, 1, Addp1);
 
 	if (has_provided)
-	{	fprintf(tt, "\nint\nprovided(int II, int ot, ");
+	{	fprintf(tt, "\nint\nprovided(int II, unsigned char ot, ");
 		fprintf(tt, "int tt, Trans *t)\n");
 		fprintf(tt, "{\n\tswitch(ot) {\n");
 	}
@@ -143,6 +157,14 @@ shortcut:
 	ntimes(tc, 0, 1, R8a);
 }
 
+void
+do_locinits(FILE *fd)
+{	ProcList *p;
+
+	for (p = rdy; p; p = p->nxt)
+		c_add_locinit(fd, p->tn, p->n->name);
+}
+
 void
 genother(void)
 {	ProcList *p;
@@ -190,7 +212,9 @@ genother(void)
 	ntimes(th, nrRdy+1, nrRdy+2, R2); /* +1 for np_ */
 
 	fprintf(tc, "	iniglobals();\n");
-	ntimes(tc, 0,     1, Code2);
+	ntimes(tc, 0,     1, Code2a);
+	ntimes(tc, 0,     1, Code2b);	/* bfs option */
+	ntimes(tc, 0,     1, Code2c);
 	ntimes(tc, 0,     nrRdy, R4);
 	fprintf(tc, "}\n\n");
 
@@ -245,7 +269,7 @@ end_labs(Symbol *s, int i)
 					ln[j].s);
 				goto complain;
 			}
-			if (l->e->status & ATOM)
+			if (j > 0 && (l->e->status & ATOM))
 			{	sprintf(foo, "%s label inside atomic",
 					ln[j].s);
 		complain:	lineno = l->e->n->ln;
@@ -317,7 +341,7 @@ checktype(Symbol *sp, char *s)
 	} else if (!(sp->hidden&4))
 	{	if (!(verbose&32)) return;
 		sputtype(buf, sp->type);
-		i = strlen(buf);
+		i = (int) strlen(buf);
 		while (buf[--i] == ' ') buf[i] = '\0';
 		prehint(sp);
 		if (sp->context)
@@ -329,7 +353,7 @@ checktype(Symbol *sp, char *s)
 	} else if (sp->type != BYTE && !(sp->hidden&8))
 	{	if (!(verbose&32)) return;
 		sputtype(buf, sp->type);
-		i = strlen(buf);
+		i = (int) strlen(buf);
 		while (buf[--i] == ' ') buf[i] = '\0';
 		prehint(sp);
 		if (sp->context)
@@ -342,7 +366,7 @@ checktype(Symbol *sp, char *s)
 }
 
 int
-dolocal(FILE *ofd, char *pre, int dowhat, int p, char *s, char *how)
+dolocal(FILE *ofd, char *pre, int dowhat, int p, char *s)
 {	int h, j, k=0; extern int nr_errs;
 	Ordered *walk;
 	Symbol *sp;
@@ -364,7 +388,7 @@ dolocal(FILE *ofd, char *pre, int dowhat, int p, char *s, char *how)
 					break;
 				sprintf(buf, "%s%s:", pre, s);
 				{ sprintf(buf2, "\", ((P%d *)pptr(h))->", p);
-				  sprintf(buf3, ");\n", p);
+				  sprintf(buf3, ");\n");
 				}
 				do_var(ofd, dowhat, "", sp, buf, buf2, buf3);
 				break;
@@ -385,6 +409,160 @@ dolocal(FILE *ofd, char *pre, int dowhat, int p, char *s, char *how)
 	return k;
 }
 
+void
+c_chandump(FILE *fd)
+{	Queue *q;
+	char buf[256];
+	int i;
+
+	if (!qtab)
+	{	fprintf(fd, "void\nc_chandump(int unused) ");
+		fprintf(fd, "{ unused = unused++; /* avoid complaints */ }\n");
+		return;
+	}
+
+	fprintf(fd, "void\nc_chandump(int from)\n");
+	fprintf(fd, "{	uchar *z; int slot;\n");
+
+	fprintf(fd, "	from--;\n");
+	fprintf(fd, "	if (from >= (int) now._nr_qs || from < 0)\n");
+	fprintf(fd, "	{	printf(\"pan: bad qid %%d\\n\", from+1);\n");
+	fprintf(fd, "		return;\n");
+	fprintf(fd, "	}\n");
+	fprintf(fd, "	z = qptr(from);\n");
+	fprintf(fd, "	switch (((Q0 *)z)->_t) {\n");
+
+	for (q = qtab; q; q = q->nxt)
+	{	fprintf(fd, "	case %d:\n\t\t", q->qid);
+		sprintf(buf, "((Q%d *)z)->", q->qid);
+
+		fprintf(fd, "for (slot = 0; slot < %sQlen; slot++)\n\t\t", buf);
+		fprintf(fd, "{	printf(\" [\");\n\t\t");
+		for (i = 0; i < q->nflds; i++)
+		{	if (q->fld_width[i] == MTYPE)
+			{	fprintf(fd, "\tprintm(%scontents[slot].fld%d);\n\t\t",
+				buf, i);
+			} else
+			fprintf(fd, "\tprintf(\"%%d,\", %scontents[slot].fld%d);\n\t\t",
+				buf, i);
+		}
+		fprintf(fd, "	printf(\"],\");\n\t\t");
+		fprintf(fd, "}\n\t\t");
+		fprintf(fd, "break;\n");
+	}
+	fprintf(fd, "	}\n");
+	fprintf(fd, "	printf(\"\\n\");\n}\n");
+}
+
+void
+c_var(FILE *fd, char *pref, Symbol *sp)
+{	char buf[256];
+	int i;
+
+	switch (sp->type) {
+	case STRUCT:
+		/* c_struct(fd, pref, sp); */
+		fprintf(fd, "\t\tprintf(\"\t(struct %s)\\n\");\n",
+			sp->name);
+		sprintf(buf, "%s%s.", pref, sp->name);
+		c_struct(fd, buf, sp);
+		break;
+	case BIT:   case BYTE:
+	case SHORT: case INT:
+	case UNSIGNED:
+		sputtype(buf, sp->type);
+		if (sp->nel == 1)
+		fprintf(fd, "\tprintf(\"\t%s %s:\t%%d\\n\", %s%s);\n",
+			buf, sp->name, pref, sp->name);
+		else
+		for (i = 0; i < sp->nel; i++)
+		fprintf(fd, "\tprintf(\"\t%s %s[%d]:\t%%d\\n\", %s%s[%d]);\n",
+			buf, sp->name, i, pref, sp->name, i);
+		break;
+	case CHAN:
+		if (sp->nel == 1)
+		{  fprintf(fd, "\tprintf(\"\tchan %s (=%%d):\tlen %%d:\\t\", ",
+			sp->name);
+		   fprintf(fd, "%s%s, q_len(%s%s));\n",
+			pref, sp->name, pref, sp->name);
+		   fprintf(fd, "\tc_chandump(%s%s);\n", pref, sp->name);
+		} else
+		for (i = 0; i < sp->nel; i++)
+		{  fprintf(fd, "\tprintf(\"\tchan %s[%d] (=%%d):\tlen %%d:\\t\", ",
+			sp->name, i);
+		   fprintf(fd, "%s%s[%d], q_len(%s%s[%d]));\n",
+			pref, sp->name, i, pref, sp->name, i);
+		   fprintf(fd, "\tc_chandump(%s%s[%d]);\n",
+			pref, sp->name, i);
+		}
+		break;
+	}
+}
+
+void
+c_splurge(FILE *fd, ProcList *p)
+{	Ordered *walk;
+	Symbol *sp;
+	char pref[64];
+
+	if (strcmp(p->n->name, ":never:") != 0
+	&&  strcmp(p->n->name, ":trace:") != 0
+	&&  strcmp(p->n->name, ":notrace:") != 0)
+	for (walk = all_names; walk; walk = walk->next)
+	{	sp = walk->entry;
+		if (!sp->context
+		||  strcmp(sp->context->name, p->n->name) != 0
+		||  sp->owner || (sp->hidden&1)
+		|| (sp->type == MTYPE && ismtype(sp->name)))
+			continue;
+
+		sprintf(pref, "((P%d *)pptr(pid))->", p->tn);
+		c_var(fd, pref, sp);
+	}
+}
+
+void
+c_wrapper(FILE *fd)	/* allow pan.c to print out global sv entries */
+{	Ordered *walk;
+	ProcList *p;
+	Symbol *sp;
+	Lextok *n;
+	extern Lextok *Mtype;
+	int j;
+
+	fprintf(fd, "void\nc_globals(void)\n{\t/* int i; */\n");
+	fprintf(fd, "	printf(\"global vars:\\n\");\n");
+	for (walk = all_names; walk; walk = walk->next)
+	{	sp = walk->entry;
+		if (sp->context || sp->owner || (sp->hidden&1)
+		|| (sp->type == MTYPE && ismtype(sp->name)))
+			continue;
+
+		c_var(fd, "now.", sp);
+	}
+	fprintf(fd, "}\n");
+
+	fprintf(fd, "void\nc_locals(int pid, int tp)\n{\t/* int i; */\n");
+	fprintf(fd, "	switch(tp) {\n");
+	for (p = rdy; p; p = p->nxt)
+	{	fprintf(fd, "	case %d:\n", p->tn);
+		fprintf(fd, "	\tprintf(\"local vars proc %%d (%s):\\n\", pid);\n",
+			p->n->name);
+		c_splurge(fd, p);
+		fprintf(fd, "	\tbreak;\n");
+	}
+	fprintf(fd, "	}\n}\n");
+
+	fprintf(fd, "void\nprintm(int x)\n{\n");
+	fprintf(fd, "	switch (x) {\n");
+        for (n = Mtype, j = 1; n && j; n = n->rgt, j++)
+                fprintf(fd, "\tcase %d: Printf(\"%s\"); break;\n",
+			j, n->lft->sym->name);
+	fprintf(fd, "	default: Printf(\"%%d\", x);\n");
+	fprintf(fd, "	}\n");
+	fprintf(fd, "}\n");
+}
+
 static int
 doglobal(char *pre, int dowhat)
 {	Ordered *walk;
@@ -396,7 +574,6 @@ doglobal(char *pre, int dowhat)
 	{	sp = walk->entry;
 		if (!sp->context
 		&&  !sp->owner
-	/*	&&  !(sp->hidden&1)	*/
 		&&  sp->type == Types[j])
 		{	if (Types[j] != MTYPE || !ismtype(sp->name))
 			switch (dowhat) {
@@ -513,15 +690,29 @@ static void
 put_ptype(char *s, int i, int m0, int m1)
 {	int k;
 
+	if (strcmp(s, ":init:") == 0)
+		fprintf(th, "#define Pinit	((P%d *)this)\n", i);
+
+	if (strcmp(s, ":never:") != 0
+	&&  strcmp(s, ":trace:") != 0
+	&&  strcmp(s, ":notrace:") != 0
+	&&  strcmp(s, ":init:")  != 0
+	&&  strcmp(s, "_:never_template:_") != 0
+	&&  strcmp(s, "np_")     != 0)
+		fprintf(th, "#define P%s	((P%d *)this)\n", s, i);
+
 	fprintf(th, "typedef struct P%d { /* %s */\n", i, s);
 	fprintf(th, "	unsigned _pid : 8;  /* 0..255 */\n");
 	fprintf(th, "	unsigned _t   : %d; /* proctype */\n", blog(m1));
 	fprintf(th, "	unsigned _p   : %d; /* state    */\n", blog(m0));
 	LstSet = ZS;
 	nBits = 8 + blog(m1) + blog(m0);
-	k = dolocal(tc, "", PUTV, i, s, "");	/* includes pars */
+	k = dolocal(tc, "", PUTV, i, s);	/* includes pars */
+
+	c_add_loc(th, s);
+
 	fprintf(th, "} P%d;\n", i);
-	if (!LstSet && k > 0)
+	if ((!LstSet && k > 0) || has_state)
 		fprintf(th, "#define Air%d	0\n", i);
 	else
 	{	fprintf(th, "#define Air%d	(sizeof(P%d) - ", i, i);
@@ -531,15 +722,8 @@ put_ptype(char *s, int i, int m0, int m1)
 		}
 		if ((LstSet->type != BIT && LstSet->type != UNSIGNED)
 		||   LstSet->nel != 1)
-		{	fprintf(th, "Offsetof(P%d, %s%s) - %d*sizeof(",
-				i,
-				LstSet->name,
-#if 1
-				"",
-#else
-				(LstSet->nel > 1)?"[0]":"",
-#endif
-				LstSet->nel);
+		{	fprintf(th, "Offsetof(P%d, %s) - %d*sizeof(",
+				i, LstSet->name, LstSet->nel);
 		}
 		switch(LstSet->type) {
 		case UNSIGNED:
@@ -608,7 +792,7 @@ put_pinit(ProcList *P)
 	&&  separate == 2)
 		return;
 
-	ini = huntele(e, e->status)->seqno;
+	ini = huntele(e, e->status, -1)->seqno;
 	fprintf(th, "#define start%d	%d\n", i, ini);
 	if (i == claimnr)
 	fprintf(th, "#define start_claim	%d\n", ini);
@@ -648,7 +832,7 @@ put_pinit(ProcList *P)
 		{	if (full_name(tc, t, t->sym, 1))
 			{	lineno = t->ln;
 				Fname  = t->fn;
-				fatal("hidden array in parameter, %s",
+				fatal("hidden array in parameter %s",
 				t->sym->name);
 			}
 		} else
@@ -656,12 +840,17 @@ put_pinit(ProcList *P)
 		fprintf(tc, " = par%d;\n", j);
 	}
 	fprintf(tc, "\t\t/* locals: */\n");
-	k = dolocal(tc, "", INIV, i, s->name, "");
+	k = dolocal(tc, "", INIV, i, s->name);
 	if (k > 0)
 	{	fprintf(tc, "#ifdef VAR_RANGES\n");
-		(void) dolocal(tc, "logval(\"", LOGV, i, s->name, "");
+		(void) dolocal(tc, "logval(\"", LOGV, i, s->name);
 		fprintf(tc, "#endif\n");
 	}
+
+	fprintf(tc, "#ifdef HAS_CODE\n");
+	fprintf(tc, "\t\tlocinit%d(h);\n", i);
+	fprintf(tc, "#endif\n");
+
 	dumpclaims(tc, i, s->name);
 	fprintf(tc, "\t	break;\n");
 }
@@ -669,28 +858,35 @@ put_pinit(ProcList *P)
 Element *
 huntstart(Element *f)
 {	Element *e = f;
+	Element *elast = (Element *) 0;
+	int cnt = 0;
+
+	while (elast != e && cnt++ < 20)	/* new 4.0.8 */
+	{	elast = e;
+		if (e->n)
+		{	if (e->n->ntyp == '.' && e->nxt)
+				e = e->nxt;
+			else if (e->n->ntyp == UNLESS)
+				e = e->sub->this->frst;
+	}	}
 
-	if (e->n)
-	{	if (e->n->ntyp == '.' && e->nxt)
-			e = e->nxt;
-		else if (e->n->ntyp == ATOMIC
-		     ||  e->n->ntyp == D_STEP
-		     ||  e->n->ntyp == NON_ATOMIC)
-			e->n->sl->this->last->nxt = e->nxt;
-		else if (e->n->ntyp == UNLESS)
-			return e->sub->this->frst;
-	}
+	if (cnt >= 20 || !e)
+		fatal("confusing control structure", (char *) 0);
 	return e;
 }
 
 Element *
-huntele(Element *f, int o)
+huntele(Element *f, int o, int stopat)
 {	Element *g, *e = f;
-	int cnt; /* a precaution against loops */
+	int cnt=0; /* a precaution against loops */
 
 	if (e)
-	for (cnt=0; cnt < 10 && e->n; cnt++)
-	{	switch (e->n->ntyp) {
+	for (cnt = 0; cnt < 20 && e->n; cnt++)
+	{
+		if (e->seqno == stopat)
+			break;
+
+		switch (e->n->ntyp) {
 		case GOTO:
 			g = get_lab(e->n,1);
 			cross_dsteps(e->n, g->n);
@@ -702,19 +898,20 @@ huntele(Element *f, int o)
 			g = e->nxt;
 			break;
 		case UNLESS:
-			g = huntele(e->sub->this->frst, o);
+			g = huntele(e->sub->this->frst, o, stopat);
 			break;
 		case D_STEP:
 		case ATOMIC:
 		case NON_ATOMIC:
-			e->n->sl->this->last->nxt = e->nxt;
-		default:	/* fall through */
+		default:
 			return e;
 		}
 		if ((o & ATOM) && !(g->status & ATOM))
 			return e;
 		e = g;
 	}
+	if (cnt >= 20 || !e)
+		fatal("confusing control structure", (char *) 0);
 	return e;
 }
 
@@ -743,6 +940,7 @@ typ2c(Symbol *sp)
 			nBits++;
 			break;
 		} /* else fall through */
+		if (!(sp->hidden&1) && (verbose&32))
 		printf("spin: warning: bit-array %s[%d] mapped to byte-array\n",
 			sp->name, sp->nel);
 		nBits += 8*sp->nel; /* mapped onto array of uchars */
@@ -768,6 +966,7 @@ typ2c(Symbol *sp)
 			sp->name);
 		LstSet = ZS;
 		break;
+	case CODE_FRAG:
 	case PREDEF:
 		return;
 	default:
@@ -790,22 +989,49 @@ ncases(FILE *fd, int p, int n, int m, char *c[])
 	}
 }
 
+void