summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKris De Gussem <kris.degussem@gmail.com>2013-08-04 14:24:43 +0000
committerKris <Kris.De.Gussem@hotmail.com>2013-08-04 14:24:43 +0000
commit82f86789e746672e91bdd287c534546f6af0b456 (patch)
treebb5fe93813cd97fdf0f5f289d684cf4eead41f69 /src
parentcatch exception by reference (diff)
downloadinkscape-82f86789e746672e91bdd287c534546f6af0b456.tar.gz
inkscape-82f86789e746672e91bdd287c534546f6af0b456.zip
cppcheck: c-style casts > c++ style casts
(bzr r12466)
Diffstat (limited to 'src')
-rw-r--r--src/sp-desc.cpp2
-rw-r--r--src/sp-font-face.cpp2
-rw-r--r--src/sp-paint-server.cpp2
-rw-r--r--src/sp-tspan.cpp34
-rw-r--r--src/unicoderange.cpp193
5 files changed, 113 insertions, 120 deletions
diff --git a/src/sp-desc.cpp b/src/sp-desc.cpp
index 9b27c4d17..aec90714d 100644
--- a/src/sp-desc.cpp
+++ b/src/sp-desc.cpp
@@ -22,7 +22,7 @@ G_DEFINE_TYPE(SPDesc, sp_desc, SP_TYPE_OBJECT);
static void sp_desc_class_init(SPDescClass *klass)
{
- SPObjectClass *sp_object_class = (SPObjectClass *)(klass);
+ SPObjectClass *sp_object_class = reinterpret_cast<SPObjectClass *>(klass);
sp_object_class->write = sp_desc_write;
}
diff --git a/src/sp-font-face.cpp b/src/sp-font-face.cpp
index 0a649b17f..6b6d07c6d 100644
--- a/src/sp-font-face.cpp
+++ b/src/sp-font-face.cpp
@@ -272,7 +272,7 @@ G_DEFINE_TYPE(SPFontFace, sp_fontface, SP_TYPE_OBJECT);
static void sp_fontface_class_init(SPFontFaceClass *fc)
{
- SPObjectClass *sp_object_class = (SPObjectClass *) fc;
+ SPObjectClass *sp_object_class = reinterpret_cast<SPObjectClass *>(fc);
sp_object_class->build = sp_fontface_build;
sp_object_class->release = sp_fontface_release;
diff --git a/src/sp-paint-server.cpp b/src/sp-paint-server.cpp
index 298b39117..bae0e2242 100644
--- a/src/sp-paint-server.cpp
+++ b/src/sp-paint-server.cpp
@@ -53,7 +53,7 @@ cairo_pattern_t *sp_paint_server_create_pattern(SPPaintServer *ps,
g_return_val_if_fail(SP_IS_PAINT_SERVER(ps), NULL);
cairo_pattern_t *cp = NULL;
- SPPaintServerClass *psc = (SPPaintServerClass *) G_OBJECT_GET_CLASS(ps);
+ SPPaintServerClass *psc = reinterpret_cast<SPPaintServerClass *>(G_OBJECT_GET_CLASS(ps));
if ( psc->pattern_new ) {
cp = (*psc->pattern_new)(ps, ct, bbox, opacity);
}
diff --git a/src/sp-tspan.cpp b/src/sp-tspan.cpp
index 09429df6f..6f0b6ac39 100644
--- a/src/sp-tspan.cpp
+++ b/src/sp-tspan.cpp
@@ -145,7 +145,7 @@ static void sp_tspan_update(SPObject *object, SPCtx *ctx, guint flags)
for ( SPObject *ochild = object->firstChild() ; ochild ; ochild = ochild->getNext() ) {
if ( flags || ( ochild->uflags & SP_OBJECT_MODIFIED_FLAG )) {
- ochild->updateDisplay(ctx, flags);
+ ochild->updateDisplay(ctx, flags);
}
}
}
@@ -270,8 +270,7 @@ void refresh_textpath_source(SPTextPath* offset);
G_DEFINE_TYPE(SPTextPath, sp_textpath, SP_TYPE_ITEM);
-static void
-sp_textpath_class_init(SPTextPathClass *classname)
+static void sp_textpath_class_init(SPTextPathClass *classname)
{
GObjectClass *gobject_class = G_OBJECT_CLASS(classname);
SPObjectClass *sp_object_class = SP_OBJECT_CLASS(classname);
@@ -299,16 +298,14 @@ sp_textpath_init(SPTextPath *textpath)
textpath->sourcePath->user_unlink = sp_textpath_to_text;
}
-static void
-sp_textpath_finalize(GObject *obj)
+static void sp_textpath_finalize(GObject *obj)
{
- SPTextPath *textpath = (SPTextPath *) obj;
+ SPTextPath *textpath = static_cast<SPTextPath *>(obj);
delete textpath->sourcePath;
}
-static void
-sp_textpath_release(SPObject *object)
+static void sp_textpath_release(SPObject *object)
{
SPTextPath *textpath = SP_TEXTPATH(object);
@@ -321,8 +318,7 @@ sp_textpath_release(SPObject *object)
(SP_OBJECT_CLASS(sp_textpath_parent_class))->release(object);
}
-static void
-sp_textpath_build(SPObject *object, SPDocument *doc, Inkscape::XML::Node *repr)
+static void sp_textpath_build(SPObject *object, SPDocument *doc, Inkscape::XML::Node *repr)
{
object->readAttr( "x" );
object->readAttr( "y" );
@@ -352,8 +348,7 @@ sp_textpath_build(SPObject *object, SPDocument *doc, Inkscape::XML::Node *repr)
}
}
-static void
-sp_textpath_set(SPObject *object, unsigned key, gchar const *value)
+static void sp_textpath_set(SPObject *object, unsigned key, gchar const *value)
{
SPTextPath *textpath = SP_TEXTPATH(object);
@@ -403,7 +398,7 @@ static void sp_textpath_update(SPObject *object, SPCtx *ctx, guint flags)
}
-void refresh_textpath_source(SPTextPath* tp)
+void refresh_textpath_source(SPTextPath* tp)
{
if ( tp == NULL ) return;
tp->sourcePath->refresh_source();
@@ -423,8 +418,7 @@ void refresh_textpath_source(SPTextPath* tp)
}
}
-static void
-sp_textpath_modified(SPObject *object, unsigned flags)
+static void sp_textpath_modified(SPObject *object, unsigned flags)
{
if ((SP_OBJECT_CLASS(sp_textpath_parent_class))->modified) {
(SP_OBJECT_CLASS(sp_textpath_parent_class))->modified(object, flags);
@@ -454,7 +448,7 @@ sp_textpath_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::
textpath->attributes.writeTo(repr);
if (textpath->startOffset._set) {
if (textpath->startOffset.unit == SVGLength::PERCENT) {
- Inkscape::SVGOStringStream os;
+ Inkscape::SVGOStringStream os;
os << (textpath->startOffset.computed * 100.0) << "%";
textpath->getRepr()->setAttribute("startOffset", os.str().c_str());
} else {
@@ -506,19 +500,17 @@ sp_textpath_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::
}
-SPItem *
-sp_textpath_get_path_item(SPTextPath *tp)
+SPItem *sp_textpath_get_path_item(SPTextPath *tp)
{
if (tp && tp->sourcePath) {
SPItem *refobj = tp->sourcePath->getObject();
if (SP_IS_ITEM(refobj))
- return (SPItem *) refobj;
+ return refobj;
}
return NULL;
}
-void
-sp_textpath_to_text(SPObject *tp)
+void sp_textpath_to_text(SPObject *tp)
{
SPObject *text = tp->parent;
diff --git a/src/unicoderange.cpp b/src/unicoderange.cpp
index 67239d0d2..36435024d 100644
--- a/src/unicoderange.cpp
+++ b/src/unicoderange.cpp
@@ -4,124 +4,125 @@
#include <string.h>
static unsigned int hex2int(char* s){
- int res=0;
- int i=0, mul=1;
- while(s[i+1]!='\0') i++;
+ int res=0;
+ int i=0, mul=1;
+ while(s[i+1]!='\0') i++;
- while(i>=0){
- if (s[i] >= 'A' && s[i] <= 'F') res += mul * (s[i]-'A'+10);
- if (s[i] >= 'a' && s[i] <= 'f') res += mul * (s[i]-'a'+10);
- if (s[i] >= '0' && s[i] <= '9') res += mul * (s[i]-'0');
- i--;
- mul*=16;
- }
- return res;
+ while(i>=0){
+ if (s[i] >= 'A' && s[i] <= 'F') res += mul * (s[i]-'A'+10);
+ if (s[i] >= 'a' && s[i] <= 'f') res += mul * (s[i]-'a'+10);
+ if (s[i] >= '0' && s[i] <= '9') res += mul * (s[i]-'0');
+ i--;
+ mul*=16;
+ }
+ return res;
}
UnicodeRange::UnicodeRange(const gchar* value){
- if (!value) return;
- gchar* val = (gchar*) value;
- while(val[0] != '\0'){
- if (val[0]=='U' && val[1]=='+'){
- val += add_range(val+2);
- } else {
- this->unichars.push_back(g_utf8_get_char(&val[0]));
- val++;
- }
- //skip spaces or commas
- while(val[0]==' ' || val[0]==',') val++;
- }
+ if (!value) return;
+ gchar* val = (gchar*) value;
+ while(val[0] != '\0'){
+ if (val[0]=='U' && val[1]=='+'){
+ val += add_range(val+2);
+ } else {
+ this->unichars.push_back(g_utf8_get_char(&val[0]));
+ val++;
+ }
+ //skip spaces or commas
+ while(val[0]==' ' || val[0]==',') val++;
+ }
}
-int
-UnicodeRange::add_range(gchar* val){
- Urange r;
- int i=0, count=0;
- while(val[i]!='\0' && val[i]!='-' && val[i]!=' ' && val[i]!=','){
+int UnicodeRange::add_range(gchar* val){
+ Urange r;
+ int i=0, count=0;
+ while(val[i]!='\0' && val[i]!='-' && val[i]!=' ' && val[i]!=','){
i++;
- }
+ }
r.start = (gchar*) malloc((i+1)*sizeof(gchar*));
- strncpy(r.start, val, i);
- r.start[i] = '\0';
- val+=i;
- count+=i;
- i=0;
- if (val[0]=='-'){
- val++;
- while(val[i]!='\0' && val[i]!='-' && val[i]!=' ' && val[i]!=',') i++;
- r.end = (gchar*) malloc((i+1)*sizeof(gchar*));
- strncpy(r.end, val, i);
- r.end[i] = '\0';
- // val+=i;
- count+=i;
- } else {
- r.end=NULL;
- }
- this->range.push_back(r);
- return count+1;
+ strncpy(r.start, val, i);
+ r.start[i] = '\0';
+ val+=i;
+ count+=i;
+ i=0;
+ if (val[0]=='-'){
+ val++;
+ while(val[i]!='\0' && val[i]!='-' && val[i]!=' ' && val[i]!=',') i++;
+ r.end = (gchar*) malloc((i+1)*sizeof(gchar*));
+ strncpy(r.end, val, i);
+ r.end[i] = '\0';
+ // val+=i;
+ count+=i;
+ } else {
+ r.end=NULL;
+ }
+ this->range.push_back(r);
+ return count+1;
}
bool UnicodeRange::contains(gchar unicode){
- for(unsigned int i=0;i<this->unichars.size();i++){
- if ((gunichar) unicode == this->unichars[i]) return true;
- }
+ for(unsigned int i=0;i<this->unichars.size();i++){
+ if (static_cast<gunichar>(unicode) == this->unichars[i]){
+ return true;
+ }
+ }
- unsigned int unival;
- unival = g_utf8_get_char (&unicode);
- char uni[9] = "00000000";
- uni[8]= '\0';
- unsigned char val;
- for (unsigned int i=7; unival>0; i--){
- val = unival & 0xf;
- unival = unival >> 4;
- if (val < 10) uni[i] = '0' + val;
- else uni[i] = 'A'+ val - 10;
- }
+ unsigned int unival;
+ unival = g_utf8_get_char (&unicode);
+ char uni[9] = "00000000";
+ uni[8]= '\0';
+ unsigned char val;
+ for (unsigned int i=7; unival>0; i--){
+ val = unival & 0xf;
+ unival = unival >> 4;
+ if (val < 10) uni[i] = '0' + val;
+ else uni[i] = 'A'+ val - 10;
+ }
- bool found;
- for(unsigned int i=0;i<this->range.size();i++){
- Urange r = this->range[i];
- if (r.end){
- if (unival >= hex2int(r.start) && unival <= hex2int(r.end)) return true;
- } else {
- found = true;
+ bool found;
+ for(unsigned int i=0;i<this->range.size();i++){
+ Urange r = this->range[i];
+ if (r.end){
+ if (unival >= hex2int(r.start) && unival <= hex2int(r.end)) return true;
+ } else {
+ found = true;
- int p=0;
- while (r.start[p]!='\0') p++;
- p--;
+ int p=0;
+ while (r.start[p]!='\0') p++;
+ p--;
- for (int pos=8;p>=0;pos--,p--){
- if (uni[pos]!='?' && uni[pos]!=r.start[p]) found = false;
- }
- if (found) return true;
- }
- }
- return false;
+ for (int pos=8;p>=0;pos--,p--){
+ if (uni[pos]!='?' && uni[pos]!=r.start[p]) found = false;
+ }
+ if (found) return true;
+ }
+ }
+ return false;
}
Glib::ustring UnicodeRange::attribute_string(){
- Glib::ustring result;
- unsigned int i;
- for(i=0; i<this->unichars.size(); i++){
- result += this->unichars[i];
- if (i!=this->unichars.size()-1) result += ",";
- }
+ Glib::ustring result;
+ unsigned int i;
+ for(i=0; i<this->unichars.size(); i++){
+ result += this->unichars[i];
+ if (i!=this->unichars.size()-1) result += ",";
+ }
- for(i=0; i<this->range.size(); i++){
- result += "U+" + Glib::ustring(this->range[i].start);
- if (this->range[i].end) result += "-" + Glib::ustring(this->range[i].end);
- if (i!=this->range.size()-1) result += ", ";
- }
+ for(i=0; i<this->range.size(); i++){
+ result += "U+" + Glib::ustring(this->range[i].start);
+ if (this->range[i].end) result += "-" + Glib::ustring(this->range[i].end);
+ if (i!=this->range.size()-1) result += ", ";
+ }
- return result;
+ return result;
}
gunichar UnicodeRange::sample_glyph(){
- //This could be better
- if (!unichars.empty())
- return unichars[0];
- if (!range.empty())
- return hex2int(range[0].start);
- return (gunichar) ' ';
+ //This could be better
+ if (!unichars.empty())
+ return unichars[0];
+ if (!range.empty())
+ return hex2int(range[0].start);
+ return (gunichar) ' ';
}