@@ -74,8 +74,12 @@ namespace io{
74
74
}
75
75
76
76
void set_file_name (const char *file_name){
77
- std::strncpy (this ->file_name , file_name, max_file_name_length);
78
- this ->file_name [max_file_name_length] = ' \0 ' ;
77
+ if (file_name != nullptr ){
78
+ strncpy (this ->file_name , file_name, error::max_file_name_length);
79
+ this ->file_name [error::max_file_name_length] = ' \0 ' ;
80
+ }else {
81
+ this ->file_name [0 ] = ' \0 ' ;
82
+ }
79
83
}
80
84
81
85
char file_name[max_file_name_length+1 ];
@@ -417,8 +421,12 @@ namespace io{
417
421
}
418
422
419
423
void set_file_name (const char *file_name){
420
- strncpy (this ->file_name , file_name, error::max_file_name_length);
421
- this ->file_name [error::max_file_name_length] = ' \0 ' ;
424
+ if (file_name != nullptr ){
425
+ strncpy (this ->file_name , file_name, error::max_file_name_length);
426
+ this ->file_name [error::max_file_name_length] = ' \0 ' ;
427
+ }else {
428
+ this ->file_name [0 ] = ' \0 ' ;
429
+ }
422
430
}
423
431
424
432
const char *get_truncated_file_name ()const {
@@ -498,8 +506,12 @@ namespace io{
498
506
}
499
507
500
508
void set_column_name (const char *column_name){
501
- std::strncpy (this ->column_name , column_name, max_column_name_length);
502
- this ->column_name [max_column_name_length] = ' \0 ' ;
509
+ if (column_name != nullptr ){
510
+ std::strncpy (this ->column_name , column_name, max_column_name_length);
511
+ this ->column_name [max_column_name_length] = ' \0 ' ;
512
+ }else {
513
+ this ->column_name [0 ] = ' \0 ' ;
514
+ }
503
515
}
504
516
505
517
char column_name[max_column_name_length+1 ];
@@ -514,8 +526,12 @@ namespace io{
514
526
}
515
527
516
528
void set_column_content (const char *column_content){
517
- std::strncpy (this ->column_content , column_content, max_column_content_length);
518
- this ->column_content [max_column_content_length] = ' \0 ' ;
529
+ if (column_content != nullptr ){
530
+ std::strncpy (this ->column_content , column_content, max_column_content_length);
531
+ this ->column_content [max_column_content_length] = ' \0 ' ;
532
+ }else {
533
+ this ->column_content [0 ] = ' \0 ' ;
534
+ }
519
535
}
520
536
521
537
char column_content[max_column_content_length+1 ];
@@ -683,9 +699,9 @@ namespace io{
683
699
684
700
public:
685
701
static void trim (char *&str_begin, char *&str_end){
686
- while (is_trim_char (*str_begin, trim_char_list...) && str_begin != str_end )
702
+ while (str_begin != str_end && is_trim_char (*str_begin, trim_char_list...))
687
703
++str_begin;
688
- while (is_trim_char (*(str_end-1 ), trim_char_list...) && str_begin != str_end )
704
+ while (str_begin != str_end && is_trim_char (*(str_end-1 ), trim_char_list...))
689
705
--str_end;
690
706
*str_end = ' \0 ' ;
691
707
}
0 commit comments