4 #define INLINELEN (4*8192)
6 /* if sf is a string that ends in .f, end in .F, or vice verrsa */
8 int switch_little_big_f ( char s
[] )
12 if ( !strcmp( &(s
[n
-2]) , ".f" ) ) { s
[n
-1] = 'F' ; }
13 else if ( !strcmp( &(s
[n
-2]) , ".F" ) ) { s
[n
-1] = 'f' ; }
17 int contains_str( char *s1
, char *s2
)
21 if ( s2
== NULL
|| s1
== NULL
) return ( 0 ) ;
22 if ( *s2
== '\0' || *s1
== '\0' ) return ( 0 ) ;
25 if ((r
= (char *)index( p
, *s2
)) == NULL
) { return( 0 ) ; }
26 for ( q
= s2
; *q
&& *r
== *q
; r
++ , q
++ ) ;
27 if ( *q
== '\0' ) return (1) ;
34 find_str( char *s1
, char *s2
, char **strp
)
38 if ( s2
== NULL
|| s1
== NULL
) return ( 0 ) ;
39 if ( *s2
== '\0' || *s1
== '\0' ) return ( 0 ) ;
43 if ((r
= (char *)index( p
, *s2
)) == NULL
) { return( 0 ) ; }
45 for ( q
= s2
; *q
&& *r
== *q
; r
++ , q
++ ) ;
46 if ( *q
== '\0' ) return (1) ;
53 int contains_tok( char *s1
, char *s2
, char *delims
)
56 char tempstr
[INLINELEN
] ;
59 strcpy( tempstr
, s1
) ;
60 p
= strtok ( tempstr
, delims
) ;
64 if ( !strcmp ( p
, s2
) ) { return(i
) ;}
66 p
= strtok( NULL
, delims
) ;
72 get_token_n ( char *s1
, char *delims
, int n
, char* retval
)
76 static char tempstr
[INLINELEN
] ;
77 strcpy( tempstr
, s1
) ;
78 p
= strtok ( tempstr
, delims
) ;
82 if ( i
== n
) { strcpy( retval
, p
) ; return( 1 ) ; }
83 p
= strtok( NULL
, delims
) ;
90 get_arg_n ( char *s1
, int n
, char *retval
)
93 int i
, arg
, inquote
= -1, inparen
= -1 ;
94 static char tempstr
[INLINELEN
] ;
95 char quotes
[INLINELEN
] ;
96 char parens
[INLINELEN
] ;
97 strcpy( tempstr
, s1
) ;
98 strcpy( retval
, "" ) ;
100 if ( (p
= index(tempstr
, '(')) == NULL
) return(0) ;
103 while ( *p
&& arg
< n
+1 ) {
108 if ( *p
== '\'' || *p
== '"' ) {
109 if ( inquote
>= 0 ) {
110 if ( quotes
[inquote
] == *p
) {
114 quotes
[inquote
] = *p
;
118 quotes
[inquote
] = *p
;
122 if ( *p
== '(' ) inparen
++ ;
124 if ( inparen
>= 0 ) { inparen
-- ; }
125 else { *p
= '\0' ; arg
++ ; break ;}
128 if ( inquote
< 0 && inparen
< 0 ) {
129 if ( *p
== ',' ) { arg
++ ; *p
= '\0' ; p
++ ; break ; }
134 for ( ; *q
; q
++ ) { if ( *q
!= ' ' && *q
!= '\t' ) break ; }
135 strcpy( retval
, q
) ;
138 strcpy( retval
, "" ) ;
147 for ( p
= s
; *p
; p
++ )
149 if ( ! ( *p
== ' ' || *p
== '\t' || *p
== '\n' ) ) return( 0 ) ;
154 remove_nl ( char *s
)
157 if (( p
= index( s
, '\n' )) != NULL
) *p
= '\0' ;
161 remove_comments ( char *s
)
164 char quotes
[INLINELEN
] ;
166 for ( p
= s
; *p
; p
++ )
168 if ( *p
== '\'' || *p
== '"' ) {
169 if ( inquote
>= 0 ) {
170 if ( quotes
[inquote
] == *p
) {
174 quotes
[inquote
] = *p
;
178 quotes
[inquote
] = *p
;
182 if ( *p
== '!' ) { *p
= '\0' ; break ; }
188 remove_chars ( char *s
, char *r
, char replace
)
192 char quotes
[INLINELEN
] ;
194 for ( p
= s
; *p
; p
++ )
196 if ( *p
== '\'' || *p
== '"' ) {
197 if ( inquote
>= 0 ) {
198 if ( quotes
[inquote
] == *p
) {
202 quotes
[inquote
] = *p
;
206 quotes
[inquote
] = *p
;
210 for ( q
= r
; *q
; q
++ ) {
211 if ( *p
== *q
) { *p
= replace
; retval
= 1 ; }
219 remove_whitespace ( char *s
)
222 for ( p
= s
, q
= s
; *p
; p
++ )
224 if ( ! (*p
== ' ' || *p
== '\t') ) {
237 for ( p
= s
; *p
; p
++ ) if ( *p
!= ' ' && *p
!= '\t' ) return(0) ;
242 remove_ampersands ( char *s
)
246 if (( p
= rindex ( s
, '&' )) != NULL
)
248 if ( iswhite( p
+1 ) ) retval
= 1 ;
255 remove_chars ( s
, "&", ' ' ) ;
259 lower_case_str ( char *s
)
262 for ( p
= s
; *p
; p
++ )
264 if ( *p
>= 'A' && *p
<= 'Z' ) *p
= *p
- 'A' + 'a' ;
268 upper_case_str ( char *s
)
271 for ( p
= s
; *p
; p
++ )
273 if ( *p
>= 'a' && *p
<= 'z' ) *p
= *p
- 'a' + 'A' ;