Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cdo
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mpim-sw
cdo
Commits
4cada1bc
Commit
4cada1bc
authored
3 years ago
by
Uwe Schulzweida
Browse files
Options
Downloads
Patches
Plain Diff
namelist: add large file support.
parent
6f2b1868
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#8636
passed
3 years ago
Stage: build
Stage: check
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
ChangeLog
+1
-0
1 addition, 0 deletions
ChangeLog
NEWS
+1
-0
1 addition, 0 deletions
NEWS
src/namelist.cc
+9
-9
9 additions, 9 deletions
src/namelist.cc
src/namelist.h
+4
-4
4 additions, 4 deletions
src/namelist.h
with
15 additions
and
13 deletions
ChangeLog
+
1
−
0
View file @
4cada1bc
...
...
@@ -6,6 +6,7 @@
2021-06-14 Uwe Schulzweida
* namelist: add large file support
* KVListAppendNamelist: replace snprintf() my memcpy()
2021-06-13 Uwe Schulzweida
...
...
This diff is collapsed.
Click to expand it.
NEWS
+
1
−
0
View file @
4cada1bc
...
...
@@ -8,6 +8,7 @@ Version 2.0.0 (25 October 2021):
New features:
* Changed to C++14
* Expr: Add function cdeltaz(x)
* namelist: Add large file support
* outputtab: Add key x and y to print coordinates of the original grid
New operators:
* selcircle: select cells inside a circle
...
...
This diff is collapsed.
Click to expand it.
src/namelist.cc
+
9
−
9
View file @
4cada1bc
...
...
@@ -26,7 +26,7 @@ NamelistParser::allocToken()
{
if
(
this
->
toknext
>=
this
->
num_tokens
)
{
constexpr
unsigned
int
TOK_MEM_INCR
=
64
;
constexpr
unsigned
long
TOK_MEM_INCR
=
64
;
this
->
num_tokens
+=
TOK_MEM_INCR
;
this
->
tokens
.
resize
(
this
->
num_tokens
);
}
...
...
@@ -38,7 +38,7 @@ NamelistParser::allocToken()
// Fills token type and boundaries.
void
NamelistToken
::
fill
(
NamelistType
_type
,
int
_start
,
int
_end
)
NamelistToken
::
fill
(
NamelistType
_type
,
long
_start
,
long
_end
)
{
this
->
type
=
_type
;
this
->
start
=
_start
;
...
...
@@ -98,12 +98,12 @@ NamelistParser::parseString(const char *buf, size_t len, char quote)
this
->
pos
++
;
/
*
Skip starting quote
*/
/
/
Skip starting quote
for
(;
this
->
pos
<
len
&&
buf
[
this
->
pos
]
!=
'\0'
;
this
->
pos
++
)
{
const
auto
c
=
buf
[
this
->
pos
];
/
*
Quote: end of string
*/
/
/
Quote: end of string
if
(
c
==
quote
)
{
auto
token
=
this
->
allocToken
();
...
...
@@ -111,7 +111,7 @@ NamelistParser::parseString(const char *buf, size_t len, char quote)
return
NamelistError
::
UNDEFINED
;
}
/
*
Backslash: Quoted symbol expected
*/
/
/
Backslash: Quoted symbol expected
if
(
c
==
'\\'
&&
this
->
pos
+
1
<
len
)
{
this
->
pos
++
;
...
...
@@ -128,7 +128,7 @@ NamelistParser::parseString(const char *buf, size_t len, char quote)
// Allows escaped symbol \uXXXX
case
'u'
:
this
->
pos
++
;
for
(
int
i
=
0
;
i
<
4
&&
this
->
pos
<
len
&&
buf
[
this
->
pos
]
!=
'\0'
;
i
++
)
for
(
long
i
=
0
;
i
<
4
&&
this
->
pos
<
len
&&
buf
[
this
->
pos
]
!=
'\0'
;
i
++
)
{
// If it isn't a hex character we have an error
if
(
!
((
buf
[
this
->
pos
]
>=
48
&&
buf
[
this
->
pos
]
<=
57
)
||
// 0-9
...
...
@@ -161,7 +161,7 @@ NamelistParser::checkKeyname(const char *buf, NamelistToken *t)
while
(
isspace
((
int
)
buf
[
t
->
start
])
&&
t
->
start
<
t
->
end
)
t
->
start
++
;
while
(
isspace
((
int
)
buf
[
t
->
end
-
1
])
&&
t
->
start
<
t
->
end
)
t
->
end
--
;
if
((
t
->
end
-
t
->
start
)
<
1
)
return
NamelistError
::
EMKEY
;
for
(
int
i
=
t
->
start
;
i
<
t
->
end
;
++
i
)
for
(
long
i
=
t
->
start
;
i
<
t
->
end
;
++
i
)
if
(
isspace
((
int
)
buf
[
i
]))
return
NamelistError
::
INKEY
;
t
->
type
=
NamelistType
::
KEY
;
break
;
...
...
@@ -186,7 +186,7 @@ NamelistParser::parse(const char *buf, size_t len)
{
case
'&'
:
this
->
newObject
();
break
;
case
'/'
:
for
(
int
i
=
this
->
toknext
-
1
;
i
>=
0
;
i
--
)
for
(
long
i
=
this
->
toknext
-
1
;
i
>=
0
;
i
--
)
{
auto
token
=
&
this
->
tokens
[
i
];
if
(
token
->
start
!=
-
1
&&
token
->
end
==
-
1
)
...
...
@@ -236,7 +236,7 @@ NamelistParser::dump(const char *buf)
for
(
unsigned
int
it
=
0
;
it
<
ntok
;
++
it
)
{
auto
t
=
&
this
->
tokens
[
it
];
auto
length
=
t
->
end
-
t
->
start
;
int
length
=
t
->
end
-
t
->
start
;
const
auto
start
=
buf
+
t
->
start
;
printf
(
"Token %u"
,
it
+
1
);
if
(
t
->
type
==
NamelistType
::
OBJECT
)
...
...
This diff is collapsed.
Click to expand it.
src/namelist.h
+
4
−
4
View file @
4cada1bc
...
...
@@ -44,10 +44,10 @@ class NamelistToken
{
public:
NamelistType
type
;
// type (object, key, string word)
int
start
;
// start position in NAMELIST buffer
int
end
;
// end position in NAMELIST buffer
long
start
;
// start position in NAMELIST buffer
long
end
;
// end position in NAMELIST buffer
void
fill
(
NamelistType
type
,
int
start
,
int
end
);
void
fill
(
NamelistType
type
,
long
start
,
long
end
);
};
class
NamelistParser
...
...
@@ -56,7 +56,7 @@ public:
std
::
vector
<
NamelistToken
>
tokens
;
unsigned
int
num_tokens
=
0
;
unsigned
int
toknext
=
0
;
unsigned
int
pos
=
0
;
unsigned
long
pos
=
0
;
unsigned
int
lineno
=
0
;
NamelistError
parse
(
const
char
*
buf
,
size_t
len
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment