From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pizarro.uberspace.de ([185.26.156.189]) by ewsd; Sat Jul 4 06:02:04 EDT 2020 Received: (qmail 15354 invoked from network); 4 Jul 2020 10:01:46 -0000 Received: from localhost (HELO localhost) (127.0.0.1) by pizarro.uberspace.de with SMTP; 4 Jul 2020 10:01:46 -0000 Message-ID: To: 9front@9front.org Subject: Re: [9front] patch: calendar look ahead Date: Sat, 4 Jul 2020 12:01:44 +0200 From: sirjofri@sirjofri.de In-Reply-To: <319D46C3FB4CBC39E29649E2C255F5C6@pizarro.uberspace.de> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="upas-zidglkkmelcqktbhdfwxfxscrz" List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: self-healing XMPP method-scale deep-learning generator This is a multi-part message in MIME format. --upas-zidglkkmelcqktbhdfwxfxscrz Content-Disposition: inline Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Hello again, I totally forgot to include some more details. I had to send that mail like 3 times because of my mail configuration. Also it seems like 9front ML doesn't accept gmail plain text messages sent with other addresses anymore? What is the intended behavior of calendar(1) -p days? Is the attached patch an improvement for calendar(1)? These are the questions I wanted to open the disussion with. Thank you sirjofri --upas-zidglkkmelcqktbhdfwxfxscrz Content-Type: message/rfc822 Content-Disposition: inline Delivered-To: sirjofri+web@gmail.com Received: by 2002:a19:f517:0:0:0:0:0 with SMTP id j23csp1395899lfb; Thu, 2 Jul 2020 07:21:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJytDDsY3ZVpT75QgOLPF/GyxDafhW16RdOmaeEMJeGzcoen+EyKN9MWOC3nZDdNPw2hb7+2 X-Received: by 2002:a1c:5986:: with SMTP id n128mr20008511wmb.112.1593699681518; Thu, 02 Jul 2020 07:21:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593699681; cv=none; d=google.com; s=arc-20160816; b=hDqG/WwomyIbjsiu6VHU9Nt8KZQJvNcT0dc0HTzip4EFYN1HeBilTZiwU/3mUqr1CQ RICllPm5G6v3Sf+vKv4rVqIyK7GIlz6BUs2n+ABlpDV77/f7PB9xPLDOXw5pzro5saQO g4ZGkXW2qpcBL/XlwWxDD+2pb4dBMzzKW2Wvc/4avzysblp5euwAH8CnCkqjlU0CqH2K qbZwtnI0josVLmhs5eCJNWeA2fnoWg0W29w5wxF2dJgYRiGpyDo2nqVi66RQbIQI6Sd6 jAIiObWhpfjsNMRtreO1lObtwseTlWcM0GnjGqee89DQ+kJmB69FGibkzvVi2bB7uML3 ZN1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=precedence:reply-to:subject:list-help:list-id:mime-version:from :date:to:message-id:delivered-to:delivered-to; bh=/AFWyL/jaFnXqXc8dHh5PnYpz25zASTtuDWHlbpdQMI=; b=aqLO5qJV6e5eMZj1K7P0GLo9Y3bhMzFh+oFozu1euyDZOY5fV9swvgWUMWfV0Gp5fm uJ7tQPDxoqxlpKReSyHVFfXzsKlSxbFOgQXgXg5/qeEl5HA9SR3tKIdd2oWiyjs4mbZI aMlnsO/QrmKS9SmBPJlJHRxI5/pUMU256GZVplGjbUPKi//Vy71v581FXyT9f1VLdBWd y3Ya10xCb9awCmnSSyMt1qxrjot0QNV9rd5x/kEd9DM0NK2FsyE3FMYyiEDK1HzVz+XR dIvNJow4lElXGIrjAM0jX5Tvl21ALFv1Iyrrtb+CKpUBu7zd8Cc8YMpuzj0QQo76tsL6 B+ig== ARC-Authentication-Results: i=1; mx.google.com; spf=fail (google.com: domain of 9front-bounces@ewsd.inri.net does not designate 185.26.156.189 as permitted sender) smtp.mailfrom=9front-bounces@ewsd.inri.net Return-Path: <9front-bounces@ewsd.inri.net> Received: from pizarro.uberspace.de (pizarro.uberspace.de. [185.26.156.189]) by mx.google.com with ESMTPS id g14si8554311wro.351.2020.07.02.07.21.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Jul 2020 07:21:21 -0700 (PDT) Received-SPF: fail (google.com: domain of 9front-bounces@ewsd.inri.net does not designate 185.26.156.189 as permitted sender) client-ip=185.26.156.189; Authentication-Results: mx.google.com; spf=fail (google.com: domain of 9front-bounces@ewsd.inri.net does not designate 185.26.156.189 as permitted sender) smtp.mailfrom=9front-bounces@ewsd.inri.net Received: (qmail 1721 invoked by uid 1358); 2 Jul 2020 14:21:21 -0000 Delivered-To: sirj1@pizarro.uberspace.de Received: (qmail 1650 invoked by uid 1358); 2 Jul 2020 14:21:20 -0000 Delivered-To: sirj1-sirjofri@sirjofri.de Received: (qmail 1252 invoked by uid 990); 2 Jul 2020 14:20:56 -0000 Received: from ewsd.inri.net (ewsd.inri.net [107.191.116.128]) by pizarro.uberspace.de (Haraka/2.8.25) with ESMTP id D1F7C961-8AA9-41B1-A927-68E03D1D5CF2.1 envelope-from <9front-bounces@ewsd.inri.net>; Thu, 02 Jul 2020 16:20:43 +0200 Received: from pizarro.uberspace.de ([185.26.156.189]) by ewsd; Thu Jul 2 10:20:06 EDT 2020 Received: (qmail 31819 invoked from network); 2 Jul 2020 14:19:48 -0000 Received: from localhost (HELO localhost) (127.0.0.1) by pizarro.uberspace.de with SMTP; 2 Jul 2020 14:19:48 -0000 Message-ID: <319D46C3FB4CBC39E29649E2C255F5C6@pizarro.uberspace.de> To: 9front@9front.org Date: Thu, 2 Jul 2020 16:19:47 +0200 From: sirjofri@sirjofri.de MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="upas-epwztzgequkpharumnvspdvpbs" List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: distributed managed deep-learning GPU extension Subject: [9front] patch: calendar look ahead Reply-To: 9front@9front.org Precedence: bulk X-Rspamd-Bar: +++++ X-Rspamd-Report: R_SPF_ALLOW(-0.2) MIME_GOOD(-0.1) CTYPE_MIXED_BOGUS(1) MAILLIST(-0.1125) RCVD_NO_TLS_LAST(0.1) REPLYTO_EQ_TO_ADDR(5) X-Rspamd-Score: 5.687499 This is a multi-part message in MIME format. --upas-epwztzgequkpharumnvspdvpbs Content-Disposition: inline Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Hey 9front. finally I hope this mail arrives... The following patch changes calendar behaviour. Today is the first. If I call calendar with -p 5 it looks at the 1,2,6 and misses my dates on 3-5. That doesn't really make sense and is not how I understand the man page. This patch changes it's behavior to look at all dates between today and today+5, so in the example above it looks at 1,2,6,5,4,3 (in that order). (/sys/src/cmd/calendar.c) 74c74 < if(ahead){ --- > while(ahead > 1){ 78a79 > ahead--; --upas-epwztzgequkpharumnvspdvpbs Content-Disposition: inline Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit #include #include #include #include #include typedef struct Date Date; struct Date { Reprog *p; /* an RE to match this date */ Date *next; /* pointer to next in list */ }; enum{ Secondsperday = 24*60*60 }; Date *Base = nil; Biobuf in; int debug, matchyear; void dates(Tm*); void upper2lower(char*, char*, int); void *emalloc(unsigned int); void usage(void) { fprint(2, "usage: calendar [-dy] [-p days] [files ...]\n"); exits("usage"); } void main(int argc, char *argv[]) { int i, fd, ahead; long now; char *line; Tm *tm; Date *d; char buf[1024]; ahead = 0; ARGBEGIN{ case 'y': matchyear = 1; break; case 'd': debug = 1; break; case 'p': ahead = atoi(EARGF(usage())); break; default: usage(); }ARGEND; /* make a list of dates */ now = time(0); tm = localtime(now); dates(tm); now += Secondsperday; tm = localtime(now); dates(tm); if(tm->wday == 6){ now += Secondsperday; tm = localtime(now); dates(tm); } if(tm->wday == 0){ now += Secondsperday; tm = localtime(now); dates(tm); } while(ahead > 1){ now = time(0); now += ahead * Secondsperday; tm = localtime(now); dates(tm); ahead--; } for(i=0; inext) if(regexec(d->p, buf, 0, 0)){ print("%s\n", line); break; } } close(fd); } exits(""); } char *months[] = { "january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december" }; char *nth[] = { "first", "second", "third", "fourth", "fifth" }; char *days[] = { "sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday" }; /* * Generate two Date structures. First has month followed by day; * second has day followed by month. Link them into list after * last, and return the first. */ void dates(Tm *tm) { Date *nd; char mo[128], day[128], buf[128]; if(utflen(days[tm->wday]) > 3) snprint(day, sizeof day, "%3.3s(%s)?", days[tm->wday], days[tm->wday]+3); else snprint(day, sizeof day, "%3.3s", days[tm->wday]); if(utflen(months[tm->mon]) > 3) snprint(mo, sizeof mo, "%3.3s(%s)?", months[tm->mon], months[tm->mon]+3); else snprint(mo, sizeof mo, "%3.3s", months[tm->mon]); if (matchyear) snprint(buf, sizeof buf, "^[\t ]*((%s( |\t)+)|(%d/))%d( |\t|$)(((%d|%d|%02d)( |\t|$))|[^0-9]|([0-9]+[^0-9 \t]))", mo, tm->mon+1, tm->mday, tm->year+1900, tm->year%100, tm->year%100); else snprint(buf, sizeof buf, "^[\t ]*((%s( |\t)+)|(%d/))%d( |\t|$)", mo, tm->mon+1, tm->mday); if(debug) print("%s\n", buf); nd = emalloc(sizeof(Date)); nd->p = regcomp(buf); nd->next = Base; Base = nd; if (matchyear) snprint(buf, sizeof buf, "^[\t ]*%d( |\t)+(%s)( |\t|$)(((%d|%d|%02d)( |\t|$))|[^0-9]|([0-9]+[^0-9 \t]))", tm->mday, mo, tm->year+1900, tm->year%100, tm->year%100); else snprint(buf, sizeof buf, "^[\t ]*%d( |\t)+(%s)( |\t|$)", tm->mday, mo); if(debug) print("%s\n", buf); nd = emalloc(sizeof(Date)); nd->p = regcomp(buf); nd->next = Base; Base = nd; snprint(buf, sizeof buf, "^[\t ]*every[ \t]+%s", day); if(debug) print("%s\n", buf); nd = emalloc(sizeof(Date)); nd->p = regcomp(buf); nd->next = Base; Base = nd; snprint(buf, sizeof buf, "[\t ]*the[\t ]+%s[\t ]+%s", nth[(tm->mday-1)/7], day); if(debug) print("%s\n", buf); nd = emalloc(sizeof(Date)); nd->p = regcomp(buf); nd->next = Base; Base = nd; } /* * Copy 'from' to 'to', converting to lower case */ void upper2lower(char *to, char *from, int len) { while(--len>0 && *from!='\0') *to++ = tolower(*from++); *to = 0; } /* * Call malloc and check for errors */ void* emalloc(unsigned int n) { void *p; p = malloc(n); if(p == 0){ fprint(2, "calendar: malloc failed: %r\n"); exits("malloc"); } return p; } --upas-epwztzgequkpharumnvspdvpbs-- --upas-zidglkkmelcqktbhdfwxfxscrz--