update
authormirabilos <t.glaser@tarent.de>
Sun, 3 Dec 2017 02:41:08 +0000 (03:41 +0100)
committermirabilos <t.glaser@tarent.de>
Sun, 3 Dec 2017 02:41:08 +0000 (03:41 +0100)
20 files changed:
HINTS
Make-w32.sh
Makefile.am
Makefile.bsd-wrapper
Makefile.in
TODO
autoconf.h.in
b.c
charmap.c
config.h
configure
configure.ac
i18n.c
main.c
rc.c
termcap.c
uedit.c
uerror.c
umath.c
utag.c

diff --git a/HINTS b/HINTS
index 396db99..8776e09 100644 (file)
--- a/HINTS
+++ b/HINTS
@@ -4,19 +4,13 @@ yet.
 GCC
 ---
 
-Using -fomit-frame-pointer may miscompile code at least in gcc 3.4.6, see
-http://article.gmane.org/gmane.os.miros.cvs/11607 for details.
-
 Disable the following warnings; the code doesn't cope with it:
 -Wno-pointer-sign
--Wno-unused-parameter
--Wno-old-style-definition -Wno-strict-prototypes
+-Wno-old-style-definition
+-Wno-unused-parameter -Wno-strict-prototypes
 -Wno-cast-qual
 -Wno-missing-prototypes -Wno-missing-declarations
 
-Additionally, -Wstrict-overflow bitches around if you enable it.
-This needs verification and possibly fixes.
-
 UTF-8
 -----
 
@@ -134,4 +128,4 @@ will not insert.
 - Search, incremental search, and search & replace all operate as usual.
 
 ___________________________________________________________________
-$MirOS: contrib/code/jupp/HINTS,v 1.11 2017/12/02 18:50:01 tg Exp $
+$MirOS: contrib/code/jupp/HINTS,v 1.12 2017/12/03 01:43:49 tg Exp $
index cb14ea6..48ce49e 100644 (file)
@@ -1,5 +1,5 @@
 #!/bin/mksh
-# $MirOS: contrib/code/jupp/Make-w32.sh,v 1.18 2017/12/02 18:53:37 tg Exp $
+# $MirOS: contrib/code/jupp/Make-w32.sh,v 1.19 2017/12/03 01:43:50 tg Exp $
 
 usage() {
        print -ru2 "Usage: $0 [-bCgn]"
@@ -24,8 +24,8 @@ done
 
 extrawarnings="-Wall -Wextra"
 (( debug )) && extrawarnings="$extrawarnings -g3"
-extrawarnings="$extrawarnings -Wno-unused-parameter"
-extrawarnings="$extrawarnings -Wno-old-style-definition -Wno-strict-prototypes"
+extrawarnings="$extrawarnings -Wno-old-style-definition"
+extrawarnings="$extrawarnings -Wno-unused-parameter -Wno-strict-prototypes"
 extrawarnings="$extrawarnings -Wno-cast-qual"
 extrawarnings="$extrawarnings -Wno-missing-prototypes -Wno-missing-declarations"
 
index c5c9848..8336be9 100644 (file)
@@ -1,4 +1,4 @@
-# $MirOS: contrib/code/jupp/Makefile.am,v 1.17 2017/12/02 04:02:42 tg Exp $
+# $MirOS: contrib/code/jupp/Makefile.am,v 1.18 2017/12/03 01:11:48 tg Exp $
 
 AUTOMAKE_OPTIONS = foreign
 
@@ -46,14 +46,6 @@ if WANT_TERMIDX
 bin_PROGRAMS += termidx
 endif
 
-if JUPP_WIN32RELOC
-joe_WIN32_DEFS = -DJUPP_WIN32RELOC=1 -UJOERC
-else
-joe_WIN32_DEFS = -DJUPP_WIN32RELOC=0 -DJOERC="\"$(sysconf_joedir)/\""
-endif
-
-INCLUDES = $(joe_WIN32_DEFS)
-
 joe_SOURCES = \
        b.c blocks.c builtin.c builtins.c bw.c charmap.c cmd.c compat.c \
        hash.c help.c i18n.c kbd.c macro.c main.c menu.c path.c \
index 2db076e..69147b4 100644 (file)
@@ -1,4 +1,4 @@
-# $MirOS: contrib/code/jupp/Makefile.bsd-wrapper,v 1.12 2017/12/02 18:50:01 tg Exp $
+# $MirOS: contrib/code/jupp/Makefile.bsd-wrapper,v 1.14 2017/12/03 01:49:12 tg Exp $
 #-
 # make -f Makefile.bsd-wrapper CFPREFIX=/usr/mpkg sysconfjoesubdir=/joe
 
@@ -30,8 +30,8 @@ CFARGS+=      --enable-win32reloc
 FSFISLIB=      No
 
 .ifdef __CRAZY
-COPTS+=                -Wno-unused-parameter \
-               -Wno-old-style-definition -Wno-strict-prototypes \
+COPTS+=                -Wno-old-style-definition \
+               -Wno-unused-parameter -Wno-strict-prototypes \
                -Wno-cast-qual \
                -Wno-missing-prototypes -Wno-missing-declarations
 .endif
@@ -51,7 +51,7 @@ winman: joe.1
            -e '1d' -e '$$d' -e $$'s/$$/\r/' >joe.txt
 
 
-.ifmake joe.pdf
+.ifmake cats
 V_GROFF!=      pkg_info -e 'groff-*'
 V_GHOSTSCRIPT!=        pkg_info -e 'ghostscript-*'
 .  if empty(V_GROFF) || empty(V_GHOSTSCRIPT)
@@ -62,10 +62,9 @@ V_GHOSTSCRIPT!=      pkg_info -e 'ghostscript-*'
 CLEANFILES+=   joe.htm joe.ps1 joe.pdf
 CATS_KW=       jmacs, joe, jpico, jstar, jupp, rjoe
 CATS_TITLE_joe_1=joe - Joe's Own Editor
-joe.htm: joe.cat1
+cats: joe.cat1 joe.ps1
        set -e; . ${BSDSRCDIR:Q}/scripts/roff2htm; set_target_absolute; \
            do_conversion_verbose joe 1 joe.cat1 joe.htm
-joe.pdf: joe.ps1
        x=$$(ident joe.1 | \
            awk '/Mir''OS:/ { print $$4$$5; }' | \
            tr -dc 0-9); (( $${#x} == 14 )) || exit 1; exec \
index 280f84c..576f12b 100644 (file)
@@ -14,7 +14,7 @@
 
 @SET_MAKE@
 
-# $MirOS: contrib/code/jupp/Makefile.am,v 1.17 2017/12/02 04:02:42 tg Exp $
+# $MirOS: contrib/code/jupp/Makefile.am,v 1.18 2017/12/03 01:11:48 tg Exp $
 
 
 
@@ -176,8 +176,6 @@ INSTALL_DATA = @INSTALL_DATA@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
-JUPP_WIN32RELOC_FALSE = @JUPP_WIN32RELOC_FALSE@
-JUPP_WIN32RELOC_TRUE = @JUPP_WIN32RELOC_TRUE@
 LDFLAGS = @LDFLAGS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
@@ -291,9 +289,6 @@ noinst_HEADERS = \
        uisrch.h umath.h undo.h usearch.h ushell.h utag.h utf8.h utils.h \
        va.h vfile.h vs.h w.h
 
-@JUPP_WIN32RELOC_FALSE@joe_WIN32_DEFS = -DJUPP_WIN32RELOC=0 -DJOERC="\"$(sysconf_joedir)/\""
-@JUPP_WIN32RELOC_TRUE@joe_WIN32_DEFS = -DJUPP_WIN32RELOC=1 -UJOERC
-INCLUDES = $(joe_WIN32_DEFS)
 joe_SOURCES = \
        b.c blocks.c builtin.c builtins.c bw.c charmap.c cmd.c compat.c \
        hash.c help.c i18n.c kbd.c macro.c main.c menu.c path.c \
diff --git a/TODO b/TODO
index ba7c2a5..b7507de 100644 (file)
--- a/TODO
+++ b/TODO
@@ -248,7 +248,7 @@ Del: \e[3~
 Ctrl-arrows: -
 Shift-arrows: -
 
-Alt-enything: prefixed with ESC
+Alt-anything: prefixed with ESC
 
 -----------------------
 jstar missing sequences
@@ -385,8 +385,6 @@ regex: character classes? a-z matches any letter?
 New features:
 -----------------------
 
-  move *rc files to .etc/jupp directory? Or XDG, see below.
-
   check all instances of 'chars': use unicode to locale symbols instead.
   EBCDIC ?
     - we assume '\n' is line terminator.
@@ -553,9 +551,8 @@ Options
 
 Other requests:
 
- -cleanup (delete extra lines and extra spaces at ends of lines).
-
  -show no. utf characters, not no. bytes
+ (if so, both need to be available)
 
 
 ┌───────────┐
@@ -588,4 +585,4 @@ Other requests:
 • …
 
 __________________________________________________________________
-$MirOS: contrib/code/jupp/TODO,v 1.42 2017/12/02 18:33:24 tg Exp $
+$MirOS: contrib/code/jupp/TODO,v 1.43 2017/12/03 01:43:50 tg Exp $
index 23b516d..2fefe90 100644 (file)
 /* Define if isblank() works with expressions with side effects */
 #undef HAVE_WORKING_ISBLANK
 
+/* Unix absolute paths base */
+#undef JOERC
+
+/* Use Win32 argv0-relative paths? */
+#undef JUPP_WIN32RELOC
+
 /* Define to 1 if `lstat' dereferences a symlink specified with a trailing
    slash. */
 #undef LSTAT_FOLLOWS_SLASHED_SYMLINK
diff --git a/b.c b/b.c
index 05cbe9e..9e4e2d3 100644 (file)
--- a/b.c
+++ b/b.c
@@ -9,7 +9,7 @@
 #include "config.h"
 #include "types.h"
 
-__RCSID("$MirOS: contrib/code/jupp/b.c,v 1.19 2017/12/02 18:50:02 tg Exp $");
+__RCSID("$MirOS: contrib/code/jupp/b.c,v 1.20 2017/12/03 02:36:00 tg Exp $");
 
 #include <unistd.h>
 #include <sys/stat.h>
@@ -2024,33 +2024,22 @@ B *bread(int fi, long int max)
 unsigned char *parsens(unsigned char *s, long int *skip, long int *amnt)
 {
        unsigned char *n = vsncpy(NULL, 0, sz(s));
-       int x;
+       size_t x;
 
        *skip = 0;
        *amnt = LONG_MAX;
        for (x = sLEN(n) - 1; x > 0 && ((n[x] >= '0' && n[x] <= '9') || n[x] == 'x' || n[x] == 'X'); --x) ;
        if (n[x] == ',') {
+               void *vp;
+
                n[x] = 0;
-               if (n[x + 1] == 'x' || n[x + 1] == 'X')
-                       sscanf((char *)(n + x + 2), "%lx", skip);
-               else if (n[x + 1] == '0' && (n[x + 2] == 'x' || n[x + 2] == 'X'))
-                       sscanf((char *)(n + x + 3), "%lx", skip);
-               else if (n[x + 1] == '0')
-                       sscanf((char *)(n + x + 1), "%lo", skip);
-               else
-                       sscanf((char *)(n + x + 1), "%ld", skip);
+               *skip = ustol(n + x + 1, &vp, USTOL_EOS);
                for (--x; x > 0 && ((n[x] >= '0' && n[x] <= '9') || n[x] == 'x' || n[x] == 'X'); --x) ;
                if (n[x] == ',') {
                        n[x] = 0;
-                       *amnt = *skip;
-                       if (n[x + 1] == 'x' || n[x + 1] == 'X')
-                               sscanf((char *)(n + x + 2), "%lx", skip);
-                       else if (n[x + 1] == '0' && (n[x + 2] == 'x' || n[x + 2] == 'X'))
-                               sscanf((char *)(n + x + 3), "%lx", skip);
-                       else if (n[x + 1] == '0')
-                               sscanf((char *)(n + x + 1), "%lo", skip);
-                       else
-                               sscanf((char *)(n + x + 1), "%ld", skip);
+                       if (vp != NULL)
+                               *amnt = *skip;
+                       *skip = ustol(n + x + 1, NULL, USTOL_EOS);
                }
        }
 #ifndef __MSDOS__
index d9b2751..aee4593 100644 (file)
--- a/charmap.c
+++ b/charmap.c
@@ -12,7 +12,7 @@
 #include "config.h"
 #include "types.h"
 
-__RCSID("$MirOS: contrib/code/jupp/charmap.c,v 1.21 2017/12/02 04:32:38 tg Exp $");
+__RCSID("$MirOS: contrib/code/jupp/charmap.c,v 1.23 2017/12/03 02:36:00 tg Exp $");
 
 #include <stdlib.h>
 #include <string.h>
@@ -1306,10 +1306,10 @@ parse_charmap(const unsigned char *name, FILE *f)
                        int uni;
                        int byt;
 
-                       sscanf((char *)bf1+2, "%x", &uni);
+                       uni = ustolb(bf1 + 2, NULL, 0, 0x10FFFF, USTOL_HEX);
                        parse_ws(&p, comment_char);
                        parse_tows(&p, bf1);
-                       sscanf((char *)bf1+2, "%x", &byt);
+                       byt = ustolb(bf1 + 2, NULL, 0, 255, USTOL_HEX);
                        b->to_uni[byt] = uni;
                }
        }
@@ -1425,7 +1425,7 @@ main(int argc, char *argv[])
                printf("Not found\n");
                return (1);
        }
-       sscanf(argv[2], "%x", &u);
+       u = ustol(argv[2], NULL, USTOL_TRIM | USTOL_EOS);
        printf("Unicode=%X\n", uni = to_uni(map, u));
        printf("Local=%X\n", from_uni(map, uni));
        return (0);
@@ -1529,7 +1529,7 @@ joe_strtolower(unsigned char *s)
 
 PROG=          charmap
 SRCS=          charmap.c
-SRCS+=         i18n.c path.c utf8.c utils.c va.c vs.c
+SRCS+=         compat.c i18n.c path.c utf8.c utils.c va.c vs.c
 NOMAN=         Yes
 CPPFLAGS+=     -DTEST -DTEST_CHARMAP
 CPPFLAGS+=     -DJUPP_WIN32RELOC=0 -D'JOERC="/etc/joe"'
@@ -1537,8 +1537,8 @@ CPPFLAGS+=        -DJUPP_WIN32RELOC=0 -D'JOERC="/etc/joe"'
 .include <bsd.own.mk>
 
 .ifdef __CRAZY
-COPTS+=                -Wno-unused-parameter \
-               -Wno-strict-prototypes \
+COPTS+=                -Wno-old-style-definition \
+               -Wno-unused-parameter -Wno-strict-prototypes \
                -Wno-cast-qual \
                -Wno-missing-prototypes -Wno-missing-declarations
 .endif
index 59f0f21..a1467b5 100644 (file)
--- a/config.h
+++ b/config.h
@@ -6,6 +6,9 @@
 #ifndef TEST
 #include "autoconf.h"
 #else
+#define HAVE_CTIME 1
+#define HAVE_STRLCAT 1
+#define HAVE_STRLCPY 1
 #define HAVE_DECL_STRLCAT 1
 #define HAVE_DECL_STRLCPY 1
 #define HAVE_GETCWD 1
@@ -157,7 +160,7 @@ size_t strlcpy(char *, const char *, size_t)
 #endif
 
 #ifdef EXTERN
-__IDSTRING(rcsid_config_h, "$MirOS: contrib/code/jupp/config.h,v 1.10 2017/12/02 17:00:48 tg Exp $");
+__IDSTRING(rcsid_config_h, "$MirOS: contrib/code/jupp/config.h,v 1.11 2017/12/03 02:36:01 tg Exp $");
 #endif
 
 #endif /* ifndef _JOE_CONFIG_H */
index 3ff9467..ce9b147 100644 (file)
--- a/configure
+++ b/configure
@@ -709,8 +709,6 @@ LN_S
 WANT_TERMIDX_TRUE
 WANT_TERMIDX_FALSE
 sysconfjoesubdir
-JUPP_WIN32RELOC_TRUE
-JUPP_WIN32RELOC_FALSE
 joeinitfile
 joeinitcopy
 joeresides
@@ -4526,16 +4524,21 @@ else
   win32reloc=no
 fi
 
-
-
 if test x"$win32reloc" = x"yes"; then
-  JUPP_WIN32RELOC_TRUE=
-  JUPP_WIN32RELOC_FALSE='#'
+       JUPP_WIN32RELOC=1
 else
-  JUPP_WIN32RELOC_TRUE='#'
-  JUPP_WIN32RELOC_FALSE=
+       JUPP_WIN32RELOC=0
+
+cat >>confdefs.h <<_ACEOF
+#define JOERC "$sysconfdir$sysconfjoesubdir"
+_ACEOF
+
 fi
 
+cat >>confdefs.h <<_ACEOF
+#define JUPP_WIN32RELOC $JUPP_WIN32RELOC
+_ACEOF
+
 if test x"$win32reloc" = x"yes"; then
        joeinitfile='\\fBjoerc\\fR in the same directory as the binary resides in'
        joeinitcopy='which resides in the same directory as the binary'
@@ -10832,13 +10835,6 @@ echo "$as_me: error: conditional \"WANT_TERMIDX\" was never defined.
 Usually this means the macro was only invoked conditionally." >&2;}
    { (exit 1); exit 1; }; }
 fi
-if test -z "${JUPP_WIN32RELOC_TRUE}" && test -z "${JUPP_WIN32RELOC_FALSE}"; then
-  { { echo "$as_me:$LINENO: error: conditional \"JUPP_WIN32RELOC\" was never defined.
-Usually this means the macro was only invoked conditionally." >&5
-echo "$as_me: error: conditional \"JUPP_WIN32RELOC\" was never defined.
-Usually this means the macro was only invoked conditionally." >&2;}
-   { (exit 1); exit 1; }; }
-fi
 
 : ${CONFIG_STATUS=./config.status}
 ac_clean_files_save=$ac_clean_files
@@ -11493,7 +11489,7 @@ LN_S!$LN_S$ac_delim
 WANT_TERMIDX_TRUE!$WANT_TERMIDX_TRUE$ac_delim
 WANT_TERMIDX_FALSE!$WANT_TERMIDX_FALSE$ac_delim
 sysconfjoesubdir!$sysconfjoesubdir$ac_delim
-JUPP_WIN32RELOC_TRUE!$JUPP_WIN32RELOC_TRUE$ac_delim
+joeinitfile!$joeinitfile$ac_delim
 _ACEOF
 
   if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then
@@ -11535,8 +11531,6 @@ _ACEOF
 ac_delim='%!_!# '
 for ac_last_try in false false false false false :; do
   cat >conf$$subs.sed <<_ACEOF
-JUPP_WIN32RELOC_FALSE!$JUPP_WIN32RELOC_FALSE$ac_delim
-joeinitfile!$joeinitfile$ac_delim
 joeinitcopy!$joeinitcopy$ac_delim
 joeresides!$joeresides$ac_delim
 jrcbefore!$jrcbefore$ac_delim
@@ -11546,7 +11540,7 @@ SPELL!$SPELL$ac_delim
 LTLIBOBJS!$LTLIBOBJS$ac_delim
 _ACEOF
 
-  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 9; then
+  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 7; then
     break
   elif $ac_last_try; then
     { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
index 9935c47..56e3015 100644 (file)
@@ -1,4 +1,4 @@
-# $MirOS: contrib/code/jupp/configure.ac,v 1.61 2017/12/02 05:26:39 tg Exp $
+# $MirOS: contrib/code/jupp/configure.ac,v 1.62 2017/12/03 01:11:49 tg Exp $
 #-
 # Process this file with autoconf to produce a configure script.
 
@@ -112,7 +112,13 @@ AC_SUBST(sysconfjoesubdir)
 AC_ARG_ENABLE([win32reloc],
 [  --enable-win32reloc     enable win32 self-relocation],
        [win32reloc=$enableval], [win32reloc=no])
-AM_CONDITIONAL([JUPP_WIN32RELOC], [test x"$win32reloc" = x"yes"])
+if test x"$win32reloc" = x"yes"; then
+       JUPP_WIN32RELOC=1
+else
+       JUPP_WIN32RELOC=0
+       AC_DEFINE_UNQUOTED([JOERC], ["$sysconfdir$sysconfjoesubdir"], [Unix absolute paths base])
+fi
+AC_DEFINE_UNQUOTED([JUPP_WIN32RELOC], [$JUPP_WIN32RELOC], [Use Win32 argv0-relative paths?])
 if test x"$win32reloc" = x"yes"; then
        joeinitfile='\\fBjoerc\\fR in the same directory as the binary resides in'
        joeinitcopy='which resides in the same directory as the binary'
diff --git a/i18n.c b/i18n.c
index 4dc188e..29914e4 100644 (file)
--- a/i18n.c
+++ b/i18n.c
 #include <stdlib.h>
 #endif
 
-__RCSID("$MirOS: contrib/code/jupp/i18n.c,v 1.27 2017/12/02 18:50:02 tg Exp $");
+__RCSID("$MirOS: contrib/code/jupp/i18n.c,v 1.29 2017/12/03 02:36:01 tg Exp $");
 
 #include "charmap.h"
+#include "utils.h"
 
 /* From: X11/xc/programs/xterm/wcwidth.c,v 1.10 */
 
@@ -6902,10 +6903,13 @@ int
 main(int argc,char *argv[])
 {
        int c;
+       void *vp;
 
        if (argc != 2)
                return (1);
-       sscanf(argv[1],"%x",&c);
+       c = ustolb(argv[1], &vp, 0, 0x10FFFF, USTOL_TRIM | USTOL_EOS);
+       if (!vp)
+               return (1);
        printf("Properties of character %X:\n",c);
        printf("upper=%X\n",joe_iswupper(NULL,c));
        printf("lower=%X\n",joe_iswlower(NULL,c));
@@ -6928,14 +6932,15 @@ main(int argc,char *argv[])
 .endif
 
 PROG=          i18n
+SRCS=          compat.c i18n.c
 NOMAN=         Yes
 CPPFLAGS+=     -DTEST -DTEST_I18N
 
 .include <bsd.own.mk>
 
 .ifdef __CRAZY
-COPTS+=                -Wno-unused-parameter \
-               -Wno-old-style-definition -Wno-strict-prototypes \
+COPTS+=                -Wno-old-style-definition \
+               -Wno-unused-parameter -Wno-strict-prototypes \
                -Wno-cast-qual \
                -Wno-missing-prototypes -Wno-missing-declarations
 .endif
diff --git a/main.c b/main.c
index 66a984a..d12a5f3 100644 (file)
--- a/main.c
+++ b/main.c
@@ -32,7 +32,7 @@
 #include "config.h"
 #include "types.h"
 
-__RCSID("$MirOS: contrib/code/jupp/main.c,v 1.33 2017/12/02 04:32:40 tg Exp $");
+__RCSID("$MirOS: contrib/code/jupp/main.c,v 1.35 2017/12/03 02:39:32 tg Exp $");
 
 #include <fcntl.h>
 #include <string.h>
@@ -55,6 +55,7 @@ __RCSID("$MirOS: contrib/code/jupp/main.c,v 1.33 2017/12/02 04:32:40 tg Exp $");
 #include "w.h"
 #include "charmap.h"
 #include "syntax.h"
+#include "utils.h"
 
 extern int mid, dspasis, help, pgamnt, nobackups, lightoff, exask, lines, columns, dopadding, marking, dobeep;
 
@@ -204,11 +205,11 @@ main_init(int argc, char **argv, char **envp, SCRN **np)
        run = namprt(argv[0]);
 
        if ((s = (unsigned char *)getenv("LINES")) != NULL)
-               sscanf((char *)s, "%d", &lines);
+               lines = ustol(s, NULL, USTOL_DEC | USTOL_EOS);
        if ((s = (unsigned char *)getenv("COLUMNS")) != NULL)
-               sscanf((char *)s, "%d", &columns);
+               columns = ustol(s, NULL, USTOL_DEC | USTOL_EOS);
        if ((s = (unsigned char *)getenv("BAUD")) != NULL)
-               sscanf((char *)s, "%u", &Baud);
+               Baud = ustol(s, NULL, USTOL_DEC | USTOL_EOS);
        if (getenv("DOPADDING"))
                dopadding = 1;
        if (getenv("NOXON"))
@@ -354,7 +355,7 @@ main_init(int argc, char **argv, char **envp, SCRN **np)
                                        old_context = bw->o.context;
                                        while (backopt != c) {
                                                if (argv[backopt][0] == '+') {
-                                                       sscanf((char *)(argv[backopt] + 1), "%ld", &lnum);
+                                                       lnum = ustol(argv[backopt] + 1, NULL, USTOL_TRIM | USTOL_EOS);
                                                        ++backopt;
                                                } else {
                                                        if (glopt(argv[backopt] + 1, argv[backopt + 1], &bw->o, 0) == 2)
diff --git a/rc.c b/rc.c
index a247727..2d8ce4a 100644 (file)
--- a/rc.c
+++ b/rc.c
@@ -9,7 +9,7 @@
 #include "config.h"
 #include "types.h"
 
-__RCSID("$MirOS: contrib/code/jupp/rc.c,v 1.28 2017/12/02 18:33:24 tg Exp $");
+__RCSID("$MirOS: contrib/code/jupp/rc.c,v 1.29 2017/12/03 02:36:02 tg Exp $");
 
 #include <string.h>
 #ifdef HAVE_STDLIB_H
@@ -226,7 +226,7 @@ void setopt(B *b, unsigned char *parsed_name)
 #define G(type,name,setiaddr,yes,no,menu,low,high) \
        X(type,name,setiaddr,yes,no,menu,low,high)
 #define X(type,name,seti,addr,yes,no,menu,low,high) \
-       { UC name, { seti }, US addr, UC yes, UC no, UC menu, type, 0, low, high }
+       { UC name, { seti }, US addr, UC yes, UC no, UC menu, 0, type, low, high }
 #define L(x) &x, NULL
 struct glopts {
        const unsigned char *name;      /* Option name */
@@ -238,6 +238,7 @@ struct glopts {
        const unsigned char *yes;       /* Message if option was turned on, or prompt string */
        const unsigned char *no;        /* Message if option was turned off */
        const unsigned char *menu;      /* Menu string */
+       size_t ofst;                    /* Local options structure member offset */
        int type;               /* 0 for global option flag
                                   1 for global option numeric
                                   2 for global option string
@@ -249,7 +250,6 @@ struct glopts {
                                   9 for syntax
                                  13 for encoding
                                 */
-       int ofst;               /* Local options structure member offset */
        int low;                /* Low limit for numeric options */
        int high;               /* High limit for numeric options */
 } glopts[] = {
@@ -366,6 +366,7 @@ int glopt(unsigned char *s, unsigned char *arg, OPTIONS *options_, int set)
        int ret = 0;
        int st = 1;     /* 1 to set option, 0 to clear it */
        int x;
+       void *vp;
 
        /* Initialize offsets */
        if (!isiz)
@@ -386,8 +387,8 @@ int glopt(unsigned char *s, unsigned char *arg, OPTIONS *options_, int set)
                                break;
                        case 1: /* Global variable integer option */
                                if (set && arg) {
-                                       sscanf((char *)arg, "%d", &val);
-                                       if (val >= glopts[x].low && val <= glopts[x].high)
+                                       val = ustolb(arg, &vp, glopts[x].low, glopts[x].high, USTOL_TRIM | USTOL_EOS);
+                                       if (vp)
                                                *glopts[x].set.i = val;
                                }
                                break;
@@ -404,26 +405,19 @@ int glopt(unsigned char *s, unsigned char *arg, OPTIONS *options_, int set)
                                        *(int *) ((unsigned char *) options_ + glopts[x].ofst) = st;
                                break;
                        case 5: /* Local option integer */
-                               if (arg) {
-                                       if (options_) {
-                                               sscanf((char *)arg, "%d", &val);
-                                               if (val >= glopts[x].low && val <= glopts[x].high)
-                                                       *(int *) ((unsigned char *)
-                                                                 options_ + glopts[x].ofst) = val;
-                                       }
+                               if (arg && options_) {
+                                       val = ustolb(arg, &vp, glopts[x].low, glopts[x].high, USTOL_TRIM | USTOL_EOS);
+                                       if (vp)
+                                               *(int *) ((unsigned char *)
+                                                         options_ + glopts[x].ofst) = val;
                                }
                                break;
                        case 7: /* Local option numeric + 1, with range checking */
                                if (arg) {
-                                       int zz = 0;
-
-                                       sscanf((char *)arg, "%d", &zz);
-                                       if (zz >= glopts[x].low && zz <= glopts[x].high) {
-                                               --zz;
-                                               if (options_)
-                                                       *(int *) ((unsigned char *)
-                                                                 options_ + glopts[x].ofst) = zz;
-                                       }
+                                       val = ustolb(arg, &vp, glopts[x].low, glopts[x].high, USTOL_TRIM | USTOL_EOS);
+                                       if (vp && options_)
+                                               *(int *) ((unsigned char *)
+                                                         options_ + glopts[x].ofst) = val - 1;
                                }
                                break;
 
index e3281ab..1891517 100644 (file)
--- a/termcap.c
+++ b/termcap.c
@@ -8,7 +8,7 @@
 #include "config.h"
 #include "types.h"
 
-__RCSID("$MirOS: contrib/code/jupp/termcap.c,v 1.16 2017/12/02 04:46:10 tg Exp $");
+__RCSID("$MirOS: contrib/code/jupp/termcap.c,v 1.17 2017/12/03 02:36:02 tg Exp $");
 
 #ifdef HAVE_SYS_STAT_H
 #include <sys/stat.h>
@@ -121,17 +121,15 @@ static off_t findidx(FILE *file, unsigned char *name)
        off_t addr = 0;
 
        while (fgets((char *)buf, 80, file)) {
-               int x = 0, flg = 0, c, y, z;
+               int x = 0, flg = 0, c, y;
 
                do {
                        for (y = x; buf[y] && buf[y] != ' ' && buf[y] != '\n'; ++y) ;
                        c = buf[y];
                        buf[y] = 0;
-                       if (c == '\n' || !c) {
-                               z = 0;
-                               sscanf((char *)(buf + x), "%x", &z);
-                               addr += z;
-                       } else if (!strcmp(buf + x, name))
+                       if (c == '\n' || !c)
+                               addr += ustol(buf + x, NULL, USTOL_HEX);
+                       else if (!strcmp(buf + x, name))
                                flg = 1;
                        x = y + 1;
                } while (c && c != '\n');
diff --git a/uedit.c b/uedit.c
index 9d8320f..8023df4 100644 (file)
--- a/uedit.c
+++ b/uedit.c
@@ -8,7 +8,7 @@
 #include "config.h"
 #include "types.h"
 
-__RCSID("$MirOS: contrib/code/jupp/uedit.c,v 1.20 2017/12/02 04:32:42 tg Exp $");
+__RCSID("$MirOS: contrib/code/jupp/uedit.c,v 1.21 2017/12/03 02:36:03 tg Exp $");
 
 #include <string.h>
 
@@ -1180,7 +1180,7 @@ static int dounicode(BW *bw, unsigned char *s, void *object, int *notify)
 {
        int num;
 
-       sscanf((char *)s,"%x",&num);
+       num = ustolb(s, NULL, 0, 0x10FFFF, USTOL_HEX | USTOL_TRIM | USTOL_EOS);
        if (notify)
                *notify = 1;
        vsrm(s);
index a901eba..b3e70f4 100644 (file)
--- a/uerror.c
+++ b/uerror.c
@@ -8,7 +8,7 @@
 #include "config.h"
 #include "types.h"
 
-__RCSID("$MirOS: contrib/code/jupp/uerror.c,v 1.6 2017/12/02 18:50:03 tg Exp $");
+__RCSID("$MirOS: contrib/code/jupp/uerror.c,v 1.7 2017/12/03 02:36:03 tg Exp $");
 
 #include "b.h"
 #include "bw.h"
@@ -153,10 +153,15 @@ static int parseit(struct charmap *map,unsigned char *s, long int row)
        for (y = x; s[y] >= '0' && s[y] <= '9'; ++y) ;
 
        /* Save line number */
-       if (x != y)
-               sscanf((char *)(s + x), "%ld", &line);
-       if (line != -1)
-               --line;
+       if (x != y) {
+               void *vp;
+
+               line = ustol(s + x, &vp, USTOL_DEC);
+               if (!vp)
+                       line = -1;
+               else
+                       --line;
+       }
 
        /* Look for ':' */
        flg = 0;
diff --git a/umath.c b/umath.c
index eddf17c..4c2c65e 100644 (file)
--- a/umath.c
+++ b/umath.c
@@ -8,7 +8,7 @@
 #include "config.h"
 #include "types.h"
 
-__RCSID("$MirOS: contrib/code/jupp/umath.c,v 1.15 2017/12/02 18:33:25 tg Exp $");
+__RCSID("$MirOS: contrib/code/jupp/umath.c,v 1.16 2017/12/03 02:36:03 tg Exp $");
 
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
@@ -90,12 +90,11 @@ static double expr(int prec, struct var **rtv)
                *ptr = c;
        } else if (ptr[0] == '0' && (ptr[1] | 0x20) == 'x') {
                unsigned long xi;
+               void *dp;
 
-               sscanf((char *)ptr, "%li", &xi);
+               xi = ustol(ptr, &dp, USTOL_AUTO);
                x = (double)xi;
-               ptr += 2;
-               while ((*ptr >= '0' && *ptr <= '9') || ((*ptr | 0x20) >= 'a' && (*ptr | 0x20) <= 'f'))
-                       ++ptr;
+               ptr = dp;
        } else if ((*ptr >= '0' && *ptr <= '9') || *ptr == '.') {
                char *eptr;
 
diff --git a/utag.c b/utag.c
index f6bceb7..9ff0da0 100644 (file)
--- a/utag.c
+++ b/utag.c
@@ -8,7 +8,7 @@
 #include "config.h"
 #include "types.h"
 
-__RCSID("$MirOS: contrib/code/jupp/utag.c,v 1.5 2017/12/02 04:32:43 tg Exp $");
+__RCSID("$MirOS: contrib/code/jupp/utag.c,v 1.6 2017/12/03 02:36:03 tg Exp $");
 
 #include "b.h"
 #include "bw.h"
@@ -75,7 +75,7 @@ static int dotag(BW *bw, unsigned char *s, void *obj, int *notify)
                                        long line = 0;
 
                                        if (buf[y] >= '0' && buf[y] <= '9') {
-                                               sscanf((char *)(buf + y), "%ld", &line);
+                                               line = ustol(buf + y, NULL, USTOL_AUTO);
                                                if (line >= 1) {
                                                        int omid = mid;