Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 8729 → Rev 8730

/programs/develop/libraries/kolibri-libc/source/ctype/tolower.c
0,0 → 1,7
#include <ctype.h>
 
int tolower(int c)
{
if (isupper(c)) return c | 32;
return c;
}
/programs/develop/libraries/kolibri-libc/source/ctype/toupper.c
0,0 → 1,7
#include <ctype.h>
 
int toupper(int c)
{
if (islower(c)) return c & 0x5f;
return c;
}
/programs/develop/libraries/kolibri-libc/source/libc.c
1,4 → 1,6
#include "ctype/is.c"
#include "ctype/tolower.c"
#include "ctype/toupper.c"
 
#include "sys/rewinddir.c"
#include "sys/readdir.c"
49,6 → 51,7
#include "stdio/rewind.c"
#include "stdio/vfprintf.c"
#include "stdio/fprintf.c"
#include "stdio/ungetc.c"
 
#include "string/strerror.c"
#include "string/strxfrm.c"
/programs/develop/libraries/kolibri-libc/source/stdio/fgetc.c
2,8 → 2,8
 
int fgetc(FILE* stream)
{
int c=EOF;
if(fwrite(&c, sizeof(int), 1, stream)==1){
int c=0;
if(fread(&c, sizeof(char), 1, stream)==1){
return c;
}else{
return EOF;
/programs/develop/libraries/kolibri-libc/source/stdio/fputc.c
4,7 → 4,7
 
int fputc(int c, FILE *stream)
{
if(fwrite(&c, sizeof(int), 1, stream)==1){
if(fwrite(&c, sizeof(char), 1, stream)==1){
return c;
}else{
return EOF;
/programs/develop/libraries/kolibri-libc/source/stdio/fputs.c
2,5 → 2,10
#include <string.h>
 
int fputs(const char *str, FILE *stream){
return fwrite(str, sizeof(char), strlen(str), stream);
size_t str_len = strlen(str);
if(str_len == fwrite(str, sizeof(char), str_len , stream)){
return str[str_len-1];
}else{
return EOF;
}
}
/programs/develop/libraries/kolibri-libc/source/stdio/fread.c
8,20 → 8,24
unsigned bytes_count = size * nmemb;
if(!stream){
errno = EINVAL;
errno = EBADF;
return 0;
}
if(stream==stdin){
__con_init();
__con_gets((char*)ptr, bytes_count);
__con_gets((char*)ptr, bytes_count+1);
return nmemb;
}
 
else{
if(stream->mode != _STDIO_F_W){
if(stream->mode & _FILEMODE_R){
if(!stream->__ungetc_emu_buff){
((char*) ptr)[0]=(char)stream->__ungetc_emu_buff;
//debug_printf("Ungetc: %x\n", ((char*) ptr)[0]);
}
unsigned status = _ksys_file_read_file(stream->name, stream->position, bytes_count, ptr , &bytes_read);
if (status != KSYS_FS_ERR_SUCCESS) {
if (status) {
errno = EIO;
stream->error = errno;
return 0;
/programs/develop/libraries/kolibri-libc/source/stdio/freopen.c
1,3 → 1,4
#include "stddef.h"
#include "sys/ksys.h"
#include <errno.h>
#include <stdio.h>
4,39 → 5,49
#include <stdlib.h>
#include <string.h>
 
#define CREATE_FILE() if(_ksys_file_create(_name)){ \
errno= EIO; \
free(out); \
out = NULL; \
}
 
FILE *freopen(const char *restrict _name, const char *restrict _mode, FILE *restrict out) {
static ksys_bdfe_t info;
info.size=0;
if (!out) {
errno = ENOMEM;
if(!_name || !_mode || !out){
errno = EINVAL;
return NULL;
}
 
_ksys_file_get_info(_name, &info);
if (strchr(_mode, 'r')) { out->mode = _FILEMODE_R; }
if (strchr(_mode, 'a')) { out->mode = _FILEMODE_A; }
if (strchr(_mode, 'w')) { out->mode = _FILEMODE_W; }
 
ksys_bdfe_t info;
int no_file = _ksys_file_get_info(_name, &info);
out->eof=0;
out->error=0;
out->position=0;
out->name = strdup(_name);
out->position = 0;
out->error = 0;
out->eof = 0;
out->kind = 0;
out->orientation = 0;
out->mode = 0;
out->start_size = info.size;
 
if (strchr(_mode, 'b')) { out->mode |= _STDIO_F_B; }
if (strchr(_mode, 'x')) { out->mode |= _STDIO_F_X; }
if (strchr(_mode, 'a')) { out->mode |= _STDIO_F_A; }
if (strchr(_mode, 'r')) { out->mode |= _STDIO_F_R; }
if (strchr(_mode, 'w')) { out->mode |= _STDIO_F_W; }
if (strchr(_mode, '+')) { out->mode |= _STDIO_F_R | _STDIO_F_W; }
 
if (out->mode & _STDIO_F_A) {
switch (out->mode) {
case _FILEMODE_A :
if(no_file){
CREATE_FILE();
}
out->position = info.size;
out->append_offset = info.size;
} else if(out->mode & _STDIO_F_W){
if(_ksys_file_create(_name)){
return NULL;
break;
case _FILEMODE_W :
CREATE_FILE();
break;
case _FILEMODE_R :
if(no_file){
free(out);
out = NULL;
}
break;
default:
free(out);
out = NULL;
break;
}
return out;
}
}
/programs/develop/libraries/kolibri-libc/source/stdio/fwrite.c
9,7 → 9,7
unsigned bytes_count = size * nmemb;
if(!stream){
errno = EINVAL;
errno = EBADF;
return 0;
}
25,7 → 25,7
}
}
else{
if(stream->mode != _STDIO_F_R){
if(stream->mode != _FILEMODE_R){
unsigned status = _ksys_file_write_file(stream->name, stream->position, bytes_count, ptr, &bytes_written);
if (status != KSYS_FS_ERR_SUCCESS) {
errno = EIO;
/programs/develop/libraries/kolibri-libc/source/stdio/getchar.c
2,7 → 2,9
#include "conio.h"
 
int getchar(void) {
int c = __con_getch();
__con_init();
char c = 0;
__con_gets(&c, 2);
if (c == 0) {
c = EOF;
}
/programs/develop/libraries/kolibri-libc/source/stdio/ungetc.c
11,12 → 11,12
return EOF;
}
 
if (file->mode != _STDIO_F_R){
if (file->mode != _FILEMODE_R){
errno = EACCES;
return EOF;
}
 
if (file->position > file->start_size || file->position == 0 || c == EOF || file->__ungetc_emu_buff != EOF)
if (file->position == 0 || c == EOF)
{
errno = EOF;
return EOF;
/programs/develop/libraries/kolibri-libc/source/symbols.txt
40,6 → 40,7
vfscanf
vsnprintf
vsscanf
ungetc
!____STDLIB____
abs
atoi
125,5 → 126,7
setjmp
!____CTYPE____
__is
tolower
toupper
!___CONIO___
con_set_title