Files
@ ef37386d0c6f
Branch filter:
Location: CSY/reowolf/examples/utility.c - annotation
ef37386d0c6f
816 B
text/x-csrc
Put expression types of procedures in type table
Before we annotated the AST. But that is silly in hindsight:
certain operations have a completely different meaning when applied
in a polymorphic context (i.e. the field index determined by a
select expression).
Before we annotated the AST. But that is silly in hindsight:
certain operations have a completely different meaning when applied
in a polymorphic context (i.e. the field index determined by a
select expression).
33da6b69e9a2 33da6b69e9a2 33da6b69e9a2 7b9df91324ad 7b9df91324ad a3c92705eeee a3c92705eeee a3c92705eeee a3c92705eeee 8df425c3752e a3c92705eeee a3c92705eeee a3c92705eeee a3c92705eeee a3c92705eeee a3c92705eeee a3c92705eeee a3c92705eeee a3c92705eeee 33da6b69e9a2 33da6b69e9a2 33da6b69e9a2 1f2d007ac1cc 33da6b69e9a2 33da6b69e9a2 33da6b69e9a2 33da6b69e9a2 33da6b69e9a2 33da6b69e9a2 33da6b69e9a2 33da6b69e9a2 33da6b69e9a2 33da6b69e9a2 33da6b69e9a2 33da6b69e9a2 a3c92705eeee | #include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <unistd.h>
#include "../reowolf.h"
size_t get_user_msg(char * buf, size_t cap) {
memset(buf, 0, cap);
printf("Insert a msg of max len %zu: ", cap);
fgets(buf, cap, stdin);
for(size_t len = 0; len<cap; len++)
if(buf[len]==0 || buf[len]=='\n')
return len;
return cap;
}
void rw_err_peek(Connector * c) {
printf("Error str `%s`\n", reowolf_error_peek(NULL));
}
// allocates a buffer!
char * buffer_pdl(char * filename) {
FILE *f = fopen(filename, "rb");
if (f == NULL) {
printf("Opening pdl file returned errno %d!\n", errno);
exit(1);
}
fseek(f, 0, SEEK_END);
long fsize = ftell(f);
fseek(f, 0, SEEK_SET);
char *pdl = malloc(fsize + 1);
fread(pdl, 1, fsize, f);
fclose(f);
pdl[fsize] = 0;
return pdl;
}
|