Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 8663 → Rev 8664

/contrib/games/wolf3d/kolibri.cpp
1,7 → 1,16
#include <stdlib.h>
#include <sys/stat.h>
#include "../../kolibri-libc/source/include/ksys.h"
#include <string.h>
 
void *memrchr(const void *m, int c, size_t n)
{
const unsigned char *s = (const unsigned char*)m;
c = (unsigned char)c;
while (n--) if (s[n]==c) return (void *)(s+n);
return 0;
}
 
void kolibri_set_win_center()
{
ksys_proc_table_t *info = (ksys_proc_table_t*)malloc(sizeof(ksys_proc_table_t));
19,3 → 28,54
return _ksys_mkdir(path);
}
 
char *dirname (char *path)
{
static const char dot[] = ".";
char *last_slash;
/* Find last '/'. */
last_slash = path != NULL ? strrchr (path, '/') : NULL;
if (last_slash != NULL && last_slash != path && last_slash[1] == '\0')
{
/* Determine whether all remaining characters are slashes. */
char *runp;
for (runp = last_slash; runp != path; --runp)
if (runp[-1] != '/')
break;
/* The '/' is the last character, we have to look further. */
if (runp != path)
last_slash = (char*)memrchr((void*)path, '/', runp - path);
}
if (last_slash != NULL)
{
/* Determine whether all remaining characters are slashes. */
char *runp;
for (runp = last_slash; runp != path; --runp)
if (runp[-1] != '/')
break;
/* Terminate the path. */
if (runp == path)
{
/* The last slash is the first character in the string. We have to
return "/". As a special case we have to return "//" if there
are exactly two slashes at the beginning of the string. See
XBD 4.10 Path Name Resolution for more information. */
if (last_slash == path + 1)
++last_slash;
else
last_slash = path + 1;
}
else
last_slash = runp;
last_slash[0] = '\0';
}
else
/* This assignment is ill-designed but the XPG specs require to
return a string containing "." in any case no directory part is
found and so a static and constant string is required. */
path = (char *) dot;
return path;
}
 
void setcwd(char* path){
_ksys_setcwd(path);
}
/contrib/games/wolf3d/wl_main.cpp
25,6 → 25,8
 
extern byte signon[];
extern void kolibri_set_win_center();
extern char* dirname(char* path);
extern void setcwd(char* path);
/*
=============================================================================
 
1959,6 → 1961,10
 
int main (int argc, char *argv[])
{
#ifdef _KOLIBRI
setcwd(dirname(argv[0]));
#endif
 
#if defined(_arch_dreamcast)
DC_Init();
#else