Prefix escaped identifiers in VCD and LXT(2) output with a back slash.
GTKWave needs to have escaped identifiers properly escaped (preceded with a back slash) in its VCD input. Without this the name may not display correctly. Even though it is not required, to keep things consistent LXT and LXT2 formats also prefix escaped identifiers with a back slash.
This commit is contained in:
parent
870aa417ba
commit
5d80c4856d
|
|
@ -108,6 +108,7 @@ static char *create_full_name(const char *name)
|
|||
{
|
||||
char *n, *n2;
|
||||
int len = 0;
|
||||
int is_esc_id = is_escaped_id(name);
|
||||
struct lxt_scope *t = lxt_scope_head;
|
||||
|
||||
/* Figure out how long the combined string will be. */
|
||||
|
|
@ -117,6 +118,7 @@ static char *create_full_name(const char *name)
|
|||
}
|
||||
|
||||
len += strlen(name) + 1;
|
||||
if (is_esc_id) len += 1;
|
||||
|
||||
/* Allocate a string buffer. */
|
||||
n = n2 = malloc(len);
|
||||
|
|
@ -130,6 +132,10 @@ static char *create_full_name(const char *name)
|
|||
t=t->next;
|
||||
}
|
||||
|
||||
if (is_esc_id) {
|
||||
*n2 = '\\';
|
||||
n2++;
|
||||
}
|
||||
strcpy(n2, name);
|
||||
n2 += strlen(n2);
|
||||
assert( (n2 - n + 1) == len );
|
||||
|
|
|
|||
|
|
@ -109,6 +109,7 @@ static char *create_full_name(const char *name)
|
|||
{
|
||||
char *n, *n2;
|
||||
int len = 0;
|
||||
int is_esc_id = is_escaped_id(name);
|
||||
struct lxt_scope *t = lxt_scope_head;
|
||||
|
||||
/* Figure out how long the combined string will be. */
|
||||
|
|
@ -118,6 +119,7 @@ static char *create_full_name(const char *name)
|
|||
}
|
||||
|
||||
len += strlen(name) + 1;
|
||||
if (is_esc_id) len += 1;
|
||||
|
||||
/* Allocate a string buffer. */
|
||||
n = n2 = malloc(len);
|
||||
|
|
@ -131,6 +133,10 @@ static char *create_full_name(const char *name)
|
|||
t=t->next;
|
||||
}
|
||||
|
||||
if (is_esc_id) {
|
||||
*n2 = '\\';
|
||||
n2++;
|
||||
}
|
||||
strcpy(n2, name);
|
||||
n2 += strlen(n2);
|
||||
assert( (n2 - n + 1) == len );
|
||||
|
|
|
|||
|
|
@ -549,6 +549,7 @@ static void scan_item(unsigned depth, vpiHandle item, int skip)
|
|||
|
||||
const char* type;
|
||||
const char* name;
|
||||
const char* prefix;
|
||||
const char* ident;
|
||||
int nexus_id;
|
||||
|
||||
|
|
@ -587,6 +588,7 @@ static void scan_item(unsigned depth, vpiHandle item, int skip)
|
|||
break;
|
||||
|
||||
name = vpi_get_str(vpiName, item);
|
||||
prefix = is_escaped_id(name) ? "\\" : "";
|
||||
|
||||
nexus_id = vpi_get(_vpiNexusId, item);
|
||||
|
||||
|
|
@ -625,9 +627,9 @@ static void scan_item(unsigned depth, vpiHandle item, int skip)
|
|||
info->cb = vpi_register_cb(&cb);
|
||||
}
|
||||
|
||||
fprintf(dump_file, "$var %s %u %s %s",
|
||||
fprintf(dump_file, "$var %s %u %s %s%s",
|
||||
type, vpi_get(vpiSize, item), ident,
|
||||
name);
|
||||
prefix, name);
|
||||
/* FIXME
|
||||
if (vpi_get(vpiVector, item)
|
||||
*/
|
||||
|
|
@ -646,10 +648,11 @@ static void scan_item(unsigned depth, vpiHandle item, int skip)
|
|||
|
||||
/* Declare the variable in the VCD file. */
|
||||
name = vpi_get_str(vpiName, item);
|
||||
prefix = is_escaped_id(name) ? "\\" : "";
|
||||
ident = strdup(vcdid);
|
||||
gen_new_vcd_id();
|
||||
fprintf(dump_file, "$var real 1 %s %s $end\n",
|
||||
ident, name);
|
||||
fprintf(dump_file, "$var real 1 %s %s%s $end\n",
|
||||
ident, prefix, name);
|
||||
|
||||
/* Add a callback for the variable. */
|
||||
info = malloc(sizeof(*info));
|
||||
|
|
|
|||
|
|
@ -29,8 +29,29 @@
|
|||
#ifdef HAVE_MALLOC_H
|
||||
# include <malloc.h>
|
||||
#endif
|
||||
# include <ctype.h>
|
||||
# include "stringheap.h"
|
||||
|
||||
int is_escaped_id(const char *name)
|
||||
{
|
||||
int lp;
|
||||
|
||||
assert(name);
|
||||
/* The first digit must be alpha or '_' to be a normal id. */
|
||||
if (isalpha(name[0]) || name[0] == '_') {
|
||||
for (lp=1; name[lp] != '\0'; lp++) {
|
||||
/* If this digit is not alpha-numeric or '_' we have
|
||||
* an escaped identifier. */
|
||||
if (!(isalnum(name[lp]) || name[lp] == '_')) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
/* We looked at all the digits, so this is a normal id. */
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
struct stringheap_s name_heap = {0, 0};
|
||||
|
||||
struct vcd_names_s {
|
||||
|
|
@ -167,26 +188,3 @@ void set_nexus_ident(int nex, const char *id)
|
|||
vcd_ids[ihash(nex)] = bucket;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* $Log: vcd_priv.c,v $
|
||||
* Revision 1.6 2004/10/04 01:10:58 steve
|
||||
* Clean up spurious trailing white space.
|
||||
*
|
||||
* Revision 1.5 2004/01/21 01:22:53 steve
|
||||
* Give the vip directory its own configure and vpi_config.h
|
||||
*
|
||||
* Revision 1.4 2003/11/10 20:18:02 steve
|
||||
* Missing config.h.
|
||||
*
|
||||
* Revision 1.3 2003/04/28 01:03:11 steve
|
||||
* Fix stringheap list management failure.
|
||||
*
|
||||
* Revision 1.2 2003/02/13 18:13:28 steve
|
||||
* Make lxt use stringheap to perm-allocate strings.
|
||||
*
|
||||
* Revision 1.1 2003/02/11 05:21:33 steve
|
||||
* Support dump of vpiRealVar objects.
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@
|
|||
#ident "$Id: vcd_priv.h,v 1.2 2003/02/13 18:13:28 steve Exp $"
|
||||
#endif
|
||||
|
||||
extern int is_escaped_id(const char *name);
|
||||
|
||||
struct vcd_names_s;
|
||||
extern struct stringheap_s name_heap;
|
||||
|
||||
|
|
@ -42,13 +44,4 @@ extern void vcd_names_sort(struct vcd_names_list_s*tab);
|
|||
extern const char*find_nexus_ident(int nex);
|
||||
extern void set_nexus_ident(int nex, const char *id);
|
||||
|
||||
/*
|
||||
* $Log: vcd_priv.h,v $
|
||||
* Revision 1.2 2003/02/13 18:13:28 steve
|
||||
* Make lxt use stringheap to perm-allocate strings.
|
||||
*
|
||||
* Revision 1.1 2003/02/11 05:21:33 steve
|
||||
* Support dump of vpiRealVar objects.
|
||||
*
|
||||
*/
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in New Issue