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
ddf6c810
Commit
ddf6c810
authored
10 years ago
by
deuce
Browse files
Options
Downloads
Patches
Plain Diff
More fixin' for the last commit... we need to fall-through from a soft CR
into the wrapping bits since we've added a space.
parent
cb4f5970
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/sbbs3/wordwrap.c
+47
-39
47 additions, 39 deletions
src/sbbs3/wordwrap.c
with
47 additions
and
39 deletions
src/sbbs3/wordwrap.c
+
47
−
39
View file @
ddf6c810
...
...
@@ -274,6 +274,40 @@ char* wordwrap(char* inbuf, int len, int oldlen, BOOL handle_quotes)
case
'\r'
:
crcount
++
;
break
;
case
'\x1f'
:
/* Delete... meaningless... strip. */
break
;
case
'\b'
:
/* Backspace... handle if possible, but don't go crazy. */
if
(
l
>
0
)
{
if
(
l
>
1
&&
linebuf
[
l
-
2
]
==
'\x01'
)
{
if
(
linebuf
[
l
-
1
]
==
'\x01'
)
{
ocol
--
;
icol
--
;
}
l
-=
2
;
}
else
{
l
--
;
ocol
--
;
icol
--
;
}
}
break
;
case
'\t'
:
/* TAB */
linebuf
[
l
++
]
=
inbuf
[
i
];
/* Can't ever wrap on whitespace remember. */
icol
++
;
ocol
++
;
while
(
ocol
%
8
)
ocol
++
;
while
(
icol
%
8
)
icol
++
;
break
;
case
'\x01'
:
/* CTRL-A */
linebuf
[
l
++
]
=
inbuf
[
i
++
];
if
(
inbuf
[
i
]
!=
'\x01'
)
{
linebuf
[
l
++
]
=
inbuf
[
i
];
break
;
}
case
'\n'
:
if
(
handle_quotes
&&
(
quote_count
=
get_prefix
(
inbuf
+
i
+
1
,
&
prefix_bytes
,
&
prefix_len
,
len
*
2
+
2
))
!=
0
)
{
/* Move the input pointer offset to the last char of the prefix */
...
...
@@ -285,6 +319,7 @@ char* wordwrap(char* inbuf, int len, int oldlen, BOOL handle_quotes)
outbuf_append
(
&
outbuf
,
&
outp
,
linebuf
,
l
,
&
outbuf_size
);
l
=
0
;
ocol
=
1
;
continue
;
}
/* If there's a new prefix, it is a hardcr */
else
if
(
compare_prefix
(
prefix
,
old_prefix_bytes
,
inbuf
+
i
+
1
-
prefix_bytes
,
prefix_bytes
)
!=
0
)
{
...
...
@@ -308,6 +343,8 @@ char* wordwrap(char* inbuf, int len, int oldlen, BOOL handle_quotes)
l
=
prefix_bytes
;
ocol
=
prefix_len
+
1
;
old_prefix_bytes
=
prefix_bytes
;
icol
=
prefix_len
+
1
;
continue
;
}
else
if
(
isspace
((
unsigned
char
)
inbuf
[
i
+
1
]))
{
/* Next line starts with whitespace. This is a "hard" CR. */
linebuf
[
l
++
]
=
'\r'
;
...
...
@@ -315,6 +352,8 @@ char* wordwrap(char* inbuf, int len, int oldlen, BOOL handle_quotes)
outbuf_append
(
&
outbuf
,
&
outp
,
linebuf
,
l
,
&
outbuf_size
);
l
=
prefix_bytes
;
ocol
=
prefix_len
+
1
;
icol
=
prefix_len
+
1
;
continue
;
}
else
{
if
(
icol
<
oldlen
)
{
/* If this line is overly long, It's impossible for the next word to fit */
...
...
@@ -328,6 +367,8 @@ char* wordwrap(char* inbuf, int len, int oldlen, BOOL handle_quotes)
memcpy
(
linebuf
,
prefix
,
prefix_bytes
);
l
=
prefix_bytes
;
ocol
=
prefix_len
+
1
;
icol
=
prefix_len
+
1
;
continue
;
}
else
{
/* Not a hard CR... add space if needed */
if
(
l
<
1
||
!
isspace
((
unsigned
char
)
linebuf
[
l
-
1
]))
{
...
...
@@ -343,47 +384,14 @@ char* wordwrap(char* inbuf, int len, int oldlen, BOOL handle_quotes)
}
}
}
icol
=
prefix_len
+
1
;
break
;
case
'\x1f'
:
/* Delete... meaningless... strip. */
break
;
case
'\b'
:
/* Backspace... handle if possible, but don't go crazy. */
if
(
l
>
0
)
{
if
(
l
>
1
&&
linebuf
[
l
-
2
]
==
'\x01'
)
{
if
(
linebuf
[
l
-
1
]
==
'\x01'
)
{
ocol
--
;
icol
--
;
}
l
-=
2
;
}
else
{
l
--
;
ocol
--
;
icol
--
;
}
}
break
;
case
'\t'
:
/* TAB */
linebuf
[
l
++
]
=
inbuf
[
i
];
/* Can't ever wrap on whitespace remember. */
icol
++
;
ocol
++
;
while
(
ocol
%
8
)
/* Fall-through soft CRs for wrapping! */
default:
if
(
inbuf
[
i
]
!=
'\n'
)
{
linebuf
[
l
++
]
=
inbuf
[
i
];
ocol
++
;
while
(
icol
%
8
)
icol
++
;
break
;
case
'\x01'
:
/* CTRL-A */
linebuf
[
l
++
]
=
inbuf
[
i
++
];
if
(
inbuf
[
i
]
!=
'\x01'
)
{
linebuf
[
l
++
]
=
inbuf
[
i
];
break
;
}
default:
linebuf
[
l
++
]
=
inbuf
[
i
];
ocol
++
;
icol
++
;
if
(
ocol
>
len
&&
inbuf
[
i
+
1
]
&&
!
isspace
((
unsigned
char
)
inbuf
[
i
+
1
]))
{
/* Need to wrap here */
if
(
ocol
>
len
&&
inbuf
[
i
+
1
]
&&
!
isspace
(
inbuf
[
i
+
1
]))
{
/* Need to wrap here */
/* Find the start of the last word */
k
=
l
;
/* Original next char */
l
--
;
/* Move back to the last char */
...
...
@@ -394,7 +402,7 @@ char* wordwrap(char* inbuf, int len, int oldlen, BOOL handle_quotes)
* If it's longer than len, there's no point in trying
* to make it fit, so we can just chop it.
*/
next_len
=
(
ocol
-
1
)
-
(
l
+
1
)
+
get_word_len
(
inbuf
,
i
+
1
);
next_len
=
(
k
-
(
l
==
0
?
0
:
(
l
+
1
))
)
+
get_word_len
(
inbuf
,
i
+
1
);
if
(
next_len
>
len
)
{
/* Won't be able to wrap... may as well chop. */
l
=
k
;
while
(
l
>
1
&&
linebuf
[
l
-
2
]
==
'\x01'
&&
linebuf
[
l
-
1
]
!=
'\x01'
)
...
...
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