Deleted Added
full compact
elftc_demangle.c (280932) elftc_demangle.c (295577)
1/*-
2 * Copyright (c) 2009 Kai Wang
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 19 unchanged lines hidden (view full) ---

28#include <assert.h>
29#include <errno.h>
30#include <libelftc.h>
31#include <stdlib.h>
32#include <string.h>
33
34#include "_libelftc.h"
35
1/*-
2 * Copyright (c) 2009 Kai Wang
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 19 unchanged lines hidden (view full) ---

28#include <assert.h>
29#include <errno.h>
30#include <libelftc.h>
31#include <stdlib.h>
32#include <string.h>
33
34#include "_libelftc.h"
35
36ELFTC_VCSID("$Id: elftc_demangle.c 3174 2015-03-27 17:13:41Z emaste $");
36ELFTC_VCSID("$Id: elftc_demangle.c 3296 2016-01-09 14:17:28Z jkoshy $");
37
37
38static int
39is_mangled(const char *s, int style)
38static unsigned int
39is_mangled(const char *s, unsigned int style)
40{
41
42 switch (style) {
43 case ELFTC_DEM_ARM: return (is_cpp_mangled_ARM(s) ? style : 0);
44 case ELFTC_DEM_GNU2: return (is_cpp_mangled_gnu2(s) ? style : 0);
45 case ELFTC_DEM_GNU3: return (is_cpp_mangled_gnu3(s) ? style : 0);
46 }
47

--- 5 unchanged lines hidden (view full) ---

53 if (is_cpp_mangled_ARM(s))
54 return (ELFTC_DEM_ARM);
55
56 /* Cannot be demangled. */
57 return (0);
58}
59
60static char *
40{
41
42 switch (style) {
43 case ELFTC_DEM_ARM: return (is_cpp_mangled_ARM(s) ? style : 0);
44 case ELFTC_DEM_GNU2: return (is_cpp_mangled_gnu2(s) ? style : 0);
45 case ELFTC_DEM_GNU3: return (is_cpp_mangled_gnu3(s) ? style : 0);
46 }
47

--- 5 unchanged lines hidden (view full) ---

53 if (is_cpp_mangled_ARM(s))
54 return (ELFTC_DEM_ARM);
55
56 /* Cannot be demangled. */
57 return (0);
58}
59
60static char *
61demangle(const char *s, int style, int rc)
61demangle(const char *s, unsigned int style, unsigned int rc)
62{
63
64 (void) rc; /* XXX */
65 switch (style) {
66 case ELFTC_DEM_ARM: return (cpp_demangle_ARM(s));
67 case ELFTC_DEM_GNU2: return (cpp_demangle_gnu2(s));
68 case ELFTC_DEM_GNU3: return (cpp_demangle_gnu3(s));
69 default:
70 assert(0);
71 return (NULL);
72 }
73}
74
75int
76elftc_demangle(const char *mangledname, char *buffer, size_t bufsize,
77 unsigned int flags)
78{
62{
63
64 (void) rc; /* XXX */
65 switch (style) {
66 case ELFTC_DEM_ARM: return (cpp_demangle_ARM(s));
67 case ELFTC_DEM_GNU2: return (cpp_demangle_gnu2(s));
68 case ELFTC_DEM_GNU3: return (cpp_demangle_gnu3(s));
69 default:
70 assert(0);
71 return (NULL);
72 }
73}
74
75int
76elftc_demangle(const char *mangledname, char *buffer, size_t bufsize,
77 unsigned int flags)
78{
79 int style, rc;
79 unsigned int style, rc;
80 char *rlt;
81
82 style = flags & 0xFFFF;
83 rc = flags >> 16;
84
85 if (mangledname == NULL ||
86 ((style = is_mangled(mangledname, style)) == 0)) {
87 errno = EINVAL;

--- 20 unchanged lines hidden ---
80 char *rlt;
81
82 style = flags & 0xFFFF;
83 rc = flags >> 16;
84
85 if (mangledname == NULL ||
86 ((style = is_mangled(mangledname, style)) == 0)) {
87 errno = EINVAL;

--- 20 unchanged lines hidden ---