1 /*  ---------------------------------------------------------------  */
2 /*      The HMM-Based Speech Synthesis System (HTS): version 1.1b    */
3 /*                        HTS Working Group                          */
4 /*                                                                   */
5 /*                   Department of Computer Science                  */
6 /*                   Nagoya Institute of Technology                  */
7 /*                                and                                */
8 /*    Interdisciplinary Graduate School of Science and Engineering   */
9 /*                   Tokyo Institute of Technology                   */
10 /*                      Copyright (c) 2001-2003                      */
11 /*                        All Rights Reserved.                       */
12 /*                                                                   */
13 /*  Permission is hereby granted, free of charge, to use and         */
14 /*  distribute this software and its documentation without           */
15 /*  restriction, including without limitation the rights to use,     */
16 /*  copy, modify, merge, publish, distribute, sublicense, and/or     */
17 /*  sell copies of this work, and to permit persons to whom this     */
18 /*  work is furnished to do so, subject to the following conditions: */
19 /*                                                                   */
20 /*    1. The code must retain the above copyright notice, this list  */
21 /*       of conditions and the following disclaimer.                 */
22 /*                                                                   */
23 /*    2. Any modifications must be clearly marked as such.           */
24 /*                                                                   */
25 /*  NAGOYA INSTITUTE OF TECHNOLOGY, TOKYO INSITITUTE OF TECHNOLOGY,  */
26 /*  HTS WORKING GROUP, AND THE CONTRIBUTORS TO THIS WORK DISCLAIM    */
27 /*  ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL       */
28 /*  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT   */
29 /*  SHALL NAGOYA INSTITUTE OF TECHNOLOGY, TOKYO INSITITUTE OF        */
30 /*  TECHNOLOGY, HTS WORKING GROUP, NOR THE CONTRIBUTORS BE LIABLE    */
31 /*  FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY        */
32 /*  DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,  */
33 /*  WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTUOUS   */
34 /*  ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR          */
35 /*  PERFORMANCE OF THIS SOFTWARE.                                    */
36 /*                                                                   */
37 /*  ---------------------------------------------------------------  */
38 /*    misc.c : miscellaneous functions (from SPTK)                   */
39 /*                                                                   */
40 /*                                    2003/06/11 by Heiga Zen        */
41 /*  ---------------------------------------------------------------  */
42 
43 #include <cstdio>
44 #include <cstdlib>
45 #include <cstring>
46 #include <cctype>
47 #include "festival.h"
48 #include "misc.h"
49 
getfp(char * name,char * opt)50 FILE *getfp (char *name, char *opt)
51 {
52    FILE *fp;
53 
54    if ((fp=fopen(name, opt)) == NULL) {
55       fprintf (stderr, "Can't open '%s'!\n", name);
56       festival_error();
57    }
58    return (fp);
59 }
60 
GetToken(FILE * fp,char * buff)61 void GetToken (FILE *fp, char *buff)
62 {
63    char c;
64    int i;
65    HTS_Boolean squote = 0;
66    HTS_Boolean dquote = 0;
67 
68    c = fgetc (fp);
69 
70    while (isspace(c))
71       c = fgetc (fp);
72 
73    if (c=='\'') {  /* single quote case */
74       c = fgetc (fp);
75       squote = 1;
76    }
77 
78    if (c=='\"') {  /*double quote case */
79       c = fgetc (fp);
80       dquote = 1;
81    }
82 
83    if (c==',') {   /*special character ',' */
84       strcpy (buff, ",");
85       return;
86    }
87 
88    i = 0;
89    while (1) {
90       buff[i++] = c;
91       c = fgetc (fp);
92       if (squote && c == '\'') break;
93       if (dquote && c == '\"') break;
94       if (!(squote || dquote || isgraph(c)) ) break;
95    }
96 
97    buff[i]=0;
98 }
99 
movem(double * a,double * b,int nitem)100 void movem (double *a, double *b, int nitem)
101 {
102    register long i;
103 
104    i = nitem;
105 
106    if (a>b)
107       while (i--) *b++ = *a++;
108    else {
109       a += i; b += i;
110       while (i--) *--b = *--a;
111    }
112 }
113 
114 /* -------------------- End of "misc.c" -------------------- */
115