270 |
|
|
271 |
static void do_latex(EditState *e, const char *cmd) |
static void do_latex(EditState *e, const char *cmd) |
272 |
{ |
{ |
273 |
|
char bname[MAX_FILENAME_SIZE]; |
274 |
char buf[1024]; |
char buf[1024]; |
275 |
int i; |
int i, len; |
|
char *p, *f; |
|
|
char *bname; |
|
276 |
|
|
277 |
/* strip extension from filename, find the last dot after the last |
/* strip extension from filename */ |
278 |
* slash (ie, the last dot in the filename) |
pstrcpy(bname, sizeof(bname), e->b->filename); |
279 |
*/ |
len = extension(bname) - bname; |
280 |
/* CG: should use extension(), also should ignore leading dots */ |
bname[len] = '\0'; |
|
f = strrchr(e->b->filename, '/'); |
|
|
if (f) |
|
|
f++; |
|
|
else |
|
|
f = e->b->filename; |
|
|
p = strrchr(f, '.'); |
|
|
if (p) { |
|
|
int len = p - e->b->filename; |
|
|
bname = (char *)malloc(len + 1); |
|
|
pstrncpy(bname, len + 1, e->b->filename, len); |
|
|
} else { |
|
|
bname = strdup(e->b->filename); |
|
|
} |
|
281 |
|
|
282 |
if (!cmd || cmd[0] == '\0') |
if (!cmd || cmd[0] == '\0') |
283 |
strcpy(buf, "LaTeX"); |
cmd = "LaTeX"; |
|
else |
|
|
strcpy(buf, cmd); |
|
284 |
|
|
285 |
/* check what command to run */ |
/* check what command to run */ |
286 |
for (i = 0; latex_funcs[i].name; i++) { |
for (i = 0; latex_funcs[i].name; i++) { |
287 |
if (strcasecmp(buf, latex_funcs[i].name) == 0) { |
if (strcasecmp(cmd, latex_funcs[i].name) == 0) { |
288 |
/* pass the EditState through to latex_cmd_run() */ |
/* pass the EditState through to latex_cmd_run() */ |
289 |
latex_funcs[i].es = e; |
latex_funcs[i].es = e; |
290 |
/* construct the command line to run */ |
/* construct the command line to run */ |
299 |
} else { |
} else { |
300 |
latex_cmd_run((void *)&latex_funcs[i], buf); |
latex_cmd_run((void *)&latex_funcs[i], buf); |
301 |
} |
} |
302 |
break; |
return; |
303 |
} |
} |
304 |
} |
} |
305 |
if (latex_funcs[i].name == 0) |
put_status(e, "%s: No match", buf); |
|
put_status(e, "%s: No match", buf); |
|
|
free(bname); |
|
306 |
} |
} |
307 |
|
|
308 |
/* specific LaTeX commands */ |
/* specific LaTeX commands */ |