forked from osmocom/wireshark
parent
5cd8dbd028
commit
943848cb02
|
@ -2649,16 +2649,17 @@ PRIVATE void tplt_xfer(const char *name, FILE *in, FILE *out, int *lineno)
|
||||||
PRIVATE FILE *tplt_open(struct lemon *lemp)
|
PRIVATE FILE *tplt_open(struct lemon *lemp)
|
||||||
{
|
{
|
||||||
static char templatename[] = "lempar.c";
|
static char templatename[] = "lempar.c";
|
||||||
char buf[1000];
|
char* buf;
|
||||||
FILE *in;
|
FILE *in;
|
||||||
char *tpltname = NULL;
|
char *tpltname = NULL;
|
||||||
char *cp;
|
char *cp;
|
||||||
|
|
||||||
if (lemp->templatename) {
|
if (lemp->templatename) {
|
||||||
tpltname = lemp->templatename;
|
tpltname = strdup(lemp->templatename);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
cp = strrchr(lemp->filename,'.');
|
cp = strrchr(lemp->filename,'.');
|
||||||
|
buf = malloc(1000);
|
||||||
if( cp ){
|
if( cp ){
|
||||||
sprintf(buf,"%.*s.lt",(int)(cp - lemp->filename),lemp->filename);
|
sprintf(buf,"%.*s.lt",(int)(cp - lemp->filename),lemp->filename);
|
||||||
}else{
|
}else{
|
||||||
|
@ -2668,21 +2669,25 @@ PRIVATE FILE *tplt_open(struct lemon *lemp)
|
||||||
tpltname = buf;
|
tpltname = buf;
|
||||||
}else{
|
}else{
|
||||||
tpltname = pathsearch(lemp->argv0,templatename,0);
|
tpltname = pathsearch(lemp->argv0,templatename,0);
|
||||||
|
free(buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( tpltname==0 ){
|
if( tpltname==0 ){
|
||||||
fprintf(stderr,"Can't find the parser driver template file \"%s\".\n",
|
fprintf(stderr,"Can't find the parser driver template file \"%s\".\n",
|
||||||
templatename);
|
templatename);
|
||||||
lemp->errorcnt++;
|
lemp->errorcnt++;
|
||||||
|
free(tpltname);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
in = fopen(tpltname,"r");
|
in = fopen(tpltname,"r");
|
||||||
|
free(tpltname);
|
||||||
|
|
||||||
if( in==0 ){
|
if( in==0 ){
|
||||||
fprintf(stderr,"Can't open the template file \"%s\".\n",templatename);
|
fprintf(stderr,"Can't open the template file \"%s\".\n",templatename);
|
||||||
lemp->errorcnt++;
|
lemp->errorcnt++;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (tpltname) free(tpltname);
|
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue