14 |
* manipulation |
* manipulation |
15 |
*/ |
*/ |
16 |
|
|
17 |
|
#ifdef HAVE_CONFIG_H |
18 |
|
# include <config.h> |
19 |
|
#endif |
20 |
|
|
21 |
|
/* Verify interface. */ |
22 |
|
#include "rcs.h" |
23 |
|
|
24 |
#include "cvs.h" |
#include "cvs.h" |
25 |
#include "edit.h" |
#include "edit.h" |
26 |
#include "hardlink.h" |
#include "hardlink.h" |
27 |
|
#include "sign.h" |
28 |
|
|
29 |
/* These need to be source after cvs.h or HAVE_MMAP won't be set... */ |
/* These need to be source after cvs.h or HAVE_MMAP won't be set... */ |
30 |
#ifdef HAVE_MMAP |
#ifdef HAVE_MMAP |
433 |
|
|
434 |
|
|
435 |
|
|
436 |
|
/* Return a Node type for a newphrase buffer entry. */ |
437 |
|
static Ntype |
438 |
|
rcsbuf_get_node_type (struct rcsbuffer *rcsbuf) |
439 |
|
{ |
440 |
|
if (rcsbuf_valcmp (rcsbuf)) return RCSCMPFLD; |
441 |
|
/* else */ if (rcsbuf->at_string) return RCSSTRING; |
442 |
|
/* else */ return RCSFIELD; |
443 |
|
} |
444 |
|
|
445 |
|
|
446 |
|
|
447 |
/* Do the real work of parsing an RCS file. |
/* Do the real work of parsing an RCS file. |
448 |
|
|
449 |
On error, die with a fatal error; if it returns at all it was successful. |
On error, die with a fatal error; if it returns at all it was successful. |
595 |
if (rdata->other == NULL) |
if (rdata->other == NULL) |
596 |
rdata->other = getlist (); |
rdata->other = getlist (); |
597 |
kv = getnode (); |
kv = getnode (); |
598 |
kv->type = rcsbuf_valcmp (&rcsbuf) ? RCSCMPFLD : RCSFIELD; |
kv->type = rcsbuf_get_node_type (&rcsbuf); |
599 |
kv->key = xstrdup (key); |
kv->key = xstrdup (key); |
600 |
kv->data = rcsbuf_valcopy (&rcsbuf, value, kv->type == RCSFIELD, NULL); |
kv->data = rcsbuf_valcopy (&rcsbuf, value, kv->type != RCSCMPFLD, |
601 |
|
&kv->len); |
602 |
if (addnode (rdata->other, kv) != 0) |
if (addnode (rdata->other, kv) != 0) |
603 |
{ |
{ |
604 |
error (0, 0, "warning: duplicate key `%s' in RCS file `%s'", |
error (0, 0, "warning: duplicate key `%s' in RCS file `%s'", |
800 |
if (vnode->other == NULL) |
if (vnode->other == NULL) |
801 |
vnode->other = getlist (); |
vnode->other = getlist (); |
802 |
kv = getnode (); |
kv = getnode (); |
803 |
kv->type = rcsbuf_valcmp (&rcsbuf) ? RCSCMPFLD : RCSFIELD; |
kv->type = rcsbuf_get_node_type (&rcsbuf); |
804 |
kv->key = xstrdup (key); |
kv->key = xstrdup (key); |
805 |
kv->data = rcsbuf_valcopy (&rcsbuf, value, kv->type == RCSFIELD, |
kv->data = rcsbuf_valcopy (&rcsbuf, value, |
806 |
NULL); |
kv->type != RCSCMPFLD, NULL); |
807 |
if (addnode (vnode->other, kv) != 0) |
if (addnode (vnode->other, kv) != 0) |
808 |
{ |
{ |
809 |
error (0, 0, |
error (0, 0, |
5121 |
np->data = xstrdup(global_session_id); |
np->data = xstrdup(global_session_id); |
5122 |
addnode (delta->other_delta, np); |
addnode (delta->other_delta, np); |
5123 |
|
|
5124 |
|
/* Save the OpenPGP signature. */ |
5125 |
|
if (get_sign_commits (server_active, true) |
5126 |
|
|| have_sigfile (server_active, workfile)) |
5127 |
|
{ |
5128 |
|
np = getnode(); |
5129 |
|
np->type = RCSSTRING; |
5130 |
|
np->key = xstrdup ("openpgp-signatures"); |
5131 |
|
np->data = get_signature (server_active, "", workfile, |
5132 |
|
rcs->expand && STREQ (rcs->expand, "b"), |
5133 |
|
&np->len); |
5134 |
|
addnode (delta->other_delta, np); |
5135 |
|
} |
5136 |
|
|
5137 |
#ifdef PRESERVE_PERMISSIONS_SUPPORT |
#ifdef PRESERVE_PERMISSIONS_SUPPORT |
5138 |
/* If permissions should be preserved on this project, then |
/* If permissions should be preserved on this project, then |
7786 |
if (vnode->other_delta == NULL) |
if (vnode->other_delta == NULL) |
7787 |
vnode->other_delta = getlist (); |
vnode->other_delta = getlist (); |
7788 |
kv = getnode (); |
kv = getnode (); |
7789 |
kv->type = rcsbuf_valcmp (rcsbuf) ? RCSCMPFLD : RCSFIELD; |
kv->type = rcsbuf_get_node_type (rcsbuf); |
7790 |
kv->key = xstrdup (key); |
kv->key = xstrdup (key); |
7791 |
kv->data = rcsbuf_valcopy (rcsbuf, value, kv->type == RCSFIELD, NULL); |
kv->data = rcsbuf_valcopy (rcsbuf, value, kv->type != RCSCMPFLD, |
7792 |
|
&kv->len); |
7793 |
if (addnode (vnode->other_delta, kv) != 0) |
if (addnode (vnode->other_delta, kv) != 0) |
7794 |
{ |
{ |
7795 |
/* Complaining about duplicate keys in newphrases seems |
/* Complaining about duplicate keys in newphrases seems |
7872 |
break; |
break; |
7873 |
|
|
7874 |
p = getnode(); |
p = getnode(); |
7875 |
p->type = rcsbuf_valcmp (rcsbuf) ? RCSCMPFLD : RCSFIELD; |
p->type = rcsbuf_get_node_type (rcsbuf); |
7876 |
p->key = xstrdup (key); |
p->key = xstrdup (key); |
7877 |
p->data = rcsbuf_valcopy (rcsbuf, value, p->type == RCSFIELD, NULL); |
p->data = rcsbuf_valcopy (rcsbuf, value, p->type != RCSCMPFLD, |
7878 |
|
&p->len); |
7879 |
if (addnode (d->other, p) < 0) |
if (addnode (d->other, p) < 0) |
7880 |
{ |
{ |
7881 |
error (0, 0, "warning: %s, delta %s: duplicate field `%s'", |
error (0, 0, "warning: %s, delta %s: duplicate field `%s'", |
7942 |
fprintf (fp, "\n%s\t", node->key); |
fprintf (fp, "\n%s\t", node->key); |
7943 |
if (node->data != NULL) |
if (node->data != NULL) |
7944 |
{ |
{ |
7945 |
/* If the field's value contains evil characters, |
/* If the field's value may contain evil characters, |
7946 |
it must be stringified. */ |
it must be stringified. */ |
7947 |
/* FIXME: This does not quite get it right. "7jk8f" is not a valid |
if (node->type != RCSSTRING) |
7948 |
value for a value in a newpharse, according to doc/RCSFILES, |
fwrite (node->data, 1, node->len ? node->len : strlen (node->data), |
7949 |
because digits are not valid in an "id". We might do OK by |
fp); |
|
always writing strings (enclosed in @@). Would be nice to |
|
|
explicitly mention this one way or another in doc/RCSFILES. |
|
|
A case where we are wrong in a much more clear-cut way is that |
|
|
we let through non-graphic characters such as whitespace and |
|
|
control characters. */ |
|
|
|
|
|
if (node->type == RCSCMPFLD || strpbrk (node->data, "$,.:;@") == NULL) |
|
|
fputs (node->data, fp); |
|
7950 |
else |
else |
7951 |
{ |
{ |
7952 |
putc ('@', fp); |
putc ('@', fp); |
7953 |
expand_at_signs (node->data, (off_t) strlen (node->data), fp); |
expand_at_signs (node->data, |
7954 |
|
node->len ? node->len : strlen (node->data), |
7955 |
|
fp); |
7956 |
putc ('@', fp); |
putc ('@', fp); |
7957 |
} |
} |
7958 |
} |
} |