Hello,
I'm attaching two enhancements against mg(1):
0001-Include-limits.h-for-INT_MIN-and-INT_MAX.patch
0002-Comparison-of-array-bp-b_fname-not-equal-to-a-null-p.patch
Regards,
>From f4a353e59af01b14455a6302e6309887b70796ba Mon Sep 17 00:00:00 2001
From: Kamil Rytarowski <[email protected]>
Date: Sat, 15 Nov 2014 09:03:19 +0000
Subject: [PATCH 1/2] Include <limits.h> for INT_MIN and INT_MAX
---
basic.c | 1 +
cscope.c | 1 +
extend.c | 1 +
grep.c | 1 +
line.c | 1 +
main.c | 1 +
paragraph.c | 1 +
7 files changed, 7 insertions(+)
diff --git a/basic.c b/basic.c
index 5d6f093..340bd8d 100644
--- a/basic.c
+++ b/basic.c
@@ -14,6 +14,7 @@
#include "def.h"
#include <ctype.h>
+#include <limits.h>
/*
* Go to beginning of line.
diff --git a/cscope.c b/cscope.c
index b334e6b..9f79579 100644
--- a/cscope.c
+++ b/cscope.c
@@ -13,6 +13,7 @@
#include <ctype.h>
#include <fcntl.h>
#include <fnmatch.h>
+#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/extend.c b/extend.c
index 6196691..2f3d965 100644
--- a/extend.c
+++ b/extend.c
@@ -12,6 +12,7 @@
#include <sys/types.h>
#include <ctype.h>
+#include <limits.h>
#include "macro.h"
diff --git a/grep.c b/grep.c
index 55f7ae1..055bf33 100644
--- a/grep.c
+++ b/grep.c
@@ -9,6 +9,7 @@
#include <sys/types.h>
#include <ctype.h>
#include <libgen.h>
+#include <limits.h>
#include <time.h>
int globalwd = FALSE;
diff --git a/line.c b/line.c
index 51d1765..ca0b776 100644
--- a/line.c
+++ b/line.c
@@ -19,6 +19,7 @@
#include "def.h"
+#include <limits.h>
#include <stdlib.h>
#include <string.h>
diff --git a/main.c b/main.c
index 9204d63..7bcfe61 100644
--- a/main.c
+++ b/main.c
@@ -12,6 +12,7 @@
#include "macro.h"
#include <err.h>
+#include <limits.h>
#include <locale.h>
int thisflag; /* flags, this command */
diff --git a/paragraph.c b/paragraph.c
index d45efc4..9d593f7 100644
--- a/paragraph.c
+++ b/paragraph.c
@@ -8,6 +8,7 @@
*/
#include <ctype.h>
+#include <limits.h>
#include "def.h"
--
2.1.0
>From 4e3150317ef5e73933b0c53b3163861710085f67 Mon Sep 17 00:00:00 2001
From: Kamil Rytarowski <[email protected]>
Date: Sat, 15 Nov 2014 16:29:07 +0000
Subject: [PATCH 2/2] Comparison of array 'bp->b_fname' not equal to a null
pointer is always true
---
buffer.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/buffer.c b/buffer.c
index 331fbbb..51b2838 100644
--- a/buffer.c
+++ b/buffer.c
@@ -458,8 +458,7 @@ anycb(int f)
char pbuf[NFILEN + 11];
for (bp = bheadp; bp != NULL; bp = bp->b_bufp) {
- if (bp->b_fname != NULL && *(bp->b_fname) != '\0' &&
- (bp->b_flag & BFCHG) != 0) {
+ if (*(bp->b_fname) != '\0' && (bp->b_flag & BFCHG) != 0) {
ret = snprintf(pbuf, sizeof(pbuf), "Save file %s",
bp->b_fname);
if (ret < 0 || ret >= sizeof(pbuf)) {
--
2.1.0