Permalink
Browse files

Small bugfixes, some for bugs found using triq (ets_test.erl).

  • Loading branch information...
1 parent 3e10a48 commit 777ff9ce24c8510d97616a83c5e5e8041d63a967 Erik Søe Sørensen committed Nov 2, 2010
Showing with 7 additions and 5 deletions.
  1. +1 −1 ej
  2. +1 −1 src/main/java/erjang/Main.java
  3. +2 −1 src/main/java/erjang/m/ets/EMatchSpec.java
  4. +3 −2 src/main/java/erjang/m/ets/Native.java
View
2 ej
@@ -26,4 +26,4 @@ exec java \
+A 10 \
+S 1 \
+e $ERTS_VSN \
- $*
+ "$@"
@@ -124,7 +124,7 @@ public static void main(String[] args)
break;
}
- if (arg.charAt(0) == '+') {
+ if (arg.startsWith("+")) {
switch (arg.charAt(1)) {
case 'a':
case 'e': // strip erts version too
@@ -165,7 +165,8 @@
static final boolean is_match_var(EAtom am) {
String name = am.getName();
- return name.charAt(0) == '$' && MATCH_VAR.matcher(name).matches();
+ return name.length() > 0 && name.charAt(0) == '$' &&
+ MATCH_VAR.matcher(name).matches();
}
static final boolean is_expr_match_var(EAtom am) {
@@ -81,7 +81,7 @@
static AtomicLong next_tid = new AtomicLong(1);
/** maps a table name to the corresponding TID */
- static Map<EAtom, EInteger> name_to_tid = new ConcurrentHashMap<EAtom, EInteger>();
+ static ConcurrentHashMap<EAtom, EInteger> name_to_tid = new ConcurrentHashMap<EAtom, EInteger>();
/** maps a TID to the corresponding table */
static Map<EInteger, ETable> tid_to_table = new ConcurrentHashMap<EInteger, ETable>();
@@ -186,7 +186,8 @@
tid_to_table.put(tid, table);
if (is_named) {
- name_to_tid.put(aname, tid);
+ Object existing = name_to_tid.putIfAbsent(aname, tid);
+ if (existing != null) throw ERT.badarg(name, options);
return aname;
} else {
return tid;

0 comments on commit 777ff9c

Please sign in to comment.