14 void get_output_name(char *buf, size_t buflen, const char *inputname,
17 size_t last_dot = 0xffffffff;
19 for(const char *c = inputname; *c != 0; ++c) {
24 if(last_dot == 0xffffffff)
27 if(last_dot >= buflen)
28 panic("filename too long");
29 memcpy(buf, inputname, last_dot);
31 size_t extlen = strlen(newext) + 1;
32 if(extlen + last_dot >= buflen)
33 panic("filename too long");
34 memcpy(buf+last_dot, newext, extlen);
39 void compile(const char *fname)
43 FILE *in = fopen(fname, "r");
45 fprintf(stderr, "Couldn't open '%s': %s\n", fname, strerror(errno));
49 lexer_open_stream(in, fname);
52 lexer_next_token(&token);
53 print_token(stdout, &token);
55 } while(token.type != T_EOF);
60 int main(int argc, char **argv)
67 for(int i = 1; i < argc; ++i) {