aboutsummaryrefslogtreecommitdiff
path: root/gnu/usr.bin/rcs/lib
diff options
context:
space:
mode:
authorPeter Wemm <peter@FreeBSD.org>1995-10-28 21:07:39 +0000
committerPeter Wemm <peter@FreeBSD.org>1995-10-28 21:07:39 +0000
commit7603e8a868f58e967c8b70bb8c2f519357ed147a (patch)
tree7114793938194c2cf26e17493ee035b1ed47dd97 /gnu/usr.bin/rcs/lib
parent8b9b0e39a75a4e5a037baa4a8bafd9579ff90aa3 (diff)
parent5b4f007e0b8943a496b1f8ba2392e39b3b188fa5 (diff)
Notes
Diffstat (limited to 'gnu/usr.bin/rcs/lib')
-rw-r--r--gnu/usr.bin/rcs/lib/maketime.h39
-rw-r--r--gnu/usr.bin/rcs/lib/merger.c77
-rw-r--r--gnu/usr.bin/rcs/lib/partime.h71
-rw-r--r--gnu/usr.bin/rcs/lib/rcsmap.c9
-rw-r--r--gnu/usr.bin/rcs/lib/rcstime.c191
-rw-r--r--gnu/usr.bin/rcs/lib/version.c2
6 files changed, 351 insertions, 38 deletions
diff --git a/gnu/usr.bin/rcs/lib/maketime.h b/gnu/usr.bin/rcs/lib/maketime.h
new file mode 100644
index 000000000000..fbe12562051d
--- /dev/null
+++ b/gnu/usr.bin/rcs/lib/maketime.h
@@ -0,0 +1,39 @@
+/* Yield time_t from struct partime yielded by partime. */
+
+/* Copyright 1993, 1994, 1995 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,
+59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+Report problems and direct all questions to:
+
+ rcs-bugs@cs.purdue.edu
+
+*/
+
+#if defined(__STDC__) || has_prototypes
+# define __MAKETIME_P(x) x
+#else
+# define __MAKETIME_P(x) ()
+#endif
+
+struct tm *time2tm __MAKETIME_P((time_t,int));
+time_t difftm __MAKETIME_P((struct tm const *, struct tm const *));
+time_t str2time __MAKETIME_P((char const *, time_t, long));
+time_t tm2time __MAKETIME_P((struct tm *, int));
+void adjzone __MAKETIME_P((struct tm *, long));
diff --git a/gnu/usr.bin/rcs/lib/merger.c b/gnu/usr.bin/rcs/lib/merger.c
index 7162ffa58eb7..003e0a6906ca 100644
--- a/gnu/usr.bin/rcs/lib/merger.c
+++ b/gnu/usr.bin/rcs/lib/merger.c
@@ -1,6 +1,6 @@
-/* merger - three-way file merge internals */
+/* three-way file merge internals */
-/* Copyright 1991 by Paul Eggert
+/* Copyright 1991, 1992, 1993, 1994, 1995 Paul Eggert
Distributed under license by the Free Software Foundation, Inc.
This file is part of RCS.
@@ -16,8 +16,9 @@ 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.
+along with RCS; see the file COPYING.
+If not, write to the Free Software Foundation,
+59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Report problems and direct all questions to:
@@ -27,38 +28,40 @@ Report problems and direct all questions to:
#include "rcsbase.h"
-libId(mergerId, "$Id: merger.c,v 1.3 1991/08/20 23:05:00 eggert Exp $")
+libId(mergerId, "$Id: merger.c,v 1.7 1995/06/16 06:19:24 eggert Exp $")
+ static char const *normalize_arg P((char const*,char**));
static char const *
normalize_arg(s, b)
char const *s;
char **b;
/*
* If S looks like an option, prepend ./ to it. Yield the result.
- * Set *B to the address of any storage that was allocated..
+ * Set *B to the address of any storage that was allocated.
*/
{
char *t;
- switch (*s) {
- case '-': case '+':
- *b = t = testalloc(strlen(s) + 3);
- VOID sprintf(t, ".%c%s", SLASH, s);
- return t;
- default:
- *b = 0;
- return s;
+ if (*s == '-') {
+ *b = t = testalloc(strlen(s) + 3);
+ VOID sprintf(t, ".%c%s", SLASH, s);
+ return t;
+ } else {
+ *b = 0;
+ return s;
}
}
int
-merge(tostdout, label, argv)
+merge(tostdout, edarg, label, argv)
int tostdout;
- char const *const label[2];
+ char const *edarg;
+ char const *const label[3];
char const *const argv[3];
/*
- * Do `merge [-p] -L l0 -L l1 a0 a1 a2',
+ * Do `merge [-p] EDARG -L l0 -L l1 -L l2 a0 a1 a2',
* where TOSTDOUT specifies whether -p is present,
- * LABEL gives l0 and l1, and ARGV gives a0, a1, and a2.
+ * EDARG gives the editing type (e.g. "-A", or null for the default),
+ * LABEL gives l0, l1 and l2, and ARGV gives a0, a1 and a2.
* Yield DIFF_SUCCESS or DIFF_FAILURE.
*/
{
@@ -74,30 +77,35 @@ merge(tostdout, label, argv)
for (i=3; 0<=--i; )
a[i] = normalize_arg(argv[i], &b[i]);
+
+ if (!edarg)
+ edarg = "-E";
#if DIFF3_BIN
t = 0;
if (!tostdout)
t = maketemp(0);
s = run(
- (char*)0, t,
- DIFF3, "-am", "-L", label[0], "-L", label[1],
+ -1, t,
+ DIFF3, edarg, "-am",
+ "-L", label[0],
+ "-L", label[1],
+ "-L", label[2],
a[0], a[1], a[2], (char*)0
);
switch (s) {
case DIFF_SUCCESS:
break;
case DIFF_FAILURE:
- if (!quietflag)
- warn("overlaps during merge");
+ warn("conflicts during merge");
break;
default:
exiterr();
}
if (t) {
- if (!(f = fopen(argv[0], FOPEN_W)))
+ if (!(f = fopenSafer(argv[0], "w")))
efaterror(argv[0]);
- if (!(rt = Iopen(t, FOPEN_R, (struct stat*)0)))
+ if (!(rt = Iopen(t, "r", (struct stat*)0)))
efaterror(t);
fastcopy(rt, f);
Ifclose(rt);
@@ -106,29 +114,30 @@ merge(tostdout, label, argv)
#else
for (i=0; i<2; i++)
switch (run(
- (char*)0, d[i]=maketemp(i),
+ -1, d[i]=maketemp(i),
DIFF, a[i], a[2], (char*)0
)) {
case DIFF_FAILURE: case DIFF_SUCCESS: break;
- default: exiterr();
+ default: faterror("diff failed");
}
t = maketemp(2);
s = run(
- (char*)0, t,
- DIFF3, "-E", d[0], d[1], a[0], a[1], a[2],
- label[0], label[1], (char*)0
+ -1, t,
+ DIFF3, edarg, d[0], d[1], a[0], a[1], a[2],
+ label[0], label[2], (char*)0
);
if (s != DIFF_SUCCESS) {
s = DIFF_FAILURE;
- if (!quietflag)
- warn("overlaps or other problems during merge");
+ warn("overlaps or other problems during merge");
}
- if (!(f = fopen(t, "a")))
+ if (!(f = fopenSafer(t, "a+")))
efaterror(t);
aputs(tostdout ? "1,$p\n" : "w\n", f);
- Ofclose(f);
- if (run(t, (char*)0, ED, "-", a[0], (char*)0))
+ Orewind(f);
+ aflush(f);
+ if (run(fileno(f), (char*)0, ED, "-", a[0], (char*)0))
exiterr();
+ Ofclose(f);
#endif
tempunlink();
diff --git a/gnu/usr.bin/rcs/lib/partime.h b/gnu/usr.bin/rcs/lib/partime.h
new file mode 100644
index 000000000000..5d3983fbb048
--- /dev/null
+++ b/gnu/usr.bin/rcs/lib/partime.h
@@ -0,0 +1,71 @@
+/* Parse a string, yielding a struct partime that describes it. */
+
+/* Copyright 1993, 1994, 1995 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,
+59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+Report problems and direct all questions to:
+
+ rcs-bugs@cs.purdue.edu
+
+*/
+
+#define TM_UNDEFINED (-1)
+#define TM_DEFINED(x) (0 <= (x))
+
+#define TM_UNDEFINED_ZONE ((long) -24 * 60 * 60)
+#define TM_LOCAL_ZONE (TM_UNDEFINED_ZONE - 1)
+
+struct partime {
+ /*
+ * This structure describes the parsed time.
+ * Only the following tm_* values in it are used:
+ * sec, min, hour, mday, mon, year, wday, yday.
+ * If TM_UNDEFINED(value), the parser never found the value.
+ * The tm_year field is the actual year, not the year - 1900;
+ * but see ymodulus below.
+ */
+ struct tm tm;
+
+ /*
+ * If !TM_UNDEFINED(ymodulus),
+ * then tm.tm_year is actually modulo ymodulus.
+ */
+ int ymodulus;
+
+ /*
+ * Week of year, ISO 8601 style.
+ * If TM_UNDEFINED(yweek), the parser never found yweek.
+ * Weeks start on Mondays.
+ * Week 1 includes Jan 4.
+ */
+ int yweek;
+
+ /* Seconds east of UTC; or TM_LOCAL_ZONE or TM_UNDEFINED_ZONE. */
+ long zone;
+};
+
+#if defined(__STDC__) || has_prototypes
+# define __PARTIME_P(x) x
+#else
+# define __PARTIME_P(x) ()
+#endif
+
+char *partime __PARTIME_P((char const *, struct partime *));
+char *parzone __PARTIME_P((char const *, long *));
diff --git a/gnu/usr.bin/rcs/lib/rcsmap.c b/gnu/usr.bin/rcs/lib/rcsmap.c
index 0e7b23c85f4a..0345ef82f24d 100644
--- a/gnu/usr.bin/rcs/lib/rcsmap.c
+++ b/gnu/usr.bin/rcs/lib/rcsmap.c
@@ -1,7 +1,7 @@
/* RCS map of character types */
/* Copyright (C) 1982, 1988, 1989 Walter Tichy
- Copyright 1990, 1991 by Paul Eggert
+ Copyright 1990, 1991, 1995 by Paul Eggert
Distributed under license by the Free Software Foundation, Inc.
This file is part of RCS.
@@ -17,8 +17,9 @@ 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.
+along with RCS; see the file COPYING.
+If not, write to the Free Software Foundation,
+59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Report problems and direct all questions to:
@@ -28,7 +29,7 @@ Report problems and direct all questions to:
#include "rcsbase.h"
-libId(mapId, "$Id: rcsmap.c,v 5.2 1991/08/19 03:13:55 eggert Exp $")
+libId(mapId, "$Id: rcsmap.c,v 5.3 1995/06/16 06:19:24 eggert Exp $")
/* map of character types */
/* ISO 8859/1 (Latin-1) */
diff --git a/gnu/usr.bin/rcs/lib/rcstime.c b/gnu/usr.bin/rcs/lib/rcstime.c
new file mode 100644
index 000000000000..a49a8576c51d
--- /dev/null
+++ b/gnu/usr.bin/rcs/lib/rcstime.c
@@ -0,0 +1,191 @@
+/* Convert between RCS time format and Posix and/or C formats. */
+
+/* Copyright 1992, 1993, 1994, 1995 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,
+59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+Report problems and direct all questions to:
+
+ rcs-bugs@cs.purdue.edu
+
+*/
+
+#include "rcsbase.h"
+#include "partime.h"
+#include "maketime.h"
+
+libId(rcstimeId, "$Id: rcstime.c,v 1.4 1995/06/16 06:19:24 eggert Exp $")
+
+static long zone_offset; /* seconds east of UTC, or TM_LOCAL_ZONE */
+static int use_zone_offset; /* if zero, use UTC without zone indication */
+
+/*
+* Convert Unix time to RCS format.
+* For compatibility with older versions of RCS,
+* dates from 1900 through 1999 are stored without the leading "19".
+*/
+ void
+time2date(unixtime,date)
+ time_t unixtime;
+ char date[datesize];
+{
+ register struct tm const *tm = time2tm(unixtime, RCSversion<VERSION(5));
+ VOID sprintf(date,
+# if has_printf_dot
+ "%.2d.%.2d.%.2d.%.2d.%.2d.%.2d",
+# else
+ "%02d.%02d.%02d.%02d.%02d.%02d",
+# endif
+ tm->tm_year + ((unsigned)tm->tm_year < 100 ? 0 : 1900),
+ tm->tm_mon+1, tm->tm_mday,
+ tm->tm_hour, tm->tm_min, tm->tm_sec
+ );
+}
+
+/* Like str2time, except die if an error was found. */
+static time_t str2time_checked P((char const*,time_t,long));
+ static time_t
+str2time_checked(source, default_time, default_zone)
+ char const *source;
+ time_t default_time;
+ long default_zone;
+{
+ time_t t = str2time(source, default_time, default_zone);
+ if (t == -1)
+ faterror("unknown date/time: %s", source);
+ return t;
+}
+
+/*
+* Parse a free-format date in SOURCE, convert it
+* into RCS internal format, and store the result into TARGET.
+*/
+ void
+str2date(source, target)
+ char const *source;
+ char target[datesize];
+{
+ time2date(
+ str2time_checked(source, now(),
+ use_zone_offset ? zone_offset
+ : RCSversion<VERSION(5) ? TM_LOCAL_ZONE
+ : 0
+ ),
+ target
+ );
+}
+
+/* Convert an RCS internal format date to time_t. */
+ time_t
+date2time(source)
+ char const source[datesize];
+{
+ char s[datesize + zonelenmax];
+ return str2time_checked(date2str(source, s), (time_t)0, 0);
+}
+
+
+/* Set the time zone for date2str output. */
+ void
+zone_set(s)
+ char const *s;
+{
+ if ((use_zone_offset = *s)) {
+ long zone;
+ char const *zonetail = parzone(s, &zone);
+ if (!zonetail || *zonetail)
+ error("%s: not a known time zone", s);
+ else
+ zone_offset = zone;
+ }
+}
+
+
+/*
+* Format a user-readable form of the RCS format DATE into the buffer DATEBUF.
+* Yield DATEBUF.
+*/
+ char const *
+date2str(date, datebuf)
+ char const date[datesize];
+ char datebuf[datesize + zonelenmax];
+{
+ register char const *p = date;
+
+ while (*p++ != '.')
+ continue;
+ if (!use_zone_offset)
+ VOID sprintf(datebuf,
+ "19%.*s/%.2s/%.2s %.2s:%.2s:%s"
+ + (date[2]=='.' && VERSION(5)<=RCSversion ? 0 : 2),
+ (int)(p-date-1), date,
+ p, p+3, p+6, p+9, p+12
+ );
+ else {
+ struct tm t;
+ struct tm const *z;
+ int non_hour;
+ long zone;
+ char c;
+
+ t.tm_year = atoi(date) - (date[2]=='.' ? 0 : 1900);
+ t.tm_mon = atoi(p) - 1;
+ t.tm_mday = atoi(p+3);
+ t.tm_hour = atoi(p+6);
+ t.tm_min = atoi(p+9);
+ t.tm_sec = atoi(p+12);
+ t.tm_wday = -1;
+ zone = zone_offset;
+ if (zone == TM_LOCAL_ZONE) {
+ time_t u = tm2time(&t, 0), d;
+ z = localtime(&u);
+ d = difftm(z, &t);
+ zone = (time_t)-1 < 0 || d < -d ? d : -(long)-d;
+ } else {
+ adjzone(&t, zone);
+ z = &t;
+ }
+ c = '+';
+ if (zone < 0) {
+ zone = -zone;
+ c = '-';
+ }
+ VOID sprintf(datebuf,
+# if has_printf_dot
+ "%.2d-%.2d-%.2d %.2d:%.2d:%.2d%c%.2d",
+# else
+ "%02d-%02d-%02d %02d:%02d:%02d%c%02d",
+# endif
+ z->tm_year + 1900,
+ z->tm_mon + 1, z->tm_mday, z->tm_hour, z->tm_min, z->tm_sec,
+ c, (int) (zone / (60*60))
+ );
+ if ((non_hour = zone % (60*60))) {
+# if has_printf_dot
+ static char const fmt[] = ":%.2d";
+# else
+ static char const fmt[] = ":%02d";
+# endif
+ VOID sprintf(datebuf + strlen(datebuf), fmt, non_hour / 60);
+ if ((non_hour %= 60))
+ VOID sprintf(datebuf + strlen(datebuf), fmt, non_hour);
+ }
+ }
+ return datebuf;
+}
diff --git a/gnu/usr.bin/rcs/lib/version.c b/gnu/usr.bin/rcs/lib/version.c
new file mode 100644
index 000000000000..81f5585b9d1d
--- /dev/null
+++ b/gnu/usr.bin/rcs/lib/version.c
@@ -0,0 +1,2 @@
+#include "rcsbase.h"
+char const RCS_version_string[] = "5.7";