9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] tiny bug in Acme News
@ 2001-07-29  3:07 crdevilb
  2001-07-29  3:31 ` Jonathan Sergent
  2001-07-30 17:50 ` [9fans] lucent not the bright light it used to be matt
  0 siblings, 2 replies; 3+ messages in thread
From: crdevilb @ 2001-07-29  3:07 UTC (permalink / raw)
  To: 9fans

/acme/news/src/news.c:119
		if(1 <= j && j <= 31)
should be
		if(1 <= j && j <= 31 && !d)

or it will report the date as the current hour.

--
Colin DeVilbiss
crdevilb@mtu.edu


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [9fans] tiny bug in Acme News
  2001-07-29  3:07 [9fans] tiny bug in Acme News crdevilb
@ 2001-07-29  3:31 ` Jonathan Sergent
  2001-07-30 17:50 ` [9fans] lucent not the bright light it used to be matt
  1 sibling, 0 replies; 3+ messages in thread
From: Jonathan Sergent @ 2001-07-29  3:31 UTC (permalink / raw)
  To: 9fans


On Saturday, July 28, 2001, at 08:07 PM, crdevilb@mtu.edu wrote:

> /acme/news/src/news.c:119
> 		if(1 <= j && j <= 31)
> should be
> 		if(1 <= j && j <= 31 && !d)
>
> or it will report the date as the current hour.

There are actually more problems than that if you look at the different
formats in use in an average (?) newsgroup.  There are things with
timezone specifiers and such.  A few months ago, I hacked my fixdate()
to:

char*
fixdate(char *s)
{
         char *f[10], *m, *t, *wd, tmp[40];
         int d, i, j, nf, hh, mm, mn, yr;

         nf = tokenize(s, f, nelem(f));

         wd = nil;
         d = 0;
         m = nil;
         t = nil;
         yr = 0;
         mn = 0;
         for(i=0; i<nf; i++){
                 for(j=0; j<7; j++)
                         if(cistrncmp(day[j], f[i], 3)==0)
                                 wd = day[j];
                 for(j=0; j<12; j++)
                         if(cistrncmp(mon[j], f[i], 3)==0) {
                                 m = mon[j];
                                 mn = j;
                         }

                 while (f[i][0] && f[i][0] == '0')
                         f[i]++;

                 j = atoi(f[i]);
                 if(strchr(f[i], ':'))
                         t = f[i];
                 else if(f[i][0] == '+')
                         continue;
                 else if((d == 0) && (1 <= j && j <= 31))
                         d = j;
                 else if ((d != 0) && (j > 0)) {
                         if (j < 70)
                                 yr = j + 2000;
                         else if (j < 100)
                                 yr = j + 1900;
                         else if (j > 1970)
                                 yr = j;
                 }
         }

         if(d==0 || m==nil || t==nil)
                 return nil;

         hh = strtol(t, 0, 10);
         mm = strtol(strchr(t, ':')+1, 0, 10);

         if (wd == nil) {
                 Tm tm = { 0, mm, hh, d, mn, yr - 1900, 0, 0, "", 0 };
                 if (yr == 0 || mn == 0)
                         return nil;
                 wd = day[localtime(tm2sec(&tm))->wday];
         }

         sprint(tmp, "%s %d %s %d:%.2d", wd, d, m, hh, mm);
         return estrdup(tmp);
}

I might have changed more than this function, but I can't remember.  The
whole thing is a little ugly.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [9fans] lucent not the bright light it used to be
  2001-07-29  3:07 [9fans] tiny bug in Acme News crdevilb
  2001-07-29  3:31 ` Jonathan Sergent
@ 2001-07-30 17:50 ` matt
  1 sibling, 0 replies; 3+ messages in thread
From: matt @ 2001-07-30 17:50 UTC (permalink / raw)
  To: 9fans

more news on Lucent from the register

http://www.theregister.co.uk/content/5/20729.html

this time it's reducing the electric bill

I sure hope the company pulls through. I've seen a lot of cool stuff come
from Lucent in the past few years. I'm not sure how people in the company
feel but I guess it's a pretty stressful place to work atm. esp. for those of
them who ended up under the Lucent umbrella through aquisitions and the like.

My previous employer was put out of business when the parent company went
broke despite our subsidiary being profitabile. Mind you it work out alright
for my dept. in the end. We started out on our own and took our best clients
with us and most of us ended up with a larger salary and shed an annoying
layer of managment that got in the way of doing our thing.

M


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2001-07-30 17:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-07-29  3:07 [9fans] tiny bug in Acme News crdevilb
2001-07-29  3:31 ` Jonathan Sergent
2001-07-30 17:50 ` [9fans] lucent not the bright light it used to be matt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).