Compare commits
3 Commits
f139efba6d
...
9dcef6a14f
Author | SHA1 | Date | |
---|---|---|---|
9dcef6a14f | |||
ee7be81434 | |||
0c5c680f62 |
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -1,3 +0,0 @@
|
|||||||
[submodule "vera++"]
|
|
||||||
path = vera++
|
|
||||||
url = https://bitbucket.org/verateam/vera.git
|
|
@ -3,7 +3,7 @@ cmake_minimum_required (VERSION 3.10)
|
|||||||
project (logdiag VERSION 0.2.1 LANGUAGES C)
|
project (logdiag VERSION 0.2.1 LANGUAGES C)
|
||||||
|
|
||||||
# Options
|
# Options
|
||||||
option (OPTION_USE_VERA "Use vera++ for source code style checks" OFF)
|
option (OPTION_CLANG_TIDY "Enable use of clang-tidy" OFF)
|
||||||
option (OPTION_NOINSTALL "For developers only--work without installing" OFF)
|
option (OPTION_NOINSTALL "For developers only--work without installing" OFF)
|
||||||
option (OPTION_GTKDOC "For developers only--enable use of gtk-doc" OFF)
|
option (OPTION_GTKDOC "For developers only--enable use of gtk-doc" OFF)
|
||||||
option (BUILD_TESTING "Build tests" OFF)
|
option (BUILD_TESTING "Build tests" OFF)
|
||||||
@ -266,42 +266,38 @@ find_package (CppCheck)
|
|||||||
GENERATE_CPPCHECK (SOURCES liblogdiag src tests ENABLE_IDS all
|
GENERATE_CPPCHECK (SOURCES liblogdiag src tests ENABLE_IDS all
|
||||||
TARGET_NAME ${PROJECT_NAME}_cppcheck INCLUDES ${PROJECT_BINARY_DIR})
|
TARGET_NAME ${PROJECT_NAME}_cppcheck INCLUDES ${PROJECT_BINARY_DIR})
|
||||||
|
|
||||||
if (OPTION_USE_VERA)
|
# Various clang-based diagnostics, loads of fake positives and spam
|
||||||
# Force this off, we don't need it
|
if (OPTION_CLANG_TIDY)
|
||||||
option (VERA_LUA "" OFF)
|
set (clang_tidy_checks
|
||||||
|
clang-analyzer-* bugprone-* misc-* readability-* performance-*
|
||||||
|
-bugprone-reserved-identifier # GObject
|
||||||
|
-performance-no-int-to-ptr # GObject
|
||||||
|
-bugprone-narrowing-conversions
|
||||||
|
-bugprone-macro-parentheses # too coarse-grained
|
||||||
|
-readability-braces-around-statements # fine by me
|
||||||
|
-readability-isolate-declaration # fine by me
|
||||||
|
-readability-magic-numbers # too coarse-grained
|
||||||
|
-misc-unused-parameters) # fine by me
|
||||||
|
|
||||||
# Make it build within the same build tree
|
string (REPLACE ";" "," clang_tidy_checks "${clang_tidy_checks}")
|
||||||
get_directory_property (backup_includes INCLUDE_DIRECTORIES)
|
set (clang_tidy_config "{
|
||||||
set_directory_properties (PROPERTIES INCLUDE_DIRECTORIES "")
|
Checks: '${clang_tidy_checks}',
|
||||||
set (backup_source_dir "${CMAKE_SOURCE_DIR}")
|
CheckOptions: [{
|
||||||
set (CMAKE_SOURCE_DIR "${CMAKE_SOURCE_DIR}/vera++")
|
key: readability-function-cognitive-complexity.Threshold,
|
||||||
|
value: '30'
|
||||||
|
}]}")
|
||||||
|
|
||||||
add_subdirectory ("vera++")
|
string (REPLACE "\n" " " clang_tidy_config "${clang_tidy_config}")
|
||||||
|
|
||||||
set_directory_properties (PROPERTIES INCLUDE_DIRECTORIES "${backup_includes}")
|
set (CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
set (CMAKE_SOURCE_DIR "${backup_source_dir}")
|
set (clang_tidy_sources ${liblogdiag_SOURCES} ${logdiag_SOURCES})
|
||||||
|
add_custom_target (${PROJECT_NAME}_clang_tidy
|
||||||
# Check the sources
|
COMMAND clang-tidy --quiet -p ${PROJECT_BINARY_DIR}
|
||||||
# XXX: maybe do it per source file and not all at once
|
"--config=${clang_tidy_config}" ${clang_tidy_sources}
|
||||||
set (vera_srcs ${liblogdiag_SOURCES} ${logdiag_SOURCES} ${logdiag_HEADERS})
|
| sh -c "cat 1>&2"
|
||||||
set (vera_output ${PROJECT_BINARY_DIR}/vera.log)
|
DEPENDS ${clang_tidy_sources} VERBATIM
|
||||||
add_custom_command (OUTPUT ${vera_output}
|
USES_TERMINAL WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
|
||||||
COMMAND vera
|
endif ()
|
||||||
-R F001 -R L001 -R T001 -R T004 -R T005 -R T006
|
|
||||||
-R T007 -R T009 -R T010 -R T015 -R T017 -R T018
|
|
||||||
-R L004 -P max-line-length=80
|
|
||||||
-R L005 -P max-consecutive-empty-lines=2
|
|
||||||
--root ${CMAKE_SOURCE_DIR}/vera++
|
|
||||||
--std-report=-
|
|
||||||
--std-report=${vera_output}
|
|
||||||
--warning -s
|
|
||||||
${vera_srcs}
|
|
||||||
DEPENDS ${vera_srcs}
|
|
||||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
||||||
COMMENT "Checking style for logdiag")
|
|
||||||
|
|
||||||
add_custom_target (logdiag_vera ALL DEPENDS ${vera_output})
|
|
||||||
endif (OPTION_USE_VERA)
|
|
||||||
|
|
||||||
# GSettings
|
# GSettings
|
||||||
find_program (GLIB_COMPILE_SCHEMAS_EXECUTABLE glib-compile-schemas)
|
find_program (GLIB_COMPILE_SCHEMAS_EXECUTABLE glib-compile-schemas)
|
||||||
|
@ -1315,7 +1315,7 @@ point_to_line_segment_distance
|
|||||||
/* The projection is beyond the line segment. */
|
/* The projection is beyond the line segment. */
|
||||||
if (u < 0.)
|
if (u < 0.)
|
||||||
return ld_point_distance (point, p1->x, p1->y);
|
return ld_point_distance (point, p1->x, p1->y);
|
||||||
else if (u > 1.)
|
if (u > 1.)
|
||||||
return ld_point_distance (point, p2->x, p2->y);
|
return ld_point_distance (point, p2->x, p2->y);
|
||||||
|
|
||||||
/* The projection is on the line segment. */
|
/* The projection is on the line segment. */
|
||||||
|
@ -49,6 +49,8 @@ static gboolean foreach_dir (const gchar *path,
|
|||||||
gboolean (*callback) (const gchar *, const gchar *, gpointer),
|
gboolean (*callback) (const gchar *, const gchar *, gpointer),
|
||||||
gpointer userdata, GError **error);
|
gpointer userdata, GError **error);
|
||||||
|
|
||||||
|
static LdSymbol *traverse_path (LdCategory *category, gchar **path);
|
||||||
|
|
||||||
|
|
||||||
G_DEFINE_TYPE (LdLibrary, ld_library, G_TYPE_OBJECT)
|
G_DEFINE_TYPE (LdLibrary, ld_library, G_TYPE_OBJECT)
|
||||||
|
|
||||||
@ -356,62 +358,51 @@ ld_library_load (LdLibrary *self, const gchar *directory)
|
|||||||
LdSymbol *
|
LdSymbol *
|
||||||
ld_library_find_symbol (LdLibrary *self, const gchar *identifier)
|
ld_library_find_symbol (LdLibrary *self, const gchar *identifier)
|
||||||
{
|
{
|
||||||
gchar **id_el_start, **id_el;
|
gchar **path;
|
||||||
const GSList *list, *list_el;
|
LdSymbol *symbol = NULL;
|
||||||
LdCategory *cat;
|
|
||||||
|
|
||||||
g_return_val_if_fail (LD_IS_LIBRARY (self), NULL);
|
g_return_val_if_fail (LD_IS_LIBRARY (self), NULL);
|
||||||
g_return_val_if_fail (identifier != NULL, NULL);
|
g_return_val_if_fail (identifier != NULL, NULL);
|
||||||
|
|
||||||
id_el_start = g_strsplit (identifier, LD_LIBRARY_IDENTIFIER_SEPARATOR, 0);
|
path = g_strsplit (identifier, LD_LIBRARY_IDENTIFIER_SEPARATOR, 0);
|
||||||
if (!id_el_start)
|
if (path)
|
||||||
return NULL;
|
|
||||||
|
|
||||||
/* We need at least one category name plus the symbol name. */
|
|
||||||
id_el = id_el_start;
|
|
||||||
if (!id_el[0] || !id_el[1])
|
|
||||||
goto ld_library_find_symbol_error;
|
|
||||||
|
|
||||||
/* Find the category where the symbol is in. */
|
|
||||||
cat = self->priv->root;
|
|
||||||
while (1)
|
|
||||||
{
|
{
|
||||||
gboolean found = FALSE;
|
symbol = traverse_path (self->priv->root, path);
|
||||||
|
g_strfreev (path);
|
||||||
list = ld_category_get_children (cat);
|
|
||||||
for (list_el = list; list_el; list_el = g_slist_next (list_el))
|
|
||||||
{
|
|
||||||
cat = LD_CATEGORY (list_el->data);
|
|
||||||
if (!strcmp (*id_el, ld_category_get_name (cat)))
|
|
||||||
{
|
|
||||||
found = TRUE;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!found)
|
|
||||||
goto ld_library_find_symbol_error;
|
|
||||||
|
|
||||||
if (!(id_el++)[2])
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* And then the actual symbol. */
|
|
||||||
list = ld_category_get_symbols (cat);
|
|
||||||
for (list_el = list; list_el; list_el = g_slist_next (list_el))
|
|
||||||
{
|
|
||||||
LdSymbol *symbol;
|
|
||||||
|
|
||||||
symbol = LD_SYMBOL (list_el->data);
|
|
||||||
if (!strcmp (*id_el, ld_symbol_get_name (symbol)))
|
|
||||||
{
|
|
||||||
g_strfreev (id_el_start);
|
|
||||||
return symbol;
|
return symbol;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static LdSymbol *
|
||||||
|
traverse_path (LdCategory *category, gchar **path)
|
||||||
|
{
|
||||||
|
const GSList *list, *iter;
|
||||||
|
LdSymbol *symbol;
|
||||||
|
|
||||||
|
g_return_val_if_fail (*path != NULL, NULL);
|
||||||
|
|
||||||
|
/* Walk the category tree to where the symbol is supposed to be. */
|
||||||
|
for (; path[1]; path++)
|
||||||
|
{
|
||||||
|
list = ld_category_get_children (category);
|
||||||
|
for (iter = list; iter; iter = g_slist_next (iter))
|
||||||
|
{
|
||||||
|
category = LD_CATEGORY (iter->data);
|
||||||
|
if (!strcmp (*path, ld_category_get_name (category)))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!iter)
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ld_library_find_symbol_error:
|
/* And look up the actual symbol at the leaf. */
|
||||||
g_strfreev (id_el_start);
|
list = ld_category_get_symbols (category);
|
||||||
|
for (iter = list; iter; iter = g_slist_next (iter))
|
||||||
|
{
|
||||||
|
symbol = LD_SYMBOL (iter->data);
|
||||||
|
if (!strcmp (*path, ld_symbol_get_name (symbol)))
|
||||||
|
return symbol;
|
||||||
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,7 +250,6 @@ ld_lua_alloc (void *ud, void *ptr, size_t osize, size_t nsize)
|
|||||||
g_free (ptr);
|
g_free (ptr);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
return g_try_realloc (ptr, nsize);
|
return g_try_realloc (ptr, nsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -618,7 +618,7 @@ diagram_get_name (LdWindowMain *self)
|
|||||||
|
|
||||||
if (self->priv->filename)
|
if (self->priv->filename)
|
||||||
return g_filename_display_basename (self->priv->filename);
|
return g_filename_display_basename (self->priv->filename);
|
||||||
else
|
|
||||||
return g_strdup (_("Unsaved Diagram"));
|
return g_strdup (_("Unsaved Diagram"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -698,13 +698,11 @@ diagram_save (LdWindowMain *self, GtkWindow *dialog_parent,
|
|||||||
gtk_widget_destroy (message_dialog);
|
gtk_widget_destroy (message_dialog);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
ld_diagram_set_modified (self->priv->diagram, FALSE);
|
ld_diagram_set_modified (self->priv->diagram, FALSE);
|
||||||
update_title (self);
|
update_title (self);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* diagram_open:
|
* diagram_open:
|
||||||
@ -1179,11 +1177,11 @@ static gboolean
|
|||||||
on_action_about_activate_link (GtkAboutDialog *dialog, gchar *uri,
|
on_action_about_activate_link (GtkAboutDialog *dialog, gchar *uri,
|
||||||
LdWindowMain *self)
|
LdWindowMain *self)
|
||||||
{
|
{
|
||||||
|
#ifdef G_OS_WIN32
|
||||||
GdkWindow *window;
|
GdkWindow *window;
|
||||||
|
|
||||||
window = gtk_widget_get_window (GTK_WIDGET (self));
|
window = gtk_widget_get_window (GTK_WIDGET (self));
|
||||||
|
|
||||||
#ifdef G_OS_WIN32
|
|
||||||
/* gtk_show_uri() on Windows XP fails, due to trying to establish
|
/* gtk_show_uri() on Windows XP fails, due to trying to establish
|
||||||
* an SSL connection, so let's first try to not do that on Windows.
|
* an SSL connection, so let's first try to not do that on Windows.
|
||||||
* `cmd.exe /c start "" ...` would pop up a command line window,
|
* `cmd.exe /c start "" ...` would pop up a command line window,
|
||||||
|
1
vera++
1
vera++
@ -1 +0,0 @@
|
|||||||
Subproject commit 45f3ab870d3722891642098bd7fc0d6fc97c8571
|
|
Loading…
x
Reference in New Issue
Block a user