home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 3 / goldfish_volume_3.bin / files / dev / misc / hwgrcs / src / rcs.rcsfiles / rcsgen.c,v < prev    next >
Encoding:
Text File  |  1995-06-25  |  23.5 KB  |  944 lines

  1. head    5.10;
  2. branch    5.10.1;
  3. access;
  4. symbols
  5.     HWGRCSP12F:5.10.1.3
  6.     HWGRCSP11F:5.10.1.3
  7.     HWGRCSP10F:5.10.1.3
  8.     HWGRCSP9:5.10.1.3
  9.     HWGRCSP8F:5.10.1.3
  10.     HWGRCSP7F:5.10.1.3
  11.     HWGRCSP6F:5.10.1.3
  12.     HWGRCSP5F:5.10.1.1
  13.     HWGRCSp4:5.10.1.1
  14.     HWGRCSp3:5.10.1
  15.     HWGRCS_Fish:5.10.1
  16.     HWGRCS:5.10.1;
  17. locks; strict;
  18. comment    @ * @;
  19.  
  20.  
  21. 5.10
  22. date    91.10.07.17.32.46;    author eggert;    state Exp;
  23. branches
  24.     5.10.1.1;
  25. next    ;
  26.  
  27. 5.10.1.1
  28. date    93.01.18.14.38.34;    author heinz;    state Exp;
  29. branches;
  30. next    5.10.1.2;
  31.  
  32. 5.10.1.2
  33. date    93.12.18.16.12.22;    author heinz;    state Exp;
  34. branches;
  35. next    5.10.1.3;
  36.  
  37. 5.10.1.3
  38. date    93.12.18.17.17.59;    author heinz;    state Exp;
  39. branches;
  40. next    ;
  41.  
  42.  
  43. desc
  44. @Checked in with -k 16.jan.93 HWG
  45. @
  46.  
  47.  
  48. 5.10
  49. log
  50. @checked in with -k by heinz at 1993/01/17 01:53:17
  51. @
  52. text
  53. @/*
  54.  *                     RCS revision generation
  55.  */
  56.  
  57. /* Copyright (C) 1982, 1988, 1989 Walter Tichy
  58.    Copyright 1990, 1991 by Paul Eggert
  59.    Distributed under license by the Free Software Foundation, Inc.
  60.  
  61. This file is part of RCS.
  62.  
  63. RCS is free software; you can redistribute it and/or modify
  64. it under the terms of the GNU General Public License as published by
  65. the Free Software Foundation; either version 2, or (at your option)
  66. any later version.
  67.  
  68. RCS is distributed in the hope that it will be useful,
  69. but WITHOUT ANY WARRANTY; without even the implied warranty of
  70. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  71. GNU General Public License for more details.
  72.  
  73. You should have received a copy of the GNU General Public License
  74. along with RCS; see the file COPYING.  If not, write to
  75. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  76.  
  77. Report problems and direct all questions to:
  78.  
  79.     rcs-bugs@@cs.purdue.edu
  80.  
  81. */
  82.  
  83.  
  84.  
  85. /* $Log: rcsgen.c,v $
  86.  * Revision 5.10  1991/10/07  17:32:46  eggert
  87.  * Fix log bugs, e.g. ci -t/dev/null when has_mmap.
  88.  *
  89.  * Revision 5.9  1991/09/10  22:15:46  eggert
  90.  * Fix test for redirected stdin.
  91.  *
  92.  * Revision 5.8  1991/08/19  03:13:55  eggert
  93.  * Add piece tables.  Tune.
  94.  *
  95.  * Revision 5.7  1991/04/21  11:58:24  eggert
  96.  * Add MS-DOS support.
  97.  *
  98.  * Revision 5.6  1990/12/27  19:54:26  eggert
  99.  * Fix bug: rcs -t inserted \n, making RCS file grow.
  100.  *
  101.  * Revision 5.5  1990/12/04  05:18:45  eggert
  102.  * Use -I for prompts and -q for diagnostics.
  103.  *
  104.  * Revision 5.4  1990/11/01  05:03:47  eggert
  105.  * Add -I and new -t behavior.  Permit arbitrary data in logs.
  106.  *
  107.  * Revision 5.3  1990/09/21  06:12:43  hammer
  108.  * made putdesc() treat stdin the same whether or not it was from a terminal
  109.  * by making it recognize that a single '.' was then end of the
  110.  * description always
  111.  *
  112.  * Revision 5.2  1990/09/04  08:02:25  eggert
  113.  * Fix `co -p1.1 -ko' bug.  Standardize yes-or-no procedure.
  114.  *
  115.  * Revision 5.1  1990/08/29  07:14:01  eggert
  116.  * Clean old log messages too.
  117.  *
  118.  * Revision 5.0  1990/08/22  08:12:52  eggert
  119.  * Remove compile-time limits; use malloc instead.
  120.  * Ansify and Posixate.
  121.  *
  122.  * Revision 4.7  89/05/01  15:12:49  narten
  123.  * changed copyright header to reflect current distribution rules
  124.  * 
  125.  * Revision 4.6  88/08/28  14:59:10  eggert
  126.  * Shrink stdio code size; allow cc -R; remove lint; isatty() -> ttystdin()
  127.  * 
  128.  * Revision 4.5  87/12/18  11:43:25  narten
  129.  * additional lint cleanups, and a bug fix from the 4.3BSD version that
  130.  * keeps "ci" from sticking a '\377' into the description if you run it
  131.  * with a zero-length file as the description. (Guy Harris)
  132.  * 
  133.  * Revision 4.4  87/10/18  10:35:10  narten
  134.  * Updating version numbers. Changes relative to 1.1 actually relative to
  135.  * 4.2
  136.  * 
  137.  * Revision 1.3  87/09/24  13:59:51  narten
  138.  * Sources now pass through lint (if you ignore printf/sprintf/fprintf 
  139.  * warnings)
  140.  * 
  141.  * Revision 1.2  87/03/27  14:22:27  jenkins
  142.  * Port to suns
  143.  * 
  144.  * Revision 4.2  83/12/02  23:01:39  wft
  145.  * merged 4.1 and 3.3.1.1 (clearerr(stdin)).
  146.  * 
  147.  * Revision 4.1  83/05/10  16:03:33  wft
  148.  * Changed putamin() to abort if trying to reread redirected stdin.
  149.  * Fixed getdesc() to output a prompt on initial newline.
  150.  * 
  151.  * Revision 3.3.1.1  83/10/19  04:21:51  lepreau
  152.  * Added clearerr(stdin) for re-reading description from stdin.
  153.  * 
  154.  * Revision 3.3  82/11/28  21:36:49  wft
  155.  * 4.2 prerelease
  156.  * 
  157.  * Revision 3.3  82/11/28  21:36:49  wft
  158.  * Replaced ferror() followed by fclose() with ffclose().
  159.  * Putdesc() now suppresses the prompts if stdin
  160.  * is not a terminal. A pointer to the current log message is now
  161.  * inserted into the corresponding delta, rather than leaving it in a
  162.  * global variable.
  163.  *
  164.  * Revision 3.2  82/10/18  21:11:26  wft
  165.  * I added checks for write errors during editing, and improved
  166.  * the prompt on putdesc().
  167.  *
  168.  * Revision 3.1  82/10/13  15:55:09  wft
  169.  * corrected type of variables assigned to by getc (char --> int)
  170.  */
  171.  
  172.  
  173.  
  174.  
  175. #include "rcsbase.h"
  176.  
  177. libId(genId, "$Id: rcsgen.c,v 5.10 1991/10/07 17:32:46 eggert Exp $")
  178.  
  179. int interactiveflag;  /* Should we act as if stdin is a tty?  */
  180. struct buf curlogbuf;  /* buffer for current log message */
  181.  
  182. enum stringwork { enter, copy, edit, expand, edit_expand };
  183. static void scandeltatext P((struct hshentry*,enum stringwork,int));
  184.  
  185.  
  186.  
  187.  
  188.     char const *
  189. buildrevision(deltas, target, outfile, expandflag)
  190.     struct hshentries const *deltas;
  191.     struct hshentry *target;
  192.     FILE *outfile;
  193.     int expandflag;
  194. /* Function: Generates the revision given by target
  195.  * by retrieving all deltas given by parameter deltas and combining them.
  196.  * If outfile is set, the revision is output to it,
  197.  * otherwise written into a temporary file.
  198.  * Temporary files are allocated by maketemp().
  199.  * if expandflag is set, keyword expansion is performed.
  200.  * Return nil if outfile is set, the name of the temporary file otherwise.
  201.  *
  202.  * Algorithm: Copy initial revision unchanged.  Then edit all revisions but
  203.  * the last one into it, alternating input and output files (resultfile and
  204.  * editfile). The last revision is then edited in, performing simultaneous
  205.  * keyword substitution (this saves one extra pass).
  206.  * All this simplifies if only one revision needs to be generated,
  207.  * or no keyword expansion is necessary, or if output goes to stdout.
  208.  */
  209. {
  210.     if (deltas->first == target) {
  211.                 /* only latest revision to generate */
  212.         openfcopy(outfile);
  213.         scandeltatext(target, expandflag?expand:copy, true);
  214.         if (outfile)
  215.             return 0;
  216.         else {
  217.             Ozclose(&fcopy);
  218.                         return(resultfile);
  219.         }
  220.         } else {
  221.                 /* several revisions to generate */
  222.         /* Get initial revision without keyword expansion.  */
  223.         scandeltatext(deltas->first, enter, false);
  224.         while ((deltas=deltas->rest)->rest) {
  225.                         /* do all deltas except last one */
  226.             scandeltatext(deltas->first, edit, false);
  227.                 }
  228.         if (expandflag || outfile) {
  229.                         /* first, get to beginning of file*/
  230.             finishedit((struct hshentry *)nil, outfile, false);
  231.                 }
  232.         scandeltatext(deltas->first, expandflag?edit_expand:edit, true);
  233.         finishedit(
  234.             expandflag ? deltas->first : (struct hshentry*)nil,
  235.             outfile, true
  236.         );
  237.         if (outfile)
  238.             return 0;
  239.         Ozclose(&fcopy);
  240.         return resultfile;
  241.         }
  242. }
  243.  
  244.  
  245.  
  246.     static void
  247. scandeltatext(delta, func, needlog)
  248.     struct hshentry * delta;
  249.     enum stringwork func;
  250.     int needlog;
  251. /* Function: Scans delta text nodes up to and including the one given
  252.  * by delta. For the one given by delta, the log message is saved into
  253.  * delta->log if needlog is set; func specifies how to handle the text.
  254.  * Assumes the initial lexeme must be read in first.
  255.  * Does not advance nexttok after it is finished.
  256.  */
  257. {
  258.     struct hshentry const *nextdelta;
  259.     struct cbuf cb;
  260.  
  261.         for (;;) {
  262.         if (eoflex())
  263.             fatserror("can't find delta for revision %s", delta->num);
  264.                 nextlex();
  265.                 if (!(nextdelta=getnum())) {
  266.             fatserror("delta number corrupted");
  267.                 }
  268.         getkeystring(Klog);
  269.         if (needlog && delta==nextdelta) {
  270.             cb = savestring(&curlogbuf);
  271.             delta->log = cleanlogmsg(curlogbuf.string, cb.size);
  272.                 } else {readstring();
  273.                 }
  274.                 nextlex();
  275.         while (nexttok==ID && strcmp(NextString,Ktext)!=0)
  276.             ignorephrase();
  277.         getkeystring(Ktext);
  278.  
  279.         if (delta==nextdelta)
  280.             break;
  281.         readstring(); /* skip over it */
  282.  
  283.     }
  284.     switch (func) {
  285.         case enter: enterstring(); break;
  286.         case copy: copystring(); break;
  287.         case expand: xpandstring(delta); break;
  288.         case edit: editstring((struct hshentry *)nil); break;
  289.         case edit_expand: editstring(delta); break;
  290.     }
  291. }
  292.  
  293.     struct cbuf
  294. cleanlogmsg(m, s)
  295.     char *m;
  296.     size_t s;
  297. {
  298.     register char *t = m;
  299.     register char const *f = t;
  300.     struct cbuf r;
  301.     while (s) {
  302.         --s;
  303.         if ((*t++ = *f++) == '\n')
  304.         while (m < --t)
  305.             if (t[-1]!=' ' && t[-1]!='\t') {
  306.             *t++ = '\n';
  307.             break;
  308.             }
  309.     }
  310.     while (m < t  &&  (t[-1]==' ' || t[-1]=='\t' || t[-1]=='\n'))
  311.         --t;
  312.     r.string = m;
  313.     r.size = t - m;
  314.     return r;
  315. }
  316.  
  317.  
  318. int ttystdin()
  319. {
  320.     static int initialized;
  321.     if (!initialized) {
  322.         if (!interactiveflag)
  323.             interactiveflag = isatty(STDIN_FILENO);
  324.         initialized = true;
  325.     }
  326.     return interactiveflag;
  327. }
  328.  
  329.     int
  330. getcstdin()
  331. {
  332.     register FILE *in;
  333.     register int c;
  334.  
  335.     in = stdin;
  336.     if (feof(in) && ttystdin())
  337.         clearerr(in);
  338.     c = getc(in);
  339.     if (c < 0) {
  340.         testIerror(in);
  341.         if (feof(in) && ttystdin())
  342.             afputc('\n',stderr);
  343.     }
  344.     return c;
  345. }
  346.  
  347. #if has_prototypes
  348.     int
  349. yesorno(int default_answer, char const *question, ...)
  350. #else
  351.         /*VARARGS2*/ int
  352.     yesorno(default_answer, question, va_alist)
  353.         int default_answer; char const *question; va_dcl
  354. #endif
  355. {
  356.     va_list args;
  357.     register int c, r;
  358.     if (!quietflag && ttystdin()) {
  359.         oflush();
  360.         vararg_start(args, question);
  361.         fvfprintf(stderr, question, args);
  362.         va_end(args);
  363.         eflush();
  364.         r = c = getcstdin();
  365.         while (c!='\n' && !feof(stdin))
  366.             c = getcstdin();
  367.         if (r=='y' || r=='Y')
  368.             return true;
  369.         if (r=='n' || r=='N')
  370.             return false;
  371.     }
  372.     return default_answer;
  373. }
  374.  
  375.  
  376.     void
  377. putdesc(textflag, textfile)
  378.     int textflag;
  379.     char *textfile;
  380. /* Function: puts the descriptive text into file frewrite.
  381.  * if finptr && !textflag, the text is copied from the old description.
  382.  * Otherwise, if the textfile!=nil, the text is read from that
  383.  * file, or from stdin, if textfile==nil.
  384.  * A textfile with a leading '-' is treated as a string, not a file name.
  385.  * If finptr, the old descriptive text is discarded.
  386.  * Always clears foutptr.
  387.  */
  388. {
  389.     static struct buf desc;
  390.     static struct cbuf desclean;
  391.  
  392.     register FILE *txt;
  393.     register int c;
  394.     register FILE * frew;
  395.     register char *p;
  396.     register size_t s;
  397.     char const *plim;
  398.  
  399.     frew = frewrite;
  400.     if (finptr && !textflag) {
  401.                 /* copy old description */
  402.         aprintf(frew, "\n\n%s%c", Kdesc, nextc);
  403.         foutptr = frewrite;
  404.         getdesc(false);
  405.         foutptr = 0;
  406.         } else {
  407.         foutptr = 0;
  408.                 /* get new description */
  409.         if (finptr) {
  410.                         /*skip old description*/
  411.             getdesc(false);
  412.                 }
  413.         aprintf(frew,"\n\n%s\n%c",Kdesc,SDELIM);
  414.         if (!textfile)
  415.             desclean = getsstdin(
  416.                 "t-", "description",
  417.                 "NOTE: This is NOT the log message!\n", &desc
  418.             );
  419.         else if (!desclean.string) {
  420.             if (*textfile == '-') {
  421.                 p = textfile + 1;
  422.                 s = strlen(p);
  423.             } else {
  424.                 if (!(txt = fopen(textfile, "r")))
  425.                     efaterror(textfile);
  426.                 bufalloc(&desc, 1);
  427.                 p = desc.string;
  428.                 plim = p + desc.size;
  429.                 for (;;) {
  430.                     if ((c=getc(txt)) < 0) {
  431.                         testIerror(txt);
  432.                         if (feof(txt))
  433.                             break;
  434.                     }
  435.                     if (plim <= p)
  436.                         p = bufenlarge(&desc, &plim);
  437.                     *p++ = c;
  438.                 }
  439.                 if (fclose(txt) != 0)
  440.                     Ierror();
  441.                 s = p - desc.string;
  442.                 p = desc.string;
  443.             }
  444.             desclean = cleanlogmsg(p, s);
  445.         }
  446.         putstring(frew, false, desclean, true);
  447.         aputc('\n', frew);
  448.         }
  449. }
  450.  
  451.     struct cbuf
  452. getsstdin(option, name, note, buf)
  453.     char const *option, *name, *note;
  454.     struct buf *buf;
  455. {
  456.     register int c;
  457.     register char *p;
  458.     register size_t i;
  459.     register int tty = ttystdin();
  460.  
  461.     if (tty)
  462.         aprintf(stderr,
  463.         "enter %s, terminated with single '.' or end of file:\n%s>> ",
  464.         name, note
  465.         );
  466.     else if (feof(stdin))
  467.         faterror("can't reread redirected stdin for %s; use -%s<%s>",
  468.         name, option, name
  469.         );
  470.     
  471.     for (
  472.        i = 0,  p = 0;
  473.        c = getcstdin(),  !feof(stdin);
  474.        bufrealloc(buf, i+1),  p = buf->string,  p[i++] = c
  475.     )
  476.         if (c == '\n')
  477.             if (i  &&  p[i-1]=='.'  &&  (i==1 || p[i-2]=='\n')) {
  478.                 /* Remove trailing '.'.  */
  479.                 --i;
  480.                 break;
  481.             } else if (tty)
  482.                 aputs(">> ", stderr);
  483.     return cleanlogmsg(p, i);
  484. }
  485. @
  486.  
  487.  
  488. 5.10.1.1
  489. log
  490. @Start of the AMIGA port of RCS 5.6. I call it HWGRCS now ;^)
  491. @
  492. text
  493. @d2 1
  494. a2 1
  495.  *               RCS revision generation
  496. d34 1
  497. a34 1
  498.  * Revision 5.10  1991/10/07  17:32:46    eggert
  499. d53 1
  500. a53 1
  501.  * Add -I and new -t behavior.    Permit arbitrary data in logs.
  502. d72 1
  503. a72 1
  504.  *
  505. d75 1
  506. a75 1
  507.  *
  508. d80 1
  509. a80 1
  510.  *
  511. d84 1
  512. a84 1
  513.  *
  514. d86 1
  515. a86 1
  516.  * Sources now pass through lint (if you ignore printf/sprintf/fprintf
  517. d88 1
  518. a88 1
  519.  *
  520. d91 1
  521. a91 1
  522.  *
  523. d94 1
  524. a94 1
  525.  *
  526. d98 1
  527. a98 1
  528.  *
  529. d101 1
  530. a101 1
  531.  *
  532. d104 1
  533. a104 1
  534.  *
  535. d150 1
  536. a150 1
  537.  * Algorithm: Copy initial revision unchanged.    Then edit all revisions but
  538. d159 1
  539. a159 1
  540.         /* only latest revision to generate */
  541. d166 1
  542. a166 1
  543.             return(resultfile);
  544. d168 2
  545. a169 2
  546.     } else {
  547.         /* several revisions to generate */
  548. d173 1
  549. a173 1
  550.             /* do all deltas except last one */
  551. d175 1
  552. a175 1
  553.         }
  554. d177 1
  555. a177 1
  556.             /* first, get to beginning of file*/
  557. d179 1
  558. a179 1
  559.         }
  560. d189 1
  561. a189 1
  562.     }
  563. d209 1
  564. a209 1
  565.     for (;;) {
  566. d212 2
  567. a213 2
  568.         nextlex();
  569.         if (!(nextdelta=getnum())) {
  570. d215 1
  571. a215 1
  572.         }
  573. d220 3
  574. a222 3
  575.         } else {readstring();
  576.         }
  577.         nextlex();
  578. a282 4
  579. #ifdef AMIGA
  580.     eflush();
  581. #endif
  582.  
  583. d349 1
  584. a349 1
  585.         /* copy old description */
  586. d354 1
  587. a354 1
  588.     } else {
  589. d356 1
  590. a356 1
  591.         /* get new description */
  592. d358 1
  593. a358 1
  594.             /*skip old description*/
  595. d360 1
  596. a360 1
  597.         }
  598. d396 1
  599. a396 1
  600.     }
  601. d418 1
  602. a418 1
  603.  
  604. @
  605.  
  606.  
  607. 5.10.1.2
  608. log
  609. @Changed all checks for AMIGA to _AMIGA. This is more standard like
  610. and helps future updates. Major patch cleanup on the way.
  611. [Note: Added a VOID_CLOSEDIR define for this global change, too!]
  612. @
  613. text
  614. @d2 1
  615. a2 1
  616.  *                     RCS revision generation
  617. d34 1
  618. a34 4
  619.  * Revision 5.10.1.1  1993/01/18  14:38:34  heinz
  620.  * Start of the AMIGA port of RCS 5.6. I call it HWGRCS now ;^)
  621.  *
  622.  * Revision 5.10  1991/10/07  17:32:46  eggert
  623. d53 1
  624. a53 1
  625.  * Add -I and new -t behavior.  Permit arbitrary data in logs.
  626. d125 1
  627. a125 1
  628. libId(genId, "$Id: rcsgen.c,v 5.10.1.1 1993/01/18 14:38:34 heinz Exp heinz $")
  629. d136 1
  630. a136 1
  631.         char const *
  632. d138 4
  633. a141 4
  634.         struct hshentries const *deltas;
  635.         struct hshentry *target;
  636.         FILE *outfile;
  637.         int expandflag;
  638. d150 1
  639. a150 1
  640.  * Algorithm: Copy initial revision unchanged.  Then edit all revisions but
  641. d158 32
  642. a189 32
  643.         if (deltas->first == target) {
  644.                 /* only latest revision to generate */
  645.                 openfcopy(outfile);
  646.                 scandeltatext(target, expandflag?expand:copy, true);
  647.                 if (outfile)
  648.                         return 0;
  649.                 else {
  650.                         Ozclose(&fcopy);
  651.                         return(resultfile);
  652.                 }
  653.         } else {
  654.                 /* several revisions to generate */
  655.                 /* Get initial revision without keyword expansion.  */
  656.                 scandeltatext(deltas->first, enter, false);
  657.                 while ((deltas=deltas->rest)->rest) {
  658.                         /* do all deltas except last one */
  659.                         scandeltatext(deltas->first, edit, false);
  660.                 }
  661.                 if (expandflag || outfile) {
  662.                         /* first, get to beginning of file*/
  663.                         finishedit((struct hshentry *)nil, outfile, false);
  664.                 }
  665.                 scandeltatext(deltas->first, expandflag?edit_expand:edit, true);
  666.                 finishedit(
  667.                         expandflag ? deltas->first : (struct hshentry*)nil,
  668.                         outfile, true
  669.                 );
  670.                 if (outfile)
  671.                         return 0;
  672.                 Ozclose(&fcopy);
  673.                 return resultfile;
  674.         }
  675. d194 1
  676. a194 1
  677.         static void
  678. d196 3
  679. a198 3
  680.         struct hshentry * delta;
  681.         enum stringwork func;
  682.         int needlog;
  683. d206 2
  684. a207 2
  685.         struct hshentry const *nextdelta;
  686.         struct cbuf cb;
  687. d209 30
  688. a238 30
  689.         for (;;) {
  690.                 if (eoflex())
  691.                     fatserror("can't find delta for revision %s", delta->num);
  692.                 nextlex();
  693.                 if (!(nextdelta=getnum())) {
  694.                     fatserror("delta number corrupted");
  695.                 }
  696.                 getkeystring(Klog);
  697.                 if (needlog && delta==nextdelta) {
  698.                         cb = savestring(&curlogbuf);
  699.                         delta->log = cleanlogmsg(curlogbuf.string, cb.size);
  700.                 } else {readstring();
  701.                 }
  702.                 nextlex();
  703.                 while (nexttok==ID && strcmp(NextString,Ktext)!=0)
  704.                         ignorephrase();
  705.                 getkeystring(Ktext);
  706.  
  707.                 if (delta==nextdelta)
  708.                         break;
  709.                 readstring(); /* skip over it */
  710.  
  711.         }
  712.         switch (func) {
  713.                 case enter: enterstring(); break;
  714.                 case copy: copystring(); break;
  715.                 case expand: xpandstring(delta); break;
  716.                 case edit: editstring((struct hshentry *)nil); break;
  717.                 case edit_expand: editstring(delta); break;
  718.         }
  719. d241 1
  720. a241 1
  721.         struct cbuf
  722. d243 2
  723. a244 2
  724.         char *m;
  725.         size_t s;
  726. d246 17
  727. a262 17
  728.         register char *t = m;
  729.         register char const *f = t;
  730.         struct cbuf r;
  731.         while (s) {
  732.             --s;
  733.             if ((*t++ = *f++) == '\n')
  734.                 while (m < --t)
  735.                     if (t[-1]!=' ' && t[-1]!='\t') {
  736.                         *t++ = '\n';
  737.                         break;
  738.                     }
  739.         }
  740.         while (m < t  &&  (t[-1]==' ' || t[-1]=='\t' || t[-1]=='\n'))
  741.             --t;
  742.         r.string = m;
  743.         r.size = t - m;
  744.         return r;
  745. d268 7
  746. a274 7
  747.         static int initialized;
  748.         if (!initialized) {
  749.                 if (!interactiveflag)
  750.                         interactiveflag = isatty(STDIN_FILENO);
  751.                 initialized = true;
  752.         }
  753.         return interactiveflag;
  754. d277 1
  755. a277 1
  756.         int
  757. d280 2
  758. a281 2
  759.         register FILE *in;
  760.         register int c;
  761. d283 3
  762. a285 9
  763. #ifdef _AMIGA
  764. /* As standard buffering is line buffering, it is wise to flush this output
  765.    channel before reading in a user response. The user wants to see some
  766.    text, I guess. I am not sureif this is a bug fix or an "Amiga Only"
  767.    patch
  768. */
  769.  
  770.         eflush();
  771. #endif /* _AMIGA */
  772. d287 10
  773. a296 10
  774.         in = stdin;
  775.         if (feof(in) && ttystdin())
  776.                 clearerr(in);
  777.         c = getc(in);
  778.         if (c < 0) {
  779.                 testIerror(in);
  780.                 if (feof(in) && ttystdin())
  781.                         afputc('\n',stderr);
  782.         }
  783.         return c;
  784. d300 1
  785. a300 1
  786.         int
  787. d303 3
  788. a305 3
  789.                 /*VARARGS2*/ int
  790.         yesorno(default_answer, question, va_alist)
  791.                 int default_answer; char const *question; va_dcl
  792. d308 17
  793. a324 17
  794.         va_list args;
  795.         register int c, r;
  796.         if (!quietflag && ttystdin()) {
  797.                 oflush();
  798.                 vararg_start(args, question);
  799.                 fvfprintf(stderr, question, args);
  800.                 va_end(args);
  801.                 eflush();
  802.                 r = c = getcstdin();
  803.                 while (c!='\n' && !feof(stdin))
  804.                         c = getcstdin();
  805.                 if (r=='y' || r=='Y')
  806.                         return true;
  807.                 if (r=='n' || r=='N')
  808.                         return false;
  809.         }
  810.         return default_answer;
  811. d328 1
  812. a328 1
  813.         void
  814. d330 2
  815. a331 2
  816.         int textflag;
  817.         char *textfile;
  818. d341 2
  819. a342 2
  820.         static struct buf desc;
  821.         static struct cbuf desclean;
  822. d344 57
  823. a400 57
  824.         register FILE *txt;
  825.         register int c;
  826.         register FILE * frew;
  827.         register char *p;
  828.         register size_t s;
  829.         char const *plim;
  830.  
  831.         frew = frewrite;
  832.         if (finptr && !textflag) {
  833.                 /* copy old description */
  834.                 aprintf(frew, "\n\n%s%c", Kdesc, nextc);
  835.                 foutptr = frewrite;
  836.                 getdesc(false);
  837.                 foutptr = 0;
  838.         } else {
  839.                 foutptr = 0;
  840.                 /* get new description */
  841.                 if (finptr) {
  842.                         /*skip old description*/
  843.                         getdesc(false);
  844.                 }
  845.                 aprintf(frew,"\n\n%s\n%c",Kdesc,SDELIM);
  846.                 if (!textfile)
  847.                         desclean = getsstdin(
  848.                                 "t-", "description",
  849.                                 "NOTE: This is NOT the log message!\n", &desc
  850.                         );
  851.                 else if (!desclean.string) {
  852.                         if (*textfile == '-') {
  853.                                 p = textfile + 1;
  854.                                 s = strlen(p);
  855.                         } else {
  856.                                 if (!(txt = fopen(textfile, "r")))
  857.                                         efaterror(textfile);
  858.                                 bufalloc(&desc, 1);
  859.                                 p = desc.string;
  860.                                 plim = p + desc.size;
  861.                                 for (;;) {
  862.                                         if ((c=getc(txt)) < 0) {
  863.                                                 testIerror(txt);
  864.                                                 if (feof(txt))
  865.                                                         break;
  866.                                         }
  867.                                         if (plim <= p)
  868.                                             p = bufenlarge(&desc, &plim);
  869.                                         *p++ = c;
  870.                                 }
  871.                                 if (fclose(txt) != 0)
  872.                                         Ierror();
  873.                                 s = p - desc.string;
  874.                                 p = desc.string;
  875.                         }
  876.                         desclean = cleanlogmsg(p, s);
  877.                 }
  878.                 putstring(frew, false, desclean, true);
  879.                 aputc('\n', frew);
  880.         }
  881. d403 1
  882. a403 1
  883.         struct cbuf
  884. d405 2
  885. a406 2
  886.         char const *option, *name, *note;
  887.         struct buf *buf;
  888. d408 28
  889. a435 28
  890.         register int c;
  891.         register char *p;
  892.         register size_t i;
  893.         register int tty = ttystdin();
  894.  
  895.         if (tty)
  896.             aprintf(stderr,
  897.                 "enter %s, terminated with single '.' or end of file:\n%s>> ",
  898.                 name, note
  899.             );
  900.         else if (feof(stdin))
  901.             faterror("can't reread redirected stdin for %s; use -%s<%s>",
  902.                 name, option, name
  903.             );
  904.  
  905.         for (
  906.            i = 0,  p = 0;
  907.            c = getcstdin(),  !feof(stdin);
  908.            bufrealloc(buf, i+1),  p = buf->string,  p[i++] = c
  909.         )
  910.                 if (c == '\n')
  911.                         if (i  &&  p[i-1]=='.'  &&  (i==1 || p[i-2]=='\n')) {
  912.                                 /* Remove trailing '.'.  */
  913.                                 --i;
  914.                                 break;
  915.                         } else if (tty)
  916.                                 aputs(">> ", stderr);
  917.         return cleanlogmsg(p, i);
  918. @
  919.  
  920.  
  921. 5.10.1.3
  922. log
  923. @Some cosmetic changes to prepare for test diffing to the RCS5.6.0.1
  924. sources.
  925. @
  926. text
  927. @a33 5
  928.  * Revision 5.10.1.2  1993/12/18  16:12:22  heinz
  929.  * Changed all checks for AMIGA to _AMIGA. This is more standard like
  930.  * and helps future updates. Major patch cleanup on the way.
  931.  * [Note: Added a VOID_CLOSEDIR define for this global change, too!]
  932.  *
  933. d128 1
  934. a128 1
  935. libId(genId, "$Id: rcsgen.c,v 5.10.1.2 1993/12/18 16:12:22 heinz Exp heinz $")
  936. d287 4
  937. a290 4
  938. /* As standard buffering is line buffering with SAS/C, it is wise to flush
  939.    this output channel before reading in a user response. The user wants to
  940.    see some text, I guess. I am not sure if this is a bug fix or an "Amiga
  941.    only" patch. Anyway, it can't hurt, I guess.
  942. d295 1
  943. @
  944.