STYLE: Make sure to use the proper cast.

This commit is contained in:
Mathieu Malaterre 2006-03-10 12:01:29 -05:00
parent 1ef5bdf669
commit 5fe4a9dcef
4 changed files with 32 additions and 32 deletions

View File

@ -396,7 +396,7 @@ bool Glob::FindFiles(const kwsys_stl::string& inexpr)
} }
else else
{ {
cexpr.append(1, (char)ch); cexpr.append(1, static_cast<char>(ch));
} }
} }
if ( cexpr.size() > 0 ) if ( cexpr.size() > 0 )

View File

@ -798,7 +798,7 @@ kwsys_stl::string RegistryHelper::DecodeValue(const char* str)
case '%': case '%':
if ( *(str+1) && *(str+2) && sscanf(str+1, "%x", &val) == 1 ) if ( *(str+1) && *(str+2) && sscanf(str+1, "%x", &val) == 1 )
{ {
ostr << (char)val; ostr << static_cast<char>(val);
str += 2; str += 2;
} }
else else

View File

@ -14,7 +14,7 @@
// //
// Copyright (C) 1991 Texas Instruments Incorporated. // Copyright (C) 1991 Texas Instruments Incorporated.
// //
// Permission is granted to any individual or institution to use, copy, modify, // Permission is granted to any individual or institution to use, copy, modify
// and distribute this software, provided that this complete copyright and // and distribute this software, provided that this complete copyright and
// permission notice is maintained, intact, in all copies and supporting // permission notice is maintained, intact, in all copies and supporting
// documentation. // documentation.
@ -52,7 +52,7 @@ RegularExpression::RegularExpression (const RegularExpression& rxp) {
this->program = 0; this->program = 0;
return; return;
} }
int ind; int ind;
this->progsize = rxp.progsize; // Copy regular expression size this->progsize = rxp.progsize; // Copy regular expression size
this->program = new char[this->progsize]; // Allocate storage this->program = new char[this->progsize]; // Allocate storage
for(ind=this->progsize; ind-- != 0;) // Copy regular expresion for(ind=this->progsize; ind-- != 0;) // Copy regular expresion
@ -82,10 +82,10 @@ bool RegularExpression::operator== (const RegularExpression& rxp) const {
if (ind != rxp.progsize) // If different size regexp if (ind != rxp.progsize) // If different size regexp
return false; // Return failure return false; // Return failure
while(ind-- != 0) // Else while still characters while(ind-- != 0) // Else while still characters
if(this->program[ind] != rxp.program[ind]) // If regexp are different if(this->program[ind] != rxp.program[ind]) // If regexp are different
return false; // Return failure return false; // Return failure
} }
return true; // Else same, return success return true; // Else same, return success
} }
@ -97,18 +97,18 @@ bool RegularExpression::deep_equal (const RegularExpression& rxp) const {
if (ind != rxp.progsize) // If different size regexp if (ind != rxp.progsize) // If different size regexp
return false; // Return failure return false; // Return failure
while(ind-- != 0) // Else while still characters while(ind-- != 0) // Else while still characters
if(this->program[ind] != rxp.program[ind]) // If regexp are different if(this->program[ind] != rxp.program[ind]) // If regexp are different
return false; // Return failure return false; // Return failure
return (this->startp[0] == rxp.startp[0] && // Else if same start/end ptrs, return (this->startp[0] == rxp.startp[0] && // Else if same start/end ptrs,
this->endp[0] == rxp.endp[0]); // Return true this->endp[0] == rxp.endp[0]); // Return true
} }
// The remaining code in this file is derived from the regular expression code // The remaining code in this file is derived from the regular expression code
// whose copyright statement appears below. It has been changed to work // whose copyright statement appears below. It has been changed to work
// with the class concepts of C++ and COOL. // with the class concepts of C++ and COOL.
/* /*
* compile and find * compile and find
* *
* Copyright (c) 1986 by University of Toronto. * Copyright (c) 1986 by University of Toronto.
* Written by Henry Spencer. Not derived from licensed software. * Written by Henry Spencer. Not derived from licensed software.
@ -333,23 +333,23 @@ bool RegularExpression::compile (const char* exp) {
} }
this->startp[0] = this->endp[0] = this->searchstring = 0; this->startp[0] = this->endp[0] = this->searchstring = 0;
// Small enough for pointer-storage convention? // Small enough for pointer-storage convention?
if (regsize >= 32767L) { // Probably could be 65535L. if (regsize >= 32767L) { // Probably could be 65535L.
//RAISE Error, SYM(RegularExpression), SYM(Expr_Too_Big), //RAISE Error, SYM(RegularExpression), SYM(Expr_Too_Big),
printf ("RegularExpression::compile(): Expression too big.\n"); printf ("RegularExpression::compile(): Expression too big.\n");
return false; return false;
} }
// Allocate space. // Allocate space.
//#ifndef WIN32 //#ifndef WIN32
if (this->program != 0) delete [] this->program; if (this->program != 0) delete [] this->program;
//#endif //#endif
this->program = new char[regsize]; this->program = new char[regsize];
this->progsize = (int) regsize; this->progsize = static_cast<int>(regsize);
if (this->program == 0) { if (this->program == 0) {
//RAISE Error, SYM(RegularExpression), SYM(Out_Of_Memory), //RAISE Error, SYM(RegularExpression), SYM(Out_Of_Memory),
printf ("RegularExpression::compile(): Out of memory.\n"); printf ("RegularExpression::compile(): Out of memory.\n");
return false; return false;
} }
@ -381,7 +381,7 @@ bool RegularExpression::compile (const char* exp) {
// ties in favor of later strings, since the regstart check works // ties in favor of later strings, since the regstart check works
// with the beginning of the r.e. and avoiding duplication // with the beginning of the r.e. and avoiding duplication
// strengthens checking. Not a strong reason, but sufficient in the // strengthens checking. Not a strong reason, but sufficient in the
// absence of others. // absence of others.
// //
if (flags & SPSTART) { if (flags & SPSTART) {
longest = 0; longest = 0;
@ -866,14 +866,14 @@ bool RegularExpression::find (const char* string) {
{ {
return false; return false;
} }
// Check validity of program. // Check validity of program.
if (UCHARAT(this->program) != MAGIC) { if (UCHARAT(this->program) != MAGIC) {
//RAISE Error, SYM(RegularExpression), SYM(Internal_Error), //RAISE Error, SYM(RegularExpression), SYM(Internal_Error),
printf ("RegularExpression::find(): Compiled regular expression corrupted.\n"); printf ("RegularExpression::find(): Compiled regular expression corrupted.\n");
return 0; return 0;
} }
// If there is a "must appear" string, look for it. // If there is a "must appear" string, look for it.
if (this->regmust != 0) { if (this->regmust != 0) {
s = string; s = string;
@ -885,14 +885,14 @@ bool RegularExpression::find (const char* string) {
if (s == 0) // Not present. if (s == 0) // Not present.
return (0); return (0);
} }
// Mark beginning of line for ^ . // Mark beginning of line for ^ .
regbol = string; regbol = string;
// Simplest case: anchored match need be tried only once. // Simplest case: anchored match need be tried only once.
if (this->reganch) if (this->reganch)
return (regtry(string, this->startp, this->endp, this->program) != 0); return (regtry(string, this->startp, this->endp, this->program) != 0);
// Messy cases: unanchored match. // Messy cases: unanchored match.
s = string; s = string;
if (this->regstart != '\0') if (this->regstart != '\0')
@ -901,7 +901,7 @@ bool RegularExpression::find (const char* string) {
if (regtry(s, this->startp, this->endp, this->program)) if (regtry(s, this->startp, this->endp, this->program))
return (1); return (1);
s++; s++;
} }
else else
// We don't -- general case. // We don't -- general case.
@ -909,7 +909,7 @@ bool RegularExpression::find (const char* string) {
if (regtry(s, this->startp, this->endp, this->program)) if (regtry(s, this->startp, this->endp, this->program))
return (1); return (1);
} while (*s++ != '\0'); } while (*s++ != '\0');
// Failure. // Failure.
return (0); return (0);
} }
@ -1027,7 +1027,7 @@ static int regmatch (const char* prog) {
// //
// Don't set startp if some later invocation of the // Don't set startp if some later invocation of the
// same parentheses already has. // same parentheses already has.
// //
if (regstartp[no] == 0) if (regstartp[no] == 0)
regstartp[no] = save; regstartp[no] = save;
@ -1056,7 +1056,7 @@ static int regmatch (const char* prog) {
// //
// Don't set endp if some later invocation of the // Don't set endp if some later invocation of the
// same parentheses already has. // same parentheses already has.
// //
if (regendp[no] == 0) if (regendp[no] == 0)
regendp[no] = save; regendp[no] = save;
@ -1067,7 +1067,7 @@ static int regmatch (const char* prog) {
} }
// break; // break;
case BRANCH:{ case BRANCH:{
register const char* save; register const char* save;
if (OP(next) != BRANCH) // No choice. if (OP(next) != BRANCH) // No choice.
@ -1094,7 +1094,7 @@ static int regmatch (const char* prog) {
// //
// Lookahead to avoid useless match attempts when we know // Lookahead to avoid useless match attempts when we know
// what character comes next. // what character comes next.
// //
nextch = '\0'; nextch = '\0';
if (OP(next) == EXACTLY) if (OP(next) == EXACTLY)
@ -1125,10 +1125,10 @@ static int regmatch (const char* prog) {
scan = next; scan = next;
} }
// //
// We get here only if there's trouble -- normally "case END" is the // We get here only if there's trouble -- normally "case END" is the
// terminating point. // terminating point.
// //
//RAISE Error, SYM(RegularExpression), SYM(Internal_Error), //RAISE Error, SYM(RegularExpression), SYM(Internal_Error),
printf ("RegularExpression::find(): Internal error -- corrupted pointers.\n"); printf ("RegularExpression::find(): Internal error -- corrupted pointers.\n");
return (0); return (0);

View File

@ -22,7 +22,7 @@
# include "kwsys_ios_iostream.h.in" # include "kwsys_ios_iostream.h.in"
#endif #endif
void* random_ptr = (void*)0x123; void* random_ptr = reinterpret_cast<void*>(0x123);
int argument(const char* arg, const char* value, void* call_data) int argument(const char* arg, const char* value, void* call_data)
{ {