Merge branch '7.0' of https://github.com/epics-base/epics-base into rtems5
This commit is contained in:
@@ -173,9 +173,8 @@ struct dbr_alDouble {DBRalDouble};
|
||||
#define dbr_alLong_size sizeof(struct dbr_alLong)
|
||||
#define dbr_alDouble_size sizeof(struct dbr_alDouble)
|
||||
|
||||
#ifndef INCerrMdefh
|
||||
#include "errMdef.h"
|
||||
#endif
|
||||
|
||||
#define S_db_notFound (M_dbAccess| 1) /*Process Variable Not Found*/
|
||||
#define S_db_badDbrtype (M_dbAccess| 3) /*Illegal Database Request Type*/
|
||||
#define S_db_noMod (M_dbAccess| 5) /*Attempt to modify noMod field*/
|
||||
|
||||
@@ -169,6 +169,9 @@ static long dbConstLoadScalar(struct link *plink, short dbrType, void *pbuffer)
|
||||
return dbPutConvertJSON(pstr, dbrType, pbuffer, &nReq);
|
||||
}
|
||||
|
||||
if(dbrType>=NELEMENTS(convert))
|
||||
return S_db_badDbrtype;
|
||||
|
||||
return convert[dbrType](pstr, pbuffer, NULL);
|
||||
}
|
||||
|
||||
|
||||
@@ -1185,8 +1185,9 @@ static void dbRecordField(char *name,char *value)
|
||||
char msg[128];
|
||||
|
||||
errSymLookup(status, msg, sizeof(msg));
|
||||
epicsPrintf("Can't set \"%s.%s\" to \"%s\" %s\n",
|
||||
dbGetRecordName(pdbentry), name, value, msg);
|
||||
epicsPrintf("Can't set \"%s.%s\" to \"%s\" %s : %s\n",
|
||||
dbGetRecordName(pdbentry), name, value, pdbentry->message ? pdbentry->message : "", msg);
|
||||
dbPutStringSuggest(pdbentry, value);
|
||||
yyerror(NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -81,8 +81,6 @@ maplinkType pamaplinkType[LINK_NTYPES] = {
|
||||
};
|
||||
|
||||
/*forward references for private routines*/
|
||||
static void dbMsgPrint(DBENTRY *pdbentry, const char *fmt, ...)
|
||||
EPICS_PRINTF_STYLE(2,3);
|
||||
static long dbAddOnePath (DBBASE *pdbbase, const char *path, unsigned length);
|
||||
|
||||
/* internal routines*/
|
||||
@@ -199,7 +197,6 @@ void dbMsgNCpy(DBENTRY *pdbentry, const char *msg, size_t len)
|
||||
pdbentry->message[len] = '\0';
|
||||
}
|
||||
|
||||
static
|
||||
void dbMsgPrint(DBENTRY *pdbentry, const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
@@ -2635,6 +2632,52 @@ long dbPutString(DBENTRY *pdbentry,const char *pstring)
|
||||
return(status);
|
||||
}
|
||||
|
||||
void dbPutStringSuggest(DBENTRY *pdbentry, const char *pstring)
|
||||
{
|
||||
dbFldDes *pflddes = pdbentry->pflddes;
|
||||
|
||||
switch (pflddes->field_type) {
|
||||
case DBF_MENU:
|
||||
case DBF_DEVICE: {
|
||||
int i, nchoices = 0;
|
||||
char** choices = NULL;
|
||||
const char *best = NULL;
|
||||
double maxdist = 0.0; /* don't offer suggestions which have no similarity */
|
||||
|
||||
if(pflddes->field_type==DBF_MENU) {
|
||||
dbMenu *pdbMenu = (dbMenu *)pflddes->ftPvt;
|
||||
if(!pdbMenu)
|
||||
return;
|
||||
|
||||
choices = pdbMenu->papChoiceValue;
|
||||
nchoices = pdbMenu->nChoice;
|
||||
|
||||
} else {
|
||||
dbDeviceMenu *pdbDeviceMenu = dbGetDeviceMenu(pdbentry);
|
||||
if(!pdbDeviceMenu)
|
||||
return;
|
||||
|
||||
choices = pdbDeviceMenu->papChoice;
|
||||
nchoices = pdbDeviceMenu->nChoice;
|
||||
}
|
||||
|
||||
for(i=0; i<nchoices; i++) {
|
||||
double dist = epicsStrSimilarity(pstring, choices[i]);
|
||||
if(dist>maxdist) {
|
||||
best = choices[i];
|
||||
maxdist = dist;
|
||||
}
|
||||
}
|
||||
if(best) {
|
||||
epicsPrintf(" Did you mean \"%s\"?\n", best);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
char * dbVerify(DBENTRY *pdbentry, const char *pstring)
|
||||
{
|
||||
dbFldDes *pflddes = pdbentry->pflddes;
|
||||
|
||||
@@ -36,6 +36,10 @@ char *dbRecordName(DBENTRY *pdbentry);
|
||||
char *dbGetStringNum(DBENTRY *pdbentry);
|
||||
long dbPutStringNum(DBENTRY *pdbentry,const char *pstring);
|
||||
|
||||
void dbMsgPrint(DBENTRY *pdbentry, const char *fmt, ...) EPICS_PRINTF_STYLE(2,3);
|
||||
|
||||
void dbPutStringSuggest(DBENTRY *pdbentry, const char *pstring);
|
||||
|
||||
struct jlink;
|
||||
|
||||
typedef struct dbLinkInfo {
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "dbCommonPvt.h"
|
||||
#include "dbStaticLib.h"
|
||||
#include "dbStaticPvt.h"
|
||||
#include "dbAccess.h"
|
||||
#include "devSup.h"
|
||||
#include "special.h"
|
||||
|
||||
@@ -479,8 +480,17 @@ long dbPutStringNum(DBENTRY *pdbentry, const char *pstring)
|
||||
epicsEnum16 value;
|
||||
long status = epicsParseUInt16(pstring, &value, 0, NULL);
|
||||
|
||||
if (status)
|
||||
if (status) {
|
||||
status = S_db_badChoice;
|
||||
if(pflddes->field_type==DBF_MENU) {
|
||||
dbMenu *pdbMenu = (dbMenu *)pflddes->ftPvt;
|
||||
dbMsgPrint(pdbentry, "using menu %s", pdbMenu->name);
|
||||
|
||||
} else if(pflddes->field_type==DBF_DEVICE) {
|
||||
dbMsgPrint(pdbentry, "no such device support for '%s' record type", pdbentry->precordType->name);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
index = dbGetNMenuChoices(pdbentry);
|
||||
if (value > index && index > 0 && value < USHRT_MAX)
|
||||
|
||||
Reference in New Issue
Block a user