diff options
| author | grischka <grischka> | 2010-01-14 20:55:51 +0100 |
|---|---|---|
| committer | grischka <grischka> | 2010-01-14 20:59:42 +0100 |
| commit | 2341ee5142c184e06964f66696ebf88931953e7d (patch) | |
| tree | 6f858fd311ae47ec4508301e6ebf1df33bd42c8a /win32 | |
| parent | bdb9387a7494d7d5e299cb13bcc94f00215976dd (diff) | |
| download | tinycc-2341ee5142c184e06964f66696ebf88931953e7d.tar.gz tinycc-2341ee5142c184e06964f66696ebf88931953e7d.tar.bz2 | |
tccpe: improve dllimport/export and use for tcc_add_symbol
Diffstat (limited to 'win32')
| -rw-r--r-- | win32/tools/tiny_impdef.c | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/win32/tools/tiny_impdef.c b/win32/tools/tiny_impdef.c index b024a90..f801e0b 100644 --- a/win32/tools/tiny_impdef.c +++ b/win32/tools/tiny_impdef.c @@ -60,6 +60,7 @@ int main(int argc, char **argv) fp = op = NULL; v = 0; ret = 1; + p = NULL; for (i = 1; i < argc; ++i) { const char *a = argv[i]; @@ -90,19 +91,20 @@ usage: if (0 == outfile[0]) { strcpy(outfile, file_basename(infile)); - p = strrchr(outfile, '.'); - if (NULL == p) - p = strchr(outfile, 0); - strcpy(p, ".def"); + q = strrchr(outfile, '.'); + if (NULL == q) + q = strchr(outfile, 0); + strcpy(q, ".def"); } file = infile; + #ifdef _WIN32 - for (pp = ext; *pp; ++pp) - if (SearchPath(NULL, file, *pp, sizeof path, path, NULL)) { - file = path; - break; - } + pp = ext; + do if (SearchPath(NULL, file, *pp, sizeof path, path, NULL)) { + file = path; + break; + } while (*pp++); #endif fp = fopen(file, "rb"); @@ -110,28 +112,26 @@ usage: fprintf(stderr, "tiny_impdef: no such file: %s\n", infile); goto the_end; } - - op = fopen(outfile, "w"); - if (NULL == op) { - fprintf(stderr, "tiny_impdef: could not create output file: %s\n", outfile); - goto the_end; - } - if (v) - printf("--> %s\n", infile); + printf("--> %s\n", file); - fprintf(op, "LIBRARY %s\n\nEXPORTS\n", file_basename(infile)); p = get_export_names(fp); if (NULL == p) { fprintf(stderr, "tiny_impdef: could not get exported function names.\n"); goto the_end; } + op = fopen(outfile, "w"); + if (NULL == op) { + fprintf(stderr, "tiny_impdef: could not create output file: %s\n", outfile); + goto the_end; + } + + fprintf(op, "LIBRARY %s\n\nEXPORTS\n", file_basename(file)); for (q = p, i = 0; *q; ++i) { fprintf(op, "%s\n", q); q += strlen(q) + 1; } - free(p); if (v) { printf("<-- %s\n", outfile); @@ -141,6 +141,8 @@ usage: ret = 0; the_end: + if (p) + free(p); if (fp) fclose(fp); if (op) |
