Add formatting/static analysis (#486)
* Reform source with clang-format. Rules applied with: $ find . -iname *.h -o -iname *.cc | xargs clang-format \ -style=file -i -fallback-style=google * Add clang-format and analyze to build. Based on the excellent work at: https://github.com/ttroy50/cmake-examples * Clean up CMake stuff on macOS. * Remove vim/emacs modelines. * Update copyright dates. * Build fixes. * Build fixes. * Build fixes. * Build fixes. * Build fixes. * Build fixes.
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
# vim: ts=4 sw=4 noet ai cindent syntax=cmake
|
||||
#
|
||||
# Conky, a system monitor, based on torsmo
|
||||
#
|
||||
# Please see COPYING for details
|
||||
#
|
||||
# Copyright (c) 2005-2012 Brenden Matthews, et. al. (see AUTHORS)
|
||||
# Copyright (c) 2005-2018 Brenden Matthews, et. al. (see AUTHORS)
|
||||
# All rights reserved.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
|
@@ -1,10 +1,10 @@
|
||||
/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
|
||||
/*
|
||||
*
|
||||
* Conky, a system monitor, based on torsmo
|
||||
*
|
||||
* Please see COPYING for details
|
||||
*
|
||||
* Copyright (c) 2005-2012 Brenden Matthews, Philip Kovacs, et. al.
|
||||
* Copyright (c) 2005-2018 Brenden Matthews, Philip Kovacs, et. al.
|
||||
* (see AUTHORS)
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -28,15 +28,15 @@
|
||||
#include <cairo.h>
|
||||
|
||||
cairo_text_extents_t *create_cairo_text_extents_t(void) {
|
||||
return calloc(1, sizeof(cairo_text_extents_t));
|
||||
return calloc(1, sizeof(cairo_text_extents_t));
|
||||
}
|
||||
|
||||
cairo_font_extents_t *create_cairo_font_extents_t(void) {
|
||||
return calloc(1, sizeof(cairo_font_extents_t));
|
||||
return calloc(1, sizeof(cairo_font_extents_t));
|
||||
}
|
||||
|
||||
cairo_matrix_t *create_cairo_matrix_t(void) {
|
||||
return calloc(1, sizeof(cairo_matrix_t));
|
||||
return calloc(1, sizeof(cairo_matrix_t));
|
||||
}
|
||||
|
||||
#endif /* _LIBCAIRO_HELPER_H_ */
|
||||
|
@@ -1,10 +1,10 @@
|
||||
/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
|
||||
/*
|
||||
*
|
||||
* Conky, a system monitor, based on torsmo
|
||||
*
|
||||
* Please see COPYING for details
|
||||
*
|
||||
* Copyright (c) 2005-2012 Brenden Matthews, Philip Kovacs, et. al.
|
||||
* Copyright (c) 2005-2018 Brenden Matthews, Philip Kovacs, et. al.
|
||||
* (see AUTHORS)
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -25,22 +25,22 @@
|
||||
#ifndef _LIBCAIRO_IMAGE_HELPER_H_
|
||||
#define _LIBCAIRO_IMAGE_HELPER_H_
|
||||
|
||||
#include <cairo.h>
|
||||
#include <Imlib2.h>
|
||||
#include <cairo.h>
|
||||
|
||||
void
|
||||
cairo_draw_image(const char * file, cairo_surface_t * cs, int x, int y,
|
||||
double scale_x, double scale_y,
|
||||
double * return_scale_w, double * return_scale_h)
|
||||
{
|
||||
Imlib_Image * image = imlib_load_image(file);
|
||||
if (! image) { return; }
|
||||
void cairo_draw_image(const char *file, cairo_surface_t *cs, int x, int y,
|
||||
double scale_x, double scale_y, double *return_scale_w,
|
||||
double *return_scale_h) {
|
||||
Imlib_Image *image = imlib_load_image(file);
|
||||
if (!image) {
|
||||
return;
|
||||
}
|
||||
|
||||
imlib_context_set_image(image);
|
||||
int w = imlib_image_get_width(), h = imlib_image_get_height();
|
||||
|
||||
double scaled_w = *return_scale_w = scale_x * (double)w
|
||||
, scaled_h = *return_scale_h = scale_y * (double)h;
|
||||
double scaled_w = *return_scale_w = scale_x * (double)w,
|
||||
scaled_h = *return_scale_h = scale_y * (double)h;
|
||||
|
||||
/* create temporary image */
|
||||
Imlib_Image premul = imlib_create_image(scaled_w, scaled_h);
|
||||
@@ -59,11 +59,11 @@ cairo_draw_image(const char * file, cairo_surface_t * cs, int x, int y,
|
||||
imlib_image_copy_alpha_to_image(image, 0, 0);
|
||||
|
||||
/* now pass the result to cairo */
|
||||
cairo_surface_t * result = cairo_image_surface_create_for_data(
|
||||
(void *) imlib_image_get_data_for_reading_only(),
|
||||
CAIRO_FORMAT_ARGB32, scaled_w, scaled_h, sizeof(DATA32) * scaled_w);
|
||||
cairo_surface_t *result = cairo_image_surface_create_for_data(
|
||||
(void *)imlib_image_get_data_for_reading_only(), CAIRO_FORMAT_ARGB32,
|
||||
scaled_w, scaled_h, sizeof(DATA32) * scaled_w);
|
||||
|
||||
cairo_t * cr = cairo_create(cs);
|
||||
cairo_t *cr = cairo_create(cs);
|
||||
cairo_set_source_surface(cr, result, x, y);
|
||||
cairo_paint(cr);
|
||||
|
||||
|
@@ -1,10 +1,10 @@
|
||||
/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
|
||||
/*
|
||||
*
|
||||
* Conky, a system monitor, based on torsmo
|
||||
*
|
||||
* Please see COPYING for details
|
||||
*
|
||||
* Copyright (c) 2005-2012 Brenden Matthews, Philip Kovacs, et. al.
|
||||
* Copyright (c) 2005-2018 Brenden Matthews, Philip Kovacs, et. al.
|
||||
* (see AUTHORS)
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -26,19 +26,15 @@
|
||||
#define _LIBRSVG_HELPER_H_
|
||||
|
||||
#include <glib.h>
|
||||
#include <stdlib.h>
|
||||
#include <librsvg/rsvg.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
RsvgDimensionData *
|
||||
rsvgDimensionDataCreate(void)
|
||||
{
|
||||
RsvgDimensionData *rsvgDimensionDataCreate(void) {
|
||||
return (RsvgDimensionData *)calloc(1, sizeof(RsvgDimensionData));
|
||||
}
|
||||
|
||||
void
|
||||
rsvgDimensionDataGet(RsvgDimensionData * dd,
|
||||
int * width, int * height, double * em, double * ex)
|
||||
{
|
||||
void rsvgDimensionDataGet(RsvgDimensionData *dd, int *width, int *height,
|
||||
double *em, double *ex) {
|
||||
if (dd) {
|
||||
*width = dd->width;
|
||||
*height = dd->height;
|
||||
@@ -47,51 +43,40 @@ rsvgDimensionDataGet(RsvgDimensionData * dd,
|
||||
}
|
||||
}
|
||||
|
||||
RsvgPositionData *
|
||||
rsvgPositionDataCreate(void)
|
||||
{
|
||||
RsvgPositionData *rsvgPositionDataCreate(void) {
|
||||
return (RsvgPositionData *)calloc(1, sizeof(RsvgPositionData));
|
||||
}
|
||||
|
||||
void
|
||||
rsvgPositionDataGet(RsvgPositionData * pd, int * x, int * y)
|
||||
{
|
||||
void rsvgPositionDataGet(RsvgPositionData *pd, int *x, int *y) {
|
||||
if (pd) {
|
||||
*x = pd->x;
|
||||
*y = pd->y;
|
||||
}
|
||||
}
|
||||
|
||||
RsvgHandle *
|
||||
rsvg_create_handle_from_file(const char * filename)
|
||||
{
|
||||
GError * error = NULL;
|
||||
RsvgHandle * handle = rsvg_handle_new_from_file(filename, &error);
|
||||
RsvgHandle *rsvg_create_handle_from_file(const char *filename) {
|
||||
GError *error = NULL;
|
||||
RsvgHandle *handle = rsvg_handle_new_from_file(filename, &error);
|
||||
|
||||
if (error) {
|
||||
g_object_unref(error);
|
||||
if (handle)
|
||||
g_object_unref(handle);
|
||||
if (handle) g_object_unref(handle);
|
||||
handle = NULL;
|
||||
}
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
int
|
||||
rsvg_destroy_handle(RsvgHandle * handle)
|
||||
{
|
||||
int rsvg_destroy_handle(RsvgHandle *handle) {
|
||||
int status = 0;
|
||||
|
||||
if (handle) {
|
||||
GError * error = NULL;
|
||||
GError *error = NULL;
|
||||
status = rsvg_handle_close(handle, &error);
|
||||
|
||||
if (status)
|
||||
g_object_unref(handle);
|
||||
if (status) g_object_unref(handle);
|
||||
|
||||
if (error)
|
||||
g_object_unref(error);
|
||||
if (error) g_object_unref(error);
|
||||
}
|
||||
|
||||
return status;
|
||||
|
Reference in New Issue
Block a user