From 7c00cc8045b7684fdc3d6df0e2b24d4e4eb07daf Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Wed, 5 Sep 2018 11:43:26 +0200 Subject: [PATCH] ioc/dbStatic: HW links allow optional '@' For HW link types other than INST_IO, allow trailing '@' to be omitted. --- src/ioc/db/test/dbPutLinkTest.c | 5 +++-- src/ioc/dbStatic/dbStaticLib.c | 10 +++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/ioc/db/test/dbPutLinkTest.c b/src/ioc/db/test/dbPutLinkTest.c index 6f5efed8d..8407ff5bf 100644 --- a/src/ioc/db/test/dbPutLinkTest.c +++ b/src/ioc/db/test/dbPutLinkTest.c @@ -60,7 +60,9 @@ static const struct testParseDataT { TEST_PV_LINK(" world MSICP", "world", pvlOptMSI|pvlOptCP), {"#C14 S145 @testing", {VME_IO, "testing", 0, "CS", {14, 145}}}, + {"#C14 S145", {VME_IO, "", 0, "CS", {14, 145}}}, {"#B11 C12 N13 A14 F15 @cparam", {CAMAC_IO, "cparam", 0, "BCNAF", {11, 12, 13, 14, 15}}}, + {"#B11 C12 N13 A14 F15", {CAMAC_IO, "", 0, "BCNAF", {11, 12, 13, 14, 15}}}, {" #B111 C112 N113 @cparam", {CAMAC_IO, "cparam", 0, "BCN", {111, 112, 113}}}, {" @hello world ", {INST_IO, "hello world", 0, "", /*{}*/}}, {" {\"x\":true} ", {JSON_LINK, "{\"x\":true}", 0, "", /*{}*/}}, @@ -129,7 +131,6 @@ static const char *testParseFailData[] = { "#A0 B @", "#A0 B C @", "#R1 M2 D3 E4 @oops", /* RF_IO has no parm */ - "#C1 S2", /* VME_IO needs parm */ NULL }; @@ -688,7 +689,7 @@ void testTSEL(void) MAIN(dbPutLinkTest) { - testPlan(320); + testPlan(334); testLinkParse(); testLinkFailParse(); testCADBSet(); diff --git a/src/ioc/dbStatic/dbStaticLib.c b/src/ioc/dbStatic/dbStaticLib.c index a43b49e51..c67e849c7 100644 --- a/src/ioc/dbStatic/dbStaticLib.c +++ b/src/ioc/dbStatic/dbStaticLib.c @@ -2353,9 +2353,13 @@ long dbParseLink(const char *str, short ftype, dbLinkInfo *pinfo, unsigned opts) else if (strcmp(pinfo->hwid, "VS")==0) pinfo->ltype = VXI_IO; else goto fail; - if (parm && pinfo->ltype != RF_IO) { - /* move parm string to beginning of buffer */ - memmove(pinfo->target, parm, len + 1); + if (pinfo->ltype != RF_IO) { + if (!parm) { + pinfo->target[0] = '\0'; + } else { + /* move parm string to beginning of buffer */ + memmove(pinfo->target, parm, len + 1); + } } else if (!parm && pinfo->ltype == RF_IO) { /* RF_IO, the string isn't needed at all */ free(pinfo->target);