Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 5198 → Rev 5197

/contrib/sdk/sources/newlib/libc/crt/crtdll.c
33,6 → 33,8
void* get_entry_point(void *raw);
int (*entry)(int, char **, char **);
 
char __appcwd[1024];
int __appcwdlen;
char* __appenv;
int __appenv_size;
 
200,6 → 202,11
if( link_app() == 0)
goto done;
 
__appcwdlen = strrchr(header->path, '/') - header->path;
__appcwdlen = __appcwdlen > 1022 ? 1022 : __appcwdlen;
memcpy(__appcwd, header->path, __appcwdlen);
set_cwd(__appcwd);
 
if( header->cmdline[0] != 0)
{
argc = split_cmdline(header->cmdline, NULL) + 1;
/contrib/sdk/sources/newlib/libc/crt/crt1.c
37,6 → 37,9
int _errno;
int _fmode;
 
char __appcwd[1024];
int __appcwdlen;
 
int _argc;
char **_argv;
 
95,6 → 98,13
 
__do_global_ctors();
 
__appcwdlen = strrchr(&__pgmname[0], '/') - &__pgmname[0] + 1;
__appcwdlen = __appcwdlen > 1023 ? 1023 : __appcwdlen;
memcpy(__appcwd, &__pgmname, __appcwdlen);
__appcwd[__appcwdlen] = 0;
 
set_cwd(__appcwd);
 
arg[0] = &__pgmname[0];
 
if( __cmdline[0] != 0)
/contrib/sdk/sources/newlib/libc/Makefile
272,7 → 272,6
refill.c \
rget.c \
remove.c \
rewind.c \
setvbuf.c \
stdio.c \
tmpfile.c \
/contrib/sdk/sources/newlib/libc/stdio/rewind.c
File deleted
/contrib/sdk/sources/newlib/libc/sys/open.c
22,89 → 22,8
#undef erro
extern int errno;
 
static inline int is_slash(char c)
{
return c=='/' || c=='\\';
}
 
void fix_slashes(char * in,char * out)
{
int slash_count;
 
for(slash_count=1;in && out && *in;in++)
{
if(is_slash(*in))
{
slash_count++;
continue;
}
else
{
if(slash_count)
{
slash_count=0;
*out++='/';
}
*out++=*in;
}
}
*out='\0';
};
 
 
void buildpath(char *buf, const char* file)
{
char *ptr;
 
ptr = buf + strlen(buf);
 
while (*file)
{
if (file[0] == '.' && file[1] == 0)
break;
 
if (file[0] == '.' && file[1] == '/')
{
file+=2;
continue;
};
 
if (file[0] == '.' && file[1] == '.' &&
(file[2] == 0 || file[2] == '/'))
{
while (ptr > buf && ptr[-1] != '/')
--ptr;
file+=2;
if (*file == 0)
break;
++file;
continue;
}
*ptr++ = '/';
if (*file == '/')
++file;
while (*file && *file!='/')
*ptr++ = *file++;
}
*ptr = 0;
};
 
static char *getccwd(char *buf, size_t size)
{
int bsize;
__asm__ __volatile__(
"int $0x40"
:"=a"(bsize)
:"a"(30),"b"(2),"c"(buf), "d"(size)
:"memory");
 
return buf;
};
 
int open (const char * filename, int flags, ...)
{
char buf[1024];
 
__io_handle *ioh;
fileinfo_t info;
int iomode, rwmode, offset;
118,20 → 37,10
return (-1);
};
 
if (filename[0]=='/')
{
strcpy(buf,filename);
}
else
{
getccwd(buf, 1024);
buildpath(buf, filename);
}
// path = getfullpath(name);
 
// printf("%s %s\n", __FUNCTION__, buf);
err = get_fileinfo(filename, &info);
 
err = get_fileinfo(buf, &info);
 
if( flags & O_EXCL &&
flags & O_CREAT )
{
145,7 → 54,7
if( err )
{
if(flags & O_CREAT)
err=create_file(buf);
err=create_file(filename);
if( err )
{
errno = EACCES;
154,7 → 63,7
};
 
if( flags & O_TRUNC )
set_file_size(buf, 0);
set_file_size(filename, 0);
 
ioh = &__io_tab[hid];
 
183,14 → 92,12
} else
iomode |= _BINARY;
 
ioh->name = strdup(buf);
ioh->name = strdup(filename);
ioh->offset = offset;
ioh->mode = iomode;
ioh->read = read_file;
ioh->write = write_file;
 
// printf("%s %s\n", __FUNCTION__, ioh->name);
 
return hid;
};