ReactOS  0.4.14-dev-845-g8381e29
revision.c File Reference
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "version.h"
#include "compat.h"
#include "util.h"
#include "options.h"
#include "log2lines.h"
Include dependency graph for revision.c:

Go to the source code of this file.

Functions

static void log_rev_check (FILE *outFile, char *fileName, int showfile)
 
static void logRevCheck (FILE *outFile)
 
int getRevision (char *fileName, int lastChanged)
 
int getTBRevision (char *fileName)
 
void reportRevision (FILE *outFile)
 
unsigned long findRev (FILE *finx, int *rev)
 
int regscan (FILE *outFile)
 
int updateSvnlog (void)
 

Function Documentation

◆ findRev()

unsigned long findRev ( FILE finx,
int rev 
)

Definition at line 139 of file revision.c.

140 {
141  unsigned long pos = 0L;
142 
143  while (!fseek(finx, (*rev) * sizeof(unsigned long), SEEK_SET))
144  {
145  fread(&pos, sizeof(long), 1, finx);
146  (*rev)--;
147  if (pos)
148  break;
149  }
150  return pos;
151 }
_Check_return_opt_ _CRTIMP size_t __cdecl fread(_Out_writes_bytes_(_ElementSize *_Count) void *_DstBuf, _In_ size_t _ElementSize, _In_ size_t _Count, _Inout_ FILE *_File)
_Check_return_opt_ _CRTIMP int __cdecl fseek(_Inout_ FILE *_File, _In_ long _Offset, _In_ int _Origin)
#define SEEK_SET
Definition: jmemansi.c:26
int rev
Definition: sort.c:17
static const WCHAR L[]
Definition: oid.c:1250

Referenced by regscan().

◆ getRevision()

int getRevision ( char fileName,
int  lastChanged 
)

Definition at line 61 of file revision.c.

62 {
63  char s[LINESIZE];
64  FILE *psvn;
65  int rev = 0;
66 
67  if (!fileName)
68  fileName = opt_SourcesPath;
69  sprintf(s, "svn info %s", fileName);
70  if ((psvn = POPEN(s, "r")))
71  {
72  while (fgets(s, LINESIZE, psvn))
73  {
74  if (lastChanged)
75  {
76  if (sscanf(s, "Last Changed Rev: %d", &rev))
77  break;
78  }
79  else
80  {
81  if (sscanf(s, "Revision: %d", &rev))
82  break;
83  }
84  }
85  }
86  else
87  l2l_dbg(1, "Can't popen: \"%s\"\n", s);
88 
89  if (psvn)
90  PCLOSE(psvn);
91 
92  return rev;
93 }
#define PCLOSE
Definition: compat.h:22
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define l2l_dbg(level,...)
Definition: util.h:35
_Check_return_ _CRTIMP int __cdecl sscanf(_In_z_ const char *_Src, _In_z_ _Scanf_format_string_ const char *_Format,...)
int rev
Definition: sort.c:17
GLdouble s
Definition: gl.h:2039
_Check_return_opt_ _CRTIMP char *__cdecl fgets(_Out_writes_z_(_MaxCount) char *_Buf, _In_ int _MaxCount, _Inout_ FILE *_File)
#define LINESIZE
Definition: chargen.c:18
#define POPEN
Definition: compat.h:21
char opt_SourcesPath[LINESIZE]
Definition: options.c:47

Referenced by getTBRevision(), log_rev_check(), and optionInit().

◆ getTBRevision()

int getTBRevision ( char fileName)

Definition at line 96 of file revision.c.

97 {
98  char *s;
99  int rev = 0;
100 
101  s = strrchr(fileName, PATH_CHAR);
102  if (s)
103  s += 1;
104  else
105  s = fileName;
106 
107  sscanf(s, TRKBUILDPREFIX "%d", &rev);
108  if (!rev)
109  {
110  s = strrchr(fileName, PATH_CHAR);
111  if (s)
112  *s = '\0'; // clear, so we have the parent dir
113  else
114  {
115  // where else to look?
116  fileName = opt_SourcesPath;
117  }
118  rev = getRevision(fileName, 1);
119  if (s)
120  *s = PATH_CHAR; // restore
121  }
122 
123  l2l_dbg(1, "TBRevision: %d\n", rev);
124  return rev;
125 }
#define TRKBUILDPREFIX
Definition: config.h:15
int getRevision(char *fileName, int lastChanged)
Definition: revision.c:61
_Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
#define l2l_dbg(level,...)
Definition: util.h:35
_Check_return_ _CRTIMP int __cdecl sscanf(_In_z_ const char *_Src, _In_z_ _Scanf_format_string_ const char *_Format,...)
int rev
Definition: sort.c:17
GLdouble s
Definition: gl.h:2039
#define PATH_CHAR
Definition: rmkdir.c:17
char opt_SourcesPath[LINESIZE]
Definition: options.c:47

Referenced by optionInit().

◆ log_rev_check()

static void log_rev_check ( FILE outFile,
char fileName,
int  showfile 
)
static

Definition at line 19 of file revision.c.

20 {
21  int rev = 0;
22  char s[LINESIZE];
23 
25  strcat(s, fileName);
26  rev = getRevision(s, 1);
27  if (!showfile)
28  s[0] = '\0';
29  if (revinfo.opt_verbose)
30  log(outFile, "| R--- %s Last Changed Rev: %d\n", s, rev);
31 
32  if (rev && opt_Revision_check)
33  {
35  {
37  log(outFile, "| R--- Conflict %s: source tree(%d) < build(%d)\n", s, rev, revinfo.buildrev);
38  }
39  else if (rev > revinfo.buildrev)
40  {
42  log(outFile, "| R--- Conflict %s: file(%d) > build(%d)\n", s, rev, revinfo.buildrev);
43  }
44  }
45 }
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
int getRevision(char *fileName, int lastChanged)
Definition: revision.c:61
int opt_Revision_check
Definition: options.c:41
REVINFO revinfo
Definition: log2lines.c:37
int revconflicts
Definition: stat.h:20
int rev
Definition: sort.c:17
int opt_verbose
Definition: revision.h:17
GLdouble s
Definition: gl.h:2039
#define LINESIZE
Definition: chargen.c:18
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
SUMM summ
Definition: log2lines.c:36
#define log(outFile, fmt,...)
Definition: util.h:15
char opt_SourcesPath[LINESIZE]
Definition: options.c:47

Referenced by logRevCheck().

◆ logRevCheck()

static void logRevCheck ( FILE outFile)
static

Definition at line 48 of file revision.c.

49 {
50  int twice = 0;
51 
52  twice = (lastLine.nr2 && strcmp(lastLine.file1, lastLine.file2) != 0);
53  log_rev_check(outFile, lastLine.file1, twice);
54  if (twice)
55  {
56  log_rev_check(outFile, lastLine.file2, twice);
57  }
58 }
LINEINFO lastLine
Definition: log2lines.c:33
static void log_rev_check(FILE *outFile, char *fileName, int showfile)
Definition: revision.c:19
char file2[LINESIZE]
Definition: log2lines.h:19
char file1[LINESIZE]
Definition: log2lines.h:16
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469

Referenced by reportRevision().

◆ regscan()

int regscan ( FILE outFile)

Definition at line 154 of file revision.c.

155 {
156  int res = 0;
157  char logname[PATH_MAX];
158  char inxname[PATH_MAX];
159  char line[LINESIZE + 1];
160  char line2[LINESIZE + 1];
161  FILE *flog = NULL;
162  FILE *finx = NULL;
163  unsigned long pos = 0L;
164  int r;
165 
166  sprintf(logname, "%s" PATH_STR "%s", opt_SourcesPath, SVNDB);
167  sprintf(inxname, "%s" PATH_STR "%s", opt_SourcesPath, SVNDB_INX);
168  flog = fopen(logname, "rb");
169  finx = fopen(inxname, "rb");
170 
171  if (flog && finx)
172  {
173  r = revinfo.buildrev;
174  if (!fread(&pos, sizeof(long), 1, finx))
175  {
176  res = 2;
177  l2l_dbg(0, "Cannot read magic number\n");
178  }
179 
180  if (!res)
181  {
182  if (pos != MAGIC_INX)
183  {
184  res = 3;
185  l2l_dbg(0, "Incorrect magic number (%lx)\n", pos);
186  }
187  }
188 
189  if (!res)
190  {
191  char flag[2];
192  char path[PATH_MAX];
193  char path2[PATH_MAX];
194  int wflag = 0;
195  clilog(outFile, "Regression candidates:\n");
196  while (( pos = findRev(finx, &r) ))
197  {
198  if (r < (revinfo.buildrev - revinfo.range))
199  {
200  l2l_dbg(1, "r%d is outside range of %d revisions\n", r, revinfo.range);
201  break;
202  }
203  fseek(flog, pos, SEEK_SET);
204  wflag = 1;
205  fgets(line, LINESIZE, flog);
206  fgets(line2, LINESIZE, flog);
207  while (fgets(line2, LINESIZE, flog))
208  {
209  path2[0] = '\0';
210  if (sscanf(line2, "%1s %s %s", flag, path, path2) >= 2)
211  {
213  {
214  if (wflag == 1)
215  {
216  clilog(outFile, "%sChanged paths:\n", line);
217  summ.regfound++;
218  wflag = 2;
219  }
220  clilog(outFile, "%s", line2);
221  }
222  }
223  else
224  break;
225  }
226  if (wflag == 2)
227  {
228  int i = 0;
229  clilog(outFile, "\n");
230  while (fgets(line2, LINESIZE, flog))
231  {
232  i++;
233  clilog(outFile, "%s", line2);
234  if (strncmp(LOGBOTTOM, line2, sizeof(LOGBOTTOM) - 1) == 0)
235  break;
236  }
237  }
238  }
239  }
240  }
241  else
242  {
243  res = 1;
244  l2l_dbg(0, "Cannot open %s or %s\n", logname, inxname);
245  }
246 
247  if (flog)
248  fclose(flog);
249  if (finx)
250  fclose(finx);
251 
252  return res;
253 }
static const WCHAR path2[]
Definition: path.c:29
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define MAGIC_INX
Definition: config.h:11
#define sprintf(buf, format,...)
Definition: sprintf.c:55
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
_Check_return_opt_ _CRTIMP size_t __cdecl fread(_Out_writes_bytes_(_ElementSize *_Count) void *_DstBuf, _In_ size_t _ElementSize, _In_ size_t _Count, _Inout_ FILE *_File)
#define SVNDB_INX
Definition: config.h:9
#define l2l_dbg(level,...)
Definition: util.h:35
smooth NULL
Definition: ftsmooth.c:416
REVINFO revinfo
Definition: log2lines.c:37
_Check_return_opt_ _CRTIMP int __cdecl fseek(_Inout_ FILE *_File, _In_ long _Offset, _In_ int _Origin)
GLsizei GLenum * sources
Definition: glext.h:7753
Definition: parser.c:48
_Check_return_ _CRTIMP int __cdecl sscanf(_In_z_ const char *_Src, _In_z_ _Scanf_format_string_ const char *_Format,...)
#define SEEK_SET
Definition: jmemansi.c:26
PLIST_MEMBER entry_lookup(PLIST list, char *name)
Definition: list.c:19
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
#define PATH_MAX
Definition: types.h:280
#define clilog(outFile, fmt,...)
Definition: util.h:27
static const WCHAR L[]
Definition: oid.c:1250
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean flag
Definition: glfuncs.h:52
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
#define LOGBOTTOM
Definition: config.h:7
_Check_return_opt_ _CRTIMP char *__cdecl fgets(_Out_writes_z_(_MaxCount) char *_Buf, _In_ int _MaxCount, _Inout_ FILE *_File)
#define LINESIZE
Definition: chargen.c:18
unsigned long findRev(FILE *finx, int *rev)
Definition: revision.c:139
GLuint res
Definition: glext.h:9613
#define SVNDB
Definition: config.h:8
SUMM summ
Definition: log2lines.c:36
int regfound
Definition: stat.h:21
#define PATH_STR
Definition: compat.h:27
char opt_SourcesPath[LINESIZE]
Definition: options.c:47

Referenced by handle_escape_cmd(), and translate_files().

◆ reportRevision()

void reportRevision ( FILE outFile)

Definition at line 129 of file revision.c.

130 {
131  if (opt_Revision_check)
132  {
133  if (lastLine.valid)
134  logRevCheck(outFile);
135  }
136 }
static void logRevCheck(FILE *outFile)
Definition: revision.c:48
int opt_Revision_check
Definition: options.c:41
LINEINFO lastLine
Definition: log2lines.c:33

Referenced by report().

◆ updateSvnlog()

int updateSvnlog ( void  )

Definition at line 257 of file revision.c.

258 {
259  int res = 0;
260  char logname[PATH_MAX];
261  char inxname[PATH_MAX];
262  char line[LINESIZE + 1];
263  FILE *flog = NULL;
264  FILE *finx = NULL;
265  unsigned long pos;
266  int r, y, m, d;
267  char name[NAMESIZE];
268 
269  sprintf(logname, "%s" PATH_STR "%s", opt_SourcesPath, SVNDB);
270  sprintf(inxname, "%s" PATH_STR "%s", opt_SourcesPath, SVNDB_INX);
271  flog = fopen(logname, "rb");
272  finx = fopen(inxname, "wb");
273 
274  if (flog && finx)
275  {
276  pos = MAGIC_INX;
277  fwrite(&pos, sizeof(long), 1, finx);
278  pos = ftell(flog);
279  while (fgets(line, LINESIZE, flog))
280  {
281  if (sscanf(line, "r%d | %s | %d-%d-%d", &r, name, &y, &m, &d) == 5)
282  {
283  l2l_dbg(1, "%ld r%d | %s | %d-%d-%d\n", pos, r, name, y, m, d);
284  fseek(finx, r * sizeof(unsigned long), SEEK_SET);
285  fwrite(&pos, sizeof(unsigned long), 1, finx);
286  }
287  pos = ftell(flog);
288  }
289  }
290 
291  if (flog)
292  fclose(flog);
293  if (finx)
294  fclose(finx);
295 
296  return res;
297 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define MAGIC_INX
Definition: config.h:11
_Check_return_opt_ _CRTIMP size_t __cdecl fwrite(_In_reads_bytes_(_Size *_Count) const void *_Str, _In_ size_t _Size, _In_ size_t _Count, _Inout_ FILE *_File)
const GLfloat * m
Definition: glext.h:10848
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define NAMESIZE
Definition: config.h:35
#define SVNDB_INX
Definition: config.h:9
#define l2l_dbg(level,...)
Definition: util.h:35
smooth NULL
Definition: ftsmooth.c:416
_Check_return_opt_ _CRTIMP int __cdecl fseek(_Inout_ FILE *_File, _In_ long _Offset, _In_ int _Origin)
Definition: parser.c:48
_Check_return_ _CRTIMP int __cdecl sscanf(_In_z_ const char *_Src, _In_z_ _Scanf_format_string_ const char *_Format,...)
#define SEEK_SET
Definition: jmemansi.c:26
#define d
Definition: ke_i.h:81
#define PATH_MAX
Definition: types.h:280
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
_Check_return_opt_ _CRTIMP char *__cdecl fgets(_Out_writes_z_(_MaxCount) char *_Buf, _In_ int _MaxCount, _Inout_ FILE *_File)
#define LINESIZE
Definition: chargen.c:18
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
Definition: name.c:38
GLuint res
Definition: glext.h:9613
_Check_return_ _CRTIMP long __cdecl ftell(_Inout_ FILE *_File)
#define SVNDB
Definition: config.h:8
#define PATH_STR
Definition: compat.h:27
char opt_SourcesPath[LINESIZE]
Definition: options.c:47

Referenced by main().