9front - general discussion about 9front
 help / color / mirror / Atom feed
From: Sean Hinchee <henesy.dev@gmail.com>
To: 9front@9front.org
Cc: nabijaczleweli@nabijaczleweli.xyz
Subject: [9front] seq: fix infinite loop
Date: Sun, 15 Aug 2021 15:02:38 -0700	[thread overview]
Message-ID: <CADmmOS-wcgtcQ+=c01NvssHO3=06zbQjU6NzLt_K0eOX4OQe=w@mail.gmail.com> (raw)

наб on twitter, then over e-mail (CC'd) pointed out that seq(1) in
9front with some very large inputs

For example:

    ; seq 2e16 20000000000000002

would loop forever.

After patch application, seq with the above example would print
'2e+16' once and then exit.

Patch also brings the usage message in line with the manual usage.

Patch link: http://okturing.com/src/11872/body

Inline:

--- //.git/fs/object/2af46e406bbd443ae10025777247798a685afc3c/tree/sys/src/cmd/seq.c
+++ sys/src/cmd/seq.c
@@ -11,7 +11,7 @@
 void
 usage(void)
 {
- fprint(2, "usage: seq [-fformat] [-w] [first [incr]] last\n");
+ fprint(2, "usage: seq [-w] [-fformat] [first [incr]] last\n");
  exits("usage");
 }

@@ -67,6 +67,7 @@
  default:
  goto out;
  }ARGEND
+
     out:
  if(argc<1 || argc>3)
  usage();
@@ -81,6 +82,7 @@
  }
  if(!format)
  buildfmt();
+
  if(incr > 0){
  for(val = min; val <= max; val += incr){
  n = sprint(buf, format, val);
@@ -88,6 +90,8 @@
  for(j=0; buf[j]==' '; j++)
  buf[j] ='0';
  write(1, buf, n);
+ if(val == max)
+ break;
  }
  }else{
  for(val = min; val >= max; val += incr){
@@ -96,7 +100,10 @@
  for(j=0; buf[j]==' '; j++)
  buf[j] ='0';
  write(1, buf, n);
+ if(val == max)
+ break;
  }
  }
+
  exits(0);
 }

             reply	other threads:[~2021-08-16 11:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-15 22:02 Sean Hinchee [this message]
2021-08-16 21:45 ` Amavect
2021-08-18 22:53   ` Eckard Brauer
2021-08-16 22:24 ` [9front] " Anthony Martin
2021-08-16 23:38   ` ori
2021-08-17  2:15     ` hiro
2021-08-21  1:30   ` Amavect
2021-08-18  2:49 ` [9front] " ori

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CADmmOS-wcgtcQ+=c01NvssHO3=06zbQjU6NzLt_K0eOX4OQe=w@mail.gmail.com' \
    --to=henesy.dev@gmail.com \
    --cc=9front@9front.org \
    --cc=nabijaczleweli@nabijaczleweli.xyz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).