Truls Becken | 17 Dec 21:14 2014
Picon

[sbase] [PATCH] cut: clean up file loop

---
 cut.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/cut.c b/cut.c
index aca0083..99ec4ce 100644
--- a/cut.c
+++ b/cut.c
 <at>  <at>  -162,21 +162,19  <at>  <at>  main(int argc, char *argv[])

 	if (!mode)
 		usage();
-	if (!argc)
+
+	if (!argc) {
 		cut(stdin);
-	else {
-		for (; argc--; argv++) {
-			if (strcmp(*argv, "-"))
-				fp = fopen(*argv, "r");
-			else
-				fp = stdin;
-			if (!fp) {
+	} else for (; argc--; argv++) {
+		if (!strcmp(*argv, "-")) {
+			cut(stdin);
+		} else {
+			if (!(fp = fopen(*argv, "r"))) {
 				weprintf("fopen %s:", *argv);
 				continue;
(Continue reading)

sekret | 17 Dec 13:47 2014
Picon

[ratox] status of helper scripts

Hey guys!

I've been looking into Tox lately and remembered, that there was this fifo based client mentioned here
while back. The client is kind of cool, but unhandy to use with pure commandline (in my opinion)

Now I'm no coder really, but have always managed to find my way with little scripts etc. So I wanted to ask,
before I sit down and try to create something like a cli for ratox (which would probably suck, because I
really suck at this!), I wanted to ask, if there are some first scripts I just couldn't find on the interweb.

Best
sekret

Truls Becken | 16 Dec 20:33 2014
Picon

[sbase] Why do extra work when the kernel will do it more efficiently?

Hi everyone,

As the original contributor of sbase cut, I can't help wondering what the
purpose of the mem freeing added in the two commits from 1st of June is
supposed to be. The most efficient and reliable way to free allocated memory
is to terminate the process. There is no reason to clean things up just to
exit immediately after. Also, the line buffer was reused on purpose, no need
to allocate a new one per file.

-Truls

Greg Reagle | 15 Dec 17:47 2014

problem report for sbase/cal

greagle <at> 530GA ~/a/sbase> ./cal -3
    November 2014          December 2014          January 2015
Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa
                   1       1  2  3  4  5  6             1  2  3  4
 2  3  4  5  6  7  8    7  8  9 10 11 12 13    5  6  7  8  9 10 11
 9 10 11 12 13 14 15   14 15 16 17 18 19 20   12 13 14 15 16 17 18
16 17 18 19 20 21 22   21 22 23 24 25 26 27   19 20 21 22 23 24 25
23 24 25 26 27 28 29   28 29 30 31            26 27 28 29 30 31
30
greagle <at> 530GA ~/a/sbase> ./cal 1 2015
    January 2015
Su Mo Tu We Th Fr Sa
             1  2  3
 4  5  6  7  8  9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31

January 2015 is supposed to start on a Thursday.  Note the first result
is incorrect but the second result is correct.  I wish I could provide a
patch too, but I don't understand the calendar algorithm(s) used in
cal.c.  Incidentally, I am in the process of doing a rewrite of cal for
my own education and entertainment (and maybe for submission to
suckless, if it turns out well), and it does not have this problem, but,
alas, it is not ready yet.

--

-- 
http://www.fastmail.com - IMAP accessible web-mail

(Continue reading)

Jonny Langley | 14 Dec 08:11 2014
Picon

[dmenu] dmenu_run in C

Hi,

While browsing the wiki I came across a rewrite of dmenu_path in C
written by cls [1]

I've used this as the basis for the attached patch, which adds the
functionality of dmenu_run into dmenu.c
It adds just under 100 LOC, but means the shell scripts
dmenu_{run,path} are unneeded.

Comments, advice and flames welcome;

Jonny

=====
[1] http://tools.suckless.org/dmenu/patches/legacy/dmenu_path
diff --git a/Makefile b/Makefile
index 0f7dfbd..e07e87f 100644
--- a/Makefile
+++ b/Makefile
 <at>  <at>  -39,7 +39,7  <at>  <at>  clean:
 dist: clean
 	 <at> echo creating dist tarball
 	 <at> mkdir -p dmenu-${VERSION}
-	 <at> cp LICENSE Makefile README config.mk dmenu.1 draw.h dmenu_path dmenu_run stest.1 ${SRC} dmenu-${VERSION}
+	 <at> cp LICENSE Makefile README config.mk dmenu.1 draw.h stest.1 ${SRC} dmenu-${VERSION}
 	 <at> tar -cf dmenu-${VERSION}.tar dmenu-${VERSION}
 	 <at> gzip dmenu-${VERSION}.tar
(Continue reading)

Ivan Delalande | 12 Dec 08:39 2014
Picon

[st] [PATCH] Fix crash due to invalid timespec given to pselect

If blinktimeout is set to a value greater than 1000, pselect will
receive a timeout argument with tv_nsec greater than 1E9 (1 sec), and
fail, making st crash. This patch just ensures that the timespec
structure is correctly filled with a value properly decomposed between
tv_sec and tv_nsec.

Reported by JasonWoof on IRC. Thanks!
---
 st.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/st.c b/st.c
index fc91334..db9a332 100644
--- a/st.c
+++ b/st.c
 <at>  <at>  -3922,6 +3922,9  <at>  <at>  run(void) {
 							TIMEDIFF(now,
 								lastblink)));
 					}
+					drawtimeout.tv_sec = \
+					    drawtimeout.tv_nsec / 1E9;
+					drawtimeout.tv_nsec %= (long)1E9;
 				} else {
 					tv = NULL;
 				}
-- 
2.1.3

--

-- 
Ivan "Colona" Delalande
(Continue reading)

u | 11 Dec 10:49 2014
Picon

dwm make PIE default in config.mk


Hi,

let's add PIE in config.mk:

diff --git a/config.mk b/config.mk
index bc3d80e..364a649 100644
--- a/config.mk
+++ b/config.mk
 <at>  <at>  -21,7 +21,7  <at>  <at>  LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS}
 # flags
 CPPFLAGS = -D_BSD_SOURCE -D_POSIX_C_SOURCE=2 -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
 #CFLAGS   = -g -std=c99 -pedantic -Wall -O0 ${INCS} ${CPPFLAGS}
-CFLAGS   = -std=c99 -pedantic -Wall -Wno-deprecated-declarations -Os ${INCS} ${CPPFLAGS}
+CFLAGS   = -DFORTIFY_SOURCE=2 -fstack-protector -fstack-protector-all -std=c99 -pedantic -Wall
-Wno-deprecated-declarations -Os ${INCS} ${CPPFLAGS}
 LDFLAGS  = -s ${LIBS}

 # Solaris

Greetings
--

M Farkas-Dyck | 10 Dec 20:11 2014
Picon

st with scrollback

I merged jspricke's scrollback code into latest master:
https://github.com/strake/st

Tested briefly, seems to work.

Michael Forney | 8 Dec 04:25 2014

[sbase] [PATCH] cp: Rename -d option to -P

The -d option is a GNU extension and is equivalent to its "-P
--preserve=links" options.

Since we don't implement the --preserve=links functionality anyway (it
means preserve hard links between files), just call it -P, which is
specified by POSIX.

Additionally, there is no need to check for cp_Pflag again before
copying the symlink itself because the only way the mode in the stat
will indicate a symlink is if we used lstat (which we only do if -P is
specified).
---
 cp.1         | 6 +++---
 cp.c         | 6 +++---
 fs.h         | 2 +-
 libutil/cp.c | 8 ++++----
 4 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/cp.1 b/cp.1
index f0f5b65..95f39c3 100644
--- a/cp.1
+++ b/cp.1
 <at>  <at>  -8,7 +8,7  <at>  <at>  cp \- copy files and directories
 .RI [ name ]
 .P
 .B cp
-.RB [ \-adpRrv ]
+.RB [ \-aPpRrv ]
 .RI [ file ...]
 .RI [ directory ]
(Continue reading)

Michael Forney | 8 Dec 03:19 2014

[sbase] [PATCH] ls: Always leave room for the NULL byte in the link target

Otherwise, if the length of the link target is the same as BUFSIZ, we
will try to write past the end of buf.
---
 ls.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ls.c b/ls.c
index b48391b..a2fb5cb 100644
--- a/ls.c
+++ b/ls.c
 <at>  <at>  -291,7 +291,7  <at>  <at>  output(Entry *ent)
 		printf("%10lu ", (unsigned long)ent->size);
 	printf("%s %s%s", buf, ent->name, indicator(ent->mode));
 	if (S_ISLNK(ent->mode)) {
-		if ((len = readlink(ent->name, buf, sizeof buf)) < 0)
+		if ((len = readlink(ent->name, buf, sizeof buf - 1)) < 0)
 			eprintf("readlink %s:", ent->name);
 		buf[len] = '\0';
 		mkent(&entlnk, buf, Fflag);
--

-- 
2.1.3.1.g339ec9c

Michael Forney | 7 Dec 23:40 2014

[sbase] [PATCH] ls: List directory contents if file is a symlink to a directory

---
 ls.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/ls.c b/ls.c
index b48391b..90193cc 100644
--- a/ls.c
+++ b/ls.c
 <at>  <at>  -21,6 +21,7  <at>  <at>  typedef struct {
 	off_t size;
 	time_t mtime;
 	ino_t ino;
+	int isdir;
 } Entry;

 static int entcmp(const void *, const void *);
 <at>  <at>  -117,7 +118,7  <at>  <at>  entcmp(const void *va, const void *vb)
 static void
 ls(Entry *ent)
 {
-	if (S_ISDIR(ent->mode) && !dflag) {
+	if (ent->isdir && !dflag) {
 		lsdir(ent->name);
 	} else {
 		output(ent);
 <at>  <at>  -191,6 +192,7  <at>  <at>  mkent(Entry *ent, char *path, int dostat)
 	ent->size   = st.st_size;
 	ent->mtime  = st.st_mtime;
 	ent->ino    = st.st_ino;
+	ent->isdir  = S_ISLNK(ent->mode) && stat(path, &st) == 0 && S_ISDIR(st.st_mode);
(Continue reading)


Gmane