Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pike
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
Container Registry
Model registry
Operate
Environments
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
pikelang
pike
Commits
a294ff7c
Commit
a294ff7c
authored
26 years ago
by
Henrik (Grubba) Grubbström
Browse files
Options
Downloads
Patches
Plain Diff
o_cast() array to string now knows about wide strings.
Rev: src/opcodes.c:1.31
parent
99761fc5
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/opcodes.c
+48
-9
48 additions, 9 deletions
src/opcodes.c
with
48 additions
and
9 deletions
src/opcodes.c
+
48
−
9
View file @
a294ff7c
...
@@ -22,7 +22,7 @@
...
@@ -22,7 +22,7 @@
#include
"builtin_functions.h"
#include
"builtin_functions.h"
#include
"module_support.h"
#include
"module_support.h"
RCSID
(
"$Id: opcodes.c,v 1.3
0
1998/10/09
17:56:32 h
ubb
e
Exp $"
);
RCSID
(
"$Id: opcodes.c,v 1.3
1
1998/10/09
23:33:39 gr
ubb
a
Exp $"
);
void
index_no_free
(
struct
svalue
*
to
,
struct
svalue
*
what
,
struct
svalue
*
ind
)
void
index_no_free
(
struct
svalue
*
to
,
struct
svalue
*
what
,
struct
svalue
*
ind
)
{
{
...
@@ -211,21 +211,60 @@ void o_cast(struct pike_string *type, INT32 run_time_type)
...
@@ -211,21 +211,60 @@ void o_cast(struct pike_string *type, INT32 run_time_type)
int
i
;
int
i
;
struct
array
*
a
=
sp
[
-
1
].
u
.
array
;
struct
array
*
a
=
sp
[
-
1
].
u
.
array
;
struct
pike_string
*
s
;
struct
pike_string
*
s
;
int
shift
=
0
;
for
(
i
=
a
->
size
;
i
--
;
)
{
for
(
i
=
a
->
size
;
i
--
;
)
{
unsigned
INT32
val
;
if
(
a
->
item
[
i
].
type
!=
T_INT
)
{
if
(
a
->
item
[
i
].
type
!=
T_INT
)
{
error
(
"cast: Item %d is not an integer.
\n
"
,
i
);
error
(
"cast: Item %d is not an integer.
\n
"
,
i
);
}
}
if
((
a
->
item
[
i
].
u
.
integer
<
0
)
||
val
=
(
unsigned
INT32
)
a
->
item
[
i
].
u
.
integer
;
(
a
->
item
[
i
].
u
.
integer
>
255
))
{
if
(
val
>
0xff
)
{
error
(
"cast: Wide strings are not supported yet.
\n
"
shift
=
1
;
"Index %d is %d, and is out of range 0 .. 255.
\n
"
,
if
(
val
>
0xffff
)
{
i
,
a
->
item
[
i
].
u
.
integer
);
shift
=
2
;
break
;
}
while
(
i
--
)
{
if
(
a
->
item
[
i
].
type
!=
T_INT
)
{
error
(
"cast: Item %d is not an integer.
\n
"
,
i
);
}
val
=
(
unsigned
INT32
)
a
->
item
[
i
].
u
.
integer
;
if
(
val
>
0xffff
)
{
shift
=
2
;
break
;
}
}
break
;
}
}
}
}
s
=
begin_shared_string
(
a
->
size
);
s
=
begin_wide_shared_string
(
a
->
size
,
shift
);
for
(
i
=
a
->
size
;
i
--
;
)
{
switch
(
shift
)
{
s
->
str
[
i
]
=
a
->
item
[
i
].
u
.
integer
;
case
0
:
for
(
i
=
a
->
size
;
i
--
;
)
{
s
->
str
[
i
]
=
a
->
item
[
i
].
u
.
integer
;
}
break
;
case
1
:
{
p_wchar1
*
str1
=
STR1
(
s
);
for
(
i
=
a
->
size
;
i
--
;
)
{
str1
[
i
]
=
a
->
item
[
i
].
u
.
integer
;
}
}
break
;
case
2
:
{
p_wchar2
*
str2
=
STR2
(
s
);
for
(
i
=
a
->
size
;
i
--
;
)
{
str2
[
i
]
=
a
->
item
[
i
].
u
.
integer
;
}
}
break
;
default:
free_string
(
end_shared_string
(
s
));
fatal
(
"cast: Bad shift: %d.
\n
"
,
shift
);
break
;
}
}
s
=
end_shared_string
(
s
);
s
=
end_shared_string
(
s
);
pop_stack
();
pop_stack
();
...
...
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