MCPcopy Create free account
hub / github.com/Kitware/CMake / Check_Integer_Field

Function Check_Integer_Field

Source/CursesDialog/form/fty_int.c:92–126  ·  view source on GitHub ↗

--------------------------------------------------------------------------- | Facility : libnform | Function : static bool Check_Integer_Field( | FIELD * field, | const void * argp) | | Description : Validate buffer content to be a valid integer value | | Return Values

Source from the content-addressed store, hash-verified

90| FALSE - field is invalid
91+--------------------------------------------------------------------------*/
92static bool Check_Integer_Field(FIELD * field, const void * argp)
93{
94 const integerARG *argi = (const integerARG *)argp;
95 long low = argi->low;
96 long high = argi->high;
97 int prec = argi->precision;
98 unsigned char *bp = (unsigned char *)field_buffer(field,0);
99 char *s = (char *)bp;
100 long val;
101 char buf[100];
102
103 while( *bp && *bp==' ') bp++;
104 if (*bp)
105 {
106 if (*bp=='-') bp++;
107 while (*bp)
108 {
109 if (!isdigit(*bp)) break;
110 bp++;
111 }
112 while(*bp && *bp==' ') bp++;
113 if (*bp=='\0')
114 {
115 val = atol(s);
116 if (low<high)
117 {
118 if (val<low || val>high) return FALSE;
119 }
120 snprintf(buf,sizeof(buf),"%.*ld",(prec>0?prec:0),val);
121 set_field_buffer(field,0,buf);
122 return TRUE;
123 }
124 }
125 return FALSE;
126}
127
128/*---------------------------------------------------------------------------
129| Facility : libnform

Callers

nothing calls this directly

Calls 3

field_bufferFunction · 0.85
set_field_bufferFunction · 0.85
snprintfFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…