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)
|
||||
|
||||
# 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_GTKDOC "For developers only--enable use of gtk-doc" OFF)
|
||||
option (BUILD_TESTING "Build tests" OFF)
|
||||
@ -266,42 +266,38 @@ find_package (CppCheck)
|
||||
GENERATE_CPPCHECK (SOURCES liblogdiag src tests ENABLE_IDS all
|
||||
TARGET_NAME ${PROJECT_NAME}_cppcheck INCLUDES ${PROJECT_BINARY_DIR})
|
||||
|
||||
if (OPTION_USE_VERA)
|
||||
# Force this off, we don't need it
|
||||
option (VERA_LUA "" OFF)
|
||||
# Various clang-based diagnostics, loads of fake positives and spam
|
||||
if (OPTION_CLANG_TIDY)
|
||||
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
|
||||
get_directory_property (backup_includes INCLUDE_DIRECTORIES)
|
||||
set_directory_properties (PROPERTIES INCLUDE_DIRECTORIES "")
|
||||
set (backup_source_dir "${CMAKE_SOURCE_DIR}")
|
||||
set (CMAKE_SOURCE_DIR "${CMAKE_SOURCE_DIR}/vera++")
|
||||
string (REPLACE ";" "," clang_tidy_checks "${clang_tidy_checks}")
|
||||
set (clang_tidy_config "{
|
||||
Checks: '${clang_tidy_checks}',
|
||||
CheckOptions: [{
|
||||
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_SOURCE_DIR "${backup_source_dir}")
|
||||
|
||||
# Check the sources
|
||||
# XXX: maybe do it per source file and not all at once
|
||||
set (vera_srcs ${liblogdiag_SOURCES} ${logdiag_SOURCES} ${logdiag_HEADERS})
|
||||
set (vera_output ${PROJECT_BINARY_DIR}/vera.log)
|
||||
add_custom_command (OUTPUT ${vera_output}
|
||||
COMMAND vera
|
||||
-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)
|
||||
set (CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
set (clang_tidy_sources ${liblogdiag_SOURCES} ${logdiag_SOURCES})
|
||||
add_custom_target (${PROJECT_NAME}_clang_tidy
|
||||
COMMAND clang-tidy --quiet -p ${PROJECT_BINARY_DIR}
|
||||
"--config=${clang_tidy_config}" ${clang_tidy_sources}
|
||||
| sh -c "cat 1>&2"
|
||||
DEPENDS ${clang_tidy_sources} VERBATIM
|
||||
USES_TERMINAL WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
|
||||
endif ()
|
||||
|
||||
# GSettings
|
||||
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. */
|
||||
if (u < 0.)
|
||||
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);
|
||||
|
||||
/* 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),
|
||||
gpointer userdata, GError **error);
|
||||
|
||||
static LdSymbol *traverse_path (LdCategory *category, gchar **path);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (LdLibrary, ld_library, G_TYPE_OBJECT)
|
||||
|
||||
@ -356,62 +358,51 @@ ld_library_load (LdLibrary *self, const gchar *directory)
|
||||
LdSymbol *
|
||||
ld_library_find_symbol (LdLibrary *self, const gchar *identifier)
|
||||
{
|
||||
gchar **id_el_start, **id_el;
|
||||
const GSList *list, *list_el;
|
||||
LdCategory *cat;
|
||||
gchar **path;
|
||||
LdSymbol *symbol = NULL;
|
||||
|
||||
g_return_val_if_fail (LD_IS_LIBRARY (self), NULL);
|
||||
g_return_val_if_fail (identifier != NULL, NULL);
|
||||
|
||||
id_el_start = g_strsplit (identifier, LD_LIBRARY_IDENTIFIER_SEPARATOR, 0);
|
||||
if (!id_el_start)
|
||||
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)
|
||||
path = g_strsplit (identifier, LD_LIBRARY_IDENTIFIER_SEPARATOR, 0);
|
||||
if (path)
|
||||
{
|
||||
gboolean found = FALSE;
|
||||
|
||||
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;
|
||||
symbol = traverse_path (self->priv->root, path);
|
||||
g_strfreev (path);
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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:
|
||||
g_strfreev (id_el_start);
|
||||
/* And look up the actual symbol at the leaf. */
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -250,7 +250,6 @@ ld_lua_alloc (void *ud, void *ptr, size_t osize, size_t nsize)
|
||||
g_free (ptr);
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
return g_try_realloc (ptr, nsize);
|
||||
}
|
||||
|
||||
|
@ -618,7 +618,7 @@ diagram_get_name (LdWindowMain *self)
|
||||
|
||||
if (self->priv->filename)
|
||||
return g_filename_display_basename (self->priv->filename);
|
||||
else
|
||||
|
||||
return g_strdup (_("Unsaved Diagram"));
|
||||
}
|
||||
|
||||
@ -698,13 +698,11 @@ diagram_save (LdWindowMain *self, GtkWindow *dialog_parent,
|
||||
gtk_widget_destroy (message_dialog);
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
ld_diagram_set_modified (self->priv->diagram, FALSE);
|
||||
update_title (self);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* diagram_open:
|
||||
@ -1179,11 +1177,11 @@ static gboolean
|
||||
on_action_about_activate_link (GtkAboutDialog *dialog, gchar *uri,
|
||||
LdWindowMain *self)
|
||||
{
|
||||
#ifdef G_OS_WIN32
|
||||
GdkWindow *window;
|
||||
|
||||
window = gtk_widget_get_window (GTK_WIDGET (self));
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
/* 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.
|
||||
* `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