texinfo-commits
[Top][All Lists]
Advanced

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

[7595] use memcmp instead of strcmp


From: gavinsmith0123
Subject: [7595] use memcmp instead of strcmp
Date: Sun, 1 Jan 2017 11:41:59 +0000 (UTC)

Revision: 7595
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=7595
Author:   gavin
Date:     2017-01-01 11:41:59 +0000 (Sun, 01 Jan 2017)
Log Message:
-----------
use memcmp instead of strcmp

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/tp/Texinfo/MiscXS/miscxs.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog     2016-12-31 16:39:33 UTC (rev 7594)
+++ trunk/ChangeLog     2017-01-01 11:41:59 UTC (rev 7595)
@@ -1,3 +1,8 @@
+2017-01-01  Gavin Smith  <address@hidden>
+
+       * tp/Texinfo/MiscXS/miscxs.c (xs_merge_text): Use "memcmp" with 
+       length of string instead of "strcmp".
+
 2016-12-31  Gavin Smith  <address@hidden>
 
        * tp/Texinfo/MiscXS/miscxs.c (xs_abort_empty_line)

Modified: trunk/tp/Texinfo/MiscXS/miscxs.c
===================================================================
--- trunk/tp/Texinfo/MiscXS/miscxs.c    2016-12-31 16:39:33 UTC (rev 7594)
+++ trunk/tp/Texinfo/MiscXS/miscxs.c    2017-01-01 11:41:59 UTC (rev 7595)
@@ -49,6 +49,7 @@
   int contents_num;
   HV *last_elt;
   char *type;
+  int type_len;
   SV *existing_text_sv;
 
   dTHX;
@@ -84,15 +85,15 @@
   if (!svp)
     return 0;
 
-  type = SvPV_nolen (*svp);
+  type = SvPV (*svp, type_len);
   if (!type)
     return 0;
 
   /* Must be one of these types to continue. */
-  if (strcmp (type, "empty_line")
-       && strcmp (type, "empty_line_after_command")
-       && strcmp (type, "empty_spaces_before_argument")
-       && strcmp (type, "empty_spaces_after_close_brace"))
+  if (memcmp (type, "empty_line", type_len)
+       && memcmp (type, "empty_line_after_command", type_len)
+       && memcmp (type, "empty_spaces_before_argument", type_len)
+       && memcmp (type, "empty_spaces_after_close_brace", type_len))
     {
       return 0;
     }
@@ -183,6 +184,7 @@
   else if (!strcmp (type, "empty_line"))
     {
       char *current_type;
+      int len;
       AV *context_stack;
       SV *top_context_sv;
       char *top_context;
@@ -192,15 +194,15 @@
       if (!svp)
         current_type = 0;
       else
-        current_type = SvPV_nolen (*svp);
+        current_type = SvPV (*svp, len);
 
       /* "Types with paragraphs".  Remove the type unless we are inside
          one of these types. */
       if (current_type
-          && strcmp (current_type, "before_item")
-          && strcmp (current_type, "text_root")
-          && strcmp (current_type, "document_root")
-          && strcmp (current_type, "brace_command_context"))
+          && memcmp (current_type, "before_item", len)
+          && memcmp (current_type, "text_root", len)
+          && memcmp (current_type, "document_root", len)
+          && memcmp (current_type, "brace_command_context", len))
         goto delete_type;
 
       /* Check the context stack. */
@@ -215,16 +217,16 @@
       if (!svp)
         goto delete_type; /* shouldn't happen */
       top_context_sv = *svp;
-      top_context = SvPV_nolen (top_context_sv);
+      top_context = SvPV (top_context_sv, len);
 
       /* Change type to "empty_spaces_before_paragraph" unless we are in
          one of these contexts. */
-      if (strcmp (top_context, "math")
-          && strcmp (top_context, "menu")
-          && strcmp (top_context, "preformatted")
-          && strcmp (top_context, "rawpreformatted")
-          && strcmp (top_context, "def")
-          && strcmp (top_context, "inlineraw"))
+      if (memcmp (top_context, "math", len)
+          && memcmp (top_context, "menu", len)
+          && memcmp (top_context, "preformatted", len)
+          && memcmp (top_context, "rawpreformatted", len)
+          && memcmp (top_context, "def", len)
+          && memcmp (top_context, "inlineraw", len))
         {
           hv_store (last_elt, "type", strlen ("type"),
                     newSVpv ("empty_spaces_before_paragraph", 0), 0);
@@ -298,18 +300,20 @@
         {
           HV *last_elt;
           char *type = 0;
+          int type_len;
 
           last_elt = (HV *)
             SvRV (*av_fetch (contents_array, contents_num - 1, 0));
 
           svp = hv_fetch (last_elt, "type", strlen ("type"), 0);
           if (svp)
-            type = SvPV_nolen (*svp);
+            type = SvPV (*svp, type_len);
           if (type
-              && (!strcmp (type, "empty_line_after_command")
-                  || !strcmp (type, "empty_spaces_after_command")
-                  || !strcmp (type, "empty_spaces_before_argument")
-                  || !strcmp (type, "empty_spaces_after_close_brace")))
+              && (!memcmp (type, "empty_line_after_command", type_len)
+                  || !memcmp (type, "empty_spaces_after_command", type_len)
+                  || !memcmp (type, "empty_spaces_before_argument", type_len)
+                  || !memcmp (type, "empty_spaces_after_close_brace", 
+                              type_len)))
             {
               no_merge_with_following_text = 1;
             }




reply via email to

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