Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 5197 → Rev 5198

/contrib/sdk/sources/newlib/libc/Makefile
272,6 → 272,7
refill.c \
rget.c \
remove.c \
rewind.c \
setvbuf.c \
stdio.c \
tmpfile.c \
/contrib/sdk/sources/newlib/libc/crt/crt1.c
37,9 → 37,6
int _errno;
int _fmode;
 
char __appcwd[1024];
int __appcwdlen;
 
int _argc;
char **_argv;
 
98,13 → 95,6
 
__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/crt/crtdll.c
33,8 → 33,6
void* get_entry_point(void *raw);
int (*entry)(int, char **, char **);
 
char __appcwd[1024];
int __appcwdlen;
char* __appenv;
int __appenv_size;
 
202,11 → 200,6
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/stdio/rewind.c
0,0 → 1,81
/*
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by the University of California, Berkeley. The name of the
* University may not be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
 
/*
FUNCTION
<<rewind>>---reinitialize a file or stream
 
INDEX
rewind
INDEX
_rewind_r
 
ANSI_SYNOPSIS
#include <stdio.h>
void rewind(FILE *<[fp]>);
void _rewind_r(struct _reent *<[ptr]>, FILE *<[fp]>);
 
TRAD_SYNOPSIS
#include <stdio.h>
void rewind(<[fp]>)
FILE *<[fp]>;
 
void _rewind_r(<[ptr]>, <[fp]>)
struct _reent *<[ptr]>;
FILE *<[fp]>;
 
DESCRIPTION
<<rewind>> returns the file position indicator (if any) for the file
or stream identified by <[fp]> to the beginning of the file. It also
clears any error indicator and flushes any pending output.
 
RETURNS
<<rewind>> does not return a result.
 
PORTABILITY
ANSI C requires <<rewind>>.
 
No supporting OS subroutines are required.
*/
 
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "%W% (Berkeley) %G%";
#endif /* LIBC_SCCS and not lint */
 
#include <_ansi.h>
#include <reent.h>
#include <stdio.h>
 
_VOID
_DEFUN(_rewind_r, (ptr, fp),
struct _reent * ptr _AND
register FILE * fp)
{
_CAST_VOID _fseek_r (ptr, fp, 0L, SEEK_SET);
clearerr (fp);
}
 
#ifndef _REENT_ONLY
 
_VOID
_DEFUN(rewind, (fp),
register FILE * fp)
{
_rewind_r (_REENT, fp);
}
 
#endif /* !_REENT_ONLY */
/contrib/sdk/sources/newlib/libc/sys/open.c
22,8 → 22,89
#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;
37,10 → 118,20
return (-1);
};
 
// path = getfullpath(name);
if (filename[0]=='/')
{
strcpy(buf,filename);
}
else
{
getccwd(buf, 1024);
buildpath(buf, filename);
}
 
err = get_fileinfo(filename, &info);
// printf("%s %s\n", __FUNCTION__, buf);
 
err = get_fileinfo(buf, &info);
 
if( flags & O_EXCL &&
flags & O_CREAT )
{
54,7 → 145,7
if( err )
{
if(flags & O_CREAT)
err=create_file(filename);
err=create_file(buf);
if( err )
{
errno = EACCES;
63,7 → 154,7
};
 
if( flags & O_TRUNC )
set_file_size(filename, 0);
set_file_size(buf, 0);
 
ioh = &__io_tab[hid];
 
92,12 → 183,14
} else
iomode |= _BINARY;
 
ioh->name = strdup(filename);
ioh->name = strdup(buf);
ioh->offset = offset;
ioh->mode = iomode;
ioh->read = read_file;
ioh->write = write_file;
 
// printf("%s %s\n", __FUNCTION__, ioh->name);
 
return hid;
};