home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / INDENTP.ZIP / INDENT1 next >
Text File  |  1992-04-11  |  59KB  |  1,710 lines

  1. #    This is a shell archive.
  2. #    Remove everything above and including the cut line.
  3. #    Then run the rest of the file through sh.
  4. #----cut here-----cut here-----cut here-----cut here----#
  5. #!/bin/sh
  6. # shar:    Shell Archiver
  7. #    Run the following text with /bin/sh to create:
  8. #    readme
  9. #    indent.man
  10. #    indent.1
  11. #    indent.def
  12. #    Makefile.1x
  13. #    Makefile.20
  14. #    Makefile.bsd
  15. #    Makefile.cs2
  16. #    codes.h
  17. #    globals.h
  18. #    proto.h
  19. # This archive created: Sat Apr 11 15:09:56 1992
  20. echo shar: extracting readme
  21. sed 's/^X//' << \SHAR_EOF > readme
  22. X---------------------------------------------------------------------
  23. X
  24. XIndent is a C/C++ program formatter.  It reformats the C/C++ program
  25. Xin the input-file according to a long list of command line switches.
  26. X
  27. XThe original indent (part of the Berkeley Software Distribution) was
  28. Xonly for C programs.  It has since been modified to understand C++
  29. Xsyntax as well.
  30. X
  31. X---------------------------------------------------------------------
  32. X
  33. X            A quick guide to indent
  34. X        (for impatient users of OS/2 or MSDOS)
  35. X
  36. XAssuming you have managed to unpack the distribution sources and have
  37. Xcompiled indent.exe:-
  38. X
  39. X1. Set up an environment variable called HOME pointing at some directory
  40. X   where you keep useful things.  Copy indent.pro into that directory.
  41. X
  42. X2. If you use a brain-damaged editor which doesn't allow tabs to be set
  43. X   at any interval other than 8 columns, either change the line in
  44. X   indent.pro which says
  45. X    -tabs 4
  46. X   or simply remove it altogether.
  47. X
  48. X3. Copy indent.exe to some directory on your PATH.
  49. X
  50. X4. Change directory to where your messy C or C++ programs reside.
  51. X
  52. X5. To clean up all the programs issue the command:
  53. X    for %f in (*.c *.cpp) do indent %f
  54. X
  55. X---------------------------------------------------------------------
  56. X
  57. X             An even quicker guide to indent
  58. X        (for impatient users of BSD-flavoured UNIX)
  59. X
  60. XRead the guide for OS/2-MSDOS and make the following changes:
  61. X
  62. X1. Copy indent.pro into your home directory, calling it .indent.pro
  63. X
  64. X5. Use a loop syntax appropriate for your shell.
  65. X
  66. X---------------------------------------------------------------------
  67. X
  68. X                      OS/2 implementor's note
  69. X                      -----------------------
  70. X
  71. XThere seems to have been three streams of development for this program.
  72. X
  73. XThe original indent was ported to MSDOS by Bruce Mallett and various fixes
  74. Xwere done by Bruce Mallett and James Thompson.  James Thompson also imple-
  75. Xmented the handling of tabs at spacings other than 8 (surely a most worth-
  76. Xwhile enhancement; who programs in C with tabs set at 8 anyway?)
  77. X
  78. XWhile all this good stuff was going on, other (unnamed) people upgraded the
  79. Xoriginal program to handle C++ syntax as well as ordinary C and apparently
  80. Xfixed a few minor annoyances which were extant in the version from which
  81. Xthe MSDOS implementation was derived.
  82. X
  83. XThen of course, the GNU project people have been doing things with sources
  84. Xobviously derived from the BSD version.  I have not looked at the GNU
  85. Xversion of indent.
  86. X
  87. XI started with the BSD C++ formatter sources and modified them for
  88. Xcompilation with Microsoft C386 under OS/2 2.0.  That gave me a working
  89. Xbaseline version to which I made the following modifications:
  90. X
  91. X1  Changed some of the file names to allow compilation with Microsoft C
  92. X   version 6.00A which objects to files whose names do not conform to
  93. X   MSDOS's 8.3 format.
  94. X
  95. X2  Built new makefiles for OS/2 2.0 and for OS/2 1.X.  (The MSDOS version
  96. X   is created by post-processing the OS/2 1.X version.)
  97. X
  98. X   Note that when you use Makefile.1x you'll see some warning messages
  99. X   concerning the truncation of variable names.  You may safely ignore
  100. X   them.  The messages do not appear when compiling the 32-bit version.
  101. X
  102. X2  Added James Thompson's tab stuff.
  103. X
  104. X3  Fixed a bug which was causing //-style comments to be followed by an
  105. X   extra newline or an extra space depending on context.
  106. X
  107. X4  Corrected the stack overflow problem in the OS/2 1.x and MSDOS versions.
  108. X   (This seems to have been independently discovered and fixed twice
  109. X   previously but the sources contained no trace of the fix.)
  110. X
  111. X5  Patched the manual source to reflect the new -tabs option and generated
  112. X   a human-readable version.
  113. X
  114. XFinally, I put the sources through the indenter to clean up the mess.
  115. X
  116. XMore recently still, I built the program using the IBM C Set/2 tools after
  117. Xgenerating yet another Makefile.  I also fixed a bug notified by Steve
  118. XComen which was causing overlength // comments to be split incorrectly.
  119. X
  120. XNow, if I have done the job properly, the current source should combine both
  121. Xthe BSD development streams.  Furthermore, it should compile under OS/2 1.x
  122. Xfor OS/2 and MSDOS, under OS/2 2.0 for the 32-bit 'flat' model using either
  123. Xthe Microsoft C386 compiler or the IBM C Set/2 compiler and on the original
  124. XBSD UNIX platform.
  125. X
  126. XI am indebted to Steve Comen and his colleagues for help with testing and
  127. Xverifying the BSD compatibility and for several patches.
  128. X
  129. XNow all that remains to be done is to incorporate the nicer features of this
  130. Xversion into the GNU one.  Any volunteers?
  131. X
  132. XJon Saxton
  133. XApril 1992
  134. X
  135. X-------------------------------------------------------------------------
  136. X
  137. XManifest
  138. X
  139. X    args.c        \
  140. X    comment.c     \
  141. X    indent.c      \_    Program source files
  142. X    io.c          /
  143. X    lexi.c         /
  144. X    parse.c        /
  145. X
  146. X    codes.h        \
  147. X    globals.h     >-    Header files
  148. X    proto.h        /
  149. X
  150. X    indent.1        Manual source
  151. X
  152. X    indent.man        Manual in human-readable form
  153. X
  154. X    indent.def        Used only when compiling
  155. X                under OS/2 for OS/2 or MSDOS
  156. X
  157. X    indent.pro        A sample profile (the one used to format
  158. X                these sources).  Rename to .indent.pro
  159. X                for use with BSD UNIX.
  160. X
  161. X    Makefile.1x        Makefile for compiling under OS/2 1.x.
  162. X                Generates a bound 16-bit executable which
  163. X                will run under OS/2 or MSDOS.
  164. X
  165. X    Makefile.20        Makefile for compiling under OS/2 2.0 using
  166. X                the Microsoft C386 compiler.  Generates a
  167. X                32-bit executable.
  168. X
  169. X    Makefile.cs2        Makefile for compiling under OS/2 2.0 using
  170. X                the IBM C Set/2 compiler.  Generates a 32-
  171. X                bit executable.
  172. X
  173. X    Makefile.bsd        Untouched.  This is the original Makefile
  174. X                as distributed with the BSD version.
  175. X
  176. X    readme            This file
  177. SHAR_EOF
  178. if test 5548 -ne "`wc -c readme`"
  179. then
  180. echo shar: error transmitting readme '(should have been 5548 characters)'
  181. fi
  182. echo shar: extracting indent.man
  183. sed 's/^X//' << \SHAR_EOF > indent.man
  184. Xcat indent.man
  185. X
  186. X
  187. X
  188. X     INDENT(1)             A/UX (July 14, 1989)              INDENT(1)
  189. X
  190. X
  191. X
  192. X     NAME
  193. X          indent - indent and format C program source
  194. X
  195. X     SYNOPSIS
  196. X          indent  [ input-file [ output-file ] ] [ -bad | -nbad ]
  197. X                 [ -bap | -nbap ] [ -bbb | -nbbb ] [ -bc | -nbc ]
  198. X                 [ -bl ] [ -br ] [ -brr ] [ -cn ] [ -cdn ]
  199. X                 [ -cdb | -ncdb ] [ -ce | -nce ] [ -cin ] [ -clin ]
  200. X                 [ -ccin ] [ -dn ] [ -din ] [ -fc1 | -nfc1 ] [ -in ]
  201. X                 [ -ip | -nip ] [ -ln ] [ -lcn ] [ -lp | -nlp ]
  202. X                 [ -pcs | -npcs ] [ -npro ] [ -prs | -nprs ]
  203. X                 [ -psl | -npsl ] [ -sc | -nsc ] [ -sob | -nsob ]
  204. X                 [ -st ] [ -tabsn ] [ -troff ] [ -v | -nv ] [ -+ ]
  205. X
  206. X
  207. X     DESCRIPTION
  208. X          Indent is a C program formatter.  It reformats the C program
  209. X          in the input-file according to the switches.  The switches
  210. X          which can be specified are described below. They may appear
  211. X          before or after the file names.
  212. X
  213. X          NOTE: If you only specify an input-file, the formatting is
  214. X          done 'in-place', that is, the formatted file is written back
  215. X          into input-file and a backup copy of input-file is written
  216. X          in the current directory.  If input-file is named
  217. X          '/blah/blah/file', the backup file is named file.BAK.
  218. X
  219. X          If output-file is specified, indent checks to make sure it
  220. X          is different from input-file.
  221. X
  222. X     OPTIONS
  223. X          The options listed below control the formatting style
  224. X          imposed by indent.
  225. X
  226. X          -bap,-nbap     If -bap is specified, a blank line is forced
  227. X                         after every procedure body.  Default:  -nbap.
  228. X
  229. X          -bad,-nbad     If -bad is specified, a blank line is forced
  230. X                         after every block of declarations.  Default:
  231. X                         -nbad.
  232. X
  233. X          -bbb,-nbbb     If -bbb is specified, a blank line is forced
  234. X                         before every block comment.  Default:  -nbbb.
  235. X
  236. X          -bc,-nbc       If -bc is specified, then a newline is forced
  237. X                         after each comma in a declaration. -nbc turns
  238. X                         off this option.  The default is -bc.
  239. X
  240. X          -br,-bl,-brr   Specifying -bl lines up compound statements
  241. X
  242. X
  243. X
  244. X
  245. X
  246. X
  247. X     Page 1                                          (printed 3/16/92)
  248. X
  249. X
  250. X
  251. X
  252. X
  253. X
  254. X     INDENT(1)             A/UX (July 14, 1989)              INDENT(1)
  255. X
  256. X
  257. X
  258. X                         like this:
  259. X                             if (...)
  260. X                             {
  261. X                                 code
  262. X                             }
  263. X                         Specifying -br (the default) makes them look
  264. X                         like this:
  265. X                             if (...) {
  266. X                                 code
  267. X                             }
  268. X                         And specifying -brr makes them look like
  269. X                         this:
  270. X                             if (...)
  271. X                                 {
  272. X                                 code
  273. X                                 }
  274. X
  275. X          -cn            The column in which comments on code start.
  276. X                         The default is 33.
  277. X
  278. X          -cdn           The column in which comments on declarations
  279. X                         start.  The default is for these comments to
  280. X                         start in the same column as those on code.
  281. X
  282. X          -cdb,-ncdb     Enables (disables) the placement of comment
  283. X                         delimiters on blank lines.  With this option
  284. X                         enabled, comments look like this:
  285. X                              /*
  286. X                               * this is a comment
  287. X                               */
  288. X                         Rather than like this:
  289. X                              /* this is a comment */
  290. X                         This only affects block comments, not
  291. X                         comments to the right of code. The default is
  292. X                         -cdb .
  293. X
  294. X          -ce,-nce       Enables (disables) forcing 'else's to cuddle
  295. X                         up to the immediatly preceeding -ce .
  296. X
  297. X          -cin           Sets the continuation indent to be n.
  298. X                         Continuation lines will be indented that far
  299. X                         from the beginning of the first line of the
  300. X                         statement.  Parenthesized expressions have
  301. X                         extra indentation added to indicate the
  302. X                         nesting, unless -lp is in effect.  -ci
  303. X                         defaults to the same value as -i.
  304. X
  305. X          -clin          Causes case labels to be indented n tab stops
  306. X                         to the right of the containing switch
  307. X                         statement.  -cli0.5 causes case labels to be
  308. X                         indented half a tab stop.  The default is
  309. X                         -cli0 .
  310. X
  311. X
  312. X
  313. X     Page 2                                          (printed 3/16/92)
  314. X
  315. X
  316. X
  317. X
  318. X
  319. X
  320. X     INDENT(1)             A/UX (July 14, 1989)              INDENT(1)
  321. X
  322. X
  323. X
  324. X          -ccin          Causes case code to be indented n tab stops
  325. X                         to the right of the corresponding case label.
  326. X                         -cci0.5 causes case code to be indented half
  327. X                         a tab stop.  The default is -cci1 .
  328. X
  329. X          -dn            Controls the placement of comments which are
  330. X                         not to the right of code.  The default -d1
  331. X                         means that such comments are placed one
  332. X                         indentation level to the left of code.
  333. X                         Specifying -d0 lines up these comments with
  334. X                         the code.  See the section on comment
  335. X                         indentation below.
  336. X
  337. X          -din           Specifies the indentation, in character
  338. X                         positions, from a declaration keyword to the
  339. X                         following identifier.  The default is -di16 .
  340. X
  341. X          -fc1,-nfc1     Enables (disables) the formatting of comments
  342. X                         that start in column 1.  Often, comments
  343. X                         whose leading '/' is in column 1 have been
  344. X                         carefully hand formatted by the programmer.
  345. X                         In such cases, -nfc1 should be used.  The
  346. X                         default is -fc1.
  347. X
  348. X          -in            The number of spaces for one indentation
  349. X                         level.  The default is 4.
  350. X
  351. X          -ip,-nip       Enables (disables) the indentation of
  352. X                         parameter declarations from the left margin.
  353. X                         The default is -ip .
  354. X
  355. X          -ln            Maximum length of an output line.  The
  356. X                         default is 75.
  357. X
  358. X          -npro          Causes the profile files, './.indent.pro' and
  359. X                         '~/.indent.pro', to be ignored.
  360. X
  361. X          -lp,-nlp       Lines up code surrounded by parenthesis in
  362. X                         continuation lines.  If a line has a left
  363. X                         paren which is not closed on that line, then
  364. X                         continuation lines will be lined up to start
  365. X                         at the character position just after the left
  366. X                         paren.  For example, here is how a piece of
  367. X                         continued code looks with -nlp in effect:
  368. X                             p1 = first_procedure(second_procedure(p2, p3),
  369. X                                 third_procedure(p4, p5));
  370. X                         With -lp in effect (the default) the code
  371. X                         looks somewhat clearer:
  372. X                             p1 = first_procedure(second_procedure(p2, p3),
  373. X                                                  third_procedure(p4, p5));
  374. X
  375. X
  376. X
  377. X
  378. X
  379. X     Page 3                                          (printed 3/16/92)
  380. X
  381. X
  382. X
  383. X
  384. X
  385. X
  386. X     INDENT(1)             A/UX (July 14, 1989)              INDENT(1)
  387. X
  388. X
  389. X
  390. X                         Inserting a couple more newlines we get:
  391. X                             p1 = first_procedure(second_procedure(p2,
  392. X                                                                   p3),
  393. X                                                  third_procedure(p4,
  394. X                                                                  p5));
  395. X
  396. X          -pcs , -npcs   If true (-pcs) all procedure calls will have
  397. X                         a space inserted between the name and the
  398. X                         '('.  The default is -npcs
  399. X
  400. X          -prs , -nprs   If true (-prs) all parentheses will have a
  401. X                         space inserted after the '(' and before the
  402. X                         ')'.  The default is -nprs
  403. X
  404. X          -psl , -npsl   If true (-psl) the names of procedures being
  405. X                         defined are placed in column 1 - their types,
  406. X                         if any, will be left on the previous lines.
  407. X                         The default is -psl
  408. X
  409. X          -sc,-nsc       Enables (disables) the placement of asterisks
  410. X                         ('*'s) at the left edge of all comments.
  411. X
  412. X          -sob,-nsob     If -sob is specified, indent will swallow
  413. X                         optional blank lines.  You can use this to
  414. X                         get rid of blank lines after declarations.
  415. X                         Default:  -nsob
  416. X
  417. X          -st            Causes indent to take its input from stdin,
  418. X                         and put its output to stdout.
  419. X
  420. X          -Ttypename     Adds typename to the list of type keywords.
  421. X                         Names accumulate:  -T can be specified more
  422. X                         than once.  You need to specify all the
  423. X                         typenames that appear in your program that
  424. X                         are defined by typedefs - nothing will be
  425. X                         harmed if you miss a few, but the program
  426. X                         won't be formatted as nicely as it should.
  427. X                         This sounds like a painful thing to have to
  428. X                         do, but it's really a symptom of a problem in
  429. X                         C: typedef causes a syntactic change in the
  430. X                         language and indent can't find all typedefs.
  431. X
  432. X          -tabsn         Tells indent that tabs are assumed to be at
  433. X                         every n columns.  The default is -tabs8 .
  434. X
  435. X          -troff         Causes indent to format the program for
  436. X                         processing by troff.  It will produce a fancy
  437. X                         listing in much the same spirit as vgrind.
  438. X                         If the output file is not specified, the
  439. X                         default is standard output, rather than
  440. X                         formatting in place.
  441. X
  442. X
  443. X
  444. X
  445. X     Page 4                                          (printed 3/16/92)
  446. X
  447. X
  448. X
  449. X
  450. X
  451. X
  452. X     INDENT(1)             A/UX (July 14, 1989)              INDENT(1)
  453. X
  454. X
  455. X
  456. X          -v,-nv         -v turns on 'verbose' mode, -nv turns it off.
  457. X                         When in verbose mode, indent reports when it
  458. X                         splits one line of input into two or more
  459. X                         lines of output, and gives some size
  460. X                         statistics at completion. The default is -nv.
  461. X
  462. X          -+             turns on support for C++. In c++ mode, :: is
  463. X                         permited in identifiers, C++ keywords are
  464. X                         supported, and class definition keywords
  465. X                         (public, private, etc.) are set in column 2.
  466. X
  467. X     FURTHER DESCRIPTION
  468. X          You may set up your own 'profile' of defaults to indent by
  469. X          creating a file called .indent.pro in either your login
  470. X          directory or the current directory and including whatever
  471. X          switches you like.  A '.indent.pro' in the current directory
  472. X          takes precedence over the one in your login directory.  If
  473. X          indent is run and a profile file exists, then it is read to
  474. X          set up the program's defaults.  Switches on the command
  475. X          line, though, always override profile switches.  The
  476. X          switches should be separated by spaces, tabs or newlines.
  477. X
  478. X          Comments
  479. X
  480. X          'Box' comments.  Indent assumes that any comment with a dash
  481. X          or star immediately after the start of comment (that is,
  482. X          '/*-' or '/**') is a comment surrounded by a box of stars.
  483. X          Each line of such a comment is left unchanged, except that
  484. X          its indentation may be adjusted to account for the change in
  485. X          indentation of the first line of the comment.
  486. X
  487. X          Straight text.  All other comments are treated as straight
  488. X          text.  Indent fits as many words (separated by blanks, tabs,
  489. X          or newlines) on a line as possible.  Blank lines break
  490. X          paragraphs.
  491. X
  492. X          Comment indentation
  493. X
  494. X          If a comment is on a line with code it is started in the
  495. X          'comment column', which is set by the -cn command line
  496. X          parameter.  Otherwise, the comment is started at n
  497. X          indentation levels less than where code is currently being
  498. X          placed, where n is specified by the -dn command line
  499. X          parameter.  If the code on a line extends past the comment
  500. X          column, the comment starts further to the right, and the
  501. X          right margin may be automatically extended in extreme cases.
  502. X
  503. X          Special Comments
  504. X
  505. X          Indent produces and interprets some special comments.  When
  506. X          indent cannot parse the source, it prints a message on
  507. X          standard error and inserts a comment into the output of the
  508. X
  509. X
  510. X
  511. X     Page 5                                          (printed 3/16/92)
  512. X
  513. X
  514. X
  515. X
  516. X
  517. X
  518. X     INDENT(1)             A/UX (July 14, 1989)              INDENT(1)
  519. X
  520. X
  521. X
  522. X          form
  523. X               /**INDENT** ErrorMessage */
  524. X
  525. X          Indent interprets several special comments as directives.
  526. X          First, it makes no attempt to format lines containing the
  527. X          error comment described above.
  528. X
  529. X          Second, lines of the form:
  530. X               /* INDENT OFF */
  531. X          or
  532. X               /* INDENT ON */
  533. X          disable and re-enable indent formatting. Any amount of
  534. X          whitespace may replace the spaces shown in the examples.
  535. X
  536. X          Third, indent allows formatting controls to be included in
  537. X          the source via comments of the form:
  538. X               /* INDENT: arg1 arg2 arg3 ... arg4 */
  539. X          The arguments given are in the same syntax as the command
  540. X          line or profile file.  For example:
  541. X               /* INDENT: -cli.25 -nfc1 */
  542. X
  543. X          Preprocessor lines
  544. X
  545. X          In general, indent leaves preprocessor lines alone.  The
  546. X          only reformmatting that it will do is to straighten up
  547. X          trailing comments.  It leaves imbedded comments alone.
  548. X          Conditional compilation (#ifdef...#endif) is recognized and
  549. X          indent attempts to correctly compensate for the syntactic
  550. X          peculiarites introduced.
  551. X
  552. X          C syntax
  553. X
  554. X          Indent understands a substantial amount about the syntax of
  555. X          C, but it has a 'forgiving' parser.  It attempts to cope
  556. X          with the usual sorts of incomplete and misformed syntax.  In
  557. X          particular, the use of macros like:
  558. X                  #define forever for(;;)
  559. X          is handled properly.
  560. X
  561. X     FILES
  562. X          ./.indent.pro  profile file
  563. X
  564. X     BUGS
  565. X          Indent has even more switches than ls.
  566. X
  567. X          A common mistake that often causes grief is typing:
  568. X              indent *.c
  569. X          to the shell in an attempt to indent all the C programs in a
  570. X          directory.  This is a really nasty thing to do.  (Think
  571. X          about it.)
  572. X
  573. X
  574. X
  575. X
  576. X
  577. X     Page 6                                          (printed 3/16/92)
  578. X
  579. X
  580. X
  581. X/users/jrs>SHAR_EOF
  582. if test 15722 -ne "`wc -c indent.man`"
  583. then
  584. echo shar: error transmitting indent.man '(should have been 15722 characters)'
  585. fi
  586. echo shar: extracting indent.1
  587. sed 's/^X//' << \SHAR_EOF > indent.1
  588. X.\" Copyright 1989 Object Design, Inc.
  589. X.\" Copyright (c) 1985 Sun Microsystems, Inc.
  590. X.\" Copyright (c) 1980 The Regents of the University of California.
  591. X.\" Copyright (c) 1976 Board of Trustees of the University of Illinois.
  592. X.\" All rights reserved.
  593. X.\" Redistribution and use in source and binary forms are permitted
  594. X.\" provided that the above copyright notice and this paragraph are
  595. X.\" duplicated in all such forms and that any documentation,
  596. X.\" advertising materials, and other materials related to such
  597. X.\" distribution and use acknowledge that the software was developed
  598. X.\" by the University of California, Berkeley, the University of Illinois,
  599. X.\" Urbana, and Sun Microsystems, Inc.  The name of either University
  600. X.\" or Sun Microsystems may not be used to endorse or promote products
  601. X.\" derived from this software without specific prior written permission.
  602. X.\" THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
  603. X.\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  604. X.\" WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  605. X.\" 
  606. X.\"    @(#)indent.1    6.5 (Berkeley) 88/09/15
  607. X.\"
  608. X.TH INDENT 1 "July 14, 1989
  609. X.SH NAME
  610. Xindent \- indent and format C program source
  611. X.SH SYNOPSIS
  612. X.in +\w'\fBindent \fR'u
  613. X.ti -\w'\fBindent \fR'u
  614. X\fBindent \fR [ \fIinput-file\fR [ \fIoutput-file\fR ] ]
  615. X[\ \fB\-bad\fR\ |\ \fB\-nbad\fR\ ]
  616. X[\ \fB\-bap\fR\ |\ \fB\-nbap\fR\ ]
  617. X[\ \fB\-bbb\fR\ |\ \fB\-nbbb\fR\ ]
  618. X[\ \fB\-bc\fR\ |\ \fB\-nbc\fR\ ]
  619. X[\ \fB\-bl\fR\ ]
  620. X[\ \fB\-br\fR\ ]
  621. X[\ \fB\-brr\fR\ ]
  622. X[\ \fB\-c\fIn\fR\ ]
  623. X[\ \fB\-cd\fIn\fR\ ]
  624. X[\ \fB\-cdb\fR\ |\ \fB\-ncdb\fR\ ]
  625. X[\ \fB\-ce\fR\ |\ \fB\-nce\fR\ ]
  626. X[\ \fB\-ci\fIn\fR\ ]
  627. X[\ \fB\-cli\fIn\fR\ ]
  628. X[\ \fB\-cci\fIn\fR\ ]
  629. X[\ \fB\-d\fIn\fR\ ]
  630. X[\ \fB\-di\fIn\fR\ ]
  631. X[\ \fB\-fc1\fR\ |\ \fB\-nfc1\fR\ ]
  632. X[\ \fB\-i\fIn\fR\ ]
  633. X[\ \fB\-ip\fR\ |\ \fB\-nip\fR\ ]
  634. X[\ \fB\-l\fIn\fR\ ]
  635. X[\ \fB\-lc\fIn\fR\ ]
  636. X[\ \fB\-lp\fR\ |\ \fB\-nlp\fR\ ]
  637. X[\ \fB\-pcs\fR\ |\ \fB\-npcs\fR\ ]
  638. X[\ \fB\-npro\fR\ ]
  639. X[\ \fB\-prs\fR\ |\ \fB\-nprs\fR\ ]
  640. X[\ \fB\-psl\fR\ |\ \fB\-npsl\fR\ ]
  641. X[\ \fB\-sc\fR\ |\ \fB\-nsc\fR\ ]
  642. X[\ \fB\-sob\fR\ |\ \fB\-nsob\fR\ ]
  643. X[\ \fB\-st\fR\ ]
  644. X[\ \fB\-tabs\fIn\fR\ ]
  645. X[\ \fB\-troff\fR\ ]
  646. X[\ \fB\-v\fR\ |\ \fB\-nv\fR\ ]
  647. X[\ \fB-+\fR ]
  648. X
  649. X.SH DESCRIPTION
  650. X.I Indent
  651. Xis a \fBC\fR program formatter.  It reformats the \fBC\fR program in the
  652. X\fIinput-file\fR according to the switches.  The switches which can be
  653. Xspecified are described below. They may appear before or after the file
  654. Xnames.
  655. X.LP
  656. X\fBNOTE\fP: If you only specify an \fIinput-file\fR, the formatting is
  657. Xdone 'in-place', that is, the formatted file is written back into
  658. X.I input-file
  659. Xand a backup copy of
  660. X.I input-file
  661. Xis written in the current directory.  If
  662. X.I input-file
  663. Xis named '/blah/blah/file', the backup file is named
  664. X.RI file .BAK.
  665. X.LP
  666. XIf
  667. X.I output-file
  668. Xis specified,
  669. X.I indent
  670. Xchecks to make sure it is different from
  671. X.IR input-file .
  672. X.SH OPTIONS
  673. X.LP
  674. XThe options listed below control the formatting style imposed by
  675. X.IR indent .
  676. X.TP 15
  677. X.BR \-bap , \-nbap
  678. XIf
  679. X.B \-bap
  680. Xis specified, a blank line is forced after every procedure body.  Default:
  681. X.B \-nbap.
  682. X.TP 15
  683. X.BR \-bad , \-nbad
  684. XIf
  685. X.B \-bad
  686. Xis specified, a blank line is forced after every block of
  687. Xdeclarations.  Default:  
  688. X.B \-nbad.
  689. X.TP 15
  690. X.BR \-bbb , \-nbbb
  691. XIf
  692. X.B \-bbb
  693. Xis specified, a blank line is forced before every block comment.  Default:
  694. X.B \-nbbb.
  695. X.TP 15
  696. X.BR \-bc , \-nbc
  697. XIf
  698. X.B \-bc
  699. Xis specified, then a newline is forced after each comma in a declaration. 
  700. X.B \-nbc
  701. Xturns off this option.  The default is
  702. X.BR \-bc .
  703. X.TP 15
  704. X.BR \-br , \-bl , \-brr
  705. XSpecifying
  706. X.B \-bl
  707. Xlines up compound statements like this:
  708. X.ne 4
  709. X.nf
  710. X.ft L
  711. X    if (...)
  712. X    {
  713. X        code
  714. X    }
  715. X.ft R
  716. X.fi
  717. XSpecifying
  718. X.B \-br
  719. X(the default) makes them look like this:
  720. X.ne 3
  721. X.nf
  722. X.ft L
  723. X    if (...) {
  724. X        code
  725. X    }
  726. X.ft R
  727. X.fi
  728. XAnd specifying
  729. X.B \-brr
  730. Xmakes them look like this:
  731. X.ne 3
  732. X.nf
  733. X.ft L
  734. X    if (...)
  735. X        {
  736. X        code
  737. X        }
  738. X.ft R
  739. X.fi
  740. X.LP
  741. X.TP 15
  742. X.BI \-c n
  743. XThe column in which comments on code start.  The default is 33.  
  744. X.TP 15
  745. X.BI \-cd n
  746. XThe column in which comments on declarations start.  The default
  747. Xis for these comments to start in the same column as those on code.
  748. X.TP 15
  749. X.BI \-cdb , \-ncdb
  750. XEnables (disables) the placement of comment delimiters on blank lines.  With
  751. Xthis option enabled, comments look like this:
  752. X.nf
  753. X.ft L
  754. X.ne 3
  755. X    /*
  756. X     * this is a comment
  757. X     */
  758. X.ft R
  759. X.fi
  760. XRather than like this:
  761. X.nf
  762. X.ft L
  763. X    /* this is a comment */
  764. X.ft R
  765. X.fi
  766. XThis only affects block comments, not comments to the right of code. The default is
  767. X.B \-cdb .
  768. X.TP 15
  769. X.BI \-ce , \-nce
  770. XEnables (disables) forcing 'else's to cuddle up to the immediatly preceeding
  771. X'}'.  The default is
  772. X.B \-ce .
  773. X.TP 15
  774. X.BI \-ci n
  775. XSets the continuation indent to be \fIn\fR.  Continuation
  776. Xlines will be indented that far from the beginning of the first line of the
  777. Xstatement.  Parenthesized expressions have extra indentation added to
  778. Xindicate the nesting, unless \fB\-lp\fR is in effect.
  779. X\fB\-ci\fR defaults to the same value as \fB\-i\fR.
  780. X.TP 15
  781. X.BI \-cli n
  782. XCauses case labels to be indented
  783. X.I n
  784. Xtab stops to the right of the containing \fBswitch\fR statement.
  785. X\fB-cli0.5\fR causes case labels to be indented half a tab stop.  The
  786. Xdefault is
  787. X.B \-cli0 .
  788. X.TP 15
  789. X.BI \-cci n
  790. XCauses case code to be indented
  791. X.I n
  792. Xtab stops to the right of the corresponding case label.
  793. X\fB-cci0.5\fR causes case code to be indented half a tab stop.  The
  794. Xdefault is
  795. X.B \-cci1 .
  796. X.TP 15
  797. X.BI \-d n
  798. XControls the placement of comments which are not to the
  799. Xright of code.  The default
  800. X.B \-d1
  801. Xmeans that such comments are placed one indentation level to the
  802. Xleft of code.  Specifying
  803. X.B \-d0
  804. Xlines up these comments with the code.  See the section on comment
  805. Xindentation below.
  806. X.TP 15
  807. X.BI \-di n
  808. XSpecifies the indentation, in character positions, from a declaration keyword
  809. Xto the following identifier.  The default is
  810. X.B \-di16 .
  811. X.if 0 \{.TP 15
  812. X.BR \-dj , \-ndj
  813. X.B \-dj
  814. Xleft justifies declarations.
  815. X.B \-ndj
  816. Xindents declarations the same as code.  The default is
  817. X.BR \-ndj .
  818. X.TP 15
  819. X.BI \-ei , \-nei
  820. XEnables (disables) special
  821. X.B else-if
  822. Xprocessing.  If it's enabled,
  823. X.BR if "s"
  824. Xfollowing
  825. X.BR else "s"
  826. Xwill have the same indendation as the preceeding
  827. X.B if
  828. Xstatement.\}
  829. X.TP 15
  830. X.BI \-fc1 , \-nfc1
  831. XEnables (disables) the formatting of comments that start in column 1.
  832. XOften, comments whose leading '/' is in column 1 have been carefully
  833. Xhand formatted by the programmer.  In such cases, \fB\-nfc1\fR should be
  834. Xused.  The default is \fB\-fc1\fR.
  835. X.TP 15
  836. X.BI \-i n
  837. XThe number of spaces for one indentation level.  The default is 4.
  838. X.TP 15
  839. X.BI \-ip , \-nip
  840. XEnables (disables) the indentation of parameter declarations from the left
  841. Xmargin.  The default is
  842. X.B \-ip .
  843. X.TP 15
  844. X.BI \-l n
  845. XMaximum length of an output line.  The default is 75.
  846. X.TP 15
  847. X.B \-npro
  848. XCauses the profile files, './.indent.pro' and '~/.indent.pro', to be ignored.
  849. X.TP 15
  850. X.BI \-lp , \-nlp
  851. XLines up code surrounded by parenthesis in continuation lines.  If a line
  852. Xhas a left paren which is not closed on that line, then continuation lines
  853. Xwill be lined up to start at the character position just after the left
  854. Xparen.  For example, here is how a piece of continued code looks with -nlp
  855. Xin effect:
  856. X.ne 2
  857. X.nf
  858. X.ft L
  859. X    p1 = first_procedure(second_procedure(p2, p3),
  860. X        third_procedure(p4, p5));
  861. X.ft R
  862. X.fi
  863. X.ne 5
  864. XWith \fB-lp\fR in effect (the default) the code looks somewhat clearer:
  865. X.nf
  866. X.ft L
  867. X    p1 = first_procedure(second_procedure(p2, p3),
  868. X                         third_procedure(p4, p5));
  869. X.ft R
  870. X.fi
  871. X.ne 5
  872. XInserting a couple more newlines we get:
  873. X.nf
  874. X.ft L
  875. X    p1 = first_procedure(second_procedure(p2,
  876. X                                          p3),
  877. X                         third_procedure(p4,
  878. X                                         p5));
  879. X.ft R
  880. X.fi
  881. X.TP 15
  882. X.B \-pcs , \-npcs
  883. XIf true (\fB-pcs\fR) all procedure calls will have a space inserted between
  884. Xthe name and the '('.  The default is 
  885. X.B \-npcs
  886. X.TP 15
  887. X.B \-prs , \-nprs
  888. XIf true (\fB-prs\fR) all parentheses will have a space inserted
  889. Xafter the '(' and before the ')'.  The default is 
  890. X.B \-nprs
  891. X.TP 15
  892. X.B \-psl , \-npsl
  893. XIf true (\fB-psl\fR) the names of procedures being defined are placed in
  894. Xcolumn 1 \- their types, if any, will be left on the previous lines.  The
  895. Xdefault is 
  896. X.B -psl
  897. X.TP 15
  898. X.BI \-sc , \-nsc
  899. XEnables (disables) the placement of asterisks ('*'s) at the left edge of all
  900. Xcomments.    
  901. X.TP 15
  902. X.BR \-sob , \-nsob
  903. XIf
  904. X.B \-sob
  905. Xis specified, indent will swallow optional blank lines.  You can use this to
  906. Xget rid of blank lines after declarations.  Default:
  907. X.B \-nsob
  908. X.TP 15
  909. X.B \-st
  910. XCauses
  911. X.B indent
  912. Xto take its input from stdin, and put its output to stdout.
  913. X.TP 15
  914. X.BI \-T typename
  915. XAdds
  916. X.I typename
  917. Xto the list of type keywords.  Names accumulate:
  918. X.B \-T
  919. Xcan be specified more than once.  You need to specify all the typenames that
  920. Xappear in your program that are defined by \fBtypedef\fRs \- nothing will be
  921. Xharmed if you miss a few, but the program won't be formatted as nicely as
  922. Xit should.  This sounds like a painful thing to have to do, but it's really
  923. Xa symptom of a problem in C: \fBtypedef\fR causes a syntactic change in the
  924. Xlanguage and \fIindent\fR can't find all \fBtypedef\fRs.
  925. X.TP 15
  926. X.BI \-tabs n
  927. XTells indent that tabs are assumed to be at every
  928. X.I n
  929. Xcolumns.  The
  930. Xdefault is
  931. X.B \-tabs8 .
  932. X.TP 15
  933. X.B \-troff
  934. XCauses
  935. X.B indent
  936. Xto format the program for processing by troff.  It will produce a fancy
  937. Xlisting in much the same spirit as
  938. X.BR vgrind.
  939. XIf the output file is not specified, the default is standard output,
  940. Xrather than formatting in place.
  941. X.TP 15
  942. X.BR \-v , \-nv
  943. X.B \-v
  944. Xturns on 'verbose' mode,
  945. X.B \-nv
  946. Xturns it off.  When in verbose mode,
  947. X.I indent
  948. Xreports when it splits one line of input into two or more lines of output,
  949. Xand gives some size statistics at completion. The default is
  950. X.BR \-nv .
  951. X.TP 15
  952. X.B \-+
  953. Xturns on support for C++. In c++ mode, :: is permited in identifiers, 
  954. XC++ keywords are supported, and class definition keywords 
  955. X(public, private, etc.) are set in column 2.
  956. X.SH "FURTHER DESCRIPTION"
  957. X.LP
  958. XYou may set up your own 'profile' of defaults to
  959. X.I indent
  960. Xby creating a file called
  961. X.BI . indent . pro
  962. Xin either your login directory or the current directory and including
  963. Xwhatever switches you like.  A '.indent.pro' in the current directory takes
  964. Xprecedence over the one in your login directory.  If
  965. X.I indent
  966. Xis run and a profile file exists, then it is read to set up the program's
  967. Xdefaults.  Switches on the command line, though, always override profile
  968. Xswitches.  The switches should be separated by spaces, tabs or newlines.
  969. X.LP
  970. X.B Comments
  971. X.LP
  972. X.IR "'Box' comments" .
  973. X.I Indent
  974. Xassumes that any comment with a dash or star immediately after the start of
  975. Xcomment (that is, '/*\-' or '/**') is a comment surrounded by a box of stars.
  976. XEach line of such a comment is left unchanged, except that its indentation
  977. Xmay be adjusted to account for the change in indentation of the first line
  978. Xof the comment.
  979. X.LP
  980. X.IR "Straight text" .
  981. XAll other comments are treated as straight text.
  982. X.I Indent
  983. Xfits as many words (separated by blanks, tabs, or newlines) on a
  984. Xline as possible.  Blank lines break paragraphs.
  985. X.LP
  986. X.B Comment indentation
  987. X.LP
  988. XIf a comment is on a line with code it is started in the 'comment column',
  989. Xwhich is set by the
  990. X.BI \-c n
  991. Xcommand line parameter.  Otherwise, the comment is started at
  992. X.I n
  993. Xindentation levels less than where code is currently being placed, where
  994. X.I n
  995. Xis specified by the
  996. X.BI \-d n
  997. Xcommand line parameter.  If the code on a line extends past the comment
  998. Xcolumn, the comment starts further to the right, and the right margin may be
  999. Xautomatically extended in extreme cases.
  1000. X.LP
  1001. X.B Special Comments
  1002. X.LP
  1003. X.I Indent
  1004. Xproduces and interprets some special comments.
  1005. XWhen indent cannot parse the source, it prints a message on standard error
  1006. Xand inserts a comment into the output of the form
  1007. X.nf
  1008. X.ft L
  1009. X    /**INDENT** ErrorMessage */
  1010. X.ft R
  1011. X.fi
  1012. X.LP
  1013. X.I Indent
  1014. Xinterprets several special comments as directives. 
  1015. XFirst, it makes no attempt to format lines containing the error comment
  1016. Xdescribed above.
  1017. X.LP
  1018. XSecond, lines of the form:
  1019. X.nf
  1020. X.ft L
  1021. X    /* INDENT OFF */
  1022. Xor
  1023. X    /* INDENT ON */
  1024. X.ft R
  1025. X.fi
  1026. Xdisable and re-enable indent formatting. 
  1027. XAny amount of whitespace may replace the spaces shown in the examples.
  1028. X.LP
  1029. XThird, 
  1030. X.I indent
  1031. Xallows formatting controls to be included in the source via comments of the form:
  1032. X.nf
  1033. X.ft L
  1034. X    /* INDENT: arg1 arg2 arg3 ... arg4 */
  1035. X.ft R
  1036. X.fi
  1037. XThe arguments given are in the same syntax as the command line or profile file.
  1038. XFor example:
  1039. X.nf
  1040. X.ft L
  1041. X    /* INDENT: -cli.25 -nfc1 */
  1042. X.ft R
  1043. X.fi
  1044. X.LP
  1045. X.B Preprocessor lines
  1046. X.LP
  1047. XIn general, \fIindent\fR leaves preprocessor lines alone.  The only
  1048. Xreformmatting that it will do is to straighten up trailing comments.  It
  1049. Xleaves imbedded comments alone.  Conditional compilation
  1050. X(\fB#ifdef...#endif\fR) is recognized and \fIindent\fR attempts to correctly
  1051. Xcompensate for the syntactic peculiarites introduced.
  1052. X.LP
  1053. X.B C syntax
  1054. X.LP
  1055. X\fIIndent\fR understands a substantial amount about the syntax of C, but it
  1056. Xhas a 'forgiving' parser.  It attempts to cope with the usual sorts of
  1057. Xincomplete and misformed syntax.  In particular, the use of macros like:
  1058. X.nf
  1059. X.ft L
  1060. X        #define forever for(;;)
  1061. X.ft R
  1062. X.fi
  1063. Xis handled properly.
  1064. X.SH FILES
  1065. X.DT
  1066. X.br
  1067. X\&./.indent.pro    profile file
  1068. X.br
  1069. X.SH BUGS
  1070. X.I Indent
  1071. Xhas even more switches than \fIls\fR.
  1072. X
  1073. X.ne 5
  1074. XA common mistake that often causes grief is typing:
  1075. X.nf
  1076. X.ft L
  1077. X    indent *.c
  1078. X.ft R
  1079. X.fi
  1080. Xto the shell in an attempt to indent all the \fBC\fR programs in a directory.
  1081. XThis is a really nasty thing to do.  (Think about it.)
  1082. SHAR_EOF
  1083. if test 13503 -ne "`wc -c indent.1`"
  1084. then
  1085. echo shar: error transmitting indent.1 '(should have been 13503 characters)'
  1086. fi
  1087. echo shar: extracting indent.def
  1088. sed 's/^X//' << \SHAR_EOF > indent.def
  1089. XName Indent WindowCompat NewFiles
  1090. Xstacksize 12000
  1091. SHAR_EOF
  1092. if test 50 -ne "`wc -c indent.def`"
  1093. then
  1094. echo shar: error transmitting indent.def '(should have been 50 characters)'
  1095. fi
  1096. echo shar: extracting Makefile.1x
  1097. sed 's/^X//' << \SHAR_EOF > Makefile.1x
  1098. X# Copyright (c) 1987 Regents of the University of California.
  1099. X# All rights reserved.
  1100. X#
  1101. X# Redistribution and use in source and binary forms are permitted
  1102. X# provided that the above copyright notice and this paragraph are
  1103. X# duplicated in all such forms and that any documentation,
  1104. X# advertising materials, and other materials related to such
  1105. X# distribution and use acknowledge that the software was developed
  1106. X# by the University of California, Berkeley.  The name of the
  1107. X# University may not be used to endorse or promote products derived
  1108. X# from this software without specific prior written permission.
  1109. X# THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
  1110. X# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  1111. X# WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  1112. X#
  1113. X#    @(#)Makefile    5.9 (Berkeley) 88/09/15
  1114. X#
  1115. X#
  1116. X# Makefile for OS/2 1.x by Jon Saxton, February 1992
  1117. X
  1118. X
  1119. XCFLAGS=    -c -DMAXPATHLEN=256 -G2 -W3 -Zp -DANSIC
  1120. XCC=    cl
  1121. XLN=    link
  1122. XLIBC=
  1123. XSRCS=    indent.c io.c lexi.c parse.c comment.c args.c
  1124. XH=    codes.h globals.h proto.h
  1125. XOBJS=    indent.obj io.obj lexi.obj parse.obj comment.obj args.obj
  1126. X
  1127. X.c.obj:
  1128. X    $(CC) $(CFLAGS) $*.c
  1129. X
  1130. Xall: indent.exe
  1131. X
  1132. Xindent.exe: $(OBJS)
  1133. X    $(LN) /st:3000 $(OBJS), $@, nul,,indent.def
  1134. X    bind $@ /names DOSQFSATTACH
  1135. X
  1136. Xindent.obj:    indent.c $H
  1137. X
  1138. Xio.obj:        io.c globals.h proto.h
  1139. X
  1140. Xlexi.obj:    lexi.c $H
  1141. X
  1142. Xparse.obj:    parse.c $H
  1143. X
  1144. Xcomment.obj:    comment.c globals.h proto.h
  1145. X
  1146. Xargs.obj:    args.c globals.h proto.h
  1147. SHAR_EOF
  1148. if test 1436 -ne "`wc -c Makefile.1x`"
  1149. then
  1150. echo shar: error transmitting Makefile.1x '(should have been 1436 characters)'
  1151. fi
  1152. echo shar: extracting Makefile.20
  1153. sed 's/^X//' << \SHAR_EOF > Makefile.20
  1154. X# Copyright (c) 1987 Regents of the University of California.
  1155. X# All rights reserved.
  1156. X#
  1157. X# Redistribution and use in source and binary forms are permitted
  1158. X# provided that the above copyright notice and this paragraph are
  1159. X# duplicated in all such forms and that any documentation,
  1160. X# advertising materials, and other materials related to such
  1161. X# distribution and use acknowledge that the software was developed
  1162. X# by the University of California, Berkeley.  The name of the
  1163. X# University may not be used to endorse or promote products derived
  1164. X# from this software without specific prior written permission.
  1165. X# THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
  1166. X# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  1167. X# WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  1168. X#
  1169. X#    @(#)Makefile    5.9 (Berkeley) 88/09/15
  1170. X#
  1171. X#
  1172. X# Makefile for OS/2 2.0 by Jon Saxton, February 1992
  1173. X
  1174. XCFLAGS=    -c -DMAXPATHLEN=256 -G3 -W3 -Zp -DANSIC
  1175. XCC=    cl386
  1176. XLN=    link386
  1177. XLIBC=
  1178. XSRCS=    indent.c io.c lexi.c parse.c comment.c args.c
  1179. XH=    codes.h globals.h proto.h
  1180. XOBJS=    indent.obj io.obj lexi.obj parse.obj comment.obj args.obj
  1181. X
  1182. X.c.obj:
  1183. X    $(CC) $(CFLAGS) $*.c
  1184. X
  1185. Xall: indent.exe
  1186. X
  1187. Xindent.exe: $(OBJS)
  1188. X    $(LN) $(OBJS),$@,nul,,indent.def
  1189. X
  1190. Xindent.obj:    indent.c $H
  1191. X
  1192. Xio.obj:        io.c globals.h proto.h
  1193. X
  1194. Xlexi.obj:    lexi.c $H
  1195. X
  1196. Xparse.obj:    parse.c $H
  1197. X
  1198. Xcomment.obj:    comment.c globals.h proto.h
  1199. X
  1200. Xargs.obj:    args.c i_globals.h proto.h
  1201. SHAR_EOF
  1202. if test 1403 -ne "`wc -c Makefile.20`"
  1203. then
  1204. echo shar: error transmitting Makefile.20 '(should have been 1403 characters)'
  1205. fi
  1206. echo shar: extracting Makefile.bsd
  1207. sed 's/^X//' << \SHAR_EOF > Makefile.bsd
  1208. X# Copyright (c) 1987 Regents of the University of California.
  1209. X# All rights reserved.
  1210. X#
  1211. X# Redistribution and use in source and binary forms are permitted
  1212. X# provided that the above copyright notice and this paragraph are
  1213. X# duplicated in all such forms and that any documentation,
  1214. X# advertising materials, and other materials related to such
  1215. X# distribution and use acknowledge that the software was developed
  1216. X# by the University of California, Berkeley.  The name of the
  1217. X# University may not be used to endorse or promote products derived
  1218. X# from this software without specific prior written permission.
  1219. X# THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
  1220. X# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  1221. X# WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  1222. X#
  1223. X#    @(#)Makefile    5.9 (Berkeley) 88/09/15
  1224. X#
  1225. XCFLAGS=    -O -DBSD #-DMAXPATHLEN=256
  1226. XLIBC=    /lib/libc.a
  1227. XSRCS=    indent.c io.c lexi.c parse.c comment.c args.c
  1228. XOBJS=    indent.o io.o lexi.o parse.o comment.o args.o
  1229. XMAN=    indent.0
  1230. X
  1231. Xall: indent
  1232. X
  1233. Xindent: ${OBJS} ${LIBC}
  1234. X    ${CC} -o $@ ${CFLAGS} ${OBJS}
  1235. X
  1236. Xclean:
  1237. X    rm -f ${OBJS} core indent
  1238. X
  1239. Xcleandir: clean
  1240. X    rm -f ${MAN} tags .depend
  1241. X
  1242. Xdepend: ${SRCS}
  1243. X    mkdep ${CFLAGS} ${SRCS}
  1244. X
  1245. Xinstall: ${MAN}
  1246. X    install -s -o bin -g bin -m 755 indent ${DESTDIR}/usr/ucb/indent
  1247. X    install -c -o bin -g bin -m 444 indent.0 ${DESTDIR}/usr/man/cat1/indent.0
  1248. X
  1249. Xlint: ${SRCS}
  1250. X    lint ${CFLAGS} ${SRCS}
  1251. X
  1252. Xtags: ${SRCS}
  1253. X    ctags ${SRCS}
  1254. SHAR_EOF
  1255. if test 1429 -ne "`wc -c Makefile.bsd`"
  1256. then
  1257. echo shar: error transmitting Makefile.bsd '(should have been 1429 characters)'
  1258. fi
  1259. echo shar: extracting Makefile.cs2
  1260. sed 's/^X//' << \SHAR_EOF > Makefile.cs2
  1261. X# Copyright (c) 1987 Regents of the University of California.
  1262. X# All rights reserved.
  1263. X#
  1264. X# Redistribution and use in source and binary forms are permitted
  1265. X# provided that the above copyright notice and this paragraph are
  1266. X# duplicated in all such forms and that any documentation,
  1267. X# advertising materials, and other materials related to such
  1268. X# distribution and use acknowledge that the software was developed
  1269. X# by the University of California, Berkeley.  The name of the
  1270. X# University may not be used to endorse or promote products derived
  1271. X# from this software without specific prior written permission.
  1272. X# THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
  1273. X# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  1274. X# WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  1275. X#
  1276. X#    @(#)Makefile    5.9 (Berkeley) 88/09/15
  1277. X#
  1278. X#
  1279. X# Makefile for OS/2 2.0 by Jon Saxton, February 1992
  1280. X# Amended for C Set/2 by Jon Saxton, April 1992
  1281. X
  1282. XCFLAGS=    -c -DMAXPATHLEN=256 -G3 -W3 -DANSIC -DMSDOS -dM_I386 -Sm
  1283. XCC=    icc
  1284. XLN=    link386
  1285. XLIBC=
  1286. XSRCS=    indent.c io.c lexi.c parse.c comment.c args.c
  1287. XH=    codes.h globals.h proto.h
  1288. XOBJS=    indent.obj io.obj lexi.obj parse.obj comment.obj args.obj
  1289. XOBS=    indent+io+lexi+parse+comment+args
  1290. X
  1291. X.c.obj:
  1292. X    $(CC) $(CFLAGS) $*.c
  1293. X
  1294. Xall: indent.exe
  1295. X
  1296. Xindent.exe: $(OBJS)
  1297. X    $(LN) $(OBS),$@,nul,,indent.def
  1298. X
  1299. Xindent.obj:    indent.c $H
  1300. X
  1301. Xio.obj:        io.c globals.h proto.h
  1302. X
  1303. Xlexi.obj:    lexi.c $H
  1304. X
  1305. Xparse.obj:    parse.c $H
  1306. X
  1307. Xcomment.obj:    comment.c globals.h proto.h
  1308. X
  1309. Xargs.obj:    args.c globals.h proto.h
  1310. SHAR_EOF
  1311. if test 1502 -ne "`wc -c Makefile.cs2`"
  1312. then
  1313. echo shar: error transmitting Makefile.cs2 '(should have been 1502 characters)'
  1314. fi
  1315. echo shar: extracting codes.h
  1316. sed 's/^X//' << \SHAR_EOF > codes.h
  1317. X/*
  1318. X * Copyright 1989 Object Design, Inc.
  1319. X * Copyright (c) 1985 Sun Microsystems, Inc.
  1320. X * Copyright (c) 1980 The Regents of the University of California.
  1321. X * Copyright (c) 1976 Board of Trustees of the University of Illinois.
  1322. X * All rights reserved.
  1323. X *
  1324. X * Redistribution and use in source and binary forms are permitted
  1325. X * provided that the above copyright notice and this paragraph are
  1326. X * duplicated in all such forms and that any documentation,
  1327. X * advertising materials, and other materials related to such
  1328. X * distribution and use acknowledge that the software was developed
  1329. X * by the University of California, Berkeley, the University of Illinois,
  1330. X * Urbana, and Sun Microsystems, Inc.  The name of either University
  1331. X * or Sun Microsystems may not be used to endorse or promote products
  1332. X * derived from this software without specific prior written permission.
  1333. X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  1334. X * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  1335. X * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  1336. X *
  1337. X *    @(#)indent_codes.h    5.6 (Berkeley) 9/15/88
  1338. X */
  1339. X
  1340. X#define newline        1
  1341. X#define lparen        2
  1342. X#define rparen        3
  1343. X#define unary_op    4
  1344. X#define binary_op    5
  1345. X#define postop        6
  1346. X#define question    7
  1347. X#define casestmt    8
  1348. X#define colon        9
  1349. X#define semicolon    10
  1350. X#define lbrace        11
  1351. X#define rbrace        12
  1352. X#define ident        13
  1353. X#define comma        14
  1354. X#define comment        15
  1355. X#define swstmt        16
  1356. X#define preesc        17
  1357. X#define form_feed    18
  1358. X#define decl        19
  1359. X#define sp_paren    20
  1360. X#define sp_nparen    21
  1361. X#define ifstmt        22
  1362. X#define whilestmt    23
  1363. X#define forstmt        24
  1364. X#define stmt        25
  1365. X#define stmtl        26
  1366. X#define elselit        27
  1367. X#define dolit        28
  1368. X#define dohead        29
  1369. X#define ifhead        30
  1370. X#define elsehead    31
  1371. X#define period        32
  1372. X
  1373. X#define cc_commnt    33
  1374. X#define class        34
  1375. X#define privpub        35
  1376. SHAR_EOF
  1377. if test 1786 -ne "`wc -c codes.h`"
  1378. then
  1379. echo shar: error transmitting codes.h '(should have been 1786 characters)'
  1380. fi
  1381. echo shar: extracting globals.h
  1382. sed 's/^X//' << \SHAR_EOF > globals.h
  1383. X/*
  1384. X * Copyright 1989 Object Design, Inc.
  1385. X * Copyright (c) 1985 Sun Microsystems, Inc.
  1386. X * Copyright (c) 1980 The Regents of the University of California.
  1387. X * Copyright (c) 1976 Board of Trustees of the University of Illinois.
  1388. X * All rights reserved.
  1389. X *
  1390. X * Redistribution and use in source and binary forms are permitted
  1391. X * provided that the above copyright notice and this paragraph are
  1392. X * duplicated in all such forms and that any documentation,
  1393. X * advertising materials, and other materials related to such
  1394. X * distribution and use acknowledge that the software was developed
  1395. X * by the University of California, Berkeley, the University of Illinois,
  1396. X * Urbana, and Sun Microsystems, Inc.  The name of either University
  1397. X * or Sun Microsystems may not be used to endorse or promote products
  1398. X * derived from this software without specific prior written permission.
  1399. X * THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
  1400. X * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  1401. X * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  1402. X *
  1403. X *    @(#)indent_globs.h    5.7 (Berkeley) 15 sep 88
  1404. X */
  1405. X
  1406. X#include <stdio.h>
  1407. X#include <memory.h>                /* gst: 24 mar 89 */
  1408. X
  1409. X#define BACKSLASH '\\'
  1410. X#define bufsize 1000            /* size of internal buffers */
  1411. X#define inp_bufs 600            /* size of input buffer */
  1412. X#define sc_size 5000            /* size of save_com buffer */
  1413. X#define label_offset 2            /* number of levels a label is placed to left
  1414. X                                   of code */
  1415. X#define cplus_ppp_indent 2        /* spaces to indent public, private, protected
  1416. X                                   in c++ */
  1417. X
  1418. X#define false 0
  1419. X#define true  1
  1420. X
  1421. X
  1422. XFILE *input;                    /* the fid for the input file */
  1423. XFILE *output;                    /* the output file */
  1424. X
  1425. X#ifdef MSDOS
  1426. X#define check_size(name) \
  1427. X    if (e_##name >= l_##name) { \
  1428. X        register nsize = l_##name-s_##name+400; \
  1429. X        name##buf = (char *) realloc(name##buf, nsize); \
  1430. X        e_##name = name##buf + (e_##name-s_##name) + 1; \
  1431. X        l_##name = name##buf + nsize - 5; \
  1432. X        s_##name = name##buf + 1; \
  1433. X    }
  1434. X#else
  1435. X#define check_size(name) \
  1436. X    if (e_/**/name >= l_/**/name) { \
  1437. X        register nsize = l_/**/name-s_/**/name+400; \
  1438. X        name/**/buf = (char *) realloc(name/**/buf, nsize); \
  1439. X        e_/**/name = name/**/buf + (e_/**/name-s_/**/name) + 1; \
  1440. X        l_/**/name = name/**/buf + nsize - 5; \
  1441. X        s_/**/name = name/**/buf + 1; \
  1442. X    }
  1443. X#endif
  1444. X
  1445. Xchar *labbuf;                    /* buffer for label */
  1446. Xchar *s_lab;                    /* start ... */
  1447. Xchar *e_lab;                    /* .. and end of stored label */
  1448. Xchar *l_lab;                    /* limit of label buffer */
  1449. X
  1450. Xchar *codebuf;                    /* buffer for code section */
  1451. Xchar *s_code;                    /* start ... */
  1452. Xchar *e_code;                    /* .. and end of stored code */
  1453. Xchar *l_code;                    /* limit of code section */
  1454. X
  1455. Xchar *combuf;                    /* buffer for comments */
  1456. Xchar *s_com;                    /* start ... */
  1457. Xchar *e_com;                    /* ... and end of stored comments */
  1458. Xchar *l_com;                    /* limit of comment buffer */
  1459. X
  1460. Xchar in_buffer[inp_bufs];        /* input buffer */
  1461. Xchar *buf_ptr;                    /* ptr to next character to be taken from
  1462. X                                   in_buffer */
  1463. Xchar *buf_end;                    /* ptr to first after last char in in_buffer */
  1464. X
  1465. Xchar save_com[sc_size];            /* input text is saved here when looking for
  1466. X                                   the brace after an if, while, etc */
  1467. Xchar *sc_end;                    /* pointer into save_com buffer */
  1468. X
  1469. Xchar *bp_save;                    /* saved value of buf_ptr when taking input
  1470. X                                   from save_com */
  1471. Xchar *be_save;                    /* similarly saved value of buf_end */
  1472. X
  1473. Xchar token[bufsize];            /* the last token scanned */
  1474. X
  1475. Xint cplus;                        /* c++ */
  1476. Xint pointer_as_binop;
  1477. Xint blanklines_after_declarations;
  1478. Xint blanklines_before_blockcomments;
  1479. Xint blanklines_after_procs;
  1480. Xint blanklines_around_conditional_compilation;
  1481. Xint swallow_optional_blanklines;
  1482. Xint n_real_blanklines;
  1483. Xint prefix_blankline_requested;
  1484. Xint postfix_blankline_requested;
  1485. X
  1486. Xint tabsize;
  1487. X
  1488. Xint break_comma;                /* when true and not in parens, break after a
  1489. X                                   comma */
  1490. Xint btype_2;                    /* when true, brace should be on same line as
  1491. X                                   if, while, etc */
  1492. Xint btype_3;                    /* when true, braces are not only on the next
  1493. X                                   line but indented with the enclosed code */
  1494. Xfloat case_ind;                    /* indentation level to be used for a "case n:" */
  1495. Xint code_lines;                    /* count of lines with code */
  1496. Xint had_eof;                    /* set to true when input is exhausted */
  1497. Xint line_no;                    /* the current line number. */
  1498. Xint max_col;                    /* the maximum allowable line length */
  1499. Xint verbose;                    /* when true, non-essential error messages are
  1500. X                                   printed */
  1501. Xint cuddle_else;                /* true if else should cuddle up to '}' */
  1502. Xint star_comment_cont;            /* true iff comment continuation lines should
  1503. X                                   have stars at the beginning of each line. */
  1504. Xint comment_delimiter_on_blankline;
  1505. Xint troff;                        /* true iff were generating troff input */
  1506. Xint procnames_start_line;        /* if true, the names of procedures being
  1507. X                                   defined get placed in column 1 (ie. a
  1508. X                                   newline is placed between the type of the
  1509. X                                   procedure and its name) */
  1510. Xint proc_calls_space;            /* If true, procedure calls look like: foo(bar)
  1511. X                                   rather than foo (bar) */
  1512. Xint parens_space;                /* If true, parens gets spaces inside them */
  1513. Xint format_col1_comments;        /* If comments which start in column 1 are to
  1514. X                                   be magically reformatted (just like comments
  1515. X                                   that begin in later columns) */
  1516. Xint inhibit_formatting;            /* true if INDENT OFF is in effect */
  1517. Xint suppress_blanklines;        /* set iff following blanklines should be
  1518. X                                   suppressed */
  1519. Xint continuation_indent;        /* set to the indentation between the edge of
  1520. X                                   code and continuation lines */
  1521. Xint lineup_to_parens;            /* if true, continued code within parens will
  1522. X                                   be lined up to the open paren */
  1523. Xint Bill_Shannon;                /* true iff a blank should always be inserted
  1524. X                                   after sizeof */
  1525. Xint blanklines_after_declarations_at_proctop;    /* This is vaguely similar to
  1526. X                                                   blanklines_after_decla
  1527. X                                                   rations except that it only
  1528. X                                                   applies to the first set of
  1529. X                                                   declarations in a procedure
  1530. X                                                   (just after the first '{')
  1531. X                                                   and it causes a blank line
  1532. X                                                   to be generated even if
  1533. X                                                   there are no declarations */
  1534. Xint block_comment_max_col;
  1535. Xint extra_expression_indent;    /* True if continuation lines from the
  1536. X                                   expression part of "if(e)", "while(e)",
  1537. X                                   "for(e;e;e)" should be indented an extra tab
  1538. X                                   stop so that they don't conflict with the
  1539. X                                   code that follows */
  1540. X
  1541. X/* -troff font state information */
  1542. X
  1543. Xstruct fstate
  1544. X{
  1545. X    char font[4];
  1546. X    char size;
  1547. X    int allcaps:1;
  1548. X};
  1549. Xchar *chfont();
  1550. X
  1551. Xstruct fstate
  1552. X    keywordf,                    /* keyword font */
  1553. X    stringf,                    /* string font */
  1554. X    boxcomf,                    /* Box comment font */
  1555. X    blkcomf,                    /* Block comment font */
  1556. X    scomf,                        /* Same line comment font */
  1557. X    bodyf;                        /* major body font */
  1558. X
  1559. X
  1560. X#define STACKSIZE 150
  1561. X
  1562. Xstruct parser_state
  1563. X{
  1564. X    int last_token;
  1565. X    struct fstate cfont;        /* Current font */
  1566. X    int p_stack[STACKSIZE];        /* this is the parsers stack */
  1567. X    int il[STACKSIZE];            /* this stack stores indentation levels */
  1568. X    float cstk[STACKSIZE];        /* used to store case stmt indentation levels */
  1569. X    int box_com;                /* set to true when we are in a "boxed"
  1570. X                                   comment. In that case, the first non-blank
  1571. X                                   char should be lined up with the / in /* */
  1572. X    int comment_delta, n_comment_delta;
  1573. X    int cast_mask;                /* indicates which close parens close off casts */
  1574. X    int sizeof_mask;            /* indicates which close parens close off
  1575. X                                   sizeof''s */
  1576. X    int block_init;                /* true iff inside a block initialization */
  1577. X    int block_init_level;        /* The level of brace nesting in an
  1578. X                                   initialization */
  1579. X    int last_nl;                /* this is true if the last thing scanned was a
  1580. X                                   newline */
  1581. X    int in_or_st;                /* Will be true iff there has been a declarator
  1582. X                                   (e.g. int or char) and no left paren since
  1583. X                                   the last semicolon. When true, a '{' is
  1584. X                                   starting a structure definition or an
  1585. X                                   initialization list */
  1586. X    int bl_line;                /* set to 1 by dump_line if the line is blank */
  1587. X    int col_1;                    /* set to true if the last token started in
  1588. X                                   column 1 */
  1589. X    int com_col;                /* this is the column in which the current
  1590. X                                   coment should start */
  1591. X    int com_ind;                /* the column in which comments to the right of
  1592. X                                   code should start */
  1593. X    int com_lines;                /* the number of lines with comments, set by
  1594. X                                   dump_line */
  1595. X    int dec_nest;                /* current nesting level for structure or init */
  1596. X    int decl_com_ind;            /* the column in which comments after
  1597. X                                   declarations should be put */
  1598. X    int decl_on_line;            /* set to true if this line of code has part of
  1599. X                                   a declaration on it */
  1600. X    int i_l_follow;                /* the level to which ind_level should be set
  1601. X                                   after the current line is printed */
  1602. X    int in_decl;                /* set to true when we are in a declaration
  1603. X                                   stmt.  The processing of braces is then
  1604. X                                   slightly different */
  1605. X    int in_stmt;                /* set to 1 while in a stmt */
  1606. X    int ind_level;                /* the current indentation level */
  1607. X    int ind_size;                /* the size of one indentation level */
  1608. X    int ind_stmt;                /* set to 1 if next line should have an extra
  1609. X                                   indentation level because we are in the
  1610. X                                   middle of a stmt */
  1611. X    int last_u_d;                /* set to true after scanning a token which
  1612. X                                   forces a following operator to be unary */
  1613. X    int leave_comma;            /* if true, never break declarations after
  1614. X                                   commas */
  1615. X    int ljust_decl;                /* true if declarations should be left
  1616. X                                   justified */
  1617. X    int out_coms;                /* the number of comments processed, set by
  1618. X                                   pr_comment */
  1619. X    int out_lines;                /* the number of lines written, set by
  1620. X                                   dump_line */
  1621. X    int p_l_follow;                /* used to remember how to indent following
  1622. X                                   statement */
  1623. X    int paren_level;            /* parenthesization level. used to indent
  1624. X                                   within stmts */
  1625. X    short paren_indents[20];    /* column positions of each paren */
  1626. X    int pcase;                    /* set to 1 if the current line label is a
  1627. X                                   case.  It is printed differently from a
  1628. X                                   regular label */
  1629. X    int search_brace;            /* set to true by parse when it is necessary to
  1630. X                                   buffer up all info up to the start of a stmt
  1631. X                                   after an if, while, etc */
  1632. X    int unindent_displace;        /* comments not to the right of code will be
  1633. X                                   placed this many indentation levels to the
  1634. X                                   left of code */
  1635. X    int use_ff;                    /* set to one if the current line should be
  1636. X                                   terminated with a form feed */
  1637. X    int want_blank;                /* set to true when the following token should
  1638. X                                   be prefixed by a blank. (Said prefixing is
  1639. X                                   ignored in some cases.) */
  1640. X    int else_if;                /* True iff else if pairs should be handled
  1641. X                                   specially */
  1642. X    int decl_indent;            /* column to indent declared identifiers to */
  1643. X    int its_a_keyword;
  1644. X    int sizeof_keyword;
  1645. X    int dumped_decl_indent;
  1646. X    float case_indent;            /* The distance to indent case labels from the
  1647. X                                   switch statement */
  1648. X    float case_code_indent;        /* The distance to indent case code from the
  1649. X                                   case label */
  1650. X    int in_parameter_declaration;
  1651. X    int indent_parameters;
  1652. X    int tos;                    /* pointer to top of stack */
  1653. X    char procname[100];            /* The name of the current procedure */
  1654. X    int just_saw_decl;
  1655. X    int cc_comment;                /* saw a C++ comment ("//...") */
  1656. X}   ps;
  1657. X
  1658. Xint ifdef_level;
  1659. Xstruct parser_state state_stack[5];
  1660. Xstruct parser_state match_state[5];
  1661. X
  1662. Xtypedef enum cplus_flag
  1663. X{
  1664. X    c_only,
  1665. X    c_and_cplus,
  1666. X    cplus_only
  1667. X}   cplus_flag;
  1668. X
  1669. X#ifdef ANSIC
  1670. X#include "proto.h"
  1671. X#endif
  1672. SHAR_EOF
  1673. if test 11497 -ne "`wc -c globals.h`"
  1674. then
  1675. echo shar: error transmitting globals.h '(should have been 11497 characters)'
  1676. fi
  1677. echo shar: extracting proto.h
  1678. sed 's/^X//' << \SHAR_EOF > proto.h
  1679. X/*------------------------------------------------------------------------------
  1680. X
  1681. X    proto.h
  1682. X
  1683. X    Function prototypes.  Only used if ANSIC is defined.
  1684. X
  1685. X------------------------------------------------------------------------------*/
  1686. X
  1687. Xvoid set_profile(void);
  1688. Xvoid set_defaults(void);
  1689. Xvoid set_option(register char *);
  1690. Xvoid parsefont(register struct fstate *, char *);
  1691. Xvoid writefdef(struct fstate *, int);
  1692. Xvoid fill_buffer(void);
  1693. Xvoid parse(int);
  1694. Xvoid dump_line(void);
  1695. Xint lexi(void);
  1696. Xvoid diag(int, char *,...);
  1697. Xchar *chfont(struct fstate *, struct fstate *, char *);
  1698. Xvoid pr_comment(void);
  1699. Xint compute_label_target(void);
  1700. Xint compute_code_target(void);
  1701. Xint count_spaces(int, char *);
  1702. Xvoid addkey(char *, int);
  1703. SHAR_EOF
  1704. if test 712 -ne "`wc -c proto.h`"
  1705. then
  1706. echo shar: error transmitting proto.h '(should have been 712 characters)'
  1707. fi
  1708. #    End of shell archive
  1709. exit 0
  1710.