Commit dad4f5e8 authored by Pavel Vainerman's avatar Pavel Vainerman

Исправил баг в функиях conf->getPIntProp() приводивший к тому,

что невозможно передать отрицательное число.
parent 44234ec3
......@@ -3,7 +3,7 @@
Name: libuniset
Version: 1.0
Release: alt7
Release: alt8
Summary: UniSet - library for building distributed industrial control systems
License: GPL
Group: Development/C++
......@@ -191,6 +191,9 @@ rm -f %buildroot%_libdir/*.la
%exclude %_pkgconfigdir/libUniSet.pc
%changelog
* Fri Mar 11 2011 Pavel Vainerman <pv@altlinux.ru> 1.0-alt8
- fixed bug in conf->getArgPInt function (new libUniSet revision)
* Wed Mar 02 2011 Pavel Vainerman <pv@altlinux.ru> 1.0-alt7
- add UNet2 to extensions
......
......@@ -33,7 +33,7 @@
</UniSet>
<dlog name="dlog"/>
<IOControl name="IOControl"/>
<testnode id="1000"/>
<testnode name="testnode" id="1000" id2="-100"/>
<SharedMemory name="SharedMemory" shmID="SharedMemory">
<History savetime="200">
<item filter="a1" fuse_id="AlarmFuse1_S" fuse_invert="1" id="1" size="30"/>
......
......@@ -3,7 +3,7 @@
# See doc: http://www.gnu.org/software/hello/manual/autoconf/Generic-Programs.html
# AC_PREREQ(2.59)
AC_INIT([uniset], [1.0.0], pv@etersoft.ru)
AC_INIT([uniset], [1.1.0], pv@etersoft.ru)
AM_INIT_AUTOMAKE(AC_PACKAGE_NAME,AC_PACKAGE_VERSION)
# AC_CONFIG_MACRO_DIR([m4])
......@@ -30,7 +30,7 @@ AC_ENABLE_SHARED(yes)
AC_ENABLE_STATIC(no)
AM_PROG_LIBTOOL
LIBVER=1:0:0
LIBVER=1:1:0
AC_SUBST(LIBVER)
# Checks for libraries.
......
......@@ -422,18 +422,20 @@ int Configuration::getArgInt( const string name, const string defval )
int Configuration::getArgPInt( const string name, int defval )
{
int i = getArgInt(name);
if ( i <= 0 )
string param = getArgParam(name,"");
if( param.empty() )
return defval;
return i;
return UniSetTypes::uni_atoi(param);
}
int Configuration::getArgPInt( const string name, const string strdefval, int defval )
{
int i = getArgInt(name, strdefval);
if ( i <= 0 )
string param = getArgParam(name,strdefval);
if( param.empty() && strdefval.empty() )
return defval;
return i;
return UniSetTypes::uni_atoi(param);
}
......
......@@ -133,10 +133,11 @@ int UniXML::getIntProp(const xmlNode* node, const string name )
int UniXML::getPIntProp(const xmlNode* node, const string name, int def )
{
int i = getIntProp(node, name);
if (i <= 0)
string param = getProp(node,name);
if( param.empty() )
return def;
return i;
return UniSetTypes::uni_atoi(param);
}
void UniXML::setProp(xmlNode* node, string name, string text)
......
......@@ -4,7 +4,7 @@
SUBDIRS=JrnTests
noinst_PROGRAMS = passivetimer unixml ui umutex conftest iterator_test
noinst_PROGRAMS = passivetimer unixml ui umutex conftest iterator_test sscanf_hex
passivetimer_SOURCES = passivetimer.cc
passivetimer_LDADD = $(top_builddir)/lib/libUniSet.la
......@@ -30,6 +30,8 @@ conftest_SOURCES = conftest.cc
conftest_LDADD = $(top_builddir)/lib/libUniSet.la
conftest_CPPFLAGS = -I$(top_builddir)/include
sscanf_hex_SOURCES = sscanf_hex.cc
include $(top_builddir)/conf/setting.mk
......@@ -38,6 +38,40 @@ int main(int argc, const char **argv)
UniversalIO::IOTypes t3=conf->getIOType("Input1_S");
cout << "**** check getIOType(name): for short name 'Input1_S': (" << t3 << ") " << ( t3 == UniversalIO::UnknownIOType ? "FAILED" : "OK" ) << endl;
int i1 = uni_atoi("-100");
cout << "**** check uni_atoi: '-100' " << ( ( i1 != -100 ) ? "FAILED" : "OK" ) << endl;
int i2 = uni_atoi("20");
cout << "**** check uni_atoi: '20' " << ( ( i2 != 20 ) ? "FAILED" : "OK" ) << endl;
xmlNode* cnode = conf->getNode("testnode");
if( cnode == NULL )
{
cerr << "<testnode name='testnode'> not found" << endl;
return 1;
}
cout << "**** check conf->getNode function [OK] " << endl;
UniXML_iterator it(cnode);
int prop2 = conf->getArgInt("--prop-id2",it.getProp("id2"));
cerr << "**** check conf->getArgInt(arg1,...): " << ( (prop2 == 0) ? "[FAILED]" : "OK" ) << endl;
int prop3 = conf->getArgInt("--prop-dummy",it.getProp("id2"));
cerr << "**** check conf->getArgInt(...,arg2): " << ( (prop3 != -100) ? "[FAILED]" : "OK" ) << endl;
int prop1 = conf->getArgPInt("--prop-id2",it.getProp("id2"),0);
cerr << "**** check conf->getArgPInt(...): " << ( (prop1 == 0) ? "[FAILED]" : "OK" ) << endl;
int prop4 = conf->getArgPInt("--prop-dummy",it.getProp("dummy"),20);
cerr << "**** check conf->getArgPInt(...,...,defval): " << ( (prop4 != 20) ? "[FAILED]" : "OK" ) << endl;
int prop5 = conf->getArgPInt("--prop-dummy",it.getProp("dummy"),0);
cerr << "**** check conf->getArgPInt(...,...,defval): " << ( (prop5 != 0) ? "[FAILED]" : "OK" ) << endl;
return 0;
}
catch(SystemError& err)
......
......@@ -5,7 +5,7 @@ SID=$1
[ -z "$SID" ] && SID=1
echo "check auto ID configuration..."
uniset-start.sh -f ./conftest --confile test.xml
uniset-start.sh -f ./conftest --confile test.xml --prop-id2 -10
echo "check id from file configuration..."
uniset-start.sh -f ./conftest --confile testID.xml
......
......@@ -5,8 +5,8 @@ bool check(const char *t, int nres)
int n = 105;
sscanf(t, "%i", &n);
printf("res=%d\n", n);
if ( n != nres)
printf("FAILED\n");
if ( n != nres )
printf("check %d [FAILED]\n",nres);
return n == nres;
}
......@@ -20,4 +20,5 @@ int main()
check("-1000",-1000);
check("",0);
// check(NULL,0); // SegFault
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment