The mysterious "Call" function 
Author Message
 The mysterious "Call" function

'allo.

I'm looking at the C source to the ZLIB compression library and have
run into this line:

Call UPDATE_HASH() MIN_MATCH-3 more times

The Q is what the heck does "Call" mean?

I have a vague recollection that's it's a preprocessor directive and
it certainly looks and feels like one (UPDATE_HASH is a macro) but I
can't find any documentation on. (Try doing a keyword search on "call"
and see how many pages you get. :)

Anyone provide a link of the syntax?

Thanks,
--min



Tue, 01 Nov 2005 12:25:57 GMT  
 The mysterious "Call" function

Quote:
> 'allo.

> I'm looking at the C source to the ZLIB compression library and have
> run into this line:

> Call UPDATE_HASH() MIN_MATCH-3 more times

> The Q is what the heck does "Call" mean?

The answer is "ask the authors of the library."
This has nothing to do with the topic of
comp.lang.c, which is the ISO standard C
language.

Quote:

> I have a vague recollection that's it's a preprocessor directive and
> it certainly looks and feels like one (UPDATE_HASH is a macro) but I
> can't find any documentation on. (Try doing a keyword search on "call"
> and see how many pages you get. :)

I asked google to find "ZLIB".  The first hit was:
http://www.gzip.org/zlib/

Looks like the place to start to me.
I see links there to a FAQ and a manual.

Quote:

> Anyone provide a link of the syntax?

Before posting here again, please see:
http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html

and please restrict your posts here
to the topic described therein.

Thank you.

-Mike



Tue, 01 Nov 2005 12:50:40 GMT  
 The mysterious "Call" function

Quote:
>'allo.

>I'm looking at the C source to the ZLIB compression library and have
>run into this line:

>Call UPDATE_HASH() MIN_MATCH-3 more times

>The Q is what the heck does "Call" mean?

"Call" is used here with the plain "programmer English" meaning:
"invoke the UPDATE_HASH() macro/function MIN_MATCH-3 more times".

Dan
--
Dan Pop
DESY Zeuthen, RZ group



Tue, 01 Nov 2005 23:01:54 GMT  
 The mysterious "Call" function

Quote:

> "Call" is used here with the plain "programmer English" meaning:
> "invoke the UPDATE_HASH() macro/function MIN_MATCH-3 more times".

In other words, you're looking at a comment, not code.  (Although it is
in a context were it *should* be code.  The intent, presumably, is to
produce a compile should that line ever be compiled whilst commenting
what kind of code needs to be written to resolve it.)

-Larry Jones

Oh, now YOU'RE going to start in on me TOO, huh? -- Calvin



Wed, 02 Nov 2005 04:20:55 GMT  
 The mysterious "Call" function

Quote:

>>'allo.

>>I'm looking at the C source to the ZLIB compression library and have
>>run into this line:

>>Call UPDATE_HASH() MIN_MATCH-3 more times

>>The Q is what the heck does "Call" mean?

>"Call" is used here with the plain "programmer English" meaning:
>"invoke the UPDATE_HASH() macro/function MIN_MATCH-3 more times".

Yep. You're completely correct. Had a chat with the original author
about it -- he was amused. ;-)

I'd just never actually ran into code where the author purposely made
a conditional where it would crash the compiler with plain english
before. What was confusing me is that there actually WAS a variable
named "more" defined a few lines before the statement, etc.. Was
thinking it was all some high black-magic C that no one ever let me in
on. ;-)

Quote:
>Dan

Thanks,
--min


Wed, 02 Nov 2005 04:58:15 GMT  
 The mysterious "Call" function
 > I'm looking at the C source to the ZLIB compression library and have
 > run into this line:
 >
 > Call UPDATE_HASH() MIN_MATCH-3 more times
 >
 > The Q is what the heck does "Call" mean?

This is on-topic, I think, but only by the slimmest of margins.  It's
really a question about reading C source code.

You didn't include a sufficiently large fragment.  This line appears
twice in deflate.c, and in context reads:

#if MIN_MATCH != 3
             Call UPDATE_HASH() MIN_MATCH-3 more times
#endif

which is a clue.  When you compile this source, what is MIN_MATCH
defined as?  It's 3, and this line is removed during the preprocessing step.

This line is not C.  It's English, and it's a comment directed to
maintainers.  It's not a C comment (ie surrounded by /* */) presumably
because the author (Jean-loup Gailly, apparently) felt it's sufficiently
important to cause an error during translation (which it would, since
the UPDATE_HASH macro takes three parameters and they're not supplied
here, which is a constraint violation and requies a diagnostic, even if
there weren't other problems).  The idea is that if some clever sort
mucks with the definition of MIN_MATCH, they'll get an error from the
compiler which will prod them into understanding how deflate.c works and
what else they need to change to hope to have a working program.

There are better ways to do this sort of thing, of course, notably the
#error preprocessing directive.  But perhaps the author wasn't familiar
with #error, or wanted to support some broken implementation that didn't
support it.

The m{*filter*}of the story: Preprocessing directives are part of the source,
and if you want to understand the source, you'd best understand the
preprocessing directives.

--
Michael Wojcik
Micro Focus International



Wed, 02 Nov 2005 04:23:41 GMT  
 The mysterious "Call" function
On Fri, 16 May 2003 16:23:41 -0400, Michael Wojcik

Quote:


> > I'm looking at the C source to the ZLIB compression library and have
> > run into this line:

> > Call UPDATE_HASH() MIN_MATCH-3 more times

> > The Q is what the heck does "Call" mean?

>This is on-topic, I think, but only by the slimmest of margins.  It's
>really a question about reading C source code.

>You didn't include a sufficiently large fragment.  This line appears
>twice in deflate.c, and in context reads:

>#if MIN_MATCH != 3
>             Call UPDATE_HASH() MIN_MATCH-3 more times
>#endif

>which is a clue.  When you compile this source, what is MIN_MATCH
>defined as?  It's 3, and this line is removed during the preprocessing step.

>This line is not C.  It's English, and it's a comment directed to
>maintainers.  It's not a C comment (ie surrounded by /* */) presumably
>because the author (Jean-loup Gailly, apparently) felt it's sufficiently
>important to cause an error during translation (which it would, since

Yes, I've talked to him since the original post. That was exactly his
original intent.

The problem was there is a LOT of macro expansion code going on in the
source code (as you are probably well aware at since you've since the
C source). There was also a variable called "more" declared a few
lines few before the line in question.

In other words, except for "times" everything else was an in-scope
macro or variable. After a very long day ripping apart obscure macro's
(I'm tasked with converting the entire thing to standard C++) ...
well... just needed to step back and get some fresh eyes . :)

Quote:
>the UPDATE_HASH macro takes three parameters and they're not supplied
>here, which is a constraint violation and requies a diagnostic, even if
>there weren't other problems).  The idea is that if some clever sort

True. True. But there ARE three parms after the Call names the
UPDATE_HASH function. ;-) Things like that just conspired to make me
think perhaps it was some strange macro syntax.

Just a classic case of over-thinking a problem.

Quote:
>mucks with the definition of MIN_MATCH, they'll get an error from the
>compiler which will prod them into understanding how deflate.c works and
>what else they need to change to hope to have a working program.

>There are better ways to do this sort of thing, of course, notably the
>#error preprocessing directive.  But perhaps the author wasn't familiar
>with #error, or wanted to support some broken implementation that didn't
>support it.

Absoutely agreed. If there had been a #warning or #error in front of
it it would have clued me in immediately. Part of the problem with
their C source is it tries to be friendly to every compiler ever made
(it even works on 16-bit 8086 machines - yuck). I forgot to ask, but
I'm sure that's probably why he did it that way.

I think that's ISO standard across platforms now though isn't it?
Maybe not. I'll have to look that up later. ... Ah. It does seem to be
part of the ANSI standard. Specifically:

"The directive #error has been introduced to provide an explicit
mechanism for forcing translation to fail under certain conditions.
...  Traditionally such failure has had to be forced by inserting text
so ill-formed that the translator gagged on it. "

Cool.

I voluntered to go over the 1.2 beta's of zlib. Adding a nice #error
would have to be at the top the "fix me" list I'd have to say. ;-)

Quote:
>The m{*filter*}of the story: Preprocessing directives are part of the source,
>and if you want to understand the source, you'd best understand the
>preprocessing directives.

Especially the one's that don't actually exist. ;->

--min



Wed, 02 Nov 2005 12:04:34 GMT  
 The mysterious "Call" function


Quote:


> >'allo.

> >I'm looking at the C source to the ZLIB compression library and have
> >run into this line:

> >Call UPDATE_HASH() MIN_MATCH-3 more times

> >The Q is what the heck does "Call" mean?

> "Call" is used here with the plain "programmer English" meaning:
> "invoke the UPDATE_HASH() macro/function MIN_MATCH-3 more times".

Interesting question.  While I believe that functions and subroutines can be
called (consider call by value, call by reference) it is hard to describe a
macro as being called.  But since they look like, and sometimes act like
function calls the word does make some sence.

-- glen



Thu, 03 Nov 2005 07:30:52 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Mysterious "Unable to create object"

2. mysterious "do nothing" statement

3. How to call the function "RasEnumEntries"

4. function call with "pipe"

5. what is called a "hush function"?

6. "Pure Virtual Function Call"

7. Passing "callback" function to a function

8. about "call by value" and "call by reference"

9. "c" calling Fortran, and Fortran calling "c"

10. remove() vrs fopen("""w")

11. Displaying binary data as ascii "1"'s and "0"'s

12. Looking for "Shroud"/"Obfus"

 

 
Powered by phpBB® Forum Software