[hackers] [sbase][PATCH] ed: Fix j command bugs

2017-05-15 Thread Wolfgang Corcoran-Mathe
Remove a double free() that caused joins to randomly segfault. Fix a bug in delete() that occasionally caused lines to be transposed. --- ed.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ed.c b/ed.c index e737d57..f6e195f 100644 --- a/ed.c +++ b/ed.c @@ -781,7 +781,7 @@ d

[hackers] [sbase][PATCH] Rework l command for the Unicode world.

2017-05-11 Thread Wolfgang Corcoran-Mathe
Rather than printing byte sequences for any non-ASCII characters, printable (via isprintrune()) Unicode characters are displayed normally. The usual \$, \t, \b and \\ escapes are displayed, but other non-printing characters are replaced with a Unicode escape (\u). This may be controversial, as

[hackers] [sbase] [PATCH] ed: Do not try to read-in a nonexistant file

2015-12-26 Thread Wolfgang Corcoran-Mathe
This fixes a segfault caused by running ed with a nonexistant filename argument, e.g. 'ed not_a_file_yet'. --- ed.c | 39 ++- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/ed.c b/ed.c index 8903957..599e575 100644 --- a/ed.c +++ b/ed.c @@ -609,

[hackers] [sbase] [PATCH] tail: Don't print garbage when input contains no newlines.

2015-08-27 Thread Wolfgang Corcoran-Mathe
getline(3) expects newline-terminated input. While glibc's implementation seems to catch unterminated input and zero the buffer, other versions (notably musl's) do not. This is a workaround. Garbage will still be read, but not printed. --- tail.c | 5 +++-- 1 file changed, 3 insertions(+), 2 dele

[hackers] [sbase] [PATCH] comm: Print first trailing unpaired line in file 1

2015-08-03 Thread Wolfgang Corcoran-Mathe
Previously, a line read from file 1 before a strcmp was performed would be overwritten and lost. Something like this: comm one_line_file empty_file produced no output. This patch is a bit inelegant, but quite simple. --- comm.c | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-)

[hackers] [sbase] [PATCH] join: Use LIMIT macro

2015-07-22 Thread Wolfgang Corcoran-Mathe
--- join.c | 5 + 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/join.c b/join.c index 1f2fb8c..ddccdf1 100644 --- a/join.c +++ b/join.c @@ -173,10 +173,7 @@ linecmp(struct line *la, struct line *lb, size_t jfa, size_t jfb) } else { status = memcmp(la->fi

[hackers] [9base] [PATCH] sam: Fix dprint format strings

2015-07-01 Thread Wolfgang Corcoran-Mathe
The '%lud' format used in dprint caused 'd' to appear at the end of each line number or character range. Using %ld seems to fix this. --- sam/io.c | 2 +- sam/sam.c | 8 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sam/io.c b/sam/io.c index 8740c7c..a554b11 100644 --- a

[hackers] [sbase] [PATCH] join: Stricter parsing of -o list

2015-06-23 Thread Wolfgang Corcoran-Mathe
This fixes naive parsing that would happily read a giant string of numbers into fileno provided the first character was correct. --- join.c | 17 ++--- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/join.c b/join.c index a013946..1f2fb8c 100644 --- a/join.c +++ b/join.c

Re: [hackers] [sbase][patch] find: empty line means no for -ok

2015-06-18 Thread Wolfgang Corcoran-Mathe
emg, Quoth Evan Gates on Thu, Jun 18 2015 14:47 -0700: diff --git a/find.c b/find.c index 186263b..0de1951 100644 --- a/find.c +++ b/find.c @@ -415,10 +415,9 @@ pri_ok(struct arg *arg) reply = fgetc(stdin); /* throw away rest of line */ - while ((c = fgetc(stdin)) != '\n'

Re: [hackers] [sbase] Better cksum patch

2015-06-17 Thread Wolfgang Corcoran-Mathe
Carlos, Quoth Carlos Torres on Wed, Jun 17 2015 17:26 -0400: you forgot to attach the patch :) As I understand git send-email, patches are sent as replies to the intro message and not as attachments. Since FRIGN commented on the 'missing' patch, it couldn't have been lost. I don't think anythi

Re: [hackers] [sbase] [PATCH 1/3] find: Fix unterminated array in -ok primary

2015-06-15 Thread Wolfgang Corcoran-Mathe
Quoth Evan Gates on Mon, Jun 15 2015 13:51 -0700: On Mon, Jun 15, 2015 at 12:27 PM, Wolfgang Corcoran-Mathe wrote: --- find.c | 1 + 1 file changed, 1 insertion(+) diff --git a/find.c b/find.c index dedf5a1..a870a90 100644 --- a/find.c +++ b/find.c @@ -429,6 +429,7 @@ pri_ok(struct arg *arg

[hackers] [sbase] [PATCH 1/3] find: Fix unterminated array in -ok primary

2015-06-15 Thread Wolfgang Corcoran-Mathe
--- find.c | 1 + 1 file changed, 1 insertion(+) diff --git a/find.c b/find.c index dedf5a1..a870a90 100644 --- a/find.c +++ b/find.c @@ -429,6 +429,7 @@ pri_ok(struct arg *arg) /* insert filename everywhere user gave us {} */ for (brace = o->braces; *brace; brace++)

[hackers] [sbase] [PATCH 2/3] find: Fix flushing input buffer with -ok

2015-06-15 Thread Wolfgang Corcoran-Mathe
The original flush-stdin loop (with fgets()) hung until the user entered some extraneous characters for it to kill. emg's FIXME about nulls still applies. --- find.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/find.c b/find.c index a870a90..3871105 100644 --- a/find.

Re: [hackers] [sbase] [PATCH] find

2015-06-15 Thread Wolfgang Corcoran-Mathe
emg, I noticed a few other things in get_ok_arg(), primarily that the fgets() flushing loop was causing find to hang mysteriously. Patch 2/3 should fix this, hopefully. The isplus branch seems to work, based on limited testing. I've enjoyed reading your code, btw. -- WCM

[hackers] [sbase] [PATCH 3/3] find: Improve prompt spacing with -ok

2015-06-15 Thread Wolfgang Corcoran-Mathe
--- find.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/find.c b/find.c index 3871105..4ce150f 100644 --- a/find.c +++ b/find.c @@ -411,7 +411,7 @@ pri_ok(struct arg *arg) char ***brace, c; struct okarg *o = arg->extra.p; - fprintf(stderr, "%s: %s ?",

[hackers] [sbase] [PATCH] find: Fix unterminated array

2015-06-13 Thread Wolfgang Corcoran-Mathe
This caused a segfault with semicolon-terminated -exec primaries. --- find.c | 1 + 1 file changed, 1 insertion(+) diff --git a/find.c b/find.c index dcefca5..dedf5a1 100644 --- a/find.c +++ b/find.c @@ -607,6 +607,7 @@ get_exec_arg(char *argv[], union extra *extra) for (arg = arg

[hackers] [sbase] [PATCH] cksum: Skip files with read errors and continue

2015-06-11 Thread Wolfgang Corcoran-Mathe
Previously, 'cksum *' exited early if * contained a directory or other file causing an fread() error. Exit status is set to indicate an error has occurred. --- cksum.c | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cksum.c b/cksum.c index 3355b4c..570ca81 100644 ---

Re: [hackers] [sbase] [PATCH] cksum: Skip files with read errors and continue

2015-06-11 Thread Wolfgang Corcoran-Mathe
Patch redone with global ret. Thanks, FRIGN. -- WCM

[hackers] [sbase] [PATCH] cksum: Skip files with read errors and continue

2015-06-11 Thread Wolfgang Corcoran-Mathe
Previously, 'cksum *' would exit early if * contained any directories or other files causing fread() errors. Exit status is set to indicate an error has occurred. --- cksum.c | 11 +++ 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/cksum.c b/cksum.c index 3355b4c..179ab05 1

[hackers] [sbase] Better cksum patch

2015-06-11 Thread Wolfgang Corcoran-Mathe
I went too quickly with the last patch. This version sets the exit status properly when a file causes a read error, then continues to the next file. Sorry for patch spam. -- WCM

[hackers] [sbase] [PATCH] cksum: Skip files with errors and continue

2015-06-11 Thread Wolfgang Corcoran-Mathe
Previously, 'cksum *' would exit early if * contained a directory or any other file causing a read error. --- cksum.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cksum.c b/cksum.c index 3355b4c..3b4f4f8 100644 --- a/cksum.c +++ b/cksum.c @@ -71,8 +71,10 @@ cksum(FILE

Re: [hackers] [sbase] [PATCH 2/2] join: Fix typo

2015-06-06 Thread Wolfgang Corcoran-Mathe
Quoth FRIGN on Sat, Jun 06 2015 22:40 +0200: Next time, please provide the patch with git format-patch, then authorship will be preserved. Thanks, noted. -- Wolfgang Corcoran-Mathe

Re: [hackers] [sbase] [PATCH 1/2] join: get rid of strlen--fwrite barbarity

2015-06-06 Thread Wolfgang Corcoran-Mathe
structure. Patch withdrawn! I'm sorry if it was a waste of time. I appreciate your opinions on this. -- Wolfgang Corcoran-Mathe

[hackers] [sbase] [PATCH 2/2] join: Fix typo

2015-06-06 Thread Wolfgang Corcoran-Mathe
This was causing some mysterious output bugs. -- Wolfgang Corcoran-Mathe diff --git a/join.c b/join.c index f682023..76f9ff5 100644 --- a/join.c +++ b/join.c @@ -141,7 +141,7 @@ prjoin(struct line *la, struct line *lb, size_t jfa, size_t jfb) for (i = 0; i < lb->

[hackers] [sbase] [PATCH 1/2] join: get rid of strlen--fwrite barbarity

2015-06-06 Thread Wolfgang Corcoran-Mathe
join: Store string length in the line struct This gets rid of a barbarous strlen()/fwrite() construct. -- Wolfgang Corcoran-Mathe diff --git a/join.c b/join.c index b2fd07e..f682023 100644 --- a/join.c +++ b/join.c @@ -29,6 +29,7 @@ struct field { struct line { char *text