White-space patch for programs/winetest/main.c
Jakob Eriksson
jakov at vmlinux.org
Wed Apr 21 10:46:22 CDT 2004
This is a pure whitespace/comment patch.
(Apply this before applying code patch for detecting Wine - coming later.)
This is also an example of how the file can store its indent preference
in a comment.
I will run this when I'm done editing the file:
FILENAME=main.c && `grep indent $FILENAME` $FILENAME
regards,
Jakob
-------------- next part --------------
Index: main.c
===================================================================
RCS file: /home/wine/wine/programs/winetest/main.c,v
retrieving revision 1.11
diff -u -r1.11 main.c
--- main.c 20 Apr 2004 04:00:07 -0000 1.11
+++ main.c 21 Apr 2004 15:42:28 -0000
@@ -1,4 +1,5 @@
/*
+ indent -bap -bad -bbo -br -bli4 -bls -bs -ci4 -cli0 -cs -hnl -i4 -l80 -lp -nv -pcs -saf -sai -saw -ss -TTCHAR -ts4 -nut -di2 -npsl
* Wine Conformance Test EXE
*
* Copyright 2003 Jakob Eriksson (for Solid Form Sweden AB)
@@ -50,8 +51,8 @@
struct rev_info
{
- const char* file;
- const char* rev;
+ const char *file;
+ const char *rev;
};
static struct wine_test *wine_tests;
@@ -64,12 +65,11 @@
OSVERSIONINFOEX ver;
BOOL ext;
- ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
- if (!(ext = GetVersionEx ((OSVERSIONINFO *) &ver)))
- {
- ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
- if (!GetVersionEx ((OSVERSIONINFO *) &ver))
- report (R_FATAL, "Can't get OS version.");
+ ver.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEX);
+ if (!(ext = GetVersionEx ((OSVERSIONINFO *) & ver))) {
+ ver.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
+ if (!GetVersionEx ((OSVERSIONINFO *) & ver))
+ report (R_FATAL, "Can't get OS version.");
}
xprintf (" dwMajorVersion=%ld\n dwMinorVersion=%ld\n"
@@ -77,7 +77,8 @@
ver.dwMajorVersion, ver.dwMinorVersion, ver.dwBuildNumber,
ver.dwPlatformId, ver.szCSDVersion);
- if (!ext) return;
+ if (!ext)
+ return;
xprintf (" wServicePackMajor=%d\n wServicePackMinor=%d\n"
" wSuiteMask=%d\n wProductType=%d\n wReserved=%d\n",
@@ -85,14 +86,14 @@
ver.wProductType, ver.wReserved);
}
-static inline int is_dot_dir(const char* x)
+static inline int is_dot_dir (const char *x)
{
return ((x[0] == '.') && ((x[1] == 0) || ((x[1] == '.') && (x[2] == 0))));
}
void remove_dir (const char *dir)
{
- HANDLE hFind;
+ HANDLE hFind;
WIN32_FIND_DATA wfd;
char path[MAX_PATH];
size_t dirlen = strlen (dir);
@@ -101,16 +102,19 @@
memcpy (path, dir, dirlen);
strcpy (path + dirlen++, "\\*");
hFind = FindFirstFile (path, &wfd);
- if (hFind == INVALID_HANDLE_VALUE) return;
+ if (hFind == INVALID_HANDLE_VALUE)
+ return;
do {
char *lp = wfd.cFileName;
- if (!lp[0]) lp = wfd.cAlternateFileName; /* ? FIXME not (!lp) ? */
- if (is_dot_dir (lp)) continue;
+ if (!lp[0])
+ lp = wfd.cAlternateFileName; /* ? FIXME not (!lp) ? */
+ if (is_dot_dir (lp))
+ continue;
strcpy (path + dirlen, lp);
if (FILE_ATTRIBUTE_DIRECTORY & wfd.dwFileAttributes)
- remove_dir(path);
+ remove_dir (path);
else if (!DeleteFile (path))
report (R_WARNING, "Can't delete file %s: error %d",
path, GetLastError ());
@@ -121,33 +125,34 @@
dir, GetLastError ());
}
-const char* get_test_source_file(const char* test, const char* subtest)
+const char *get_test_source_file (const char *test, const char *subtest)
{
- static const char* special_dirs[][2] = {
- { "gdi32", "gdi"}, { "kernel32", "kernel" },
- { "user32", "user" }, { "winspool.drv", "winspool" },
- { "ws2_32", "winsock" }, { 0, 0 }
+ static const char *special_dirs[][2] = {
+ {"gdi32", "gdi"}, {"kernel32", "kernel"},
+ {"user32", "user"}, {"winspool.drv", "winspool"},
+ {"ws2_32", "winsock"}, {0, 0}
};
static char buffer[MAX_PATH];
int i;
for (i = 0; special_dirs[i][0]; i++) {
- if (strcmp(test, special_dirs[i][0]) == 0) {
- test = special_dirs[i][1];
- break;
- }
+ if (strcmp (test, special_dirs[i][0]) == 0) {
+ test = special_dirs[i][1];
+ break;
+ }
}
- snprintf(buffer, sizeof(buffer), "dlls/%s/tests/%s.c", test, subtest);
+ snprintf (buffer, sizeof (buffer), "dlls/%s/tests/%s.c", test, subtest);
return buffer;
}
-const char* get_file_rev(const char* file)
+const char *get_file_rev (const char *file)
{
- const struct rev_info* rev;
-
- for(rev = rev_infos; rev->file; rev++) {
- if (strcmp(rev->file, file) == 0) return rev->rev;
+ const struct rev_info *rev;
+
+ for (rev = rev_infos; rev->file; rev++) {
+ if (strcmp (rev->file, file) == 0)
+ return rev->rev;
}
return "-";
@@ -160,46 +165,45 @@
HMODULE module = GetModuleHandle (NULL);
for (i = 0; TRUE; i++) {
- if (i >= size) {
- size += 100;
- rev_infos = xrealloc (rev_infos, size * sizeof (*rev_infos));
- }
- memset(rev_infos + i, 0, sizeof(rev_infos[i]));
-
- len = LoadStringA (module, i + 30000, revinfo, sizeof(revinfo));
- if (len == 0) break; /* end of revision info */
- if (len >= sizeof(revinfo) - 1)
- report (R_FATAL, "Revision info too long.");
- if(!(p = strrchr(revinfo, ':')))
- report (R_FATAL, "Revision info malformed (i=%d)", i);
- *p = 0;
- rev_infos[i].file = strdup(revinfo);
- rev_infos[i].rev = strdup(p + 1);
+ if (i >= size) {
+ size += 100;
+ rev_infos = xrealloc (rev_infos, size * sizeof (*rev_infos));
+ }
+ memset (rev_infos + i, 0, sizeof (rev_infos[i]));
+
+ len = LoadStringA (module, i + 30000, revinfo, sizeof (revinfo));
+ if (len == 0)
+ break; /* end of revision info */
+ if (len >= sizeof (revinfo) - 1)
+ report (R_FATAL, "Revision info too long.");
+ if (!(p = strrchr (revinfo, ':')))
+ report (R_FATAL, "Revision info malformed (i=%d)", i);
+ *p = 0;
+ rev_infos[i].file = strdup (revinfo);
+ rev_infos[i].rev = strdup (p + 1);
}
}
-void* extract_rcdata (int id, DWORD* size)
+void *extract_rcdata (int id, DWORD * size)
{
HRSRC rsrc;
HGLOBAL hdl;
LPVOID addr = NULL;
-
- if (!(rsrc = FindResource (0, (LPTSTR)id, TESTRESOURCE)) ||
+
+ if (!(rsrc = FindResource (0, (LPTSTR) id, TESTRESOURCE)) ||
!(*size = SizeofResource (0, rsrc)) ||
- !(hdl = LoadResource (0, rsrc)) ||
- !(addr = LockResource (hdl)))
+ !(hdl = LoadResource (0, rsrc)) || !(addr = LockResource (hdl)))
report (R_FATAL, "Can't extract test file of id %d: %d",
id, GetLastError ());
return addr;
}
/* Fills in the name and exename fields */
-void
-extract_test (struct wine_test *test, const char *dir, int id)
+void extract_test (struct wine_test *test, const char *dir, int id)
{
- BYTE* code;
+ BYTE *code;
DWORD size;
- FILE* fout;
+ FILE *fout;
int strlen, bufflen = 128;
char *exepos;
@@ -210,18 +214,19 @@
bufflen *= 2;
test->name = xrealloc (test->name, bufflen);
}
- if (!strlen) report (R_FATAL, "Can't read name of test %d.", id);
+ if (!strlen)
+ report (R_FATAL, "Can't read name of test %d.", id);
test->exename = strmake (NULL, "%s/%s", dir, test->name);
exepos = strstr (test->name, "_test.exe");
- if (!exepos) report (R_FATAL, "Not an .exe file: %s", test->name);
+ if (!exepos)
+ report (R_FATAL, "Not an .exe file: %s", test->name);
*exepos = 0;
test->name = xrealloc (test->name, exepos - test->name + 1);
report (R_STEP, "Extracting: %s", test->name);
if (!(fout = fopen (test->exename, "wb")) ||
- (fwrite (code, size, 1, fout) != 1) ||
- fclose (fout)) report (R_FATAL, "Failed to write file %s.",
- test->exename);
+ (fwrite (code, size, 1, fout) != 1) || fclose (fout))
+ report (R_FATAL, "Failed to write file %s.", test->exename);
}
/* Run a command for MS milliseconds. If OUT != NULL, also redirect
@@ -230,8 +235,7 @@
Return the exit status, -2 if can't create process or the return
value of WaitForSingleObject.
*/
-int
-run_ex (char *cmd, const char *out, DWORD ms)
+int run_ex (char *cmd, const char *out, DWORD ms)
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
@@ -254,15 +258,16 @@
close (fd);
}
- if (!CreateProcessA (NULL, cmd, NULL, NULL, TRUE, 0,
- NULL, NULL, &si, &pi)) {
+ if (!CreateProcessA (NULL, cmd, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi)) {
status = -2;
- } else {
+ }
+ else {
CloseHandle (pi.hThread);
wait = WaitForSingleObject (pi.hProcess, ms);
if (wait == WAIT_OBJECT_0) {
GetExitCodeProcess (pi.hProcess, &status);
- } else {
+ }
+ else {
switch (wait) {
case WAIT_FAILED:
report (R_ERROR, "Wait for '%s' failed: %d", cmd,
@@ -291,8 +296,7 @@
report (R_ERROR, "Can't kill process '%s'", cmd);
break;
default:
- report (R_ERROR, "Waiting for termination: %d",
- wait);
+ report (R_ERROR, "Waiting for termination: %d", wait);
}
}
CloseHandle (pi.hProcess);
@@ -307,8 +311,7 @@
return status;
}
-void
-get_subtests (const char *tempdir, struct wine_test *test, int id)
+void get_subtests (const char *tempdir, struct wine_test *test, int id)
{
char *subname;
FILE *subfile;
@@ -320,7 +323,8 @@
test->subtest_count = 0;
subname = tempnam (0, "sub");
- if (!subname) report (R_FATAL, "Can't name subtests file.");
+ if (!subname)
+ report (R_FATAL, "Can't name subtests file.");
extract_test (test, tempdir, id);
run_ex (test->exename, subname, 5000);
@@ -342,40 +346,37 @@
index = strstr (buffer, header);
if (!index) {
- report (R_ERROR, "Can't parse subtests output of %s",
- test->name);
+ report (R_ERROR, "Can't parse subtests output of %s", test->name);
goto quit;
}
index += sizeof header;
allocated = 10;
- test->subtests = xmalloc (allocated * sizeof(char*));
+ test->subtests = xmalloc (allocated * sizeof (char *));
index = strtok (index, seps);
while (index) {
if (test->subtest_count == allocated) {
allocated *= 2;
test->subtests = xrealloc (test->subtests,
- allocated * sizeof(char*));
+ allocated * sizeof (char *));
}
test->subtests[test->subtest_count++] = strdup (index);
index = strtok (NULL, seps);
}
test->subtests = xrealloc (test->subtests,
- test->subtest_count * sizeof(char*));
+ test->subtest_count * sizeof (char *));
- quit:
+ quit:
if (remove (subname))
- report (R_WARNING, "Can't delete file '%s': %d",
- subname, errno);
+ report (R_WARNING, "Can't delete file '%s': %d", subname, errno);
free (subname);
}
-void
-run_test (struct wine_test* test, const char* subtest)
+void run_test (struct wine_test *test, const char *subtest)
{
int status;
- const char* file = get_test_source_file(test->name, subtest);
- const char* rev = get_file_rev(file);
+ const char *file = get_test_source_file (test->name, subtest);
+ const char *rev = get_file_rev (file);
char *cmd = strmake (NULL, "%s %s", test->exename, subtest);
xprintf ("%s:%s start %s %s\n", test->name, subtest, file, rev);
@@ -388,12 +389,11 @@
EnumTestFileProc (HMODULE hModule, LPCTSTR lpszType,
LPTSTR lpszName, LONG_PTR lParam)
{
- (*(int*)lParam)++;
+ (*(int *) lParam)++;
return TRUE;
}
-char *
-run_tests (char *logname, const char *tag)
+char *run_tests (char *logname, const char *tag)
{
int nr_of_files = 0, nr_of_tests = 0, i;
char *tempdir;
@@ -402,7 +402,8 @@
SetErrorMode (SEM_NOGPFAULTERRORBOX);
- if (!(wineloader = getenv("WINELOADER"))) wineloader = "wine";
+ if (!(wineloader = getenv ("WINELOADER")))
+ wineloader = "wine";
tempdir = tempnam (0, "wct");
if (!tempdir)
@@ -413,40 +414,40 @@
if (!logname) {
logname = tempnam (0, "res");
- if (!logname) report (R_FATAL, "Can't name logfile.");
+ if (!logname)
+ report (R_FATAL, "Can't name logfile.");
}
report (R_OUT, logname);
logfile = fopen (logname, "a");
- if (!logfile) report (R_FATAL, "Could not open logfile.");
+ if (!logfile)
+ report (R_FATAL, "Could not open logfile.");
if (-1 == dup2 (fileno (logfile), 1))
report (R_FATAL, "Can't redirect stdout.");
fclose (logfile);
xprintf ("Version 2\n");
- i = LoadStringA (GetModuleHandle (NULL), 0,
- build_tag, sizeof build_tag);
- if (i == 0) report (R_FATAL, "Build descriptor not found: %d",
- GetLastError ());
+ i = LoadStringA (GetModuleHandle (NULL), 0, build_tag, sizeof build_tag);
+ if (i == 0)
+ report (R_FATAL, "Build descriptor not found: %d", GetLastError ());
if (i >= sizeof build_tag)
report (R_FATAL, "Build descriptor too long.");
xprintf ("Tests from build %s\n", build_tag);
- xprintf ("Tag: %s\n", tag?tag:"");
+ xprintf ("Tag: %s\n", tag ? tag : "");
xprintf ("Operating system version:\n");
print_version ();
- xprintf ("Test output:\n" );
+ xprintf ("Test output:\n");
report (R_STATUS, "Counting tests");
if (!EnumResourceNames (NULL, TESTRESOURCE,
- EnumTestFileProc, (LPARAM)&nr_of_files))
- report (R_FATAL, "Can't enumerate test files: %d",
- GetLastError ());
+ EnumTestFileProc, (LPARAM) & nr_of_files))
+ report (R_FATAL, "Can't enumerate test files: %d", GetLastError ());
wine_tests = xmalloc (nr_of_files * sizeof wine_tests[0]);
report (R_STATUS, "Extracting tests");
report (R_PROGRESS, 0, nr_of_files);
for (i = 0; i < nr_of_files; i++) {
- get_subtests (tempdir, wine_tests+i, i+1);
+ get_subtests (tempdir, wine_tests + i, i + 1);
nr_of_tests += wine_tests[i].subtest_count;
}
report (R_DELTA, 0, "Extracting: Done");
@@ -457,10 +458,9 @@
struct wine_test *test = wine_tests + i;
int j;
- for (j = 0; j < test->subtest_count; j++) {
- report (R_STEP, "Running: %s:%s", test->name,
- test->subtests[j]);
- run_test (test, test->subtests[j]);
+ for (j = 0; j < test->subtest_count; j++) {
+ report (R_STEP, "Running: %s:%s", test->name, test->subtests[j]);
+ run_test (test, test->subtests[j]);
}
}
report (R_DELTA, 0, "Running: Done");
@@ -474,8 +474,7 @@
return logname;
}
-void
-usage ()
+void usage ()
{
fprintf (stderr, "\
Usage: winetest [OPTION]...\n\n\
@@ -488,8 +487,7 @@
}
/* One can't nest strtok()-s, so here is a replacement. */
-char *
-mystrtok (char *newstr)
+char *mystrtok (char *newstr)
{
static char *start, *end;
static int finish = 1;
@@ -497,29 +495,36 @@
if (newstr) {
start = newstr;
finish = 0;
- } else start = end;
- if (finish) return NULL;
- while (*start == ' ') start++;
- if (*start == 0) return NULL;
+ }
+ else
+ start = end;
+ if (finish)
+ return NULL;
+ while (*start == ' ')
+ start++;
+ if (*start == 0)
+ return NULL;
end = start;
while (*end != ' ')
if (*end == 0) {
finish = 1;
return start;
- } else end++;
+ }
+ else
+ end++;
*end++ = 0;
return start;
}
-int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrevInst,
- LPSTR cmdLine, int cmdShow)
+int WINAPI
+WinMain (HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR cmdLine, int cmdShow)
{
char *logname = NULL;
char *tag = NULL, *cp;
const char *submit = NULL;
/* initialize the revision information first */
- extract_rev_infos();
+ extract_rev_infos ();
cmdLine = mystrtok (cmdLine);
while (cmdLine) {
More information about the wine-patches
mailing list