pkgsrc-WIP-changes archive

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

yasr: Port ready to import to Pkgsrc.



Module Name:	pkgsrc-wip
Committed By:	adr <adr%sdf.org@localhost>
Pushed By:	adr
Date:		Sun Mar 10 15:24:34 2024 +0000
Changeset:	97efc7c8fe06677de222f76d420afc20f6748dcf

Modified Files:
	yasr/Makefile
	yasr/distinfo
	yasr/patches/patch-yasr_main.c
	yasr/patches/patch-yasr_tts.c
	yasr/patches/patch-yasr_yasr.h
Removed Files:
	yasr/patches/patch-yasr_yasr.conf

Log Message:
yasr: Port ready to import to Pkgsrc.

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=97efc7c8fe06677de222f76d420afc20f6748dcf

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 yasr/Makefile                     |  15 +-
 yasr/distinfo                     |   7 +-
 yasr/patches/patch-yasr_main.c    | 850 ++++++++++++++++++++++++++++++++++----
 yasr/patches/patch-yasr_tts.c     | 324 ++++++++++++++-
 yasr/patches/patch-yasr_yasr.conf |  23 --
 yasr/patches/patch-yasr_yasr.h    |  19 +-
 6 files changed, 1131 insertions(+), 107 deletions(-)

diffs:
diff --git a/yasr/Makefile b/yasr/Makefile
index 82f7e45535..7510d0d699 100644
--- a/yasr/Makefile
+++ b/yasr/Makefile
@@ -14,8 +14,19 @@ LICENSE=	gnu-gpl-v2
 USE_LANGUAGES=	c
 USE_TOOLS=	pkg-config msgfmt xgettext
 
-#REMOVE!!!!!!!!!!!!!!!
-CFLAGS+=	"-ggdb"
+# Replace bash with sh in configuration example
+SUBST_CLASSES+=		use-sh
+SUBST_STAGE.use-sh=	pre-configure
+SUBST_MESSAGE.use-sh=	Use sh instead of bash
+SUBST_FILES.use-sh=	yasr/yasr.conf
+SUBST_SED.use-sh=	-e 's,/bin/bash,/bin/sh,'
+
+# Fix eflite path in configuration example
+SUBST_CLASSES+=			fix-eflite
+SUBST_STAGE.fix-eflite=		pre-configure
+SUBST_MESSAGE.fix-eflite=	Fix eflite path
+SUBST_FILES.fix-eflite=		yasr/yasr.conf
+SUBST_SED.fix-eflite=		-e 's,/usr/local/bin/eflite,${PREFIX}/bin/eflite,'
 
 .include "../../devel/meson/build.mk"
 .include "../../audio/speech-dispatcher/buildlink3.mk"
diff --git a/yasr/distinfo b/yasr/distinfo
index 00d5c7c3f8..0fb4c4d716 100644
--- a/yasr/distinfo
+++ b/yasr/distinfo
@@ -4,7 +4,6 @@ BLAKE2s (yasr-0.0.0.144-f60db19350542e6f4b7d268a310b9f2b9f3076c0.tar.gz) = 72d9f
 SHA512 (yasr-0.0.0.144-f60db19350542e6f4b7d268a310b9f2b9f3076c0.tar.gz) = 1a97f4d18586e9e72a01b05b0c6240a7e346b44d920771d662a0cbf9cba26467732d5681f391938d01cf0bd9e269bf0879fd7fcbf48f9678b5eafa30cbecca63
 Size (yasr-0.0.0.144-f60db19350542e6f4b7d268a310b9f2b9f3076c0.tar.gz) = 99434 bytes
 SHA1 (patch-meson.build) = 81c27075691073e33799681441e4662275e62d3a
-SHA1 (patch-yasr_main.c) = a769cd70d9e0e727ad1038d12eee6e7813a91450
-SHA1 (patch-yasr_tts.c) = 8827f021dda2f2b07ec6810b5f2a43e43e72aa47
-SHA1 (patch-yasr_yasr.conf) = 73157a2dec79cb39050a4617af99e59349ca9531
-SHA1 (patch-yasr_yasr.h) = 68c15be283d0c21e94d0acf890cbea95634b5827
+SHA1 (patch-yasr_main.c) = 5e6493b9a995b3fb15b160569d21c893e99ed9d9
+SHA1 (patch-yasr_tts.c) = c7cd92e8530785e682d61f9423d4b796391fa453
+SHA1 (patch-yasr_yasr.h) = 8c1f5fdeb8c9f05e9145ee60983c707834c04b16
diff --git a/yasr/patches/patch-yasr_main.c b/yasr/patches/patch-yasr_main.c
index 9676602169..8c8d920408 100644
--- a/yasr/patches/patch-yasr_main.c
+++ b/yasr/patches/patch-yasr_main.c
@@ -1,30 +1,46 @@
 $NetBSD$
 
 Remove non-portable use of WCHAR_T in iconv code.
-Remove the enforcing of UTF-8
+Remove the enforcing of UTF-8 (but the code is expeting multibyte
+encodings or ASCII).
+Fix the reading of char after space using right cursor key.
+Use defined constants in buffer sizes when they are used elsewhere.
+Remove unused argument of gulp().
+Fix bug: buf[] used instead of kbuf[].
+Fix bug: the reading of master can be truncated even just getting one char at
+a time (bug in NetBSD's pty implementation?), the code has to take that
+into account.
+Simplify formatting now that we are there, but according to the rest of the code.
 
 --- yasr/main.c.orig	2023-04-08 21:22:57.000000000 +0000
 +++ yasr/main.c
-@@ -33,14 +33,14 @@
- #include <sys/types.h>
- #include <sys/wait.h>
- #include <langinfo.h>
--#include <iconv.h>
--iconv_t ih_inp;
- static int cpid;
+@@ -39,8 +39,10 @@ static int cpid;
  static int size, wsize;
  static int master, slave;
  char *conffile = NULL;
 -unsigned char buf[256];
 -wchar_t wide_buf[256];
-+#define BUF_MAX 256
-+#define WIDE_BUF_MAX 256
-+char buf[BUF_MAX];
-+wchar_t wide_buf[WIDE_BUF_MAX];
++#define BUF_SIZE 256
++#define WIDE_BUF_SIZE 256
++char buf[BUF_SIZE];
++wchar_t wide_buf[WIDE_BUF_SIZE];
  char usershell[OPT_STR_SIZE];
  static struct termios t;
  Win *win;
-@@ -307,23 +307,13 @@ is_separator (int ch)
+@@ -50,9 +52,10 @@ Tts tts;
+ Ui ui;
+ Uirev rev;
+ static int speaking = 1;
+-int kbuf[100];
++#define KBUF_SIZE 100
++int kbuf[KBUF_SIZE];
+ int kbuflen = 0;
+-static wchar_t okbuf[100];
++static wchar_t okbuf[KBUF_SIZE];
+ static int okbuflen = 0;
+ static int oldcr = 0, oldcc = 0, oldch = 0;
+ Voices voices;
+@@ -307,40 +310,22 @@ is_separator (int ch)
  static int
  getkey_buf ()
  {
@@ -50,37 +66,128 @@ Remove the enforcing of UTF-8
 +    return (int)ch;
    key = (int) buf[0];
    if (size > 1)
-   {
-@@ -355,7 +345,7 @@ getinput ()
+-  {
+     key = (key << 8) + buf[1];
+-  }
+   if (size > 2)
+-  {
+     key = (key << 8) + buf[2];
+-  }
+   if (size > 3)
+-  {
+     key = (key << 8) + buf[3];
+-  }
+   if (key >> 8 == 0x1b4f)
+-  {
+     key += 0x000c00;
+-  }
+ 
+   /* Convert high-bit meta keys to escape form */
+ #ifndef __linux__
+@@ -355,11 +340,9 @@ getinput ()
  {
    int key;
  
 -  size = read (0, buf, 255);
-+  size = read (0, buf, BUF_MAX);
++  size = read (0, buf, BUF_SIZE);
    if (size <= 0)
-   {
+-  {
      finish (0);
-@@ -533,41 +523,44 @@ oldgulp (unsigned char *buf, int *size, 
+-  }
+   key = getkey_buf ();
+   if (key == ui.disable)
+   {
+@@ -385,9 +368,7 @@ getinput ()
+ 
+   tts_silence ();
+   if (ui.silent == -1)
+-  {
+     ui.silent = 0;
+-  }
+   ui.silent = -ui.silent;
+   if (ui.meta)
+   {
+@@ -401,9 +382,7 @@ getinput ()
+     okbuflen = tts.oflag = 0;
+   }
+   if (!ui_keypress (key))
+-  {
+     (void) write (master, buf, size);
+-  }
+ }
+ 
+ static void
+@@ -418,9 +397,7 @@ wincpy (Win ** d, Win * s)
+   (*d)->cc = s->cc;
+   (*d)->mode = s->mode;
+   for (i = 0; i < s->rows; i++)
+-  {
+     (void) memcpy ((*d)->row[i], s->row[i], s->cols * CHARSIZE);
+-  }
+   (void) memcpy (&(*d)->savecp, &s->savecp, sizeof (Curpos));
+ }
+ 
+@@ -430,9 +407,7 @@ win_end (Win * win)
+   int i;
+ 
+   for (i = 0; i < win->rows; i++)
+-  {
+     free (win->row[i]);
+-  }
+   free (win->row);
+   free (win->tab);
+ }
+@@ -450,9 +425,7 @@ win_scrollup ()
+   tmpc = win->row[win_scrollmin];
+   (void) memset (tmpc, 0, win->cols * CHARSIZE);
+   for (i = win_scrollmin; i < win_scrollmax; i++)
+-  {
+     win->row[i] = win->row[i + 1];
+-  }
+   win->row[i] = tmpc;
+   win->cr--;
+ }
+@@ -472,9 +445,7 @@ win_lf ()
+     tmpc = win->row[win_scrollmin];
+     (void) memset (tmpc, 0, win->cols * CHARSIZE);
+     for (i = win_scrollmin; i < win_scrollmax; i++)
+-    {
+       win->row[i] = win->row[i + 1];
+-    }
+     win->row[i] = tmpc;
+     win->cr--;
+   }
+@@ -490,9 +461,7 @@ win_scrolldown ()
+   tmpc = win->row[win_scrollmax];
+   (void) memset (tmpc, 0, CHARSIZE * win->cols);
+   for (i = win_scrollmax - 1; i >= win->cr; i--)
+-  {
+     win->row[i + 1] = win->row[i];
+-  }
+   win->row[win->cr] = tmpc;
+ }
+ 
+@@ -533,41 +502,44 @@ oldgulp (unsigned char *buf, int *size, 
      if (ep)
      {
        n = buf + *size - *ep;
 -      (void) memmove (buf, *ep, 256 - n);
 -      *size = n + read (master, buf + n, 255 - n);
-+      (void) memmove (buf, *ep, BUF_MAX - n);
-+      *size = n + read (master, buf + n, BUF_MAX - 1  - n);
++      (void) memmove (buf, *ep, BUF_SIZE - n);
++      *size = n + read (master, buf + n, BUF_SIZE - 1  - n);
        buf[*size] = '\0';
        (void) write (1, buf + n, *size - n);
        *ep = buf;
        return ((char *) buf + n);
      }
 -    *size = read (master, buf, 255);
-+    *size = read (master, buf, BUF_MAX - 1);
++    *size = read (master, buf, BUF_SIZE - 1);
      buf[*size] = '\0';
      (void) write (1, buf, *size);
      return ((char *) buf);
    }
 -  *size += read (master, buf + *size, 255 - *size);
-+  *size += read (master, buf + *size, BUF_MAX - 1 - *size);
++  *size += read (master, buf + *size, BUF_SIZE - 1 - *size);
    buf[*size] = '\0';
    return ((char *) (buf + os));
  }
@@ -104,20 +211,20 @@ Remove the enforcing of UTF-8
 -  {
 -    memcpy (buf, bytes_left_start, bytes_left);
 +  int mbcharsize;
-+  char *bmb, tmpch[BUF_MAX];
-+  wchar_t *bwc, tmpwc[WIDE_BUF_MAX];
-+  size_t smb;
-+
++  char *mbb;
++  wchar_t *wcb, tmpb[WIDE_BUF_SIZE];
++  size_t mbs;
++  
 +  if (bytes_left){
-+    memcpy (tmpch, bytes_left_start, bytes_left);
-+    memcpy (buf, tmpch, bytes_left);
++    memcpy (tmpb, bytes_left_start, bytes_left);
++    memcpy (buf, tmpb, bytes_left);
    }
 -  size = read (master, buf + bytes_left, 255 - bytes_left - leave);
-+  size = read (master, buf + bytes_left, BUF_MAX - bytes_left - 1);
++  size = read (master, buf + bytes_left, BUF_SIZE - bytes_left - 1);
    if (size < 0)
    {
      perror ("read");
-@@ -577,32 +570,45 @@ read_buf (int leave)
+@@ -577,39 +549,43 @@ read_buf (int leave)
    size += bytes_left;
    buf[size] = 0;
    bytes_left = 0;
@@ -133,32 +240,25 @@ Remove the enforcing of UTF-8
 -
 -    iconv (ih_inp, NULL, NULL, NULL, NULL);
 -    if (iconv (ih_inp, &b1, &s1, &b2, &s2) == (size_t) -1)
-+  bmb = buf;
-+  bwc = wide_buf + leave;
++  mbb = buf;
++  wcb = wide_buf + leave;
 +  if (leave != 0 && leave < wsize){
-+    memcpy (tmpwc, wide_buf + wsize - leave, sizeof (wchar_t) * leave);
-+    memcpy (wide_buf, tmpwc, sizeof (wchar_t) * leave);
++    memcpy (tmpb, wide_buf + wsize - leave, sizeof (wchar_t) * leave);
++    memcpy (wide_buf, tmpb, sizeof (wchar_t) * leave);
 +  }
-+  smb = size;
-+  wsize = 0;
-+  while (smb > 0 && wsize < (WIDE_BUF_MAX - 1))
++  mbs = size;
++  wsize = leave;
++  while (mbs > 0 && wsize < (WIDE_BUF_SIZE - 1))
 +  {
-+    mbcharsize = mbtowc (bwc, bmb, smb);
-+    if (mbcharsize == 0) /* it reached buf[size] */
-+    {
-+      bytes_left = 0;
-+      bytes_left_start = NULL;
-+      wsize = bwc - wide_buf;
-+      wide_buf[wsize] = 0;
-+      return;
-+    }
-+    if (mbcharsize == -1)
++    mbcharsize = mbrtowc (wcb, mbb, mbs, NULL);
++    /* '\0's will not be copyed to wide_buf */
++    if (mbcharsize <= 0)
      {
 -      if (errno == EINVAL)	/* incomplete sequence at end of buffer */
-+      if (errno == EILSEQ)	/* incomplete sequence at end of buffer */
-       {
+-      {
++      if (mbcharsize == (size_t)-2)	/* incomplete sequence at end of buffer */
  	break;
-       }
+-      }
        /* invalid multibyte sequence - should we ignore or insert
           some character meaning 'invalid'? */
 -      b1++;
@@ -168,63 +268,570 @@ Remove the enforcing of UTF-8
 -  bytes_left = s1;
 -  bytes_left_start = b1;
 -  wsize = (wchar_t *) b2 - wide_buf;
-+      bmb++;
-+      smb--;
+-  wide_buf[wsize] = 0;
++      mbb++;
++      mbs--;
 +      continue;
 +    }
-+    bwc++;
-+    bmb += mbcharsize;
-+    smb -= mbcharsize;
-+    wsize = bwc - wide_buf;
++    wcb++;
++    wsize++;
++    mbb += mbcharsize;
++    mbs -= mbcharsize;
 +  }
-+  bytes_left = smb;
-+  bytes_left_start = bmb;
-+  wsize = bwc - wide_buf;
-   wide_buf[wsize] = 0;
++  bytes_left = mbs;
++  bytes_left_start = mbb;
++  wide_buf[wsize] = L'\0';
+ }
+ 
+ static wchar_t *
+-gulp (wchar_t *cp, wchar_t **ep)
++gulp (wchar_t **ep)
+ {
+   int leave;
++
+   if (!ep)
+     leave = 0;
+   else
+@@ -619,7 +595,7 @@ gulp (wchar_t *cp, wchar_t **ep)
+   read_buf (leave);
+   if (ep)
+     *ep = wide_buf;
+-  return wide_buf;
++  return wide_buf + leave;
+ }
+ 
+ static void
+@@ -627,12 +603,10 @@ kbsay ()
+ {
+   if (!ui.kbsay)
+     return;
+-  if (buf[0] == 8 || kbuf[0] == 127)
++  if (kbuf[0] == 8 || kbuf[0] == 127)
+   {
+     if ((ui.kbsay == 2) && (okbuflen != 0))
+-    {
+       okbuf[--okbuflen] = 0;
+-    }
+ 
+     /*tts_say(_("back")); */
+     return;
+@@ -644,10 +618,8 @@ kbsay ()
+   }
+ 
+   /* ui.kbsay == 2 -- handle word echo */
+-  if (okbuflen < sizeof (kbuf) - 1 && is_char (kbuf[0]))
+-  {
++  if (okbuflen < KBUF_SIZE - 1 && is_char (kbuf[0]))
+     okbuf[okbuflen++] = kbuf[0];
+-  }
+ }
+ 
+ #define MIN(a, b) ((a)>(b)? (b): (a))
+@@ -656,9 +628,7 @@ strwtol (wchar_t **p)
+ {
+   long t = 0;
+   while (iswdigit (**p))
+-  {
+     t = 10 * t + *(*p)++ - '0';
+-  }
+   return t;
+ }
+ 
+@@ -671,24 +641,33 @@ win_csi (wchar_t **pp)
+   int i;
+   int x;
+ 
++  /* last gulp could be just 1 char... */
++  
++  if (!**pp)
++  {
++    if (!gulp (NULL))
++      return;
++    *pp = wide_buf;
++  }
++
+   p = *pp;
++  
+   if (*p == '[')
+     p++;
++  
++  if (!*p && !(p = gulp (pp)))
++    return;
+   if (*p == '?')
+     p++;
+   while (!*p || iswdigit ((int) *p) || *p == ';')
+   {
+     if (!*p)
+     {
+-      if (!(p = gulp (p, pp)))
+-      {
++      if (!(p = gulp (pp)))
+ 	return;
+-      }
+     }
+     else
+-    {
+       p++;
+-    }
+   }
+   p = *pp;
+   if (*p == '[')
+@@ -697,9 +676,7 @@ win_csi (wchar_t **pp)
+     p++;
+   }
+   if (*p == '?')
+-  {
+     p++;
+-  }
+   (void) memset (&parm, 0, sizeof (int) * 16);
+   while (numparms < 16 && (*p == ';' || iswdigit ((int) *p)))
+   {
+@@ -709,12 +686,10 @@ win_csi (wchar_t **pp)
+     else
+       break;			/* TODO: is this redundant? */
+   }
+-
+   *pp = p + 1;
+   if (ignore)
+-  {
+     return;
+-  }
++
+   switch (*p)
+   {
+   case '@':			/* insert characters */
+@@ -727,9 +702,7 @@ win_csi (wchar_t **pp)
+   case 'A':			/* move up */
+     win->cr -= PARM1;
+     if (win->cr < 0)
+-    {
+       win->cr = 0;
+-    }
+     break;
+ 
+   case 'B':			/* move down */
+@@ -780,24 +753,18 @@ win_csi (wchar_t **pp)
+       (void) memset (win->row[win->cr] + win->cc, 0,
+ 		     CHARSIZE * (win->cols - win->cc));
+       for (i = win->cr + 1; i < win->rows; i++)
+-      {
+ 	(void) memset (win->row[i], 0, win->cols * CHARSIZE);
+-      }
+       break;
+ 
+     case 1:			/* erase from start to cursor */
+       (void) memset (win->row[win->cr], 0, win->cc);
+       for (i = 0; i < win->cr; i++)
+-      {
+ 	(void) memset (win->row[i], 0, win->cols * CHARSIZE);
+-      }
+       break;
+ 
+     case 2:			/* erase whole screen */
+       for (i = 0; i < win->rows; i++)
+-      {
+ 	(void) memset (win->row[i], 0, win->cols * CHARSIZE);
+-      }
+       break;
+     }
+     break;
+@@ -823,29 +790,19 @@ win_csi (wchar_t **pp)
+   case 'L':			/* insert rows */
+     x = MIN (PARM1, win_scrollmax - win->cr);
+     for (i = win_scrollmax; i >= win->cr + x; i--)
+-    {
+       (void) memcpy (win->row[i], win->row[i - x], win->cols * CHARSIZE);
+-    }
+     for (i = win->cr; i < win->cr + x; i++)
+-    {
+       (void) memset (win->row[i], 0, win->cols * CHARSIZE);
+-    }
+     break;
+ 
+   case 'M':
+     x = MIN (PARM1, win_scrollmax - win->cr);
+     if (x + win->cr > win_scrollmax)
+-    {
+       x = win_scrollmax - win->cr;
+-    }
+     for (i = win->cr; i <= win_scrollmax - x; i++)
+-    {
+       (void) memcpy (win->row[i], win->row[i + x], win->cols * CHARSIZE);
+-    }
+     for (i = win_scrollmax - x + 1; i <= win_scrollmax; i++)
+-    {
+       (void) memset (win->row[i], 0, win->cols * CHARSIZE);
+-    }
+     break;
+ 
+   case 'P':			/* delete characters */
+@@ -858,16 +815,12 @@ win_csi (wchar_t **pp)
+ 
+   case 'S':			/* Scroll up */
+     for (i = 0; i < PARM1; i++)
+-    {
+       win_scrollup ();
+-    }
+     break;
+ 
+   case 'T':			/* Scroll down */
+     for (i = 0; i < PARM1; i++)
+-    {
+       win_scrolldown ();;
+-    }
+     break;
+ 
+   case 'X':			/* Erase characters */
+@@ -884,9 +837,7 @@ win_csi (wchar_t **pp)
+     {
+     case 3:
+       for (i = 0; i < win->cols; i++)
+-      {
+ 	win->tab[i] = 0;
+-      }
+       break;
+ 
+     case 0:
+@@ -956,13 +907,9 @@ win_csi (wchar_t **pp)
+   }
+ 
+   if (win->cr >= win->rows)
+-  {
+     win->cr = win->rows - 1;
+-  }
+   else if (win->cr < 0)
+-  {
+     win->cr = 0;
+-  }
+   if (win->cc >= win->cols - 1)
+     win->cc = win->cols - 1;
+   else if (win->cc < 0)
+@@ -979,20 +926,14 @@ win_addchr (wchar_t ch, int tflag)
+     win->carry++;
+   }
+   if (win->mode & 0x08)
+-  {
+     (void) memmove (win->row[win->cr] + win->cc + 1,
+ 		    win->row[win->cr] + win->cc,
+ 		    (win->cols - win->cc - 1) * CHARSIZE);
+-  }
+   win->row[win->cr][win->cc].attr = win->attr;
+   win->row[win->cr][win->cc++].wchar = ch;
+   if (tflag)
+-  {
+     if (ui.silent != 1)
+-    {
+       tts_addchr (ch);
+-    }
+-  }
+ }
+ 
+ wchar_t
+@@ -1012,12 +953,8 @@ bol (int cr, int cc)
+ 
+   rptr = win->row[cr];
+   for (i = 0; i < cc; i++)
+-  {
+     if (y_isblank (rptr[i].wchar))
+-    {
+       return (0);
+-    }
+-  }
+ 
+   return (1);
+ }
+@@ -1032,12 +969,8 @@ eol (int cr, int cc)
+ 
+   rptr = win->row[cr];
+   for (i = cc + 1; i < win->cols; i++)
+-  {
+     if (y_isblank (rptr[i].wchar))
+-    {
+       return (0);
+-    }
+-  }
+ 
+   return (1);
+ }
+@@ -1053,16 +986,10 @@ firstword (int cr, int cc)
+   rptr = win->row[cr];
+   i = cc;
+   while (i && !y_isblank (rptr[i].wchar))
+-  {
+     i--;
+-  }
+   for (; i; i--)
+-  {
+     if (!y_isblank (rptr[i].wchar))
+-    {
+       return (0);
+-    }
+-  }
+ 
+   return (1);
+ }
+@@ -1077,20 +1004,12 @@ lastword (int cr, int cc)
+ 
+   rptr = win->row[cr];
+   if (y_isblank (rptr[i].wchar))
+-  {
+     i++;
+-  }
+   while (i < win->cols && !y_isblank (rptr[i].wchar))
+-  {
+     i++;
+-  }
+   while (i < win->cols)
+-  {
+     if (!y_isblank (rptr[i++].wchar))
+-    {
+       return (0);
+-    }
+-  }
+ 
+   return (1);
  }
+@@ -1105,14 +1024,13 @@ getoutput ()
+   static int stathit = 0, oldoflag = 0;
  
-@@ -1108,7 +1114,7 @@ getoutput ()
+   read_buf (0);
++
  #ifdef TERMTEST
    (void) printf ("size=%d buf=%s\n", size, buf);
  #endif
 -
 +  
    if (!size)
-   {
+-  {
      finish (0);
-@@ -1253,8 +1259,9 @@ getoutput ()
+-  }
+   p = wide_buf;
+ 
+   while (p - wide_buf < wsize)
+@@ -1126,6 +1044,7 @@ getoutput ()
+     case 8:
+       if (win->cc)
+ 	win->cc--;
++
+       else if (win->carry && win->cr)
+       {
+ 	win->cr--;
+@@ -1138,9 +1057,7 @@ getoutput ()
+ 	ui_saychar (win->cr, win->cc);
+       }
+       if (tts.outlen)
+-      {
+ 	tts.outlen--;
+-      }
+       break;
+ 
+     case 9:
+@@ -1153,9 +1070,7 @@ getoutput ()
+ 	}
+       }
+       if (i == win->cols)
+-      {
+ 	win->cc = i - 1;
+-      }
+       break;
+ 
+     case 10:
+@@ -1173,15 +1088,13 @@ getoutput ()
+       break;			/* may need to change in the future */
+ 
+     case 27:
+-      if (!*p && !(p = gulp (p, NULL)))
+-      {
++      if (!*p && !(p = gulp (NULL)))
+ 	return;
+-      }
+       switch (*p++)
+       {
+       case 'D':
+ 	win_lf ();
+-	break;
++        break;
+       case 'E':
+ 	break;			/* FIXME -- new line */
+       case 'H':
+@@ -1212,13 +1125,9 @@ getoutput ()
+       if (special)
+       {
+ 	if (ch == '<')
+-	{
+ 	  speaking = 0;		/* hack for medievia.com */
+-	}
+ 	else if (ch == '>')
+-	{
+ 	  speaking = 1;
+-	}
+       }
+ #endif
+       if (ch == kbuf[0] && win->cr == oldcr && win->cc == oldcc && kbuflen)
+@@ -1229,19 +1138,13 @@ getoutput ()
+ 	(void) memmove (kbuf, kbuf + 1, (--kbuflen) * sizeof (int));
+       }
+       else
+-      {
+ 	win_addchr (ch, speaking && (!special || !win->cr));
+-      }
+       chr = 1;
+     }
+     if (!chr && ch != 8 && (stathit == 0 || ch < '0' || ch > '9'))
+-    {
+       tts_flush ();
+-    }
+     else
+-    {
+       chr = 0;
+-    }
+     if ((!win->cc && win->cr > win->rows - 3) || win->cr == win->rows - 1)
+     {
+       stathit = win->cr;
+@@ -1253,10 +1156,17 @@ getoutput ()
        tts.oflag = oldoflag;
      }
    }
 -  if (ch == 13 || ch == 10 || ch == 32)
--  {
-+
-+
-+  if (ch == 13 || ch == 10){
-     tts_flush ();
++  /* If last key was cursor left or cursor right just say char at cursor */
++  if (kbuf[0] == 0x1b5b43 || kbuf[0] == 0x1b5b44)
+   {
+-    tts_flush ();
++    ui_saychar (win->cr, win->cc);
++    oldcr = win->cr;
++    oldcc = win->cc;
++    oldch = win->row[win->cr][win->cc].wchar;
++    return;
    }
++  if (ch == 13 || ch == 10 || ch == 32)
++    tts_flush ();
    if (size > 1)
-@@ -1264,10 +1271,6 @@ getoutput ()
-     else
+   {
+     if (!readable (master, 0))
+@@ -1265,9 +1175,7 @@ getoutput ()
        return;
    }
--  else if (ch == 32 || ch == 13)
+   else if (ch == 32 || ch == 13)
 -  {
--    tts_flush ();
+     tts_flush ();
 -  }
    if (tts.oflag || kbuf[0] == 13 || kbuf[0] == 3 || ui.silent)
    {
      tts.oflag = stathit = 0;
-@@ -1288,7 +1291,7 @@ getoutput ()
+@@ -1288,25 +1196,18 @@ getoutput ()
      case 1:			/* cursor moved right one character */
        if ((realchar (win->row[win->cr][win->cc - 1].wchar) == kbuf[0] &&
  	   realchar (oldch) != kbuf[0]) ||
 -	  ((y_isblank (oldch) && kbuf[0] == 32)))
+-      {
 +		  ((y_isblank (oldch) && kbuf[0] == 32)))
+ 	break;
+-      }
+-      if (kbuf[0] == 0x1b5b43 ||
+-	  ((ui.curtrack == 2) && (ui.kbsay != 2 || is_separator (kbuf[0]))))
+-      {
++      if (ui.curtrack == 2 && (ui.kbsay != 2 || is_separator (kbuf[0])))
+ 	ui_saychar (win->cr, win->cc);
+-      }
+       break;
+ 
+     case 0:
+       break;
+ 
+     case -1:
+-      if (kbuf[0] == 0x1b5b44 || ui.curtrack == 2)
+-      {
++      if (ui.curtrack == 2)
+ 	ui_saychar (win->cr, win->cc);
+-      }
+       break;
+ 
+     default:
+@@ -1315,18 +1216,11 @@ getoutput ()
+ 	if (eol (win->cr, win->cc))
+ 	  ui_saychar (win->cr, win->cc);
+ 	else
+-	{
+ 	  ui_sayword (win->cr, cblank (win->cr, win->cc) ?
+ 		      win->cc + 1 : win->cc);
+-	}
+       }
+     }
+   }
+-  else if ((kbuf[0] == 0x1b5b43 && bol (win->cr, win->cc)) ||
+-	   (kbuf[0] == 0x1b5b44 && eol (win->cr, win->cc)))
+-  {
+-    ui_saychar (win->cr, win->cc);
+-  }
+   else
+   {
+     switch (win->cr - oldcr)
+@@ -1337,24 +1231,18 @@ getoutput ()
+ 	ui_sayline (win->cr, 1);
+ 	break;
+       }
+-      if (win->cc == 0 && (oldcr == win->cols - 1 || kbuf[0] == 0x1b5b43))
++      if (win->cc == 0 && oldcr == win->cols - 1)
        {
+ 	ui_saychar (win->cr, win->cc);
+ 	break;
+       }
+       if (ui.curtrack < 2)
+-      {
  	break;
+-      }
+       if (win->cc && bol (win->cr, win->cc) && lastword (oldcr, oldcc)
+ 	  && oldcc)
+-      {
+ 	ui_sayword (win->cr, win->cc);
+-      }
+       else
+-      {
+ 	ui_sayline (win->cr, 1);
+-      }
+       break;
+     case -1:			/* cursor moved up a line */
+       if (kbuf[0] == 0x1b5b41)
+@@ -1364,17 +1252,13 @@ getoutput ()
        }
-@@ -1470,17 +1473,6 @@ main (int argc, char *argv[])
+       if (ui.curtrack < 2)
+ 	break;
+-      if (win->cc == win->cols - 1 && (oldcr == 0 || kbuf[0] == 0x1b5b44))
+-      {
++      if (win->cc == win->cols - 1 && oldcr == 0)
+ 	ui_saychar (win->cr, win->cc);
+-      }
+       else if (lastword (win->cr, win->cc) &&
+ 	       !firstword (win->cr, win->cc) &&
+ 	       (!win->cc || cblank (win->cr, win->cc - 1)) &&
+ 	       firstword (oldcr, oldcc))
+-      {
+ 	ui_sayword (win->cr, win->cc);
+-      }
+       else
+ 	ui_sayline (win->cr, 1);
+       break;
+@@ -1429,18 +1313,14 @@ parent ()
+       }
+     }
+     if (FD_ISSET (0, &rf))
+-    {
+       getinput ();
+-    }
+     if (FD_ISSET (master, &rf))
+     {
+       getoutput ();
+-      kbuflen = 0;
++      kbuf[0] = kbuflen = 0;
+     }
+     if (FD_ISSET (tts.fd, &rf))
+-    {
+       get_tts_input ();
+-    }
+   }
+ }
+ 
+@@ -1470,25 +1350,12 @@ main (int argc, char *argv[])
    bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
    textdomain (GETTEXT_PACKAGE);
    strcpy (charmap, nl_langinfo (CODESET));
@@ -242,3 +849,98 @@ Remove the enforcing of UTF-8
  #endif
  
    if (argv[0][0] == '-')
+     shell = 1;
+   if (isatty (0))
+-  {
+     (void) ioctl (0, TIOCGWINSZ, &winsz);
+-  }
+   if (!winsz.ws_row)
+   {
+     winsz.ws_row = 25;
+@@ -1529,9 +1396,7 @@ main (int argc, char *argv[])
+     }
+   }
+   if (argv[optind])
+-  {
+     subprog = argv + optind;
+-  }
+   readconf ();
+ 
+ #if 0				/* this doesn't work */
+@@ -1539,9 +1404,7 @@ main (int argc, char *argv[])
+   {
+     cp = usershell + strlen (usershell) - 1;
+     while (*cp && *cp != '/')
+-    {
+       cp--;
+-    }
+     cp++;
+     argv[0] = cp;
+     (void) execv (usershell, argv);
+@@ -1620,9 +1483,7 @@ w_speak (wchar_t *ibuf, int len)
+     {
+       olen -= nc;
+       if (olen)
+-      {
+ 	tts_out_w (wstart, olen);
+-      }
+       olen = 0;
+       while (i < len1 && ibuf[i + 1] == lc)
+       {
+@@ -1641,22 +1502,16 @@ w_speak (wchar_t *ibuf, int len)
+ 	wstart = ibuf + i;
+       olen++;
+       if (ibuf[i] != lc)
+-      {
+ 	nc = 0;
+-      }
+       if (!iswalnum (ibuf[i]) &&
+ 	  ibuf[i] != 32 && ibuf[i] != '=' && ibuf[i] >= 0)
+-      {
+ 	lc = ibuf[i];
+-      }
+       else
+ 	lc = 0;
+     }
+   }
+   if (olen)
+-  {
+     tts_out_w (wstart, olen);
+-  }
+ }
+ 
+ #if 0
+@@ -1678,9 +1533,7 @@ speak (char *ibuf, int len)
+     {
+       olen -= nc;
+       if (olen)
+-      {
+ 	tts_out ((unsigned char *) obuf, olen);
+-      }
+       olen = 0;
+       while (i < len1 && ibuf[i + 1] == lc)
+       {
+@@ -1697,14 +1550,10 @@ speak (char *ibuf, int len)
+     {
+       obuf[olen++] = ibuf[i];
+       if (ibuf[i] != lc)
+-      {
+ 	nc = 0;
+-      }
+       if (!isalpha ((int) ibuf[i]) && !isdigit ((int) ibuf[i]) &&
+ 	  ibuf[i] != 32 && ibuf[i] != '=' && ibuf[i] >= 0)
+-      {
+ 	lc = ibuf[i];
+-      }
+       else
+ 	lc = 0;
+       if (olen > 250 && !nc)
+@@ -1715,8 +1564,6 @@ speak (char *ibuf, int len)
+     }
+   }
+   if (olen)
+-  {
+     tts_out ((unsigned char *) obuf, olen);
+-  }
+ }
+ #endif
diff --git a/yasr/patches/patch-yasr_tts.c b/yasr/patches/patch-yasr_tts.c
index c03fc70e02..e55d54fc2f 100644
--- a/yasr/patches/patch-yasr_tts.c
+++ b/yasr/patches/patch-yasr_tts.c
@@ -5,7 +5,162 @@ Fix comment's alignment.
 
 --- yasr/tts.c.orig	2023-04-08 21:22:57.000000000 +0000
 +++ yasr/tts.c
-@@ -412,7 +412,6 @@ tts_out_w (wchar_t *buf, int len)
+@@ -53,7 +53,8 @@ static Tts_synth synth[] = {
+   {NULL, NULL, "CANCEL SELF\r\n", NULL, NULL, FALSE, "", "quit\r\n"},
+ };
+ 
+-static char *dict[256];
++#define DICT_SIZE 256
++static char *dict[DICT_SIZE];
+ static int tts_flushed = 0;
+ 
+ 
+@@ -67,9 +68,7 @@ dict_read (char *buf)
+   {
+     c = strtol (buf, &p, 0);
+     if (c > 255)
+-    {
+       return (1);
+-    }
+     p++;
+   }
+   else
+@@ -88,20 +87,14 @@ dict_write (FILE * fp)
+ {
+   int i;
+ 
+-  for (i = 0; i < 256; i++)
+-  {
++  for (i = 0; i < DICT_SIZE; i++)
+     if (dict[i])
+     {
+       if (i > 31 && i < 127 && i != 35 && i != 91)
+-      {
+ 	(void) fprintf (fp, "%c=%s\n", i, dict[i]);
+-      }
+       else
+-      {
+ 	(void) fprintf (fp, "0x%.2x=%s\n", i, dict[i]);
+-      }
+     }
+-  }
+ }
+ 
+ 
+@@ -111,9 +104,7 @@ void
+ tts_flush ()
+ {
+   if (tts.outlen)
+-  {
+     w_speak (tts.buf, tts.outlen);
+-  }
+ 
+   tts.outlen = 0;
+ 
+@@ -128,9 +119,7 @@ tts_wait (int usecs)
+   if (usecs != -1 && !readable (tts.fd, usecs))
+     return;
+   while (readable (tts.fd, 0))
+-  {
+     read (tts.fd, buf, sizeof (buf));
+-  }
+ }
+ #endif
+ 
+@@ -140,9 +129,7 @@ tts_silence ()
+   char tmp[1] = { 0 };
+ 
+   if (tts_flushed)
+-  {
+     return;
+-  }
+   tts.obufhead = tts.obuftail = tts.flood = 0;
+ #ifdef ENABLE_SPEECHD
+   if (tts.synth == TTS_SPEECHD)
+@@ -200,17 +187,13 @@ tts_obufout (int x)
+   int oldoflag;
+ 
+   if (!tts.flood)
+-  {
+     opt_queue_empty (2);
+-  }
+   oldoflag = tts.oflag;
+   while (tts.obufhead < tts.obuftail)
+   {
+     len = strlen (tts.obuf + tts.obufhead);
+     if (len > 1024)
+-    {
+       len = 1024;
+-    }
+     len2 = write (tts.fd, tts.obuf + tts.obufhead, len);
+ #ifdef TTSLOG
+     (void) write (ofd, tts.obuf + tts.obufhead, len2);
+@@ -225,9 +208,7 @@ tts_obufout (int x)
+       return;
+     }
+     while (tts.obufhead < tts.obuftail && !tts.obuf[tts.obufhead])
+-    {
+       tts.obufhead++;
+-    }
+   }
+   tts.flood = 0;
+   tts.oflag = oldoflag;
+@@ -242,9 +223,7 @@ tts_addbuf (char *buf, int len, int len2
+ 
+   tts.flood = 1;
+   if (len2 == -1)
+-  {
+     ptr = buf;
+-  }
+   else
+   {
+     ptr = buf + len2;
+@@ -258,9 +237,7 @@ tts_addbuf (char *buf, int len, int len2
+       tts.obuf = realloc (tts.obuf, tts.obuflen);
+     }
+     else
+-    {
+       tts_obufpack ();
+-    }
+   }
+   (void) memcpy (tts.obuf + tts.obuftail, ptr, len);
+   tts.obuftail += len;
+@@ -276,13 +253,9 @@ tts_send (char *buf, int len)
+   int len2;
+ 
+   if (!len)
+-  {
+     return;
+-  }
+   if (tts_flushed)
+-  {
+     tts_flushed = 0;
+-  }
+ #ifndef SILENT
+   if (!tts.flood)
+   {
+@@ -293,9 +266,7 @@ tts_send (char *buf, int len)
+ #endif
+ 
+     if (len2 < len)
+-    {
+       tts_addbuf (buf, len, len2);
+-    }
+   }
+   else
+     tts_addbuf (buf, len, 0);
+@@ -315,10 +286,8 @@ unspeakable (unsigned char ch)
+   if (ch < 32)
+     return 1;
+   while (*p)
+-  {
+     if (*p++ == ch)
+       return 1;
+-  }
+   return (0);
+ }
+ 
+@@ -412,7 +381,6 @@ tts_out_w (wchar_t *buf, int len)
    char *p;
    int i;
    int xml = 0;			/* what's this? */
@@ -13,7 +168,47 @@ Fix comment's alignment.
    if (!len)
      return;
    if (tts.synth == TTS_SPEECHD)
-@@ -674,21 +673,22 @@ tts_saychar (wchar_t ch)
+@@ -420,9 +388,7 @@ tts_out_w (wchar_t *buf, int len)
+     while (len > 0)
+     {
+       if (*buf < 0x80)
+-      {
+ 	obuf[obo++] = *buf;
+-      }
+       else if (*buf < 0x800)
+       {
+ 	obuf[obo++] = 0xc0 | (*buf >> 6);
+@@ -514,9 +480,7 @@ tts_out_w (wchar_t *buf, int len)
+       }
+     }
+     else
+-    {
+       obuf[obo++] = *p;
+-    }
+     p++;
+   }
+   tts_send (obuf, obo);
+@@ -619,9 +583,7 @@ tts_out (unsigned char *buf, int len)
+       }
+     }
+     else
+-    {
+       obuf[obo++] = *p;
+-    }
+     p++;
+   }
+   tts_send (obuf, obo);
+@@ -656,9 +618,7 @@ tts_saychar (wchar_t ch)
+   char buf[8];
+ 
+   if (!ch)
+-  {
+     ch = 32;
+-  }
+   if (tts.synth == TTS_SPEECHD)
+   {
+ #ifdef ENABLE_SPEECHD
+@@ -674,21 +634,22 @@ tts_saychar (wchar_t ch)
        tts_printf_ll ("CHAR %c\r\n", ch);
  #else
      else if (ch < 0x80)
@@ -43,7 +238,7 @@ Fix comment's alignment.
        iconv (cd, &cin, &l1, &cout, &l2);
        iconv_close (cd);
        *cout = 0;
-@@ -704,7 +704,8 @@ tts_saychar (wchar_t ch)
+@@ -704,7 +665,8 @@ tts_saychar (wchar_t ch)
      return;
    }
    if (!synth[tts.synth].charoff)
@@ -53,3 +248,126 @@ Fix comment's alignment.
      (void) sprintf (ttsbuf, synth[tts.synth].charon, ch);
      tts_send (ttsbuf, strlen (ttsbuf));
      return;
+@@ -725,9 +687,7 @@ tts_saychar (wchar_t ch)
+   ttsbuf[0] = ch;
+   tts_send (ttsbuf, 1);
+   if (synth[tts.synth].saychar_needs_flush)
+-  {
+     tts_send (synth[tts.synth].say + 2, strlen (synth[tts.synth].say) - 2);
+-  }
+   while (j)
+   {
+     j -= 2;
+@@ -887,9 +847,7 @@ tts_init (int first_call)
+ #ifdef TTSLOG
+   ofd = open ("tts.log", O_WRONLY | O_CREAT);
+   if (ofd == -1)
+-  {
+     perror ("open");
+-  }
+ #endif
+ 
+ #ifdef ENABLE_SPEECHD
+@@ -920,17 +878,11 @@ tts_init (int first_call)
+   else if (tts.port[0] != '|')
+   {
+     if (tts.synth == TTS_DECTALK)
+-    {
+       mode = O_NOCTTY | O_RDWR;
+-    }
+     else if (tts.synth == TTS_EMACSPEAK_SERVER)
+-    {
+       mode = O_WRONLY;
+-    }
+     if (first_call)
+-    {
+       tts.fd = open (portname, mode);
+-    }
+     if (tts.fd == -1)
+     {
+       perror ("tts");
+@@ -958,21 +910,15 @@ tts_init (int first_call)
+     (void) strcpy (buf, tts.port + 1);
+     arg[i = 0] = strtok (buf, " ");
+     while (i < 7)
+-    {
+       if (!(arg[++i] = strtok (NULL, " ")))
+-      {
+ 	break;
+-      }
+-    }
+ 
+     if (first_call)
+-    {
+       if (openpty (&tts.fd, &tts.fd_slave, NULL, NULL, NULL) == -1)
+       {
+ 	perror ("openpty");
+ 	exit (1);
+       }
+-    }
+ 
+     if (!(tts.pid = fork ()))
+     {
+@@ -989,9 +935,7 @@ tts_init (int first_call)
+     }
+     (void) usleep (10000);
+     if (tts.pid == -1)
+-    {
+       perror ("forkpty");
+-    }
+   }
+   if (tts.synth == TTS_SPEECHD)
+   {
+@@ -1043,10 +987,8 @@ void
+ tts_addchr (wchar_t ch)
+ {
+   tts.buf[tts.outlen++] = ch;
+-  if (tts.outlen > 250)
+-  {
++  if (tts.outlen > TTS_BUF_SIZE)
+     tts_flush ();
+-  }
+ }
+ 
+ 
+@@ -1065,9 +1007,7 @@ tts_initsynth (int *argp)
+     }
+   }
+   if (!ui.silent)
+-  {
+     tts_say (_("Synthesizer reinitialized."));
+-  }
+ }
+ 
+ 
+@@ -1078,9 +1018,7 @@ tts_reinit (int *argp)
+   int pid = tts.pid;
+ 
+   if (pid == 0)
+-  {
+     return;
+-  }
+ 
+   tts.reinit = 1;		/* Start reinit */
+ 
+@@ -1090,20 +1028,14 @@ tts_reinit (int *argp)
+   if (kill (pid, SIGTERM) != 0)
+   {
+     if (errno == ESRCH)
+-    {
+       tts_reinit2 ();
+-    }
+     else
+-    {
+       kill (pid, SIGKILL);
+-    }
+   }
+ 
+   /* wait init completion (tts.fd must be available) */
+   while (tts.reinit)
+-  {
+     usleep (100000);
+-  }
+ }
+ 
+ 
diff --git a/yasr/patches/patch-yasr_yasr.conf b/yasr/patches/patch-yasr_yasr.conf
deleted file mode 100644
index 875bd7386f..0000000000
--- a/yasr/patches/patch-yasr_yasr.conf
+++ /dev/null
@@ -1,23 +0,0 @@
-$NetBSD$
-
-Replace bash with sh.
-Fix eflite path.
-
---- yasr/yasr.conf.orig	2024-02-29 21:20:52.966066354 +0000
-+++ yasr/yasr.conf
-@@ -59,13 +59,13 @@ cursor tracking=full
- synthesizer=speech dispatcher
- #synthesizer port=S0
- #synthesizer port=l0
--#synthesizer port=|/usr/local/bin/eflite
-+#synthesizer port=|/usr/pkg/bin/eflite
- # Below line communicates with speech-dispatcher via TCP if yasr was not
- # built with libspeechd support. Note that speech-dispatcher no longer
- # enables TCP by default.
- #synthesizer port=127.0.0.1:6560
- key echo=off
--shell=/bin/bash
-+shell=/bin/sh
- special=off
- up and down arrows=speak line
- DisableKey=6925
diff --git a/yasr/patches/patch-yasr_yasr.h b/yasr/patches/patch-yasr_yasr.h
index 6569c8d9f3..95a5d89a04 100644
--- a/yasr/patches/patch-yasr_yasr.h
+++ b/yasr/patches/patch-yasr_yasr.h
@@ -4,7 +4,24 @@ Remove size of array declarations defined elsewhere
 
 --- yasr/yasr.h.orig	2023-04-08 21:22:57.000000000 +0000
 +++ yasr/yasr.h
-@@ -304,11 +304,11 @@ extern int cl_synthport;
+@@ -128,6 +128,7 @@ enum mpunct
+ 
+ #define OPT_STR_SIZE 256
+ 
++#define TTS_BUF_SIZE 256
+ typedef struct Tts Tts;
+ struct Tts
+ {
+@@ -140,7 +141,7 @@ struct Tts
+   int obufhead, obuflen, obuftail;
+   int oflag;			/* set to 1 every time tts_send is called */
+   int outlen;
+-  wchar_t buf[256];
++  wchar_t buf[TTS_BUF_SIZE];
+   int synth;
+   pid_t pid;
+   char port[OPT_STR_SIZE];
+@@ -304,11 +305,11 @@ extern int cl_synthport;
  extern Opt opt[];
  extern int synthopt;
  extern char *conffile;


Home | Main Index | Thread Index | Old Index