Commit 5aea23be authored by claes's avatar claes

Symbols for INT_MIN, INT_MAX, FLT_MIN and FLT_MAX

parent 24b6d54a
/*
* Proview $Id: wb_print_wbl.cpp,v 1.20 2007-09-19 15:13:02 claes Exp $
* Proview $Id: wb_print_wbl.cpp,v 1.21 2007-12-06 10:53:18 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -655,7 +655,12 @@ bool wb_print_wbl::printValue (wb_volume& v,
sprintf(sval, "%d", *(pwr_tBoolean *) val);
break;
case pwr_eType_Float32:
sprintf(sval, "%.*e", FLT_DIG, *(pwr_tFloat32 *) val);
if ( *(pwr_tFloat32 *)val == FLT_MIN)
strcpy( sval, "FLT_MIN");
else if ( *(pwr_tFloat32 *)val == FLT_MAX)
strcpy( sval, "FLT_MAX");
else
sprintf(sval, "%.*e", FLT_DIG, *(pwr_tFloat32 *) val);
break;
case pwr_eType_Float64:
sprintf(sval, "%.*e", DBL_DIG, *(pwr_tFloat64 *) val);
......@@ -673,7 +678,12 @@ bool wb_print_wbl::printValue (wb_volume& v,
sprintf(sval, "%d", *(pwr_tInt16 *) val);
break;
case pwr_eType_Int32:
sprintf(sval, "%d", *(pwr_tInt32 *) val);
if ( *(pwr_tInt32 *)val == INT_MIN)
strcpy( sval, "INT_MIN");
else if ( *(pwr_tInt32 *)val == INT_MAX)
strcpy( sval, "INT_MAX");
else
sprintf(sval, "%d", *(pwr_tInt32 *) val);
break;
case pwr_eType_Int64:
sprintf(sval, "%lld", *(pwr_tInt64 *) val);
......
/*
* Proview $Id: wb_wblnode.cpp,v 1.59 2007-10-23 08:54:16 claes Exp $
* Proview $Id: wb_wblnode.cpp,v 1.60 2007-12-06 10:53:18 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -17,6 +17,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
#include <float.h>
#include <limits.h>
#include "pwr_class.h"
#include "co_cdh.h"
#include "co_time.h"
......@@ -2015,7 +2017,13 @@ int wb_wblnode::attrStringToValue( int type_id, char *value_str,
}
case pwr_eType_Float32:
{
if ( sscanf( value_str, "%f", (float *)buffer_ptr) != 1)
if ( strcmp( value_str, "FLT_MIN") == 0) {
*(float *)buffer_ptr = FLT_MIN;
}
else if ( strcmp( value_str, "FLT_MAX") == 0) {
*(float *)buffer_ptr = FLT_MAX;
}
else if ( sscanf( value_str, "%f", (float *)buffer_ptr) != 1)
return 0;
break;
}
......@@ -2056,7 +2064,13 @@ int wb_wblnode::attrStringToValue( int type_id, char *value_str,
case pwr_eType_Status:
case pwr_eType_NetStatus:
{
if ( sscanf( value_str, "%d", (int *)buffer_ptr) != 1)
if ( strcmp( value_str, "INT_MIN") == 0) {
*(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)
return 0;
break;
}
......
/*
* Proview $Id: xtt_xnav.cpp,v 1.34 2007-05-21 14:28:32 claes Exp $
* Proview $Id: xtt_xnav.cpp,v 1.35 2007-12-06 10:56:28 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -23,6 +23,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <float.h>
#include "co_nav_help.h"
#include "pwr_privilege.h"
......@@ -235,7 +236,11 @@ int XNav::attr_string_to_value( int type_id, char *value_str,
break;
}
case pwr_eType_Float32: {
if ( sscanf( value_str, "%f", (float *)buffer_ptr) != 1)
if ( strcmp( value_str, "FLT_MIN") == 0)
*(float *)buffer_ptr = FLT_MIN;
else if ( strcmp( value_str, "FLT_MAX") == 0)
*(float *)buffer_ptr = FLT_MAX;
else if ( sscanf( value_str, "%f", (float *)buffer_ptr) != 1)
return XNAV__INPUT_SYNTAX;
break;
}
......@@ -271,7 +276,11 @@ int XNav::attr_string_to_value( int type_id, char *value_str,
case pwr_eType_Int32:
case pwr_eType_Status:
case pwr_eType_NetStatus: {
if ( sscanf( value_str, "%d", (int *)buffer_ptr) != 1)
if ( strcmp( value_str, "INT_MIN") == 0)
*(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)
return XNAV__INPUT_SYNTAX;
break;
}
......@@ -436,10 +445,20 @@ void XNav::attrvalue_to_string( int type_id, pwr_tTid tid, void *value_ptr,
break;
}
case pwr_eType_Float32: {
if ( !format)
*len = sprintf( str, "%f", *(float *)value_ptr);
else
*len = sprintf( str, format, *(float *)value_ptr);
if ( *(float *)value_ptr == FLT_MIN) {
strcpy( str, "FLT_MIN");
*len = strlen(str);
}
else if ( *(float *)value_ptr == FLT_MAX) {
strcpy( str, "FLT_MAX");
*len = strlen(str);
}
else {
if ( !format)
*len = sprintf( str, "%f", *(float *)value_ptr);
else
*len = sprintf( str, format, *(float *)value_ptr);
}
break;
}
case pwr_eType_Float64: {
......@@ -471,10 +490,20 @@ void XNav::attrvalue_to_string( int type_id, pwr_tTid tid, void *value_ptr,
break;
}
case pwr_eType_Int32: {
if ( !format)
*len = sprintf( str, "%d", *(int *)value_ptr);
else
*len = sprintf( str, format, *(int *)value_ptr);
if ( *(int *)value_ptr == INT_MIN) {
strcpy( str, "INT_MIN");
*len = strlen(str);
}
else if ( *(int *)value_ptr == INT_MAX) {
strcpy( str, "INT_MAX");
*len = strlen(str);
}
else {
if ( !format)
*len = sprintf( str, "%d", *(int *)value_ptr);
else
*len = sprintf( str, format, *(int *)value_ptr);
}
break;
}
case pwr_eType_Int64: {
......
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