6363#include < locale.h>
6464#endif
6565
66- static const int mode_read = O_RDONLY;
67- static const int mode_write = O_WRONLY | O_CREAT;
68- static const int mask = 0666 ;
66+ static constexpr int mode_read = O_RDONLY;
67+ static constexpr int mode_write = O_WRONLY | O_CREAT;
68+ static constexpr int mask = 0666 ;
6969
7070static DESC open_platf (const char * name, int writeFlag)
7171{
@@ -123,7 +123,7 @@ enum gsplit_option
123123};
124124
125125
126- const static Switches::in_sw_tab_t spit_in_sw_table[] =
126+ constexpr static Switches::in_sw_tab_t spit_in_sw_table[] =
127127{
128128 {IN_SW_SPIT_SP, 0 , " SPLIT_BK_FILE" , 0 , 0 , 0 , false , 0 , 0 , 0 },
129129 {IN_SW_SPIT_JT, 0 , " JOIN_BK_FILE" , 0 , 0 , 0 , false , 0 , 0 , 0 },
@@ -145,8 +145,8 @@ struct header_rec
145145 TEXT fl_name[MAX_FILE_NM_LEN];
146146};
147147
148- const size_t header_rec_len = sizeof (header_rec);
149- static const char * const header_rec_name = " InterBase/gsplit, " ;
148+ constexpr size_t header_rec_len = sizeof (header_rec);
149+ static constexpr const char * header_rec_name = " InterBase/gsplit, " ;
150150
151151
152152// backup files structure
@@ -159,12 +159,12 @@ struct b_fil
159159 SINT64 b_fil_size;
160160};
161161
162- const size_t b_fil_len = sizeof (b_fil);
162+ constexpr size_t b_fil_len = sizeof (b_fil);
163163
164164
165165// local function declarations
166166
167- static int conv_ntoc (SLONG, TEXT*);
167+ static int conv_ntoc (SLONG, TEXT*) noexcept ;
168168static int free_file_list (b_fil*);
169169static int final_flush_io_buff (const UCHAR*, SLONG, FILE_DESC);
170170static int final_read_and_write (FILE_DESC, FILE_DESC, const TEXT*, SLONG, UCHAR**, bool *);
@@ -173,8 +173,8 @@ static int get_file_name(const SCHAR*, SINT64, b_fil**);
173173static int get_file_size (const SCHAR*, const SCHAR*, SINT64*);
174174static int get_function_option (const SCHAR*, gsplit_option*, const SCHAR*, const Switches&);
175175static int gen_multy_bakup_files (b_fil*, FILE_DESC, SLONG);
176- static int set_hdr_str (TEXT*, const TEXT*, SLONG, SLONG);
177- static int join_multy_bakup_files (b_fil*);
176+ static int set_hdr_str (TEXT*, const TEXT*, SLONG, SLONG) noexcept ;
177+ static int join_multy_bakup_files (const b_fil*);
178178static void print_clo (const TEXT*);
179179static int read_and_write (FILE_DESC, FILE_DESC, /* const TEXT*,*/ SLONG,
180180 SINT64, UCHAR**, bool *, SINT64*, SLONG*);
@@ -605,7 +605,7 @@ static int gen_multy_bakup_files(b_fil* file_list, FILE_DESC input_file_desc, SL
605605 hdr_rec.name [indx] = BLANK;
606606
607607 pos = pos + sizeof (hdr_rec.name );
608- time_t clock = time (0 ); // was SLONG
608+ const time_t clock = time (0 ); // was SLONG
609609 ret_cd = set_hdr_str (header_str, ctime (&clock), pos, sizeof (hdr_rec.date_time ));
610610 for (indx = 0 ; indx < sizeof (hdr_rec.date_time ); indx++)
611611 hdr_rec.date_time [indx] = BLANK;
@@ -953,7 +953,7 @@ static int final_read_and_write(FILE_DESC input_file_desc,
953953}
954954
955955
956- static int join_multy_bakup_files ( b_fil* file_list)
956+ static int join_multy_bakup_files (const b_fil* file_list)
957957{
958958/* *******************************************************************
959959**
@@ -994,15 +994,15 @@ static int join_multy_bakup_files( b_fil* file_list)
994994 next_fl = fl_ptr->b_fil_next ;
995995 const TEXT* file_name = fl_ptr->b_fil_name ;
996996
997- SLONG ret_cd = read_and_write_for_join (output_fl_desc, file_name, io_buffer, cnt, &total_int);
997+ const SLONG ret_cd = read_and_write_for_join (output_fl_desc, file_name, io_buffer, cnt, &total_int);
998998
999999 if (ret_cd == FB_FAILURE)
10001000 {
10011001 free (io_buffer);
10021002 return FB_FAILURE;
10031003 }
10041004
1005- } // end of for loop
1005+ }
10061006
10071007 free (io_buffer);
10081008 return FB_SUCCESS;
@@ -1050,7 +1050,7 @@ static int read_and_write_for_join(FILE_DESC output_fl_desc,
10501050 }
10511051
10521052 const TEXT* char_ptr1 = reinterpret_cast <char *>(io_buffer);
1053- SLONG ret_cd = strncmp (char_ptr1, header_rec_name, sizeof (hdr_rec.name ) - 1 );
1053+ const SLONG ret_cd = strncmp (char_ptr1, header_rec_name, sizeof (hdr_rec.name ) - 1 );
10541054 if (ret_cd != 0 )
10551055 {
10561056 close_platf (input_fl_desc);
@@ -1059,8 +1059,8 @@ static int read_and_write_for_join(FILE_DESC output_fl_desc,
10591059 return FB_FAILURE;
10601060 }
10611061
1062- const SLONG skip_to_num = sizeof (hdr_rec.name ) + sizeof (hdr_rec.date_time ) + sizeof (hdr_rec.text1 );
1063- const SLONG skip_to_total = skip_to_num + sizeof (hdr_rec.num ) + sizeof (hdr_rec.text2 );
1062+ constexpr SLONG skip_to_num = sizeof (hdr_rec.name ) + sizeof (hdr_rec.date_time ) + sizeof (hdr_rec.text1 );
1063+ constexpr SLONG skip_to_total = skip_to_num + sizeof (hdr_rec.num ) + sizeof (hdr_rec.text2 );
10641064
10651065 char_ptr1 = reinterpret_cast <char *>(io_buffer + skip_to_num);
10661066 const TEXT* char_ptr2 = reinterpret_cast <char *>(io_buffer + skip_to_total);
@@ -1110,7 +1110,7 @@ static int read_and_write_for_join(FILE_DESC output_fl_desc,
11101110 break ;
11111111 }
11121112
1113- SLONG write_cnt = write_platf (output_fl_desc, io_buffer, read_cnt);
1113+ const SLONG write_cnt = write_platf (output_fl_desc, io_buffer, read_cnt);
11141114
11151115 switch (write_cnt)
11161116 {
@@ -1129,7 +1129,7 @@ static int read_and_write_for_join(FILE_DESC output_fl_desc,
11291129}
11301130
11311131
1132- static int conv_ntoc ( SLONG numeric_in, TEXT char_out[])
1132+ static int conv_ntoc (SLONG numeric_in, TEXT char_out[]) noexcept
11331133{
11341134/* *******************************************************************
11351135**
@@ -1209,7 +1209,7 @@ static int write_header(const b_fil* fl_ptr,
12091209 ret_cd = set_hdr_str (header_str, file_name, pos, static_cast <SLONG>(strlen (file_name)));
12101210
12111211 SLONG end, indx;
1212- SLONG write_cnt = write_platf (output_fl_desc, header_str, header_rec_len);
1212+ const SLONG write_cnt = write_platf (output_fl_desc, header_str, header_rec_len);
12131213 switch (write_cnt)
12141214 {
12151215 case -1 : // write failed
@@ -1304,7 +1304,7 @@ static int final_flush_io_buff(const UCHAR* remaining_io,
13041304*********************************************************************
13051305*/
13061306
1307- SLONG write_cnt = write_platf (output_fl_desc, remaining_io, remaining_io_len);
1307+ const SLONG write_cnt = write_platf (output_fl_desc, remaining_io, remaining_io_len);
13081308 switch (write_cnt)
13091309 {
13101310 case -1 : // write failed
@@ -1348,7 +1348,7 @@ static void print_clo(const TEXT* prog_name)
13481348}
13491349
13501350
1351- static int set_hdr_str (TEXT header_str[], const TEXT* in_str, SLONG pos, SLONG len)
1351+ static int set_hdr_str (TEXT header_str[], const TEXT* in_str, SLONG pos, SLONG len) noexcept
13521352{
13531353/* *******************************************************************
13541354**
0 commit comments