Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
proview
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Esteban Blanc
proview
Commits
2d6dc9a1
Commit
2d6dc9a1
authored
Oct 17, 2013
by
Claes Sjofors
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Xtt and wb, input syntax check for erroneous characters at end (refs #147)
parent
eff2ae46
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
36 deletions
+41
-36
wb/lib/wb/src/wb_wnav.cpp
wb/lib/wb/src/wb_wnav.cpp
+15
-14
xtt/exe/rt_xtt/gtk/rt_xtt_gtk.cpp
xtt/exe/rt_xtt/gtk/rt_xtt_gtk.cpp
+2
-0
xtt/lib/ge/src/ge_graph.cpp
xtt/lib/ge/src/ge_graph.cpp
+13
-12
xtt/lib/xtt/src/xtt_xnav.cpp
xtt/lib/xtt/src/xtt_xnav.cpp
+11
-10
No files found.
wb/lib/wb/src/wb_wnav.cpp
View file @
2d6dc9a1
...
...
@@ -74,10 +74,11 @@ int wnav_attr_string_to_value( ldh_tSesContext ldhses, int type_id, char *value
void
*
buffer_ptr
,
int
buff_size
,
int
attr_size
)
{
int
sts
;
char
s
[
100
];
switch
(
type_id
)
{
case
pwr_eType_Boolean
:
{
if
(
sscanf
(
value_str
,
"%d
"
,
(
pwr_tBoolean
*
)
buffer_ptr
)
!=
1
)
if
(
sscanf
(
value_str
,
"%d
%s"
,
(
pwr_tBoolean
*
)
buffer_ptr
,
s
)
!=
1
)
return
WNAV__INPUT_SYNTAX
;
if
(
*
(
pwr_tBoolean
*
)
buffer_ptr
>
1
)
return
WNAV__INPUT_SYNTAX
;
...
...
@@ -92,14 +93,14 @@ int wnav_attr_string_to_value( ldh_tSesContext ldhses, int type_id, char *value
*
(
float
*
)
buffer_ptr
=
FLT_MAX
;
else
if
(
strcmp
(
value_str
,
"FLT_NMAX"
)
==
0
)
*
(
float
*
)
buffer_ptr
=
-
FLT_MAX
;
else
if
(
sscanf
(
value_str
,
"%f
"
,
(
float
*
)
buffer_ptr
)
!=
1
)
else
if
(
sscanf
(
value_str
,
"%f
%s"
,
(
float
*
)
buffer_ptr
,
s
)
!=
1
)
return
WNAV__INPUT_SYNTAX
;
break
;
}
case
pwr_eType_Float64
:
{
pwr_tFloat32
f
;
pwr_tFloat64
d
;
if
(
sscanf
(
value_str
,
"%f
"
,
&
f
)
!=
1
)
if
(
sscanf
(
value_str
,
"%f
%s"
,
&
f
,
s
)
!=
1
)
return
WNAV__INPUT_SYNTAX
;
d
=
f
;
memcpy
(
buffer_ptr
,
(
char
*
)
&
d
,
sizeof
(
d
));
...
...
@@ -112,21 +113,21 @@ int wnav_attr_string_to_value( ldh_tSesContext ldhses, int type_id, char *value
c
=
'\0'
;
memcpy
(
buffer_ptr
,
&
c
,
sizeof
(
c
));
}
else
if
(
sscanf
(
value_str
,
"%c
"
,
(
char
*
)
buffer_ptr
)
!=
1
)
else
if
(
sscanf
(
value_str
,
"%c
%s"
,
(
char
*
)
buffer_ptr
,
s
)
!=
1
)
return
WNAV__INPUT_SYNTAX
;
break
;
}
case
pwr_eType_Int8
:
{
pwr_tInt8
i8
;
pwr_tInt16
i16
;
if
(
sscanf
(
value_str
,
"%hd
"
,
&
i16
)
!=
1
)
if
(
sscanf
(
value_str
,
"%hd
%s"
,
&
i16
,
s
)
!=
1
)
return
WNAV__INPUT_SYNTAX
;
i8
=
i16
;
memcpy
(
buffer_ptr
,
(
char
*
)
&
i8
,
sizeof
(
i8
));
break
;
}
case
pwr_eType_Int16
:
{
if
(
sscanf
(
value_str
,
"%hd
"
,
(
short
*
)
buffer_ptr
)
!=
1
)
if
(
sscanf
(
value_str
,
"%hd
%s"
,
(
short
*
)
buffer_ptr
,
s
)
!=
1
)
return
WNAV__INPUT_SYNTAX
;
break
;
}
...
...
@@ -135,47 +136,47 @@ int wnav_attr_string_to_value( ldh_tSesContext ldhses, int type_id, char *value
*
(
int
*
)
buffer_ptr
=
INT_MIN
;
else
if
(
strcmp
(
value_str
,
"INT_MAX"
)
==
0
)
*
(
int
*
)
buffer_ptr
=
INT_MAX
;
else
if
(
sscanf
(
value_str
,
"%d
"
,
(
int
*
)
buffer_ptr
)
!=
1
)
else
if
(
sscanf
(
value_str
,
"%d
%s"
,
(
int
*
)
buffer_ptr
,
s
)
!=
1
)
return
WNAV__INPUT_SYNTAX
;
break
;
}
case
pwr_eType_Int64
:
{
if
(
sscanf
(
value_str
,
pwr_dFormatInt64
,
(
pwr_tUInt64
*
)
buffer_ptr
)
!=
1
)
if
(
sscanf
(
value_str
,
pwr_dFormatInt64
"%s"
,
(
pwr_tUInt64
*
)
buffer_ptr
,
s
)
!=
1
)
return
WNAV__INPUT_SYNTAX
;
break
;
}
case
pwr_eType_UInt8
:
{
pwr_tUInt8
i8
;
pwr_tUInt16
i16
;
if
(
sscanf
(
value_str
,
"%hu
"
,
&
i16
)
!=
1
)
if
(
sscanf
(
value_str
,
"%hu
%s"
,
&
i16
,
s
)
!=
1
)
return
WNAV__INPUT_SYNTAX
;
i8
=
i16
;
memcpy
(
buffer_ptr
,
(
char
*
)
&
i8
,
sizeof
(
i8
));
break
;
}
case
pwr_eType_UInt16
:
{
if
(
sscanf
(
value_str
,
"%hu
"
,
(
pwr_tUInt16
*
)
buffer_ptr
)
!=
1
)
if
(
sscanf
(
value_str
,
"%hu
%s"
,
(
pwr_tUInt16
*
)
buffer_ptr
,
s
)
!=
1
)
return
WNAV__INPUT_SYNTAX
;
break
;
}
case
pwr_eType_UInt32
:
case
pwr_eType_DisableAttr
:
{
if
(
sscanf
(
value_str
,
"%u
"
,
(
pwr_tDisableAttr
*
)
buffer_ptr
)
!=
1
)
if
(
sscanf
(
value_str
,
"%u
%s"
,
(
pwr_tDisableAttr
*
)
buffer_ptr
,
s
)
!=
1
)
return
WNAV__INPUT_SYNTAX
;
break
;
}
case
pwr_eType_UInt64
:
{
if
(
sscanf
(
value_str
,
pwr_dFormatUInt64
,
(
pwr_tUInt64
*
)
buffer_ptr
)
!=
1
)
if
(
sscanf
(
value_str
,
pwr_dFormatUInt64
"%s"
,
(
pwr_tUInt64
*
)
buffer_ptr
,
s
)
!=
1
)
return
WNAV__INPUT_SYNTAX
;
break
;
}
case
pwr_eType_Enum
:
{
if
(
sscanf
(
value_str
,
"%d
"
,
(
pwr_tEnum
*
)
buffer_ptr
)
!=
1
)
if
(
sscanf
(
value_str
,
"%d
%s"
,
(
pwr_tEnum
*
)
buffer_ptr
,
s
)
!=
1
)
return
WNAV__INPUT_SYNTAX
;
break
;
}
case
pwr_eType_Mask
:
{
if
(
sscanf
(
value_str
,
"%u
"
,
(
pwr_tMask
*
)
buffer_ptr
)
!=
1
)
if
(
sscanf
(
value_str
,
"%u
%s"
,
(
pwr_tMask
*
)
buffer_ptr
,
s
)
!=
1
)
return
WNAV__INPUT_SYNTAX
;
break
;
}
...
...
xtt/exe/rt_xtt/gtk/rt_xtt_gtk.cpp
View file @
2d6dc9a1
...
...
@@ -637,6 +637,8 @@ void XttGtk::valchanged_cmd_input( GtkWidget *w, gpointer data)
xtt
->
set_prompt
(
""
);
xtt
->
input_open
=
0
;
xtt
->
xnav
->
set_inputfocus
();
if
(
EVEN
(
sts
))
xtt
->
message
(
'E'
,
XNav
::
get_message
(
sts
));
}
else
if
(
xtt
->
command_open
)
{
sts
=
xtt
->
xnav
->
command
(
text
);
...
...
xtt/lib/ge/src/ge_graph.cpp
View file @
2d6dc9a1
...
...
@@ -5337,12 +5337,13 @@ int graph_attr_string_to_value( int type_id, const char *value_str,
void
*
buffer_ptr
,
int
buff_size
,
int
attr_size
)
{
int
sts
;
char
s
[
100
];
switch
(
type_id
)
{
case
pwr_eType_Boolean
:
{
if
(
sscanf
(
value_str
,
"%d
"
,
(
pwr_tBoolean
*
)
buffer_ptr
)
!=
1
)
if
(
sscanf
(
value_str
,
"%d
%s"
,
(
pwr_tBoolean
*
)
buffer_ptr
,
s
)
!=
1
)
return
GE__INPUT_SYNTAX
;
if
(
*
(
pwr_tBoolean
*
)
buffer_ptr
>
1
)
return
GE__INPUT_SYNTAX
;
...
...
@@ -5350,7 +5351,7 @@ int graph_attr_string_to_value( int type_id, const char *value_str,
}
case
pwr_eType_Float32
:
{
if
(
sscanf
(
value_str
,
"%f
"
,
(
float
*
)
buffer_ptr
)
!=
1
)
if
(
sscanf
(
value_str
,
"%f
%s"
,
(
float
*
)
buffer_ptr
,
s
)
!=
1
)
return
GE__INPUT_SYNTAX
;
break
;
}
...
...
@@ -5358,7 +5359,7 @@ int graph_attr_string_to_value( int type_id, const char *value_str,
{
pwr_tFloat32
f
;
pwr_tFloat64
d
;
if
(
sscanf
(
value_str
,
"%f
"
,
&
f
)
!=
1
)
if
(
sscanf
(
value_str
,
"%f
%s"
,
&
f
,
s
)
!=
1
)
return
GE__INPUT_SYNTAX
;
d
=
f
;
memcpy
(
buffer_ptr
,
(
char
*
)
&
d
,
sizeof
(
d
));
...
...
@@ -5367,7 +5368,7 @@ int graph_attr_string_to_value( int type_id, const char *value_str,
}
case
pwr_eType_Char
:
{
if
(
sscanf
(
value_str
,
"%c
"
,
(
char
*
)
buffer_ptr
)
!=
1
)
if
(
sscanf
(
value_str
,
"%c
%s"
,
(
char
*
)
buffer_ptr
,
s
)
!=
1
)
return
GE__INPUT_SYNTAX
;
break
;
}
...
...
@@ -5375,7 +5376,7 @@ int graph_attr_string_to_value( int type_id, const char *value_str,
{
pwr_tInt8
i8
;
pwr_tInt16
i16
;
if
(
sscanf
(
value_str
,
"%hd
"
,
&
i16
)
!=
1
)
if
(
sscanf
(
value_str
,
"%hd
%s"
,
&
i16
,
s
)
!=
1
)
return
GE__INPUT_SYNTAX
;
i8
=
i16
;
memcpy
(
buffer_ptr
,
(
char
*
)
&
i8
,
sizeof
(
i8
));
...
...
@@ -5383,20 +5384,20 @@ int graph_attr_string_to_value( int type_id, const char *value_str,
}
case
pwr_eType_Int16
:
{
if
(
sscanf
(
value_str
,
"%hd
"
,
(
short
*
)
buffer_ptr
)
!=
1
)
if
(
sscanf
(
value_str
,
"%hd
%s"
,
(
short
*
)
buffer_ptr
,
s
)
!=
1
)
return
GE__INPUT_SYNTAX
;
break
;
}
case
pwr_eType_Int32
:
case
pwr_eType_Enum
:
{
if
(
sscanf
(
value_str
,
"%d
"
,
(
int
*
)
buffer_ptr
)
!=
1
)
if
(
sscanf
(
value_str
,
"%d
%s"
,
(
int
*
)
buffer_ptr
,
s
)
!=
1
)
return
GE__INPUT_SYNTAX
;
break
;
}
case
pwr_eType_Int64
:
{
if
(
sscanf
(
value_str
,
pwr_dFormatInt64
,
(
pwr_tInt64
*
)
buffer_ptr
)
!=
1
)
if
(
sscanf
(
value_str
,
pwr_dFormatInt64
"%s"
,
(
pwr_tInt64
*
)
buffer_ptr
,
s
)
!=
1
)
return
GE__INPUT_SYNTAX
;
break
;
}
...
...
@@ -5404,7 +5405,7 @@ int graph_attr_string_to_value( int type_id, const char *value_str,
{
pwr_tUInt8
i8
;
pwr_tUInt16
i16
;
if
(
sscanf
(
value_str
,
"%hu
"
,
&
i16
)
!=
1
)
if
(
sscanf
(
value_str
,
"%hu
%s"
,
&
i16
,
s
)
!=
1
)
return
GE__INPUT_SYNTAX
;
i8
=
i16
;
memcpy
(
buffer_ptr
,
(
char
*
)
&
i8
,
sizeof
(
i8
));
...
...
@@ -5412,20 +5413,20 @@ int graph_attr_string_to_value( int type_id, const char *value_str,
}
case
pwr_eType_UInt16
:
{
if
(
sscanf
(
value_str
,
"%hu
"
,
(
unsigned
short
*
)
buffer_ptr
)
!=
1
)
if
(
sscanf
(
value_str
,
"%hu
%s"
,
(
unsigned
short
*
)
buffer_ptr
,
s
)
!=
1
)
return
GE__INPUT_SYNTAX
;
break
;
}
case
pwr_eType_UInt32
:
case
pwr_eType_Mask
:
{
if
(
sscanf
(
value_str
,
"%lu
"
,
(
unsigned
long
*
)
buffer_ptr
)
!=
1
)
if
(
sscanf
(
value_str
,
"%lu
%s"
,
(
unsigned
long
*
)
buffer_ptr
,
s
)
!=
1
)
return
GE__INPUT_SYNTAX
;
break
;
}
case
pwr_eType_UInt64
:
{
if
(
sscanf
(
value_str
,
pwr_dFormatUInt64
,
(
pwr_tUInt64
*
)
buffer_ptr
)
!=
1
)
if
(
sscanf
(
value_str
,
pwr_dFormatUInt64
"%s"
,
(
pwr_tUInt64
*
)
buffer_ptr
,
s
)
!=
1
)
return
GE__INPUT_SYNTAX
;
break
;
}
...
...
xtt/lib/xtt/src/xtt_xnav.cpp
View file @
2d6dc9a1
...
...
@@ -248,10 +248,11 @@ int XNav::attr_string_to_value( int type_id, char *value_str,
void
*
buffer_ptr
,
int
buff_size
,
int
attr_size
)
{
int
sts
;
char
s
[
100
];
switch
(
type_id
)
{
case
pwr_eType_Boolean
:
{
if
(
sscanf
(
value_str
,
"%d
"
,
(
pwr_tBoolean
*
)
buffer_ptr
)
!=
1
)
if
(
sscanf
(
value_str
,
"%d
%s"
,
(
pwr_tBoolean
*
)
buffer_ptr
,
s
)
!=
1
)
return
XNAV__INPUT_SYNTAX
;
if
(
*
(
pwr_tBoolean
*
)
buffer_ptr
>
1
)
return
XNAV__INPUT_SYNTAX
;
...
...
@@ -266,14 +267,14 @@ int XNav::attr_string_to_value( int type_id, char *value_str,
*
(
float
*
)
buffer_ptr
=
FLT_MAX
;
else
if
(
strcmp
(
value_str
,
"FLT_NMAX"
)
==
0
)
*
(
float
*
)
buffer_ptr
=
-
FLT_MAX
;
else
if
(
sscanf
(
value_str
,
"%f
"
,
(
float
*
)
buffer_ptr
)
!=
1
)
else
if
(
sscanf
(
value_str
,
"%f
%s"
,
(
float
*
)
buffer_ptr
,
s
)
!=
1
)
return
XNAV__INPUT_SYNTAX
;
break
;
}
case
pwr_eType_Float64
:
{
pwr_tFloat32
f
;
pwr_tFloat64
d
;
if
(
sscanf
(
value_str
,
"%f
"
,
&
f
)
!=
1
)
if
(
sscanf
(
value_str
,
"%f
%s"
,
&
f
,
s
)
!=
1
)
return
XNAV__INPUT_SYNTAX
;
d
=
f
;
memcpy
(
buffer_ptr
,
(
char
*
)
&
d
,
sizeof
(
d
));
...
...
@@ -281,14 +282,14 @@ int XNav::attr_string_to_value( int type_id, char *value_str,
break
;
}
case
pwr_eType_Char
:
{
if
(
sscanf
(
value_str
,
"%c
"
,
(
char
*
)
buffer_ptr
)
!=
1
)
if
(
sscanf
(
value_str
,
"%c
%s"
,
(
char
*
)
buffer_ptr
,
s
)
!=
1
)
return
XNAV__INPUT_SYNTAX
;
break
;
}
case
pwr_eType_Int8
:
{
pwr_tInt8
i8
;
pwr_tInt16
i16
;
if
(
sscanf
(
value_str
,
"%hd
"
,
&
i16
)
!=
1
)
if
(
sscanf
(
value_str
,
"%hd
%s"
,
&
i16
,
s
)
!=
1
)
return
XNAV__INPUT_SYNTAX
;
i8
=
i16
;
memcpy
(
buffer_ptr
,
(
char
*
)
&
i8
,
sizeof
(
i8
));
...
...
@@ -306,19 +307,19 @@ int XNav::attr_string_to_value( int type_id, char *value_str,
*
(
int
*
)
buffer_ptr
=
INT_MIN
;
else
if
(
strcmp
(
value_str
,
"INT_MAX"
)
==
0
)
*
(
int
*
)
buffer_ptr
=
INT_MAX
;
else
if
(
sscanf
(
value_str
,
"%d
"
,
(
int
*
)
buffer_ptr
)
!=
1
)
else
if
(
sscanf
(
value_str
,
"%d
%s"
,
(
int
*
)
buffer_ptr
,
s
)
!=
1
)
return
XNAV__INPUT_SYNTAX
;
break
;
}
case
pwr_eType_Int64
:
{
if
(
sscanf
(
value_str
,
pwr_dFormatInt64
,
(
pwr_tInt64
*
)
buffer_ptr
)
!=
1
)
if
(
sscanf
(
value_str
,
pwr_dFormatInt64
"%s"
,
(
pwr_tInt64
*
)
buffer_ptr
,
s
)
!=
1
)
return
XNAV__INPUT_SYNTAX
;
break
;
}
case
pwr_eType_UInt8
:
{
pwr_tUInt8
i8
;
pwr_tUInt16
i16
;
if
(
sscanf
(
value_str
,
"%hu
"
,
&
i16
)
!=
1
)
if
(
sscanf
(
value_str
,
"%hu
%s"
,
&
i16
,
s
)
!=
1
)
return
XNAV__INPUT_SYNTAX
;
i8
=
i16
;
memcpy
(
buffer_ptr
,
(
char
*
)
&
i8
,
sizeof
(
i8
));
...
...
@@ -333,12 +334,12 @@ int XNav::attr_string_to_value( int type_id, char *value_str,
case
pwr_eType_Mask
:
case
pwr_eType_Enum
:
case
pwr_eType_DisableAttr
:
{
if
(
sscanf
(
value_str
,
"%lu
"
,
(
unsigned
long
*
)
buffer_ptr
)
!=
1
)
if
(
sscanf
(
value_str
,
"%lu
%s"
,
(
unsigned
long
*
)
buffer_ptr
,
s
)
!=
1
)
return
XNAV__INPUT_SYNTAX
;
break
;
}
case
pwr_eType_UInt64
:
{
if
(
sscanf
(
value_str
,
pwr_dFormatUInt64
,
(
pwr_tUInt64
*
)
buffer_ptr
)
!=
1
)
if
(
sscanf
(
value_str
,
pwr_dFormatUInt64
"%s"
,
(
pwr_tUInt64
*
)
buffer_ptr
,
s
)
!=
1
)
return
XNAV__INPUT_SYNTAX
;
break
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment