Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Cleaned up returns that look like function calls for my updated codin…
…g style.
  • Loading branch information
icculus committed Jan 28, 2010
1 parent 17b2640 commit 595ac1d
Show file tree
Hide file tree
Showing 23 changed files with 687 additions and 690 deletions.
14 changes: 7 additions & 7 deletions extras/globbing.c
Expand Up @@ -77,14 +77,14 @@ static int matchesPattern(const char *fname, const char *wildcard,
fnameptr++;

if (x != y)
return(0);
return 0;
} /* else */
} /* while */

while (*wildptr == '*')
wildptr++;

return(*fnameptr == *wildptr);
return (*fnameptr == *wildptr);
} /* matchesPattern */

typedef struct
Expand Down Expand Up @@ -188,7 +188,7 @@ char **PHYSFSEXT_enumerateFilesWildcard(const char *dir, const char *wildcard,
} /* if */

PHYSFS_freeList(list);
return(retval);
return retval;
} /* PHYSFSEXT_enumerateFilesWildcard */


Expand All @@ -203,20 +203,20 @@ int main(int argc, char **argv)
{
printf("USAGE: %s <pattern> <caseSen>\n"
" where <caseSen> is 1 or 0.\n", argv[0]);
return(1);
return 1;
} /* if */

if (!PHYSFS_init(argv[0]))
{
fprintf(stderr, "PHYSFS_init(): %s\n", PHYSFS_getLastError());
return(1);
return 1;
} /* if */

if (!PHYSFS_addToSearchPath(".", 1))
{
fprintf(stderr, "PHYSFS_addToSearchPath(): %s\n", PHYSFS_getLastError());
PHYSFS_deinit();
return(1);
return 1;
} /* if */

flist = PHYSFSEXT_enumerateFilesWildcard("/", argv[1], atoi(argv[2]));
Expand All @@ -231,7 +231,7 @@ int main(int argc, char **argv)
PHYSFSEXT_freeEnumeration(flist);
PHYSFS_deinit();

return(0);
return 0;
} /* main */
#endif

Expand Down
32 changes: 16 additions & 16 deletions extras/ignorecase.c
Expand Up @@ -37,12 +37,12 @@ static int caseInsensitiveStringCompare(const char *x, const char *y)
ux = toupper((int) *x);
uy = toupper((int) *y);
if (ux != uy)
return((ux > uy) ? 1 : -1);
return ((ux > uy) ? 1 : -1);
x++;
y++;
} while ((ux) && (uy));

return(0);
return 0;
} /* caseInsensitiveStringCompare */


Expand All @@ -53,7 +53,7 @@ static int locateOneElement(char *buf)
char **i;

if (PHYSFS_exists(buf))
return(1); /* quick rejection: exists in current case. */
return 1; /* quick rejection: exists in current case. */

ptr = strrchr(buf, '/'); /* find entry at end of path. */
if (ptr == NULL)
Expand All @@ -75,13 +75,13 @@ static int locateOneElement(char *buf)
{
strcpy(ptr, *i); /* found a match. Overwrite with this case. */
PHYSFS_freeList(rc);
return(1);
return 1;
} /* if */
} /* for */

/* no match at all... */
PHYSFS_freeList(rc);
return(0);
return 0;
} /* locateOneElement */


Expand All @@ -96,19 +96,19 @@ int PHYSFSEXT_locateCorrectCase(char *buf)

ptr = prevptr = buf;
if (*ptr == '\0')
return(0); /* Uh...I guess that's success. */
return 0; /* Uh...I guess that's success. */

while (ptr = strchr(ptr + 1, '/'))
{
*ptr = '\0'; /* block this path section off */
rc = locateOneElement(buf);
*ptr = '/'; /* restore path separator */
if (!rc)
return(-2); /* missing element in path. */
return -2; /* missing element in path. */
} /* while */

/* check final element... */
return(locateOneElement(buf) ? 0 : -1);
return locateOneElement(buf ? 0 : -1);
} /* PHYSFSEXT_locateCorrectCase */


Expand All @@ -122,35 +122,35 @@ int main(int argc, char **argv)
if (!PHYSFS_init(argv[0]))
{
fprintf(stderr, "PHYSFS_init(): %s\n", PHYSFS_getLastError());
return(1);
return 1;
} /* if */

if (!PHYSFS_addToSearchPath(".", 1))
{
fprintf(stderr, "PHYSFS_addToSearchPath(): %s\n", PHYSFS_getLastError());
PHYSFS_deinit();
return(1);
return 1;
} /* if */

if (!PHYSFS_setWriteDir("."))
{
fprintf(stderr, "PHYSFS_setWriteDir(): %s\n", PHYSFS_getLastError());
PHYSFS_deinit();
return(1);
return 1;
} /* if */

if (!PHYSFS_mkdir("/a/b/c"))
{
fprintf(stderr, "PHYSFS_mkdir(): %s\n", PHYSFS_getLastError());
PHYSFS_deinit();
return(1);
return 1;
} /* if */

if (!PHYSFS_mkdir("/a/b/C"))
{
fprintf(stderr, "PHYSFS_mkdir(): %s\n", PHYSFS_getLastError());
PHYSFS_deinit();
return(1);
return 1;
} /* if */

f = PHYSFS_openWrite("/a/b/c/x.txt");
Expand All @@ -159,7 +159,7 @@ int main(int argc, char **argv)
{
fprintf(stderr, "PHYSFS_openWrite(): %s\n", PHYSFS_getLastError());
PHYSFS_deinit();
return(1);
return 1;
} /* if */

f = PHYSFS_openWrite("/a/b/C/X.txt");
Expand All @@ -168,7 +168,7 @@ int main(int argc, char **argv)
{
fprintf(stderr, "PHYSFS_openWrite(): %s\n", PHYSFS_getLastError());
PHYSFS_deinit();
return(1);
return 1;
} /* if */

strcpy(buf, "/a/b/c/x.txt");
Expand Down Expand Up @@ -211,7 +211,7 @@ int main(int argc, char **argv)
PHYSFS_delete("/a/b");
PHYSFS_delete("/a");
PHYSFS_deinit();
return(0);
return 0;
} /* main */
#endif

Expand Down
14 changes: 7 additions & 7 deletions extras/physfshttpd.c
Expand Up @@ -144,7 +144,7 @@ static void *do_http(void *_args)
close(args->sock);
free(args->addr);
free(args);
return(NULL);
return NULL;
} /* do_http */


Expand Down Expand Up @@ -202,7 +202,7 @@ static int create_listen_socket(short portnum)
} /* if */
} /* if */

return(retval);
return retval;
} /* create_listen_socket */


Expand Down Expand Up @@ -244,13 +244,13 @@ int main(int argc, char **argv)
if (argc == 1)
{
printf("USAGE: %s <archive1> [archive2 [... archiveN]]\n", argv[0]);
return(42);
return 42;
} /* if */

if (!PHYSFS_init(argv[0]))
{
printf("PHYSFS_init() failed: %s\n", PHYSFS_getLastError());
return(42);
return 42;
} /* if */

/* normally, this is bad practice, but oh well. */
Expand All @@ -266,7 +266,7 @@ int main(int argc, char **argv)
if (listensocket < 0)
{
printf("listen socket failed to create.\n");
return(42);
return 42;
} /* if */

while (1) /* infinite loop for now. */
Expand All @@ -278,13 +278,13 @@ int main(int argc, char **argv)
{
printf("accept() failed: %s\n", strerror(errno));
close(listensocket);
return(42);
return 42;
} /* if */

serve_http_request(s, &addr, len);
} /* while */

return(0);
return 0;
} /* main */

/* end of physfshttpd.c ... */
Expand Down
36 changes: 18 additions & 18 deletions extras/physfsrwops.c
Expand Up @@ -40,18 +40,18 @@ static int physfsrwops_seek(SDL_RWops *rw, int offset, int whence)
{
SDL_SetError("Can't find position in file: %s",
PHYSFS_getLastError());
return(-1);
return -1;
} /* if */

pos = (int) current;
if ( ((PHYSFS_sint64) pos) != current )
{
SDL_SetError("Can't fit current file position in an int!");
return(-1);
return -1;
} /* if */

if (offset == 0) /* this is a "tell" call. We're done. */
return(pos);
return pos;

pos += offset;
} /* else if */
Expand All @@ -62,14 +62,14 @@ static int physfsrwops_seek(SDL_RWops *rw, int offset, int whence)
if (len == -1)
{
SDL_SetError("Can't find end of file: %s", PHYSFS_getLastError());
return(-1);
return -1;
} /* if */

pos = (int) len;
if ( ((PHYSFS_sint64) pos) != len )
{
SDL_SetError("Can't fit end-of-file position in an int!");
return(-1);
return -1;
} /* if */

pos += offset;
Expand All @@ -78,22 +78,22 @@ static int physfsrwops_seek(SDL_RWops *rw, int offset, int whence)
else
{
SDL_SetError("Invalid 'whence' parameter.");
return(-1);
return -1;
} /* else */

if ( pos < 0 )
{
SDL_SetError("Attempt to seek past start of file.");
return(-1);
return -1;
} /* if */

if (!PHYSFS_seek(handle, (PHYSFS_uint64) pos))
{
SDL_SetError("PhysicsFS error: %s", PHYSFS_getLastError());
return(-1);
return -1;
} /* if */

return(pos);
return pos;
} /* physfsrwops_seek */


Expand All @@ -107,7 +107,7 @@ static int physfsrwops_read(SDL_RWops *rw, void *ptr, int size, int maxnum)
SDL_SetError("PhysicsFS error: %s", PHYSFS_getLastError());
} /* if */

return((int) rc);
return ((int) rc);
} /* physfsrwops_read */


Expand All @@ -118,7 +118,7 @@ static int physfsrwops_write(SDL_RWops *rw, const void *ptr, int size, int num)
if (rc != num)
SDL_SetError("PhysicsFS error: %s", PHYSFS_getLastError());

return((int) rc);
return ((int) rc);
} /* physfsrwops_write */


Expand All @@ -128,11 +128,11 @@ static int physfsrwops_close(SDL_RWops *rw)
if (!PHYSFS_close(handle))
{
SDL_SetError("PhysicsFS error: %s", PHYSFS_getLastError());
return(-1);
return -1;
} /* if */

SDL_FreeRW(rw);
return(0);
return 0;
} /* physfsrwops_close */


Expand All @@ -155,7 +155,7 @@ static SDL_RWops *create_rwops(PHYSFS_File *handle)
} /* if */
} /* else */

return(retval);
return retval;
} /* create_rwops */


Expand All @@ -167,25 +167,25 @@ SDL_RWops *PHYSFSRWOPS_makeRWops(PHYSFS_File *handle)
else
retval = create_rwops(handle);

return(retval);
return retval;
} /* PHYSFSRWOPS_makeRWops */


SDL_RWops *PHYSFSRWOPS_openRead(const char *fname)
{
return(create_rwops(PHYSFS_openRead(fname)));
return create_rwops(PHYSFS_openRead(fname));
} /* PHYSFSRWOPS_openRead */


SDL_RWops *PHYSFSRWOPS_openWrite(const char *fname)
{
return(create_rwops(PHYSFS_openWrite(fname)));
return create_rwops(PHYSFS_openWrite(fname));
} /* PHYSFSRWOPS_openWrite */


SDL_RWops *PHYSFSRWOPS_openAppend(const char *fname)
{
return(create_rwops(PHYSFS_openAppend(fname)));
return create_rwops(PHYSFS_openAppend(fname));
} /* PHYSFSRWOPS_openAppend */


Expand Down

0 comments on commit 595ac1d

Please sign in to comment.