about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2015-05-05 16:41:36 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2015-05-05 16:41:36 +0000
commitdda18efbf37e2def7490bb7865d41b1560d8412c (patch)
tree183e963df6417e3620440e07954cd50a3be45811
parentc7f0abb049cbd58704545ee94ec6e6aa40d00f0a (diff)
downloads6-portable-utils-dda18efbf37e2def7490bb7865d41b1560d8412c.tar.gz
s6-portable-utils-dda18efbf37e2def7490bb7865d41b1560d8412c.tar.xz
s6-portable-utils-dda18efbf37e2def7490bb7865d41b1560d8412c.zip
- add s6-seq v2.0.5.0
 - rc for 2.0.5.0
-rw-r--r--doc/index.html3
-rw-r--r--doc/s6-seq.html66
-rw-r--r--doc/upgrade.html3
-rw-r--r--package/deps.mak3
-rw-r--r--package/info2
-rw-r--r--package/modes1
-rw-r--r--package/targets.mak1
-rw-r--r--src/skaembutils/deps-exe/s6-seq1
-rw-r--r--src/skaembutils/s6-seq.c61
9 files changed, 138 insertions, 3 deletions
diff --git a/doc/index.html b/doc/index.html
index 5f599eb..b2f40fd 100644
--- a/doc/index.html
+++ b/doc/index.html
@@ -76,7 +76,7 @@ library. </li>
 
 <ul>
  <li> The current released version of s6-portable-utils is
-<a href="s6-portable-utils-2.0.4.1.tar.gz">2.0.4.1</a>. </li>
+<a href="s6-portable-utils-2.0.5.0.tar.gz">2.0.5.0</a>. </li>
  <li> Alternatively, you can checkout a copy of the s6-portable-utils git repository:
 <pre> git clone git://git.skarnet.org/s6-portable-utils </pre> </li>
 </ul>
@@ -135,6 +135,7 @@ the previous versions of s6-portable-utils and the current one. </li>
  <li> The <a href="s6-quote.html"><tt>s6-quote</tt></a> program </li>
  <li> The <a href="s6-rename.html"><tt>s6-rename</tt></a> program </li>
  <li> The <a href="s6-rmrf.html"><tt>s6-rmrf</tt></a> program </li>
+ <li> The <a href="s6-seq.html"><tt>s6-seq</tt></a> program </li>
  <li> The <a href="s6-sleep.html"><tt>s6-sleep</tt></a> program </li>
  <li> The <a href="s6-sort.html"><tt>s6-sort</tt></a> program </li>
  <li> The <a href="s6-sync.html"><tt>s6-sync</tt></a> program </li>
diff --git a/doc/s6-seq.html b/doc/s6-seq.html
new file mode 100644
index 0000000..68227ad
--- /dev/null
+++ b/doc/s6-seq.html
@@ -0,0 +1,66 @@
+<html>
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+    <meta http-equiv="Content-Language" content="en" />
+    <title>s6-portable-utils: the s6-seq program</title>
+    <meta name="Description" content="s6-portable-utils: the s6-seq program" />
+    <meta name="Keywords" content="s6-portable-utils command s6-seq seq numbers loop" />
+    <!-- <link rel="stylesheet" type="text/css" href="http://skarnet.org/default.css" /> -->
+  </head>
+<body>
+
+<p>
+<a href="index.html">s6-portable-utils</a><br />
+<a href="http://skarnet.org/software/">Software</a><br />
+<a href="http://skarnet.org/">skarnet.org</a>
+</p>
+
+<h1> The <tt>s6-seq</tt> program </h1>
+
+<p>
+ s6-seq prints a sequence of numbers.
+</p>
+
+<h2> Interface </h2>
+
+<pre>
+     s6-seq [ -w ] [ -s separator ] <em>limits</em>
+</pre>
+
+<ul>
+ <li> <em>limits</em> can be one, two or three arguments.
+ <ul>
+  <li> Three arguments are interpreted as <em>first</em>,
+<em>increment</em> and <em>last</em>, in this order. </li>
+  <li> Two arguments are interpreted as <em>first</em> and
+<em>last</em>, and <em>increment</em> defaults to 1. </li>
+  <li> One argument is interpreted as <em>last</em>, and
+<em>first</em> and <em>increment</em> both default to 1. </li>
+ </ul> </li>
+ <li> s6-seq prints all unsigned integers from <em>first</em>
+to <em>last</em> inclusive, with a step of <em>increment</em>,
+with a newline after each integer.
+It then exits 0. </li>
+</ul>
+
+<h2> Options </h2>
+
+<ul>
+ <li> <tt>-w</tt>&nbsp;: fixed width. The numbers will all be printed
+with the same width; smaller numbers will have leading <tt>0</tt>
+characters. </li>
+ <li> <tt>-s</tt>&nbsp;<em>sep</em>&nbsp;: print <em>sep</em> after
+each number. Default is a newline. If <em>sep</em>
+is the empty string, a null character will be printed. </li>
+</ul>
+
+<h2> Notes </h2>
+
+<p>
+ s6-seq is similar to the GNU <tt>seq</tt> program. However, it
+does not handle negative numbers, floating point numbers or
+printf-style formatting.
+</p>
+
+</body>
+</html>
diff --git a/doc/upgrade.html b/doc/upgrade.html
index 403476d..c75ef87 100644
--- a/doc/upgrade.html
+++ b/doc/upgrade.html
@@ -17,10 +17,11 @@
 
 <h1> What has changed in s6-portable-utils </h1>
 
-<h2> in 2.0.4.1 </h2>
+<h2> in 2.0.5.0 </h2>
 
 <ul>
  <li> skalibs dependency bumped to 2.3.4.0. </li>
+ <li> New command: <a href="s6-seq.html">s6-seq</a>. </li>
 </ul>
 
 <h2> in 2.0.4.0 </h2>
diff --git a/package/deps.mak b/package/deps.mak
index d5de160..b72f18d 100644
--- a/package/deps.mak
+++ b/package/deps.mak
@@ -32,6 +32,7 @@ src/skaembutils/s6-quote-filter.o src/skaembutils/s6-quote-filter.lo: src/skaemb
 src/skaembutils/s6-quote.o src/skaembutils/s6-quote.lo: src/skaembutils/s6-quote.c
 src/skaembutils/s6-rename.o src/skaembutils/s6-rename.lo: src/skaembutils/s6-rename.c
 src/skaembutils/s6-rmrf.o src/skaembutils/s6-rmrf.lo: src/skaembutils/s6-rmrf.c
+src/skaembutils/s6-seq.o src/skaembutils/s6-seq.lo: src/skaembutils/s6-seq.c
 src/skaembutils/s6-sleep.o src/skaembutils/s6-sleep.lo: src/skaembutils/s6-sleep.c
 src/skaembutils/s6-sort.o src/skaembutils/s6-sort.lo: src/skaembutils/s6-sort.c
 src/skaembutils/s6-sync.o src/skaembutils/s6-sync.lo: src/skaembutils/s6-sync.c
@@ -105,6 +106,8 @@ s6-rename: private EXTRA_LIBS :=
 s6-rename: src/skaembutils/s6-rename.o -lskarnet
 s6-rmrf: private EXTRA_LIBS :=
 s6-rmrf: src/skaembutils/s6-rmrf.o -lskarnet
+s6-seq: private EXTRA_LIBS :=
+s6-seq: src/skaembutils/s6-seq.o -lskarnet
 s6-sleep: private EXTRA_LIBS := ${TAINNOW_LIB}
 s6-sleep: src/skaembutils/s6-sleep.o -lskarnet
 s6-sort: private EXTRA_LIBS :=
diff --git a/package/info b/package/info
index c780675..60e67c4 100644
--- a/package/info
+++ b/package/info
@@ -1,4 +1,4 @@
 package=s6-portable-utils
-version=2.0.4.1
+version=2.0.5.0
 category=admin
 package_macro_name=S6_PORTABLE_UTILS
diff --git a/package/modes b/package/modes
index 325eb60..a14e4bc 100644
--- a/package/modes
+++ b/package/modes
@@ -28,6 +28,7 @@ s6-quote		0755
 s6-quote-filter		0755
 s6-rename		0755
 s6-rmrf			0755
+s6-seq			0755
 s6-sleep		0755
 s6-sort			0755
 s6-sync			0755
diff --git a/package/targets.mak b/package/targets.mak
index f7b3869..c562da8 100644
--- a/package/targets.mak
+++ b/package/targets.mak
@@ -29,6 +29,7 @@ s6-quote \
 s6-quote-filter \
 s6-rename \
 s6-rmrf \
+s6-seq \
 s6-sleep \
 s6-sort \
 s6-sync \
diff --git a/src/skaembutils/deps-exe/s6-seq b/src/skaembutils/deps-exe/s6-seq
new file mode 100644
index 0000000..e7187fe
--- /dev/null
+++ b/src/skaembutils/deps-exe/s6-seq
@@ -0,0 +1 @@
+-lskarnet
diff --git a/src/skaembutils/s6-seq.c b/src/skaembutils/s6-seq.c
new file mode 100644
index 0000000..bad4afd
--- /dev/null
+++ b/src/skaembutils/s6-seq.c
@@ -0,0 +1,61 @@
+/* ISC license. */
+
+#include <skalibs/uint.h>
+#include <skalibs/sgetopt.h>
+#include <skalibs/buffer.h>
+#include <skalibs/strerr2.h>
+
+#define USAGE "s6-seq [ -w ] [ -s separator ] limits"
+#define dieusage() strerr_dieusage(100, USAGE)
+
+int main (int argc, char const *const *argv)
+{
+  char const *sep = "\n" ;
+  unsigned int fixed = 0, seplen = 1, i = 1, increment = 1 ;
+  unsigned int last ;
+  char fmt[UINT_FMT] ;
+  PROG = "s6-seq" ;
+  {
+    subgetopt_t l = SUBGETOPT_ZERO ;
+    for (;;)
+    {
+      register int opt = subgetopt_r(argc, argv, "ws:", &l) ;
+      if (opt == -1) break ;
+      switch (opt)
+      {
+        case 'w': fixed = 1 ; break ;
+        case 's': sep = l.arg ; seplen = str_len(sep) ; break ;
+        default : dieusage() ;
+      }
+    }
+    argc -= l.ind ; argv += l.ind ;
+  }
+  switch (argc)
+  {
+    case 1 :
+      if (!uint0_scan(argv[0], &last)) dieusage() ;
+      break ;
+    case 2 :
+      if (!uint0_scan(argv[0], &i)
+       || !uint0_scan(argv[1], &last)) dieusage() ;
+      break ;
+    case 3 :
+      if (!uint0_scan(argv[0], &i)
+       || !uint0_scan(argv[1], &increment)
+       || !uint0_scan(argv[2], &last)) dieusage() ;
+      break ;
+    default : dieusage() ;
+  }
+  if (!seplen) seplen = 1 ;
+  if (fixed) fixed = uint_fmt(0, i + increment * ((last - i) / increment)) ;
+  for (; i <= last ; i += increment)
+  {
+    if (buffer_put(buffer_1, fmt, fixed ? (uint0_fmt(fmt, i, fixed), fixed) : uint_fmt(fmt, i)) < 0) goto err ;
+    if (buffer_put(buffer_1, sep, seplen) < 0) goto err ;
+  }
+  if (!buffer_flush(buffer_1)) goto err ;
+  return 0 ;
+
+err:
+  strerr_diefu1sys(111, "write to stdout") ;
+}