Created
May 16, 2010 00:48
-
-
Save ELLIOTTCABLE/402546 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * Pastie 2.0: This time it compiles! | |
| */ | |
| #include <stdio.h> /* can't compile a C app without it I think */ | |
| #include <string.h> /* I just love this library */ | |
| #include <stdlib.h> | |
| #include <unistd.h> | |
| #define ONETHREETHREESEVEN 0 | |
| int main(int argc, char *argv[], char *envp[]) | |
| { | |
| /* this var will contain the whole source file | |
| * obviously I'm using char *buf because using | |
| * char* buf would be dumb, thanks again K&R | |
| */ | |
| char *buf; | |
| /* other boring variables, needed for stuff */ | |
| FILE *fp; /* yes elliott, FP not FD */ | |
| int v; | |
| long fz; | |
| /* needs at least 1 argument! */ | |
| if (argc < 2) { | |
| fprintf(stderr, "Moar args plz, dumbass! usage: %s sourcefile.t\n", | |
| argv[0]); | |
| return 1; | |
| } | |
| /* open file etc.. */ | |
| fp = fopen(argv[1], "r"); | |
| if (!fp) { | |
| fprintf(stderr, "Couldn't open file try an existing file FFS!\n"); | |
| return 0; | |
| } | |
| /* find the end...read it etc.. */ | |
| fseek(fp, 0L, SEEK_END); | |
| fz = ftell(fp); | |
| fseek(fp, 0L, SEEK_SET); | |
| buf = malloc(fz); | |
| fread(buf, 1, fz, fp); | |
| v = strcmp (buf, "print('Hello, World!');"); | |
| if(v != 0) | |
| { | |
| printf("Dude COMPILATION ERROR! YOUR CODE SUCKS, go read tinier's manual"); | |
| } | |
| else | |
| { | |
| execvp("/Developer/usr/bin/i686-apple-darwin10-gcc-4.2.1", argv); | |
| } | |
| return ONETHREETHREESEVEN; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment