summaryrefslogtreecommitdiffhomepage
path: root/src/internal
diff options
context:
space:
mode:
Diffstat (limited to 'src/internal')
-rw-r--r--src/internal/argv/argv.h16
-rw-r--r--src/internal/mdso_errinfo_impl.c2
-rw-r--r--src/internal/mdso_errinfo_impl.h2
-rw-r--r--src/internal/mdso_hexfmt_impl.c35
-rw-r--r--src/internal/mdso_hexfmt_impl.h14
-rw-r--r--src/internal/mdso_object_impl.h16
-rw-r--r--src/internal/perk/perk_structs.h2
7 files changed, 80 insertions, 7 deletions
diff --git a/src/internal/argv/argv.h b/src/internal/argv/argv.h
index 0be1d0e..b50e9c7 100644
--- a/src/internal/argv/argv.h
+++ b/src/internal/argv/argv.h
@@ -833,6 +833,7 @@ static void argv_usage_impl(
{
const struct argv_option ** optv;
const struct argv_option * option;
+ int nlong;
bool fshort,flong,fboth;
size_t len,optlen,desclen;
char cache;
@@ -865,7 +866,7 @@ static void argv_usage_impl(
if (header)
argv_dprintf(fd,"%s",header);
- for (optlen=0,optv=options; *optv; optv++) {
+ for (optlen=0,nlong=0,optv=options; *optv; optv++) {
option = *optv;
/* indent + comma */
@@ -884,6 +885,11 @@ static void argv_usage_impl(
/* optlen */
if (len > optlen)
optlen = len;
+
+ /* long (vs. hybrid-only) option? */
+ if (option->long_name)
+ if (!(option->flags & ARGV_OPTION_HYBRID_ONLY))
+ nlong++;
}
if (optlen >= optcap) {
@@ -904,7 +910,7 @@ static void argv_usage_impl(
/* color */
if (fcolor) {
color = (color == ccyan) ? cblue : ccyan;
- argv_dprintf(fd,color);
+ argv_dprintf(fd,color,0);
}
/* description, using either paradigm or argname if applicable */
@@ -916,7 +922,11 @@ static void argv_usage_impl(
/* long/hybrid option prefix (-/--) */
prefix = option->flags & ARGV_OPTION_HYBRID_ONLY
- ? " -" : "--";
+ ? " -" : " --";
+
+ /* avoid extra <stace> when all long opts are hybrid-only */
+ if (nlong == 0)
+ prefix++;
/* option string */
if (fboth && option->short_name && option->long_name)
diff --git a/src/internal/mdso_errinfo_impl.c b/src/internal/mdso_errinfo_impl.c
index d7ea6ae..28a663c 100644
--- a/src/internal/mdso_errinfo_impl.c
+++ b/src/internal/mdso_errinfo_impl.c
@@ -1,6 +1,6 @@
/****************************************************************/
/* mdso: midipix dso scavenger */
-/* Copyright (C) 2015--2021 SysDeer Technologies, LLC */
+/* Copyright (C) 2015--2024 SysDeer Technologies, LLC */
/* Released under GPLv2 and GPLv3; see COPYING.MDSO. */
/****************************************************************/
diff --git a/src/internal/mdso_errinfo_impl.h b/src/internal/mdso_errinfo_impl.h
index 4b4b693..6c83033 100644
--- a/src/internal/mdso_errinfo_impl.h
+++ b/src/internal/mdso_errinfo_impl.h
@@ -1,6 +1,6 @@
/****************************************************************/
/* mdso: midipix dso scavenger */
-/* Copyright (C) 2015--2021 SysDeer Technologies, LLC */
+/* Copyright (C) 2015--2024 SysDeer Technologies, LLC */
/* Released under GPLv2 and GPLv3; see COPYING.MDSO. */
/****************************************************************/
diff --git a/src/internal/mdso_hexfmt_impl.c b/src/internal/mdso_hexfmt_impl.c
new file mode 100644
index 0000000..33d337b
--- /dev/null
+++ b/src/internal/mdso_hexfmt_impl.c
@@ -0,0 +1,35 @@
+/****************************************************************/
+/* mdso: midipix dso scavenger */
+/* Copyright (C) 2015--2024 SysDeer Technologies, LLC */
+/* Released under GPLv2 and GPLv3; see COPYING.MDSO. */
+/****************************************************************/
+
+#include <stdint.h>
+
+char buf[256] = {0};
+
+static unsigned char mdso_hexfmt[16] = {
+ '0','1','2','3','4','5','6','7',
+ '8','9','a','b','c','d','e','f',
+};
+
+void mdso_write_hex_64(char * ch, uint64_t val)
+{
+ ch[0xf] = mdso_hexfmt[val % 16]; val >>= 4;
+ ch[0xe] = mdso_hexfmt[val % 16]; val >>= 4;
+ ch[0xd] = mdso_hexfmt[val % 16]; val >>= 4;
+ ch[0xc] = mdso_hexfmt[val % 16]; val >>= 4;
+ ch[0xb] = mdso_hexfmt[val % 16]; val >>= 4;
+ ch[0xa] = mdso_hexfmt[val % 16]; val >>= 4;
+ ch[0x9] = mdso_hexfmt[val % 16]; val >>= 4;
+ ch[0x8] = mdso_hexfmt[val % 16]; val >>= 4;
+
+ ch[0x7] = mdso_hexfmt[val % 16]; val >>= 4;
+ ch[0x6] = mdso_hexfmt[val % 16]; val >>= 4;
+ ch[0x5] = mdso_hexfmt[val % 16]; val >>= 4;
+ ch[0x4] = mdso_hexfmt[val % 16]; val >>= 4;
+ ch[0x3] = mdso_hexfmt[val % 16]; val >>= 4;
+ ch[0x2] = mdso_hexfmt[val % 16]; val >>= 4;
+ ch[0x1] = mdso_hexfmt[val % 16]; val >>= 4;
+ ch[0x0] = mdso_hexfmt[val % 16]; val >>= 4;
+}
diff --git a/src/internal/mdso_hexfmt_impl.h b/src/internal/mdso_hexfmt_impl.h
new file mode 100644
index 0000000..1ad74d1
--- /dev/null
+++ b/src/internal/mdso_hexfmt_impl.h
@@ -0,0 +1,14 @@
+/****************************************************************/
+/* mdso: midipix dso scavenger */
+/* Copyright (C) 2015--2024 SysDeer Technologies, LLC */
+/* Released under GPLv2 and GPLv3; see COPYING.MDSO. */
+/****************************************************************/
+
+#ifndef MDSO_HEXFMT_IMPL_H
+#define MDSO_HEXFMT_IMPL_H
+
+#include <stdint.h>
+
+void mdso_write_hex_64(char * ch, uint64_t val);
+
+#endif
diff --git a/src/internal/mdso_object_impl.h b/src/internal/mdso_object_impl.h
index 3442856..539a77d 100644
--- a/src/internal/mdso_object_impl.h
+++ b/src/internal/mdso_object_impl.h
@@ -1,6 +1,6 @@
/****************************************************************/
/* mdso: midipix dso scavenger */
-/* Copyright (C) 2015--2021 SysDeer Technologies, LLC */
+/* Copyright (C) 2015--2024 SysDeer Technologies, LLC */
/* Released under GPLv2 and GPLv3; see COPYING.MDSO. */
/****************************************************************/
@@ -31,3 +31,17 @@ static inline void mdso_obj_write_quad(unsigned char * ch, uint64_t val)
ch[6] = val >> 48;
ch[7] = val >> 56;
}
+
+static inline void mdso_obj_write_dec(unsigned char * ch, uint64_t dec)
+{
+ int digits;
+ uint64_t val;
+
+ *ch = '0';
+
+ for (digits=0,val=dec; val; digits++)
+ val /= 10;
+
+ for (val=dec; val; val/=10)
+ ch[--digits] = (val % 10) + '0';
+}
diff --git a/src/internal/perk/perk_structs.h b/src/internal/perk/perk_structs.h
index b1823b4..9ffb480 100644
--- a/src/internal/perk/perk_structs.h
+++ b/src/internal/perk/perk_structs.h
@@ -332,7 +332,7 @@ struct pe_raw_coff_symbol_name {
struct pe_raw_coff_strtbl {
unsigned char cst_size [0x04]; /* 0x00 */
- unsigned char cst_data [0x01]; /* 0x04 */
+ unsigned char cst_data []; /* 0x04 */
};