texinfo-commits
[Top][All Lists]
Advanced

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

[7391] parsetexi documentlanguage


From: gavinsmith0123
Subject: [7391] parsetexi documentlanguage
Date: Mon, 19 Sep 2016 18:25:11 +0000 (UTC)

Revision: 7391
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=7391
Author:   gavin
Date:     2016-09-19 18:25:10 +0000 (Mon, 19 Sep 2016)
Log Message:
-----------
parsetexi documentlanguage

Modified Paths:
--------------
    trunk/tp/parsetexi/end_line.c
    trunk/tp/parsetexi/parser.c
    trunk/tp/parsetexi/parser.h

Modified: trunk/tp/parsetexi/end_line.c
===================================================================
--- trunk/tp/parsetexi/end_line.c       2016-09-19 17:13:00 UTC (rev 7390)
+++ trunk/tp/parsetexi/end_line.c       2016-09-19 18:25:10 UTC (rev 7391)
@@ -118,11 +118,11 @@
 
       /* Find trailing whitespace on line. */
       q = strchr (p, '\0');
-      while (strchr (whitespace_chars, *q))
+      while (strchr (whitespace_chars, q[-1]))
         q--;
 
       if (q >= p)
-        ADD_ARG(p, q - p + 1); /* value */
+        ADD_ARG(p, q - p); /* value */
       else
         ADD_ARG("", 0);
 
@@ -1561,13 +1561,62 @@
             }
           else if (current->cmd == CM_documentlanguage) // 3223
             {
+              char *p, *q;
+
+              /* Texinfo::Common::warn_unknown_language checks with
+                 tp/Texinfo/Documentlanguages.pm, which is an automatically
+                 generated list of official IANA language codes.  For now,
+                 just check if the language code looks right. */
+
+              p = text;
+              while (isalpha (*p))
+                p++;
+              if (*p == '_')
+                {
+                  q = p + 1;
+                  /* Language code should be of the form LL_CC, language code
+                     followed by country code. */
+                  while (isalpha (*p))
+                    p++;
+                  if (*p)
+                    {
+                      /* non-alphabetic char in country code */
+                      command_warn (current, "%s is not a valid region code",
+                                    q);
+                    }
+                }
+              else if (*p)
+                {
+                   /* non-alphabetic char in language code */
+                  command_warn (current, "%s is not a valid language code",
+                                text);
+                }
+
+              global_documentlanguage = text;
+              /* TODO: check customization variable */
             }
         }
       if (superfluous_arg)
         {
-          command_error (current, "bad argument to @%s", 
-                         command_name(current->cmd));
-          // TODO say what the bad argument is
+          char *texi_line, *p, *p1;
+          p = convert_to_texinfo (args_child_by_index(current, 0));
+
+          texi_line = p;
+          while (isspace (*texi_line))
+            texi_line++;
+
+          /* Trim leading and trailing whitespace. */
+          p1 = strchr (texi_line, '\0');
+          if (p1 > texi_line)
+            {
+              while (p1 > texi_line && isspace (p1[-1]))
+                p1--;
+              c = *p1;
+              *p1 = '\0';
+            }
+          command_error (current, "bad argument to @%s: %s", 
+                         command_name(current->cmd), texi_line);
+          free (p);
         }
     }
   else if (current->cmd == CM_node) /* 3235 */

Modified: trunk/tp/parsetexi/parser.c
===================================================================
--- trunk/tp/parsetexi/parser.c 2016-09-19 17:13:00 UTC (rev 7390)
+++ trunk/tp/parsetexi/parser.c 2016-09-19 18:25:10 UTC (rev 7391)
@@ -116,6 +116,7 @@
    for example document language and encoding. */
 GLOBAL_INFO global_info;
 char *global_clickstyle = "arrow";
+char *global_documentlanguage = "";
 
 enum kbd_enum global_kbdinputstyle = kbd_distinct;
 
@@ -124,6 +125,7 @@
 {
   global_clickstyle = "arrow";
   global_kbdinputstyle = kbd_distinct;
+  global_documentlanguage = "";
   memset (&global_info, 0, sizeof (global_info));
 }
 

Modified: trunk/tp/parsetexi/parser.h
===================================================================
--- trunk/tp/parsetexi/parser.h 2016-09-19 17:13:00 UTC (rev 7390)
+++ trunk/tp/parsetexi/parser.h 2016-09-19 18:25:10 UTC (rev 7391)
@@ -81,6 +81,7 @@
 
 extern GLOBAL_INFO global_info;
 extern char *global_clickstyle;
+extern char *global_documentlanguage;
 
 enum kbd_enum {kbd_none, kbd_code, kbd_example, kbd_distinct };
 extern enum kbd_enum global_kbdinputstyle;




reply via email to

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