From 4c2f1f7ccb54097c14b87e215c209e0825e5003d Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Tue, 7 Nov 2006 19:49:58 +0000 Subject: Based on a change from Paul Blankenbaker, make the "show" attribute for a field an empty string if the field is zero-length; for some reason, the existing code doesn't handle that correctly. Also, the NetPDL Visualization Extension: http://www.nbee.org/Docs/NetPDL/NetPDLVisualization.htm seems to imply that "value" has to be present, so display it even if the field is zero-length. svn path=/trunk/; revision=19862 --- print.c | 64 +++++++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 37 insertions(+), 27 deletions(-) (limited to 'print.c') diff --git a/print.c b/print.c index 1d5fb78771..4e9a0328b6 100644 --- a/print.c +++ b/print.c @@ -341,37 +341,47 @@ proto_tree_write_node_pdml(proto_node *node, gpointer data) fputs("\" show=\"\" value=\"", pdata->fh); break; default: - /* XXX - this is a hack until we can just call - * fvalue_to_string_repr() for *all* FT_* types. */ - dfilter_string = proto_construct_dfilter_string(fi, + /* + * Set the 'show' attribute to empty string + * if the field is zero-length. + * + * XXX - why does the code in the else clause + * not do that correctly? + */ + if (fi->length == 0) { + fputs("\" show=\"", pdata->fh); + } else { + /* XXX - this is a hack until we can just call + * fvalue_to_string_repr() for *all* FT_* + * types. */ + dfilter_string = proto_construct_dfilter_string(fi, pdata->edt); - if (dfilter_string != NULL) { - chop_len = strlen(fi->hfinfo->abbrev) + 4; /* for " == " */ - - /* XXX - Remove double-quotes. Again, once we - * can call fvalue_to_string_repr(), we can - * ask it not to produce the version for - * display-filters, and thus, no - * double-quotes. */ - if (dfilter_string[strlen(dfilter_string)-1] == '"') { - dfilter_string[strlen(dfilter_string)-1] = '\0'; - chop_len++; + if (dfilter_string != NULL) { + chop_len = strlen(fi->hfinfo->abbrev) + 4; /* for " == " */ + + /* XXX - Remove double-quotes. Again, + * once we can call fvalue_to_string_repr(), we can + * ask it not to produce the version + * for display-filters, and thus, no + * double-quotes. */ + if (dfilter_string[strlen(dfilter_string)-1] == '"') { + dfilter_string[strlen(dfilter_string)-1] = '\0'; + chop_len++; + } + + fputs("\" show=\"", pdata->fh); + print_escaped_xml(pdata->fh, &dfilter_string[chop_len]); } - - fputs("\" show=\"", pdata->fh); - print_escaped_xml(pdata->fh, &dfilter_string[chop_len]); } - if (fi->length > 0) { - fputs("\" value=\"", pdata->fh); + fputs("\" value=\"", pdata->fh); - if (fi->hfinfo->bitmask!=0) { - fprintf(pdata->fh, "%X", fvalue_get_integer(&fi->value)); - fputs("\" unmaskedvalue=\"", pdata->fh); - write_pdml_field_hex_value(pdata, fi); - } - else { - write_pdml_field_hex_value(pdata, fi); - } + if (fi->hfinfo->bitmask!=0) { + fprintf(pdata->fh, "%X", fvalue_get_integer(&fi->value)); + fputs("\" unmaskedvalue=\"", pdata->fh); + write_pdml_field_hex_value(pdata, fi); + } + else { + write_pdml_field_hex_value(pdata, fi); } } -- cgit v1.2.3