#include <ctype.h>
#include "flexdef.h"
#include <assert.h>
#include <sys/types.h>
Go to the source code of this file.
#define isascii |
( |
|
c | ) |
((c) <= 0177) |
Definition at line 62 of file misc.c.
67 if ( buf[0] ==
'%' && buf[1] ==
'%' )
int all_lower |
( |
Char * |
str | ) |
|
Definition at line 104 of file misc.c.
108 if ( !
isascii( (
int) *
str ) || ! islower( (
int) *str ) )
int all_upper |
( |
Char * |
str | ) |
|
Definition at line 125 of file misc.c.
129 if ( !
isascii( (
int) *
str ) || ! isupper( (
int) *str ) )
void* allocate_array |
( |
int |
size, |
|
|
int |
element_size |
|
) |
| |
Definition at line 76 of file misc.c.
84 if ( element_size * size <= 0 )
85 flexfatal(
"request for < 1 byte in allocate_array()" );
87 mem = (
void *) malloc( (
unsigned) (element_size * size) );
90 flexfatal(
"memory allocation failed in allocate_array()" );
void flexfatal(char *msg)
void bubble |
( |
int |
v[], |
|
|
int |
n |
|
) |
| |
Definition at line 152 of file misc.c.
156 for ( i = n; i > 1; --
i )
157 for ( j = 1; j <
i; ++j )
158 if ( v[j] > v[j + 1] )
Definition at line 175 of file misc.c.
177 return ( (
isascii( c ) && isupper( c )) ? tolower( c ) : c );
char* copy_string |
( |
char * |
str | ) |
|
Definition at line 188 of file misc.c.
194 for ( c =
str; *c; ++c )
197 copy = malloc( (
unsigned) ((c -
str + 1) *
sizeof(
char )) );
200 flexfatal(
"dynamic memory failure in copy_string()" );
202 for ( c = copy; (*c++ = *
str++); )
void flexfatal(char *msg)
void copy(PVValueArray< T > &pvFrom, size_t fromOffset, size_t fromStride, PVValueArray< T > &pvTo, size_t toOffset, size_t toStride, size_t count)
Copy a subarray from one scalar array to another.
Char* copy_unsigned_string |
( |
Char * |
str | ) |
|
Definition at line 217 of file misc.c.
223 for ( c =
str; *c; ++c )
226 copy = (
Char *) malloc( (
unsigned) ((c -
str + 1) *
sizeof(
Char )) );
229 flexfatal(
"dynamic memory failure in copy_unsigned_string()" );
231 for ( c = copy; (*c++ = *
str++); )
void flexfatal(char *msg)
void copy(PVValueArray< T > &pvFrom, size_t fromOffset, size_t fromStride, PVValueArray< T > &pvTo, size_t toOffset, size_t toStride, size_t count)
Copy a subarray from one scalar array to another.
void cshell |
( |
Char * |
v, |
|
|
int |
n, |
|
|
int |
special_case_0 |
|
) |
| |
Definition at line 256 of file misc.c.
261 for ( gap = n / 2; gap > 0; gap = gap / 2 )
262 for ( i = gap; i < n; ++
i )
263 for ( j = i - gap; j >= 0; j = j - gap )
267 if ( special_case_0 )
272 else if ( v[j] != 0 && v[j] <= v[jg] )
276 else if ( v[j] <= v[jg] )
char* flex_gettime |
( |
void |
| ) |
|
Definition at line 381 of file misc.c.
383 time_t t, time(time_t *);
char * copy_string(char *str)
void flexerror |
( |
char * |
msg | ) |
|
void flexfatal |
( |
char * |
msg | ) |
|
int htoi |
( |
unsigned char * |
str | ) |
|
int is_hex_digit |
( |
int |
ch | ) |
|
void lerrif |
( |
char * |
msg, |
|
|
int |
arg |
|
) |
| |
Definition at line 405 of file misc.c.
408 (void) sprintf( errmsg, msg, arg );
void flexerror(char *msg)
void lerrsf |
( |
char * |
msg, |
|
|
char * |
arg |
|
) |
| |
Definition at line 420 of file misc.c.
424 (void) sprintf( errmsg, msg, arg );
void flexerror(char *msg)
void line_directive_out |
( |
FILE * |
output_file_name | ) |
|
void mk2data |
( |
int |
value | ) |
|
int myctoi |
( |
Char * |
array | ) |
|
Definition at line 554 of file misc.c.
558 (void) sscanf( (
char *) array,
"%d", &val );
Definition at line 572 of file misc.c.
579 case 'a':
return (
'\a' );
580 case 'b':
return (
'\b' );
581 case 'f':
return (
'\f' );
582 case 'n':
return (
'\n' );
583 case 'r':
return (
'\r' );
584 case 't':
return (
'\t' );
585 case 'v':
return (
'\v' );
600 while (
isascii( array[sptr] ) && isdigit( array[sptr] ) )
610 esc_char =
otoi( array + 1 );
631 esc_char =
htoi( array + 2 );
int htoi(unsigned char *str)
char* readable_form |
( |
int |
c | ) |
|
Definition at line 672 of file misc.c.
674 static char rform[10];
676 if ( (c >= 0 && c < 32) || c >= 127 )
680 case '\n':
return (
"\\n" );
681 case '\t':
return (
"\\t" );
682 case '\f':
return (
"\\f" );
683 case '\r':
return (
"\\r" );
684 case '\b':
return (
"\\b" );
687 (void) sprintf( rform,
"\\%.3o", c );
void* reallocate_array |
( |
void * |
array, |
|
|
int |
size, |
|
|
int |
element_size |
|
) |
| |
Definition at line 707 of file misc.c.
712 if ( size * element_size <= 0 )
713 flexfatal(
"attempt to increase array size by less than 1 byte" );
716 (
void *) realloc( (
char *)array, (unsigned) (size * element_size ));
718 if ( new_array ==
NULL )
719 flexfatal(
"attempt to increase array size failed" );
721 return ( new_array );
void flexfatal(char *msg)
Definition at line 734 of file misc.c.
739 if ( buf[0] ==
'%' && buf[1] ==
'%' )
void transition_struct_out |
( |
int |
element_v, |
|
|
int |
element_n |
|
) |
| |
Definition at line 756 of file misc.c.
758 printf(
"%7d, %5d,", element_v, element_n );
#define TRANS_STRUCT_PRINT_LENGTH