aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2024-12-14 23:51:29 -0500
committerB. Watson <urchlay@slackware.uk>2024-12-14 23:51:29 -0500
commit01a5b51315430bc714a194cd0a864d4e33d6682f (patch)
tree419d378abec2a43015b6a20a5a2a73e06ed8a6b6
parentaa10bae90176d5025148225781d9176b6ee347d4 (diff)
downloaduxd-01a5b51315430bc714a194cd0a864d4e33d6682f.tar.gz
rename getopt() so we can compile with g++ if needed.
-rw-r--r--getopt.c15
-rw-r--r--uxd.14
-rw-r--r--uxd.c19
3 files changed, 13 insertions, 25 deletions
diff --git a/getopt.c b/getopt.c
index c6bf394..0c0057e 100644
--- a/getopt.c
+++ b/getopt.c
@@ -36,17 +36,12 @@ extern char *self;
#define ENDARGS "--"
/* this is included because index is not on some UNIX systems */
-static
-char *
-index (s, c)
-register char *s;
-register int c;
- {
+static char *index (char *s, int c) {
while (*s)
if (c == *s) return (s);
else s++;
return (NULL);
- }
+}
/*
* get option letter from argument vector
@@ -60,11 +55,9 @@ char *optarg; /* argument associated with option */
fputc(optopt,stderr);fputs(" (use -h for help)\n",stderr);return(BADCH);
-int getopt(int nargc, char **nargv, char *ostr)
-{
+int my_getopt(int nargc, char **nargv, char *ostr) {
static char *place = EMSG; /* option letter processing */
- register char *oli; /* option letter list index */
- char *index();
+ char *oli; /* option letter list index */
if(!*place) { /* update scanning pointer */
if(optind >= nargc || *(place = nargv[optind]) != '-' || !*++place) return(EOF);
diff --git a/uxd.1 b/uxd.1
index 87d5858..eb8b99c 100644
--- a/uxd.1
+++ b/uxd.1
@@ -75,7 +75,9 @@ NOT IMPLEMENTED YET.
Print built\-in usage message and exit.
.TP
.BI \-l \ length
-Stop dumping after \fIlength\fP bytes (note: bytes, not characters).
+Stop dumping after \fIlength\fP bytes (not characters). If the limit is
+reached in the middle of a multibyte character, the entire character
+will be dumped.
.TP
.B \-m
Monochrome mode. Uses underline, bold, reverse video instead of color.
diff --git a/uxd.c b/uxd.c
index 2502463..c4ad772 100644
--- a/uxd.c
+++ b/uxd.c
@@ -3,18 +3,6 @@
#include <string.h>
#include <unistd.h>
-extern int getopt(int, char **, char *);
-extern char *optarg;
-extern int optind;
-
-/* output looks like:
-
- 0 1 2 3 4 5 6 7 8 9 A B C D E F
-0000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 abcdefghijklmnop
-
-...first column will extend to more digits if needed.
-*/
-
/* UTF-8 spec summary, taken from Wikipedia and elsewhere, kept here
for locality of reference.
@@ -45,6 +33,11 @@ fe ff, it's UTF-16 big-endian. We detect these and print a warning
on stderr.
*/
+/* from getopt.c */
+extern int my_getopt(int, char **, char *);
+extern char *optarg;
+extern int optind;
+
#ifndef VERSION
#define VERSION "(unknown version)"
#endif
@@ -127,7 +120,7 @@ void parse_options(int argc, char **argv) {
version();
}
- while((opt = getopt(argc, argv, "l:rmo:s:uhv")) != -1) {
+ while((opt = my_getopt(argc, argv, "l:rmo:s:uhv")) != -1) {
switch(opt) {
case 'l':
limit = parse_number(optarg); break;