Update of /cvsroot/cvs-nserver/cvs-nserver/src
In directory usw-pr-cvs1:/tmp/cvs-serv6844
Modified Files:
Tag: NCLI-1-11-1
rcs.c
Log Message:
Bug w/ checkout imported sources fixed
Index: rcs.c
===================================================================
RCS file: /cvsroot/cvs-nserver/cvs-nserver/src/rcs.c,v
retrieving revision 1.1.1.7.4.2
retrieving revision 1.1.1.7.4.3
diff -u -d -r1.1.1.7.4.2 -r1.1.1.7.4.3
--- rcs.c 29 May 2002 05:06:23 -0000 1.1.1.7.4.2
+++ rcs.c 24 Sep 2002 05:40:47 -0000 1.1.1.7.4.3
@@ -3949,7 +3949,7 @@
{
int free_rev = 0;
enum kflag expand;
- FILE *fp, *ofp;
+ FILE *fp, *ofp = NULL;
struct stat sb;
struct rcsbuffer rcsbuf;
char *key;
@@ -8443,12 +8443,25 @@
int all_numeric;
char* p;
char* orig_version;
- char* version = NULL;
char* branch = NULL;
- char* pZ;
char* pT;
- char* magic = NULL;
+ char* version = NULL; /* for brach version (X.Y.Z.M -> X.Y.) */
+ size_t version_len; /* its length */
+ char* branch_num; /* for cut branch number (X.Y.Z.M -> Z) */
+ size_t branch_len; /* for length of br_num */
+ /* Actually 41 was chosen from a simple conclusion:
+ * RCS_MAGIC_BRANCH is a number :-)
+ * any decimal (even 64 bit) numbers are fit into ~20+
+ * characters. So 40 ought to be enough for everything :-)
+ */
+ static char magic[41] = "";
+ static size_t magic_len;
+ if (!magic[0]) {
+ snprintf(magic, sizeof(magic)-1, "%d.", RCS_MAGIC_BRANCH);
+ magic_len = strlen(magic);
+ }
+
/* see if the `rev' is all numeric */
all_numeric = 1;
if (rev) {
@@ -8483,36 +8496,47 @@
goto out;
}
- /* convert `version' (X.Y.Z.T) to a magic branch number (X.Y.0.Z) */
+ /* Here we should check for a magic branch numbers (i.e. one w/
+ * zero on next to last position. We also should check "imported"
+ * branches i.e. ones w/ odd number of *digit series*
+ */
pT = strrchr(version, '.');
if (pT == NULL)
error(1, 0, "Internal error: version '%s' does not contain dots", version);
- *pT++ = '\0';
+ *pT = '\0';
- pZ = strrchr(version, '.');
- if (pZ == NULL)
+ branch_num = strrchr(version, '.');
+ if (branch_num == NULL)
error(1, 0, "Internal error: version '%s' does not contain enough dots", version);
- *pZ++ = '\0';
-
- /* "X.Y." + "." + "0" + "." + "Z" + '\0' */
- magic = malloc(strlen(version) + 1 + 1 + 1 + strlen(pZ) + 1);
- if (!magic)
- goto out;
- strcpy(magic, version);
- strcat(magic, ".");
- strcat(magic, "0"); /* FIXME: actually RCS_MAGIC_BRANCH should be used here */
- strcat(magic, ".");
- strcat(magic, pZ);
-
+ branch_num++;
+ version_len = branch_num - version;
+ branch_len = pT - branch_num;
+ /* Here what we need to check:
+ branch tags may be derived either from locally generated
+ revisions or during "import" command. First have even number of
+ digit parts in it and the next to last is RSC_MAGIC_BRANCH
+ (usually 0). Latter have odd number of parts (RCS_MAGIC_BRANCH
+ part is missing. So what we seek may looking like this:
+ | entire branch revision |
+ | version | MAGIC_BRANCH | branch-num |
+ or like this
+ | entire branch revision |
+ | version | branch-num |
+ */
/* get a list of symbolic tags, including branches */
RCS_symbols(rcs);
if (rcs->symbols) {
head = rcs->symbols->list;
for (cur = head->next; cur != head; cur = cur->next) {
- if (strcmp(magic, cur->data) == 0) {
+ size_t data_len = strlen(cur->data);
+ if (((version_len + magic_len + branch_len == data_len &&
+ 0 == strncmp(magic, cur->data + version_len, magic_len)) ||
+ (branch_len + version_len == data_len)) &&
+ 0 == strncmp(cur->data, version, version_len) &&
+ 0 == strncmp(cur->data + data_len - branch_len, branch_num, branch_len)) {
branch = cur->key;
goto out;
- }
+ }
}
}
if (branch == NULL)
@@ -8520,7 +8544,6 @@
out:
free(version);
- free(magic);
return branch;
}
|