[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[7597] xs_process_text
From: |
gavinsmith0123 |
Subject: |
[7597] xs_process_text |
Date: |
Sun, 1 Jan 2017 12:26:03 +0000 (UTC) |
Revision: 7597
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=7597
Author: gavin
Date: 2017-01-01 12:26:02 +0000 (Sun, 01 Jan 2017)
Log Message:
-----------
xs_process_text
Modified Paths:
--------------
trunk/ChangeLog
trunk/tp/Texinfo/MiscXS/MiscXS.xs
trunk/tp/Texinfo/MiscXS/miscxs.c
trunk/tp/Texinfo/MiscXS/miscxs.h
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2017-01-01 12:17:19 UTC (rev 7596)
+++ trunk/ChangeLog 2017-01-01 12:26:02 UTC (rev 7597)
@@ -1,3 +1,10 @@
+2017-01-01 Gavin Smith <address@hidden>
+
+ * tp/Texinfo/MiscXS/MiscXS.xs,
+ * tp/Texinfo/MiscXS/miscxs.c (xs_process_text): New function.
+ * tp/Texinfo/Convert/Plaintext.pm: Add a 'UNITCHECK' section to
+ use 'Texinfo::MiscXS::process_text' inside '_process_text' function.
+
2016-12-31 Gavin Smith <address@hidden>
* tp/Texinfo/MiscXS/miscxs.c (xs_abort_empty_line)
Modified: trunk/tp/Texinfo/MiscXS/MiscXS.xs
===================================================================
--- trunk/tp/Texinfo/MiscXS/MiscXS.xs 2017-01-01 12:17:19 UTC (rev 7596)
+++ trunk/tp/Texinfo/MiscXS/MiscXS.xs 2017-01-01 12:26:02 UTC (rev 7597)
@@ -53,6 +53,26 @@
SV *text_in
SV *
+xs_process_text (text_in)
+ SV *text_in
+ PREINIT:
+ char *text;
+ char *retval;
+ CODE:
+ /* Make sure the input is in UTF8. */
+ if (!SvUTF8 (text_in))
+ sv_utf8_upgrade (text_in);
+
+ text = SvPV_nolen (text_in);
+
+ retval = xs_process_text (text);
+
+ RETVAL = newSVpv (retval, 0);
+ SvUTF8_on (RETVAL);
+ OUTPUT:
+ RETVAL
+
+SV *
xs_unicode_text (text_in, ...)
SV *text_in
PREINIT:
Modified: trunk/tp/Texinfo/MiscXS/miscxs.c
===================================================================
--- trunk/tp/Texinfo/MiscXS/miscxs.c 2017-01-01 12:17:19 UTC (rev 7596)
+++ trunk/tp/Texinfo/MiscXS/miscxs.c 2017-01-01 12:26:02 UTC (rev 7597)
@@ -404,6 +404,57 @@
}
char *
+xs_process_text (char *text)
+{
+ char *new, *p, *q;
+
+ new = strdup (text);
+
+ p = q = new;
+ while (*p)
+ {
+ if (*p == '-' && p[1] == '-')
+ {
+ if (p[2] == '-')
+ {
+ *q = '-'; q[1] = '-';
+ p += 3; q += 2;
+ }
+ else
+ {
+ *q = '-';
+ p += 2; q += 1;
+ }
+ }
+ else if (*p == '\'' && p[1] == '\'')
+ {
+ *q = '"';
+ p += 2; q += 1;
+ }
+ else if (*p == '`')
+ {
+ if (p[1] == '`')
+ {
+ *q = '"';
+ p += 2; q += 1;
+ }
+ else
+ {
+ *q = '\'';
+ p += 1; q += 1;
+ }
+ }
+ else
+ {
+ *q++ = *p++;
+ }
+ }
+ *q = '\0';
+
+ return new;
+}
+
+char *
xs_unicode_text (char *text, int in_code)
{
char *p, *q;
Modified: trunk/tp/Texinfo/MiscXS/miscxs.h
===================================================================
--- trunk/tp/Texinfo/MiscXS/miscxs.h 2017-01-01 12:17:19 UTC (rev 7596)
+++ trunk/tp/Texinfo/MiscXS/miscxs.h 2017-01-01 12:26:02 UTC (rev 7597)
@@ -1,3 +1,4 @@
char *xs_unicode_text (char *, int);
+char *xs_process_text (char *text);
HV *xs_merge_text (HV *self, HV *current, SV *text_in);
int xs_abort_empty_line (HV *self, HV *current, SV *additional_text);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [7597] xs_process_text,
gavinsmith0123 <=