aboutsummaryrefslogtreecommitdiff
path: root/src/IvyClient.java
diff options
context:
space:
mode:
authorjestin2001-10-10 15:36:44 +0000
committerjestin2001-10-10 15:36:44 +0000
commitcb920a78a1ee3eeaf6d45c0c29aa74714b2d9319 (patch)
treed5d5f8469189d441124072f5ea06313cfdbeab12 /src/IvyClient.java
parent5ef7f02fef093aebb79ef1a1f37908664702b1cb (diff)
downloadivy-java-cb920a78a1ee3eeaf6d45c0c29aa74714b2d9319.zip
ivy-java-cb920a78a1ee3eeaf6d45c0c29aa74714b2d9319.tar.gz
ivy-java-cb920a78a1ee3eeaf6d45c0c29aa74714b2d9319.tar.bz2
ivy-java-cb920a78a1ee3eeaf6d45c0c29aa74714b2d9319.tar.xz
Bugfix related to the "a(.*) (.*)' regexp causing the loss of front empty
messages.
Diffstat (limited to 'src/IvyClient.java')
-rwxr-xr-xsrc/IvyClient.java22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/IvyClient.java b/src/IvyClient.java
index 069a45b..4faeb00 100755
--- a/src/IvyClient.java
+++ b/src/IvyClient.java
@@ -100,6 +100,10 @@ public class IvyClient extends Thread {
RE regexp = (RE)regexp_in.get(key);
REMatch result = regexp.getMatch(message);
if ( result != null ) {
+ // it's just to check if matching went right.... It is right.
+ //String tmp="";
+ //for (int i=1;i<=regexp.getNumSubs();i++) { tmp+="'"+result.toString(i)+"' "; }
+ //System.out.println(">> matching "+regexp.getNumSubs()+" blocks "+tmp);
send(Msg,key,regexp.getNumSubs(),result);
count++;
}
@@ -160,14 +164,8 @@ public class IvyClient extends Thread {
break;
}
if(!st.hasMoreTokens()){close("Bad format no id '"+msg+"'");break;}
- /* IST */
token=st.nextToken(StartArg).trim();
- /*
- * TODO
- * this doesn't work on jdk1.3 !!!
- * the token equals " 3992", which provoques a NumberFormatException
- */
try {
msgid=Integer.valueOf(token);
} catch ( NumberFormatException e ) {
@@ -175,13 +173,20 @@ public class IvyClient extends Thread {
break;
}
String msgarg="";
- if (st.hasMoreTokens()) msgarg=st.nextToken("\n").trim();
+ // if (st.hasMoreTokens()) msgarg=st.nextToken("\n").trim();
+ if (st.hasMoreTokens()) msgarg=st.nextToken("\n");
+ // TODO: here is a bug !
+ // quick and dirty fix: I do the trimming by hand later on.
+ // (cf ref: This method may be used to trim whitespace from the
+ // beginning and end of a string; in fact, it trims all ASCII control characters as well.
+
/*
* second stage: process the message
*/
switch (msgtype) {
case Bye: break;
case AddRegexp:
+ msgarg.trim();
if ( bus.CheckRegexp(msgarg) ) {
try {
regexp_in.put(msgid,new RE(msgarg));
@@ -208,7 +213,7 @@ public class IvyClient extends Thread {
break;
case Msg:
try {
- bus.callCallback(this,msgid,msgarg);
+ bus.callCallback(this,msgid,msgarg.substring(1,msgarg.length()-1));
} catch (IvyException ie) {
// calling an inexistant callback
System.err.println("calling an inexistant callback, the caller must be wrong !");
@@ -226,6 +231,7 @@ public class IvyClient extends Thread {
}
break;
case DirectMsg:
+ msgarg.trim();
bus.directMessage( this, msgid.intValue(), msgarg );
break;
case Die: