home *** CD-ROM | disk | FTP | other *** search
- head 5.4;
- branch 5.4.1;
- access;
- symbols
- HWGRCSP12F:5.4.1.4
- HWGRCSP11F:5.4.1.4
- HWGRCSP10F:5.4.1.4
- HWGRCSP9:5.4.1.4
- HWGRCSP8F:5.4.1.4
- HWGRCSP7F:5.4.1.1
- HWGRCSP6F:5.4.1.1
- HWGRCSP5F:5.4.1.1
- HWGRCSp4:5.4.1.1
- HWGRCSp3:5.4.1
- HWGRCS_Fish:5.4.1
- HWGRCS:5.4.1;
- locks; strict;
- comment @ * @;
-
-
- 5.4
- date 91.08.19.03.13.55; author eggert; state Exp;
- branches
- 5.4.1.1;
- next ;
-
- 5.4.1.1
- date 93.01.18.14.38.39; author heinz; state Exp;
- branches;
- next 5.4.1.2;
-
- 5.4.1.2
- date 94.02.12.19.20.21; author heinz; state Exp;
- branches;
- next 5.4.1.3;
-
- 5.4.1.3
- date 94.02.14.19.29.45; author heinz; state Exp;
- branches;
- next 5.4.1.4;
-
- 5.4.1.4
- date 94.03.14.09.22.13; author heinz; state Exp;
- branches;
- next ;
-
-
- desc
- @Checked in with -k 16.jan.93 HWG
- @
-
-
- 5.4
- log
- @checked in with -k by heinz at 1993/01/17 01:53:17
- @
- text
- @/*
- * RCS keyword extraction
- */
- /*****************************************************************************
- * main routine: getoldkeys()
- * Testprogram: define KEEPTEST
- *****************************************************************************
- */
-
- /* Copyright (C) 1982, 1988, 1989 Walter Tichy
- Copyright 1990, 1991 by Paul Eggert
- Distributed under license by the Free Software Foundation, Inc.
-
- This file is part of RCS.
-
- RCS is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- RCS is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with RCS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
- Report problems and direct all questions to:
-
- rcs-bugs@@cs.purdue.edu
-
- */
-
-
-
- /* $Log: rcskeep.c,v $
- * Revision 5.4 1991/08/19 03:13:55 eggert
- * Tune.
- *
- * Revision 5.3 1991/04/21 11:58:25 eggert
- * Shorten names to keep them distinct on shortname hosts.
- *
- * Revision 5.2 1990/10/04 06:30:20 eggert
- * Parse time zone offsets; future RCS versions may output them.
- *
- * Revision 5.1 1990/09/20 02:38:56 eggert
- * ci -k now checks dates more thoroughly.
- *
- * Revision 5.0 1990/08/22 08:12:53 eggert
- * Retrieve old log message if there is one.
- * Don't require final newline.
- * Remove compile-time limits; use malloc instead. Tune.
- * Permit dates past 1999/12/31. Ansify and Posixate.
- *
- * Revision 4.6 89/05/01 15:12:56 narten
- * changed copyright header to reflect current distribution rules
- *
- * Revision 4.5 88/08/09 19:13:03 eggert
- * Remove lint and speed up by making FILE *fp local, not global.
- *
- * Revision 4.4 87/12/18 11:44:21 narten
- * more lint cleanups (Guy Harris)
- *
- * Revision 4.3 87/10/18 10:35:50 narten
- * Updating version numbers. Changes relative to 1.1 actually relative
- * to 4.1
- *
- * Revision 1.3 87/09/24 14:00:00 narten
- * Sources now pass through lint (if you ignore printf/sprintf/fprintf
- * warnings)
- *
- * Revision 1.2 87/03/27 14:22:29 jenkins
- * Port to suns
- *
- * Revision 4.1 83/05/10 16:26:44 wft
- * Added new markers Id and RCSfile; extraction added.
- * Marker matching with trymatch().
- *
- * Revision 3.2 82/12/24 12:08:26 wft
- * added missing #endif.
- *
- * Revision 3.1 82/12/04 13:22:41 wft
- * Initial revision.
- *
- */
-
- /*
- #define KEEPTEST
- */
- /* Testprogram; prints out the keyword values found. */
-
- #include "rcsbase.h"
-
- libId(keepId, "$Id: rcskeep.c,v 5.4 1991/08/19 03:13:55 eggert Exp $")
-
- static int checknum P((char const*,int));
- static int getval P((RILE*,struct buf*,int));
- static int get0val P((int,RILE*,struct buf*,int));
- static int keepdate P((RILE*));
- static int keepid P((int,RILE*,struct buf*));
- static int keeprev P((RILE*));
-
- int prevkeys;
- struct buf prevauthor, prevdate, prevrev, prevstate;
-
- int
- getoldkeys(fp)
- register RILE *fp;
- /* Function: Tries to read keyword values for author, date,
- * revision number, and state out of the file fp.
- * If FNAME is nonnull, it is opened and closed instead of using FP.
- * The results are placed into
- * prevauthor, prevdate, prevrev, prevstate.
- * Aborts immediately if it finds an error and returns false.
- * If it returns true, it doesn't mean that any of the
- * values were found; instead, check to see whether the corresponding arrays
- * contain the empty string.
- */
- {
- register int c;
- char keyword[keylength+1];
- register char * tp;
- int needs_closing;
-
- if (prevkeys)
- return true;
-
- needs_closing = false;
- if (!fp) {
- if (!(fp = Iopen(workfilename, FOPEN_R_WORK, (struct stat*)0))) {
- eerror(workfilename);
- return false;
- }
- needs_closing = true;
- }
-
- /* initialize to empty */
- bufscpy(&prevauthor, "");
- bufscpy(&prevdate, "");
- bufscpy(&prevrev, "");
- bufscpy(&prevstate, "");
-
- c = '\0'; /* anything but KDELIM */
- for (;;) {
- if ( c==KDELIM) {
- do {
- /* try to get keyword */
- tp = keyword;
- for (;;) {
- Igeteof(fp, c, goto ok;);
- switch (c) {
- default:
- if (keyword+keylength <= tp)
- break;
- *tp++ = c;
- continue;
-
- case '\n': case KDELIM: case VDELIM:
- break;
- }
- break;
- }
- } while (c==KDELIM);
- if (c!=VDELIM) continue;
- *tp = c;
- Igeteof(fp, c, break;);
- switch (c) {
- case ' ': case '\t': break;
- default: continue;
- }
-
- switch (trymatch(keyword)) {
- case Author:
- if (!keepid(0, fp, &prevauthor))
- return false;
- c = 0;
- break;
- case Date:
- if (!(c = keepdate(fp)))
- return false;
- break;
- case Header:
- case Id:
- if (!(
- getval(fp, (struct buf*)nil, false) &&
- keeprev(fp) &&
- (c = keepdate(fp)) &&
- keepid(c, fp, &prevauthor) &&
- keepid(0, fp, &prevstate)
- ))
- return false;
- /* Skip either ``who'' (new form) or ``Locker: who'' (old). */
- if (getval(fp, (struct buf*)nil, true) &&
- getval(fp, (struct buf*)nil, true))
- c = 0;
- else if (nerror)
- return false;
- else
- c = KDELIM;
- break;
- case Locker:
- case Log:
- case RCSfile:
- case Source:
- if (!getval(fp, (struct buf*)nil, false))
- return false;
- c = 0;
- break;
- case Revision:
- if (!keeprev(fp))
- return false;
- c = 0;
- break;
- case State:
- if (!keepid(0, fp, &prevstate))
- return false;
- c = 0;
- break;
- default:
- continue;
- }
- if (!c)
- Igeteof(fp, c, c=0;);
- if (c != KDELIM) {
- error("closing %c missing on keyword", KDELIM);
- return false;
- }
- if (*prevauthor.string && *prevdate.string && *prevrev.string && *prevstate.string) {
- break;
- }
- }
- Igeteof(fp, c, break;);
- }
-
- ok:
- if (needs_closing)
- Ifclose(fp);
- else
- Irewind(fp);
- prevkeys = true;
- return true;
- }
-
- static int
- badly_terminated()
- {
- error("badly terminated keyword value");
- return false;
- }
-
- static int
- getval(fp, target, optional)
- register RILE *fp;
- struct buf *target;
- int optional;
- /* Reads a keyword value from FP into TARGET.
- * Returns true if one is found, false otherwise.
- * Does not modify target if it is nil.
- * Do not report an error if OPTIONAL is set and KDELIM is found instead.
- */
- {
- int c;
- Igeteof(fp, c, return badly_terminated(););
- return get0val(c, fp, target, optional);
- }
-
- static int
- get0val(c, fp, target, optional)
- register int c;
- register RILE *fp;
- struct buf *target;
- int optional;
- /* Reads a keyword value from C+FP into TARGET, perhaps OPTIONALly.
- * Same as getval, except C is the lookahead character.
- */
- { register char * tp;
- char const *tlim;
- register int got1;
-
- if (target) {
- bufalloc(target, 1);
- tp = target->string;
- tlim = tp + target->size;
- } else
- tlim = tp = 0;
- got1 = false;
- for (;;) {
- switch (c) {
- default:
- got1 = true;
- if (tp) {
- *tp++ = c;
- if (tlim <= tp)
- tp = bufenlarge(target, &tlim);
- }
- break;
-
- case ' ':
- case '\t':
- if (tp) {
- *tp = 0;
- # ifdef KEEPTEST
- VOID printf("getval: %s\n", target);
- # endif
- }
- if (!got1)
- error("too much white space in keyword value");
- return got1;
-
- case KDELIM:
- if (!got1 && optional)
- return false;
- /* fall into */
- case '\n':
- case 0:
- return badly_terminated();
- }
- Igeteof(fp, c, return badly_terminated(););
- }
- }
-
-
- static int
- keepdate(fp)
- RILE *fp;
- /* Function: reads a date prevdate; checks format
- * Return 0 on error, lookahead character otherwise.
- */
- {
- struct buf prevday, prevtime, prevzone;
- register char const *p;
- register int c;
-
- c = 0;
- bufautobegin(&prevday);
- if (getval(fp,&prevday,false)) {
- bufautobegin(&prevtime);
- if (getval(fp,&prevtime,false)) {
- bufautobegin(&prevzone);
- bufscpy(&prevzone, "");
- Igeteof(fp, c, c=0;);
- if (c=='-' || c=='+')
- if (!get0val(c,fp,&prevzone,false))
- c = 0;
- else
- Igeteof(fp, c, c=0;);
- if (c) {
- p = prevday.string;
- bufalloc(&prevdate, strlen(p) + strlen(prevtime.string) + strlen(prevzone.string) + 5);
- VOID sprintf(prevdate.string, "%s%s %s %s",
- /* Parse dates put out by old versions of RCS. */
- isdigit(p[0]) && isdigit(p[1]) && p[2]=='/' ? "19" : "",
- p, prevtime.string, prevzone.string
- );
- }
- bufautoend(&prevzone);
- }
- bufautoend(&prevtime);
- }
- bufautoend(&prevday);
- return c;
- }
-
- static int
- keepid(c, fp, b)
- int c;
- RILE *fp;
- struct buf *b;
- /* Get previous identifier from C+FP into B. */
- {
- if (!c)
- Igeteof(fp, c, return false;);
- if (!get0val(c, fp, b, false))
- return false;
- checksid(b->string);
- return true;
- }
-
- static int
- keeprev(fp)
- RILE *fp;
- /* Get previous revision from FP into prevrev. */
- {
- return getval(fp,&prevrev,false) && checknum(prevrev.string,-1);
- }
-
-
- static int
- checknum(sp,fields)
- register char const *sp;
- int fields;
- { register int dotcount;
- dotcount=0;
- while(*sp) {
- if (*sp=='.') dotcount++;
- else if (!isdigit(*sp)) return false;
- sp++;
- }
- return fields<0 ? dotcount&1 : dotcount==fields;
- }
-
-
-
- #ifdef KEEPTEST
-
- char const cmdid[] ="keeptest";
-
- int
- main(argc, argv)
- int argc; char *argv[];
- {
- while (*(++argv)) {
- workfilename = *argv;
- getoldkeys((RILE*)0);
- VOID printf("%s: revision: %s, date: %s, author: %s, state: %s\n",
- *argv, prevrev.string, prevdate.string, prevauthor.string, prevstate.string);
- }
- exitmain(EXIT_SUCCESS);
- }
- #endif
- @
-
-
- 5.4.1.1
- log
- @Start of the AMIGA port of RCS 5.6. I call it HWGRCS now ;^)
- @
- text
- @@
-
-
- 5.4.1.2
- log
- @Support for the new keywords VER, AmigaREV, and AmigaProtection.
- @
- text
- @a38 3
- * Revision 5.4.1.1 1993/01/18 14:38:39 heinz
- * Start of the AMIGA port of RCS 5.6. I call it HWGRCS now ;^)
- *
- d59 1
- a59 1
- *
- d62 1
- a62 1
- *
- d65 1
- a65 1
- *
- d69 1
- a69 1
- *
- d71 1
- a71 1
- * Sources now pass through lint (if you ignore printf/sprintf/fprintf
- d73 1
- a73 1
- *
- d76 1
- a76 1
- *
- d80 1
- a80 1
- *
- d96 1
- a96 1
- libId(keepId, "$Id: rcskeep.c,v 5.4.1.1 1993/01/18 14:38:39 heinz Exp heinz $")
- a106 13
- #ifdef _AMIGA
- /* This is a function similar to getval, but it reads anything up to
- '\n' or KDELIM into the target!
- */
- static int
- linegetval(RILE *fp, struct buf *target, int readkdelim)
- /* Reads a keyword value from C+FP into TARGET, perhaps OPTIONALly.
- * Same as getval, except C is the lookahead character.
- */
- {
- char * tp;
- char const *tlim;
- int got1, c;
- d108 1
- a108 44
- Igeteof(fp, c, return false;);
- if (target)
- {
- bufalloc(target, 1);
- tp = target->string;
- tlim = tp + target->size;
- }
- else
- {
- tlim = tp = 0;
- } /* if */
-
- got1 = false;
- for (;;)
- {
- if(c && c != '\n' && (c != KDELIM || readkdelim))
- {
- got1 = true;
- if (tp)
- {
- *tp++ = c;
- if (tlim <= tp)
- tp = bufenlarge(target, &tlim);
- } /* if */
- } /* if */
-
- if(!c || c == KDELIM || c == '\n')
- {
- if (tp)
- {
- *tp = 0;
- } /* if */
- if (!got1)
- error("too much white space in keyword value");
- return true;
- } /* if */
- Igeteof(fp, c, return false;);
- } /* for */
-
- } /* linegetval */
-
- #endif /* _AMIGA */
-
- int
- d110 1
- a110 1
- register RILE *fp;
- d128 1
- a128 1
- return true;
- d132 5
- a136 5
- if (!(fp = Iopen(workfilename, FOPEN_R_WORK, (struct stat*)0))) {
- eerror(workfilename);
- return false;
- }
- needs_closing = true;
- d148 18
- a165 18
- do {
- /* try to get keyword */
- tp = keyword;
- for (;;) {
- Igeteof(fp, c, goto ok;);
- switch (c) {
- default:
- if (keyword+keylength <= tp)
- break;
- *tp++ = c;
- continue;
-
- case '\n': case KDELIM: case VDELIM:
- break;
- }
- break;
- }
- } while (c==KDELIM);
- d167 6
- a172 6
- *tp = c;
- Igeteof(fp, c, break;);
- switch (c) {
- case ' ': case '\t': break;
- default: continue;
- }
- d174 1
- a174 1
- switch (trymatch(keyword)) {
- d176 3
- a178 3
- if (!keepid(0, fp, &prevauthor))
- return false;
- c = 0;
- d181 2
- a182 2
- if (!(c = keepdate(fp)))
- return false;
- d186 17
- a202 17
- if (!(
- getval(fp, (struct buf*)nil, false) &&
- keeprev(fp) &&
- (c = keepdate(fp)) &&
- keepid(c, fp, &prevauthor) &&
- keepid(0, fp, &prevstate)
- ))
- return false;
- /* Skip either ``who'' (new form) or ``Locker: who'' (old). */
- if (getval(fp, (struct buf*)nil, true) &&
- getval(fp, (struct buf*)nil, true))
- c = 0;
- else if (nerror)
- return false;
- else
- c = KDELIM;
- break;
- d207 3
- a209 3
- if (!getval(fp, (struct buf*)nil, false))
- return false;
- c = 0;
- d212 3
- a214 3
- if (!keeprev(fp))
- return false;
- c = 0;
- d217 3
- a219 19
- if (!keepid(0, fp, &prevstate))
- return false;
- c = 0;
- break;
- #ifdef _AMIGA
- case CBMVersion:
- if (!linegetval(fp, (struct buf*)nil, true))
- return false;
- c = KDELIM;
- break;
- case CBMRevision:
- if (!linegetval(fp, (struct buf*)nil, false))
- return false;
- c = 0;
- break;
- case CBMProtection:
- if (!linegetval(fp, (struct buf*)nil, false))
- return false;
- c = 0;
- a220 1
- #endif /* _AMIGA */
- d224 7
- a230 7
- if (!c)
- Igeteof(fp, c, c=0;);
- if (c != KDELIM) {
- error("closing %c missing on keyword", KDELIM);
- return false;
- }
- if (*prevauthor.string && *prevdate.string && *prevrev.string && *prevstate.string) {
- d234 1
- a234 1
- Igeteof(fp, c, break;);
- d239 1
- a239 1
- Ifclose(fp);
- d241 1
- a241 1
- Irewind(fp);
- d246 1
- a246 1
- static int
- d249 2
- a250 2
- error("badly terminated keyword value");
- return false;
- d253 1
- a253 1
- static int
- d255 3
- a257 3
- register RILE *fp;
- struct buf *target;
- int optional;
- d264 3
- a266 3
- int c;
- Igeteof(fp, c, return badly_terminated(););
- return get0val(c, fp, target, optional);
- d269 1
- a269 1
- static int
- d271 4
- a274 4
- register int c;
- register RILE *fp;
- struct buf *target;
- int optional;
- d283 3
- a285 3
- bufalloc(target, 1);
- tp = target->string;
- tlim = tp + target->size;
- d287 1
- a287 1
- tlim = tp = 0;
- d290 31
- a320 31
- switch (c) {
- default:
- got1 = true;
- if (tp) {
- *tp++ = c;
- if (tlim <= tp)
- tp = bufenlarge(target, &tlim);
- }
- break;
-
- case ' ':
- case '\t':
- if (tp) {
- *tp = 0;
- # ifdef KEEPTEST
- VOID printf("getval: %s\n", target);
- # endif
- }
- if (!got1)
- error("too much white space in keyword value");
- return got1;
-
- case KDELIM:
- if (!got1 && optional)
- return false;
- /* fall into */
- case '\n':
- case 0:
- return badly_terminated();
- }
- Igeteof(fp, c, return badly_terminated(););
- d325 1
- a325 1
- static int
- d327 1
- a327 1
- RILE *fp;
- d339 22
- a360 22
- bufautobegin(&prevtime);
- if (getval(fp,&prevtime,false)) {
- bufautobegin(&prevzone);
- bufscpy(&prevzone, "");
- Igeteof(fp, c, c=0;);
- if (c=='-' || c=='+')
- if (!get0val(c,fp,&prevzone,false))
- c = 0;
- else
- Igeteof(fp, c, c=0;);
- if (c) {
- p = prevday.string;
- bufalloc(&prevdate, strlen(p) + strlen(prevtime.string) + strlen(prevzone.string) + 5);
- VOID sprintf(prevdate.string, "%s%s %s %s",
- /* Parse dates put out by old versions of RCS. */
- isdigit(p[0]) && isdigit(p[1]) && p[2]=='/' ? "19" : "",
- p, prevtime.string, prevzone.string
- );
- }
- bufautoend(&prevzone);
- }
- bufautoend(&prevtime);
- d366 1
- a366 1
- static int
- d368 3
- a370 3
- int c;
- RILE *fp;
- struct buf *b;
- d373 6
- a378 6
- if (!c)
- Igeteof(fp, c, return false;);
- if (!get0val(c, fp, b, false))
- return false;
- checksid(b->string);
- return true;
- d381 1
- a381 1
- static int
- d383 1
- a383 1
- RILE *fp;
- d386 1
- a386 1
- return getval(fp,&prevrev,false) && checknum(prevrev.string,-1);
- d390 1
- a390 1
- static int
- d392 2
- a393 2
- register char const *sp;
- int fields;
- d398 1
- a398 1
- else if (!isdigit(*sp)) return false;
- d410 1
- a410 1
- int
- d415 2
- a416 2
- workfilename = *argv;
- getoldkeys((RILE*)0);
- d418 3
- a420 3
- *argv, prevrev.string, prevdate.string, prevauthor.string, prevstate.string);
- }
- exitmain(EXIT_SUCCESS);
- @
-
-
- 5.4.1.3
- log
- @First version of Amiga keywords implemented. Ugly, but acceptable for now.
- @
- text
- @a38 3
- * Revision 5.4.1.2 1994/02/12 19:20:21 heinz
- * Support for the new keywords VER, AmigaREV, and AmigaProtection.
- *
- d99 1
- a99 1
- libId(keepId, "$Id: rcskeep.c,v 5.4.1.2 1994/02/12 19:20:21 heinz Exp heinz $")
- d287 4
- a290 1
- case CBMDate:
- @
-
-
- 5.4.1.4
- log
- @Oops. Wrong delimiter corrected.
- @
- text
- @a38 3
- * Revision 5.4.1.3 1994/02/14 19:29:45 heinz
- * First version of Amiga keywords implemented. Ugly, but acceptable for now.
- *
- d102 1
- a102 1
- libId(keepId, "$Id: rcskeep.c,v 5.4.1.3 1994/02/14 19:29:45 heinz Exp heinz $")
- d294 1
- a294 1
- c = KDELIM;
- @
-