@@ -63,7 +63,7 @@ typedef struct st_pointer_array { /* when using array-strings */
63
63
#define LAST_CHAR_CODE 259
64
64
65
65
typedef struct st_replace {
66
- bool found ;
66
+ my_bool found ;
67
67
struct st_replace * next [256 ];
68
68
} REPLACE ;
69
69
@@ -80,19 +80,18 @@ typedef struct st_replace_found {
80
80
81
81
/* functions defined in this file */
82
82
83
- extern int main (int argc ,char * * argv );
84
83
static int static_get_options (int * argc ,char * * * argv );
85
84
static int get_replace_strings (int * argc ,char * * * argv ,
86
85
POINTER_ARRAY * from_array ,
87
86
POINTER_ARRAY * to_array );
88
- int insert_pointer_name (POINTER_ARRAY * pa , my_string name );
89
- void free_pointer_array (POINTER_ARRAY * pa );
87
+ static int insert_pointer_name (POINTER_ARRAY * pa , my_string name );
88
+ static void free_pointer_array (POINTER_ARRAY * pa );
90
89
static int convert_pipe (REPLACE * ,FILE * ,FILE * );
91
90
static int convert_file (REPLACE * , my_string );
92
- REPLACE * init_replace (my_string * from , my_string * to ,uint count , my_string
93
- word_end_chars );
94
- uint replace_strings (REPLACE * rep , my_string * start ,uint * max_length ,
95
- my_string from );
91
+ static REPLACE * init_replace (my_string * from , my_string * to ,uint count ,
92
+ my_string word_end_chars );
93
+ static uint replace_strings (REPLACE * rep , my_string * start ,uint * max_length ,
94
+ my_string from );
96
95
static int initialize_buffer (void );
97
96
static void reset_buffer (void );
98
97
static void free_buffer (void );
@@ -101,9 +100,7 @@ static int silent=0,verbose=0,updated=0;
101
100
102
101
/* The main program */
103
102
104
- int main (argc ,argv )
105
- int argc ;
106
- char * argv [];
103
+ int main (int argc , char * argv [])
107
104
{
108
105
int i ,error ;
109
106
char word_end_chars [256 ],* pos ;
@@ -118,7 +115,7 @@ char *argv[];
118
115
119
116
for (i = 1 ,pos = word_end_chars ; i < 256 ; i ++ )
120
117
if (my_isspace (& my_charset_latin1 ,i ))
121
- * pos ++ = i ;
118
+ * pos ++ = ( char ) i ;
122
119
* pos = 0 ;
123
120
if (!(replace = init_replace ((char * * ) from .typelib .type_names ,
124
121
(char * * ) to .typelib .type_names ,
@@ -153,7 +150,7 @@ static int static_get_options(argc,argv)
153
150
register int * argc ;
154
151
register char * * argv [];
155
152
{
156
- int help ,version , opt ;
153
+ int help ,version ;
157
154
char * pos ;
158
155
159
156
silent = verbose = help = 0 ;
@@ -162,7 +159,7 @@ register char **argv[];
162
159
while (* ++ pos )
163
160
{
164
161
version = 0 ;
165
- switch ((opt = * pos )) {
162
+ switch ((* pos )) {
166
163
case 's' :
167
164
silent = 1 ;
168
165
break ;
@@ -249,7 +246,7 @@ POINTER_ARRAY *from_array,*to_array;
249
246
return 0 ;
250
247
}
251
248
252
- int insert_pointer_name (reg1 POINTER_ARRAY * pa ,my_string name )
249
+ static int insert_pointer_name (reg1 POINTER_ARRAY * pa ,my_string name )
253
250
{
254
251
uint i ,length ,old_count ;
255
252
byte * new_pos ;
@@ -323,8 +320,7 @@ int insert_pointer_name(reg1 POINTER_ARRAY *pa,my_string name)
323
320
324
321
/* free pointer array */
325
322
326
- void free_pointer_array (pa )
327
- reg1 POINTER_ARRAY * pa ;
323
+ static void free_pointer_array (reg1 POINTER_ARRAY * pa )
328
324
{
329
325
if (pa -> typelib .count )
330
326
{
@@ -382,9 +378,9 @@ static void or_bits(REP_SET *to,REP_SET *from);
382
378
static void copy_bits (REP_SET * to ,REP_SET * from );
383
379
static int cmp_bits (REP_SET * set1 ,REP_SET * set2 );
384
380
static int get_next_bit (REP_SET * set ,uint lastpos );
385
- static int find_set (REP_SETS * sets ,REP_SET * find );
386
- static int find_found (FOUND_SET * found_set ,uint table_offset ,
387
- int found_offset );
381
+ static short find_set (REP_SETS * sets ,REP_SET * find );
382
+ static short find_found (FOUND_SET * found_set ,uint table_offset ,
383
+ int found_offset );
388
384
static uint start_at_word (my_string pos );
389
385
static uint end_of_word (my_string pos );
390
386
static uint replace_len (my_string pos );
@@ -394,11 +390,12 @@ static uint found_sets=0;
394
390
395
391
/* Init a replace structure for further calls */
396
392
397
- REPLACE * init_replace (my_string * from , my_string * to ,uint count ,
398
- my_string word_end_chars )
393
+ static REPLACE * init_replace (my_string * from , my_string * to ,uint count ,
394
+ my_string word_end_chars )
399
395
{
400
396
uint i ,j ,states ,set_nr ,len ,result_len ,max_length ,found_end ,bits_set ,bit_nr ;
401
- int used_sets ,chr ,default_state ;
397
+ int used_sets ,chr ;
398
+ short default_state ;
402
399
char used_chars [LAST_CHAR_CODE ],is_word_end [256 ];
403
400
my_string pos ,to_pos ,* to_array ;
404
401
REP_SETS sets ;
@@ -561,7 +558,7 @@ REPLACE *init_replace(my_string *from, my_string *to,uint count,
561
558
for (chr = 0 ; chr < 256 ; chr ++ )
562
559
{
563
560
if (! used_chars [chr ])
564
- set -> next [chr ]= chr ? default_state : -1 ;
561
+ set -> next [chr ]= ( short ) ( chr ? default_state : -1 ) ;
565
562
else
566
563
{
567
564
new_set = make_new_set (& sets );
@@ -652,7 +649,7 @@ REPLACE *init_replace(my_string *from, my_string *to,uint count,
652
649
for (i = 1 ; i <= found_sets ; i ++ )
653
650
{
654
651
pos = from [found_set [i - 1 ].table_offset ];
655
- rep_str [i ].found = !bcmp (pos ,"\\^" ,3 ) ? 2 : 1 ;
652
+ rep_str [i ].found = ( my_bool ) ( !bcmp (pos ,"\\^" ,3 ) ? 2 : 1 ) ;
656
653
rep_str [i ].replace_string = to_array [found_set [i - 1 ].table_offset ];
657
654
rep_str [i ].to_offset = found_set [i - 1 ].found_offset - start_at_word (pos );
658
655
rep_str [i ].from_offset = found_set [i - 1 ].found_offset - replace_len (pos )+
@@ -812,38 +809,41 @@ static int get_next_bit(REP_SET *set,uint lastpos)
812
809
free given set, else put in given set in sets and return it's
813
810
position */
814
811
815
- static int find_set (REP_SETS * sets ,REP_SET * find )
812
+ static short find_set (REP_SETS * sets ,REP_SET * find )
816
813
{
817
814
uint i ;
818
815
for (i = 0 ; i < sets -> count - 1 ; i ++ )
819
816
{
820
817
if (!cmp_bits (sets -> set + i ,find ))
821
818
{
822
819
free_last_set (sets );
823
- return i ;
820
+ return ( short ) i ;
824
821
}
825
822
}
826
- return i ; /* return new postion */
823
+ return ( short ) i ; /* return new postion */
827
824
}
828
825
829
- /* find if there is a found_set with same table_offset & found_offset
830
- If there is return offset to it, else add new offset and return pos.
831
- Pos returned is -offset-2 in found_set_structure because it's is
832
- saved in set->next and set->next[] >= 0 points to next set and
833
- set->next[] == -1 is reserved for end without replaces.
834
- */
835
826
836
- static int find_found (FOUND_SET * found_set ,uint table_offset , int found_offset )
827
+ /*
828
+ find if there is a found_set with same table_offset & found_offset
829
+ If there is return offset to it, else add new offset and return pos.
830
+ Pos returned is -offset-2 in found_set_structure because it's is
831
+ saved in set->next and set->next[] >= 0 points to next set and
832
+ set->next[] == -1 is reserved for end without replaces.
833
+ */
834
+
835
+ static short find_found (FOUND_SET * found_set ,uint table_offset ,
836
+ int found_offset )
837
837
{
838
838
int i ;
839
839
for (i = 0 ; (uint ) i < found_sets ; i ++ )
840
840
if (found_set [i ].table_offset == table_offset &&
841
841
found_set [i ].found_offset == found_offset )
842
- return - i - 2 ;
842
+ return ( short ) ( - i - 2 ) ;
843
843
found_set [i ].table_offset = table_offset ;
844
844
found_set [i ].found_offset = found_offset ;
845
845
found_sets ++ ;
846
- return - i - 2 ; /* return new postion */
846
+ return ( short ) ( - i - 2 ); /* return new postion */
847
847
}
848
848
849
849
/* Return 1 if regexp starts with \b or ends with \b*/
@@ -878,7 +878,8 @@ static uint replace_len(my_string str)
878
878
879
879
/* The actual loop */
880
880
881
- uint replace_strings (REPLACE * rep , my_string * start ,uint * max_length , my_string from )
881
+ static uint replace_strings (REPLACE * rep , my_string * start ,uint * max_length ,
882
+ my_string from )
882
883
{
883
884
reg1 REPLACE * rep_pos ;
884
885
reg2 REPLACE_STRING * rep_str ;
0 commit comments