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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
diff --git a/README.md b/README.md
index 3ead7a7..bba4f89 100644
--- a/README.md
+++ b/README.md
@@ -9,7 +9,7 @@ Bug reports: https://github.com/LonnyGomes/hexcurse/issues
Description
-----------
-Hexcurse is a curses-base hex editing utility that can open, edit, and save files, editing both the hexadecimal and decimal values.
+Hexcurse is a curses-based hex editing utility that can open, edit, and save files, editing both the hexadecimal and decimal values.
It was written by [Lonny Gomes](https://twitter.com/lonnygomes) and [James Stephenson](https://plus.google.com/u/0/103174459258175070784/about) but we haven't maintained it for some time. We recently saw an old tarball of the code floating around the net and thought it would be good to start maintaining the codebase again.
@@ -33,9 +33,9 @@ Usage
usage: hexcurse [-?|help] [-a] [-r rnum] [-o outputfile] [[-i] infile]
- -a Output addresses in decimal format initially
- -e Output characters in EBCDIC format rather than ASCII
- -r rnum Resize the display to "rnum" bytes wide
+ -a Output addresses in decimal format initially
+ -e Output characters in EBCDIC format rather than ASCII
+ -r rnum Resize the display to "rnum" bytes wide
-o outfile Write output to outfile by default
-? | -help Display usage and version of hexcurse program
[-i] infile Read from data from infile (-i required if not last argument)
diff --git a/src/acceptch.c b/src/acceptch.c
index 1580645..d57207b 100644
--- a/src/acceptch.c
+++ b/src/acceptch.c
@@ -297,6 +297,7 @@ int wacceptch(WINS *win, off_t len)
}
else
currentLine -= (2*MAXY);
+ /* fall through */
case CTRL_AND('d'):
case KEY_PGDN: /* if KEY_PGDN... */
diff --git a/src/hexcurse.c b/src/hexcurse.c
index 9a275ee..e723ddc 100644
--- a/src/hexcurse.c
+++ b/src/hexcurse.c
@@ -217,9 +217,13 @@ off_t parseArgs(int argc, char *argv[])
fpINfilename = strdup(argv[0]);
}
- if (fpINfilename && strcmp(fpINfilename, ""))
+ if (fpINfilename == NULL) {
+ print_usage();
+ exit(-1);
+ } else if (fpINfilename && strcmp(fpINfilename, "")) {
if ((fpIN = fopen(fpINfilename, "r")) == NULL)
exit_err("Could not open file");
+ }
return ((fpIN != NULL) ? maxLoc(fpIN):0); /* return file length */
}
@@ -231,10 +235,9 @@ off_t parseArgs(int argc, char *argv[])
\********************************************************/
int getMinimumAddressLength(off_t len)
{
- char buffer[1];
int min_address_length;
- min_address_length = snprintf(buffer, 1, "%jd", (intmax_t)len);
+ min_address_length = snprintf(NULL, 0, "%jd", (intmax_t)len);
/* At least 8 characters wide */
return min_address_length > 8 ? min_address_length : 8;
|