From: Jim Evins Date: Wed, 30 Apr 2003 03:01:33 +0000 (+0000) Subject: Made all comparisons case sensitive. X-Git-Tag: glabels-2_3_0~634 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=9f6e057631e99baa8c5cd1eff1b661c54f578f24;p=glabels Made all comparisons case sensitive. git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@255 f5e0f49d-192f-0410-a22d-a8d8700d0965 --- diff --git a/glabels2/src/xml-label-04.c b/glabels2/src/xml-label-04.c index edf9ceef..a1e05a59 100644 --- a/glabels2/src/xml-label-04.c +++ b/glabels2/src/xml-label-04.c @@ -71,7 +71,7 @@ glLabel *gl_xml_label_04_parse (xmlNodePtr root, *status = XML_LABEL_OK; - if (g_strcasecmp (root->name, "Label") != 0) { + if (!xmlStrEqual (root->name, "Label")) { g_warning (_("Bad root node = \"%s\""), root->name); *status = XML_LABEL_ERROR_OPEN_PARSE; return NULL; @@ -87,37 +87,37 @@ glLabel *gl_xml_label_04_parse (xmlNodePtr root, gl_debug (DEBUG_XML, "node name = \"%s\"", node->name); if (!xmlNodeIsText (node)) { - if (g_strcasecmp (node->name, "Media_Type") == 0) { + if (xmlStrEqual (node->name, "Media_Type")) { if (!xml04_parse_media_description (node, label)) { *status = XML_LABEL_UNKNOWN_MEDIA; } - } else if (g_strcasecmp (node->name, "Text") == 0) { + } else if (xmlStrEqual (node->name, "Text")) { object = gl_label_text_new (label); xml04_parse_object (node, GL_LABEL_OBJECT(object)); xml04_parse_text_props (node, GL_LABEL_TEXT(object)); - } else if (g_strcasecmp (node->name, "Box") == 0) { + } else if (xmlStrEqual (node->name, "Box")) { object = gl_label_box_new (label); xml04_parse_object (node, GL_LABEL_OBJECT(object)); xml04_parse_box_props (node, GL_LABEL_BOX(object)); - } else if (g_strcasecmp (node->name, "Line") == 0) { + } else if (xmlStrEqual (node->name, "Line")) { object = gl_label_line_new (label); xml04_parse_object (node, GL_LABEL_OBJECT(object)); xml04_parse_line_props (node, GL_LABEL_LINE(object)); - } else if (g_strcasecmp (node->name, "Ellipse") == 0) { + } else if (xmlStrEqual (node->name, "Ellipse")) { object = gl_label_ellipse_new (label); xml04_parse_object (node, GL_LABEL_OBJECT(object)); xml04_parse_ellipse_props (node, GL_LABEL_ELLIPSE(object)); - } else if (g_strcasecmp (node->name, "Image") == 0) { + } else if (xmlStrEqual (node->name, "Image")) { object = gl_label_image_new (label); xml04_parse_object (node, GL_LABEL_OBJECT(object)); xml04_parse_image_props (node, GL_LABEL_IMAGE(object)); - } else if (g_strcasecmp (node->name, "Barcode") == 0) { + } else if (xmlStrEqual (node->name, "Barcode")) { object = gl_label_barcode_new (label); xml04_parse_object (node, GL_LABEL_OBJECT(object)); xml04_parse_barcode_props (node, GL_LABEL_BARCODE(object)); - } else if (g_strcasecmp (node->name, "Merge_Properties") == 0) { + } else if (xmlStrEqual (node->name, "Merge_Properties")) { xml04_parse_merge_properties (node, label); } else { g_warning (_("bad node = \"%s\""), node->name); @@ -230,13 +230,13 @@ xml04_parse_text_props (xmlNodePtr object_node, for (line_node = object_node->xmlChildrenNode; line_node != NULL; line_node = line_node->next) { - if (g_strcasecmp (line_node->name, "Line") == 0) { + if (xmlStrEqual (line_node->name, "Line")) { nodes = NULL; for (text_node = line_node->xmlChildrenNode; text_node != NULL; text_node = text_node->next) { - if (g_strcasecmp (text_node->name, "Field") == + if (xmlStrEqual (text_node->name, "Field") == 0) { node_text = g_new0 (glTextNode, 1); node_text->field_flag = TRUE; @@ -433,7 +433,7 @@ xml04_parse_barcode_props (xmlNodePtr node, child = node->xmlChildrenNode; text_node = g_new0 (glTextNode, 1); - if (g_strcasecmp (child->name, "Field") == 0) { + if (xmlStrEqual (child->name, "Field")) { text_node->field_flag = TRUE; text_node->data = xmlGetProp (child, "name"); } else if (xmlNodeIsText (child)) { diff --git a/glabels2/src/xml-label.c b/glabels2/src/xml-label.c index 15de4064..de039044 100644 --- a/glabels2/src/xml-label.c +++ b/glabels2/src/xml-label.c @@ -177,8 +177,10 @@ gl_xml_label_open (const gchar *filename, xmlFreeDoc (doc); - gl_label_set_filename (label, filename); - gl_label_clear_modified (label); + if (label) { + gl_label_set_filename (label, filename); + gl_label_clear_modified (label); + } gl_debug (DEBUG_XML, "END"); @@ -206,10 +208,12 @@ gl_xml_label_open_buffer (const gchar *buffer, label = xml_doc_to_label (doc, status); - gl_label_clear_modified (label); - xmlFreeDoc (doc); + if (label) { + gl_label_clear_modified (label); + } + gl_debug (DEBUG_XML, "END"); return label; @@ -284,7 +288,7 @@ xml_parse_label (xmlNodePtr root, *status = XML_LABEL_OK; - if (g_strcasecmp (root->name, "Document") != 0) { + if (!xmlStrEqual (root->name, "Document")) { g_warning (_("Bad root node = \"%s\""), root->name); *status = XML_LABEL_ERROR_OPEN_PARSE; return NULL; @@ -294,7 +298,7 @@ xml_parse_label (xmlNodePtr root, /* Pass 1, extract data nodes to pre-load cache. */ for (node = root->xmlChildrenNode; node != NULL; node = node->next) { - if (g_strcasecmp (node->name, "Data") == 0) { + if (xmlStrEqual (node->name, "Data")) { xml_parse_data (node, label); } } @@ -302,7 +306,7 @@ xml_parse_label (xmlNodePtr root, /* Pass 2, now extract everything else. */ for (node = root->xmlChildrenNode; node != NULL; node = node->next) { - if (g_strcasecmp (node->name, "Sheet") == 0) { + if (xmlStrEqual (node->name, "Sheet")) { template = gl_xml_template_parse_sheet (node); if (!template) { *status = XML_LABEL_UNKNOWN_MEDIA; @@ -310,11 +314,11 @@ xml_parse_label (xmlNodePtr root, } gl_label_set_template (label, template); gl_template_free (&template); - } else if (g_strcasecmp (node->name, "Objects") == 0) { + } else if (xmlStrEqual (node->name, "Objects")) { xml_parse_objects (node, label); - } else if (g_strcasecmp (node->name, "Merge_Fields") == 0) { + } else if (xmlStrEqual (node->name, "Merge_Fields")) { xml_parse_merge_fields (node, label); - } else if (g_strcasecmp (node->name, "Data") == 0) { + } else if (xmlStrEqual (node->name, "Data")) { /* Handled in pass 1. */ } else { if (!xmlNodeIsText (node)) { @@ -346,7 +350,7 @@ xml_parse_objects (xmlNodePtr objects_node, for (node = objects_node->xmlChildrenNode; node != NULL; node = node->next) { - if (g_strcasecmp (node->name, "Object") == 0) { + if (xmlStrEqual (node->name, "Object")) { xml_parse_object (node, label); } else { if (!xmlNodeIsText (node)) { @@ -374,17 +378,17 @@ xml_parse_object (xmlNodePtr object_node, string = xmlGetProp (object_node, "type"); - if ( g_strcasecmp (string, "text") == 0 ) { + if ( xmlStrEqual (string, "Text") ) { object = xml_parse_text_props (object_node, label); - } else if ( g_strcasecmp (string, "box") == 0 ) { + } else if ( xmlStrEqual (string, "Box") ) { object = xml_parse_box_props (object_node, label); - } else if ( g_strcasecmp (string, "line") == 0 ) { + } else if ( xmlStrEqual (string, "Line") ) { object = xml_parse_line_props (object_node, label); - } else if ( g_strcasecmp (string, "ellipse") == 0 ) { + } else if ( xmlStrEqual (string, "Ellipse") ) { object = xml_parse_ellipse_props (object_node, label); - } else if ( g_strcasecmp (string, "image") == 0 ) { + } else if ( xmlStrEqual (string, "Image") ) { object = xml_parse_image_props (object_node, label); - } else if ( g_strcasecmp (string, "barcode") == 0 ) { + } else if ( xmlStrEqual (string, "Barcode") ) { object = xml_parse_barcode_props (object_node, label); } else { g_warning ("Unknown label object type \"%s\"", string); @@ -462,18 +466,18 @@ xml_parse_text_props (xmlNodePtr object_node, line_node != NULL; line_node = line_node->next) { - if (g_strcasecmp (line_node->name, "Line") == 0) { + if (xmlStrEqual (line_node->name, "Line")) { nodes = NULL; for (text_node = line_node->xmlChildrenNode; text_node != NULL; text_node = text_node->next) { - if (g_strcasecmp (text_node->name, "Field") == 0) { + if (xmlStrEqual (text_node->name, "Field")) { node_text = g_new0 (glTextNode, 1); node_text->field_flag = TRUE; node_text->data = xmlGetProp (text_node, "name"); nodes = g_list_append (nodes, node_text); - } else if (g_strcasecmp (text_node->name, "Literal") == 0) { + } else if (xmlStrEqual (text_node->name, "Literal")) { node_text = g_new0 (glTextNode, 1); node_text->field_flag = FALSE; node_text->data = @@ -631,10 +635,10 @@ xml_parse_image_props (xmlNodePtr node, filename = g_new0 (glTextNode, 1); for (child = node->xmlChildrenNode; child != NULL; child = child->next) { - if (g_strcasecmp (child->name, "Field") == 0) { + if (xmlStrEqual (child->name, "Field")) { filename->field_flag = TRUE; filename->data = xmlGetProp (child, "name"); - } else if (g_strcasecmp (child->name, "File") == 0) { + } else if (xmlStrEqual (child->name, "File")) { filename->field_flag = FALSE; filename->data = xmlGetProp (child, "src"); } else if (!xmlNodeIsText (child)) { @@ -687,10 +691,10 @@ xml_parse_barcode_props (xmlNodePtr node, text_node = g_new0 (glTextNode, 1); for (child = node->xmlChildrenNode; child != NULL; child = child->next) { - if (g_strcasecmp (child->name, "Field") == 0) { + if (xmlStrEqual (child->name, "Field")) { text_node->field_flag = TRUE; text_node->data = xmlGetProp (child, "name"); - } else if (g_strcasecmp (child->name, "Literal") == 0) { + } else if (xmlStrEqual (child->name, "Literal")) { text_node->field_flag = FALSE; text_node->data = xmlNodeGetContent (child); } else if (!xmlNodeIsText (child)) { @@ -752,7 +756,7 @@ xml_parse_data (xmlNodePtr node, for (child = node->xmlChildrenNode; child != NULL; child = child->next) { - if (g_strcasecmp (child->name, "Pixdata") == 0) { + if (xmlStrEqual (child->name, "Pixdata")) { xml_parse_pixdata (child, label); } else { if (!xmlNodeIsText (child)) { diff --git a/glabels2/src/xml-template.c b/glabels2/src/xml-template.c index 5fc3b22e..5bacd5e9 100644 --- a/glabels2/src/xml-template.c +++ b/glabels2/src/xml-template.c @@ -95,7 +95,7 @@ gl_xml_template_read_templates_from_file (GList *templates, xmlFreeDoc (doc); return templates; } - if (g_strcasecmp (root->name, "glabels-templates") != 0) { + if (!xmlStrEqual (root->name, "GLabels-templates")) { g_warning ("\"%s\" is not a glabels template file (wrong root node)", xml_filename); xmlFreeDoc (doc); @@ -104,12 +104,12 @@ gl_xml_template_read_templates_from_file (GList *templates, for (node = root->xmlChildrenNode; node != NULL; node = node->next) { - if (g_strcasecmp (node->name, "Sheet") == 0) { + if (xmlStrEqual (node->name, "Sheet")) { template = gl_xml_template_parse_sheet (node); templates = g_list_append (templates, template); } else { if ( !xmlNodeIsText(node) ) { - if (g_strcasecmp (node->name,"comment") != 0) { + if (!xmlStrEqual (node->name,"comment")) { g_warning ("bad node = \"%s\"",node->name); } } @@ -141,10 +141,10 @@ gl_xml_template_parse_sheet (xmlNodePtr sheet_node) gl_debug (DEBUG_TEMPLATE, "Sheet = %s", template->name->data); template->page_size = xmlGetProp (sheet_node, "size"); - if ( strcmp (template->page_size,"US-Letter") == 0 ) { + if ( xmlStrEqual (template->page_size,"US-Letter")) { template->page_size = "US Letter"; } - if (g_strcasecmp (template->page_size, "Other") == 0) { + if (xmlStrEqual (template->page_size, "Other")) { template->page_width = gl_xml_get_prop_double (sheet_node, "width", 0); template->page_height = gl_xml_get_prop_double (sheet_node, "height", 0); @@ -163,12 +163,12 @@ gl_xml_template_parse_sheet (xmlNodePtr sheet_node) for (node = sheet_node->xmlChildrenNode; node != NULL; node = node->next) { - if (g_strcasecmp (node->name, "Label") == 0) { + if (xmlStrEqual (node->name, "Label")) { xml_parse_label (node, template); - } else if (g_strcasecmp (node->name, "Alias") == 0) { + } else if (xmlStrEqual (node->name, "Alias")) { xml_parse_alias (node, template); } else { - if (g_strcasecmp (node->name, "text") != 0) { + if (!xmlNodeIsText (node)) { g_warning ("bad node = \"%s\"", node->name); } } @@ -192,11 +192,11 @@ xml_parse_label (xmlNodePtr label_node, gl_debug (DEBUG_TEMPLATE, "START"); style = xmlGetProp (label_node, "style"); - if (g_strcasecmp (style, "rectangle") == 0) { + if (xmlStrEqual (style, "rectangle")) { template->label.style = GL_TEMPLATE_STYLE_RECT; - } else if (g_strcasecmp (style, "round") == 0) { + } else if (xmlStrEqual (style, "round")) { template->label.style = GL_TEMPLATE_STYLE_ROUND; - } else if (g_strcasecmp (style, "cd") == 0) { + } else if (xmlStrEqual (style, "cd")) { template->label.style = GL_TEMPLATE_STYLE_CD; } else { template->label.style = GL_TEMPLATE_STYLE_RECT; @@ -230,11 +230,11 @@ xml_parse_label (xmlNodePtr label_node, for (node = label_node->xmlChildrenNode; node != NULL; node = node->next) { - if (g_strcasecmp (node->name, "Layout") == 0) { + if (xmlStrEqual (node->name, "Layout")) { xml_parse_layout (node, template); - } else if (g_strcasecmp (node->name, "Markup") == 0) { + } else if (xmlStrEqual (node->name, "Markup")) { xml_parse_markup (node, template); - } else if (g_strcasecmp (node->name, "text") != 0) { + } else if (!xmlNodeIsText (node)) { g_warning ("bad node = \"%s\"", node->name); } } @@ -266,7 +266,7 @@ xml_parse_layout (xmlNodePtr layout_node, for (node = layout_node->xmlChildrenNode; node != NULL; node = node->next) { - if (g_strcasecmp (node->name, "text") != 0) { + if (!xmlNodeIsText (node)) { g_warning ("bad node = \"%s\"", node->name); } } @@ -293,7 +293,7 @@ xml_parse_markup (xmlNodePtr markup_node, gl_debug (DEBUG_TEMPLATE, "START"); type = xmlGetProp (markup_node, "type"); - if (g_strcasecmp (type, "margin") == 0) { + if (xmlStrEqual (type, "margin")) { size = gl_xml_get_prop_double (markup_node, "size", 0); @@ -301,7 +301,7 @@ xml_parse_markup (xmlNodePtr markup_node, g_list_append (template->label.any.markups, gl_template_markup_margin_new (size)); - } else if (g_strcasecmp (type, "line") == 0) { + } else if (xmlStrEqual (type, "line")) { x1 = gl_xml_get_prop_double (markup_node, "x1", 0); y1 = gl_xml_get_prop_double (markup_node, "y1", 0); @@ -316,7 +316,7 @@ xml_parse_markup (xmlNodePtr markup_node, for (node = markup_node->xmlChildrenNode; node != NULL; node = node->next) { - if (g_strcasecmp (node->name, "text") != 0) { + if (!xmlNodeIsText (node)) { g_warning ("bad node = \"%s\"", node->name); } } @@ -357,7 +357,7 @@ gl_xml_template_add_sheet (const glTemplate *template, xmlSetProp (node, "name", template->name->data); xmlSetProp (node, "size", template->page_size); - if (g_strcasecmp (template->page_size, "Other") == 0) { + if (xmlStrEqual (template->page_size, "Other")) { gl_xml_set_prop_double (node, "width", template->page_width); gl_xml_set_prop_double (node, "height", template->page_height); diff --git a/glabels2/src/xml.c b/glabels2/src/xml.c index d90091b8..a42e6024 100644 --- a/glabels2/src/xml.c +++ b/glabels2/src/xml.c @@ -74,7 +74,8 @@ gl_xml_get_prop_boolean (xmlNodePtr node, string = xmlGetProp (node, property); if ( string != NULL ) { - val = !(g_strcasecmp (string, "false") == 0); + val = !((xmlStrcasecmp (string, "false") == 0) || + xmlStrEqual (string, "0"));; g_free (string); return val; }