texinfo-commits
[Top][All Lists]
Advanced

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

[7227] parsetexi @U argument checking


From: gavinsmith0123
Subject: [7227] parsetexi @U argument checking
Date: Tue, 14 Jun 2016 19:03:23 +0000 (UTC)

Revision: 7227
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=7227
Author:   gavin
Date:     2016-06-14 19:03:22 +0000 (Tue, 14 Jun 2016)
Log Message:
-----------
parsetexi @U argument checking

Modified Paths:
--------------
    trunk/tp/parsetexi/convert.c
    trunk/tp/parsetexi/separator.c

Modified: trunk/tp/parsetexi/convert.c
===================================================================
--- trunk/tp/parsetexi/convert.c        2016-06-14 19:01:28 UTC (rev 7226)
+++ trunk/tp/parsetexi/convert.c        2016-06-14 19:03:22 UTC (rev 7227)
@@ -23,6 +23,7 @@
 #include "text.h"
 
 /* Stub for Texinfo::Convert::Text::convert */
+/* TODO: Don't use this function at all. */
 char *
 text_convert (ELEMENT *e)
 {

Modified: trunk/tp/parsetexi/separator.c
===================================================================
--- trunk/tp/parsetexi/separator.c      2016-06-14 19:01:28 UTC (rev 7226)
+++ trunk/tp/parsetexi/separator.c      2016-06-14 19:03:22 UTC (rev 7227)
@@ -372,6 +372,59 @@
           // if (!ignore_global_commands)
           line_error (text_convert (current));
         }
+      else if (closed_command == CM_U)
+        {
+          int i;
+          /* Find arg */
+          /* Should we use trim_spaces_comment_from_content instead? */
+          for (i = 0; i < current->contents.number; i++)
+            {
+              enum element_type t = current->contents.list[i]->type;
+              if (current->contents.list[i]->text.end > 0
+                  && t != ET_empty_line_after_command
+                  && t != ET_empty_spaces_after_command
+                  && t != ET_empty_spaces_before_argument
+                  && t != ET_empty_space_at_end_def_bracketed
+                  && t != ET_empty_spaces_after_close_brace)
+                break;
+            }
+          if (i == current->contents.number)
+            {
+              line_warn ("no argument specified for @U");
+            }
+          else
+            {
+              char *arg = current->contents.list[i]->text.text;
+              int n = strspn (arg, "0123456789ABCDEFabcdef");
+              if (arg[n])
+                {
+                  line_error ("non-hex digits in argument for @U: %s", arg);
+                }
+              else if (n < 4)
+                {
+                  line_warn
+                    ("fewer than four hex digits in argument for @U: %s", arg);
+                }
+              else
+                {
+                  int val;
+                  int ret = sscanf (arg, "%d", &val);
+                  if (ret != 1)
+                    {
+                      debug ("hex sscanf failed %s", arg);
+                      /* unknown error.  possibly argument is too large
+                         for an int. */
+                    }
+                  if (ret != 1 || val > 0x10FFF)
+                    {
+                      line_error
+                       ("argument for @U exceeds Unicode maximum 0x10FFFF: %s",
+                        arg);
+                    }
+                }
+
+            }
+        }
       else if (command_with_command_as_argument (current->parent->parent)
                && current->contents.number == 0)
         {




reply via email to

[Prev in Thread] Current Thread [Next in Thread]