forked from Imagelibrary/rtems
* ftpd/ftpd.c, httpd/asp.c, httpd/ejparse.c, httpd/emfdb.c, httpd/misc.c, httpd/um.c, httpd/webs.c, httpd/websuemf.c, libfs/src/dosfs/msdos_dir.c, libfs/src/dosfs/msdos_format.c, libfs/src/dosfs/msdos_misc.c, libfs/src/nfsclient/src/nfs.c, libmisc/capture/capture-cli.c, libmisc/monitor/mon-network.c, libmisc/shell/hexdump-odsyntax.c, libmisc/shell/main_ifconfig.c, libmisc/shell/shell.c, libmisc/shell/shell_makeargs.c, libmisc/uuid/parse.c, libnetworking/libc/gethostbydns.c, libnetworking/libc/gethostbyht.c, libnetworking/libc/gethostnamadr.c, libnetworking/libc/getnetnamadr.c, libnetworking/libc/inet_addr.c, libnetworking/libc/inet_network.c, libnetworking/libc/res_debug.c, libnetworking/libc/res_init.c, libnetworking/libc/res_query.c, libnetworking/rtems/rtems_mii_ioctl.c, score/src/objectgetnameasstring.c: Readdress use of ctype methods per recommendation from D.J. Delorie on the newlib mailing list. We should pass an unsigned char into these methods.
67 lines
1.1 KiB
C
67 lines
1.1 KiB
C
/*
|
|
* Split string into argc/argv style argument list
|
|
*
|
|
* COPYRIGHT (c) 1989-2008.
|
|
* On-Line Applications Research Corporation (OAR).
|
|
*
|
|
* The license and distribution terms for this file may be
|
|
* found in the file LICENSE in this distribution or at
|
|
* http://www.rtems.com/license/LICENSE.
|
|
*
|
|
* $Id$
|
|
*/
|
|
|
|
#if HAVE_CONFIG_H
|
|
#include "config.h"
|
|
#endif
|
|
|
|
#include <string.h>
|
|
#include <ctype.h>
|
|
|
|
int rtems_shell_make_args(
|
|
char *commandLine,
|
|
int *argc_p,
|
|
char **argv_p,
|
|
int max_args
|
|
)
|
|
{
|
|
int argc;
|
|
char *ch;
|
|
int status = 0;
|
|
|
|
argc = 0;
|
|
ch = commandLine;
|
|
|
|
while ( *ch ) {
|
|
|
|
while ( isspace((unsigned char)*ch) ) ch++;
|
|
|
|
if ( *ch == '\0' )
|
|
break;
|
|
|
|
if ( *ch == '"' ) {
|
|
argv_p[ argc++ ] = ++ch;
|
|
while ( ( *ch == '\0' ) && ( *ch != '"' ) ) ch++;
|
|
} else {
|
|
argv_p[ argc++ ] = ch;
|
|
while ( ( *ch == '\0' ) && ( !isspace((unsigned char)*ch) ) ) ch++;
|
|
}
|
|
|
|
if ( *ch == '\0' )
|
|
break;
|
|
|
|
*ch++ = '\0';
|
|
|
|
if ( argc == (max_args-1) ) {
|
|
status = -1;
|
|
break;
|
|
}
|
|
|
|
|
|
}
|
|
argv_p[ argc ] = NULL;
|
|
*argc_p = argc;
|
|
return status;
|
|
}
|
|
|