annotate th_string.h @ 80:12f1af4ffc6d

Cosmetics.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 04 May 2013 03:38:41 +0300
parents 909ae72c0763
children c9c0541bed90
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
bd61a80a6c54 Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 /*
bd61a80a6c54 Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
2 * Miscellaneous string-handling related utility-functions
bd61a80a6c54 Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
3 * Programmed and designed by Matti 'ccr' Hamalainen
66
34d58b0f2d52 Update copyrights.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
4 * (C) Copyright 2002-2012 Tecnic Software productions (TNSP)
0
bd61a80a6c54 Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
5 *
bd61a80a6c54 Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
6 * Please read file 'COPYING' for information on license and distribution.
bd61a80a6c54 Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
7 */
49
598609fb49b0 Change how "config.h" is included, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
8 #ifndef TH_STRING_H
598609fb49b0 Change how "config.h" is included, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
9 #define TH_STRING_H
0
bd61a80a6c54 Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10
bd61a80a6c54 Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
11 #ifdef __cplusplus
bd61a80a6c54 Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
12 extern "C" {
bd61a80a6c54 Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
13 #endif
bd61a80a6c54 Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
14
bd61a80a6c54 Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
15 #include "th_util.h"
bd61a80a6c54 Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
16 #include <stdlib.h>
bd61a80a6c54 Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
17 #include <ctype.h>
14
e5e6370217ef Various cleanups, additions and removals.
Matti Hamalainen <ccr@tnsp.org>
parents: 10
diff changeset
18 #include <stdarg.h>
0
bd61a80a6c54 Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
19
bd61a80a6c54 Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
20 /* Macros
bd61a80a6c54 Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
21 */
10
a25f5d22483e Updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
22 #define th_isalnum(c) isalnum((int)(unsigned char) c)
a25f5d22483e Updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
23 #define th_isalpha(c) isalpha((int)(unsigned char) c)
a25f5d22483e Updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
24 #define th_isascii(c) isascii((int)(unsigned char) c)
a25f5d22483e Updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
25 #define th_isblank(c) isblank((int)(unsigned char) c)
a25f5d22483e Updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
26 #define th_iscntrl(c) iscntrl((int)(unsigned char) c)
a25f5d22483e Updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
27 #define th_isdigit(c) isdigit((int)(unsigned char) c)
a25f5d22483e Updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
28 #define th_isgraph(c) isgraph((int)(unsigned char) c)
a25f5d22483e Updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
29 #define th_islower(c) islower((int)(unsigned char) c)
a25f5d22483e Updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
30 #define th_isprint(c) isprint((int)(unsigned char) c)
a25f5d22483e Updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
31 #define th_ispunct(c) ispunct((int)(unsigned char) c)
a25f5d22483e Updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
32 #define th_isspace(c) isspace((int)(unsigned char) c)
a25f5d22483e Updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
33 #define th_isupper(c) isupper((int)(unsigned char) c)
a25f5d22483e Updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
34 #define th_isxdigit(c) isxdigit((int)(unsigned char) c)
a25f5d22483e Updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
35 #define th_iscrlf(c) ((c=='\r')||(c=='\n'))
0
bd61a80a6c54 Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
36
10
a25f5d22483e Updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
37 #define th_isspecial(q) (((q >= 0x5b) && (q <= 0x60)) || ((q >= 0x7b) && (q <= 0x7d)))
0
bd61a80a6c54 Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
38
10
a25f5d22483e Updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
39 #define th_tolower(c) tolower((int)(unsigned char) c)
a25f5d22483e Updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
40 #define th_toupper(c) toupper((int)(unsigned char) c)
0
bd61a80a6c54 Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
41
bd61a80a6c54 Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
42
bd61a80a6c54 Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
43 /* Normal NUL-terminated string functions
bd61a80a6c54 Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
44 */
80
12f1af4ffc6d Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 79
diff changeset
45 char *th_strdup(const char *);
14
e5e6370217ef Various cleanups, additions and removals.
Matti Hamalainen <ccr@tnsp.org>
parents: 10
diff changeset
46 int th_strcasecmp(const char *, const char *);
e5e6370217ef Various cleanups, additions and removals.
Matti Hamalainen <ccr@tnsp.org>
parents: 10
diff changeset
47 int th_strncasecmp(const char *, const char *, size_t);
10
a25f5d22483e Updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
48 void th_strip_ctrlchars(char *);
0
bd61a80a6c54 Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
49
14
e5e6370217ef Various cleanups, additions and removals.
Matti Hamalainen <ccr@tnsp.org>
parents: 10
diff changeset
50 char *th_strdup_vprintf(const char *, va_list);
e5e6370217ef Various cleanups, additions and removals.
Matti Hamalainen <ccr@tnsp.org>
parents: 10
diff changeset
51 char *th_strdup_printf(const char *, ...);
e5e6370217ef Various cleanups, additions and removals.
Matti Hamalainen <ccr@tnsp.org>
parents: 10
diff changeset
52
30
10d2dc143e4b Add helper functions th_pstr_vprintf() and th_pstr_printf().
Matti Hamalainen <ccr@tnsp.org>
parents: 29
diff changeset
53 void th_pstr_vprintf(char **, const char *, va_list);
10d2dc143e4b Add helper functions th_pstr_vprintf() and th_pstr_printf().
Matti Hamalainen <ccr@tnsp.org>
parents: 29
diff changeset
54 void th_pstr_printf(char **, const char *, ...);
10d2dc143e4b Add helper functions th_pstr_vprintf() and th_pstr_printf().
Matti Hamalainen <ccr@tnsp.org>
parents: 29
diff changeset
55
14
e5e6370217ef Various cleanups, additions and removals.
Matti Hamalainen <ccr@tnsp.org>
parents: 10
diff changeset
56 int th_pstrcpy(char **, const char *);
e5e6370217ef Various cleanups, additions and removals.
Matti Hamalainen <ccr@tnsp.org>
parents: 10
diff changeset
57 int th_pstrcat(char **, const char *);
0
bd61a80a6c54 Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
58
78
2579250f2a84 Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 66
diff changeset
59 /* Parsing, matching
2579250f2a84 Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 66
diff changeset
60 */
14
e5e6370217ef Various cleanups, additions and removals.
Matti Hamalainen <ccr@tnsp.org>
parents: 10
diff changeset
61 const char *th_findnext(const char *, size_t *);
e5e6370217ef Various cleanups, additions and removals.
Matti Hamalainen <ccr@tnsp.org>
parents: 10
diff changeset
62 const char *th_findsep(const char *, size_t *, char);
e5e6370217ef Various cleanups, additions and removals.
Matti Hamalainen <ccr@tnsp.org>
parents: 10
diff changeset
63 const char *th_findseporspace(const char *, size_t *, char);
0
bd61a80a6c54 Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
64
14
e5e6370217ef Various cleanups, additions and removals.
Matti Hamalainen <ccr@tnsp.org>
parents: 10
diff changeset
65 BOOL th_strmatch(const char *, const char *);
e5e6370217ef Various cleanups, additions and removals.
Matti Hamalainen <ccr@tnsp.org>
parents: 10
diff changeset
66 BOOL th_strcasematch(const char *, const char *);
0
bd61a80a6c54 Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
67
14
e5e6370217ef Various cleanups, additions and removals.
Matti Hamalainen <ccr@tnsp.org>
parents: 10
diff changeset
68 int th_get_hex_triplet(const char *);
0
bd61a80a6c54 Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
69
78
2579250f2a84 Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 66
diff changeset
70 /* Growing string buffer
2579250f2a84 Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 66
diff changeset
71 */
35
e9a3fe655dd9 Make th_growbuf() public.
Matti Hamalainen <ccr@tnsp.org>
parents: 30
diff changeset
72 BOOL th_growbuf(char **buf, size_t *bufsize, size_t *len, size_t grow);
29
04cfdefc3253 th_vputs() and th_vputch() now return a boolean value, TRUE if operation was successful, FALSE if it failed. If result was FALSE, the buffer pointer may now be NULL.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
73 BOOL th_vputch(char **buf, size_t *bufsize, size_t *len, const char ch);
04cfdefc3253 th_vputs() and th_vputch() now return a boolean value, TRUE if operation was successful, FALSE if it failed. If result was FALSE, the buffer pointer may now be NULL.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
74 BOOL th_vputs(char **buf, size_t *bufsize, size_t *len, const char *str);
21
1f7d8693fda8 Add functions for growing a string/buffer and concatenating characters and/or other strings to it.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
75
1f7d8693fda8 Add functions for growing a string/buffer and concatenating characters and/or other strings to it.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
76 #define TH_BUFGROW (32)
1f7d8693fda8 Add functions for growing a string/buffer and concatenating characters and/or other strings to it.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
77
0
bd61a80a6c54 Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
78 #ifdef __cplusplus
bd61a80a6c54 Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
79 }
bd61a80a6c54 Initial import into Mercurial repository. Discarding old cvs/svn history
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
80 #endif
49
598609fb49b0 Change how "config.h" is included, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
81 #endif /* TH_STRING_H */