mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 18:35:41 +00:00
Fix bug #4558 ("buildno" is not compatible with SVN 1.6).
svn path=/trunk/; revision=41397
This commit is contained in:
parent
829df8eb70
commit
ad59e09b0e
1 changed files with 29 additions and 28 deletions
|
@ -45,38 +45,35 @@ int count_wide_string( const wchar_t *str )
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
long
|
||||||
GetRev(void)
|
GetRev(char *Revision, size_t length)
|
||||||
{
|
{
|
||||||
static char Unknown[] = "UNKNOWN";
|
long revno = 0;
|
||||||
static char Revision[10]; /* 999999999 revisions should be enough for everyone... */
|
char *p;
|
||||||
|
|
||||||
/* SVN 1.4.x-1.5.x */
|
|
||||||
FILE *fp = NULL;
|
FILE *fp = NULL;
|
||||||
char ch;
|
|
||||||
size_t count = 0, chars = 0;
|
|
||||||
fp = fopen(".svn/entries", "r");
|
fp = fopen(".svn/entries", "r");
|
||||||
if (fp != NULL)
|
if (fp != NULL)
|
||||||
{
|
{
|
||||||
ch=fgetc(fp);
|
if (fgets(Revision, length, fp) != NULL)
|
||||||
if (ch == 56 || ch == 57) /* some kind of header? */
|
|
||||||
{
|
{
|
||||||
while((ch=fgetc(fp)) != EOF)
|
/* If the first character of the file is not a digit,
|
||||||
|
then it is probably in XML format. */
|
||||||
|
if (isdigit(Revision[0]))
|
||||||
{
|
{
|
||||||
if (ch == 10)
|
while (fgets(Revision, length, fp) != NULL)
|
||||||
count++; /* seems to used as a seperator */
|
|
||||||
if (count > 3)
|
|
||||||
break;
|
|
||||||
if ((count == 3) && (chars < sizeof(Revision)))
|
|
||||||
{
|
{
|
||||||
if (chars != 0)
|
revno = strtol(Revision, &p, 10);
|
||||||
Revision[chars - 1] = ch;
|
if (revno != 0)
|
||||||
chars++;
|
{
|
||||||
|
*p = '\0';
|
||||||
|
fclose(fp);
|
||||||
|
return revno;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
return Revision;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -113,20 +110,21 @@ GetRev(void)
|
||||||
}
|
}
|
||||||
if ("revision" == Attribute->name)
|
if ("revision" == Attribute->name)
|
||||||
{
|
{
|
||||||
if (sizeof(Revision) <= Attribute->value.length() + 1)
|
if (length <= Attribute->value.length() + 1)
|
||||||
{
|
{
|
||||||
strcpy(Revision, "revtoobig");
|
strcpy(Revision, "revtoobig");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
strcpy(Revision, Attribute->value.c_str());
|
strcpy(Revision, Attribute->value.c_str());
|
||||||
|
revno = strtol(Revision, NULL, 10);
|
||||||
}
|
}
|
||||||
GotRevision = true;
|
GotRevision = true;
|
||||||
}
|
}
|
||||||
if (GotName && GotKind && GotRevision)
|
if (GotName && GotKind && GotRevision)
|
||||||
{
|
{
|
||||||
delete head;
|
delete head;
|
||||||
return Revision;
|
return revno;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -139,11 +137,12 @@ GetRev(void)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Unknown;
|
strcpy(Revision, "UNKNOWN");
|
||||||
|
return revno;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
write_h (int build, char *buildstr)
|
write_h (int build, char *buildstr, long revno)
|
||||||
{
|
{
|
||||||
FILE *h = NULL;
|
FILE *h = NULL;
|
||||||
char* s;
|
char* s;
|
||||||
|
@ -159,7 +158,7 @@ write_h (int build, char *buildstr)
|
||||||
s = s + sprintf (s, "#define _INC_REACTOS_BUILDNO\n" );
|
s = s + sprintf (s, "#define _INC_REACTOS_BUILDNO\n" );
|
||||||
|
|
||||||
s = s + sprintf (s, "#define KERNEL_VERSION_BUILD\t%d\n", build);
|
s = s + sprintf (s, "#define KERNEL_VERSION_BUILD\t%d\n", build);
|
||||||
s = s + sprintf (s, "#define KERNEL_VERSION_BUILD_HEX\t0x%x\n", atoi(GetRev()));
|
s = s + sprintf (s, "#define KERNEL_VERSION_BUILD_HEX\t0x%lx\n", revno);
|
||||||
s = s + sprintf (s, "#define KERNEL_VERSION_BUILD_STR\t\"%s\"\n", buildstr);
|
s = s + sprintf (s, "#define KERNEL_VERSION_BUILD_STR\t\"%s\"\n", buildstr);
|
||||||
s = s + sprintf (s, "#define KERNEL_VERSION_BUILD_RC\t\"%s\\0\"\n", buildstr);
|
s = s + sprintf (s, "#define KERNEL_VERSION_BUILD_RC\t\"%s\\0\"\n", buildstr);
|
||||||
s = s + sprintf (s, "#define KERNEL_RELEASE_RC\t\"%d.%d",
|
s = s + sprintf (s, "#define KERNEL_RELEASE_RC\t\"%d.%d",
|
||||||
|
@ -285,7 +284,8 @@ main (int argc, char * argv [])
|
||||||
int quiet = FALSE;
|
int quiet = FALSE;
|
||||||
|
|
||||||
int build = 0;
|
int build = 0;
|
||||||
char buildstr[64];
|
long revno;
|
||||||
|
char buildstr[64], revision[10];
|
||||||
|
|
||||||
time_t t1 = 0;
|
time_t t1 = 0;
|
||||||
struct tm * t1_tm = NULL;
|
struct tm * t1_tm = NULL;
|
||||||
|
@ -382,7 +382,8 @@ main (int argc, char * argv [])
|
||||||
build_tag = new_build_tag;
|
build_tag = new_build_tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(buildstr, "%d-r%s", build, GetRev());
|
revno = GetRev(revision, sizeof(revision));
|
||||||
|
sprintf(buildstr, "%d-r%s", build, revision);
|
||||||
|
|
||||||
if (! quiet)
|
if (! quiet)
|
||||||
{
|
{
|
||||||
|
@ -399,7 +400,7 @@ main (int argc, char * argv [])
|
||||||
/* (Over)write the include file, unless the user switched on -p. */
|
/* (Over)write the include file, unless the user switched on -p. */
|
||||||
if (! print_only)
|
if (! print_only)
|
||||||
{
|
{
|
||||||
write_h (build, buildstr);
|
write_h (build, buildstr, revno);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue