@@ -277,21 +277,21 @@ int edfopen_file_readonly(const char *path, struct edf_hdr_struct *edfhdr, int r
277
277
return -1 ;
278
278
}
279
279
280
- if (check_file_size < 0 )
281
- {
282
- edfhdr -> filetype = EDFLIB_INVALID_CHECK_SIZE_VALUE ;
280
+ if (check_file_size < 0 )
281
+ {
282
+ edfhdr -> filetype = EDFLIB_INVALID_CHECK_SIZE_VALUE ;
283
283
284
284
285
- return -1 ;
286
- }
285
+ return -1 ;
286
+ }
287
287
288
- if (check_file_size > 2 )
289
- {
290
- edfhdr -> filetype = EDFLIB_INVALID_CHECK_SIZE_VALUE ;
288
+ if (check_file_size > 2 )
289
+ {
290
+ edfhdr -> filetype = EDFLIB_INVALID_CHECK_SIZE_VALUE ;
291
291
292
292
return -1 ;
293
293
}
294
-
294
+
295
295
memset (edfhdr , 0 , sizeof (struct edf_hdr_struct ));
296
296
297
297
if (edf_files_open >=EDFLIB_MAXFILES )
@@ -329,7 +329,7 @@ int edfopen_file_readonly(const char *path, struct edf_hdr_struct *edfhdr, int r
329
329
fclose (file );
330
330
edflib_repair_file_size (path , hdr );
331
331
free (hdr -> edfparam );
332
- free (hdr );
332
+ free (hdr );
333
333
file = fopeno (path , "rb" );
334
334
hdr = edflib_check_edf_file (file , & edf_error , EDFLIB_CHECK_FILE_SIZE );
335
335
}
@@ -2622,7 +2622,7 @@ static struct edfhdrblock * edflib_check_edf_file(FILE *inputfile, int *edf_erro
2622
2622
edfhdr -> hdrsize = edfhdr -> edfsignals * 256 + 256 ;
2623
2623
2624
2624
if (check_file_size != EDFLIB_DO_NOT_CHECK_FILE_SIZE )
2625
- {
2625
+ {
2626
2626
fseeko (inputfile , 0LL , SEEK_END );
2627
2627
if (ftello (inputfile )< (edfhdr -> recordsize * edfhdr -> datarecords + edfhdr -> hdrsize ))
2628
2628
{
@@ -2834,7 +2834,7 @@ static long long edflib_get_long_duration(char *str)
2834
2834
}
2835
2835
str [7 ] = ' ' ;
2836
2836
}
2837
-
2837
+
2838
2838
for (i = 0 ; i < 8 ; i ++ )
2839
2839
{
2840
2840
if (str [i ]== ' ' )
@@ -3789,24 +3789,24 @@ int edfopen_file_writeonly(const char *path, int filetype, int number_of_signals
3789
3789
{
3790
3790
hdr -> edf = 1 ;
3791
3791
hdr -> edfplus = 1 ;
3792
- hdr -> nr_annot_chns = 1 ;
3793
-
3792
+ hdr -> nr_annot_chns = 1 ;
3793
+
3794
3794
}
3795
-
3795
+
3796
3796
if (filetype == EDFLIB_FILETYPE_EDF )
3797
3797
{
3798
3798
hdr -> edf = 1 ;
3799
3799
hdr -> edfplus = 0 ;
3800
3800
hdr -> nr_annot_chns = 0 ;
3801
3801
}
3802
-
3802
+
3803
3803
if (filetype == EDFLIB_FILETYPE_BDFPLUS )
3804
3804
{
3805
3805
hdr -> bdf = 1 ;
3806
3806
hdr -> bdfplus = 1 ;
3807
- hdr -> nr_annot_chns = 1 ;
3807
+ hdr -> nr_annot_chns = 1 ;
3808
3808
}
3809
-
3809
+
3810
3810
if (filetype == EDFLIB_FILETYPE_BDF )
3811
3811
{
3812
3812
hdr -> bdf = 1 ;
@@ -5198,24 +5198,24 @@ static int edflib_write_edf_header(struct edfhdrblock *hdr)
5198
5198
{
5199
5199
return EDFLIB_NO_SAMPLES_IN_RECORD ;
5200
5200
}
5201
-
5201
+
5202
5202
if (hdr -> edfparam [i ].dig_max == hdr -> edfparam [i ].dig_min )
5203
5203
{
5204
5204
return EDFLIB_DIGMIN_IS_DIGMAX ;
5205
5205
}
5206
-
5206
+
5207
5207
if (hdr -> edfparam [i ].dig_max < hdr -> edfparam [i ].dig_min )
5208
5208
{
5209
5209
return EDFLIB_DIGMAX_LOWER_THAN_DIGMIN ;
5210
5210
}
5211
-
5211
+
5212
5212
if (hdr -> edfparam [i ].phys_max == hdr -> edfparam [i ].phys_min )
5213
5213
{
5214
5214
return EDFLIB_PHYSMIN_IS_PHYSMAX ;
5215
5215
}
5216
-
5216
+
5217
5217
hdr -> recordsize += hdr -> edfparam [i ].smp_per_record ;
5218
-
5218
+
5219
5219
}
5220
5220
if (i > 0 )
5221
5221
{
@@ -5225,7 +5225,7 @@ static int edflib_write_edf_header(struct edfhdrblock *hdr)
5225
5225
}
5226
5226
}
5227
5227
}
5228
-
5228
+
5229
5229
5230
5230
if (hdr -> edf )
5231
5231
{
@@ -5827,7 +5827,7 @@ static int edflib_write_edf_header(struct edfhdrblock *hdr)
5827
5827
{
5828
5828
fputc (' ' , file );
5829
5829
}
5830
-
5830
+
5831
5831
return 0 ;
5832
5832
}
5833
5833
@@ -7090,6 +7090,15 @@ static int edflib_snprint_number_nonlocalized(char *dest, double val, int sz)
7090
7090
7091
7091
if (sz < 1 ) return 0 ;
7092
7092
7093
+ if (val < 0.0 )
7094
+ {
7095
+ val -= 1e-12 ;
7096
+ }
7097
+ else
7098
+ {
7099
+ val += 1e-12 ;
7100
+ }
7101
+
7093
7102
q = (int )val ;
7094
7103
7095
7104
var = val - q ;
@@ -7100,7 +7109,7 @@ static int edflib_snprint_number_nonlocalized(char *dest, double val, int sz)
7100
7109
7101
7110
if (q < 0 )
7102
7111
{
7103
- q = - q ;
7112
+ base = - base ;
7104
7113
}
7105
7114
}
7106
7115
@@ -7154,7 +7163,7 @@ static int edflib_snprint_number_nonlocalized(char *dest, double val, int sz)
7154
7163
7155
7164
if (q < 0 )
7156
7165
{
7157
- q = - q ;
7166
+ base = - base ;
7158
7167
}
7159
7168
7160
7169
if (!q )
@@ -7447,31 +7456,3 @@ static int edflib_strlcat(char *dst, const char *src, int sz)
7447
7456
7448
7457
return (dstlen + srclen );
7449
7458
}
7450
-
7451
-
7452
-
7453
-
7454
-
7455
-
7456
-
7457
-
7458
-
7459
-
7460
-
7461
-
7462
-
7463
-
7464
-
7465
-
7466
-
7467
-
7468
-
7469
-
7470
-
7471
-
7472
-
7473
-
7474
-
7475
-
7476
-
7477
-
0 commit comments