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

gEDA-cvs: gaf.git: branch: master updated (1.5.1-20081221-116-g373becd)



The branch, master has been updated
       via  373becd3a5156236963b82e7f9a27be8f90db0c4 (commit)
      from  8a1b27af48d06ffe4fa2dc71a67810f7b4a71e32 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


=========
 Summary
=========

 gsymcheck/include/prototype.h      |    1 +
 gsymcheck/src/s_check.c            |   86 ++++++++++++++++++++++++++++++++++++
 gsymcheck/tests/Makefile.am        |    4 +-
 gsymcheck/tests/text_errors.output |   16 +++++++
 gsymcheck/tests/text_errors.sym    |   66 +++++++++++++++++++++++++++
 5 files changed, 171 insertions(+), 2 deletions(-)
 create mode 100644 gsymcheck/tests/text_errors.output
 create mode 100644 gsymcheck/tests/text_errors.sym


=================
 Commit Messages
=================

commit 373becd3a5156236963b82e7f9a27be8f90db0c4
Author: Werner Hoch <werner.ho@xxxxxx>
Date:   Fri Jan 2 20:39:56 2009 +0100

    gsymcheck: checks for overbars and escaping
    
    Test for single overbar markers '\_label' and print a warning.
    libgeda currently closes an open overbar at the end of the string
    but a different implementation could drop the overbar.
    
    It also tests for single backslash characters. They will
    be invisible as a '\x' combination will only print the second
    char 'x'. The user should decide whether he likes to remove
    the backslash or whether to escape it and write '\\x'

:100644 100644 ad24b2a... b71ab0e... M	gsymcheck/include/prototype.h
:100644 100644 8942ea2... 1ba5052... M	gsymcheck/src/s_check.c
:100644 100644 7beb753... 5a42109... M	gsymcheck/tests/Makefile.am
:000000 100644 0000000... b2140bc... A	gsymcheck/tests/text_errors.output
:000000 100644 0000000... 6e26570... A	gsymcheck/tests/text_errors.sym

=========
 Changes
=========

commit 373becd3a5156236963b82e7f9a27be8f90db0c4
Author: Werner Hoch <werner.ho@xxxxxx>
Date:   Fri Jan 2 20:39:56 2009 +0100

    gsymcheck: checks for overbars and escaping
    
    Test for single overbar markers '\_label' and print a warning.
    libgeda currently closes an open overbar at the end of the string
    but a different implementation could drop the overbar.
    
    It also tests for single backslash characters. They will
    be invisible as a '\x' combination will only print the second
    char 'x'. The user should decide whether he likes to remove
    the backslash or whether to escape it and write '\\x'

diff --git a/gsymcheck/include/prototype.h b/gsymcheck/include/prototype.h
index ad24b2a..b71ab0e 100644
--- a/gsymcheck/include/prototype.h
+++ b/gsymcheck/include/prototype.h
@@ -17,6 +17,7 @@ int s_check_all(TOPLEVEL *pr_current);
 int s_check_symbol(TOPLEVEL *pr_current, PAGE *p_current, const GList *obj_list);
 gboolean s_check_list_has_item(char **list , char *item);
 void s_check_symbol_structure(const GList *obj_list, SYMCHECK *s_current);
+void s_check_text (const GList *obj_list, SYMCHECK *s_current);
 void s_check_graphical(const GList *obj_list, SYMCHECK *s_current);
 void s_check_device(const GList *obj_list, SYMCHECK *s_current);
 void s_check_pinseq(const GList *obj_list, SYMCHECK *s_current);
diff --git a/gsymcheck/src/s_check.c b/gsymcheck/src/s_check.c
index 8942ea2..1ba5052 100644
--- a/gsymcheck/src/s_check.c
+++ b/gsymcheck/src/s_check.c
@@ -78,6 +78,9 @@ s_check_symbol (TOPLEVEL *pr_current, PAGE *p_current, const GList *obj_list)
   /* overal symbol structure test */
   s_check_symbol_structure (obj_list, s_symcheck);
 
+  /* test all text elements */
+  s_check_text (obj_list, s_symcheck);
+
   /* check for graphical attribute */
   s_check_graphical (obj_list, s_symcheck);
 
@@ -259,6 +262,89 @@ s_check_symbol_structure (const GList *obj_list, SYMCHECK *s_current)
 }
 
 void
+s_check_text (const GList *obj_list, SYMCHECK *s_current)
+{
+  const GList *iter;
+  OBJECT *o_current;
+  gboolean overbar_started, escape, leave_parser;
+  char *message;
+  char *text_string, *ptr;
+  gunichar current_char;
+
+  for (iter = obj_list; iter != NULL; iter = g_list_next(iter)) {
+    o_current = iter->data;
+
+    if (o_current->type != OBJ_TEXT)
+      continue;
+
+    overbar_started = escape = leave_parser = FALSE;
+    text_string = o_current->text->string;
+
+    for (ptr = text_string;
+         ptr != NULL && !leave_parser;
+         ptr = g_utf8_find_next_char (ptr, NULL)) {
+
+      current_char = g_utf8_get_char_validated (ptr, -1);
+
+      /* state machine to interpret the string:
+       * there are two independant state variables overbar_started and escape.
+       */
+      switch (current_char) {
+      case '\0':
+        /* end of the string */
+        leave_parser = TRUE;
+        break;
+      case '\\':
+        if (escape == TRUE) {
+          escape = FALSE;
+        } else {
+          escape = TRUE;
+        }
+        break;
+      case '_':
+        if (escape == TRUE) {
+          escape = FALSE;
+          if (overbar_started == TRUE) {
+            overbar_started = FALSE;
+          } else {
+            overbar_started = TRUE;
+          }
+        }
+        break;
+      default:
+        if (escape == TRUE) {
+          message = g_strdup_printf ("Found text with a '\\' in it: consider"
+                                     " to escape it with '\\\\' [%s]\n",
+                                     text_string);
+          s_current->warning_messages = g_list_append(s_current->warning_messages,
+                                                      message);
+          s_current->warning_count++;
+          escape = FALSE;
+        }
+      }
+    }
+
+    if (escape == TRUE) {
+      message = g_strdup_printf ("Found text with a trailing '\': consider to "
+                                 "escape it with '\\\\' [%s]\n",
+                                 text_string);
+      s_current->warning_messages = g_list_append(s_current->warning_messages,
+                                                  message);
+      s_current->warning_count++;
+    }
+
+    if (overbar_started == TRUE) {
+      message = g_strdup_printf ("Found text with unbalanced overbar "
+                                 "markers '\\_' in it' [%s]\n",
+                                 text_string);
+      s_current->warning_messages = g_list_append(s_current->warning_messages,
+                                                  message);
+      s_current->warning_count++;
+    }
+  }
+}
+
+void
 s_check_graphical (const GList *obj_list, SYMCHECK *s_current)
 {
   char *temp;
diff --git a/gsymcheck/tests/Makefile.am b/gsymcheck/tests/Makefile.am
index 7beb753..5a42109 100644
--- a/gsymcheck/tests/Makefile.am
+++ b/gsymcheck/tests/Makefile.am
@@ -13,7 +13,7 @@ EXTRA_DIST = buses.sym connections1.sym connections2.sym connections3.sym \
              oldslot.sym typeinside.sym urefinside.sym zero_pinnumber.sym \
              zero_pinseq.sym zero_slotnum.sym zero_slots.sym \
 	     duplicate_net.sym pin_offgrid.sym pintypes.sym \
-	     misplaced_attributes.sym \
+	     misplaced_attributes.sym text_errors.sym \
 	     runtest.sh \
 	     buses.output connections1.output connections2.output \
 	     connections3.output correct.output duplicate_net.output \
@@ -33,7 +33,7 @@ EXTRA_DIST = buses.sym connections1.sym connections2.sym connections3.sym \
 	     oldslot.output old_symbol.output typeinside.output \
 	     urefinside.output zero_pinnumber.output zero_pinseq.output \
 	     zero_slotnum.output zero_slots.output pin_offgrid.output \
-	     pintypes.output misplaced_attributes.output
+	     pintypes.output misplaced_attributes.output text_errors.output
 
 check_SCRIPTS = tests
 
diff --git a/gsymcheck/tests/text_errors.output b/gsymcheck/tests/text_errors.output
new file mode 100644
index 0000000..b2140bc
--- /dev/null
+++ b/gsymcheck/tests/text_errors.output
@@ -0,0 +1,16 @@
+Warning: Found unknown name1= attribute: [name1=value1]
+Warning: Found unknown value_invisible= attribute: [value_invisible=value_invisible]
+Warning: Found unknown name_invisible= attribute: [name_invisible=name_invisible]
+Warning: Found a simple text object with only SHOW_NAME or SHOW_VALUE set [text with value_invisible]
+Warning: Found a simple text object with only SHOW_NAME or SHOW_VALUE set [text with name_invisible]
+Warning: Found text with unbalanced overbar markers '\_' in it' [pinlabel=\_Reset]
+Warning: Found text with a '\' in it: consider to escape it with '\\' [pinlabel=a\b]
+Warning: Found text with a '\' in it: consider to escape it with '\\' [pinlabel=ab\c\d\]
+Warning: Found text with a '\' in it: consider to escape it with '\\' [pinlabel=ab\c\d\]
+Warning: Found text with a trailing '': consider to escape it with '\\' [pinlabel=ab\c\d\]
+Warning: Missing footprint= attribute
+Warning: Missing refdes= attribute
+Warning: Did not find numslots= attribute, not checking slotting
+ERROR: Missing device= attribute
+13 warnings found 
+1 ERROR found 
diff --git a/gsymcheck/tests/text_errors.sym b/gsymcheck/tests/text_errors.sym
new file mode 100644
index 0000000..6e26570
--- /dev/null
+++ b/gsymcheck/tests/text_errors.sym
@@ -0,0 +1,66 @@
+v 20081221 2
+B 300 0 900 1700 3 0 0 0 -1 -1 0 -1 -1 -1 -1 -1
+P 0 200 300 200 1 0 0
+{
+T 0 200 5 10 0 0 0 0 1
+pintype=in
+T 355 195 5 10 1 1 0 0 1
+pinlabel=\_Reset
+T 205 245 5 10 1 1 0 6 1
+pinnumber=1
+T 0 200 5 10 0 0 0 0 1
+pinseq=1
+}
+T 1300 200 9 10 1 0 0 0 1
+Single overbar "\\_"
+P 0 600 300 600 1 0 0
+{
+T 0 600 5 10 0 0 0 0 1
+pintype=in
+T 355 595 5 10 1 1 0 0 1
+pinlabel=a\b
+T 205 645 5 10 1 1 0 6 1
+pinnumber=2
+T 0 600 5 10 0 0 0 0 1
+pinseq=2
+}
+T 1300 600 9 10 1 0 0 0 1
+Single backslash "\\"
+P 0 1000 300 1000 1 0 0
+{
+T 0 1000 5 10 0 0 0 0 1
+pintype=in
+T 355 995 5 10 1 1 0 0 1
+pinlabel=ab\c\d\
+T 205 1045 5 10 1 1 0 6 1
+pinnumber=3
+T 0 1000 5 10 0 0 0 0 1
+pinseq=3
+}
+T 1300 1000 9 10 1 0 0 0 1
+more single backslashes
+T 300 2900 9 10 1 0 0 0 1
+name1=value1
+T 300 2700 9 10 1 2 0 0 1
+value_invisible=value_invisible
+T 300 2500 9 10 1 1 0 0 1
+name_invisible=name_invisible
+T 300 2300 9 10 1 0 0 0 1
+Regular text
+T 300 2100 9 10 1 2 0 0 1
+text with value_invisible
+T 300 1900 9 10 1 1 0 0 1
+text with name_invisible
+P 0 1400 300 1400 1 0 0
+{
+T 0 1400 5 10 0 0 0 0 1
+pintype=in
+T 355 1395 5 10 1 1 0 0 1
+pinlabel=R/\_W\_
+T 205 1445 5 10 1 1 0 6 1
+pinnumber=4
+T 0 1400 5 10 0 0 0 0 1
+pinseq=4
+}
+T 1300 1400 9 10 1 0 0 0 1
+valid overbars "\\_"




_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs