return pp;
}
+static void output_decorated_pp(FILE *fout,
+ const struct parsed_proto *pp)
+{
+ if (pp->name[0] != '_')
+ fprintf(fout, pp->is_fastcall ? "@" : "_");
+ fprintf(fout, "%s", pp->name);
+ if (pp->is_stdcall && pp->argc > 0)
+ fprintf(fout, "@%d", pp->argc * 4);
+}
+
static int cmpstringp(const void *p1, const void *p2)
{
return strcmp(*(char * const *)p1, *(char * const *)p2);
{
FILE *fout, *fasm, *fhdr, *frlist;
const struct parsed_proto *pp;
+ int no_decorations = 0;
char words[20][256];
char word[256];
char line[256];
char *p2;
if (argc < 4) {
- printf("usage:\n%s <.s> <.asm> <hdrf> [rlist]*\n",
+ // -nd: no symbol decorations
+ printf("usage:\n%s [-nd] <.s> <.asm> <hdrf> [rlist]*\n",
argv[0]);
return 1;
}
+ for (arg = 1; arg < argc; arg++) {
+ if (IS(argv[arg], "-nd"))
+ no_decorations = 1;
+ else
+ break;
+ }
+
arg_out = arg++;
asmfn = argv[arg++];
g_func_sym_pp = NULL;
len = strlen(sym);
- fprintf(fout, "_%s:", sym);
+ fprintf(fout, "%s%s:", no_decorations ? "" : "_", sym);
len += 2;
if (len < 8)
}
else {
pp = check_var(fhdr, sym, p);
- if (p[0] != '_')
- fprintf(fout, (pp && pp->is_fastcall) ? "@" : "_");
- fprintf(fout, "%s", p);
- if (pp && pp->is_stdcall && pp->argc > 0)
- fprintf(fout, "@%d", pp->argc * 4);
+ if (pp == NULL) {
+ fprintf(fout, "%s%s",
+ (no_decorations || p[0] == '_') ? "" : "_", p);
+ }
+ else {
+ if (no_decorations)
+ fprintf(fout, "%s", pp->name);
+ else
+ output_decorated_pp(fout, pp);
+ }
}
}
else {
// dump public syms
for (i = 0; i < pub_sym_cnt; i++)
- fprintf(fout, ".global _%s\n", pub_syms[i]);
+ fprintf(fout, ".global %s%s\n",
+ no_decorations ? "" : "_", pub_syms[i]);
fclose(fout);
fclose(fasm);
char line[256];
char fmt[256];
char word[256];
+ int noname = 0;
+ const char *p2;
char *p;
- int arg = 1;
+ int arg;
int ret, ord;
int l;
- if (argc != 3) {
- printf("usage:\n%s <.h> <.def>\n", argv[0]);
+ for (arg = 1; arg < argc; arg++) {
+ if (IS(argv[arg], "-n"))
+ noname = 1;
+ else
+ break;
+ }
+
+ if (argc != arg + 2) {
+ printf("usage:\n%s [-n] <.h> <.def>\n", argv[0]);
return 1;
}
p = strrchr(hdrfn, '.');
my_assert_not(p, NULL);
- l = p - hdrfn;
- my_assert(l < 256, 1);
- memcpy(basename, hdrfn, l);
+ p2 = strrchr(hdrfn, '/');
+ if (p2++ == NULL)
+ p2 = hdrfn;
+ l = p - p2;
+ my_assert((unsigned int)l < 256, 1);
+ memcpy(basename, p2, l);
basename[l] = 0;
snprintf(fmt, sizeof(fmt), "%s_%%d", basename);
fprintf(fout, "@%-2d", pp->argc_stack * 4);
else
fprintf(fout, " ");
- fprintf(fout, " @%d\n", ord);
+ fprintf(fout, " @%d", ord);
+ if (noname)
+ fprintf(fout, " NONAME");
+ fprintf(fout, "\n");
}
fclose(fhdr);