diff options
| author | Simon Tatham <anakin@pobox.com> | 2004-04-01 17:22:56 +0000 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 2004-04-01 17:22:56 +0000 |
| commit | 02299a79f1d552580bf7b660251f79ec7f479a23 (patch) | |
| tree | c23cc603f6acca910facef31a2b79c3794da5cab /ustring.c | |
| parent | af770784f1153b346a550363406c57b58d4c2552 (diff) | |
| download | halibut-02299a79f1d552580bf7b660251f79ec7f479a23.zip halibut-02299a79f1d552580bf7b660251f79ec7f479a23.tar.gz halibut-02299a79f1d552580bf7b660251f79ec7f479a23.tar.bz2 halibut-02299a79f1d552580bf7b660251f79ec7f479a23.tar.xz | |
Arrange a mechanism whereby each backend can be passed a filename
from its command-line option (`--text=foo.txt') and automatically
convert it into one or more notional \cfg directives. In the HTML
case this mechanism enables single-file mode as well as setting the
filename.
[originally from svn r4018]
Diffstat (limited to 'ustring.c')
| -rw-r--r-- | ustring.c | 30 |
1 files changed, 30 insertions, 0 deletions
@@ -33,6 +33,21 @@ char *ustrtoa(wchar_t *s, char *outbuf, int size) { return outbuf; } +wchar_t *ustrfroma(char *s, wchar_t *outbuf, int size) { + wchar_t *p; + if (!s) { + *outbuf = L'\0'; + return outbuf; + } + for (p = outbuf; *s && p < outbuf+size; p++,s++) + *p = *s; + if (p < outbuf+size) + *p = '\0'; + else + outbuf[size-1] = '\0'; + return outbuf; +} + char *utoa_dup(wchar_t *s) { int len; char *buf = NULL; @@ -48,6 +63,21 @@ char *utoa_dup(wchar_t *s) { return buf; } +wchar_t *ufroma_dup(char *s) { + int len; + wchar_t *buf = NULL; + + len = strlen(s) + 1; + do { + buf = resize(buf, len); + ustrfroma(s, buf, len); + len = (3 * len) / 2 + 1; /* this guarantees a strict increase */ + } while (ustrlen(buf) >= len-1); + + buf = resize(buf, ustrlen(buf)+1); + return buf; +} + int ustrlen(wchar_t *s) { int len = 0; while (*s++) len++; |