imread/imwrite

View: New views
12 Messages — Rating Filter:   Alert me  

imread/imwrite

by thomas.l.scofield :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


If no one else is working on this, I would like to try my hand at implementing these functions in Octave.

I've not contributed before, and I still haven't figured out mercurial on my Intel Mac with OS 10.4.11.  So, I'll probably have questions along the way concerning these.

I've followed discussions about imread/imwrite over the past 6 months or so, so I am aware of things like

 - these functions are already implemented in the image package, with special cases
   implemented for .png and .jpg files.
 - getting these functions into core Octave soon has been made a priority by John Eaton.
 - the general consensus has thus far been that the best compromise between ease
   of implementation and bloat is to employ the Magick++ library.

Is anyone else working on this?  Has anyone worked on it privately and dropped it, but has useful information to share?

Dumb question from someone who hasn't used libraries for programming in a long time: Does anyone ever remove chunks of code from a library to produce a smaller library?  If it is even possible, does this violate the GPL in any way?  My impression is that the beef against Magick++ is that it has far more capability in it than is now needed, causing a big draw on memory that isn't really necessary.

Thomas L. Scofield
--------------------------------------------------------
Associate Professor
Department of Mathematics and Statistics
Calvin College
--------------------------------------------------------


Re: imread/imwrite

by Julian Schnidder-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Thomas!


Am 19.06.2008 um 23:16 schrieb Thomas L. Scofield:
> I've not contributed before, and I still haven't figured out  
> mercurial on my Intel Mac with OS 10.4.11.  So, I'll probably have  
> questions along the way concerning these.

What version of python do you use?

I use the binary installer for python 2.5.2 from the python homepage.
Mercurial then installs  under /usr/local/lib/python2.5/site-
packages/ and doesn't work for me.

You can try to

1. move the directories "hgext" and "mercurial" from /usr/local/lib/
python2.5/site-packages to /Library/Frameworks/Python.framework/
Versions/2.5/lib/python2.5/site-packages and
2. place the attached files there too (to tell python of the presence  
of mercurial).

That solved the problem for me.

Kind regards,

JCS








hgext.pth (7 bytes) Download Attachment
mercurial.pth (11 bytes) Download Attachment

mercurial in OS 10.4.11 (was imread/imwrite)

by thomas.l.scofield :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


I've been using some scripts that Ben Abbott supplied me with.  The main script is

cd ~/devel/mercurial/octave
hg update -C default
cd ..
if [ -d "octave-3.0.0" ]; then
        rm -r octave-3.0.0
fi
if [ -f "octave-3.0.0.tar.gz" ]; then
        rm octave-3.0.0.tar.gz
fi
cp -r octave octave-3.0.0
cd octave-3.0.0
../osx_fix.sh
./autogen.sh
cd ..
tar cvzf octave-3.0.0.tar.gz octave-3.0.0
md5 octave-3.0.0.tar.gz
echo "(1) Add md5 to octave.info"
mate "/sw/fink/10.4/local/main/finkinfo/sci/octave.info"
sudo cp octave-3.0.0.tar.gz /sw/src/.
sudo fink rebuild octave
sudo fink remove octave
sudo fink install octave


while the osx_fix.sh script does as he describes in this note to Maintainers



Things progress along quite well for some time into the "make" process.  Here are the last few lines of output:

make -C src all
making DASPK-opts.cc from ../liboctave/DASPK-opts.in
making DASRT-opts.cc from ../liboctave/DASRT-opts.in
making DASSL-opts.cc from ../liboctave/DASSL-opts.in
making LSODE-opts.cc from ../liboctave/LSODE-opts.in
making NLEqn-opts.cc from ../liboctave/NLEqn-opts.in
making Quad-opts.cc from ../liboctave/Quad-opts.in
making defaults.h from defaults.h.in
making graphics.h
awk: syntax error at source line 413 in function emit_source source file ./genprops.awk
 context is
                dval = gensub >>>  (/^.*\{(.*)\}.*$/, <<<  "\"\\1\"", "g", dval);
awk: illegal statement at source line 414 in function emit_source source file ./genprops.awk
awk: syntax error at source line 439 source file ./genprops.awk
make[2]: *** [graphics.h] Error 2
make[1]: *** [src] Error 2
make: *** [all] Error 2
### execution of /var/tmp/tmp.2.W8ECNr failed, exit code 2


In answer to your python question, I appear to have two versions installed.  There is v. 2.3.5 installed in /usr/bin (and that is the one that comes first in my path), and v. 2.5.2 in /sw/bin which I must have installed using Fink.  I would not necessarily have thought, from the output above, that python versions were at the heart of my problem (and perhaps it is not).  On the other hand, I cannot imagine how a true syntax error has passed by other Mac users.

Thanks.

Thomas


On Jun 19, 2008, at 5:34 PM, Julian Schnidder wrote:

Hello Thomas!


Am 19.06.2008 um 23:16 schrieb Thomas L. Scofield:
I've not contributed before, and I still haven't figured out mercurial on my Intel Mac with OS 10.4.11.  So, I'll probably have questions along the way concerning these.

What version of python do you use?

I use the binary installer for python 2.5.2 from the python homepage.
Mercurial then installs  under /usr/local/lib/python2.5/site-packages/ and doesn't work for me.

You can try to

1. move the directories "hgext" and "mercurial" from /usr/local/lib/python2.5/site-packages to /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages and
2. place the attached files there too (to tell python of the presence of mercurial).

That solved the problem for me.

Kind regards,

JCS

<hgext.pth><mercurial.pth>



Thomas L. Scofield
--------------------------------------------------------
Associate Professor
Department of Mathematics and Statistics
Calvin College
--------------------------------------------------------


Re: mercurial in OS 10.4.11 (was imread/imwrite)

by David Bateman :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thomas L. Scofield wrote:

>
> I've been using some scripts that Ben Abbott supplied me with.  The
> main script is
>
> cd ~/devel/mercurial/octave
> hg update -C default
> cd ..
> if [ -d "octave-3.0.0" ]; then
>         rm -r octave-3.0.0
> fi
> if [ -f "octave-3.0.0.tar.gz" ]; then
>         rm octave-3.0.0.tar.gz
> fi
> cp -r octave octave-3.0.0
> cd octave-3.0.0
> ../osx_fix.sh
> ./autogen.sh
> cd ..
> tar cvzf octave-3.0.0.tar.gz octave-3.0.0
> md5 octave-3.0.0.tar.gz
> echo "(1) Add md5 to octave.info"
> mate "/sw/fink/10.4/local/main/finkinfo/sci/octave.info"
> sudo cp octave-3.0.0.tar.gz /sw/src/.
> sudo fink rebuild octave
> sudo fink remove octave
> sudo fink install octave
>
>
> while the osx_fix.sh script does as he describes in this note to
> Maintainers
>
> http://www.cae.wisc.edu/pipermail/octave-maintainers/2008-April/006941.html
>
>
> Things progress along quite well for some time into the "make"
> process.  Here are the last few lines of output:
>
> make -C src all
> making DASPK-opts.cc from ../liboctave/DASPK-opts.in
> making DASRT-opts.cc from ../liboctave/DASRT-opts.in
> making DASSL-opts.cc from ../liboctave/DASSL-opts.in
> making LSODE-opts.cc from ../liboctave/LSODE-opts.in
> making NLEqn-opts.cc from ../liboctave/NLEqn-opts.in
> making Quad-opts.cc from ../liboctave/Quad-opts.in
> making defaults.h from defaults.h.in
> making graphics.h
> awk: syntax error at source line 413 in function emit_source source
> file ./genprops.awk
>  context is
>                 dval = gensub >>>  (/^.*\{(.*)\}.*$/, <<<  "\"\\1\"",
> "g", dval);
> awk: illegal statement at source line 414 in function emit_source
> source file ./genprops.awk
> awk: syntax error at source line 439 source file ./genprops.awk
> make[2]: *** [graphics.h] Error 2
> make[1]: *** [src] Error 2
> make: *** [all] Error 2
> ### execution of /var/tmp/tmp.2.W8ECNr failed, exit code 2

You need "gawk" and not "awk" to be used.. Unfortunately the
genprops.awk script uses a "gawk"-ism and there is no obvious way to
remove. However, I'd be all for making genprops.awk vanilla awk
compatible if possible.

http://www.nabble.com/Again-error-with-graphics.h-to17487289.html

where its explained the issue is related to the gensub versus gsub
functions in gawk.

D.

--
David Bateman                                David.Bateman@...
Motorola Labs - Paris                        +33 1 69 35 48 04 (Ph)
Parc Les Algorithmes, Commune de St Aubin    +33 6 72 01 06 33 (Mob)
91193 Gif-Sur-Yvette FRANCE                  +33 1 69 35 77 01 (Fax)

The information contained in this communication has been classified as:

[x] General Business Information
[ ] Motorola Internal Use Only
[ ] Motorola Confidential Proprietary


Re: mercurial in OS 10.4.11 (was imread/imwrite)

by Jaroslav Hajek-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, Jun 20, 2008 at 9:49 AM, David Bateman
<David.Bateman@...> wrote:

> Thomas L. Scofield wrote:
>>
>> I've been using some scripts that Ben Abbott supplied me with.  The
>> main script is
>>
>> cd ~/devel/mercurial/octave
>> hg update -C default
>> cd ..
>> if [ -d "octave-3.0.0" ]; then
>>         rm -r octave-3.0.0
>> fi
>> if [ -f "octave-3.0.0.tar.gz" ]; then
>>         rm octave-3.0.0.tar.gz
>> fi
>> cp -r octave octave-3.0.0
>> cd octave-3.0.0
>> ../osx_fix.sh
>> ./autogen.sh
>> cd ..
>> tar cvzf octave-3.0.0.tar.gz octave-3.0.0
>> md5 octave-3.0.0.tar.gz
>> echo "(1) Add md5 to octave.info"
>> mate "/sw/fink/10.4/local/main/finkinfo/sci/octave.info"
>> sudo cp octave-3.0.0.tar.gz /sw/src/.
>> sudo fink rebuild octave
>> sudo fink remove octave
>> sudo fink install octave
>>
>>
>> while the osx_fix.sh script does as he describes in this note to
>> Maintainers
>>
>> http://www.cae.wisc.edu/pipermail/octave-maintainers/2008-April/006941.html
>>
>>
>> Things progress along quite well for some time into the "make"
>> process.  Here are the last few lines of output:
>>
>> make -C src all
>> making DASPK-opts.cc from ../liboctave/DASPK-opts.in
>> making DASRT-opts.cc from ../liboctave/DASRT-opts.in
>> making DASSL-opts.cc from ../liboctave/DASSL-opts.in
>> making LSODE-opts.cc from ../liboctave/LSODE-opts.in
>> making NLEqn-opts.cc from ../liboctave/NLEqn-opts.in
>> making Quad-opts.cc from ../liboctave/Quad-opts.in
>> making defaults.h from defaults.h.in
>> making graphics.h
>> awk: syntax error at source line 413 in function emit_source source
>> file ./genprops.awk
>>  context is
>>                 dval = gensub >>>  (/^.*\{(.*)\}.*$/, <<<  "\"\\1\"",
>> "g", dval);
>> awk: illegal statement at source line 414 in function emit_source
>> source file ./genprops.awk
>> awk: syntax error at source line 439 source file ./genprops.awk
>> make[2]: *** [graphics.h] Error 2
>> make[1]: *** [src] Error 2
>> make: *** [all] Error 2
>> ### execution of /var/tmp/tmp.2.W8ECNr failed, exit code 2
>
> You need "gawk" and not "awk" to be used.. Unfortunately the
> genprops.awk script uses a "gawk"-ism and there is no obvious way to
> remove. However, I'd be all for making genprops.awk vanilla awk
> compatible if possible.
>
> http://www.nabble.com/Again-error-with-graphics.h-to17487289.html
>
> where its explained the issue is related to the gensub versus gsub
> functions in gawk.
>

I believe the attached patch could work, because match should be POSIX
with all features included. Thomas, can you test it or tell me what
awk you have?
I'll try downloading some other awks to test this.

regards,

> D.
>
> --
> David Bateman                                David.Bateman@...
> Motorola Labs - Paris                        +33 1 69 35 48 04 (Ph)
> Parc Les Algorithmes, Commune de St Aubin    +33 6 72 01 06 33 (Mob)
> 91193 Gif-Sur-Yvette FRANCE                  +33 1 69 35 77 01 (Fax)
>
> The information contained in this communication has been classified as:
>
> [x] General Business Information
> [ ] Motorola Internal Use Only
> [ ] Motorola Confidential Proprietary
>
>

--
RNDr. Jaroslav Hajek
computing expert
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz

[genprops.awk.diff]

# HG changeset patch
# User Jaroslav Hajek <highegg@...>
# Date 1213952938 -7200
# Node ID 82218ced29ce288a764dc7d4c14def64d5951d0d
# Parent  0280a546622c42bf60fb8a2839297691996359dd
[mq]: genprops.awk.diff

diff --git a/src/genprops.awk b/src/genprops.awk
--- a/src/genprops.awk
+++ b/src/genprops.awk
@@ -465,9 +465,11 @@
     {
       dval = defval[i];
       if (type[i] == "radio_property" || type[i] == "color_property")
-        dval = gensub (/^.*\{(.*)\}.*$/, "\"\\1\"", "g", dval);
-      if (! dval)
-        dval = "octave_value ()";
+ if (match (dval, /^.*\{(.*)\}.*$/, res))
+  dval = "\"" + res[1] + "\"";
+ else
+  dval = "octave_value ()";
+
       printf ("  m[\"%s\"] = %s%s;\n", name[i], dval,
  (type[i] == "handle_property" ? ".as_octave_value ()" : "")) >> filename;
     }
@@ -490,7 +492,8 @@
 /BEGIN_PROPERTIES\(.*\)/ {
   gather = 1;
   idx = 0;
-  class_name = gensub (/^.*BEGIN_PROPERTIES\((.*)\)/, "\\1", "g");
+  if (match ($0, /^.*BEGIN_PROPERTIES\((.*)\)/, res))
+    class_name = res[1];
   next;
 }
 


Re: imread/imwrite

by Ben Abbott :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Jun 19, 2008, at 5:16 PM, Thomas L. Scofield wrote:

> I've not contributed before, and I still haven't figured out  
> mercurial on my Intel Mac with OS 10.4.11.  So, I'll probably have  
> questions along the way concerning these.
>

Thomas,

Fink may be useful for you. I use fink to manage many *nix style  
packages ... mercurial, python, octave, etc. For octave I've set up a  
local octave.info.

        http://www.finkproject.org/

Ben

imread/imwrite

by John W. Eaton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 19-Jun-2008, Thomas L. Scofield wrote:

|
| If no one else is working on this, I would like to try my hand at  
| implementing these functions in Octave.
|
| I've not contributed before, and I still haven't figured out  
| mercurial on my Intel Mac with OS 10.4.11.  So, I'll probably have  
| questions along the way concerning these.
|
| I've followed discussions about imread/imwrite over the past 6 months  
| or so, so I am aware of things like
|
|   - these functions are already implemented in the image package,  
| with special cases
|     implemented for .png and .jpg files.
|   - getting these functions into core Octave soon has been made a  
| priority by John Eaton.
|   - the general consensus has thus far been that the best compromise  
| between ease
|     of implementation and bloat is to employ the Magick++ library.

I think we should use the GraphicsMagick++ library since that seems to
have a stable interface.

| Is anyone else working on this?  Has anyone worked on it privately  
| and dropped it, but has useful information to share?

I only looked at it briefly without doing much actual work.  I think
the place to start is the code in Octave Forge.  To simplify the code
in Octave, I think I would would prefer to only use the
GraphicsMagick++ interface and drop the special cases.

| Dumb question from someone who hasn't used libraries for programming  
| in a long time: Does anyone ever remove chunks of code from a library  
| to produce a smaller library?  If it is even possible, does this  
| violate the GPL in any way?  My impression is that the beef against  
| Magick++ is that it has far more capability in it than is now needed,  
| causing a big draw on memory that isn't really necessary.

We won't be distributing the GraphicsMagick++ with Octave, so I would
not worry about this, at least for now.  Is the library really very
big?  It looks like it is around 2.7MB on my system, though it depends
on a lot of other libraries, some of which will be linked to Octave
anyway.  I don't know what the total size is, but does it matter that
much even if it is 20-30MB?

jwe

Re: mercurial in OS 10.4.11 (was imread/imwrite)

by John W. Eaton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 20-Jun-2008, Jaroslav Hajek wrote:

| On Fri, Jun 20, 2008 at 9:49 AM, David Bateman
| <David.Bateman@...> wrote:
| > Thomas L. Scofield wrote:
| >>
| >> I've been using some scripts that Ben Abbott supplied me with.  The
| >> main script is
| >>
| >> cd ~/devel/mercurial/octave
| >> hg update -C default
| >> cd ..
| >> if [ -d "octave-3.0.0" ]; then
| >>         rm -r octave-3.0.0
| >> fi
| >> if [ -f "octave-3.0.0.tar.gz" ]; then
| >>         rm octave-3.0.0.tar.gz
| >> fi
| >> cp -r octave octave-3.0.0
| >> cd octave-3.0.0
| >> ../osx_fix.sh
| >> ./autogen.sh
| >> cd ..
| >> tar cvzf octave-3.0.0.tar.gz octave-3.0.0
| >> md5 octave-3.0.0.tar.gz
| >> echo "(1) Add md5 to octave.info"
| >> mate "/sw/fink/10.4/local/main/finkinfo/sci/octave.info"
| >> sudo cp octave-3.0.0.tar.gz /sw/src/.
| >> sudo fink rebuild octave
| >> sudo fink remove octave
| >> sudo fink install octave
| >>
| >>
| >> while the osx_fix.sh script does as he describes in this note to
| >> Maintainers
| >>
| >> http://www.cae.wisc.edu/pipermail/octave-maintainers/2008-April/006941.html
| >>
| >>
| >> Things progress along quite well for some time into the "make"
| >> process.  Here are the last few lines of output:
| >>
| >> make -C src all
| >> making DASPK-opts.cc from ../liboctave/DASPK-opts.in
| >> making DASRT-opts.cc from ../liboctave/DASRT-opts.in
| >> making DASSL-opts.cc from ../liboctave/DASSL-opts.in
| >> making LSODE-opts.cc from ../liboctave/LSODE-opts.in
| >> making NLEqn-opts.cc from ../liboctave/NLEqn-opts.in
| >> making Quad-opts.cc from ../liboctave/Quad-opts.in
| >> making defaults.h from defaults.h.in
| >> making graphics.h
| >> awk: syntax error at source line 413 in function emit_source source
| >> file ./genprops.awk
| >>  context is
| >>                 dval = gensub >>>  (/^.*\{(.*)\}.*$/, <<<  "\"\\1\"",
| >> "g", dval);
| >> awk: illegal statement at source line 414 in function emit_source
| >> source file ./genprops.awk
| >> awk: syntax error at source line 439 source file ./genprops.awk
| >> make[2]: *** [graphics.h] Error 2
| >> make[1]: *** [src] Error 2
| >> make: *** [all] Error 2
| >> ### execution of /var/tmp/tmp.2.W8ECNr failed, exit code 2
| >
| > You need "gawk" and not "awk" to be used.. Unfortunately the
| > genprops.awk script uses a "gawk"-ism and there is no obvious way to
| > remove. However, I'd be all for making genprops.awk vanilla awk
| > compatible if possible.
| >
| > http://www.nabble.com/Again-error-with-graphics.h-to17487289.html
| >
| > where its explained the issue is related to the gensub versus gsub
| > functions in gawk.
| >
|
|
| I believe the attached patch could work, because match should be POSIX
| with all features included. Thomas, can you test it or tell me what
| awk you have?
| I'll try downloading some other awks to test this.

| diff --git a/src/genprops.awk b/src/genprops.awk
| --- a/src/genprops.awk
| +++ b/src/genprops.awk
| @@ -465,9 +465,11 @@
|      {
|        dval = defval[i];
|        if (type[i] == "radio_property" || type[i] == "color_property")
| -        dval = gensub (/^.*\{(.*)\}.*$/, "\"\\1\"", "g", dval);
| -      if (! dval)
| -        dval = "octave_value ()";
| + if (match (dval, /^.*\{(.*)\}.*$/, res))
| +  dval = "\"" + res[1] + "\"";
| + else
| +  dval = "octave_value ()";
| +
|        printf ("  m[\"%s\"] = %s%s;\n", name[i], dval,
|   (type[i] == "handle_property" ? ".as_octave_value ()" : "")) >> filename;
|      }

The AWK book only documents a two-argument version of match, but notes
that it sets RSTART and RLENGTH.  I see that mawk fails for this:

  echo "foo bar baz" | mawk '{match ($0, /^foo ([^ ]*)/, res); print res[1]; }'
  mawk: line 1: syntax error at or near ,

The following doesn't fail, but it doesn't really do the right thing
either:

  echo "foo bar baz" | gawk '{match ($0, /^foo ([^ ]*)/); print RSTART, RLENGTH; }'
  1 7

Note RSTART and RLENGTH cover the entire regexp, not just the part in
parens.  So I guess something else is needed if you want this to be
portable.

jwe

Re: mercurial in OS 10.4.11 (was imread/imwrite)

by Jaroslav Hajek-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, Jun 20, 2008 at 10:28 PM, John W. Eaton <jwe@...> wrote:

> On 20-Jun-2008, Jaroslav Hajek wrote:
>
> | On Fri, Jun 20, 2008 at 9:49 AM, David Bateman
> | <David.Bateman@...> wrote:
> | > Thomas L. Scofield wrote:
> | >>
> | >> I've been using some scripts that Ben Abbott supplied me with.  The
> | >> main script is
> | >>
> | >> cd ~/devel/mercurial/octave
> | >> hg update -C default
> | >> cd ..
> | >> if [ -d "octave-3.0.0" ]; then
> | >>         rm -r octave-3.0.0
> | >> fi
> | >> if [ -f "octave-3.0.0.tar.gz" ]; then
> | >>         rm octave-3.0.0.tar.gz
> | >> fi
> | >> cp -r octave octave-3.0.0
> | >> cd octave-3.0.0
> | >> ../osx_fix.sh
> | >> ./autogen.sh
> | >> cd ..
> | >> tar cvzf octave-3.0.0.tar.gz octave-3.0.0
> | >> md5 octave-3.0.0.tar.gz
> | >> echo "(1) Add md5 to octave.info"
> | >> mate "/sw/fink/10.4/local/main/finkinfo/sci/octave.info"
> | >> sudo cp octave-3.0.0.tar.gz /sw/src/.
> | >> sudo fink rebuild octave
> | >> sudo fink remove octave
> | >> sudo fink install octave
> | >>
> | >>
> | >> while the osx_fix.sh script does as he describes in this note to
> | >> Maintainers
> | >>
> | >> http://www.cae.wisc.edu/pipermail/octave-maintainers/2008-April/006941.html
> | >>
> | >>
> | >> Things progress along quite well for some time into the "make"
> | >> process.  Here are the last few lines of output:
> | >>
> | >> make -C src all
> | >> making DASPK-opts.cc from ../liboctave/DASPK-opts.in
> | >> making DASRT-opts.cc from ../liboctave/DASRT-opts.in
> | >> making DASSL-opts.cc from ../liboctave/DASSL-opts.in
> | >> making LSODE-opts.cc from ../liboctave/LSODE-opts.in
> | >> making NLEqn-opts.cc from ../liboctave/NLEqn-opts.in
> | >> making Quad-opts.cc from ../liboctave/Quad-opts.in
> | >> making defaults.h from defaults.h.in
> | >> making graphics.h
> | >> awk: syntax error at source line 413 in function emit_source source
> | >> file ./genprops.awk
> | >>  context is
> | >>                 dval = gensub >>>  (/^.*\{(.*)\}.*$/, <<<  "\"\\1\"",
> | >> "g", dval);
> | >> awk: illegal statement at source line 414 in function emit_source
> | >> source file ./genprops.awk
> | >> awk: syntax error at source line 439 source file ./genprops.awk
> | >> make[2]: *** [graphics.h] Error 2
> | >> make[1]: *** [src] Error 2
> | >> make: *** [all] Error 2
> | >> ### execution of /var/tmp/tmp.2.W8ECNr failed, exit code 2
> | >
> | > You need "gawk" and not "awk" to be used.. Unfortunately the
> | > genprops.awk script uses a "gawk"-ism and there is no obvious way to
> | > remove. However, I'd be all for making genprops.awk vanilla awk
> | > compatible if possible.
> | >
> | > http://www.nabble.com/Again-error-with-graphics.h-to17487289.html
> | >
> | > where its explained the issue is related to the gensub versus gsub
> | > functions in gawk.
> | >
> |
> |
> | I believe the attached patch could work, because match should be POSIX
> | with all features included. Thomas, can you test it or tell me what
> | awk you have?
> | I'll try downloading some other awks to test this.
>
> | diff --git a/src/genprops.awk b/src/genprops.awk
> | --- a/src/genprops.awk
> | +++ b/src/genprops.awk
> | @@ -465,9 +465,11 @@
> |      {
> |        dval = defval[i];
> |        if (type[i] == "radio_property" || type[i] == "color_property")
> | -        dval = gensub (/^.*\{(.*)\}.*$/, "\"\\1\"", "g", dval);
> | -      if (! dval)
> | -        dval = "octave_value ()";
> | +     if (match (dval, /^.*\{(.*)\}.*$/, res))
> | +       dval = "\"" + res[1] + "\"";
> | +     else
> | +       dval = "octave_value ()";
> | +
> |        printf ("  m[\"%s\"] = %s%s;\n", name[i], dval,
> |                (type[i] == "handle_property" ? ".as_octave_value ()" : "")) >> filename;
> |      }
>
> The AWK book only documents a two-argument version of match, but notes
> that it sets RSTART and RLENGTH.  I see that mawk fails for this:
>
>  echo "foo bar baz" | mawk '{match ($0, /^foo ([^ ]*)/, res); print res[1]; }'
>  mawk: line 1: syntax error at or near ,
>
> The following doesn't fail, but it doesn't really do the right thing
> either:
>
>  echo "foo bar baz" | gawk '{match ($0, /^foo ([^ ]*)/); print RSTART, RLENGTH; }'
>  1 7
>
> Note RSTART and RLENGTH cover the entire regexp, not just the part in
> parens.  So I guess something else is needed if you want this to be
> portable.
>
> jwe
>
Okay, so what about the following? It's the "good old way", using only
index and substr.
This should definitely be POSIX compatible...

--
RNDr. Jaroslav Hajek
computing expert
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz

[genprops.awk.diff]

# HG changeset patch
# User Jaroslav Hajek <highegg@...>
# Date 1213997924 -7200
# Node ID f97dc6cba12f9bc6f530ea401ea118e0415f85e7
# Parent  fbf0cafeb0aef93e6a93f44eda561db20f379a93
avoid using gensub in genprops.awk

diff --git a/src/ChangeLog b/src/ChangeLog
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2008-06-20  Jaroslav Hajek <highegg@...>
+
+ * genprops.awk (emit_source): Avoid gensub to ensure compatibility.
+ (BEGIN): dtto
+
 2008-06-17  John W. Eaton  <jwe@...>
 
  * toplev.h, toplev.cc (class octave_call_stack):
diff --git a/src/genprops.awk b/src/genprops.awk
--- a/src/genprops.awk
+++ b/src/genprops.awk
@@ -465,9 +465,16 @@
     {
       dval = defval[i];
       if (type[i] == "radio_property" || type[i] == "color_property")
-        dval = gensub (/^.*\{(.*)\}.*$/, "\"\\1\"", "g", dval);
-      if (! dval)
-        dval = "octave_value ()";
+ {
+  k = index (dval, "{");
+  dval = substr (dval, k+1);
+  l = index (dval, "}");
+  if (k > 0 && l > 0)
+    dval = "\"" + substr (dval, 1, l-1) +  "\"";
+  else
+    dval = "octave_value ()";
+ }
+
       printf ("  m[\"%s\"] = %s%s;\n", name[i], dval,
  (type[i] == "handle_property" ? ".as_octave_value ()" : "")) >> filename;
     }
@@ -490,7 +497,11 @@
 /BEGIN_PROPERTIES\(.*\)/ {
   gather = 1;
   idx = 0;
-  class_name = gensub (/^.*BEGIN_PROPERTIES\((.*)\)/, "\\1", "g");
+  str = $0;
+  k = index (str, "BEGIN_PROPERTIES(");
+  str = substr (str, k + 17);
+  l = index (str, ")");
+  class_name = substr (str, 1, l-1);
   next;
 }
 


Re: mercurial in OS 10.4.11 (was imread/imwrite)

by dbateman :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Jaroslav Hajek-2 wrote:
Okay, so what about the following? It's the "good old way", using only
index and substr.
This should definitely be POSIX compatible...
snip

@@ -490,7 +497,11 @@
 /BEGIN_PROPERTIES\(.*\)/ {
   gather = 1;
   idx = 0;
-  class_name = gensub (/^.*BEGIN_PROPERTIES\((.*)\)/, "\\1", "g");
+  str = $0;
+  k = index (str, "BEGIN_PROPERTIES(");
+  str = substr (str, k + 17);
+  l = index (str, ")");
+  class_name = substr (str, 1, l-1);
   next;
 }
Doesn't the "g" in the gensub command mean "global" so I expect you also need a loop for the above.

D.

Re: mercurial in OS 10.4.11 (was imread/imwrite)

by Jaroslav Hajek-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sat, Jun 21, 2008 at 12:06 AM, dbateman <dbateman@...> wrote:

>
>
>
> Jaroslav Hajek-2 wrote:
>>
>> Okay, so what about the following? It's the "good old way", using only
>> index and substr.
>> This should definitely be POSIX compatible...
>>
>
> snip
>
>
>
>> @@ -490,7 +497,11 @@
>>  /BEGIN_PROPERTIES\(.*\)/ {
>>    gather = 1;
>>    idx = 0;
>> -  class_name = gensub (/^.*BEGIN_PROPERTIES\((.*)\)/, "\\1", "g");
>> +  str = $0;
>> +  k = index (str, "BEGIN_PROPERTIES(");
>> +  str = substr (str, k + 17);
>> +  l = index (str, ")");
>> +  class_name = substr (str, 1, l-1);
>>    next;
>>  }
>>
>
> Doesn't the "g" in the gensub command mean "global" so I expect you also
> need a loop for the above.
>

It does, but there are never multiple BEGIN_PROPERTIES on the same
line in graphics.h.in and I think there should never be. Also, the GNU
Awk manual says that sub, gsub and gensub search for "the leftmost,
longest" match, so the original gensub would not work either for
multiple decls on the same line.
A similar case is the one with {} matching - there should always be at
most one default value.


> D.
>
> --
> View this message in context: http://www.nabble.com/imread-imwrite-tp18018475p18038201.html
> Sent from the Octave - Maintainers mailing list archive at Nabble.com.
>
>



--
RNDr. Jaroslav Hajek
computing expert
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz

Re: mercurial in OS 10.4.11 (was imread/imwrite)

by John W. Eaton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 20-Jun-2008, Jaroslav Hajek wrote:

| On Fri, Jun 20, 2008 at 10:28 PM, John W. Eaton <jwe@...> wrote:
|
| > The AWK book only documents a two-argument version of match, but notes
| > that it sets RSTART and RLENGTH.  I see that mawk fails for this:
| >
| >  echo "foo bar baz" | mawk '{match ($0, /^foo ([^ ]*)/, res); print res[1]; }'
| >  mawk: line 1: syntax error at or near ,
| >
| > The following doesn't fail, but it doesn't really do the right thing
| > either:
| >
| >  echo "foo bar baz" | gawk '{match ($0, /^foo ([^ ]*)/); print RSTART, RLENGTH; }'
| >  1 7
| >
| > Note RSTART and RLENGTH cover the entire regexp, not just the part in
| > parens.  So I guess something else is needed if you want this to be
| > portable.
| >
| > jwe
| >
|
| Okay, so what about the following? It's the "good old way", using only
| index and substr.
| This should definitely be POSIX compatible...

I checked it in.

Thanks,

jwe