mirror of
https://github.com/9fans/plan9port.git
synced 2025-01-12 11:10:07 +00:00
tpic: clean up
This commit is contained in:
parent
d5b2552b95
commit
b1b88c75fd
5 changed files with 14 additions and 8 deletions
|
@ -586,7 +586,7 @@ char shellbuf[1000], *shellp;
|
|||
void
|
||||
shell_init(void) /* set up to interpret a shell command */
|
||||
{
|
||||
sprintf(shellbuf, "sh -c '");
|
||||
snprintf(shellbuf, sizeof shellbuf, "sh -c '");
|
||||
shellp = shellbuf + strlen(shellbuf);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include <stdarg.h>
|
||||
#include "pic.h"
|
||||
#include "y.tab.h"
|
||||
|
||||
|
@ -62,7 +63,7 @@ main(int argc, char **argv)
|
|||
text = (Text *) grow((char *)text, "text", ntextlist += 1000, sizeof(Text));
|
||||
attr = (Attr *) grow((char *)attr, "attr", nattrlist += 100, sizeof(Attr));
|
||||
|
||||
sprintf(buf, "/%d/", getpid());
|
||||
snprintf(buf, sizeof buf, "/%d/", getpid());
|
||||
pushsrc(String, buf);
|
||||
definition("pid");
|
||||
|
||||
|
@ -275,3 +276,11 @@ reset(void)
|
|||
xmin = ymin = 30000;
|
||||
xmax = ymax = -30000;
|
||||
}
|
||||
|
||||
void
|
||||
tpicsnprintf(char *buf, int n, const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
vsnprintf(buf, n, fmt, args);
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ sprintgen(char *fmt)
|
|||
{
|
||||
char buf[1000];
|
||||
|
||||
sprintf(buf, fmt, exprlist[0], exprlist[1], exprlist[2], exprlist[3], exprlist[4]);
|
||||
snprintf(buf, sizeof buf, fmt, exprlist[0], exprlist[1], exprlist[2], exprlist[3], exprlist[4]);
|
||||
nexpr = 0;
|
||||
free(fmt);
|
||||
return tostring(buf);
|
||||
|
|
|
@ -13,9 +13,7 @@
|
|||
|
||||
extern char errbuf[1000];
|
||||
|
||||
#undef sprintf /* Snow Leopard */
|
||||
|
||||
#define ERROR sprintf(errbuf,
|
||||
#define ERROR tpicsnprintf(errbuf, sizeof errbuf,
|
||||
#define FATAL ), yyerror(errbuf), exit(1)
|
||||
#define WARNING ), yyerror(errbuf)
|
||||
|
||||
|
@ -283,5 +281,6 @@ int unput(int c);
|
|||
int whatpos(obj *p, int corner, double *px, double *py) /* what is the position (no side effect) */;
|
||||
void yyerror(char *s);
|
||||
int yyparse(void);
|
||||
void tpicsnprintf(char*, int, const char*, ...);
|
||||
|
||||
#include "tex.h"
|
||||
|
|
|
@ -14,10 +14,8 @@
|
|||
#include "pic.h"
|
||||
#include "y.tab.h"
|
||||
|
||||
extern double atof();
|
||||
extern char *filename;
|
||||
extern struct symtab symtab[];
|
||||
extern struct symtab*copythru();
|
||||
|
||||
#define CADD cbuf[clen++]=yytext[0]; if(clen>=CBUFLEN-1) {ERROR "string too long" WARNING; BEGIN A;}
|
||||
#define CBUFLEN 500
|
||||
|
|
Loading…
Reference in a new issue