mirror of https://github.com/flysand7/ciabatta.git
Some err handling and ++todo
This commit is contained in:
parent
51360060a5
commit
bf9646609e
|
@ -168,6 +168,9 @@ FILE *fopen(const char *restrict name, const char *restrict mode) {
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
HANDLE handle = CreateFileA(name, access, share, NULL, disp, flags, NULL);
|
HANDLE handle = CreateFileA(name, access, share, NULL, disp, flags, NULL);
|
||||||
|
if(handle == INVALID_HANDLE_VALUE) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
FILE *stream = create_stream(handle, io_mode, bt_mode);
|
FILE *stream = create_stream(handle, io_mode, bt_mode);
|
||||||
void *buffer_data = malloc(BUFSIZ);
|
void *buffer_data = malloc(BUFSIZ);
|
||||||
stream->buffer = (stream_buffer_t) {1, _IOFBF, BUFSIZ, buffer_data};
|
stream->buffer = (stream_buffer_t) {1, _IOFBF, BUFSIZ, buffer_data};
|
||||||
|
@ -406,6 +409,6 @@ int puts(char const *str) {
|
||||||
return putchar('\n');
|
return putchar('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
char *gets(char str) {
|
char *gets(char *str) {
|
||||||
return fgets(str, 0x7fffffff, stdin);
|
return fgets(str, 0x7fffffff, stdin);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,38 +1,17 @@
|
||||||
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
void demo_scanf(const char* fmt, FILE* s)
|
|
||||||
{
|
|
||||||
while (*fmt != '\0') {
|
|
||||||
if (*fmt == '%') {
|
|
||||||
int c;
|
|
||||||
switch (*++fmt) {
|
|
||||||
case 'u':
|
|
||||||
while (isspace(c=getc(s))) {}
|
|
||||||
unsigned int num = 0;
|
|
||||||
while (isdigit(c)) {
|
|
||||||
num = num*10 + c-'0';
|
|
||||||
c = getc(s);
|
|
||||||
}
|
|
||||||
printf("%%u scanned %u\n", num);
|
|
||||||
ungetc(c, s);
|
|
||||||
break;
|
|
||||||
case 'c':
|
|
||||||
c = getc(s);
|
|
||||||
printf("%%c scanned '%c'\n", c);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
++fmt;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
printf("Please enter a string: ");
|
char const *filename = "todo";
|
||||||
fflush(stdout);
|
FILE *f = fopen(filename, "rb");
|
||||||
demo_scanf("%u%c", stdin);
|
if(f == NULL) {
|
||||||
|
printf("File %s doesn't exist\n", filename);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
int c;
|
||||||
|
while((c=fgetc(f)) != EOF) {
|
||||||
|
putchar(c);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
10
todo
10
todo
|
@ -2,6 +2,8 @@
|
||||||
general:
|
general:
|
||||||
* Start writing documentation concerning various implementation defined
|
* Start writing documentation concerning various implementation defined
|
||||||
behaviours of the library.
|
behaviours of the library.
|
||||||
|
* Ok I just realised that I assumed that wchar_t is a 16-bit string in
|
||||||
|
a bunch of places.
|
||||||
|
|
||||||
math.h:
|
math.h:
|
||||||
* exp
|
* exp
|
||||||
|
@ -33,6 +35,14 @@ stdio.h:
|
||||||
with a buffer would increase performance.
|
with a buffer would increase performance.
|
||||||
* Formatted scan
|
* Formatted scan
|
||||||
* %s precision should specify how much characters to *write*
|
* %s precision should specify how much characters to *write*
|
||||||
|
* %Ls this is an actual weird territory. If (wchar_t *) is a unicode string
|
||||||
|
then to determine it's "width" (to figure out field padding) would require
|
||||||
|
to use a Unicode composition algorithm. But the problem is that windows
|
||||||
|
Unicode rendering advances text by 2 units, even if it's 1 graphical
|
||||||
|
character that was composed from 2 unicode characters. The question
|
||||||
|
becomes: do we implement the thing correctly by using a more complex
|
||||||
|
solution, or do we succumb to windows' bullshittery. I guess the answer is
|
||||||
|
obvious. That's why I wrote this todo item :D
|
||||||
|
|
||||||
stdlib.h:
|
stdlib.h:
|
||||||
* Strtod base 16 must be correctly rounded
|
* Strtod base 16 must be correctly rounded
|
||||||
|
|
Loading…
Reference in New Issue