gen_action_registry.sh incorrectly generates Action Registry

Bug #379814 reported by Nate Michael
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Obsolete Junk
Peekabot-0.6.x-20090506-215405
Invalid
Undecided
Unassigned
peekabot
Status tracked in Trunk
Trunk
Fix Released
Medium
Staffan Gimåker

Bug Description

When compiling the current trunk (r731), the script for generating the action registry creates an ActionRegistry.cc file that cannot be compiled. The reason for this is the definition of the "class" and "id" variables. The fix for my system is to change lines 40-41 of gen_action_registry.sh to:

 class="$(echo $f | sed "s:actions/::" | sed "s:.hh::")"
 id="$(echo $foo | sed "s/PEEKABOT_REGISTER_SERIALIZABLE[[:space:]]\([0-9]\)/\1/g")"

Before this change, the sed commands were extracting the full values of $f and $foo. After the fix the class and id variables are set correctly. This is probably a cross-platform issue, but for completeness the system is Mac OS 10.5.7.

Revision history for this message
Staffan Gimåker (gimaker) wrote :

Thanks for the report. Unfortunately, your fix does not work well with GNU sed. Does the original code work if you use "sed -E" instead?

Revision history for this message
Staffan Gimåker (gimaker) wrote :

Can you try these two lines?

class="$(echo $f | sed --posix "s/^actions\/\(\w\{0,\}\)\.hh/\1/g")"
id="$(echo $foo | sed --posix "s/PEEKABOT_REGISTER_SERIALIZABLE[[:space:]]\{1,\}//g")"

Changed in peekabot:
assignee: nobody → Staffan Gimåker (gimaker)
importance: Undecided → Medium
status: New → In Progress
Revision history for this message
Nate Michael (nate-michael) wrote : Re: [Bug 379814] Re: gen_action_registry.sh incorrectly generates Action Registry

Hi Staffan,

> class="$(echo $f | sed --posix "s/^actions\/\(\w\{0,\}\)\.hh/\1/g")"
> id="$(echo $foo | sed --posix "s/
> PEEKABOT_REGISTER_SERIALIZABLE[[:space:]]\{1,\}//g")"

This does not work, --posix is not a valid flag. I also tried the
other suggested method:

> Does the original code work if you use "sed -E" instead?

which returns undesired values.

How about the following:

 class="$(echo $f | sed "s:actions\/*::" | sed "s:\([a-zA-Z]\)\.hh:
\1:g")"
 id="$(echo $foo | sed "s/[a-zA-Z_ ]*//g")"

I tried this on OS X and Debian linux and both worked.

Nate

Revision history for this message
Staffan Gimåker (gimaker) wrote :

Ah, sorry, what happens if you remove the "--posix" flag (which was put there by accident :)? I.e.

  class="$(echo $f | sed "s/^actions\/\(\w\{0,\}\)\.hh/\1/g")"
  id="$(echo $foo | sed "s/PEEKABOT_REGISTER_SERIALIZABLE[[:space:]]\{1,\}//g")"

Still a no-go?

What's the reason for using the ":" syntax, instead of the "/" syntax?

Revision history for this message
Nate Michael (nate-michael) wrote :

> class="$(echo $f | sed "s/^actions\/\(\w\{0,\}\)\.hh/\1/g")"
> id="$(echo $foo | sed "s/PEEKABOT_REGISTER_SERIALIZABLE[[:space:]]
> \{1,\}//g")"
>
> Still a no-go?

One line from the output follows:

Found action actions/SetJointMax.hh, id=95 (./actions/SetJointMax.hh)

So the id matching works, but not the definition of class.

> What's the reason for using the ":" syntax, instead of the "/" syntax?

Personal preference, I find it easier to read.

Nate

Revision history for this message
Staffan Gimåker (gimaker) wrote :

Or:

    class="$(echo $f | sed "s/^actions\/\([[:alnum:]]\{0,\}\)\.hh/\1/g")"
    id="$(echo $foo | sed "s/PEEKABOT_REGISTER_SERIALIZABLE[[:space:]]\{1,\}//g")"

As far as I can tell by reading the man pages for BSD sed and "re_format", this should be portable.

Revision history for this message
Staffan Gimåker (gimaker) wrote :

Ok. Thanks. I'll commit your variant of the class matching regexp then.

Revision history for this message
Nate Michael (nate-michael) wrote :

> class="$(echo $f | sed "s/^actions\/\([[:alnum:]]\{0,\}\)\.hh/\1/
> g")"
> id="$(echo $foo | sed "s/PEEKABOT_REGISTER_SERIALIZABLE[[:space:]]
> \{1,\}//g")"

This works.

Nate

Revision history for this message
Staffan Gimåker (gimaker) wrote :

Fix commited. Re-open the bug if it still doesn't work.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.