1 |
ChangeLog entry: |
ChangeLog entry: |
2 |
|
|
3 |
2005-09-28 Mark D. Baushke <mdb@gnu.org> |
2005-09-29 Mark D. Baushke <mdb@gnu.org> |
4 |
|
|
5 |
* man/rcsfile.5in: Document new commitid delta phrase. |
* man/rcsfile.5in: Document new commitid delta phrase. |
6 |
* man/rcsfile.5: Regenerated. |
* man/rcsfile.5: Regenerated. |
7 |
|
|
8 |
* src/ci.c (RANDOM_BYTES, N): New constants. |
* src/ci.c (RANDOM_BYTES, COMMITID_RAW_SIZE): New constants. |
9 |
(mainProg): Add commitid to delta records. Use |
(mainProg): Add commitid to delta records. Use |
10 |
random data and represent in base62 or fall back to using the |
random data and represent in base62 or fall back to using the |
11 |
same basic format construction as is used by CVS and CVSNT. |
same basic format construction as is used by CVS and CVSNT. |
12 |
(divide_by): New function used by convert. |
(divide_by): New function used by convert. |
13 |
(convert): New fucntion to convert to base62. |
(convert): New fucntion to convert to base62. |
14 |
* rcsbase.h (commitidsize): Room for base62 encoded block or |
* rcsbase.h (commitidsize): Room for base62 encoded block or |
15 |
32bit pid, 32bit time, 16bit random rendered as hex plus one |
32bit pid plus a 32bit time rendered as hex plus one |
16 |
NUL byte round up to 64. |
NUL byte round up to 64. |
17 |
(struct hshentry): Add new commitid field. |
(struct hshentry): Add new commitid field. |
18 |
* src/rcsgen.c (putdelta): Preserve old commitid entries. |
* src/rcsgen.c (putdelta): Preserve old commitid entries. |
239 |
void unexpected_EOF P((void)) exiting; |
void unexpected_EOF P((void)) exiting; |
240 |
Index:src/ci.c |
Index:src/ci.c |
241 |
--- src/ci.c~ 1995-06-15 23:19:24.000000000 -0700 |
--- src/ci.c~ 1995-06-15 23:19:24.000000000 -0700 |
242 |
+++ src/ci.c 2005-09-28 15:01:57.823507000 -0700 |
+++ src/ci.c 2005-09-29 01:14:00.856504000 -0700 |
243 |
@@ -262,6 +262,10 @@ static void cleanup P((void)); |
@@ -262,6 +262,10 @@ static void cleanup P((void)); |
244 |
static void incnum P((char const*,struct buf*)); |
static void incnum P((char const*,struct buf*)); |
245 |
static void addassoclst P((int,char const*)); |
static void addassoclst P((int,char const*)); |
246 |
|
|
247 |
+enum {RANDOM_BYTES = 8}; |
+enum {RANDOM_BYTES = 8}; |
248 |
+enum {N = (sizeof(time_t) + RANDOM_BYTES)}; |
+enum {COMMITID_RAW_SIZE = (sizeof(time_t) + RANDOM_BYTES)}; |
249 |
+static void convert P((char const input[N], char *output)); |
+static void convert P((char const input[COMMITID_RAW_SIZE], char *output)); |
250 |
+ |
+ |
251 |
static FILE *exfile; |
static FILE *exfile; |
252 |
static RILE *workptr; /* working file pointer */ |
static RILE *workptr; /* working file pointer */ |
259 |
char *a, **newargv, *textfile; |
char *a, **newargv, *textfile; |
260 |
char const *author, *krev, *rev, *state; |
char const *author, *krev, *rev, *state; |
261 |
char const *diffname, *expname; |
char const *diffname, *expname; |
262 |
@@ -309,6 +314,28 @@ mainProg(ciId, "ci", " ci.c,v 5.30 1 |
@@ -309,6 +314,38 @@ mainProg(ciId, "ci", " ci.c,v 5.30 1 |
263 |
suffixes = X_DEFAULT; |
suffixes = X_DEFAULT; |
264 |
nextassoc = &assoclst; |
nextassoc = &assoclst; |
265 |
|
|
266 |
+ { |
+ { |
267 |
+ char buf[N] = { 0, }; |
+ char buf[COMMITID_RAW_SIZE] = { 0, }; |
268 |
+ ssize_t len = 0; |
+ ssize_t len = 0; |
269 |
+ time_t rightnow = time (NULL); |
+ time_t rightnow = time (NULL); |
270 |
+ unsigned char *p = (unsigned char *) (buf + sizeof(time_t)); |
+ unsigned char *p = (unsigned char *) (buf + sizeof(time_t)); |
273 |
+ len = read (fd, buf + sizeof(time_t), RANDOM_BYTES); |
+ len = read (fd, buf + sizeof(time_t), RANDOM_BYTES); |
274 |
+ close (fd); |
+ close (fd); |
275 |
+ } |
+ } |
276 |
+ if (len > 0 && rightnow >= 0) { |
+ if (len > 0) { |
277 |
+ while (rightnow != 0) { |
+ while (rightnow > 0) { |
278 |
+ *--p = rightnow % (UCHAR_MAX + 1); |
+ *--p = rightnow % (UCHAR_MAX + 1); |
279 |
+ rightnow /= UCHAR_MAX + 1; |
+ rightnow /= UCHAR_MAX + 1; |
280 |
+ } |
+ } |
281 |
+ convert(buf, commitid); |
+ } else { |
282 |
+ } else |
+ long int pid = (long int)getpid (); |
283 |
+ snprintf(commitid, sizeof(commitid), "%x%08lx%04x", |
+ p = (unsigned char *) (buf + sizeof (buf)); |
284 |
+ (int)getpid(), (long int)rightnow, |
+ while (rightnow > 0) { |
285 |
+ rand()&0xFFFF); |
+ *--p = rightnow % (UCHAR_MAX + 1); |
286 |
|
+ rightnow /= UCHAR_MAX + 1; |
287 |
|
+ } |
288 |
|
+ p = (unsigned char *) (buf + sizeof (buf) |
289 |
|
+ - sizeof (time_t)); |
290 |
|
+ while (pid > 0) { |
291 |
|
+ *--p = pid % (UCHAR_MAX + 1); |
292 |
|
+ pid /= UCHAR_MAX + 1; |
293 |
|
+ } |
294 |
|
+ } |
295 |
|
+ convert(buf, commitid); |
296 |
+ } |
+ } |
297 |
+ |
+ |
298 |
argc = getRCSINIT(argc, argv, &newargv); |
argc = getRCSINIT(argc, argv, &newargv); |
299 |
argv = newargv; |
argv = newargv; |
300 |
while (a = *++argv, 0<--argc && *a++=='-') { |
while (a = *++argv, 0<--argc && *a++=='-') { |
301 |
@@ -532,6 +559,8 @@ mainProg(ciId, "ci", " ci.c,v 5.30 1 |
@@ -532,6 +569,8 @@ mainProg(ciId, "ci", " ci.c,v 5.30 1 |
302 |
newdelta.name = 0; |
newdelta.name = 0; |
303 |
clear_buf(&newdelta.ig); |
clear_buf(&newdelta.ig); |
304 |
clear_buf(&newdelta.igtext); |
clear_buf(&newdelta.igtext); |
307 |
/* set author */ |
/* set author */ |
308 |
if (author) |
if (author) |
309 |
newdelta.author=author; /* set author given by -w */ |
newdelta.author=author; /* set author given by -w */ |
310 |
@@ -1317,3 +1346,38 @@ addassoclst(flag, sp) |
@@ -1317,3 +1356,38 @@ addassoclst(flag, sp) |
311 |
*nextassoc = pt; |
*nextassoc = pt; |
312 |
nextassoc = &pt->nextsym; |
nextassoc = &pt->nextsym; |
313 |
} |
} |
319 |
+ quotient. BUF[0] is the most significant part of BUF. |
+ quotient. BUF[0] is the most significant part of BUF. |
320 |
+ D must not exceed UINT_MAX >> CHAR_BIT. */ |
+ D must not exceed UINT_MAX >> CHAR_BIT. */ |
321 |
+static unsigned int |
+static unsigned int |
322 |
+divide_by (unsigned char buf[N], unsigned int d) |
+divide_by (unsigned char buf[COMMITID_RAW_SIZE], unsigned int d) |
323 |
+{ |
+{ |
324 |
+ unsigned int carry = 0; |
+ unsigned int carry = 0; |
325 |
+ int i; |
+ int i; |
326 |
+ for (i = 0; i < N; i++) |
+ for (i = 0; i < COMMITID_RAW_SIZE; i++) |
327 |
+ { |
+ { |
328 |
+ unsigned int byte = buf[i]; |
+ unsigned int byte = buf[i]; |
329 |
+ unsigned int dividend = (carry << CHAR_BIT) + byte; |
+ unsigned int dividend = (carry << CHAR_BIT) + byte; |
334 |
+} |
+} |
335 |
+ |
+ |
336 |
+static void |
+static void |
337 |
+convert (char const input[N], char *output) |
+convert (char const input[COMMITID_RAW_SIZE], char *output) |
338 |
+{ |
+{ |
339 |
+ static char const zero[N] = { 0, }; |
+ static char const zero[COMMITID_RAW_SIZE] = { 0, }; |
340 |
+ unsigned char buf[N]; |
+ unsigned char buf[COMMITID_RAW_SIZE]; |
341 |
+ size_t o = 0; |
+ size_t o = 0; |
342 |
+ memcpy (buf, input, N); |
+ memcpy (buf, input, COMMITID_RAW_SIZE); |
343 |
+ while (memcmp (buf, zero, N) != 0) |
+ while (memcmp (buf, zero, COMMITID_RAW_SIZE) != 0) |
344 |
+ output[o++] = alphabet[divide_by (buf, sizeof alphabet)]; |
+ output[o++] = alphabet[divide_by (buf, sizeof alphabet)]; |
345 |
+ if (! o) |
+ if (! o) |
346 |
+ output[o++] = '0'; |
+ output[o++] = '0'; |