Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Unify all arch/*/stand's atoi() to MI libsa.



details:   https://anonhg.NetBSD.org/src/rev/5f9d8b266551
branches:  trunk
changeset: 331384:5f9d8b266551
user:      isaki <isaki%NetBSD.org@localhost>
date:      Sun Aug 10 07:40:49 2014 +0000

description:
Unify all arch/*/stand's atoi() to MI libsa.
lib/libsa/atoi.c was separated from lib/libsa/bootcfg.c.
PR/49084

diffstat:

 sys/arch/hp300/stand/common/devopen.c   |  12 +-------
 sys/arch/hp300/stand/common/samachdep.h |   3 +-
 sys/arch/hp300/stand/inst/inst.c        |  13 ++------
 sys/arch/i386/stand/lib/bootmenu.c      |  24 ++--------------
 sys/arch/i386/stand/lib/bootmenu.h      |   3 +-
 sys/arch/next68k/stand/boot/devopen.c   |  13 +--------
 sys/arch/prep/stand/boot/devopen.c      |  13 +--------
 sys/arch/rs6000/stand/boot/devopen.c    |  13 +--------
 sys/arch/x68k/stand/boot/switch.c       |  18 +-----------
 sys/arch/zaurus/stand/zboot/bootmenu.c  |  22 +-------------
 sys/arch/zaurus/stand/zboot/bootmenu.h  |   3 +-
 sys/lib/libsa/Makefile                  |   4 +-
 sys/lib/libsa/atoi.c                    |  49 +++++++++++++++++++++++++++++++++
 sys/lib/libsa/bootcfg.c                 |  24 +--------------
 sys/lib/libsa/stand.h                   |   4 ++-
 15 files changed, 72 insertions(+), 146 deletions(-)

diffs (truncated from 474 to 300 lines):

diff -r fd6a49197471 -r 5f9d8b266551 sys/arch/hp300/stand/common/devopen.c
--- a/sys/arch/hp300/stand/common/devopen.c     Sun Aug 10 07:33:40 2014 +0000
+++ b/sys/arch/hp300/stand/common/devopen.c     Sun Aug 10 07:40:49 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: devopen.c,v 1.10 2008/04/28 20:23:19 martin Exp $      */
+/*     $NetBSD: devopen.c,v 1.11 2014/08/10 07:40:49 isaki Exp $       */
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -73,16 +73,6 @@
 static int devlookup(const char * ,int);
 static int devparse(const char *, int *, int*, int*, int*, int*, char **);
 
-int
-atoi(char *cp)
-{
-       int val = 0;
-
-       while (isdigit((unsigned char)*cp))
-               val = val * 10 + (*cp++ - '0');
-       return val;
-}
-
 void
 usage(void)
 {
diff -r fd6a49197471 -r 5f9d8b266551 sys/arch/hp300/stand/common/samachdep.h
--- a/sys/arch/hp300/stand/common/samachdep.h   Sun Aug 10 07:33:40 2014 +0000
+++ b/sys/arch/hp300/stand/common/samachdep.h   Sun Aug 10 07:40:49 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: samachdep.h,v 1.17 2014/04/19 06:04:58 tsutsui Exp $   */
+/*     $NetBSD: samachdep.h,v 1.18 2014/08/10 07:40:49 isaki Exp $     */
 
 /*
  * Copyright (c) 1982, 1990, 1993
@@ -74,7 +74,6 @@
 
 /* devopen.c */
 extern u_int opendev;
-int atoi(char *);
 
 /* exec.c */
 void exec_hp300(char *, u_long, int);
diff -r fd6a49197471 -r 5f9d8b266551 sys/arch/hp300/stand/inst/inst.c
--- a/sys/arch/hp300/stand/inst/inst.c  Sun Aug 10 07:33:40 2014 +0000
+++ b/sys/arch/hp300/stand/inst/inst.c  Sun Aug 10 07:40:49 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: inst.c,v 1.19 2014/06/21 02:01:21 tsutsui Exp $        */
+/*     $NetBSD: inst.c,v 1.20 2014/08/10 07:40:49 isaki Exp $  */
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -760,18 +760,11 @@
        __asm("stop #0x2700");
 }
 
-/*
- * XXX Should have a generic atoi for libkern/libsa.
- */
 int
 a2int(char *cp)
 {
-       int i = 0;
-
        if (*cp == '\0')
-               return (-1);
+               return -1;
 
-       while (*cp != '\0')
-               i = i * 10 + *cp++ - '0';
-       return (i);
+       return atoi(cp);
 }
diff -r fd6a49197471 -r 5f9d8b266551 sys/arch/i386/stand/lib/bootmenu.c
--- a/sys/arch/i386/stand/lib/bootmenu.c        Sun Aug 10 07:33:40 2014 +0000
+++ b/sys/arch/i386/stand/lib/bootmenu.c        Sun Aug 10 07:40:49 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bootmenu.c,v 1.13 2014/06/28 09:16:18 rtr Exp $        */
+/*     $NetBSD: bootmenu.c,v 1.14 2014/08/10 07:40:49 isaki Exp $      */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -40,8 +40,6 @@
 #include <libi386.h>
 #include <bootmenu.h>
 
-#define isnum(c) ((c) >= '0' && (c) <= '9')
-
 static void docommandchoice(int);
 
 extern struct x86_boot_params boot_params;
@@ -51,22 +49,6 @@
 #define MENUFORMAT_NUMBER 1
 #define MENUFORMAT_LETTER 2
 
-int
-atoi(const char *in)
-{
-       char *c;
-       int ret;
-
-       ret = 0;
-       c = (char *)in;
-       if (*c == '-')
-               c++;
-       for (; isnum(*c); c++)
-               ret = (ret * 10) + (*c - '0');
-
-       return (*in == '-') ? -ret : ret;
-}
-
 /*
  * XXX
  * if module_add, userconf_add are strictly mi they can be folded back
@@ -105,14 +87,14 @@
                choice = (*input) - 'A';
        else if (*input >= 'a' && *input < bootcfg_info.nummenu + 'a')
                choice = (*input) - 'a';
-       else if (isnum(*input)) {
+       else if (isdigit(*input)) {
                choice = atoi(input) - 1;
                if (choice < 0 || choice >= bootcfg_info.nummenu)
                        choice = -1;
        }
 
        if (bootcfg_info.menuformat != MENUFORMAT_LETTER &&
-           !isnum(*input) && !usedef)
+           !isdigit(*input) && !usedef)
                choice = -1;
 
        return choice;
diff -r fd6a49197471 -r 5f9d8b266551 sys/arch/i386/stand/lib/bootmenu.h
--- a/sys/arch/i386/stand/lib/bootmenu.h        Sun Aug 10 07:33:40 2014 +0000
+++ b/sys/arch/i386/stand/lib/bootmenu.h        Sun Aug 10 07:40:49 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bootmenu.h,v 1.4 2014/06/28 09:16:18 rtr Exp $ */
+/*     $NetBSD: bootmenu.h,v 1.5 2014/08/10 07:40:49 isaki Exp $       */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -34,6 +34,5 @@
 void parsebootconf(const char *);
 void doboottypemenu(void);
 void bootdefault(void);
-int atoi(const char *);
 
 #endif /* !_BOOTMENU_H */
diff -r fd6a49197471 -r 5f9d8b266551 sys/arch/next68k/stand/boot/devopen.c
--- a/sys/arch/next68k/stand/boot/devopen.c     Sun Aug 10 07:33:40 2014 +0000
+++ b/sys/arch/next68k/stand/boot/devopen.c     Sun Aug 10 07:40:49 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: devopen.c,v 1.5 2005/12/11 12:18:29 christos Exp $     */
+/*     $NetBSD: devopen.c,v 1.6 2014/08/10 07:40:49 isaki Exp $        */
 /*
  * Copyright (c) 1994 Rolf Grossmann
  * All rights reserved.
@@ -32,21 +32,10 @@
 #include <lib/libsa/stand.h>
 #include <lib/libkern/libkern.h>
 
-int atoi(const char *);
 int devlookup(const char *, int);
 int devparse(const char *, int *, char *, char *, char *, char **);
 
 int
-atoi(const char *cp)
-{
-    int val = 0;
-
-    while(isdigit((unsigned char)*cp))
-       val = val * 10 + (*cp++ - '0');
-    return val;
-}
-
-int
 devlookup(const char *d, int len)
 {
     struct devsw *dp = devsw;
diff -r fd6a49197471 -r 5f9d8b266551 sys/arch/prep/stand/boot/devopen.c
--- a/sys/arch/prep/stand/boot/devopen.c        Sun Aug 10 07:33:40 2014 +0000
+++ b/sys/arch/prep/stand/boot/devopen.c        Sun Aug 10 07:40:49 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: devopen.c,v 1.4 2012/05/19 14:40:13 kiyohara Exp $     */
+/*     $NetBSD: devopen.c,v 1.5 2014/08/10 07:40:49 isaki Exp $        */
 
 /*-
  *  Copyright (c) 1993 John Brezak
@@ -33,21 +33,10 @@
 
 #define        ispart(c)       ((c) >= 'a' && (c) <= 'h')
 
-int atoi(char *);
 int devlookup(char *);
 int devparse(const char *, int *, int *, int *, int *, int *, char **);
 
 int
-atoi(char *cp)
-{
-       int val = 0;
-
-       while (isdigit(*cp))
-               val = val * 10 + (*cp++ - '0');
-       return (val);
-}
-
-int
 devlookup(char *d)
 {
        struct devsw *dp = devsw;
diff -r fd6a49197471 -r 5f9d8b266551 sys/arch/rs6000/stand/boot/devopen.c
--- a/sys/arch/rs6000/stand/boot/devopen.c      Sun Aug 10 07:33:40 2014 +0000
+++ b/sys/arch/rs6000/stand/boot/devopen.c      Sun Aug 10 07:40:49 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: devopen.c,v 1.1 2007/12/17 19:09:48 garbled Exp $      */
+/*     $NetBSD: devopen.c,v 1.2 2014/08/10 07:40:49 isaki Exp $        */
 
 /*-
  *  Copyright (c) 1993 John Brezak
@@ -33,21 +33,10 @@
 
 #define        ispart(c)       ((c) >= 'a' && (c) <= 'h')
 
-int atoi(char *);
 int devlookup(char *);
 int devparse(const char *, int *, int *, int *, int *, int *, char **);
 
 int
-atoi(char *cp)
-{
-       int val = 0;
-
-       while (isdigit(*cp))
-               val = val * 10 + (*cp++ - '0');
-       return (val);
-}
-
-int
 devlookup(char *d)
 {
        struct devsw *dp = devsw;
diff -r fd6a49197471 -r 5f9d8b266551 sys/arch/x68k/stand/boot/switch.c
--- a/sys/arch/x68k/stand/boot/switch.c Sun Aug 10 07:33:40 2014 +0000
+++ b/sys/arch/x68k/stand/boot/switch.c Sun Aug 10 07:40:49 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: switch.c,v 1.1 2014/08/05 13:49:04 isaki Exp $ */
+/*     $NetBSD: switch.c,v 1.2 2014/08/10 07:40:50 isaki Exp $ */
 
 /*
  * Copyright (c) 2014 Tetsuya Isaki. All rights reserved.
@@ -63,22 +63,6 @@
 }
 
 static int
-atoi(const char *in)
-{
-       char *c;
-       int ret;
-
-       ret = 0;
-       c = (char *)in;
-       if (*c == '-')
-               c++;
-       for (; isdigit(*c); c++)
-               ret = (ret * 10) + (*c - '0');
-
-       return (*in == '-') ? -ret : ret;
-}
-
-static int
 hextoi(const char *in)
 {
        char *c;
diff -r fd6a49197471 -r 5f9d8b266551 sys/arch/zaurus/stand/zboot/bootmenu.c
--- a/sys/arch/zaurus/stand/zboot/bootmenu.c    Sun Aug 10 07:33:40 2014 +0000
+++ b/sys/arch/zaurus/stand/zboot/bootmenu.c    Sun Aug 10 07:40:49 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bootmenu.c,v 1.3 2014/06/28 09:16:18 rtr Exp $ */
+/*     $NetBSD: bootmenu.c,v 1.4 2014/08/10 07:40:50 isaki Exp $       */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -35,28 +35,10 @@
 #include "bootmenu.h"
 #include "pathnames.h"
 
-#define isnum(c) ((c) >= '0' && (c) <= '9')
-
 #define MENUFORMAT_AUTO          0
 #define MENUFORMAT_NUMBER 1
 #define MENUFORMAT_LETTER 2
 
-int
-atoi(const char *in)
-{
-       char *c;
-       int ret;
-
-       ret = 0;
-       c = (char *)in;
-       if (*c == '-')



Home | Main Index | Thread Index | Old Index