Commit 845bc426 authored by Sébastien Wilmet's avatar Sébastien Wilmet
Browse files

Have same coding style for logical negation in Vala and C

To make the life easier for contributors (and to myself too). Reduce the
number of differences between the coding style in Vala and C.

Done with:
$ sed -i 's/! /!/g' *.vala

I've checked the diff, everything looks fine.
parent 101d18fe
......@@ -31,7 +31,7 @@ For Vala:
- Some spaces almost everywhere:
- function (blah); // not function(blah);
- int num = 5; // not int num=5;
- if (! foo) // not if (!foo)
- if (!foo) // not if(!foo)
- for (int i = 0; i < max; i++) // not for(int i=0;i<max;i++)
- etc...
- Do not use 'var' for declaring variables, unless the type is very long.
......@@ -42,8 +42,6 @@ For C:
- Follow the same coding style as GtkSourceView:
https://git.gnome.org/browse/gtksourceview/tree/HACKING
- No maximum line length (but short lines are better).
- Spacing differences with Vala:
- if (!foo)
- Note that the GNU coding style was previously used, all the *.c files
have been converted to the GtkSourceView coding style with the uncrustify
config file (see the scripts/ directory in the GtkSourceView git
......
......@@ -236,14 +236,14 @@ int main (string[] args)
}
File xml_file = File.new_for_commandline_arg (args[1]);
if (! xml_file.query_exists ())
if (!xml_file.query_exists ())
{
stderr.printf ("'%s' does not exist.\n", args[1]);
return 1;
}
File dir = File.new_for_commandline_arg (args[2]);
if (! dir.query_exists ())
if (!dir.query_exists ())
{
stderr.printf ("'%s' does not exist.\n", args[2]);
return 1;
......
......@@ -202,7 +202,7 @@ public class BuildToolsPreferences : GLib.Object
TreeModel model = store as TreeModel;
model.get (iter, BuildToolColumn.ENABLED, out enabled);
enabled = ! enabled;
enabled = !enabled;
store.set (iter, BuildToolColumn.ENABLED, enabled);
int num = int.parse (path_string);
......
......@@ -42,7 +42,7 @@ public class CleanBuildFiles : GLib.Object
public void clean ()
{
if (! _doc.is_main_file_a_tex_file ())
if (!_doc.is_main_file_a_tex_file ())
return;
Gee.ArrayList<File> files_to_delete;
......@@ -66,7 +66,7 @@ public class CleanBuildFiles : GLib.Object
if (files_to_delete.size == 0)
{
if (! no_confirm)
if (!no_confirm)
show_info_no_file ();
return;
}
......@@ -219,7 +219,7 @@ public class CleanBuildFiles : GLib.Object
store.get_iter (out iter, path);
store.get (iter, CleanFileColumn.DELETE, out active);
// inverse the value
store.set (iter, CleanFileColumn.DELETE, ! active);
store.set (iter, CleanFileColumn.DELETE, !active);
});
TreeViewColumn column = new TreeViewColumn.with_attributes ("Delete?",
......
......@@ -152,7 +152,7 @@ public class CompletionProvider : GLib.Object, SourceCompletionProvider
return true;
}
if (! iter.starts_word ())
if (!iter.starts_word ())
iter.backward_visible_word_start ();
prev = iter;
......@@ -203,7 +203,7 @@ public class CompletionProvider : GLib.Object, SourceCompletionProvider
private void populate_command (SourceCompletionContext context, string cmd)
{
if (! is_user_request (context))
if (!is_user_request (context))
{
uint min_nb_chars;
_settings.get ("interactive-completion-num", "u", out min_nb_chars);
......@@ -227,7 +227,7 @@ public class CompletionProvider : GLib.Object, SourceCompletionProvider
private void populate_argument (SourceCompletionContext context, ArgumentContext info)
{
// invalid argument's command
if (! _commands.has_key (info.cmd_name))
if (!_commands.has_key (info.cmd_name))
{
show_no_proposals (context);
return;
......@@ -537,7 +537,7 @@ public class CompletionProvider : GLib.Object, SourceCompletionProvider
while (text.get_prev_char (ref index, out cur_char))
{
if ((cur_char == '[' || cur_char == '{')
&& ! Utils.char_is_escaped (text, index))
&& !Utils.char_is_escaped (text, index))
{
break;
}
......@@ -578,7 +578,7 @@ public class CompletionProvider : GLib.Object, SourceCompletionProvider
}
// A LaTeX command contains only normal letters and '*'.
if (! cur_char.isalpha () && cur_char != '*')
if (!cur_char.isalpha () && cur_char != '*')
break;
}
......@@ -600,12 +600,12 @@ public class CompletionProvider : GLib.Object, SourceCompletionProvider
while (true)
{
unichar cur_char;
if (! text.get_prev_char (ref cur_index, out cur_char))
if (!text.get_prev_char (ref cur_index, out cur_char))
return false;
// End of the argument's contents.
bool opening_bracket = cur_char == '{' || cur_char == '[';
if (opening_bracket && ! Utils.char_is_escaped (text, cur_index))
if (opening_bracket && !Utils.char_is_escaped (text, cur_index))
{
info.args_types.insert (0, cur_char == '[');
info.arg_contents = text[cur_index + 1 : last_index];
......@@ -620,7 +620,7 @@ public class CompletionProvider : GLib.Object, SourceCompletionProvider
while (true)
{
unichar cur_char;
if (! text.get_prev_char (ref cur_index, out cur_char))
if (!text.get_prev_char (ref cur_index, out cur_char))
return false;
// In the contents of a previous argument.
......@@ -650,7 +650,7 @@ public class CompletionProvider : GLib.Object, SourceCompletionProvider
}
// Spaces are allowed between arguments.
else if (! cur_char.isspace ())
else if (!cur_char.isspace ())
return false;
}
}
......@@ -734,7 +734,7 @@ public class CompletionProvider : GLib.Object, SourceCompletionProvider
break;
// missing non-optional argument
else if (! all_args[num].optional)
else if (!all_args[num].optional)
return -1;
num++;
......@@ -751,7 +751,7 @@ public class CompletionProvider : GLib.Object, SourceCompletionProvider
string text_to_insert = cmd.name;
foreach (CompletionArgument arg in cmd.args)
{
if (! arg.optional)
if (!arg.optional)
text_to_insert += "{}";
}
return text_to_insert;
......
......@@ -106,7 +106,7 @@ namespace Dialogs
store.get_iter (out iter, path);
store.get (iter, UnsavedDocColumn.SAVE, out active, -1);
// inverse the value
store.set (iter, UnsavedDocColumn.SAVE, ! active, -1);
store.set (iter, UnsavedDocColumn.SAVE, !active, -1);
});
TreeViewColumn column = new TreeViewColumn.with_attributes ("Save?", renderer1,
......@@ -146,7 +146,7 @@ namespace Dialogs
// close all saved documents
foreach (Document doc in window.get_documents ())
{
if (! doc.get_modified ())
if (!doc.get_modified ())
window.close_tab (doc.tab);
}
......
......@@ -159,7 +159,7 @@ public class Document : Tepl.Buffer
return_if_fail (location != null);
// if not modified, don't save
if (! force && ! new_file && ! get_modified ())
if (!force && !new_file && !get_modified ())
return;
// we use get_text () to exclude undisplayed text
......@@ -175,7 +175,7 @@ public class Document : Tepl.Buffer
{
GLib.Settings settings =
new GLib.Settings ("org.gnome.gnome-latex.preferences.editor");
bool make_backup = ! backup_made
bool make_backup = !backup_made
&& settings.get_boolean ("create-backup-copy");
string? etag = check_file_changed_on_disk ? _etag : null;
......@@ -190,7 +190,7 @@ public class Document : Tepl.Buffer
// check if parent directories exist, if not, create it
File parent = location.get_parent ();
if (parent != null && ! parent.query_exists ())
if (parent != null && !parent.query_exists ())
parent.make_directory_with_parents ();
location.replace_contents (text.data, etag, make_backup,
......
......@@ -159,7 +159,7 @@ public class DocumentStructure : GLib.Object
bool item_found = search_low_level_item (line_text, start_index, out type,
out contents, out start_match_index, out end_match_index);
if (! item_found)
if (!item_found)
break;
TextIter iter = line_iter;
......@@ -215,13 +215,13 @@ public class DocumentStructure : GLib.Object
while (match_info.matches ())
{
int after_char_index;
if (! match_info.fetch_pos (0, out start_match_index, out after_char_index))
if (!match_info.fetch_pos (0, out start_match_index, out after_char_index))
{
warning ("Structure parsing: position can not be fetched");
return false;
}
if (! Utils.char_is_escaped (line, start_match_index))
if (!Utils.char_is_escaped (line, start_match_index))
{
string char_matched = match_info.fetch (0);
......@@ -323,7 +323,7 @@ public class DocumentStructure : GLib.Object
return true;
}
if (contents == "document" && ! is_begin_env)
if (contents == "document" && !is_begin_env)
{
type = StructType.END_DOCUMENT;
return true;
......@@ -342,7 +342,7 @@ public class DocumentStructure : GLib.Object
string after_backslash_text = line.substring (after_backslash_index);
MatchInfo match_info;
if (! _command_name_regex.match (after_backslash_text, 0, out match_info))
if (!_command_name_regex.match (after_backslash_text, 0, out match_info))
return null;
int pos;
......@@ -375,14 +375,14 @@ public class DocumentStructure : GLib.Object
{
int next_index = cur_index;
unichar cur_char;
bool end = ! line.get_next_char (ref next_index, out cur_char);
bool end = !line.get_next_char (ref next_index, out cur_char);
if (in_optional_arg)
{
switch (cur_char)
{
case ']':
if (! Utils.char_is_escaped (line, cur_index))
if (!Utils.char_is_escaped (line, cur_index))
{
if (0 < additional_bracket_level)
additional_bracket_level--;
......@@ -392,7 +392,7 @@ public class DocumentStructure : GLib.Object
break;
case '[':
if (! Utils.char_is_escaped (line, cur_index))
if (!Utils.char_is_escaped (line, cur_index))
additional_bracket_level++;
break;
}
......@@ -440,12 +440,12 @@ public class DocumentStructure : GLib.Object
{
int next_index = cur_index;
unichar cur_char;
bool end = ! line.get_next_char (ref next_index, out cur_char);
bool end = !line.get_next_char (ref next_index, out cur_char);
if (cur_char == '{' && ! Utils.char_is_escaped (line, cur_index))
if (cur_char == '{' && !Utils.char_is_escaped (line, cur_index))
brace_level++;
else if (cur_char == '}' && ! Utils.char_is_escaped (line, cur_index))
else if (cur_char == '}' && !Utils.char_is_escaped (line, cur_index))
{
if (brace_level > 0)
brace_level--;
......@@ -482,7 +482,7 @@ public class DocumentStructure : GLib.Object
string text_after = line.substring (after_percent_index).strip ();
MatchInfo match_info;
if (! _comment_regex.match (text_after, 0, out match_info))
if (!_comment_regex.match (text_after, 0, out match_info))
return false;
string type_str = match_info.fetch_named ("type");
......@@ -683,7 +683,7 @@ public class DocumentStructure : GLib.Object
begin_line.set_line_offset (0);
TextIter end_line = iter;
if (! iter.ends_line ())
if (!iter.ends_line ())
end_line.forward_to_line_end ();
TextBuffer buffer = iter.get_buffer ();
......@@ -702,7 +702,7 @@ public class DocumentStructure : GLib.Object
if (action_type == StructAction.COMMENT)
{
if (! comment_item (tree_iter))
if (!comment_item (tree_iter))
throw new StructError.DATA_OUTDATED ("");
_model.delete (tree_iter);
......@@ -724,7 +724,7 @@ public class DocumentStructure : GLib.Object
bool success = shift_item (tree_iter, shift_right, out doc_modified);
_doc.end_user_action ();
if (! success)
if (!success)
{
if (doc_modified)
_doc.undo ();
......@@ -745,7 +745,7 @@ public class DocumentStructure : GLib.Object
TextIter end_iter;
bool found = get_exact_item_bounds (tree_iter, out start_iter, out end_iter);
if (! found)
if (!found)
throw new StructError.DATA_OUTDATED ("");
if (start_iter.get_line () != end_iter.get_line ())
......@@ -804,7 +804,7 @@ public class DocumentStructure : GLib.Object
}
/* comment a simple item */
if (! Structure.is_section (type))
if (!Structure.is_section (type))
{
_doc.comment_between (start_iter, end_iter, end_iter_set);
return true;
......@@ -832,7 +832,7 @@ public class DocumentStructure : GLib.Object
bool end_of_file;
end_iter = get_end_document_iter (out end_of_file);
end_iter_set = true;
go_one_line_backward = ! end_of_file;
go_one_line_backward = !end_of_file;
}
else
......@@ -847,7 +847,7 @@ public class DocumentStructure : GLib.Object
if (go_one_line_backward)
{
if (! end_iter.backward_line ())
if (!end_iter.backward_line ())
end_iter_set = false;
}
......@@ -880,7 +880,7 @@ public class DocumentStructure : GLib.Object
bool found = get_low_level_item_bounds (item_type, item_contents, start_iter,
true, out end_iter);
if (! found)
if (!found)
return false;
/* search 'end_iter' */
......@@ -951,7 +951,7 @@ public class DocumentStructure : GLib.Object
out contents, out start_match_index, out end_match_index);
// If an item is found, it should be located at exactly the same place.
if (! found || start_index != start_match_index)
if (!found || start_index != start_match_index)
return false;
if (contents == null)
......@@ -1050,7 +1050,7 @@ public class DocumentStructure : GLib.Object
else
return_val_if_fail (type != StructType.PART, false);
if (! Structure.is_section (type))
if (!Structure.is_section (type))
return true;
/* Get the markup name, do some checks, etc. */
......@@ -1113,7 +1113,7 @@ public class DocumentStructure : GLib.Object
child_num);
return_val_if_fail (child_iter_set, false);
if (! shift_item (child_iter, shift_right))
if (!shift_item (child_iter, shift_right))
return false;
}
......
......@@ -52,13 +52,13 @@ public class DocumentTab : Tepl.Tab
_auto_save_interval = value;
if (! _auto_save)
if (!_auto_save)
return;
if (auto_save_timeout > 0)
{
return_if_fail (document.location != null);
return_if_fail (! document.readonly);
return_if_fail (!document.readonly);
remove_auto_save_timeout ();
install_auto_save_timeout ();
}
......@@ -81,19 +81,19 @@ public class DocumentTab : Tepl.Tab
_auto_save = value;
if (_auto_save && auto_save_timeout <= 0 && document.location != null
&& ! document.readonly)
&& !document.readonly)
{
install_auto_save_timeout ();
return;
}
if (! _auto_save && auto_save_timeout > 0)
if (!_auto_save && auto_save_timeout > 0)
{
remove_auto_save_timeout ();
return;
}
return_if_fail ((! _auto_save && auto_save_timeout <= 0)
return_if_fail ((!_auto_save && auto_save_timeout <= 0)
|| document.location == null || document.readonly);
}
}
......@@ -156,7 +156,7 @@ public class DocumentTab : Tepl.Tab
return false;
// if file was never saved or is remote we do not check
if (! get_buffer ().get_file ().is_local ())
if (!get_buffer ().get_file ().is_local ())
return false;
if (document.is_externally_modified ())
......@@ -208,7 +208,7 @@ public class DocumentTab : Tepl.Tab
{
return_val_if_fail (auto_save_timeout <= 0, false);
if (auto_save && document.location != null && ! document.readonly)
if (auto_save && document.location != null && !document.readonly)
{
install_auto_save_timeout ();
return true;
......@@ -228,7 +228,7 @@ public class DocumentTab : Tepl.Tab
private bool on_auto_save ()
{
return_val_if_fail (document.location != null, false);
return_val_if_fail (! document.readonly, false);
return_val_if_fail (!document.readonly, false);
return_val_if_fail (auto_save_timeout > 0, false);
return_val_if_fail (auto_save, false);
return_val_if_fail (auto_save_interval > 0, false);
......
......@@ -39,7 +39,7 @@ public class DocumentView : Tepl.View
doc.notify["readonly"].connect ((d, p) =>
{
this.editable = ! ((Document) d).readonly;
this.editable = !((Document) d).readonly;
});
wrap_mode = WrapMode.WORD;
......@@ -289,7 +289,7 @@ public class DocumentView : Tepl.View
{
Gspell.TextView gspell_view =
Gspell.TextView.get_from_gtk_text_view (this as TextView);
if (! gspell_view.inline_spell_checking)
if (!gspell_view.inline_spell_checking)
return;
Gspell.Checker? spell_checker = get_spell_checker ();
......
......@@ -158,7 +158,7 @@ public class FileBrowser : Grid
{
TreeModel model = _list_store as TreeModel;
TreeIter iter;
if (! model.get_iter (out iter, path))
if (!model.get_iter (out iter, path))
return;
string basename;
......@@ -477,7 +477,7 @@ public class FileBrowser : Grid
break;
string basename = info.get_display_name ();
if (basename[0] == '.' && ! show_hidden_files)
if (basename[0] == '.' && !show_hidden_files)
continue;
FileType type = info.get_file_type ();
......@@ -487,7 +487,7 @@ public class FileBrowser : Grid
continue;
}
if (! show_build_files)
if (!show_build_files)
{
bool is_build_file = false;
......@@ -603,7 +603,7 @@ public class FileBrowser : Grid
private void set_directory (File directory, bool force = false)
{
if (! force && _current_directory == directory)
if (!force && _current_directory == directory)
return;
_current_directory = directory;
......
......@@ -23,7 +23,7 @@ namespace Finance
{
public void show_dialog (Window parent_window, bool startup)
{
if (startup && ! should_show_dialog_on_startup ())
if (startup && !should_show_dialog_on_startup ())
return;
string title;
......
......@@ -374,7 +374,7 @@ public class LatexilaApp : Gtk.Application
synctex.backward_search.connect ((tex_uri, line, timestamp) =>
{
File tex_file = File.new_for_uri (tex_uri);
if (! tex_file.query_exists ())
if (!tex_file.query_exists ())
{
warning (@"Backward search: the file \"$tex_uri\" doesn't exist.");
return;
......
......@@ -628,14 +628,14 @@ public class MainWindow : ApplicationWindow
/* check if the document is already opened */
foreach (Window window in LatexilaApp.get_instance ().get_windows ())
{
if (! (window is MainWindow))
if (!(window is MainWindow))
continue;
MainWindow w = window as MainWindow;
foreach (Document doc in w.get_documents ())
{
if (doc.location == null || ! location.equal (doc.location))
if (doc.location == null || !location.equal (doc.location))
continue;
/* the document is already opened in this window */
......@@ -735,7 +735,7 @@ public class MainWindow : ApplicationWindow
_main_window_edit.update_sensitivity ();
_main_window_tools.update_sensitivity ();
if (! this.get_visible ())
if (!this.get_visible ())
this.present ();
return tab;
......@@ -747,7 +747,7 @@ public class MainWindow : ApplicationWindow
/* If document not saved
* Ask the user if he wants to save the file, or close without saving, or cancel
*/
if (! force_close && tab.get_buffer ().get_modified ())
if (!force_close && tab.get_buffer ().get_modified ())
{
Dialog dialog = new MessageDialog (this,
DialogFlags.DESTROY_WITH_PARENT,
......@@ -802,7 +802,7 @@ public class MainWindow : ApplicationWindow
// return true if the document has been saved
public bool save_document (Document doc, bool force_save_as)
{
if (! force_save_as && doc.location != null)
if (!force_save_as && doc.location != null)
{
doc.save ();
......
......@@ -133,7 +133,7 @@ public class MainWindowBuildTools
as GLib.SimpleAction;
// a build tool can not be modified when it is running
preferences_action.set_enabled (! build_tool_is_running);
preferences_action.set_enabled (!build_tool_is_running);
Gtk.Action clean_action = _static_action_group.get_action ("BuildClean");
Gtk.Action view_log_action = _static_action_group.get_action ("BuildViewLog");
......@@ -214,7 +214,7 @@ public class MainWindowBuildTools
private void update_build_tool_sensitivity (Latexila.BuildTool tool,
string action_name)
{
if (! tool.enabled)
if (!tool.enabled)
return;
Gtk.Action action = _dynamic_action_group.get_action (action_name);
......@@ -315,7 +315,7 @@ public class MainWindowBuildTools
private void add_dynamic_action (Latexila.BuildTool build_tool, string action_name,
ref int accel_num)
{
if (! build_tool.enabled)
if (!build_tool.enabled)
return;
Gtk.Action action = new Gtk.Action (action_name, build_tool.label,
......
......@@ -193,7 +193,7 @@ public class MainWindowDocuments
return_if_fail (_documents_panel != null);
RadioAction radio_action = action as RadioAction;
if (! radio_action.get_active ())
if (!radio_action.get_active ())
return;
_documents_panel.set_current_page (radio_action.get_current_value ());
......
......@@ -72,7 +72,7 @@ public class MostUsedSymbols : GLib.Object
{
TreeIter iter;
if (! get_iter_at_symbol_id (id, out iter))
if (!get_iter_at_symbol_id (id, out iter))
add_symbol (id, 1);
else
{
......@@ -88,7 +88,7 @@ public class MostUsedSymbols : GLib.Object
private bool get_iter_at_symbol_id (string id, out TreeIter iter)
{
if (! _store.get_iter_first (out iter))
if (!_store.get_iter_first (out iter))