🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.readers
9 messages
9 total messages Started by Lloyd Zusman Sun, 30 Aug 1998 00:00
[slrn] Could extract_article_header() return # of lines?
#42942
Author: Lloyd Zusman
Date: Sun, 30 Aug 1998 00:00
18 lines
1107 bytes
I'm using slrn (0.9.5.2) and I'm wondering if there's any way that the
`extract_article_header()' intrinsic could be modified to also return
the number of lines in the article.  I'd be happy if this was simply
the contents of the "Lines:" header, which is currently ignored by
`extract_acticle_header()'.

I'm happy to supply a patch to slrn which would provide this
functionality, but before I do, I'm wondering if there is some
compelling reason for not doing this.

Any thoughts?

-- 
 Lloyd Zusman
 ljz@asfast.com
 God bless you.

Re: [slrn] Could extract_article_header() return # of lines?
#42931
Author: Dawn Owens-Nicholson
Date: Sun, 30 Aug 1998 00:00
42 lines
2585 bytes
Lloyd Zusman <ljz@asfast.com> wrote:
> And I think that your function could be speeded up by eliminating the
> dual calls to `extract_article_header', as follows:

Yes, thanks!

> define bugfix_extract_article_header_2 (header) {
> 
>    if (is_group_mode ())
>      error (_function_name () + "doesn\'t work in group mode");
> 
>    switch (header)
>      { case ("Message-ID") :
>          return (strtrim (extract_article_header (retval)));

Whoops -- I'm pretty sure you meant "header" instead of "retval" there.

> Also, I applied my patch to `slrn_extract_header' in art.c, and it
> works great.  With this patch, there would be no need for the S-Lang
> `extract_article_header()' workaround, and everything runs faster.

Thanks again, I look forward to using it; ultimately, that's what is
needed--a fix for the slrn source.

> I'm doing more work within `slrn_extract_header' to handle trimming
> problems with "Message-Id" and elsewhere.  I'll post the updated patch
> when I'm finished.

I'm not sure the problem is centered in that function, because following up
and replying after viewing the article also show a leading space in some
headers (Newsgroups: and References: as I write this--I'll leave the leading
space in so you can see what I'm talking about).  I'm guessing there is some
common code that erroneously puts the whitespace in there and this might
affect more than message-ID: header retreives.

If you happen to stumble on an obscure bug where one can make multi-article
threads where a one-article thread existed before, I'd appreciate any info
you have on it.  I'm hitting that in my macros but I have no solid idea what
I'm doing to cause it.  All I know for sure right now is that I shouldn't be
able to do something that I'm making slrn do.

Re: [slrn] Could extract_article_header() return # of lines?
#42933
Author: Lloyd Zusman
Date: Sun, 30 Aug 1998 00:00
86 lines
3951 bytes
bluemoon@ux6.cso.uiuc.edu (Dawn Owens-Nicholson) writes:

> Lloyd Zusman <ljz@asfast.com> wrote:
> > Hmmm ... how would I do that?  Here's some sample code that
> > illustrates how I'm traversing all the articles in a given newsgroup.
> 
> You could make a wrapper for extract_article_header() that will work around
> the bugs or include similar code in your function, I'll demonstrate both
> ways.  [ ... ]
> 
> The workaround:

Thanks ... this shows the answer I was looking for: to call
"select_article" to grab each article.

And I think that your function could be speeded up by eliminating the
dual calls to `extract_article_header', as follows:

% Bugfix for slrn's extract_article_header()             % -*- slang -*-
%
% Fixes extract_article_header() for known problem areas:
%   Message-ID -- remove leading (and trailing, if any) whitespace.
%   Lines      -- return as an integer after selecting/deselecting article.

define bugfix_extract_article_header_2 (header) {

   if (is_group_mode ())
     error (_function_name () + "doesn\'t work in group mode");

   switch (header)
     { case ("Message-ID") :
         return (strtrim (extract_article_header (retval)));
     }
     { case ("Lines")      :
	variable article_was_visible = is_article_visible ();
	call ("select_article");
	!if (article_was_visible) call ("hide_article");
	return (integer (strtrim (extract_article_header (header))));
     }
     { return (extract_article_header (header)); }
}
 
> [ ... ]

> Or you can put this in your code:
> 
> [ ... etc. ... ]

This second example (deleted to save space) illustrates another way
to grab the appropriate article: to call "scroll_dn" when looking
for "Lines" (and using `is_article_visible()' and "hide_article"
as required).

> [ ... ]
>
> By the way, the "variable" calls inside the loop will fail in S-Lang 1.x if
> the do-while loop executes more than once--you'll be declaring a variable
> that already exists and that's an error in S-Lang.  You'll need to move
> those declarations before the loop.  What you've got works in S-Lang prior
> to 1.x, however.  I don't know what version of S-Lang you're using, so I
> thought I'd mention it.

Thanks.  In my example, I had taken some code that was resident in a
subroutine and explicitly stuck it in the outer loop ... that's where
the `variable' calls came from.  In "real life", this problem wouldn't
have occurred.  But I hadn't thought about how these `variable'
declarations work, so I'll check the rest of my S-Lang macros, which
might contain one or more of these `variable' calls within loops.

> Hope this helps!

It does.  Thanks again.

Also, I applied my patch to `slrn_extract_header' in art.c, and it
works great.  With this patch, there would be no need for the S-Lang
`extract_article_header()' workaround, and everything runs faster.

I'm doing more work within `slrn_extract_header' to handle trimming
problems with "Message-Id" and elsewhere.  I'll post the updated patch
when I'm finished.

-- 
 Lloyd Zusman
 ljz@asfast.com

Re: [slrn] Could extract_article_header() return # of lines?
#42934
Author: Lloyd Zusman
Date: Sun, 30 Aug 1998 00:00
116 lines
5032 bytes
bluemoon@ux6.cso.uiuc.edu (Dawn Owens-Nicholson) writes:

> Lloyd Zusman <ljz@asfast.com> wrote:
> > I'd be happy if this was simply the contents of the "Lines:" header, which
> > is currently ignored by `extract_acticle_header()'.
> 
> I believe it's a bug in extract_article_header().  extract_article_header()
> doesn't ignore Lines:, you have to make the target article the most recently
> read article (selecting the article and, optionally, hiding it, for
> instance) in order for extract_article_header("Lines") to do the right
> thing.

Hmmm ... how would I do that?  Here's some sample code that
illustrates how I'm traversing all the articles in a given newsgroup.
Note that if I'm looking for certain other headers (such as the "From"
header), this works fine.  Also note that my application requires that
I do this within `article_mode_hook()' ...

  %%% Sample only ...
  define article_mode_hook ()
  {
     call( "header_bob" );
     uncollapse_threads();

     do
     {
        %%% What do I do here to make each article the
        %%% 'most recently read' article?

        variable stringLines = extract_article_header( "Lines" );
        variable integerLines = integer( strtrim( stringLines ) );

        %%% At this point, `stringLines' is the empty string and
        %%% `integerLines' is zero.

        variable stringFrom = extract_article_header( "From" );

        %%% At this point, `stringFrom' contains the text from
        %%% the appropriate "From:" line.

     } while ( header_down( 1 ) );

     collapse_threads();
     call( "header_bob" );
  }

> [ ... ]
> 
> > I'm happy to supply a patch to slrn which would provide this functionality,
> > but before I do, I'm wondering if there is some compelling reason for not
> > doing this.
> 
> I can't think of any, but there are two bugs here, one of which I think JED
> already knows about (the leading whitespace bug).

Here's a potential fix for one of the bugs.  It allows the "Lines"
header to be recognized even if the header is not for the "most
recently raed" article.

The `slrn_extract_header' routine in `art.c' is what gets called by
`extract_article_header'.  Here's the beginning of the code in this
routine (with some of the lines wrapped to fit within 80 columns):

  char *slrn_extract_header (char *hdr, unsigned int len) /*{{{*/
  {
     Slrn_Article_Line_Type *l;
     
     if (Slrn_Current_Header == NULL)
       return NULL;
  
     if ((len > 2) && (hdr[len-1] == ' ') && (hdr[len-2] == ':'))
       len--;
  
     if (Slrn_Current_Header != Header_Showing)
       {
          if (0 == slrn_case_strncmp ((unsigned char *)"From: ",
                                (unsigned char *) hdr, len))
            return Slrn_Current_Header->from;
          if (0 == slrn_case_strncmp ((unsigned char *)"Subject: ",
                                (unsigned char *)hdr, len))
            return Slrn_Current_Header->subject;
          if (0 == slrn_case_strncmp ((unsigned char *)"Message-Id: ",
                                (unsigned char *)hdr, len))
            return Slrn_Current_Header->msgid;
          if (0 == slrn_case_strncmp ((unsigned char *)"Date: ",
                                (unsigned char *) hdr, len))
            return Slrn_Current_Header->date;
          if (0 == slrn_case_strncmp ((unsigned char *)"References: ",
                                (unsigned char *)hdr, len))
            return Slrn_Current_Header->refs;
          if (0 == slrn_case_strncmp ((unsigned char *)"Xref: ",
                                (unsigned char *) hdr, len))
            return Slrn_Current_Header->from;

          /***** FIX STARTS HERE *****/
          if (0 == slrn_case_strncmp ((unsigned char *)"Lines: ",
                                (unsigned char *) hdr, len))
             {
               static char linesBuf[16];
               sprintf(linesBuf, "%d", Slrn_Current_Header->lines);
               return linesBuf;
             }
          /***** FIX ENDS HERE *****/

          return NULL;
       }

       /* ... etc. ... */

Can anyone see anything wrong with this proposed fix?

-- 
 Lloyd Zusman
 ljz@asfast.com

[slrn] PATCH: fixes for extract_article_header()
#42935
Author: Lloyd Zusman
Date: Sun, 30 Aug 1998 00:00
147 lines
6355 bytes
I have a patch which (I hope!) fixes a couple bugs in that show up in
the `extract_article_header()' routine in Slrn.  This routine is
actually a front end to `slrn_extract_header' in `art.c' in the Slrn
source, and this is where this patch gets applied.

Note that this patch is only valid for version 0.9.5.2 of Slrn.

One of the bugs that this patch fixes is that it will return the
"Lines:" value, even if it is applied to a header for a non-selected
article (other headers, such as "From:", "Subject:", etc. already work
properly within `extract_article_header' for non-selected articles).

This patch also does the equivalent of an `strtrim()' on the results
that it returns for all possible headers [NOTE: do we really want this
behavior for *all* headers?]

Another bug also gets fixed in this patch.  In the case where
`extract_article_header()' gets applied to the currently-selected
article (and *only* in this case), it's possible that incorrect
results could be returned.  For example, assume that the following
header appears in the currently-selected article ...

  Subject: Foo bar

In this case, the result of `extract_article_header("Subj")' would be

  ect: Foo bar

At least this appears to be the way that 0.9.5.2 works, given the way
the C code is written.  I have also fixed this in my patch.

I hope that some of you will test and evaluate this patch, to make
sure that I haven't introduced some new errors.  Everything looks good
so far in my own testing, but one never knows ...

Lloyd Zusman
ljz@asfast.com

--------------------------- patch begins here ---------------------------
*** art.c.orig	Sun Aug 30 18:58:31 1998
--- art.c	Sun Aug 30 19:39:52 1998
***************
*** 868,873 ****
--- 868,875 ----
  char *slrn_extract_header (char *hdr, unsigned int len) /*{{{*/
  {
     Slrn_Article_Line_Type *l;
+    char *result = NULL;
+    int found;
     
     if (Slrn_Current_Header == NULL)
       return NULL;
***************
*** 878,895 ****
     if (Slrn_Current_Header != Header_Showing)
       {
  	if (0 == slrn_case_strncmp ((unsigned char *)"From: ", (unsigned char *)hdr, len))
! 	  return Slrn_Current_Header->from;
! 	if (0 == slrn_case_strncmp ((unsigned char *)"Subject: ", (unsigned char *)hdr, len))
! 	  return Slrn_Current_Header->subject;
! 	if (0 == slrn_case_strncmp ((unsigned char *)"Message-Id: ", (unsigned char *)hdr, len))
! 	  return Slrn_Current_Header->msgid;
! 	if (0 == slrn_case_strncmp ((unsigned char *)"Date: ", (unsigned char *)hdr, len))
! 	  return Slrn_Current_Header->date;
! 	if (0 == slrn_case_strncmp ((unsigned char *)"References: ", (unsigned char *)hdr, len))
! 	  return Slrn_Current_Header->refs;
! 	if (0 == slrn_case_strncmp ((unsigned char *)"Xref: ", (unsigned char *)hdr, len))
! 	  return Slrn_Current_Header->from;
! 	return NULL;
       }
     
     l = Slrn_Article_Lines;
--- 880,907 ----
     if (Slrn_Current_Header != Header_Showing)
       {
  	if (0 == slrn_case_strncmp ((unsigned char *)"From: ", (unsigned char *)hdr, len))
! 	  result = Slrn_Current_Header->from;
! 	else if (0 == slrn_case_strncmp ((unsigned char *)"Subject: ", (unsigned char *)hdr, len))
! 	  result = Slrn_Current_Header->subject;
! 	else if (0 == slrn_case_strncmp ((unsigned char *)"Message-Id: ", (unsigned char *)hdr, len))
! 	  result = Slrn_Current_Header->msgid;
! 	else if (0 == slrn_case_strncmp ((unsigned char *)"Date: ", (unsigned char *)hdr, len))
! 	  result = Slrn_Current_Header->date;
! 	else if (0 == slrn_case_strncmp ((unsigned char *)"References: ", (unsigned char *)hdr, len))
! 	  result = Slrn_Current_Header->refs;
! 	else if (0 == slrn_case_strncmp ((unsigned char *)"Xref: ", (unsigned char *)hdr, len))
! 	  result = Slrn_Current_Header->from;
! 	else if (0 == slrn_case_strncmp ((unsigned char *)"Lines: ", (unsigned char *)hdr, len))
! 	  {
! 	     static char headerLines[16];
! 	     sprintf(headerLines, "%d", Slrn_Current_Header->lines);
! 	     return headerLines;
! 	  }
! 	if (NULL == result)
! 	  return NULL;
! 
! 	slrn_trim_string(result);
! 	return slrn_skip_whitespace(result);
       }
     
     l = Slrn_Article_Lines;
***************
*** 903,909 ****
  	     if ((l->next != NULL) && (l->next->flags & WRAPPED_LINE))
  	       unwrap_line (l->next);
  	     
! 	     return l->buf + len;
  	  }
  	l = l->next;
       }
--- 915,948 ----
  	     if ((l->next != NULL) && (l->next->flags & WRAPPED_LINE))
  	       unwrap_line (l->next);
  	     
! 	     /* Someone might have supplied a partial header, such as
! 	      * "Subj".  Therefore, we cannot assume that the end of the
! 	      * supplied header string is the beginning of the data we
! 	      * wish to return.  We need to search for a colon and
! 	      * return the first non-whitespace character which follows it.
! 	      */
! 	     found = 0;
! 	     for (result = l->buf; '\0' != *result; result++)
! 	       {
! 		  if (' ' == *result || '\t' == *result)
! 		    {
! 		       /* ERROR! ... white space before colon.
! 			* Treat this as a non-match.
! 			*/
! 		       break;
! 		    }
! 		  else if (':' == *result)
! 		    {
! 		       result++;
! 		       found = 1;
! 		       break;
! 		    }
! 	       }
! 	     if (!found)
! 	       continue;
! 	     
! 	     slrn_trim_string(result);
! 	     return slrn_skip_whitespace(result);
  	  }
  	l = l->next;
       }

Re: [slrn] Could extract_article_header() return # of lines?
#42937
Author: Dawn Owens-Nicholson
Date: Sun, 30 Aug 1998 00:00
20 lines
1623 bytes
Lloyd Zusman <ljz@asfast.com> wrote:
> I'd be happy if this was simply the contents of the "Lines:" header, which
> is currently ignored by `extract_acticle_header()'.

I believe it's a bug in extract_article_header().  extract_article_header()
doesn't ignore Lines:, you have to make the target article the most recently
read article (selecting the article and, optionally, hiding it, for
instance) in order for extract_article_header("Lines") to do the right
thing.  Then (in slrn 0.9.5.2) you'll probably want to use strtrim() to
remove the whitespace before the returned value (to work around a minor bug).
If you do computations with it, don't forget to make it an integer.

> I'm happy to supply a patch to slrn which would provide this functionality,
> but before I do, I'm wondering if there is some compelling reason for not
> doing this.

I can't think of any, but there are two bugs here, one of which I think JED
already knows about (the leading whitespace bug).

Re: [slrn] Could extract_article_header() return # of lines?
#42940
Author: Dawn Owens-Nicholson
Date: Sun, 30 Aug 1998 00:00
100 lines
4712 bytes
Lloyd Zusman <ljz@asfast.com> wrote:
> Hmmm ... how would I do that?  Here's some sample code that
> illustrates how I'm traversing all the articles in a given newsgroup.

You could make a wrapper for extract_article_header() that will work around
the bugs or include similar code in your function, I'll demonstrate both
ways.  The workaround has a bug -- if the cursor is not at the visible
article, there's no way to figure out what article is showing
(extract_article_header()'s job is to show info like this for the article at
the cursor), so this will punt and show you the current article.  It's not a
low-bandwidth workaround, but if you use extract_article_header("Lines") a
lot and you're on a high-speed connection to your news server, this might be
easier to spot and alter when extract_article_header() is fixed.

The workaround:

% Bugfix for slrn's extract_article_header()                    % -*- slang -*-
%
% Fixes extract_article_header() for known problem areas:
%   Message-ID -- remove leading (and trailing, if any) whitespace.
%   Lines      -- return as an integer after selecting/deselecting article.

define bugfix_extract_article_header (header)
{
   if (is_group_mode ())
     error (_function_name () + "doesn\'t work in group mode");

   % Most times, extract_article_header() works okay, so we record it...
   variable retval = extract_article_header (header);

   switch (header)                               % ...other times, we fix it.
     { case ("Message-ID") : return (strtrim (retval)); }
     { case ("Lines")      :
	variable article_was_visible = is_article_visible ();
	call ("select_article");
	!if (article_was_visible) call ("hide_article");
	return (integer (strtrim (extract_article_header (header))));
     }
     { return (retval); }                        % ...and return it unmodified.
}

For "Message-ID:" return the message-ID without the leading whitespace.  For
"Lines:" return the number of lines as an integer (it makes more sense to me
that you'd want that).  You could use this by substituting
"bugfix_extract_article_header" where you use "extract_article_header".
When the function is fixed, restore your code to the way it should be.

Or you can put this in your code:

>   %%% Sample only ...
>   define article_mode_hook ()
>   {
>      call( "header_bob" );
>      uncollapse_threads();
>
       variable article_was_visible = 0;         % for recording some state

>      do
>      {
>         %%% What do I do here to make each article the
>         %%% 'most recently read' article?

          % Find out if the article was visible
	  article_was_visible = is_article_visible ();

	  % Select the article, then conditionally hide it.
	  call ("scroll_dn");                    % select the article (unhide)
	  !if (article_was_visible)              % conditionally hide article
	     call ("hide_article");

>         variable stringLines = extract_article_header( "Lines" );
>         variable integerLines = integer( strtrim( stringLines ) );
>
>         %%% At this point, `stringLines' is the empty string and
>         %%% `integerLines' is zero.

          % Now, stringLines should be "74" (for instance) and
	  % integerLines should be 74.
>
>         variable stringFrom = extract_article_header( "From" );
>
>         %%% At this point, `stringFrom' contains the text from
>         %%% the appropriate "From:" line.
>
>      } while ( header_down( 1 ) );
>
>      collapse_threads();
>      call( "header_bob" );
>   }

By the way, the "variable" calls inside the loop will fail in S-Lang 1.x if
the do-while loop executes more than once--you'll be declaring a variable
that already exists and that's an error in S-Lang.  You'll need to move
those declarations before the loop.  What you've got works in S-Lang prior
to 1.x, however.  I don't know what version of S-Lang you're using, so I
thought I'd mention it.

Hope this helps!

Re: [slrn] Could extract_article_header() return # of lines?
#42984
Author: Lloyd Zusman
Date: Wed, 02 Sep 1998 00:00
134 lines
5424 bytes
On 2 Sep 1998 10:47:09 GMT, John E. Davis <davis@space.mit.edu> wrote:
> 
> [ ... ]
> 
>    The `lines' field of the header is treated internally as an integer
> by slrn.  Here is a patch to art.c that allows it to be returned as a
> string by `extract_acticle_header':
> 
> [ ... ]

Thank you for this patch.  I have recently posted a related patch that
addresses this problem as well as two other problems:

(1) the "whitespace" problem.  Look at the slrn_trim_string and
    slrn_skip_whitespace calls within this patch.
    
(2) a problem which occurs if the currently selected article's headers
    are being examined and the first argument of extract_article_header
    doesn't contain a trailing colon (e.g., "Lines" instead of "Lines:).

What do you think of these changes?

Lloyd Zusman
ljz@asfast.com

--------------------------- patch begins here ---------------------------
*** art.c.orig	Sun Aug 30 18:58:31 1998
--- art.c	Sun Aug 30 19:39:52 1998
***************
*** 868,873 ****
--- 868,875 ----
  char *slrn_extract_header (char *hdr, unsigned int len) /*{{{*/
  {
     Slrn_Article_Line_Type *l;
+    char *result = NULL;
+    int found;
     
     if (Slrn_Current_Header == NULL)
       return NULL;
***************
*** 878,895 ****
     if (Slrn_Current_Header != Header_Showing)
       {
  	if (0 == slrn_case_strncmp ((unsigned char *)"From: ", (unsigned char *)hdr, len))
! 	  return Slrn_Current_Header->from;
! 	if (0 == slrn_case_strncmp ((unsigned char *)"Subject: ", (unsigned char *)hdr, len))
! 	  return Slrn_Current_Header->subject;
! 	if (0 == slrn_case_strncmp ((unsigned char *)"Message-Id: ", (unsigned char *)hdr, len))
! 	  return Slrn_Current_Header->msgid;
! 	if (0 == slrn_case_strncmp ((unsigned char *)"Date: ", (unsigned char *)hdr, len))
! 	  return Slrn_Current_Header->date;
! 	if (0 == slrn_case_strncmp ((unsigned char *)"References: ", (unsigned char *)hdr, len))
! 	  return Slrn_Current_Header->refs;
! 	if (0 == slrn_case_strncmp ((unsigned char *)"Xref: ", (unsigned char *)hdr, len))
! 	  return Slrn_Current_Header->from;
! 	return NULL;
       }
     
     l = Slrn_Article_Lines;
--- 880,907 ----
     if (Slrn_Current_Header != Header_Showing)
       {
  	if (0 == slrn_case_strncmp ((unsigned char *)"From: ", (unsigned char *)hdr, len))
! 	  result = Slrn_Current_Header->from;
! 	else if (0 == slrn_case_strncmp ((unsigned char *)"Subject: ", (unsigned char *)hdr, len))
! 	  result = Slrn_Current_Header->subject;
! 	else if (0 == slrn_case_strncmp ((unsigned char *)"Message-Id: ", (unsigned char *)hdr, len))
! 	  result = Slrn_Current_Header->msgid;
! 	else if (0 == slrn_case_strncmp ((unsigned char *)"Date: ", (unsigned char *)hdr, len))
! 	  result = Slrn_Current_Header->date;
! 	else if (0 == slrn_case_strncmp ((unsigned char *)"References: ", (unsigned char *)hdr, len))
! 	  result = Slrn_Current_Header->refs;
! 	else if (0 == slrn_case_strncmp ((unsigned char *)"Xref: ", (unsigned char *)hdr, len))
! 	  result = Slrn_Current_Header->from;
! 	else if (0 == slrn_case_strncmp ((unsigned char *)"Lines: ", (unsigned char *)hdr, len))
! 	  {
! 	     static char line_buf[16];
! 	     sprintf(line_buf, "%d", Slrn_Current_Header->lines);
! 	     return line_buf;
! 	  }
! 	if (NULL == result)
! 	  return NULL;
! 
! 	slrn_trim_string(result);
! 	return slrn_skip_whitespace(result);
       }
     
     l = Slrn_Article_Lines;
***************
*** 903,909 ****
  	     if ((l->next != NULL) && (l->next->flags & WRAPPED_LINE))
  	       unwrap_line (l->next);
  	     
! 	     return l->buf + len;
  	  }
  	l = l->next;
       }
--- 915,948 ----
  	     if ((l->next != NULL) && (l->next->flags & WRAPPED_LINE))
  	       unwrap_line (l->next);
  	     
! 	     /* Someone might have supplied a header with no colon, such
! 	      * as "Subject".  Therefore, we cannot assume that the end of
! 	      * the supplied header string is the beginning of the data we
! 	      * wish to return.  We need to search for a colon and
! 	      * return the first non-whitespace character which follows it.
! 	      */
! 	     found = 0;
! 	     for (result = l->buf; '\0' != *result; result++)
! 	       {
! 		  if (' ' == *result || '\t' == *result)
! 		    {
! 		       /* ERROR! ... white space before colon.
! 			* Treat this as a non-match (should we?).
! 			*/
! 		       break;
! 		    }
! 		  else if (':' == *result)
! 		    {
! 		       result++;
! 		       found = 1;
! 		       break;
! 		    }
! 	       }
! 	     if (!found)
! 	       continue;
! 	     
! 	     slrn_trim_string(result);
! 	     return slrn_skip_whitespace(result);
  	  }
  	l = l->next;
       }

Re: [slrn] Could extract_article_header() return # of lines?
#42990
Author: John E. Davis
Date: Wed, 02 Sep 1998 00:00
27 lines
1766 bytes
On 30 Aug 1998 01:16:57 GMT, Lloyd Zusman <ljz@asfast.com>
wrote:
>the number of lines in the article.  I'd be happy if this was simply
>the contents of the "Lines:" header, which is currently ignored by
>`extract_acticle_header()'.

   The `lines' field of the header is treated internally as an integer
by slrn.  Here is a patch to art.c that allows it to be returned as a
string by `extract_acticle_header':

--- art.c~	Tue Jul 14 15:16:05 1998
+++ art.c	Tue Sep  1 13:34:04 1998
@@ -890,6 +890,12 @@
 	  return slrn_skip_whitespace (Slrn_Current_Header->refs);
 	if (0 == slrn_case_strncmp ((unsigned char *)"Xref: ", (unsigned char *)hdr, len))
 	  return Slrn_Current_Header->xref;
+	if (0 == slrn_case_strncmp ((unsigned char *)"Lines: ", (unsigned char *)hdr, len))
+	  {
+	     static char lines_buf[16];
+	     sprintf (lines_buf, "%d", Slrn_Current_Header->lines);
+	     return lines_buf;
+	  }
 	return NULL;
      }
    

Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads