/programs/develop/ktcc/trunk/libc/build.bat |
---|
7,7 → 7,7 |
set LIBNAME=libck.a |
set INCLUDE=include |
set CC=kos32-tcc |
set CFLAGS=-c -nostdinc -DGNUC -I"%cd%\%INCLUDE%" -Wall |
set CFLAGS=-c -nostdinc -DGNUC -I"%cd%\%INCLUDE%" |
set AR=kos32-ar |
set ASM=fasm |
set dirs=stdio memory kolibrisys string stdlib |
/programs/develop/ktcc/trunk/libc/string/strrev.c |
---|
File deleted |
\ No newline at end of file |
/programs/develop/ktcc/trunk/libc/string/strcoll.c |
---|
1,5 → 1,3 |
#include <string.h> |
int strcoll(const char* string1,const char* string2) |
{ |
return strcmp(string1,string2); |
/programs/develop/ktcc/trunk/libc/string/strdup.c |
---|
1,7 → 1,4 |
#include <stdlib.h> |
#include <string.h> |
char* strdup(const char* str) |
char* strdup(char* str) |
{ |
char* res; |
int len; |
/programs/develop/ktcc/trunk/libc/string/strnbrk.c |
---|
1,6 → 1,6 |
char* strpbrk(const char* string, const char* strCharSet) |
{ |
const char* temp; |
char* temp; |
while (*string!='\0') |
{ |
temp=strCharSet; |
7,7 → 7,7 |
while (*temp!='\0') |
{ |
if (*string==*temp) |
return (char*)string; |
return string; |
temp++; |
} |
string++; |
/programs/develop/ktcc/trunk/libc/string/strstr.c |
---|
1,5 → 1,4 |
#include<string.h> |
extern int strncmp(char* s1,char* s2,int len); |
char* strstr(const char* s, const char* find) |
{ |
int len; |
6,7 → 5,7 |
len=strlen(find); |
while (1) |
{ |
if (strncmp(s,find,len)==0) return (char*)s; |
if (strncmp(s,find,len)==0) return s; |
if (*s=='\0') |
return (char*) 0; |
s++; |
/programs/develop/ktcc/trunk/libc/include/stddef.h |
---|
File deleted |
/programs/develop/ktcc/trunk/libc/include/stdbool.h |
---|
File deleted |
/programs/develop/ktcc/trunk/libc/include/varargs.h |
---|
File deleted |
/programs/develop/ktcc/trunk/libc/include/float.h |
---|
File deleted |
/programs/develop/ktcc/trunk/libc/include/stdarg.h |
---|
File deleted |
/programs/develop/ktcc/trunk/libc/include/stdlib.h |
---|
11,8 → 11,8 |
extern int atoi(char *s); |
extern unsigned char tolower(unsigned char c); |
extern unsigned char toupper(unsigned char c); |
extern char *itoab(int n,char* s,int b); |
extern char *itoa(int n,char* s); |
extern void itoab(int n,char* s,int b); |
extern void itoa(int n,char* s); |
extern void* stdcall malloc(dword size); |
extern void stdcall free(void *pointer); |
/programs/develop/ktcc/trunk/libc/include/stdio.h |
---|
10,7 → 10,7 |
#define va_end(ap) (ap = (va_list)0) |
#define NULL ((void*)0) |
int format_print(char *dest, size_t maxlen,const char *fmt0, va_list argp); |
//extern int stdcall format_print(char *dest, size_t maxlen, const char *fmt0, va_list argp); |
typedef struct { |
char* buffer; |
54,6 → 54,4 |
extern int cdecl snprintf(char *dest, size_t size, const char *format,...); |
extern int cdecl sprintf(char *dest,const char *format,...); |
#define getc(a) fgetc(a) |
#endif |
/programs/develop/ktcc/trunk/libc/include/string.h |
---|
22,5 → 22,4 |
extern char* strtok(char*,const char*); |
extern int strxfrm(char*,const char*,int); |
extern char* strdup(const char*); |
extern char* strrev(char *p); |
#endif |
/programs/develop/ktcc/trunk/libc/stdlib/itoa.c |
---|
1,12 → 1,11 |
#include <stdio.h> |
#include <stdlib.h> |
#include <ctype.h> |
#include <string.h> |
#include "stdio.h" |
#include "stdlib.h" |
#include "ctype.h" |
/* |
** itoa(n,s) - Convert n to characters in s |
*/ |
char* itoa(int n,char* s) |
void itoa(int n,char* s) |
{ |
int sign; |
char *ptr; |
17,6 → 16,6 |
} while ((n = n / 10) > 0); |
if (sign < 0) *ptr++ = '-'; |
*ptr = '\0'; |
return strrev(s); |
reverse(s); |
} |
/programs/develop/ktcc/trunk/libc/stdlib/itoab.c |
---|
1,13 → 1,12 |
#include <stdio.h> |
#include <stdlib.h> |
#include <ctype.h> |
#include <string.h> |
#include "stdio.h" |
#include "stdlib.h" |
#include "ctype.h" |
/* |
** itoab(n,s,b) - Convert "unsigned" n to characters in s using base b. |
** NOTE: This is a non-standard function. |
*/ |
char* itoab(int n,char* s,int b) |
void itoab(int n,char* s,int b) |
{ |
char *ptr; |
int lowbit; |
21,5 → 20,5 |
++ptr; |
} while(n /= b); |
*ptr = 0; |
return strrev(s); |
reverse (s); |
} |
/programs/develop/ktcc/trunk/libc/memory/memalloc.asm |
---|
31,8 → 31,8 |
mov ebx,20 |
mov eax,68 |
mov edx,[esp+4] ; pointer |
mov ecx,[esp+8] ; size |
mov ecx,[esp+4] |
mov edx,[esp+8] |
int 0x40 |
ret 8 |
/programs/develop/ktcc/trunk/libc/stdio/fopen.c |
---|
128,7 → 128,7 |
res->filesize=0; |
res->filepos=0; |
res->mode=imode; |
res->filename=(char*)getfullpath(filename); |
res->filename=getfullpath(filename); |
if ((imode==FILE_OPEN_READ) || (imode==FILE_OPEN_APPEND)) |
{ |
/programs/develop/ktcc/trunk/libc/stdio/format_print.c |
---|
414,11 → 414,9 |
flag_unsigned=1; |
break; |
case 'x': |
case 'p': |
format_flag=1; |
break; |
case 'X': |
case 'P': |
flag_register=1; |
format_flag=1; |
break; |
453,7 → 451,7 |
{ |
case 'c': |
case 'C': |
if ((pos+1)<=maxlen) |
if ((pos+1)<maxlen) |
{ |
//*s=(int)va_arg(argp,char*); |
*s=*((char *)argp); |
465,10 → 463,11 |
case 'S': |
str=va_arg(argp,char*); |
length=strlen(str); |
if (pos + length > maxlen) |
length = maxlen - pos; |
if ((pos+length)<maxlen) |
{ |
memcpy(s,str,length); |
s=s+length;pos=pos+length; |
} |
break; |
case 'd': |
case 'D': |
479,7 → 478,7 |
if (flag_long==2) {intdigit=va_arg(argp,long long);} |
//intdigit=*((long*)argp); |
//argp=argp+4; |
if ((intdigit>0) && (flag_plus==1) && (pos+1<=maxlen)) |
if ((intdigit>0) && (flag_plus==1) && (pos+1<maxlen)) |
{ |
*s='+'; |
s++; |
486,10 → 485,11 |
pos++; |
} |
length=formatted_long_to_string(intdigit,0,buf); |
if (pos + length > maxlen) |
length = maxlen - pos; |
if ((pos+length)<maxlen) |
{ |
memcpy(s,buf,length); |
s=s+length;pos=pos+length; |
} |
break; |
case 'o': |
if (flag_long==0) {intdigit=va_arg(argp,int);} |
499,10 → 499,11 |
//argp=argp+4; |
length=formatted_octa_to_string(intdigit,0,flag_register,buf); |
if (pos + length > maxlen) |
length = maxlen - pos; |
if ((pos+length)<maxlen) |
{ |
memcpy(s,buf,length); |
s=s+length;pos=pos+length; |
} |
break; |
case 'u': |
case 'U': |
515,13 → 516,12 |
} |
length=formatted_long_to_string(intdigit,0,buf); |
if (pos + length > maxlen) |
length = maxlen - pos; |
if ((pos+length)<maxlen) |
{ |
memcpy(s,buf,length); |
s=s+length;pos=pos+length; |
} |
break; |
case 'p': |
case 'P': |
case 'x': |
case 'X': |
if (flag_long==0) {intdigit=va_arg(argp,int);} |
531,10 → 531,11 |
//argp=argp+4; |
length=formatted_hex_to_string(intdigit,0,flag_register,buf); |
if (pos + length > maxlen) |
length = maxlen - pos; |
if ((pos+length)<maxlen) |
{ |
memcpy(s,buf,length); |
s=s+length;pos=pos+length; |
} |
break; |
case 'z': |
case 'Z': |
545,10 → 546,11 |
} |
length=formatted_long_to_string(intdigit,0,buf); |
if (pos + length > maxlen) |
length = maxlen - pos; |
if ((pos+length)<maxlen) |
{ |
memcpy(s,buf,length); |
s=s+length;pos=pos+length; |
} |
break; |
default:; |
715,7 → 717,10 |
} |
else |
{ |
if (!(*s++ = *fmt++)) break; |
if (*fmt=='\0') {break;} |
*s=*fmt; |
fmt++; |
s++; |
pos++; |
} |
exit_check:; |
/programs/develop/ktcc/trunk/libc/stdio/fprintf.c |
---|
1,5 → 1,4 |
#include <stdio.h> |
#include <stdlib.h> |
int format_print(char *dest, size_t maxlen, const char *fmt,va_list argp); |
/programs/develop/ktcc/trunk/libc/stdio/fscanf.c |
---|
4,7 → 4,7 |
int c; |
while(1) |
{ |
c=fgetc(file); |
c=getc(file); |
if (c!=' ' && c!='\r' && c!='\n') |
{ |
ungetc(c,file); |
12,7 → 12,6 |
} |
} |
} |
int fscanf(FILE* file,const char* format, ...) |
{ |
int res; |
35,7 → 34,7 |
c=fgetc(file); |
if (c!=*format) |
{ |
ungetc(c,file); |
fungetc(c,file); |
return -1; |
} |
format++; |
/programs/develop/ktcc/trunk/libc/stdio/fseek.c |
---|
1,7 → 1,6 |
#include <stdio.h> |
int fseek(FILE* file,long offset,int origin) |
{ |
fpos_t pos; |
if (origin==SEEK_CUR) |
offset+=file->filepos; |
else if (origin==SEEK_END) |
8,6 → 7,5 |
offset+=file->filesize; |
else if (origin!=SEEK_SET) |
return EOF; |
pos = offset; |
return fsetpos(file, &pos); |
return fsetpos(file,offset); |
} |
/programs/develop/ktcc/trunk/libc/stdio/printf.c |
---|
1,4 → 1,4 |
#include <stdlib.h> |
#include <stdio.h> |
#include <string.h> |
#include <kolibrisys.h> |