From: Matthew Fernandez Date: Sun, 22 Jan 2023 18:52:51 +0000 (-0800) Subject: gv2gxl: abbreviate some open coded 'startswith' X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=561e4643a5307bff1d2c4d0063fdd266f205ff57;p=graphviz gv2gxl: abbreviate some open coded 'startswith' --- diff --git a/cmd/tools/gv2gxl.c b/cmd/tools/gv2gxl.c index 8d1b3e12d..e72dc84fc 100644 --- a/cmd/tools/gv2gxl.c +++ b/cmd/tools/gv2gxl.c @@ -15,6 +15,7 @@ #include #include +#include #include #include #include "convert.h" @@ -42,7 +43,6 @@ #define GXL_LOC "_gxl_locator_" #define GXL_COMP_LEN (SLEN(GXL_COMP)) -#define GXL_LOC_LEN (SLEN(GXL_LOC)) typedef struct { Agrec_t h; @@ -174,12 +174,12 @@ static int xml_url_puts(FILE *f, const char *s) { static int isGxlGrammar(char *name) { - return (strncmp(name, GXL_ATTR, (sizeof(GXL_ATTR) - 1)) == 0); + return startswith(name, GXL_ATTR); } static int isLocatorType(char *name) { - return (strncmp(name, GXL_LOC, GXL_LOC_LEN) == 0); + return startswith(name, GXL_LOC); } static void *idexists(Dt_t * ids, char *id) @@ -398,7 +398,7 @@ writeDict(Agraph_t * g, FILE * gxlFile, char *name, Dict_t * dict, } } else { /* gxl attr; check for special cases like composites */ - if (strncmp(sym->name, GXL_COMP, GXL_COMP_LEN) == 0) { + if (startswith(sym->name, GXL_COMP)) { if (EMPTY(sym->defval)) { if (view == NULL) continue; @@ -613,7 +613,7 @@ writeNondefaultAttr(void *obj, FILE * gxlFile, Dict_t * defdict) } } else { /* gxl attr; check for special cases like composites */ - if (strncmp(sym->name, GXL_COMP, GXL_COMP_LEN) == 0) { + if (startswith(sym->name, GXL_COMP)) { if (data->str[sym->id] != sym->defval) { tabover(gxlFile);