Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
blaar
blibs
blc_core
Commits
a145383a
Commit
a145383a
authored
Jul 31, 2019
by
Arnaud Blanchard
Browse files
Remove last tab in a line while writting TSV
parent
638bc75e
Changes
1
Show whitespace changes
Inline
Side-by-side
src/blc_array.cpp
View file @
a145383a
...
...
@@ -172,16 +172,16 @@ int blc_array::sprint_dims(char *string, int string_size){
width
=
snprintf
(
string
,
string_size
,
"%lu"
,
dims
[
0
].
length
);
for
(
i
=
1
;
i
<
dims_nb
;
i
++
)
width
+=
snprintf
(
string
+
width
,
string_size
-
width
,
"x%lu"
,
dims
[
i
].
length
);
}
if
(
width
>=
string_size
)
EXIT_ON_ERROR
(
"The reserved size %d is too small to store the %d dims."
,
size
,
dims_nb
);
if
(
width
>=
string_size
)
EXIT_ON_ERROR
(
"The reserved size
'
%d
'
is too small to store the
'
%d
'
dims."
,
size
,
dims_nb
);
return
width
;
}
int
blc_array
::
fprint_dims
(
FILE
*
file
)
const
{
int
i
,
width
=
0
;
int
i
,
width
;
if
(
dims_nb
==
0
)
width
+
=
fprintf
(
file
,
"0"
);
if
(
dims_nb
==
0
)
width
=
fprintf
(
file
,
"0"
);
else
{
width
+
=
fprintf
(
file
,
"%lu"
,
dims
[
0
].
length
);
width
=
fprintf
(
file
,
"%lu"
,
dims
[
0
].
length
);
for
(
i
=
1
;
i
<
dims_nb
;
i
++
)
width
+=
fprintf
(
file
,
"x%lu"
,
dims
[
i
].
length
);
}
return
width
;
...
...
@@ -189,11 +189,11 @@ int blc_array::fprint_dims(FILE *file)const {
void
blc_array
::
fscan_dims
(
FILE
*
file
){
blc_dim
*
dim
;
in
t
length
;
size_
t
length
;
size
=
get_type_size
();
FSCANF
(
1
,
file
,
"%
d
"
,
&
length
);
FSCANF
(
1
,
file
,
"%
lu
"
,
&
length
);
if
(
dims
)
FREE
(
dims
);
dims_nb
=
0
;
...
...
@@ -203,7 +203,7 @@ void blc_array::fscan_dims(FILE *file){
dim
->
length
=
length
;
dim
->
step
=
size
;
size
*=
dim
->
length
;
}
while
(
fscanf
(
file
,
"x%
d
"
,
&
length
)
==
1
);
}
while
(
fscanf
(
file
,
"x%
lu
"
,
&
length
)
==
1
);
}
total_length
=
size
/
get_type_size
();
}
...
...
@@ -211,11 +211,11 @@ void blc_array::fscan_dims(FILE *file){
int
blc_array
::
sscan_dims
(
char
const
*
string
){
blc_dim
*
dim
;
int
pos
,
total_pos
;
in
t
length
;
size_
t
length
;
size
=
get_type_size
();
SSCANF
(
1
,
string
,
"%
d
%n"
,
&
length
,
&
pos
);
SSCANF
(
1
,
string
,
"%
lu
%n"
,
&
length
,
&
pos
);
total_pos
=
0
;
dims_nb
=
0
;
if
(
dims
)
FREE
(
dims
);
...
...
@@ -297,7 +297,7 @@ void blc_array::fscan_properties(FILE *file){
//is it usefull ??
/*
size_t blc_array::get_minimum_size(){
size_t blc_array::get_minimum_size(){
blc_dim *dim;
size_t size = get_type_size();
...
...
@@ -306,7 +306,7 @@ size_t blc_array::get_minimum_size(){
size*=dim->length;
}
return size;
}*/
}*/
void
blc_array
::
fprint_debug
(
FILE
*
file
)
const
{
uint32_t
type_str
,
format_str
;
...
...
@@ -409,32 +409,46 @@ void blc_array::fprint_tsv(FILE *file){
else
FOR
(
i
,
length
)
fprintf
(
file
,
"%4d
\n
t"
,
chars
[
i
+
j
]);
break
;
case
'
UIN8
'
:
FOR
(
i
,
length
)
fprintf
(
file
,
"%3u
\t
"
,
uchars
[
i
+
j
]);
FOR
(
i
,
length
){
fprintf
(
file
,
"%3u"
,
uchars
[
i
+
j
]);
if
(
i
!=
length
-
1
)
fputc
(
'\t'
,
file
);
}
break
;
case
'
IN16
'
:
FOR
(
i
,
length
)
fprintf
(
file
,
"%6d
\t
"
,
ints16
[
i
+
j
]);
FOR
(
i
,
length
){
fprintf
(
file
,
"%6d"
,
ints16
[
i
+
j
]);
if
(
i
!=
length
-
1
)
fputc
(
'\t'
,
file
);
}
break
;
case
'
UI16
'
:
FOR
(
i
,
length
)
fprintf
(
file
,
"%5u
\t
"
,
uints16
[
i
+
j
]);
FOR
(
i
,
length
){
fprintf
(
file
,
"%5u"
,
uints16
[
i
+
j
]);
if
(
i
!=
length
-
1
)
fputc
(
'\t'
,
file
);
}
break
;
case
'
IN32
'
:
FOR
(
i
,
length
)
fprintf
(
file
,
"%d
\t
"
,
uints32
[
i
+
j
]);
FOR
(
i
,
length
){
fprintf
(
file
,
"%d"
,
uints32
[
i
+
j
]);
if
(
i
!=
length
-
1
)
fputc
(
'\t'
,
file
);
}
break
;
case
'
UI32
'
:
FOR
(
i
,
length
)
fprintf
(
file
,
"%u
\t
"
,
uints32
[
i
+
j
]);
FOR
(
i
,
length
){
fprintf
(
file
,
"%u"
,
uints32
[
i
+
j
]);
if
(
i
!=
length
-
1
)
fputc
(
'\t'
,
file
);
}
break
;
case
'
FL32
'
:
FOR
(
i
,
length
)
fprintf
(
file
,
"%f
\t
"
,
floats
[
i
+
j
]);
FOR
(
i
,
length
){
fprintf
(
file
,
"%f"
,
floats
[
i
+
j
]);
if
(
i
!=
length
-
1
)
fputc
(
'\t'
,
file
);
}
break
;
case
'
FL64
'
:
FOR
(
i
,
length
)
fprintf
(
file
,
"%lf
\t
"
,
doubles
[
i
+
j
]);
FOR
(
i
,
length
){
fprintf
(
file
,
"%lf"
,
doubles
[
i
+
j
]);
if
(
i
!=
length
-
1
)
fputc
(
'\t'
,
file
);
}
break
;
default:
EXIT_ON_ARRAY_ERROR
(
this
,
"You cannot display type: '%.4s'"
,
UINT32_TO_STRING
(
type_str
,
type
));
...
...
@@ -453,7 +467,7 @@ void blc_array::fprint_tsv(FILE *file){
}
else
dim
--
;
if
(
dim
==
dims_nb
-
2
)
fprintf
(
file
,
"
\n
"
);
if
(
dim
==
dims_nb
-
2
)
fprintf
(
file
,
"
\n
"
);
else
fprintf
(
file
,
"
\t
"
);
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment