[Debian-med-packaging] C help needed for new version of tifffile

Christian Seiler christian at iwakd.de
Thu Oct 5 19:51:39 UTC 2017


Hi Andreas,

On 10/05/2017 09:00 PM, Andreas Tille wrote:
> It seems that the definition of GET_NEXT_CODE is just wrong - but
> what would be correct?

So the code contains the following:

#define GET_NEXT_CODE \
    code = *((uint32_t*)((void*)(encoded + (bitcount >> 3)))); \
    if (little_endian) \
        code = SWAP4BYTES(code); \
    code <<= (uint32_t)(bitcount % 8); \
    code &= mask; \
    code >>= shr; \
    bitcount += bitw; \
static PyObject*

Clearly the static PyObject* should not be part of the macro, but in fact it
is. The other compiler warnings you see are actually a result of that:

> tifffile.c:575:1: warning: return type defaults to 'int' [-Wimplicit-int]
>  py_decodelzw(PyObject* obj, PyObject* args)
>  ^~~~~~~~~~~~
> tifffile.c: In function 'py_decodelzw':
> tifffile.c:590:16: warning: return makes integer from pointer without a cast [-Wint-conversion]
>          return NULL;
>                 ^~~~

The py_decodelzw should actually return a PyObject* and not an int, but
the return type is absorbed into the macro.

And the reason why you had the problem is that the getorig.sh script
in the package downloads a pretty-printed version of the C file from
a website and the conversion procedure removes all empty lines. The
upstream source code does have the issue that the trailing \ is in
the last line of the macro - but since the next line is an empty line
anyway it doesn't actually cause any problems upstream.

This appears to be a problem in links (which you use to dump the plain
text) that when a line within <pre> starts with a tag (e.g.
<a name="line-X"> as in the highlighter used here, it strips out any
empty lines:

$ links -dump /dev/stdin <<EOF
<!DOCTYPE html>
<html>
<head>
<title>Text dump test</title>
</head>
<body>
<pre>
<a name="line-1"></a>Hello
<a name="line-2"></a>World
<a name="line-3"></a>
<a name="line-4"></a>A
<a name="line-5"></a>B
<a name="line-6"></a>C
</pre>
</body>
</html>
EOF

 Hello
 World
 A
 B
 C

While browsers keep them. You should probably report that to the
links people.

You can get the original C file as text/plain by removing the ".html"
from the URL, but that doesn't work for the Python file, so I'm not
sure that that is intentional by the author. You should really ask
the upstream author to provide a proper download URI for the original
source files so that you don't have to do all this weird things.
Maybe suggest that they make those available if you add ".txt"
instead of ".html".

In the mean time: lynx -dump doesn't appear to suffer from this
issue, and it also doesn't add a whitespace to the beginning of every
line, so you could easily just use lynx -dump instead of links -dump
in getorig.sh for now. (And drop the 'sed' there.) But again: I don't
think that converting syntax-highlighted HTML of the original source
back to the original source is the best of ideas, it would be much
better if the original source were directly available in text form.

Hope that helps...

Regards,
Christian



More information about the Debian-med-packaging mailing list