Print this page
Address Robert's feedback
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/lib/libsysdemangle/common/sysdemangle.c
+++ new/usr/src/lib/libsysdemangle/common/sysdemangle.c
1 1 /*
2 2 * This file and its contents are supplied under the terms of the
3 3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 4 * You may only use this file in accordance with the terms of version
5 5 * 1.0 of the CDDL.
6 6 *
7 7 * A full copy of the text of the CDDL should have accompanied this
8 8 * source. A copy of the CDDL is also available via the Internet at
9 9 * http://www.illumos.org/license/CDDL.
10 10 */
11 11
12 12 /*
13 13 * Copyright 2017 Jason King
14 14 */
15 15
16 16 #include <string.h>
17 17 #include <errno.h>
18 18 #include "sysdemangle.h"
19 19 #include "sysdemangle_int.h"
20 20
21 21
22 22 static sysdem_lang_t
23 23 detect_lang(const char *str)
24 24 {
25 25 size_t n = strlen(str);
26 26
27 27 if (n < 3 || str[0] != '_')
28 28 return (SYSDEM_LANG_AUTO);
29 29
30 30 switch (str[1]) {
31 31 case 'Z':
32 32 return (SYSDEM_LANG_CPP);
33 33
34 34 case '_':
35 35 break;
36 36
37 37 default:
38 38 return (SYSDEM_LANG_AUTO);
39 39 }
40 40
41 41 /* why they use ___Z sometimes is puzzling.. *sigh* */
42 42 if (str[2] == '_' && str[3] == 'Z')
43 43 return (SYSDEM_LANG_CPP);
44 44
45 45 return (SYSDEM_LANG_AUTO);
46 46 }
47 47
↓ open down ↓ |
47 lines elided |
↑ open up ↑ |
48 48 char *
49 49 sysdemangle(const char *str, sysdem_lang_t lang, sysdem_ops_t *ops)
50 50 {
51 51
52 52 if (ops == NULL)
53 53 ops = sysdem_ops_default;
54 54
55 55 if (lang == SYSDEM_LANG_AUTO) {
56 56 lang = detect_lang(str);
57 57 if (lang == SYSDEM_LANG_AUTO) {
58 - errno = ENOSYS;
58 + errno = ENOTSUP;
59 59 return (NULL);
60 60 }
61 61 }
62 62
63 63 switch (lang) {
64 + case SYSDEM_LANG_AUTO:
65 + break;
64 66 case SYSDEM_LANG_CPP:
65 67 return (cpp_demangle(str, ops));
66 -
67 - default:
68 - break;
69 68 }
70 69
71 - /* XXX: better return value? */
72 - errno = ENOSYS;
70 + errno = ENOTSUP;
73 71 return (NULL);
74 72 }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX