[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[7603] avoid using strndup
From: |
gavinsmith0123 |
Subject: |
[7603] avoid using strndup |
Date: |
Tue, 3 Jan 2017 10:36:58 +0000 (UTC) |
Revision: 7603
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=7603
Author: gavin
Date: 2017-01-03 10:36:58 +0000 (Tue, 03 Jan 2017)
Log Message:
-----------
avoid using strndup
Modified Paths:
--------------
trunk/ChangeLog
trunk/tp/Texinfo/MiscXS/miscxs.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2017-01-03 10:26:30 UTC (rev 7602)
+++ trunk/ChangeLog 2017-01-03 10:36:58 UTC (rev 7603)
@@ -1,5 +1,10 @@
2017-01-03 Gavin Smith <address@hidden>
+ * tp/Texinfo/MiscXS/miscxs.c (xs_parse_texi_regex): Use malloc
+ and memcpy instead of strndup for better portability.
+
+2017-01-03 Gavin Smith <address@hidden>
+
* tp/Texinfo/Convert/Plaintext.pm (_output_old): Remove unused
function.
Whole file: Get subroutine arguments by assigning from @_.
Modified: trunk/tp/Texinfo/MiscXS/miscxs.c
===================================================================
--- trunk/tp/Texinfo/MiscXS/miscxs.c 2017-01-03 10:26:30 UTC (rev 7602)
+++ trunk/tp/Texinfo/MiscXS/miscxs.c 2017-01-03 10:36:58 UTC (rev 7603)
@@ -584,7 +584,9 @@
q = text + 2;
while (isalnum (*q) || *q == '-' || *q == '_')
q++;
- *at_command = strndup (p, q - p);
+ *at_command = malloc (q - p + 1);
+ memcpy (*at_command, p, q - p);
+ (*at_command)[q - p] = '\0';
}
else
{
@@ -624,9 +626,13 @@
p = text;
p += strcspn (p, "{}@,:\t.\n\f");
if (p > text)
- *new_text = strndup (text, p - text);
+ {
+ *new_text = malloc (p - text + 1);
+ memcpy (*new_text, text, p - text);
+ (*new_text)[p - text] = '\0';
+ }
}
- }
+ }
return;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [7603] avoid using strndup,
gavinsmith0123 <=