Re: has_parent() oddity

[email protected] Tue, 18 Feb 2014 18:49:58 -0500
Newsgroups gmane.network.slrn.user
Message-ID <[email protected]>
J.B. Nicholson-Owens <[email protected]> wrote:
> It seems to me that if has_parent() returns non-zero, one ought to be 
> able to identify the article that is that article's parent, even if that 
> article is not present on the server.

In this case, neither of the articles you mentioned reference
anything.  But because the subjects are the same, slrn associates them
as part of a common thread.  In addition to creating a tree structure
to represent the thread, slrn also adds metadata to the tree that the
screen management routines use to draw the thread tree.  The metadata
are encoded into the flag bits of each article.  The intrinsic
function `get_header_flags` may be used to retrieve some of those
bits.  However, it does not return the ones that may interest you.

Appended below is a patch for the get_header_flags function in
interp.c that will return all of the flags when passed an optional
non-zero integer:

   some_flags = get_header_flags ();
   some_flags = get_header_flags (0);
   all_flags = get_header_flags (1);

Using this function (after applying the patch), to create other
helper functions that may be of use to you:

   define has_fake_parent ()
   {
      return get_header_flags(1) & 0x0400;
   }

   define has_fake_children ()
   {
      return get_header_flags(1) & 0x800;
   }

   define has_real_parent ()
   {
      return has_parent() && not has_fake_parent();
   }

Let me know if this change is useful.  If so, I will add it to the
next snapshot.  Thanks, --John

diff --git a/src/interp.c b/src/interp.c
index 9d1e964..35b523f 100644
--- a/src/interp.c
+++ b/src/interp.c
@@ -1102,10 +1102,19 @@ static int header_next_unread (void)
 
 static int get_header_flags (void) /*{{{*/
 {
+   unsigned int mask = HEADER_HARMLESS_FLAGS_MASK;
+   if (SLang_Num_Function_Args == 1)
+     {
+	int i;
+	if (-1 == SLang_pop_integer (&i))
+	  return -1;
+	if (i) mask = 0xFFFFFFFFU;
+     }
+
    if ((-1 == check_article_mode ())
        || (Slrn_Current_Header == NULL))
      return 0;
-   return (int) (Slrn_Current_Header->flags & HEADER_HARMLESS_FLAGS_MASK);
+   return (int) (Slrn_Current_Header->flags & mask);
 }
 
 /*}}}*/

------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk