Annotation of gcc/config/msdos/mklibgcc.c, revision 1.1

1.1     ! root        1: #include <stdio.h>
        !             2: #include <string.h>
        !             3: #include <dirent.h>
        !             4: 
        !             5: char *skips[] = {
        !             6:   "__main",
        !             7:   "_ctors",
        !             8:   "_exit",
        !             9:   "_ctor_list",
        !            10:   "_dtor_list",
        !            11:   0
        !            12: };
        !            13: 
        !            14: int
        !            15: do_clean()
        !            16: {
        !            17:   DIR *dir;
        !            18:   struct dirent *de;
        !            19:   remove("mklibnow.bat");
        !            20: 
        !            21:   dir = opendir("lgcctmp");
        !            22:   if (!dir)
        !            23:     return 0;
        !            24:   while ((de=readdir(dir)))
        !            25:   {
        !            26:     char buf[30];
        !            27:     if (de->d_name[0] == '.')
        !            28:       continue;
        !            29:     sprintf(buf, "lgcctmp/%s", de->d_name);
        !            30:     unlink(buf);
        !            31:   }
        !            32:   closedir(dir);
        !            33:   return 0;
        !            34: }
        !            35: 
        !            36: int
        !            37: main(int argc, char **argv)
        !            38: {
        !            39:   char *cc = argv[1];
        !            40:   char *csrc=argv[2];
        !            41:   int i;
        !            42:   FILE *batfile;
        !            43:   FILE *cfile;
        !            44: 
        !            45:   if (argc > 1 && strcmp(argv[1], "-c")==0)
        !            46:     return do_clean();
        !            47: 
        !            48:   mkdir("lgcctmp", 0755);
        !            49: 
        !            50:   batfile = fopen("mklibnow.bat", "a");
        !            51:   if (!batfile)
        !            52:   {
        !            53:     perror("mklibnow.bat");
        !            54:     return 1;
        !            55:   }
        !            56:   fprintf(batfile, "@echo off\n");
        !            57: 
        !            58:   for (i=3; i<argc; i++)
        !            59:   {
        !            60:     char basename[30], *bp;
        !            61:     int s;
        !            62:     for (s=0; skips[s]; s++)
        !            63:       if (strcmp(skips[s], argv[i]) == 0)
        !            64:        break;
        !            65:     if (skips[s])
        !            66:       continue;
        !            67:     strcpy(basename, "lgcctmp/");
        !            68:     if (strncmp(argv[i], "_fix", 4)==0)
        !            69:     {
        !            70:       strcat(basename, "fx");
        !            71:       strcat(basename, argv[i]+4);
        !            72:     }
        !            73:     else if (strncmp(argv[i], "_float", 4)==0)
        !            74:     {
        !            75:       strcat(basename, "flt");
        !            76:       strcat(basename, argv[i]+6);
        !            77:     }
        !            78:     else
        !            79:     {
        !            80:       strcat(basename, argv[i]);
        !            81:     }
        !            82:     bp = basename + strlen(basename);
        !            83:     fprintf(batfile, "%s -c %s.c -o %s.o\n", cc, basename, basename);
        !            84:     strcpy(bp, ".c");
        !            85:     cfile = fopen(basename, "w");
        !            86:     if (cfile)
        !            87:     {
        !            88:       *bp = 0;
        !            89:       fprintf(cfile, "#define L%s\n#include \"%s\"\n", argv[i], csrc);
        !            90:       fclose(cfile);
        !            91:     }
        !            92:     else
        !            93:       perror(basename);
        !            94:   }
        !            95: 
        !            96:   fclose(batfile);
        !            97:   return 0;
        !            98: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.