diff options
author | Matthew Johnson <mjj29@hecate.matthew.ath.cx> | 2008-05-31 20:20:54 +0100 |
---|---|---|
committer | Matthew Johnson <mjj29@hecate.matthew.ath.cx> | 2008-05-31 20:20:54 +0100 |
commit | 417244f5799811b08002ad6a11dd75e3aeaa425b (patch) | |
tree | ed87ac98927e9ce7af9d9410804e2038102ecec0 /org | |
parent | 53ebc8b71b5e7eed4a573116fde12aabb8451213 (diff) |
fixes
Diffstat (limited to 'org')
-rw-r--r-- | org/freedesktop/dbus/Transport.java | 2 | ||||
-rw-r--r-- | org/freedesktop/dbus/bin/CreateInterface.java | 11 | ||||
-rw-r--r-- | org/freedesktop/dbus/bin/DBusDaemon.java | 8 | ||||
-rw-r--r-- | org/freedesktop/dbus/bin/IdentifierMangler.java | 43 |
4 files changed, 58 insertions, 6 deletions
diff --git a/org/freedesktop/dbus/Transport.java b/org/freedesktop/dbus/Transport.java index 3a43293..12f2f1a 100644 --- a/org/freedesktop/dbus/Transport.java +++ b/org/freedesktop/dbus/Transport.java @@ -272,6 +272,8 @@ public class Transport top: while (true) { int c = s.read(); switch (c) { + case -1: + throw new IOException("Stream unexpectedly short (broken pipe)"); case 0: case '\r': continue; diff --git a/org/freedesktop/dbus/bin/CreateInterface.java b/org/freedesktop/dbus/bin/CreateInterface.java index 314f992..73c5ea8 100644 --- a/org/freedesktop/dbus/bin/CreateInterface.java +++ b/org/freedesktop/dbus/bin/CreateInterface.java @@ -11,6 +11,7 @@ package org.freedesktop.dbus.bin; import static org.freedesktop.dbus.Gettext._; +import static org.freedesktop.dbus.bin.IdentifierMangler.mangle; import java.io.File; import java.io.FileInputStream; @@ -155,7 +156,7 @@ public class CreateInterface Vector<Element> out = new Vector<Element>(); if (null == meth.getAttribute("name") || "".equals(meth.getAttribute("name"))) { - System.err.println(_("ERROR: Interface name was blank, failed")); + System.err.println(_("ERROR: Method name was blank, failed")); System.exit(1); } String annotations = ""; @@ -193,7 +194,7 @@ public class CreateInterface comment = ""; sig += parseReturns(out, imports, tuples, structs); - sig += meth.getAttribute("name")+"("; + sig += mangle(meth.getAttribute("name"))+"("; char defaultname = 'a'; String params = ""; @@ -201,7 +202,7 @@ public class CreateInterface String type = getJavaType(arg.getAttribute("type"), imports, structs, false, false); String name = arg.getAttribute("name"); if (null == name || "".equals(name)) name = ""+(defaultname++); - params += type+" "+name+", "; + params += type+" "+mangle(name)+", "; } return ("".equals(comment) ? "" : " /**\n" + comment + " */\n") + annotations + " public " + sig + @@ -229,8 +230,8 @@ public class CreateInterface String type = getJavaType(arg.getAttribute("type"), imports, structs, false, false); String name = arg.getAttribute("name"); if (null == name || "".equals(name)) name = ""+(defaultname++); - params.put(name, type); - porder.add(name); + params.put(mangle(name), type); + porder.add(mangle(name)); } } diff --git a/org/freedesktop/dbus/bin/DBusDaemon.java b/org/freedesktop/dbus/bin/DBusDaemon.java index 97444fa..5147a72 100644 --- a/org/freedesktop/dbus/bin/DBusDaemon.java +++ b/org/freedesktop/dbus/bin/DBusDaemon.java @@ -838,7 +838,13 @@ public class DBusDaemon extends Thread // accept new connections while (d._run) { Socket s = ss.accept(); - if ((new Transport.SASL()).auth(Transport.SASL.MODE_SERVER, Transport.SASL.AUTH_EXTERNAL, address.getParameter("guid"), s.getOutputStream(), s.getInputStream(), null)) { + boolean authOK=false; + try { + authOK = (new Transport.SASL()).auth(Transport.SASL.MODE_SERVER, Transport.SASL.AUTH_EXTERNAL, address.getParameter("guid"), s.getOutputStream(), s.getInputStream(), null); + } catch (Exception e) { + if (Debug.debug) Debug. print(Debug.DEBUG, e); + } + if (authOK) { d.addSock(s); } else s.close(); diff --git a/org/freedesktop/dbus/bin/IdentifierMangler.java b/org/freedesktop/dbus/bin/IdentifierMangler.java new file mode 100644 index 0000000..0ccf60b --- /dev/null +++ b/org/freedesktop/dbus/bin/IdentifierMangler.java @@ -0,0 +1,43 @@ +/* + D-Bus Java Implementation + Copyright (c) 2005-2006 Matthew Johnson + + This program is free software; you can redistribute it and/or modify it + under the terms of either the GNU General Public License Version 2 or the + Academic Free Licence Version 2.1. + + Full licence texts are included in the COPYING file with this program. +*/ +package org.freedesktop.dbus.bin; + +import java.util.Arrays; + +/** + * Checks identifiers for keywords etc and mangles them if so. + */ +public class IdentifierMangler +{ + private static String[] keywords; + static { + keywords = new String[] { + "true","false","null", + "abstract","continue","for","new","switch", + "assert","default","goto","package","synchronized", + "boolean","do","if","private","this", + "break","double","implements","protected","throw", + "byte","else","import","public","throws", + "case","enum","instanceof","return","transient", + "catch","extends","int","short","try", + "char","final","interface","static","void", + "class","finally","long","strictfp","volatile", + "const","float","native","super","while" + }; + Arrays.sort(keywords); + } + public static String mangle(String name) + { + if (Arrays.binarySearch(keywords, name) >= 0) + name = "_"+name; + return name; + } +} |