Return object index from EN_addnode and EN_addlink (issue #432)
Adds an output argument to EN_addnode and EN_addlink that returns the index of the newly added object. Also refactors the validity check on object ID names.
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
Authors: see AUTHORS
|
||||
Copyright: see AUTHORS
|
||||
License: see LICENSE
|
||||
Last Updated: 04/03/2019
|
||||
Last Updated: 04/18/2019
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
@@ -988,6 +988,18 @@ int setcomment(Network *network, int object, int index, const char *newcomment)
|
||||
}
|
||||
}
|
||||
|
||||
int namevalid(const char *name)
|
||||
//----------------------------------------------------------------
|
||||
// Input: name = name used to ID an object
|
||||
// Output: returns TRUE if name is valid, FALSE if not
|
||||
// Purpose: checks that an object's ID name is valid.
|
||||
//----------------------------------------------------------------
|
||||
{
|
||||
size_t n = strlen(name);
|
||||
if (n < 1 || n > MAXID || strpbrk(name, " \";")) return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
char *getTmpName(char *fname)
|
||||
//----------------------------------------------------------------
|
||||
// Input: fname = file name string
|
||||
|
||||
Reference in New Issue
Block a user