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
8aef7fea
Commit
8aef7fea
authored
19 years ago
by
deuce
Browse files
Options
Downloads
Patches
Plain Diff
Re-write make_lines() to not use regexps mildly faster now.
parent
51e213d8
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
exec/fseditor.js
+58
-43
58 additions, 43 deletions
exec/fseditor.js
with
58 additions
and
43 deletions
exec/fseditor.js
+
58
−
43
View file @
8aef7fea
...
@@ -798,55 +798,70 @@ function make_lines(str, attr, nl_is_hardcr)
...
@@ -798,55 +798,70 @@ function make_lines(str, attr, nl_is_hardcr)
}
}
}
}
while
(
str
.
length
>
0
)
{
while
(
str
.
length
>
0
)
{
var
m
=
str
.
match
(
/^
(
.
{0,79}
*
)(\n?)
/
);
var
done
=
false
;
if
(
m
!=
null
)
{
/* We have zero or more characters followed by zero or more spaces followed by zero or one \n */
nl
[
nl
.
length
]
=
new
Line
;
nl
[
nl
.
length
]
=
new
Line
;
nl
[
nl
.
length
-
1
].
text
=
m
[
1
];
while
(
str
.
length
>
0
&&
!
done
)
{
nl
[
nl
.
length
-
1
].
attr
=
attr
.
substr
(
0
,
nl
[
nl
.
length
-
1
].
text
.
length
);
switch
(
str
.
substr
(
0
,
1
))
{
str
=
str
.
substr
(
m
[
0
].
length
);
case
'
\n
'
:
attr
=
attr
.
substr
(
m
[
0
].
length
);
str
=
str
.
substr
(
1
);
if
(
nl_is_hardcr
)
{
attr
=
attr
.
substr
(
1
);
if
(
m
[
2
].
length
>
0
)
done
=
true
;
if
(
nl_is_hardcr
)
nl
[
nl
.
length
-
1
].
hardcr
=
true
;
nl
[
nl
.
length
-
1
].
hardcr
=
true
;
}
else
{
else
{
/* Deduce if this is a hard or soft CR as follows */
/* Deduce if this is a hard or soft CR as follows */
/* If the next char is a nl, or whitespace, it is hard. */
/* If the next char is a nl, or whitespace, it is hard. */
/* If there is room for the first word of the next line on this
/* If there is room for the first word of the next line on this
* line, it is hard */
* line, it is hard */
/* Otherwise, it is soft. */
/* Otherwise, it is soft. */
if
(
str
.
substr
(
0
,
1
)
==
'
'
||
str
.
substr
(
0
,
1
)
==
'
\t
'
)
/* Next line starts with whitespace - is hard */
if
(
str
.
search
(
/^
\s
/
)
!=-
1
)
nl
[
nl
.
length
-
1
].
hardcr
=
true
;
nl
[
nl
.
length
-
1
].
hardcr
=
true
;
else
{
else
{
/* Get first word of next line */
var
len
;
var
m2
=
str
.
match
(
/^
(
.*
\s)
/
);
for
(
len
=
0
;
str
.
length
>=
len
&&
str
.
substr
(
len
,
1
)
!=
'
'
&&
str
.
substr
(
len
,
1
)
!=
'
\t
'
;
len
++
);
if
(
m2
!=
null
)
{
if
(
nl
[
nl
.
length
-
1
].
text
.
length
+
len
<
80
)
if
(
m
[
1
].
length
+
m2
[
1
].
length
<
80
)
nl
[
nl
.
length
-
1
].
hardcr
=
true
;
nl
[
nl
.
length
-
1
].
hardcr
=
true
;
}
}
}
}
/* Add trailing space if needed */
break
;
if
((
!
nl
[
nl
.
length
-
1
].
hardcr
)
&&
nl
[
nl
.
length
-
1
].
text
.
search
(
/
\s
^/
)
==-
1
)
{
case
'
'
:
/* Whitespace... never wrap here. */
nl
[
nl
.
length
-
1
].
text
+=
'
'
;
case
'
\t
'
:
nl
[
nl
.
length
-
1
].
attr
+=
nl
[
nl
.
length
-
1
].
attr
.
substr
(
-
1
);
nl
[
nl
.
length
-
1
].
text
+=
str
.
substr
(
0
,
1
);
nl
[
nl
.
length
-
1
].
attr
+=
attr
.
substr
(
0
,
1
);
str
=
str
.
substr
(
1
);
attr
=
attr
.
substr
(
1
);
break
;
default
:
/* Printable char... may need to wrap */
if
(
nl
[
nl
.
length
-
1
].
text
.
length
>
79
)
{
/* Need to have wrapped */
var
offset
;
for
(
offset
=
nl
[
nl
.
length
-
1
].
text
.
length
-
1
;
offset
>=
0
;
offset
--
)
{
if
(
nl
[
nl
.
length
-
1
].
text
.
substr
(
offset
,
1
)
!=
'
'
&&
nl
[
nl
.
length
-
1
].
text
.
substr
(
offset
,
1
)
!=
'
\t
'
)
{
str
=
nl
[
nl
.
length
-
1
].
text
.
substr
(
offset
)
+
str
;
attr
=
nl
[
nl
.
length
-
1
].
attr
.
substr
(
offset
)
+
attr
;
break
;
}
}
}
}
/* If we have 79 chars in a row with no spaces and not a whitspace
if
(
offset
==-
1
)
{
* on the end, and the forst char of the next line isn't whitespace,
/* There were no spaces this line. */
* we have a kludged line */
nl
[
nl
.
length
-
1
].
text
=
str
.
substr
(
0
,
79
);
if
(
nl
[
nl
.
length
-
1
].
text
.
length
==
79
&&
nl
[
nl
.
length
-
1
].
text
.
search
(
/
\s
/
)
==-
1
&&
str
.
search
(
/^
\s
/
)
==-
1
)
nl
[
nl
.
length
-
1
].
attr
=
attr
.
substr
(
0
,
79
);
nl
[
nl
.
length
-
1
].
kludged
=
true
;
nl
[
nl
.
length
-
1
].
kludged
=
true
;
str
=
str
.
substr
(
79
);
attr
=
attr
.
substr
(
79
);
}
done
=
true
;
}
}
else
{
else
{
/* Not sure how THIS could happen */
nl
[
nl
.
length
-
1
].
text
+=
str
.
substr
(
0
,
1
);
alert
(
"
The impossible happened.
"
);
nl
[
nl
.
length
-
1
].
attr
+=
attr
.
substr
(
0
,
1
);
console
.
pause
();
str
=
str
.
substr
(
1
);
exit
();
attr
=
attr
.
substr
(
1
);
}
}
}
}
}
}
return
(
nl
);
return
(
nl
);
}
}
...
...
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