home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume24 / rcs / part09 < prev    next >
Text File  |  1991-03-05  |  56KB  |  2,187 lines

  1. Subject:  v24i009:  RCS source control system, Part09/12
  2. Newsgroups: comp.sources.unix
  3. Approved: rsalz@uunet.UU.NET
  4. X-Checksum-Snefru: b64c24b5 9a5058b9 c2611eb7 14f98d5a
  5.  
  6. Submitted-by: Adam Hammer <hammer@cs.purdue.edu>
  7. Posting-number: Volume 24, Issue 9
  8. Archive-name: rcs/part09
  9.  
  10. #! /bin/sh
  11. # This is a shell archive.  Remove anything before this line, then feed it
  12. # into a shell via "sh file" or similar.  To overwrite existing files,
  13. # type "sh file -c".
  14. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  15. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  16. # Contents:  man/ci.1 man/co.1 src/conf.sh src/rcsgen.c
  17. # Wrapped by rsalz@litchi.bbn.com on Thu Feb 21 14:37:07 1991
  18. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  19. echo If this archive is complete, you will see the following message:
  20. echo '          "shar: End of archive 9 (of 12)."'
  21. if test -f 'man/ci.1' -a "${1}" != "-c" ; then 
  22.   echo shar: Will not clobber existing file \"'man/ci.1'\"
  23. else
  24.   echo shar: Extracting \"'man/ci.1'\" \(10006 characters\)
  25.   sed "s/^X//" >'man/ci.1' <<'END_OF_FILE'
  26. X.de Id
  27. X.ds Rv \\$3
  28. X.ds Dt \\$4
  29. X..
  30. X.Id $Id: ci.1,v 5.4 1990/12/04 05:18:31 eggert Exp $
  31. X.ds r \s-1RCS\s0
  32. X.if n .ds - \%--
  33. X.if t .ds - \(em
  34. X.TH CI 1 \*(Dt GNU
  35. X.SH NAME
  36. Xci \- check in RCS revisions
  37. X.SH SYNOPSIS
  38. X.B ci
  39. X.RI [ options ] " file " .\|.\|.
  40. X.SH DESCRIPTION
  41. X.B ci
  42. Xstores new revisions into \*r files.
  43. XEach file name ending in
  44. X.B ,v
  45. Xis taken to be an \*r file.
  46. XAll others
  47. Xare assumed to be working files containing new revisions.
  48. X.B ci
  49. Xdeposits the contents of each working file
  50. Xinto the corresponding \*r file.
  51. XIf only a working file is given,
  52. X.B ci
  53. Xtries to find the corresponding \*r file in an \*r subdirectory
  54. Xand then in the working file's directory.
  55. XFor more details, see
  56. X.SM "FILE NAMING"
  57. Xbelow.
  58. X.PP
  59. XFor
  60. X.B ci
  61. Xto work, the caller's login must be on the access list,
  62. Xexcept if the access list is empty or the caller is the superuser or the
  63. Xowner of the file.
  64. XTo append a new revision to an existing branch, the tip revision on
  65. Xthat branch must be locked by the caller.  Otherwise, only a
  66. Xnew branch can be created.  This restriction is not enforced
  67. Xfor the owner of the file if non-strict locking is used
  68. X(see
  69. X.BR rcs (1)).
  70. XA lock held by someone else may be broken with the
  71. X.B rcs
  72. Xcommand.
  73. X.PP
  74. XNormally,
  75. X.B ci
  76. Xchecks whether the revision to be deposited is different
  77. Xfrom the preceding one.  If it is not different,
  78. X.B ci
  79. Xaborts the deposit, asking beforehand if possible.
  80. XA deposit can be forced with the
  81. X.B \-f
  82. Xoption.
  83. X.PP
  84. XFor each revision deposited,
  85. X.B ci
  86. Xprompts for a log message.
  87. XThe log message should summarize the change and must be terminated by
  88. Xend-of-file or by a line containing
  89. X.BR \&. "\ by"
  90. Xitself.
  91. XIf several files are checked in
  92. X.B ci
  93. Xasks whether to reuse the
  94. Xprevious log message.
  95. XIf the standard input is not a terminal,
  96. X.B ci
  97. Xsuppresses the prompt
  98. Xand uses the same log message for all files.
  99. XSee also
  100. X.BR \-m .
  101. X.PP
  102. XThe number of the deposited revision can be given by any of the options
  103. X.BR \-f ,
  104. X.BR \-I ,
  105. X.BR \-k ,
  106. X.BR \-l ,
  107. X.BR \-q ,
  108. X.BR \-r ,
  109. Xor
  110. X.BR \-u .
  111. X.PP
  112. XIf the \*r file does not exist,
  113. X.B ci
  114. Xcreates it and
  115. Xdeposits the contents of the working file as the initial revision
  116. X(default number:
  117. X.BR 1.1 ).
  118. XThe access list is initialized to empty.
  119. XInstead of the log message,
  120. X.B ci
  121. Xrequests descriptive text (see
  122. X.B \-t
  123. Xbelow).
  124. X.SH OPTIONS
  125. X.TP
  126. X.BR \-r [\f2rev\fP]
  127. Xassigns the revision number
  128. X.I rev
  129. Xto the checked-in revision, releases the corresponding lock, and
  130. Xdeletes the working file.  This is the default.
  131. X.I rev
  132. Xmay be symbolic, numeric, or mixed.
  133. X.RS
  134. X.PP
  135. XIf
  136. X.I rev
  137. Xis a revision number, it must be higher than the latest
  138. Xone on the branch to which
  139. X.I rev
  140. Xbelongs, or must start a new branch.
  141. X.PP
  142. XIf
  143. X.I rev
  144. Xis a branch rather than a revision number,
  145. Xthe new revision is appended to that branch.  The level number is obtained
  146. Xby incrementing the tip revision number of that branch.
  147. XIf
  148. X.I rev
  149. Xindicates a non-existing branch,
  150. Xthat branch is created with the initial revision numbered
  151. X.IB rev .1\f1.\fP
  152. X.br
  153. X.ne 8
  154. X.PP
  155. XIf
  156. X.I rev
  157. Xis omitted,
  158. X.B ci
  159. Xtries to derive the new revision number from
  160. Xthe caller's last lock.  If the caller has locked the tip revision of a branch,
  161. Xthe new revision is appended to that branch.
  162. XThe new revision number is obtained
  163. Xby incrementing the tip revision number.
  164. XIf the caller locked a non-tip revision, a new branch is started at
  165. Xthat revision by incrementing the highest branch number at that revision.
  166. XThe default initial branch and level numbers are
  167. X.BR 1 .
  168. X.PP
  169. XIf
  170. X.I rev
  171. Xis omitted and the caller has no lock, but owns
  172. Xthe file and locking
  173. Xis not set to
  174. X.IR strict ,
  175. Xthen the revision is appended to the
  176. Xdefault branch (normally the trunk; see the
  177. X.B \-b
  178. Xoption of
  179. X.BR rcs (1)).
  180. X.PP
  181. XException: On the trunk, revisions can be appended to the end, but
  182. Xnot inserted.
  183. X.RE
  184. X.TP
  185. X.BR \-f [\f2rev\fP]
  186. Xforces a deposit; the new revision is deposited even it is not different
  187. Xfrom the preceding one.
  188. X.TP
  189. X.BR \-k [\f2rev\fP]
  190. Xsearches the working file for keyword values to determine its revision number,
  191. Xcreation date, state, and author (see
  192. X.BR co (1)),
  193. Xand assigns these
  194. Xvalues to the deposited revision, rather than computing them locally.
  195. XIt also generates a default login message noting the login of the caller
  196. Xand the actual checkin date.
  197. XThis option is useful for software distribution.  A revision that is sent to
  198. Xseveral sites should be checked in with the
  199. X.B \-k
  200. Xoption at these sites to
  201. Xpreserve the original number, date, author, and state.
  202. XThe extracted keyword values and the default log message may be overridden
  203. Xwith the options
  204. X.BR \-d ,
  205. X.BR \-m ,
  206. X.BR \-s ,
  207. X.BR \-w ,
  208. Xand any option that carries a revision number.
  209. X.TP
  210. X.BR \-l [\f2rev\fP]
  211. Xworks like
  212. X.BR \-r ,
  213. Xexcept it performs an additional
  214. X.B "co\ \-l"
  215. Xfor the
  216. Xdeposited revision.  Thus, the deposited revision is immediately
  217. Xchecked out again and locked.
  218. XThis is useful for saving a revision although one wants to continue
  219. Xediting it after the checkin.
  220. X.TP
  221. X.BR \-u [\f2rev\fP]
  222. Xworks like
  223. X.BR \-l ,
  224. Xexcept that the deposited revision is not locked.
  225. XThis lets one read the working file
  226. Ximmediately after checkin.
  227. X.TP
  228. X.BR \-q [\f2rev\fP]
  229. Xquiet mode; diagnostic output is not printed.
  230. XA revision that is not different from the preceding one is not deposited,
  231. Xunless
  232. X.B \-f
  233. Xis given.
  234. X.TP
  235. X.BR \-I [\f2rev\fP]
  236. Xinteractive mode;
  237. Xthe user is prompted and questioned
  238. Xeven if the standard input is not a terminal.
  239. X.TP
  240. X.BR \-d "[\f2date\fP]"
  241. Xuses
  242. X.I date
  243. Xfor the checkin date and time.
  244. XThe
  245. X.I date
  246. Xis specified in free format as explained in
  247. X.BR co (1).
  248. XThis is useful for lying about the checkin date, and for
  249. X.B \-k
  250. Xif no date is available.
  251. XIf
  252. X.I date
  253. Xis empty, the working file's time of last modification is used.
  254. X.TP
  255. X.BI \-m "msg"
  256. Xuses the string
  257. X.I msg
  258. Xas the log message for all revisions checked in.
  259. X.TP
  260. X.BI \-n "name"
  261. Xassigns the symbolic name
  262. X.I name
  263. Xto the number of the checked-in revision.
  264. X.B ci
  265. Xprints an error message if
  266. X.I name
  267. Xis already assigned to another
  268. Xnumber.
  269. X.TP
  270. X.BI \-N "name"
  271. Xsame as
  272. X.BR \-n ,
  273. Xexcept that it overrides a previous assignment of
  274. X.IR name .
  275. X.TP
  276. X.BI \-s "state"
  277. Xsets the state of the checked-in revision to the identifier
  278. X.IR state .
  279. XThe default state is
  280. X.BR Exp .
  281. X.TP
  282. X.BI \-t file
  283. Xwrites descriptive text from the contents of the named
  284. X.I file
  285. Xinto the \*r file,
  286. Xdeleting the existing text.
  287. XThe
  288. X.I file
  289. Xname may not begin with
  290. X.BR \- .
  291. X.TP
  292. X.BI \-t\- string
  293. XWrite descriptive text from the
  294. X.I string
  295. Xinto the \*r file, deleting the existing text.
  296. X.RS
  297. X.PP
  298. XThe
  299. X.B \-t
  300. Xoption, in both its forms, has effect only during an initial checkin;
  301. Xit is silently ignored otherwise.
  302. X.PP
  303. XDuring the initial checkin, if
  304. X.B \-t
  305. Xis not given,
  306. X.B ci
  307. Xobtains the text from standard input,
  308. Xterminated by end-of-file or by a line containing
  309. X.BR \&. "\ by"
  310. Xitself.
  311. XThe user is prompted for the text if interaction is possible; see
  312. X.BR \-I .
  313. X.PP
  314. XFor backward compatibility with older versions of \*r, a bare
  315. X.B \-t
  316. Xoption is ignored.
  317. X.RE
  318. X.TP
  319. X.BI \-w "login"
  320. Xuses
  321. X.I login
  322. Xfor the author field of the deposited revision.
  323. XUseful for lying about the author, and for
  324. X.B \-k
  325. Xif no author is available.
  326. X.TP
  327. X.BI \-V n
  328. XEmulate \*r version
  329. X.IR n .
  330. XSee
  331. X.BR co (1)
  332. Xfor details.
  333. X.SH "FILE NAMING"
  334. XPairs of \*r files and working files may be specified in three ways
  335. X(see also the
  336. Xexample section of
  337. X.BR co (1)).
  338. X.PP
  339. X1) Both the \*r file and the working file are given.  The \*r file name is of
  340. Xthe form
  341. X.IB path1 / workfile ,v
  342. Xand the working file name is of the form
  343. X.IB path2 / workfile
  344. Xwhere
  345. X.IB path1 /
  346. Xand
  347. X.IB path2 /
  348. Xare (possibly different or empty) paths and
  349. X.I workfile
  350. Xis a file name.
  351. X.PP
  352. X2) Only the \*r file is given.  Then the working file is created in the current
  353. Xdirectory and its name is derived from the name of the \*r file
  354. Xby removing
  355. X.IB path1 /
  356. Xand the suffix
  357. X.BR ,v .
  358. X.PP
  359. X3) Only the working file is given.
  360. XThen
  361. X.B ci
  362. Xlooks for an \*r file of the form
  363. X.IB path2 /RCS/ workfile ,v
  364. Xor
  365. X.IB path2 / workfile ,v
  366. X(in this order).
  367. X.PP
  368. XIf the \*r file is specified without a path in 1) and 2), then
  369. X.B ci
  370. Xlooks for the \*r file first in the directory
  371. X.B ./RCS
  372. Xand then in the current
  373. Xdirectory.
  374. X.SH "FILE MODES"
  375. XAn \*r file created by
  376. X.B ci
  377. Xinherits the read and execute permissions
  378. Xfrom the working file.  If the \*r file exists already,
  379. X.B ci
  380. Xpreserves its read and execute permissions.
  381. X.B ci
  382. Xalways turns off all write permissions of \*r files.
  383. X.SH FILES
  384. XSeveral temporary files may be created.
  385. XA semaphore file is created in the directory containing the \*r file.
  386. XThe effective user+group must be able to read the \*r file
  387. Xand to search and write the directory containing the \*r file.
  388. XNormally, the real user+group must be able to read the working file
  389. Xand to search and write the directory containing the working file;
  390. Xhowever, some older hosts that do not conform to Posix 1003.1-1990
  391. Xcannot easily switch between real and effective ids,
  392. Xso on these hosts the effective user+group is used for all accesses.
  393. XThe effective user+group is the same as the real user+group
  394. Xunless your copy of \*r has setuid or setgid privileges.
  395. XThese privileges yield extra security if \*r files are protected so that
  396. Xonly the effective user+group can write \*r directories.
  397. XFurther protection can be achieved by granting access
  398. Xonly to the effective user+group.
  399. X.PP
  400. X.B ci
  401. Xnever changes an \*r or working file;
  402. Xinstead, it unlinks the file and creates a new one.
  403. XThis strategy breaks hard links to such files,
  404. Xbut does not affect symbolic links.
  405. X.SH DIAGNOSTICS
  406. XFor each revision,
  407. X.B ci
  408. Xprints the \*r file, the working file, and the number
  409. Xof both the deposited and the preceding revision.
  410. XThe exit status is zero if and only if all operations were successful.
  411. X.SH IDENTIFICATION
  412. XAuthor: Walter F. Tichy.
  413. X.br
  414. XRevision Number: \*(Rv; Release Date: \*(Dt.
  415. X.br
  416. XCopyright \(co 1982, 1988, 1989 by Walter F. Tichy.
  417. X.br
  418. XCopyright \(co 1990 by Paul Eggert.
  419. X.SH "SEE ALSO"
  420. Xco(1), ident(1), rcs(1), rcsdiff(1), rcsintro(1), rcsmerge(1), rlog(1),
  421. Xrcsfile(5)
  422. X.br
  423. XWalter F. Tichy,
  424. X\*r\*-A System for Version Control,
  425. X.I "Software\*-Practice & Experience"
  426. X.BR 15 ,
  427. X7 (July 1985), 637-654.
  428. END_OF_FILE
  429.   if test 10006 -ne `wc -c <'man/ci.1'`; then
  430.     echo shar: \"'man/ci.1'\" unpacked with wrong size!
  431.   fi
  432.   # end of 'man/ci.1'
  433. fi
  434. if test -f 'man/co.1' -a "${1}" != "-c" ; then 
  435.   echo shar: Will not clobber existing file \"'man/co.1'\"
  436. else
  437.   echo shar: Extracting \"'man/co.1'\" \(14638 characters\)
  438.   sed "s/^X//" >'man/co.1' <<'END_OF_FILE'
  439. X.de Id
  440. X.ds Rv \\$3
  441. X.ds Dt \\$4
  442. X..
  443. X.Id $Id: co.1,v 5.4 1990/12/04 05:18:32 eggert Exp $
  444. X.ds g \s-1GMT\s0
  445. X.ds r \s-1RCS\s0
  446. X.if n .ds - \%--
  447. X.if t .ds - \(em
  448. X.TH CO 1 \*(Dt GNU
  449. X.SH NAME
  450. Xco \- check out RCS revisions
  451. X.SH SYNOPSIS
  452. X.B co
  453. X.RI [ options ] " file " .\|.\|.
  454. X.SH DESCRIPTION
  455. X.B co
  456. Xretrieves a revision from each \*r file and stores it into
  457. Xthe corresponding working file.
  458. XEach file name ending in
  459. X.B ,v
  460. Xis taken to be an \*r file;
  461. Xall other files are assumed to be working files.
  462. XIf only a working file is given,
  463. X.B co
  464. Xtries to find the corresponding \*r file in the directory
  465. X.B ./RCS
  466. Xand then in the current directory.
  467. XFor more details, see
  468. X.SM "FILE NAMING"
  469. Xbelow.
  470. X.PP
  471. XRevisions of an \*r file may be checked out locked or unlocked.  Locking a
  472. Xrevision prevents overlapping updates.  A revision checked out for reading or
  473. Xprocessing (e.g., compiling) need not be locked.  A revision checked out
  474. Xfor editing and later checkin must normally be locked.  Checkout with locking
  475. Xfails if the revision to be checked out is currently locked by another user.
  476. X(A lock may be broken with
  477. X.BR rcs "(1).)\ \&"
  478. XCheckout with locking also requires the caller to be on the access list of
  479. Xthe \*r file, unless he is the owner of the
  480. Xfile or the superuser, or the access list is empty.
  481. XCheckout without locking is not subject to accesslist restrictions, and is
  482. Xnot affected by the presence of locks.
  483. X.PP
  484. XA revision is selected by options for revision or branch number,
  485. Xcheckin date/time, author, or state.
  486. XWhen the selection options
  487. Xare applied in combination,
  488. X.B co
  489. Xretrieves the latest revision
  490. Xthat satisfies all of them.
  491. XIf none of the selection options
  492. Xis specified,
  493. X.B co
  494. Xretrieves the latest revision
  495. Xon the default branch (normally the trunk, see the
  496. X.B \-b
  497. Xoption of
  498. X.BR rcs (1)).
  499. XA revision or branch number may be attached
  500. Xto any of the options
  501. X.BR \-f ,
  502. X.BR \-I ,
  503. X.BR \-l ,
  504. X.BR \-p ,
  505. X.BR \-q ,
  506. X.BR \-r ,
  507. Xor
  508. X.BR \-u .
  509. XThe options
  510. X.B \-d
  511. X(date),
  512. X.B \-s
  513. X(state), and
  514. X.B \-w
  515. X(author)
  516. Xretrieve from a single branch, the
  517. X.I selected
  518. Xbranch,
  519. Xwhich is either specified by one of
  520. X.BR \-f,
  521. X\&.\|.\|.,
  522. X.BR \-u ,
  523. Xor the default branch.
  524. X.PP
  525. XA
  526. X.B co
  527. Xcommand applied to an \*r
  528. Xfile with no revisions creates a zero-length working file.
  529. X.B co
  530. Xalways performs keyword substitution (see below).
  531. X.SH OPTIONS
  532. X.TP
  533. X.BR \-r [\f2rev\fP]
  534. Xretrieves the latest revision whose number is less than or equal to
  535. X.I rev.
  536. XIf
  537. X.I rev
  538. Xindicates a branch rather than a revision,
  539. Xthe latest revision on that branch is retrieved.
  540. XIf
  541. X.I rev
  542. Xis omitted, the latest revision on the default branch
  543. X(see the
  544. X.B \-b
  545. Xoption of
  546. X.BR rcs (1))
  547. Xis retrieved.
  548. XA revision is composed of one or more numeric or symbolic fields
  549. Xseparated by periods.  The numeric equivalent of a symbolic field
  550. Xis specified with the
  551. X.B \-n
  552. Xoption of the commands
  553. X.BR ci (1)
  554. Xand
  555. X.BR rcs (1).
  556. X.TP
  557. X.BR \-l [\f2rev\fP]
  558. Xsame as
  559. X.BR \-r ,
  560. Xexcept that it also locks the retrieved revision for
  561. Xthe caller.
  562. X.TP
  563. X.BR \-u [\f2rev\fP]
  564. Xsame as
  565. X.BR \-r ,
  566. Xexcept that it unlocks the retrieved revision if it was
  567. Xlocked by the caller.  If
  568. X.I rev
  569. Xis omitted,
  570. X.B \-u
  571. Xretrieves the latest revision locked by the caller; if no such lock exists,
  572. Xit retrieves the latest revision on the default branch.
  573. X.TP
  574. X.BR \-f [\f2rev\fP]
  575. Xforces the overwriting of the working file;
  576. Xuseful in connection with
  577. X.BR \-q .
  578. XSee also
  579. X.SM "FILE MODES"
  580. Xbelow.
  581. X.TP
  582. X.B \-kkv
  583. XGenerate keyword strings using the default form, e.g.\&
  584. X.B "$\&Revision: \*(Rv $"
  585. Xfor the
  586. X.B Revision
  587. Xkeyword.
  588. XA locker's name is inserted in the value of the
  589. X.BR Header ,
  590. X.BR Id ,
  591. Xand
  592. X.B Locker
  593. Xkeyword strings
  594. Xonly as a file is being locked,
  595. Xi.e. by
  596. X.B "ci\ \-l"
  597. Xand
  598. X.BR "co\ \-l".
  599. XThis is the default.
  600. X.TP
  601. X.B \-kkvl
  602. XLike
  603. X.BR \-kkv ,
  604. Xexcept that a locker's name is always inserted
  605. Xif the given revision is currently locked.
  606. X.TP
  607. X.BR \-kk
  608. XGenerate only keyword names in keyword strings; omit their values.
  609. XSee
  610. X.SM "KEYWORD SUBSTITUTION"
  611. Xbelow.
  612. XFor example, for the
  613. X.B Revision
  614. Xkeyword, generate the string
  615. X.B $\&Revision$
  616. Xinstead of
  617. X.BR "$\&Revision: \*(Rv $".
  618. XThis option is useful to ignore differences due to keyword substitution
  619. Xwhen comparing different revisions of a file.
  620. X.TP
  621. X.BR \-ko
  622. XGenerate the old keyword string,
  623. Xpresent in the working file just before it was checked in.
  624. XFor example, for the
  625. X.B Revision
  626. Xkeyword, generate the string
  627. X.B "$\&Revision: 1.1 $"
  628. Xinstead of
  629. X.B "$\&Revision: \*(Rv $"
  630. Xif that is how the string appeared when the file was checked in.
  631. XThis can be useful for binary file formats
  632. Xthat cannot tolerate any changes to substrings
  633. Xthat happen to take the form of keyword strings.
  634. X.TP
  635. X.BR \-kv
  636. XGenerate only keyword values for keyword strings.
  637. XFor example, for the
  638. X.B Revision
  639. Xkeyword, generate the string
  640. X.B \*(Rv
  641. Xinstead of
  642. X.BR "$\&Revision: \*(Rv $".
  643. XThis can help generate files in programming languages where it is hard to
  644. Xstrip keyword delimiters like
  645. X.B "$\&Revision:\ $"
  646. Xfrom a string.
  647. XHowever, further keyword substitution cannot be performed once the
  648. Xkeyword names are removed, so this option should be used with care.
  649. XBecause of this danger of losing keywords,
  650. Xthis option cannot be combined with
  651. X.BR \-l ,
  652. Xand the owner write permission of the working file is turned off;
  653. Xto edit the file later, check it out again without
  654. X.BR \-kv .
  655. X.TP
  656. X.BR \-p [\f2rev\fP]
  657. Xprints the retrieved revision on the standard output rather than storing it
  658. Xin the working file.
  659. XThis option is useful when
  660. X.B co
  661. Xis part of a pipe.
  662. X.TP
  663. X.BR \-q [\f2rev\fP]
  664. Xquiet mode; diagnostics are not printed.
  665. X.TP
  666. X.BR \-I [\f2rev\fP]
  667. Xinteractive mode;
  668. Xthe user is prompted and questioned
  669. Xeven if the standard input is not a terminal.
  670. X.TP
  671. X.BI \-d date
  672. Xretrieves the latest revision on the selected branch whose checkin date/time is
  673. Xless than or equal to
  674. X.I date.
  675. XThe date and time may be given in free format.
  676. XThe time zone
  677. X.B LT
  678. Xstands for local time;
  679. Xother common time zone names are understood.
  680. XFor example, the following
  681. X.IR date s
  682. Xare equivalent
  683. Xif local time is January 11, 1990, 8pm Pacific Standard Time
  684. X(eight hours west of \*g):
  685. X.RS
  686. X.LP
  687. X.RS
  688. X.nf
  689. X.ta \w'\f3Thu, 11 Jan 1990 20:00:00 \-0800\fP  'u
  690. X.ne 9
  691. X\f38:00 pm lt\fP
  692. X\f34:00 AM, Jan. 12, 1990\fP    note: default is \*g
  693. X\f31990/01/12 04:00:00\fP    \*r date format
  694. X\f3Thu Jan 11 20:00:00 1990 LT\fP    output of \f3ctime\fP(3) + \f3LT\fP
  695. X\f3Thu Jan 11 20:00:00 PST 1990\fP    output of \f3date\fP(1)
  696. X\f3Fri Jan 12 04:00:00 GMT 1990\fP
  697. X\f3Thu, 11 Jan 1990 20:00:00 \-0800\fP
  698. X\f3Fri-JST, 1990, 1pm Jan 12\fP
  699. X\f312-January-1990, 04:00-WET\fP
  700. X.ta 4n +4n +4n +4n
  701. X.fi
  702. X.RE
  703. X.LP
  704. XMost fields in the date and time may be defaulted.
  705. XThe default time zone is \*g.
  706. XThe other defaults are determined in the order year, month, day,
  707. Xhour, minute, and second (most to least significant).  At least one of these
  708. Xfields must be provided.  For omitted fields that are of higher significance
  709. Xthan the highest provided field, the time zone's current values are assumed.
  710. XFor all other omitted fields,
  711. Xthe lowest possible values are assumed.
  712. XFor example, the date
  713. X.B "20, 10:30"
  714. Xdefaults to
  715. X10:30:00 \*g of the 20th of the \*g time zone's current month and year.
  716. XThe date/time must be quoted if it contains spaces.
  717. X.RE
  718. X.TP
  719. X.BI \-s state
  720. Xretrieves the latest revision on the selected branch whose state is set to
  721. X.I state.
  722. X.TP
  723. X.BR \-w [\f2login\fP]
  724. Xretrieves the latest revision on the selected branch which was checked in
  725. Xby the user with login name
  726. X.I login.
  727. XIf the argument
  728. X.I login
  729. Xis
  730. Xomitted, the caller's login is assumed.
  731. X.TP
  732. X.BI \-j joinlist
  733. Xgenerates a new revision which is the join of the revisions on
  734. X.I joinlist.
  735. XThis option is largely obsoleted by
  736. X.BR rcsmerge (1)
  737. Xbut is retained for backwards compatibility.
  738. X.RS
  739. X.PP
  740. XThe
  741. X.I joinlist
  742. Xis a comma-separated list of pairs of the form
  743. X.IB rev2 : rev3,
  744. Xwhere
  745. X.I rev2
  746. Xand
  747. X.I rev3
  748. Xare (symbolic or numeric)
  749. Xrevision numbers.
  750. XFor the initial such pair,
  751. X.I rev1
  752. Xdenotes the revision selected
  753. Xby the above options
  754. X.BR \-f,
  755. X\&.\|.\|.,
  756. X.BR \-w .
  757. XFor all other pairs,
  758. X.I rev1
  759. Xdenotes the revision generated by the previous pair.
  760. X(Thus, the output
  761. Xof one join becomes the input to the next.)
  762. X.PP
  763. XFor each pair,
  764. X.B co
  765. Xjoins revisions
  766. X.I rev1
  767. Xand
  768. X.I rev3
  769. Xwith respect to
  770. X.I rev2.
  771. XThis means that all changes that transform
  772. X.I rev2
  773. Xinto
  774. X.I rev1
  775. Xare applied to a copy of
  776. X.I rev3.
  777. XThis is particularly useful if
  778. X.I rev1
  779. Xand
  780. X.I rev3
  781. Xare the ends of two branches that have
  782. X.I rev2
  783. Xas a common ancestor.  If
  784. X.IR rev1 < rev2 < rev3
  785. Xon the same branch,
  786. Xjoining generates a new revision which is like
  787. X.I rev3,
  788. Xbut with all changes that lead from
  789. X.I rev1
  790. Xto
  791. X.I rev2
  792. Xundone.
  793. XIf changes from
  794. X.I rev2
  795. Xto
  796. X.I rev1
  797. Xoverlap with changes from
  798. X.I rev2
  799. Xto
  800. X.I rev3,
  801. X.B co
  802. Xprints a warning and includes the
  803. Xoverlapping sections, delimited by the lines
  804. X.BI <<<<<<< "\ rev1,"
  805. X.BR ======= ,
  806. Xand
  807. X.BI >>>>>>> "\ rev3."
  808. X.PP
  809. XFor the initial pair,
  810. X.I rev2
  811. Xmay be omitted.  The default is the common
  812. Xancestor.
  813. XIf any of the arguments indicate branches, the latest revisions
  814. Xon those branches are assumed.
  815. XThe options
  816. X.B \-l
  817. Xand
  818. X.B \-u
  819. Xlock or unlock
  820. X.I rev1.
  821. X.RE
  822. X.TP
  823. X.BI \-V n
  824. XEmulate \*r version
  825. X.I n,
  826. Xwhere
  827. X.I n
  828. Xmay be
  829. X.BR 3 ,
  830. X.BR 4 ,
  831. Xor
  832. X.BR 5 .
  833. XThis may be useful when interchanging \*r files with others who are
  834. Xrunning older versions of \*r.
  835. XTo see which version of \*r your correspondents are running, have them invoke
  836. X.B rlog
  837. Xon an \*r file;
  838. Xif none of the first few lines of output contain the string
  839. X.B branch:
  840. Xit is version 3;
  841. Xif the dates' years have just two digits, it is version 4;
  842. Xotherwise, it is version 5.
  843. XAn \*r file generated while emulating version 3 will lose its default branch.
  844. XAn \*r revision generated while emulating version 4 or earlier will have
  845. Xa timestamp that is off by up to 13 hours.
  846. XA revision extracted while emulating version 4 or earlier will contain
  847. Xdates of the form
  848. X.IB yy / mm / dd
  849. Xinstead of
  850. X.IB yyyy / mm / dd
  851. Xand may also contain different white space in the substitution for
  852. X.BR $\&Log$ .
  853. X.SH "KEYWORD SUBSTITUTION"
  854. XStrings of the form
  855. X.BI $ keyword $
  856. Xand
  857. X.BI $ keyword : .\|.\|. $
  858. Xembedded in
  859. Xthe text are replaced
  860. Xwith strings of the form
  861. X.BI $ keyword : value $
  862. Xwhere
  863. X.I keyword
  864. Xand
  865. X.I value
  866. Xare pairs listed below.
  867. XKeywords may be embedded in literal strings
  868. Xor comments to identify a revision.
  869. X.PP
  870. XInitially, the user enters strings of the form
  871. X.BI $ keyword $ .
  872. XOn checkout,
  873. X.B co
  874. Xreplaces these strings with strings of the form
  875. X.BI $ keyword : value $ .
  876. XIf a revision containing strings of the latter form
  877. Xis checked back in, the value fields will be replaced during the next
  878. Xcheckout.
  879. XThus, the keyword values are automatically updated on checkout.
  880. XThis automatic substitution can be modified by the
  881. X.B \-k
  882. Xoptions.
  883. X.PP
  884. XKeywords and their corresponding values:
  885. X.TP
  886. X.B $\&Author$
  887. XThe login name of the user who checked in the revision.
  888. X.TP
  889. X.B $\&Date$
  890. XThe date and time (\*g) the revision was checked in.
  891. X.TP
  892. X.B $\&Header$
  893. XA standard header containing the full pathname of the \*r file, the
  894. Xrevision number, the date (\*g), the author, the state,
  895. Xand the locker (if locked).
  896. X.TP
  897. X.B $\&Id$
  898. XSame as
  899. X.BR $\&Header$ ,
  900. Xexcept that the \*r file name is without a path.
  901. X.TP
  902. X.B $\&Locker$
  903. XThe login name of the user who locked the revision (empty if not locked).
  904. X.TP
  905. X.B $\&Log$
  906. XThe log message supplied during checkin, preceded by a header
  907. Xcontaining the \*r file name, the revision number, the author, and the date
  908. X(\*g).
  909. XExisting log messages are
  910. X.I not
  911. Xreplaced.
  912. XInstead, the new log message is inserted after
  913. X.BR $\&Log: .\|.\|. $ .
  914. XThis is useful for
  915. Xaccumulating a complete change log in a source file.
  916. X.TP
  917. X.B $\&RCSfile$
  918. XThe name of the \*r file without a path.
  919. X.TP
  920. X.B $\&Revision$
  921. XThe revision number assigned to the revision.
  922. X.TP
  923. X.B $\&Source$
  924. XThe full pathname of the \*r file.
  925. X.TP
  926. X.B $\&State$
  927. XThe state assigned to the revision with the
  928. X.B \-s
  929. Xoption of
  930. X.BR rcs (1)
  931. Xor
  932. X.BR ci (1).
  933. X.SH "FILE NAMING"
  934. XPairs of \*r files and working files may be specified in three ways
  935. X(see also the
  936. Xexample section).
  937. X.PP
  938. X1) Both the \*r file and the working file are given.  The \*r file name is of
  939. Xthe form
  940. X.IB path1 / workfile ,v
  941. Xand the working file name is of the form
  942. X.IB path2 / workfile
  943. Xwhere
  944. X.IB path1 /
  945. Xand
  946. X.IB path2 /
  947. Xare (possibly different or empty) paths and
  948. X.I workfile
  949. Xis a file name.
  950. X.PP
  951. X2) Only the \*r file is given.  Then the working file is created in the current
  952. Xdirectory and its name is derived from the name of the \*r file
  953. Xby removing
  954. X.IB path1 /
  955. Xand the suffix
  956. X.BR ,v .
  957. X.PP
  958. X3) Only the working file is given.
  959. XThen
  960. X.B co
  961. Xlooks for an \*r file of the form
  962. X.IB path2 /RCS/ workfile ,v
  963. Xor
  964. X.IB path2 / workfile ,v
  965. X(in this order).
  966. X.PP
  967. XIf the \*r file is specified without a path in 1) and 2), then
  968. X.B co
  969. Xlooks for the \*r file first in the directory
  970. X.B ./RCS
  971. Xand then in the current
  972. Xdirectory.
  973. X.SH EXAMPLES
  974. XSuppose the current directory contains a subdirectory
  975. X.B RCS
  976. Xwith an \*r file
  977. X.BR io.c,v .
  978. XThen all of the following commands retrieve the latest
  979. Xrevision from
  980. X.B RCS/io.c,v
  981. Xand store it into
  982. X.BR io.c .
  983. X.LP
  984. X.RS
  985. X.nf
  986. X.ft 3
  987. Xco  io.c;    co  RCS/io.c,v;   co  io.c,v;
  988. Xco  io.c  RCS/io.c,v;    co  io.c  io.c,v;
  989. Xco  RCS/io.c,v  io.c;    co  io.c,v  io.c;
  990. X.ft
  991. X.fi
  992. X.RE
  993. X.SH "FILE MODES"
  994. XThe working file inherits the read and execute permissions from the \*r
  995. Xfile.  In addition, the owner write permission is turned on, unless
  996. X.B \-kv
  997. Xis set or the file
  998. Xis checked out unlocked and locking is set to strict (see
  999. X.BR rcs (1)).
  1000. X.PP
  1001. XIf a file with the name of the working file exists already and has write
  1002. Xpermission,
  1003. X.B co
  1004. Xaborts the checkout,
  1005. Xasking beforehand if possible.
  1006. XIf the existing working file is
  1007. Xnot writable or
  1008. X.B \-f
  1009. Xis given, the working file is deleted without asking.
  1010. X.SH FILES
  1011. X.B co
  1012. Xaccesses files much as
  1013. X.BR ci (1)
  1014. Xdoes, except that it does not need to read the working file.
  1015. X.SH DIAGNOSTICS
  1016. XThe \*r file name, the working file name,
  1017. Xand the revision number retrieved are
  1018. Xwritten to the diagnostic output.
  1019. XThe exit status is zero if and only if all operations were successful.
  1020. X.SH IDENTIFICATION
  1021. XAuthor: Walter F. Tichy.
  1022. X.br
  1023. XRevision Number: \*(Rv; Release Date: \*(Dt.
  1024. X.br
  1025. XCopyright \(co 1982, 1988, 1989 by Walter F. Tichy.
  1026. X.br
  1027. XCopyright \(co 1990 by Paul Eggert.
  1028. X.SH "SEE ALSO"
  1029. Xci(1), ctime(3), date(1), ident(1),
  1030. Xrcs(1), rcsdiff(1), rcsintro(1), rcsmerge(1), rlog(1),
  1031. Xrcsfile(5)
  1032. X.br
  1033. XWalter F. Tichy,
  1034. X\*r\*-A System for Version Control,
  1035. X.I "Software\*-Practice & Experience"
  1036. X.BR 15 ,
  1037. X7 (July 1985), 637-654.
  1038. X.SH LIMITS
  1039. XLinks to the \*r and working files are not preserved.
  1040. X.PP
  1041. XThere is no way to selectively suppress the expansion of keywords, except
  1042. Xby writing them differently.  In nroff and troff, this is done by embedding the
  1043. Xnull-character
  1044. X.B \e&
  1045. Xinto the keyword.
  1046. X.SH BUGS
  1047. XThe
  1048. X.B \-d
  1049. Xoption sometimes gets confused, and accepts no date before 1970.
  1050. END_OF_FILE
  1051.   if test 14638 -ne `wc -c <'man/co.1'`; then
  1052.     echo shar: \"'man/co.1'\" unpacked with wrong size!
  1053.   fi
  1054.   # end of 'man/co.1'
  1055. fi
  1056. if test -f 'src/conf.sh' -a "${1}" != "-c" ; then 
  1057.   echo shar: Will not clobber existing file \"'src/conf.sh'\"
  1058. else
  1059.   echo shar: Extracting \"'src/conf.sh'\" \(14859 characters\)
  1060.   sed "s/^X//" >'src/conf.sh' <<'END_OF_FILE'
  1061. X#!/bin/sh
  1062. X# Output RCS compile-time configuration.
  1063. XId='$Id: conf.sh,v 5.6 1990/11/01 05:03:28 eggert Exp $'
  1064. X#    Copyright 1990 by Paul Eggert
  1065. X#    Distributed under license by the Free Software Foundation, Inc.
  1066. X
  1067. X# This file is part of RCS.
  1068. X#
  1069. X# RCS is free software; you can redistribute it and/or modify
  1070. X# it under the terms of the GNU General Public License as published by
  1071. X# the Free Software Foundation; either version 1, or (at your option)
  1072. X# any later version.
  1073. X#
  1074. X# RCS is distributed in the hope that it will be useful,
  1075. X# but WITHOUT ANY WARRANTY; without even the implied warranty of
  1076. X# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1077. X# GNU General Public License for more details.
  1078. X#
  1079. X# You should have received a copy of the GNU General Public License
  1080. X# along with RCS; see the file COPYING.  If not, write to
  1081. X# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  1082. X#
  1083. X# Report problems and direct all questions to:
  1084. X#
  1085. X#     rcs-bugs@cs.purdue.edu
  1086. X
  1087. X
  1088. X# Direct standard output to "a.h"; later parts of this procedure need it.
  1089. X# Standard error can be ignored if a.h is OK,
  1090. X# and can be inspected for clues otherwise.
  1091. Xexec >a.h || exit
  1092. X
  1093. X# The Makefile overrides the following defaults.
  1094. X: ${C='cc -O'}
  1095. X: ${COMPAT2=0}
  1096. X: ${DIFF_FLAGS=-an}
  1097. X: ${DIFF_L=1}
  1098. X: ${RCSPREFIX=/usr/local/bin/}
  1099. X: ${SENDMAIL=/usr/lib/sendmail}
  1100. X: ${L=}
  1101. X: ${DIFF=${RCSPREFIX}diff}
  1102. X
  1103. X
  1104. Xcat <<EOF || exit
  1105. X/* RCS compile-time configuration */
  1106. X
  1107. X    /* $Id */
  1108. X
  1109. X/*
  1110. X * This file is generated automatically.
  1111. X * If you edit it by hand your changes may be lost.
  1112. X * Instead, please try to fix conf.sh,
  1113. X * and send your fixes to rcs-bugs@cs.purdue.edu.
  1114. X */
  1115. X
  1116. XEOF
  1117. X
  1118. X: exitmain
  1119. Xcat >a.c <<EOF && $C a.c $L >&2 || exit
  1120. X#include "a.h"
  1121. Xint main(argc,argv) int argc; char **argv; { return argc-1; }
  1122. XEOF
  1123. Xe='(n) ? (exit(n),(n)) : (n) /* lint fodder */'
  1124. Xif ./a.out -
  1125. Xthen :
  1126. Xelif ./a.out
  1127. Xthen e=n
  1128. Xfi
  1129. Xecho "#define exitmain(n) return $e /* how to exit from main() */"
  1130. X
  1131. X: standard includes
  1132. XstandardIncludes=
  1133. Xfor h in stdio sys/types sys/stat fcntl limits stdlib string unistd vfork
  1134. Xdo
  1135. X    cat >a.c <<EOF || exit
  1136. X#include "a.h"
  1137. X$standardIncludes
  1138. X#include <$h.h>
  1139. Xint main(){ exitmain(0); }
  1140. XEOF
  1141. X    if ($C a.c $L && ./a.out) >&2
  1142. X    then i="#    include <$h.h>"
  1143. X    else
  1144. X        case $h in
  1145. X        string)
  1146. X            i='#    include <strings.h>';;
  1147. X        *)
  1148. X            i="    /* #include <$h.h> does not work.  */"
  1149. X        esac
  1150. X    fi || exit
  1151. X    standardIncludes="$standardIncludes
  1152. X$i"
  1153. Xdone
  1154. X
  1155. Xcat <<EOF || exit
  1156. X#if !MAKEDEPEND$standardIncludes
  1157. X#endif /* !MAKEDEPEND */
  1158. XEOF
  1159. X
  1160. X# has_sys_*_h
  1161. Xfor H in dir param wait
  1162. Xdo
  1163. X    : has_sys_${H}_h
  1164. X    cat >a.c <<EOF || exit
  1165. X#include "a.h"
  1166. X#include <sys/$H.h>
  1167. Xint main() { exitmain(0); }
  1168. XEOF
  1169. X    if ($C a.c $L && ./a.out) >&2
  1170. X    then h=1
  1171. X    else h=0
  1172. X    fi
  1173. X    echo "#define has_sys_${H}_h $h /* Does #include <sys/$H.h> work?  */"
  1174. Xdone
  1175. X
  1176. X: const, volatile
  1177. Xfor i in const volatile
  1178. Xdo
  1179. X    cat >a.c <<EOF || exit
  1180. X#    include "a.h"
  1181. X    $i int * $i * zero;
  1182. XEOF
  1183. X    if $C -S a.c >&2
  1184. X    then echo "/* #define $i */ /* The '$i' keyword works.  */"
  1185. X    else echo "#define $i /* The '$i' keyword does not work.  */"
  1186. X    fi
  1187. Xdone
  1188. X
  1189. X# *_t
  1190. Xcat >a.c <<'EOF' || exit
  1191. X#include "a.h"
  1192. X#include <signal.h>
  1193. Xt x;
  1194. XEOF
  1195. Xfor t in gid_t mode_t pid_t sig_atomic_t size_t time_t uid_t
  1196. Xdo
  1197. X    : $t
  1198. X    case $t in
  1199. X    time_t) i=long;;
  1200. X    *) i=int;;
  1201. X    esac
  1202. X    if $C -S -Dt=$t a.c >&2
  1203. X    then echo "/* typedef $i $t; */ /* Standard headers define $t.  */"
  1204. X    else echo "typedef $i $t; /* Standard headers do not define $t.  */"
  1205. X    fi
  1206. Xdone
  1207. X
  1208. X: has_prototypes
  1209. Xcat >a.c <<'EOF' || exit
  1210. X#include "a.h"
  1211. Xint main(int, char**);
  1212. Xint main(int argc, char **argv) { exitmain(!argv[argc-1]); }
  1213. XEOF
  1214. Xif $C -S a.c >&2
  1215. Xthen h=1
  1216. Xelse h=0
  1217. Xfi
  1218. Xcat <<EOF
  1219. X#define has_prototypes $h /* Do function prototypes work?  */
  1220. X#if has_prototypes
  1221. X#    define P(params) params
  1222. X#    if !MAKEDEPEND
  1223. X#        include <stdarg.h>
  1224. X#    endif
  1225. X#    define vararg_start(ap,p) va_start(ap,p)
  1226. X#else
  1227. X#    define P(params) ()
  1228. X#    if !MAKEDEPEND
  1229. X#        include <varargs.h>
  1230. X#    endif
  1231. X#    define vararg_start(ap,p) va_start(ap)
  1232. X#endif
  1233. XEOF
  1234. X
  1235. X: has_getuid
  1236. Xcat >a.c <<'EOF' || exit
  1237. X#include "a.h"
  1238. X#ifndef getuid
  1239. X    uid_t getuid();
  1240. X#endif
  1241. Xint main() { exitmain(getuid()!=getuid()); }
  1242. XEOF
  1243. Xif ($C a.c $L && ./a.out) >&2
  1244. Xthen h=1
  1245. Xelse h=0
  1246. Xfi
  1247. Xecho "#define has_getuid $h /* Does getuid() work?  */"
  1248. X
  1249. X: declare_getpwuid
  1250. Xcat >a.c <<'EOF' || exit
  1251. X#include "a.h"
  1252. X#include <pwd.h>
  1253. Xd
  1254. Xint main() { exitmain(!getpwuid(0)); }
  1255. XEOF
  1256. XD='struct passwd *getpwuid P((uid_t));'
  1257. Xif ($C -Dd="$D" a.c $L && ./a.out) >&2
  1258. Xthen define="#define declare_getpwuid $D"
  1259. Xelif ($C -Dd= a.c $L && ./a.out) >&2
  1260. Xthen define="#define declare_getpwuid /* $D */"
  1261. Xelse define="/* #define declare_getpwuid $D */"
  1262. Xfi
  1263. Xecho "$define"
  1264. X
  1265. X: has_rename, bad_rename
  1266. Xcat >a.c <<'EOF' && rm -f a.d || exit
  1267. X#include "a.h"
  1268. X#ifndef rename
  1269. X    int rename();
  1270. X#endif
  1271. Xint main() { exitmain(rename("a.c","a.d")); }
  1272. XEOF
  1273. Xif ($C a.c $L && ./a.out && test -f a.d) >&2
  1274. Xthen
  1275. X    h=1
  1276. X    echo x >a.c
  1277. X    if ./a.out && test ! -f a.c -a -f a.d
  1278. X    then b=0
  1279. X    else b=1
  1280. X    fi
  1281. Xelse h=0 b=0
  1282. Xfi
  1283. Xecho "#define has_rename $h /* Does rename() work?  */"
  1284. Xecho "#define bad_rename $b /* Does rename(A,B) fail if B exists?  */"
  1285. X
  1286. X: void, VOID
  1287. Xcat >a.c <<'EOF' || exit
  1288. X#include "a.h"
  1289. Xvoid f() {}
  1290. Xint main() {f(); exitmain(0);}
  1291. XEOF
  1292. Xif $C -S a.c >&2
  1293. Xthen
  1294. X    v='(void) '
  1295. Xelse
  1296. X    v=
  1297. X    echo 'typedef int void;'
  1298. Xfi
  1299. Xecho "#define VOID $v/* 'VOID e;' discards the value of an expression 'e'.  */"
  1300. X
  1301. X: signal_type, sig_zaps_handler
  1302. Xcat >a.c <<'EOF' || exit
  1303. X#include "a.h"
  1304. X#include <signal.h>
  1305. X#ifndef getpid
  1306. X    pid_t getpid();
  1307. X#endif
  1308. X#ifndef kill
  1309. X    int kill();
  1310. X#endif
  1311. X#ifndef signal
  1312. X    signal_type (*signal P((int,signal_type(*)P((int)))))P((int));
  1313. X#endif
  1314. Xsignal_type nothing(i) int i; {}
  1315. Xint main(argc, argv) int argc; char **argv;
  1316. X{
  1317. X    signal(SIGINT, nothing);
  1318. X    while (--argc)
  1319. X        kill(getpid(), SIGINT);
  1320. X    exitmain(0);
  1321. X}
  1322. XEOF
  1323. Xfor signal_type in void int bad
  1324. Xdo
  1325. X    case $signal_type in
  1326. X    bad) echo >&2 "cannot deduce signal_type"; exit 1
  1327. X    esac
  1328. X    ($C -Dsignal_type=$signal_type a.c $L && ./a.out 1) >&2 && break
  1329. Xdone
  1330. Xecho "#define signal_type $signal_type /* type returned by signal handlers */"
  1331. Xif ./a.out 1 2 >&2
  1332. Xthen z=0
  1333. Xelse z=1
  1334. Xfi
  1335. Xecho "#define sig_zaps_handler $z /* Must a signal handler reinvoke signal()?  */"
  1336. X
  1337. X: has_seteuid
  1338. Xcat >a.c <<'EOF' || exit
  1339. X#include "a.h"
  1340. X#ifndef geteuid
  1341. X    uid_t geteuid();
  1342. X#endif
  1343. Xint main() {
  1344. X/* Guess, don't test.  Ugh.  Testing would require running conf.sh setuid.  */
  1345. X#if !_POSIX_VERSION || _POSIX_VERSION==198808L&&!defined(sun)&&!defined(__sun__)
  1346. X    exitmain(1);
  1347. X#else
  1348. X    exitmain(seteuid(geteuid()) < 0);
  1349. X#endif
  1350. X}
  1351. XEOF
  1352. Xif ($C a.c $L && ./a.out) >&2
  1353. Xthen h=1
  1354. Xelse h=0
  1355. Xfi
  1356. Xecho "#define has_seteuid $h /* Does seteuid() obey Posix 1003.1-1990?  */"
  1357. X
  1358. X: has_sigaction
  1359. Xcat >a.c <<'EOF' || exit
  1360. X#include <signal.h>
  1361. Xstruct sigaction s;
  1362. XEOF
  1363. Xif $C -S a.c >&2
  1364. Xthen h=1
  1365. Xelse h=0
  1366. Xfi
  1367. Xecho "#define has_sigaction $h /* Does struct sigaction work?  */"
  1368. X
  1369. X: has_sigblock
  1370. Xcat >a.c <<'EOF' || exit
  1371. X#include "a.h"
  1372. X#include <signal.h>
  1373. X#ifndef sigblock
  1374. X    int sigblock();
  1375. X#endif
  1376. Xint main() { sigblock(0); exitmain(0); }
  1377. XEOF
  1378. Xif ($C a.c $L && ./a.out) >&2
  1379. Xthen h=1
  1380. Xelse h=0
  1381. Xfi
  1382. Xecho "#define has_sigblock $h /* Does sigblock() work?  */"
  1383. X
  1384. X: has_sys_siglist
  1385. Xcat >a.c <<'EOF' || exit
  1386. X#include "a.h"
  1387. X#ifndef sys_siglist
  1388. X    extern const char *sys_siglist[];
  1389. X#endif
  1390. Xint main() { exitmain(!sys_siglist[1][0]); }
  1391. XEOF
  1392. Xif ($C a.c $L && ./a.out) >&2
  1393. Xthen h=1
  1394. Xelse h=0
  1395. Xfi
  1396. Xecho "#define has_sys_siglist $h /* Does sys_siglist[] work?  */"
  1397. X
  1398. X: exit_type, underscore_exit_type
  1399. Xcat >a.c <<'EOF' || exit
  1400. X#include "a.h"
  1401. X#ifndef exit
  1402. X    void exit();
  1403. X#endif
  1404. Xint main() { exit(0); }
  1405. XEOF
  1406. Xif $C -S a.c >&2
  1407. Xthen t=void
  1408. Xelse t=int
  1409. Xfi
  1410. Xecho "#define exit_type $t /* type returned by exit() */"
  1411. Xcat >a.c <<'EOF' || exit
  1412. X#include "a.h"
  1413. X#ifndef _exit
  1414. X    void _exit();
  1415. X#endif
  1416. Xint main() { _exit(0); }
  1417. XEOF
  1418. Xif $C -S a.c >&2
  1419. Xthen t=void
  1420. Xelse t=int
  1421. Xfi
  1422. Xecho "#define underscore_exit_type $t /* type returned by _exit() */"
  1423. X
  1424. X: fread_type
  1425. Xcat >a.c <<'EOF' || exit
  1426. X#include "a.h"
  1427. X#ifndef fread
  1428. X    size_t fread();
  1429. X#endif
  1430. Xint main() { char b; exitmain(!(fread(&b,1,1,stdin)==1 && b=='#')); }
  1431. XEOF
  1432. Xif $C -S a.c $L >&2
  1433. Xthen t=size_t
  1434. Xelse t=int
  1435. Xfi
  1436. Xecho "typedef $t fread_type; /* type returned by fread() and fwrite() */"
  1437. X
  1438. X: malloc_type
  1439. Xcat >a.c <<'EOF' || exit
  1440. X#include "a.h"
  1441. Xtypedef void *malloc_type;
  1442. X#ifndef malloc
  1443. X    malloc_type malloc();
  1444. X#endif
  1445. Xint main() { exitmain(!malloc(1)); }
  1446. XEOF
  1447. Xif $C -S a.c >&2
  1448. Xthen t=void
  1449. Xelse t=char
  1450. Xfi
  1451. Xecho "typedef $t *malloc_type; /* type returned by malloc() */"
  1452. X
  1453. X: free_type
  1454. Xcat >a.c <<'EOF' || exit
  1455. X#include "a.h"
  1456. X#ifndef malloc
  1457. X    malloc_type malloc();
  1458. X#endif
  1459. X#ifndef free
  1460. X    void free();
  1461. X#endif
  1462. Xint main() { free(malloc(1)); exitmain(0); }
  1463. XEOF
  1464. Xif $C -S a.c >&2
  1465. Xthen t=void
  1466. Xelse t=int
  1467. Xfi
  1468. Xecho "#define free_type $t /* type returned by free() */"
  1469. X
  1470. X: strlen_type
  1471. Xcat >a.c <<'EOF' || exit
  1472. X#include "a.h"
  1473. X#ifndef strlen
  1474. X    size_t strlen();
  1475. X#endif
  1476. Xint main() { exitmain(strlen("")); }
  1477. XEOF
  1478. Xif $C -S a.c >&2
  1479. Xthen t=size_t
  1480. Xelse t=int
  1481. Xfi
  1482. Xecho "typedef $t strlen_type; /* type returned by strlen() */"
  1483. X
  1484. X: has_getcwd
  1485. Xcat >a.c <<'EOF' || exit
  1486. X#include "a.h"
  1487. X#ifndef getcwd
  1488. X    char *getcwd();
  1489. X#endif
  1490. Xchar buf[10000];
  1491. Xint main() { exitmain(!getcwd(buf,10000)); }
  1492. XEOF
  1493. Xif ($C a.c $L && ./a.out) >&2
  1494. Xthen has_getcwd=1
  1495. Xelse has_getcwd=0
  1496. Xfi
  1497. Xecho "#define has_getcwd $has_getcwd /* Does getcwd() work?  */"
  1498. X
  1499. X: has_getwd
  1500. Xcase $has_getcwd in
  1501. X0)
  1502. X    cat >a.c <<'EOF' || exit
  1503. X#include "a.h"
  1504. X#include <sys/param.h>
  1505. X#ifndef getwd
  1506. X    char *getwd();
  1507. X#endif
  1508. Xchar buf[MAXPATHLEN];
  1509. Xint main() { exitmain(!getwd(buf)); }
  1510. XEOF
  1511. X    if ($C a.c $L && ./a.out) >&2
  1512. X    then h=1
  1513. X    else h=0
  1514. X    fi
  1515. X    echo "#define has_getwd $h /* Does getwd() work?  */";;
  1516. X1)
  1517. X    echo "/* #define has_getwd ? */ /* Does getwd() work?  */"
  1518. Xesac
  1519. X
  1520. X: has_vfork
  1521. Xcat >a.c <<'EOF' || exit
  1522. X#include "a.h"
  1523. X#if has_sys_wait_h
  1524. X#    include <sys/wait.h>
  1525. X#endif
  1526. X#ifndef _exit
  1527. X    underscore_exit_type _exit();
  1528. X#endif
  1529. X#ifndef getpid
  1530. X    pid_t getpid();
  1531. X#endif
  1532. X#ifndef wait
  1533. X    pid_t wait();
  1534. X#endif
  1535. Xpid_t child;
  1536. Xint status;
  1537. Xstruct stat st;
  1538. Xint main()
  1539. X{
  1540. X    pid_t parent = getpid();
  1541. X    if (!(child = vfork())) {
  1542. X        /* Tickle vfork/compiler bug (e.g. sparc gcc -O (1.37.1).  */
  1543. X        pid_t i = getpid(), j = getpid();
  1544. X        if (i!=getpid() || j!=getpid())
  1545. X            _exit(!i);
  1546. X        /* Tickle file descriptor bug (e.g. IRIX 3.3).  */
  1547. X        _exit(close(1) < 0);
  1548. X    } else {
  1549. X        while (wait(&status) != child)
  1550. X            ;
  1551. X        /* Test for presence of bugs.  */
  1552. X        exitmain(status  ||  parent != getpid()  ||  fstat(1, &st) < 0);
  1553. X    }
  1554. X}
  1555. XEOF
  1556. Xif ($C a.c $L && ./a.out) >&2
  1557. Xthen h=1
  1558. Xelse h=0
  1559. Xfi
  1560. Xecho "#define has_vfork $h /* Does vfork() work?  */"
  1561. X
  1562. X: has_vfprintf
  1563. Xcat >a.c <<'EOF' || exit
  1564. X#include "a.h"
  1565. X#if has_prototypes
  1566. Xint p(const char *format,...)
  1567. X#else
  1568. X/*VARARGS1*/ int p(format, va_alist) char *format; va_dcl
  1569. X#endif
  1570. X{
  1571. X    int r;
  1572. X    va_list args;
  1573. X    vararg_start(args, format);
  1574. X    r = vfprintf(stderr, format, args);
  1575. X    va_end(args);
  1576. X    return r;
  1577. X}
  1578. Xint main() { exitmain(p("")); }
  1579. XEOF
  1580. Xif ($C a.c $L && ./a.out) >&2
  1581. Xthen h=1
  1582. Xelse h=0
  1583. Xfi
  1584. Xecho "#define has_vfprintf $h /* Does vfprintf() work?  */"
  1585. X
  1586. X: strrchr
  1587. Xcat >a.c <<'EOF' || exit
  1588. X#include "a.h"
  1589. X#ifndef strrchr
  1590. X    char *strrchr();
  1591. X#endif
  1592. Xint main() {exitmain(!strrchr("abc", 'c'));}
  1593. XEOF
  1594. X($C a.c $L && ./a.out) >&2 ||
  1595. X  echo "#define strrchr rindex /* Use old-fashioned name for strrchr(). */"
  1596. X
  1597. X: CO
  1598. Xecho "#define CO \"${RCSPREFIX}co\" /* name of 'co' program */"
  1599. X
  1600. X: COMPAT2
  1601. Xecho "#define COMPAT2 $COMPAT2 /* Are version 2 files supported?  */"
  1602. X
  1603. X: DATEFORM
  1604. Xcat >a.c <<'EOF' || exit
  1605. X#include "a.h"
  1606. Xint main() { printf("%.2d", 1); exitmain(0); }
  1607. XEOF
  1608. X$C a.c $L >&2 && r=`./a.out` || exit
  1609. Xcase $r in
  1610. X01)    f=%.2d;;
  1611. X*)    f=%02d
  1612. Xesac
  1613. Xecho "#define DATEFORM \"$f.$f.$f.$f.$f.$f\" /* e.g. 01.01.01.01.01.01 */"
  1614. X
  1615. X: DIFF
  1616. Xecho "#define DIFF \"$DIFF\" /* name of 'diff' program */"
  1617. X
  1618. X: DIFF_FLAGS
  1619. Xdfs=
  1620. Xfor df in $DIFF_FLAGS
  1621. Xdo dfs="$dfs, \"$df\""
  1622. Xdone
  1623. Xecho "#define DIFF_FLAGS $dfs /* Make diff output suitable for RCS.  */"
  1624. X
  1625. X: DIFF_L
  1626. Xecho "#define DIFF_L $DIFF_L /* Does diff -L work? */"
  1627. X
  1628. X: EXECRCS
  1629. Xe=execv
  1630. Xfor i in "$DIFF" "$RCSPREFIX" "$SENDMAIL"
  1631. Xdo
  1632. X    case $i in
  1633. X    */*) ;;
  1634. X    *) e=execvp break
  1635. X    esac
  1636. Xdone
  1637. Xecho "#define EXECRCS $e /* variant of execv() to use on subprograms */"
  1638. X
  1639. X: MERGE
  1640. Xecho "#define MERGE \"${RCSPREFIX}merge\" /* name of 'merge' program */"
  1641. X
  1642. X: RCSDIR, SLASH, TMPDIR
  1643. Xrm -fr a.RCS && mkdir a.RCS && echo x >a.RCS/x &&
  1644. Xcat >a.c <<'EOF' || exit
  1645. X#include "a.h"
  1646. Xmain() { exitmain(!fopen(NAME,"r")); }
  1647. XEOF
  1648. Xfor NAME in a.RCS/x 'a.rcs/x' 'A.RCS\\x' bad
  1649. Xdo ($C -DNAME="\"$NAME\"" a.c $L && ./a.out) && break
  1650. Xdone
  1651. Xcase $NAME in
  1652. Xa.RCS/x) RCSDIR=RCS/ SLASH=/ TMPDIR=/tmp/;;
  1653. Xa.rcs/x) RCSDIR=rcs/ SLASH=/ TMPDIR=/tmp/;;
  1654. X'A.RCS\\X') RCSDIR='RCS\\' SLASH='\\' TMPDIR='\\TMP\\';;
  1655. X*) echo >&2 "cannot deduce RCSDIR"; exit 1;;
  1656. Xesac
  1657. Xrm -fr a.RCS
  1658. Xecho "#define RCSDIR \"$RCSDIR\" /* subdirectory for RCS files */"
  1659. Xecho "#define SLASH '$SLASH' /* path name separator */"
  1660. Xecho "#define TMPDIR \"$TMPDIR\" /* default directory for temporary files */"
  1661. X
  1662. X: DIFF_PATH_HARDWIRED
  1663. Xcase $DIFF in
  1664. X"$SLASH"*) h=1;;
  1665. X*) h=0
  1666. Xesac
  1667. Xecho "#define DIFF_PATH_HARDWIRED $h /* Is DIFF absolute, not relative?  */"
  1668. X
  1669. X: ROOTPATH
  1670. Xcase `pwd` in
  1671. X[/\\]*)
  1672. X    echo '#define ROOTPATH(p) ((p)[0]==SLASH)';;
  1673. X?:[/\\]*)
  1674. X    echo '#define ROOTPATH(p) ((p)[0] && (p)[1]==':' && (p)[2]==SLASH)';;
  1675. X*)
  1676. X    echo >&2 "cannot deduce ROOTPATH"; exit 1;;
  1677. Xesac
  1678. X
  1679. X: RCSSEP
  1680. Xif echo x >a.1234567890,v && ($C -DNAME=\"a.1234567890,v\" a.c $L && ./a.out)
  1681. Xthen RCSSEP=','
  1682. Xelse RCSSEP='\0'
  1683. Xfi
  1684. Xecho "#define RCSSEP '$RCSSEP' /* separator for RCSSUF */"
  1685. X
  1686. X: SENDMAIL
  1687. Xecho "#define SENDMAIL $SENDMAIL /* how to send mail */"
  1688. X
  1689. X: fprintf, printf, vfprintf
  1690. Xcat >a.c <<'EOF' || exit
  1691. X#include "a.h"
  1692. X#ifndef printf
  1693. X    int printf P((const char*,...));
  1694. X#endif
  1695. Xint main() { printf(""); exitmain(0); }
  1696. XEOF
  1697. Xif $C -S a.c >&2
  1698. Xthen a='1 /* These agree with <stdio.h>.  */'
  1699. Xelse a='0 /* These conflict with <stdio.h>.  */'
  1700. Xfi
  1701. Xcat <<EOF || exit
  1702. X#if $a
  1703. X    int fprintf P((FILE*,const char*,...));
  1704. X    int printf P((const char*,...));
  1705. X#    if has_vfprintf
  1706. X        int vfprintf P((FILE*,const char*,...));
  1707. X#    else
  1708. X        void _doprnt P((const char*,...));
  1709. X#    endif
  1710. X#endif
  1711. XEOF
  1712. X
  1713. X: sprintf and other routines with '...' and default promotion problems
  1714. Xcat >a.c <<'EOF' || exit
  1715. X#include "a.h"
  1716. X#ifndef sprintf
  1717. X    int sprintf();
  1718. X#endif
  1719. Xint main()
  1720. X{
  1721. X    char buf[1];
  1722. X    exitmain(sprintf(buf, "") != 0);
  1723. X}
  1724. XEOF
  1725. Xif ($C a.c $L && ./a.out) >&2
  1726. Xthen t='int '
  1727. Xelse t='char *'
  1728. Xfi
  1729. Xcat >a.c <<'EOF' || exit
  1730. X#include "a.h"
  1731. X#if has_sys_wait_h
  1732. X#    include <sys/wait.h>
  1733. X#endif
  1734. Xdeclaration
  1735. Xint main() { exitmain(0); }
  1736. XEOF
  1737. Xfor declaration in \
  1738. X    "${t}sprintf P((char*,const char*,...));" \
  1739. X    'int chmod P((const char*,mode_t));' \
  1740. X    'int fcntl P((int,int,...));' \
  1741. X    'int open P((const char*,int,...));' \
  1742. X    'mode_t umask P((mode_t));' \
  1743. X    'pid_t wait P((int*));'
  1744. Xdo
  1745. X    if $C -S -Ddeclaration="$declaration" a.c >&2
  1746. X    then echo "$declaration"
  1747. X    else echo "/* $declaration */"
  1748. X    fi
  1749. Xdone
  1750. Xfor i in '
  1751. X#ifndef O_CREAT
  1752. X    int creat P((const char*,mode_t));
  1753. X#endif' '
  1754. X#if has_seteuid
  1755. X    int setegid P((gid_t));
  1756. X    int seteuid P((uid_t));
  1757. X#endif'
  1758. X    # See declare_getpwuid for how getpwuid() is handled.
  1759. Xdo
  1760. X    echo '#include "a.h"
  1761. X        int main() { exitmain(0); }'"$i" >a.c || exit
  1762. X    if $C -S a.c >&2
  1763. X    then sed 1,2d a.c
  1764. X    else sed '1,2d; s|.*|/* & */|' a.c
  1765. X    fi
  1766. Xdone
  1767. END_OF_FILE
  1768.   if test 14859 -ne `wc -c <'src/conf.sh'`; then
  1769.     echo shar: \"'src/conf.sh'\" unpacked with wrong size!
  1770.   fi
  1771.   # end of 'src/conf.sh'
  1772. fi
  1773. if test -f 'src/rcsgen.c' -a "${1}" != "-c" ; then 
  1774.   echo shar: Will not clobber existing file \"'src/rcsgen.c'\"
  1775. else
  1776.   echo shar: Extracting \"'src/rcsgen.c'\" \(11524 characters\)
  1777.   sed "s/^X//" >'src/rcsgen.c' <<'END_OF_FILE'
  1778. X/*
  1779. X *                     RCS revision generation
  1780. X */
  1781. X
  1782. X/* Copyright (C) 1982, 1988, 1989 Walter Tichy
  1783. X   Copyright 1990 by Paul Eggert
  1784. X   Distributed under license by the Free Software Foundation, Inc.
  1785. X
  1786. XThis file is part of RCS.
  1787. X
  1788. XRCS is free software; you can redistribute it and/or modify
  1789. Xit under the terms of the GNU General Public License as published by
  1790. Xthe Free Software Foundation; either version 1, or (at your option)
  1791. Xany later version.
  1792. X
  1793. XRCS is distributed in the hope that it will be useful,
  1794. Xbut WITHOUT ANY WARRANTY; without even the implied warranty of
  1795. XMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1796. XGNU General Public License for more details.
  1797. X
  1798. XYou should have received a copy of the GNU General Public License
  1799. Xalong with RCS; see the file COPYING.  If not, write to
  1800. Xthe Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  1801. X
  1802. XReport problems and direct all questions to:
  1803. X
  1804. X    rcs-bugs@cs.purdue.edu
  1805. X
  1806. X*/
  1807. X
  1808. X
  1809. X
  1810. X/* $Log: rcsgen.c,v $
  1811. X * Revision 5.6  1990/12/27  19:54:26  eggert
  1812. X * Fix bug: rcs -t inserted \n, making RCS file grow.
  1813. X *
  1814. X * Revision 5.5  1990/12/04  05:18:45  eggert
  1815. X * Use -I for prompts and -q for diagnostics.
  1816. X *
  1817. X * Revision 5.4  1990/11/01  05:03:47  eggert
  1818. X * Add -I and new -t behavior.  Permit arbitrary data in logs.
  1819. X *
  1820. X * Revision 5.3  1990/09/21  06:12:43  hammer
  1821. X * made putdesc() treat stdin the same whether or not it was from a terminal
  1822. X * by making it recognize that a single '.' was then end of the
  1823. X * description always
  1824. X *
  1825. X * Revision 5.2  1990/09/04  08:02:25  eggert
  1826. X * Fix `co -p1.1 -ko' bug.  Standardize yes-or-no procedure.
  1827. X *
  1828. X * Revision 5.1  1990/08/29  07:14:01  eggert
  1829. X * Clean old log messages too.
  1830. X *
  1831. X * Revision 5.0  1990/08/22  08:12:52  eggert
  1832. X * Remove compile-time limits; use malloc instead.
  1833. X * Ansify and Posixate.
  1834. X *
  1835. X * Revision 4.7  89/05/01  15:12:49  narten
  1836. X * changed copyright header to reflect current distribution rules
  1837. X * 
  1838. X * Revision 4.6  88/08/28  14:59:10  eggert
  1839. X * Shrink stdio code size; allow cc -R; remove lint; isatty() -> ttystdin()
  1840. X * 
  1841. X * Revision 4.5  87/12/18  11:43:25  narten
  1842. X * additional lint cleanups, and a bug fix from the 4.3BSD version that
  1843. X * keeps "ci" from sticking a '\377' into the description if you run it
  1844. X * with a zero-length file as the description. (Guy Harris)
  1845. X * 
  1846. X * Revision 4.4  87/10/18  10:35:10  narten
  1847. X * Updating version numbers. Changes relative to 1.1 actually relative to
  1848. X * 4.2
  1849. X * 
  1850. X * Revision 1.3  87/09/24  13:59:51  narten
  1851. X * Sources now pass through lint (if you ignore printf/sprintf/fprintf 
  1852. X * warnings)
  1853. X * 
  1854. X * Revision 1.2  87/03/27  14:22:27  jenkins
  1855. X * Port to suns
  1856. X * 
  1857. X * Revision 4.2  83/12/02  23:01:39  wft
  1858. X * merged 4.1 and 3.3.1.1 (clearerr(stdin)).
  1859. X * 
  1860. X * Revision 4.1  83/05/10  16:03:33  wft
  1861. X * Changed putamin() to abort if trying to reread redirected stdin.
  1862. X * Fixed getdesc() to output a prompt on initial newline.
  1863. X * 
  1864. X * Revision 3.3.1.1  83/10/19  04:21:51  lepreau
  1865. X * Added clearerr(stdin) for re-reading description from stdin.
  1866. X * 
  1867. X * Revision 3.3  82/11/28  21:36:49  wft
  1868. X * 4.2 prerelease
  1869. X * 
  1870. X * Revision 3.3  82/11/28  21:36:49  wft
  1871. X * Replaced ferror() followed by fclose() with ffclose().
  1872. X * Putdesc() now suppresses the prompts if stdin
  1873. X * is not a terminal. A pointer to the current log message is now
  1874. X * inserted into the corresponding delta, rather than leaving it in a
  1875. X * global variable.
  1876. X *
  1877. X * Revision 3.2  82/10/18  21:11:26  wft
  1878. X * I added checks for write errors during editing, and improved
  1879. X * the prompt on putdesc().
  1880. X *
  1881. X * Revision 3.1  82/10/13  15:55:09  wft
  1882. X * corrected type of variables assigned to by getc (char --> int)
  1883. X */
  1884. X
  1885. X
  1886. X
  1887. X
  1888. X#include "rcsbase.h"
  1889. X
  1890. XlibId(genId, "$Id: rcsgen.c,v 5.6 1990/12/27 19:54:26 eggert Exp $")
  1891. X
  1892. Xint interactiveflag;  /* Should we act as if stdin is a tty?  */
  1893. Xstruct cbuf curlogmsg;  /* buffer for current log message */
  1894. Xstruct buf curlogbuf;  /* same, including allocated but unused bytes */
  1895. X
  1896. Xenum stringwork {copy, edit, expand, edit_expand };
  1897. X
  1898. Xstatic void scandeltatext P((struct hshentry*,enum stringwork));
  1899. X
  1900. X
  1901. X
  1902. X
  1903. X    const char *
  1904. Xbuildrevision(deltas, target, tostdout, expandflag)
  1905. X    const struct hshentries *deltas;
  1906. X    struct hshentry *target;
  1907. X    int tostdout;
  1908. X    int expandflag;
  1909. X/* Function: Generates the revision given by target
  1910. X * by retrieving all deltas given by parameter deltas and combining them.
  1911. X * If tostdout is set, the revision is printed on the standard output,
  1912. X * otherwise written into a temporary file.
  1913. X * Temporary files are put into tmp unless the caller has already set up
  1914. X * the temp file directory by invoking initeditfiles(), which sets fcopy.
  1915. X * if expandflag is set, keyword expansion is performed.
  1916. X * Returns nil on errors, the name of the file with the revision otherwise.
  1917. X *
  1918. X * Algorithm: Copy initial revision unchanged.  Then edit all revisions but
  1919. X * the last one into it, alternating input and output files (resultfile and
  1920. X * editfile). The last revision is then edited in, performing simultaneous
  1921. X * keyword substitution (this saves one extra pass).
  1922. X * All this simplifies if only one revision needs to be generated,
  1923. X * or no keyword expansion is necessary, or if output goes to stdout.
  1924. X */
  1925. X{
  1926. X    static const char nonnil[] = ""; /* some char* value that isn't nil */
  1927. X
  1928. X    if (deltas->first == target) {
  1929. X                /* only latest revision to generate */
  1930. X        if (tostdout) {
  1931. X                        fcopy=stdout;
  1932. X            scandeltatext(target, expandflag?expand:copy);
  1933. X            return nonnil;
  1934. X                } else {
  1935. X            if (!fcopy)
  1936. X                inittmpeditfiles();
  1937. X                        scandeltatext(target,expandflag?expand:copy);
  1938. X                        ffclose(fcopy);
  1939. X                        return(resultfile);
  1940. X                }
  1941. X        } else {
  1942. X                /* several revisions to generate */
  1943. X        if (!fcopy)
  1944. X            inittmpeditfiles();
  1945. X                /* write initial revision into fcopy, no keyword expansion */
  1946. X        scandeltatext(deltas->first, copy);
  1947. X        while ((deltas=deltas->rest)->rest) {
  1948. X                        /* do all deltas except last one */
  1949. X            scandeltatext(deltas->first, edit);
  1950. X                }
  1951. X        if (expandflag | tostdout) {
  1952. X                        /* first, get to beginning of file*/
  1953. X            finishedit((struct hshentry *)nil);
  1954. X            swapeditfiles(tostdout);
  1955. X                }
  1956. X        scandeltatext(deltas->first, expandflag ? edit_expand : edit);
  1957. X        finishedit(expandflag ? deltas->first : (struct hshentry*)nil);
  1958. X        if (tostdout)
  1959. X            return nonnil;
  1960. X        ffclose(fcopy);
  1961. X        return resultfile;
  1962. X        }
  1963. X}
  1964. X
  1965. X
  1966. X
  1967. X    static void
  1968. Xscandeltatext(delta,func)
  1969. Xstruct hshentry * delta; enum stringwork func;
  1970. X/* Function: Scans delta text nodes up to and including the one given
  1971. X * by delta. For the one given by delta, the log message is saved into
  1972. X * curlogmsg and the text is processed according to parameter func.
  1973. X * Assumes the initial lexeme must be read in first.
  1974. X * Does not advance nexttok after it is finished.
  1975. X */
  1976. X{
  1977. X    const struct hshentry *nextdelta;
  1978. X    struct cbuf cb;
  1979. X
  1980. X        for (;;) {
  1981. X                nextlex();
  1982. X                if (!(nextdelta=getnum())) {
  1983. X            fatserror("can't find delta for revision %s", delta->num);
  1984. X                }
  1985. X        getkeystring(Klog);
  1986. X        if (delta==nextdelta) {
  1987. X            cb = savestring(&curlogbuf);
  1988. X            delta->log = curlogmsg =
  1989. X                cleanlogmsg(curlogbuf.string, cb.size);
  1990. X                } else {readstring();
  1991. X                }
  1992. X                nextlex();
  1993. X        while (nexttok==ID && strcmp(NextString,Ktext)!=0)
  1994. X            ignorephrase();
  1995. X        getkeystring(Ktext);
  1996. X
  1997. X        if (delta==nextdelta)
  1998. X            break;
  1999. X        readstring(); /* skip over it */
  2000. X
  2001. X    }
  2002. X    switch (func) {
  2003. X        case copy: copystring(); break;
  2004. X        case expand: xpandstring(delta); break;
  2005. X        case edit: editstring((struct hshentry *)nil); break;
  2006. X        case edit_expand: editstring(delta); break;
  2007. X    }
  2008. X}
  2009. X
  2010. X    struct cbuf
  2011. Xcleanlogmsg(m, s)
  2012. X    char *m;
  2013. X    size_t s;
  2014. X{
  2015. X    register char *t = m;
  2016. X    register const char *f = t;
  2017. X    struct cbuf r;
  2018. X    while (s) {
  2019. X        --s;
  2020. X        if ((*t++ = *f++) == '\n')
  2021. X        while (m < --t)
  2022. X            if (t[-1]!=' ' && t[-1]!='\t') {
  2023. X            *t++ = '\n';
  2024. X            break;
  2025. X            }
  2026. X    }
  2027. X    while (m < t  &&  (t[-1]==' ' || t[-1]=='\t' || t[-1]=='\n'))
  2028. X        --t;
  2029. X    r.string = m;
  2030. X    r.size = t - m;
  2031. X    return r;
  2032. X}
  2033. X
  2034. X
  2035. Xint ttystdin()
  2036. X{
  2037. X    static int initialized;
  2038. X    if (!initialized) {
  2039. X        if (!interactiveflag)
  2040. X            interactiveflag = isatty(STDIN_FILENO);
  2041. X        initialized = true;
  2042. X    }
  2043. X    return interactiveflag;
  2044. X}
  2045. X
  2046. X    int
  2047. Xgetcstdin()
  2048. X{
  2049. X    register int c = getchar();
  2050. X    if (c == EOF) {
  2051. X        if (ferror(stdin))
  2052. X            IOerror();
  2053. X        if (ttystdin()) {
  2054. X            clearerr(stdin);
  2055. X            afputc('\n',stderr);
  2056. X        }
  2057. X    }
  2058. X    return c;
  2059. X}
  2060. X
  2061. X#if has_prototypes
  2062. X    int
  2063. Xyesorno(int default_answer, const char *question, ...)
  2064. X#else
  2065. X        /*VARARGS2*/ int
  2066. X    yesorno(default_answer, question, va_alist)
  2067. X        int default_answer; const char *question; va_dcl
  2068. X#endif
  2069. X{
  2070. X    va_list args;
  2071. X    register int c, r;
  2072. X    if (!quietflag && ttystdin()) {
  2073. X        oflush();
  2074. X        vararg_start(args, question);
  2075. X        fvfprintf(stderr, question, args);
  2076. X        va_end(args);
  2077. X        eflush();
  2078. X        r = c = getcstdin();
  2079. X        while (c!='\n' && c!=EOF)
  2080. X            c = getcstdin();
  2081. X        if (r=='y' || r=='Y')
  2082. X            return true;
  2083. X        if (r=='n' || r=='N')
  2084. X            return false;
  2085. X    }
  2086. X    return default_answer;
  2087. X}
  2088. X
  2089. X
  2090. X    void
  2091. Xputdesc(textflag, textfile)
  2092. X    int textflag;
  2093. X    const char *textfile;
  2094. X/* Function: puts the descriptive text into file frewrite.
  2095. X * if finptr && !textflag, the text is copied from the old description.
  2096. X * Otherwise, if the textfile!=nil, the text is read from that
  2097. X * file, or from stdin, if textfile==nil.
  2098. X * A textfile with a leading '-' is treated as a string, not a file name.
  2099. X * If finptr, the old descriptive text is discarded.
  2100. X */
  2101. X{       register FILE * txt; register int c, old1, old2;
  2102. X    register FILE * frew;
  2103. X
  2104. X    frew = frewrite;
  2105. X    if (finptr && !textflag) {
  2106. X                /* copy old description */
  2107. X        aprintf(frew,"\n\n%s%c",Kdesc,nextc);
  2108. X        foutptr = frewrite;
  2109. X        getdesc(false);
  2110. X        } else {
  2111. X                /* get new description */
  2112. X        if (finptr) {
  2113. X                        /*skip old description*/
  2114. X            foutptr = NULL;
  2115. X            getdesc(false);
  2116. X                }
  2117. X        aprintf(frew,"\n\n%s\n%c",Kdesc,SDELIM);
  2118. X                if (textfile) {
  2119. X                        old1='\n';
  2120. X                        /* copy textfile */
  2121. X            txt = NULL;
  2122. X            if (*textfile=='-' || (txt=fopen(textfile,"r"))) {
  2123. X                while (txt ? (c=getc(txt))!=EOF : (c = *++textfile)) {
  2124. X                    if (c==SDELIM) afputc(c,frew); /*double up*/
  2125. X                    afputc(c,frew);
  2126. X                                        old1=c;
  2127. X                                }
  2128. X                if (old1!='\n') afputc('\n',frew);
  2129. X                if (txt) ffclose(txt);
  2130. X                aprintf(frew, "%c\n", SDELIM);
  2131. X                return;
  2132. X                        } else {
  2133. X                efaterror(textfile);
  2134. X                        }
  2135. X                }
  2136. X                /* read text from stdin */
  2137. X        if (feof(stdin))
  2138. X            faterror("can't reread redirected stdin for description; use -t-<description>");
  2139. X        if (ttystdin())
  2140. X            aputs("enter description, terminated with single '.' or end of file:\nNOTE: This is NOT the log message!\n>> ",stderr);
  2141. X        if ((old1=getcstdin()) != EOF) {
  2142. X             old2 = '\n';
  2143. X             for (;;) {
  2144. X                if (old1=='\n' && ttystdin())
  2145. X                    aputs(">> ",stderr);
  2146. X                c = getcstdin();
  2147. X                            if (c==EOF) {
  2148. X                    afputc(old1,frew);
  2149. X                    if (old1!='\n') afputc('\n',frew);
  2150. X                                    break;
  2151. X                            }
  2152. X                if (c=='\n' && old1=='.' && old2=='\n') {
  2153. X                                    break;
  2154. X                            }
  2155. X                if (old1==SDELIM) afputc(old1,frew); /* double up*/
  2156. X                afputc(old1,frew);
  2157. X                            old2=old1;
  2158. X                            old1=c;
  2159. X                    } /* end for */
  2160. X        }
  2161. X        aprintf(frew, "%c\n", SDELIM);
  2162. X        }
  2163. X}
  2164. END_OF_FILE
  2165.   if test 11524 -ne `wc -c <'src/rcsgen.c'`; then
  2166.     echo shar: \"'src/rcsgen.c'\" unpacked with wrong size!
  2167.   fi
  2168.   # end of 'src/rcsgen.c'
  2169. fi
  2170. echo shar: End of archive 9 \(of 12\).
  2171. cp /dev/null ark9isdone
  2172. MISSING=""
  2173. for I in 1 2 3 4 5 6 7 8 9 10 11 12 ; do
  2174.     if test ! -f ark${I}isdone ; then
  2175.     MISSING="${MISSING} ${I}"
  2176.     fi
  2177. done
  2178. if test "${MISSING}" = "" ; then
  2179.     echo You have unpacked all 12 archives.
  2180.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2181. else
  2182.     echo You still must unpack the following archives:
  2183.     echo "        " ${MISSING}
  2184. fi
  2185. exit 0
  2186. exit 0 # Just in case...
  2187.