p2c.man
上传用户:upcnvip
上传日期:2007-01-06
资源大小:474k
文件大小:45k
源码类别:

编译器/解释器

开发平台:

C/C++

  1. ." p2c  Copyright 1989 Dave Gillespie
  2. .TH P2C 1 "local"
  3. .SH NAME
  4. p2c - Pascal to C translator, version 1.14
  5. .SH SYNOPSIS
  6. .B p2c
  7. [ options ] [ file [ module ] ]
  8. .SH DESCRIPTION
  9. .I P2c
  10. is a tool for translating Pascal programs into C.  The input consists
  11. of a set of source files in any of the following Pascal dialects:
  12. HP Pascal, Turbo/UCSD Pascal, DEC VAX Pascal, Oregon Software Pascal/2,
  13. Macintosh Programmer's Workshop Pascal, Sun/Berkeley Pascal.
  14. Modula-2 syntax is also supported.  Output is a set of
  15. .B .c
  16. and
  17. .B .h
  18. files that comprise an equivalent program in any of several dialects
  19. of C.  Output code may be kept machine- and dialect-independent, or
  20. it may be targeted to a specific machine and compiler.  Most reasonable
  21. Pascal programs are converted into fully functional C which will compile
  22. and run with no further modifications, although
  23. .I p2c
  24. sometimes chooses to generate readable code at the expense of absolute
  25. generality.  
  26. .I P2c
  27. endeavors to insert notes and warning messages into the output code
  28. to point out areas which may require human intervention.  Output code
  29. is arranged to be readable and efficient, and to make use of C idioms
  30. wherever possible.  The main goal of the translation is to produce C
  31. files which are pleasant and "natural" enough to be acceptable as the new
  32. source files for a program.  In a pinch,
  33. .I p2c
  34. will also serve as an ad hoc Pascal compiler.
  35. .PP
  36. Code generated by
  37. .I p2c
  38. normally does not assume characters are signed or unsigned.
  39. Also, it assumes
  40. .B int
  41. is the same as either
  42. .B short
  43. or
  44. .B long
  45. but does not depend on which.  However, if
  46. .B int
  47. is not the same as
  48. .BR long
  49. it is best to use a modern C compiler which supports prototypes.
  50. Generated code does not require an ANSI-compatible compiler
  51. (unless ANSI-style code is requested), but it does use various
  52. ANSI-standard library routines.
  53. .PP
  54. All generated code includes the file
  55. .I <p2c/p2c.h>
  56. which in turn includes
  57. .I <stdio.h>
  58. and various other common resources.  Also, many translated programs
  59. will need to be linked with the run-time library, typically
  60. .I -lp2c.
  61. .PP
  62. Given a file name,
  63. .I p2c
  64. reads from the specified file and outputs to a file with a
  65. .B .c
  66. suffix added or substituted.  For example,
  67. .IP "" 5
  68. p2c myfile.pas
  69. .PP
  70. reads from
  71. .I myfile.pas
  72. to produce the file
  73. .I myfile.c.
  74. The input file may contain a Pascal main program or a
  75. single Pascal module (or "unit" in Turbo and UCSD Pascal nomenclature),
  76. or it may just contain a number of procedures and declarations.
  77. .I P2c
  78. is designed to work for correct input programs.  That is, it will accept
  79. partial programs but may occasionally core dump if the input refers to
  80. undefined symbols.
  81. .PP
  82. If the input is a module, the translator will also produce a file
  83. .IB module .h
  84. containing a translation of the module's interface section.
  85. The implementation section may be omitted in which case only the
  86. .B .h
  87. file will be interesting.  If the program or module has include files,
  88. these may cause additional
  89. .B .c
  90. files to be generated depending on the value of the
  91. .B ExpandIncludes
  92. option (see below).
  93. .PP
  94. If no file name is given,
  95. .I p2c
  96. reads Pascal from the standard input and writes the resulting C to
  97. standard output (though a
  98. .B .h
  99. file may still be produced).  If a file name and module name are given,
  100. the file may include several modules (or units).  The specified module
  101. is translated; any others are skipped.  The output files will be named
  102. .IB module .c
  103. and
  104. .IB module .h .
  105. .I P2c
  106. never translates more than one module per run.
  107. .PP
  108. Before starting,
  109. .I p2c
  110. reads the file
  111. .I --HOMEDIR--/p2crc
  112. for a number of configuration parameters.  (The actual path used on your
  113. system may vary.  The
  114. .B -i
  115. option is a handy way to examine this file.)
  116. If the P2CRC environment variable is set, it gives the name of a file
  117. to read instead of the system file; this file can start with
  118. .B Include %H/p2crc
  119. to include the system file.  Next,
  120. .I p2c
  121. attempts to read the file
  122. .I p2crc
  123. in your directory for further configuration.  If this file does not
  124. exist,
  125. .I p2c
  126. looks for
  127. .I .p2crc
  128. instead.
  129. .SH OPTIONS
  130. .TP
  131. .BI -o " cfile"
  132. Use
  133. .I cfile
  134. in place of
  135. .IB file .c
  136. or
  137. .IB module .c
  138. as the primary output file.  A single dash (`-o -') says to write the
  139. C code to the standard output.
  140. .TP
  141. .BI -h " hfile"
  142. Use
  143. .I hfile
  144. in place of
  145. .IB module .h
  146. as the output file for interface text.  This only has effect if the
  147. input is an HP Pascal module or a Turbo Pascal unit.
  148. .TP
  149. .BI -s " sfile"
  150. Read interface text from
  151. .I sfile
  152. before beginning the translation.  This file typically contains one or
  153. more modules, often with interface sections omitted for speed, which the
  154. program or module being translated will use.  (Typically the
  155. .B ImportFrom
  156. and
  157. .B ImportDir
  158. parameters in
  159. .I p2crc
  160. are set up to allow
  161. .I p2c
  162. to locate interface text without needing any
  163. .B -s
  164. options.)  If there are several
  165. .B -s
  166. options in the command, the
  167. .I sfiles
  168. are read from left to right.
  169. .TP
  170. .BI -p n
  171. Display progress of translation in the form of a line number/file name
  172. display.  This is refreshed every
  173. .I n
  174. lines, 25 by default.
  175. .TP
  176. .BI -c " rcfile"
  177. Read local configuration commands from
  178. .I rcfile
  179. instead of
  180. .I p2crc
  181. or
  182. .I .p2crc.
  183. A dash (`-c -') in place of
  184. .I rcfile
  185. causes no local configuration file to be used.
  186. .TP
  187. .B -v
  188. ("Vanilla.")  Do not read from the system configuration file
  189. .I --HOMEDIR--/p2crc.
  190. Since some of the parameters in this file are required, your local
  191. configuration file must include those parameters instead.  This
  192. also suppresses the file named by the P2CRC environment variable.
  193. .TP
  194. .BI -H " homedir"
  195. Use
  196. .I homedir
  197. instead of
  198. .I --HOMEDIR--
  199. as the
  200. .I p2c
  201. home directory.  The system
  202. .I p2crc
  203. file will be searched for in this directory. 
  204. .TP
  205. .BI -I pattern
  206. Add
  207. .I pattern
  208. to the
  209. .B ImportDir
  210. search list of places to find modules which are imported.  The pattern
  211. should include a
  212. .I %s
  213. to represent the module name, and should evaluate to a potential file name
  214. for that module's source code.  For example,
  215. .B ../%s.pas
  216. looks for
  217. .IB modulename .pas
  218. in the parent of the current directory.
  219. .TP
  220. .B -i
  221. This special option (which must be the only argument on the
  222. command line if used) simply copies the system configuration
  223. file
  224. .I --HOMEDIR--/p2crc
  225. to the standard output in its entirety.  (It may be used with
  226. .BR -H ,
  227. but
  228. .B -i
  229. is most useful precisely when you don't know the
  230. location of the home directory.)
  231. .TP
  232. .B -q
  233. Quiet mode.  Suppresses output of status messages during translation.
  234. .TP
  235. .BI -E n
  236. Abort translation after
  237. .I n
  238. errors.  If
  239. .I n
  240. is omitted it defaults to zero, which means unlimited errors are allowed.
  241. Use
  242. .B -E1
  243. to make
  244. .I p2c
  245. halt after the first error.
  246. .TP
  247. .B -e
  248. Echo the Pascal source into the output file, surrounded by #ifdefs.
  249. This is the same as the
  250. .B CopySource
  251. parameter in the
  252. .I p2crc
  253. file.
  254. .TP
  255. .B -a
  256. Produce modern ANSI C.  This is a convenient override for the
  257. .B AnsiC
  258. parameter in the
  259. .I p2crc
  260. file.
  261. .TP
  262. .BI -L " language"
  263. Select input language name, such as VAX or TURBO.  This is a convenient
  264. override for the
  265. .B Language
  266. parameter.
  267. .TP
  268. .B -V
  269. Verbose mode.  This causes
  270. .I p2c
  271. to generate an additional ".log" file with further details of the
  272. translation, such as a list of warnings and notes including those
  273. which are suppressed in the regular output.
  274. .TP
  275. .B -M0
  276. Disable memory conservation.  This prevents
  277. .I p2c
  278. from freeing various data structures after translating each function,
  279. in case this new conservation feature causes unforseen problems.
  280. .TP
  281. .B -R
  282. Regression testing mode.  Formats notes and warning messages in a way
  283. that makes it easier to run
  284. .IR diff (1)
  285. on the output of
  286. .I p2c.
  287. .PP
  288. .I P2c
  289. also understands a few debugging options which may occasionally be
  290. useful when tracking down translation problems.  The
  291. .BI -d n
  292. option sets the "debug level" to
  293. .I n,
  294. a small integer which is normally zero.  Debugging output is
  295. written into the regular output file along with the C code; the
  296. higher your
  297. .I n,
  298. the more "wallpaper" you get.  Also,
  299. .B -t
  300. prints debugging information at every Pascal token,
  301. .BI -B n
  302. enables line-breaker debugging, and
  303. .BI -C n
  304. enables comment placement debugging.
  305. .SH CHOICE OF SOURCE LANGUAGE
  306. The
  307. .B Language
  308. configuration parameter or
  309. .B -L
  310. command-line option tells
  311. .I p2c
  312. which Pascal dialect to expect in the input file.  Any language features
  313. which do not overlap between dialects are supported all of the time.  The
  314. .B Language
  315. parameter is consulted when a syntax or usage is detected that has different
  316. meanings in two different dialects, and also to determine default values
  317. for various other translation parameters as described below.
  318. .PP
  319. The following language words are supported by
  320. .I p2c.
  321. Names are case-insensitive.
  322. .TP 8
  323. .B HP
  324. HP Pascal.  This is the default language.  All features of HP Standard
  325. Pascal, the Pascal Workstation version, are supported except as noted
  326. in BUGS below.  Some features of MODCAL, HP's extended Pascal, are also
  327. supported.  This is a superset of ISO standard Pascal, including
  328. conformant arrays and procedural parameters.
  329. .TP
  330. .B HP-UX
  331. HP Pascal, HP-UX version.  Almost identical to the "HP" dialect.
  332. .TP
  333. .B Turbo
  334. Turbo Pascal 5.0 for the IBM PC.  Few conflicts with HP Pascal, so the
  335. .B Language
  336. parameter is not often needed for Turbo.  (Most important is that the Turbo
  337. and HP dialects use 16 and 32 bit integers, respectively.)
  338. .TP
  339. .B UCSD
  340. UCSD Pascal.  Similar to Turbo in many ways.
  341. .TP
  342. .B MPW
  343. Macintosh Programmer's Workshop Pascal 2.0.  Should also do a pretty
  344. good job for Lightspeed Pascal.  Object Pascal features are not supported,
  345. nor is the fact that
  346. .B char
  347. variables are sometimes stored in 16 bits.
  348. .TP
  349. .B VAX
  350. VAX/VMS Pascal version 3.5.  Most but not all language features supported.
  351. This has not yet been tested on large programs.
  352. .TP
  353. .B Oregon
  354. Oregon Software Pascal/2.  All features implemented.
  355. .TP
  356. .B Berk
  357. Berkeley Pascal with Sun extensions.
  358. .TP
  359. .B Modula
  360. Modula-2.  Based on Wirth's
  361. .I Programming in Modula-2,
  362. 3rd edition.  Proper setting of the
  363. .B Language
  364. parameter is
  365. .I not
  366. optional.  Translation will be incomplete in most cases, but should be
  367. good enough to work with.  Structure of local sub-modules is essentially
  368. ignored; like-named identifiers may be confused.  Type WORD is translated
  369. as an integer, but type ADDRESS is translated as char * or void *; this
  370. may cause inconsistencies in the output code.
  371. .IP
  372. Modula-2 modules have two parts in separate files.  Suppose these are
  373. called
  374. .I foo.def
  375. (definition part) and
  376. .I foo.mod
  377. (implementation part) for module
  378. .I foo.
  379. Then a pattern like
  380. .B %s.def
  381. must be included in the
  382. .B ImportDir
  383. list, and
  384. .B LibraryFile
  385. must be changed to refer to
  386. .I system.m2
  387. instead of
  388. .I system.imp.
  389. To translate the definition part, give the command
  390. .IP
  391.      p2c foo.def
  392. .IP
  393. to translate the definition part into files
  394. .I foo.h
  395. and
  396. .IR foo.c ;
  397. the latter will usually be empty.  The command
  398. .IP
  399.      p2c -s foo.def foo.mod
  400. .IP
  401. will translate the implementation part into file
  402. .I foo.c.
  403. .PP
  404. Even if all language features are supported for a dialect, some
  405. predefined functions may be omitted.  In these cases, the function call
  406. will be translated literally into C with a warning.  Some hand modification
  407. may be required.
  408. .SH CONFIGURATION PARAMETERS
  409. .I P2c
  410. is highly configurable.  The defaults are suitable for most applications,
  411. but customizing these parameters will help you get the best possible
  412. translation.  Since the output of
  413. .I p2c
  414. is intended to be used as human-maintainable source code, there are many
  415. parameters for describing the coding style and conventions you prefer.
  416. Others give hints about your program that help
  417. .I p2c
  418. to generate more correct, efficient, or readable code.
  419. .PP
  420. The
  421. .I p2crc
  422. files contain a list of parameters, one per line.  The system
  423. configuration file, which may be viewed using the
  424. .B -i
  425. option to
  426. .I p2c,
  427. serves as an example of the proper format.  Parameter names are
  428. case-insensitive.  If a parameter name occurs exactly once in the system
  429. .I p2crc,
  430. this indicates that it must have a unique value and the last value given to
  431. it by the
  432. configuration files is used.  Other parameters are written several times
  433. in a row; these are lists to which each configuration line adds an entry.
  434. .PP
  435. Many
  436. .I p2crc
  437. options take a numeric value of 0 or 1, roughly corresponding to
  438. "no" or "yes."  Sometimes a blank value or the value "fBdeffR"
  439. corresponds to an intermediate "maybe" state.  For example, the stylistic
  440. option
  441. .B ExtraParens
  442. switches between copious or minimal parentheses in expressions, with
  443. the default being a nice compromise intended to be best for readers
  444. with an average knowledge of C operator precedences.
  445. .PP
  446. Configuration options may also be embedded in the source file in the
  447. form of Pascal comments:
  448. .PP
  449.      {ShortOpt=0} {AvoidName=fred}
  450. .br
  451.      {FuncMacro slope(x,y)=atan2(y,x)*RadDeg}
  452. .PP
  453. disables automatic short-circuiting of
  454. .B and
  455. and
  456. .B or
  457. expressions, adds "fIfredfR" to the list of names to avoid using in
  458. generated C code, and defines a special translation for the Pascal
  459. program's
  460. .I slope
  461. function 
  462. using the standard C
  463. .I atan2
  464. function and a constant
  465. .I RadDeg
  466. presumably defined in the program.  Whitespace is generally not allowed
  467. in embedded parameters.
  468. The `=' sign is required for embedded parameters, though it is optional in
  469. .I p2crc
  470. files.  Comments within embedded parameters are delimited by `##'.
  471. Numeric parameters may replace `=' with `+' or `-' to increase
  472. or decrease the parameter; list-based parameters may use `-' to remove
  473. a name from a list rather than adding it.  Also, the parameter name
  474. by itself in comment braces means to restore the parameter's value
  475. that was current before the last change:
  476. .PP
  477.      {VarFiles=0  ## Pass FILE *'s params by value even if VAR}
  478. .br
  479. .I      some declarations
  480. .br
  481.      {VarFiles    ## Back to original FILE * passing}
  482. .PP
  483. causes the parameter
  484. .B VarFiles
  485. to have the value 0 for those few declarations, without affecting the
  486. parameter's value elsewhere in the file.
  487. .PP
  488. If an embedded parameter appears in an include file or in interface text
  489. for a module,
  490. the effect of the assignment normally carries over to any programs that
  491. included that file.  If the parameter name is preceded by a `*', then
  492. the assignment is automatically undone after the source file that contains
  493. it ends:
  494. .PP
  495.      {IncludeFrom strings=<p2c/strings.h>}
  496. .br
  497.      {*ExportSymbol=pascal_%s}
  498. .br
  499.      module strings;
  500. .PP
  501. will record the location of the
  502. .I strings
  503. module's include file for the rest of the translation, but the assignment
  504. of
  505. .B ExportSymbol
  506. pertains only to the module itself.
  507. .PP
  508. For the complete list of
  509. .I p2crc
  510. parameters, run
  511. .I p2c
  512. with the
  513. .B -i
  514. option.  Here are some additional comments on selected parameters:
  515. .TP 15
  516. .B ImportAll
  517. Because Turbo Pascal only allows one unit per source file,
  518. .I p2c
  519. normally stops reading past the word
  520. .I implementation
  521. in a file being scanned for interface text.  But HP Pascal allows several
  522. modules per file and so this would not be safe to do.  The
  523. .B ImportAll
  524. option lets you override the default behavior for your Pascal dialect.
  525. .TP
  526. .B AnsiC
  527. This parameter selects which dialect of C to use.  If 1, all conventions
  528. of ANSI C such as prototypes,
  529. .B void *
  530. pointers, etc. are used.  If 0, only strict K&R (first edition) C is used.
  531. The default is to use "traditional UNIX C," which includes
  532. .B enum
  533. and
  534. .B void
  535. but not
  536. .B void *
  537. or prototypes.  Once again there are a number of other parameters which
  538. may be used to control the individual features if just setting
  539. .B AnsiC
  540. is not enough.
  541. .TP
  542. .B C++
  543. At present
  544. .I p2c
  545. does not use much of C++ at all.  The default action is to generate code
  546. that will compile in either language.
  547. .TP
  548. .B UseVExtern
  549. Many non-UNIX linkers prohibit variables from being defined (not declared)
  550. by more than one source file.  One module must declare, e.g., "int foo;",
  551. and all others must declare "extern int foo;".
  552. .I P2c
  553. accomplishes this by declaring public variables "fBvexternfR"
  554. in header files, and arranging for the macro
  555. .B vextern
  556. to expand to
  557. .B extern
  558. or to nothing when appropriate.  If you set
  559. .BR UseVExtern =0
  560. .I p2c
  561. will instead declare variables in a simpler way that works only on
  562. UNIX-style linkers.
  563. .TP
  564. .B UseAnyptrMacros
  565. Certain C reserved words have meanings which may vary from one C
  566. implementation to another.
  567. .I P2c
  568. uses special capitalized names for these words; these names are
  569. defined as macros in the file
  570. .I p2c.h
  571. which all translated programs include.  You can set
  572. .BR UseAnyptrMacros =0
  573. to disable the use of these macros.  Note that the functions of many of
  574. these macros can also be had directly using other parameters; for example,
  575. .B UseConsts
  576. allows you to specify whether your target language recognizes the word
  577. .B const
  578. in constant declarations.  The default is to use the
  579. .B Const
  580. macro instead, so that your code will be portable to either kind of
  581. implementation.
  582. .IP
  583. .B Signed
  584. expands to the reserved word
  585. .B signed
  586. if that word is available, otherwise it is given a null definition.
  587. Similarly,
  588. .B Const
  589. expands to
  590. .B const
  591. if that feature is available.  The words
  592. .B Volatile
  593. and
  594. .B Register
  595. are also defined in
  596. .I p2c.h,
  597. although
  598. .I p2c
  599. does not use them at present.  The word
  600. .B Char
  601. expands to
  602. .B char
  603. by default, but might need to be redefined to
  604. .B signed char
  605. or
  606. .B unsigned char
  607. in a particular implementation.  This is used for the Pascal character
  608. type; lowercase
  609. .B char
  610. is used when the desired meaning is "byte," not "character."
  611. .IP
  612. The word
  613. .B Static
  614. always expands to
  615. .B static
  616. by default.  This is used in situations where a function or variable is
  617. declared static to make it local to the source file; lowercase
  618. .B static
  619. is used for static local variables.  Thus you can redefine
  620. .B Static
  621. to be null if you want to force private names to be public for purposes
  622. of debugging.
  623. .IP
  624. The word
  625. .B Void
  626. expands to
  627. .B void
  628. in all cases; it is used when declaring a function with no return value.
  629. The word
  630. .B Anyptr
  631. is a typedef for
  632. .B void *
  633. or
  634. .B char *
  635. as necessary; it represents a generic pointer.
  636. .TP
  637. .B UsePPMacros
  638. The
  639. .I p2c.h
  640. header also declares two macros for function prototyping,
  641. .BR PP (x)
  642. and
  643. .BR PV ().
  644. These macros are used as follows:
  645. .IP
  646.      Void foo  PP( (int x, int y, Char *z) );
  647. .br
  648.      Char *bar PV( );
  649. .IP
  650. If prototypes are available, these macros will expand to
  651. .IP
  652.      Void foo  (int x, int y, Char *z);
  653. .br
  654.      Char *bar (void);
  655. .IP
  656. but if only old-style declarations are supported, you instead get
  657. .IP
  658.      Void foo  ();
  659. .br
  660.      Char *bar ();
  661. .IP
  662. By default,
  663. .I p2c
  664. uses these macros for all function declarations, but function
  665. .I definitions
  666. are written in old-style C.  The
  667. .B UsePPMacros
  668. parameter can be set to 0 to disable all use of
  669. .B PP
  670. and
  671. .BR PV ,
  672. or it can be set to 1 to use the macros even when defining a function.
  673. (This is accomplished by preceding each old-style definition with a
  674. .BR PP -style
  675. declaration.)  If you know your code will always be
  676. compiled on systems that support prototyping, it is prettier to set
  677. .BR Prototypes =1
  678. or simply
  679. .BR AnsiC =1
  680. to get true function prototypes.
  681. .TP
  682. .B EatNotes
  683. Notes and warning messages containing any of these strings as sub-strings
  684. are not omitted.  Each type of message includes an identifier like
  685. .BR [145] ;
  686. you can add this identifier to the
  687. .B EatNotes
  688. list to suppress that message.  Another useful form is to use a variable
  689. name or other identifier to suppress warnings about that variable.  The
  690. strings are a space-separated list, and thus may not contain embedded spaces.
  691. To suppress notes around a section of code, use, e.g.,
  692. .I {EatNotes+[145]}
  693. and
  694. .I {EatNotes-[145]}.
  695. Most notes are generated during parsing, but to suppress those generated
  696. during output the string may need to remain in the list far beyond the point
  697. where it appears to be generated.  Use the string "1" or "0" to disable or
  698. enable all notes, respectively.
  699. .TP
  700. .B ExpandIncludes
  701. The default action is to expand Pascal include files in-line.  This
  702. may not be desirable if include files are being used to simulate modules.
  703. With
  704. .BR ExpandIncludes =0,
  705. .I p2c
  706. attempts to convert include files containing only whole procedures and
  707. global declarations into analogous C include files.  This may not always
  708. work, though; if you get error messages, don't use this option.  By
  709. combining this option with
  710. .BR StaticFunctions =0,
  711. then doing some fairly minor editing on the result, you can convert
  712. a pseudo-modular Pascal program into a truly modular collection of C
  713. source files.
  714. .TP
  715. .B ElimDeadCode
  716. Some transformations that
  717. .I p2c
  718. does on the program may result in unreachable or "dead" code.  By
  719. default
  720. .I p2c
  721. removes such code, but sometimes it removes more than it should.
  722. If you have "if false" segments which you wish to retain in C, you
  723. may have to set
  724. .BR ElimDeadCode =0.
  725. .TP
  726. .B SkipIndices
  727. Normally Pascal arrays not based at zero are "shifted" down for C,
  728. preserving the total size of the array.  A Pascal array a[2..10] is
  729. translated to a C array a[9] with references like "a[i]" changed to
  730. "a[i-2]" everywhere.  If
  731. .B SkipIndices
  732. is set to a value of 2 or higher, this array would instead be translated
  733. to a[11] with the first two elements never used.  This arrangement may
  734. generate incorrect code, though, for tricky source programs.
  735. .TP
  736. .B FoldConstants
  737. Pascal non-structured constants generally translate to
  738. .BR #define 's
  739. in C.  Set this to 1 to have constants instantiated directly into the
  740. code.  This may be turned on or off around specific constant declarations.
  741. Set this to 0 to force
  742. .I p2c
  743. to make absolutely no assumptions about the constant's value in generated
  744. code, so that you can change the constant later in the C code without
  745. invalidating the translation.  The default is to allow
  746. .I p2c
  747. to take advantage of its knowledge of a constant's value, such as by
  748. generating code that assumes the constant is positive.
  749. .TP
  750. .B VarStrings
  751. In HP Pascal, a parameter of the form "var s : string" will match a
  752. string variable of any size; a hidden size parameter is passed which
  753. may be accessed by the Pascal
  754. .I strmax
  755. function.  You can prevent
  756. .I p2c
  757. from creating a hidden size parameter by setting
  758. .BR VarString =0.
  759. (Note that each function uses the value of
  760. .B VarStrings
  761. as of the
  762. .I first
  763. declaration of the function that is parsed, which is often in the interface
  764. section of a module.)
  765. .TP
  766. .B Prototypes
  767. Control whether ANSI C function prototypes are used.  Default is according to
  768. .BR AnsiC .
  769. This also controls whether to include parameter names or just their types
  770. in situations where names are optional.  The
  771. .B FullPrototyping
  772. parameter allows prototypes to be generated for declarations but not
  773. for definitions (older versions of Lightspeed C required this).  If you
  774. use a mixture of prototypes and old-style definitions, types like short
  775. and float will be promoted to int and double as required by the ANSI
  776. standard, unless
  777. .B PromoteArgs
  778. is used to override this.  The
  779. .B CastArgs
  780. parameter controls whether type-casts are used in function arguments;
  781. by default they are used only if prototypes are not available.
  782. .TP
  783. .B StaticLinks
  784. HP Pascal and Turbo Pascal each include the concept of procedure or
  785. function pointers, though with somewhat different syntaxes.
  786. .I P2c
  787. recognizes both notational styles.  Another difference is that HP's
  788. procedure pointers can point to nested procedures, while Turbo's can
  789. point only to global procedures.  In HP Pascal a procedure pointer must
  790. be stored as a
  791. .B struct
  792. containing both a pure C function pointer and a "static link," a pointer
  793. to the parent procedure's locals.  (The static link is NULL for global
  794. procedures.)  This notation can be forced by setting
  795. .BR StaticLinks =1.
  796. In Turbo, the default
  797. .RB ( StaticLinks =0)
  798. is to use plain C function pointers with no static links.  A third option
  799. .RB ( StaticLinks =2)
  800. uses structures with static links, but assumes the links are always NULL
  801. when calling through a pointer (if you need compatibility with the HP
  802. format but know your procedures are global).
  803. .TP
  804. .B SmallSetConst
  805. Pascal sets are translated into one of two formats, depending on the size
  806. of the set.  If all elements have ordinal values in the range 0..31, the
  807. set is translated as a single integer variable using bit operations.
  808. (The
  809. .B SetBits
  810. parameter may be used to change the upper limit of 31.)
  811. The
  812. .B SmallSetConst
  813. parameter controls whether these small-sets are used, and, if so, how
  814. constant sets should be represented in C.
  815. .IR
  816. For larger sets, an array of
  817. .B long
  818. is used.  The
  819. .IR s [0]
  820. element contains the number of succeeding array elements
  821. which are in use.  Set elements in the range 0..31 are stored in the
  822. .IR s [1]
  823. array element, and so on.  Sets are normalized so that
  824. .IR s [ s [0]]
  825. is nonzero for any nonempty set.  The standard run-time library
  826. includes all the necessary procedures for operating on sets.
  827. .TP
  828. .B ReturnValueName
  829. This is one of many "naming conventions" parameters.  Most of these
  830. take the form of a
  831. .IR printf -like
  832. string containing a
  833. .I %s
  834. where the relevant information should go.  In the case of
  835. .BR ReturnValueName ,
  836. the
  837. .I %s
  838. refers to a function name and the resulting string gives the name of
  839. the variable to use to hold the function's return value.  Such a variable
  840. will be made if a function contains assignments to its return value
  841. buried within the body, so that
  842. .I return
  843. statements cannot conveniently be used.  Some parameters
  844. .RB ( ReturnValueName
  845. included) do not require the
  846. .I %s
  847. to be present in the format string; for example, the standard
  848. .I p2crc
  849. file stores every function's return value in a variable called
  850. .I Result.
  851. .TP
  852. .B AlternateName
  853. .I P2c
  854. normally translates Pascal names into C names verbatim, but occasionally
  855. this is not possible.  A Pascal name may be a C reserved word or
  856. traditional C name like
  857. .I putc,
  858. or there may be several like-named things that are hidden from each other by
  859. Pascal's scoping rules but must be global in C.  In these situations
  860. .I p2c
  861. uses the parameter
  862. .B AlternateName1
  863. to generate an alternative name for the symbol.  The default is to add
  864. an underscore to the name.  There is also an
  865. .B AlternateName2
  866. parameter for a second alternate name, and an
  867. .B AlternateName
  868. parameter for the
  869. .IR n th
  870. alternate name.  (The value for this parameter should include both a
  871. .I %s
  872. and a
  873. .I %d,
  874. in either order.)  If these latter parameters are not defined,
  875. .I p2c
  876. applies
  877. .B AlternateName1
  878. many times over.
  879. .TP
  880. .B ExportSymbol
  881. Symbols in the interface section for a Pascal module are formatted
  882. according to the value of
  883. .BR ExportSymbol ,
  884. if any.  It is not uncommon to use
  885. .I modulename_%s
  886. for this symbol; the default is
  887. .I %s,
  888. i.e., no special treatment for exported symbols.  If you also define the
  889. .B Export_Symbol
  890. parameter, that format is used instead for exported symbols which
  891. contain an underscore character.  If
  892. .I %S
  893. (with a capital "S") appears in the format string it stands for the
  894. current module name.
  895. .TP
  896. .B Alias
  897. If the value of this parameter contains a
  898. .I %s,
  899. it is a format string applied to the names of external functions or
  900. variables.  If the value does not contain a
  901. .I %s,
  902. it becomes the name of the next external symbol which is declared (after
  903. which the parameter is cleared).
  904. .TP
  905. .B Synonym
  906. This creates a synonym for another Pascal symbol or keyword.  The format is
  907. .IP
  908. .B "     Synonym"
  909. .I old-name = new-name
  910. .IP
  911. All occurrences of 
  912. .I old-name
  913. in the input text are treated as if they were
  914. .I new-name
  915. by the parser.  If
  916. .I new-name
  917. is a keyword,
  918. .I old-name
  919. will be an equivalent keyword.  If
  920. .I new-name
  921. is the name of a predefined function,
  922. .I old-name
  923. will behave in the same way as that function, and so on.  If
  924. .I new-name
  925. is omitted, then occurrences of
  926. .I old-name
  927. are entirely ignored in the input file.  Synonyms allow you to skip over
  928. a keyword in your dialect of Pascal that is not understood by
  929. .I p2c,
  930. or to simulate a keyword or predefined identifier of your dialect with a
  931. similar one that
  932. .I p2c
  933. recognizes.  Note that all predefined functions are available at all times;
  934. if you have a library routine that behaves like, e.g., Turbo Pascal's
  935. .I getmem
  936. procedure, you can make your routine a synonym for
  937. .I getmem
  938. even if you are not translating in Turbo mode.
  939. .TP
  940. .B NameOf
  941. This defines the name to use in C for a specific symbol.  It must appear
  942. before the symbol is declared in the Pascal code; it is usually placed
  943. in the local
  944. .I p2crc
  945. file for the project.  The format is
  946. .IP
  947. .B "     NameOf"
  948. .I pascal-name = C-name
  949. .IP
  950. By default, Pascal names map directly onto C names with no change
  951. (except for the various kinds of formatting outlined above).  If the
  952. .I pascal-name
  953. is of the form
  954. .I module.name
  955. or
  956. .I procedure.name
  957. then the command applies only to the instance of the Pascal name that is
  958. global to that module, or local to that procedure.  Otherwise, it applies
  959. to all usages of the name.
  960. .TP
  961. .B VarMacro
  962. This is analogous to
  963. .BR NameOf ,
  964. but specifically for use with Pascal variables.  The righthand side can
  965. be most any C expression; all references to the variable are expanded
  966. into that C expression.  Names used in the C expression are taken
  967. verbatim.  There is also a
  968. .B ConstMacro
  969. parameter for translating constants as arbitrary expressions.
  970. Note that the variable on the lefthand side must actually be declared
  971. in the program or in a module that it uses.
  972. The declaration for the variable will be omitted from the generated code
  973. unless the Pascal-name appears in the expression:  If you ask to
  974. replace
  975. .I i
  976. with
  977. .I i+1,
  978. the variable
  979. .I i
  980. will still be declared but its value will be shifted accordingly.
  981. Note that if
  982. .I i
  983. appears on the lefthand side of an assignment,
  984. .I p2c
  985. will use algebra to "solve" for
  986. .I i.
  987. .IP
  988. In all cases where
  989. .I p2c
  990. parses C expressions, all C operators are recognized except compound
  991. assignments like `+='.  (Increment and decrement operators are allowed.)
  992. All variable and function names are assumed to have integer type, even
  993. if they are names that occur in the actual program.  A type-specification
  994. operator `::' has been introduced; it has the same precedence as `.' or `->'
  995. but the righthand side must be a Pascal type identifier (built-in or defined
  996. by your program previously to when the macro definition was parsed),
  997. or an arbitrary Pascal type expression in parentheses.
  998. The lefthand argument is then
  999. considered to have the specified type.  This may be necessary if your
  1000. macro is used in situations where the exact type of the expression
  1001. must be known (say, as the argument to a
  1002. .IR writeln ).
  1003. .TP
  1004. .B FieldMacro
  1005. Here the lefthand side must have the form
  1006. .I record.field,
  1007. where
  1008. .I record
  1009. is the Pascal type or variable name for a record, and
  1010. .I field
  1011. is a field in that record.  The righthand side must be a C expression
  1012. generally including the name
  1013. .I record.
  1014. All instances of that name are replaced by the actual record being "dotted."
  1015. For example,
  1016. .IP
  1017.      FieldMacro Rect.topLeft = topLeft(Rect)
  1018. .IP
  1019. translates
  1020. .I a[i].topLeft
  1021. into
  1022. .I topLeft(a[i]),
  1023. where
  1024. .I a
  1025. is an array of
  1026. .I Rect.
  1027. .TP
  1028. .B FuncMacro
  1029. The lefthand side must be any Pascal function or procedure name plus a
  1030. parameter list.  The number of parameters must match the number in the
  1031. function's uses and declaration.  Calls to the function are replaced by the
  1032. C expression on the righthand side.  For example,
  1033. .IP
  1034.      FuncMacro PtInRect(p,r) = PtInRect(p,&r)
  1035. .IP
  1036. causes the second argument of
  1037. .I PtInRect
  1038. to be passed by reference, even though the declaration says it's not.
  1039. If the function in question is actually defined in the program or module
  1040. being translated, the
  1041. .B FuncMacro
  1042. will not affect the definition but it will affect all calls to the function
  1043. elsewhere in the module.
  1044. .B FuncMacros
  1045. can also be applied to predefined or never-defined functions.
  1046. .TP
  1047. .B IncludeFrom
  1048. This specifies that a given module's header should be included from a
  1049. given place.  The second argument may be surrounded by " " or < > as
  1050. necessary; if the second argument is omitted, no include directive will
  1051. be generated for the module.
  1052. .TP
  1053. .B ImportFrom
  1054. This specifies that a given module's Pascal interface text can be found
  1055. in the given file.  The named file should be either the source file for
  1056. the module, or a specially prepared file with the implementation section
  1057. removed for speed.  If no
  1058. .B ImportFrom
  1059. entry is found for a module, the path defined by the
  1060. .B ImportDir
  1061. list is searched.  Each entry in the path may contain a
  1062. .I %s,
  1063. which expands to the name of the module.  The default path looks for
  1064. .I %s.pas
  1065. and
  1066. .I %s.text
  1067. in the current directory, then for
  1068. .I --HOMEDIR--/%s.imp.
  1069. (where --HOMEDIR-- is the
  1070. .I p2c
  1071. home directory.)
  1072. .TP
  1073. .B StructFunction
  1074. This parameter is a list of functions which follow the
  1075. .I p2c
  1076. semantics for structure-valued functions (functions returning arrays,
  1077. sets, and strings, and structs in primitive C dialects).  For these
  1078. functions, a pointer to a return-value area is passed to the function
  1079. as a special first parameter.  The function stores the result in this
  1080. area, then returns a copy of the pointer.  (The standard C function
  1081. .I strcpy
  1082. is an example of this concept.
  1083. .I Sprintf
  1084. also behaves this way in some dialects; it always appears on the
  1085. .B StructFunction
  1086. list regardless of the type of implementation.)  The system configuration
  1087. file includes a list of common structured functions so that
  1088. .IR p2c 's
  1089. optimizer will know how to manipulate them.
  1090. .TP
  1091. .B StrlapFunction
  1092. Functions on this list are structured functions as above, but with the
  1093. ability to work in-place; that is, the same pointer may be passed as both the
  1094. return value area and a regular parameter.
  1095. .TP
  1096. .B Deterministic
  1097. Functions on this list have no side effects or side dependencies.
  1098. An example is the
  1099. .I sin
  1100. function in the standard math library; two calls with the same parameter
  1101. values produce the same result, and have no effects other than returning
  1102. a value.
  1103. .I P2c
  1104. can make use of this knowledge when optimizing code for efficiency or
  1105. readability.  Functions on this list are also assumed to be relatively
  1106. fast, so that it is acceptable to duplicate a call to the function.
  1107. .TP
  1108. .B LeaveAlone
  1109. Functions on this list are not subjected to the normal built-in translation
  1110. rules that
  1111. .I p2c
  1112. would otherwise use.  For example, adding
  1113. .I writeln
  1114. to this list would translate
  1115. .I writeln
  1116. statements blindly into calls to a C
  1117. .I writeln()
  1118. function, rather than being translated into equivalent
  1119. .I printf
  1120. calls.  The built-in translation is also suppressed if the function has a
  1121. .BR FuncMacro .
  1122. .TP
  1123. .B BufferedFile
  1124. .I P2c
  1125. normally assumes binary files will use
  1126. .I read/write,
  1127. not
  1128. .I get/put/^
  1129. notation.
  1130. A file buffer variable will only be created for a file if buffer notation
  1131. is used for it.  For global file variables this may be detected too late
  1132. (a declaration without buffers may already have been written).  Such files
  1133. can be listed in
  1134. .B BufferedFile
  1135. to force
  1136. .I p2c
  1137. to allocate buffers for them; do this if you get a warning
  1138. message that says it is necessary.  Set
  1139. .BR BufferedFile =1
  1140. to buffer all files, in which case
  1141. .B UnBufferedFile
  1142. allows you to force certain files
  1143. .I not
  1144. to have buffers.
  1145. .TP
  1146. .B CheckFileEOF
  1147. Normally only file-open operations are checked for errors.  Additional
  1148. error checking, such as read-past-end-of-file, can be enabled with
  1149. parameters like
  1150. .BR CheckFileEOF .
  1151. These checks can make the code very ugly!  If I/O checking is enabled
  1152. by the program
  1153. .RB ( "$iocheck on$"
  1154. in HP Pascal;
  1155. .B {$I+}
  1156. in Turbo; this is always the default state),
  1157. these checks will generate fatal errors unless enclosed in an HP Pascal
  1158. .BR try - recover
  1159. construct.  If I/O checking is disabled, these will cause the global
  1160. variable
  1161. .I P_ioresult
  1162. to be set zero or nonzero according to the outcome.  The default for most
  1163. of these options is to check only when I/O checking is disabled.
  1164. .SH ISSUES
  1165. .B Integer size.
  1166. .I P2c
  1167. normally generates code to work with either 16 or 32 bit ints.
  1168. If you know your C integers will be 16 or 32 bits, set
  1169. .B IntSize
  1170. appropriately.  In particular setting
  1171. .BR IntSize =32
  1172. will generate much cleaner code:
  1173. .I p2c
  1174. no longer must carefully cast function arguments between int and long.
  1175. These casts also will be unnecessary if ANSI prototypes are available.
  1176. To disable int/long casting because you know at least one of these
  1177. cases will hold, set
  1178. .BR CastLongArgs =0.
  1179. (The
  1180. .B CastArgs
  1181. parameter similarly controls other types of casts, such as between ints
  1182. and doubles.)
  1183. The
  1184. .B Integer16
  1185. parameter controls whether Pascal integers are interpreted as 16 or 32
  1186. bits, or translated as native C integers.  The default value depends on the
  1187. .B Language
  1188. selected.
  1189. .PP
  1190. .B Signed/unsigned chars.
  1191. Pascal characters are normally "weakly" interpreted as unsigned; this
  1192. is controlled by
  1193. .BR UnsignedChar .
  1194. The default is "either," so that C's native
  1195. .B char
  1196. type may be used even if its signed-ness is unknown.  Code that uses
  1197. characters outside of the range 0-127 may need a different setting.
  1198. Alternatively, you can use the types
  1199. .B {SIGNED} char
  1200. and
  1201. .B {UNSIGNED} char
  1202. in the few cases where it really matters.  These comments are controlled
  1203. by the
  1204. .B SignedComment
  1205. and
  1206. .B UnsignedComment
  1207. parameters.  (The type
  1208. .B {UNSIGNED} integer
  1209. is also recognized.)  The
  1210. .B SignedChar
  1211. parameter tells whether C characters are signed or unsigned (default is
  1212. "unknown").  The
  1213. .B HasSignedChar
  1214. parameter tells whether the phrase "signed char" is legal in the output.
  1215. If it is not,
  1216. .I p2c
  1217. may have to translate Pascal signed bytes into C shorts.
  1218. .PP
  1219. .B Special types.
  1220. .I P2c
  1221. understands the following predefined Pascal type names:
  1222. .BR integer ,
  1223. signed integers depending on
  1224. .BR Integer16 ;
  1225. .BR longint ,
  1226. signed 32-bit integers;
  1227. .BR unsigned ,
  1228. unsigned 32-bit integers;
  1229. .BR sword ,
  1230. signed 16-bit integers;
  1231. .BR word ,
  1232. unsigned 16-bit integers;
  1233. .BR c_int ,
  1234. signed native C integers;
  1235. .BR c_uint ,
  1236. unsigned native C integers;
  1237. .BR sbyte ,
  1238. signed 8-bit integers;
  1239. .BR byte ,
  1240. unsigned 8-bit integers;
  1241. .BR real ,
  1242. floating-point numbers depending on
  1243. .BR DoubleReals ;
  1244. .BR single ,
  1245. single-precision floats;
  1246. .BR longreal ,
  1247. .BR double ,
  1248. and
  1249. .BR extended ,
  1250. double-precision floats;
  1251. .B pointer
  1252. and
  1253. .BR anyptr ,
  1254. generic pointers (assignment-compatible with any pointer type);
  1255. .BR string ,
  1256. generic string of length
  1257. .B StringDefault
  1258. (normally 255);
  1259. also, the usual Pascal types
  1260. .BR char ,
  1261. .BR boolean ,
  1262. and
  1263. .BR text .
  1264. (If your Pascal uses different names for these concepts, the
  1265. .B Synonym
  1266. option will come in handy.)
  1267. .PP
  1268. .B Embedded code.
  1269. It is possible to write a Pascal comment containing C code to
  1270. be embedded into the output.  See the descriptions of
  1271. .B EmbedComment
  1272. and its relatives in the system
  1273. .I p2crc
  1274. file.  These techniques are helpful if you plan to do repeated translations
  1275. of code that is still being maintained in Pascal.
  1276. .PP
  1277. .B Comments and blank lines.
  1278. .I P2c
  1279. collects the comments in a procedure into a list.  All comments and statements
  1280. are stamped with serial numbers which are used to reattach comments to
  1281. statements even after code has been added, removed, or rearranged during
  1282. translation.  "Orphan" comments attached to statements that have been lost
  1283. are attached to nearby statements or emitted at the end of the procedure.
  1284. Blank lines are treated as a kind of comment, so
  1285. .I p2c
  1286. will also reproduce your usage of blank lines.  If the comment mechanism
  1287. goes awry, you can disable comments with
  1288. .B EatComments
  1289. or disable their being attached to code with
  1290. .BR SpitComments .
  1291. .PP
  1292. .B Indentation.
  1293. .I P2c
  1294. has a number of parameters to govern indentation of code.  The default
  1295. values produce the GNU Emacs standard indentation style, although
  1296. .I p2c
  1297. can do a better job since it knows more about the code it is indenting.
  1298. Indentation works by applying "indentation deltas," which are either
  1299. absolute numbers (which override the previous indentation), or signed
  1300. relative numbers (which augment the previous indentation).  A delta of
  1301. "+0" specifies no change in indentation.  All of the indentation
  1302. options are described in the standard
  1303. .I p2crc
  1304. file.
  1305. .PP
  1306. .B Line breaking.
  1307. .I P2c
  1308. uses an algorithm similar to the TeX typesetter's paragraph formatter
  1309. for breaking long statements into multiple lines.  A "penalty" is assigned
  1310. to various undesirable aspects of all possible line breaks; the "badness"
  1311. of a set of line breaks is approximately the sum of all the penalties.
  1312. Chief among these are serious penalties for overrunning the desired maximum
  1313. line length (default 78 columns),
  1314. an infinite penalty for overrunning the absolute
  1315. maximum line length (default 90), and progressively greater penalties for
  1316. breaking at operators deeply nested in expressions.  Parameters such as
  1317. .B OpBreakPenalty
  1318. control the relative weights of various choices.
  1319. .B BreakArith
  1320. and its neighbors control whether the operator at a line break should be
  1321. placed at the end of the previous line or at the beginning of the next.
  1322. If you don't want any oversize lines, define
  1323. .BR MaxLineWidth =78.
  1324. .PP
  1325. Unlike TeX,
  1326. .IR p2c 's
  1327. line breaker must actually try all possible sets of break points.  To
  1328. avoid excessive computation, the total penalty contributed at each decision
  1329. point must sum to a nonnegative value; negative values are clipped up to zero.
  1330. This allows
  1331. .I p2c
  1332. to prune away obviously undesirable alternatives in advance.  The
  1333. .B MaxLineBreakTries
  1334. parameter (default 5000) controls how many alternatives to try before
  1335. giving up and using the best so far.
  1336. .PP
  1337. .B PASCAL_MAIN.
  1338. .I P2c
  1339. generates a call to this function at the front of the main program.
  1340. In the (unmodified) run-time library all this does is save argc and argv
  1341. away because in both HP and Turbo these are accessed as global variables.
  1342. If you do not wish to use this feature, define
  1343. .B ArgCName
  1344. to be
  1345. .I argc,
  1346. .B ArgVName
  1347. to be
  1348. .I argv,
  1349. and
  1350. .B MainName
  1351. (normally "PASCAL_MAIN") to be blank.  This will work if argc and argv
  1352. are never accessed outside of your main program.
  1353. .SH BUGS
  1354. .I P2c
  1355. was designed with the idea that clean, readable output in most cases is
  1356. worth more than guaranteed correct output in extreme cases.
  1357. .I P2c
  1358. is
  1359. .I not
  1360. a compiler!  However, ideally the "extreme" cases would include only those
  1361. which never arise in real life.  Thus if
  1362. .I p2c
  1363. actually generates incorrect code I will consider it a bug, but I will not
  1364. apologize for it. :-)  Below are the major remaining cases where this is
  1365. known to occur.
  1366. .PP
  1367. Certain kinds of conformant array parameters (including multi-dimensional
  1368. conformant arrays) produce code that declares variable-length arrays in C.
  1369. Only a few C compilers, such as the GNU C compiler, support this language
  1370. extension.  Otherwise some hand re-coding will be required.
  1371. .PP
  1372. HP Pascal
  1373. .BR try - recover
  1374. structures are translated into calls to
  1375. .I TRY
  1376. and
  1377. .I RECOVER
  1378. macros, which are defined to simulate the construct using
  1379. .I setjmp
  1380. and
  1381. .I longjmp.
  1382. If this emulation does not work, define the symbol
  1383. .B FAKE_TRY
  1384. to cause these macros to become "inert."  (In cases where the
  1385. error is detected by code physically within the body of the
  1386. .B try
  1387. statement, a C
  1388. .B goto
  1389. to the
  1390. .B recover
  1391. section is always generated.)  Also, local file variables in scopes which
  1392. are destroyed by an
  1393. .B escape
  1394. are not closed.
  1395. .PP
  1396. Non-local GOTO's and
  1397. .BR try - recover
  1398. statements are each implemented, but may
  1399. conflict if both are used at once.  Non-local GOTO's are fairly careful
  1400. about closing files that go out of scope but may fail to do so in the presence
  1401. of recursion.
  1402. .PP
  1403. Arrays containing files are not initialized to NULL as other files are.
  1404. In some cases, such as file variables allocated by NEW, the file is
  1405. initialized but not automatically closed by DISPOSE.
  1406. .PP
  1407. LINK variables allowing sub-procedures access to their parents' variables
  1408. are occasionally omitted by mistake, if the access is too indirect for
  1409. .I p2c
  1410. to notice.  If this happens, you can add an explicit reference to a parent
  1411. variable in the sub-procedure.  A statement of the form "a:=a" will count
  1412. as a reference but then be optimized away by
  1413. .I p2c.
  1414. .PP
  1415. Many aspects of Modula-2 are translated only superficially.  For example,
  1416. the type-compatibility properties of the
  1417. .I WORD
  1418. and
  1419. .I ARRAY OF WORD
  1420. types are only roughly modelled, as are the scope rules concerning modules.
  1421. .PP
  1422. Parts of VAX Pascal are still untreated.  In particular, the
  1423. .I [UNSAFE]
  1424. attribute and a few others are not fully supported,
  1425. nor are the semantics of the
  1426. .I OPEN
  1427. procedure.
  1428. .PP
  1429. Turbo and VAX Pascal's
  1430. .I double, quadruple,
  1431. and
  1432. .I extended
  1433. real types all translate to the C
  1434. .B double
  1435. type.  Turbo's
  1436. .I computational
  1437. type is not supported at all.
  1438. .PP
  1439. Because Pascal strings (with length bytes) are translated into C strings
  1440. (with null terminators), certain Pascal string tricks will not work in
  1441. the translated code.  For example the assignment
  1442. .I s[0]:=chr(x)
  1443. is translated to
  1444. .I s[x]=0
  1445. on the assumption that the string is being shortened.  If
  1446. .I x
  1447. is actually greater than the current length, but not of a recognizable
  1448. form like
  1449. .I ord(s[0])+n,
  1450. then the generated code will not work.  In VAX Pascal this corresponds
  1451. to performing arithmetic on the
  1452. .I LENGTH
  1453. field of a varying-length string.
  1454. .PP
  1455. Turbo Pascal's automatic clipping of strings is not supported.  In
  1456. Turbo, if a ten character string is assigned to a
  1457. .I string[8]
  1458. variable, the last two characters are silently removed.  The code
  1459. produced by
  1460. .I p2c
  1461. generally will overrun the target string instead!  The
  1462. .B StringTruncLimit
  1463. parameter (80 by default if
  1464. .BR Language = Turbo )
  1465. specifies a string size which should be considered "short"; assignments
  1466. of potentially-long strings to short string variables will cause a warning
  1467. but will not automatically truncate.  The cure is to use
  1468. .I copy
  1469. in the Pascal source to truncate the strings explicitly.
  1470. .SH FILES
  1471. .ta w'--INCDIR--/p2c.h 'u
  1472. file.fIxxxfR Pascal source files
  1473. .br
  1474. file.c resulting C source file
  1475. .br
  1476. module.h resulting C header file
  1477. .br
  1478. p2crc local configuration file
  1479. .br
  1480. &.p2crc alternate local configuration file
  1481. .br
  1482. --HOMEDIR--/p2crc system-wide configuration file
  1483. .br
  1484. --HOMEDIR--/system.imp declarations for predefined functions
  1485. .br
  1486. --HOMEDIR--/system.m2 analogous declarations for Modula-2
  1487. .br
  1488. --HOMEDIR--/*.imp interface text for standard modules
  1489. .br
  1490. --INCDIR--/p2c.h header file for translated programs
  1491. .br
  1492. --LIBDIR--/libp2c.a run-time library
  1493. .SH AUTHOR
  1494. Dave Gillespie, daveg@csvax.caltech.edu.
  1495. .PP
  1496. Many thanks to William Bader, Rick Koshi, Eric Raymond, Magne Haveraaen,
  1497. Dirk Grunwald, David Barto, Paul Fisher, and others whose suggestions and
  1498. bug reports have helped improve
  1499. .I p2c
  1500. in countless ways.