summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvan M Jones2019-05-14 01:59:56 +0000
committerEvan M Jones2019-05-14 01:59:56 +0000
commit264520f5ddf0605f0f57ee3bce77f43c04f0d8b1 (patch)
treeabf3979cfb9a3efdd86c4114fa92782b5fbe3640
downloadaur-264520f5ddf0605f0f57ee3bce77f43c04f0d8b1.tar.gz
Feat(*): Project init, AUR release.
-rw-r--r--.SRCINFO17
-rw-r--r--.gitignore2
-rw-r--r--PKGBUILD27
-rw-r--r--license.txt21
-rw-r--r--main.c79
-rw-r--r--makefile11
-rw-r--r--readme.txt30
7 files changed, 187 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 00000000000..19dd3afead5
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,17 @@
+pkgbase = dlof
+ pkgdesc = A dead simple unfolder -- opposite of fold.
+ pkgver = 1
+ pkgrel = 1
+ epoch = 1
+ url = https://github.com/mini-eggs/dlof
+ arch = any
+ license = MIT
+ makedepends = git
+ makedepends = gcc
+ provides = dlof
+ conflicts = dlof
+ source = git+https://github.com/mini-eggs/dlof.git
+ md5sums = SKIP
+
+pkgname = dlof
+
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 00000000000..f9d3a46b2e1
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+test.txt
+unfold
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 00000000000..e75b4774f72
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,27 @@
+# Maintainer: Evan M Jones <evanjones4040@gmail.com>
+pkgname=dlof
+pkgver=1
+pkgrel=1
+epoch=1
+pkgdesc="A dead simple unfolder -- opposite of fold."
+arch=('any')
+url="https://github.com/mini-eggs/${pkgname}"
+license=('MIT')
+provides=($pkgname)
+conflicts=($pkgname)
+makedepends=('git' 'gcc')
+source=("git+https://github.com/mini-eggs/dlof.git")
+md5sums=('SKIP')
+
+pkgver() {
+ cd $pkgname
+ printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
+}
+
+package() {
+ cd $pkgname
+ make
+ install -D -m644 license.txt "$pkgdir/usr/share/licenses/dlof/LICENSE"
+ install -D -m755 dlof "$pkgdir/usr/bin/$pkgname"
+}
+
diff --git a/license.txt b/license.txt
new file mode 100644
index 00000000000..1d24922fec4
--- /dev/null
+++ b/license.txt
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2019-present Evan M Jones
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/main.c b/main.c
new file mode 100644
index 00000000000..3eb15d4fb61
--- /dev/null
+++ b/main.c
@@ -0,0 +1,79 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+void step(char last, char curr)
+{
+ char tmp;
+
+ if(curr == '\n')
+ {
+ /* check if the next char is a line spaces as well,
+ if so don't do a damn thing! */
+
+ tmp = getchar();
+
+ if(tmp == EOF)
+ {
+ /* kind of whacky, lets just output the newline and exit I suppose. */
+ putchar(curr);
+ putchar(tmp);
+ return;
+ }
+ else if (tmp == '\n')
+ {
+ /* okay cool, just leave alone! */
+ /* can prob combine w/ func above */
+ putchar(curr);
+ putchar(tmp);
+ return;
+ }
+ else
+ {
+ /* business as normal, here we don't want to put out the newline but we
+ also really don't want to put out two whitespace characters right
+ next to each other. Reverse and make sure we're not! */
+
+ /* set last, then check if last and tmp are both spaces, if so only
+ write one! */
+
+ /* Well, fuck. We cannot seek on standard input */
+
+ if(last == ' ' && tmp == ' ')
+ {
+ /* no op */
+ }
+ else if(last != ' ' && tmp != ' ')
+ {
+ putchar(' ');
+ putchar(tmp);
+ }
+ else
+ {
+ putchar(tmp);
+ }
+ }
+ }
+ else
+ {
+ putchar(curr);
+ }
+}
+
+int main(void)
+{
+ char last, curr;
+
+ last = '\0';
+ curr = getchar();
+
+ while(curr != EOF)
+ {
+ step(last, curr);
+
+ last = curr;
+ curr = getchar();
+ }
+
+ return 0;
+}
diff --git a/makefile b/makefile
new file mode 100644
index 00000000000..5bd27b4b81a
--- /dev/null
+++ b/makefile
@@ -0,0 +1,11 @@
+CC=gcc
+OPTS=-Wall -Wextra -pedantic -std=gnu89 -Ofast
+OUT=dlof
+IN=main.c
+
+all: $(IN)
+ $(CC) $(OPTS) $(IN) -o $(OUT)
+
+clean:
+ rm $(OUT)
+
diff --git a/readme.txt b/readme.txt
new file mode 100644
index 00000000000..3c1ca322104
--- /dev/null
+++ b/readme.txt
@@ -0,0 +1,30 @@
+ _ _ __
+ __| | | ___ / _|
+ / _` | |/ _ \| |_
+| (_| | | (_) | _|
+ \__,_|_|\___/|_|
+
+ _ _ _ _ __
+| |_| |__ ___ ___ _ __ _ __ ___ ___(_) |_ ___ ___ / _|
+| __| '_ \ / _ \ / _ \| '_ \| '_ \ / _ \/ __| | __/ _ \ / _ \| |_
+| |_| | | | __/ | (_) | |_) | |_) | (_) \__ \ | || __/ | (_) | _|
+ \__|_| |_|\___| \___/| .__/| .__/ \___/|___/_|\__\___| \___/|_|
+ |_| |_|
+ __ _ _
+ / _| ___ | | __| |
+| |_ / _ \| |/ _` |
+| _| (_) | | (_| |_
+|_| \___/|_|\__,_(_)
+
+Unfold a folded file.
+
+Usage:
+
+$ cat hi.txt | dlof
+
+Given the file "hi.txt" is wrapped it will print out the unwrapped versino to
+standard out.
+
+MIT licensed.
+
+