Re: ScriptInterp::getMember VS. ScriptCommand::getMember

"Zhang Le" <[email protected]> Sun, 8 Oct 2006 00:57:45 +0800
Newsgroups gmane.comp.gnu.bayonne.devel
Message-ID <[email protected]>
On 10/7/06, David Sugar <[email protected]> wrote:
>
> Are the attachements missing?


Sorry, but I could see the attachment in my "sent mail" box.
Don't know what went wrong.
I send it again. Both as content and as attachment.

*bayonne2-1.5.29-ScriptCommand-getMember.patch*
diff -urN bayonne2-1.5.29/binders/bayonnexml/checks.cpp bayonne2-1.5.29.new
/binders/bayonnexml/checks.cpp
--- bayonne2-1.5.29/binders/bayonnexml/checks.cpp    2006-06-08 21:04:
51.000000000 +0800
+++ bayonne2-1.5.29.new/binders/bayonnexml/checks.cpp    2006-10-03 10:11:
07.000000000 +0800
@@ -104,9 +104,6 @@
     if(scr->access != ScriptInterp::scrPUBLIC)
         return "cannot register non-public script";

-    if(cp)
-        ++cp;
-
     if(ext && !stricmp(ext, ".conf"))
     {
         if(cp)
@@ -172,9 +169,6 @@
     if(!strnicmp(line->cmd, "incoming.", 9))
         return "invalid member for incoming";

-    if(cp && *cp == '.')
-        ++cp;
-
     if(cp)
     {
         if(!stricmp(cp, "timeslot"))
@@ -328,9 +322,6 @@
 trunking:
     img->setPointer(sbuf, scr);

-    if(cp && *cp == '.')
-        ++cp;
-
     if(cp)
     {
         if(!stricmp(cp, "timeslot"))
diff -urN bayonne2-1.5.29/binders/ivrscript1/checks.cpp bayonne2-1.5.29.new
/binders/ivrscript1/checks.cpp
--- bayonne2-1.5.29/binders/ivrscript1/checks.cpp    2006-08-24 03:17:
41.000000000 +0800
+++ bayonne2-1.5.29.new/binders/ivrscript1/checks.cpp    2006-10-03 10:07:
56.000000000 +0800
@@ -199,9 +199,6 @@
     if(scr->access != ScriptInterp::scrPUBLIC)
         return "cannot register non-public script";

-    if(cp)
-        ++cp;
-
     if(ext && !stricmp(ext, ".conf"))
     {
         if(cp)
@@ -270,9 +267,6 @@
     if(!strnicmp(line->cmd, "incoming.", 9))
         return "invalid member for incoming";

-    if(cp && *cp == '.')
-        ++cp;
-
     if(cp)
     {
         if(!stricmp(cp, "timeslot"))
@@ -427,9 +421,6 @@
 trunking:
     img->setPointer(sbuf, scr);

-    if(cp && *cp == '.')
-        ++cp;
-
     if(cp)
     {
         if(!stricmp(cp, "timeslot"))
diff -urN bayonne2-1.5.29/server/checks.cpp bayonne2-1.5.29.new
/server/checks.cpp
--- bayonne2-1.5.29/server/checks.cpp    2006-07-30 23:06:33.000000000 +0800
+++ bayonne2-1.5.29.new/server/checks.cpp    2006-10-03 10:07:56.000000000+0800
@@ -258,7 +258,7 @@
     const char *cp = getMember(line);
     unsigned idx = 0;

-    if(cp && atoi(++cp) < 1)
+    if(cp && atoi(cp) < 1)
         return "libexec timeout member must be at least one second";

     if(!strnicmp(line->cmd, "exec", 4))
@@ -493,7 +493,7 @@
     const char *cp;

     cp = getMember(line);
-    if(cp && stricmp(cp, ".vox"))
+    if(cp && stricmp(cp, "vox"))
         return "use no member or .vox only";

     if(!useKeywords(line,
"=extension=encoding=prefix=framing=silence=intersilence=note=position=exit=timeout=menu"))
@@ -533,7 +533,7 @@
     const char *cp;

     cp = getMember(line);
-    if(cp && stricmp(cp, ".vox"))
+    if(cp && stricmp(cp, "vox"))
         return "use no member or .vox only";

     if(!useKeywords(line,
"=extension=encoding=prefix=framing=silence=intersilence=exit=timeout"))

*ccscript3-ScriptCommand-getMember.patch
*diff -urN ccscript3-1.0.9.orig/src/checks.cpp ccscript3-1.0.9
/src/checks.cpp
--- ccscript3-1.0.9.orig/src/checks.cpp    2006-05-04 01:26:15.000000000+0800
+++ ccscript3-1.0.9/src/checks.cpp    2006-09-29 16:43:56.000000000 +0800
@@ -403,7 +403,7 @@
 {
         const char *cp = getMember(line);

-        if(cp && !isdigit(cp[1]))
+        if(cp && !isdigit(cp[0]))
     {
                 cp = chkProperty(line, img);

@@ -411,7 +411,7 @@
             return cp;
     }

-    if(cp && atoi(++cp) > 6)
+    if(cp && atoi(cp) > 6)
         return "numbers only valid to 6 decimal places";

     if(hasKeywords(line))
@@ -435,7 +435,7 @@
 {
     const char *cp = getMember(line);

-    if(cp && !isdigit(cp[1]))
+    if(cp && !isdigit(cp[0]))
         return "member when used must be size";

     if(!useKeywords(line, "=size"))
@@ -494,7 +494,7 @@
 {
         const char *cp = getMember(line);

-        if(cp && !isdigit(cp[1]))
+        if(cp && !isdigit(cp[0]))
     {
                 cp = chkProperty(line, img);
         if(!cp)
@@ -514,10 +514,10 @@
 {
     const char *cp = getMember(line);

-    if(cp && !isdigit(cp[1]))
+    if(cp && !isdigit(cp[0]))
         return "member must be decimal place";

-    if(cp && atoi(++cp) > 6)
+    if(cp && atoi(cp) > 6)
         return "numbers supported only to 6 decimal places";

     if(!useKeywords(line, "=decimal"))
@@ -624,7 +624,7 @@
 const char *ScriptChecks::chkArray(Line *line, ScriptImage *img)
 {
     const char *cp = getMember(line);
-    if(cp && !isdigit(*(++cp)))
+    if(cp && !isdigit(*cp))
         return "invalid member used";

     if(!useKeywords(line, "=count=size"))
@@ -641,7 +641,7 @@
 {
     const char *cp = getMember(line);

-    if(cp && !isdigit(*(++cp)))
+    if(cp && !isdigit(*cp))
         cp = chkProperty(line, img);
     else
         cp = NULL;
@@ -730,7 +730,7 @@
 {
     const char *cp = getMember(line);

-    if(cp && atoi(++cp) < 1)
+    if(cp && atoi(cp) < 1)
         return "member must be initial value and greater than zero";

     if(hasKeywords(line))
@@ -778,7 +778,7 @@
         if(!cp)
                 return NULL;

-        prop = ScriptProperty::find(++cp);
+        prop = ScriptProperty::find(cp);
         if(!prop)
                 return "unknown script property referenced";

diff -urN ccscript3-1.0.9.orig/src/command.cpp ccscript3-1.0.9
/src/command.cpp
--- ccscript3-1.0.9.orig/src/command.cpp    2006-05-04 01:26:15.000000000+0800
+++ ccscript3-1.0.9/src/command.cpp    2006-09-29 16:43:13.000000000 +0800
@@ -383,7 +383,12 @@

 const char *ScriptCommand::getMember(Line *line)
 {
-    return strchr(line->cmd, '.');
+    const char *cp = strchr(line->cmd, '.');
+
+    if(cp)
+        ++cp;
+
+    return cp;
 }

 const char *ScriptCommand::getOption(Line *line, unsigned *idx)*

  *

Zhang Le wrote:
> > These two getMember's behavior is different.
> > For example. for "register.sip"
> > ScriptInterp::getMember's result doesn't include the leading dot, ie.
> the
> > result is "sip"
> > ScriptCommand::getMember's result include the leading dot, ie. the
> > result is
> > ".sip"
> >
> > Unfortunately, this difference is overlooked sometimes.
> > For example, in bayonne2-1.5.28 src/checks.cpp, chkSlog function assumes
> > ScriptCommand::getMember's result doesn't include the leading dot, thus
> > command like "slog.info" won't work.
> >
> > Although we could fix the problem by modifying chkSlog(), I think the
> > better
> > solution is make the behavior of the two getMember consistent with each
> > other.
> >
> > So I made two patches, one for ccscript3-1.0.9, the other for
> > bayonn2-1.5.29
> > .
> > These two patches could make ScriptCommand::getMember behave the same as
> > ScriptInterp::getMember, and solve all (at least I can't find any more)
> the
> > problems caused by this behavior change of ScriptCommand::getMember.
> > Please check the attachment.
> >
> >
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > Bayonne-devel mailing list
> > [email protected]
> > http://lists.gnu.org/mailman/listinfo/bayonne-devel
>
>
>


-- 
Zhang Le, Robert
Linux Engineer/Trainer
http://zhllg.blogspot.com
http://zh.gentoo-wiki.com
http://savannah.nongnu.org/projects/pgubook
http://groups.google.com/group/gentoo-china
http://groups.google.com/group/szlug

_______________________________________________
Bayonne-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bayonne-devel