home *** CD-ROM | disk | FTP | other *** search
/ PC-Online 1996 May / PCOnline_05_1996.bin / linux / source / contrib / perl4.036 / perl-4.003 / perl-4.036.diff
Text File  |  1995-01-17  |  146KB  |  6,016 lines

  1. diff -u --new-file --recursive perl-4.036.orig/Makefile perl-4.036/Makefile
  2. --- perl-4.036.orig/Makefile    Wed Dec 31 18:00:00 1969
  3. +++ perl-4.036/Makefile    Tue Jan 17 21:16:27 1995
  4. @@ -0,0 +1,336 @@
  5. +# : Makefile.SH,v 4063Revision: 4.0.1.4 4063Date: 92/06/08 11:40:43 $
  6. +#
  7. +# $Log:    Makefile.SH,v $
  8. +# Revision 4.0.1.4  92/06/08  11:40:43  lwall
  9. +# patch20: cray didn't give enough memory to /bin/sh
  10. +# patch20: various and sundry fixes
  11. +# 
  12. +# Revision 4.0.1.3  91/11/05  15:48:11  lwall
  13. +# patch11: saberized perl
  14. +# patch11: added support for dbz
  15. +# 
  16. +# Revision 4.0.1.2  91/06/07  10:14:43  lwall
  17. +# patch4: cflags now emits entire cc command except for the filename
  18. +# patch4: alternate make programs are now semi-supported
  19. +# patch4: uperl.o no longer tries to link in libraries prematurely
  20. +# patch4: installperl now installs x2p stuff too
  21. +# 
  22. +# Revision 4.0.1.1  91/04/11  17:30:39  lwall
  23. +# patch1: C flags are now settable on a per-file basis
  24. +# 
  25. +# Revision 4.0  91/03/20  00:58:54  lwall
  26. +# 4.0 baseline.
  27. +# 
  28. +# 
  29. +
  30. +CC = gcc
  31. +YACC = bison -y
  32. +bin = /usr/bin
  33. +scriptdir = /usr/bin
  34. +privlib = /usr/lib/perl4
  35. +mansrc = /usr/man/man1
  36. +manext = 1
  37. +LDFLAGS = -s
  38. +CLDFLAGS = -s
  39. +SMALL = 
  40. +LARGE =  
  41. +mallocsrc = 
  42. +mallocobj = 
  43. +SLN = ln -s
  44. +RMS = rm -f
  45. +
  46. +libs = -ldbm -lm 
  47. +
  48. +public = perl taintperl 
  49. +
  50. +shellflags = 
  51. +
  52. +# To use an alternate make, set  in config.sh.
  53. +MAKE = make
  54. +
  55. +
  56. +CCCMD = `sh $(shellflags) cflags $@`
  57. +
  58. +private = 
  59. +
  60. +scripts = h2ph
  61. +
  62. +manpages = perl.man h2ph.man
  63. +
  64. +util =
  65. +
  66. +sh = Makefile.SH makedepend.SH h2ph.SH
  67. +
  68. +h1 = EXTERN.h INTERN.h arg.h array.h cmd.h config.h form.h handy.h
  69. +h2 = hash.h perl.h regcomp.h regexp.h spat.h stab.h str.h util.h
  70. +
  71. +h = $(h1) $(h2)
  72. +
  73. +c1 = array.c cmd.c cons.c consarg.c doarg.c doio.c dolist.c dump.c
  74. +c2 = eval.c form.c hash.c $(mallocsrc) perl.c regcomp.c regexec.c
  75. +c3 = stab.c str.c toke.c util.c usersub.c
  76. +
  77. +c = $(c1) $(c2) $(c3)
  78. +
  79. +s1 = array.c cmd.c cons.c consarg.c doarg.c doio.c dolist.c dump.c
  80. +s2 = eval.c form.c hash.c perl.c regcomp.c regexec.c
  81. +s3 = stab.c str.c toke.c util.c usersub.c perly.c
  82. +
  83. +saber = $(s1) $(s2) $(s3)
  84. +
  85. +obj1 = array.o cmd.o cons.o consarg.o doarg.o doio.o dolist.o dump.o
  86. +obj2 = eval.o form.o $(mallocobj) perl.o regcomp.o regexec.o
  87. +obj3 = stab.o str.o toke.o util.o
  88. +
  89. +obj = $(obj1) $(obj2) $(obj3)
  90. +
  91. +tobj1 = tarray.o tcmd.o tcons.o tconsarg.o tdoarg.o tdoio.o tdolist.o tdump.o
  92. +tobj2 = teval.o tform.o thash.o $(mallocobj) tregcomp.o tregexec.o
  93. +tobj3 = tstab.o tstr.o ttoke.o tutil.o
  94. +
  95. +tobj = $(tobj1) $(tobj2) $(tobj3)
  96. +
  97. +lintflags = -hbvxac
  98. +
  99. +addedbyconf = Makefile.old bsd eunice filexp loc pdp11 usg v7
  100. +
  101. +# grrr
  102. +SHELL = /bin/sh
  103. +
  104. +.c.o:
  105. +    $(CCCMD) $*.c
  106. +
  107. +all: $(public) $(private) $(util) uperl.o $(scripts)
  108. +    cd x2p; $(MAKE) all
  109. +    touch all
  110. +
  111. +# This is the standard version that contains no "taint" checks and is
  112. +# used for all scripts that aren't set-id or running under something set-id.
  113. +# The $& notation is tells Sequent machines that it can do a parallel make,
  114. +# and is harmless otherwise.
  115. +
  116. +perl: $& perly.o $(obj) hash.o usersub.o
  117. +    $(CC) $(LARGE) $(CLDFLAGS) $(obj) hash.o perly.o usersub.o $(libs) -o perl
  118. +
  119. +# This command assumes that /usr/include/dbz.h and /usr/lib/dbz.o exist.
  120. +
  121. +dbzperl: $& perly.o $(obj) zhash.o usersub.o
  122. +    $(CC) $(LARGE) $(CLDFLAGS) $(obj) zhash.o /usr/lib/dbz.o perly.o usersub.o $(libs) -o dbzperl
  123. +
  124. +zhash.o: hash.c $(h)
  125. +    $(RMS) zhash.c
  126. +    $(SLN) hash.c zhash.c
  127. +    $(CCCMD) -DWANT_DBZ zhash.c
  128. +    $(RMS) zhash.c
  129. +
  130. +uperl.o: $& perly.o $(obj) hash.o
  131. +    -ld $(LARGE) $(LDFLAGS) -r $(obj) hash.o perly.o -o uperl.o
  132. +
  133. +saber: $(saber)
  134. +    # load $(saber)
  135. +    # load /lib/libm.a
  136. +
  137. +# This version, if specified in Configure, does ONLY those scripts which need
  138. +# set-id emulation.  Suidperl must be setuid root.  It contains the "taint"
  139. +# checks as well as the special code to validate that the script in question
  140. +# has been invoked correctly.
  141. +
  142. +suidperl: $& tperly.o sperl.o $(tobj) usersub.o
  143. +    $(CC) $(LARGE) $(CLDFLAGS) sperl.o $(tobj) tperly.o usersub.o $(libs) \
  144. +        -o suidperl
  145. +
  146. +# This version interprets scripts that are already set-id either via a wrapper
  147. +# or through the kernel allowing set-id scripts (bad idea).  Taintperl must
  148. +# NOT be setuid to root or anything else.  The only difference between it
  149. +# and normal perl is the presence of the "taint" checks.
  150. +
  151. +taintperl: $& tperly.o tperl.o $(tobj) usersub.o
  152. +    $(CC) $(LARGE) $(CLDFLAGS) tperl.o $(tobj) tperly.o usersub.o $(libs) \
  153. +        -o taintperl
  154. +
  155. +# Replicating all this junk is yucky, but I don't see a portable way to fix it.
  156. +
  157. +tperly.o: perly.c perly.h $(h)
  158. +    $(RMS) tperly.c
  159. +    $(SLN) perly.c tperly.c
  160. +    $(CCCMD) -DTAINT tperly.c
  161. +    $(RMS) tperly.c
  162. +
  163. +tperl.o: perl.c perly.h patchlevel.h perl.h $(h)
  164. +    $(RMS) tperl.c
  165. +    $(SLN) perl.c tperl.c
  166. +    $(CCCMD) -DTAINT tperl.c
  167. +    $(RMS) tperl.c
  168. +
  169. +sperl.o: perl.c perly.h patchlevel.h $(h)
  170. +    $(RMS) sperl.c
  171. +    $(SLN) perl.c sperl.c
  172. +    $(CCCMD) -DTAINT -DIAMSUID sperl.c
  173. +    $(RMS) sperl.c
  174. +
  175. +tarray.o: array.c $(h)
  176. +    $(RMS) tarray.c
  177. +    $(SLN) array.c tarray.c
  178. +    $(CCCMD) -DTAINT tarray.c
  179. +    $(RMS) tarray.c
  180. +
  181. +tcmd.o: cmd.c $(h)
  182. +    $(RMS) tcmd.c
  183. +    $(SLN) cmd.c tcmd.c
  184. +    $(CCCMD) -DTAINT tcmd.c
  185. +    $(RMS) tcmd.c
  186. +
  187. +tcons.o: cons.c $(h) perly.h
  188. +    $(RMS) tcons.c
  189. +    $(SLN) cons.c tcons.c
  190. +    $(CCCMD) -DTAINT tcons.c
  191. +    $(RMS) tcons.c
  192. +
  193. +tconsarg.o: consarg.c $(h)
  194. +    $(RMS) tconsarg.c
  195. +    $(SLN) consarg.c tconsarg.c
  196. +    $(CCCMD) -DTAINT tconsarg.c
  197. +    $(RMS) tconsarg.c
  198. +
  199. +tdoarg.o: doarg.c $(h)
  200. +    $(RMS) tdoarg.c
  201. +    $(SLN) doarg.c tdoarg.c
  202. +    $(CCCMD) -DTAINT tdoarg.c
  203. +    $(RMS) tdoarg.c
  204. +
  205. +tdoio.o: doio.c $(h)
  206. +    $(RMS) tdoio.c
  207. +    $(SLN) doio.c tdoio.c
  208. +    $(CCCMD) -DTAINT tdoio.c
  209. +    $(RMS) tdoio.c
  210. +
  211. +tdolist.o: dolist.c $(h)
  212. +    $(RMS) tdolist.c
  213. +    $(SLN) dolist.c tdolist.c
  214. +    $(CCCMD) -DTAINT tdolist.c
  215. +    $(RMS) tdolist.c
  216. +
  217. +tdump.o: dump.c $(h)
  218. +    $(RMS) tdump.c
  219. +    $(SLN) dump.c tdump.c
  220. +    $(CCCMD) -DTAINT tdump.c
  221. +    $(RMS) tdump.c
  222. +
  223. +teval.o: eval.c $(h)
  224. +    $(RMS) teval.c
  225. +    $(SLN) eval.c teval.c
  226. +    $(CCCMD) -DTAINT teval.c
  227. +    $(RMS) teval.c
  228. +
  229. +tform.o: form.c $(h)
  230. +    $(RMS) tform.c
  231. +    $(SLN) form.c tform.c
  232. +    $(CCCMD) -DTAINT tform.c
  233. +    $(RMS) tform.c
  234. +
  235. +thash.o: hash.c $(h)
  236. +    $(RMS) thash.c
  237. +    $(SLN) hash.c thash.c
  238. +    $(CCCMD) -DTAINT thash.c
  239. +    $(RMS) thash.c
  240. +
  241. +tregcomp.o: regcomp.c $(h)
  242. +    $(RMS) tregcomp.c
  243. +    $(SLN) regcomp.c tregcomp.c
  244. +    $(CCCMD) -DTAINT tregcomp.c
  245. +    $(RMS) tregcomp.c
  246. +
  247. +tregexec.o: regexec.c $(h)
  248. +    $(RMS) tregexec.c
  249. +    $(SLN) regexec.c tregexec.c
  250. +    $(CCCMD) -DTAINT tregexec.c
  251. +    $(RMS) tregexec.c
  252. +
  253. +tstab.o: stab.c $(h)
  254. +    $(RMS) tstab.c
  255. +    $(SLN) stab.c tstab.c
  256. +    $(CCCMD) -DTAINT tstab.c
  257. +    $(RMS) tstab.c
  258. +
  259. +tstr.o: str.c $(h) perly.h
  260. +    $(RMS) tstr.c
  261. +    $(SLN) str.c tstr.c
  262. +    $(CCCMD) -DTAINT tstr.c
  263. +    $(RMS) tstr.c
  264. +
  265. +ttoke.o: toke.c $(h) perly.h
  266. +    $(RMS) ttoke.c
  267. +    $(SLN) toke.c ttoke.c
  268. +    $(CCCMD) -DTAINT ttoke.c
  269. +    $(RMS) ttoke.c
  270. +
  271. +tutil.o: util.c $(h)
  272. +    $(RMS) tutil.c
  273. +    $(SLN) util.c tutil.c
  274. +    $(CCCMD) -DTAINT tutil.c
  275. +    $(RMS) tutil.c
  276. +
  277. +perly.h: perly.c
  278. +    @ echo Dummy dependency for dumb parallel make
  279. +    touch perly.h
  280. +
  281. +perly.c: perly.y perly.fixer
  282. +    @ \
  283. +case "$(YACC)" in \
  284. +    *bison*) echo 'Expect' 25 shift/reduce and 59 reduce/reduce conflicts;; \
  285. +    *) echo 'Expect' 27 shift/reduce and 57 reduce/reduce conflicts;; \
  286. +esac
  287. +    $(YACC) -d perly.y
  288. +    sh $(shellflags) ./perly.fixer y.tab.c perly.c
  289. +    mv y.tab.h perly.h
  290. +    echo 'extern YYSTYPE yylval;' >>perly.h
  291. +
  292. +perly.o: perly.c perly.h $(h)
  293. +    $(CCCMD) perly.c
  294. +
  295. +install: all
  296. +    ./perl installperl
  297. +
  298. +clean:
  299. +    rm -f *.o all perl taintperl suidperl perly.c
  300. +    cd x2p; $(MAKE) clean
  301. +
  302. +realclean: clean
  303. +    cd x2p; $(MAKE) realclean
  304. +    rm -f *.orig */*.orig *~ */*~ core $(addedbyconf) h2ph h2ph.man
  305. +    rm -f perly.c perly.h t/perl Makefile config.h makedepend makedir
  306. +    rm -f makefile x2p/Makefile x2p/makefile cflags x2p/cflags
  307. +    rm -f c2ph pstruct
  308. +
  309. +# The following lint has practically everything turned on.  Unfortunately,
  310. +# you have to wade through a lot of mumbo jumbo that can't be suppressed.
  311. +# If the source file has a /*NOSTRICT*/ somewhere, ignore the lint message
  312. +# for that spot.
  313. +
  314. +lint: perly.c $(c)
  315. +    lint $(lintflags) $(defs) perly.c $(c) > perl.fuzz
  316. +
  317. +depend: makedepend
  318. +    - test -f perly.h || cp /dev/null perly.h
  319. +    ./makedepend
  320. +    - test -s perly.h || /bin/rm -f perly.h
  321. +    cd x2p; $(MAKE) depend
  322. +
  323. +test: perl
  324. +    - cd t && chmod +x TEST */*.t
  325. +    - cd t && (rm -f perl; $(SLN) ../perl perl) && ./perl TEST </dev/tty
  326. +
  327. +clist:
  328. +    echo $(c) | tr ' ' '\012' >.clist
  329. +
  330. +hlist:
  331. +    echo $(h) | tr ' ' '\012' >.hlist
  332. +
  333. +shlist:
  334. +    echo $(sh) | tr ' ' '\012' >.shlist
  335. +
  336. +# AUTOMATICALLY GENERATED MAKE DEPENDENCIES--PUT NOTHING BELOW THIS LINE
  337. +$(obj) hash.o:
  338. +    @ echo "You haven't done a "'"make depend" yet!'; exit 1
  339. +makedepend: makedepend.SH
  340. +    /bin/sh $(shellflags) makedepend.SH
  341. diff -u --new-file --recursive perl-4.036.orig/c2ph perl-4.036/c2ph
  342. --- perl-4.036.orig/c2ph    Wed Dec 31 18:00:00 1969
  343. +++ perl-4.036/c2ph    Tue Jan 17 21:16:27 1995
  344. @@ -0,0 +1,1071 @@
  345. +#!/usr/bin/perl
  346. +#
  347. +#
  348. +#   c2ph (aka pstruct)
  349. +#   Tom Christiansen, <tchrist@convex.com>
  350. +#   
  351. +#   As pstruct, dump C structures as generated from 'cc -g -S' stabs.
  352. +#   As c2ph, do this PLUS generate perl code for getting at the structures.
  353. +#
  354. +#   See the usage message for more.  If this isn't enough, read the code.
  355. +#
  356. +
  357. +$RCSID = '$RCSfile: c2ph.SH,v $$Revision: 4.0.1.2 $$Date: 92/06/08 11:56:08 $';
  358. +
  359. +
  360. +######################################################################
  361. +
  362. +# some handy data definitions.   many of these can be reset later.
  363. +
  364. +$bitorder = 'b';  # ascending; set to B for descending bit fields
  365. +
  366. +%intrinsics = 
  367. +%template = (
  368. +    'char',             'c',
  369. +    'unsigned char',         'C',
  370. +    'short',            's',
  371. +    'short int',        's',
  372. +    'unsigned short',        'S',
  373. +    'unsigned short int',    'S',
  374. +    'short unsigned int',    'S',
  375. +    'int',            'i',
  376. +    'unsigned int',        'I',
  377. +    'long',            'l',
  378. +    'long int',            'l',
  379. +    'unsigned long',        'L',
  380. +    'unsigned long',        'L',
  381. +    'long unsigned int',    'L',
  382. +    'unsigned long int',    'L',
  383. +    'long long',        'q',
  384. +    'long long int',        'q',
  385. +    'unsigned long long',    'Q',
  386. +    'unsigned long long int',    'Q',
  387. +    'float',            'f',
  388. +    'double',            'd',
  389. +    'pointer',            'p',
  390. +    'null',            'x',
  391. +    'neganull',            'X',
  392. +    'bit',            $bitorder,
  393. +); 
  394. +
  395. +&buildscrunchlist;
  396. +delete $intrinsics{'neganull'};
  397. +delete $intrinsics{'bit'};
  398. +delete $intrinsics{'null'};
  399. +
  400. +# use -s to recompute sizes
  401. +%sizeof = (
  402. +    'char',             '1',
  403. +    'unsigned char',         '1',
  404. +    'short',            '2',
  405. +    'short int',        '2',
  406. +    'unsigned short',        '2',
  407. +    'unsigned short int',    '2',
  408. +    'short unsigned int',    '2',
  409. +    'int',            '4',
  410. +    'unsigned int',        '4',
  411. +    'long',            '4',
  412. +    'long int',            '4',
  413. +    'unsigned long',        '4',
  414. +    'unsigned long int',    '4',
  415. +    'long unsigned int',    '4',
  416. +    'long long',        '8',
  417. +    'long long int',        '8',
  418. +    'unsigned long long',    '8',
  419. +    'unsigned long long int',    '8',
  420. +    'float',            '4',
  421. +    'double',            '8',
  422. +    'pointer',            '4',
  423. +);
  424. +
  425. +($type_width, $member_width, $offset_width, $size_width) = (20, 20, 6, 5);
  426. +
  427. +($offset_fmt, $size_fmt) = ('d', 'd');
  428. +
  429. +$indent = 2;
  430. +
  431. +$CC = 'cc';
  432. +$CFLAGS = '-g -S';
  433. +$DEFINES = '';
  434. +
  435. +$perl++ if $0 =~ m#/?c2ph$#;
  436. +
  437. +require 'getopts.pl';
  438. +
  439. +eval '$'.$1.'$2;' while $ARGV[0] =~ /^([A-Za-z_]+=)(.*)/ && shift;
  440. +
  441. +&Getopts('aixdpvtnws:') || &usage(0);
  442. +
  443. +$opt_d && $debug++;
  444. +$opt_t && $trace++;
  445. +$opt_p && $perl++;
  446. +$opt_v && $verbose++;
  447. +$opt_n && ($perl = 0);
  448. +
  449. +if ($opt_w) {
  450. +    ($type_width, $member_width, $offset_width) = (45, 35, 8);
  451. +} 
  452. +if ($opt_x) {
  453. +    ($offset_fmt, $offset_width, $size_fmt, $size_width) = ( 'x', '08', 'x', 04 );
  454. +}
  455. +
  456. +eval '$'.$1.'$2;' while $ARGV[0] =~ /^([A-Za-z_]+=)(.*)/ && shift;
  457. +
  458. +sub PLUMBER {
  459. +    select(STDERR);
  460. +    print "oops, apperent pager foulup\n";
  461. +    $isatty++;
  462. +    &usage(1);
  463. +} 
  464. +
  465. +sub usage {
  466. +    local($oops) = @_;
  467. +    unless (-t STDOUT) {
  468. +    select(STDERR);
  469. +    } elsif (!$oops) {
  470. +    $isatty++;
  471. +    $| = 1;
  472. +    print "hit <RETURN> for further explanation: ";
  473. +    <STDIN>;
  474. +    open (PIPE, "|". ($ENV{PAGER} || 'more'));
  475. +    $SIG{PIPE} = PLUMBER;
  476. +    select(PIPE);
  477. +    } 
  478. +
  479. +    print "usage: $0 [-dpnP] [var=val] [files ...]\n";
  480. +
  481. +    exit unless $isatty;
  482. +
  483. +    print <<EOF;
  484. +
  485. +Options:
  486. +
  487. +-w    wide; short for: type_width=45 member_width=35 offset_width=8
  488. +-x    hex; short for:  offset_fmt=x offset_width=08 size_fmt=x size_width=04
  489. +
  490. +-n      do not generate perl code  (default when invoked as pstruct)
  491. +-p      generate perl code         (default when invoked as c2ph)
  492. +-v    generate perl code, with C decls as comments
  493. +
  494. +-i    do NOT recompute sizes for intrinsic datatypes
  495. +-a    dump information on intrinsics also
  496. +
  497. +-t     trace execution
  498. +-d    spew reams of debugging output
  499. +
  500. +-slist  give comma-separated list a structures to dump
  501. +
  502. +
  503. +Var Name        Default Value    Meaning
  504. +
  505. +EOF
  506. +
  507. +    &defvar('CC', 'which_compiler to call');
  508. +    &defvar('CFLAGS', 'how to generate *.s files with stabs');
  509. +    &defvar('DEFINES','any extra cflags or cpp defines, like -I, -D, -U');
  510. +
  511. +    print "\n";
  512. +
  513. +    &defvar('type_width', 'width of type field   (column 1)');
  514. +    &defvar('member_width', 'width of member field (column 2)');
  515. +    &defvar('offset_width', 'width of offset field (column 3)');
  516. +    &defvar('size_width', 'width of size field   (column 4)');
  517. +
  518. +    print "\n";
  519. +
  520. +    &defvar('offset_fmt', 'sprintf format type for offset');
  521. +    &defvar('size_fmt', 'sprintf format type for size');
  522. +
  523. +    print "\n";
  524. +
  525. +    &defvar('indent', 'how far to indent each nesting level');
  526. +
  527. +   print <<'EOF';
  528. +
  529. +    If any *.[ch] files are given, these will be catted together into
  530. +    a temporary *.c file and sent through:
  531. +        $CC $CFLAGS $DEFINES 
  532. +    and the resulting *.s groped for stab information.  If no files are
  533. +    supplied, then stdin is read directly with the assumption that it
  534. +    contains stab information.  All other liens will be ignored.  At
  535. +    most one *.s file should be supplied.
  536. +
  537. +EOF
  538. +    close PIPE;
  539. +    exit 1;
  540. +} 
  541. +
  542. +sub defvar {
  543. +    local($var, $msg) = @_;
  544. +    printf "%-16s%-15s  %s\n", $var, eval "\$$var", $msg;
  545. +} 
  546. +
  547. +$recurse = 1;
  548. +
  549. +if (@ARGV) {
  550. +    if (grep(!/\.[csh]$/,@ARGV)) {
  551. +    warn "Only *.[csh] files expected!\n";
  552. +    &usage;
  553. +    } 
  554. +    elsif (grep(/\.s$/,@ARGV)) {
  555. +    if (@ARGV > 1) { 
  556. +        warn "Only one *.s file allowed!\n";
  557. +        &usage;
  558. +    }
  559. +    } 
  560. +    elsif (@ARGV == 1 && $ARGV[0] =~ /\.c$/) {
  561. +    local($dir, $file) = $ARGV[0] =~ m#(.*/)?(.*)$#;
  562. +    $chdir = "cd $dir; " if $dir;
  563. +    &system("$chdir$CC $CFLAGS $DEFINES $file") && exit 1;
  564. +    $ARGV[0] =~ s/\.c$/.s/;
  565. +    } 
  566. +    else {
  567. +    $TMP = "/tmp/c2ph.$$.c";
  568. +    &system("cat @ARGV > $TMP") && exit 1;
  569. +    &system("cd /tmp; $CC $CFLAGS $DEFINES $TMP") && exit 1;
  570. +    unlink $TMP;
  571. +    $TMP =~ s/\.c$/.s/;
  572. +    @ARGV = ($TMP);
  573. +    } 
  574. +}
  575. +
  576. +if ($opt_s) {
  577. +    for (split(/[\s,]+/, $opt_s)) {
  578. +    $interested{$_}++;
  579. +    } 
  580. +} 
  581. +
  582. +
  583. +$| = 1 if $debug;
  584. +
  585. +main: {
  586. +
  587. +    if ($trace) {
  588. +    if (-t && !@ARGV) { 
  589. +        print STDERR "reading from your keyboard: ";
  590. +    } else {
  591. +        print STDERR "reading from " . (@ARGV ? "@ARGV" : "<STDIN>").": ";
  592. +    }
  593. +    }
  594. +
  595. +STAB: while (<>) {
  596. +    if ($trace && !($. % 10)) {
  597. +        $lineno = $..'';
  598. +        print STDERR $lineno, "\b" x length($lineno);
  599. +    } 
  600. +    next unless /^\s*\.stabs\s+/;
  601. +    $line = $_;
  602. +    s/^\s*\.stabs\s+//; 
  603. +    &stab; 
  604. +    }
  605. +    print STDERR "$.\n" if $trace;
  606. +    unlink $TMP if $TMP;
  607. +
  608. +    &compute_intrinsics if $perl && !$opt_i;
  609. +
  610. +    print STDERR "resolving types\n" if $trace;
  611. +
  612. +    &resolve_types;
  613. +    &adjust_start_addrs;
  614. +
  615. +    $sum = 2 + $type_width + $member_width;
  616. +    $pmask1 = "%-${type_width}s %-${member_width}s"; 
  617. +    $pmask2 = "%-${sum}s %${offset_width}${offset_fmt}%s %${size_width}${size_fmt}%s";
  618. +
  619. +    if ($perl) {
  620. +    # resolve template -- should be in stab define order, but even this isn't enough.
  621. +    print STDERR "\nbuilding type templates: " if $trace;
  622. +    for $i (reverse 0..$#type) {
  623. +        next unless defined($name = $type[$i]);
  624. +        next unless defined $struct{$name};
  625. +        $build_recursed = 0;
  626. +        &build_template($name) unless defined $template{&psou($name)} ||
  627. +                    $opt_s && !$interested{$name};
  628. +    } 
  629. +    print STDERR "\n\n" if $trace;
  630. +    }
  631. +
  632. +    print STDERR "dumping structs: " if $trace;
  633. +
  634. +
  635. +    foreach $name (sort keys %struct) {
  636. +    next if $opt_s && !$interested{$name};
  637. +    print STDERR "$name " if $trace;
  638. +
  639. +    undef @sizeof;
  640. +    undef @typedef;
  641. +    undef @offsetof;
  642. +    undef @indices;
  643. +    undef @typeof;
  644. +
  645. +    $mname = &munge($name);
  646. +
  647. +    $fname = &psou($name);
  648. +
  649. +    print "# " if $perl && $verbose;
  650. +    $pcode = '';
  651. +    print "$fname {\n" if !$perl || $verbose; 
  652. +    $template{$fname} = &scrunch($template{$fname}) if $perl;
  653. +    &pstruct($name,$name,0); 
  654. +    print "# " if $perl && $verbose;
  655. +    print "}\n" if !$perl || $verbose; 
  656. +    print "\n" if $perl && $verbose;
  657. +
  658. +    if ($perl) {
  659. +        print "$pcode";
  660. +
  661. +        printf("\nsub %-32s { %4d; }\n\n", "${mname}'struct", $countof{$name});
  662. +
  663. +        print <<EOF;
  664. +sub ${mname}'typedef { 
  665. +    local(\$${mname}'index) = shift;
  666. +    defined \$${mname}'index 
  667. +    ? \$${mname}'typedef[\$${mname}'index] 
  668. +    : \$${mname}'typedef;
  669. +}
  670. +EOF
  671. +
  672. +        print <<EOF;
  673. +sub ${mname}'sizeof { 
  674. +    local(\$${mname}'index) = shift;
  675. +    defined \$${mname}'index 
  676. +    ? \$${mname}'sizeof[\$${mname}'index] 
  677. +    : \$${mname}'sizeof;
  678. +}
  679. +EOF
  680. +
  681. +        print <<EOF;
  682. +sub ${mname}'offsetof { 
  683. +    local(\$${mname}'index) = shift;
  684. +    defined \$${mname}index 
  685. +    ? \$${mname}'offsetof[\$${mname}'index] 
  686. +    : \$${mname}'sizeof;
  687. +}
  688. +EOF
  689. +
  690. +        print <<EOF;
  691. +sub ${mname}'typeof { 
  692. +    local(\$${mname}'index) = shift;
  693. +    defined \$${mname}index 
  694. +    ? \$${mname}'typeof[\$${mname}'index] 
  695. +    : '$name';
  696. +}
  697. +EOF
  698. +    
  699. +
  700. +        print "\$${mname}'typedef = '" . &scrunch($template{$fname}) 
  701. +        . "';\n";
  702. +
  703. +        print "\$${mname}'sizeof = $sizeof{$name};\n\n";
  704. +
  705. +
  706. +        print "\@${mname}'indices = (", &squishseq(@indices), ");\n";
  707. +
  708. +        print "\n";
  709. +
  710. +        print "\@${mname}'typedef[\@${mname}'indices] = (",
  711. +            join("\n\t", '', @typedef), "\n    );\n\n";
  712. +        print "\@${mname}'sizeof[\@${mname}'indices] = (",
  713. +            join("\n\t", '', @sizeof), "\n    );\n\n";
  714. +        print "\@${mname}'offsetof[\@${mname}'indices] = (",
  715. +            join("\n\t", '', @offsetof), "\n    );\n\n";
  716. +        print "\@${mname}'typeof[\@${mname}'indices] = (",
  717. +            join("\n\t", '', @typeof), "\n    );\n\n";
  718. +
  719. +        $template_printed{$fname}++;
  720. +        $size_printed{$fname}++;
  721. +    } 
  722. +    print "\n";
  723. +    }
  724. +
  725. +    print STDERR "\n" if $trace;
  726. +
  727. +    unless ($perl && $opt_a) { 
  728. +    print "\n1;\n";
  729. +    exit;
  730. +    }
  731. +
  732. +
  733. +
  734. +    foreach $name (sort bysizevalue keys %intrinsics) {
  735. +    next if $size_printed{$name};
  736. +    print '$',&munge($name),"'sizeof = ", $sizeof{$name}, ";\n";
  737. +    }
  738. +
  739. +    print "\n";
  740. +
  741. +    sub bysizevalue { $sizeof{$a} <=> $sizeof{$b}; }
  742. +
  743. +
  744. +    foreach $name (sort keys %intrinsics) {
  745. +    print '$',&munge($name),"'typedef = '", $template{$name}, "';\n";
  746. +    }
  747. +
  748. +    print "\n1;\n";
  749. +    
  750. +    exit;
  751. +}
  752. +
  753. +########################################################################################
  754. +
  755. +
  756. +sub stab {
  757. +    next unless /:[\$\w]+(\(\d+,\d+\))?=[\*\$\w]+/;  # (\d+,\d+) is for sun
  758. +    s/"//                         || next;
  759. +    s/",([x\d]+),([x\d]+),([x\d]+),.*//         || next;
  760. +
  761. +    next if /^\s*$/;
  762. +
  763. +    $size = $3 if $3;
  764. +
  765. +
  766. +    $line = $_;
  767. +
  768. +    if (($name, $pdecl) = /^([\$ \w]+):[tT]((\d+)(=[rufs*](\d+))+)$/) {
  769. +    print "$name is a typedef for some funky pointers: $pdecl\n" if $debug;
  770. +    &pdecl($pdecl);
  771. +    next;
  772. +    }
  773. +
  774. +
  775. +
  776. +    if (/(([ \w]+):t(\d+|\(\d+,\d+\)))=r?(\d+|\(\d+,\d+\))(;\d+;\d+;)?/) {  
  777. +    local($ident) = $2;
  778. +    push(@intrinsics, $ident);
  779. +    $typeno = &typeno($3);
  780. +    $type[$typeno] = $ident;
  781. +    print STDERR "intrinsic $ident in new type $typeno\n" if $debug; 
  782. +    next;
  783. +    }
  784. +
  785. +    if (($name, $typeordef, $typeno, $extra, $struct, $_) 
  786. +    = /^([\$ \w]+):([ustT])(\d+|\(\d+,\d+\))(=[rufs*](\d+))?(.*)$/) 
  787. +    {
  788. +    $typeno = &typeno($typeno);  # sun foolery
  789. +    } 
  790. +    elsif (/^[\$\w]+:/) {
  791. +    next; # variable
  792. +    }
  793. +    else { 
  794. +    warn "can't grok stab: <$_> in: $line " if $_;
  795. +    next;
  796. +    } 
  797. +
  798. +    #warn "got size $size for $name\n";
  799. +    $sizeof{$name} = $size if $size;
  800. +
  801. +    s/;[-\d]*;[-\d]*;$//;  # we don't care about ranges
  802. +
  803. +    $typenos{$name} = $typeno;
  804. +
  805. +    unless (defined $type[$typeno]) {
  806. +    &panic("type 0??") unless $typeno;
  807. +    $type[$typeno] = $name unless defined $type[$typeno];
  808. +    printf "new type $typeno is $name" if $debug;
  809. +    if ($extra =~ /\*/ && defined $type[$struct]) {
  810. +        print ", a typedef for a pointer to " , $type[$struct] if $debug;
  811. +    }
  812. +    } else {
  813. +    printf "%s is type %d", $name, $typeno if $debug;
  814. +    print ", a typedef for " , $type[$typeno] if $debug;
  815. +    } 
  816. +    print "\n" if $debug;
  817. +    #next unless $extra =~ /[su*]/;
  818. +
  819. +    #$type[$struct] = $name;
  820. +
  821. +    if ($extra =~ /[us*]/) {
  822. +    &sou($name, $extra);
  823. +    $_ = &sdecl($name, $_, 0);
  824. +    }
  825. +    elsif (/^=ar/) {
  826. +    print "it's a bare array typedef -- that's pretty sick\n" if $debug;
  827. +    $_ = "$typeno$_";
  828. +    $scripts = '';
  829. +    $_ = &adecl($_,1);
  830. +
  831. +    }
  832. +    elsif (s/((\w+):t(\d+|\(\d+,\d+\)))?=r?(;\d+;\d+;)?//) {  # the ?'s are for gcc
  833. +    push(@intrinsics, $2);
  834. +    $typeno = &typeno($3);
  835. +    $type[$typeno] = $2;
  836. +    print STDERR "intrinsic $2 in new type $typeno\n" if $debug; 
  837. +    }
  838. +    elsif (s/^=e//) { # blessed by thy compiler; mine won't do this
  839. +    &edecl;
  840. +    } 
  841. +    else {
  842. +    warn "Funny remainder for $name on line $_ left in $line " if $_;
  843. +    } 
  844. +}
  845. +
  846. +sub typeno {  # sun thinks types are (0,27) instead of just 27
  847. +    local($_) = @_;
  848. +    s/\(\d+,(\d+)\)/$1/;
  849. +    $_;
  850. +} 
  851. +
  852. +sub pstruct {
  853. +    local($what,$prefix,$base) = @_; 
  854. +    local($field, $fieldname, $typeno, $count, $offset, $entry); 
  855. +    local($fieldtype);
  856. +    local($type, $tname); 
  857. +    local($mytype, $mycount, $entry2);
  858. +    local($struct_count) = 0;
  859. +    local($pad, $revpad, $length, $prepad, $lastoffset, $lastlength, $fmt);
  860. +    local($bits,$bytes);
  861. +    local($template);
  862. +
  863. +
  864. +    local($mname) = &munge($name);
  865. +
  866. +    sub munge { 
  867. +    local($_) = @_;
  868. +    s/[\s\$\.]/_/g;
  869. +    $_;
  870. +    }
  871. +
  872. +    local($sname) = &psou($what);
  873. +
  874. +    $nesting++;
  875. +
  876. +    for $field (split(/;/, $struct{$what})) {
  877. +    $pad = $prepad = 0;
  878. +    $entry = ''; 
  879. +    ($fieldname, $typeno, $count, $offset, $length) = split(/,/, $field); 
  880. +
  881. +    $type = $type[$typeno];
  882. +
  883. +    $type =~ /([^[]*)(\[.*\])?/;
  884. +    $mytype = $1;
  885. +    $count .= $2;
  886. +    $fieldtype = &psou($mytype);
  887. +
  888. +    local($fname) = &psou($name);
  889. +
  890. +    if ($build_templates) {
  891. +
  892. +        $pad = ($offset - ($lastoffset + $lastlength))/8 
  893. +        if defined $lastoffset;
  894. +
  895. +        if (! $finished_template{$sname}) {
  896. +        if ($isaunion{$what}) {
  897. +            $template{$sname} .= 'X' x $revpad . ' '    if $revpad;
  898. +        } else {
  899. +            $template{$sname} .= 'x' x $pad    . ' '    if $pad;
  900. +        }
  901. +        }
  902. +
  903. +        $template = &fetch_template($type) x 
  904. +                ($count ? &scripts2count($count) : 1);
  905. +
  906. +        if (! $finished_template{$sname}) {
  907. +        $template{$sname} .= $template;
  908. +        }
  909. +
  910. +        $revpad = $length/8 if $isaunion{$what};
  911. +
  912. +        ($lastoffset, $lastlength) = ($offset, $length);
  913. +
  914. +    } else { 
  915. +        print '# ' if $perl && $verbose;
  916. +        $entry = sprintf($pmask1,
  917. +            ' ' x ($nesting * $indent) . $fieldtype,
  918. +            "$prefix.$fieldname" . $count); 
  919. +
  920. +        $entry =~ s/(\*+)( )/$2$1/; 
  921. +
  922. +        printf $pmask2,
  923. +            $entry,
  924. +            ($base+$offset)/8,
  925. +            ($bits = ($base+$offset)%8) ? ".$bits" : "  ",
  926. +            $length/8,
  927. +            ($bits = $length % 8) ? ".$bits": ""
  928. +            if !$perl || $verbose;
  929. +
  930. +
  931. +        if ($perl && $nesting == 1) {
  932. +        $template = &scrunch(&fetch_template($type) x 
  933. +                ($count ? &scripts2count($count) : 1));
  934. +        push(@sizeof, int($length/8) .",\t# $fieldname");
  935. +        push(@offsetof, int($offset/8) .",\t# $fieldname");
  936. +        push(@typedef, "'$template', \t# $fieldname");
  937. +        $type =~ s/(struct|union) //;
  938. +        push(@typeof, "'$type" . ($count ? $count : '') .
  939. +            "',\t# $fieldname");
  940. +        }
  941. +
  942. +        print '  ', ' ' x $indent x $nesting, $template
  943. +                if $perl && $verbose;
  944. +
  945. +        print "\n" if !$perl || $verbose;
  946. +
  947. +    }    
  948. +    if ($perl) {
  949. +        local($mycount) = defined $struct{$mytype} ? $countof{$mytype} : 1;
  950. +        $mycount *= &scripts2count($count) if $count;
  951. +        if ($nesting==1 && !$build_templates) {
  952. +        $pcode .= sprintf("sub %-32s { %4d; }\n", 
  953. +            "${mname}'${fieldname}", $struct_count);
  954. +        push(@indices, $struct_count);
  955. +        }
  956. +        $struct_count += $mycount;
  957. +    } 
  958. +
  959. +
  960. +    &pstruct($type, "$prefix.$fieldname", $base+$offset) 
  961. +        if $recurse && defined $struct{$type}; 
  962. +    }
  963. +
  964. +    $countof{$what} = $struct_count unless defined $countof{$whati};
  965. +
  966. +    $template{$sname} .= '$' if $build_templates;
  967. +    $finished_template{$sname}++;
  968. +
  969. +    if ($build_templates && !defined $sizeof{$name}) {
  970. +    local($fmt) = &scrunch($template{$sname});
  971. +    print STDERR "no size for $name, punting with $fmt..." if $debug;
  972. +    eval '$sizeof{$name} = length(pack($fmt, ()))';
  973. +    if ($@) {
  974. +        chop $@;
  975. +        warn "couldn't get size for \$name: $@";
  976. +    } else {
  977. +        print STDERR $sizeof{$name}, "\n" if $debUg;
  978. +    }
  979. +    } 
  980. +
  981. +    --$nesting;
  982. +}
  983. +
  984. +
  985. +sub psize {
  986. +    local($me) = @_; 
  987. +    local($amstruct) = $struct{$me} ?  'struct ' : '';
  988. +
  989. +    print '$sizeof{\'', $amstruct, $me, '\'} = '; 
  990. +    printf "%d;\n", $sizeof{$me}; 
  991. +}
  992. +
  993. +sub pdecl {
  994. +    local($pdecl) = @_;
  995. +    local(@pdecls);
  996. +    local($tname);
  997. +
  998. +    warn "pdecl: $pdecl\n" if $debug;
  999. +
  1000. +    $pdecl =~ s/\(\d+,(\d+)\)/$1/g;
  1001. +    $pdecl =~ s/\*//g; 
  1002. +    @pdecls = split(/=/, $pdecl); 
  1003. +    $typeno = $pdecls[0];
  1004. +    $tname = pop @pdecls;
  1005. +
  1006. +    if ($tname =~ s/^f//) { $tname = "$tname&"; } 
  1007. +    #else { $tname = "$tname*"; } 
  1008. +
  1009. +    for (reverse @pdecls) {
  1010. +    $tname  .= s/^f// ? "&" : "*"; 
  1011. +    #$tname =~ s/^f(.*)/$1&/;
  1012. +    print "type[$_] is $tname\n" if $debug;
  1013. +    $type[$_] = $tname unless defined $type[$_];
  1014. +    } 
  1015. +}
  1016. +
  1017. +
  1018. +
  1019. +sub adecl {
  1020. +    ($arraytype, $unknown, $lower, $upper) = ();
  1021. +    #local($typeno);
  1022. +    # global $typeno, @type
  1023. +    local($_, $typedef) = @_;
  1024. +
  1025. +    while (s/^((\d+)=)?ar(\d+);//) {
  1026. +    ($arraytype, $unknown) = ($2, $3); 
  1027. +    if (s/^(\d+);(\d+);//) {
  1028. +        ($lower, $upper) = ($1, $2); 
  1029. +        $scripts .= '[' .  ($upper+1) . ']'; 
  1030. +    } else {
  1031. +        warn "can't find array bounds: $_"; 
  1032. +    } 
  1033. +    }
  1034. +    if (s/^([\d*f=]*),(\d+),(\d+);//) {
  1035. +    ($start, $length) = ($2, $3); 
  1036. +    local($whatis) = $1;
  1037. +    if ($whatis =~ /^(\d+)=/) {
  1038. +        $typeno = $1;
  1039. +        &pdecl($whatis);
  1040. +    } else {
  1041. +        $typeno = $whatis;
  1042. +    }
  1043. +    } elsif (s/^(\d+)(=[*suf]\d*)//) {
  1044. +    local($whatis) = $2; 
  1045. +
  1046. +    if ($whatis =~ /[f*]/) {
  1047. +        &pdecl($whatis); 
  1048. +    } elsif ($whatis =~ /[su]/) {  # 
  1049. +        print "$prefix.$fieldname is an array$scripts anon structs; disgusting\n" 
  1050. +        if $debug;
  1051. +        #$type[$typeno] = $name unless defined $type[$typeno];
  1052. +        ##printf "new type $typeno is $name" if $debug;
  1053. +        $typeno = $1;
  1054. +        $type[$typeno] = "$prefix.$fieldname";
  1055. +        local($name) = $type[$typeno];
  1056. +        &sou($name, $whatis);
  1057. +        $_ = &sdecl($name, $_, $start+$offset);
  1058. +        1;
  1059. +        $start = $start{$name};
  1060. +        $offset = $sizeof{$name};
  1061. +        $length = $offset;
  1062. +    } else {
  1063. +        warn "what's this? $whatis in $line ";
  1064. +    } 
  1065. +    } elsif (/^\d+$/) {
  1066. +    $typeno = $_;
  1067. +    } else {
  1068. +    warn "bad array stab: $_ in $line ";
  1069. +    next STAB;
  1070. +    } 
  1071. +    #local($wasdef) = defined($type[$typeno]) && $debug;
  1072. +    #if ($typedef) { 
  1073. +    #print "redefining $type[$typeno] to " if $wasdef;
  1074. +    #$type[$typeno] = "$whatis$scripts"; # unless defined $type[$typeno];
  1075. +    #print "$type[$typeno]\n" if $wasdef;
  1076. +    #} else {
  1077. +    #$type[$arraytype] = $type[$typeno] unless defined $type[$arraytype];
  1078. +    #}
  1079. +    $type[$arraytype] = "$type[$typeno]$scripts" if defined $type[$typeno];
  1080. +    print "type[$arraytype] is $type[$arraytype]\n" if $debug;
  1081. +    print "$prefix.$fieldname is an array of $type[$arraytype]\n" if $debug;
  1082. +    $_;
  1083. +}
  1084. +
  1085. +
  1086. +
  1087. +sub sdecl {
  1088. +    local($prefix, $_, $offset) = @_;
  1089. +
  1090. +    local($fieldname, $scripts, $type, $arraytype, $unknown,
  1091. +    $whatis, $pdecl, $upper,$lower, $start,$length) = ();
  1092. +    local($typeno,$sou);
  1093. +
  1094. +
  1095. +SFIELD:
  1096. +    while (/^([^;]+);/) {
  1097. +    $scripts = '';
  1098. +    warn "sdecl $_\n" if $debug;
  1099. +    if (s/^([\$\w]+)://) { 
  1100. +        $fieldname = $1;
  1101. +    } elsif (s/(\d+)=([us])(\d+|\(\d+,\d+\))//) { # 
  1102. +        $typeno = &typeno($1);
  1103. +        $type[$typeno] = "$prefix.$fieldname";
  1104. +        local($name) = "$prefix.$fieldname";
  1105. +        &sou($name,$2);
  1106. +        $_ = &sdecl("$prefix.$fieldname", $_, $start+$offset);
  1107. +        $start = $start{$name};
  1108. +        $offset += $sizeof{$name};
  1109. +        #print "done with anon, start is $start, offset is $offset\n";
  1110. +        #next SFIELD;
  1111. +    } else  {
  1112. +        warn "weird field $_ of $line" if $debug;
  1113. +        next STAB;
  1114. +        #$fieldname = &gensym;
  1115. +        #$_ = &sdecl("$prefix.$fieldname", $_, $start+$offset);
  1116. +    }
  1117. +
  1118. +    if (/^\d+=ar/) {
  1119. +        $_ = &adecl($_);
  1120. +    }
  1121. +    elsif (s/^(\d+|\(\d+,\d+\))?,(\d+),(\d+);//) {
  1122. +        ($start, $length) =  ($2, $3); 
  1123. +        &panic("no length?") unless $length;
  1124. +        $typeno = &typeno($1) if $1;
  1125. +    }
  1126. +    elsif (s/^((\d+|\(\d+,\d+\))(=[*f](\d+|\(\d+,\d+\)))+),(\d+),(\d+);//) {
  1127. +        ($pdecl, $start, $length) =  ($1,$5,$6); 
  1128. +        &pdecl($pdecl); 
  1129. +    }
  1130. +    elsif (s/(\d+)=([us])(\d+|\(\d+,\d+\))//) { # the dratted anon struct
  1131. +        ($typeno, $sou) = ($1, $2);
  1132. +        $typeno = &typeno($typeno);
  1133. +        if (defined($type[$typeno])) {
  1134. +        warn "now how did we get type $1 in $fieldname of $line?";
  1135. +        } else {
  1136. +        print "anon type $typeno is $prefix.$fieldname\n" if $debug;
  1137. +        $type[$typeno] = "$prefix.$fieldname" unless defined $type[$typeno];
  1138. +        };
  1139. +        local($name) = "$prefix.$fieldname";
  1140. +        &sou($name,$sou);
  1141. +        print "anon ".($isastruct{$name}) ? "struct":"union"." for $prefix.$fieldname\n" if $debug;
  1142. +        $type[$typeno] = "$prefix.$fieldname";
  1143. +        $_ = &sdecl("$prefix.$fieldname", $_, $start+$offset); 
  1144. +        $start = $start{$name};
  1145. +        $length = $sizeof{$name};
  1146. +    }
  1147. +    else {
  1148. +        warn "can't grok stab for $name ($_) in line $line "; 
  1149. +        next STAB; 
  1150. +    }
  1151. +
  1152. +    &panic("no length for $prefix.$fieldname") unless $length;
  1153. +    $struct{$name} .= join(',', $fieldname, $typeno, $scripts, $start, $length) . ';';
  1154. +    }
  1155. +    if (s/;\d*,(\d+),(\d+);//) {
  1156. +    local($start, $size) = ($1, $2); 
  1157. +    $sizeof{$prefix} = $size;
  1158. +    print "start of $prefix is $start, size of $sizeof{$prefix}\n" if $debug; 
  1159. +    $start{$prefix} = $start; 
  1160. +    } 
  1161. +    $_;
  1162. +}
  1163. +
  1164. +sub edecl {
  1165. +    s/;$//;
  1166. +    $enum{$name} = $_;
  1167. +    $_ = '';
  1168. +} 
  1169. +
  1170. +sub resolve_types {
  1171. +    local($sou);
  1172. +    for $i (0 .. $#type) {
  1173. +    next unless defined $type[$i];
  1174. +    $_ = $type[$i];
  1175. +    unless (/\d/) {
  1176. +        print "type[$i] $type[$i]\n" if $debug;
  1177. +        next;
  1178. +    }
  1179. +    print "type[$i] $_ ==> " if $debug;
  1180. +    s/^(\d+)(\**)\&\*(\**)/"$2($3".&type($1) . ')()'/e;
  1181. +    s/^(\d+)\&/&type($1)/e; 
  1182. +    s/^(\d+)/&type($1)/e; 
  1183. +    s/(\*+)([^*]+)(\*+)/$1$3$2/;
  1184. +    s/\((\*+)(\w+)(\*+)\)/$3($1$2)/;
  1185. +    s/^(\d+)([\*\[].*)/&type($1).$2/e;
  1186. +    #s/(\d+)(\*|(\[[\[\]\d\*]+]\])+)/&type($1).$2/ge;
  1187. +    $type[$i] = $_;
  1188. +    print "$_\n" if $debug;
  1189. +    }
  1190. +}
  1191. +sub type { &psou($type[$_[0]] || "<UNDEFINED>"); } 
  1192. +
  1193. +sub adjust_start_addrs {
  1194. +    for (sort keys %start) {
  1195. +    ($basename = $_) =~ s/\.[^.]+$//;
  1196. +    $start{$_} += $start{$basename};
  1197. +    print "start: $_ @ $start{$_}\n" if $debug;
  1198. +    }
  1199. +}
  1200. +
  1201. +sub sou {
  1202. +    local($what, $_) = @_;
  1203. +    /u/ && $isaunion{$what}++;
  1204. +    /s/ && $isastruct{$what}++;
  1205. +}
  1206. +
  1207. +sub psou {
  1208. +    local($what) = @_;
  1209. +    local($prefix) = '';
  1210. +    if ($isaunion{$what})  {
  1211. +    $prefix = 'union ';
  1212. +    } elsif ($isastruct{$what})  {
  1213. +    $prefix = 'struct ';
  1214. +    }
  1215. +    $prefix . $what;
  1216. +}
  1217. +
  1218. +sub scrunch {
  1219. +    local($_) = @_;
  1220. +
  1221. +    study;
  1222. +
  1223. +    s/\$//g;
  1224. +    s/  / /g;
  1225. +    1 while s/(\w) \1/$1$1/g;
  1226. +
  1227. +    # i wanna say this, but perl resists my efforts:
  1228. +    #       s/(\w)(\1+)/$2 . length($1)/ge;
  1229. +
  1230. +    &quick_scrunch;
  1231. +
  1232. +    s/ $//;
  1233. +
  1234. +    $_;
  1235. +}
  1236. +
  1237. +sub buildscrunchlist {
  1238. +    $scrunch_code = "sub quick_scrunch {\n";
  1239. +    for (values %intrinsics) {
  1240. +        $scrunch_code .= "\ts/($_{2,})/'$_' . length(\$1)/ge;\n";
  1241. +    } 
  1242. +    $scrunch_code .= "}\n";
  1243. +    print "$scrunch_code" if $debug;
  1244. +    eval $scrunch_code;
  1245. +    &panic("can't eval scrunch_code $@ \nscrunch_code") if $@;
  1246. +} 
  1247. +
  1248. +sub fetch_template {
  1249. +    local($mytype) = @_;
  1250. +    local($fmt);
  1251. +    local($count) = 1;
  1252. +
  1253. +    &panic("why do you care?") unless $perl;
  1254. +
  1255. +    if ($mytype =~ s/(\[\d+\])+$//) {
  1256. +    $count .= $1;
  1257. +    } 
  1258. +
  1259. +    if ($mytype =~ /\*/) {
  1260. +    $fmt = $template{'pointer'};
  1261. +    } 
  1262. +    elsif (defined $template{$mytype}) {
  1263. +    $fmt = $template{$mytype};
  1264. +    } 
  1265. +    elsif (defined $struct{$mytype}) {
  1266. +    if (!defined $template{&psou($mytype)}) {
  1267. +        &build_template($mytype) unless $mytype eq $name;
  1268. +    } 
  1269. +    elsif ($template{&psou($mytype)} !~ /\$$/) {
  1270. +        #warn "incomplete template for $mytype\n";
  1271. +    } 
  1272. +    $fmt = $template{&psou($mytype)} || '?';
  1273. +    } 
  1274. +    else {
  1275. +    warn "unknown fmt for $mytype\n";
  1276. +    $fmt = '?';
  1277. +    } 
  1278. +
  1279. +    $fmt x $count . ' ';
  1280. +}
  1281. +
  1282. +sub compute_intrinsics {
  1283. +    local($TMP) = "/tmp/c2ph-i.$$.c";
  1284. +    open (TMP, ">$TMP") || die "can't open $TMP: $!";
  1285. +    select(TMP);
  1286. +
  1287. +    print STDERR "computing intrinsic sizes: " if $trace;
  1288. +
  1289. +    undef %intrinsics;
  1290. +
  1291. +    print <<'EOF';
  1292. +main() {
  1293. +    char *mask = "%d %s\n";
  1294. +EOF
  1295. +
  1296. +    for $type (@intrinsics) {
  1297. +    next if $type eq 'void';
  1298. +    print <<"EOF";
  1299. +    printf(mask,sizeof($type), "$type");
  1300. +EOF
  1301. +    } 
  1302. +
  1303. +    print <<'EOF';
  1304. +    printf(mask,sizeof(char *), "pointer");
  1305. +    exit(0);
  1306. +}
  1307. +EOF
  1308. +    close TMP;
  1309. +
  1310. +    select(STDOUT);
  1311. +    open(PIPE, "cd /tmp && $CC $TMP && /tmp/a.out|");
  1312. +    while (<PIPE>) {
  1313. +    chop;
  1314. +    split(' ',$_,2);;
  1315. +    print "intrinsic $_[1] is size $_[0]\n" if $debug;
  1316. +    $sizeof{$_[1]} = $_[0];
  1317. +    $intrinsics{$_[1]} = $template{$_[0]};
  1318. +    } 
  1319. +    close(PIPE) || die "couldn't read intrinsics!";
  1320. +    unlink($TMP, '/tmp/a.out');
  1321. +    print STDERR "done\n" if $trace;
  1322. +} 
  1323. +
  1324. +sub scripts2count {
  1325. +    local($_) = @_;
  1326. +
  1327. +    s/^\[//;
  1328. +    s/\]$//;
  1329. +    s/\]\[/*/g;
  1330. +    $_ = eval;
  1331. +    &panic("$_: $@") if $@;
  1332. +    $_;
  1333. +}
  1334. +
  1335. +sub system {
  1336. +    print STDERR "@_\n" if $trace;
  1337. +    system @_;
  1338. +} 
  1339. +
  1340. +sub build_template { 
  1341. +    local($name) = @_;
  1342. +
  1343. +    &panic("already got a template for $name") if defined $template{$name};
  1344. +
  1345. +    local($build_templates) = 1;
  1346. +
  1347. +    local($lparen) = '(' x $build_recursed;
  1348. +    local($rparen) = ')' x $build_recursed;
  1349. +
  1350. +    print STDERR "$lparen$name$rparen " if $trace;
  1351. +    $build_recursed++;
  1352. +    &pstruct($name,$name,0);
  1353. +    print STDERR "TEMPLATE for $name is ", $template{&psou($name)}, "\n" if $debug;
  1354. +    --$build_recursed;
  1355. +}
  1356. +
  1357. +
  1358. +sub panic {
  1359. +
  1360. +    select(STDERR);
  1361. +
  1362. +    print "\npanic: @_\n";
  1363. +
  1364. +    exit 1 if $] <= 4.003;  # caller broken
  1365. +
  1366. +    local($i,$_);
  1367. +    local($p,$f,$l,$s,$h,$a,@a,@sub);
  1368. +    for ($i = 0; ($p,$f,$l,$s,$h,$w) = caller($i); $i++) {
  1369. +    @a = @DB'args;
  1370. +    for (@a) {
  1371. +        if (/^StB\000/ && length($_) == length($_main{'_main'})) {
  1372. +        $_ = sprintf("%s",$_);
  1373. +        }
  1374. +        else {
  1375. +        s/'/\\'/g;
  1376. +        s/([^\0]*)/'$1'/ unless /^-?[\d.]+$/;
  1377. +        s/([\200-\377])/sprintf("M-%c",ord($1)&0177)/eg;
  1378. +        s/([\0-\37\177])/sprintf("^%c",ord($1)^64)/eg;
  1379. +        }
  1380. +    }
  1381. +    $w = $w ? '@ = ' : '$ = ';
  1382. +    $a = $h ? '(' . join(', ', @a) . ')' : '';
  1383. +    push(@sub, "$w&$s$a from file $f line $l\n");
  1384. +    last if $signal;
  1385. +    }
  1386. +    for ($i=0; $i <= $#sub; $i++) {
  1387. +    last if $signal;
  1388. +    print $sub[$i];
  1389. +    }
  1390. +    exit 1;
  1391. +} 
  1392. +
  1393. +sub squishseq {
  1394. +    local($num);
  1395. +    local($last) = -1e8;
  1396. +    local($string);
  1397. +    local($seq) = '..';
  1398. +
  1399. +    while (defined($num = shift)) {
  1400. +        if ($num == ($last + 1)) {
  1401. +            $string .= $seq unless $inseq++;
  1402. +            $last = $num;
  1403. +            next;
  1404. +        } elsif ($inseq) {
  1405. +            $string .= $last unless $last == -1e8;
  1406. +        }
  1407. +
  1408. +        $string .= ',' if defined $string;
  1409. +        $string .= $num;
  1410. +        $last = $num;
  1411. +        $inseq = 0;
  1412. +    }
  1413. +    $string .= $last if $inseq && $last != -e18;
  1414. +    $string;
  1415. +}
  1416. diff -u --new-file --recursive perl-4.036.orig/cflags perl-4.036/cflags
  1417. --- perl-4.036.orig/cflags    Wed Dec 31 18:00:00 1969
  1418. +++ perl-4.036/cflags    Tue Jan 17 21:16:27 1995
  1419. @@ -0,0 +1,91 @@
  1420. +case "$0" in
  1421. +*/*) cd `expr X$0 : 'X\(.*\)/'` ;;
  1422. +esac
  1423. +case $CONFIG in
  1424. +'')
  1425. +    if test ! -f config.sh; then
  1426. +    ln ../config.sh . || \
  1427. +    ln ../../config.sh . || \
  1428. +    ln ../../../config.sh . || \
  1429. +    (echo "Can't find config.sh."; exit 1)
  1430. +    fi 2>/dev/null
  1431. +    . ./config.sh
  1432. +    ;;
  1433. +esac
  1434. +
  1435. +also=': '
  1436. +case $# in
  1437. +1) also='echo 1>&2 "      CCCMD = "'
  1438. +esac
  1439. +
  1440. +case $# in
  1441. +0) set *.c; echo "The current C flags are:" ;;
  1442. +esac
  1443. +
  1444. +set `echo "$* " | sed 's/\.[oc] / /g'`
  1445. +
  1446. +for file do
  1447. +
  1448. +    case "$#" in
  1449. +    1) ;;
  1450. +    *) echo $n "    $file.c    $c" ;;
  1451. +    esac
  1452. +
  1453. +    : allow variables like toke_cflags to be evaluated
  1454. +
  1455. +    eval 'eval ${'"${file}_cflags"'-""}'
  1456. +
  1457. +    : or customize here
  1458. +
  1459. +    case "$file" in
  1460. +    array) ;;
  1461. +    cmd) ;;
  1462. +    cons) ;;
  1463. +    consarg) ;;
  1464. +    doarg) ;;
  1465. +    doio) ;;
  1466. +    dolist) ;;
  1467. +    dump) ;;
  1468. +    eval) ;;
  1469. +    form) ;;
  1470. +    hash) ;;
  1471. +    malloc) ;;
  1472. +    perl) ;;
  1473. +    perly) ;;
  1474. +    regcomp) ;;
  1475. +    regexec) ;;
  1476. +    stab) ;;
  1477. +    str) ;;
  1478. +    toke) ;;
  1479. +    usersub) ;;
  1480. +    util) ;;
  1481. +    tarray) ;;
  1482. +    tcmd) ;;
  1483. +    tcons) ;;
  1484. +    tconsarg) ;;
  1485. +    tdoarg) ;;
  1486. +    tdoio) ;;
  1487. +    tdolist) ;;
  1488. +    tdump) ;;
  1489. +    teval) ;;
  1490. +    tform) ;;
  1491. +    thash) ;;
  1492. +    tmalloc) ;;
  1493. +    tperl) ;;
  1494. +    tperly) ;;
  1495. +    tregcomp) ;;
  1496. +    tregexec) ;;
  1497. +    tstab) ;;
  1498. +    tstr) ;;
  1499. +    ttoke) ;;
  1500. +    tusersub) ;;
  1501. +    tutil) ;;
  1502. +    *) ;;
  1503. +    esac
  1504. +
  1505. +    echo "$cc -c $ccflags $optimize $large $split"
  1506. +    eval "$also "'"$cc -c $ccflags $optimize $large $split"'
  1507. +
  1508. +    . ./config.sh
  1509. +
  1510. +done
  1511. diff -u --new-file --recursive perl-4.036.orig/config.h perl-4.036/config.h
  1512. --- perl-4.036.orig/config.h    Wed Dec 31 18:00:00 1969
  1513. +++ perl-4.036/config.h    Tue Jan 17 21:16:28 1995
  1514. @@ -0,0 +1,892 @@
  1515. +#ifndef config_h
  1516. +#define config_h
  1517. +/* config.h
  1518. + * This file was produced by running the config.h.SH script, which
  1519. + * gets its values from config.sh, which is generally produced by
  1520. + * running Configure.
  1521. + *
  1522. + * Feel free to modify any of this as the need arises.  Note, however,
  1523. + * that running config.h.SH again will wipe out any changes you've made.
  1524. + * For a more permanent change edit config.sh and rerun config.h.SH.
  1525. + */
  1526. + /*SUPPRESS 460*/
  1527. +
  1528. +
  1529. +/* EUNICE
  1530. + *    This symbol, if defined, indicates that the program is being compiled
  1531. + *    under the EUNICE package under VMS.  The program will need to handle
  1532. + *    things like files that don't go away the first time you unlink them,
  1533. + *    due to version numbering.  It will also need to compensate for lack
  1534. + *    of a respectable link() command.
  1535. + */
  1536. +/* VMS
  1537. + *    This symbol, if defined, indicates that the program is running under
  1538. + *    VMS.  It is currently only set in conjunction with the EUNICE symbol.
  1539. + */
  1540. +/*#undef    EUNICE        /**/
  1541. +/*#undef    VMS        /**/
  1542. +
  1543. +/* LOC_SED
  1544. + *     This symbol holds the complete pathname to the sed program.
  1545. + */
  1546. +#define LOC_SED "/usr/bin/sed"             /**/
  1547. +
  1548. +/* ALIGNBYTES
  1549. + *    This symbol contains the number of bytes required to align a double.
  1550. + *    Usual values are 2, 4, and 8.
  1551. + */
  1552. +#define ALIGNBYTES 4        /**/
  1553. +
  1554. +/* BIN
  1555. + *    This symbol holds the name of the directory in which the user wants
  1556. + *    to keep publicly executable images for the package in question.  It
  1557. + *    is most often a local directory such as /usr/local/bin.
  1558. + */
  1559. +#define BIN "/usr/bin"             /**/
  1560. +
  1561. +/* BYTEORDER
  1562. + *    This symbol contains an encoding of the order of bytes in a long.
  1563. + *    Usual values (in hex) are 0x1234, 0x4321, 0x2143, 0x3412...
  1564. + */
  1565. +#define BYTEORDER 0x1234        /**/
  1566. +
  1567. +/* CPPSTDIN
  1568. + *    This symbol contains the first part of the string which will invoke
  1569. + *    the C preprocessor on the standard input and produce to standard
  1570. + *    output.     Typical value of "cc -E" or "/lib/cpp".
  1571. + */
  1572. +/* CPPMINUS
  1573. + *    This symbol contains the second part of the string which will invoke
  1574. + *    the C preprocessor on the standard input and produce to standard
  1575. + *    output.  This symbol will have the value "-" if CPPSTDIN needs a minus
  1576. + *    to specify standard input, otherwise the value is "".
  1577. + */
  1578. +#define CPPSTDIN "cppstdin"
  1579. +#define CPPMINUS ""
  1580. +
  1581. +/* HAS_BCMP
  1582. + *    This symbol, if defined, indicates that the bcmp routine is available
  1583. + *    to compare blocks of memory.  If undefined, use memcmp.  If that's
  1584. + *    not available, roll your own.
  1585. + */
  1586. +#define    HAS_BCMP        /**/
  1587. +
  1588. +/* HAS_BCOPY
  1589. + *    This symbol, if defined, indicates that the bcopy routine is available
  1590. + *    to copy blocks of memory.  Otherwise you should probably use memcpy().
  1591. + *    If neither is defined, roll your own.
  1592. + */
  1593. +/* SAFE_BCOPY
  1594. + *    This symbol, if defined, indicates that the bcopy routine is available
  1595. + *    to copy potentially overlapping copy blocks of bcopy.  Otherwise you
  1596. + *    should probably use memmove() or memcpy().  If neither is defined,
  1597. + *    roll your own.
  1598. + */
  1599. +#define    HAS_BCOPY        /**/
  1600. +#define    SAFE_BCOPY        /**/
  1601. +
  1602. +/* HAS_BZERO
  1603. + *    This symbol, if defined, indicates that the bzero routine is available
  1604. + *    to zero blocks of memory.  Otherwise you should probably use memset()
  1605. + *    or roll your own.
  1606. + */
  1607. +#define    HAS_BZERO        /**/
  1608. +
  1609. +/* CASTNEGFLOAT
  1610. + *    This symbol, if defined, indicates that this C compiler knows how to
  1611. + *    cast negative or large floating point numbers to unsigned longs, ints
  1612. + *    and shorts.
  1613. + */
  1614. +/* CASTFLAGS
  1615. + *    This symbol contains flags that say what difficulties the compiler
  1616. + *    has casting odd floating values to unsigned long:
  1617. + *        1 = couldn't cast < 0
  1618. + *        2 = couldn't cast >= 0x80000000
  1619. + */
  1620. +#define    CASTNEGFLOAT    /**/
  1621. +#define    CASTFLAGS 0    /**/
  1622. +
  1623. +/* CHARSPRINTF
  1624. + *    This symbol is defined if this system declares "char *sprintf()" in
  1625. + *    stdio.h.  The trend seems to be to declare it as "int sprintf()".  It
  1626. + *    is up to the package author to declare sprintf correctly based on the
  1627. + *    symbol.
  1628. + */
  1629. +/*#undef    CHARSPRINTF     /**/
  1630. +
  1631. +/* HAS_CHSIZE
  1632. + *    This symbol, if defined, indicates that the chsize routine is available
  1633. + *    to truncate files.  You might need a -lx to get this routine.
  1634. + */
  1635. +/*#undef    HAS_CHSIZE        /**/
  1636. +
  1637. +/* HAS_CRYPT
  1638. + *    This symbol, if defined, indicates that the crypt routine is available
  1639. + *    to encrypt passwords and the like.
  1640. + */
  1641. +#define    HAS_CRYPT        /**/
  1642. +
  1643. +/* CSH
  1644. + *    This symbol, if defined, indicates that the C-shell exists.
  1645. + *    If defined, contains the full pathname of csh.
  1646. + */
  1647. +#define CSH "/bin/csh"        /**/
  1648. +
  1649. +/* DOSUID
  1650. + *    This symbol, if defined, indicates that the C program should
  1651. + *    check the script that it is executing for setuid/setgid bits, and
  1652. + *    attempt to emulate setuid/setgid on systems that have disabled
  1653. + *    setuid #! scripts because the kernel can't do it securely.
  1654. + *    It is up to the package designer to make sure that this emulation
  1655. + *    is done securely.  Among other things, it should do an fstat on
  1656. + *    the script it just opened to make sure it really is a setuid/setgid
  1657. + *    script, it should make sure the arguments passed correspond exactly
  1658. + *    to the argument on the #! line, and it should not trust any
  1659. + *    subprocesses to which it must pass the filename rather than the
  1660. + *    file descriptor of the script to be executed.
  1661. + */
  1662. +/*#undef DOSUID        /**/
  1663. +
  1664. +/* HAS_DUP2
  1665. + *    This symbol, if defined, indicates that the dup2 routine is available
  1666. + *    to dup file descriptors.  Otherwise you should use dup().
  1667. + */
  1668. +#define    HAS_DUP2        /**/
  1669. +
  1670. +/* HAS_FCHMOD
  1671. + *    This symbol, if defined, indicates that the fchmod routine is available
  1672. + *    to change mode of opened files.  If unavailable, use chmod().
  1673. + */
  1674. +#define    HAS_FCHMOD        /**/
  1675. +
  1676. +/* HAS_FCHOWN
  1677. + *    This symbol, if defined, indicates that the fchown routine is available
  1678. + *    to change ownership of opened files.  If unavailable, use chown().
  1679. + */
  1680. +#define    HAS_FCHOWN        /**/
  1681. +
  1682. +/* HAS_FCNTL
  1683. + *    This symbol, if defined, indicates to the C program that
  1684. + *    the fcntl() function exists.
  1685. + */
  1686. +#define    HAS_FCNTL        /**/
  1687. +
  1688. +/* FLEXFILENAMES
  1689. + *    This symbol, if defined, indicates that the system supports filenames
  1690. + *    longer than 14 characters.
  1691. + */
  1692. +#define    FLEXFILENAMES        /**/
  1693. +
  1694. +/* HAS_FLOCK
  1695. + *    This symbol, if defined, indicates that the flock() routine is
  1696. + *    available to do file locking.
  1697. + */
  1698. +#define    HAS_FLOCK        /**/
  1699. +
  1700. +/* HAS_GETGROUPS
  1701. + *    This symbol, if defined, indicates that the getgroups() routine is
  1702. + *    available to get the list of process groups.  If unavailable, multiple
  1703. + *    groups are probably not supported.
  1704. + */
  1705. +/*#undef    HAS_GETGROUPS        /**/
  1706. +
  1707. +/* HAS_GETHOSTENT
  1708. + *    This symbol, if defined, indicates that the gethostent() routine is
  1709. + *    available to lookup host names in some data base or other.
  1710. + */
  1711. +/*#undef    HAS_GETHOSTENT        /**/
  1712. +
  1713. +/* HAS_GETPGRP
  1714. + *    This symbol, if defined, indicates that the getpgrp() routine is
  1715. + *    available to get the current process group.
  1716. + */
  1717. +#define    HAS_GETPGRP        /**/
  1718. +
  1719. +/* HAS_GETPGRP2
  1720. + *    This symbol, if defined, indicates that the getpgrp2() (as in DG/UX)
  1721. + *    routine is available to get the current process group.
  1722. + */
  1723. +/*#undef    HAS_GETPGRP2        /**/
  1724. +
  1725. +/* HAS_GETPRIORITY
  1726. + *    This symbol, if defined, indicates that the getpriority() routine is
  1727. + *    available to get a process's priority.
  1728. + */
  1729. +/*#undef    HAS_GETPRIORITY        /**/
  1730. +
  1731. +/* HAS_HTONS
  1732. + *    This symbol, if defined, indicates that the htons routine (and friends)
  1733. + *    are available to do network order byte swapping.
  1734. + */
  1735. +/* HAS_HTONL
  1736. + *    This symbol, if defined, indicates that the htonl routine (and friends)
  1737. + *    are available to do network order byte swapping.
  1738. + */
  1739. +/* HAS_NTOHS
  1740. + *    This symbol, if defined, indicates that the ntohs routine (and friends)
  1741. + *    are available to do network order byte swapping.
  1742. + */
  1743. +/* HAS_NTOHL
  1744. + *    This symbol, if defined, indicates that the ntohl routine (and friends)
  1745. + *    are available to do network order byte swapping.
  1746. + */
  1747. +/*#undef    HAS_HTONS    /**/
  1748. +/*#undef    HAS_HTONL    /**/
  1749. +/*#undef    HAS_NTOHS    /**/
  1750. +/*#undef    HAS_NTOHL    /**/
  1751. +
  1752. +/* index
  1753. + *    This preprocessor symbol is defined, along with rindex, if the system
  1754. + *    uses the strchr and strrchr routines instead.
  1755. + */
  1756. +/* rindex
  1757. + *    This preprocessor symbol is defined, along with index, if the system
  1758. + *    uses the strchr and strrchr routines instead.
  1759. + */
  1760. +/*#undef    index strchr    /* cultural */
  1761. +/*#undef    rindex strrchr    /*  differences? */
  1762. +
  1763. +/* HAS_ISASCII
  1764. + *    This symbol, if defined, indicates that the isascii routine is available
  1765. + *    to test characters for asciiness.
  1766. + */
  1767. +/*#undef    HAS_ISASCII        /**/
  1768. +
  1769. +/* HAS_KILLPG
  1770. + *    This symbol, if defined, indicates that the killpg routine is available
  1771. + *    to kill process groups.  If unavailable, you probably should use kill
  1772. + *    with a negative process number.
  1773. + */
  1774. +#define    HAS_KILLPG        /**/
  1775. +
  1776. +/* HAS_LSTAT
  1777. + *    This symbol, if defined, indicates that the lstat() routine is
  1778. + *    available to stat symbolic links.
  1779. + */
  1780. +#define    HAS_LSTAT        /**/
  1781. +
  1782. +/* HAS_MEMCMP
  1783. + *    This symbol, if defined, indicates that the memcmp routine is available
  1784. + *    to compare blocks of memory.  If undefined, roll your own.
  1785. + */
  1786. +#define    HAS_MEMCMP        /**/
  1787. +
  1788. +/* HAS_MEMCPY
  1789. + *    This symbol, if defined, indicates that the memcpy routine is available
  1790. + *    to copy blocks of memory.  Otherwise you should probably use bcopy().
  1791. + *    If neither is defined, roll your own.
  1792. + */
  1793. +/* SAFE_MEMCPY
  1794. + *    This symbol, if defined, indicates that the memcpy routine is available
  1795. + *    to copy potentially overlapping copy blocks of memory.  Otherwise you
  1796. + *    should probably use memmove() or bcopy().  If neither is defined,
  1797. + *    roll your own.
  1798. + */
  1799. +#define    HAS_MEMCPY        /**/
  1800. +/*#undef    SAFE_MEMCPY        /**/
  1801. +
  1802. +/* HAS_MEMMOVE
  1803. + *    This symbol, if defined, indicates that the memmove routine is available
  1804. + *    to move potentially overlapping blocks of memory.  Otherwise you
  1805. + *    should use bcopy() or roll your own.
  1806. + */
  1807. +#define    HAS_MEMMOVE        /**/
  1808. +
  1809. +/* HAS_MEMSET
  1810. + *    This symbol, if defined, indicates that the memset routine is available
  1811. + *    to set a block of memory to a character.  If undefined, roll your own.
  1812. + */
  1813. +#define    HAS_MEMSET        /**/
  1814. +
  1815. +/* HAS_MKDIR
  1816. + *    This symbol, if defined, indicates that the mkdir routine is available
  1817. + *    to create directories.  Otherwise you should fork off a new process to
  1818. + *    exec /bin/mkdir.
  1819. + */
  1820. +#define    HAS_MKDIR        /**/
  1821. +
  1822. +/* HAS_MSG
  1823. + *    This symbol, if defined, indicates that the entire msg*(2) library is
  1824. + *    supported.
  1825. + */
  1826. +#define    HAS_MSG        /**/
  1827. +
  1828. +/* HAS_MSGCTL
  1829. + *    This symbol, if defined, indicates that the msgctl() routine is
  1830. + *    available to control message passing.
  1831. + */
  1832. +#define    HAS_MSGCTL        /**/
  1833. +
  1834. +/* HAS_MSGGET
  1835. + *    This symbol, if defined, indicates that the msgget() routine is
  1836. + *    available to get messages.
  1837. + */
  1838. +#define    HAS_MSGGET        /**/
  1839. +
  1840. +/* HAS_MSGRCV
  1841. + *    This symbol, if defined, indicates that the msgrcv() routine is
  1842. + *    available to receive messages.
  1843. + */
  1844. +#define    HAS_MSGRCV        /**/
  1845. +
  1846. +/* HAS_MSGSND
  1847. + *    This symbol, if defined, indicates that the msgsnd() routine is
  1848. + *    available to send messages.
  1849. + */
  1850. +#define    HAS_MSGSND        /**/
  1851. +
  1852. +/* HAS_NDBM
  1853. + *    This symbol, if defined, indicates that ndbm.h exists and should
  1854. + *    be included.
  1855. + */
  1856. +#define    HAS_NDBM        /**/
  1857. +
  1858. +/* HAS_ODBM
  1859. + *    This symbol, if defined, indicates that dbm.h exists and should
  1860. + *    be included.
  1861. + */
  1862. +#define    HAS_ODBM        /**/
  1863. +
  1864. +/* HAS_OPEN3
  1865. + *    This manifest constant lets the C program know that the three
  1866. + *    argument form of open(2) is available.
  1867. + */
  1868. +#define    HAS_OPEN3        /**/
  1869. +
  1870. +/* HAS_READDIR
  1871. + *    This symbol, if defined, indicates that the readdir routine is available
  1872. + *    from the C library to read directories.
  1873. + */
  1874. +#define    HAS_READDIR        /**/
  1875. +
  1876. +/* HAS_RENAME
  1877. + *    This symbol, if defined, indicates that the rename routine is available
  1878. + *    to rename files.  Otherwise you should do the unlink(), link(), unlink()
  1879. + *    trick.
  1880. + */
  1881. +#define    HAS_RENAME        /**/
  1882. +
  1883. +/* HAS_REWINDDIR
  1884. + *    This symbol, if defined, indicates that the rewindir routine is
  1885. + *    available to rewind directories.
  1886. + */
  1887. +#define    HAS_REWINDDIR        /**/
  1888. +
  1889. +/* HAS_RMDIR
  1890. + *    This symbol, if defined, indicates that the rmdir routine is available
  1891. + *    to remove directories.  Otherwise you should fork off a new process to
  1892. + *    exec /bin/rmdir.
  1893. + */
  1894. +#define    HAS_RMDIR        /**/
  1895. +
  1896. +/* HAS_SEEKDIR
  1897. + *    This symbol, if defined, indicates that the seekdir routine is
  1898. + *    available to seek into directories.
  1899. + */
  1900. +#define    HAS_SEEKDIR        /**/
  1901. +
  1902. +/* HAS_SELECT
  1903. + *    This symbol, if defined, indicates that the select() subroutine
  1904. + *    exists.
  1905. + */
  1906. +#define    HAS_SELECT    /**/
  1907. +
  1908. +/* HAS_SEM
  1909. + *    This symbol, if defined, indicates that the entire sem*(2) library is
  1910. + *    supported.
  1911. + */
  1912. +#define    HAS_SEM        /**/
  1913. +
  1914. +/* HAS_SEMCTL
  1915. + *    This symbol, if defined, indicates that the semctl() routine is
  1916. + *    available to control semaphores.
  1917. + */
  1918. +#define    HAS_SEMCTL        /**/
  1919. +
  1920. +/* HAS_SEMGET
  1921. + *    This symbol, if defined, indicates that the semget() routine is
  1922. + *    available to get semaphores ids.
  1923. + */
  1924. +#define    HAS_SEMGET        /**/
  1925. +
  1926. +/* HAS_SEMOP
  1927. + *    This symbol, if defined, indicates that the semop() routine is
  1928. + *    available to perform semaphore operations.
  1929. + */
  1930. +#define    HAS_SEMOP        /**/
  1931. +
  1932. +/* HAS_SETEGID
  1933. + *    This symbol, if defined, indicates that the setegid routine is available
  1934. + *    to change the effective gid of the current program.
  1935. + */
  1936. +#define    HAS_SETEGID        /**/
  1937. +
  1938. +/* HAS_SETEUID
  1939. + *    This symbol, if defined, indicates that the seteuid routine is available
  1940. + *    to change the effective uid of the current program.
  1941. + */
  1942. +#define    HAS_SETEUID        /**/
  1943. +
  1944. +/* HAS_SETPGRP
  1945. + *    This symbol, if defined, indicates that the setpgrp() routine is
  1946. + *    available to set the current process group.
  1947. + */
  1948. +#define    HAS_SETPGRP        /**/
  1949. +
  1950. +/* HAS_SETPGRP2
  1951. + *    This symbol, if defined, indicates that the setpgrp2() (as in DG/UX)
  1952. + *    routine is available to set the current process group.
  1953. + */
  1954. +/*#undef    HAS_SETPGRP2        /**/
  1955. +
  1956. +/* HAS_SETPRIORITY
  1957. + *    This symbol, if defined, indicates that the setpriority() routine is
  1958. + *    available to set a process's priority.
  1959. + */
  1960. +/*#undef    HAS_SETPRIORITY        /**/
  1961. +
  1962. +/* HAS_SETREGID
  1963. + *    This symbol, if defined, indicates that the setregid routine is
  1964. + *    available to change the real and effective gid of the current program.
  1965. + */
  1966. +/* HAS_SETRESGID
  1967. + *    This symbol, if defined, indicates that the setresgid routine is
  1968. + *    available to change the real, effective and saved gid of the current
  1969. + *    program.
  1970. + */
  1971. +#define    HAS_SETREGID        /**/
  1972. +/*#undef    HAS_SETRESGID        /**/
  1973. +
  1974. +/* HAS_SETREUID
  1975. + *    This symbol, if defined, indicates that the setreuid routine is
  1976. + *    available to change the real and effective uid of the current program.
  1977. + */
  1978. +/* HAS_SETRESUID
  1979. + *    This symbol, if defined, indicates that the setresuid routine is
  1980. + *    available to change the real, effective and saved uid of the current
  1981. + *    program.
  1982. + */
  1983. +#define    HAS_SETREUID        /**/
  1984. +/*#undef    HAS_SETRESUID        /**/
  1985. +
  1986. +/* HAS_SETRGID
  1987. + *    This symbol, if defined, indicates that the setrgid routine is available
  1988. + *    to change the real gid of the current program.
  1989. + */
  1990. +/*#undef    HAS_SETRGID        /**/
  1991. +
  1992. +/* HAS_SETRUID
  1993. + *    This symbol, if defined, indicates that the setruid routine is available
  1994. + *    to change the real uid of the current program.
  1995. + */
  1996. +/*#undef    HAS_SETRUID        /**/
  1997. +
  1998. +/* HAS_SHM
  1999. + *    This symbol, if defined, indicates that the entire shm*(2) library is
  2000. + *    supported.
  2001. + */
  2002. +#define    HAS_SHM        /**/
  2003. +
  2004. +/* HAS_SHMAT
  2005. + *    This symbol, if defined, indicates that the shmat() routine is
  2006. + *    available to attach a shared memory segment.
  2007. + */
  2008. +/* VOID_SHMAT
  2009. + *    This symbol, if defined, indicates that the shmat() routine
  2010. + *    returns a pointer of type void*.
  2011. + */
  2012. +#define    HAS_SHMAT        /**/
  2013. +
  2014. +/*#undef    VOIDSHMAT        /**/
  2015. +
  2016. +/* HAS_SHMCTL
  2017. + *    This symbol, if defined, indicates that the shmctl() routine is
  2018. + *    available to control a shared memory segment.
  2019. + */
  2020. +#define    HAS_SHMCTL        /**/
  2021. +
  2022. +/* HAS_SHMDT
  2023. + *    This symbol, if defined, indicates that the shmdt() routine is
  2024. + *    available to detach a shared memory segment.
  2025. + */
  2026. +#define    HAS_SHMDT        /**/
  2027. +
  2028. +/* HAS_SHMGET
  2029. + *    This symbol, if defined, indicates that the shmget() routine is
  2030. + *    available to get a shared memory segment id.
  2031. + */
  2032. +#define    HAS_SHMGET        /**/
  2033. +
  2034. +/* HAS_SOCKET
  2035. + *    This symbol, if defined, indicates that the BSD socket interface is
  2036. + *    supported.
  2037. + */
  2038. +/* HAS_SOCKETPAIR
  2039. + *    This symbol, if defined, indicates that the BSD socketpair call is
  2040. + *    supported.
  2041. + */
  2042. +/* OLDSOCKET
  2043. + *    This symbol, if defined, indicates that the 4.1c BSD socket interface
  2044. + *    is supported instead of the 4.2/4.3 BSD socket interface.
  2045. + */
  2046. +#define    HAS_SOCKET        /**/
  2047. +
  2048. +#define    HAS_SOCKETPAIR    /**/
  2049. +
  2050. +/*#undef    OLDSOCKET    /**/
  2051. +
  2052. +/* STATBLOCKS
  2053. + *    This symbol is defined if this system has a stat structure declaring
  2054. + *    st_blksize and st_blocks.
  2055. + */
  2056. +#define    STATBLOCKS     /**/
  2057. +
  2058. +/* STDSTDIO
  2059. + *    This symbol is defined if this system has a FILE structure declaring
  2060. + *    _ptr and _cnt in stdio.h.
  2061. + */
  2062. +/*#undef    STDSTDIO     /**/
  2063. +
  2064. +/* STRUCTCOPY
  2065. + *    This symbol, if defined, indicates that this C compiler knows how
  2066. + *    to copy structures.  If undefined, you'll need to use a block copy
  2067. + *    routine of some sort instead.
  2068. + */
  2069. +#define    STRUCTCOPY    /**/
  2070. +
  2071. +/* HAS_STRERROR
  2072. + *    This symbol, if defined, indicates that the strerror() routine is
  2073. + *    available to translate error numbers to strings.
  2074. + */
  2075. +#define    HAS_STRERROR        /**/
  2076. +
  2077. +/* HAS_SYMLINK
  2078. + *    This symbol, if defined, indicates that the symlink routine is available
  2079. + *    to create symbolic links.
  2080. + */
  2081. +#define    HAS_SYMLINK        /**/
  2082. +
  2083. +/* HAS_SYSCALL
  2084. + *    This symbol, if defined, indicates that the syscall routine is available
  2085. + *    to call arbitrary system calls.  If undefined, that's tough.
  2086. + */
  2087. +#define    HAS_SYSCALL        /**/
  2088. +
  2089. +/* HAS_TELLDIR
  2090. + *    This symbol, if defined, indicates that the telldir routine is
  2091. + *    available to tell your location in directories.
  2092. + */
  2093. +#define    HAS_TELLDIR        /**/
  2094. +
  2095. +/* HAS_TRUNCATE
  2096. + *    This symbol, if defined, indicates that the truncate routine is
  2097. + *    available to truncate files.
  2098. + */
  2099. +#define    HAS_TRUNCATE        /**/
  2100. +
  2101. +/* HAS_VFORK
  2102. + *    This symbol, if defined, indicates that vfork() exists.
  2103. + */
  2104. +#define    HAS_VFORK    /**/
  2105. +
  2106. +/* VOIDSIG
  2107. + *    This symbol is defined if this system declares "void (*signal())()" in
  2108. + *    signal.h.  The old way was to declare it as "int (*signal())()".  It
  2109. + *    is up to the package author to declare things correctly based on the
  2110. + *    symbol.
  2111. + */
  2112. +/* TO_SIGNAL
  2113. + *    This symbol's value is either "void" or "int", corresponding to the
  2114. + *    appropriate return "type" of a signal handler.  Thus, one can declare
  2115. + *    a signal handler using "TO_SIGNAL (*handler())()", and define the
  2116. + *    handler using "TO_SIGNAL handler(sig)".
  2117. + */
  2118. +#define    VOIDSIG     /**/
  2119. +#define    TO_SIGNAL    int     /**/
  2120. +
  2121. +/* HASVOLATILE
  2122. + *    This symbol, if defined, indicates that this C compiler knows about
  2123. + *    the volatile declaration.
  2124. + */
  2125. +#define    HASVOLATILE    /**/
  2126. +
  2127. +/* HAS_VPRINTF
  2128. + *    This symbol, if defined, indicates that the vprintf routine is available
  2129. + *    to printf with a pointer to an argument list.  If unavailable, you
  2130. + *    may need to write your own, probably in terms of _doprnt().
  2131. + */
  2132. +/* CHARVSPRINTF
  2133. + *    This symbol is defined if this system has vsprintf() returning type
  2134. + *    (char*).  The trend seems to be to declare it as "int vsprintf()".  It
  2135. + *    is up to the package author to declare vsprintf correctly based on the
  2136. + *    symbol.
  2137. + */
  2138. +#define    HAS_VPRINTF    /**/
  2139. +/*#undef    CHARVSPRINTF     /**/
  2140. +
  2141. +/* HAS_WAIT4
  2142. + *    This symbol, if defined, indicates that wait4() exists.
  2143. + */
  2144. +#define    HAS_WAIT4    /**/
  2145. +
  2146. +/* HAS_WAITPID
  2147. + *    This symbol, if defined, indicates that waitpid() exists.
  2148. + */
  2149. +#define    HAS_WAITPID    /**/
  2150. +
  2151. +/* GIDTYPE
  2152. + *    This symbol has a value like gid_t, int, ushort, or whatever type is
  2153. + *    used to declare group ids in the kernel.
  2154. + */
  2155. +#define GIDTYPE unsigned short        /**/
  2156. +
  2157. +/* GROUPSTYPE
  2158. + *    This symbol has a value like gid_t, int, ushort, or whatever type is
  2159. + *    used in the return value of getgroups().
  2160. + */
  2161. +#define GROUPSTYPE unsigned short        /**/
  2162. +
  2163. +/* I_FCNTL
  2164. + *    This manifest constant tells the C program to include <fcntl.h>.
  2165. + */
  2166. +/*#undef    I_FCNTL    /**/
  2167. +
  2168. +/* I_GDBM
  2169. + *    This symbol, if defined, indicates that gdbm.h exists and should
  2170. + *    be included.
  2171. + */
  2172. +#define    I_GDBM        /**/
  2173. +
  2174. +/* I_GRP
  2175. + *    This symbol, if defined, indicates to the C program that it should
  2176. + *    include grp.h.
  2177. + */
  2178. +#define    I_GRP        /**/
  2179. +
  2180. +/* I_NETINET_IN
  2181. + *    This symbol, if defined, indicates to the C program that it should
  2182. + *    include netinet/in.h.
  2183. + */
  2184. +/* I_SYS_IN
  2185. + *    This symbol, if defined, indicates to the C program that it should
  2186. + *    include sys/in.h.
  2187. + */
  2188. +#define    I_NETINET_IN        /**/
  2189. +/*#undef    I_SYS_IN        /**/
  2190. +
  2191. +/* I_PWD
  2192. + *    This symbol, if defined, indicates to the C program that it should
  2193. + *    include pwd.h.
  2194. + */
  2195. +/* PWQUOTA
  2196. + *    This symbol, if defined, indicates to the C program that struct passwd
  2197. + *    contains pw_quota.
  2198. + */
  2199. +/* PWAGE
  2200. + *    This symbol, if defined, indicates to the C program that struct passwd
  2201. + *    contains pw_age.
  2202. + */
  2203. +/* PWCHANGE
  2204. + *    This symbol, if defined, indicates to the C program that struct passwd
  2205. + *    contains pw_change.
  2206. + */
  2207. +/* PWCLASS
  2208. + *    This symbol, if defined, indicates to the C program that struct passwd
  2209. + *    contains pw_class.
  2210. + */
  2211. +/* PWEXPIRE
  2212. + *    This symbol, if defined, indicates to the C program that struct passwd
  2213. + *    contains pw_expire.
  2214. + */
  2215. +/* PWCOMMENT
  2216. + *    This symbol, if defined, indicates to the C program that struct passwd
  2217. + *    contains pw_comment.
  2218. + */
  2219. +#define    I_PWD        /**/
  2220. +/*#undef    PWQUOTA        /**/
  2221. +/*#undef    PWAGE        /**/
  2222. +/*#undef    PWCHANGE    /**/
  2223. +/*#undef    PWCLASS        /**/
  2224. +/*#undef    PWEXPIRE    /**/
  2225. +/*#undef    PWCOMMENT    /**/
  2226. +
  2227. +/* I_SYS_FILE
  2228. + *    This manifest constant tells the C program to include <sys/file.h>.
  2229. + */
  2230. +#define    I_SYS_FILE    /**/
  2231. +
  2232. +/* I_SYSIOCTL
  2233. + *    This symbol, if defined, indicates that sys/ioctl.h exists and should
  2234. + *    be included.
  2235. + */
  2236. +#define    I_SYSIOCTL        /**/
  2237. +
  2238. +/* I_TIME
  2239. + *    This symbol is defined if the program should include <time.h>.
  2240. + */
  2241. +/* I_SYS_TIME
  2242. + *    This symbol is defined if the program should include <sys/time.h>.
  2243. + */
  2244. +/* SYSTIMEKERNEL
  2245. + *    This symbol is defined if the program should include <sys/time.h>
  2246. + *    with KERNEL defined.
  2247. + */
  2248. +/* I_SYS_SELECT
  2249. + *    This symbol is defined if the program should include <sys/select.h>.
  2250. + */
  2251. +/*#undef    I_TIME         /**/
  2252. +#define    I_SYS_TIME     /**/
  2253. +/*#undef    SYSTIMEKERNEL     /**/
  2254. +/*#undef    I_SYS_SELECT     /**/
  2255. +
  2256. +/* I_UTIME
  2257. + *    This symbol, if defined, indicates to the C program that it should
  2258. + *    include utime.h.
  2259. + */
  2260. +#define    I_UTIME        /**/
  2261. +
  2262. +/* I_VARARGS
  2263. + *    This symbol, if defined, indicates to the C program that it should
  2264. + *    include varargs.h.
  2265. + */
  2266. +/*#undef    I_VARARGS        /**/
  2267. +
  2268. +/* I_VFORK
  2269. + *    This symbol, if defined, indicates to the C program that it should
  2270. + *    include vfork.h.
  2271. + */
  2272. +/*#undef    I_VFORK        /**/
  2273. +
  2274. +/* INTSIZE
  2275. + *    This symbol contains the size of an int, so that the C preprocessor
  2276. + *    can make decisions based on it.
  2277. + */
  2278. +#define INTSIZE 4        /**/
  2279. +
  2280. +/* I_DIRENT
  2281. + *    This symbol, if defined, indicates that the program should use the
  2282. + *    P1003-style directory routines, and include <dirent.h>.
  2283. + */
  2284. +/* I_SYS_DIR
  2285. + *    This symbol, if defined, indicates that the program should use the
  2286. + *    directory functions by including <sys/dir.h>.
  2287. + */
  2288. +/* I_NDIR
  2289. + *    This symbol, if defined, indicates that the program should include the
  2290. + *    system's version of ndir.h, rather than the one with this package.
  2291. + */
  2292. +/* I_SYS_NDIR
  2293. + *    This symbol, if defined, indicates that the program should include the
  2294. + *    system's version of sys/ndir.h, rather than the one with this package.
  2295. + */
  2296. +/* I_MY_DIR
  2297. + *    This symbol, if defined, indicates that the program should compile
  2298. + *    the ndir.c code provided with the package.
  2299. + */
  2300. +/* DIRNAMLEN
  2301. + *    This symbol, if defined, indicates to the C program that the length
  2302. + *    of directory entry names is provided by a d_namlen field.  Otherwise
  2303. + *    you need to do strlen() on the d_name field.
  2304. + */
  2305. +#define    I_DIRENT    /**/
  2306. +/*#undef    I_SYS_DIR    /**/
  2307. +/*#undef    I_NDIR        /**/
  2308. +/*#undef    I_SYS_NDIR    /**/
  2309. +/*#undef    I_MY_DIR    /**/
  2310. +#define    DIRNAMLEN    /**/
  2311. +
  2312. +/* MYMALLOC
  2313. + *    This symbol, if defined, indicates that we're using our own malloc.
  2314. + */
  2315. +/* MALLOCPTRTYPE
  2316. + *    This symbol defines the kind of ptr returned by malloc and realloc.
  2317. + */
  2318. +/*#undef MYMALLOC            /**/
  2319. +
  2320. +#define MALLOCPTRTYPE void         /**/
  2321. +
  2322. +
  2323. +/* RANDBITS
  2324. + *    This symbol contains the number of bits of random number the rand()
  2325. + *    function produces.  Usual values are 15, 16, and 31.
  2326. + */
  2327. +#define RANDBITS 31        /**/
  2328. +
  2329. +/* SCRIPTDIR
  2330. + *    This symbol holds the name of the directory in which the user wants
  2331. + *    to keep publicly executable scripts for the package in question.  It
  2332. + *    is often a directory that is mounted across diverse architectures.
  2333. + */
  2334. +#define SCRIPTDIR "/usr/bin"             /**/
  2335. +
  2336. +/* SIG_NAME
  2337. + *    This symbol contains an list of signal names in order.
  2338. + */
  2339. +#define SIG_NAME "ZERO","HUP","INT","QUIT","ILL","TRAP","IOT","BUS","FPE","KILL","USR1","SEGV","USR2","PIPE","ALRM","TERM","STKFLT","CHLD","CONT","STOP","TSTP","TTIN","TTOU","URG","XCPU","XFSZ","VTALRM","PROF","WINCH","LOST","PWR","UNUSED"        /**/
  2340. +
  2341. +/* STDCHAR
  2342. + *    This symbol is defined to be the type of char used in stdio.h.
  2343. + *    It has the values "unsigned char" or "char".
  2344. + */
  2345. +#define STDCHAR char    /**/
  2346. +
  2347. +/* UIDTYPE
  2348. + *    This symbol has a value like uid_t, int, ushort, or whatever type is
  2349. + *    used to declare user ids in the kernel.
  2350. + */
  2351. +#define UIDTYPE unsigned short        /**/
  2352. +
  2353. +/* VOIDHAVE
  2354. + *    This symbol indicates how much support of the void type is given by this
  2355. + *    compiler.  What various bits mean:
  2356. + *
  2357. + *        1 = supports declaration of void
  2358. + *        2 = supports arrays of pointers to functions returning void
  2359. + *        4 = supports comparisons between pointers to void functions and
  2360. + *            addresses of void functions
  2361. + *
  2362. + *    The package designer should define VOIDWANT to indicate the requirements
  2363. + *    of the package.  This can be done either by #defining VOIDWANT before
  2364. + *    including config.h, or by defining voidwant in Myinit.U.  If the level
  2365. + *    of void support necessary is not present, config.h defines void to "int",
  2366. + *    VOID to the empty string, and VOIDP to "char *".
  2367. + */
  2368. +/* void
  2369. + *    This symbol is used for void casts.  On implementations which support
  2370. + *    void appropriately, its value is "void".  Otherwise, its value maps
  2371. + *    to "int".
  2372. + */
  2373. +/* VOID
  2374. + *    This symbol's value is "void" if the implementation supports void
  2375. + *    appropriately.  Otherwise, its value is the empty string.  The primary
  2376. + *    use of this symbol is in specifying void parameter lists for function
  2377. + *    prototypes.
  2378. + */
  2379. +/* VOIDP
  2380. + *    This symbol is used for casting generic pointers.  On implementations
  2381. + *    which support void appropriately, its value is "void *".  Otherwise,
  2382. + *    its value is "char *".
  2383. + */
  2384. +#ifndef VOIDWANT
  2385. +#define VOIDWANT 7
  2386. +#endif
  2387. +#define VOIDHAVE 7
  2388. +#if (VOIDHAVE & VOIDWANT) != VOIDWANT
  2389. +#define void int        /* is void to be avoided? */
  2390. +#define VOID
  2391. +#define VOIDP (char *)
  2392. +#define M_VOID        /* Xenix strikes again */
  2393. +#else
  2394. +#define VOID void
  2395. +#define VOIDP (void *)
  2396. +#endif
  2397. +
  2398. +/* PRIVLIB
  2399. + *    This symbol contains the name of the private library for this package.
  2400. + *    The library is private in the sense that it needn't be in anyone's
  2401. + *    execution path, but it should be accessible by the world.  The program
  2402. + *    should be prepared to do ~ expansion.
  2403. + */
  2404. +#define PRIVLIB "/usr/lib/perl4"        /**/
  2405. +
  2406. +#endif
  2407. diff -u --new-file --recursive perl-4.036.orig/config.sh perl-4.036/config.sh
  2408. --- perl-4.036.orig/config.sh    Wed Dec 31 18:00:00 1969
  2409. +++ perl-4.036/config.sh    Tue Jan 17 21:16:24 1995
  2410. @@ -0,0 +1,268 @@
  2411. +#!/bin/sh
  2412. +# config.sh
  2413. +# This file was produced by running the Configure script.
  2414. +d_eunice='undef'
  2415. +define='define'
  2416. +eunicefix=':'
  2417. +loclist='
  2418. +cat
  2419. +cp
  2420. +echo
  2421. +expr
  2422. +grep
  2423. +mkdir
  2424. +mv
  2425. +rm
  2426. +sed
  2427. +sort
  2428. +tr
  2429. +uniq
  2430. +'
  2431. +expr='/usr/bin/expr'
  2432. +sed='/usr/bin/sed'
  2433. +echo='/bin/echo'
  2434. +cat='/bin/cat'
  2435. +rm='/bin/rm'
  2436. +mv='/bin/mv'
  2437. +cp='/bin/cp'
  2438. +tail=''
  2439. +tr='/usr/bin/tr'
  2440. +mkdir='/bin/mkdir'
  2441. +sort='/usr/bin/sort'
  2442. +uniq='/usr/bin/uniq'
  2443. +grep='/usr/bin/grep'
  2444. +trylist='
  2445. +Mcc
  2446. +bison
  2447. +cpp
  2448. +csh
  2449. +egrep
  2450. +line
  2451. +nroff
  2452. +perl
  2453. +test
  2454. +uname
  2455. +yacc
  2456. +'
  2457. +test='test'
  2458. +inews=''
  2459. +egrep='/usr/bin/egrep'
  2460. +more=''
  2461. +pg=''
  2462. +Mcc='Mcc'
  2463. +vi=''
  2464. +mailx=''
  2465. +mail=''
  2466. +cpp='/lib/cpp'
  2467. +perl='/usr/bin/perl'
  2468. +emacs=''
  2469. +ls=''
  2470. +rmail=''
  2471. +sendmail=''
  2472. +shar=''
  2473. +smail=''
  2474. +tbl=''
  2475. +troff=''
  2476. +nroff='groff'
  2477. +uname='/bin/uname'
  2478. +uuname=''
  2479. +line='line'
  2480. +chgrp=''
  2481. +chmod=''
  2482. +lint=''
  2483. +sleep=''
  2484. +pr=''
  2485. +tar=''
  2486. +ln=''
  2487. +lpr=''
  2488. +lp=''
  2489. +touch=''
  2490. +make=''
  2491. +date=''
  2492. +csh='/bin/csh'
  2493. +bash=''
  2494. +ksh=''
  2495. +lex=''
  2496. +flex=''
  2497. +bison='/usr/bin/bison'
  2498. +Log='$Log'
  2499. +Header='$Header'
  2500. +Id='$Id'
  2501. +lastuname='Linux fuzzy 1.1.82 #2 Mon Jan 16 10:30:09 EST 1995 i486'
  2502. +alignbytes='4'
  2503. +bin='/usr/bin'
  2504. +installbin='/usr/bin'
  2505. +byteorder='1234'
  2506. +contains='grep'
  2507. +cppstdin='cppstdin'
  2508. +cppminus=''
  2509. +d_bcmp='define'
  2510. +d_bcopy='define'
  2511. +d_safebcpy='define'
  2512. +d_bzero='define'
  2513. +d_castneg='define'
  2514. +castflags='0'
  2515. +d_charsprf='undef'
  2516. +d_chsize='undef'
  2517. +d_crypt='define'
  2518. +cryptlib=''
  2519. +d_csh='define'
  2520. +d_dosuid='undef'
  2521. +d_dup2='define'
  2522. +d_fchmod='define'
  2523. +d_fchown='define'
  2524. +d_fcntl='define'
  2525. +d_flexfnam='define'
  2526. +d_flock='define'
  2527. +d_getgrps='undef'
  2528. +d_gethent='undef'
  2529. +d_getpgrp='define'
  2530. +d_getpgrp2='undef'
  2531. +d_getprior='undef'
  2532. +d_htonl='undef'
  2533. +d_index='undef'
  2534. +d_isascii='undef'
  2535. +d_killpg='define'
  2536. +d_lstat='define'
  2537. +d_memcmp='define'
  2538. +d_memcpy='define'
  2539. +d_safemcpy='undef'
  2540. +d_memmove='define'
  2541. +d_memset='define'
  2542. +d_mkdir='define'
  2543. +d_msg='define'
  2544. +d_msgctl='define'
  2545. +d_msgget='define'
  2546. +d_msgrcv='define'
  2547. +d_msgsnd='define'
  2548. +d_ndbm='define'
  2549. +d_odbm='define'
  2550. +d_open3='define'
  2551. +d_readdir='define'
  2552. +d_rename='define'
  2553. +d_rewindir='define'
  2554. +d_rmdir='define'
  2555. +d_seekdir='define'
  2556. +d_select='define'
  2557. +d_sem='define'
  2558. +d_semctl='define'
  2559. +d_semget='define'
  2560. +d_semop='define'
  2561. +d_setegid='define'
  2562. +d_seteuid='define'
  2563. +d_setpgrp='define'
  2564. +d_setpgrp2='undef'
  2565. +d_setprior='undef'
  2566. +d_setregid='define'
  2567. +d_setresgid='undef'
  2568. +d_setreuid='define'
  2569. +d_setresuid='undef'
  2570. +d_setrgid='undef'
  2571. +d_setruid='undef'
  2572. +d_shm='define'
  2573. +d_shmat='define'
  2574. +d_voidshmat='undef'
  2575. +d_shmctl='define'
  2576. +d_shmdt='define'
  2577. +d_shmget='define'
  2578. +d_socket='define'
  2579. +d_sockpair='define'
  2580. +d_oldsock='undef'
  2581. +socketlib=''
  2582. +d_statblks='define'
  2583. +d_stdstdio='undef'
  2584. +d_strctcpy='define'
  2585. +d_strerror='define'
  2586. +d_symlink='define'
  2587. +d_syscall='define'
  2588. +d_telldir='define'
  2589. +d_truncate='define'
  2590. +d_vfork='define'
  2591. +d_voidsig='define'
  2592. +d_tosignal='int'
  2593. +d_volatile='define'
  2594. +d_vprintf='define'
  2595. +d_charvspr='undef'
  2596. +d_wait4='define'
  2597. +d_waitpid='define'
  2598. +gidtype='unsigned short'
  2599. +groupstype='unsigned short'
  2600. +i_fcntl='undef'
  2601. +i_gdbm='define'
  2602. +i_grp='define'
  2603. +i_niin='define'
  2604. +i_sysin='undef'
  2605. +i_pwd='define'
  2606. +d_pwquota='undef'
  2607. +d_pwage='undef'
  2608. +d_pwchange='undef'
  2609. +d_pwclass='undef'
  2610. +d_pwexpire='undef'
  2611. +d_pwcomment='undef'
  2612. +i_sys_file='define'
  2613. +i_sysioctl='define'
  2614. +i_time='undef'
  2615. +i_sys_time='define'
  2616. +i_sys_select='undef'
  2617. +d_systimekernel='undef'
  2618. +i_utime='define'
  2619. +i_varargs='undef'
  2620. +i_vfork='undef'
  2621. +intsize='4'
  2622. +libc='/usr/lib/libc.a'
  2623. +nm_opts=''
  2624. +libndir=''
  2625. +i_my_dir='undef'
  2626. +i_ndir='undef'
  2627. +i_sys_ndir='undef'
  2628. +i_dirent='define'
  2629. +i_sys_dir='undef'
  2630. +d_dirnamlen='define'
  2631. +ndirc=''
  2632. +ndiro=''
  2633. +mallocsrc=''
  2634. +mallocobj=''
  2635. +d_mymalloc='undef'
  2636. +mallocptrtype='void'
  2637. +mansrc='/usr/man/man1'
  2638. +manext='1'
  2639. +models='none'
  2640. +split=''
  2641. +small=''
  2642. +medium=''
  2643. +large=''
  2644. +huge=''
  2645. +optimize='-O2'
  2646. +ccflags=''
  2647. +cppflags=''
  2648. +ldflags='-s'
  2649. +cc='gcc'
  2650. +nativegcc='define'
  2651. +libs='-ldbm -lm'
  2652. +n='-n'
  2653. +c=''
  2654. +package='perl(linux-36LA)'
  2655. +randbits='31'
  2656. +scriptdir='/usr/bin'
  2657. +installscr='/usr/bin'
  2658. +sig_name='ZERO HUP INT QUIT ILL TRAP IOT BUS FPE KILL USR1 SEGV USR2 PIPE ALRM TERM STKFLT CHLD CONT STOP TSTP TTIN TTOU URG XCPU XFSZ VTALRM PROF WINCH LOST PWR UNUSED'
  2659. +spitshell='cat'
  2660. +shsharp='true'
  2661. +sharpbang='#!'
  2662. +startsh='#!/bin/sh'
  2663. +stdchar='char'
  2664. +uidtype='unsigned short'
  2665. +usrinclude='/usr/include'
  2666. +inclPath=''
  2667. +void=''
  2668. +voidhave='7'
  2669. +voidwant='7'
  2670. +w_localtim='1'
  2671. +w_s_timevl='1'
  2672. +w_s_tm='1'
  2673. +yacc='bison -y'
  2674. +lib=''
  2675. +privlib='/usr/lib/perl4'
  2676. +installprivlib='/usr/lib/perl4'
  2677. +PATCHLEVEL=36
  2678. +CONFIG=true
  2679. diff -u --new-file --recursive perl-4.036.orig/cppstdin perl-4.036/cppstdin
  2680. --- perl-4.036.orig/cppstdin    Wed Dec 31 18:00:00 1969
  2681. +++ perl-4.036/cppstdin    Tue Jan 17 21:15:05 1995
  2682. @@ -0,0 +1 @@
  2683. +cat >.$$.c; gcc -E ${1+"$@"} .$$.c; rm .$$.c
  2684. diff -u --new-file --recursive perl-4.036.orig/h2ph perl-4.036/h2ph
  2685. --- perl-4.036.orig/h2ph    Wed Dec 31 18:00:00 1969
  2686. +++ perl-4.036/h2ph    Tue Jan 17 21:16:29 1995
  2687. @@ -0,0 +1,253 @@
  2688. +#!/usr/bin/perl
  2689. +'di';
  2690. +'ig00';
  2691. +
  2692. +$perlincl = '/usr/lib/perl4';
  2693. +
  2694. +chdir '/usr/include' || die "Can't cd /usr/include";
  2695. +
  2696. +@isatype = split(' ',<<END);
  2697. +    char    uchar    u_char
  2698. +    short    ushort    u_short
  2699. +    int    uint    u_int
  2700. +    long    ulong    u_long
  2701. +    FILE
  2702. +END
  2703. +
  2704. +@isatype{@isatype} = (1) x @isatype;
  2705. +
  2706. +@ARGV = ('-') unless @ARGV;
  2707. +
  2708. +foreach $file (@ARGV) {
  2709. +    if ($file eq '-') {
  2710. +    open(IN, "-");
  2711. +    open(OUT, ">-");
  2712. +    }
  2713. +    else {
  2714. +    ($outfile = $file) =~ s/\.h$/.ph/ || next;
  2715. +    print "$file -> $outfile\n";
  2716. +    if ($file =~ m|^(.*)/|) {
  2717. +        $dir = $1;
  2718. +        if (!-d "$perlincl/$dir") {
  2719. +        mkdir("$perlincl/$dir",0777);
  2720. +        }
  2721. +    }
  2722. +    open(IN,"$file") || ((warn "Can't open $file: $!\n"),next);
  2723. +    open(OUT,">$perlincl/$outfile") || die "Can't create $outfile: $!\n";
  2724. +    }
  2725. +    while (<IN>) {
  2726. +    chop;
  2727. +    while (/\\$/) {
  2728. +        chop;
  2729. +        $_ .= <IN>;
  2730. +        chop;
  2731. +    }
  2732. +    if (s:/\*:\200:g) {
  2733. +        s:\*/:\201:g;
  2734. +        s/\200[^\201]*\201//g;    # delete single line comments
  2735. +        if (s/\200.*//) {        # begin multi-line comment?
  2736. +        $_ .= '/*';
  2737. +        $_ .= <IN>;
  2738. +        redo;
  2739. +        }
  2740. +    }
  2741. +    if (s/^#\s*//) {
  2742. +        if (s/^define\s+(\w+)//) {
  2743. +        $name = $1;
  2744. +        $new = '';
  2745. +        s/\s+$//;
  2746. +        if (s/^\(([\w,\s]*)\)//) {
  2747. +            $args = $1;
  2748. +            if ($args ne '') {
  2749. +            foreach $arg (split(/,\s*/,$args)) {
  2750. +                $arg =~ s/^\s*([^\s].*[^\s])\s*$/$1/;
  2751. +                $curargs{$arg} = 1;
  2752. +            }
  2753. +            $args =~ s/\b(\w)/\$$1/g;
  2754. +            $args = "local($args) = \@_;\n$t    ";
  2755. +            }
  2756. +            s/^\s+//;
  2757. +            do expr();
  2758. +            $new =~ s/(["\\])/\\$1/g;
  2759. +            if ($t ne '') {
  2760. +            $new =~ s/(['\\])/\\$1/g;
  2761. +            print OUT $t,
  2762. +              "eval 'sub $name {\n$t    ${args}eval \"$new\";\n$t}';\n";
  2763. +            }
  2764. +            else {
  2765. +            print OUT "sub $name {\n    ${args}eval \"$new\";\n}\n";
  2766. +            }
  2767. +            %curargs = ();
  2768. +        }
  2769. +        else {
  2770. +            s/^\s+//;
  2771. +            do expr();
  2772. +            $new = 1 if $new eq '';
  2773. +            if ($t ne '') {
  2774. +            $new =~ s/(['\\])/\\$1/g;
  2775. +            print OUT $t,"eval 'sub $name {",$new,";}';\n";
  2776. +            }
  2777. +            else {
  2778. +            print OUT $t,"sub $name {",$new,";}\n";
  2779. +            }
  2780. +        }
  2781. +        }
  2782. +        elsif (/^include\s+<(.*)>/) {
  2783. +        ($incl = $1) =~ s/\.h$/.ph/;
  2784. +        print OUT $t,"require '$incl';\n";
  2785. +        }
  2786. +        elsif (/^ifdef\s+(\w+)/) {
  2787. +        print OUT $t,"if (defined &$1) {\n";
  2788. +        $tab += 4;
  2789. +        $t = "\t" x ($tab / 8) . ' ' x ($tab % 8);
  2790. +        }
  2791. +        elsif (/^ifndef\s+(\w+)/) {
  2792. +        print OUT $t,"if (!defined &$1) {\n";
  2793. +        $tab += 4;
  2794. +        $t = "\t" x ($tab / 8) . ' ' x ($tab % 8);
  2795. +        }
  2796. +        elsif (s/^if\s+//) {
  2797. +        $new = '';
  2798. +        do expr();
  2799. +        print OUT $t,"if ($new) {\n";
  2800. +        $tab += 4;
  2801. +        $t = "\t" x ($tab / 8) . ' ' x ($tab % 8);
  2802. +        }
  2803. +        elsif (s/^elif\s+//) {
  2804. +        $new = '';
  2805. +        do expr();
  2806. +        $tab -= 4;
  2807. +        $t = "\t" x ($tab / 8) . ' ' x ($tab % 8);
  2808. +        print OUT $t,"}\n${t}elsif ($new) {\n";
  2809. +        $tab += 4;
  2810. +        $t = "\t" x ($tab / 8) . ' ' x ($tab % 8);
  2811. +        }
  2812. +        elsif (/^else/) {
  2813. +        $tab -= 4;
  2814. +        $t = "\t" x ($tab / 8) . ' ' x ($tab % 8);
  2815. +        print OUT $t,"}\n${t}else {\n";
  2816. +        $tab += 4;
  2817. +        $t = "\t" x ($tab / 8) . ' ' x ($tab % 8);
  2818. +        }
  2819. +        elsif (/^endif/) {
  2820. +        $tab -= 4;
  2821. +        $t = "\t" x ($tab / 8) . ' ' x ($tab % 8);
  2822. +        print OUT $t,"}\n";
  2823. +        }
  2824. +    }
  2825. +    }
  2826. +    print OUT "1;\n";
  2827. +}
  2828. +
  2829. +sub expr {
  2830. +    while ($_ ne '') {
  2831. +    s/^(\s+)//        && do {$new .= ' '; next;};
  2832. +    s/^(0x[0-9a-fA-F]+)//    && do {$new .= $1; next;};
  2833. +    s/^(\d+)//        && do {$new .= $1; next;};
  2834. +    s/^("(\\"|[^"])*")//    && do {$new .= $1; next;};
  2835. +    s/^'((\\"|[^"])*)'//    && do {
  2836. +        if ($curargs{$1}) {
  2837. +        $new .= "ord('\$$1')";
  2838. +        }
  2839. +        else {
  2840. +        $new .= "ord('$1')";
  2841. +        }
  2842. +        next;
  2843. +    };
  2844. +    s/^sizeof\s*\(([^)]+)\)/{$1}/ && do {
  2845. +        $new .= '$sizeof';
  2846. +        next;
  2847. +    };
  2848. +    s/^([_a-zA-Z]\w*)//    && do {
  2849. +        $id = $1;
  2850. +        if ($id eq 'struct') {
  2851. +        s/^\s+(\w+)//;
  2852. +        $id .= ' ' . $1;
  2853. +        $isatype{$id} = 1;
  2854. +        }
  2855. +        elsif ($id eq 'unsigned') {
  2856. +        s/^\s+(\w+)//;
  2857. +        $id .= ' ' . $1;
  2858. +        $isatype{$id} = 1;
  2859. +        }
  2860. +        if ($curargs{$id}) {
  2861. +        $new .= '$' . $id;
  2862. +        }
  2863. +        elsif ($id eq 'defined') {
  2864. +        $new .= 'defined';
  2865. +        }
  2866. +        elsif (/^\(/) {
  2867. +        s/^\((\w),/("$1",/ if $id =~ /^_IO[WR]*$/i;    # cheat
  2868. +        $new .= " &$id";
  2869. +        }
  2870. +        elsif ($isatype{$id}) {
  2871. +        if ($new =~ /{\s*$/) {
  2872. +            $new .= "'$id'";
  2873. +        }
  2874. +        elsif ($new =~ /\(\s*$/ && /^[\s*]*\)/) {
  2875. +            $new =~ s/\(\s*$//;
  2876. +            s/^[\s*]*\)//;
  2877. +        }
  2878. +        else {
  2879. +            $new .= $id;
  2880. +        }
  2881. +        }
  2882. +        else {
  2883. +        $new .= ' &' . $id;
  2884. +        }
  2885. +        next;
  2886. +    };
  2887. +    s/^(.)//            && do {$new .= $1; next;};
  2888. +    }
  2889. +}
  2890. +##############################################################################
  2891. +
  2892. +    # These next few lines are legal in both Perl and nroff.
  2893. +
  2894. +.00;            # finish .ig
  2895. +'di            \" finish diversion--previous line must be blank
  2896. +.nr nl 0-1        \" fake up transition to first page again
  2897. +.nr % 0            \" start at page 1
  2898. +'; __END__ ############# From here on it's a standard manual page ############
  2899. +.TH H2PH 1 "August 8, 1990"
  2900. +.AT 3
  2901. +.SH NAME
  2902. +h2ph \- convert .h C header files to .ph Perl header files
  2903. +.SH SYNOPSIS
  2904. +.B h2ph [headerfiles]
  2905. +.SH DESCRIPTION
  2906. +.I h2ph
  2907. +converts any C header files specified to the corresponding Perl header file
  2908. +format.
  2909. +It is most easily run while in /usr/include:
  2910. +.nf
  2911. +
  2912. +    cd /usr/include; h2ph * sys/*
  2913. +
  2914. +.fi
  2915. +If run with no arguments, filters standard input to standard output.
  2916. +.SH ENVIRONMENT
  2917. +No environment variables are used.
  2918. +.SH FILES
  2919. +/usr/include/*.h
  2920. +.br
  2921. +/usr/include/sys/*.h
  2922. +.br
  2923. +etc.
  2924. +.SH AUTHOR
  2925. +Larry Wall
  2926. +.SH "SEE ALSO"
  2927. +perl(1)
  2928. +.SH DIAGNOSTICS
  2929. +The usual warnings if it can't read or write the files involved.
  2930. +.SH BUGS
  2931. +Doesn't construct the %sizeof array for you.
  2932. +.PP
  2933. +It doesn't handle all C constructs, but it does attempt to isolate
  2934. +definitions inside evals so that you can get at the definitions
  2935. +that it can translate.
  2936. +.PP
  2937. +It's only intended as a rough tool.
  2938. +You may need to dicker with the files produced.
  2939. +.ex
  2940. diff -u --new-file --recursive perl-4.036.orig/h2ph.man perl-4.036/h2ph.man
  2941. --- perl-4.036.orig/h2ph.man    Wed Dec 31 18:00:00 1969
  2942. +++ perl-4.036/h2ph.man    Tue Jan 17 21:16:29 1995
  2943. @@ -0,0 +1,253 @@
  2944. +#!/usr/bin/perl
  2945. +'di';
  2946. +'ig00';
  2947. +
  2948. +$perlincl = '/usr/lib/perl4';
  2949. +
  2950. +chdir '/usr/include' || die "Can't cd /usr/include";
  2951. +
  2952. +@isatype = split(' ',<<END);
  2953. +    char    uchar    u_char
  2954. +    short    ushort    u_short
  2955. +    int    uint    u_int
  2956. +    long    ulong    u_long
  2957. +    FILE
  2958. +END
  2959. +
  2960. +@isatype{@isatype} = (1) x @isatype;
  2961. +
  2962. +@ARGV = ('-') unless @ARGV;
  2963. +
  2964. +foreach $file (@ARGV) {
  2965. +    if ($file eq '-') {
  2966. +    open(IN, "-");
  2967. +    open(OUT, ">-");
  2968. +    }
  2969. +    else {
  2970. +    ($outfile = $file) =~ s/\.h$/.ph/ || next;
  2971. +    print "$file -> $outfile\n";
  2972. +    if ($file =~ m|^(.*)/|) {
  2973. +        $dir = $1;
  2974. +        if (!-d "$perlincl/$dir") {
  2975. +        mkdir("$perlincl/$dir",0777);
  2976. +        }
  2977. +    }
  2978. +    open(IN,"$file") || ((warn "Can't open $file: $!\n"),next);
  2979. +    open(OUT,">$perlincl/$outfile") || die "Can't create $outfile: $!\n";
  2980. +    }
  2981. +    while (<IN>) {
  2982. +    chop;
  2983. +    while (/\\$/) {
  2984. +        chop;
  2985. +        $_ .= <IN>;
  2986. +        chop;
  2987. +    }
  2988. +    if (s:/\*:\200:g) {
  2989. +        s:\*/:\201:g;
  2990. +        s/\200[^\201]*\201//g;    # delete single line comments
  2991. +        if (s/\200.*//) {        # begin multi-line comment?
  2992. +        $_ .= '/*';
  2993. +        $_ .= <IN>;
  2994. +        redo;
  2995. +        }
  2996. +    }
  2997. +    if (s/^#\s*//) {
  2998. +        if (s/^define\s+(\w+)//) {
  2999. +        $name = $1;
  3000. +        $new = '';
  3001. +        s/\s+$//;
  3002. +        if (s/^\(([\w,\s]*)\)//) {
  3003. +            $args = $1;
  3004. +            if ($args ne '') {
  3005. +            foreach $arg (split(/,\s*/,$args)) {
  3006. +                $arg =~ s/^\s*([^\s].*[^\s])\s*$/$1/;
  3007. +                $curargs{$arg} = 1;
  3008. +            }
  3009. +            $args =~ s/\b(\w)/\$$1/g;
  3010. +            $args = "local($args) = \@_;\n$t    ";
  3011. +            }
  3012. +            s/^\s+//;
  3013. +            do expr();
  3014. +            $new =~ s/(["\\])/\\$1/g;
  3015. +            if ($t ne '') {
  3016. +            $new =~ s/(['\\])/\\$1/g;
  3017. +            print OUT $t,
  3018. +              "eval 'sub $name {\n$t    ${args}eval \"$new\";\n$t}';\n";
  3019. +            }
  3020. +            else {
  3021. +            print OUT "sub $name {\n    ${args}eval \"$new\";\n}\n";
  3022. +            }
  3023. +            %curargs = ();
  3024. +        }
  3025. +        else {
  3026. +            s/^\s+//;
  3027. +            do expr();
  3028. +            $new = 1 if $new eq '';
  3029. +            if ($t ne '') {
  3030. +            $new =~ s/(['\\])/\\$1/g;
  3031. +            print OUT $t,"eval 'sub $name {",$new,";}';\n";
  3032. +            }
  3033. +            else {
  3034. +            print OUT $t,"sub $name {",$new,";}\n";
  3035. +            }
  3036. +        }
  3037. +        }
  3038. +        elsif (/^include\s+<(.*)>/) {
  3039. +        ($incl = $1) =~ s/\.h$/.ph/;
  3040. +        print OUT $t,"require '$incl';\n";
  3041. +        }
  3042. +        elsif (/^ifdef\s+(\w+)/) {
  3043. +        print OUT $t,"if (defined &$1) {\n";
  3044. +        $tab += 4;
  3045. +        $t = "\t" x ($tab / 8) . ' ' x ($tab % 8);
  3046. +        }
  3047. +        elsif (/^ifndef\s+(\w+)/) {
  3048. +        print OUT $t,"if (!defined &$1) {\n";
  3049. +        $tab += 4;
  3050. +        $t = "\t" x ($tab / 8) . ' ' x ($tab % 8);
  3051. +        }
  3052. +        elsif (s/^if\s+//) {
  3053. +        $new = '';
  3054. +        do expr();
  3055. +        print OUT $t,"if ($new) {\n";
  3056. +        $tab += 4;
  3057. +        $t = "\t" x ($tab / 8) . ' ' x ($tab % 8);
  3058. +        }
  3059. +        elsif (s/^elif\s+//) {
  3060. +        $new = '';
  3061. +        do expr();
  3062. +        $tab -= 4;
  3063. +        $t = "\t" x ($tab / 8) . ' ' x ($tab % 8);
  3064. +        print OUT $t,"}\n${t}elsif ($new) {\n";
  3065. +        $tab += 4;
  3066. +        $t = "\t" x ($tab / 8) . ' ' x ($tab % 8);
  3067. +        }
  3068. +        elsif (/^else/) {
  3069. +        $tab -= 4;
  3070. +        $t = "\t" x ($tab / 8) . ' ' x ($tab % 8);
  3071. +        print OUT $t,"}\n${t}else {\n";
  3072. +        $tab += 4;
  3073. +        $t = "\t" x ($tab / 8) . ' ' x ($tab % 8);
  3074. +        }
  3075. +        elsif (/^endif/) {
  3076. +        $tab -= 4;
  3077. +        $t = "\t" x ($tab / 8) . ' ' x ($tab % 8);
  3078. +        print OUT $t,"}\n";
  3079. +        }
  3080. +    }
  3081. +    }
  3082. +    print OUT "1;\n";
  3083. +}
  3084. +
  3085. +sub expr {
  3086. +    while ($_ ne '') {
  3087. +    s/^(\s+)//        && do {$new .= ' '; next;};
  3088. +    s/^(0x[0-9a-fA-F]+)//    && do {$new .= $1; next;};
  3089. +    s/^(\d+)//        && do {$new .= $1; next;};
  3090. +    s/^("(\\"|[^"])*")//    && do {$new .= $1; next;};
  3091. +    s/^'((\\"|[^"])*)'//    && do {
  3092. +        if ($curargs{$1}) {
  3093. +        $new .= "ord('\$$1')";
  3094. +        }
  3095. +        else {
  3096. +        $new .= "ord('$1')";
  3097. +        }
  3098. +        next;
  3099. +    };
  3100. +    s/^sizeof\s*\(([^)]+)\)/{$1}/ && do {
  3101. +        $new .= '$sizeof';
  3102. +        next;
  3103. +    };
  3104. +    s/^([_a-zA-Z]\w*)//    && do {
  3105. +        $id = $1;
  3106. +        if ($id eq 'struct') {
  3107. +        s/^\s+(\w+)//;
  3108. +        $id .= ' ' . $1;
  3109. +        $isatype{$id} = 1;
  3110. +        }
  3111. +        elsif ($id eq 'unsigned') {
  3112. +        s/^\s+(\w+)//;
  3113. +        $id .= ' ' . $1;
  3114. +        $isatype{$id} = 1;
  3115. +        }
  3116. +        if ($curargs{$id}) {
  3117. +        $new .= '$' . $id;
  3118. +        }
  3119. +        elsif ($id eq 'defined') {
  3120. +        $new .= 'defined';
  3121. +        }
  3122. +        elsif (/^\(/) {
  3123. +        s/^\((\w),/("$1",/ if $id =~ /^_IO[WR]*$/i;    # cheat
  3124. +        $new .= " &$id";
  3125. +        }
  3126. +        elsif ($isatype{$id}) {
  3127. +        if ($new =~ /{\s*$/) {
  3128. +            $new .= "'$id'";
  3129. +        }
  3130. +        elsif ($new =~ /\(\s*$/ && /^[\s*]*\)/) {
  3131. +            $new =~ s/\(\s*$//;
  3132. +            s/^[\s*]*\)//;
  3133. +        }
  3134. +        else {
  3135. +            $new .= $id;
  3136. +        }
  3137. +        }
  3138. +        else {
  3139. +        $new .= ' &' . $id;
  3140. +        }
  3141. +        next;
  3142. +    };
  3143. +    s/^(.)//            && do {$new .= $1; next;};
  3144. +    }
  3145. +}
  3146. +##############################################################################
  3147. +
  3148. +    # These next few lines are legal in both Perl and nroff.
  3149. +
  3150. +.00;            # finish .ig
  3151. +'di            \" finish diversion--previous line must be blank
  3152. +.nr nl 0-1        \" fake up transition to first page again
  3153. +.nr % 0            \" start at page 1
  3154. +'; __END__ ############# From here on it's a standard manual page ############
  3155. +.TH H2PH 1 "August 8, 1990"
  3156. +.AT 3
  3157. +.SH NAME
  3158. +h2ph \- convert .h C header files to .ph Perl header files
  3159. +.SH SYNOPSIS
  3160. +.B h2ph [headerfiles]
  3161. +.SH DESCRIPTION
  3162. +.I h2ph
  3163. +converts any C header files specified to the corresponding Perl header file
  3164. +format.
  3165. +It is most easily run while in /usr/include:
  3166. +.nf
  3167. +
  3168. +    cd /usr/include; h2ph * sys/*
  3169. +
  3170. +.fi
  3171. +If run with no arguments, filters standard input to standard output.
  3172. +.SH ENVIRONMENT
  3173. +No environment variables are used.
  3174. +.SH FILES
  3175. +/usr/include/*.h
  3176. +.br
  3177. +/usr/include/sys/*.h
  3178. +.br
  3179. +etc.
  3180. +.SH AUTHOR
  3181. +Larry Wall
  3182. +.SH "SEE ALSO"
  3183. +perl(1)
  3184. +.SH DIAGNOSTICS
  3185. +The usual warnings if it can't read or write the files involved.
  3186. +.SH BUGS
  3187. +Doesn't construct the %sizeof array for you.
  3188. +.PP
  3189. +It doesn't handle all C constructs, but it does attempt to isolate
  3190. +definitions inside evals so that you can get at the definitions
  3191. +that it can translate.
  3192. +.PP
  3193. +It's only intended as a rough tool.
  3194. +You may need to dicker with the files produced.
  3195. +.ex
  3196. diff -u --new-file --recursive perl-4.036.orig/makedepend perl-4.036/makedepend
  3197. --- perl-4.036.orig/makedepend    Wed Dec 31 18:00:00 1969
  3198. +++ perl-4.036/makedepend    Tue Jan 17 21:16:29 1995
  3199. @@ -0,0 +1,147 @@
  3200. +#!/bin/sh
  3201. +# : makedepend.SH,v 4063Revision: 4.0.1.4 4063Date: 92/06/08 13:51:24 $
  3202. +#
  3203. +# $Log:    makedepend.SH,v $
  3204. +# Revision 4.0.1.4  92/06/08  13:51:24  lwall
  3205. +# patch20: various and sundry fixes
  3206. +# 
  3207. +# Revision 4.0.1.3  91/11/05  17:56:33  lwall
  3208. +# patch11: various portability fixes
  3209. +# 
  3210. +# Revision 4.0.1.2  91/06/07  15:40:06  lwall
  3211. +# patch4: fixed cppstdin to run in the right directory
  3212. +# 
  3213. +# Revision 4.0.1.1  91/06/07  11:20:06  lwall
  3214. +# patch4: Makefile is no longer self-modifying code under makedepend
  3215. +# 
  3216. +# Revision 4.0  91/03/20  01:27:04  lwall
  3217. +# 4.0 baseline.
  3218. +# 
  3219. +# 
  3220. +
  3221. +export PATH || (echo "OOPS, this isn't sh.  Desperation time.  I will feed myself to sh."; sh $0; kill $$)
  3222. +
  3223. +cat='/bin/cat'
  3224. +cppflags=''
  3225. +cp='/bin/cp'
  3226. +cppstdin='cppstdin'
  3227. +cppminus=''
  3228. +echo='/bin/echo'
  3229. +egrep='/usr/bin/egrep'
  3230. +expr='/usr/bin/expr'
  3231. +mv='/bin/mv'
  3232. +rm='/bin/rm'
  3233. +sed='/usr/bin/sed'
  3234. +sort='/usr/bin/sort'
  3235. +test='test'
  3236. +tr='/usr/bin/tr'
  3237. +uniq='/usr/bin/uniq'
  3238. +
  3239. +PATH="$PATH:."
  3240. +export PATH
  3241. +
  3242. +$cat /dev/null >.deptmp
  3243. +$rm -f *.c.c c/*.c.c
  3244. +if test -f Makefile; then
  3245. +    cp Makefile makefile
  3246. +fi
  3247. +mf=makefile
  3248. +if test -f $mf; then
  3249. +    defrule=`<$mf sed -n        \
  3250. +    -e '/^\.c\.o:.*;/{'        \
  3251. +    -e    's/\$\*\.c//'        \
  3252. +    -e    's/^[^;]*;[     ]*//p'    \
  3253. +    -e    q                \
  3254. +    -e '}'                \
  3255. +    -e '/^\.c\.o: *$/{'        \
  3256. +    -e    N                \
  3257. +    -e    's/\$\*\.c//'        \
  3258. +    -e    's/^.*\n[     ]*//p'        \
  3259. +    -e    q                \
  3260. +    -e '}'`
  3261. +fi
  3262. +case "$defrule" in
  3263. +'') defrule='$(CC) -c $(CFLAGS)' ;;
  3264. +esac
  3265. +
  3266. +make clist || ($echo "Searching for .c files..."; \
  3267. +    $echo *.c | $tr ' ' '\012' | $egrep -v '\*' >.clist)
  3268. +for file in `$cat .clist`; do
  3269. +# for file in `cat /dev/null`; do
  3270. +    case "$file" in
  3271. +    *.c) filebase=`basename $file .c` ;;
  3272. +    *.y) filebase=`basename $file .y` ;;
  3273. +    esac
  3274. +    case "$file" in
  3275. +    */*) finc="-I`echo $file | sed 's#/[^/]*$##`" ;;
  3276. +    *)   finc= ;;
  3277. +    esac
  3278. +    $echo "Finding dependencies for $filebase.o."
  3279. +    ( $echo "#line 1 \"$file\""; \
  3280. +      $sed -n <$file \
  3281. +    -e "/^${filebase}_init(/q" \
  3282. +    -e '/^#/{' \
  3283. +    -e 's|/\*.*$||' \
  3284. +    -e 's|\\$||' \
  3285. +    -e p \
  3286. +    -e '}' ) >$file.c
  3287. +    $cppstdin $finc -I/usr/local/include -I. $cppflags $cppminus <$file.c |
  3288. +    $sed \
  3289. +    -e 's#\.[0-9][0-9]*\.c#'"$file.c#" \
  3290. +    -e 's/^[     ]*#[     ]*line/#/' \
  3291. +    -e '/^# *[0-9][0-9]* *[".\/]/!d' \
  3292. +    -e 's/^.*"\(.*\)".*$/'$filebase'.o: \1/' \
  3293. +    -e 's/^# *[0-9][0-9]* \(.*\)$/'$filebase'.o: \1/' \
  3294. +    -e 's|: \./|: |' \
  3295. +    -e 's|\.c\.c|.c|' | \
  3296. +    $uniq | $sort | $uniq >> .deptmp
  3297. +done
  3298. +
  3299. +$sed <$mf >$mf.new -e '1,/^# AUTOMATICALLY/!d'
  3300. +
  3301. +make shlist || ($echo "Searching for .SH files..."; \
  3302. +    $echo *.SH | $tr ' ' '\012' | $egrep -v '\*' >.shlist)
  3303. +if $test -s .deptmp; then
  3304. +    for file in `cat .shlist`; do
  3305. +    $echo `$expr X$file : 'X\(.*\).SH'`: $file config.sh \; \
  3306. +        /bin/sh $file >> .deptmp
  3307. +    done
  3308. +    $echo "Updating $mf..."
  3309. +    $echo "# If this runs make out of memory, delete /usr/include lines." \
  3310. +    >> $mf.new
  3311. +    $sed 's|^\(.*\.o:\) *\(.*/.*\.c\) *$|\1 \2; '"$defrule \2|" .deptmp \
  3312. +       >>$mf.new
  3313. +else
  3314. +    make hlist || ($echo "Searching for .h files..."; \
  3315. +    $echo *.h | $tr ' ' '\012' | $egrep -v '\*' >.hlist)
  3316. +    $echo "You don't seem to have a proper C preprocessor.  Using grep instead."
  3317. +    $egrep '^#include ' `cat .clist` `cat .hlist`  >.deptmp
  3318. +    $echo "Updating $mf..."
  3319. +    <.clist $sed -n                            \
  3320. +    -e '/\//{'                            \
  3321. +    -e   's|^\(.*\)/\(.*\)\.c|\2.o: \1/\2.c; '"$defrule \1/\2.c|p"    \
  3322. +    -e   d                                \
  3323. +    -e '}'                                \
  3324. +    -e 's|^\(.*\)\.c|\1.o: \1.c|p' >> $mf.new
  3325. +    <.hlist $sed -n 's|\(.*/\)\(.*\)|s= \2= \1\2=|p' >.hsed
  3326. +    <.deptmp $sed -n 's|c:#include "\(.*\)".*$|o: \1|p' | \
  3327. +       $sed 's|^[^;]*/||' | \
  3328. +       $sed -f .hsed >> $mf.new
  3329. +    <.deptmp $sed -n 's|c:#include <\(.*\)>.*$|o: /usr/include/\1|p' \
  3330. +       >> $mf.new
  3331. +    <.deptmp $sed -n 's|h:#include "\(.*\)".*$|h: \1|p' | \
  3332. +       $sed -f .hsed >> $mf.new
  3333. +    <.deptmp $sed -n 's|h:#include <\(.*\)>.*$|h: /usr/include/\1|p' \
  3334. +       >> $mf.new
  3335. +    for file in `$cat .shlist`; do
  3336. +    $echo `$expr X$file : 'X\(.*\).SH'`: $file config.sh \; \
  3337. +        /bin/sh $file >> $mf.new
  3338. +    done
  3339. +fi
  3340. +$rm -f $mf.old
  3341. +$cp $mf $mf.old
  3342. +$cp $mf.new $mf
  3343. +$rm $mf.new
  3344. +$echo "# WARNING: Put nothing here or make depend will gobble it up!" >> $mf
  3345. +$rm -f .deptmp `sed 's/\.c/.c.c/' .clist` .shlist .clist .hlist .hsed
  3346. +
  3347. diff -u --new-file --recursive perl-4.036.orig/makedir perl-4.036/makedir
  3348. --- perl-4.036.orig/makedir    Wed Dec 31 18:00:00 1969
  3349. +++ perl-4.036/makedir    Tue Jan 17 21:16:29 1995
  3350. @@ -0,0 +1,56 @@
  3351. +#!/bin/sh
  3352. +# : makedir.SH,v 4063Revision: 4.0.1.1 4063Date: 92/06/08 14:24:55 $
  3353. +# 
  3354. +# $Log:    makedir.SH,v $
  3355. +# Revision 4.0.1.1  92/06/08  14:24:55  lwall
  3356. +# patch20: SH files didn't work well with symbolic links
  3357. +# 
  3358. +# Revision 4.0  91/03/20  01:27:13  lwall
  3359. +# 4.0 baseline.
  3360. +# 
  3361. +# 
  3362. +
  3363. +export PATH || (echo "OOPS, this isn't sh.  Desperation time.  I will feed myself to sh."; sh $0; kill $$)
  3364. +
  3365. +case $# in
  3366. +  0)
  3367. +    /bin/echo "makedir pathname filenameflag"
  3368. +    exit 1
  3369. +    ;;
  3370. +esac
  3371. +
  3372. +: guarantee one slash before 1st component
  3373. +case $1 in
  3374. +  /*) ;;
  3375. +  *)  set ./$1 $2 ;;
  3376. +esac
  3377. +
  3378. +: strip last component if it is to be a filename
  3379. +case X$2 in
  3380. +  X1) set `/bin/echo $1 | /usr/bin/sed 's:\(.*\)/[^/]*$:\1:'` ;;
  3381. +  *)  set $1 ;;
  3382. +esac
  3383. +
  3384. +: return reasonable status if nothing to be created
  3385. +if test -d "$1" ; then
  3386. +    exit 0
  3387. +fi
  3388. +
  3389. +list=''
  3390. +while true ; do
  3391. +    case $1 in
  3392. +    */*)
  3393. +    list="$1 $list"
  3394. +    set `echo $1 | /usr/bin/sed 's:\(.*\)/:\1 :'`
  3395. +    ;;
  3396. +    *)
  3397. +    break
  3398. +    ;;
  3399. +    esac
  3400. +done
  3401. +
  3402. +set $list
  3403. +
  3404. +for dir do
  3405. +    /bin/mkdir $dir >/dev/null 2>&1
  3406. +done
  3407. diff -u --new-file --recursive perl-4.036.orig/pstruct perl-4.036/pstruct
  3408. --- perl-4.036.orig/pstruct    Wed Dec 31 18:00:00 1969
  3409. +++ perl-4.036/pstruct    Tue Jan 17 21:16:27 1995
  3410. @@ -0,0 +1,1071 @@
  3411. +#!/usr/bin/perl
  3412. +#
  3413. +#
  3414. +#   c2ph (aka pstruct)
  3415. +#   Tom Christiansen, <tchrist@convex.com>
  3416. +#   
  3417. +#   As pstruct, dump C structures as generated from 'cc -g -S' stabs.
  3418. +#   As c2ph, do this PLUS generate perl code for getting at the structures.
  3419. +#
  3420. +#   See the usage message for more.  If this isn't enough, read the code.
  3421. +#
  3422. +
  3423. +$RCSID = '$RCSfile: c2ph.SH,v $$Revision: 4.0.1.2 $$Date: 92/06/08 11:56:08 $';
  3424. +
  3425. +
  3426. +######################################################################
  3427. +
  3428. +# some handy data definitions.   many of these can be reset later.
  3429. +
  3430. +$bitorder = 'b';  # ascending; set to B for descending bit fields
  3431. +
  3432. +%intrinsics = 
  3433. +%template = (
  3434. +    'char',             'c',
  3435. +    'unsigned char',         'C',
  3436. +    'short',            's',
  3437. +    'short int',        's',
  3438. +    'unsigned short',        'S',
  3439. +    'unsigned short int',    'S',
  3440. +    'short unsigned int',    'S',
  3441. +    'int',            'i',
  3442. +    'unsigned int',        'I',
  3443. +    'long',            'l',
  3444. +    'long int',            'l',
  3445. +    'unsigned long',        'L',
  3446. +    'unsigned long',        'L',
  3447. +    'long unsigned int',    'L',
  3448. +    'unsigned long int',    'L',
  3449. +    'long long',        'q',
  3450. +    'long long int',        'q',
  3451. +    'unsigned long long',    'Q',
  3452. +    'unsigned long long int',    'Q',
  3453. +    'float',            'f',
  3454. +    'double',            'd',
  3455. +    'pointer',            'p',
  3456. +    'null',            'x',
  3457. +    'neganull',            'X',
  3458. +    'bit',            $bitorder,
  3459. +); 
  3460. +
  3461. +&buildscrunchlist;
  3462. +delete $intrinsics{'neganull'};
  3463. +delete $intrinsics{'bit'};
  3464. +delete $intrinsics{'null'};
  3465. +
  3466. +# use -s to recompute sizes
  3467. +%sizeof = (
  3468. +    'char',             '1',
  3469. +    'unsigned char',         '1',
  3470. +    'short',            '2',
  3471. +    'short int',        '2',
  3472. +    'unsigned short',        '2',
  3473. +    'unsigned short int',    '2',
  3474. +    'short unsigned int',    '2',
  3475. +    'int',            '4',
  3476. +    'unsigned int',        '4',
  3477. +    'long',            '4',
  3478. +    'long int',            '4',
  3479. +    'unsigned long',        '4',
  3480. +    'unsigned long int',    '4',
  3481. +    'long unsigned int',    '4',
  3482. +    'long long',        '8',
  3483. +    'long long int',        '8',
  3484. +    'unsigned long long',    '8',
  3485. +    'unsigned long long int',    '8',
  3486. +    'float',            '4',
  3487. +    'double',            '8',
  3488. +    'pointer',            '4',
  3489. +);
  3490. +
  3491. +($type_width, $member_width, $offset_width, $size_width) = (20, 20, 6, 5);
  3492. +
  3493. +($offset_fmt, $size_fmt) = ('d', 'd');
  3494. +
  3495. +$indent = 2;
  3496. +
  3497. +$CC = 'cc';
  3498. +$CFLAGS = '-g -S';
  3499. +$DEFINES = '';
  3500. +
  3501. +$perl++ if $0 =~ m#/?c2ph$#;
  3502. +
  3503. +require 'getopts.pl';
  3504. +
  3505. +eval '$'.$1.'$2;' while $ARGV[0] =~ /^([A-Za-z_]+=)(.*)/ && shift;
  3506. +
  3507. +&Getopts('aixdpvtnws:') || &usage(0);
  3508. +
  3509. +$opt_d && $debug++;
  3510. +$opt_t && $trace++;
  3511. +$opt_p && $perl++;
  3512. +$opt_v && $verbose++;
  3513. +$opt_n && ($perl = 0);
  3514. +
  3515. +if ($opt_w) {
  3516. +    ($type_width, $member_width, $offset_width) = (45, 35, 8);
  3517. +} 
  3518. +if ($opt_x) {
  3519. +    ($offset_fmt, $offset_width, $size_fmt, $size_width) = ( 'x', '08', 'x', 04 );
  3520. +}
  3521. +
  3522. +eval '$'.$1.'$2;' while $ARGV[0] =~ /^([A-Za-z_]+=)(.*)/ && shift;
  3523. +
  3524. +sub PLUMBER {
  3525. +    select(STDERR);
  3526. +    print "oops, apperent pager foulup\n";
  3527. +    $isatty++;
  3528. +    &usage(1);
  3529. +} 
  3530. +
  3531. +sub usage {
  3532. +    local($oops) = @_;
  3533. +    unless (-t STDOUT) {
  3534. +    select(STDERR);
  3535. +    } elsif (!$oops) {
  3536. +    $isatty++;
  3537. +    $| = 1;
  3538. +    print "hit <RETURN> for further explanation: ";
  3539. +    <STDIN>;
  3540. +    open (PIPE, "|". ($ENV{PAGER} || 'more'));
  3541. +    $SIG{PIPE} = PLUMBER;
  3542. +    select(PIPE);
  3543. +    } 
  3544. +
  3545. +    print "usage: $0 [-dpnP] [var=val] [files ...]\n";
  3546. +
  3547. +    exit unless $isatty;
  3548. +
  3549. +    print <<EOF;
  3550. +
  3551. +Options:
  3552. +
  3553. +-w    wide; short for: type_width=45 member_width=35 offset_width=8
  3554. +-x    hex; short for:  offset_fmt=x offset_width=08 size_fmt=x size_width=04
  3555. +
  3556. +-n      do not generate perl code  (default when invoked as pstruct)
  3557. +-p      generate perl code         (default when invoked as c2ph)
  3558. +-v    generate perl code, with C decls as comments
  3559. +
  3560. +-i    do NOT recompute sizes for intrinsic datatypes
  3561. +-a    dump information on intrinsics also
  3562. +
  3563. +-t     trace execution
  3564. +-d    spew reams of debugging output
  3565. +
  3566. +-slist  give comma-separated list a structures to dump
  3567. +
  3568. +
  3569. +Var Name        Default Value    Meaning
  3570. +
  3571. +EOF
  3572. +
  3573. +    &defvar('CC', 'which_compiler to call');
  3574. +    &defvar('CFLAGS', 'how to generate *.s files with stabs');
  3575. +    &defvar('DEFINES','any extra cflags or cpp defines, like -I, -D, -U');
  3576. +
  3577. +    print "\n";
  3578. +
  3579. +    &defvar('type_width', 'width of type field   (column 1)');
  3580. +    &defvar('member_width', 'width of member field (column 2)');
  3581. +    &defvar('offset_width', 'width of offset field (column 3)');
  3582. +    &defvar('size_width', 'width of size field   (column 4)');
  3583. +
  3584. +    print "\n";
  3585. +
  3586. +    &defvar('offset_fmt', 'sprintf format type for offset');
  3587. +    &defvar('size_fmt', 'sprintf format type for size');
  3588. +
  3589. +    print "\n";
  3590. +
  3591. +    &defvar('indent', 'how far to indent each nesting level');
  3592. +
  3593. +   print <<'EOF';
  3594. +
  3595. +    If any *.[ch] files are given, these will be catted together into
  3596. +    a temporary *.c file and sent through:
  3597. +        $CC $CFLAGS $DEFINES 
  3598. +    and the resulting *.s groped for stab information.  If no files are
  3599. +    supplied, then stdin is read directly with the assumption that it
  3600. +    contains stab information.  All other liens will be ignored.  At
  3601. +    most one *.s file should be supplied.
  3602. +
  3603. +EOF
  3604. +    close PIPE;
  3605. +    exit 1;
  3606. +} 
  3607. +
  3608. +sub defvar {
  3609. +    local($var, $msg) = @_;
  3610. +    printf "%-16s%-15s  %s\n", $var, eval "\$$var", $msg;
  3611. +} 
  3612. +
  3613. +$recurse = 1;
  3614. +
  3615. +if (@ARGV) {
  3616. +    if (grep(!/\.[csh]$/,@ARGV)) {
  3617. +    warn "Only *.[csh] files expected!\n";
  3618. +    &usage;
  3619. +    } 
  3620. +    elsif (grep(/\.s$/,@ARGV)) {
  3621. +    if (@ARGV > 1) { 
  3622. +        warn "Only one *.s file allowed!\n";
  3623. +        &usage;
  3624. +    }
  3625. +    } 
  3626. +    elsif (@ARGV == 1 && $ARGV[0] =~ /\.c$/) {
  3627. +    local($dir, $file) = $ARGV[0] =~ m#(.*/)?(.*)$#;
  3628. +    $chdir = "cd $dir; " if $dir;
  3629. +    &system("$chdir$CC $CFLAGS $DEFINES $file") && exit 1;
  3630. +    $ARGV[0] =~ s/\.c$/.s/;
  3631. +    } 
  3632. +    else {
  3633. +    $TMP = "/tmp/c2ph.$$.c";
  3634. +    &system("cat @ARGV > $TMP") && exit 1;
  3635. +    &system("cd /tmp; $CC $CFLAGS $DEFINES $TMP") && exit 1;
  3636. +    unlink $TMP;
  3637. +    $TMP =~ s/\.c$/.s/;
  3638. +    @ARGV = ($TMP);
  3639. +    } 
  3640. +}
  3641. +
  3642. +if ($opt_s) {
  3643. +    for (split(/[\s,]+/, $opt_s)) {
  3644. +    $interested{$_}++;
  3645. +    } 
  3646. +} 
  3647. +
  3648. +
  3649. +$| = 1 if $debug;
  3650. +
  3651. +main: {
  3652. +
  3653. +    if ($trace) {
  3654. +    if (-t && !@ARGV) { 
  3655. +        print STDERR "reading from your keyboard: ";
  3656. +    } else {
  3657. +        print STDERR "reading from " . (@ARGV ? "@ARGV" : "<STDIN>").": ";
  3658. +    }
  3659. +    }
  3660. +
  3661. +STAB: while (<>) {
  3662. +    if ($trace && !($. % 10)) {
  3663. +        $lineno = $..'';
  3664. +        print STDERR $lineno, "\b" x length($lineno);
  3665. +    } 
  3666. +    next unless /^\s*\.stabs\s+/;
  3667. +    $line = $_;
  3668. +    s/^\s*\.stabs\s+//; 
  3669. +    &stab; 
  3670. +    }
  3671. +    print STDERR "$.\n" if $trace;
  3672. +    unlink $TMP if $TMP;
  3673. +
  3674. +    &compute_intrinsics if $perl && !$opt_i;
  3675. +
  3676. +    print STDERR "resolving types\n" if $trace;
  3677. +
  3678. +    &resolve_types;
  3679. +    &adjust_start_addrs;
  3680. +
  3681. +    $sum = 2 + $type_width + $member_width;
  3682. +    $pmask1 = "%-${type_width}s %-${member_width}s"; 
  3683. +    $pmask2 = "%-${sum}s %${offset_width}${offset_fmt}%s %${size_width}${size_fmt}%s";
  3684. +
  3685. +    if ($perl) {
  3686. +    # resolve template -- should be in stab define order, but even this isn't enough.
  3687. +    print STDERR "\nbuilding type templates: " if $trace;
  3688. +    for $i (reverse 0..$#type) {
  3689. +        next unless defined($name = $type[$i]);
  3690. +        next unless defined $struct{$name};
  3691. +        $build_recursed = 0;
  3692. +        &build_template($name) unless defined $template{&psou($name)} ||
  3693. +                    $opt_s && !$interested{$name};
  3694. +    } 
  3695. +    print STDERR "\n\n" if $trace;
  3696. +    }
  3697. +
  3698. +    print STDERR "dumping structs: " if $trace;
  3699. +
  3700. +
  3701. +    foreach $name (sort keys %struct) {
  3702. +    next if $opt_s && !$interested{$name};
  3703. +    print STDERR "$name " if $trace;
  3704. +
  3705. +    undef @sizeof;
  3706. +    undef @typedef;
  3707. +    undef @offsetof;
  3708. +    undef @indices;
  3709. +    undef @typeof;
  3710. +
  3711. +    $mname = &munge($name);
  3712. +
  3713. +    $fname = &psou($name);
  3714. +
  3715. +    print "# " if $perl && $verbose;
  3716. +    $pcode = '';
  3717. +    print "$fname {\n" if !$perl || $verbose; 
  3718. +    $template{$fname} = &scrunch($template{$fname}) if $perl;
  3719. +    &pstruct($name,$name,0); 
  3720. +    print "# " if $perl && $verbose;
  3721. +    print "}\n" if !$perl || $verbose; 
  3722. +    print "\n" if $perl && $verbose;
  3723. +
  3724. +    if ($perl) {
  3725. +        print "$pcode";
  3726. +
  3727. +        printf("\nsub %-32s { %4d; }\n\n", "${mname}'struct", $countof{$name});
  3728. +
  3729. +        print <<EOF;
  3730. +sub ${mname}'typedef { 
  3731. +    local(\$${mname}'index) = shift;
  3732. +    defined \$${mname}'index 
  3733. +    ? \$${mname}'typedef[\$${mname}'index] 
  3734. +    : \$${mname}'typedef;
  3735. +}
  3736. +EOF
  3737. +
  3738. +        print <<EOF;
  3739. +sub ${mname}'sizeof { 
  3740. +    local(\$${mname}'index) = shift;
  3741. +    defined \$${mname}'index 
  3742. +    ? \$${mname}'sizeof[\$${mname}'index] 
  3743. +    : \$${mname}'sizeof;
  3744. +}
  3745. +EOF
  3746. +
  3747. +        print <<EOF;
  3748. +sub ${mname}'offsetof { 
  3749. +    local(\$${mname}'index) = shift;
  3750. +    defined \$${mname}index 
  3751. +    ? \$${mname}'offsetof[\$${mname}'index] 
  3752. +    : \$${mname}'sizeof;
  3753. +}
  3754. +EOF
  3755. +
  3756. +        print <<EOF;
  3757. +sub ${mname}'typeof { 
  3758. +    local(\$${mname}'index) = shift;
  3759. +    defined \$${mname}index 
  3760. +    ? \$${mname}'typeof[\$${mname}'index] 
  3761. +    : '$name';
  3762. +}
  3763. +EOF
  3764. +    
  3765. +
  3766. +        print "\$${mname}'typedef = '" . &scrunch($template{$fname}) 
  3767. +        . "';\n";
  3768. +
  3769. +        print "\$${mname}'sizeof = $sizeof{$name};\n\n";
  3770. +
  3771. +
  3772. +        print "\@${mname}'indices = (", &squishseq(@indices), ");\n";
  3773. +
  3774. +        print "\n";
  3775. +
  3776. +        print "\@${mname}'typedef[\@${mname}'indices] = (",
  3777. +            join("\n\t", '', @typedef), "\n    );\n\n";
  3778. +        print "\@${mname}'sizeof[\@${mname}'indices] = (",
  3779. +            join("\n\t", '', @sizeof), "\n    );\n\n";
  3780. +        print "\@${mname}'offsetof[\@${mname}'indices] = (",
  3781. +            join("\n\t", '', @offsetof), "\n    );\n\n";
  3782. +        print "\@${mname}'typeof[\@${mname}'indices] = (",
  3783. +            join("\n\t", '', @typeof), "\n    );\n\n";
  3784. +
  3785. +        $template_printed{$fname}++;
  3786. +        $size_printed{$fname}++;
  3787. +    } 
  3788. +    print "\n";
  3789. +    }
  3790. +
  3791. +    print STDERR "\n" if $trace;
  3792. +
  3793. +    unless ($perl && $opt_a) { 
  3794. +    print "\n1;\n";
  3795. +    exit;
  3796. +    }
  3797. +
  3798. +
  3799. +
  3800. +    foreach $name (sort bysizevalue keys %intrinsics) {
  3801. +    next if $size_printed{$name};
  3802. +    print '$',&munge($name),"'sizeof = ", $sizeof{$name}, ";\n";
  3803. +    }
  3804. +
  3805. +    print "\n";
  3806. +
  3807. +    sub bysizevalue { $sizeof{$a} <=> $sizeof{$b}; }
  3808. +
  3809. +
  3810. +    foreach $name (sort keys %intrinsics) {
  3811. +    print '$',&munge($name),"'typedef = '", $template{$name}, "';\n";
  3812. +    }
  3813. +
  3814. +    print "\n1;\n";
  3815. +    
  3816. +    exit;
  3817. +}
  3818. +
  3819. +########################################################################################
  3820. +
  3821. +
  3822. +sub stab {
  3823. +    next unless /:[\$\w]+(\(\d+,\d+\))?=[\*\$\w]+/;  # (\d+,\d+) is for sun
  3824. +    s/"//                         || next;
  3825. +    s/",([x\d]+),([x\d]+),([x\d]+),.*//         || next;
  3826. +
  3827. +    next if /^\s*$/;
  3828. +
  3829. +    $size = $3 if $3;
  3830. +
  3831. +
  3832. +    $line = $_;
  3833. +
  3834. +    if (($name, $pdecl) = /^([\$ \w]+):[tT]((\d+)(=[rufs*](\d+))+)$/) {
  3835. +    print "$name is a typedef for some funky pointers: $pdecl\n" if $debug;
  3836. +    &pdecl($pdecl);
  3837. +    next;
  3838. +    }
  3839. +
  3840. +
  3841. +
  3842. +    if (/(([ \w]+):t(\d+|\(\d+,\d+\)))=r?(\d+|\(\d+,\d+\))(;\d+;\d+;)?/) {  
  3843. +    local($ident) = $2;
  3844. +    push(@intrinsics, $ident);
  3845. +    $typeno = &typeno($3);
  3846. +    $type[$typeno] = $ident;
  3847. +    print STDERR "intrinsic $ident in new type $typeno\n" if $debug; 
  3848. +    next;
  3849. +    }
  3850. +
  3851. +    if (($name, $typeordef, $typeno, $extra, $struct, $_) 
  3852. +    = /^([\$ \w]+):([ustT])(\d+|\(\d+,\d+\))(=[rufs*](\d+))?(.*)$/) 
  3853. +    {
  3854. +    $typeno = &typeno($typeno);  # sun foolery
  3855. +    } 
  3856. +    elsif (/^[\$\w]+:/) {
  3857. +    next; # variable
  3858. +    }
  3859. +    else { 
  3860. +    warn "can't grok stab: <$_> in: $line " if $_;
  3861. +    next;
  3862. +    } 
  3863. +
  3864. +    #warn "got size $size for $name\n";
  3865. +    $sizeof{$name} = $size if $size;
  3866. +
  3867. +    s/;[-\d]*;[-\d]*;$//;  # we don't care about ranges
  3868. +
  3869. +    $typenos{$name} = $typeno;
  3870. +
  3871. +    unless (defined $type[$typeno]) {
  3872. +    &panic("type 0??") unless $typeno;
  3873. +    $type[$typeno] = $name unless defined $type[$typeno];
  3874. +    printf "new type $typeno is $name" if $debug;
  3875. +    if ($extra =~ /\*/ && defined $type[$struct]) {
  3876. +        print ", a typedef for a pointer to " , $type[$struct] if $debug;
  3877. +    }
  3878. +    } else {
  3879. +    printf "%s is type %d", $name, $typeno if $debug;
  3880. +    print ", a typedef for " , $type[$typeno] if $debug;
  3881. +    } 
  3882. +    print "\n" if $debug;
  3883. +    #next unless $extra =~ /[su*]/;
  3884. +
  3885. +    #$type[$struct] = $name;
  3886. +
  3887. +    if ($extra =~ /[us*]/) {
  3888. +    &sou($name, $extra);
  3889. +    $_ = &sdecl($name, $_, 0);
  3890. +    }
  3891. +    elsif (/^=ar/) {
  3892. +    print "it's a bare array typedef -- that's pretty sick\n" if $debug;
  3893. +    $_ = "$typeno$_";
  3894. +    $scripts = '';
  3895. +    $_ = &adecl($_,1);
  3896. +
  3897. +    }
  3898. +    elsif (s/((\w+):t(\d+|\(\d+,\d+\)))?=r?(;\d+;\d+;)?//) {  # the ?'s are for gcc
  3899. +    push(@intrinsics, $2);
  3900. +    $typeno = &typeno($3);
  3901. +    $type[$typeno] = $2;
  3902. +    print STDERR "intrinsic $2 in new type $typeno\n" if $debug; 
  3903. +    }
  3904. +    elsif (s/^=e//) { # blessed by thy compiler; mine won't do this
  3905. +    &edecl;
  3906. +    } 
  3907. +    else {
  3908. +    warn "Funny remainder for $name on line $_ left in $line " if $_;
  3909. +    } 
  3910. +}
  3911. +
  3912. +sub typeno {  # sun thinks types are (0,27) instead of just 27
  3913. +    local($_) = @_;
  3914. +    s/\(\d+,(\d+)\)/$1/;
  3915. +    $_;
  3916. +} 
  3917. +
  3918. +sub pstruct {
  3919. +    local($what,$prefix,$base) = @_; 
  3920. +    local($field, $fieldname, $typeno, $count, $offset, $entry); 
  3921. +    local($fieldtype);
  3922. +    local($type, $tname); 
  3923. +    local($mytype, $mycount, $entry2);
  3924. +    local($struct_count) = 0;
  3925. +    local($pad, $revpad, $length, $prepad, $lastoffset, $lastlength, $fmt);
  3926. +    local($bits,$bytes);
  3927. +    local($template);
  3928. +
  3929. +
  3930. +    local($mname) = &munge($name);
  3931. +
  3932. +    sub munge { 
  3933. +    local($_) = @_;
  3934. +    s/[\s\$\.]/_/g;
  3935. +    $_;
  3936. +    }
  3937. +
  3938. +    local($sname) = &psou($what);
  3939. +
  3940. +    $nesting++;
  3941. +
  3942. +    for $field (split(/;/, $struct{$what})) {
  3943. +    $pad = $prepad = 0;
  3944. +    $entry = ''; 
  3945. +    ($fieldname, $typeno, $count, $offset, $length) = split(/,/, $field); 
  3946. +
  3947. +    $type = $type[$typeno];
  3948. +
  3949. +    $type =~ /([^[]*)(\[.*\])?/;
  3950. +    $mytype = $1;
  3951. +    $count .= $2;
  3952. +    $fieldtype = &psou($mytype);
  3953. +
  3954. +    local($fname) = &psou($name);
  3955. +
  3956. +    if ($build_templates) {
  3957. +
  3958. +        $pad = ($offset - ($lastoffset + $lastlength))/8 
  3959. +        if defined $lastoffset;
  3960. +
  3961. +        if (! $finished_template{$sname}) {
  3962. +        if ($isaunion{$what}) {
  3963. +            $template{$sname} .= 'X' x $revpad . ' '    if $revpad;
  3964. +        } else {
  3965. +            $template{$sname} .= 'x' x $pad    . ' '    if $pad;
  3966. +        }
  3967. +        }
  3968. +
  3969. +        $template = &fetch_template($type) x 
  3970. +                ($count ? &scripts2count($count) : 1);
  3971. +
  3972. +        if (! $finished_template{$sname}) {
  3973. +        $template{$sname} .= $template;
  3974. +        }
  3975. +
  3976. +        $revpad = $length/8 if $isaunion{$what};
  3977. +
  3978. +        ($lastoffset, $lastlength) = ($offset, $length);
  3979. +
  3980. +    } else { 
  3981. +        print '# ' if $perl && $verbose;
  3982. +        $entry = sprintf($pmask1,
  3983. +            ' ' x ($nesting * $indent) . $fieldtype,
  3984. +            "$prefix.$fieldname" . $count); 
  3985. +
  3986. +        $entry =~ s/(\*+)( )/$2$1/; 
  3987. +
  3988. +        printf $pmask2,
  3989. +            $entry,
  3990. +            ($base+$offset)/8,
  3991. +            ($bits = ($base+$offset)%8) ? ".$bits" : "  ",
  3992. +            $length/8,
  3993. +            ($bits = $length % 8) ? ".$bits": ""
  3994. +            if !$perl || $verbose;
  3995. +
  3996. +
  3997. +        if ($perl && $nesting == 1) {
  3998. +        $template = &scrunch(&fetch_template($type) x 
  3999. +                ($count ? &scripts2count($count) : 1));
  4000. +        push(@sizeof, int($length/8) .",\t# $fieldname");
  4001. +        push(@offsetof, int($offset/8) .",\t# $fieldname");
  4002. +        push(@typedef, "'$template', \t# $fieldname");
  4003. +        $type =~ s/(struct|union) //;
  4004. +        push(@typeof, "'$type" . ($count ? $count : '') .
  4005. +            "',\t# $fieldname");
  4006. +        }
  4007. +
  4008. +        print '  ', ' ' x $indent x $nesting, $template
  4009. +                if $perl && $verbose;
  4010. +
  4011. +        print "\n" if !$perl || $verbose;
  4012. +
  4013. +    }    
  4014. +    if ($perl) {
  4015. +        local($mycount) = defined $struct{$mytype} ? $countof{$mytype} : 1;
  4016. +        $mycount *= &scripts2count($count) if $count;
  4017. +        if ($nesting==1 && !$build_templates) {
  4018. +        $pcode .= sprintf("sub %-32s { %4d; }\n", 
  4019. +            "${mname}'${fieldname}", $struct_count);
  4020. +        push(@indices, $struct_count);
  4021. +        }
  4022. +        $struct_count += $mycount;
  4023. +    } 
  4024. +
  4025. +
  4026. +    &pstruct($type, "$prefix.$fieldname", $base+$offset) 
  4027. +        if $recurse && defined $struct{$type}; 
  4028. +    }
  4029. +
  4030. +    $countof{$what} = $struct_count unless defined $countof{$whati};
  4031. +
  4032. +    $template{$sname} .= '$' if $build_templates;
  4033. +    $finished_template{$sname}++;
  4034. +
  4035. +    if ($build_templates && !defined $sizeof{$name}) {
  4036. +    local($fmt) = &scrunch($template{$sname});
  4037. +    print STDERR "no size for $name, punting with $fmt..." if $debug;
  4038. +    eval '$sizeof{$name} = length(pack($fmt, ()))';
  4039. +    if ($@) {
  4040. +        chop $@;
  4041. +        warn "couldn't get size for \$name: $@";
  4042. +    } else {
  4043. +        print STDERR $sizeof{$name}, "\n" if $debUg;
  4044. +    }
  4045. +    } 
  4046. +
  4047. +    --$nesting;
  4048. +}
  4049. +
  4050. +
  4051. +sub psize {
  4052. +    local($me) = @_; 
  4053. +    local($amstruct) = $struct{$me} ?  'struct ' : '';
  4054. +
  4055. +    print '$sizeof{\'', $amstruct, $me, '\'} = '; 
  4056. +    printf "%d;\n", $sizeof{$me}; 
  4057. +}
  4058. +
  4059. +sub pdecl {
  4060. +    local($pdecl) = @_;
  4061. +    local(@pdecls);
  4062. +    local($tname);
  4063. +
  4064. +    warn "pdecl: $pdecl\n" if $debug;
  4065. +
  4066. +    $pdecl =~ s/\(\d+,(\d+)\)/$1/g;
  4067. +    $pdecl =~ s/\*//g; 
  4068. +    @pdecls = split(/=/, $pdecl); 
  4069. +    $typeno = $pdecls[0];
  4070. +    $tname = pop @pdecls;
  4071. +
  4072. +    if ($tname =~ s/^f//) { $tname = "$tname&"; } 
  4073. +    #else { $tname = "$tname*"; } 
  4074. +
  4075. +    for (reverse @pdecls) {
  4076. +    $tname  .= s/^f// ? "&" : "*"; 
  4077. +    #$tname =~ s/^f(.*)/$1&/;
  4078. +    print "type[$_] is $tname\n" if $debug;
  4079. +    $type[$_] = $tname unless defined $type[$_];
  4080. +    } 
  4081. +}
  4082. +
  4083. +
  4084. +
  4085. +sub adecl {
  4086. +    ($arraytype, $unknown, $lower, $upper) = ();
  4087. +    #local($typeno);
  4088. +    # global $typeno, @type
  4089. +    local($_, $typedef) = @_;
  4090. +
  4091. +    while (s/^((\d+)=)?ar(\d+);//) {
  4092. +    ($arraytype, $unknown) = ($2, $3); 
  4093. +    if (s/^(\d+);(\d+);//) {
  4094. +        ($lower, $upper) = ($1, $2); 
  4095. +        $scripts .= '[' .  ($upper+1) . ']'; 
  4096. +    } else {
  4097. +        warn "can't find array bounds: $_"; 
  4098. +    } 
  4099. +    }
  4100. +    if (s/^([\d*f=]*),(\d+),(\d+);//) {
  4101. +    ($start, $length) = ($2, $3); 
  4102. +    local($whatis) = $1;
  4103. +    if ($whatis =~ /^(\d+)=/) {
  4104. +        $typeno = $1;
  4105. +        &pdecl($whatis);
  4106. +    } else {
  4107. +        $typeno = $whatis;
  4108. +    }
  4109. +    } elsif (s/^(\d+)(=[*suf]\d*)//) {
  4110. +    local($whatis) = $2; 
  4111. +
  4112. +    if ($whatis =~ /[f*]/) {
  4113. +        &pdecl($whatis); 
  4114. +    } elsif ($whatis =~ /[su]/) {  # 
  4115. +        print "$prefix.$fieldname is an array$scripts anon structs; disgusting\n" 
  4116. +        if $debug;
  4117. +        #$type[$typeno] = $name unless defined $type[$typeno];
  4118. +        ##printf "new type $typeno is $name" if $debug;
  4119. +        $typeno = $1;
  4120. +        $type[$typeno] = "$prefix.$fieldname";
  4121. +        local($name) = $type[$typeno];
  4122. +        &sou($name, $whatis);
  4123. +        $_ = &sdecl($name, $_, $start+$offset);
  4124. +        1;
  4125. +        $start = $start{$name};
  4126. +        $offset = $sizeof{$name};
  4127. +        $length = $offset;
  4128. +    } else {
  4129. +        warn "what's this? $whatis in $line ";
  4130. +    } 
  4131. +    } elsif (/^\d+$/) {
  4132. +    $typeno = $_;
  4133. +    } else {
  4134. +    warn "bad array stab: $_ in $line ";
  4135. +    next STAB;
  4136. +    } 
  4137. +    #local($wasdef) = defined($type[$typeno]) && $debug;
  4138. +    #if ($typedef) { 
  4139. +    #print "redefining $type[$typeno] to " if $wasdef;
  4140. +    #$type[$typeno] = "$whatis$scripts"; # unless defined $type[$typeno];
  4141. +    #print "$type[$typeno]\n" if $wasdef;
  4142. +    #} else {
  4143. +    #$type[$arraytype] = $type[$typeno] unless defined $type[$arraytype];
  4144. +    #}
  4145. +    $type[$arraytype] = "$type[$typeno]$scripts" if defined $type[$typeno];
  4146. +    print "type[$arraytype] is $type[$arraytype]\n" if $debug;
  4147. +    print "$prefix.$fieldname is an array of $type[$arraytype]\n" if $debug;
  4148. +    $_;
  4149. +}
  4150. +
  4151. +
  4152. +
  4153. +sub sdecl {
  4154. +    local($prefix, $_, $offset) = @_;
  4155. +
  4156. +    local($fieldname, $scripts, $type, $arraytype, $unknown,
  4157. +    $whatis, $pdecl, $upper,$lower, $start,$length) = ();
  4158. +    local($typeno,$sou);
  4159. +
  4160. +
  4161. +SFIELD:
  4162. +    while (/^([^;]+);/) {
  4163. +    $scripts = '';
  4164. +    warn "sdecl $_\n" if $debug;
  4165. +    if (s/^([\$\w]+)://) { 
  4166. +        $fieldname = $1;
  4167. +    } elsif (s/(\d+)=([us])(\d+|\(\d+,\d+\))//) { # 
  4168. +        $typeno = &typeno($1);
  4169. +        $type[$typeno] = "$prefix.$fieldname";
  4170. +        local($name) = "$prefix.$fieldname";
  4171. +        &sou($name,$2);
  4172. +        $_ = &sdecl("$prefix.$fieldname", $_, $start+$offset);
  4173. +        $start = $start{$name};
  4174. +        $offset += $sizeof{$name};
  4175. +        #print "done with anon, start is $start, offset is $offset\n";
  4176. +        #next SFIELD;
  4177. +    } else  {
  4178. +        warn "weird field $_ of $line" if $debug;
  4179. +        next STAB;
  4180. +        #$fieldname = &gensym;
  4181. +        #$_ = &sdecl("$prefix.$fieldname", $_, $start+$offset);
  4182. +    }
  4183. +
  4184. +    if (/^\d+=ar/) {
  4185. +        $_ = &adecl($_);
  4186. +    }
  4187. +    elsif (s/^(\d+|\(\d+,\d+\))?,(\d+),(\d+);//) {
  4188. +        ($start, $length) =  ($2, $3); 
  4189. +        &panic("no length?") unless $length;
  4190. +        $typeno = &typeno($1) if $1;
  4191. +    }
  4192. +    elsif (s/^((\d+|\(\d+,\d+\))(=[*f](\d+|\(\d+,\d+\)))+),(\d+),(\d+);//) {
  4193. +        ($pdecl, $start, $length) =  ($1,$5,$6); 
  4194. +        &pdecl($pdecl); 
  4195. +    }
  4196. +    elsif (s/(\d+)=([us])(\d+|\(\d+,\d+\))//) { # the dratted anon struct
  4197. +        ($typeno, $sou) = ($1, $2);
  4198. +        $typeno = &typeno($typeno);
  4199. +        if (defined($type[$typeno])) {
  4200. +        warn "now how did we get type $1 in $fieldname of $line?";
  4201. +        } else {
  4202. +        print "anon type $typeno is $prefix.$fieldname\n" if $debug;
  4203. +        $type[$typeno] = "$prefix.$fieldname" unless defined $type[$typeno];
  4204. +        };
  4205. +        local($name) = "$prefix.$fieldname";
  4206. +        &sou($name,$sou);
  4207. +        print "anon ".($isastruct{$name}) ? "struct":"union"." for $prefix.$fieldname\n" if $debug;
  4208. +        $type[$typeno] = "$prefix.$fieldname";
  4209. +        $_ = &sdecl("$prefix.$fieldname", $_, $start+$offset); 
  4210. +        $start = $start{$name};
  4211. +        $length = $sizeof{$name};
  4212. +    }
  4213. +    else {
  4214. +        warn "can't grok stab for $name ($_) in line $line "; 
  4215. +        next STAB; 
  4216. +    }
  4217. +
  4218. +    &panic("no length for $prefix.$fieldname") unless $length;
  4219. +    $struct{$name} .= join(',', $fieldname, $typeno, $scripts, $start, $length) . ';';
  4220. +    }
  4221. +    if (s/;\d*,(\d+),(\d+);//) {
  4222. +    local($start, $size) = ($1, $2); 
  4223. +    $sizeof{$prefix} = $size;
  4224. +    print "start of $prefix is $start, size of $sizeof{$prefix}\n" if $debug; 
  4225. +    $start{$prefix} = $start; 
  4226. +    } 
  4227. +    $_;
  4228. +}
  4229. +
  4230. +sub edecl {
  4231. +    s/;$//;
  4232. +    $enum{$name} = $_;
  4233. +    $_ = '';
  4234. +} 
  4235. +
  4236. +sub resolve_types {
  4237. +    local($sou);
  4238. +    for $i (0 .. $#type) {
  4239. +    next unless defined $type[$i];
  4240. +    $_ = $type[$i];
  4241. +    unless (/\d/) {
  4242. +        print "type[$i] $type[$i]\n" if $debug;
  4243. +        next;
  4244. +    }
  4245. +    print "type[$i] $_ ==> " if $debug;
  4246. +    s/^(\d+)(\**)\&\*(\**)/"$2($3".&type($1) . ')()'/e;
  4247. +    s/^(\d+)\&/&type($1)/e; 
  4248. +    s/^(\d+)/&type($1)/e; 
  4249. +    s/(\*+)([^*]+)(\*+)/$1$3$2/;
  4250. +    s/\((\*+)(\w+)(\*+)\)/$3($1$2)/;
  4251. +    s/^(\d+)([\*\[].*)/&type($1).$2/e;
  4252. +    #s/(\d+)(\*|(\[[\[\]\d\*]+]\])+)/&type($1).$2/ge;
  4253. +    $type[$i] = $_;
  4254. +    print "$_\n" if $debug;
  4255. +    }
  4256. +}
  4257. +sub type { &psou($type[$_[0]] || "<UNDEFINED>"); } 
  4258. +
  4259. +sub adjust_start_addrs {
  4260. +    for (sort keys %start) {
  4261. +    ($basename = $_) =~ s/\.[^.]+$//;
  4262. +    $start{$_} += $start{$basename};
  4263. +    print "start: $_ @ $start{$_}\n" if $debug;
  4264. +    }
  4265. +}
  4266. +
  4267. +sub sou {
  4268. +    local($what, $_) = @_;
  4269. +    /u/ && $isaunion{$what}++;
  4270. +    /s/ && $isastruct{$what}++;
  4271. +}
  4272. +
  4273. +sub psou {
  4274. +    local($what) = @_;
  4275. +    local($prefix) = '';
  4276. +    if ($isaunion{$what})  {
  4277. +    $prefix = 'union ';
  4278. +    } elsif ($isastruct{$what})  {
  4279. +    $prefix = 'struct ';
  4280. +    }
  4281. +    $prefix . $what;
  4282. +}
  4283. +
  4284. +sub scrunch {
  4285. +    local($_) = @_;
  4286. +
  4287. +    study;
  4288. +
  4289. +    s/\$//g;
  4290. +    s/  / /g;
  4291. +    1 while s/(\w) \1/$1$1/g;
  4292. +
  4293. +    # i wanna say this, but perl resists my efforts:
  4294. +    #       s/(\w)(\1+)/$2 . length($1)/ge;
  4295. +
  4296. +    &quick_scrunch;
  4297. +
  4298. +    s/ $//;
  4299. +
  4300. +    $_;
  4301. +}
  4302. +
  4303. +sub buildscrunchlist {
  4304. +    $scrunch_code = "sub quick_scrunch {\n";
  4305. +    for (values %intrinsics) {
  4306. +        $scrunch_code .= "\ts/($_{2,})/'$_' . length(\$1)/ge;\n";
  4307. +    } 
  4308. +    $scrunch_code .= "}\n";
  4309. +    print "$scrunch_code" if $debug;
  4310. +    eval $scrunch_code;
  4311. +    &panic("can't eval scrunch_code $@ \nscrunch_code") if $@;
  4312. +} 
  4313. +
  4314. +sub fetch_template {
  4315. +    local($mytype) = @_;
  4316. +    local($fmt);
  4317. +    local($count) = 1;
  4318. +
  4319. +    &panic("why do you care?") unless $perl;
  4320. +
  4321. +    if ($mytype =~ s/(\[\d+\])+$//) {
  4322. +    $count .= $1;
  4323. +    } 
  4324. +
  4325. +    if ($mytype =~ /\*/) {
  4326. +    $fmt = $template{'pointer'};
  4327. +    } 
  4328. +    elsif (defined $template{$mytype}) {
  4329. +    $fmt = $template{$mytype};
  4330. +    } 
  4331. +    elsif (defined $struct{$mytype}) {
  4332. +    if (!defined $template{&psou($mytype)}) {
  4333. +        &build_template($mytype) unless $mytype eq $name;
  4334. +    } 
  4335. +    elsif ($template{&psou($mytype)} !~ /\$$/) {
  4336. +        #warn "incomplete template for $mytype\n";
  4337. +    } 
  4338. +    $fmt = $template{&psou($mytype)} || '?';
  4339. +    } 
  4340. +    else {
  4341. +    warn "unknown fmt for $mytype\n";
  4342. +    $fmt = '?';
  4343. +    } 
  4344. +
  4345. +    $fmt x $count . ' ';
  4346. +}
  4347. +
  4348. +sub compute_intrinsics {
  4349. +    local($TMP) = "/tmp/c2ph-i.$$.c";
  4350. +    open (TMP, ">$TMP") || die "can't open $TMP: $!";
  4351. +    select(TMP);
  4352. +
  4353. +    print STDERR "computing intrinsic sizes: " if $trace;
  4354. +
  4355. +    undef %intrinsics;
  4356. +
  4357. +    print <<'EOF';
  4358. +main() {
  4359. +    char *mask = "%d %s\n";
  4360. +EOF
  4361. +
  4362. +    for $type (@intrinsics) {
  4363. +    next if $type eq 'void';
  4364. +    print <<"EOF";
  4365. +    printf(mask,sizeof($type), "$type");
  4366. +EOF
  4367. +    } 
  4368. +
  4369. +    print <<'EOF';
  4370. +    printf(mask,sizeof(char *), "pointer");
  4371. +    exit(0);
  4372. +}
  4373. +EOF
  4374. +    close TMP;
  4375. +
  4376. +    select(STDOUT);
  4377. +    open(PIPE, "cd /tmp && $CC $TMP && /tmp/a.out|");
  4378. +    while (<PIPE>) {
  4379. +    chop;
  4380. +    split(' ',$_,2);;
  4381. +    print "intrinsic $_[1] is size $_[0]\n" if $debug;
  4382. +    $sizeof{$_[1]} = $_[0];
  4383. +    $intrinsics{$_[1]} = $template{$_[0]};
  4384. +    } 
  4385. +    close(PIPE) || die "couldn't read intrinsics!";
  4386. +    unlink($TMP, '/tmp/a.out');
  4387. +    print STDERR "done\n" if $trace;
  4388. +} 
  4389. +
  4390. +sub scripts2count {
  4391. +    local($_) = @_;
  4392. +
  4393. +    s/^\[//;
  4394. +    s/\]$//;
  4395. +    s/\]\[/*/g;
  4396. +    $_ = eval;
  4397. +    &panic("$_: $@") if $@;
  4398. +    $_;
  4399. +}
  4400. +
  4401. +sub system {
  4402. +    print STDERR "@_\n" if $trace;
  4403. +    system @_;
  4404. +} 
  4405. +
  4406. +sub build_template { 
  4407. +    local($name) = @_;
  4408. +
  4409. +    &panic("already got a template for $name") if defined $template{$name};
  4410. +
  4411. +    local($build_templates) = 1;
  4412. +
  4413. +    local($lparen) = '(' x $build_recursed;
  4414. +    local($rparen) = ')' x $build_recursed;
  4415. +
  4416. +    print STDERR "$lparen$name$rparen " if $trace;
  4417. +    $build_recursed++;
  4418. +    &pstruct($name,$name,0);
  4419. +    print STDERR "TEMPLATE for $name is ", $template{&psou($name)}, "\n" if $debug;
  4420. +    --$build_recursed;
  4421. +}
  4422. +
  4423. +
  4424. +sub panic {
  4425. +
  4426. +    select(STDERR);
  4427. +
  4428. +    print "\npanic: @_\n";
  4429. +
  4430. +    exit 1 if $] <= 4.003;  # caller broken
  4431. +
  4432. +    local($i,$_);
  4433. +    local($p,$f,$l,$s,$h,$a,@a,@sub);
  4434. +    for ($i = 0; ($p,$f,$l,$s,$h,$w) = caller($i); $i++) {
  4435. +    @a = @DB'args;
  4436. +    for (@a) {
  4437. +        if (/^StB\000/ && length($_) == length($_main{'_main'})) {
  4438. +        $_ = sprintf("%s",$_);
  4439. +        }
  4440. +        else {
  4441. +        s/'/\\'/g;
  4442. +        s/([^\0]*)/'$1'/ unless /^-?[\d.]+$/;
  4443. +        s/([\200-\377])/sprintf("M-%c",ord($1)&0177)/eg;
  4444. +        s/([\0-\37\177])/sprintf("^%c",ord($1)^64)/eg;
  4445. +        }
  4446. +    }
  4447. +    $w = $w ? '@ = ' : '$ = ';
  4448. +    $a = $h ? '(' . join(', ', @a) . ')' : '';
  4449. +    push(@sub, "$w&$s$a from file $f line $l\n");
  4450. +    last if $signal;
  4451. +    }
  4452. +    for ($i=0; $i <= $#sub; $i++) {
  4453. +    last if $signal;
  4454. +    print $sub[$i];
  4455. +    }
  4456. +    exit 1;
  4457. +} 
  4458. +
  4459. +sub squishseq {
  4460. +    local($num);
  4461. +    local($last) = -1e8;
  4462. +    local($string);
  4463. +    local($seq) = '..';
  4464. +
  4465. +    while (defined($num = shift)) {
  4466. +        if ($num == ($last + 1)) {
  4467. +            $string .= $seq unless $inseq++;
  4468. +            $last = $num;
  4469. +            next;
  4470. +        } elsif ($inseq) {
  4471. +            $string .= $last unless $last == -1e8;
  4472. +        }
  4473. +
  4474. +        $string .= ',' if defined $string;
  4475. +        $string .= $num;
  4476. +        $last = $num;
  4477. +        $inseq = 0;
  4478. +    }
  4479. +    $string .= $last if $inseq && $last != -e18;
  4480. +    $string;
  4481. +}
  4482. diff -u --new-file --recursive perl-4.036.orig/x2p/Makefile perl-4.036/x2p/Makefile
  4483. --- perl-4.036.orig/x2p/Makefile    Wed Dec 31 18:00:00 1969
  4484. +++ perl-4.036/x2p/Makefile    Tue Jan 17 21:16:30 1995
  4485. @@ -0,0 +1,130 @@
  4486. +# : Makefile.SH,v 4063Revision: 4.0.1.3 4063Date: 92/06/08 16:11:32 $
  4487. +#
  4488. +# $Log:    Makefile.SH,v $
  4489. +# Revision 4.0.1.3  92/06/08  16:11:32  lwall
  4490. +# patch20: SH files didn't work well with symbolic links
  4491. +# patch20: cray didn't give enough memory to /bin/sh
  4492. +# patch20: makefiles now display new shift/reduce expectations
  4493. +# 
  4494. +# Revision 4.0.1.2  91/11/05  19:19:04  lwall
  4495. +# patch11: random cleanup
  4496. +# 
  4497. +# Revision 4.0.1.1  91/06/07  12:12:14  lwall
  4498. +# patch4: cflags now emits entire cc command except for the filename
  4499. +# 
  4500. +# Revision 4.0  91/03/20  01:57:03  lwall
  4501. +# 4.0 baseline.
  4502. +# 
  4503. +# 
  4504. +
  4505. +CC = gcc
  4506. +YACC = bison -y
  4507. +bin = /usr/bin
  4508. +lib = 
  4509. +mansrc = /usr/man/man1
  4510. +manext = 1
  4511. +LDFLAGS = -s
  4512. +SMALL = 
  4513. +LARGE =  
  4514. +mallocsrc = 
  4515. +mallocobj = 
  4516. +shellflags = 
  4517. +
  4518. +libs = -ldbm -lm
  4519. +
  4520. +CCCMD = `sh $(shellflags) cflags $@`
  4521. +
  4522. +public = a2p s2p find2perl
  4523. +
  4524. +private = 
  4525. +
  4526. +manpages = a2p.man s2p.man
  4527. +
  4528. +util =
  4529. +
  4530. +sh = Makefile.SH makedepend.SH
  4531. +
  4532. +h = EXTERN.h INTERN.h ../config.h handy.h hash.h a2p.h str.h util.h
  4533. +
  4534. +c = hash.c $(mallocsrc) str.c util.c walk.c
  4535. +
  4536. +obj = hash.o $(mallocobj) str.o util.o walk.o
  4537. +
  4538. +lintflags = -phbvxac
  4539. +
  4540. +addedbyconf = Makefile.old bsd eunice filexp loc pdp11 usg v7
  4541. +
  4542. +# grrr
  4543. +SHELL = /bin/sh
  4544. +
  4545. +.c.o:
  4546. +    $(CCCMD) $*.c
  4547. +
  4548. +all: $(public) $(private) $(util)
  4549. +    touch all
  4550. +
  4551. +a2p: $(obj) a2p.o
  4552. +    $(CC) $(LDFLAGS) $(obj) a2p.o $(libs) -o a2p
  4553. +
  4554. +a2p.c: a2p.y
  4555. +    @ echo Expect 231 shift/reduce conflicts...
  4556. +    $(YACC) a2p.y
  4557. +    mv y.tab.c a2p.c
  4558. +
  4559. +a2p.o: a2p.c a2py.c a2p.h EXTERN.h util.h INTERN.h handy.h ../config.h str.h hash.h
  4560. +    $(CCCMD) $(LARGE) a2p.c
  4561. +
  4562. +install: a2p s2p
  4563. +# won't work with csh
  4564. +    export PATH || exit 1
  4565. +    - mv $(bin)/a2p $(bin)/a2p.old 2>/dev/null
  4566. +    - mv $(bin)/s2p $(bin)/s2p.old 2>/dev/null
  4567. +    - if test `pwd` != $(bin); then cp $(public) $(bin); fi
  4568. +    cd $(bin); \
  4569. +for pub in $(public); do \
  4570. +chmod +x `basename $$pub`; \
  4571. +done
  4572. +    - if test `pwd` != $(mansrc); then \
  4573. +for page in $(manpages); do \
  4574. +cp $$page $(mansrc)/`basename $$page .man`.$(manext); \
  4575. +done; \
  4576. +fi
  4577. +
  4578. +clean:
  4579. +    rm -f a2p *.o a2p.c
  4580. +
  4581. +realclean: clean
  4582. +    rm -f *.orig */*.orig core $(addedbyconf) a2p.c s2p find2perl all cflags
  4583. +
  4584. +# The following lint has practically everything turned on.  Unfortunately,
  4585. +# you have to wade through a lot of mumbo jumbo that can't be suppressed.
  4586. +# If the source file has a /*NOSTRICT*/ somewhere, ignore the lint message
  4587. +# for that spot.
  4588. +
  4589. +lint:
  4590. +    lint $(lintflags) $(defs) $(c) > a2p.fuzz
  4591. +
  4592. +depend: $(mallocsrc) ../makedepend
  4593. +    ../makedepend
  4594. +
  4595. +clist:
  4596. +    echo $(c) | tr ' ' '\012' >.clist
  4597. +
  4598. +hlist:
  4599. +    echo $(h) | tr ' ' '\012' >.hlist
  4600. +
  4601. +shlist:
  4602. +    echo $(sh) | tr ' ' '\012' >.shlist
  4603. +
  4604. +config.sh: ../config.sh
  4605. +    rm -f config.sh
  4606. +    ln ../config.sh .
  4607. +
  4608. +malloc.c: ../malloc.c
  4609. +    sed 's/"perl.h"/"..\/perl.h"/' ../malloc.c >malloc.c
  4610. +
  4611. +# AUTOMATICALLY GENERATED MAKE DEPENDENCIES--PUT NOTHING BELOW THIS LINE
  4612. +$(obj):
  4613. +    @ echo "You haven't done a "'"make depend" yet!'; exit 1
  4614. +makedepend: makedepend.SH
  4615. +    /bin/sh $(shellflags) makedepend.SH
  4616. diff -u --new-file --recursive perl-4.036.orig/x2p/cflags perl-4.036/x2p/cflags
  4617. --- perl-4.036.orig/x2p/cflags    Wed Dec 31 18:00:00 1969
  4618. +++ perl-4.036/x2p/cflags    Tue Jan 17 21:16:30 1995
  4619. @@ -0,0 +1,55 @@
  4620. +case "$0" in
  4621. +*/*) cd `expr X$0 : 'X\(.*\)/'` ;;
  4622. +esac
  4623. +case $CONFIG in
  4624. +'')
  4625. +    if test ! -f config.sh; then
  4626. +    ln ../config.sh . || \
  4627. +    ln ../../config.sh . || \
  4628. +    ln ../../../config.sh . || \
  4629. +    (echo "Can't find config.sh."; exit 1)
  4630. +    fi 2>/dev/null
  4631. +    . ./config.sh
  4632. +    ;;
  4633. +esac
  4634. +
  4635. +also=': '
  4636. +case $# in
  4637. +1) also='echo 1>&2 "      CCCMD = "'
  4638. +esac
  4639. +
  4640. +case $# in
  4641. +0) set *.c; echo "The current C flags are:" ;;
  4642. +esac
  4643. +
  4644. +set `echo "$* " | sed 's/\.[oc] / /g'`
  4645. +
  4646. +for file do
  4647. +
  4648. +    case "$#" in
  4649. +    1) ;;
  4650. +    *) echo $n "    $file.c    $c" ;;
  4651. +    esac
  4652. +
  4653. +    : allow variables like str_cflags to be evaluated
  4654. +
  4655. +    eval 'eval ${'"${file}_cflags"'-""}'
  4656. +
  4657. +    : or customize here
  4658. +
  4659. +    case "$file" in
  4660. +    a2p) ;;
  4661. +    a2py) ;;
  4662. +    hash) ;;
  4663. +    str) ;;
  4664. +    util) ;;
  4665. +    walk) ;;
  4666. +    *) ;;
  4667. +    esac
  4668. +
  4669. +    echo "$cc -c $ccflags $optimize $large $split"
  4670. +    eval "$also "'"$cc -c $ccflags $optimize $large $split"'
  4671. +
  4672. +    . ./config.sh
  4673. +
  4674. +done
  4675. diff -u --new-file --recursive perl-4.036.orig/x2p/cppstdin perl-4.036/x2p/cppstdin
  4676. --- perl-4.036.orig/x2p/cppstdin    Wed Dec 31 18:00:00 1969
  4677. +++ perl-4.036/x2p/cppstdin    Tue Jan 17 21:16:26 1995
  4678. @@ -0,0 +1 @@
  4679. +cat >.$$.c; gcc -E ${1+"$@"} .$$.c; rm .$$.c
  4680. diff -u --new-file --recursive perl-4.036.orig/x2p/find2perl perl-4.036/x2p/find2perl
  4681. --- perl-4.036.orig/x2p/find2perl    Wed Dec 31 18:00:00 1969
  4682. +++ perl-4.036/x2p/find2perl    Tue Jan 17 21:16:31 1995
  4683. @@ -0,0 +1,568 @@
  4684. +#!/usr/bin/perl
  4685. +
  4686. +eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
  4687. +    if $running_under_some_shell;
  4688. +
  4689. +$bin = "/usr/bin";
  4690. +
  4691. +
  4692. +while ($ARGV[0] =~ /^[^-!(]/) {
  4693. +    push(@roots, shift);
  4694. +}
  4695. +@roots = ('.') unless @roots;
  4696. +for (@roots) { $_ = "e($_); }
  4697. +$roots = join(',', @roots);
  4698. +
  4699. +$indent = 1;
  4700. +
  4701. +while (@ARGV) {
  4702. +    $_ = shift;
  4703. +    s/^-// || /^[()!]/ || die "Unrecognized switch: $_\n";
  4704. +    if ($_ eq '(') {
  4705. +    $out .= &tab . "(\n";
  4706. +    $indent++;
  4707. +    next;
  4708. +    }
  4709. +    elsif ($_ eq ')') {
  4710. +    $indent--;
  4711. +    $out .= &tab . ")";
  4712. +    }
  4713. +    elsif ($_ eq '!') {
  4714. +    $out .= &tab . "!";
  4715. +    next;
  4716. +    }
  4717. +    elsif ($_ eq 'name') {
  4718. +    $out .= &tab;
  4719. +    $pat = &fileglob_to_re(shift);
  4720. +    $out .= '/' . $pat . "/";
  4721. +    }
  4722. +    elsif ($_ eq 'perm') {
  4723. +    $onum = shift;
  4724. +    die "Malformed -perm argument: $onum\n" unless $onum =~ /^-?[0-7]+$/;
  4725. +    if ($onum =~ s/^-//) {
  4726. +        $onum = '0' . sprintf("%o", oct($onum) & 017777);    # s/b 07777 ?
  4727. +        $out .= &tab . "((\$mode & $onum) == $onum)";
  4728. +    }
  4729. +    else {
  4730. +        $onum = '0' . $onum unless $onum =~ /^0/;
  4731. +        $out .= &tab . "((\$mode & 0777) == $onum)";
  4732. +    }
  4733. +    }
  4734. +    elsif ($_ eq 'type') {
  4735. +    ($filetest = shift) =~ tr/s/S/;
  4736. +    $out .= &tab . "-$filetest _";
  4737. +    }
  4738. +    elsif ($_ eq 'print') {
  4739. +    $out .= &tab . 'print("$name\n")';
  4740. +    }
  4741. +    elsif ($_ eq 'print0') {
  4742. +    $out .= &tab . 'print("$name\0")';
  4743. +    }
  4744. +    elsif ($_ eq 'fstype') {
  4745. +    $out .= &tab;
  4746. +    $type = shift;
  4747. +    if ($type eq 'nfs')
  4748. +        { $out .= '$dev < 0'; }
  4749. +    else
  4750. +        { $out .= '$dev >= 0'; }
  4751. +    }
  4752. +    elsif ($_ eq 'user') {
  4753. +    $uname = shift;
  4754. +    $out .= &tab . "\$uid == \$uid{'$uname'}";
  4755. +    $inituser++;
  4756. +    }
  4757. +    elsif ($_ eq 'group') {
  4758. +    $gname = shift;
  4759. +    $out .= &tab . "\$gid == \$gid{'$gname'}";
  4760. +    $initgroup++;
  4761. +    }
  4762. +    elsif ($_ eq 'nouser') {
  4763. +    $out .= &tab . '!defined $uid{$uid}';
  4764. +    $inituser++;
  4765. +    }
  4766. +    elsif ($_ eq 'nogroup') {
  4767. +    $out .= &tab . '!defined $gid{$gid}';
  4768. +    $initgroup++;
  4769. +    }
  4770. +    elsif ($_ eq 'links') {
  4771. +    $out .= &tab . '$nlink ' . &n(shift);
  4772. +    }
  4773. +    elsif ($_ eq 'inum') {
  4774. +    $out .= &tab . '$ino ' . &n(shift);
  4775. +    }
  4776. +    elsif ($_ eq 'size') {
  4777. +    $out .= &tab . 'int((-s _ + 511) / 512) ' . &n(shift);
  4778. +    }
  4779. +    elsif ($_ eq 'atime') {
  4780. +    $out .= &tab . 'int(-A _) ' . &n(shift);
  4781. +    }
  4782. +    elsif ($_ eq 'mtime') {
  4783. +    $out .= &tab . 'int(-M _) ' . &n(shift);
  4784. +    }
  4785. +    elsif ($_ eq 'ctime') {
  4786. +    $out .= &tab . 'int(-C _) ' . &n(shift);
  4787. +    }
  4788. +    elsif ($_ eq 'exec') {
  4789. +    for (@cmd = (); @ARGV && $ARGV[0] ne ';'; push(@cmd,shift)) { }
  4790. +    shift;
  4791. +    $_ = "@cmd";
  4792. +    if (m#^(/bin/)?rm -f {}$#) {
  4793. +        if (!@ARGV) {
  4794. +        $out .= &tab . 'unlink($_)';
  4795. +        }
  4796. +        else {
  4797. +        $out .= &tab . '(unlink($_) || 1)';
  4798. +        }
  4799. +    }
  4800. +    elsif (m#^(/bin/)?rm {}$#) {
  4801. +        $out .= &tab . '(unlink($_) || warn "$name: $!\n")';
  4802. +    }
  4803. +    else {
  4804. +        for (@cmd) { s/'/\\'/g; }
  4805. +        $" = "','";
  4806. +        $out .= &tab . "&exec(0, '@cmd')";
  4807. +        $" = ' ';
  4808. +        $initexec++;
  4809. +    }
  4810. +    }
  4811. +    elsif ($_ eq 'ok') {
  4812. +    for (@cmd = (); @ARGV && $ARGV[0] ne ';'; push(@cmd,shift)) { }
  4813. +    shift;
  4814. +    for (@cmd) { s/'/\\'/g; }
  4815. +    $" = "','";
  4816. +    $out .= &tab . "&exec(1, '@cmd')";
  4817. +    $" = ' ';
  4818. +    $initexec++;
  4819. +    }
  4820. +    elsif ($_ eq 'prune') {
  4821. +    $out .= &tab . '($prune = 1)';
  4822. +    }
  4823. +    elsif ($_ eq 'xdev') {
  4824. +    $out .= &tab . '(($prune |= ($dev != $topdev)),1)';
  4825. +    }
  4826. +    elsif ($_ eq 'newer') {
  4827. +    $out .= &tab;
  4828. +    $file = shift;
  4829. +    $newername = 'AGE_OF' . $file;
  4830. +    $newername =~ s/[^\w]/_/g;
  4831. +    $newername = '$' . $newername;
  4832. +    $out .= "-M _ < $newername";
  4833. +    $initnewer .= "$newername = -M " . "e($file) . ";\n";
  4834. +    }
  4835. +    elsif ($_ eq 'eval') {
  4836. +    $prog = "e(shift);
  4837. +    $out .= &tab . "eval $prog";
  4838. +    }
  4839. +    elsif ($_ eq 'depth') {
  4840. +    $depth++;
  4841. +    next;
  4842. +    }
  4843. +    elsif ($_ eq 'ls') {
  4844. +    $out .= &tab . "&ls";
  4845. +    $initls++;
  4846. +    }
  4847. +    elsif ($_ eq 'tar') {
  4848. +    $out .= &tab;
  4849. +    die "-tar must have a filename argument\n" unless @ARGV;
  4850. +    $file = shift;
  4851. +    $fh = 'FH' . $file;
  4852. +    $fh =~ s/[^\w]/_/g;
  4853. +    $out .= "&tar($fh)";
  4854. +    $file = '>' . $file;
  4855. +    $initfile .= "open($fh, " . "e($file) .
  4856. +      qq{) || die "Can't open $fh: \$!\\n";\n};
  4857. +    $inittar++;
  4858. +    $flushall = "\n&tflushall;\n";
  4859. +    }
  4860. +    elsif (/^n?cpio$/) {
  4861. +    $depth++;
  4862. +    $out .= &tab;
  4863. +    die "-$_ must have a filename argument\n" unless @ARGV;
  4864. +    $file = shift;
  4865. +    $fh = 'FH' . $file;
  4866. +    $fh =~ s/[^\w]/_/g;
  4867. +    $out .= "&cpio('" . substr($_,0,1) . "', $fh)";
  4868. +    $file = '>' . $file;
  4869. +    $initfile .= "open($fh, " . "e($file) .
  4870. +      qq{) || die "Can't open $fh: \$!\\n";\n};
  4871. +    $initcpio++;
  4872. +    $flushall = "\n&flushall;\n";
  4873. +    }
  4874. +    else {
  4875. +    die "Unrecognized switch: -$_\n";
  4876. +    }
  4877. +    if (@ARGV) {
  4878. +    if ($ARGV[0] eq '-o') {
  4879. +        { local($statdone) = 1; $out .= "\n" . &tab . "||\n"; }
  4880. +        $statdone = 0 if $indent == 1 && $delayedstat;
  4881. +        $saw_or++;
  4882. +        shift;
  4883. +    }
  4884. +    else {
  4885. +        $out .= " &&" unless $ARGV[0] eq ')';
  4886. +        $out .= "\n";
  4887. +        shift if $ARGV[0] eq '-a';
  4888. +    }
  4889. +    }
  4890. +}
  4891. +
  4892. +print <<"END";
  4893. +#!$bin/perl
  4894. +
  4895. +eval 'exec $bin/perl -S \$0 \${1+"\$@"}'
  4896. +    if \$running_under_some_shell;
  4897. +
  4898. +END
  4899. +
  4900. +if ($initls) {
  4901. +    print <<'END';
  4902. +@rwx = ('---','--x','-w-','-wx','r--','r-x','rw-','rwx');
  4903. +@moname = (Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec);
  4904. +
  4905. +END
  4906. +}
  4907. +
  4908. +if ($inituser || $initls) {
  4909. +    print 'while (($name, $pw, $uid) = getpwent) {', "\n";
  4910. +    print '    $uid{$name} = $uid{$uid} = $uid;', "\n" if $inituser;
  4911. +    print '    $user{$uid} = $name unless $user{$uid};', "\n" if $initls;
  4912. +    print "}\n\n";
  4913. +}
  4914. +
  4915. +if ($initgroup || $initls) {
  4916. +    print 'while (($name, $pw, $gid) = getgrent) {', "\n";
  4917. +    print '    $gid{$name} = $gid{$gid} = $gid;', "\n" if $initgroup;
  4918. +    print '    $group{$gid} = $name unless $group{$gid};', "\n" if $initls;
  4919. +    print "}\n\n";
  4920. +}
  4921. +
  4922. +print $initnewer, "\n" if $initnewer;
  4923. +
  4924. +print $initfile, "\n" if $initfile;
  4925. +
  4926. +$find = $depth ? "finddepth" : "find";
  4927. +print <<"END";
  4928. +require "$find.pl";
  4929. +
  4930. +# Traverse desired filesystems
  4931. +
  4932. +&$find($roots);
  4933. +$flushall
  4934. +exit;
  4935. +
  4936. +sub wanted {
  4937. +$out;
  4938. +}
  4939. +
  4940. +END
  4941. +
  4942. +if ($initexec) {
  4943. +    print <<'END';
  4944. +sub exec {
  4945. +    local($ok, @cmd) = @_;
  4946. +    foreach $word (@cmd) {
  4947. +    $word =~ s#{}#$name#g;
  4948. +    }
  4949. +    if ($ok) {
  4950. +    local($old) = select(STDOUT);
  4951. +    $| = 1;
  4952. +    print "@cmd";
  4953. +    select($old);
  4954. +    return 0 unless <STDIN> =~ /^y/;
  4955. +    }
  4956. +    chdir $cwd;        # sigh
  4957. +    system @cmd;
  4958. +    chdir $dir;
  4959. +    return !$?;
  4960. +}
  4961. +
  4962. +END
  4963. +}
  4964. +
  4965. +if ($initls) {
  4966. +    print <<'END';
  4967. +sub ls {
  4968. +    ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$sizemm,
  4969. +      $atime,$mtime,$ctime,$blksize,$blocks) = lstat(_);
  4970. +
  4971. +    $pname = $name;
  4972. +
  4973. +    if (defined $blocks) {
  4974. +    $blocks = int(($blocks + 1) / 2);
  4975. +    }
  4976. +    else {
  4977. +    $blocks = int(($size + 1023) / 1024);
  4978. +    }
  4979. +
  4980. +    if    (-f _) { $perms = '-'; }
  4981. +    elsif (-d _) { $perms = 'd'; }
  4982. +    elsif (-c _) { $perms = 'c'; $sizemm = &sizemm; }
  4983. +    elsif (-b _) { $perms = 'b'; $sizemm = &sizemm; }
  4984. +    elsif (-p _) { $perms = 'p'; }
  4985. +    elsif (-S _) { $perms = 's'; }
  4986. +    else         { $perms = 'l'; $pname .= ' -> ' . readlink($_); }
  4987. +
  4988. +    $tmpmode = $mode;
  4989. +    $tmp = $rwx[$tmpmode & 7];
  4990. +    $tmpmode >>= 3;
  4991. +    $tmp = $rwx[$tmpmode & 7] . $tmp;
  4992. +    $tmpmode >>= 3;
  4993. +    $tmp = $rwx[$tmpmode & 7] . $tmp;
  4994. +    substr($tmp,2,1) =~ tr/-x/Ss/ if -u _;
  4995. +    substr($tmp,5,1) =~ tr/-x/Ss/ if -g _;
  4996. +    substr($tmp,8,1) =~ tr/-x/Tt/ if -k _;
  4997. +    $perms .= $tmp;
  4998. +
  4999. +    $user = $user{$uid} || $uid;
  5000. +    $group = $group{$gid} || $gid;
  5001. +
  5002. +    ($sec,$min,$hour,$mday,$mon,$year) = localtime($mtime);
  5003. +    $moname = $moname[$mon];
  5004. +    if (-M _ > 365.25 / 2) {
  5005. +    $timeyear = '19' . $year;
  5006. +    }
  5007. +    else {
  5008. +    $timeyear = sprintf("%02d:%02d", $hour, $min);
  5009. +    }
  5010. +
  5011. +    printf "%5lu %4ld %-10s %2d %-8s %-8s %8s %s %2d %5s %s\n",
  5012. +        $ino,
  5013. +         $blocks,
  5014. +              $perms,
  5015. +                $nlink,
  5016. +                $user,
  5017. +                     $group,
  5018. +                      $sizemm,
  5019. +                          $moname,
  5020. +                         $mday,
  5021. +                             $timeyear,
  5022. +                             $pname;
  5023. +    1;
  5024. +}
  5025. +
  5026. +sub sizemm {
  5027. +    sprintf("%3d, %3d", ($rdev >> 8) & 255, $rdev & 255);
  5028. +}
  5029. +
  5030. +END
  5031. +}
  5032. +
  5033. +if ($initcpio) {
  5034. +print <<'END';
  5035. +sub cpio {
  5036. +    local($nc,$fh) = @_;
  5037. +    local($text);
  5038. +
  5039. +    if ($name eq 'TRAILER!!!') {
  5040. +    $text = '';
  5041. +    $size = 0;
  5042. +    }
  5043. +    else {
  5044. +    ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
  5045. +      $atime,$mtime,$ctime,$blksize,$blocks) = lstat(_);
  5046. +    if (-f _) {
  5047. +        open(IN, "./$_\0") || do {
  5048. +        warn "Couldn't open $name: $!\n";
  5049. +        return;
  5050. +        };
  5051. +    }
  5052. +    else {
  5053. +        $text = readlink($_);
  5054. +        $size = 0 unless defined $text;
  5055. +    }
  5056. +    }
  5057. +
  5058. +    ($nm = $name) =~ s#^\./##;
  5059. +    $nc{$fh} = $nc;
  5060. +    if ($nc eq 'n') {
  5061. +    $cpout{$fh} .=
  5062. +      sprintf("%06o%06o%06o%06o%06o%06o%06o%06o%011lo%06o%011lo%s\0",
  5063. +        070707,
  5064. +        $dev & 0777777,
  5065. +        $ino & 0777777,
  5066. +        $mode & 0777777,
  5067. +        $uid & 0777777,
  5068. +        $gid & 0777777,
  5069. +        $nlink & 0777777,
  5070. +        $rdev & 0177777,
  5071. +        $mtime,
  5072. +        length($nm)+1,
  5073. +        $size,
  5074. +        $nm);
  5075. +    }
  5076. +    else {
  5077. +    $cpout{$fh} .= "\0" if length($cpout{$fh}) & 1;
  5078. +    $cpout{$fh} .= pack("SSSSSSSSLSLa*",
  5079. +        070707, $dev, $ino, $mode, $uid, $gid, $nlink, $rdev, $mtime,
  5080. +        length($nm)+1, $size, $nm . (length($nm) & 1 ? "\0" : "\0\0"));
  5081. +    }
  5082. +    if ($text ne '') {
  5083. +    $cpout{$fh} .= $text;
  5084. +    }
  5085. +    elsif ($size) {
  5086. +    &flush($fh) while ($l = length($cpout{$fh})) >= 5120;
  5087. +    while (sysread(IN, $cpout{$fh}, 5120 - $l, $l)) {
  5088. +        &flush($fh);
  5089. +        $l = length($cpout{$fh});
  5090. +    }
  5091. +    }
  5092. +    close IN;
  5093. +}
  5094. +
  5095. +sub flush {
  5096. +    local($fh) = @_;
  5097. +
  5098. +    while (length($cpout{$fh}) >= 5120) {
  5099. +    syswrite($fh,$cpout{$fh},5120);
  5100. +    ++$blocks{$fh};
  5101. +    substr($cpout{$fh}, 0, 5120) = '';
  5102. +    }
  5103. +}
  5104. +
  5105. +sub flushall {
  5106. +    $name = 'TRAILER!!!';
  5107. +    foreach $fh (keys %cpout) {
  5108. +    &cpio($nc{$fh},$fh);
  5109. +    $cpout{$fh} .= "0" x (5120 - length($cpout{$fh}));
  5110. +    &flush($fh);
  5111. +    print $blocks{$fh} * 10, " blocks\n";
  5112. +    }
  5113. +}
  5114. +
  5115. +END
  5116. +}
  5117. +
  5118. +if ($inittar) {
  5119. +print <<'END';
  5120. +sub tar {
  5121. +    local($fh) = @_;
  5122. +    local($linkname,$header,$l,$slop);
  5123. +    local($linkflag) = "\0";
  5124. +
  5125. +    ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
  5126. +      $atime,$mtime,$ctime,$blksize,$blocks) = lstat(_);
  5127. +    $nm = $name;
  5128. +    if ($nlink > 1) {
  5129. +    if ($linkname = $linkseen{$fh,$dev,$ino}) {
  5130. +        $linkflag = 1;
  5131. +    }
  5132. +    else {
  5133. +        $linkseen{$fh,$dev,$ino} = $nm;
  5134. +    }
  5135. +    }
  5136. +    if (-f _) {
  5137. +    open(IN, "./$_\0") || do {
  5138. +        warn "Couldn't open $name: $!\n";
  5139. +        return;
  5140. +    };
  5141. +    $size = 0 if $linkflag ne "\0";
  5142. +    }
  5143. +    else {
  5144. +    $linkname = readlink($_);
  5145. +    $linkflag = 2 if defined $linkname;
  5146. +    $nm .= '/' if -d _;
  5147. +    $size = 0;
  5148. +    }
  5149. +
  5150. +    $header = pack("a100a8a8a8a12a12a8a1a100",
  5151. +    $nm,
  5152. +    sprintf("%6o ", $mode & 0777),
  5153. +    sprintf("%6o ", $uid & 0777777),
  5154. +    sprintf("%6o ", $gid & 0777777),
  5155. +    sprintf("%11o ", $size),
  5156. +    sprintf("%11o ", $mtime),
  5157. +    "        ",
  5158. +    $linkflag,
  5159. +    $linkname);
  5160. +    $l = length($header) % 512;
  5161. +    substr($header, 148, 6) = sprintf("%6o", unpack("%16C*", $header));
  5162. +    substr($header, 154, 1) = "\0";  # blech
  5163. +    $tarout{$fh} .= $header;
  5164. +    $tarout{$fh} .= "\0" x (512 - $l) if $l;
  5165. +    if ($size) {
  5166. +    &tflush($fh) while ($l = length($tarout{$fh})) >= 10240;
  5167. +    while (sysread(IN, $tarout{$fh}, 10240 - $l, $l)) {
  5168. +        $slop = length($tarout{$fh}) % 512;
  5169. +        $tarout{$fh} .= "\0" x (512 - $slop) if $slop;
  5170. +        &tflush($fh);
  5171. +        $l = length($tarout{$fh});
  5172. +    }
  5173. +    }
  5174. +    close IN;
  5175. +}
  5176. +
  5177. +sub tflush {
  5178. +    local($fh) = @_;
  5179. +
  5180. +    while (length($tarout{$fh}) >= 10240) {
  5181. +    syswrite($fh,$tarout{$fh},10240);
  5182. +    ++$blocks{$fh};
  5183. +    substr($tarout{$fh}, 0, 10240) = '';
  5184. +    }
  5185. +}
  5186. +
  5187. +sub tflushall {
  5188. +    local($len);
  5189. +
  5190. +    foreach $fh (keys %tarout) {
  5191. +    $len = 10240 - length($tarout{$fh});
  5192. +    $len += 10240 if $len < 1024;
  5193. +    $tarout{$fh} .= "\0" x $len;
  5194. +    &tflush($fh);
  5195. +    }
  5196. +}
  5197. +
  5198. +END
  5199. +}
  5200. +
  5201. +exit;
  5202. +
  5203. +############################################################################
  5204. +
  5205. +sub tab {
  5206. +    local($tabstring);
  5207. +
  5208. +    $tabstring = "\t" x ($indent / 2) . ' ' x ($indent % 2 * 4);
  5209. +    if (!$statdone) {
  5210. +    if ($_ =~ /^(name|print|prune|exec|ok|\(|\))/) {
  5211. +        $delayedstat++;
  5212. +    }
  5213. +    else {
  5214. +        if ($saw_or) {
  5215. +        $tabstring .= <<'ENDOFSTAT' . $tabstring;
  5216. +($nlink || (($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_))) &&
  5217. +ENDOFSTAT
  5218. +        }
  5219. +        else {
  5220. +        $tabstring .= <<'ENDOFSTAT' . $tabstring;
  5221. +(($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_)) &&
  5222. +ENDOFSTAT
  5223. +        }
  5224. +        $statdone = 1;
  5225. +    }
  5226. +    }
  5227. +    $tabstring =~ s/^\s+/ / if $out =~ /!$/;
  5228. +    $tabstring;
  5229. +}
  5230. +
  5231. +sub fileglob_to_re {
  5232. +    local($tmp) = @_;
  5233. +
  5234. +    $tmp =~ s/([.^\$()])/\\$1/g;
  5235. +    $tmp =~ s/([?*])/.$1/g;
  5236. +    "^$tmp$";
  5237. +}
  5238. +
  5239. +sub n {
  5240. +    local($n) = @_;
  5241. +
  5242. +    $n =~ s/^-/< / || $n =~ s/^\+/> / || $n =~ s/^/== /;
  5243. +    $n =~ s/ 0*(\d)/ $1/;
  5244. +    $n;
  5245. +}
  5246. +
  5247. +sub quote {
  5248. +    local($string) = @_;
  5249. +    $string =~ s/'/\\'/;
  5250. +    "'$string'";
  5251. +}
  5252. diff -u --new-file --recursive perl-4.036.orig/x2p/s2p perl-4.036/x2p/s2p
  5253. --- perl-4.036.orig/x2p/s2p    Wed Dec 31 18:00:00 1969
  5254. +++ perl-4.036/x2p/s2p    Tue Jan 17 21:16:31 1995
  5255. @@ -0,0 +1,758 @@
  5256. +#!/usr/bin/perl
  5257. +
  5258. +eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
  5259. +    if $running_under_some_shell;
  5260. +
  5261. +$bin = '/usr/bin';
  5262. +
  5263. +# $RCSfile: s2p.SH,v $$Revision: 4.0.1.2 $$Date: 92/06/08 17:26:31 $
  5264. +#
  5265. +# $Log:    s2p.SH,v $
  5266. +# Revision 4.0.1.2  92/06/08  17:26:31  lwall
  5267. +# patch20: s2p didn't output portable startup code
  5268. +# patch20: added ... as variant on ..
  5269. +# patch20: s2p didn't translate s/pat/\&/ or s/pat/\$/ or s/pat/\\1/ right
  5270. +# 
  5271. +# Revision 4.0.1.1  91/06/07  12:19:18  lwall
  5272. +# patch4: s2p now handles embedded newlines better and optimizes common idioms
  5273. +# 
  5274. +# Revision 4.0  91/03/20  01:57:59  lwall
  5275. +# 4.0 baseline.
  5276. +# 
  5277. +#
  5278. +
  5279. +$indent = 4;
  5280. +$shiftwidth = 4;
  5281. +$l = '{'; $r = '}';
  5282. +
  5283. +while ($ARGV[0] =~ /^-/) {
  5284. +    $_ = shift;
  5285. +  last if /^--/;
  5286. +    if (/^-D/) {
  5287. +    $debug++;
  5288. +    open(BODY,'>-');
  5289. +    next;
  5290. +    }
  5291. +    if (/^-n/) {
  5292. +    $assumen++;
  5293. +    next;
  5294. +    }
  5295. +    if (/^-p/) {
  5296. +    $assumep++;
  5297. +    next;
  5298. +    }
  5299. +    die "I don't recognize this switch: $_\n";
  5300. +}
  5301. +
  5302. +unless ($debug) {
  5303. +    open(BODY,">/tmp/sperl$$") ||
  5304. +      &Die("Can't open temp file: $!\n");
  5305. +}
  5306. +
  5307. +if (!$assumen && !$assumep) {
  5308. +    print BODY &q(<<'EOT');
  5309. +:    while ($ARGV[0] =~ /^-/) {
  5310. +:        $_ = shift;
  5311. +:      last if /^--/;
  5312. +:        if (/^-n/) {
  5313. +:        $nflag++;
  5314. +:        next;
  5315. +:        }
  5316. +:        die "I don't recognize this switch: $_\\n";
  5317. +:    }
  5318. +:    
  5319. +EOT
  5320. +}
  5321. +
  5322. +print BODY &q(<<'EOT');
  5323. +:    #ifdef PRINTIT
  5324. +:    #ifdef ASSUMEP
  5325. +:    $printit++;
  5326. +:    #else
  5327. +:    $printit++ unless $nflag;
  5328. +:    #endif
  5329. +:    #endif
  5330. +:    <><>
  5331. +:    $\ = "\n";        # automatically add newline on print
  5332. +:    <><>
  5333. +:    #ifdef TOPLABEL
  5334. +:    LINE:
  5335. +:    while (chop($_ = <>)) {
  5336. +:    #else
  5337. +:    LINE:
  5338. +:    while (<>) {
  5339. +:        chop;
  5340. +:    #endif
  5341. +EOT
  5342. +
  5343. +LINE:
  5344. +while (<>) {
  5345. +
  5346. +    # Wipe out surrounding whitespace.
  5347. +
  5348. +    s/[ \t]*(.*)\n$/$1/;
  5349. +
  5350. +    # Perhaps it's a label/comment.
  5351. +
  5352. +    if (/^:/) {
  5353. +    s/^:[ \t]*//;
  5354. +    $label = &make_label($_);
  5355. +    if ($. == 1) {
  5356. +        $toplabel = $label;
  5357. +        if (/^(top|(re)?start|redo|begin(ning)|again|input)$/i) {
  5358. +        $_ = <>;
  5359. +        redo LINE; # Never referenced, so delete it if not a comment.
  5360. +        }
  5361. +    }
  5362. +    $_ = "$label:";
  5363. +    if ($lastlinewaslabel++) {
  5364. +        $indent += 4;
  5365. +        print BODY &tab, ";\n";
  5366. +        $indent -= 4;
  5367. +    }
  5368. +    if ($indent >= 2) {
  5369. +        $indent -= 2;
  5370. +        $indmod = 2;
  5371. +    }
  5372. +    next;
  5373. +    } else {
  5374. +    $lastlinewaslabel = '';
  5375. +    }
  5376. +
  5377. +    # Look for one or two address clauses
  5378. +
  5379. +    $addr1 = '';
  5380. +    $addr2 = '';
  5381. +    if (s/^([0-9]+)//) {
  5382. +    $addr1 = "$1";
  5383. +    $addr1 = "\$. == $addr1" unless /^,/;
  5384. +    }
  5385. +    elsif (s/^\$//) {
  5386. +    $addr1 = 'eof()';
  5387. +    }
  5388. +    elsif (s|^/||) {
  5389. +    $addr1 = &fetchpat('/');
  5390. +    }
  5391. +    if (s/^,//) {
  5392. +    if (s/^([0-9]+)//) {
  5393. +        $addr2 = "$1";
  5394. +    } elsif (s/^\$//) {
  5395. +        $addr2 = "eof()";
  5396. +    } elsif (s|^/||) {
  5397. +        $addr2 = &fetchpat('/');
  5398. +    } else {
  5399. +        &Die("Invalid second address at line $.\n");
  5400. +    }
  5401. +    if ($addr2 =~ /^\d+$/) {
  5402. +        $addr1 .= "..$addr2";
  5403. +    }
  5404. +    else {
  5405. +        $addr1 .= "...$addr2";
  5406. +    }
  5407. +    }
  5408. +
  5409. +    # Now we check for metacommands {, }, and ! and worry
  5410. +    # about indentation.
  5411. +
  5412. +    s/^[ \t]+//;
  5413. +    # a { to keep vi happy
  5414. +    if ($_ eq '}') {
  5415. +    $indent -= 4;
  5416. +    next;
  5417. +    }
  5418. +    if (s/^!//) {
  5419. +    $if = 'unless';
  5420. +    $else = "$r else $l\n";
  5421. +    } else {
  5422. +    $if = 'if';
  5423. +    $else = '';
  5424. +    }
  5425. +    if (s/^{//) {    # a } to keep vi happy
  5426. +    $indmod = 4;
  5427. +    $redo = $_;
  5428. +    $_ = '';
  5429. +    $rmaybe = '';
  5430. +    } else {
  5431. +    $rmaybe = "\n$r";
  5432. +    if ($addr2 || $addr1) {
  5433. +        $space = ' ' x $shiftwidth;
  5434. +    } else {
  5435. +        $space = '';
  5436. +    }
  5437. +    $_ = &transmogrify();
  5438. +    }
  5439. +
  5440. +    # See if we can optimize to modifier form.
  5441. +
  5442. +    if ($addr1) {
  5443. +    if ($_ !~ /[\n{}]/ && $rmaybe && !$change &&
  5444. +      $_ !~ / if / && $_ !~ / unless /) {
  5445. +        s/;$/ $if $addr1;/;
  5446. +        $_ = substr($_,$shiftwidth,1000);
  5447. +    } else {
  5448. +        $_ = "$if ($addr1) $l\n$change$_$rmaybe";
  5449. +    }
  5450. +    $change = '';
  5451. +    next LINE;
  5452. +    }
  5453. +} continue {
  5454. +    @lines = split(/\n/,$_);
  5455. +    for (@lines) {
  5456. +    unless (s/^ *<<--//) {
  5457. +        print BODY &tab;
  5458. +    }
  5459. +    print BODY $_, "\n";
  5460. +    }
  5461. +    $indent += $indmod;
  5462. +    $indmod = 0;
  5463. +    if ($redo) {
  5464. +    $_ = $redo;
  5465. +    $redo = '';
  5466. +    redo LINE;
  5467. +    }
  5468. +}
  5469. +if ($lastlinewaslabel++) {
  5470. +    $indent += 4;
  5471. +    print BODY &tab, ";\n";
  5472. +    $indent -= 4;
  5473. +}
  5474. +
  5475. +if ($appendseen || $tseen || !$assumen) {
  5476. +    $printit++ if $dseen || (!$assumen && !$assumep);
  5477. +    print BODY &q(<<'EOT');
  5478. +:    #ifdef SAWNEXT
  5479. +:    }
  5480. +:    continue {
  5481. +:    #endif
  5482. +:    #ifdef PRINTIT
  5483. +:    #ifdef DSEEN
  5484. +:    #ifdef ASSUMEP
  5485. +:        print if $printit++;
  5486. +:    #else
  5487. +:        if ($printit)
  5488. +:        { print; }
  5489. +:        else
  5490. +:        { $printit++ unless $nflag; }
  5491. +:    #endif
  5492. +:    #else
  5493. +:        print if $printit;
  5494. +:    #endif
  5495. +:    #else
  5496. +:        print;
  5497. +:    #endif
  5498. +:    #ifdef TSEEN
  5499. +:        $tflag = 0;
  5500. +:    #endif
  5501. +:    #ifdef APPENDSEEN
  5502. +:        if ($atext) { chop $atext; print $atext; $atext = ''; }
  5503. +:    #endif
  5504. +EOT
  5505. +
  5506. +print BODY &q(<<'EOT');
  5507. +:    }
  5508. +EOT
  5509. +}
  5510. +
  5511. +close BODY;
  5512. +
  5513. +unless ($debug) {
  5514. +    open(HEAD,">/tmp/sperl2$$.c")
  5515. +      || &Die("Can't open temp file 2: $!\n");
  5516. +    print HEAD "#define PRINTIT\n"    if $printit;
  5517. +    print HEAD "#define APPENDSEEN\n"    if $appendseen;
  5518. +    print HEAD "#define TSEEN\n"    if $tseen;
  5519. +    print HEAD "#define DSEEN\n"    if $dseen;
  5520. +    print HEAD "#define ASSUMEN\n"    if $assumen;
  5521. +    print HEAD "#define ASSUMEP\n"    if $assumep;
  5522. +    print HEAD "#define TOPLABEL\n"    if $toplabel;
  5523. +    print HEAD "#define SAWNEXT\n"    if $sawnext;
  5524. +    if ($opens) {print HEAD "$opens\n";}
  5525. +    open(BODY,"/tmp/sperl$$")
  5526. +      || &Die("Can't reopen temp file: $!\n");
  5527. +    while (<BODY>) {
  5528. +    print HEAD $_;
  5529. +    }
  5530. +    close HEAD;
  5531. +
  5532. +    print &q(<<"EOT");
  5533. +:    #!$bin/perl
  5534. +:    eval 'exec $bin/perl -S \$0 \${1+"\$@"}'
  5535. +:        if \$running_under_some_shell;
  5536. +:    
  5537. +EOT
  5538. +    open(BODY,"cc -E /tmp/sperl2$$.c |") ||
  5539. +    &Die("Can't reopen temp file: $!\n");
  5540. +    while (<BODY>) {
  5541. +    /^# [0-9]/ && next;
  5542. +    /^[ \t]*$/ && next;
  5543. +    s/^<><>//;
  5544. +    print;
  5545. +    }
  5546. +}
  5547. +
  5548. +&Cleanup;
  5549. +exit;
  5550. +
  5551. +sub Cleanup {
  5552. +    chdir "/tmp";
  5553. +    unlink "sperl$$", "sperl2$$", "sperl2$$.c";
  5554. +}
  5555. +sub Die {
  5556. +    &Cleanup;
  5557. +    die $_[0];
  5558. +}
  5559. +sub tab {
  5560. +    "\t" x ($indent / 8) . ' ' x ($indent % 8);
  5561. +}
  5562. +sub make_filehandle {
  5563. +    local($_) = $_[0];
  5564. +    local($fname) = $_;
  5565. +    if (!$seen{$fname}) {
  5566. +    $_ = "FH_" . $_ if /^\d/;
  5567. +    s/[^a-zA-Z0-9]/_/g;
  5568. +    s/^_*//;
  5569. +    $_ = "\U$_";
  5570. +    if ($fhseen{$_}) {
  5571. +        for ($tmp = "a"; $fhseen{"$_$tmp"}; $a++) {}
  5572. +        $_ .= $tmp;
  5573. +    }
  5574. +    $fhseen{$_} = 1;
  5575. +    $opens .= &q(<<"EOT");
  5576. +:    open($_, '>$fname') || die "Can't create $fname: \$!";
  5577. +EOT
  5578. +    $seen{$fname} = $_;
  5579. +    }
  5580. +    $seen{$fname};
  5581. +}
  5582. +
  5583. +sub make_label {
  5584. +    local($label) = @_;
  5585. +    $label =~ s/[^a-zA-Z0-9]/_/g;
  5586. +    if ($label =~ /^[0-9_]/) { $label = 'L' . $label; }
  5587. +    $label = substr($label,0,8);
  5588. +
  5589. +    # Could be a reserved word, so capitalize it.
  5590. +    substr($label,0,1) =~ y/a-z/A-Z/
  5591. +      if $label =~ /^[a-z]/;
  5592. +
  5593. +    $label;
  5594. +}
  5595. +
  5596. +sub transmogrify {
  5597. +    {    # case
  5598. +    if (/^d/) {
  5599. +        $dseen++;
  5600. +        chop($_ = &q(<<'EOT'));
  5601. +:    <<--#ifdef PRINTIT
  5602. +:    $printit = 0;
  5603. +:    <<--#endif
  5604. +:    next LINE;
  5605. +EOT
  5606. +        $sawnext++;
  5607. +        next;
  5608. +    }
  5609. +
  5610. +    if (/^n/) {
  5611. +        chop($_ = &q(<<'EOT'));
  5612. +:    <<--#ifdef PRINTIT
  5613. +:    <<--#ifdef DSEEN
  5614. +:    <<--#ifdef ASSUMEP
  5615. +:    print if $printit++;
  5616. +:    <<--#else
  5617. +:    if ($printit)
  5618. +:        { print; }
  5619. +:    else
  5620. +:        { $printit++ unless $nflag; }
  5621. +:    <<--#endif
  5622. +:    <<--#else
  5623. +:    print if $printit;
  5624. +:    <<--#endif
  5625. +:    <<--#else
  5626. +:    print;
  5627. +:    <<--#endif
  5628. +:    <<--#ifdef APPENDSEEN
  5629. +:    if ($atext) {chop $atext; print $atext; $atext = '';}
  5630. +:    <<--#endif
  5631. +:    $_ = <>;
  5632. +:    chop;
  5633. +:    <<--#ifdef TSEEN
  5634. +:    $tflag = 0;
  5635. +:    <<--#endif
  5636. +EOT
  5637. +        next;
  5638. +    }
  5639. +
  5640. +    if (/^a/) {
  5641. +        $appendseen++;
  5642. +        $command = $space . "\$atext .= <<'End_Of_Text';\n<<--";
  5643. +        $lastline = 0;
  5644. +        while (<>) {
  5645. +        s/^[ \t]*//;
  5646. +        s/^[\\]//;
  5647. +        unless (s|\\$||) { $lastline = 1;}
  5648. +        s/^([ \t]*\n)/<><>$1/;
  5649. +        $command .= $_;
  5650. +        $command .= '<<--';
  5651. +        last if $lastline;
  5652. +        }
  5653. +        $_ = $command . "End_Of_Text";
  5654. +        last;
  5655. +    }
  5656. +
  5657. +    if (/^[ic]/) {
  5658. +        if (/^c/) { $change = 1; }
  5659. +        $addr1 = 1 if $addr1 eq '';
  5660. +        $addr1 = '$iter = (' . $addr1 . ')';
  5661. +        $command = $space .
  5662. +          "    if (\$iter == 1) { print <<'End_Of_Text'; }\n<<--";
  5663. +        $lastline = 0;
  5664. +        while (<>) {
  5665. +        s/^[ \t]*//;
  5666. +        s/^[\\]//;
  5667. +        unless (s/\\$//) { $lastline = 1;}
  5668. +        s/'/\\'/g;
  5669. +        s/^([ \t]*\n)/<><>$1/;
  5670. +        $command .= $_;
  5671. +        $command .= '<<--';
  5672. +        last if $lastline;
  5673. +        }
  5674. +        $_ = $command . "End_Of_Text";
  5675. +        if ($change) {
  5676. +        $dseen++;
  5677. +        $change = "$_\n";
  5678. +        chop($_ = &q(<<"EOT"));
  5679. +:    <<--#ifdef PRINTIT
  5680. +:    $space\$printit = 0;
  5681. +:    <<--#endif
  5682. +:    ${space}next LINE;
  5683. +EOT
  5684. +        $sawnext++;
  5685. +        }
  5686. +        last;
  5687. +    }
  5688. +
  5689. +    if (/^s/) {
  5690. +        $delim = substr($_,1,1);
  5691. +        $len = length($_);
  5692. +        $repl = $end = 0;
  5693. +        $inbracket = 0;
  5694. +        for ($i = 2; $i < $len; $i++) {
  5695. +        $c = substr($_,$i,1);
  5696. +        if ($c eq $delim) {
  5697. +            if ($inbracket) {
  5698. +            substr($_, $i, 0) = '\\';
  5699. +            $i++;
  5700. +            $len++;
  5701. +            }
  5702. +            else {
  5703. +            if ($repl) {
  5704. +                $end = $i;
  5705. +                last;
  5706. +            } else {
  5707. +                $repl = $i;
  5708. +            }
  5709. +            }
  5710. +        }
  5711. +        elsif ($c eq '\\') {
  5712. +            $i++;
  5713. +            if ($i >= $len) {
  5714. +            $_ .= 'n';
  5715. +            $_ .= <>;
  5716. +            $len = length($_);
  5717. +            $_ = substr($_,0,--$len);
  5718. +            }
  5719. +            elsif (substr($_,$i,1) =~ /^[n]$/) {
  5720. +            ;
  5721. +            }
  5722. +            elsif (!$repl &&
  5723. +              substr($_,$i,1) =~ /^[(){}\w]$/) {
  5724. +            $i--;
  5725. +            $len--;
  5726. +            substr($_, $i, 1) = '';
  5727. +            }
  5728. +            elsif (!$repl &&
  5729. +              substr($_,$i,1) =~ /^[<>]$/) {
  5730. +            substr($_,$i,1) = 'b';
  5731. +            }
  5732. +            elsif ($repl && substr($_,$i,1) =~ /^\d$/) {
  5733. +            substr($_,$i-1,1) = '$';
  5734. +            }
  5735. +        }
  5736. +        elsif ($c eq '&' && $repl) {
  5737. +            substr($_, $i, 0) = '$';
  5738. +            $i++;
  5739. +            $len++;
  5740. +        }
  5741. +        elsif ($c eq '$' && $repl) {
  5742. +            substr($_, $i, 0) = '\\';
  5743. +            $i++;
  5744. +            $len++;
  5745. +        }
  5746. +        elsif ($c eq '[' && !$repl) {
  5747. +            $i++ if substr($_,$i,1) eq '^';
  5748. +            $i++ if substr($_,$i,1) eq ']';
  5749. +            $inbracket = 1;
  5750. +        }
  5751. +        elsif ($c eq ']') {
  5752. +            $inbracket = 0;
  5753. +        }
  5754. +        elsif ($c eq "\t") {
  5755. +            substr($_, $i, 1) = '\\t';
  5756. +            $i++;
  5757. +            $len++;
  5758. +        }
  5759. +        elsif (!$repl && index("()+",$c) >= 0) {
  5760. +            substr($_, $i, 0) = '\\';
  5761. +            $i++;
  5762. +            $len++;
  5763. +        }
  5764. +        }
  5765. +        &Die("Malformed substitution at line $.\n")
  5766. +          unless $end;
  5767. +        $pat = substr($_, 0, $repl + 1);
  5768. +        $repl = substr($_, $repl+1, $end-$repl-1);
  5769. +        $end = substr($_, $end + 1, 1000);
  5770. +        &simplify($pat);
  5771. +        $dol = '$';
  5772. +        $subst = "$pat$repl$delim";
  5773. +        $cmd = '';
  5774. +        while ($end) {
  5775. +        if ($end =~ s/^g//) {
  5776. +            $subst .= 'g';
  5777. +            next;
  5778. +        }
  5779. +        if ($end =~ s/^p//) {
  5780. +            $cmd .= ' && (print)';
  5781. +            next;
  5782. +        }
  5783. +        if ($end =~ s/^w[ \t]*//) {
  5784. +            $fh = &make_filehandle($end);
  5785. +            $cmd .= " && (print $fh \$_)";
  5786. +            $end = '';
  5787. +            next;
  5788. +        }
  5789. +        &Die("Unrecognized substitution command".
  5790. +          "($end) at line $.\n");
  5791. +        }
  5792. +        chop ($_ = &q(<<"EOT"));
  5793. +:    <<--#ifdef TSEEN
  5794. +:    $subst && \$tflag++$cmd;
  5795. +:    <<--#else
  5796. +:    $subst$cmd;
  5797. +:    <<--#endif
  5798. +EOT
  5799. +        next;
  5800. +    }
  5801. +
  5802. +    if (/^p/) {
  5803. +        $_ = 'print;';
  5804. +        next;
  5805. +    }
  5806. +
  5807. +    if (/^w/) {
  5808. +        s/^w[ \t]*//;
  5809. +        $fh = &make_filehandle($_);
  5810. +        $_ = "print $fh \$_;";
  5811. +        next;
  5812. +    }
  5813. +
  5814. +    if (/^r/) {
  5815. +        $appendseen++;
  5816. +        s/^r[ \t]*//;
  5817. +        $file = $_;
  5818. +        $_ = "\$atext .= `cat $file 2>/dev/null`;";
  5819. +        next;
  5820. +    }
  5821. +
  5822. +    if (/^P/) {
  5823. +        $_ = 'print $1 if /^(.*)/;';
  5824. +        next;
  5825. +    }
  5826. +
  5827. +    if (/^D/) {
  5828. +        chop($_ = &q(<<'EOT'));
  5829. +:    s/^.*\n?//;
  5830. +:    redo LINE if $_;
  5831. +:    next LINE;
  5832. +EOT
  5833. +        $sawnext++;
  5834. +        next;
  5835. +    }
  5836. +
  5837. +    if (/^N/) {
  5838. +        chop($_ = &q(<<'EOT'));
  5839. +:    $_ .= "\n";
  5840. +:    $len1 = length;
  5841. +:    $_ .= <>;
  5842. +:    chop if $len1 < length;
  5843. +:    <<--#ifdef TSEEN
  5844. +:    $tflag = 0;
  5845. +:    <<--#endif
  5846. +EOT
  5847. +        next;
  5848. +    }
  5849. +
  5850. +    if (/^h/) {
  5851. +        $_ = '$hold = $_;';
  5852. +        next;
  5853. +    }
  5854. +
  5855. +    if (/^H/) {
  5856. +        $_ = '$hold .= "\n"; $hold .= $_;';
  5857. +        next;
  5858. +    }
  5859. +
  5860. +    if (/^g/) {
  5861. +        $_ = '$_ = $hold;';
  5862. +        next;
  5863. +    }
  5864. +
  5865. +    if (/^G/) {
  5866. +        $_ = '$_ .= "\n"; $_ .= $hold;';
  5867. +        next;
  5868. +    }
  5869. +
  5870. +    if (/^x/) {
  5871. +        $_ = '($_, $hold) = ($hold, $_);';
  5872. +        next;
  5873. +    }
  5874. +
  5875. +    if (/^b$/) {
  5876. +        $_ = 'next LINE;';
  5877. +        $sawnext++;
  5878. +        next;
  5879. +    }
  5880. +
  5881. +    if (/^b/) {
  5882. +        s/^b[ \t]*//;
  5883. +        $lab = &make_label($_);
  5884. +        if ($lab eq $toplabel) {
  5885. +        $_ = 'redo LINE;';
  5886. +        } else {
  5887. +        $_ = "goto $lab;";
  5888. +        }
  5889. +        next;
  5890. +    }
  5891. +
  5892. +    if (/^t$/) {
  5893. +        $_ = 'next LINE if $tflag;';
  5894. +        $sawnext++;
  5895. +        $tseen++;
  5896. +        next;
  5897. +    }
  5898. +
  5899. +    if (/^t/) {
  5900. +        s/^t[ \t]*//;
  5901. +        $lab = &make_label($_);
  5902. +        $_ = q/if ($tflag) {$tflag = 0; /;
  5903. +        if ($lab eq $toplabel) {
  5904. +        $_ .= 'redo LINE;}';
  5905. +        } else {
  5906. +        $_ .= "goto $lab;}";
  5907. +        }
  5908. +        $tseen++;
  5909. +        next;
  5910. +    }
  5911. +
  5912. +    if (/^y/) {
  5913. +        s/abcdefghijklmnopqrstuvwxyz/a-z/g;
  5914. +        s/ABCDEFGHIJKLMNOPQRSTUVWXYZ/A-Z/g;
  5915. +        s/abcdef/a-f/g;
  5916. +        s/ABCDEF/A-F/g;
  5917. +        s/0123456789/0-9/g;
  5918. +        s/01234567/0-7/g;
  5919. +        $_ .= ';';
  5920. +    }
  5921. +
  5922. +    if (/^=/) {
  5923. +        $_ = 'print $.;';
  5924. +        next;
  5925. +    }
  5926. +
  5927. +    if (/^q/) {
  5928. +        chop($_ = &q(<<'EOT'));
  5929. +:    close(ARGV);
  5930. +:    @ARGV = ();
  5931. +:    next LINE;
  5932. +EOT
  5933. +        $sawnext++;
  5934. +        next;
  5935. +    }
  5936. +    } continue {
  5937. +    if ($space) {
  5938. +        s/^/$space/;
  5939. +        s/(\n)(.)/$1$space$2/g;
  5940. +    }
  5941. +    last;
  5942. +    }
  5943. +    $_;
  5944. +}
  5945. +
  5946. +sub fetchpat {
  5947. +    local($outer) = @_;
  5948. +    local($addr) = $outer;
  5949. +    local($inbracket);
  5950. +    local($prefix,$delim,$ch);
  5951. +
  5952. +    # Process pattern one potential delimiter at a time.
  5953. +
  5954. +    DELIM: while (s#^([^\]+(|)[\\/]*)([]+(|)[\\/])##) {
  5955. +    $prefix = $1;
  5956. +    $delim = $2;
  5957. +    if ($delim eq '\\') {
  5958. +        s/(.)//;
  5959. +        $ch = $1;
  5960. +        $delim = '' if $ch =~ /^[(){}A-Za-mo-z]$/;
  5961. +        $ch = 'b' if $ch =~ /^[<>]$/;
  5962. +        $delim .= $ch;
  5963. +    }
  5964. +    elsif ($delim eq '[') {
  5965. +        $inbracket = 1;
  5966. +        s/^\^// && ($delim .= '^');
  5967. +        s/^]// && ($delim .= ']');
  5968. +    }
  5969. +    elsif ($delim eq ']') {
  5970. +        $inbracket = 0;
  5971. +    }
  5972. +    elsif ($inbracket || $delim ne $outer) {
  5973. +        $delim = '\\' . $delim;
  5974. +    }
  5975. +    $addr .= $prefix;
  5976. +    $addr .= $delim;
  5977. +    if ($delim eq $outer && !$inbracket) {
  5978. +        last DELIM;
  5979. +    }
  5980. +    }
  5981. +    $addr =~ s/\t/\\t/g;
  5982. +    &simplify($addr);
  5983. +    $addr;
  5984. +}
  5985. +
  5986. +sub q {
  5987. +    local($string) = @_;
  5988. +    local($*) = 1;
  5989. +    $string =~ s/^:\t?//g;
  5990. +    $string;
  5991. +}
  5992. +
  5993. +sub simplify {
  5994. +    $_[0] =~ s/_a-za-z0-9/\\w/ig;
  5995. +    $_[0] =~ s/a-z_a-z0-9/\\w/ig;
  5996. +    $_[0] =~ s/a-za-z_0-9/\\w/ig;
  5997. +    $_[0] =~ s/a-za-z0-9_/\\w/ig;
  5998. +    $_[0] =~ s/_0-9a-za-z/\\w/ig;
  5999. +    $_[0] =~ s/0-9_a-za-z/\\w/ig;
  6000. +    $_[0] =~ s/0-9a-z_a-z/\\w/ig;
  6001. +    $_[0] =~ s/0-9a-za-z_/\\w/ig;
  6002. +    $_[0] =~ s/\[\\w\]/\\w/g;
  6003. +    $_[0] =~ s/\[^\\w\]/\\W/g;
  6004. +    $_[0] =~ s/\[0-9\]/\\d/g;
  6005. +    $_[0] =~ s/\[^0-9\]/\\D/g;
  6006. +    $_[0] =~ s/\\d\\d\*/\\d+/g;
  6007. +    $_[0] =~ s/\\D\\D\*/\\D+/g;
  6008. +    $_[0] =~ s/\\w\\w\*/\\w+/g;
  6009. +    $_[0] =~ s/\\t\\t\*/\\t+/g;
  6010. +    $_[0] =~ s/(\[.[^]]*\])\1\*/$1+/g;
  6011. +    $_[0] =~ s/([\w\s!@#%^&-=,:;'"])\1\*/$1+/g;
  6012. +}
  6013. +
  6014.