aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/utils.c
diff options
context:
space:
mode:
authorLukas Larsson <[email protected]>2013-08-13 17:14:11 +0200
committerLukas Larsson <[email protected]>2013-08-21 15:20:04 +0200
commit20e0509d4e04fada3019639bc82d78b89f06b0fc (patch)
treed780872721c18782e4bdb7d9fc0f340363acbe38 /erts/emulator/beam/utils.c
parenta27e9776c839aa9fed9e71e3d06a33720377e293 (diff)
downloadotp-20e0509d4e04fada3019639bc82d78b89f06b0fc.tar.gz
otp-20e0509d4e04fada3019639bc82d78b89f06b0fc.tar.bz2
otp-20e0509d4e04fada3019639bc82d78b89f06b0fc.zip
erts: Add option to include nifs statically
Both crypto and asn1 are supported.
Diffstat (limited to 'erts/emulator/beam/utils.c')
-rw-r--r--erts/emulator/beam/utils.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/erts/emulator/beam/utils.c b/erts/emulator/beam/utils.c
index c71f8f0712..6293286c75 100644
--- a/erts/emulator/beam/utils.c
+++ b/erts/emulator/beam/utils.c
@@ -4019,6 +4019,27 @@ erts_smp_ensure_later_interval_acqb(erts_interval_t *icp, Uint64 ic)
#endif
}
+const char *erts_basename(const char* path, char* buff) {
+ /* This function is not compliant with bash basename. Edge cases like "//"
+ and "/path//" do not work properly.
+ */
+ int i;
+ int len = strlen(path);
+ const char *basename = path;
+ for (i = 0; path[i] != '\0'; i++) {
+ if (path[i] == '/') {
+ if (path[i+1] == '\0') {
+ memcpy(buff,basename,len - (basename-path));
+ buff[len - (basename-path)-1] = '\0';
+ basename = buff;
+ break;
+ } else { basename = path+i;}
+ }
+ }
+ if (basename == path)
+ return path;
+ return basename+1;
+}
/*
* A millisecond timestamp without time correction where there's no hrtime