[gnome-logs/wip/test: 21/37] Add some comments for the previous commit



commit 42cbc7315d59acaaa3d3f310d82271ced721d164
Author: Jonathan Kang <jonathan121537 gmail com>
Date:   Tue Aug 11 15:30:50 2015 +0200

    Add some comments for the previous commit
    
    https://bugzilla.gnome.org/show_bug.cgi?id=709152

 src/gl-eventviewlist.c |   19 ++++++++++++++-----
 1 files changed, 14 insertions(+), 5 deletions(-)
---
diff --git a/src/gl-eventviewlist.c b/src/gl-eventviewlist.c
index 3efbf65..0df30fb 100644
--- a/src/gl-eventviewlist.c
+++ b/src/gl-eventviewlist.c
@@ -60,6 +60,8 @@ typedef struct
     const gchar *boot_match;
 } GlEventViewListPrivate;
 
+/* We define these two enum values as 2 and 3 to avoid the conflict with TRUE
+ * and FALSE */
 typedef enum
 {
     LOGICAL_OR = 2,
@@ -189,14 +191,15 @@ calculate_match (GlJournalEntry *entry,
     gchar *field_value;
     gint i;
     gint match_stack[10];
-    gint match_count = 0;
-    gint token_index = 0;
+    guint match_count = 0;
+    guint token_index = 0;
 
     comm = gl_journal_entry_get_command_line (entry);
     message = gl_journal_entry_get_message (entry);
     kernel_device = gl_journal_entry_get_kernel_device (entry);
     audit_session = gl_journal_entry_get_audit_session (entry);
 
+    /* No logical AND or OR used in search text */
     if (token_array->len == 1 && case_sensetive == TRUE)
     {
         gchar *search_text;
@@ -296,11 +299,14 @@ calculate_match (GlJournalEntry *entry,
         }
     }
 
+    /* match_count > 2 means there are still matches to be calculated in the
+     * stack */
     if (match_count > 2)
     {
+        /* calculate the expression with logical AND */
         for (i = 0; i < match_count; i++)
         {
-            if (match_stack[i] == 3)
+            if (match_stack[i] == LOGICAL_AND)
             {
                 int j;
 
@@ -311,7 +317,8 @@ calculate_match (GlJournalEntry *entry,
                     if (j == match_count - 3)
                     {
                         match_stack[j] = match_stack[j + 2];
-                        /* We use -1 to represent the values that are not useful */
+                        /* We use -1 to represent the values that are not
+                         * useful */
                         match_stack[j + 1] = -1;
 
                         break;
@@ -323,9 +330,11 @@ calculate_match (GlJournalEntry *entry,
             }
         }
 
+        /* calculate the expression with logical OR */
         for (i = 0; i < match_count; i++)
         {
-            if ((match_stack[i] == 2) && (i != token_index - 1) &&
+            /* We use -1 to represent the values that are not useful */
+            if ((match_stack[i] == LOGICAL_OR) && (i != token_index - 1) &&
                 (match_stack[i + 1] != -1))
             {
                 int j;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]