aboutsummaryrefslogtreecommitdiffstats
path: root/lib/erl_interface/src/misc
diff options
context:
space:
mode:
authorBjörn-Egil Dahlberg <[email protected]>2011-01-03 16:16:54 +0100
committerBjörn-Egil Dahlberg <[email protected]>2011-01-03 16:16:54 +0100
commit095d5ebc0f739982b55b95fdd9919a6331b4b2b1 (patch)
tree4103f7ed11c37b97fbfe144d75546ae4f661fb49 /lib/erl_interface/src/misc
parent99372cc4053c2fa7662da2f871c9813fbf45ba7e (diff)
parentbcbe0813a0b97f86a7db354e09bf0397cf68f787 (diff)
downloadotp-095d5ebc0f739982b55b95fdd9919a6331b4b2b1.tar.gz
otp-095d5ebc0f739982b55b95fdd9919a6331b4b2b1.tar.bz2
otp-095d5ebc0f739982b55b95fdd9919a6331b4b2b1.zip
Merge branch 'vb/ei-exts' into dev
* vb/ei-exts: Fix testcases erl_global_whereis, erl_global_names Fix wrong erl_compare_ext result comparing lists Correct erl_global{register, unregister} functions Add PID (~p) type parameters to ei_format Add char (~c) type parameters to ei_format OTP-9015 Conflicts: lib/erl_interface/include/ei.h
Diffstat (limited to 'lib/erl_interface/src/misc')
-rw-r--r--lib/erl_interface/src/misc/ei_format.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/erl_interface/src/misc/ei_format.c b/lib/erl_interface/src/misc/ei_format.c
index b35421d4b2..dbd7a4479a 100644
--- a/lib/erl_interface/src/misc/ei_format.c
+++ b/lib/erl_interface/src/misc/ei_format.c
@@ -47,10 +47,12 @@
* array of unions.
*/
union arg {
+ char c;
char* s;
long l;
unsigned long u;
double d;
+ erlang_pid* pid;
};
static int eiformat(const char** s, union arg** args, ei_x_buff* x);
@@ -224,12 +226,14 @@ static int pquotedatom(const char** fmt, ei_x_buff* x)
/*
* The format letters are:
* a - An atom
+ * c - A character
* s - A string
* i - An integer
* l - A long integer
* u - An unsigned long integer
* f - A float
* d - A double float
+ * p - An Erlang PID
*/
static int pformat(const char** fmt, union arg** args, ei_x_buff* x)
{
@@ -240,6 +244,10 @@ static int pformat(const char** fmt, union arg** args, ei_x_buff* x)
res = ei_x_encode_atom(x, (*args)->s);
(*args)++;
break;
+ case 'c':
+ res = ei_x_encode_char(x, (*args)->c);
+ (*args)++;
+ break;
case 's':
res = ei_x_encode_string(x, (*args)->s);
(*args)++;
@@ -261,6 +269,10 @@ static int pformat(const char** fmt, union arg** args, ei_x_buff* x)
res = ei_x_encode_double(x, (*args)->d);
(*args)++;
break;
+ case 'p':
+ res = ei_x_encode_pid(x, (*args)->pid);
+ (*args)++;
+ break;
default:
res = -1;
break;
@@ -396,6 +408,9 @@ static int read_args(const char* fmt, va_list ap, union arg **argp)
return -1; /* Error, string not complete */
}
switch (*p++) {
+ case 'c':
+ args[i++].c = (char) va_arg(ap, int);
+ break;
case 'a':
case 's':
args[i++].s = va_arg(ap, char*);
@@ -415,6 +430,9 @@ static int read_args(const char* fmt, va_list ap, union arg **argp)
case 'd':
args[i++].d = va_arg(ap, double);
break;
+ case 'p':
+ args[i++].pid = va_arg(ap, erlang_pid*);
+ break;
default:
ei_free(args); /* Invalid specifier */
return -1;