skip_whitespace() shouldn't claim its return value is const, it doesn't know
that and callers wind up typecasting it back.
This commit is contained in:
33
libbb/dump.c
33
libbb/dump.c
@@ -10,11 +10,10 @@
|
||||
* Original copyright notice is retained at the end of this file.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "libbb.h"
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <ctype.h> /* for isdigit() */
|
||||
#include "libbb.h"
|
||||
#include "dump.h"
|
||||
|
||||
enum _vflag bb_dump_vflag = FIRST;
|
||||
@@ -83,9 +82,9 @@ int bb_dump_size(FS * fs)
|
||||
static void rewrite(FS * fs)
|
||||
{
|
||||
enum { NOTOKAY, USEBCNT, USEPREC } sokay;
|
||||
register PR *pr, **nextpr = NULL;
|
||||
register FU *fu;
|
||||
register char *p1, *p2, *p3;
|
||||
PR *pr, **nextpr = NULL;
|
||||
FU *fu;
|
||||
char *p1, *p2, *p3;
|
||||
char savech, *fmtp;
|
||||
const char *byte_count_str;
|
||||
int nconv, prec = 0;
|
||||
@@ -98,7 +97,7 @@ static void rewrite(FS * fs)
|
||||
for (nconv = 0, fmtp = fu->fmt; *fmtp; nextpr = &pr->nextpr) {
|
||||
/* NOSTRICT */
|
||||
/* DBU:[dvae@cray.com] calloc so that forward ptrs start out NULL*/
|
||||
pr = (PR *) xzalloc(sizeof(PR));
|
||||
pr = xzalloc(sizeof(PR));
|
||||
if (!fu->nextpr)
|
||||
fu->nextpr = pr;
|
||||
/* ignore nextpr -- its unused inside the loop and is
|
||||
@@ -246,8 +245,7 @@ static void rewrite(FS * fs)
|
||||
{
|
||||
savech = *p3;
|
||||
*p3 = '\0';
|
||||
if (!(pr->fmt = realloc(pr->fmt, strlen(pr->fmt)+(p3-p2)+1)))
|
||||
bb_perror_msg_and_die("hexdump");
|
||||
pr->fmt = xrealloc(pr->fmt, strlen(pr->fmt)+(p3-p2)+1);
|
||||
strcat(pr->fmt, p2);
|
||||
*p3 = savech;
|
||||
p2 = p3;
|
||||
@@ -673,17 +671,16 @@ int bb_dump_dump(char **argv)
|
||||
|
||||
void bb_dump_add(const char *fmt)
|
||||
{
|
||||
register const char *p;
|
||||
register char *p1;
|
||||
register char *p2;
|
||||
const char *p;
|
||||
char *p1;
|
||||
char *p2;
|
||||
static FS **nextfs;
|
||||
FS *tfs;
|
||||
FU *tfu, **nextfu;
|
||||
const char *savep;
|
||||
|
||||
/* start new linked list of format units */
|
||||
/* NOSTRICT */
|
||||
tfs = (FS *) xzalloc(sizeof(FS)); /*DBU:[dave@cray.com] start out NULL */
|
||||
tfs = xzalloc(sizeof(FS)); /*DBU:[dave@cray.com] start out NULL */
|
||||
if (!bb_dump_fshead) {
|
||||
bb_dump_fshead = tfs;
|
||||
} else {
|
||||
@@ -695,7 +692,7 @@ void bb_dump_add(const char *fmt)
|
||||
/* take the format string and break it up into format units */
|
||||
for (p = fmt;;) {
|
||||
/* bb_dump_skip leading white space */
|
||||
p = bb_skip_whitespace(p);
|
||||
p = skip_whitespace(p);
|
||||
if (!*p) {
|
||||
break;
|
||||
}
|
||||
@@ -703,7 +700,7 @@ void bb_dump_add(const char *fmt)
|
||||
/* allocate a new format unit and link it in */
|
||||
/* NOSTRICT */
|
||||
/* DBU:[dave@cray.com] calloc so that forward pointers start out NULL */
|
||||
tfu = (FU *) xzalloc(sizeof(FU));
|
||||
tfu = xzalloc(sizeof(FU));
|
||||
*nextfu = tfu;
|
||||
nextfu = &tfu->nextfu;
|
||||
tfu->reps = 1;
|
||||
@@ -718,12 +715,12 @@ void bb_dump_add(const char *fmt)
|
||||
tfu->reps = atoi(savep);
|
||||
tfu->flags = F_SETREP;
|
||||
/* bb_dump_skip trailing white space */
|
||||
p = bb_skip_whitespace(++p);
|
||||
p = skip_whitespace(++p);
|
||||
}
|
||||
|
||||
/* bb_dump_skip slash and trailing white space */
|
||||
if (*p == '/') {
|
||||
p = bb_skip_whitespace(++p);
|
||||
p = skip_whitespace(++p);
|
||||
}
|
||||
|
||||
/* byte count */
|
||||
@@ -734,7 +731,7 @@ void bb_dump_add(const char *fmt)
|
||||
}
|
||||
tfu->bcnt = atoi(savep);
|
||||
/* bb_dump_skip trailing white space */
|
||||
p = bb_skip_whitespace(++p);
|
||||
p = skip_whitespace(++p);
|
||||
}
|
||||
|
||||
/* format */
|
||||
|
||||
@@ -8,13 +8,13 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "libbb.h"
|
||||
#include "inet_common.h"
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "libbb.h"
|
||||
|
||||
#ifdef DEBUG
|
||||
# include <resolv.h>
|
||||
|
||||
@@ -20,9 +20,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "libbb.h"
|
||||
#include <string.h>
|
||||
#include <crypt.h>
|
||||
#include "libbb.h"
|
||||
|
||||
|
||||
char *pw_encrypt(const char *clear, const char *salt)
|
||||
|
||||
@@ -4,30 +4,15 @@
|
||||
*
|
||||
* Copyright (C) 2003 Manuel Novoa III <mjn3@codepoet.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
#include "libbb.h"
|
||||
|
||||
const char *bb_skip_whitespace(const char *s)
|
||||
char *skip_whitespace(const char *s)
|
||||
{
|
||||
while (isspace(*s)) {
|
||||
++s;
|
||||
}
|
||||
while (isspace(*s)) ++s;
|
||||
|
||||
return s;
|
||||
return (char *) s;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user