Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
4
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
STklos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Erick
STklos
Commits
a4e60822
Commit
a4e60822
authored
May 05, 2011
by
Erick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed the internal representation of strings to support multibytes strings
No real support for now
parent
6d197cc6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
12 deletions
+17
-12
src/stklos.h
src/stklos.h
+7
-5
src/str.c
src/str.c
+10
-7
No files found.
src/stklos.h
View file @
a4e60822
...
...
@@ -21,7 +21,7 @@
*
* Author: Erick Gallesio [eg@unice.fr]
* Creation date: 28-Dec-1999 22:58 (eg)
* Last file update:
1-May-2011 22:29
(eg)
* Last file update:
5-May-2011 17:56
(eg)
*/
...
...
@@ -1154,18 +1154,20 @@ int STk_init_socket(void);
*/
struct
string_obj
{
stk_header
header
;
int
size
;
char
chars
[
1
];
/* will be sized to a different value when allocated */
int
space
;
/* allocated size */
int
size
;
/* # of bytes used */
int
length
;
/* "external" length of the string */
char
*
chars
;
};
#define STRING_SPACE(p) (((struct string_obj *) (p))->space)
#define STRING_SIZE(p) (((struct string_obj *) (p))->size)
#define STRING_LENGTH(p) (((struct string_obj *) (p))->length)
#define STRING_CHARS(p) (((struct string_obj *) (p))->chars)
#define STRINGP(p) (BOXED_TYPE_EQ((p), tc_string))
#define STRING_CONST (1 << 0)
#define BOX_CSTRING(s) STk_makestring(strlen(s), (s))
SCM
STk_makestring
(
int
len
,
char
*
init
);
SCM
STk_Cstring2string
(
char
*
str
);
/* Embed a C string in Scheme world */
...
...
src/str.c
View file @
a4e60822
...
...
@@ -22,7 +22,7 @@
*
* Author: Erick Gallesio [eg@unice.fr]
* Creation date: ??????
* Last file update: 5-May-2011 1
5:55
(eg)
* Last file update: 5-May-2011 1
8:00
(eg)
*/
#include <ctype.h>
...
...
@@ -133,8 +133,9 @@ SCM STk_makestring(int len, char *init)
{
register
SCM
z
;
NEWCELL_ATOMIC
(
z
,
string
,
sizeof
(
struct
string_obj
)
+
len
);
STRING_SIZE
(
z
)
=
len
;
NEWCELL
(
z
,
string
);
STRING_CHARS
(
z
)
=
STk_must_malloc_atomic
(
len
+
1
);
STRING_SPACE
(
z
)
=
STRING_SIZE
(
z
)
=
STRING_LENGTH
(
z
)
=
len
;
if
(
init
)
memcpy
(
STRING_CHARS
(
z
),
init
,
(
size_t
)
len
);
STRING_CHARS
(
z
)[
len
]
=
'\0'
;
/* so that STRING_CHARS is compatible with C */
...
...
@@ -147,8 +148,9 @@ SCM STk_Cstring2string(char *str) /* Embed a C string in Scheme world */
SCM
z
;
size_t
len
=
strlen
(
str
);
NEWCELL_ATOMIC
(
z
,
string
,
sizeof
(
struct
string_obj
)
+
len
);
STRING_SIZE
(
z
)
=
len
;
NEWCELL
(
z
,
string
);
STRING_CHARS
(
z
)
=
STk_must_malloc_atomic
(
len
+
1
);
STRING_SPACE
(
z
)
=
STRING_SIZE
(
z
)
=
STRING_LENGTH
(
z
)
=
len
;
strcpy
(
STRING_CHARS
(
z
),
str
);
return
z
;
...
...
@@ -159,8 +161,9 @@ SCM STk_chars2string(char *str, size_t len)
{
SCM
z
;
NEWCELL_ATOMIC
(
z
,
string
,
sizeof
(
struct
string_obj
)
+
len
);
STRING_SIZE
(
z
)
=
len
;
NEWCELL
(
z
,
string
);
STRING_CHARS
(
z
)
=
STk_must_malloc_atomic
(
len
+
1
);
STRING_SPACE
(
z
)
=
STRING_SIZE
(
z
)
=
STRING_LENGTH
(
z
)
=
len
;
memcpy
(
STRING_CHARS
(
z
),
str
,
len
);
STRING_CHARS
(
z
)[
len
]
=
'\0'
;
/* so that STRING_CHARS is compatible with C */
return
z
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment