projects
/
pspp-builds.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
845f878
)
str: New function ds_steal_cstr.
author
Ben Pfaff
<blp@gnu.org>
Mon, 21 Dec 2009 04:05:24 +0000
(20:05 -0800)
committer
Ben Pfaff
<blp@gnu.org>
Tue, 5 Jan 2010 05:05:50 +0000
(21:05 -0800)
src/libpspp/str.c
patch
|
blob
|
history
src/libpspp/str.h
patch
|
blob
|
history
diff --git
a/src/libpspp/str.c
b/src/libpspp/str.c
index 8243aa0690aad24a9b519db9bd1838724d32d729..79f3c912e9b649cf39d3ab9a0b37510e25867bf5 100644
(file)
--- a/
src/libpspp/str.c
+++ b/
src/libpspp/str.c
@@
-1222,6
+1222,17
@@
ds_cstr (const struct string *st_)
return st->ss.string;
}
return st->ss.string;
}
+/* Returns the value of ST as a null-terminated string and then
+ reinitialized ST as an empty string. The caller must free the
+ returned string with free(). */
+char *
+ds_steal_cstr (struct string *st)
+{
+ char *s = ds_cstr (st);
+ ds_init_empty (st);
+ return s;
+}
+
/* Reads characters from STREAM and appends them to ST, stopping
after MAX_LENGTH characters, after appending a newline, or
after an I/O error or end of file was encountered, whichever
/* Reads characters from STREAM and appends them to ST, stopping
after MAX_LENGTH characters, after appending a newline, or
after an I/O error or end of file was encountered, whichever
diff --git
a/src/libpspp/str.h
b/src/libpspp/str.h
index a134079f90dd52f7c359d7ad4fba3049c5c85203..0b57f7364e07816400b0d90f80e12376f219b821 100644
(file)
--- a/
src/libpspp/str.h
+++ b/
src/libpspp/str.h
@@
-203,6
+203,7
@@
char *ds_xstrdup (const struct string *);
size_t ds_capacity (const struct string *);
char *ds_cstr (const struct string *);
size_t ds_capacity (const struct string *);
char *ds_cstr (const struct string *);
+char *ds_steal_cstr (struct string *);
/* File input. */
bool ds_read_line (struct string *, FILE *, size_t max_length);
/* File input. */
bool ds_read_line (struct string *, FILE *, size_t max_length);