Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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
Main
Synchronet
Commits
47f34aae
Commit
47f34aae
authored
1 year ago
by
Rob Swindell
Browse files
Options
Downloads
Patches
Plain Diff
Make parse() a member function of struct atcode_format
Silly me, this is C++, do the C++ thing No functional change.
parent
c7c06373
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/sbbs3/atcodes.cpp
+59
-61
59 additions, 61 deletions
src/sbbs3/atcodes.cpp
with
59 additions
and
61 deletions
src/sbbs3/atcodes.cpp
+
59
−
61
View file @
47f34aae
...
...
@@ -47,67 +47,65 @@ struct atcode_format {
bool
thousep
=
false
;
// thousands-separated
bool
uppercase
=
false
;
bool
width_specified
=
false
;
};
static
char
*
parse_atcode_format
(
char
*
sp
,
struct
atcode_format
&
fmt
)
{
char
*
parse
(
char
*
sp
)
{
char
*
p
;
fmt
.
disp_len
=
strlen
(
sp
)
+
2
;
disp_len
=
strlen
(
sp
)
+
2
;
if
((
p
=
strchr
(
sp
,
'|'
))
!=
NULL
)
{
if
(
strchr
(
p
,
'T'
)
!=
NULL
)
fmt
.
thousep
=
true
;
thousep
=
true
;
if
(
strchr
(
p
,
'U'
)
!=
NULL
)
fmt
.
uppercase
=
true
;
uppercase
=
true
;
if
(
strchr
(
p
,
'L'
)
!=
NULL
)
fmt
.
align
=
fmt
.
left
;
align
=
left
;
else
if
(
strchr
(
p
,
'R'
)
!=
NULL
)
fmt
.
align
=
fmt
.
right
;
align
=
right
;
else
if
(
strchr
(
p
,
'C'
)
!=
NULL
)
fmt
.
align
=
fmt
.
center
;
align
=
center
;
else
if
(
strchr
(
p
,
'W'
)
!=
NULL
)
fmt
.
doubled
=
true
;
doubled
=
true
;
else
if
(
strchr
(
p
,
'Z'
)
!=
NULL
)
fmt
.
zero_padded
=
true
;
zero_padded
=
true
;
else
if
(
strchr
(
p
,
'>'
)
!=
NULL
)
fmt
.
truncated
=
false
;
truncated
=
false
;
}
else
if
(
strchr
(
sp
,
':'
)
!=
NULL
)
p
=
NULL
;
else
if
((
p
=
strstr
(
sp
,
"-L"
))
!=
NULL
)
fmt
.
align
=
fmt
.
left
;
align
=
left
;
else
if
((
p
=
strstr
(
sp
,
"-R"
))
!=
NULL
)
fmt
.
align
=
fmt
.
right
;
align
=
right
;
else
if
((
p
=
strstr
(
sp
,
"-C"
))
!=
NULL
)
fmt
.
align
=
fmt
.
center
;
align
=
center
;
else
if
((
p
=
strstr
(
sp
,
"-W"
))
!=
NULL
)
/* wide */
fmt
.
doubled
=
true
;
doubled
=
true
;
else
if
((
p
=
strstr
(
sp
,
"-Z"
))
!=
NULL
)
fmt
.
zero_padded
=
true
;
zero_padded
=
true
;
else
if
((
p
=
strstr
(
sp
,
"-T"
))
!=
NULL
)
fmt
.
thousep
=
true
;
thousep
=
true
;
else
if
((
p
=
strstr
(
sp
,
"-U"
))
!=
NULL
)
fmt
.
uppercase
=
true
;
uppercase
=
true
;
else
if
((
p
=
strstr
(
sp
,
"->"
))
!=
NULL
)
/* wrap */
fmt
.
truncated
=
false
;
truncated
=
false
;
if
(
p
!=
NULL
)
{
char
*
lp
=
p
;
lp
++
;
// skip the '|' or '-'
while
(
*
lp
==
'>'
||
IS_ALPHA
(
*
lp
))
lp
++
;
if
(
*
lp
)
fmt
.
width_specified
=
true
;
width_specified
=
true
;
while
(
*
lp
&&
!
IS_DIGIT
(
*
lp
))
lp
++
;
if
(
*
lp
&&
IS_DIGIT
(
*
lp
))
{
fmt
.
disp_len
=
atoi
(
lp
);
fmt
.
width_specified
=
true
;
disp_len
=
atoi
(
lp
);
width_specified
=
true
;
}
*
p
=
0
;
}
return
p
;
}
};
/****************************************************************************/
/* Returns 0 if invalid @ code. Returns length of @ code if valid. */
...
...
@@ -170,7 +168,7 @@ int sbbs_t::show_atcode(const char *instr, JSObject* obj)
return
len
;
}
p
=
parse
_atcode_format
(
sp
,
fmt
);
p
=
fmt
.
parse
(
sp
);
cp
=
atcode
(
sp
,
str2
,
sizeof
(
str2
),
&
pmode
,
fmt
.
align
==
fmt
.
center
,
obj
);
if
(
cp
==
NULL
)
...
...
@@ -248,7 +246,7 @@ const char* sbbs_t::formatted_atcode(const char* sp, char* str, size_t maxlen)
struct
atcode_format
fmt
;
SAFECOPY
(
tmp
,
sp
);
char
*
p
=
parse
_atcode_format
(
tmp
,
fmt
);
char
*
p
=
fmt
.
parse
(
tmp
);
const
char
*
cp
=
atcode
(
tmp
,
buf
,
sizeof
buf
);
if
(
cp
==
nullptr
)
...
...
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