summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
b343422)
new non-const tmp variable called tmpbuf. (Joe, you were half a minute quicker
than I.)
- * $Id: config.c,v 1.9 2001-12-31 18:40:08 jmarcus Exp $
+ * $Id: config.c,v 1.10 2001-12-31 20:01:17 srittau Exp $
*
* Copyright (c) 1990,1993 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
*
* Copyright (c) 1990,1993 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
};
#define ARGV_CHUNK_SIZE 128
};
#define ARGV_CHUNK_SIZE 128
-char **parseline(char *line)
+char **parseline(const char *line)
char **argv;
/* Ignore empty lines and lines with leading hash marks. */
char **argv;
/* Ignore empty lines and lines with leading hash marks. */
return NULL;
}
strcpy( buffer, p );
return NULL;
}
strcpy( buffer, p );
argv = (char **) malloc( ARGV_CHUNK_SIZE * sizeof( char * ) );
if ( !argv ) {
argv = (char **) malloc( ARGV_CHUNK_SIZE * sizeof( char * ) );
if ( !argv ) {
* handle various escapes, e.g. \" and \031.
*/
do {
* handle various escapes, e.g. \" and \031.
*/
do {
- if ( *p == '"' ) {
- argv[ argc++ ] = ++p;
- while ( *p != '\0' && *p != '"' ) {
- p++;
+ if ( *tmpbuf == '"' ) {
+ argv[ argc++ ] = ++tmpbuf;
+ while ( *tmpbuf != '\0' && *tmpbuf != '"' ) {
+ tmpbuf++;
+ if ( *tmpbuf == '"' ) {
/* FIXME: error handling */
}
} else {
/* FIXME: error handling */
}
} else {
- argv[ argc++ ] = p;
- while ( *p != '\0' && !isspace( *p )) {
- p++;
+ argv[ argc++ ] = tmpbuf;
+ while ( *tmpbuf != '\0' && !isspace( *tmpbuf )) {
+ tmpbuf++;
/* Make room for a NULL pointer and our special pointer (s.b.) */
if ( (argc + 1) % ARGV_CHUNK_SIZE == 0 ) {
/* Make room for a NULL pointer and our special pointer (s.b.) */
if ( (argc + 1) % ARGV_CHUNK_SIZE == 0 ) {
}
/* Skip white spaces. */
}
/* Skip white spaces. */
- while ( isspace( *p ) ) {
- p++;
+ while ( isspace( *tmpbuf ) ) {
+ tmpbuf++;
- } while ( *p != '\0' );
+ } while ( *tmpbuf != '\0' );
argv[ argc++ ] = NULL;
/* We store our buffer pointer in argv, too, so we can free it later.
argv[ argc++ ] = NULL;
/* We store our buffer pointer in argv, too, so we can free it later.