From b879a95c1d1b6241e7bc1b6fb6349e91e4baf5f1 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 13 Jun 2011 23:20:18 +0100 Subject: gbuildize hwpfilter --- hwpfilter/source/cspline.cpp | 176 --- hwpfilter/source/cspline.cxx | 176 +++ hwpfilter/source/fontmap.cpp | 177 --- hwpfilter/source/fontmap.cxx | 177 +++ hwpfilter/source/formula.cpp | 689 ------------ hwpfilter/source/formula.cxx | 689 ++++++++++++ hwpfilter/source/grammar.cpp | 1456 ------------------------- hwpfilter/source/grammar.cxx | 1456 +++++++++++++++++++++++++ hwpfilter/source/hbox.cpp | 715 ------------ hwpfilter/source/hbox.cxx | 715 ++++++++++++ hwpfilter/source/hcode.cpp | 1525 -------------------------- hwpfilter/source/hcode.cxx | 1525 ++++++++++++++++++++++++++ hwpfilter/source/hfont.cpp | 108 -- hwpfilter/source/hfont.cxx | 108 ++ hwpfilter/source/hgzip.cpp | 340 ------ hwpfilter/source/hgzip.cxx | 340 ++++++ hwpfilter/source/himgutil.cpp | 172 --- hwpfilter/source/himgutil.cxx | 172 +++ hwpfilter/source/hinfo.cpp | 208 ---- hwpfilter/source/hinfo.cxx | 208 ++++ hwpfilter/source/hiodev.cpp | 366 ------- hwpfilter/source/hiodev.cxx | 366 +++++++ hwpfilter/source/hpara.cpp | 318 ------ hwpfilter/source/hpara.cxx | 318 ++++++ hwpfilter/source/hstream.cpp | 83 -- hwpfilter/source/hstream.cxx | 83 ++ hwpfilter/source/hstyle.cpp | 154 --- hwpfilter/source/hstyle.cxx | 154 +++ hwpfilter/source/htags.cpp | 167 --- hwpfilter/source/htags.cxx | 167 +++ hwpfilter/source/hutil.cpp | 102 -- hwpfilter/source/hutil.cxx | 102 ++ hwpfilter/source/hwp.component | 1 + hwpfilter/source/hwpeq.cpp | 754 ------------- hwpfilter/source/hwpeq.cxx | 754 +++++++++++++ hwpfilter/source/hwpfile.cpp | 658 ----------- hwpfilter/source/hwpfile.cxx | 658 +++++++++++ hwpfilter/source/hwpread.cpp | 814 -------------- hwpfilter/source/hwpread.cxx | 814 ++++++++++++++ hwpfilter/source/hwpreader.cxx | 27 +- hwpfilter/source/lexer.cpp | 2364 ---------------------------------------- hwpfilter/source/lexer.cxx | 2364 ++++++++++++++++++++++++++++++++++++++++ hwpfilter/source/list.hxx | 8 +- hwpfilter/source/makefile.mk | 103 -- hwpfilter/source/mzstring.cpp | 312 ------ hwpfilter/source/mzstring.cxx | 312 ++++++ hwpfilter/source/solver.cpp | 187 ---- hwpfilter/source/solver.cxx | 187 ++++ 48 files changed, 11852 insertions(+), 11977 deletions(-) delete mode 100644 hwpfilter/source/cspline.cpp create mode 100644 hwpfilter/source/cspline.cxx delete mode 100644 hwpfilter/source/fontmap.cpp create mode 100644 hwpfilter/source/fontmap.cxx delete mode 100644 hwpfilter/source/formula.cpp create mode 100644 hwpfilter/source/formula.cxx delete mode 100644 hwpfilter/source/grammar.cpp create mode 100644 hwpfilter/source/grammar.cxx delete mode 100644 hwpfilter/source/hbox.cpp create mode 100644 hwpfilter/source/hbox.cxx delete mode 100644 hwpfilter/source/hcode.cpp create mode 100644 hwpfilter/source/hcode.cxx delete mode 100644 hwpfilter/source/hfont.cpp create mode 100644 hwpfilter/source/hfont.cxx delete mode 100644 hwpfilter/source/hgzip.cpp create mode 100644 hwpfilter/source/hgzip.cxx delete mode 100644 hwpfilter/source/himgutil.cpp create mode 100644 hwpfilter/source/himgutil.cxx delete mode 100644 hwpfilter/source/hinfo.cpp create mode 100644 hwpfilter/source/hinfo.cxx delete mode 100644 hwpfilter/source/hiodev.cpp create mode 100644 hwpfilter/source/hiodev.cxx delete mode 100644 hwpfilter/source/hpara.cpp create mode 100644 hwpfilter/source/hpara.cxx delete mode 100644 hwpfilter/source/hstream.cpp create mode 100644 hwpfilter/source/hstream.cxx delete mode 100644 hwpfilter/source/hstyle.cpp create mode 100644 hwpfilter/source/hstyle.cxx delete mode 100644 hwpfilter/source/htags.cpp create mode 100644 hwpfilter/source/htags.cxx delete mode 100644 hwpfilter/source/hutil.cpp create mode 100644 hwpfilter/source/hutil.cxx delete mode 100644 hwpfilter/source/hwpeq.cpp create mode 100644 hwpfilter/source/hwpeq.cxx delete mode 100644 hwpfilter/source/hwpfile.cpp create mode 100644 hwpfilter/source/hwpfile.cxx delete mode 100644 hwpfilter/source/hwpread.cpp create mode 100644 hwpfilter/source/hwpread.cxx delete mode 100644 hwpfilter/source/lexer.cpp create mode 100644 hwpfilter/source/lexer.cxx delete mode 100644 hwpfilter/source/makefile.mk delete mode 100644 hwpfilter/source/mzstring.cpp create mode 100644 hwpfilter/source/mzstring.cxx delete mode 100644 hwpfilter/source/solver.cpp create mode 100644 hwpfilter/source/solver.cxx (limited to 'hwpfilter/source') diff --git a/hwpfilter/source/cspline.cpp b/hwpfilter/source/cspline.cpp deleted file mode 100644 index 8493ff339bb4..000000000000 --- a/hwpfilter/source/cspline.cpp +++ /dev/null @@ -1,176 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// Natural, Clamped, or Periodic Cubic Splines -// -// Input: A list of N+1 points (x_i,a_i), 0 <= i <= N, which are sampled -// from a function, a_i = f(x_i). The function f is unknown. Boundary -// conditions are -// (1) Natural splines: f"(x_0) = f"(x_N) = 0 -// (2) Clamped splines: f'(x_0) and f'(x_N) are user-specified. -// (3) Periodic splines: f(x_0) = f(x_N) [in which case a_N = a_0 is -// required in the input], f'(x_0) = f'(x_N), and f"(x_0) = f"(x_N). -// -// Output: b_i, c_i, d_i, 0 <= i <= N-1, which are coefficients for the cubic -// spline S_i(x) = a_i + b_i(x-x_i) + c_i(x-x_i)^2 + d_i(x-x_i)^3 for -// x_i <= x < x_{i+1}. -// -// The natural and clamped algorithms were implemented from -// -// Numerical Analysis, 3rd edition -// Richard L. Burden and J. Douglas Faires -// Prindle, Weber & Schmidt -// Boston, 1985, pp. 122-124. -// -// The algorithm sets up a tridiagonal linear system of equations in the -// c_i values. This can be solved in O(N) time. -// -// The periodic spline algorithm was implemented from my own derivation. The -// linear system of equations is not tridiagonal. For now I use a standard -// linear solver that does not take advantage of the sparseness of the -// matrix. Therefore for very large N, you may have to worry about memory -// usage. - -#include "solver.h" -//----------------------------------------------------------------------------- -void NaturalSpline (int N, double* x, double* a, double*& b, double*& c, - double*& d) -{ - const double oneThird = 1.0/3.0; - - int i; - double* h = new double[N]; - double* hdiff = new double[N]; - double* alpha = new double[N]; - - for (i = 0; i < N; i++){ - h[i] = x[i+1]-x[i]; - } - - for (i = 1; i < N; i++) - hdiff[i] = x[i+1]-x[i-1]; - - for (i = 1; i < N; i++) - { - double numer = 3.0*(a[i+1]*h[i-1]-a[i]*hdiff[i]+a[i-1]*h[i]); - double denom = h[i-1]*h[i]; - alpha[i] = numer/denom; - } - - double* ell = new double[N+1]; - double* mu = new double[N]; - double* z = new double[N+1]; - double recip; - - ell[0] = 1.0; - mu[0] = 0.0; - z[0] = 0.0; - - for (i = 1; i < N; i++) - { - ell[i] = 2.0*hdiff[i]-h[i-1]*mu[i-1]; - recip = 1.0/ell[i]; - mu[i] = recip*h[i]; - z[i] = recip*(alpha[i]-h[i-1]*z[i-1]); - } - ell[N] = 1.0; - z[N] = 0.0; - - b = new double[N]; - c = new double[N+1]; - d = new double[N]; - - c[N] = 0.0; - - for (i = N-1; i >= 0; i--) - { - c[i] = z[i]-mu[i]*c[i+1]; - recip = 1.0/h[i]; - b[i] = recip*(a[i+1]-a[i])-h[i]*(c[i+1]+2.0*c[i])*oneThird; - d[i] = oneThird*recip*(c[i+1]-c[i]); - } - - delete[] h; - delete[] hdiff; - delete[] alpha; - delete[] ell; - delete[] mu; - delete[] z; -} - -void PeriodicSpline (int N, double* x, double* a, double*& b, double*& c, - double*& d) -{ - double* h = new double[N]; - int i; - for (i = 0; i < N; i++) - h[i] = x[i+1]-x[i]; - - mgcLinearSystemD sys; - double** mat = sys.NewMatrix(N+1); // guaranteed to be zeroed memory - c = sys.NewVector(N+1); // guaranteed to be zeroed memory - - // c[0] - c[N] = 0 - mat[0][0] = +1.0f; - mat[0][N] = -1.0f; - - // h[i-1]*c[i-1]+2*(h[i-1]+h[i])*c[i]+h[i]*c[i+1] = - // 3*{(a[i+1]-a[i])/h[i] - (a[i]-a[i-1])/h[i-1]} - for (i = 1; i <= N-1; i++) - { - mat[i][i-1] = h[i-1]; - mat[i][i ] = 2.0f*(h[i-1]+h[i]); - mat[i][i+1] = h[i]; - c[i] = 3.0f*((a[i+1]-a[i])/h[i] - (a[i]-a[i-1])/h[i-1]); - } - - // "wrap around equation" for periodicity - // h[N-1]*c[N-1]+2*(h[N-1]+h[0])*c[0]+h[0]*c[1] = - // 3*{(a[1]-a[0])/h[0] - (a[0]-a[N-1])/h[N-1]} - mat[N][N-1] = h[N-1]; - mat[N][0 ] = 2.0f*(h[N-1]+h[0]); - mat[N][1 ] = h[0]; - c[N] = 3.0f*((a[1]-a[0])/h[0] - (a[0]-a[N-1])/h[N-1]); - - // solve for c[0] through c[N] - sys.Solve(N+1,mat,c); - - const double oneThird = 1.0/3.0; - b = new double[N]; - d = new double[N]; - for (i = 0; i < N; i++) - { - b[i] = (a[i+1]-a[i])/h[i] - oneThird*(c[i+1]+2.0f*c[i])*h[i]; - d[i] = oneThird*(c[i+1]-c[i])/h[i]; - } - - delete[] h; - sys.DeleteMatrix(N+1,mat); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/hwpfilter/source/cspline.cxx b/hwpfilter/source/cspline.cxx new file mode 100644 index 000000000000..8493ff339bb4 --- /dev/null +++ b/hwpfilter/source/cspline.cxx @@ -0,0 +1,176 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// Natural, Clamped, or Periodic Cubic Splines +// +// Input: A list of N+1 points (x_i,a_i), 0 <= i <= N, which are sampled +// from a function, a_i = f(x_i). The function f is unknown. Boundary +// conditions are +// (1) Natural splines: f"(x_0) = f"(x_N) = 0 +// (2) Clamped splines: f'(x_0) and f'(x_N) are user-specified. +// (3) Periodic splines: f(x_0) = f(x_N) [in which case a_N = a_0 is +// required in the input], f'(x_0) = f'(x_N), and f"(x_0) = f"(x_N). +// +// Output: b_i, c_i, d_i, 0 <= i <= N-1, which are coefficients for the cubic +// spline S_i(x) = a_i + b_i(x-x_i) + c_i(x-x_i)^2 + d_i(x-x_i)^3 for +// x_i <= x < x_{i+1}. +// +// The natural and clamped algorithms were implemented from +// +// Numerical Analysis, 3rd edition +// Richard L. Burden and J. Douglas Faires +// Prindle, Weber & Schmidt +// Boston, 1985, pp. 122-124. +// +// The algorithm sets up a tridiagonal linear system of equations in the +// c_i values. This can be solved in O(N) time. +// +// The periodic spline algorithm was implemented from my own derivation. The +// linear system of equations is not tridiagonal. For now I use a standard +// linear solver that does not take advantage of the sparseness of the +// matrix. Therefore for very large N, you may have to worry about memory +// usage. + +#include "solver.h" +//----------------------------------------------------------------------------- +void NaturalSpline (int N, double* x, double* a, double*& b, double*& c, + double*& d) +{ + const double oneThird = 1.0/3.0; + + int i; + double* h = new double[N]; + double* hdiff = new double[N]; + double* alpha = new double[N]; + + for (i = 0; i < N; i++){ + h[i] = x[i+1]-x[i]; + } + + for (i = 1; i < N; i++) + hdiff[i] = x[i+1]-x[i-1]; + + for (i = 1; i < N; i++) + { + double numer = 3.0*(a[i+1]*h[i-1]-a[i]*hdiff[i]+a[i-1]*h[i]); + double denom = h[i-1]*h[i]; + alpha[i] = numer/denom; + } + + double* ell = new double[N+1]; + double* mu = new double[N]; + double* z = new double[N+1]; + double recip; + + ell[0] = 1.0; + mu[0] = 0.0; + z[0] = 0.0; + + for (i = 1; i < N; i++) + { + ell[i] = 2.0*hdiff[i]-h[i-1]*mu[i-1]; + recip = 1.0/ell[i]; + mu[i] = recip*h[i]; + z[i] = recip*(alpha[i]-h[i-1]*z[i-1]); + } + ell[N] = 1.0; + z[N] = 0.0; + + b = new double[N]; + c = new double[N+1]; + d = new double[N]; + + c[N] = 0.0; + + for (i = N-1; i >= 0; i--) + { + c[i] = z[i]-mu[i]*c[i+1]; + recip = 1.0/h[i]; + b[i] = recip*(a[i+1]-a[i])-h[i]*(c[i+1]+2.0*c[i])*oneThird; + d[i] = oneThird*recip*(c[i+1]-c[i]); + } + + delete[] h; + delete[] hdiff; + delete[] alpha; + delete[] ell; + delete[] mu; + delete[] z; +} + +void PeriodicSpline (int N, double* x, double* a, double*& b, double*& c, + double*& d) +{ + double* h = new double[N]; + int i; + for (i = 0; i < N; i++) + h[i] = x[i+1]-x[i]; + + mgcLinearSystemD sys; + double** mat = sys.NewMatrix(N+1); // guaranteed to be zeroed memory + c = sys.NewVector(N+1); // guaranteed to be zeroed memory + + // c[0] - c[N] = 0 + mat[0][0] = +1.0f; + mat[0][N] = -1.0f; + + // h[i-1]*c[i-1]+2*(h[i-1]+h[i])*c[i]+h[i]*c[i+1] = + // 3*{(a[i+1]-a[i])/h[i] - (a[i]-a[i-1])/h[i-1]} + for (i = 1; i <= N-1; i++) + { + mat[i][i-1] = h[i-1]; + mat[i][i ] = 2.0f*(h[i-1]+h[i]); + mat[i][i+1] = h[i]; + c[i] = 3.0f*((a[i+1]-a[i])/h[i] - (a[i]-a[i-1])/h[i-1]); + } + + // "wrap around equation" for periodicity + // h[N-1]*c[N-1]+2*(h[N-1]+h[0])*c[0]+h[0]*c[1] = + // 3*{(a[1]-a[0])/h[0] - (a[0]-a[N-1])/h[N-1]} + mat[N][N-1] = h[N-1]; + mat[N][0 ] = 2.0f*(h[N-1]+h[0]); + mat[N][1 ] = h[0]; + c[N] = 3.0f*((a[1]-a[0])/h[0] - (a[0]-a[N-1])/h[N-1]); + + // solve for c[0] through c[N] + sys.Solve(N+1,mat,c); + + const double oneThird = 1.0/3.0; + b = new double[N]; + d = new double[N]; + for (i = 0; i < N; i++) + { + b[i] = (a[i+1]-a[i])/h[i] - oneThird*(c[i+1]+2.0f*c[i])*h[i]; + d[i] = oneThird*(c[i+1]-c[i])/h[i]; + } + + delete[] h; + sys.DeleteMatrix(N+1,mat); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/hwpfilter/source/fontmap.cpp b/hwpfilter/source/fontmap.cpp deleted file mode 100644 index d3f9906f3eb2..000000000000 --- a/hwpfilter/source/fontmap.cpp +++ /dev/null @@ -1,177 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include -#ifdef SOLARIS -#include -#else -#include -#endif - -// #i42367# prevent MS compiler from using system locale for parsing -#ifdef _MSC_VER -#pragma setlocale("C") -#endif - - -struct FontEntry -{ - const char *familyname; - int key; - double ratio; -}; -/** - * ratio\xb4\xc2 \xc7\xd1\xb1\xdb 70%, \xbc\xfd\xc0\xda 10% \xbf\xb5\xb9\xae 20%\xc0\xc7 \xba\xf1\xc0\xb2\xb7\xce \xb1\xb8\xbc\xba\xb5\xc7\xbe\xfa\xb4\xd9\xb4\xc2 \xb0\xa1\xc1\xa4\xc7\xcf\xbf\xa1 \xc1\xa4\xc7\xd8\xc1\xf8\xb4\xd9. - */ -const struct FontEntry FontMapTab[] = -{ - {"\xb8\xed\xc1\xb6",0, 0.97}, - {"\xb0\xed\xb5\xf1",1, 0.97}, - {"\xbb\xf9\xb9\xb0",1, 0.97}, - {"\xc7\xca\xb1\xe2",0, 0.97}, - {"\xbd\xc3\xbd\xba\xc5\xdb",1, 0.84}, - {"\xbd\xc3\xbd\xba\xc5\xdb \xbe\xe0\xc0\xda",1, 0.84}, - {"\xbd\xc3\xbd\xba\xc5\xdb \xb0\xa3\xc0\xda",1, 0.84}, - {"HY\xb5\xd5\xb1\xd9 \xb0\xed\xb5\xf1",2, 0.97}, - {"\xbf\xbe\xc7\xd1\xb1\xdb",0, 0.97}, - {"\xb0\xa1\xb4\xc2\xb0\xf8\xc7\xd1",0, 0.72}, - {"\xc1\xdf\xb0\xa3\xb0\xf8\xc7\xd1",0, 0.72}, - {"\xb1\xbd\xc0\xba\xb0\xf8\xc7\xd1",0, 0.72}, - {"\xb0\xa1\xb4\xc2\xc7\xd1",0, 0.72}, - {"\xc1\xdf\xb0\xa3\xc7\xd1",0, 0.72}, - {"\xb1\xbd\xc0\xba\xc7\xd1",0, 0.72}, - {"\xc8\xde\xb8\xd5\xb8\xed\xc1\xb6",0, 0.97}, - {"\xc8\xde\xb8\xd5\xb0\xed\xb5\xf1",1, 0.97}, - {"\xb0\xa1\xb4\xc2\xbe\xc8\xbb\xf3\xbc\xf6\xc3\xbc",0, 0.55}, - {"\xc1\xdf\xb0\xa3\xbe\xc8\xbb\xf3\xbc\xf6\xc3\xbc",0, 0.637}, - {"\xb1\xbd\xc0\xba\xbe\xc8\xbb\xf3\xbc\xf6\xc3\xbc",0, 0.63}, - {"\xc8\xde\xb8\xd5\xb0\xa1\xb4\xc2\xbb\xf9\xc3\xbc",0, 0.666}, - {"\xc8\xde\xb8\xd5\xc1\xdf\xb0\xa3\xbb\xf9\xc3\xbc",0, 0.685}, - {"\xc8\xde\xb8\xd5\xb1\xbd\xc0\xba\xbb\xf9\xc3\xbc",0, 0.727}, - {"\xc8\xde\xb8\xd5\xb0\xa1\xb4\xc2\xc6\xd4\xc3\xbc",0, 0.666}, - {"\xc8\xde\xb8\xd5\xc1\xdf\xb0\xa3\xc6\xd4\xc3\xbc",0, 0.685}, - {"\xc8\xde\xb8\xd5\xb1\xbd\xc0\xba\xc6\xd4\xc3\xbc",0, 0.727}, - {"\xc8\xde\xb8\xd5\xbf\xbe\xc3\xbc",3, 0.97}, - {"\xc7\xd1\xbe\xe7\xbd\xc5\xb8\xed\xc1\xb6",0, 0.97}, - {"\xc7\xd1\xbe\xe7\xb0\xdf\xb8\xed\xc1\xb6",1, 0.97}, - {"\xc7\xd1\xbe\xe7\xc1\xdf\xb0\xed\xb5\xf1",1, 0.97}, - {"\xc7\xd1\xbe\xe7\xb0\xdf\xb0\xed\xb5\xf1",1, 0.97}, - {"\xc7\xd1\xbe\xe7\xb1\xd7\xb7\xa1\xc7\xc8",0, 0.97}, - {"\xc7\xd1\xbe\xe7\xb1\xc3\xbc\xad",3, 0.97}, - {"\xb9\xae\xc8\xad\xb9\xd9\xc5\xc1",0, 0.97}, - {"\xb9\xae\xc8\xad\xb9\xd9\xc5\xc1\xc1\xa6\xb8\xf1",1, 0.97}, - {"\xb9\xae\xc8\xad\xb5\xb8\xbf\xf2",1, 0.97}, - {"\xb9\xae\xc8\xad\xb5\xb8\xbf\xf2\xc1\xa6\xb8\xf1",0, 0.97}, - {"\xb9\xae\xc8\xad\xbe\xb2\xb1\xe2",0, 0.97}, - {"\xb9\xae\xc8\xad\xbe\xb2\xb1\xe2\xc8\xea\xb8\xb2",0, 0.97}, - {"\xc6\xe6\xc8\xea\xb8\xb2",0, 0.97}, - {"\xba\xb9\xbc\xfe\xbe\xc6",0, 0.827}, - {"\xbf\xc1\xbc\xf6\xbc\xf6",0, 0.97}, - {"\xbf\xc0\xc0\xcc",0, 0.97}, - {"\xb0\xa1\xc1\xf6",0, 0.97}, - {"\xb0\xad\xb3\xb6\xc4\xe1",2, 0.97}, - {"\xb5\xfe\xb1\xe2",3, 0.97}, - {"\xc5\xb8\xc0\xcc\xc7\xc1",0, 0.987}, - {"\xc5\xc2 \xb3\xaa\xb9\xab",1, 0.97}, - {"\xc5\xc2 \xc7\xec\xb5\xe5\xb6\xf3\xc0\xce",0, 0.97}, - {"\xc5\xc2 \xb0\xa1\xb4\xc2 \xc7\xec\xb5\xe5\xb6\xf3\xc0\xce",0, 0.97}, - {"\xc5\xc2 \xc7\xec\xb5\xe5\xb6\xf3\xc0\xceT",0, 0.97}, - {"\xc5\xc2 \xb0\xa1\xb4\xc2 \xc7\xec\xb5\xe5\xb6\xf3\xc0\xceT",0, 0.97}, - {"\xbe\xe7\xc0\xe7 \xb4\xd9\xbf\xee\xb8\xed\xc1\xb6M",0, 0.97}, - {"\xbe\xe7\xc0\xe7 \xba\xbb\xb8\xf1\xb0\xa2M",0, 0.97}, - {"\xbe\xe7\xc0\xe7 \xbc\xd2\xbd\xbd",1, 0.97}, - {"\xbe\xe7\xc0\xe7 \xb8\xc5\xc8\xad",1, 0.987}, - {"\xbe\xe7\xc0\xe7 \xc6\xb0\xc6\xb0",0, 0.97}, - {"\xbe\xe7\xc0\xe7 \xc2\xfc\xbd\xa1",1, 0.97}, - {"\xbe\xe7\xc0\xe7 \xb5\xd1\xb1\xe2",0, 0.97}, - {"\xbe\xe7\xc0\xe7 \xbb\xfe\xb3\xda",1, 0.97}, - {"\xbe\xe7\xc0\xe7 \xbf\xcd\xb4\xe7",1, 0.97}, - {"\xbd\xc5\xb8\xed \xbc\xbc\xb8\xed\xc1\xb6",0, 0.97}, - {"\xbd\xc5\xb8\xed \xbd\xc5\xb8\xed\xc1\xb6",0, 0.97}, - {"\xbd\xc5\xb8\xed \xbd\xc5\xbd\xc5\xb8\xed\xc1\xb6",0, 0.97}, - {"\xbd\xc5\xb8\xed \xc1\xdf\xb8\xed\xc1\xb6",0, 0.97}, - {"\xbd\xc5\xb8\xed \xc5\xc2\xb8\xed\xc1\xb6",0, 0.97}, - {"\xbd\xc5\xb8\xed \xb0\xdf\xb8\xed\xc1\xb6",0, 0.97}, - {"\xbd\xc5\xb8\xed \xbd\xc5\xb9\xae\xb8\xed\xc1\xb6",0, 0.97}, - {"\xbd\xc5\xb8\xed \xbc\xf8\xb8\xed\xc1\xb6",0, 0.97}, - {"\xbd\xc5\xb8\xed \xbc\xbc\xb0\xed\xb5\xf1",1, 0.97}, - {"\xbd\xc5\xb8\xed \xc1\xdf\xb0\xed\xb5\xf1",1, 0.97}, - {"\xbd\xc5\xb8\xed \xc5\xc2\xb0\xed\xb5\xf1",1, 0.97}, - {"\xbd\xc5\xb8\xed \xb0\xdf\xb0\xed\xb5\xf1",1, 0.97}, - {"\xbd\xc5\xb8\xed \xbc\xbc\xb3\xaa\xb7\xe7",2, 0.97}, - {"\xbd\xc5\xb8\xed \xb5\xf0\xb3\xaa\xb7\xe7",2, 0.97}, - {"\xbd\xc5\xb8\xed \xbd\xc5\xb1\xd7\xb7\xa1\xc7\xc8",2, 0.97}, - {"\xbd\xc5\xb8\xed \xc5\xc2\xb1\xd7\xb7\xa1\xc7\xc8",2, 0.97}, - {"\xbd\xc5\xb8\xed \xb1\xc3\xbc\xad",3, 0.97} -}; - -#define FONTCOUNT 4 -#ifndef WIN32 -#if defined(LINUX) -const char* RepFontTab[] = -{ - "\xb9\xe9\xb9\xac \xb9\xd9\xc5\xc1", /* 0 */ - "\xb9\xe9\xb9\xac \xb5\xb8\xbf\xf2", /* 1 */ - "\xb9\xe9\xb9\xac \xb1\xbc\xb8\xb2", /* 2 */ - "\xb9\xe9\xb9\xac \xc7\xec\xb5\xe5\xb6\xf3\xc0\xce" /* 3 */ -}; -#else -const char* RepFontTab[] = -{ - "Batang", /* 0 */ - "Dotum", /* 1 */ - "Gulim", /* 2 */ - "Gungso" /* 3 */ -}; -#endif -#else -char* RepFontTab[] = -{ - "\xb9\xd9\xc5\xc1", /* 0 */ - "\xb5\xb8\xbf\xf2", /* 1 */ - "\xb1\xbc\xb8\xb2", /* 2 */ - "\xb1\xc3\xbc\xad" /* 3 */ -}; -#endif - -int getRepFamilyName(const char* orig, char *buf, double &ratio) -{ - int i; - int size = sizeof(FontMapTab)/sizeof(FontEntry); - for( i = 0 ; i < size ; i++) - { - if( !strcmp(orig, FontMapTab[i].familyname) ){ - ratio = FontMapTab[i].ratio; - return strlen( strcpy(buf,RepFontTab[FontMapTab[i].key]) ); - } - } - ratio = FontMapTab[0].ratio; - return strlen( strcpy(buf, RepFontTab[0] ) ); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/hwpfilter/source/fontmap.cxx b/hwpfilter/source/fontmap.cxx new file mode 100644 index 000000000000..d3f9906f3eb2 --- /dev/null +++ b/hwpfilter/source/fontmap.cxx @@ -0,0 +1,177 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include +#ifdef SOLARIS +#include +#else +#include +#endif + +// #i42367# prevent MS compiler from using system locale for parsing +#ifdef _MSC_VER +#pragma setlocale("C") +#endif + + +struct FontEntry +{ + const char *familyname; + int key; + double ratio; +}; +/** + * ratio\xb4\xc2 \xc7\xd1\xb1\xdb 70%, \xbc\xfd\xc0\xda 10% \xbf\xb5\xb9\xae 20%\xc0\xc7 \xba\xf1\xc0\xb2\xb7\xce \xb1\xb8\xbc\xba\xb5\xc7\xbe\xfa\xb4\xd9\xb4\xc2 \xb0\xa1\xc1\xa4\xc7\xcf\xbf\xa1 \xc1\xa4\xc7\xd8\xc1\xf8\xb4\xd9. + */ +const struct FontEntry FontMapTab[] = +{ + {"\xb8\xed\xc1\xb6",0, 0.97}, + {"\xb0\xed\xb5\xf1",1, 0.97}, + {"\xbb\xf9\xb9\xb0",1, 0.97}, + {"\xc7\xca\xb1\xe2",0, 0.97}, + {"\xbd\xc3\xbd\xba\xc5\xdb",1, 0.84}, + {"\xbd\xc3\xbd\xba\xc5\xdb \xbe\xe0\xc0\xda",1, 0.84}, + {"\xbd\xc3\xbd\xba\xc5\xdb \xb0\xa3\xc0\xda",1, 0.84}, + {"HY\xb5\xd5\xb1\xd9 \xb0\xed\xb5\xf1",2, 0.97}, + {"\xbf\xbe\xc7\xd1\xb1\xdb",0, 0.97}, + {"\xb0\xa1\xb4\xc2\xb0\xf8\xc7\xd1",0, 0.72}, + {"\xc1\xdf\xb0\xa3\xb0\xf8\xc7\xd1",0, 0.72}, + {"\xb1\xbd\xc0\xba\xb0\xf8\xc7\xd1",0, 0.72}, + {"\xb0\xa1\xb4\xc2\xc7\xd1",0, 0.72}, + {"\xc1\xdf\xb0\xa3\xc7\xd1",0, 0.72}, + {"\xb1\xbd\xc0\xba\xc7\xd1",0, 0.72}, + {"\xc8\xde\xb8\xd5\xb8\xed\xc1\xb6",0, 0.97}, + {"\xc8\xde\xb8\xd5\xb0\xed\xb5\xf1",1, 0.97}, + {"\xb0\xa1\xb4\xc2\xbe\xc8\xbb\xf3\xbc\xf6\xc3\xbc",0, 0.55}, + {"\xc1\xdf\xb0\xa3\xbe\xc8\xbb\xf3\xbc\xf6\xc3\xbc",0, 0.637}, + {"\xb1\xbd\xc0\xba\xbe\xc8\xbb\xf3\xbc\xf6\xc3\xbc",0, 0.63}, + {"\xc8\xde\xb8\xd5\xb0\xa1\xb4\xc2\xbb\xf9\xc3\xbc",0, 0.666}, + {"\xc8\xde\xb8\xd5\xc1\xdf\xb0\xa3\xbb\xf9\xc3\xbc",0, 0.685}, + {"\xc8\xde\xb8\xd5\xb1\xbd\xc0\xba\xbb\xf9\xc3\xbc",0, 0.727}, + {"\xc8\xde\xb8\xd5\xb0\xa1\xb4\xc2\xc6\xd4\xc3\xbc",0, 0.666}, + {"\xc8\xde\xb8\xd5\xc1\xdf\xb0\xa3\xc6\xd4\xc3\xbc",0, 0.685}, + {"\xc8\xde\xb8\xd5\xb1\xbd\xc0\xba\xc6\xd4\xc3\xbc",0, 0.727}, + {"\xc8\xde\xb8\xd5\xbf\xbe\xc3\xbc",3, 0.97}, + {"\xc7\xd1\xbe\xe7\xbd\xc5\xb8\xed\xc1\xb6",0, 0.97}, + {"\xc7\xd1\xbe\xe7\xb0\xdf\xb8\xed\xc1\xb6",1, 0.97}, + {"\xc7\xd1\xbe\xe7\xc1\xdf\xb0\xed\xb5\xf1",1, 0.97}, + {"\xc7\xd1\xbe\xe7\xb0\xdf\xb0\xed\xb5\xf1",1, 0.97}, + {"\xc7\xd1\xbe\xe7\xb1\xd7\xb7\xa1\xc7\xc8",0, 0.97}, + {"\xc7\xd1\xbe\xe7\xb1\xc3\xbc\xad",3, 0.97}, + {"\xb9\xae\xc8\xad\xb9\xd9\xc5\xc1",0, 0.97}, + {"\xb9\xae\xc8\xad\xb9\xd9\xc5\xc1\xc1\xa6\xb8\xf1",1, 0.97}, + {"\xb9\xae\xc8\xad\xb5\xb8\xbf\xf2",1, 0.97}, + {"\xb9\xae\xc8\xad\xb5\xb8\xbf\xf2\xc1\xa6\xb8\xf1",0, 0.97}, + {"\xb9\xae\xc8\xad\xbe\xb2\xb1\xe2",0, 0.97}, + {"\xb9\xae\xc8\xad\xbe\xb2\xb1\xe2\xc8\xea\xb8\xb2",0, 0.97}, + {"\xc6\xe6\xc8\xea\xb8\xb2",0, 0.97}, + {"\xba\xb9\xbc\xfe\xbe\xc6",0, 0.827}, + {"\xbf\xc1\xbc\xf6\xbc\xf6",0, 0.97}, + {"\xbf\xc0\xc0\xcc",0, 0.97}, + {"\xb0\xa1\xc1\xf6",0, 0.97}, + {"\xb0\xad\xb3\xb6\xc4\xe1",2, 0.97}, + {"\xb5\xfe\xb1\xe2",3, 0.97}, + {"\xc5\xb8\xc0\xcc\xc7\xc1",0, 0.987}, + {"\xc5\xc2 \xb3\xaa\xb9\xab",1, 0.97}, + {"\xc5\xc2 \xc7\xec\xb5\xe5\xb6\xf3\xc0\xce",0, 0.97}, + {"\xc5\xc2 \xb0\xa1\xb4\xc2 \xc7\xec\xb5\xe5\xb6\xf3\xc0\xce",0, 0.97}, + {"\xc5\xc2 \xc7\xec\xb5\xe5\xb6\xf3\xc0\xceT",0, 0.97}, + {"\xc5\xc2 \xb0\xa1\xb4\xc2 \xc7\xec\xb5\xe5\xb6\xf3\xc0\xceT",0, 0.97}, + {"\xbe\xe7\xc0\xe7 \xb4\xd9\xbf\xee\xb8\xed\xc1\xb6M",0, 0.97}, + {"\xbe\xe7\xc0\xe7 \xba\xbb\xb8\xf1\xb0\xa2M",0, 0.97}, + {"\xbe\xe7\xc0\xe7 \xbc\xd2\xbd\xbd",1, 0.97}, + {"\xbe\xe7\xc0\xe7 \xb8\xc5\xc8\xad",1, 0.987}, + {"\xbe\xe7\xc0\xe7 \xc6\xb0\xc6\xb0",0, 0.97}, + {"\xbe\xe7\xc0\xe7 \xc2\xfc\xbd\xa1",1, 0.97}, + {"\xbe\xe7\xc0\xe7 \xb5\xd1\xb1\xe2",0, 0.97}, + {"\xbe\xe7\xc0\xe7 \xbb\xfe\xb3\xda",1, 0.97}, + {"\xbe\xe7\xc0\xe7 \xbf\xcd\xb4\xe7",1, 0.97}, + {"\xbd\xc5\xb8\xed \xbc\xbc\xb8\xed\xc1\xb6",0, 0.97}, + {"\xbd\xc5\xb8\xed \xbd\xc5\xb8\xed\xc1\xb6",0, 0.97}, + {"\xbd\xc5\xb8\xed \xbd\xc5\xbd\xc5\xb8\xed\xc1\xb6",0, 0.97}, + {"\xbd\xc5\xb8\xed \xc1\xdf\xb8\xed\xc1\xb6",0, 0.97}, + {"\xbd\xc5\xb8\xed \xc5\xc2\xb8\xed\xc1\xb6",0, 0.97}, + {"\xbd\xc5\xb8\xed \xb0\xdf\xb8\xed\xc1\xb6",0, 0.97}, + {"\xbd\xc5\xb8\xed \xbd\xc5\xb9\xae\xb8\xed\xc1\xb6",0, 0.97}, + {"\xbd\xc5\xb8\xed \xbc\xf8\xb8\xed\xc1\xb6",0, 0.97}, + {"\xbd\xc5\xb8\xed \xbc\xbc\xb0\xed\xb5\xf1",1, 0.97}, + {"\xbd\xc5\xb8\xed \xc1\xdf\xb0\xed\xb5\xf1",1, 0.97}, + {"\xbd\xc5\xb8\xed \xc5\xc2\xb0\xed\xb5\xf1",1, 0.97}, + {"\xbd\xc5\xb8\xed \xb0\xdf\xb0\xed\xb5\xf1",1, 0.97}, + {"\xbd\xc5\xb8\xed \xbc\xbc\xb3\xaa\xb7\xe7",2, 0.97}, + {"\xbd\xc5\xb8\xed \xb5\xf0\xb3\xaa\xb7\xe7",2, 0.97}, + {"\xbd\xc5\xb8\xed \xbd\xc5\xb1\xd7\xb7\xa1\xc7\xc8",2, 0.97}, + {"\xbd\xc5\xb8\xed \xc5\xc2\xb1\xd7\xb7\xa1\xc7\xc8",2, 0.97}, + {"\xbd\xc5\xb8\xed \xb1\xc3\xbc\xad",3, 0.97} +}; + +#define FONTCOUNT 4 +#ifndef WIN32 +#if defined(LINUX) +const char* RepFontTab[] = +{ + "\xb9\xe9\xb9\xac \xb9\xd9\xc5\xc1", /* 0 */ + "\xb9\xe9\xb9\xac \xb5\xb8\xbf\xf2", /* 1 */ + "\xb9\xe9\xb9\xac \xb1\xbc\xb8\xb2", /* 2 */ + "\xb9\xe9\xb9\xac \xc7\xec\xb5\xe5\xb6\xf3\xc0\xce" /* 3 */ +}; +#else +const char* RepFontTab[] = +{ + "Batang", /* 0 */ + "Dotum", /* 1 */ + "Gulim", /* 2 */ + "Gungso" /* 3 */ +}; +#endif +#else +char* RepFontTab[] = +{ + "\xb9\xd9\xc5\xc1", /* 0 */ + "\xb5\xb8\xbf\xf2", /* 1 */ + "\xb1\xbc\xb8\xb2", /* 2 */ + "\xb1\xc3\xbc\xad" /* 3 */ +}; +#endif + +int getRepFamilyName(const char* orig, char *buf, double &ratio) +{ + int i; + int size = sizeof(FontMapTab)/sizeof(FontEntry); + for( i = 0 ; i < size ; i++) + { + if( !strcmp(orig, FontMapTab[i].familyname) ){ + ratio = FontMapTab[i].ratio; + return strlen( strcpy(buf,RepFontTab[FontMapTab[i].key]) ); + } + } + ratio = FontMapTab[0].ratio; + return strlen( strcpy(buf, RepFontTab[0] ) ); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/hwpfilter/source/formula.cpp b/hwpfilter/source/formula.cpp deleted file mode 100644 index d2a73ac72d07..000000000000 --- a/hwpfilter/source/formula.cpp +++ /dev/null @@ -1,689 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "formula.h" - -#include "mzstring.h" -#include "nodes.h" -#include "mapping.h" -#include "hwpeq.h" -#include - -extern LinkedList nodelist; - -#ifndef DEBUG - -#include "hcode.h" - -static hchar entity[32]; -#define ascii(x) OUString::createFromAscii(x) -#define rstartEl(x,y) do { if (m_rxDocumentHandler.is()) m_rxDocumentHandler->startElement(x,y); } while(0) -#define rendEl(x) do { if (m_rxDocumentHandler.is()) m_rxDocumentHandler->endElement(x); } while(0) -#define rchars(x) do { if (m_rxDocumentHandler.is()) m_rxDocumentHandler->characters(ascii(x)); } while(0) -#define runistr(x) do { if (m_rxDocumentHandler.is()) m_rxDocumentHandler->characters(OUString(x)); } while(0) -#define reucstr(x,y) do { if (m_rxDocumentHandler.is()) m_rxDocumentHandler->characters(OUString(x,y, RTL_TEXTENCODING_EUC_KR)); } while(0) -#define padd(x,y,z) pList->addAttribute(x,y,z) -#else -static char entity[32]; -static int indent = 0; -#define inds indent++; for(int i = 0 ; i < indent ; i++) fprintf(stderr," ") -#define inde for(int i = 0 ; i < indent ; i++) fprintf(stderr," "); indent-- -#define indo indent--; -#endif - -extern Node *mainParse(const char *); - - -void Formula::makeMathML(Node *res) -{ - Node *tmp = res; - if( !tmp ) return; -#ifdef DEBUG - inds; - fprintf(stderr,"\n"); -#else - padd(ascii("xmlns:math"), ascii("CDATA"), ascii("http://www.w3.org/1998/Math/MathML")); - rstartEl(ascii("math:math"), rList); - pList->clear(); - rstartEl(ascii("math:semantics"), rList); -#endif - if( tmp->child ) - makeLines( tmp->child ); - -#ifdef DEBUG - inds; - fprintf(stderr,"\n"); - indo; - inde; - fprintf(stderr,"\n"); -#else - rendEl(ascii("math:semantics")); - rendEl(ascii("math:math")); -#endif -} - -void Formula::makeLines(Node *res) -{ - Node *tmp = res; - if( !tmp ) return; - - if( tmp->child ){ - if( tmp->child->id == ID_LINES ) - makeLines( tmp->child ); - else - makeLine( tmp->child ); - } - if( tmp->next ) - makeLine( tmp->next ); -} - -void Formula::makeLine(Node *res) -{ - if( !res ) return; -#ifdef DEBUG - inds; fprintf(stderr,"\n"); -#else - rstartEl(ascii("math:mrow"), rList); -#endif - if( res->child ) - makeExprList( res->child ); -#ifdef DEBUG - inde; fprintf(stderr,"\n"); -#else - rendEl(ascii("math:mrow")); -#endif -} - -void Formula::makeExprList(Node *res) -{ - if( !res ) return; - Node *tmp = res->child; - if( !tmp ) return ; - - if( tmp->id == ID_EXPRLIST ){ - Node *next = tmp->next; - makeExprList( tmp ) ; - if( next ) - makeExpr( next ); - } - else - makeExpr( tmp ); -} - -void Formula::makeExpr(Node *res) -{ - if( !res ) return; - Node *tmp = res->child; - if( !tmp ) return; - switch( tmp->id ) { - case ID_PRIMARYEXPR: - if( tmp->next ){ -#ifdef DEBUG - inds; - fprintf(stderr,"\n"); -#else - rstartEl(ascii("math:mrow"), rList); -#endif - } - - makePrimary(tmp); - - if( tmp->next ){ -#ifdef DEBUG - inde; fprintf(stderr,"\n"); -#else - rendEl(ascii("math:mrow")); -#endif - } - break; - case ID_SUBEXPR: - case ID_SUPEXPR: - case ID_SUBSUPEXPR: - makeSubSup(tmp); - break; - case ID_FRACTIONEXPR: - case ID_OVER: - makeFraction(tmp); - break; - case ID_DECORATIONEXPR: - makeDecoration(tmp); - break; - case ID_SQRTEXPR: - case ID_ROOTEXPR: - makeRoot(tmp); - break; - case ID_ARROWEXPR: - makeArrow(tmp); - break; - case ID_ACCENTEXPR: - makeAccent(tmp); - break; - case ID_PARENTH: - case ID_ABS: - makeParenth(tmp); - break; - case ID_FENCE: - makeFence(tmp); - break; - case ID_BLOCK: - makeBlock(tmp); - case ID_BEGIN: - makeBegin(tmp); - case ID_END: - makeEnd(tmp); - break; - } -} - -void Formula::makeIdentifier(Node *res) -{ - Node *tmp = res; - if( !tmp ) return; - if( !tmp->value ) return; - switch( tmp->id ){ - case ID_CHARACTER : -#ifdef DEBUG - inds; - fprintf(stderr,"%s\n",tmp->value); - indo; -#else - rstartEl(ascii("math:mi"), rList); - rchars(tmp->value); - rendEl(ascii("math:mi")); -#endif - break; - case ID_STRING : - { -#ifdef DEBUG -#else - rstartEl(ascii("math:mi"), rList); - reucstr(tmp->value, strlen(tmp->value)); - rendEl(ascii("math:mi")); -#endif - } - break; - case ID_IDENTIFIER : -#ifdef DEBUG - inds; - fprintf(stderr,"%s\n",getMathMLEntity(tmp->value, entity)); - indo; -#else - rstartEl(ascii("math:mi"), rList); - runistr(getMathMLEntity(tmp->value, entity)); - rendEl(ascii("math:mi")); -#endif - break; - case ID_NUMBER : -#ifdef DEBUG - inds; - fprintf(stderr,"%s\n",tmp->value); - indo; -#else - rstartEl(ascii("math:mn"), rList); - rchars(tmp->value); - rendEl(ascii("math:mn")); -#endif - break; - case ID_OPERATOR : - case ID_DELIMETER : - { -#ifdef DEBUG - inds; fprintf(stderr,"%s\n",tmp->value); indo; -#else - rstartEl(ascii("math:mo"), rList); - runistr(getMathMLEntity(tmp->value,entity)); - rendEl(ascii("math:mo")); -#endif - break; - } - } -} -void Formula::makePrimary(Node *res) -{ - Node *tmp = res; - if( !tmp ) return ; - if( tmp->child ){ - if( tmp->child->id == ID_PRIMARYEXPR ){ - makePrimary(tmp->child); - } - else{ - makeIdentifier(tmp->child); - } - } - if( tmp->next ){ - makeIdentifier(tmp->next); - } -} - -void Formula::makeSubSup(Node *res) -{ - Node *tmp = res; - if( !tmp ) return; - -#ifdef DEBUG - inds; - if( res->id == ID_SUBEXPR ) - fprintf(stderr,"\n"); - else if( res->id == ID_SUPEXPR ) - fprintf(stderr,"\n"); - else - fprintf(stderr,"\n"); -#else - if( res->id == ID_SUBEXPR ) - rstartEl(ascii("math:msub"), rList); - else if( res->id == ID_SUPEXPR ) - rstartEl(ascii("math:msup"), rList); - else - rstartEl(ascii("math:msubsup"), rList); -#endif - - tmp = tmp->child; - if( res->id == ID_SUBSUPEXPR ) { - makeExpr(tmp); - makeBlock(tmp->next); - makeBlock(tmp->next->next); - } - else{ - makeExpr(tmp); - makeExpr(tmp->next); - } - -#ifdef DEBUG - inde; - if( res->id == ID_SUBEXPR ) - fprintf(stderr,"\n"); - else if( res->id == ID_SUPEXPR ) - fprintf(stderr,"\n"); - else - fprintf(stderr,"\n"); -#else - if( res->id == ID_SUBEXPR ) - rendEl(ascii("math:msub")); - else if( res->id == ID_SUPEXPR ) - rendEl(ascii("math:msup")); - else - rendEl(ascii("math:msubsup")); -#endif -} - -void Formula::makeFraction(Node *res) -{ - Node *tmp = res; - if( !tmp ) return; - -#ifdef DEBUG - inds; - fprintf(stderr,"\n"); -#else - rstartEl(ascii("math:mfrac"), rList); -#endif - - tmp = tmp->child; -#ifdef DEBUG - inds; - fprintf(stderr,"\n"); -#else - rstartEl(ascii("math:mrow"), rList); -#endif - - if( res->id == ID_FRACTIONEXPR ) - makeBlock(tmp); - else - makeExprList(tmp); - -#ifdef DEBUG - inde; - fprintf(stderr,"\n"); - inds; - fprintf(stderr,"\n"); -#else - rendEl(ascii("math:mrow")); - rstartEl(ascii("math:mrow"), rList); -#endif - - if( res->id == ID_FRACTIONEXPR ) - makeBlock(tmp->next); - else - makeExprList(tmp->next); - -#ifdef DEBUG - inde; - fprintf(stderr,"\n"); - inde; - fprintf(stderr,"\n"); -#else - rendEl(ascii("math:mrow")); - rendEl(ascii("math:mfrac")); -#endif -} - -void Formula::makeDecoration(Node *res) -{ - int isover = 1; - Node *tmp = res->child; - if( !tmp ) return; - if( !strncmp(tmp->value,"under", 5) ) - isover = 0; -#ifdef DEBUG - inds; - if( isover ) - fprintf(stderr,"\n"); - else - fprintf(stderr,"\n"); -#else - /* accent truḛ, , false 𸣰ڴ. */ - if( isover ){ - padd(ascii("accent"),ascii("CDATA"),ascii("true")); - rstartEl(ascii("math:mover"), rList); - } - else{ - padd(ascii("accentunder"),ascii("CDATA"),ascii("true")); - rstartEl(ascii("math:munder"), rList); - } - pList->clear(); -#endif - - makeBlock(tmp->next); - -#ifdef DEBUG - inds; - fprintf(stderr,"%s\n", getMathMLEntity(tmp->value,entity)); - indo; -#else - rstartEl(ascii("math:mo"), rList); - runistr(getMathMLEntity(tmp->value,entity)); - rendEl(ascii("math:mo")); -#endif - -#ifdef DEBUG - inde; - if( isover ) - fprintf(stderr,"\n"); - else - fprintf(stderr,"\n"); -#else - if( isover ) - rendEl(ascii("math:mover")); - else - rendEl(ascii("math:munder")); -#endif -} - -void Formula::makeRoot(Node *res) -{ - Node *tmp = res; - if( !tmp ) return; -#ifdef DEBUG - inds; - if( tmp->id == ID_SQRTEXPR ) - fprintf(stderr,"\n"); - else - fprintf(stderr,"\n"); -#else - if( tmp->id == ID_SQRTEXPR ) - rstartEl(ascii("math:msqrt"), rList); - else - rstartEl(ascii("math:mroot"), rList); -#endif - - if( tmp->id == ID_SQRTEXPR ){ - makeBlock(tmp->child); - } - else{ - makeBracket(tmp->child); - makeBlock(tmp->child->next); - } - -#ifdef DEBUG - inde; - if( tmp->id == ID_SQRTEXPR ) - fprintf(stderr,"\n"); - else - fprintf(stderr,"\n"); -#else - if( tmp->id == ID_SQRTEXPR ) - rendEl(ascii("math:msqrt")); - else - rendEl(ascii("math:mroot")); -#endif -} -// DVO: add space to avoid warning -void Formula::makeArrow(Node * /*res*/) -{ -} -void Formula::makeAccent(Node *res) -{ - makeDecoration( res ); -} -void Formula::makeParenth(Node *res) -{ - Node *tmp = res; - if( !tmp ) return; -#ifdef DEBUG - inds; - fprintf(stderr,"\n"); - inds; - if( tmp->id == ID_PARENTH ){ - fprintf(stderr,"(\n"); - } - else - fprintf(stderr,"|\n"); - indo; inds; - fprintf(stderr,"\n"); -#else - rstartEl(ascii("math:mrow"), rList); - rstartEl(ascii("math:mo"), rList); - if( tmp->id == ID_PARENTH ) - rchars("("); - else - rchars("|"); - rendEl(ascii("math:mo")); - rstartEl(ascii("math:mrow"), rList); -#endif - - if( tmp->child ) - makeExprList(tmp->child); - -#ifdef DEBUG - inde; - fprintf(stderr,"\n"); - inds; - if( tmp->id == ID_PARENTH ) - fprintf(stderr,")\n"); - else - fprintf(stderr,"|\n"); - indo; - inde; - fprintf(stderr,"\n"); -#else - rendEl(ascii("math:mrow")); - rstartEl(ascii("math:mo"), rList); - if( tmp->id == ID_PARENTH ) - rchars(")"); - else - rchars("|"); - rendEl(ascii("math:mo")); - rendEl(ascii("math:mrow")); -#endif -} - -void Formula::makeFence(Node *res) -{ - Node *tmp = res->child; -#ifdef DEBUG - inds; - fprintf(stderr,"\n",getMathMLEntity(tmp->value, entity), - getMathMLEntity(tmp->next->next->value,entity)); -#else - padd(ascii("open"), ascii("CDATA"), OUString(getMathMLEntity(tmp->value,entity)) ); - padd(ascii("close"), ascii("CDATA"), OUString(getMathMLEntity(tmp->next->next->value,entity)) ); - rstartEl(ascii("math:mfenced"), rList); - pList->clear(); -#endif - - makeExprList(tmp->next); - -#ifdef DEBUG - inde; - fprintf(stderr,"\n"); -#else - rendEl(ascii("math:mfenced")); -#endif -} - -void Formula::makeBracket(Node *res) -{ - makeBlock(res); -} - -void Formula::makeBlock(Node *res) -{ -#ifdef DEBUG - inds; - fprintf(stderr,"\n"); -#else - rstartEl(ascii("math:mrow"), rList); -#endif - - if( res->child ) - makeExprList(res->child); - -#ifdef DEBUG - inde; - fprintf(stderr,"\n"); -#else - rendEl(ascii("math:mrow")); -#endif -} - -// DVO: add space to avoid warning -void Formula::makeBegin(Node * /*res*/) -{ -} - -// DVO: add space to avoid warning -void Formula::makeEnd(Node * /*res*/) -{ -} - -int Formula::parse() -{ - Node *res = 0L; - if( !eq ) return 0; - if( isHwpEQ ){ - MzString a; - // fprintf(stderr,"\n\n[BEFORE]\n[%s]\n",eq); - eq2latex(a,eq); - - int idx=a.find(sal::static_int_cast(0xff)); - while(idx){ - //printf("idx = [%d]\n",idx); - a.replace(idx,0x20); - if((idx = a.find(sal::static_int_cast(0xff),idx+1)) < 0) - break; - } - - char *buf = (char *)malloc(a.length()+1); - bool bStart = false; - int i, j; - for( i = 0, j=0 ; i < a.length() ; i++){ // rtrim and ltrim 32 10 13 - if( bStart ){ - buf[j++] = a[i]; - } - else{ - if( a[i] != 32 && a[i] != 10 && a[i] != 13){ - bStart = true; - buf[j++] = a[i]; - } - } - } - buf[j] = 0; - for( i = j-1 ; i >= 0 ; i++ ){ - if( buf[i] == 32 || buf[i] == 10 || buf[i] == 13 ){ - buf[i] = 0; - } - else - break; - } - // fprintf(stderr,"\n\n[RESULT]\n[%s]\n",a.c_str()); - if( strlen(buf) > 0 ) - res = mainParse( a.c_str() ); - else - res = 0L; - free(buf); - } - else{ - res = mainParse( eq ); - } - - if( res ){ - makeMathML( res ); - } - Node *tmpNode; - int count = nodelist.count(); - for( int i = 0 ; i < count ; i++ ){ - tmpNode = nodelist.remove(0); - delete tmpNode; - } - - return 0; -} - -void Formula::trim() -{ - int len = strlen(eq); - char *buf = (char *)malloc(len+1); - bool bStart = false; - int i, j; - for( i = 0, j=0 ; i < len ; i++){ // rtrim and ltrim 32 10 13 - if( bStart ){ - buf[j++] = eq[i]; - } - else{ - if( eq[i] != 32 && eq[i] != 10 && eq[i] != 13){ - bStart = true; - buf[j++] = eq[i]; - } - } - } - buf[j] = 0; - for( i = j-1 ; i >= 0 ; i++ ){ - if( buf[i] == 32 || buf[i] == 10 || buf[i] == 13 ){ - buf[i] = 0; - } - else - break; - } - if( strlen(buf) > 0 ) - strcpy(eq, buf); - else - eq = 0L; - free(buf); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/hwpfilter/source/formula.cxx b/hwpfilter/source/formula.cxx new file mode 100644 index 000000000000..d2a73ac72d07 --- /dev/null +++ b/hwpfilter/source/formula.cxx @@ -0,0 +1,689 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "formula.h" + +#include "mzstring.h" +#include "nodes.h" +#include "mapping.h" +#include "hwpeq.h" +#include + +extern LinkedList nodelist; + +#ifndef DEBUG + +#include "hcode.h" + +static hchar entity[32]; +#define ascii(x) OUString::createFromAscii(x) +#define rstartEl(x,y) do { if (m_rxDocumentHandler.is()) m_rxDocumentHandler->startElement(x,y); } while(0) +#define rendEl(x) do { if (m_rxDocumentHandler.is()) m_rxDocumentHandler->endElement(x); } while(0) +#define rchars(x) do { if (m_rxDocumentHandler.is()) m_rxDocumentHandler->characters(ascii(x)); } while(0) +#define runistr(x) do { if (m_rxDocumentHandler.is()) m_rxDocumentHandler->characters(OUString(x)); } while(0) +#define reucstr(x,y) do { if (m_rxDocumentHandler.is()) m_rxDocumentHandler->characters(OUString(x,y, RTL_TEXTENCODING_EUC_KR)); } while(0) +#define padd(x,y,z) pList->addAttribute(x,y,z) +#else +static char entity[32]; +static int indent = 0; +#define inds indent++; for(int i = 0 ; i < indent ; i++) fprintf(stderr," ") +#define inde for(int i = 0 ; i < indent ; i++) fprintf(stderr," "); indent-- +#define indo indent--; +#endif + +extern Node *mainParse(const char *); + + +void Formula::makeMathML(Node *res) +{ + Node *tmp = res; + if( !tmp ) return; +#ifdef DEBUG + inds; + fprintf(stderr,"\n"); +#else + padd(ascii("xmlns:math"), ascii("CDATA"), ascii("http://www.w3.org/1998/Math/MathML")); + rstartEl(ascii("math:math"), rList); + pList->clear(); + rstartEl(ascii("math:semantics"), rList); +#endif + if( tmp->child ) + makeLines( tmp->child ); + +#ifdef DEBUG + inds; + fprintf(stderr,"\n"); + indo; + inde; + fprintf(stderr,"\n"); +#else + rendEl(ascii("math:semantics")); + rendEl(ascii("math:math")); +#endif +} + +void Formula::makeLines(Node *res) +{ + Node *tmp = res; + if( !tmp ) return; + + if( tmp->child ){ + if( tmp->child->id == ID_LINES ) + makeLines( tmp->child ); + else + makeLine( tmp->child ); + } + if( tmp->next ) + makeLine( tmp->next ); +} + +void Formula::makeLine(Node *res) +{ + if( !res ) return; +#ifdef DEBUG + inds; fprintf(stderr,"\n"); +#else + rstartEl(ascii("math:mrow"), rList); +#endif + if( res->child ) + makeExprList( res->child ); +#ifdef DEBUG + inde; fprintf(stderr,"\n"); +#else + rendEl(ascii("math:mrow")); +#endif +} + +void Formula::makeExprList(Node *res) +{ + if( !res ) return; + Node *tmp = res->child; + if( !tmp ) return ; + + if( tmp->id == ID_EXPRLIST ){ + Node *next = tmp->next; + makeExprList( tmp ) ; + if( next ) + makeExpr( next ); + } + else + makeExpr( tmp ); +} + +void Formula::makeExpr(Node *res) +{ + if( !res ) return; + Node *tmp = res->child; + if( !tmp ) return; + switch( tmp->id ) { + case ID_PRIMARYEXPR: + if( tmp->next ){ +#ifdef DEBUG + inds; + fprintf(stderr,"\n"); +#else + rstartEl(ascii("math:mrow"), rList); +#endif + } + + makePrimary(tmp); + + if( tmp->next ){ +#ifdef DEBUG + inde; fprintf(stderr,"\n"); +#else + rendEl(ascii("math:mrow")); +#endif + } + break; + case ID_SUBEXPR: + case ID_SUPEXPR: + case ID_SUBSUPEXPR: + makeSubSup(tmp); + break; + case ID_FRACTIONEXPR: + case ID_OVER: + makeFraction(tmp); + break; + case ID_DECORATIONEXPR: + makeDecoration(tmp); + break; + case ID_SQRTEXPR: + case ID_ROOTEXPR: + makeRoot(tmp); + break; + case ID_ARROWEXPR: + makeArrow(tmp); + break; + case ID_ACCENTEXPR: + makeAccent(tmp); + break; + case ID_PARENTH: + case ID_ABS: + makeParenth(tmp); + break; + case ID_FENCE: + makeFence(tmp); + break; + case ID_BLOCK: + makeBlock(tmp); + case ID_BEGIN: + makeBegin(tmp); + case ID_END: + makeEnd(tmp); + break; + } +} + +void Formula::makeIdentifier(Node *res) +{ + Node *tmp = res; + if( !tmp ) return; + if( !tmp->value ) return; + switch( tmp->id ){ + case ID_CHARACTER : +#ifdef DEBUG + inds; + fprintf(stderr,"%s\n",tmp->value); + indo; +#else + rstartEl(ascii("math:mi"), rList); + rchars(tmp->value); + rendEl(ascii("math:mi")); +#endif + break; + case ID_STRING : + { +#ifdef DEBUG +#else + rstartEl(ascii("math:mi"), rList); + reucstr(tmp->value, strlen(tmp->value)); + rendEl(ascii("math:mi")); +#endif + } + break; + case ID_IDENTIFIER : +#ifdef DEBUG + inds; + fprintf(stderr,"%s\n",getMathMLEntity(tmp->value, entity)); + indo; +#else + rstartEl(ascii("math:mi"), rList); + runistr(getMathMLEntity(tmp->value, entity)); + rendEl(ascii("math:mi")); +#endif + break; + case ID_NUMBER : +#ifdef DEBUG + inds; + fprintf(stderr,"%s\n",tmp->value); + indo; +#else + rstartEl(ascii("math:mn"), rList); + rchars(tmp->value); + rendEl(ascii("math:mn")); +#endif + break; + case ID_OPERATOR : + case ID_DELIMETER : + { +#ifdef DEBUG + inds; fprintf(stderr,"%s\n",tmp->value); indo; +#else + rstartEl(ascii("math:mo"), rList); + runistr(getMathMLEntity(tmp->value,entity)); + rendEl(ascii("math:mo")); +#endif + break; + } + } +} +void Formula::makePrimary(Node *res) +{ + Node *tmp = res; + if( !tmp ) return ; + if( tmp->child ){ + if( tmp->child->id == ID_PRIMARYEXPR ){ + makePrimary(tmp->child); + } + else{ + makeIdentifier(tmp->child); + } + } + if( tmp->next ){ + makeIdentifier(tmp->next); + } +} + +void Formula::makeSubSup(Node *res) +{ + Node *tmp = res; + if( !tmp ) return; + +#ifdef DEBUG + inds; + if( res->id == ID_SUBEXPR ) + fprintf(stderr,"\n"); + else if( res->id == ID_SUPEXPR ) + fprintf(stderr,"\n"); + else + fprintf(stderr,"\n"); +#else + if( res->id == ID_SUBEXPR ) + rstartEl(ascii("math:msub"), rList); + else if( res->id == ID_SUPEXPR ) + rstartEl(ascii("math:msup"), rList); + else + rstartEl(ascii("math:msubsup"), rList); +#endif + + tmp = tmp->child; + if( res->id == ID_SUBSUPEXPR ) { + makeExpr(tmp); + makeBlock(tmp->next); + makeBlock(tmp->next->next); + } + else{ + makeExpr(tmp); + makeExpr(tmp->next); + } + +#ifdef DEBUG + inde; + if( res->id == ID_SUBEXPR ) + fprintf(stderr,"\n"); + else if( res->id == ID_SUPEXPR ) + fprintf(stderr,"\n"); + else + fprintf(stderr,"\n"); +#else + if( res->id == ID_SUBEXPR ) + rendEl(ascii("math:msub")); + else if( res->id == ID_SUPEXPR ) + rendEl(ascii("math:msup")); + else + rendEl(ascii("math:msubsup")); +#endif +} + +void Formula::makeFraction(Node *res) +{ + Node *tmp = res; + if( !tmp ) return; + +#ifdef DEBUG + inds; + fprintf(stderr,"\n"); +#else + rstartEl(ascii("math:mfrac"), rList); +#endif + + tmp = tmp->child; +#ifdef DEBUG + inds; + fprintf(stderr,"\n"); +#else + rstartEl(ascii("math:mrow"), rList); +#endif + + if( res->id == ID_FRACTIONEXPR ) + makeBlock(tmp); + else + makeExprList(tmp); + +#ifdef DEBUG + inde; + fprintf(stderr,"\n"); + inds; + fprintf(stderr,"\n"); +#else + rendEl(ascii("math:mrow")); + rstartEl(ascii("math:mrow"), rList); +#endif + + if( res->id == ID_FRACTIONEXPR ) + makeBlock(tmp->next); + else + makeExprList(tmp->next); + +#ifdef DEBUG + inde; + fprintf(stderr,"\n"); + inde; + fprintf(stderr,"\n"); +#else + rendEl(ascii("math:mrow")); + rendEl(ascii("math:mfrac")); +#endif +} + +void Formula::makeDecoration(Node *res) +{ + int isover = 1; + Node *tmp = res->child; + if( !tmp ) return; + if( !strncmp(tmp->value,"under", 5) ) + isover = 0; +#ifdef DEBUG + inds; + if( isover ) + fprintf(stderr,"\n"); + else + fprintf(stderr,"\n"); +#else + /* accent truḛ, , false 𸣰ڴ. */ + if( isover ){ + padd(ascii("accent"),ascii("CDATA"),ascii("true")); + rstartEl(ascii("math:mover"), rList); + } + else{ + padd(ascii("accentunder"),ascii("CDATA"),ascii("true")); + rstartEl(ascii("math:munder"), rList); + } + pList->clear(); +#endif + + makeBlock(tmp->next); + +#ifdef DEBUG + inds; + fprintf(stderr,"%s\n", getMathMLEntity(tmp->value,entity)); + indo; +#else + rstartEl(ascii("math:mo"), rList); + runistr(getMathMLEntity(tmp->value,entity)); + rendEl(ascii("math:mo")); +#endif + +#ifdef DEBUG + inde; + if( isover ) + fprintf(stderr,"\n"); + else + fprintf(stderr,"\n"); +#else + if( isover ) + rendEl(ascii("math:mover")); + else + rendEl(ascii("math:munder")); +#endif +} + +void Formula::makeRoot(Node *res) +{ + Node *tmp = res; + if( !tmp ) return; +#ifdef DEBUG + inds; + if( tmp->id == ID_SQRTEXPR ) + fprintf(stderr,"\n"); + else + fprintf(stderr,"\n"); +#else + if( tmp->id == ID_SQRTEXPR ) + rstartEl(ascii("math:msqrt"), rList); + else + rstartEl(ascii("math:mroot"), rList); +#endif + + if( tmp->id == ID_SQRTEXPR ){ + makeBlock(tmp->child); + } + else{ + makeBracket(tmp->child); + makeBlock(tmp->child->next); + } + +#ifdef DEBUG + inde; + if( tmp->id == ID_SQRTEXPR ) + fprintf(stderr,"\n"); + else + fprintf(stderr,"\n"); +#else + if( tmp->id == ID_SQRTEXPR ) + rendEl(ascii("math:msqrt")); + else + rendEl(ascii("math:mroot")); +#endif +} +// DVO: add space to avoid warning +void Formula::makeArrow(Node * /*res*/) +{ +} +void Formula::makeAccent(Node *res) +{ + makeDecoration( res ); +} +void Formula::makeParenth(Node *res) +{ + Node *tmp = res; + if( !tmp ) return; +#ifdef DEBUG + inds; + fprintf(stderr,"\n"); + inds; + if( tmp->id == ID_PARENTH ){ + fprintf(stderr,"(\n"); + } + else + fprintf(stderr,"|\n"); + indo; inds; + fprintf(stderr,"\n"); +#else + rstartEl(ascii("math:mrow"), rList); + rstartEl(ascii("math:mo"), rList); + if( tmp->id == ID_PARENTH ) + rchars("("); + else + rchars("|"); + rendEl(ascii("math:mo")); + rstartEl(ascii("math:mrow"), rList); +#endif + + if( tmp->child ) + makeExprList(tmp->child); + +#ifdef DEBUG + inde; + fprintf(stderr,"\n"); + inds; + if( tmp->id == ID_PARENTH ) + fprintf(stderr,")\n"); + else + fprintf(stderr,"|\n"); + indo; + inde; + fprintf(stderr,"\n"); +#else + rendEl(ascii("math:mrow")); + rstartEl(ascii("math:mo"), rList); + if( tmp->id == ID_PARENTH ) + rchars(")"); + else + rchars("|"); + rendEl(ascii("math:mo")); + rendEl(ascii("math:mrow")); +#endif +} + +void Formula::makeFence(Node *res) +{ + Node *tmp = res->child; +#ifdef DEBUG + inds; + fprintf(stderr,"\n",getMathMLEntity(tmp->value, entity), + getMathMLEntity(tmp->next->next->value,entity)); +#else + padd(ascii("open"), ascii("CDATA"), OUString(getMathMLEntity(tmp->value,entity)) ); + padd(ascii("close"), ascii("CDATA"), OUString(getMathMLEntity(tmp->next->next->value,entity)) ); + rstartEl(ascii("math:mfenced"), rList); + pList->clear(); +#endif + + makeExprList(tmp->next); + +#ifdef DEBUG + inde; + fprintf(stderr,"\n"); +#else + rendEl(ascii("math:mfenced")); +#endif +} + +void Formula::makeBracket(Node *res) +{ + makeBlock(res); +} + +void Formula::makeBlock(Node *res) +{ +#ifdef DEBUG + inds; + fprintf(stderr,"\n"); +#else + rstartEl(ascii("math:mrow"), rList); +#endif + + if( res->child ) + makeExprList(res->child); + +#ifdef DEBUG + inde; + fprintf(stderr,"\n"); +#else + rendEl(ascii("math:mrow")); +#endif +} + +// DVO: add space to avoid warning +void Formula::makeBegin(Node * /*res*/) +{ +} + +// DVO: add space to avoid warning +void Formula::makeEnd(Node * /*res*/) +{ +} + +int Formula::parse() +{ + Node *res = 0L; + if( !eq ) return 0; + if( isHwpEQ ){ + MzString a; + // fprintf(stderr,"\n\n[BEFORE]\n[%s]\n",eq); + eq2latex(a,eq); + + int idx=a.find(sal::static_int_cast(0xff)); + while(idx){ + //printf("idx = [%d]\n",idx); + a.replace(idx,0x20); + if((idx = a.find(sal::static_int_cast(0xff),idx+1)) < 0) + break; + } + + char *buf = (char *)malloc(a.length()+1); + bool bStart = false; + int i, j; + for( i = 0, j=0 ; i < a.length() ; i++){ // rtrim and ltrim 32 10 13 + if( bStart ){ + buf[j++] = a[i]; + } + else{ + if( a[i] != 32 && a[i] != 10 && a[i] != 13){ + bStart = true; + buf[j++] = a[i]; + } + } + } + buf[j] = 0; + for( i = j-1 ; i >= 0 ; i++ ){ + if( buf[i] == 32 || buf[i] == 10 || buf[i] == 13 ){ + buf[i] = 0; + } + else + break; + } + // fprintf(stderr,"\n\n[RESULT]\n[%s]\n",a.c_str()); + if( strlen(buf) > 0 ) + res = mainParse( a.c_str() ); + else + res = 0L; + free(buf); + } + else{ + res = mainParse( eq ); + } + + if( res ){ + makeMathML( res ); + } + Node *tmpNode; + int count = nodelist.count(); + for( int i = 0 ; i < count ; i++ ){ + tmpNode = nodelist.remove(0); + delete tmpNode; + } + + return 0; +} + +void Formula::trim() +{ + int len = strlen(eq); + char *buf = (char *)malloc(len+1); + bool bStart = false; + int i, j; + for( i = 0, j=0 ; i < len ; i++){ // rtrim and ltrim 32 10 13 + if( bStart ){ + buf[j++] = eq[i]; + } + else{ + if( eq[i] != 32 && eq[i] != 10 && eq[i] != 13){ + bStart = true; + buf[j++] = eq[i]; + } + } + } + buf[j] = 0; + for( i = j-1 ; i >= 0 ; i++ ){ + if( buf[i] == 32 || buf[i] == 10 || buf[i] == 13 ){ + buf[i] = 0; + } + else + break; + } + if( strlen(buf) > 0 ) + strcpy(eq, buf); + else + eq = 0L; + free(buf); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/hwpfilter/source/grammar.cpp b/hwpfilter/source/grammar.cpp deleted file mode 100644 index 2afc1d897490..000000000000 --- a/hwpfilter/source/grammar.cpp +++ /dev/null @@ -1,1456 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - - -/* A Bison parser, made from grammar.y - by GNU Bison version 1.28 */ - -#define YYBISON 1 /* Identify Bison output. */ - -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -#ifndef YYMAXDEPTH -#define YYMAXDEPTH 0 -#endif - -#define ACCENT 257 -#define SMALL_GREEK 258 -#define CAPITAL_GREEK 259 -#define BINARY_OPERATOR 260 -#define RELATION_OPERATOR 261 -#define ARROW 262 -#define GENERAL_IDEN 263 -#define GENERAL_OPER 264 -#define BIG_SYMBOL 265 -#define FUNCTION 266 -#define ROOT 267 -#define FRACTION 268 -#define SUBSUP 269 -#define EQOVER 270 -#define DELIMETER 271 -#define LARGE_DELIM 272 -#define DECORATION 273 -#define SPACE_SYMBOL 274 -#define CHARACTER 275 -#define STRING 276 -#define OPERATOR 277 -#define EQBEGIN 278 -#define EQEND 279 -#define EQLEFT 280 -#define EQRIGHT 281 -#define NEWLINE 282 -#define LEFT_DELIM 283 -#define RIGHT_DELIM 284 -#define DIGIT 285 - -#line 1 "grammar.y" - -#include -#include - -#include "nodes.h" - -LinkedList nodelist; - -Node *mainParse(const char *_code); -void yyerror(const char *); -int yylex(); -void initFlex( const char *s ); -void viewResult(Node *res); - -Node *top=0L; - -int Node::count = 0; - -#define allocValue(x,y) \ -x = (char *)malloc( strlen(y) +1 ); \ -strcpy(x,y) - -#define allocChar(x,y) \ -x = (char *)malloc(2); \ -sprintf(x,"%c",y) -#ifdef PARSE_DEBUG -#define debug printf -#else -int debug(const char *format, ...); -#endif - - -#line 35 "grammar.y" -typedef union { - char *dval; - char *str; - Node *ptr; -} YYSTYPE; -#include - -#ifndef __cplusplus -#ifndef __STDC__ -#define const -#endif -#endif - - - -#define YYFINAL 102 -#define YYFLAG -32768 -#define YYNTBASE 43 - -#define YYTRANSLATE(x) ((unsigned)(x) <= 285 ? yytranslate[x] : 66) - -static const char yytranslate[] = { 0, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 33, - 37, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 36, - 2, 40, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 34, 2, 38, 42, 41, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 35, 32, 39, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 1, 3, 4, 5, 6, - 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, - 27, 28, 29, 30, 31 -}; - -#if YYDEBUG != 0 -static const short yyprhs[] = { 0, - 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, - 20, 22, 24, 26, 28, 30, 32, 34, 36, 39, - 42, 45, 48, 51, 54, 58, 60, 63, 66, 69, - 72, 75, 79, 81, 85, 89, 92, 96, 99, 103, - 106, 110, 114, 120, 124, 130, 132, 135, 137, 140, - 143, 147, 150, 154, 157, 159, 161, 165, 167, 169, - 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, - 192, 194 -}; - -static const short yyrhs[] = { 4, - 0, 9, 0, 10, 0, 5, 0, 11, 0, 12, - 0, 20, 0, 21, 0, 7, 0, 6, 0, 23, - 0, 17, 0, 18, 0, 8, 0, 32, 0, 31, - 0, 22, 0, 43, 0, 44, 43, 0, 26, 33, - 0, 26, 34, 0, 26, 35, 0, 26, 36, 0, - 26, 32, 0, 26, 32, 32, 0, 29, 0, 27, - 37, 0, 27, 38, 0, 27, 39, 0, 27, 40, - 0, 27, 32, 0, 27, 32, 32, 0, 30, 0, - 45, 64, 46, 0, 33, 64, 37, 0, 33, 37, - 0, 35, 64, 39, 0, 35, 39, 0, 34, 64, - 38, 0, 34, 38, 0, 65, 41, 65, 0, 65, - 42, 65, 0, 65, 41, 49, 42, 49, 0, 14, - 49, 49, 0, 35, 64, 16, 64, 39, 0, 3, - 0, 54, 49, 0, 19, 0, 56, 49, 0, 13, - 49, 0, 13, 50, 49, 0, 24, 49, 0, 24, - 49, 49, 0, 25, 49, 0, 62, 0, 63, 0, - 62, 28, 63, 0, 64, 0, 65, 0, 64, 65, - 0, 49, 0, 48, 0, 47, 0, 51, 0, 52, - 0, 53, 0, 57, 0, 58, 0, 55, 0, 44, - 0, 59, 0, 60, 0 -}; - -#endif - -#if YYDEBUG != 0 -static const short yyrline[] = { 0, - 59, 61, 62, 63, 64, 65, 66, 67, 68, 69, - 70, 71, 72, 73, 74, 75, 76, 79, 81, 84, - 86, 87, 88, 89, 90, 91, 94, 96, 97, 98, - 99, 100, 101, 104, 108, 110, 113, 115, 118, 120, - 123, 125, 126, 129, 133, 138, 142, 145, 149, 153, - 155, 158, 160, 163, 168, 172, 174, 177, 181, 183, - 186, 188, 189, 190, 191, 192, 193, 194, 195, 196, - 197, 198 -}; -#endif - - -#if YYDEBUG != 0 || defined (YYERROR_VERBOSE) - -static const char * const yytname[] = { "$","error","$undefined.","ACCENT", -"SMALL_GREEK","CAPITAL_GREEK","BINARY_OPERATOR","RELATION_OPERATOR","ARROW", -"GENERAL_IDEN","GENERAL_OPER","BIG_SYMBOL","FUNCTION","ROOT","FRACTION","SUBSUP", -"EQOVER","DELIMETER","LARGE_DELIM","DECORATION","SPACE_SYMBOL","CHARACTER","STRING", -"OPERATOR","EQBEGIN","EQEND","EQLEFT","EQRIGHT","NEWLINE","LEFT_DELIM","RIGHT_DELIM", -"DIGIT","'|'","'('","'['","'{'","'<'","')'","']'","'}'","'>'","'_'","'^'","Identifier", -"PrimaryExpr","EQLeft","EQRight","Fence","Parenth","Block","Bracket","SubSupExpr", -"FractionExpr","OverExpr","Accent","AccentExpr","Decoration","DecorationExpr", -"RootExpr","BeginExpr","EndExpr","MathML","Lines","Line","ExprList","Expr", NULL -}; -#endif - -static const short yyr1[] = { 0, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 44, 44, 45, - 45, 45, 45, 45, 45, 45, 46, 46, 46, 46, - 46, 46, 46, 47, 48, 48, 49, 49, 50, 50, - 51, 51, 51, 52, 53, 54, 55, 56, 57, 58, - 58, 59, 59, 60, 61, 62, 62, 63, 64, 64, - 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, - 65, 65 -}; - -static const short yyr2[] = { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, - 2, 2, 2, 2, 3, 1, 2, 2, 2, 2, - 2, 3, 1, 3, 3, 2, 3, 2, 3, 2, - 3, 3, 5, 3, 5, 1, 2, 1, 2, 2, - 3, 2, 3, 2, 1, 1, 3, 1, 1, 2, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1 -}; - -static const short yydefact[] = { 0, - 46, 1, 4, 10, 9, 14, 2, 3, 5, 6, - 0, 0, 12, 13, 48, 7, 8, 17, 11, 0, - 0, 0, 26, 16, 15, 0, 0, 18, 70, 0, - 63, 62, 61, 64, 65, 66, 0, 69, 0, 67, - 68, 71, 72, 55, 56, 58, 59, 0, 0, 50, - 0, 0, 52, 54, 24, 20, 21, 22, 23, 36, - 0, 38, 0, 19, 0, 47, 49, 0, 60, 0, - 0, 40, 0, 0, 51, 44, 53, 25, 35, 0, - 37, 0, 33, 34, 57, 61, 41, 42, 39, 0, - 31, 27, 28, 29, 30, 0, 45, 32, 43, 0, - 0, 0 -}; - -static const short yydefgoto[] = { 28, - 29, 30, 84, 31, 32, 33, 51, 34, 35, 36, - 37, 38, 39, 40, 41, 42, 43, 100, 44, 45, - 46, 47 -}; - -static const short yypact[] = { 393, --32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, - -30, -19,-32768,-32768,-32768,-32768,-32768,-32768,-32768, -19, - -19, -3,-32768,-32768,-32768, 290, 107,-32768, 425, 393, --32768,-32768,-32768,-32768,-32768,-32768, -19,-32768, -19,-32768, --32768,-32768,-32768, -20,-32768, 393, -21, 218, 107,-32768, - -19, -19, -19,-32768, -15,-32768,-32768,-32768,-32768,-32768, - 325,-32768, 70,-32768, 360,-32768,-32768, 393, -21, 393, - 393,-32768, 254, 144,-32768,-32768,-32768,-32768,-32768, 393, --32768, -25,-32768,-32768,-32768, -31, -21, -21,-32768, 181, - -14,-32768,-32768,-32768,-32768, -19,-32768,-32768,-32768, 22, - 23,-32768 -}; - -static const short yypgoto[] = { -2, --32768,-32768,-32768,-32768,-32768, -11,-32768,-32768,-32768,-32768, --32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, -33, - -24, -27 -}; - - -#define YYLAST 457 - - -static const short yytable[] = { 50, - 52, 61, 63, 48, 49, 65, 91, 68, 53, 54, - 96, 92, 93, 94, 95, 49, 78, 98, 69, 70, - 71, 101, 102, 73, 74, 66, 64, 67, 55, 56, - 57, 58, 59, 69, 85, 69, 0, 69, 0, 75, - 76, 77, 87, 88, 0, 69, 69, 0, 0, 0, - 0, 0, 0, 0, 0, 90, 0, 0, 86, 0, - 0, 0, 69, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, - 9, 10, 11, 12, 99, 80, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 0, 0, 23, 0, - 24, 25, 26, 0, 27, 0, 0, 0, 81, 1, - 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, - 12, 0, 0, 13, 14, 15, 16, 17, 18, 19, - 20, 21, 22, 0, 0, 23, 0, 24, 25, 26, - 0, 27, 0, 0, 0, 62, 1, 2, 3, 4, - 5, 6, 7, 8, 9, 10, 11, 12, 0, 0, - 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, - 0, 0, 23, 0, 24, 25, 26, 0, 27, 0, - 0, 0, 81, 1, 2, 3, 4, 5, 6, 7, - 8, 9, 10, 11, 12, 0, 0, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 0, 0, 23, - 0, 24, 25, 26, 0, 27, 0, 0, 0, 97, - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, - 11, 12, 0, 0, 13, 14, 15, 16, 17, 18, - 19, 20, 21, 22, 0, 0, 23, 0, 24, 25, - 26, 0, 27, 0, 0, 72, 1, 2, 3, 4, - 5, 6, 7, 8, 9, 10, 11, 12, 0, 0, - 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, - 0, 0, 23, 0, 24, 25, 26, 0, 27, 0, - 0, 89, 1, 2, 3, 4, 5, 6, 7, 8, - 9, 10, 11, 12, 0, 0, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 0, 0, 23, 0, - 24, 25, 26, 0, 27, 0, 60, 1, 2, 3, - 4, 5, 6, 7, 8, 9, 10, 11, 12, 0, - 0, 13, 14, 15, 16, 17, 18, 19, 20, 21, - 22, 0, 0, 23, 0, 24, 25, 26, 0, 27, - 0, 79, 1, 2, 3, 4, 5, 6, 7, 8, - 9, 10, 11, 12, 0, 0, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 82, 0, 23, 83, - 24, 25, 26, 0, 27, 1, 2, 3, 4, 5, - 6, 7, 8, 9, 10, 11, 12, 0, 0, 13, - 14, 15, 16, 17, 18, 19, 20, 21, 22, 0, - 0, 23, 0, 24, 25, 26, 0, 27, 2, 3, - 4, 5, 6, 7, 8, 9, 10, 0, 0, 0, - 0, 13, 14, 0, 16, 17, 18, 19, 0, 0, - 0, 0, 0, 0, 0, 24, 25 -}; - -static const short yycheck[] = { 11, - 12, 26, 27, 34, 35, 30, 32, 28, 20, 21, - 42, 37, 38, 39, 40, 35, 32, 32, 46, 41, - 42, 0, 0, 48, 49, 37, 29, 39, 32, 33, - 34, 35, 36, 61, 68, 63, -1, 65, -1, 51, - 52, 53, 70, 71, -1, 73, 74, -1, -1, -1, - -1, -1, -1, -1, -1, 80, -1, -1, 70, -1, - -1, -1, 90, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 3, 4, 5, 6, 7, 8, 9, 10, - 11, 12, 13, 14, 96, 16, 17, 18, 19, 20, - 21, 22, 23, 24, 25, 26, -1, -1, 29, -1, - 31, 32, 33, -1, 35, -1, -1, -1, 39, 3, - 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, - 14, -1, -1, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, -1, -1, 29, -1, 31, 32, 33, - -1, 35, -1, -1, -1, 39, 3, 4, 5, 6, - 7, 8, 9, 10, 11, 12, 13, 14, -1, -1, - 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, - -1, -1, 29, -1, 31, 32, 33, -1, 35, -1, - -1, -1, 39, 3, 4, 5, 6, 7, 8, 9, - 10, 11, 12, 13, 14, -1, -1, 17, 18, 19, - 20, 21, 22, 23, 24, 25, 26, -1, -1, 29, - -1, 31, 32, 33, -1, 35, -1, -1, -1, 39, - 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, - 13, 14, -1, -1, 17, 18, 19, 20, 21, 22, - 23, 24, 25, 26, -1, -1, 29, -1, 31, 32, - 33, -1, 35, -1, -1, 38, 3, 4, 5, 6, - 7, 8, 9, 10, 11, 12, 13, 14, -1, -1, - 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, - -1, -1, 29, -1, 31, 32, 33, -1, 35, -1, - -1, 38, 3, 4, 5, 6, 7, 8, 9, 10, - 11, 12, 13, 14, -1, -1, 17, 18, 19, 20, - 21, 22, 23, 24, 25, 26, -1, -1, 29, -1, - 31, 32, 33, -1, 35, -1, 37, 3, 4, 5, - 6, 7, 8, 9, 10, 11, 12, 13, 14, -1, - -1, 17, 18, 19, 20, 21, 22, 23, 24, 25, - 26, -1, -1, 29, -1, 31, 32, 33, -1, 35, - -1, 37, 3, 4, 5, 6, 7, 8, 9, 10, - 11, 12, 13, 14, -1, -1, 17, 18, 19, 20, - 21, 22, 23, 24, 25, 26, 27, -1, 29, 30, - 31, 32, 33, -1, 35, 3, 4, 5, 6, 7, - 8, 9, 10, 11, 12, 13, 14, -1, -1, 17, - 18, 19, 20, 21, 22, 23, 24, 25, 26, -1, - -1, 29, -1, 31, 32, 33, -1, 35, 4, 5, - 6, 7, 8, 9, 10, 11, 12, -1, -1, -1, - -1, 17, 18, -1, 20, 21, 22, 23, -1, -1, - -1, -1, -1, -1, -1, 31, 32 -}; -/* -*-C-*- Note some compilers choke on comments on `#line' lines. */ -#line 3 "/usr/lib/bison.simple" -/* This file comes from bison-1.28. */ - -/* Skeleton output parser for bison, - Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -/* As a special exception, when this file is copied by Bison into a - Bison output file, you may use that output file without restriction. - This special exception was added by the Free Software Foundation - in version 1.24 of Bison. */ - -/* This is the parser code that is written into each bison parser - when the %semantic_parser declaration is not specified in the grammar. - It was written by Richard Stallman by simplifying the hairy parser - used when %semantic_parser is specified. */ - -#ifndef YYSTACK_USE_ALLOCA -#ifdef alloca -#define YYSTACK_USE_ALLOCA -#else /* alloca not defined */ -#ifdef __GNUC__ -#define YYSTACK_USE_ALLOCA -#define alloca __builtin_alloca -#else /* not GNU C. */ -#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386)) -#define YYSTACK_USE_ALLOCA -#include -#else /* not sparc */ -#if defined(_AIX) - #pragma alloca -#define YYSTACK_USE_ALLOCA -#endif /* not _AIX */ -#endif /* not sparc */ -#endif /* not GNU C */ -#endif /* alloca not defined */ -#endif /* YYSTACK_USE_ALLOCA not defined */ - -#ifdef YYSTACK_USE_ALLOCA -#define YYSTACK_ALLOC alloca -#else -#define YYSTACK_ALLOC malloc -#endif - -/* Note: there must be only one dollar sign in this file. - It is replaced by the list of actions, each action - as one case of the switch. */ - -#define yyerrok (yyerrstatus = 0) -#define yyclearin (yychar = YYEMPTY) -#define YYEMPTY -2 -#define YYEOF 0 -#define YYACCEPT goto yyacceptlab -#define YYABORT goto yyabortlab -#define YYERROR goto yyerrlab1 -/* Like YYERROR except do call yyerror. - This remains here temporarily to ease the - transition to the new meaning of YYERROR, for GCC. - Once GCC version 2 has supplanted version 1, this can go. */ -#define YYFAIL goto yyerrlab -#define YYRECOVERING() (!!yyerrstatus) -#define YYBACKUP(token, value) \ -do \ - if (yychar == YYEMPTY && yylen == 1) \ - { yychar = (token), yylval = (value); \ - yychar1 = YYTRANSLATE (yychar); \ - YYPOPSTACK; \ - goto yybackup; \ - } \ - else \ - { yyerror ("syntax error: cannot back up"); YYERROR; } \ -while (0) - -#define YYTERROR 1 -#define YYERRCODE 256 - -#ifndef YYPURE -#define YYLEX yylex() -#endif - -#ifdef YYPURE -#ifdef YYLSP_NEEDED -#ifdef YYLEX_PARAM -#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM) -#else -#define YYLEX yylex(&yylval, &yylloc) -#endif -#else /* not YYLSP_NEEDED */ -#ifdef YYLEX_PARAM -#define YYLEX yylex(&yylval, YYLEX_PARAM) -#else -#define YYLEX yylex(&yylval) -#endif -#endif /* not YYLSP_NEEDED */ -#endif - -/* If nonreentrant, generate the variables here */ - -#ifndef YYPURE - -int yychar; /* the lookahead symbol */ -YYSTYPE yylval; /* the semantic value of the */ - /* lookahead symbol */ - -#ifdef YYLSP_NEEDED -YYLTYPE yylloc; /* location data for the lookahead */ - /* symbol */ -#endif - -int yynerrs; /* number of parse errors so far */ -#endif /* not YYPURE */ - -#if YYDEBUG != 0 -int yydebug; /* nonzero means print parse trace */ -/* Since this is uninitialized, it does not stop multiple parsers - from coexisting. */ -#endif - -/* YYINITDEPTH indicates the initial size of the parser's stacks */ - -#ifndef YYINITDEPTH -#define YYINITDEPTH 200 -#endif - -/* YYMAXDEPTH is the maximum size the stacks can grow to - (effective only if the built-in stack extension method is used). */ - -#if YYMAXDEPTH == 0 -#undef YYMAXDEPTH -#endif - -#ifndef YYMAXDEPTH -#define YYMAXDEPTH 10000 -#endif - -/* Define __yy_memcpy. Note that the size argument - should be passed with type unsigned int, because that is what the non-GCC - definitions require. With GCC, __builtin_memcpy takes an arg - of type size_t, but it can handle unsigned int. */ - -#if defined __GNUC__ -#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ -#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT) -#endif -#else /* not GNU C or C++ */ -#ifndef __cplusplus - -/* This is the most reliable way to avoid incompatibilities - in available built-in functions on various systems. */ -static void -__yy_memcpy (to, from, count) - char *to; - char *from; - unsigned int count; -{ - register char *f = from; - register char *t = to; - register int i = count; - - while (i-- > 0) - *t++ = *f++; -} - -#else /* __cplusplus */ - -/* This is the most reliable way to avoid incompatibilities - in available built-in functions on various systems. */ -static void -__yy_memcpy (char *to, char *from, unsigned int count) -{ - register char *t = to; - register char *f = from; - register int i = count; - - while (i-- > 0) - *t++ = *f++; -} - -#endif -#endif - -#line 217 "/usr/lib/bison.simple" - -/* The user can define YYPARSE_PARAM as the name of an argument to be passed - into yyparse. The argument should have type void *. - It should actually point to an object. - Grammar actions can access the variable by casting it - to the proper pointer type. */ - -#ifdef YYPARSE_PARAM -#ifdef __cplusplus -#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM -#define YYPARSE_PARAM_DECL -#else /* not __cplusplus */ -#define YYPARSE_PARAM_ARG YYPARSE_PARAM -#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; -#endif /* not __cplusplus */ -#else /* not YYPARSE_PARAM */ -#define YYPARSE_PARAM_ARG -#define YYPARSE_PARAM_DECL -#endif /* not YYPARSE_PARAM */ - -/* Prevent warning if -Wstrict-prototypes. */ -#ifdef __GNUC__ -#ifdef YYPARSE_PARAM -int yyparse (void *); -#else -int yyparse (void); -#endif -#endif - -int -yyparse(YYPARSE_PARAM_ARG) - YYPARSE_PARAM_DECL -{ - register int yystate; - register int yyn; - register short *yyssp; - register YYSTYPE *yyvsp; - int yyerrstatus; /* number of tokens to shift before error messages enabled */ - int yychar1 = 0; /* lookahead token as an internal (translated) token number */ - - short yyssa[YYINITDEPTH]; /* the state stack */ - YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */ - - short *yyss = yyssa; /* refer to the stacks thru separate pointers */ - YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */ - -#ifdef YYLSP_NEEDED - YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */ - YYLTYPE *yyls = yylsa; - YYLTYPE *yylsp; - -#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) -#else -#define YYPOPSTACK (yyvsp--, yyssp--) -#endif - - int yystacksize = YYINITDEPTH; - int yyfree_stacks = 0; - -#ifdef YYPURE - int yychar; - YYSTYPE yylval; - int yynerrs; -#ifdef YYLSP_NEEDED - YYLTYPE yylloc; -#endif -#endif - - YYSTYPE yyval; /* the variable used to return */ - yyval.dval = 0; - /* semantic values from the action */ - /* routines */ - - int yylen; - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Starting parse\n"); -#endif - - yystate = 0; - yyerrstatus = 0; - yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ - - /* Initialize stack pointers. - Waste one element of value and location stack - so that they stay on the same level as the state stack. - The wasted elements are never initialized. */ - - yyssp = yyss - 1; - yyvsp = yyvs; -#ifdef YYLSP_NEEDED - yylsp = yyls; -#endif - -/* Push a new state, which is found in yystate . */ -/* In all cases, when you get here, the value and location stacks - have just been pushed. so pushing a state here evens the stacks. */ -yynewstate: - - *++yyssp = sal::static_int_cast(yystate); - - if (yyssp >= yyss + yystacksize - 1) - { - /* Give user a chance to reallocate the stack */ - /* Use copies of these so that the &'s don't force the real ones into memory. */ - YYSTYPE *yyvs1 = yyvs; - short *yyss1 = yyss; -#ifdef YYLSP_NEEDED - YYLTYPE *yyls1 = yyls; -#endif - - /* Get the current used size of the three stacks, in elements. */ - int size = yyssp - yyss + 1; - -#ifdef yyoverflow - /* Each stack pointer address is followed by the size of - the data in use in that stack, in bytes. */ -#ifdef YYLSP_NEEDED - /* This used to be a conditional around just the two extra args, - but that might be undefined if yyoverflow is a macro. */ - yyoverflow("parser stack overflow", - &yyss1, size * sizeof (*yyssp), - &yyvs1, size * sizeof (*yyvsp), - &yyls1, size * sizeof (*yylsp), - &yystacksize); -#else - yyoverflow("parser stack overflow", - &yyss1, size * sizeof (*yyssp), - &yyvs1, size * sizeof (*yyvsp), - &yystacksize); -#endif - - yyss = yyss1; yyvs = yyvs1; -#ifdef YYLSP_NEEDED - yyls = yyls1; -#endif -#else /* no yyoverflow */ - /* Extend the stack our own way. */ - if (yystacksize >= YYMAXDEPTH) - { - yyerror("parser stack overflow"); - if (yyfree_stacks) - { - free (yyss); - free (yyvs); -#ifdef YYLSP_NEEDED - free (yyls); -#endif - } - return 2; - } - yystacksize *= 2; - if (yystacksize > YYMAXDEPTH) - yystacksize = YYMAXDEPTH; -#ifndef YYSTACK_USE_ALLOCA - yyfree_stacks = 1; -#endif - yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp)); - __yy_memcpy ((char *)yyss, (char *)yyss1, - size * (unsigned int) sizeof (*yyssp)); - yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp)); - __yy_memcpy ((char *)yyvs, (char *)yyvs1, - size * (unsigned int) sizeof (*yyvsp)); -#ifdef YYLSP_NEEDED - yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp)); - __yy_memcpy ((char *)yyls, (char *)yyls1, - size * (unsigned int) sizeof (*yylsp)); -#endif -#endif /* no yyoverflow */ - - yyssp = yyss + size - 1; - yyvsp = yyvs + size - 1; -#ifdef YYLSP_NEEDED - yylsp = yyls + size - 1; -#endif - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Stack size increased to %d\n", yystacksize); -#endif - - if (yyssp >= yyss + yystacksize - 1) - YYABORT; - } - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Entering state %d\n", yystate); -#endif - - goto yybackup; - yybackup: - -/* Do appropriate processing given the current state. */ -/* Read a lookahead token if we need one and don't already have one. */ -/* yyresume: */ - - /* First try to decide what to do without reference to lookahead token. */ - - yyn = yypact[yystate]; - if (yyn == YYFLAG) - goto yydefault; - - /* Not known => get a lookahead token if don't already have one. */ - - /* yychar is either YYEMPTY or YYEOF - or a valid token in external form. */ - - if (yychar == YYEMPTY) - { -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Reading a token: "); -#endif - yychar = YYLEX; - } - - /* Convert token to internal form (in yychar1) for indexing tables with */ - - if (yychar <= 0) /* This means end of input. */ - { - yychar1 = 0; - yychar = YYEOF; /* Don't call YYLEX any more */ - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Now at end of input.\n"); -#endif - } - else - { - yychar1 = YYTRANSLATE(yychar); - -#if YYDEBUG != 0 - if (yydebug) - { - fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); - /* Give the individual parser a way to print the precise meaning - of a token, for further debugging info. */ -#ifdef YYPRINT - YYPRINT (stderr, yychar, yylval); -#endif - fprintf (stderr, ")\n"); - } -#endif - } - - yyn += yychar1; - if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) - goto yydefault; - - yyn = yytable[yyn]; - - /* yyn is what to do for this token type in this state. - Negative => reduce, -yyn is rule number. - Positive => shift, yyn is new state. - New state is final state => don't bother to shift, - just return success. - 0, or most negative number => error. */ - - if (yyn < 0) - { - if (yyn == YYFLAG) - goto yyerrlab; - yyn = -yyn; - goto yyreduce; - } - else if (yyn == 0) - goto yyerrlab; - - if (yyn == YYFINAL) - YYACCEPT; - - /* Shift the lookahead token. */ - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]); -#endif - - /* Discard the token being shifted unless it is eof. */ - if (yychar != YYEOF) - yychar = YYEMPTY; - - *++yyvsp = yylval; -#ifdef YYLSP_NEEDED - *++yylsp = yylloc; -#endif - - /* count tokens shifted since error; after three, turn off error status. */ - if (yyerrstatus) yyerrstatus--; - - yystate = yyn; - goto yynewstate; - -/* Do the default action for the current state. */ -yydefault: - - yyn = yydefact[yystate]; - if (yyn == 0) - goto yyerrlab; - -/* Do a reduction. yyn is the number of a rule to reduce with. */ -yyreduce: - yylen = yyr2[yyn]; - if (yylen > 0) - yyval = yyvsp[1-yylen]; /* implement default value of the action */ - -#if YYDEBUG != 0 - if (yydebug) - { - int i; - - fprintf (stderr, "Reducing via rule %d (line %d), ", - yyn, yyrline[yyn]); - - /* Print the symbols being reduced, and their result. */ - for (i = yyprhs[yyn]; yyrhs[i] > 0; i++) - fprintf (stderr, "%s ", yytname[yyrhs[i]]); - fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]); - } -#endif - - - switch (yyn) { - -case 1: -#line 60 "grammar.y" -{ yyval.ptr = new Node(ID_IDENTIFIER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ; - break;} -case 2: -#line 61 "grammar.y" -{ yyval.ptr = new Node(ID_IDENTIFIER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ; - break;} -case 3: -#line 62 "grammar.y" -{ yyval.ptr = new Node(ID_IDENTIFIER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ; - break;} -case 4: -#line 63 "grammar.y" -{ yyval.ptr = new Node(ID_IDENTIFIER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ; - break;} -case 5: -#line 64 "grammar.y" -{ yyval.ptr = new Node(ID_IDENTIFIER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ; - break;} -case 6: -#line 65 "grammar.y" -{ yyval.ptr = new Node(ID_IDENTIFIER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ; - break;} -case 7: -#line 66 "grammar.y" -{ yyval.ptr = new Node(ID_IDENTIFIER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ; - break;} -case 8: -#line 67 "grammar.y" -{ yyval.ptr = new Node(ID_CHARACTER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ; - break;} -case 9: -#line 68 "grammar.y" -{ yyval.ptr = new Node(ID_OPERATOR); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ; - break;} -case 10: -#line 69 "grammar.y" -{ yyval.ptr = new Node(ID_OPERATOR); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ; - break;} -case 11: -#line 70 "grammar.y" -{ yyval.ptr = new Node(ID_IDENTIFIER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ; - break;} -case 12: -#line 71 "grammar.y" -{ yyval.ptr = new Node(ID_DELIMETER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ; - break;} -case 13: -#line 72 "grammar.y" -{ yyval.ptr = new Node(ID_DELIMETER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ; - break;} -case 14: -#line 73 "grammar.y" -{ yyval.ptr = new Node(ID_IDENTIFIER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ; - break;} -case 15: -#line 74 "grammar.y" -{ yyval.ptr = new Node(ID_CHARACTER); allocChar(yyval.ptr->value , '|'); debug("Identifier : '|'\n"); nodelist.insert(yyval.ptr); ; - break;} -case 16: -#line 75 "grammar.y" -{ yyval.ptr = new Node(ID_NUMBER); allocValue(yyval.ptr->value , yyvsp[0].dval); debug("Number : %s\n",yyvsp[0].dval); nodelist.insert(yyval.ptr); ; - break;} -case 17: -#line 76 "grammar.y" -{ yyval.ptr = new Node(ID_STRING); allocValue(yyval.ptr->value , yyvsp[0].str); debug("String : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ; - break;} -case 18: -#line 80 "grammar.y" -{ yyval.ptr = new Node(ID_PRIMARYEXPR); yyval.ptr->child = yyvsp[0].ptr; debug("PrimaryExpr\n"); nodelist.insert(yyval.ptr); ; - break;} -case 19: -#line 81 "grammar.y" -{ yyval.ptr = new Node(ID_PRIMARYEXPR); yyval.ptr->child = yyvsp[-1].ptr; yyval.ptr->next = yyvsp[0].ptr; debug("PrimaryExpr : PrimaryExpr Identifier\n"); nodelist.insert(yyval.ptr); ; - break;} -case 20: -#line 85 "grammar.y" -{ yyval.ptr = new Node(ID_LEFT); allocChar(yyval.ptr->value , '('); debug("EQLeft \n"); nodelist.insert(yyval.ptr); ; - break;} -case 21: -#line 86 "grammar.y" -{ yyval.ptr = new Node(ID_LEFT); allocChar(yyval.ptr->value , '['); debug("EQLeft \n"); nodelist.insert(yyval.ptr); ; - break;} -case 22: -#line 87 "grammar.y" -{ yyval.ptr = new Node(ID_LEFT); allocChar(yyval.ptr->value , '{'); debug("EQLeft \n"); nodelist.insert(yyval.ptr); ; - break;} -case 23: -#line 88 "grammar.y" -{ yyval.ptr = new Node(ID_LEFT); allocChar(yyval.ptr->value , '<'); debug("EQLeft \n"); nodelist.insert(yyval.ptr); ; - break;} -case 24: -#line 89 "grammar.y" -{ yyval.ptr = new Node(ID_LEFT); allocChar(yyval.ptr->value , '|'); debug("EQLeft \n"); nodelist.insert(yyval.ptr); ; - break;} -case 25: -#line 90 "grammar.y" -{ yyval.ptr = new Node(ID_LEFT); allocValue(yyval.ptr->value , "||"); debug("EQLeft \n"); nodelist.insert(yyval.ptr); ; - break;} -case 26: -#line 91 "grammar.y" -{ yyval.ptr = new Node(ID_LEFT); allocValue(yyval.ptr->value , yyvsp[0].str); debug("EQLeft \n"); nodelist.insert(yyval.ptr); ; - break;} -case 27: -#line 95 "grammar.y" -{ yyval.ptr = new Node(ID_RIGHT); allocChar(yyval.ptr->value , ')'); debug("EQRight \n"); nodelist.insert(yyval.ptr); ; - break;} -case 28: -#line 96 "grammar.y" -{ yyval.ptr = new Node(ID_RIGHT); allocChar(yyval.ptr->value , ']'); debug("EQRight \n"); nodelist.insert(yyval.ptr); ; - break;} -case 29: -#line 97 "grammar.y" -{ yyval.ptr = new Node(ID_RIGHT); allocChar(yyval.ptr->value , '}'); debug("EQRight \n"); nodelist.insert(yyval.ptr); ; - break;} -case 30: -#line 98 "grammar.y" -{ yyval.ptr = new Node(ID_RIGHT); allocChar(yyval.ptr->value , '>'); debug("EQRight \n"); nodelist.insert(yyval.ptr); ; - break;} -case 31: -#line 99 "grammar.y" -{ yyval.ptr = new Node(ID_RIGHT); allocChar(yyval.ptr->value , '|'); debug("EQRight \n"); nodelist.insert(yyval.ptr); ; - break;} -case 32: -#line 100 "grammar.y" -{ yyval.ptr = new Node(ID_RIGHT); allocValue(yyval.ptr->value , "||"); debug("EQRight \n"); nodelist.insert(yyval.ptr); ; - break;} -case 33: -#line 101 "grammar.y" -{ yyval.ptr = new Node(ID_RIGHT); allocValue(yyval.ptr->value , yyvsp[0].str); debug("EQRight \n"); nodelist.insert(yyval.ptr); ; - break;} -case 34: -#line 105 "grammar.y" -{ yyval.ptr = new Node(ID_FENCE); yyval.ptr->child=yyvsp[-2].ptr; yyvsp[-2].ptr->next=yyvsp[-1].ptr; yyvsp[-1].ptr->next=yyvsp[0].ptr; debug("Fence \n"); nodelist.insert(yyval.ptr); ; - break;} -case 35: -#line 109 "grammar.y" -{ yyval.ptr = new Node(ID_PARENTH); yyval.ptr->child = yyvsp[-1].ptr; debug("Parenth: '(' ExprList ')' \n"); nodelist.insert(yyval.ptr); ; - break;} -case 36: -#line 110 "grammar.y" -{ yyval.ptr = new Node(ID_PARENTH); debug("Parenth: '(' ')' \n"); nodelist.insert(yyval.ptr); ; - break;} -case 37: -#line 114 "grammar.y" -{ yyval.ptr = new Node(ID_BLOCK); yyval.ptr->child = yyvsp[-1].ptr; debug("Block: '{' ExprList '}' \n"); nodelist.insert(yyval.ptr); ; - break;} -case 38: -#line 115 "grammar.y" -{ yyval.ptr = new Node(ID_BLOCK); debug("Block: '{' '}' \n"); nodelist.insert(yyval.ptr); ; - break;} -case 39: -#line 119 "grammar.y" -{ yyval.ptr = new Node(ID_BRACKET); yyval.ptr->child = yyvsp[-1].ptr; debug("Bracket \n"); nodelist.insert(yyval.ptr); ; - break;} -case 40: -#line 120 "grammar.y" -{ yyval.ptr = new Node(ID_BRACKET); debug("Bracket \n"); nodelist.insert(yyval.ptr); ; - break;} -case 41: -#line 124 "grammar.y" -{ yyval.ptr = new Node(ID_SUBEXPR); yyval.ptr->child = yyvsp[-2].ptr; yyvsp[-2].ptr->next = yyvsp[0].ptr; debug("SubSupExpr : ID_SUBEXPR\n"); nodelist.insert(yyval.ptr); ; - break;} -case 42: -#line 125 "grammar.y" -{ yyval.ptr = new Node(ID_SUPEXPR); yyval.ptr->child = yyvsp[-2].ptr; yyvsp[-2].ptr->next = yyvsp[0].ptr; debug("SubSupExpr : ID_SUPEXPR\n"); nodelist.insert(yyval.ptr); ; - break;} -case 43: -#line 126 "grammar.y" -{ yyval.ptr = new Node(ID_SUBSUPEXPR); yyval.ptr->child=yyvsp[-4].ptr; yyvsp[-4].ptr->next=yyvsp[-2].ptr; yyvsp[-2].ptr->next=yyvsp[0].ptr; debug("SubSupExpr : ID_SUBSUPEXPR\n"); nodelist.insert(yyval.ptr); ; - break;} -case 44: -#line 130 "grammar.y" -{ yyval.ptr = new Node(ID_FRACTIONEXPR); yyval.ptr->child = yyvsp[-1].ptr; yyvsp[-1].ptr->next = yyvsp[0].ptr; debug("FractionExpr : %s\n",yyvsp[-2].str); nodelist.insert(yyval.ptr); ; - break;} -case 45: -#line 134 "grammar.y" -{ yyval.ptr = new Node(ID_OVER); yyval.ptr->child = yyvsp[-3].ptr; yyvsp[-3].ptr->next = yyvsp[-1].ptr; debug("OverExpr\n"); nodelist.insert(yyval.ptr); ; - break;} -case 46: -#line 139 "grammar.y" -{ yyval.ptr = new Node(ID_ACCENTEXPR); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Accent : %s\n", yyvsp[0].str); nodelist.insert(yyval.ptr); ; - break;} -case 47: -#line 143 "grammar.y" -{ yyval.ptr = new Node(ID_ACCENTEXPR); yyval.ptr->child=yyvsp[-1].ptr; yyvsp[-1].ptr->next = yyvsp[0].ptr; debug("AccentExpr \n"); nodelist.insert(yyval.ptr); ; - break;} -case 48: -#line 146 "grammar.y" -{ yyval.ptr = new Node(ID_DECORATIONEXPR); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Decoration : %s\n", yyvsp[0].str); nodelist.insert(yyval.ptr); ; - break;} -case 49: -#line 150 "grammar.y" -{ yyval.ptr = new Node(ID_DECORATIONEXPR); yyval.ptr->child = yyvsp[-1].ptr; yyvsp[-1].ptr->next = yyvsp[0].ptr; debug("DecorationExpr \n"); nodelist.insert(yyval.ptr); ; - break;} -case 50: -#line 154 "grammar.y" -{ yyval.ptr = new Node(ID_SQRTEXPR); yyval.ptr->child = yyvsp[0].ptr; debug("RootExpr : %s\n", yyvsp[-1].str); nodelist.insert(yyval.ptr); ; - break;} -case 51: -#line 155 "grammar.y" -{ yyval.ptr = new Node(ID_ROOTEXPR); yyval.ptr->child = yyvsp[-1].ptr; yyvsp[-1].ptr->next= yyvsp[0].ptr; debug("RootExpr : %s\n", yyvsp[-2].str); nodelist.insert(yyval.ptr); ; - break;} -case 52: -#line 159 "grammar.y" -{ yyval.ptr = new Node(ID_BEGIN); yyval.ptr->child = yyvsp[0].ptr; nodelist.insert(yyval.ptr); debug("BeginExpr\n"); ; - break;} -case 53: -#line 160 "grammar.y" -{ yyval.ptr = new Node(ID_BEGIN); yyval.ptr->child = yyvsp[-1].ptr; yyvsp[-1].ptr->next= yyvsp[0].ptr; nodelist.insert(yyval.ptr); debug("BeginExpr\n"); ; - break;} -case 54: -#line 164 "grammar.y" -{ yyval.ptr = new Node(ID_END); yyval.ptr->child = yyvsp[0].ptr; nodelist.insert(yyval.ptr); debug("EndExpr\n"); ; - break;} -case 55: -#line 169 "grammar.y" -{ yyval.ptr = new Node(ID_MATHML); yyval.ptr->child = yyvsp[0].ptr; nodelist.insert(yyval.ptr); top = yyval.ptr; debug("MathML\n"); ; - break;} -case 56: -#line 173 "grammar.y" -{ yyval.ptr = new Node(ID_LINES); yyval.ptr->child = yyvsp[0].ptr; nodelist.insert(yyval.ptr); debug("Lines\n"); ; - break;} -case 57: -#line 174 "grammar.y" -{ yyval.ptr = new Node(ID_LINES); yyval.ptr->child = yyvsp[-2].ptr; yyvsp[-2].ptr->next = yyvsp[0].ptr; nodelist.insert(yyval.ptr); debug("Lines\n"); ; - break;} -case 58: -#line 178 "grammar.y" -{ yyval.ptr = new Node(ID_LINE); yyval.ptr->child = yyvsp[0].ptr; nodelist.insert(yyval.ptr); debug("Line\n"); ; - break;} -case 59: -#line 182 "grammar.y" -{ yyval.ptr = new Node(ID_EXPRLIST); yyval.ptr->child = yyvsp[0].ptr; debug("ExprList : Expr\n"); nodelist.insert(yyval.ptr); ; - break;} -case 60: -#line 183 "grammar.y" -{ yyval.ptr = new Node(ID_EXPRLIST); yyval.ptr->child = yyvsp[-1].ptr; yyvsp[-1].ptr->next = yyvsp[0].ptr; debug("ExprList : ExprList Expr\n"); nodelist.insert(yyval.ptr); ; - break;} -case 61: -#line 187 "grammar.y" -{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : Block\n"); nodelist.insert(yyval.ptr);; - break;} -case 62: -#line 188 "grammar.y" -{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : Parenth\n"); nodelist.insert(yyval.ptr);; - break;} -case 63: -#line 189 "grammar.y" -{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : Fence\n"); nodelist.insert(yyval.ptr);; - break;} -case 64: -#line 190 "grammar.y" -{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : SubSupExpr\n"); nodelist.insert(yyval.ptr);; - break;} -case 65: -#line 191 "grammar.y" -{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : FractionExpr\n"); nodelist.insert(yyval.ptr);; - break;} -case 66: -#line 192 "grammar.y" -{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : OverExpr\n"); nodelist.insert(yyval.ptr);; - break;} -case 67: -#line 193 "grammar.y" -{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : DecorationExpr\n"); nodelist.insert(yyval.ptr);; - break;} -case 68: -#line 194 "grammar.y" -{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : RootExpr\n"); nodelist.insert(yyval.ptr);; - break;} -case 69: -#line 195 "grammar.y" -{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : AccentExpr\n"); nodelist.insert(yyval.ptr);; - break;} -case 70: -#line 196 "grammar.y" -{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : PrimaryExpr\n"); nodelist.insert(yyval.ptr);; - break;} -case 71: -#line 197 "grammar.y" -{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : BeginExpr\n"); nodelist.insert(yyval.ptr);; - break;} -case 72: -#line 198 "grammar.y" -{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : EndExpr\n"); nodelist.insert(yyval.ptr);; - break;} -} - /* the action file gets copied in in place of this dollarsign */ -#line 543 "/usr/lib/bison.simple" - - yyvsp -= yylen; - yyssp -= yylen; -#ifdef YYLSP_NEEDED - yylsp -= yylen; -#endif - -#if YYDEBUG != 0 - if (yydebug) - { - short *ssp1 = yyss - 1; - fprintf (stderr, "state stack now"); - while (ssp1 != yyssp) - fprintf (stderr, " %d", *++ssp1); - fprintf (stderr, "\n"); - } -#endif - - *++yyvsp = yyval; - -#ifdef YYLSP_NEEDED - yylsp++; - if (yylen == 0) - { - yylsp->first_line = yylloc.first_line; - yylsp->first_column = yylloc.first_column; - yylsp->last_line = (yylsp-1)->last_line; - yylsp->last_column = (yylsp-1)->last_column; - yylsp->text = 0; - } - else - { - yylsp->last_line = (yylsp+yylen-1)->last_line; - yylsp->last_column = (yylsp+yylen-1)->last_column; - } -#endif - - /* Now "shift" the result of the reduction. - Determine what state that goes to, - based on the state we popped back to - and the rule number reduced by. */ - - yyn = yyr1[yyn]; - - yystate = yypgoto[yyn - YYNTBASE] + *yyssp; - if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) - yystate = yytable[yystate]; - else - yystate = yydefgoto[yyn - YYNTBASE]; - - goto yynewstate; - -yyerrlab: /* here on detecting error */ - - if (! yyerrstatus) - /* If not already recovering from an error, report this error. */ - { - ++yynerrs; - -#ifdef YYERROR_VERBOSE - yyn = yypact[yystate]; - - if (yyn > YYFLAG && yyn < YYLAST) - { - int size = 0; - char *msg; - int x, count; - - count = 0; - /* Start X at -yyn if nec to avoid negative indexes in yycheck. */ - for (x = (yyn < 0 ? -yyn : 0); - x < (sizeof(yytname) / sizeof(char *)); x++) - if (yycheck[x + yyn] == x) - size += strlen(yytname[x]) + 15, count++; - msg = (char *) malloc(size + 15); - if (msg != 0) - { - strcpy(msg, "parse error"); - - if (count < 5) - { - count = 0; - for (x = (yyn < 0 ? -yyn : 0); - x < (sizeof(yytname) / sizeof(char *)); x++) - if (yycheck[x + yyn] == x) - { - strcat(msg, count == 0 ? ", expecting `" : " or `"); - strcat(msg, yytname[x]); - strcat(msg, "'"); - count++; - } - } - yyerror(msg); - free(msg); - } - else - yyerror ("parse error; also virtual memory exceeded"); - } - else -#endif /* YYERROR_VERBOSE */ - yyerror("parse error"); - } - - goto yyerrlab1; -yyerrlab1: /* here on error raised explicitly by an action */ - - if (yyerrstatus == 3) - { - /* if just tried and failed to reuse lookahead token after an error, discard it. */ - - /* return failure if at end of input */ - if (yychar == YYEOF) - YYABORT; - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]); -#endif - - yychar = YYEMPTY; - } - - /* Else will try to reuse lookahead token - after shifting the error token. */ - - yyerrstatus = 3; /* Each real token shifted decrements this */ - - goto yyerrhandle; - -yyerrdefault: /* current state does not do anything special for the error token. */ - -#if 0 - /* This is wrong; only states that explicitly want error tokens - should shift them. */ - yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ - if (yyn) goto yydefault; -#endif - -yyerrpop: /* pop the current state because it cannot handle the error token */ - - if (yyssp == yyss) YYABORT; - yyvsp--; - yystate = *--yyssp; -#ifdef YYLSP_NEEDED - yylsp--; -#endif - -#if YYDEBUG != 0 - if (yydebug) - { - short *ssp1 = yyss - 1; - fprintf (stderr, "Error: state stack now"); - while (ssp1 != yyssp) - fprintf (stderr, " %d", *++ssp1); - fprintf (stderr, "\n"); - } -#endif - -yyerrhandle: - - yyn = yypact[yystate]; - if (yyn == YYFLAG) - goto yyerrdefault; - - yyn += YYTERROR; - if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) - goto yyerrdefault; - - yyn = yytable[yyn]; - if (yyn < 0) - { - if (yyn == YYFLAG) - goto yyerrpop; - yyn = -yyn; - goto yyreduce; - } - else if (yyn == 0) - goto yyerrpop; - - if (yyn == YYFINAL) - YYACCEPT; - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Shifting error token, "); -#endif - - *++yyvsp = yylval; -#ifdef YYLSP_NEEDED - *++yylsp = yylloc; -#endif - - yystate = yyn; - goto yynewstate; - - yyacceptlab: - /* YYACCEPT comes here. */ - if (yyfree_stacks) - { - free (yyss); - free (yyvs); -#ifdef YYLSP_NEEDED - free (yyls); -#endif - } - return 0; - - yyabortlab: - /* YYABORT comes here. */ - if (yyfree_stacks) - { - free (yyss); - free (yyvs); -#ifdef YYLSP_NEEDED - free (yyls); -#endif - } - return 1; -} -#line 202 "grammar.y" - - -Node *mainParse(const char *_code) -{ - initFlex( _code ); - top = 0L; - yyparse(); - if( top ) - return top; - else - return 0L; -} - -void yyerror(const char * /*err*/) -{ -// printf("REALKING ERR[%s]\n",err); - // if error, delete all nodes. - Node *pNode = 0L; - int ncount = nodelist.count(); - for( int i = 0 ; i < ncount ; i++){ - pNode = nodelist.remove(0); - delete pNode; - } - top = 0L; -} - -#ifndef PARSE_DEBUG -int debug(const char * /*format*/, ...) -{ - return 0; -} -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/hwpfilter/source/grammar.cxx b/hwpfilter/source/grammar.cxx new file mode 100644 index 000000000000..2afc1d897490 --- /dev/null +++ b/hwpfilter/source/grammar.cxx @@ -0,0 +1,1456 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +/* A Bison parser, made from grammar.y + by GNU Bison version 1.28 */ + +#define YYBISON 1 /* Identify Bison output. */ + +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#ifndef YYMAXDEPTH +#define YYMAXDEPTH 0 +#endif + +#define ACCENT 257 +#define SMALL_GREEK 258 +#define CAPITAL_GREEK 259 +#define BINARY_OPERATOR 260 +#define RELATION_OPERATOR 261 +#define ARROW 262 +#define GENERAL_IDEN 263 +#define GENERAL_OPER 264 +#define BIG_SYMBOL 265 +#define FUNCTION 266 +#define ROOT 267 +#define FRACTION 268 +#define SUBSUP 269 +#define EQOVER 270 +#define DELIMETER 271 +#define LARGE_DELIM 272 +#define DECORATION 273 +#define SPACE_SYMBOL 274 +#define CHARACTER 275 +#define STRING 276 +#define OPERATOR 277 +#define EQBEGIN 278 +#define EQEND 279 +#define EQLEFT 280 +#define EQRIGHT 281 +#define NEWLINE 282 +#define LEFT_DELIM 283 +#define RIGHT_DELIM 284 +#define DIGIT 285 + +#line 1 "grammar.y" + +#include +#include + +#include "nodes.h" + +LinkedList nodelist; + +Node *mainParse(const char *_code); +void yyerror(const char *); +int yylex(); +void initFlex( const char *s ); +void viewResult(Node *res); + +Node *top=0L; + +int Node::count = 0; + +#define allocValue(x,y) \ +x = (char *)malloc( strlen(y) +1 ); \ +strcpy(x,y) + +#define allocChar(x,y) \ +x = (char *)malloc(2); \ +sprintf(x,"%c",y) +#ifdef PARSE_DEBUG +#define debug printf +#else +int debug(const char *format, ...); +#endif + + +#line 35 "grammar.y" +typedef union { + char *dval; + char *str; + Node *ptr; +} YYSTYPE; +#include + +#ifndef __cplusplus +#ifndef __STDC__ +#define const +#endif +#endif + + + +#define YYFINAL 102 +#define YYFLAG -32768 +#define YYNTBASE 43 + +#define YYTRANSLATE(x) ((unsigned)(x) <= 285 ? yytranslate[x] : 66) + +static const char yytranslate[] = { 0, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 33, + 37, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 36, + 2, 40, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 34, 2, 38, 42, 41, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 35, 32, 39, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 1, 3, 4, 5, 6, + 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31 +}; + +#if YYDEBUG != 0 +static const short yyprhs[] = { 0, + 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, + 20, 22, 24, 26, 28, 30, 32, 34, 36, 39, + 42, 45, 48, 51, 54, 58, 60, 63, 66, 69, + 72, 75, 79, 81, 85, 89, 92, 96, 99, 103, + 106, 110, 114, 120, 124, 130, 132, 135, 137, 140, + 143, 147, 150, 154, 157, 159, 161, 165, 167, 169, + 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, + 192, 194 +}; + +static const short yyrhs[] = { 4, + 0, 9, 0, 10, 0, 5, 0, 11, 0, 12, + 0, 20, 0, 21, 0, 7, 0, 6, 0, 23, + 0, 17, 0, 18, 0, 8, 0, 32, 0, 31, + 0, 22, 0, 43, 0, 44, 43, 0, 26, 33, + 0, 26, 34, 0, 26, 35, 0, 26, 36, 0, + 26, 32, 0, 26, 32, 32, 0, 29, 0, 27, + 37, 0, 27, 38, 0, 27, 39, 0, 27, 40, + 0, 27, 32, 0, 27, 32, 32, 0, 30, 0, + 45, 64, 46, 0, 33, 64, 37, 0, 33, 37, + 0, 35, 64, 39, 0, 35, 39, 0, 34, 64, + 38, 0, 34, 38, 0, 65, 41, 65, 0, 65, + 42, 65, 0, 65, 41, 49, 42, 49, 0, 14, + 49, 49, 0, 35, 64, 16, 64, 39, 0, 3, + 0, 54, 49, 0, 19, 0, 56, 49, 0, 13, + 49, 0, 13, 50, 49, 0, 24, 49, 0, 24, + 49, 49, 0, 25, 49, 0, 62, 0, 63, 0, + 62, 28, 63, 0, 64, 0, 65, 0, 64, 65, + 0, 49, 0, 48, 0, 47, 0, 51, 0, 52, + 0, 53, 0, 57, 0, 58, 0, 55, 0, 44, + 0, 59, 0, 60, 0 +}; + +#endif + +#if YYDEBUG != 0 +static const short yyrline[] = { 0, + 59, 61, 62, 63, 64, 65, 66, 67, 68, 69, + 70, 71, 72, 73, 74, 75, 76, 79, 81, 84, + 86, 87, 88, 89, 90, 91, 94, 96, 97, 98, + 99, 100, 101, 104, 108, 110, 113, 115, 118, 120, + 123, 125, 126, 129, 133, 138, 142, 145, 149, 153, + 155, 158, 160, 163, 168, 172, 174, 177, 181, 183, + 186, 188, 189, 190, 191, 192, 193, 194, 195, 196, + 197, 198 +}; +#endif + + +#if YYDEBUG != 0 || defined (YYERROR_VERBOSE) + +static const char * const yytname[] = { "$","error","$undefined.","ACCENT", +"SMALL_GREEK","CAPITAL_GREEK","BINARY_OPERATOR","RELATION_OPERATOR","ARROW", +"GENERAL_IDEN","GENERAL_OPER","BIG_SYMBOL","FUNCTION","ROOT","FRACTION","SUBSUP", +"EQOVER","DELIMETER","LARGE_DELIM","DECORATION","SPACE_SYMBOL","CHARACTER","STRING", +"OPERATOR","EQBEGIN","EQEND","EQLEFT","EQRIGHT","NEWLINE","LEFT_DELIM","RIGHT_DELIM", +"DIGIT","'|'","'('","'['","'{'","'<'","')'","']'","'}'","'>'","'_'","'^'","Identifier", +"PrimaryExpr","EQLeft","EQRight","Fence","Parenth","Block","Bracket","SubSupExpr", +"FractionExpr","OverExpr","Accent","AccentExpr","Decoration","DecorationExpr", +"RootExpr","BeginExpr","EndExpr","MathML","Lines","Line","ExprList","Expr", NULL +}; +#endif + +static const short yyr1[] = { 0, + 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 43, 44, 44, 45, + 45, 45, 45, 45, 45, 45, 46, 46, 46, 46, + 46, 46, 46, 47, 48, 48, 49, 49, 50, 50, + 51, 51, 51, 52, 53, 54, 55, 56, 57, 58, + 58, 59, 59, 60, 61, 62, 62, 63, 64, 64, + 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, + 65, 65 +}; + +static const short yyr2[] = { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, + 2, 2, 2, 2, 3, 1, 2, 2, 2, 2, + 2, 3, 1, 3, 3, 2, 3, 2, 3, 2, + 3, 3, 5, 3, 5, 1, 2, 1, 2, 2, + 3, 2, 3, 2, 1, 1, 3, 1, 1, 2, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1 +}; + +static const short yydefact[] = { 0, + 46, 1, 4, 10, 9, 14, 2, 3, 5, 6, + 0, 0, 12, 13, 48, 7, 8, 17, 11, 0, + 0, 0, 26, 16, 15, 0, 0, 18, 70, 0, + 63, 62, 61, 64, 65, 66, 0, 69, 0, 67, + 68, 71, 72, 55, 56, 58, 59, 0, 0, 50, + 0, 0, 52, 54, 24, 20, 21, 22, 23, 36, + 0, 38, 0, 19, 0, 47, 49, 0, 60, 0, + 0, 40, 0, 0, 51, 44, 53, 25, 35, 0, + 37, 0, 33, 34, 57, 61, 41, 42, 39, 0, + 31, 27, 28, 29, 30, 0, 45, 32, 43, 0, + 0, 0 +}; + +static const short yydefgoto[] = { 28, + 29, 30, 84, 31, 32, 33, 51, 34, 35, 36, + 37, 38, 39, 40, 41, 42, 43, 100, 44, 45, + 46, 47 +}; + +static const short yypact[] = { 393, +-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, + -30, -19,-32768,-32768,-32768,-32768,-32768,-32768,-32768, -19, + -19, -3,-32768,-32768,-32768, 290, 107,-32768, 425, 393, +-32768,-32768,-32768,-32768,-32768,-32768, -19,-32768, -19,-32768, +-32768,-32768,-32768, -20,-32768, 393, -21, 218, 107,-32768, + -19, -19, -19,-32768, -15,-32768,-32768,-32768,-32768,-32768, + 325,-32768, 70,-32768, 360,-32768,-32768, 393, -21, 393, + 393,-32768, 254, 144,-32768,-32768,-32768,-32768,-32768, 393, +-32768, -25,-32768,-32768,-32768, -31, -21, -21,-32768, 181, + -14,-32768,-32768,-32768,-32768, -19,-32768,-32768,-32768, 22, + 23,-32768 +}; + +static const short yypgoto[] = { -2, +-32768,-32768,-32768,-32768,-32768, -11,-32768,-32768,-32768,-32768, +-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, -33, + -24, -27 +}; + + +#define YYLAST 457 + + +static const short yytable[] = { 50, + 52, 61, 63, 48, 49, 65, 91, 68, 53, 54, + 96, 92, 93, 94, 95, 49, 78, 98, 69, 70, + 71, 101, 102, 73, 74, 66, 64, 67, 55, 56, + 57, 58, 59, 69, 85, 69, 0, 69, 0, 75, + 76, 77, 87, 88, 0, 69, 69, 0, 0, 0, + 0, 0, 0, 0, 0, 90, 0, 0, 86, 0, + 0, 0, 69, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, + 9, 10, 11, 12, 99, 80, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 0, 0, 23, 0, + 24, 25, 26, 0, 27, 0, 0, 0, 81, 1, + 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, + 12, 0, 0, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 0, 0, 23, 0, 24, 25, 26, + 0, 27, 0, 0, 0, 62, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 0, 0, + 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, + 0, 0, 23, 0, 24, 25, 26, 0, 27, 0, + 0, 0, 81, 1, 2, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 0, 0, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 0, 0, 23, + 0, 24, 25, 26, 0, 27, 0, 0, 0, 97, + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 0, 0, 13, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 0, 0, 23, 0, 24, 25, + 26, 0, 27, 0, 0, 72, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 0, 0, + 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, + 0, 0, 23, 0, 24, 25, 26, 0, 27, 0, + 0, 89, 1, 2, 3, 4, 5, 6, 7, 8, + 9, 10, 11, 12, 0, 0, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 0, 0, 23, 0, + 24, 25, 26, 0, 27, 0, 60, 1, 2, 3, + 4, 5, 6, 7, 8, 9, 10, 11, 12, 0, + 0, 13, 14, 15, 16, 17, 18, 19, 20, 21, + 22, 0, 0, 23, 0, 24, 25, 26, 0, 27, + 0, 79, 1, 2, 3, 4, 5, 6, 7, 8, + 9, 10, 11, 12, 0, 0, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 82, 0, 23, 83, + 24, 25, 26, 0, 27, 1, 2, 3, 4, 5, + 6, 7, 8, 9, 10, 11, 12, 0, 0, 13, + 14, 15, 16, 17, 18, 19, 20, 21, 22, 0, + 0, 23, 0, 24, 25, 26, 0, 27, 2, 3, + 4, 5, 6, 7, 8, 9, 10, 0, 0, 0, + 0, 13, 14, 0, 16, 17, 18, 19, 0, 0, + 0, 0, 0, 0, 0, 24, 25 +}; + +static const short yycheck[] = { 11, + 12, 26, 27, 34, 35, 30, 32, 28, 20, 21, + 42, 37, 38, 39, 40, 35, 32, 32, 46, 41, + 42, 0, 0, 48, 49, 37, 29, 39, 32, 33, + 34, 35, 36, 61, 68, 63, -1, 65, -1, 51, + 52, 53, 70, 71, -1, 73, 74, -1, -1, -1, + -1, -1, -1, -1, -1, 80, -1, -1, 70, -1, + -1, -1, 90, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 96, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, -1, -1, 29, -1, + 31, 32, 33, -1, 35, -1, -1, -1, 39, 3, + 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, + 14, -1, -1, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, -1, -1, 29, -1, 31, 32, 33, + -1, 35, -1, -1, -1, 39, 3, 4, 5, 6, + 7, 8, 9, 10, 11, 12, 13, 14, -1, -1, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, + -1, -1, 29, -1, 31, 32, 33, -1, 35, -1, + -1, -1, 39, 3, 4, 5, 6, 7, 8, 9, + 10, 11, 12, 13, 14, -1, -1, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, -1, -1, 29, + -1, 31, 32, 33, -1, 35, -1, -1, -1, 39, + 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, + 13, 14, -1, -1, 17, 18, 19, 20, 21, 22, + 23, 24, 25, 26, -1, -1, 29, -1, 31, 32, + 33, -1, 35, -1, -1, 38, 3, 4, 5, 6, + 7, 8, 9, 10, 11, 12, 13, 14, -1, -1, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, + -1, -1, 29, -1, 31, 32, 33, -1, 35, -1, + -1, 38, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, -1, -1, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, -1, -1, 29, -1, + 31, 32, 33, -1, 35, -1, 37, 3, 4, 5, + 6, 7, 8, 9, 10, 11, 12, 13, 14, -1, + -1, 17, 18, 19, 20, 21, 22, 23, 24, 25, + 26, -1, -1, 29, -1, 31, 32, 33, -1, 35, + -1, 37, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, -1, -1, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, -1, 29, 30, + 31, 32, 33, -1, 35, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, -1, -1, 17, + 18, 19, 20, 21, 22, 23, 24, 25, 26, -1, + -1, 29, -1, 31, 32, 33, -1, 35, 4, 5, + 6, 7, 8, 9, 10, 11, 12, -1, -1, -1, + -1, 17, 18, -1, 20, 21, 22, 23, -1, -1, + -1, -1, -1, -1, -1, 31, 32 +}; +/* -*-C-*- Note some compilers choke on comments on `#line' lines. */ +#line 3 "/usr/lib/bison.simple" +/* This file comes from bison-1.28. */ + +/* Skeleton output parser for bison, + Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* As a special exception, when this file is copied by Bison into a + Bison output file, you may use that output file without restriction. + This special exception was added by the Free Software Foundation + in version 1.24 of Bison. */ + +/* This is the parser code that is written into each bison parser + when the %semantic_parser declaration is not specified in the grammar. + It was written by Richard Stallman by simplifying the hairy parser + used when %semantic_parser is specified. */ + +#ifndef YYSTACK_USE_ALLOCA +#ifdef alloca +#define YYSTACK_USE_ALLOCA +#else /* alloca not defined */ +#ifdef __GNUC__ +#define YYSTACK_USE_ALLOCA +#define alloca __builtin_alloca +#else /* not GNU C. */ +#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386)) +#define YYSTACK_USE_ALLOCA +#include +#else /* not sparc */ +#if defined(_AIX) + #pragma alloca +#define YYSTACK_USE_ALLOCA +#endif /* not _AIX */ +#endif /* not sparc */ +#endif /* not GNU C */ +#endif /* alloca not defined */ +#endif /* YYSTACK_USE_ALLOCA not defined */ + +#ifdef YYSTACK_USE_ALLOCA +#define YYSTACK_ALLOC alloca +#else +#define YYSTACK_ALLOC malloc +#endif + +/* Note: there must be only one dollar sign in this file. + It is replaced by the list of actions, each action + as one case of the switch. */ + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY -2 +#define YYEOF 0 +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrlab1 +/* Like YYERROR except do call yyerror. + This remains here temporarily to ease the + transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ +#define YYFAIL goto yyerrlab +#define YYRECOVERING() (!!yyerrstatus) +#define YYBACKUP(token, value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { yychar = (token), yylval = (value); \ + yychar1 = YYTRANSLATE (yychar); \ + YYPOPSTACK; \ + goto yybackup; \ + } \ + else \ + { yyerror ("syntax error: cannot back up"); YYERROR; } \ +while (0) + +#define YYTERROR 1 +#define YYERRCODE 256 + +#ifndef YYPURE +#define YYLEX yylex() +#endif + +#ifdef YYPURE +#ifdef YYLSP_NEEDED +#ifdef YYLEX_PARAM +#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM) +#else +#define YYLEX yylex(&yylval, &yylloc) +#endif +#else /* not YYLSP_NEEDED */ +#ifdef YYLEX_PARAM +#define YYLEX yylex(&yylval, YYLEX_PARAM) +#else +#define YYLEX yylex(&yylval) +#endif +#endif /* not YYLSP_NEEDED */ +#endif + +/* If nonreentrant, generate the variables here */ + +#ifndef YYPURE + +int yychar; /* the lookahead symbol */ +YYSTYPE yylval; /* the semantic value of the */ + /* lookahead symbol */ + +#ifdef YYLSP_NEEDED +YYLTYPE yylloc; /* location data for the lookahead */ + /* symbol */ +#endif + +int yynerrs; /* number of parse errors so far */ +#endif /* not YYPURE */ + +#if YYDEBUG != 0 +int yydebug; /* nonzero means print parse trace */ +/* Since this is uninitialized, it does not stop multiple parsers + from coexisting. */ +#endif + +/* YYINITDEPTH indicates the initial size of the parser's stacks */ + +#ifndef YYINITDEPTH +#define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH is the maximum size the stacks can grow to + (effective only if the built-in stack extension method is used). */ + +#if YYMAXDEPTH == 0 +#undef YYMAXDEPTH +#endif + +#ifndef YYMAXDEPTH +#define YYMAXDEPTH 10000 +#endif + +/* Define __yy_memcpy. Note that the size argument + should be passed with type unsigned int, because that is what the non-GCC + definitions require. With GCC, __builtin_memcpy takes an arg + of type size_t, but it can handle unsigned int. */ + +#if defined __GNUC__ +#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ +#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT) +#endif +#else /* not GNU C or C++ */ +#ifndef __cplusplus + +/* This is the most reliable way to avoid incompatibilities + in available built-in functions on various systems. */ +static void +__yy_memcpy (to, from, count) + char *to; + char *from; + unsigned int count; +{ + register char *f = from; + register char *t = to; + register int i = count; + + while (i-- > 0) + *t++ = *f++; +} + +#else /* __cplusplus */ + +/* This is the most reliable way to avoid incompatibilities + in available built-in functions on various systems. */ +static void +__yy_memcpy (char *to, char *from, unsigned int count) +{ + register char *t = to; + register char *f = from; + register int i = count; + + while (i-- > 0) + *t++ = *f++; +} + +#endif +#endif + +#line 217 "/usr/lib/bison.simple" + +/* The user can define YYPARSE_PARAM as the name of an argument to be passed + into yyparse. The argument should have type void *. + It should actually point to an object. + Grammar actions can access the variable by casting it + to the proper pointer type. */ + +#ifdef YYPARSE_PARAM +#ifdef __cplusplus +#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM +#define YYPARSE_PARAM_DECL +#else /* not __cplusplus */ +#define YYPARSE_PARAM_ARG YYPARSE_PARAM +#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; +#endif /* not __cplusplus */ +#else /* not YYPARSE_PARAM */ +#define YYPARSE_PARAM_ARG +#define YYPARSE_PARAM_DECL +#endif /* not YYPARSE_PARAM */ + +/* Prevent warning if -Wstrict-prototypes. */ +#ifdef __GNUC__ +#ifdef YYPARSE_PARAM +int yyparse (void *); +#else +int yyparse (void); +#endif +#endif + +int +yyparse(YYPARSE_PARAM_ARG) + YYPARSE_PARAM_DECL +{ + register int yystate; + register int yyn; + register short *yyssp; + register YYSTYPE *yyvsp; + int yyerrstatus; /* number of tokens to shift before error messages enabled */ + int yychar1 = 0; /* lookahead token as an internal (translated) token number */ + + short yyssa[YYINITDEPTH]; /* the state stack */ + YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */ + + short *yyss = yyssa; /* refer to the stacks thru separate pointers */ + YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */ + +#ifdef YYLSP_NEEDED + YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */ + YYLTYPE *yyls = yylsa; + YYLTYPE *yylsp; + +#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) +#else +#define YYPOPSTACK (yyvsp--, yyssp--) +#endif + + int yystacksize = YYINITDEPTH; + int yyfree_stacks = 0; + +#ifdef YYPURE + int yychar; + YYSTYPE yylval; + int yynerrs; +#ifdef YYLSP_NEEDED + YYLTYPE yylloc; +#endif +#endif + + YYSTYPE yyval; /* the variable used to return */ + yyval.dval = 0; + /* semantic values from the action */ + /* routines */ + + int yylen; + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Starting parse\n"); +#endif + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss - 1; + yyvsp = yyvs; +#ifdef YYLSP_NEEDED + yylsp = yyls; +#endif + +/* Push a new state, which is found in yystate . */ +/* In all cases, when you get here, the value and location stacks + have just been pushed. so pushing a state here evens the stacks. */ +yynewstate: + + *++yyssp = sal::static_int_cast(yystate); + + if (yyssp >= yyss + yystacksize - 1) + { + /* Give user a chance to reallocate the stack */ + /* Use copies of these so that the &'s don't force the real ones into memory. */ + YYSTYPE *yyvs1 = yyvs; + short *yyss1 = yyss; +#ifdef YYLSP_NEEDED + YYLTYPE *yyls1 = yyls; +#endif + + /* Get the current used size of the three stacks, in elements. */ + int size = yyssp - yyss + 1; + +#ifdef yyoverflow + /* Each stack pointer address is followed by the size of + the data in use in that stack, in bytes. */ +#ifdef YYLSP_NEEDED + /* This used to be a conditional around just the two extra args, + but that might be undefined if yyoverflow is a macro. */ + yyoverflow("parser stack overflow", + &yyss1, size * sizeof (*yyssp), + &yyvs1, size * sizeof (*yyvsp), + &yyls1, size * sizeof (*yylsp), + &yystacksize); +#else + yyoverflow("parser stack overflow", + &yyss1, size * sizeof (*yyssp), + &yyvs1, size * sizeof (*yyvsp), + &yystacksize); +#endif + + yyss = yyss1; yyvs = yyvs1; +#ifdef YYLSP_NEEDED + yyls = yyls1; +#endif +#else /* no yyoverflow */ + /* Extend the stack our own way. */ + if (yystacksize >= YYMAXDEPTH) + { + yyerror("parser stack overflow"); + if (yyfree_stacks) + { + free (yyss); + free (yyvs); +#ifdef YYLSP_NEEDED + free (yyls); +#endif + } + return 2; + } + yystacksize *= 2; + if (yystacksize > YYMAXDEPTH) + yystacksize = YYMAXDEPTH; +#ifndef YYSTACK_USE_ALLOCA + yyfree_stacks = 1; +#endif + yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp)); + __yy_memcpy ((char *)yyss, (char *)yyss1, + size * (unsigned int) sizeof (*yyssp)); + yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp)); + __yy_memcpy ((char *)yyvs, (char *)yyvs1, + size * (unsigned int) sizeof (*yyvsp)); +#ifdef YYLSP_NEEDED + yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp)); + __yy_memcpy ((char *)yyls, (char *)yyls1, + size * (unsigned int) sizeof (*yylsp)); +#endif +#endif /* no yyoverflow */ + + yyssp = yyss + size - 1; + yyvsp = yyvs + size - 1; +#ifdef YYLSP_NEEDED + yylsp = yyls + size - 1; +#endif + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Stack size increased to %d\n", yystacksize); +#endif + + if (yyssp >= yyss + yystacksize - 1) + YYABORT; + } + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Entering state %d\n", yystate); +#endif + + goto yybackup; + yybackup: + +/* Do appropriate processing given the current state. */ +/* Read a lookahead token if we need one and don't already have one. */ +/* yyresume: */ + + /* First try to decide what to do without reference to lookahead token. */ + + yyn = yypact[yystate]; + if (yyn == YYFLAG) + goto yydefault; + + /* Not known => get a lookahead token if don't already have one. */ + + /* yychar is either YYEMPTY or YYEOF + or a valid token in external form. */ + + if (yychar == YYEMPTY) + { +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Reading a token: "); +#endif + yychar = YYLEX; + } + + /* Convert token to internal form (in yychar1) for indexing tables with */ + + if (yychar <= 0) /* This means end of input. */ + { + yychar1 = 0; + yychar = YYEOF; /* Don't call YYLEX any more */ + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Now at end of input.\n"); +#endif + } + else + { + yychar1 = YYTRANSLATE(yychar); + +#if YYDEBUG != 0 + if (yydebug) + { + fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); + /* Give the individual parser a way to print the precise meaning + of a token, for further debugging info. */ +#ifdef YYPRINT + YYPRINT (stderr, yychar, yylval); +#endif + fprintf (stderr, ")\n"); + } +#endif + } + + yyn += yychar1; + if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) + goto yydefault; + + yyn = yytable[yyn]; + + /* yyn is what to do for this token type in this state. + Negative => reduce, -yyn is rule number. + Positive => shift, yyn is new state. + New state is final state => don't bother to shift, + just return success. + 0, or most negative number => error. */ + + if (yyn < 0) + { + if (yyn == YYFLAG) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + else if (yyn == 0) + goto yyerrlab; + + if (yyn == YYFINAL) + YYACCEPT; + + /* Shift the lookahead token. */ + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]); +#endif + + /* Discard the token being shifted unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + *++yyvsp = yylval; +#ifdef YYLSP_NEEDED + *++yylsp = yylloc; +#endif + + /* count tokens shifted since error; after three, turn off error status. */ + if (yyerrstatus) yyerrstatus--; + + yystate = yyn; + goto yynewstate; + +/* Do the default action for the current state. */ +yydefault: + + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + +/* Do a reduction. yyn is the number of a rule to reduce with. */ +yyreduce: + yylen = yyr2[yyn]; + if (yylen > 0) + yyval = yyvsp[1-yylen]; /* implement default value of the action */ + +#if YYDEBUG != 0 + if (yydebug) + { + int i; + + fprintf (stderr, "Reducing via rule %d (line %d), ", + yyn, yyrline[yyn]); + + /* Print the symbols being reduced, and their result. */ + for (i = yyprhs[yyn]; yyrhs[i] > 0; i++) + fprintf (stderr, "%s ", yytname[yyrhs[i]]); + fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]); + } +#endif + + + switch (yyn) { + +case 1: +#line 60 "grammar.y" +{ yyval.ptr = new Node(ID_IDENTIFIER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ; + break;} +case 2: +#line 61 "grammar.y" +{ yyval.ptr = new Node(ID_IDENTIFIER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ; + break;} +case 3: +#line 62 "grammar.y" +{ yyval.ptr = new Node(ID_IDENTIFIER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ; + break;} +case 4: +#line 63 "grammar.y" +{ yyval.ptr = new Node(ID_IDENTIFIER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ; + break;} +case 5: +#line 64 "grammar.y" +{ yyval.ptr = new Node(ID_IDENTIFIER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ; + break;} +case 6: +#line 65 "grammar.y" +{ yyval.ptr = new Node(ID_IDENTIFIER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ; + break;} +case 7: +#line 66 "grammar.y" +{ yyval.ptr = new Node(ID_IDENTIFIER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ; + break;} +case 8: +#line 67 "grammar.y" +{ yyval.ptr = new Node(ID_CHARACTER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ; + break;} +case 9: +#line 68 "grammar.y" +{ yyval.ptr = new Node(ID_OPERATOR); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ; + break;} +case 10: +#line 69 "grammar.y" +{ yyval.ptr = new Node(ID_OPERATOR); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ; + break;} +case 11: +#line 70 "grammar.y" +{ yyval.ptr = new Node(ID_IDENTIFIER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ; + break;} +case 12: +#line 71 "grammar.y" +{ yyval.ptr = new Node(ID_DELIMETER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ; + break;} +case 13: +#line 72 "grammar.y" +{ yyval.ptr = new Node(ID_DELIMETER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ; + break;} +case 14: +#line 73 "grammar.y" +{ yyval.ptr = new Node(ID_IDENTIFIER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ; + break;} +case 15: +#line 74 "grammar.y" +{ yyval.ptr = new Node(ID_CHARACTER); allocChar(yyval.ptr->value , '|'); debug("Identifier : '|'\n"); nodelist.insert(yyval.ptr); ; + break;} +case 16: +#line 75 "grammar.y" +{ yyval.ptr = new Node(ID_NUMBER); allocValue(yyval.ptr->value , yyvsp[0].dval); debug("Number : %s\n",yyvsp[0].dval); nodelist.insert(yyval.ptr); ; + break;} +case 17: +#line 76 "grammar.y" +{ yyval.ptr = new Node(ID_STRING); allocValue(yyval.ptr->value , yyvsp[0].str); debug("String : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ; + break;} +case 18: +#line 80 "grammar.y" +{ yyval.ptr = new Node(ID_PRIMARYEXPR); yyval.ptr->child = yyvsp[0].ptr; debug("PrimaryExpr\n"); nodelist.insert(yyval.ptr); ; + break;} +case 19: +#line 81 "grammar.y" +{ yyval.ptr = new Node(ID_PRIMARYEXPR); yyval.ptr->child = yyvsp[-1].ptr; yyval.ptr->next = yyvsp[0].ptr; debug("PrimaryExpr : PrimaryExpr Identifier\n"); nodelist.insert(yyval.ptr); ; + break;} +case 20: +#line 85 "grammar.y" +{ yyval.ptr = new Node(ID_LEFT); allocChar(yyval.ptr->value , '('); debug("EQLeft \n"); nodelist.insert(yyval.ptr); ; + break;} +case 21: +#line 86 "grammar.y" +{ yyval.ptr = new Node(ID_LEFT); allocChar(yyval.ptr->value , '['); debug("EQLeft \n"); nodelist.insert(yyval.ptr); ; + break;} +case 22: +#line 87 "grammar.y" +{ yyval.ptr = new Node(ID_LEFT); allocChar(yyval.ptr->value , '{'); debug("EQLeft \n"); nodelist.insert(yyval.ptr); ; + break;} +case 23: +#line 88 "grammar.y" +{ yyval.ptr = new Node(ID_LEFT); allocChar(yyval.ptr->value , '<'); debug("EQLeft \n"); nodelist.insert(yyval.ptr); ; + break;} +case 24: +#line 89 "grammar.y" +{ yyval.ptr = new Node(ID_LEFT); allocChar(yyval.ptr->value , '|'); debug("EQLeft \n"); nodelist.insert(yyval.ptr); ; + break;} +case 25: +#line 90 "grammar.y" +{ yyval.ptr = new Node(ID_LEFT); allocValue(yyval.ptr->value , "||"); debug("EQLeft \n"); nodelist.insert(yyval.ptr); ; + break;} +case 26: +#line 91 "grammar.y" +{ yyval.ptr = new Node(ID_LEFT); allocValue(yyval.ptr->value , yyvsp[0].str); debug("EQLeft \n"); nodelist.insert(yyval.ptr); ; + break;} +case 27: +#line 95 "grammar.y" +{ yyval.ptr = new Node(ID_RIGHT); allocChar(yyval.ptr->value , ')'); debug("EQRight \n"); nodelist.insert(yyval.ptr); ; + break;} +case 28: +#line 96 "grammar.y" +{ yyval.ptr = new Node(ID_RIGHT); allocChar(yyval.ptr->value , ']'); debug("EQRight \n"); nodelist.insert(yyval.ptr); ; + break;} +case 29: +#line 97 "grammar.y" +{ yyval.ptr = new Node(ID_RIGHT); allocChar(yyval.ptr->value , '}'); debug("EQRight \n"); nodelist.insert(yyval.ptr); ; + break;} +case 30: +#line 98 "grammar.y" +{ yyval.ptr = new Node(ID_RIGHT); allocChar(yyval.ptr->value , '>'); debug("EQRight \n"); nodelist.insert(yyval.ptr); ; + break;} +case 31: +#line 99 "grammar.y" +{ yyval.ptr = new Node(ID_RIGHT); allocChar(yyval.ptr->value , '|'); debug("EQRight \n"); nodelist.insert(yyval.ptr); ; + break;} +case 32: +#line 100 "grammar.y" +{ yyval.ptr = new Node(ID_RIGHT); allocValue(yyval.ptr->value , "||"); debug("EQRight \n"); nodelist.insert(yyval.ptr); ; + break;} +case 33: +#line 101 "grammar.y" +{ yyval.ptr = new Node(ID_RIGHT); allocValue(yyval.ptr->value , yyvsp[0].str); debug("EQRight \n"); nodelist.insert(yyval.ptr); ; + break;} +case 34: +#line 105 "grammar.y" +{ yyval.ptr = new Node(ID_FENCE); yyval.ptr->child=yyvsp[-2].ptr; yyvsp[-2].ptr->next=yyvsp[-1].ptr; yyvsp[-1].ptr->next=yyvsp[0].ptr; debug("Fence \n"); nodelist.insert(yyval.ptr); ; + break;} +case 35: +#line 109 "grammar.y" +{ yyval.ptr = new Node(ID_PARENTH); yyval.ptr->child = yyvsp[-1].ptr; debug("Parenth: '(' ExprList ')' \n"); nodelist.insert(yyval.ptr); ; + break;} +case 36: +#line 110 "grammar.y" +{ yyval.ptr = new Node(ID_PARENTH); debug("Parenth: '(' ')' \n"); nodelist.insert(yyval.ptr); ; + break;} +case 37: +#line 114 "grammar.y" +{ yyval.ptr = new Node(ID_BLOCK); yyval.ptr->child = yyvsp[-1].ptr; debug("Block: '{' ExprList '}' \n"); nodelist.insert(yyval.ptr); ; + break;} +case 38: +#line 115 "grammar.y" +{ yyval.ptr = new Node(ID_BLOCK); debug("Block: '{' '}' \n"); nodelist.insert(yyval.ptr); ; + break;} +case 39: +#line 119 "grammar.y" +{ yyval.ptr = new Node(ID_BRACKET); yyval.ptr->child = yyvsp[-1].ptr; debug("Bracket \n"); nodelist.insert(yyval.ptr); ; + break;} +case 40: +#line 120 "grammar.y" +{ yyval.ptr = new Node(ID_BRACKET); debug("Bracket \n"); nodelist.insert(yyval.ptr); ; + break;} +case 41: +#line 124 "grammar.y" +{ yyval.ptr = new Node(ID_SUBEXPR); yyval.ptr->child = yyvsp[-2].ptr; yyvsp[-2].ptr->next = yyvsp[0].ptr; debug("SubSupExpr : ID_SUBEXPR\n"); nodelist.insert(yyval.ptr); ; + break;} +case 42: +#line 125 "grammar.y" +{ yyval.ptr = new Node(ID_SUPEXPR); yyval.ptr->child = yyvsp[-2].ptr; yyvsp[-2].ptr->next = yyvsp[0].ptr; debug("SubSupExpr : ID_SUPEXPR\n"); nodelist.insert(yyval.ptr); ; + break;} +case 43: +#line 126 "grammar.y" +{ yyval.ptr = new Node(ID_SUBSUPEXPR); yyval.ptr->child=yyvsp[-4].ptr; yyvsp[-4].ptr->next=yyvsp[-2].ptr; yyvsp[-2].ptr->next=yyvsp[0].ptr; debug("SubSupExpr : ID_SUBSUPEXPR\n"); nodelist.insert(yyval.ptr); ; + break;} +case 44: +#line 130 "grammar.y" +{ yyval.ptr = new Node(ID_FRACTIONEXPR); yyval.ptr->child = yyvsp[-1].ptr; yyvsp[-1].ptr->next = yyvsp[0].ptr; debug("FractionExpr : %s\n",yyvsp[-2].str); nodelist.insert(yyval.ptr); ; + break;} +case 45: +#line 134 "grammar.y" +{ yyval.ptr = new Node(ID_OVER); yyval.ptr->child = yyvsp[-3].ptr; yyvsp[-3].ptr->next = yyvsp[-1].ptr; debug("OverExpr\n"); nodelist.insert(yyval.ptr); ; + break;} +case 46: +#line 139 "grammar.y" +{ yyval.ptr = new Node(ID_ACCENTEXPR); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Accent : %s\n", yyvsp[0].str); nodelist.insert(yyval.ptr); ; + break;} +case 47: +#line 143 "grammar.y" +{ yyval.ptr = new Node(ID_ACCENTEXPR); yyval.ptr->child=yyvsp[-1].ptr; yyvsp[-1].ptr->next = yyvsp[0].ptr; debug("AccentExpr \n"); nodelist.insert(yyval.ptr); ; + break;} +case 48: +#line 146 "grammar.y" +{ yyval.ptr = new Node(ID_DECORATIONEXPR); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Decoration : %s\n", yyvsp[0].str); nodelist.insert(yyval.ptr); ; + break;} +case 49: +#line 150 "grammar.y" +{ yyval.ptr = new Node(ID_DECORATIONEXPR); yyval.ptr->child = yyvsp[-1].ptr; yyvsp[-1].ptr->next = yyvsp[0].ptr; debug("DecorationExpr \n"); nodelist.insert(yyval.ptr); ; + break;} +case 50: +#line 154 "grammar.y" +{ yyval.ptr = new Node(ID_SQRTEXPR); yyval.ptr->child = yyvsp[0].ptr; debug("RootExpr : %s\n", yyvsp[-1].str); nodelist.insert(yyval.ptr); ; + break;} +case 51: +#line 155 "grammar.y" +{ yyval.ptr = new Node(ID_ROOTEXPR); yyval.ptr->child = yyvsp[-1].ptr; yyvsp[-1].ptr->next= yyvsp[0].ptr; debug("RootExpr : %s\n", yyvsp[-2].str); nodelist.insert(yyval.ptr); ; + break;} +case 52: +#line 159 "grammar.y" +{ yyval.ptr = new Node(ID_BEGIN); yyval.ptr->child = yyvsp[0].ptr; nodelist.insert(yyval.ptr); debug("BeginExpr\n"); ; + break;} +case 53: +#line 160 "grammar.y" +{ yyval.ptr = new Node(ID_BEGIN); yyval.ptr->child = yyvsp[-1].ptr; yyvsp[-1].ptr->next= yyvsp[0].ptr; nodelist.insert(yyval.ptr); debug("BeginExpr\n"); ; + break;} +case 54: +#line 164 "grammar.y" +{ yyval.ptr = new Node(ID_END); yyval.ptr->child = yyvsp[0].ptr; nodelist.insert(yyval.ptr); debug("EndExpr\n"); ; + break;} +case 55: +#line 169 "grammar.y" +{ yyval.ptr = new Node(ID_MATHML); yyval.ptr->child = yyvsp[0].ptr; nodelist.insert(yyval.ptr); top = yyval.ptr; debug("MathML\n"); ; + break;} +case 56: +#line 173 "grammar.y" +{ yyval.ptr = new Node(ID_LINES); yyval.ptr->child = yyvsp[0].ptr; nodelist.insert(yyval.ptr); debug("Lines\n"); ; + break;} +case 57: +#line 174 "grammar.y" +{ yyval.ptr = new Node(ID_LINES); yyval.ptr->child = yyvsp[-2].ptr; yyvsp[-2].ptr->next = yyvsp[0].ptr; nodelist.insert(yyval.ptr); debug("Lines\n"); ; + break;} +case 58: +#line 178 "grammar.y" +{ yyval.ptr = new Node(ID_LINE); yyval.ptr->child = yyvsp[0].ptr; nodelist.insert(yyval.ptr); debug("Line\n"); ; + break;} +case 59: +#line 182 "grammar.y" +{ yyval.ptr = new Node(ID_EXPRLIST); yyval.ptr->child = yyvsp[0].ptr; debug("ExprList : Expr\n"); nodelist.insert(yyval.ptr); ; + break;} +case 60: +#line 183 "grammar.y" +{ yyval.ptr = new Node(ID_EXPRLIST); yyval.ptr->child = yyvsp[-1].ptr; yyvsp[-1].ptr->next = yyvsp[0].ptr; debug("ExprList : ExprList Expr\n"); nodelist.insert(yyval.ptr); ; + break;} +case 61: +#line 187 "grammar.y" +{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : Block\n"); nodelist.insert(yyval.ptr);; + break;} +case 62: +#line 188 "grammar.y" +{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : Parenth\n"); nodelist.insert(yyval.ptr);; + break;} +case 63: +#line 189 "grammar.y" +{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : Fence\n"); nodelist.insert(yyval.ptr);; + break;} +case 64: +#line 190 "grammar.y" +{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : SubSupExpr\n"); nodelist.insert(yyval.ptr);; + break;} +case 65: +#line 191 "grammar.y" +{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : FractionExpr\n"); nodelist.insert(yyval.ptr);; + break;} +case 66: +#line 192 "grammar.y" +{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : OverExpr\n"); nodelist.insert(yyval.ptr);; + break;} +case 67: +#line 193 "grammar.y" +{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : DecorationExpr\n"); nodelist.insert(yyval.ptr);; + break;} +case 68: +#line 194 "grammar.y" +{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : RootExpr\n"); nodelist.insert(yyval.ptr);; + break;} +case 69: +#line 195 "grammar.y" +{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : AccentExpr\n"); nodelist.insert(yyval.ptr);; + break;} +case 70: +#line 196 "grammar.y" +{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : PrimaryExpr\n"); nodelist.insert(yyval.ptr);; + break;} +case 71: +#line 197 "grammar.y" +{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : BeginExpr\n"); nodelist.insert(yyval.ptr);; + break;} +case 72: +#line 198 "grammar.y" +{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : EndExpr\n"); nodelist.insert(yyval.ptr);; + break;} +} + /* the action file gets copied in in place of this dollarsign */ +#line 543 "/usr/lib/bison.simple" + + yyvsp -= yylen; + yyssp -= yylen; +#ifdef YYLSP_NEEDED + yylsp -= yylen; +#endif + +#if YYDEBUG != 0 + if (yydebug) + { + short *ssp1 = yyss - 1; + fprintf (stderr, "state stack now"); + while (ssp1 != yyssp) + fprintf (stderr, " %d", *++ssp1); + fprintf (stderr, "\n"); + } +#endif + + *++yyvsp = yyval; + +#ifdef YYLSP_NEEDED + yylsp++; + if (yylen == 0) + { + yylsp->first_line = yylloc.first_line; + yylsp->first_column = yylloc.first_column; + yylsp->last_line = (yylsp-1)->last_line; + yylsp->last_column = (yylsp-1)->last_column; + yylsp->text = 0; + } + else + { + yylsp->last_line = (yylsp+yylen-1)->last_line; + yylsp->last_column = (yylsp+yylen-1)->last_column; + } +#endif + + /* Now "shift" the result of the reduction. + Determine what state that goes to, + based on the state we popped back to + and the rule number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTBASE] + *yyssp; + if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTBASE]; + + goto yynewstate; + +yyerrlab: /* here on detecting error */ + + if (! yyerrstatus) + /* If not already recovering from an error, report this error. */ + { + ++yynerrs; + +#ifdef YYERROR_VERBOSE + yyn = yypact[yystate]; + + if (yyn > YYFLAG && yyn < YYLAST) + { + int size = 0; + char *msg; + int x, count; + + count = 0; + /* Start X at -yyn if nec to avoid negative indexes in yycheck. */ + for (x = (yyn < 0 ? -yyn : 0); + x < (sizeof(yytname) / sizeof(char *)); x++) + if (yycheck[x + yyn] == x) + size += strlen(yytname[x]) + 15, count++; + msg = (char *) malloc(size + 15); + if (msg != 0) + { + strcpy(msg, "parse error"); + + if (count < 5) + { + count = 0; + for (x = (yyn < 0 ? -yyn : 0); + x < (sizeof(yytname) / sizeof(char *)); x++) + if (yycheck[x + yyn] == x) + { + strcat(msg, count == 0 ? ", expecting `" : " or `"); + strcat(msg, yytname[x]); + strcat(msg, "'"); + count++; + } + } + yyerror(msg); + free(msg); + } + else + yyerror ("parse error; also virtual memory exceeded"); + } + else +#endif /* YYERROR_VERBOSE */ + yyerror("parse error"); + } + + goto yyerrlab1; +yyerrlab1: /* here on error raised explicitly by an action */ + + if (yyerrstatus == 3) + { + /* if just tried and failed to reuse lookahead token after an error, discard it. */ + + /* return failure if at end of input */ + if (yychar == YYEOF) + YYABORT; + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]); +#endif + + yychar = YYEMPTY; + } + + /* Else will try to reuse lookahead token + after shifting the error token. */ + + yyerrstatus = 3; /* Each real token shifted decrements this */ + + goto yyerrhandle; + +yyerrdefault: /* current state does not do anything special for the error token. */ + +#if 0 + /* This is wrong; only states that explicitly want error tokens + should shift them. */ + yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ + if (yyn) goto yydefault; +#endif + +yyerrpop: /* pop the current state because it cannot handle the error token */ + + if (yyssp == yyss) YYABORT; + yyvsp--; + yystate = *--yyssp; +#ifdef YYLSP_NEEDED + yylsp--; +#endif + +#if YYDEBUG != 0 + if (yydebug) + { + short *ssp1 = yyss - 1; + fprintf (stderr, "Error: state stack now"); + while (ssp1 != yyssp) + fprintf (stderr, " %d", *++ssp1); + fprintf (stderr, "\n"); + } +#endif + +yyerrhandle: + + yyn = yypact[yystate]; + if (yyn == YYFLAG) + goto yyerrdefault; + + yyn += YYTERROR; + if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) + goto yyerrdefault; + + yyn = yytable[yyn]; + if (yyn < 0) + { + if (yyn == YYFLAG) + goto yyerrpop; + yyn = -yyn; + goto yyreduce; + } + else if (yyn == 0) + goto yyerrpop; + + if (yyn == YYFINAL) + YYACCEPT; + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Shifting error token, "); +#endif + + *++yyvsp = yylval; +#ifdef YYLSP_NEEDED + *++yylsp = yylloc; +#endif + + yystate = yyn; + goto yynewstate; + + yyacceptlab: + /* YYACCEPT comes here. */ + if (yyfree_stacks) + { + free (yyss); + free (yyvs); +#ifdef YYLSP_NEEDED + free (yyls); +#endif + } + return 0; + + yyabortlab: + /* YYABORT comes here. */ + if (yyfree_stacks) + { + free (yyss); + free (yyvs); +#ifdef YYLSP_NEEDED + free (yyls); +#endif + } + return 1; +} +#line 202 "grammar.y" + + +Node *mainParse(const char *_code) +{ + initFlex( _code ); + top = 0L; + yyparse(); + if( top ) + return top; + else + return 0L; +} + +void yyerror(const char * /*err*/) +{ +// printf("REALKING ERR[%s]\n",err); + // if error, delete all nodes. + Node *pNode = 0L; + int ncount = nodelist.count(); + for( int i = 0 ; i < ncount ; i++){ + pNode = nodelist.remove(0); + delete pNode; + } + top = 0L; +} + +#ifndef PARSE_DEBUG +int debug(const char * /*format*/, ...) +{ + return 0; +} +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/hwpfilter/source/hbox.cpp b/hwpfilter/source/hbox.cpp deleted file mode 100644 index fcdd706a3fdb..000000000000 --- a/hwpfilter/source/hbox.cpp +++ /dev/null @@ -1,715 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "precompile.h" - -#include - -#include "hwpfile.h" -#include "hbox.h" -#include "hpara.h" -#include "hutil.h" -#include "htags.h" -#include "drawdef.h" -#include "hcode.h" - -int HBox::boxCount = 0; - -HBox::HBox(hchar hch) -{ - hh = hch; - boxCount++; -} - - -HBox::~HBox() -{ - boxCount--; -} - - -int HBox::WSize(void) -{ - static int wsize[32] = - { - 1, 4, 4, 4, 4, 4, 4, 42, /* dateform */ - 48, 4, 4, 4, 4, 1, 4, 4, /* hidden */ - 4, 4, 4, 4, 4, 4, 12, 5, /* chcompose */ - 3, 3, 123, 4, 32, 4, 2, 2 - }; - - if (hh < 32) - return wsize[hh]; - else - return 1; -} - - -int HBox::GetString(hchar * hstr, int ) -{ - *hstr++ = hh; - *hstr = 0; - return 1; -} - - -hunit HBox::Height(CharShape *csty) -{ - return( csty->size ); -} - - -// skip block -SkipData::SkipData(hchar hch):HBox(hch) -{ - data_block = 0; -} - - -SkipData::~SkipData(void) -{ - delete[]data_block; -} - - -// FieldCode [5] -FieldCode::FieldCode(void) : HBox(CH_FIELD) -{ - str1 = 0; - str2 = 0; - str3 = 0; - bin = 0; - reserved1 = new char[4]; - reserved2 = new char[22]; - m_pDate = 0L; -} - - -FieldCode::~FieldCode(void) -{ - delete[] str1; - delete[] str2; - delete[] str3; - delete[] bin; - delete[] reserved1; - delete[] reserved2; - if( m_pDate ) - delete m_pDate; -} - - -// book mark(6) -Bookmark::Bookmark(void):HBox(CH_BOOKMARK) -{ -} - - -Bookmark::~Bookmark(void) -{ -} - - -// date format(7) -DateFormat::DateFormat(void):HBox(CH_DATE_FORM) -{ -} - - -// date code(8) - -DateCode::DateCode(void):HBox(CH_DATE_CODE) -{ -} - - -#define _DATECODE_WEEK_DEFINES_ -#include "datecode.h" - -int DateCode::GetString(hchar * hstr, int slen) -{ - hchar *fmt, *d; - int i, num; - const char *form; - char cbuf[256]; - bool is_pm, add_zero; - - add_zero = false; - format[DATE_SIZE - 1] = 0; - fmt = format[0] ? format : defaultform; - - d = hstr; - for (; *fmt && ((int) (d - hstr) < DATE_SIZE) && slen > 1; fmt++) - { - form = (add_zero) ? "%02d" : "%d"; - - add_zero = false; - is_pm = (date[HOUR] >= 12); - *cbuf = 0; - num = -1; - - switch (*fmt) - { - case '0': - add_zero = true; - break; - case '1': - num = date[YEAR]; - form = "%04d"; - break; - case '!': - num = date[YEAR] % 100; - break; - case '2': - num = date[MONTH]; - break; - case '@': - memcpy(cbuf, eng_mon + (date[MONTH] - 1) * 3, 3); - cbuf[3] = '.'; - cbuf[4] = 0; - break; - case '*': - strcpy(cbuf, en_mon[date[MONTH] - 1]); - break; - case '3': /* 'D' is day of korean */ - num = date[DAY]; - break; - case '#': - num = date[DAY]; - switch (date[DAY] % 10) - { - case 1: - form = "%dst"; - break; - case 2: - form = "%dnd"; - break; - case 3: - form = "%drd"; - break; - default: - form = "%dth"; - break; - } - break; - case '4': - num = date[HOUR] - ((date[HOUR] > 12) ? 12 : 0); - break; - case '$': - num = date[HOUR]; - break; - case '5': - case '%': - num = date[MIN]; - break; - case '6': - *d++ = kor_week[date[WEEK]]; - slen--; - break; - case '^': - memcpy(cbuf, eng_week + date[WEEK] * 3, 3); - cbuf[3] = '.'; - cbuf[4] = 0; - break; - case '_': - strcpy(cbuf, en_week[date[WEEK]]); - break; - case '7': - if (slen > 3) - { - *d++ = 0xB5A1; - *d++ = (is_pm) ? 0xD281 : 0xB8E5; - } - break; - case '&': - strcpy(cbuf, (is_pm) ? "p.m." : "a.m."); - break; - case '+': - strcpy(cbuf, (is_pm) ? "P.M." : "A.M."); - break; - case '8': // 2.5 feature - case '9': -#if 0 -// LATER - mkcurfilename(cbuf, *fmt); - for (i = 0; cbuf[i] != 0 && slen > 1; i++) - { //for hangle filename - if (cbuf[i] & 0x80 && cbuf[i + 1] != 0) - { - *d++ = (cbuf[i] << 8) | cbuf[i + 1]; - i++; - } - else - *d++ = cbuf[i]; - slen--; - } -#endif - cbuf[0] = 0; - break; - case '~': // 3.0b feature - if (fmt[1] == 0) - break; - fmt++; - if (*fmt == '6') - { - *d++ = china_week[date[WEEK]]; - slen--; - break; - } - break; - default: - if (*fmt == '\\' && *++fmt == 0) - goto done; - *d++ = *fmt; - slen--; - } - if (num != -1) - sprintf(cbuf, form, num); - for (i = 0; 0 != cbuf[i] && slen > 1; i++) - { - *d++ = *(cbuf + i); - slen--; - } - } - done: - *d = 0; - return hstrlen(hstr); -} - - -// tab(9) - -Tab::Tab(void):HBox(CH_TAB) -{ -} - - -// floating box -FBox::FBox(hchar hch):HBox(hch) -{ - prev = next = 0; - zorder = 0; -} - - -FBox::~FBox() -{ -} - - -// tbox(10) TABLE BOX MATH BUTTON HYPERTEXT - -TxtBox::TxtBox(void):FBox(CH_TEXT_BOX), cell(0), plists(0) -{ -} - - -TxtBox::~TxtBox(void) -{ - delete[]cell; - - for (int ii = 0; ii < nCell; ++ii) - { - LinkedListIterator < HWPPara > it(&plists[ii]); - for (; it.current(); it++) - delete it.current(); - } - - LinkedListIterator < HWPPara > it(&caption); - for (; it.current(); it++) - delete it.current(); - - delete[]plists; -} - - -hunit TxtBox::Height(CharShape * csty) -{ - return (style.anchor_type == CHAR_ANCHOR) ? box_ys : csty->size; -} - - -// picture(11) - -Picture::Picture(void):FBox(CH_PICTURE) -{ - follow = 0; - ishyper = false; -} - - -Picture::~Picture(void) -{ - delete[]follow; - if( pictype == PICTYPE_DRAW && picinfo.picdraw.hdo ) - delete (HWPDrawingObject *) picinfo.picdraw.hdo; - - LinkedListIterator < HWPPara > it(&caption); - for (; it.current(); it++) - delete it.current(); -} - - -int Picture::Type() -{ - return pictype; -} - - -hunit Picture::Height(CharShape * sty) -{ - return (style.anchor_type == CHAR_ANCHOR) ? box_ys : sty->size; -} - - -// line(14) -// hidden(15) -Hidden::~Hidden(void) -{ - LinkedListIterator < HWPPara > it(&plist); - for (; it.current(); it++) - delete it.current(); -} - - -// header/footer(16) -HeaderFooter::~HeaderFooter(void) -{ - LinkedListIterator < HWPPara > it(&plist); - for (; it.current(); it++) - delete it.current(); -} - - -// footnote(17) -Footnote::~Footnote(void) -{ - LinkedListIterator < HWPPara > it(&plist); - for (; it.current(); it++) - delete it.current(); -} - - -// auto number(18) -// new number(19) -// show page number (20) -// Ȧʽ/߱ (21) - -// mail merge(22) -int MailMerge::GetString(hchar * hstr, int ) -{ - *hstr = 0; - return 0; -} - - -// character compositon(23) -// hyphen(24) -// toc mark(25) -// index mark(26) -// outline(28) - -#define OL_HANGL_JASO 0 -#define OL_HANGL_KANATA 1 - -static hchar olHanglJaso(int num, int type) -{ - static unsigned char han_init[] = - { "\x88\x90\x94\x9c\xa0\xa4\xac\xb4\xb8\xc0\xc4\xc8\xcc\xd0" }; - static unsigned char jung[] = { 3, 5, 7, 11, 13, 19, 20, 26, 27, 29, 30 }; - static unsigned char jung2[] = { 3, 7, 13, 20, 27, 29, 30 }; - - hchar hh = 0; - - if (type == OL_HANGL_JASO) - { - num = num % (14 + (sizeof(jung) / sizeof(char))); - - if (num < 14) - hh = (han_init[num] << 8) | 'A'; - else - hh = (jung[num - 14] << 5) | 0x8401; - } - else - { - if (num < 14) - hh = (han_init[num] << 8) | 'a'; - else - { - int j = (num / 14) % (sizeof(jung2) / sizeof(char)); - - num = num % 14; - hh = (han_init[num] << 8) | (jung2[j] << 5) | 1; - } - } - return hh; -} - - -static hchar *GetOutlineStyleChars(int style) -{ - static hchar out_bul_style_entry[5][8] = // extern - { - { // 0 OLSTY_BULLET1 - 0x2f18, 0x2f12, 0x2f08, 0x2f02, 0x2f06, 0x2f00, 0x2043, 0x0000 - }, - { // 1 - 0x2f18, 0x2f12, 0x2f06, 0x2f00, 0x2f36, 0x2f30, 0x2043, 0x0000 - }, - { // 2 - 0x2f26, 0x2f20, 0x2f06, 0x2f00, 0x2f16, 0x2f10, 0x2043, 0x0000 - }, - { // 3 - 0x2f18, 0x2f16, 0x2f12, 0x2f10, 0x2f06, 0x2f00, 0x2043, 0x0000 - }, - { // - 0xAC61, 0xB677, 0xB861, 0xB8F7, 0xB781, 0x0000 - }, - }; - if (style >= OLSTY_BULLET1 && style <= OLSTY_BULLET5) - return out_bul_style_entry[style - OLSTY_BULLET1]; - return NULL; -} - - -static void getOutlineNumStr(int style, int level, int num, hchar * hstr) -{ - enum - { - U_ROM = 0x01, L_ROM = 0x02, U_ENG = 0x04, L_ENG = 0x08, - HAN = 0x10, NUM = 0x20, L_BR = 0x40, R_BR = 0x80 - }; - static unsigned char type_tbl[][MAX_OUTLINE_LEVEL] = - { - { - U_ROM, HAN, NUM, HAN | R_BR, L_BR | NUM | R_BR, - L_BR | HAN | R_BR, L_ROM | R_BR - }, - { - U_ROM, U_ENG, NUM, L_ENG | R_BR, L_BR | NUM | R_BR, - L_BR | L_ENG | R_BR, L_ROM | R_BR - }, - { - NUM, HAN, L_BR | NUM | R_BR, L_BR | HAN | R_BR, NUM | - R_BR, HAN | R_BR, L_ENG - } - }; - char fmt = type_tbl[style - OLSTY_NUMSIG1][level]; - char buf[80], *ptr; - - if (num < 1) - num = 1; - if (fmt & L_BR) - *hstr++ = '('; - if (fmt & NUM) - { - sprintf(buf, "%d", num); - str2hstr(buf, hstr); - hstr += strlen(buf); - } - else if (fmt & (U_ROM | L_ROM)) - { - num2roman(num, buf); - if (fmt & U_ROM) - { - ptr = buf; - while (*ptr) - { - *ptr = sal::static_int_cast(toupper(*ptr)); - ptr++; - } - } - str2hstr(buf, hstr); - hstr += strlen(buf); - } - else - { - num = (num - 1) % 26; - if (fmt & U_ENG) - *hstr++ = sal::static_int_cast('A' + num); - else if (fmt & L_ENG) - *hstr++ = sal::static_int_cast('a' + num); - else if (fmt & HAN) - *hstr++ = olHanglJaso(num, OL_HANGL_KANATA); - } - *hstr++ = (fmt & R_BR) ? ')' : '.'; - *hstr = 0; -} - - -enum -{ OUTLINE_ON, OUTLINE_NUM }; - -/* level 0 . 1.1.1. 2̴. - number ״  ִ. , 1.2.1 1,2,1  ִ. - style 1  ִ. hbox.h ǵ .. - */ -hchar *Outline::GetUnicode(hchar * hstr, int) -{ - hchar *p; - hchar buffer[255]; - - buffer[0] = 0; - if (kind == OUTLINE_NUM) - { - int levelnum; - switch (shape) - { - case OLSTY_NUMS1: - case OLSTY_NUMS2: - { - char cur_num_str[10], buf[80]; - int i; - - buf[0] = 0; - for (i = 0; i <= level; i++) - { - levelnum = ((number[i] < 1) ? 1 : number[i]); - if (shape == OLSTY_NUMS2 && i && i == level) - sprintf(cur_num_str, "%d%c", levelnum, 0); - else - sprintf(cur_num_str, "%d%c", levelnum, '.'); - strcat(buf, cur_num_str); - } - str2hstr(buf, buffer); - return hstr2ucsstr(buffer, hstr); - } - case OLSTY_NUMSIG1: - case OLSTY_NUMSIG2: - case OLSTY_NUMSIG3: - { - getOutlineNumStr(shape, level, number[level], buffer); - return hstr2ucsstr(buffer, hstr); - } - case OLSTY_BULLET1: - case OLSTY_BULLET2: - case OLSTY_BULLET3: - case OLSTY_BULLET4: - case OLSTY_BULLET5: - { - p = GetOutlineStyleChars(shape); - buffer[0] = p[level]; - buffer[1] = 0; - return hstr2ucsstr(buffer, hstr); - } - case OLSTY_USER: - case OLSTY_BULUSER: - { - char dest[80]; - int l = 0; - int i = level; - if( deco[i][0] ){ - buffer[l++] = deco[i][0]; - } -/* level 0 . 1.1.1. 2̴. - number ״  ִ. , 1.2.1 1,2,1  ִ. - style 1  ִ. hbox.h ǵ .. - */ - switch( user_shape[i] ) - { - case 0: - buffer[l++] = '1' + number[i] - 1; - break; - case 1: /* 빮ڷθ */ - case 2: /* ҹڷθ */ - num2roman(number[i], dest); - if( user_shape[i] == 1 ){ - char *ptr = dest; - while( *ptr ) - { - *ptr = sal::static_int_cast(toupper(*ptr)); - ptr++; - } - } - str2hstr(dest, buffer + l); - l += strlen(dest); - break; - case 3: - buffer[l++] = 'A' + number[i] -1; - break; - case 4: - buffer[l++] = 'a' + number[i] -1; - break; - case 5: - buffer[l++] = olHanglJaso(number[i] -1, OL_HANGL_KANATA); - break; - case 6: - buffer[l++] = olHanglJaso(number[i] -1, OL_HANGL_JASO); - break; - case 7: /* : Ϲ ڷ ǥ */ - buffer[l++] = '1' + number[i] -1; - break; - case 8: /* */ - buffer[l++] = 0x2e00 + number[i]; - break; - case 9: /* ĺ ҹ */ - buffer[l++] = 0x2c20 + number[i]; - break; - case 10: /* */ - buffer[l++] = 0x2c50 + number[i] -1; - break; - case 11: /* */ - buffer[l++] = 0x2c40 + number[i] -1; - break; - case 12: /* ̾ . */ - { - char cur_num_str[10],buf[80]; - int j; - buf[0] = 0; - for (j = 0; j <= level; j++) - { - levelnum = ((number[j] < 1) ? 1 : number[j]); - if ((j && j == level) || (j == level && deco[i][1])) - sprintf(cur_num_str, "%d%c", levelnum, 0); - else - sprintf(cur_num_str, "%d%c", levelnum, '.'); - strcat(buf, cur_num_str); - } - str2hstr(buf, buffer + l); - l += strlen(buf); - break; - } - default: - buffer[l++] = user_shape[i]; - break; - } - if( deco[i][1] ){ - buffer[l++] = deco[i][1]; - } - buffer[l] = 0; - return hstr2ucsstr(buffer, hstr); - } - } - } - return hstr2ucsstr(buffer, hstr); -} - - -/* ĭ(30) */ -/* ĭ(31) */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/hwpfilter/source/hbox.cxx b/hwpfilter/source/hbox.cxx new file mode 100644 index 000000000000..fcdd706a3fdb --- /dev/null +++ b/hwpfilter/source/hbox.cxx @@ -0,0 +1,715 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "precompile.h" + +#include + +#include "hwpfile.h" +#include "hbox.h" +#include "hpara.h" +#include "hutil.h" +#include "htags.h" +#include "drawdef.h" +#include "hcode.h" + +int HBox::boxCount = 0; + +HBox::HBox(hchar hch) +{ + hh = hch; + boxCount++; +} + + +HBox::~HBox() +{ + boxCount--; +} + + +int HBox::WSize(void) +{ + static int wsize[32] = + { + 1, 4, 4, 4, 4, 4, 4, 42, /* dateform */ + 48, 4, 4, 4, 4, 1, 4, 4, /* hidden */ + 4, 4, 4, 4, 4, 4, 12, 5, /* chcompose */ + 3, 3, 123, 4, 32, 4, 2, 2 + }; + + if (hh < 32) + return wsize[hh]; + else + return 1; +} + + +int HBox::GetString(hchar * hstr, int ) +{ + *hstr++ = hh; + *hstr = 0; + return 1; +} + + +hunit HBox::Height(CharShape *csty) +{ + return( csty->size ); +} + + +// skip block +SkipData::SkipData(hchar hch):HBox(hch) +{ + data_block = 0; +} + + +SkipData::~SkipData(void) +{ + delete[]data_block; +} + + +// FieldCode [5] +FieldCode::FieldCode(void) : HBox(CH_FIELD) +{ + str1 = 0; + str2 = 0; + str3 = 0; + bin = 0; + reserved1 = new char[4]; + reserved2 = new char[22]; + m_pDate = 0L; +} + + +FieldCode::~FieldCode(void) +{ + delete[] str1; + delete[] str2; + delete[] str3; + delete[] bin; + delete[] reserved1; + delete[] reserved2; + if( m_pDate ) + delete m_pDate; +} + + +// book mark(6) +Bookmark::Bookmark(void):HBox(CH_BOOKMARK) +{ +} + + +Bookmark::~Bookmark(void) +{ +} + + +// date format(7) +DateFormat::DateFormat(void):HBox(CH_DATE_FORM) +{ +} + + +// date code(8) + +DateCode::DateCode(void):HBox(CH_DATE_CODE) +{ +} + + +#define _DATECODE_WEEK_DEFINES_ +#include "datecode.h" + +int DateCode::GetString(hchar * hstr, int slen) +{ + hchar *fmt, *d; + int i, num; + const char *form; + char cbuf[256]; + bool is_pm, add_zero; + + add_zero = false; + format[DATE_SIZE - 1] = 0; + fmt = format[0] ? format : defaultform; + + d = hstr; + for (; *fmt && ((int) (d - hstr) < DATE_SIZE) && slen > 1; fmt++) + { + form = (add_zero) ? "%02d" : "%d"; + + add_zero = false; + is_pm = (date[HOUR] >= 12); + *cbuf = 0; + num = -1; + + switch (*fmt) + { + case '0': + add_zero = true; + break; + case '1': + num = date[YEAR]; + form = "%04d"; + break; + case '!': + num = date[YEAR] % 100; + break; + case '2': + num = date[MONTH]; + break; + case '@': + memcpy(cbuf, eng_mon + (date[MONTH] - 1) * 3, 3); + cbuf[3] = '.'; + cbuf[4] = 0; + break; + case '*': + strcpy(cbuf, en_mon[date[MONTH] - 1]); + break; + case '3': /* 'D' is day of korean */ + num = date[DAY]; + break; + case '#': + num = date[DAY]; + switch (date[DAY] % 10) + { + case 1: + form = "%dst"; + break; + case 2: + form = "%dnd"; + break; + case 3: + form = "%drd"; + break; + default: + form = "%dth"; + break; + } + break; + case '4': + num = date[HOUR] - ((date[HOUR] > 12) ? 12 : 0); + break; + case '$': + num = date[HOUR]; + break; + case '5': + case '%': + num = date[MIN]; + break; + case '6': + *d++ = kor_week[date[WEEK]]; + slen--; + break; + case '^': + memcpy(cbuf, eng_week + date[WEEK] * 3, 3); + cbuf[3] = '.'; + cbuf[4] = 0; + break; + case '_': + strcpy(cbuf, en_week[date[WEEK]]); + break; + case '7': + if (slen > 3) + { + *d++ = 0xB5A1; + *d++ = (is_pm) ? 0xD281 : 0xB8E5; + } + break; + case '&': + strcpy(cbuf, (is_pm) ? "p.m." : "a.m."); + break; + case '+': + strcpy(cbuf, (is_pm) ? "P.M." : "A.M."); + break; + case '8': // 2.5 feature + case '9': +#if 0 +// LATER + mkcurfilename(cbuf, *fmt); + for (i = 0; cbuf[i] != 0 && slen > 1; i++) + { //for hangle filename + if (cbuf[i] & 0x80 && cbuf[i + 1] != 0) + { + *d++ = (cbuf[i] << 8) | cbuf[i + 1]; + i++; + } + else + *d++ = cbuf[i]; + slen--; + } +#endif + cbuf[0] = 0; + break; + case '~': // 3.0b feature + if (fmt[1] == 0) + break; + fmt++; + if (*fmt == '6') + { + *d++ = china_week[date[WEEK]]; + slen--; + break; + } + break; + default: + if (*fmt == '\\' && *++fmt == 0) + goto done; + *d++ = *fmt; + slen--; + } + if (num != -1) + sprintf(cbuf, form, num); + for (i = 0; 0 != cbuf[i] && slen > 1; i++) + { + *d++ = *(cbuf + i); + slen--; + } + } + done: + *d = 0; + return hstrlen(hstr); +} + + +// tab(9) + +Tab::Tab(void):HBox(CH_TAB) +{ +} + + +// floating box +FBox::FBox(hchar hch):HBox(hch) +{ + prev = next = 0; + zorder = 0; +} + + +FBox::~FBox() +{ +} + + +// tbox(10) TABLE BOX MATH BUTTON HYPERTEXT + +TxtBox::TxtBox(void):FBox(CH_TEXT_BOX), cell(0), plists(0) +{ +} + + +TxtBox::~TxtBox(void) +{ + delete[]cell; + + for (int ii = 0; ii < nCell; ++ii) + { + LinkedListIterator < HWPPara > it(&plists[ii]); + for (; it.current(); it++) + delete it.current(); + } + + LinkedListIterator < HWPPara > it(&caption); + for (; it.current(); it++) + delete it.current(); + + delete[]plists; +} + + +hunit TxtBox::Height(CharShape * csty) +{ + return (style.anchor_type == CHAR_ANCHOR) ? box_ys : csty->size; +} + + +// picture(11) + +Picture::Picture(void):FBox(CH_PICTURE) +{ + follow = 0; + ishyper = false; +} + + +Picture::~Picture(void) +{ + delete[]follow; + if( pictype == PICTYPE_DRAW && picinfo.picdraw.hdo ) + delete (HWPDrawingObject *) picinfo.picdraw.hdo; + + LinkedListIterator < HWPPara > it(&caption); + for (; it.current(); it++) + delete it.current(); +} + + +int Picture::Type() +{ + return pictype; +} + + +hunit Picture::Height(CharShape * sty) +{ + return (style.anchor_type == CHAR_ANCHOR) ? box_ys : sty->size; +} + + +// line(14) +// hidden(15) +Hidden::~Hidden(void) +{ + LinkedListIterator < HWPPara > it(&plist); + for (; it.current(); it++) + delete it.current(); +} + + +// header/footer(16) +HeaderFooter::~HeaderFooter(void) +{ + LinkedListIterator < HWPPara > it(&plist); + for (; it.current(); it++) + delete it.current(); +} + + +// footnote(17) +Footnote::~Footnote(void) +{ + LinkedListIterator < HWPPara > it(&plist); + for (; it.current(); it++) + delete it.current(); +} + + +// auto number(18) +// new number(19) +// show page number (20) +// Ȧʽ/߱ (21) + +// mail merge(22) +int MailMerge::GetString(hchar * hstr, int ) +{ + *hstr = 0; + return 0; +} + + +// character compositon(23) +// hyphen(24) +// toc mark(25) +// index mark(26) +// outline(28) + +#define OL_HANGL_JASO 0 +#define OL_HANGL_KANATA 1 + +static hchar olHanglJaso(int num, int type) +{ + static unsigned char han_init[] = + { "\x88\x90\x94\x9c\xa0\xa4\xac\xb4\xb8\xc0\xc4\xc8\xcc\xd0" }; + static unsigned char jung[] = { 3, 5, 7, 11, 13, 19, 20, 26, 27, 29, 30 }; + static unsigned char jung2[] = { 3, 7, 13, 20, 27, 29, 30 }; + + hchar hh = 0; + + if (type == OL_HANGL_JASO) + { + num = num % (14 + (sizeof(jung) / sizeof(char))); + + if (num < 14) + hh = (han_init[num] << 8) | 'A'; + else + hh = (jung[num - 14] << 5) | 0x8401; + } + else + { + if (num < 14) + hh = (han_init[num] << 8) | 'a'; + else + { + int j = (num / 14) % (sizeof(jung2) / sizeof(char)); + + num = num % 14; + hh = (han_init[num] << 8) | (jung2[j] << 5) | 1; + } + } + return hh; +} + + +static hchar *GetOutlineStyleChars(int style) +{ + static hchar out_bul_style_entry[5][8] = // extern + { + { // 0 OLSTY_BULLET1 + 0x2f18, 0x2f12, 0x2f08, 0x2f02, 0x2f06, 0x2f00, 0x2043, 0x0000 + }, + { // 1 + 0x2f18, 0x2f12, 0x2f06, 0x2f00, 0x2f36, 0x2f30, 0x2043, 0x0000 + }, + { // 2 + 0x2f26, 0x2f20, 0x2f06, 0x2f00, 0x2f16, 0x2f10, 0x2043, 0x0000 + }, + { // 3 + 0x2f18, 0x2f16, 0x2f12, 0x2f10, 0x2f06, 0x2f00, 0x2043, 0x0000 + }, + { // + 0xAC61, 0xB677, 0xB861, 0xB8F7, 0xB781, 0x0000 + }, + }; + if (style >= OLSTY_BULLET1 && style <= OLSTY_BULLET5) + return out_bul_style_entry[style - OLSTY_BULLET1]; + return NULL; +} + + +static void getOutlineNumStr(int style, int level, int num, hchar * hstr) +{ + enum + { + U_ROM = 0x01, L_ROM = 0x02, U_ENG = 0x04, L_ENG = 0x08, + HAN = 0x10, NUM = 0x20, L_BR = 0x40, R_BR = 0x80 + }; + static unsigned char type_tbl[][MAX_OUTLINE_LEVEL] = + { + { + U_ROM, HAN, NUM, HAN | R_BR, L_BR | NUM | R_BR, + L_BR | HAN | R_BR, L_ROM | R_BR + }, + { + U_ROM, U_ENG, NUM, L_ENG | R_BR, L_BR | NUM | R_BR, + L_BR | L_ENG | R_BR, L_ROM | R_BR + }, + { + NUM, HAN, L_BR | NUM | R_BR, L_BR | HAN | R_BR, NUM | + R_BR, HAN | R_BR, L_ENG + } + }; + char fmt = type_tbl[style - OLSTY_NUMSIG1][level]; + char buf[80], *ptr; + + if (num < 1) + num = 1; + if (fmt & L_BR) + *hstr++ = '('; + if (fmt & NUM) + { + sprintf(buf, "%d", num); + str2hstr(buf, hstr); + hstr += strlen(buf); + } + else if (fmt & (U_ROM | L_ROM)) + { + num2roman(num, buf); + if (fmt & U_ROM) + { + ptr = buf; + while (*ptr) + { + *ptr = sal::static_int_cast(toupper(*ptr)); + ptr++; + } + } + str2hstr(buf, hstr); + hstr += strlen(buf); + } + else + { + num = (num - 1) % 26; + if (fmt & U_ENG) + *hstr++ = sal::static_int_cast('A' + num); + else if (fmt & L_ENG) + *hstr++ = sal::static_int_cast('a' + num); + else if (fmt & HAN) + *hstr++ = olHanglJaso(num, OL_HANGL_KANATA); + } + *hstr++ = (fmt & R_BR) ? ')' : '.'; + *hstr = 0; +} + + +enum +{ OUTLINE_ON, OUTLINE_NUM }; + +/* level 0 . 1.1.1. 2̴. + number ״  ִ. , 1.2.1 1,2,1  ִ. + style 1  ִ. hbox.h ǵ .. + */ +hchar *Outline::GetUnicode(hchar * hstr, int) +{ + hchar *p; + hchar buffer[255]; + + buffer[0] = 0; + if (kind == OUTLINE_NUM) + { + int levelnum; + switch (shape) + { + case OLSTY_NUMS1: + case OLSTY_NUMS2: + { + char cur_num_str[10], buf[80]; + int i; + + buf[0] = 0; + for (i = 0; i <= level; i++) + { + levelnum = ((number[i] < 1) ? 1 : number[i]); + if (shape == OLSTY_NUMS2 && i && i == level) + sprintf(cur_num_str, "%d%c", levelnum, 0); + else + sprintf(cur_num_str, "%d%c", levelnum, '.'); + strcat(buf, cur_num_str); + } + str2hstr(buf, buffer); + return hstr2ucsstr(buffer, hstr); + } + case OLSTY_NUMSIG1: + case OLSTY_NUMSIG2: + case OLSTY_NUMSIG3: + { + getOutlineNumStr(shape, level, number[level], buffer); + return hstr2ucsstr(buffer, hstr); + } + case OLSTY_BULLET1: + case OLSTY_BULLET2: + case OLSTY_BULLET3: + case OLSTY_BULLET4: + case OLSTY_BULLET5: + { + p = GetOutlineStyleChars(shape); + buffer[0] = p[level]; + buffer[1] = 0; + return hstr2ucsstr(buffer, hstr); + } + case OLSTY_USER: + case OLSTY_BULUSER: + { + char dest[80]; + int l = 0; + int i = level; + if( deco[i][0] ){ + buffer[l++] = deco[i][0]; + } +/* level 0 . 1.1.1. 2̴. + number ״  ִ. , 1.2.1 1,2,1  ִ. + style 1  ִ. hbox.h ǵ .. + */ + switch( user_shape[i] ) + { + case 0: + buffer[l++] = '1' + number[i] - 1; + break; + case 1: /* 빮ڷθ */ + case 2: /* ҹڷθ */ + num2roman(number[i], dest); + if( user_shape[i] == 1 ){ + char *ptr = dest; + while( *ptr ) + { + *ptr = sal::static_int_cast(toupper(*ptr)); + ptr++; + } + } + str2hstr(dest, buffer + l); + l += strlen(dest); + break; + case 3: + buffer[l++] = 'A' + number[i] -1; + break; + case 4: + buffer[l++] = 'a' + number[i] -1; + break; + case 5: + buffer[l++] = olHanglJaso(number[i] -1, OL_HANGL_KANATA); + break; + case 6: + buffer[l++] = olHanglJaso(number[i] -1, OL_HANGL_JASO); + break; + case 7: /* : Ϲ ڷ ǥ */ + buffer[l++] = '1' + number[i] -1; + break; + case 8: /* */ + buffer[l++] = 0x2e00 + number[i]; + break; + case 9: /* ĺ ҹ */ + buffer[l++] = 0x2c20 + number[i]; + break; + case 10: /* */ + buffer[l++] = 0x2c50 + number[i] -1; + break; + case 11: /* */ + buffer[l++] = 0x2c40 + number[i] -1; + break; + case 12: /* ̾ . */ + { + char cur_num_str[10],buf[80]; + int j; + buf[0] = 0; + for (j = 0; j <= level; j++) + { + levelnum = ((number[j] < 1) ? 1 : number[j]); + if ((j && j == level) || (j == level && deco[i][1])) + sprintf(cur_num_str, "%d%c", levelnum, 0); + else + sprintf(cur_num_str, "%d%c", levelnum, '.'); + strcat(buf, cur_num_str); + } + str2hstr(buf, buffer + l); + l += strlen(buf); + break; + } + default: + buffer[l++] = user_shape[i]; + break; + } + if( deco[i][1] ){ + buffer[l++] = deco[i][1]; + } + buffer[l] = 0; + return hstr2ucsstr(buffer, hstr); + } + } + } + return hstr2ucsstr(buffer, hstr); +} + + +/* ĭ(30) */ +/* ĭ(31) */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/hwpfilter/source/hcode.cpp b/hwpfilter/source/hcode.cpp deleted file mode 100644 index 65ab7d662b5c..000000000000 --- a/hwpfilter/source/hcode.cpp +++ /dev/null @@ -1,1525 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -/** - * Rule : - * Hangule johap code => unicode - * Hanja johap code => ks code => unicode - * Special johap code => ks code => unicode - */ -#include "precompile.h" -#include -#include -#include -#include -#include -#include -#ifdef WIN32 -#include -#define isnan _isnan -#endif -#include "hcode.h" -#include "ksc5601.h" - -#define PI 3.14159265358979323846 - -static hchar jaso2ks(hchar hh); - -/* Conversion table. */ -#define KSC5601_HANJA 4888 -#define KSC5601_SYMBOL 986 - -// ccvHH2ASC code convert HWP20 to ASC(KSSM) - -#define HCA_HALFCH 0x3000 -#define HCA_KSS 0x3400 -#define HCA_TG 0x37C0 -#define none 0x3401 /* 2.0 null code - space */ -#define noneha 0x00A0 -#define noneks 0xA1A1 -#define none1x 0x2402 - -#define UNI_HANGUL_FIRST 0xac00 -#define UNI_COMP_JAMO_FIRST 0x3131 - -#define NUM_CHOSEONG 19 -#define NUM_JOONGSEONG 21 -#define NUM_JONGSEONG 28 - - -#define IDX_INVALID 0xFF - -/** - * kssm code table matching with ks index - */ -static hchar ksTbl[2350] = -{ - 0x8861, 0x8862, 0x8865, 0x8868, 0x8869, 0x886A, 0x886B, 0x8871, - 0x8873, 0x8874, 0x8875, 0x8876, 0x8877, 0x8878, 0x8879, 0x887B, - 0x887C, 0x887D, 0x8881, 0x8882, 0x8885, 0x8889, 0x8891, 0x8893, - 0x8895, 0x8896, 0x8897, 0x88A1, 0x88A2, 0x88A5, 0x88A9, 0x88B5, - 0x88B7, 0x88C1, 0x88C5, 0x88C9, 0x88E1, 0x88E2, 0x88E5, 0x88E8, - 0x88E9, 0x88EB, 0x88F1, 0x88F3, 0x88F5, 0x88F6, 0x88F7, 0x88F8, - 0x88FB, 0x88FC, 0x88FD, 0x8941, 0x8945, 0x8949, 0x8951, 0x8953, - 0x8955, 0x8956, 0x8957, 0x8961, 0x8962, 0x8963, 0x8965, 0x8968, - 0x8969, 0x8971, 0x8973, 0x8975, 0x8976, 0x8977, 0x897B, 0x8981, - 0x8985, 0x8989, 0x8993, 0x8995, 0x89A1, 0x89A2, 0x89A5, 0x89A8, - 0x89A9, 0x89AB, 0x89AD, 0x89B0, 0x89B1, 0x89B3, 0x89B5, 0x89B7, - 0x89B8, 0x89C1, 0x89C2, 0x89C5, 0x89C9, 0x89CB, 0x89D1, 0x89D3, - 0x89D5, 0x89D7, 0x89E1, 0x89E5, 0x89E9, 0x89F3, 0x89F6, 0x89F7, - 0x8A41, 0x8A42, 0x8A45, 0x8A49, 0x8A51, 0x8A53, 0x8A55, 0x8A57, - 0x8A61, 0x8A65, 0x8A69, 0x8A73, 0x8A75, 0x8A81, 0x8A82, 0x8A85, - 0x8A88, 0x8A89, 0x8A8A, 0x8A8B, 0x8A90, 0x8A91, 0x8A93, 0x8A95, - 0x8A97, 0x8A98, 0x8AA1, 0x8AA2, 0x8AA5, 0x8AA9, 0x8AB6, 0x8AB7, - 0x8AC1, 0x8AD5, 0x8AE1, 0x8AE2, 0x8AE5, 0x8AE9, 0x8AF1, 0x8AF3, - 0x8AF5, 0x8B41, 0x8B45, 0x8B49, 0x8B61, 0x8B62, 0x8B65, 0x8B68, - 0x8B69, 0x8B6A, 0x8B71, 0x8B73, 0x8B75, 0x8B77, 0x8B81, 0x8BA1, - 0x8BA2, 0x8BA5, 0x8BA8, 0x8BA9, 0x8BAB, 0x8BB1, 0x8BB3, 0x8BB5, - 0x8BB7, 0x8BB8, 0x8BBC, 0x8C61, 0x8C62, 0x8C63, 0x8C65, 0x8C69, - 0x8C6B, 0x8C71, 0x8C73, 0x8C75, 0x8C76, 0x8C77, 0x8C7B, 0x8C81, - 0x8C82, 0x8C85, 0x8C89, 0x8C91, 0x8C93, 0x8C95, 0x8C96, 0x8C97, - 0x8CA1, 0x8CA2, 0x8CA9, 0x8CE1, 0x8CE2, 0x8CE3, 0x8CE5, 0x8CE9, - 0x8CF1, 0x8CF3, 0x8CF5, 0x8CF6, 0x8CF7, 0x8D41, 0x8D42, 0x8D45, - 0x8D51, 0x8D55, 0x8D57, 0x8D61, 0x8D65, 0x8D69, 0x8D75, 0x8D76, - 0x8D7B, 0x8D81, 0x8DA1, 0x8DA2, 0x8DA5, 0x8DA7, 0x8DA9, 0x8DB1, - 0x8DB3, 0x8DB5, 0x8DB7, 0x8DB8, 0x8DB9, 0x8DC1, 0x8DC2, 0x8DC9, - 0x8DD6, 0x8DD7, 0x8DE1, 0x8DE2, 0x8DF7, 0x8E41, 0x8E45, 0x8E49, - 0x8E51, 0x8E53, 0x8E57, 0x8E61, 0x8E81, 0x8E82, 0x8E85, 0x8E89, - 0x8E90, 0x8E91, 0x8E93, 0x8E95, 0x8E97, 0x8E98, 0x8EA1, 0x8EA9, - 0x8EB6, 0x8EB7, 0x8EC1, 0x8EC2, 0x8EC5, 0x8EC9, 0x8ED1, 0x8ED3, - 0x8ED6, 0x8EE1, 0x8EE5, 0x8EE9, 0x8EF1, 0x8EF3, 0x8F41, 0x8F61, - 0x8F62, 0x8F65, 0x8F67, 0x8F69, 0x8F6B, 0x8F70, 0x8F71, 0x8F73, - 0x8F75, 0x8F77, 0x8F7B, 0x8FA1, 0x8FA2, 0x8FA5, 0x8FA9, 0x8FB1, - 0x8FB3, 0x8FB5, 0x8FB7, 0x9061, 0x9062, 0x9063, 0x9065, 0x9068, - 0x9069, 0x906A, 0x906B, 0x9071, 0x9073, 0x9075, 0x9076, 0x9077, - 0x9078, 0x9079, 0x907B, 0x907D, 0x9081, 0x9082, 0x9085, 0x9089, - 0x9091, 0x9093, 0x9095, 0x9096, 0x9097, 0x90A1, 0x90A2, 0x90A5, - 0x90A9, 0x90B1, 0x90B7, 0x90E1, 0x90E2, 0x90E4, 0x90E5, 0x90E9, - 0x90EB, 0x90EC, 0x90F1, 0x90F3, 0x90F5, 0x90F6, 0x90F7, 0x90FD, - 0x9141, 0x9142, 0x9145, 0x9149, 0x9151, 0x9153, 0x9155, 0x9156, - 0x9157, 0x9161, 0x9162, 0x9165, 0x9169, 0x9171, 0x9173, 0x9176, - 0x9177, 0x917A, 0x9181, 0x9185, 0x91A1, 0x91A2, 0x91A5, 0x91A9, - 0x91AB, 0x91B1, 0x91B3, 0x91B5, 0x91B7, 0x91BC, 0x91BD, 0x91C1, - 0x91C5, 0x91C9, 0x91D6, 0x9241, 0x9245, 0x9249, 0x9251, 0x9253, - 0x9255, 0x9261, 0x9262, 0x9265, 0x9269, 0x9273, 0x9275, 0x9277, - 0x9281, 0x9282, 0x9285, 0x9288, 0x9289, 0x9291, 0x9293, 0x9295, - 0x9297, 0x92A1, 0x92B6, 0x92C1, 0x92E1, 0x92E5, 0x92E9, 0x92F1, - 0x92F3, 0x9341, 0x9342, 0x9349, 0x9351, 0x9353, 0x9357, 0x9361, - 0x9362, 0x9365, 0x9369, 0x936A, 0x936B, 0x9371, 0x9373, 0x9375, - 0x9377, 0x9378, 0x937C, 0x9381, 0x9385, 0x9389, 0x93A1, 0x93A2, - 0x93A5, 0x93A9, 0x93AF, 0x93B1, 0x93B3, 0x93B5, 0x93B7, 0x93BC, - 0x9461, 0x9462, 0x9463, 0x9465, 0x9468, 0x9469, 0x946A, 0x946B, - 0x946C, 0x9470, 0x9471, 0x9473, 0x9475, 0x9476, 0x9477, 0x9478, - 0x9479, 0x947D, 0x9481, 0x9482, 0x9485, 0x9489, 0x9491, 0x9493, - 0x9495, 0x9496, 0x9497, 0x94A1, 0x94E1, 0x94E2, 0x94E3, 0x94E5, - 0x94E8, 0x94E9, 0x94EB, 0x94EC, 0x94F1, 0x94F3, 0x94F5, 0x94F7, - 0x94F9, 0x94FC, 0x9541, 0x9542, 0x9545, 0x9549, 0x9551, 0x9553, - 0x9555, 0x9556, 0x9557, 0x9561, 0x9565, 0x9569, 0x9576, 0x9577, - 0x9581, 0x9585, 0x95A1, 0x95A2, 0x95A5, 0x95A8, 0x95A9, 0x95AB, - 0x95AD, 0x95B1, 0x95B3, 0x95B5, 0x95B7, 0x95B9, 0x95BB, 0x95C1, - 0x95C5, 0x95C9, 0x95E1, 0x95F6, 0x9641, 0x9645, 0x9649, 0x9651, - 0x9653, 0x9655, 0x9661, 0x9681, 0x9682, 0x9685, 0x9689, 0x9691, - 0x9693, 0x9695, 0x9697, 0x96A1, 0x96B6, 0x96C1, 0x96D7, 0x96E1, - 0x96E5, 0x96E9, 0x96F3, 0x96F5, 0x96F7, 0x9741, 0x9745, 0x9749, - 0x9751, 0x9757, 0x9761, 0x9762, 0x9765, 0x9768, 0x9769, 0x976B, - 0x9771, 0x9773, 0x9775, 0x9777, 0x9781, 0x97A1, 0x97A2, 0x97A5, - 0x97A8, 0x97A9, 0x97B1, 0x97B3, 0x97B5, 0x97B6, 0x97B7, 0x97B8, - 0x9861, 0x9862, 0x9865, 0x9869, 0x9871, 0x9873, 0x9875, 0x9876, - 0x9877, 0x987D, 0x9881, 0x9882, 0x9885, 0x9889, 0x9891, 0x9893, - 0x9895, 0x9896, 0x9897, 0x98E1, 0x98E2, 0x98E5, 0x98E9, 0x98EB, - 0x98EC, 0x98F1, 0x98F3, 0x98F5, 0x98F6, 0x98F7, 0x98FD, 0x9941, - 0x9942, 0x9945, 0x9949, 0x9951, 0x9953, 0x9955, 0x9956, 0x9957, - 0x9961, 0x9976, 0x99A1, 0x99A2, 0x99A5, 0x99A9, 0x99B7, 0x99C1, - 0x99C9, 0x99E1, 0x9A41, 0x9A45, 0x9A81, 0x9A82, 0x9A85, 0x9A89, - 0x9A90, 0x9A91, 0x9A97, 0x9AC1, 0x9AE1, 0x9AE5, 0x9AE9, 0x9AF1, - 0x9AF3, 0x9AF7, 0x9B61, 0x9B62, 0x9B65, 0x9B68, 0x9B69, 0x9B71, - 0x9B73, 0x9B75, 0x9B81, 0x9B85, 0x9B89, 0x9B91, 0x9B93, 0x9BA1, - 0x9BA5, 0x9BA9, 0x9BB1, 0x9BB3, 0x9BB5, 0x9BB7, 0x9C61, 0x9C62, - 0x9C65, 0x9C69, 0x9C71, 0x9C73, 0x9C75, 0x9C76, 0x9C77, 0x9C78, - 0x9C7C, 0x9C7D, 0x9C81, 0x9C82, 0x9C85, 0x9C89, 0x9C91, 0x9C93, - 0x9C95, 0x9C96, 0x9C97, 0x9CA1, 0x9CA2, 0x9CA5, 0x9CB5, 0x9CB7, - 0x9CE1, 0x9CE2, 0x9CE5, 0x9CE9, 0x9CF1, 0x9CF3, 0x9CF5, 0x9CF6, - 0x9CF7, 0x9CFD, 0x9D41, 0x9D42, 0x9D45, 0x9D49, 0x9D51, 0x9D53, - 0x9D55, 0x9D57, 0x9D61, 0x9D62, 0x9D65, 0x9D69, 0x9D71, 0x9D73, - 0x9D75, 0x9D76, 0x9D77, 0x9D81, 0x9D85, 0x9D93, 0x9D95, 0x9DA1, - 0x9DA2, 0x9DA5, 0x9DA9, 0x9DB1, 0x9DB3, 0x9DB5, 0x9DB7, 0x9DC1, - 0x9DC5, 0x9DD7, 0x9DF6, 0x9E41, 0x9E45, 0x9E49, 0x9E51, 0x9E53, - 0x9E55, 0x9E57, 0x9E61, 0x9E65, 0x9E69, 0x9E73, 0x9E75, 0x9E77, - 0x9E81, 0x9E82, 0x9E85, 0x9E89, 0x9E91, 0x9E93, 0x9E95, 0x9E97, - 0x9EA1, 0x9EB6, 0x9EC1, 0x9EE1, 0x9EE2, 0x9EE5, 0x9EE9, 0x9EF1, - 0x9EF5, 0x9EF7, 0x9F41, 0x9F42, 0x9F45, 0x9F49, 0x9F51, 0x9F53, - 0x9F55, 0x9F57, 0x9F61, 0x9F62, 0x9F65, 0x9F69, 0x9F71, 0x9F73, - 0x9F75, 0x9F77, 0x9F78, 0x9F7B, 0x9F7C, 0x9FA1, 0x9FA2, 0x9FA5, - 0x9FA9, 0x9FB1, 0x9FB3, 0x9FB5, 0x9FB7, 0xA061, 0xA062, 0xA065, - 0xA067, 0xA068, 0xA069, 0xA06A, 0xA06B, 0xA071, 0xA073, 0xA075, - 0xA077, 0xA078, 0xA07B, 0xA07D, 0xA081, 0xA082, 0xA085, 0xA089, - 0xA091, 0xA093, 0xA095, 0xA096, 0xA097, 0xA098, 0xA0A1, 0xA0A2, - 0xA0A9, 0xA0B7, 0xA0E1, 0xA0E2, 0xA0E5, 0xA0E9, 0xA0EB, 0xA0F1, - 0xA0F3, 0xA0F5, 0xA0F7, 0xA0F8, 0xA0FD, 0xA141, 0xA142, 0xA145, - 0xA149, 0xA151, 0xA153, 0xA155, 0xA156, 0xA157, 0xA161, 0xA162, - 0xA165, 0xA169, 0xA175, 0xA176, 0xA177, 0xA179, 0xA181, 0xA1A1, - 0xA1A2, 0xA1A4, 0xA1A5, 0xA1A9, 0xA1AB, 0xA1B1, 0xA1B3, 0xA1B5, - 0xA1B7, 0xA1C1, 0xA1C5, 0xA1D6, 0xA1D7, 0xA241, 0xA245, 0xA249, - 0xA253, 0xA255, 0xA257, 0xA261, 0xA265, 0xA269, 0xA273, 0xA275, - 0xA281, 0xA282, 0xA283, 0xA285, 0xA288, 0xA289, 0xA28A, 0xA28B, - 0xA291, 0xA293, 0xA295, 0xA297, 0xA29B, 0xA29D, 0xA2A1, 0xA2A5, - 0xA2A9, 0xA2B3, 0xA2B5, 0xA2C1, 0xA2E1, 0xA2E5, 0xA2E9, 0xA341, - 0xA345, 0xA349, 0xA351, 0xA355, 0xA361, 0xA365, 0xA369, 0xA371, - 0xA375, 0xA3A1, 0xA3A2, 0xA3A5, 0xA3A8, 0xA3A9, 0xA3AB, 0xA3B1, - 0xA3B3, 0xA3B5, 0xA3B6, 0xA3B7, 0xA3B9, 0xA3BB, 0xA461, 0xA462, - 0xA463, 0xA464, 0xA465, 0xA468, 0xA469, 0xA46A, 0xA46B, 0xA46C, - 0xA471, 0xA473, 0xA475, 0xA477, 0xA47B, 0xA481, 0xA482, 0xA485, - 0xA489, 0xA491, 0xA493, 0xA495, 0xA496, 0xA497, 0xA49B, 0xA4A1, - 0xA4A2, 0xA4A5, 0xA4B3, 0xA4E1, 0xA4E2, 0xA4E5, 0xA4E8, 0xA4E9, - 0xA4EB, 0xA4F1, 0xA4F3, 0xA4F5, 0xA4F7, 0xA4F8, 0xA541, 0xA542, - 0xA545, 0xA548, 0xA549, 0xA551, 0xA553, 0xA555, 0xA556, 0xA557, - 0xA561, 0xA562, 0xA565, 0xA569, 0xA573, 0xA575, 0xA576, 0xA577, - 0xA57B, 0xA581, 0xA585, 0xA5A1, 0xA5A2, 0xA5A3, 0xA5A5, 0xA5A9, - 0xA5B1, 0xA5B3, 0xA5B5, 0xA5B7, 0xA5C1, 0xA5C5, 0xA5D6, 0xA5E1, - 0xA5F6, 0xA641, 0xA642, 0xA645, 0xA649, 0xA651, 0xA653, 0xA661, - 0xA665, 0xA681, 0xA682, 0xA685, 0xA688, 0xA689, 0xA68A, 0xA68B, - 0xA691, 0xA693, 0xA695, 0xA697, 0xA69B, 0xA69C, 0xA6A1, 0xA6A9, - 0xA6B6, 0xA6C1, 0xA6E1, 0xA6E2, 0xA6E5, 0xA6E9, 0xA6F7, 0xA741, - 0xA745, 0xA749, 0xA751, 0xA755, 0xA757, 0xA761, 0xA762, 0xA765, - 0xA769, 0xA771, 0xA773, 0xA775, 0xA7A1, 0xA7A2, 0xA7A5, 0xA7A9, - 0xA7AB, 0xA7B1, 0xA7B3, 0xA7B5, 0xA7B7, 0xA7B8, 0xA7B9, 0xA861, - 0xA862, 0xA865, 0xA869, 0xA86B, 0xA871, 0xA873, 0xA875, 0xA876, - 0xA877, 0xA87D, 0xA881, 0xA882, 0xA885, 0xA889, 0xA891, 0xA893, - 0xA895, 0xA896, 0xA897, 0xA8A1, 0xA8A2, 0xA8B1, 0xA8E1, 0xA8E2, - 0xA8E5, 0xA8E8, 0xA8E9, 0xA8F1, 0xA8F5, 0xA8F6, 0xA8F7, 0xA941, - 0xA957, 0xA961, 0xA962, 0xA971, 0xA973, 0xA975, 0xA976, 0xA977, - 0xA9A1, 0xA9A2, 0xA9A5, 0xA9A9, 0xA9B1, 0xA9B3, 0xA9B7, 0xAA41, - 0xAA61, 0xAA77, 0xAA81, 0xAA82, 0xAA85, 0xAA89, 0xAA91, 0xAA95, - 0xAA97, 0xAB41, 0xAB57, 0xAB61, 0xAB65, 0xAB69, 0xAB71, 0xAB73, - 0xABA1, 0xABA2, 0xABA5, 0xABA9, 0xABB1, 0xABB3, 0xABB5, 0xABB7, - 0xAC61, 0xAC62, 0xAC64, 0xAC65, 0xAC68, 0xAC69, 0xAC6A, 0xAC6B, - 0xAC71, 0xAC73, 0xAC75, 0xAC76, 0xAC77, 0xAC7B, 0xAC81, 0xAC82, - 0xAC85, 0xAC89, 0xAC91, 0xAC93, 0xAC95, 0xAC96, 0xAC97, 0xACA1, - 0xACA2, 0xACA5, 0xACA9, 0xACB1, 0xACB3, 0xACB5, 0xACB7, 0xACC1, - 0xACC5, 0xACC9, 0xACD1, 0xACD7, 0xACE1, 0xACE2, 0xACE3, 0xACE4, - 0xACE5, 0xACE8, 0xACE9, 0xACEB, 0xACEC, 0xACF1, 0xACF3, 0xACF5, - 0xACF6, 0xACF7, 0xACFC, 0xAD41, 0xAD42, 0xAD45, 0xAD49, 0xAD51, - 0xAD53, 0xAD55, 0xAD56, 0xAD57, 0xAD61, 0xAD62, 0xAD65, 0xAD69, - 0xAD71, 0xAD73, 0xAD75, 0xAD76, 0xAD77, 0xAD81, 0xAD85, 0xAD89, - 0xAD97, 0xADA1, 0xADA2, 0xADA3, 0xADA5, 0xADA9, 0xADAB, 0xADB1, - 0xADB3, 0xADB5, 0xADB7, 0xADBB, 0xADC1, 0xADC2, 0xADC5, 0xADC9, - 0xADD7, 0xADE1, 0xADE5, 0xADE9, 0xADF1, 0xADF5, 0xADF6, 0xAE41, - 0xAE45, 0xAE49, 0xAE51, 0xAE53, 0xAE55, 0xAE61, 0xAE62, 0xAE65, - 0xAE69, 0xAE71, 0xAE73, 0xAE75, 0xAE77, 0xAE81, 0xAE82, 0xAE85, - 0xAE88, 0xAE89, 0xAE91, 0xAE93, 0xAE95, 0xAE97, 0xAE99, 0xAE9B, - 0xAE9C, 0xAEA1, 0xAEB6, 0xAEC1, 0xAEC2, 0xAEC5, 0xAEC9, 0xAED1, - 0xAED7, 0xAEE1, 0xAEE2, 0xAEE5, 0xAEE9, 0xAEF1, 0xAEF3, 0xAEF5, - 0xAEF7, 0xAF41, 0xAF42, 0xAF49, 0xAF51, 0xAF55, 0xAF57, 0xAF61, - 0xAF62, 0xAF65, 0xAF69, 0xAF6A, 0xAF71, 0xAF73, 0xAF75, 0xAF77, - 0xAFA1, 0xAFA2, 0xAFA5, 0xAFA8, 0xAFA9, 0xAFB0, 0xAFB1, 0xAFB3, - 0xAFB5, 0xAFB7, 0xAFBC, 0xB061, 0xB062, 0xB064, 0xB065, 0xB069, - 0xB071, 0xB073, 0xB076, 0xB077, 0xB07D, 0xB081, 0xB082, 0xB085, - 0xB089, 0xB091, 0xB093, 0xB096, 0xB097, 0xB0B7, 0xB0E1, 0xB0E2, - 0xB0E5, 0xB0E9, 0xB0EB, 0xB0F1, 0xB0F3, 0xB0F6, 0xB0F7, 0xB141, - 0xB145, 0xB149, 0xB185, 0xB1A1, 0xB1A2, 0xB1A5, 0xB1A8, 0xB1A9, - 0xB1AB, 0xB1B1, 0xB1B3, 0xB1B7, 0xB1C1, 0xB1C2, 0xB1C5, 0xB1D6, - 0xB1E1, 0xB1F6, 0xB241, 0xB245, 0xB249, 0xB251, 0xB253, 0xB261, - 0xB281, 0xB282, 0xB285, 0xB289, 0xB291, 0xB293, 0xB297, 0xB2A1, - 0xB2B6, 0xB2C1, 0xB2E1, 0xB2E5, 0xB357, 0xB361, 0xB362, 0xB365, - 0xB369, 0xB36B, 0xB370, 0xB371, 0xB373, 0xB381, 0xB385, 0xB389, - 0xB391, 0xB3A1, 0xB3A2, 0xB3A5, 0xB3A9, 0xB3B1, 0xB3B3, 0xB3B5, - 0xB3B7, 0xB461, 0xB462, 0xB465, 0xB466, 0xB467, 0xB469, 0xB46A, - 0xB46B, 0xB470, 0xB471, 0xB473, 0xB475, 0xB476, 0xB477, 0xB47B, - 0xB47C, 0xB481, 0xB482, 0xB485, 0xB489, 0xB491, 0xB493, 0xB495, - 0xB496, 0xB497, 0xB4A1, 0xB4A2, 0xB4A5, 0xB4A9, 0xB4AC, 0xB4B1, - 0xB4B3, 0xB4B5, 0xB4B7, 0xB4BB, 0xB4BD, 0xB4C1, 0xB4C5, 0xB4C9, - 0xB4D3, 0xB4E1, 0xB4E2, 0xB4E5, 0xB4E6, 0xB4E8, 0xB4E9, 0xB4EA, - 0xB4EB, 0xB4F1, 0xB4F3, 0xB4F4, 0xB4F5, 0xB4F6, 0xB4F7, 0xB4F8, - 0xB4FA, 0xB4FC, 0xB541, 0xB542, 0xB545, 0xB549, 0xB551, 0xB553, - 0xB555, 0xB557, 0xB561, 0xB562, 0xB563, 0xB565, 0xB569, 0xB56B, - 0xB56C, 0xB571, 0xB573, 0xB574, 0xB575, 0xB576, 0xB577, 0xB57B, - 0xB57C, 0xB57D, 0xB581, 0xB585, 0xB589, 0xB591, 0xB593, 0xB595, - 0xB596, 0xB5A1, 0xB5A2, 0xB5A5, 0xB5A9, 0xB5AA, 0xB5AB, 0xB5AD, - 0xB5B0, 0xB5B1, 0xB5B3, 0xB5B5, 0xB5B7, 0xB5B9, 0xB5C1, 0xB5C2, - 0xB5C5, 0xB5C9, 0xB5D1, 0xB5D3, 0xB5D5, 0xB5D6, 0xB5D7, 0xB5E1, - 0xB5E2, 0xB5E5, 0xB5F1, 0xB5F5, 0xB5F7, 0xB641, 0xB642, 0xB645, - 0xB649, 0xB651, 0xB653, 0xB655, 0xB657, 0xB661, 0xB662, 0xB665, - 0xB669, 0xB671, 0xB673, 0xB675, 0xB677, 0xB681, 0xB682, 0xB685, - 0xB689, 0xB68A, 0xB68B, 0xB691, 0xB693, 0xB695, 0xB697, 0xB6A1, - 0xB6A2, 0xB6A5, 0xB6A9, 0xB6B1, 0xB6B3, 0xB6B6, 0xB6B7, 0xB6C1, - 0xB6C2, 0xB6C5, 0xB6C9, 0xB6D1, 0xB6D3, 0xB6D7, 0xB6E1, 0xB6E2, - 0xB6E5, 0xB6E9, 0xB6F1, 0xB6F3, 0xB6F5, 0xB6F7, 0xB741, 0xB742, - 0xB745, 0xB749, 0xB751, 0xB753, 0xB755, 0xB757, 0xB759, 0xB761, - 0xB762, 0xB765, 0xB769, 0xB76F, 0xB771, 0xB773, 0xB775, 0xB777, - 0xB778, 0xB779, 0xB77A, 0xB77B, 0xB77C, 0xB77D, 0xB781, 0xB785, - 0xB789, 0xB791, 0xB795, 0xB7A1, 0xB7A2, 0xB7A5, 0xB7A9, 0xB7AA, - 0xB7AB, 0xB7B0, 0xB7B1, 0xB7B3, 0xB7B5, 0xB7B6, 0xB7B7, 0xB7B8, - 0xB7BC, 0xB861, 0xB862, 0xB865, 0xB867, 0xB868, 0xB869, 0xB86B, - 0xB871, 0xB873, 0xB875, 0xB876, 0xB877, 0xB878, 0xB881, 0xB882, - 0xB885, 0xB889, 0xB891, 0xB893, 0xB895, 0xB896, 0xB897, 0xB8A1, - 0xB8A2, 0xB8A5, 0xB8A7, 0xB8A9, 0xB8B1, 0xB8B7, 0xB8C1, 0xB8C5, - 0xB8C9, 0xB8E1, 0xB8E2, 0xB8E5, 0xB8E9, 0xB8EB, 0xB8F1, 0xB8F3, - 0xB8F5, 0xB8F7, 0xB8F8, 0xB941, 0xB942, 0xB945, 0xB949, 0xB951, - 0xB953, 0xB955, 0xB957, 0xB961, 0xB965, 0xB969, 0xB971, 0xB973, - 0xB976, 0xB977, 0xB981, 0xB9A1, 0xB9A2, 0xB9A5, 0xB9A9, 0xB9AB, - 0xB9B1, 0xB9B3, 0xB9B5, 0xB9B7, 0xB9B8, 0xB9B9, 0xB9BD, 0xB9C1, - 0xB9C2, 0xB9C9, 0xB9D3, 0xB9D5, 0xB9D7, 0xB9E1, 0xB9F6, 0xB9F7, - 0xBA41, 0xBA45, 0xBA49, 0xBA51, 0xBA53, 0xBA55, 0xBA57, 0xBA61, - 0xBA62, 0xBA65, 0xBA77, 0xBA81, 0xBA82, 0xBA85, 0xBA89, 0xBA8A, - 0xBA8B, 0xBA91, 0xBA93, 0xBA95, 0xBA97, 0xBAA1, 0xBAB6, 0xBAC1, - 0xBAE1, 0xBAE2, 0xBAE5, 0xBAE9, 0xBAF1, 0xBAF3, 0xBAF5, 0xBB41, - 0xBB45, 0xBB49, 0xBB51, 0xBB61, 0xBB62, 0xBB65, 0xBB69, 0xBB71, - 0xBB73, 0xBB75, 0xBB77, 0xBBA1, 0xBBA2, 0xBBA5, 0xBBA8, 0xBBA9, - 0xBBAB, 0xBBB1, 0xBBB3, 0xBBB5, 0xBBB7, 0xBBB8, 0xBBBB, 0xBBBC, - 0xBC61, 0xBC62, 0xBC65, 0xBC67, 0xBC69, 0xBC6C, 0xBC71, 0xBC73, - 0xBC75, 0xBC76, 0xBC77, 0xBC81, 0xBC82, 0xBC85, 0xBC89, 0xBC91, - 0xBC93, 0xBC95, 0xBC96, 0xBC97, 0xBCA1, 0xBCA5, 0xBCB7, 0xBCE1, - 0xBCE2, 0xBCE5, 0xBCE9, 0xBCF1, 0xBCF3, 0xBCF5, 0xBCF6, 0xBCF7, - 0xBD41, 0xBD57, 0xBD61, 0xBD76, 0xBDA1, 0xBDA2, 0xBDA5, 0xBDA9, - 0xBDB1, 0xBDB3, 0xBDB5, 0xBDB7, 0xBDB9, 0xBDC1, 0xBDC2, 0xBDC9, - 0xBDD6, 0xBDE1, 0xBDF6, 0xBE41, 0xBE45, 0xBE49, 0xBE51, 0xBE53, - 0xBE77, 0xBE81, 0xBE82, 0xBE85, 0xBE89, 0xBE91, 0xBE93, 0xBE97, - 0xBEA1, 0xBEB6, 0xBEB7, 0xBEE1, 0xBF41, 0xBF61, 0xBF71, 0xBF75, - 0xBF77, 0xBFA1, 0xBFA2, 0xBFA5, 0xBFA9, 0xBFB1, 0xBFB3, 0xBFB7, - 0xBFB8, 0xBFBD, 0xC061, 0xC062, 0xC065, 0xC067, 0xC069, 0xC071, - 0xC073, 0xC075, 0xC076, 0xC077, 0xC078, 0xC081, 0xC082, 0xC085, - 0xC089, 0xC091, 0xC093, 0xC095, 0xC096, 0xC097, 0xC0A1, 0xC0A5, - 0xC0A7, 0xC0A9, 0xC0B1, 0xC0B7, 0xC0E1, 0xC0E2, 0xC0E5, 0xC0E9, - 0xC0F1, 0xC0F3, 0xC0F5, 0xC0F6, 0xC0F7, 0xC141, 0xC142, 0xC145, - 0xC149, 0xC151, 0xC153, 0xC155, 0xC157, 0xC161, 0xC165, 0xC176, - 0xC181, 0xC185, 0xC197, 0xC1A1, 0xC1A2, 0xC1A5, 0xC1A9, 0xC1B1, - 0xC1B3, 0xC1B5, 0xC1B7, 0xC1C1, 0xC1C5, 0xC1C9, 0xC1D7, 0xC241, - 0xC245, 0xC249, 0xC251, 0xC253, 0xC255, 0xC257, 0xC261, 0xC271, - 0xC281, 0xC282, 0xC285, 0xC289, 0xC291, 0xC293, 0xC295, 0xC297, - 0xC2A1, 0xC2B6, 0xC2C1, 0xC2C5, 0xC2E1, 0xC2E5, 0xC2E9, 0xC2F1, - 0xC2F3, 0xC2F5, 0xC2F7, 0xC341, 0xC345, 0xC349, 0xC351, 0xC357, - 0xC361, 0xC362, 0xC365, 0xC369, 0xC371, 0xC373, 0xC375, 0xC377, - 0xC3A1, 0xC3A2, 0xC3A5, 0xC3A8, 0xC3A9, 0xC3AA, 0xC3B1, 0xC3B3, - 0xC3B5, 0xC3B7, 0xC461, 0xC462, 0xC465, 0xC469, 0xC471, 0xC473, - 0xC475, 0xC477, 0xC481, 0xC482, 0xC485, 0xC489, 0xC491, 0xC493, - 0xC495, 0xC496, 0xC497, 0xC4A1, 0xC4A2, 0xC4B7, 0xC4E1, 0xC4E2, - 0xC4E5, 0xC4E8, 0xC4E9, 0xC4F1, 0xC4F3, 0xC4F5, 0xC4F6, 0xC4F7, - 0xC541, 0xC542, 0xC545, 0xC549, 0xC551, 0xC553, 0xC555, 0xC557, - 0xC561, 0xC565, 0xC569, 0xC571, 0xC573, 0xC575, 0xC576, 0xC577, - 0xC581, 0xC5A1, 0xC5A2, 0xC5A5, 0xC5A9, 0xC5B1, 0xC5B3, 0xC5B5, - 0xC5B7, 0xC5C1, 0xC5C2, 0xC5C5, 0xC5C9, 0xC5D1, 0xC5D7, 0xC5E1, - 0xC5F7, 0xC641, 0xC649, 0xC661, 0xC681, 0xC682, 0xC685, 0xC689, - 0xC691, 0xC693, 0xC695, 0xC697, 0xC6A1, 0xC6A5, 0xC6A9, 0xC6B7, - 0xC6C1, 0xC6D7, 0xC6E1, 0xC6E2, 0xC6E5, 0xC6E9, 0xC6F1, 0xC6F3, - 0xC6F5, 0xC6F7, 0xC741, 0xC745, 0xC749, 0xC751, 0xC761, 0xC762, - 0xC765, 0xC769, 0xC771, 0xC773, 0xC777, 0xC7A1, 0xC7A2, 0xC7A5, - 0xC7A9, 0xC7B1, 0xC7B3, 0xC7B5, 0xC7B7, 0xC861, 0xC862, 0xC865, - 0xC869, 0xC86A, 0xC871, 0xC873, 0xC875, 0xC876, 0xC877, 0xC881, - 0xC882, 0xC885, 0xC889, 0xC891, 0xC893, 0xC895, 0xC896, 0xC897, - 0xC8A1, 0xC8B7, 0xC8E1, 0xC8E2, 0xC8E5, 0xC8E9, 0xC8EB, 0xC8F1, - 0xC8F3, 0xC8F5, 0xC8F6, 0xC8F7, 0xC941, 0xC942, 0xC945, 0xC949, - 0xC951, 0xC953, 0xC955, 0xC957, 0xC961, 0xC965, 0xC976, 0xC981, - 0xC985, 0xC9A1, 0xC9A2, 0xC9A5, 0xC9A9, 0xC9B1, 0xC9B3, 0xC9B5, - 0xC9B7, 0xC9BC, 0xC9C1, 0xC9C5, 0xC9E1, 0xCA41, 0xCA45, 0xCA55, - 0xCA57, 0xCA61, 0xCA81, 0xCA82, 0xCA85, 0xCA89, 0xCA91, 0xCA93, - 0xCA95, 0xCA97, 0xCAA1, 0xCAB6, 0xCAC1, 0xCAE1, 0xCAE2, 0xCAE5, - 0xCAE9, 0xCAF1, 0xCAF3, 0xCAF7, 0xCB41, 0xCB45, 0xCB49, 0xCB51, - 0xCB57, 0xCB61, 0xCB62, 0xCB65, 0xCB68, 0xCB69, 0xCB6B, 0xCB71, - 0xCB73, 0xCB75, 0xCB81, 0xCB85, 0xCB89, 0xCB91, 0xCB93, 0xCBA1, - 0xCBA2, 0xCBA5, 0xCBA9, 0xCBB1, 0xCBB3, 0xCBB5, 0xCBB7, 0xCC61, - 0xCC62, 0xCC63, 0xCC65, 0xCC69, 0xCC6B, 0xCC71, 0xCC73, 0xCC75, - 0xCC76, 0xCC77, 0xCC7B, 0xCC81, 0xCC82, 0xCC85, 0xCC89, 0xCC91, - 0xCC93, 0xCC95, 0xCC96, 0xCC97, 0xCCA1, 0xCCA2, 0xCCE1, 0xCCE2, - 0xCCE5, 0xCCE9, 0xCCF1, 0xCCF3, 0xCCF5, 0xCCF6, 0xCCF7, 0xCD41, - 0xCD42, 0xCD45, 0xCD49, 0xCD51, 0xCD53, 0xCD55, 0xCD57, 0xCD61, - 0xCD65, 0xCD69, 0xCD71, 0xCD73, 0xCD76, 0xCD77, 0xCD81, 0xCD89, - 0xCD93, 0xCD95, 0xCDA1, 0xCDA2, 0xCDA5, 0xCDA9, 0xCDB1, 0xCDB3, - 0xCDB5, 0xCDB7, 0xCDC1, 0xCDD7, 0xCE41, 0xCE45, 0xCE61, 0xCE65, - 0xCE69, 0xCE73, 0xCE75, 0xCE81, 0xCE82, 0xCE85, 0xCE88, 0xCE89, - 0xCE8B, 0xCE91, 0xCE93, 0xCE95, 0xCE97, 0xCEA1, 0xCEB7, 0xCEE1, - 0xCEE5, 0xCEE9, 0xCEF1, 0xCEF5, 0xCF41, 0xCF45, 0xCF49, 0xCF51, - 0xCF55, 0xCF57, 0xCF61, 0xCF65, 0xCF69, 0xCF71, 0xCF73, 0xCF75, - 0xCFA1, 0xCFA2, 0xCFA5, 0xCFA9, 0xCFB1, 0xCFB3, 0xCFB5, 0xCFB7, - 0xD061, 0xD062, 0xD065, 0xD069, 0xD06E, 0xD071, 0xD073, 0xD075, - 0xD077, 0xD081, 0xD082, 0xD085, 0xD089, 0xD091, 0xD093, 0xD095, - 0xD096, 0xD097, 0xD0A1, 0xD0B7, 0xD0E1, 0xD0E2, 0xD0E5, 0xD0E9, - 0xD0EB, 0xD0F1, 0xD0F3, 0xD0F5, 0xD0F7, 0xD141, 0xD142, 0xD145, - 0xD149, 0xD151, 0xD153, 0xD155, 0xD157, 0xD161, 0xD162, 0xD165, - 0xD169, 0xD171, 0xD173, 0xD175, 0xD176, 0xD177, 0xD181, 0xD185, - 0xD189, 0xD193, 0xD1A1, 0xD1A2, 0xD1A5, 0xD1A9, 0xD1AE, 0xD1B1, - 0xD1B3, 0xD1B5, 0xD1B7, 0xD1BB, 0xD1C1, 0xD1C2, 0xD1C5, 0xD1C9, - 0xD1D5, 0xD1D7, 0xD1E1, 0xD1E2, 0xD1E5, 0xD1F5, 0xD1F7, 0xD241, - 0xD242, 0xD245, 0xD249, 0xD253, 0xD255, 0xD257, 0xD261, 0xD265, - 0xD269, 0xD273, 0xD275, 0xD281, 0xD282, 0xD285, 0xD289, 0xD28E, - 0xD291, 0xD295, 0xD297, 0xD2A1, 0xD2A5, 0xD2A9, 0xD2B1, 0xD2B7, - 0xD2C1, 0xD2C2, 0xD2C5, 0xD2C9, 0xD2D7, 0xD2E1, 0xD2E2, 0xD2E5, - 0xD2E9, 0xD2F1, 0xD2F3, 0xD2F5, 0xD2F7, 0xD341, 0xD342, 0xD345, - 0xD349, 0xD351, 0xD355, 0xD357, 0xD361, 0xD362, 0xD365, 0xD367, - 0xD368, 0xD369, 0xD36A, 0xD371, 0xD373, 0xD375, 0xD377, 0xD37B, - 0xD381, 0xD385, 0xD389, 0xD391, 0xD393, 0xD397, 0xD3A1, 0xD3A2, - 0xD3A5, 0xD3A9, 0xD3B1, 0xD3B3, 0xD3B5, 0xD3B7 -}; - -/** - * ks symbols - */ -static unsigned tblhhtg_ks[] = -{ - 0xC7D1, 0xB1DB, 0xB0FA, 0xC4C4, 0xC7BB, 0xC5CD, noneks, noneks, - 0xA2B1, 0xA3DF, 0xA2D5, 0xA6B1, 0xA1B8, 0xA1B9, 0xA3DF, 0xA1DA, - 0xA2C6, 0xA2CC, 0xA2CB, noneks, noneks, 0xA6BE, 0xA6B9, 0xA6C1, - 0xA6C2, 0xA6B4, 0xA6AD, 0xA6AF, 0xA6B0, 0xA6C3, 0xA6C4, noneks, - 0xA6AE, 0xA6B0, 0xA2D7, 0xA1E1, 0xA1D6, noneks, 0xA6BC, 0xA6B7, - 0xA6B1, 0xA6AE, 0xA6B5, 0xA6B3, 0xA6B2, 0xA6AC, 0xA6B6, 0xA6BA, - 0xA6BF, 0xA6B8, 0xA6BD, 0xA6C5, 0xA6C6, 0xA6C8, 0xA6C7, 0xA6C0, - 0xA6BB, noneks, noneks, noneks, 0xA1E1, 0xA1E1, 0xA1E1, 0xA1E1 -}; - -/** - * kssm symbols - */ -static unsigned hhtg_tg[] = -{ - 0xD065, 0x8B69, 0x89C1, 0xC4F1, 0xCF41, 0xC8E1, 0xD3C5, 0xD931, - 0xD931, 0xD481, 0xD482, 0xD488, 0xD48A, 0xD48F, 0xD493, 0xD494, - 0xD4B0, 0xD4B1, 0xD4B2, 0xD931, 0xD931, 0xD4B5, 0xD4B6, 0xD4B7, - 0xD4B8, 0xD4B9, 0xD4BA, 0xD4BB, 0xD4BC, 0xD4BD, 0xD4BE, 0xD496, - 0xD497, 0xD49C, 0xD4A9, 0xD4AF, 0xD4F4, 0xD4F5, 0xD4C6, 0xD4C7, - 0xD4C8, 0xD4C9, 0xD4CA, 0xD4CB, 0xD4CC, 0xD4CD, 0xD4CE, 0xD4CF, - 0xD4D0, 0xD4D1, 0xD4D2, 0xD4D3, 0xD4D4, 0xD4D5, 0xD4D6, 0xD4D7, - 0xD4D8, 0xD4F7, 0xD4FA, 0xD4FE, 0xD4DC, 0xD4DD, 0xD4DE, 0xD4DF -}; - -#define LINEBASE 0x3013 - -// ? -static char LineCharDir(hchar ch) -{ - static char index2dir[] = { 10, 11, 9, 14, 15, 13, 6, 7, 5, 3, 12 }; - - return (LINEBASE <= ch && ch < LINEBASE + 11 * 7) ? - index2dir[(ch - LINEBASE) % 11] : 0; -} - - -/** - * Convert hwp's special character to ks - */ -static hchar s_hh2ks(hchar hh) -{ - hchar i, idx = hh >> 8; - - if (hh == 0x81 || hh == 0x82) - return '\"'; - else if (hh == 0x83 || hh == 0x84) - return '\''; - if (idx == 0x1F) - { - idx = 170; - i = hh & 0xff; - if (i >= 0x60) - { - idx++; - i -= 0x60; - } - return (idx << 8) | (i + 160); - } - if ((idx == 0x1F && (hh & 0xff) >= 0xC0) || (hh == 0x1F00)) - return 0; - if (idx < 0x34 || idx >= 0x38) - return 0x2020; - if (hh >= HCA_TG) - { - return sal::static_int_cast((tblhhtg_ks[hh - HCA_TG])); - } - hh -= HCA_KSS; - idx = hh / 0x60 + 161; - i = hh % 0x60 + 160; - if (idx == 170) - idx += 2; - return (idx << 8) | i; -} - - -/** - * Convert hwp's special character to kssm - */ -static hchar s_hh2kssm(hchar hh) -{ - hchar i, idx = hh >> 8; - - if ((idx < 0x34 || idx >= 0x38) && idx != 0x1F) - return 0; - if (hh >= HCA_TG) - return sal::static_int_cast((hhtg_tg[hh - HCA_TG])); - if (idx == 0x1F) - hh = hh - 0x1F00 + 0x360; - else - { - hh -= HCA_KSS; - if (hh >= 0x360) - hh += 0xC0; - } - idx = hh / 0xC0 + 217; - i = hh % 0xC0; - if (i >= 95) - i -= 2; - i += 48; - if (i >= 127) - i += 18; - return (idx << 8) | i; -} - - -static hchar lineCharConv(hchar ch) -{ - int flag; - - switch (ch) - { - case 0x3060 + '\'' - 31: - case 0x3060 + '\"' - 31: - ch--; - - case 0x3060 + '\'' - 32: - case 0x3060 + '\"' - 32: - case 0x3060 + '{' - 32: - case 0x3060 + '[' - 32: - case 0x3060 + ']' - 32: - case 0x3060 + '}' - 32: - return ch - (0x3060 - 32); - } - flag = LineCharDir(ch); - switch (flag) - { - case 3: - return '-'; - case 12: - return '|'; - default: - return '+'; - } -} - - -static int KsSearch(hchar c) -{ - int lo, hi, mid; - hchar c2; - - lo = mid = 0; - hi = 2350 - 1; - - while (lo <= hi) - { - mid = (lo + hi) >> 1; - c2 = ksTbl[mid]; - if (c == c2) - break; - if (c < c2) - hi = mid - 1; - else - lo = mid + 1; - } - return mid; -} - - -static hchar cdkssm2ks_han(hchar kssm) -{ - unsigned int index; - unsigned char lo, hi; - -/* "" */ - if (kssm == 0xd3c5) - return 0xc7d1; - - index = KsSearch(kssm); - if (kssm != ksTbl[index]) - return jaso2ks(kssm); - hi = sal::static_int_cast(index / (0xFE - 0xA1 + 1) + 0xB0); - lo = sal::static_int_cast(index % (0xFE - 0xA1 + 1) + 0xA1); - return lo | (hi << 8); -} - - -#define IsHangul(c) ((c) & 0x8000) -#define IsHanja(c) (((c) & 0x4000)==0x4000) -#define IsJapan(c) (((c) > 0x1f00 && (c) < 0x1fb7)) - -static const hchar jaso_hh_code[] = -{ - 34881, 35905, 33860, 36929, 33862, 33863, 37953, 38977, 40001, 33866, - 33867, - 33868, 33869, 33870, 33871, 33872, 41025, 42049, 43073, 33876, 44097, - 45121, - 46145, 47169, 48193, 49217, 50241, 51265, 52289, 53313, 33889, 33921, - 33953, - 33985, 34017, 34113, 34145, 34177, 34209, 34241, 34273, 34369, 34401, - 34433, - 34465, 34497, 34529, 34625, 34657, 34689, 34721 -}; - -/* os: unused -static int is_jaso(hchar hh) -{ - unsigned int i; - - for (i = 0; i < SAL_N_ELEMENTS(jaso_hh_code); i++) - if (hh == jaso_hh_code[i]) - return 1; - return 0; -}*/ - - -static hchar jaso2ks(hchar hh) -{ - unsigned int i; - - for (i = 0; i < SAL_N_ELEMENTS(jaso_hh_code); i++) - if (hh == jaso_hh_code[i]) - { - return sal::static_int_cast(0xa4a1 + i); - } - return 0; -} - - -//1 00011 00 001 00011 -static hchar choseong_to_unicode[] = -{ - 0x111e, 0, 0x1100, 0x1101, 0x1102, 0x1103, 0x1104, 0x1105, - 0x1106, 0x1107, 0x1108, 0x1109, 0x110a, 0x110b, 0x110c, 0x110d, - 0x110e, 0x110f, 0x1110, 0x1111, 0x1112, 0x1120, 0x1121, 0x1127, - 0x112b, 0x112d, 0x112f, 0x1132, 0x1136, 0x1140, 0x114c, 0x1158 -}; -/* ߼ 0 1 ٸ ڵ  ִ. ̺κп Ģ ̾ƶ. */ -static hchar joongseong_to_unicode[] = -{ - 0, 0, 0, 0x1161, 0x1162, 0x1163, 0x1164, 0x1165, - 0, 0, 0x1166, 0x1167, 0x1168, 0x1169, 0x116a, 0x116b, - 0, 0x1188, 0x116c, 0x116d, 0x116e, 0x116f, 0x1170, 0x1171, - 0x1191, 0x1194, 0x1172, 0x1173, 0x1174, 0x1175, 0x119e, 0x11a1 -}; - -static hchar jongseong_to_unicode[] = -{ - 0x11d9, 0 , 0x11a8, 0x11a9, 0x11aa, 0x11ab, 0x11ac, 0x11ad, - 0x11ae, 0x11af, 0x11b0, 0x11b1, 0x11b2, 0x11b3, 0x11b4, 0x11b5, - 0x11b6, 0x11b7, 0x11e6, 0x11b8, 0x11b9, 0x11ba, 0x11bb, 0x11bc, - 0x11bd, 0x11be, 0x11bf, 0x11c0, 0x11c1, 0x11c2, 0x11eb, 0x11f0 -}; - -/* ߼ 0 1ΰ */ -/* ó 32 ڸ, 32 . - * 0x8000 ~ 0xa413 32 , 0x0400 0x8400 ٽ 32 ȴ. - * ڸ𿵿 Ϲ ̺ ü ̺ . - */ -/* 308.. 1152 308 844 ڸ̴. */ -static hchar jamo_to_unicode[] = -{ - 0x3131, 0x3132, 0x3133, 0x3134, 0x3135, 0x3136, 0x3137, 0x3138, - 0x3139, 0x313a, 0x313b, 0x313c, 0x313d, 0x313e, 0x313f, 0x3140, - 0x3141, 0x3142, 0x3143, 0x3144, 0x3145, 0x3146, 0x3147, 0x3148, - 0x3149, 0x314a, 0x314b, 0x314c, 0x314d, 0x314e, 0x3172, 0x3173, - - 0x3176, 0x317a, 0x317c, 0x317d, 0x317e, 0x3185, 0x3178, 0x317f, - 0x3181, 0x316d, 0x11c3, 0x11c4, 0x1113, 0x1114, 0x1115, 0x1116, - 0x11c7, 0x11c8, 0x11c9, 0x11ca, 0x11cb, 0x11cc, 0x11cd, 0x11ce, - 0x11cf, 0x11d0, 0x11d1, 0x11d2, 0x11d3, 0x11d4, 0x11d5, 0x11d6, - - 0x11d7, 0x11d8, 0x111b, 0x11da, 0x11db, 0x11dc, 0x11dd, 0x11de, - 0x11df, 0x11e0, 0x11e1, 0x11e2, 0x111f, 0x11e3, 0x1122, 0x1123, - 0x1124, 0x1125, 0x1126, 0x1128, 0x1129, 0x112a, 0x11e5, 0x112c, - 0x112e, 0x1130, 0x1131, 0x1133, 0x1134, 0x1135, 0x1137, 0x1138, - - 0x1139, 0x113a, 0x113b, 0x113c, 0x113d, 0x113e, 0x113f, 0x1141, - 0x11ed, 0x1142, 0x1143, 0x1144, 0x1145, 0x1146, 0x1147, 0x1148, - 0x1149, 0x11ef, 0x114a, 0x114b, 0x11f1, 0x11f2, 0x114d, 0x114e, - 0x114f, 0x1150, 0x1151, 0x1152, 0x1153, 0x1154, 0x1155, 0x1156, - - 0x1157, 0x11f5, 0x11f6, 0x11f7, 0x11f8, 0x11f9, 0x1176, 0x1177, - 0x1178, 0x1179, 0x117a, 0x117b, 0x117c, 0x117d, 0x117e, 0x117f, - 0x1180, 0x1181, 0x1182, 0x1183, 0x1184, 0x1185, 0x1186, 0x1187, - 0x1189, 0x118a, 0x118b, 0x118c, 0x118d, 0x118e, 0x118f, 0x1190, - - 0x1192, 0x1193, 0x1195, 0x1196, 0x1197, 0x1198, 0x1199, 0x119a, - 0x119b, 0x119c, 0x119d, 0x119f, 0x11a0, 0x11a2, 0x11a8, 0x11a9, - 0x11aa, 0x11ab, 0x11ac, 0x11ad, 0x11ae, 0x1104, 0x11af, 0x11b0, - 0x11b1, 0x11b2, 0x11b3, 0x11b4, 0x11b5, 0x11b6, 0x11b7, 0x11b8, - - 0x1108, 0x11b9, 0x11ba, 0x11bb, 0x11bc, 0x11bd, 0x3149, 0x11be, - 0x11bf, 0x11c0, 0x11c1, 0x11c2, 0x111e, 0x1120, 0x1127, 0x11e7, - 0x11e8, 0x11ea, 0x1136, 0x1158, 0x11e6, 0x11eb, 0x11f0, 0x11d9, - 0x11c3, 0x11c4, 0x11c5, 0x1114, 0x11c6, 0x1116, 0x11c7, 0x11c8, - - 0x11c9, 0x11ca, 0x11cb, 0x3169, 0x11cd, 0x11ce, 0x11cf, 0x1119, - 0x11d1, 0x11d2, 0x11d3, 0x11d4, 0x11d5, 0x11d6, 0x11d7, 0x11d8, - 0x111b, 0x11da, 0x11db, 0x11dc, 0x11dd, 0x11de, 0x11df, 0x11e0, - 0x11e1, 0x11e2, 0x111f, 0x11e3, 0x1122, 0x1123, 0x1124, 0x1125, - - 0x1126, 0x1128, 0x1129, 0x11e4, 0x11e5, 0x112c, 0x112e, 0x1130, - 0x1131, 0x1133, 0x1134, 0x1135, 0x1137, 0x1138, 0x1139, 0x113a, - 0x113b, 0x113c, 0x113d, 0x113e, 0x113f, 0x11ec, 0x11ed, 0x1142, - 0x1143, 0x1144, 0x1145, 0x1146, 0x1147, 0x1148, 0x1149, 0x11ef, - - 0x114a, 0x114b, 0x11f1, 0x11f2, 0x114d, 0x114e, 0x114f, 0x1150, - 0x1151, 0x1152, 0x1153, 0x1154, 0x1155, 0x1156, 0x1157, 0x11f5, - 0x11f6, 0x11f7, 0x11f8, 0x11f9 -}; - -struct JamoComp{ - int size; - hchar v1; - hchar v2; - hchar v3; -}; -/* 704 + 12 = 706 */ -static JamoComp jamocomp1_to_unicode[] = -{ - {3, 0x1100, 0x1161, 0x11e7}, {3, 0x1100, 0x1161, 0x3167}, - {3, 0x1100, 0x1161, 0x11dd}, {3, 0x1100, 0x1161, 0x11e2}, - {3, 0x1100, 0x1161, 0x11e5}, {3, 0x1100, 0x1161, 0x11f1}, - {3, 0x1100, 0x1163, 0x11e2}, {3, 0x1100, 0x1163, 0x11f9}, - {3, 0x1100, 0x1165, 0x11e7}, {3, 0x1100, 0x1165, 0x11c7}, - {3, 0x1100, 0x1165, 0x11dd}, {3, 0x1100, 0x1165, 0x11e2}, - - {3, 0x1100, 0x1165, 0x11e3}, {3, 0x1100, 0x1167, 0x11e7}, - {3, 0x1100, 0x1167, 0x11f1}, {3, 0x1100, 0x1167, 0x11f9}, - {3, 0x1100, 0x1169, 0x11d6}, {3, 0x1100, 0x1169, 0x11dd}, - {3, 0x1100, 0x1169, 0x11e2}, {3, 0x1100, 0x1169, 0x11f1}, - {3, 0x1100, 0x1169, 0x11f7}, {3, 0x1100, 0x1169, 0x11f8}, - {3, 0x1100, 0x116a, 0x11f9}, {3, 0x1100, 0x116d, 0x11e2}, - {3, 0x1100, 0x116e, 0x11c7}, {3, 0x1100, 0x116e, 0x11cd}, - {3, 0x1100, 0x116e, 0x11da}, {3, 0x1100, 0x116e, 0x11dd}, - - {3, 0x1100, 0x116e, 0x11e2}, {3, 0x1100, 0x116e, 0x11f6}, - {3, 0x1100, 0x116e, 0x11f9}, {3, 0x1100, 0x116f, 0x11c7}, - {3, 0x1100, 0x116f, 0x11f9}, {3, 0x1100, 0x1172, 0x11e2}, - {3, 0x1100, 0x1172, 0x11f9}, {3, 0x1100, 0x1173, 0x11c7}, - {3, 0x1100, 0x1173, 0x11dd}, {3, 0x1100, 0x1173, 0x11df}, - {3, 0x1100, 0x1173, 0x11e2}, {3, 0x1100, 0x1173, 0x11f9}, - {3, 0x1100, 0x1174, 0x11f9}, {3, 0x1100, 0x1175, 0x11e7}, - {3, 0x1100, 0x1175, 0x11cd}, {3, 0x1100, 0x1175, 0x11e2}, - - {3, 0x1100, 0x1175, 0x11f9}, {3, 0x1100, 0x1191, 0x11f9}, - {3, 0x1100, 0x119e, 0x11e7}, {3, 0x1100, 0x119e, 0x11d3}, - {3, 0x1100, 0x119e, 0x11d5}, {3, 0x1100, 0x119e, 0x11e3}, - {3, 0x1100, 0x11a1, 0x11f1}, {2, 0x1100, 0x1176, 0x0000}, - {2, 0x1100, 0x1178, 0x0000}, {2, 0x1100, 0x117c, 0x0000}, - {3, 0x1100, 0x117c, 0x11ab}, {3, 0x1100, 0x117c, 0x11af}, - {3, 0x1100, 0x117c, 0x11b7}, {2, 0x1100, 0x1189, 0x0000}, - {3, 0x1100, 0x1189, 0x11ab}, {3, 0x1100, 0x1189, 0x11bc}, - - {2, 0x1100, 0x118b, 0x0000}, {3, 0x1100, 0x118b, 0x11ab}, - {2, 0x1100, 0x118c, 0x0000}, {2, 0x1100, 0x118d, 0x0000}, - {2, 0x1100, 0x1192, 0x0000}, {3, 0x1100, 0x1192, 0x11bc}, - {2, 0x1100, 0x1195, 0x0000}, {2, 0x1100, 0x1196, 0x0000}, - {2, 0x1100, 0x1198, 0x0000}, {2, 0x1100, 0x119b, 0x0000}, - {2, 0x1100, 0x119c, 0x0000}, {2, 0x1100, 0x119d, 0x0000}, - {2, 0x1100, 0x119f, 0x0000}, {3, 0x1100, 0x119f, 0x11bc}, - {3, 0x1101, 0x1163, 0x11e2}, {3, 0x1101, 0x1165, 0x11ec}, - - {3, 0x1101, 0x1165, 0x11ed}, {3, 0x1101, 0x116e, 0x11e2}, - {3, 0x1101, 0x1172, 0x11e2}, {3, 0x1101, 0x1175, 0x11e2}, - {3, 0x1101, 0x1175, 0x11f9}, {3, 0x1101, 0x1191, 0x11bc}, - {2, 0x1101, 0x1176, 0x0000}, {2, 0x1101, 0x117b, 0x0000}, - {2, 0x1101, 0x1189, 0x0000}, {2, 0x1101, 0x118c, 0x0000}, - {2, 0x1101, 0x1198, 0x0000}, {3, 0x1102, 0x1161, 0x11e7}, - {3, 0x1102, 0x1161, 0x11c4}, {3, 0x1102, 0x1161, 0x11da}, - {3, 0x1102, 0x1161, 0x11dd}, {3, 0x1102, 0x1161, 0x11e2}, - - {3, 0x1102, 0x1161, 0x11f9}, {3, 0x1102, 0x1165, 0x11db}, - {3, 0x1102, 0x1165, 0x11dd}, {3, 0x1102, 0x1165, 0x11e3}, - {3, 0x1102, 0x1167, 0x11c5}, {3, 0x1102, 0x1167, 0x11c7}, - {3, 0x1102, 0x1167, 0x11f9}, {3, 0x1102, 0x1169, 0x11e2}, - {3, 0x1102, 0x1169, 0x11e4}, {3, 0x1102, 0x1169, 0x11f3}, - {3, 0x1102, 0x116e, 0x11c6}, {3, 0x1102, 0x116e, 0x11c7}, - {3, 0x1102, 0x116e, 0x11c8}, {3, 0x1102, 0x116e, 0x11dd}, - {3, 0x1102, 0x116e, 0x11e2}, {3, 0x1102, 0x116e, 0x11f5}, - - {3, 0x1102, 0x1172, 0x11e2}, {3, 0x1102, 0x1173, 0x11c3}, - {3, 0x1102, 0x1175, 0x11c3}, {3, 0x1102, 0x1175, 0x11dd}, - {3, 0x1102, 0x1175, 0x11e2}, {3, 0x1102, 0x119e, 0x11d7}, - {2, 0x1102, 0x1176, 0x0000}, {2, 0x1102, 0x117c, 0x0000}, - {3, 0x1102, 0x117c, 0x11a8}, {2, 0x1102, 0x118c, 0x0000}, - {2, 0x1102, 0x1196, 0x0000}, {2, 0x1102, 0x1197, 0x0000}, - {2, 0x1102, 0x1198, 0x0000}, {2, 0x1102, 0x119b, 0x0000}, - {3, 0x1103, 0x1161, 0x11e7}, {3, 0x1103, 0x1161, 0x11c7}, - - {3, 0x1103, 0x1161, 0x1119}, {3, 0x1103, 0x1161, 0x11db}, - {3, 0x1103, 0x1161, 0x11dd}, {3, 0x1103, 0x1161, 0x11e2}, - {3, 0x1103, 0x1161, 0x11f1}, {3, 0x1103, 0x1161, 0x11f9}, - {3, 0x1103, 0x1163, 0x11e2}, {3, 0x1103, 0x1163, 0x11f1}, - {3, 0x1103, 0x1165, 0x11dd}, {3, 0x1103, 0x1167, 0x11f9}, - {3, 0x1103, 0x1169, 0x11e7}, {3, 0x1103, 0x1169, 0x11d6}, - {3, 0x1103, 0x1169, 0x11e2}, {3, 0x1103, 0x1169, 0x11f1}, - {3, 0x1103, 0x116d, 0x11e2}, {3, 0x1103, 0x116e, 0x11ce}, - - {3, 0x1103, 0x116e, 0x1119}, {3, 0x1103, 0x116e, 0x11da}, - {3, 0x1103, 0x116e, 0x11e2}, {3, 0x1103, 0x1172, 0x11e2}, - {3, 0x1103, 0x1173, 0x11cd}, {3, 0x1103, 0x1173, 0x11ce}, - {3, 0x1103, 0x1173, 0x11e2}, {3, 0x1103, 0x1173, 0x11e3}, - {3, 0x1103, 0x1173, 0x11f1}, {3, 0x1103, 0x1174, 0x11f9}, - {3, 0x1103, 0x1175, 0x11f9}, {3, 0x1103, 0x119e, 0x11e7}, - {3, 0x1103, 0x119e, 0x11e8}, {3, 0x1103, 0x119e, 0x11ea}, - {3, 0x1103, 0x119e, 0x11c3}, {3, 0x1103, 0x119e, 0x11cc}, - - {3, 0x1103, 0x119e, 0x11e3}, {3, 0x1103, 0x119e, 0x11e9}, - {2, 0x1103, 0x1176, 0x0000}, {2, 0x1103, 0x1178, 0x0000}, - {2, 0x1103, 0x117c, 0x0000}, {3, 0x1103, 0x117c, 0x11b7}, - {2, 0x1103, 0x1189, 0x0000}, {3, 0x1103, 0x1189, 0x11ab}, - {2, 0x1103, 0x118c, 0x0000}, {2, 0x1103, 0x1195, 0x0000}, - {2, 0x1103, 0x1196, 0x0000}, {2, 0x1103, 0x1198, 0x0000}, - {2, 0x1103, 0x1199, 0x0000}, {3, 0x1103, 0x1199, 0x11ab}, - {3, 0x1103, 0x1199, 0x11bc}, {3, 0x1104, 0x1161, 0x11d8}, - - {3, 0x1104, 0x1161, 0x11e2}, {3, 0x1104, 0x1161, 0x11f9}, - {3, 0x1104, 0x1163, 0x11e2}, {3, 0x1104, 0x1169, 0x11e2}, - {3, 0x1104, 0x1169, 0x11f9}, {3, 0x1104, 0x116d, 0x11e2}, - {3, 0x1104, 0x116e, 0x11e2}, {3, 0x1104, 0x116e, 0x11f9}, - {3, 0x1104, 0x1172, 0x11e2}, {3, 0x1104, 0x1173, 0x11e2}, - {3, 0x1104, 0x1175, 0x11f9}, {2, 0x1104, 0x117b, 0x0000}, - {2, 0x1104, 0x118c, 0x0000}, {2, 0x1104, 0x1198, 0x0000}, - {3, 0x1105, 0x1161, 0x11e7}, {3, 0x1105, 0x1161, 0x11dd}, - - {3, 0x1105, 0x1161, 0x11e2}, {3, 0x1105, 0x1161, 0x11f5}, - {3, 0x1105, 0x1161, 0x11f9}, {3, 0x1105, 0x1163, 0x11e2}, - {3, 0x1105, 0x1167, 0x11c7}, {3, 0x1105, 0x1167, 0x11e2}, - {3, 0x1105, 0x1167, 0x11f9}, {3, 0x1105, 0x1169, 0x11dd}, - {3, 0x1105, 0x1169, 0x11e2}, {3, 0x1105, 0x1169, 0x11f1}, - {3, 0x1105, 0x116d, 0x11dd}, {3, 0x1105, 0x116d, 0x11e2}, - {3, 0x1105, 0x116e, 0x11dd}, {3, 0x1105, 0x116e, 0x11e2}, - {3, 0x1105, 0x1172, 0x11e2}, {3, 0x1105, 0x1173, 0x11dd}, - - {3, 0x1105, 0x1173, 0x11e2}, {3, 0x1105, 0x1175, 0x11dd}, - {3, 0x1105, 0x1175, 0x11e2}, {3, 0x1105, 0x1175, 0x11f9}, - {3, 0x1105, 0x119e, 0x11d7}, {3, 0x1105, 0x119e, 0x11dc}, - {3, 0x1105, 0x119e, 0x11dd}, {2, 0x1105, 0x1176, 0x0000}, - -/* -- ȹٲ , 3 2 ٲپ ־ . */ - {2, 0x1105, 0x1178, 0x0000}, {2, 0x1105, 0x117a, 0x0000}, - {2, 0x1105, 0x117b, 0x0000}, {2, 0x1105, 0x1186, 0x0000}, - {2, 0x1105, 0x1187, 0x0000}, {2, 0x1105, 0x118c, 0x0000}, - {2, 0x1105, 0x1195, 0x0000}, {2, 0x1105, 0x1196, 0x0000}, - - {2, 0x1105, 0x1198, 0x0000}, {2, 0x1105, 0x1199, 0x0000}, - {3, 0x1105, 0x1199, 0x11bc}, {2, 0x1105, 0x119b, 0x0000}, - {2, 0x111a, 0x1163, 0x0000}, {3, 0x111a, 0x1163, 0x11bc}, - {3, 0x1106, 0x1161, 0x11e8}, {3, 0x1106, 0x1161, 0x11c7}, - {3, 0x1106, 0x1161, 0x11cd}, {3, 0x1106, 0x1161, 0x1119}, - {3, 0x1106, 0x1161, 0x11d8}, {3, 0x1106, 0x1161, 0x11e2}, - {3, 0x1106, 0x1163, 0x11e2}, {3, 0x1106, 0x1165, 0x11c6}, - {3, 0x1106, 0x1165, 0x11f9}, {3, 0x1106, 0x1169, 0x11c6}, - - {3, 0x1106, 0x1169, 0x11dd}, {3, 0x1106, 0x1169, 0x11e2}, - {3, 0x1106, 0x116d, 0x11e2}, {3, 0x1106, 0x116e, 0x11e7}, - {3, 0x1106, 0x116e, 0x11c7}, {3, 0x1106, 0x116e, 0x11e2}, - {3, 0x1106, 0x116e, 0x11ec}, {3, 0x1106, 0x116e, 0x11ed}, - {3, 0x1106, 0x116e, 0x11f9}, {3, 0x1106, 0x116f, 0x11f9}, - {3, 0x1106, 0x1173, 0x11e7}, {3, 0x1106, 0x1174, 0x11f9}, - {3, 0x1106, 0x1175, 0x11e7}, {3, 0x1106, 0x1175, 0x11f6}, - {3, 0x1106, 0x1175, 0x11f9}, {3, 0x1106, 0x119e, 0x11c3}, - - {2, 0x1106, 0x1176, 0x0000}, {2, 0x1106, 0x1178, 0x0000}, - {2, 0x1106, 0x117c, 0x0000}, {3, 0x1106, 0x117c, 0x11af}, - {2, 0x1106, 0x1182, 0x0000}, {2, 0x1106, 0x1183, 0x0000}, - {2, 0x1106, 0x118c, 0x0000}, {2, 0x1106, 0x1196, 0x0000}, - {3, 0x1106, 0x1196, 0x11b7}, {2, 0x1106, 0x1198, 0x0000}, - {2, 0x1106, 0x119f, 0x0000}, {3, 0x1106, 0x119f, 0x11ab}, - {3, 0x1106, 0x119f, 0x11bc}, {3, 0x1107, 0x1161, 0x11e7}, - {3, 0x1107, 0x1161, 0x11c9}, {3, 0x1107, 0x1161, 0x11dd}, - - {3, 0x1107, 0x1161, 0x11e2}, {3, 0x1107, 0x1161, 0x11e3}, - {3, 0x1107, 0x1161, 0x11f1}, {3, 0x1107, 0x1161, 0x11f6}, - {3, 0x1107, 0x1161, 0x11f9}, {3, 0x1107, 0x1165, 0x11c7}, - {3, 0x1107, 0x1167, 0x11f1}, {3, 0x1107, 0x1169, 0x11e7}, - {3, 0x1107, 0x1169, 0x11dd}, {3, 0x1107, 0x1169, 0x11e2}, - {3, 0x1107, 0x116d, 0x11e2}, {3, 0x1107, 0x116e, 0x11e7}, - {3, 0x1107, 0x116e, 0x11c7}, {3, 0x1107, 0x116e, 0x1119}, - {3, 0x1107, 0x116e, 0x11d1}, {3, 0x1107, 0x116e, 0x11d2}, - - {3, 0x1107, 0x116e, 0x11e2}, {3, 0x1107, 0x116e, 0x11ef}, - {3, 0x1107, 0x116e, 0x11f9}, {3, 0x1107, 0x116f, 0x11f9}, - {3, 0x1107, 0x1173, 0x11e7}, {3, 0x1107, 0x1173, 0x11c3}, - {3, 0x1107, 0x1175, 0x11e7}, {3, 0x1107, 0x1175, 0x11e2}, - {3, 0x1107, 0x1175, 0x11f1}, {3, 0x1107, 0x1175, 0x11f9}, - {3, 0x1107, 0x119e, 0x11c3}, {3, 0x1107, 0x119e, 0x11d5}, - {3, 0x1107, 0x119e, 0x11e3}, {3, 0x1107, 0x11a1, 0x11f1}, - {2, 0x1107, 0x1176, 0x0000}, {2, 0x1107, 0x1177, 0x0000}, - - {2, 0x1107, 0x1178, 0x0000}, {2, 0x1107, 0x117c, 0x0000}, - {3, 0x1107, 0x117c, 0x11a8}, {3, 0x1107, 0x117c, 0x11af}, - {3, 0x1107, 0x117c, 0x11b7}, {3, 0x1107, 0x117c, 0x11bc}, - {2, 0x1107, 0x1182, 0x0000}, {2, 0x1107, 0x118c, 0x0000}, - {2, 0x1107, 0x1196, 0x0000}, {2, 0x1107, 0x1198, 0x0000}, - {2, 0x1107, 0x119a, 0x0000}, {2, 0x1107, 0x119f, 0x0000}, - {3, 0x1107, 0x119f, 0x11ab}, {3, 0x1107, 0x119f, 0x11bc}, - {3, 0x1108, 0x1161, 0x11e2}, {3, 0x1108, 0x1167, 0x11f9}, - - {3, 0x1108, 0x1169, 0x11e2}, {3, 0x1108, 0x116e, 0x11e2}, - {3, 0x1108, 0x1174, 0x11f9}, {3, 0x1108, 0x1175, 0x11f9}, - {3, 0x1121, 0x116a, 0x11f9}, {3, 0x1121, 0x119e, 0x114d}, - {2, 0x1121, 0x118c, 0x0000}, {2, 0x1121, 0x1198, 0x0000}, - {3, 0x1109, 0x1161, 0x11ca}, {3, 0x1109, 0x1161, 0x11dd}, - {3, 0x1109, 0x1161, 0x11e2}, {3, 0x1109, 0x1161, 0x11f1}, - {3, 0x1109, 0x1161, 0x11f9}, {3, 0x1109, 0x1163, 0x11e2}, - {3, 0x1109, 0x1163, 0x11f1}, {3, 0x1109, 0x1165, 0x11e7}, - - {3, 0x1109, 0x1165, 0x11c3}, {3, 0x1109, 0x1165, 0x11ec}, - {3, 0x1109, 0x1165, 0x11ed}, {3, 0x1109, 0x1167, 0x11e7}, - {3, 0x1109, 0x1167, 0x11d5}, {3, 0x1109, 0x1167, 0x11dd}, - {3, 0x1109, 0x1167, 0x11e3}, {3, 0x1109, 0x1167, 0x11f1}, - {3, 0x1109, 0x1167, 0x11f9}, {3, 0x1109, 0x1169, 0x11c7}, - {3, 0x1109, 0x1169, 0x11e2}, {3, 0x1109, 0x116a, 0x11f9}, - {3, 0x1109, 0x116b, 0x11f9}, {3, 0x1109, 0x116d, 0x11e2}, - {3, 0x1109, 0x116d, 0x11f1}, {3, 0x1109, 0x116e, 0x11e7}, - - {3, 0x1109, 0x116e, 0x11e2}, {3, 0x1109, 0x116e, 0x11f9}, - {3, 0x1109, 0x1172, 0x11e2}, {3, 0x1109, 0x1173, 0x11e2}, - {3, 0x1109, 0x1173, 0x11e3}, {3, 0x1109, 0x1173, 0x11f1}, - {3, 0x1109, 0x1174, 0x11f9}, {3, 0x1109, 0x1175, 0x11c7}, - {3, 0x1109, 0x1175, 0x11ce}, {3, 0x1109, 0x1175, 0x11da}, - {3, 0x1109, 0x1175, 0x11e2}, {3, 0x1109, 0x1175, 0x11f9}, - {3, 0x1109, 0x1191, 0x11f9}, {3, 0x1109, 0x119e, 0x11ca}, - {3, 0x1109, 0x119e, 0x11d6}, {3, 0x1109, 0x119e, 0x11f1}, - - {3, 0x1109, 0x119e, 0x11e3}, {3, 0x1109, 0x11a1, 0x11dd}, - {3, 0x1109, 0x11a1, 0x11f1}, {2, 0x1109, 0x1176, 0x0000}, - {2, 0x1109, 0x1177, 0x0000}, {2, 0x1109, 0x1178, 0x0000}, - {2, 0x1109, 0x117c, 0x0000}, {3, 0x1109, 0x117c, 0x11a8}, - {3, 0x1109, 0x117c, 0x11af}, {3, 0x1109, 0x117c, 0x11b7}, - {3, 0x1109, 0x117c, 0x11bc}, {2, 0x1109, 0x117e, 0x0000}, - {2, 0x1109, 0x1189, 0x0000}, {3, 0x1109, 0x1189, 0x11ab}, - {2, 0x1109, 0x118c, 0x0000}, {2, 0x1109, 0x1190, 0x0000}, - - {2, 0x1109, 0x1192, 0x0000}, {3, 0x1109, 0x1192, 0x11bc} -}; - -//#define IS_OLD_HAN(x) (((x) >= 0x8020 && (x) <= 0x83ff ) || ( (x) >= 0x8420 && (x) <= 0x843f )) // beside these, there are very much characters in the hangul. -int hcharconv(hchar ch, hchar *dest, int codeType) -{ - unsigned char lo; - //printf("hcharconv[%04x]\n",ch); - if (ch < 128){ - dest[0] = ch; - return 1; - } - if (IsHangul(ch)) - { - hchar ch2 = ch; - if (codeType == KS) - ch = cdkssm2ks_han(ch); - else if( codeType == UNICODE ){ - if( ch2 == 0xd3c5 ){ - dest[0] = 0xd55c; - return 1 ; - } - int res = kssm_hangul_to_ucs2(ch, dest); - //printf("hcharconv Hangul[%04x]\n",dest[0]); - return res; - } - dest[0] = ch; - return 1; - } - /* ڴ 0x4000 4888 . */ - else if (IsHanja(ch)) - { - unsigned int index; - unsigned char hi; - /* 4888̿ Ʒѱۿ Ȯ̴. ̰Ϳ ؼ - ڵ峪 ϼڵ ȯ ̺ ̴. - */ - if ((index = ch - 0x4000) >= 4888) - { - if( codeType == UNICODE ) - dest[0]= 0x25A1; - else - dest[0]= 0xA1E0; - return 1; - } - if (codeType == KS) - { - /* ڵ ڵ ڵ ڵ 0xA1 - 0xFE . - ڵ忡 üִ 0xFE - 0xA1 +1 ̴. - */ - hi = sal::static_int_cast(index / (0xFE - 0xA1 + 1) + 0xCA); - lo = sal::static_int_cast(index % (0xFE - 0xA1 + 1) + 0xA1); - ch = (hi << 8) | lo; - } - else if(codeType == UNICODE){ - hi = sal::static_int_cast(index / (0xFE - 0xA1 + 1) + 0xCA); - lo = sal::static_int_cast(index % (0xFE - 0xA1 + 1) + 0xA1); - ch = (hi << 8) | lo; - ch = ksc5601_han_to_ucs2(ch); - } - else - { - hi = sal::static_int_cast(index / (0x100 - 0x31 - 0x11 - 2) + 0xE0); - lo = sal::static_int_cast(index % (0x100 - 0x31 - 0x11 - 2) + 0x31); - if (lo >= 0x7F) - lo += 0x12; - ch = (hi << 8) | lo; - } - //printf("hcharconv Hanja[%04x]\n",ch); - dest[0] = ch; - return 1; - } - if (LineCharDir(ch)) - { - dest[0] = lineCharConv(ch); - return 1; - } - else if (0x2f00 <= ch && ch <= 0x2f6f && (ch & 0x0f) < 9) - { -// bullet - lo = sal::static_int_cast(ch & 0x0f); - - if( codeType != KSSM ) - { - if (ch < 0x2f10) ch = 0xa1e0; - else if (ch < 0x2f20) ch = 0xa1db; - else if (ch < 0x2f30) ch = 0xa1de; - else if (ch < 0x2f40) ch = 0xa1e2; - else if (ch < 0x2f50) ch = 0xa1e4; - else if (ch < 0x2f60) ch = 0xa2b7; - else ch = 0xa2b9; - - ch = (lo < 6) ? ch : ch + 1; - if( codeType == UNICODE) - ch = ksc5601_sym_to_ucs2(ch); - } - else - { - if (ch < 0x2f10) ch = 0xd970; - else if (ch < 0x2f20) ch = 0xd96b; - else if (ch < 0x2f30) ch = 0xd96e; - else if (ch < 0x2f40) ch = 0xd972; - else if (ch < 0x2f50) ch = 0xd974; - else if (ch < 0x2f60) ch = 0xd9b7; - else ch = 0xd9b9; - ch = (lo < 6) ? ch : ch + 1; - } - //printf("hcharconv Bullet[%04x]\n",ch); - dest[0] = ch; - return 1 ; - } -/** - * Ư ڵ - * Ʒѱۿ 0x3400 Ưڰ ۵ȴ. 0xA1A0 - */ - else - { - if( codeType != KSSM ) - { - //printf("code[0x%04x]\n",ch); - hchar ch2 = ch; - ch = s_hh2ks(ch); - //printf("code ks[0x%04x]\n",ch); - if( codeType == UNICODE ){ - if (ch < 128){ - dest[0] = ch; - return 1; - } - /* ѱ۰ǻ : 0x37c0 ~ 0x37c5 */ - if( ch2 >= 0x37c0 && ch2 <= 0x37c5 ){ - if( ch2 == 0x37c0 ) dest[0] = 0xd55c; - else if( ch2 == 0x37c1 ) dest[0] = 0xae00; - else if( ch2 == 0x37c2 ) dest[0] = 0xacfc; - else if( ch2 == 0x37c3 ) dest[0] = 0xcef4; - else if( ch2 == 0x37c4 ) dest[0] = 0xd4e8; - else if( ch2 == 0x37c5 ) dest[0] = 0xd130; - return 1; - } - if( ch == 0x2020 ){ - switch( ch2 ){ - case 0x309b : - ch = 0xff62; - break; - case 0x309d : - ch = 0xff63; - break; - default: - ch = 0x25a1; - break; - } - } - else{ - ch = ksc5601_sym_to_ucs2(ch); - } - //printf("code ucs2[0x%04x]\n",ch); - } - } - else{ - ch = s_hh2kssm(ch); - } - - if (ch == 0){ // not '?', but square mark - if( codeType == UNICODE ) - dest[0] = 0x25A1; - else - dest[0] = 0xA1E0; - return 1; - } - //printf("hcharconv Special[%04x]\n",ch); - dest[0] = ch; - return 1; - } -} - -/* ѱ . */ -int kssm_hangul_to_ucs2(hchar ch, hchar *dest) -{ - hchar choseong, joongseong, jongseong; - - choseong = ((ch >> 10) & 0x1f); - joongseong = ((ch >> 5) & 0x1f); - jongseong = (ch & 0x1f) ; - - //printf("kssm_hangul_to_ucs2 : [%d,%d,%d]\n", choseong,joongseong,jongseong); - - if( joongseong < 2 ){ /* յ ߼=0,1 */ - if( joongseong == 0 && ch < 0xa414 ){ /* ڸ */ - int index = choseong * 32 + jongseong; - dest[0] = jamo_to_unicode[index]; - return 1; - } - else{ /* ڸ : ̺ ̿ϼ */ - unsigned int index = choseong * 32 + jongseong - 308; - if( index < SAL_N_ELEMENTS(jamocomp1_to_unicode) ){ - dest[0] = jamocomp1_to_unicode[index].v1; - dest[1] = jamocomp1_to_unicode[index].v2; - dest[2] = jamocomp1_to_unicode[index].v3; - return jamocomp1_to_unicode[index].size; - } - dest[0] = 0x25a1; // empty square. - return 1; - } - } - else if ( choseong == 1 && jongseong == 1 ){ /* */ - dest[0] = joongseong_to_unicode[joongseong]; - return 1; - } - else if ( joongseong == 2 && jongseong == 1 ){ /* */ - dest[0] = choseong_to_unicode[choseong]; - return 1; - } - else if( choseong > 20 || choseong == 0 || - joongseong == 17 || joongseong == 24 || - joongseong == 25 || joongseong > 29 || - jongseong == 0 || jongseong == 18 || - jongseong > 29 || - choseong == 1 || joongseong == 2 /* ϼ ѱ */ - ) { /* */ - int count = 0; - if( choseong != 1 ){ - dest[count] = choseong_to_unicode[choseong]; - count++; - } - if( joongseong > 2 ){ - dest[count] = joongseong_to_unicode[joongseong]; - count++; - } - if( jongseong != 1 ){ - dest[count] = jongseong_to_unicode[jongseong]; - count++; - } - return count; - } - - choseong -= 2; - if( joongseong < 0x8 ) - joongseong -= 3; - else if( joongseong < 0x10 ) - joongseong -= 5; - else if( joongseong < 0x18 ) - joongseong -= 7; - else - joongseong -= 9; - - choseong *= (NUM_JOONGSEONG * NUM_JONGSEONG); - joongseong *= NUM_JONGSEONG; - jongseong -= jongseong > 0x12 ? 2 : 1; - - dest[0] = UNI_HANGUL_FIRST + choseong + joongseong + jongseong; - return 1; -} - -hchar ksc5601_sym_to_ucs2 (hchar input) -{ - unsigned char ch = sal::static_int_cast(input >> 8); - unsigned char ch2; - int idx; - - ch2 = sal::static_int_cast(input & 0xff); - idx = (ch - 0xA1) * 94 + (ch2 - 0xA1); - if (idx <= 1114 && idx >= 0){ - hchar value = ksc5601_sym_to_ucs[idx]; - return value ? value : 0x25a1; - } - return 0x25a1; -} - -hchar ksc5601_han_to_ucs2 (hchar input) -{ - unsigned char ch = sal::static_int_cast(input >> 8); - unsigned char ch2; - int idx; - - ch2 = sal::static_int_cast(input & 0xff); - idx = (ch - 0xA1) * 94 + (ch2 - 0xA1); - if (idx >= 3854){ - // Hanja : row 42 - row 93 : 3854 = 94 * (42-1) - hchar value = ksc5601_hanja_to_ucs[idx - 3854]; - return value ? value : '?'; - } - return '?'; -} - -hchar* hstr2ucsstr(hchar* hstr, hchar* ubuf) -{ - int i = 0, j; - int res; - hchar dest[3]; - hchar *tmp = ubuf; - for( ; *hstr ; ){ - res = hcharconv(*hstr++, dest, UNICODE); - for( j = 0 ; j < res ; j++) - tmp[i++] = dest[j]; - } - - tmp[i]= '\0'; - return ubuf; -} -/** - * ĽƮ ϼƮ ȯѴ - */ -int hstr2ksstr(hchar* hstr, char* buf) -{ - - int i = 0, res, j; - int c; - hchar dest[3]; - char *tmp = buf; - for( ; *hstr ; ) - { - res = hcharconv(*hstr++, dest, KS); - for( j = 0 ; j < res ; j++ ){ - c = dest[j]; - if( c < 32 ) c = ' '; - else if( c < 256 ) - tmp[i++] = sal::static_int_cast(c); - else - { - tmp[i++] = sal::static_int_cast((c >> 8 ) & 0xff); - tmp[i++] = sal::static_int_cast(c & 0xff); - } - } - } - tmp[i]= '\0'; - - return i; -} - - -/* - * ѱۿ ڱ ִ kcharŸ ڿ - * ѱۿ ϴ hcharŸ ڿ ȯѴ. - */ -unsigned short *kstr2hstr( unsigned char *src, unsigned short *dest ) -{ - int i=0, ii; - unsigned short* tmp = dest; - - for(i=0,ii=0 ; src[i] != '\0' ; i++,ii++ ) - { - if ( src[i] < 127 ) - { - tmp[ii] = src[i]; - } - else - { - tmp[ii] = src[i] << 8 | src[i+1]; - i++; - } - } - tmp[ii] = '\0'; - return dest; -} - - -/** - * Transfer interger to string following format - */ -char* Int2Str(int value, const char *format, char *buf) -{ - sprintf(buf,format,value); - return buf; -} - - -/* colorε Ͽ Ÿǽ color ȯ */ -char *hcolor2str(uchar color, uchar shade, char *buf, bool bIsChar) -{ - unsigned short red,green,blue; - - switch( (int)color ) - { - case 0 : // black - red = 0xff * (100 - shade ) /100; - green = 0xff * (100 - shade ) /100; - blue = 0xff * (100 - shade ) /100; - break; - case 1: // blue - red = 0xff * (100 - shade ) /100; - green = 0xff * (100 - shade ) /100; - blue = 0xff; - break; - case 2: // green - red = 0xff * (100 - shade ) /100; - if( bIsChar ) - green = 0x80; - else - green = 0xff; - blue = 0xff * (100 - shade ) /100; - break; - case 3: // cyan - red = 0xff * (100 - shade ) /100; - green = 0xff; - blue = 0xff; - break; - case 4: // red - red = 0xff; - green = 0xff * (100 - shade ) /100; - blue = 0xff * (100 - shade ) /100; - break; - case 5: // magenta - red = 0xff; - green = 0xff * (100 - shade ) /100; - blue = 0xff; - break; - case 6: //yellow - red = 0xff; - green = 0xff; - blue = 0xff * (100 - shade ) /100; - break; - case 7: //white - default: - red = 0xff; - green = 0xff; - blue = 0xff; - break; - } - - sprintf(buf,"#%02x%02x%02x", red, green, blue); - return buf; -} - - -char *urltounix(const char *src, char *dest ) -{ - if( src[0] == 'C' && src[1] == ':' && src[2] == '\\' ) // Home Dir - { - unsigned int i, len; - sprintf(dest,"file://%s/", getenv("HOME") ); - len = strlen( dest ); - - for( i = 0 ; i + 3 < strlen(src) ; i++ ) - { - if( src[i + 3] == '\\') - dest[i + len] = '/'; - else - dest[i + len] = src[ i +3]; - } - dest[i + len] = '\0'; - return dest; - } - else if( src[0] == 'D' && src[1] == ':' && src[2] == '\\' ) // Root Dir - { - unsigned int i, len; - sprintf(dest,"file:///"); - len = strlen( dest ); - for( i = 0 ; i + 3 < strlen(src) ; i++ ) - { - if( src[i + 3] == '\\') - dest[i + len] = '/'; - else - dest[i + len] = src[i+3]; - } - dest[i + len] = '\0'; - return dest; - } - else if( !strncmp(src,"http",4) ) // Start from "http" - { - unsigned int i; - for( i = 0 ; i < strlen(src) ; i++ ) - { - if( src[i] == '\\') - dest[i] = '/'; - else - dest[i] = src[i]; - } - dest[i] = '\0'; - return dest; - } - else - { - unsigned int i, len, srclen; - srclen = strlen(src); - char ext[4]; - strncpy(ext,src + srclen - 3,3); - ext[3]=0; -#ifdef _WIN32 - if( _strnicmp(ext,"HWP",3) && _strnicmp(ext,"HWT",3)) -#else - if( strcasecmp(ext,"HWP") && strcasecmp(ext,"HWT")) -#endif - sprintf(dest, "http://"); - len = strlen(dest); - for( i = 0 ; i < strlen(src) ; i++ ) - { - if( src[i] == '\\') - dest[i+len] = '/'; - else - dest[i+len] = src[i]; - } - dest[i+len] = '\0'; - return dest; - } -} - -#ifdef _WIN32 -char *urltowin(const char *src, char *dest ) -{ - if( !_strnicmp(src, "http", 4)) - { - int i; - for( i = 0 ; i < sal::static_int_cast(strlen(src)) ; i++ ) - { - if( src[i] == '\\') - dest[i] = '/'; - else - dest[i] = src[i]; - } - dest[i] = '\0'; - return dest; - } - else - { - int i, len, srclen; - srclen = strlen(src); - char ext[4]; - strncpy(ext,src + srclen - 3,3); - ext[3]=0; - //printf("hcode.cpp : ext = %s\n",ext); - - if( !_strnicmp(ext,"HWP",3) || !_strnicmp(ext,"HWT",3)){ - strcpy(dest,src); - return dest; - } - sprintf(dest, "http://"); - len = strlen(dest); - for( i = 0 ; i < sal::static_int_cast(strlen(src)) ; i++ ) - { - if( src[i] == '\\') - dest[i+len] = '/'; - else - dest[i+len] = src[i]; - } - dest[i+len] = '\0'; - return dest; - } -} -#endif - -char* base64_encode_string( const uchar *buf, unsigned int len ) -{ - char basis_64[] = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - char * out; - int inPos = 0; - int outPos = 0; - int c1, c2, c3; - unsigned int i; - - out=(char *)malloc( (len*4/3)+8 ); - -/* Get three characters at a time and encode them. */ - for (i=0; i < len/3; ++i) - { - c1 = buf[inPos++] & 0xFF; - c2 = buf[inPos++] & 0xFF; - c3 = buf[inPos++] & 0xFF; - out[outPos++] = basis_64[(c1 & 0xFC) >> 2]; - out[outPos++] = basis_64[((c1 & 0x03) << 4) | ((c2 & 0xF0) >> 4)]; - out[outPos++] = basis_64[((c2 & 0x0F) << 2) | ((c3 & 0xC0) >> 6)]; - out[outPos++] = basis_64[c3 & 0x3F]; - } - -/* Encode the remaining one or two characters. */ - - switch (len % 3) - { - case 0: - break; - case 1: - c1 = buf[inPos] & 0xFF; - out[outPos++] = basis_64[(c1 & 0xFC) >> 2]; - out[outPos++] = basis_64[((c1 & 0x03) << 4)]; - out[outPos++] = '='; - out[outPos++] = '='; - break; - case 2: - c1 = buf[inPos++] & 0xFF; - c2 = buf[inPos] & 0xFF; - out[outPos++] = basis_64[(c1 & 0xFC) >> 2]; - out[outPos++] = basis_64[((c1 & 0x03) << 4) | ((c2 & 0xF0) >> 4)]; - out[outPos++] = basis_64[((c2 & 0x0F) << 2)]; - out[outPos++] = '='; - break; - } - out[outPos] = 0; - return out; -} - -double calcAngle(int x1, int y1, int x2, int y2) -{ - y1 = -y1; - y2 = -y2; - if( x2 == x1 ){ - if( y2 >= y1 ) - return 0.; - else - return 270.; - } - double angle; - angle = (180 / PI) * atan( ( y2 - y1 ) * 1.0 / ( x2 - x1 )); - if( y2 >= y1 ){ /* 1,2и */ - if( angle < 0. ) - angle += 180.; - } - else{ /* 3, 4 и */ - if( angle > 0 ) - angle += 180.; - else - angle += 360.; - } - return angle; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/hwpfilter/source/hcode.cxx b/hwpfilter/source/hcode.cxx new file mode 100644 index 000000000000..9a31e0ad5680 --- /dev/null +++ b/hwpfilter/source/hcode.cxx @@ -0,0 +1,1525 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +/** + * Rule : + * Hangule johap code => unicode + * Hanja johap code => ks code => unicode + * Special johap code => ks code => unicode + */ +#include "precompile.h" +#include +#include +#include +#include +#include +#include +#ifdef WIN32 +#include +#define isnan _isnan +#endif +#include "hcode.h" +#include "ksc5601.h" + +#define PI 3.14159265358979323846 + +static hchar jaso2ks(hchar hh); + +/* Conversion table. */ +#define KSC5601_HANJA 4888 +#define KSC5601_SYMBOL 986 + +// ccvHH2ASC code convert HWP20 to ASC(KSSM) + +#define HCA_HALFCH 0x3000 +#define HCA_KSS 0x3400 +#define HCA_TG 0x37C0 +#define none 0x3401 /* 2.0 null code - space */ +#define noneha 0x00A0 +#define noneks 0xA1A1 +#define none1x 0x2402 + +#define UNI_HANGUL_FIRST 0xac00 +#define UNI_COMP_JAMO_FIRST 0x3131 + +#define NUM_CHOSEONG 19 +#define NUM_JOONGSEONG 21 +#define NUM_JONGSEONG 28 + + +#define IDX_INVALID 0xFF + +/** + * kssm code table matching with ks index + */ +static hchar ksTbl[2350] = +{ + 0x8861, 0x8862, 0x8865, 0x8868, 0x8869, 0x886A, 0x886B, 0x8871, + 0x8873, 0x8874, 0x8875, 0x8876, 0x8877, 0x8878, 0x8879, 0x887B, + 0x887C, 0x887D, 0x8881, 0x8882, 0x8885, 0x8889, 0x8891, 0x8893, + 0x8895, 0x8896, 0x8897, 0x88A1, 0x88A2, 0x88A5, 0x88A9, 0x88B5, + 0x88B7, 0x88C1, 0x88C5, 0x88C9, 0x88E1, 0x88E2, 0x88E5, 0x88E8, + 0x88E9, 0x88EB, 0x88F1, 0x88F3, 0x88F5, 0x88F6, 0x88F7, 0x88F8, + 0x88FB, 0x88FC, 0x88FD, 0x8941, 0x8945, 0x8949, 0x8951, 0x8953, + 0x8955, 0x8956, 0x8957, 0x8961, 0x8962, 0x8963, 0x8965, 0x8968, + 0x8969, 0x8971, 0x8973, 0x8975, 0x8976, 0x8977, 0x897B, 0x8981, + 0x8985, 0x8989, 0x8993, 0x8995, 0x89A1, 0x89A2, 0x89A5, 0x89A8, + 0x89A9, 0x89AB, 0x89AD, 0x89B0, 0x89B1, 0x89B3, 0x89B5, 0x89B7, + 0x89B8, 0x89C1, 0x89C2, 0x89C5, 0x89C9, 0x89CB, 0x89D1, 0x89D3, + 0x89D5, 0x89D7, 0x89E1, 0x89E5, 0x89E9, 0x89F3, 0x89F6, 0x89F7, + 0x8A41, 0x8A42, 0x8A45, 0x8A49, 0x8A51, 0x8A53, 0x8A55, 0x8A57, + 0x8A61, 0x8A65, 0x8A69, 0x8A73, 0x8A75, 0x8A81, 0x8A82, 0x8A85, + 0x8A88, 0x8A89, 0x8A8A, 0x8A8B, 0x8A90, 0x8A91, 0x8A93, 0x8A95, + 0x8A97, 0x8A98, 0x8AA1, 0x8AA2, 0x8AA5, 0x8AA9, 0x8AB6, 0x8AB7, + 0x8AC1, 0x8AD5, 0x8AE1, 0x8AE2, 0x8AE5, 0x8AE9, 0x8AF1, 0x8AF3, + 0x8AF5, 0x8B41, 0x8B45, 0x8B49, 0x8B61, 0x8B62, 0x8B65, 0x8B68, + 0x8B69, 0x8B6A, 0x8B71, 0x8B73, 0x8B75, 0x8B77, 0x8B81, 0x8BA1, + 0x8BA2, 0x8BA5, 0x8BA8, 0x8BA9, 0x8BAB, 0x8BB1, 0x8BB3, 0x8BB5, + 0x8BB7, 0x8BB8, 0x8BBC, 0x8C61, 0x8C62, 0x8C63, 0x8C65, 0x8C69, + 0x8C6B, 0x8C71, 0x8C73, 0x8C75, 0x8C76, 0x8C77, 0x8C7B, 0x8C81, + 0x8C82, 0x8C85, 0x8C89, 0x8C91, 0x8C93, 0x8C95, 0x8C96, 0x8C97, + 0x8CA1, 0x8CA2, 0x8CA9, 0x8CE1, 0x8CE2, 0x8CE3, 0x8CE5, 0x8CE9, + 0x8CF1, 0x8CF3, 0x8CF5, 0x8CF6, 0x8CF7, 0x8D41, 0x8D42, 0x8D45, + 0x8D51, 0x8D55, 0x8D57, 0x8D61, 0x8D65, 0x8D69, 0x8D75, 0x8D76, + 0x8D7B, 0x8D81, 0x8DA1, 0x8DA2, 0x8DA5, 0x8DA7, 0x8DA9, 0x8DB1, + 0x8DB3, 0x8DB5, 0x8DB7, 0x8DB8, 0x8DB9, 0x8DC1, 0x8DC2, 0x8DC9, + 0x8DD6, 0x8DD7, 0x8DE1, 0x8DE2, 0x8DF7, 0x8E41, 0x8E45, 0x8E49, + 0x8E51, 0x8E53, 0x8E57, 0x8E61, 0x8E81, 0x8E82, 0x8E85, 0x8E89, + 0x8E90, 0x8E91, 0x8E93, 0x8E95, 0x8E97, 0x8E98, 0x8EA1, 0x8EA9, + 0x8EB6, 0x8EB7, 0x8EC1, 0x8EC2, 0x8EC5, 0x8EC9, 0x8ED1, 0x8ED3, + 0x8ED6, 0x8EE1, 0x8EE5, 0x8EE9, 0x8EF1, 0x8EF3, 0x8F41, 0x8F61, + 0x8F62, 0x8F65, 0x8F67, 0x8F69, 0x8F6B, 0x8F70, 0x8F71, 0x8F73, + 0x8F75, 0x8F77, 0x8F7B, 0x8FA1, 0x8FA2, 0x8FA5, 0x8FA9, 0x8FB1, + 0x8FB3, 0x8FB5, 0x8FB7, 0x9061, 0x9062, 0x9063, 0x9065, 0x9068, + 0x9069, 0x906A, 0x906B, 0x9071, 0x9073, 0x9075, 0x9076, 0x9077, + 0x9078, 0x9079, 0x907B, 0x907D, 0x9081, 0x9082, 0x9085, 0x9089, + 0x9091, 0x9093, 0x9095, 0x9096, 0x9097, 0x90A1, 0x90A2, 0x90A5, + 0x90A9, 0x90B1, 0x90B7, 0x90E1, 0x90E2, 0x90E4, 0x90E5, 0x90E9, + 0x90EB, 0x90EC, 0x90F1, 0x90F3, 0x90F5, 0x90F6, 0x90F7, 0x90FD, + 0x9141, 0x9142, 0x9145, 0x9149, 0x9151, 0x9153, 0x9155, 0x9156, + 0x9157, 0x9161, 0x9162, 0x9165, 0x9169, 0x9171, 0x9173, 0x9176, + 0x9177, 0x917A, 0x9181, 0x9185, 0x91A1, 0x91A2, 0x91A5, 0x91A9, + 0x91AB, 0x91B1, 0x91B3, 0x91B5, 0x91B7, 0x91BC, 0x91BD, 0x91C1, + 0x91C5, 0x91C9, 0x91D6, 0x9241, 0x9245, 0x9249, 0x9251, 0x9253, + 0x9255, 0x9261, 0x9262, 0x9265, 0x9269, 0x9273, 0x9275, 0x9277, + 0x9281, 0x9282, 0x9285, 0x9288, 0x9289, 0x9291, 0x9293, 0x9295, + 0x9297, 0x92A1, 0x92B6, 0x92C1, 0x92E1, 0x92E5, 0x92E9, 0x92F1, + 0x92F3, 0x9341, 0x9342, 0x9349, 0x9351, 0x9353, 0x9357, 0x9361, + 0x9362, 0x9365, 0x9369, 0x936A, 0x936B, 0x9371, 0x9373, 0x9375, + 0x9377, 0x9378, 0x937C, 0x9381, 0x9385, 0x9389, 0x93A1, 0x93A2, + 0x93A5, 0x93A9, 0x93AF, 0x93B1, 0x93B3, 0x93B5, 0x93B7, 0x93BC, + 0x9461, 0x9462, 0x9463, 0x9465, 0x9468, 0x9469, 0x946A, 0x946B, + 0x946C, 0x9470, 0x9471, 0x9473, 0x9475, 0x9476, 0x9477, 0x9478, + 0x9479, 0x947D, 0x9481, 0x9482, 0x9485, 0x9489, 0x9491, 0x9493, + 0x9495, 0x9496, 0x9497, 0x94A1, 0x94E1, 0x94E2, 0x94E3, 0x94E5, + 0x94E8, 0x94E9, 0x94EB, 0x94EC, 0x94F1, 0x94F3, 0x94F5, 0x94F7, + 0x94F9, 0x94FC, 0x9541, 0x9542, 0x9545, 0x9549, 0x9551, 0x9553, + 0x9555, 0x9556, 0x9557, 0x9561, 0x9565, 0x9569, 0x9576, 0x9577, + 0x9581, 0x9585, 0x95A1, 0x95A2, 0x95A5, 0x95A8, 0x95A9, 0x95AB, + 0x95AD, 0x95B1, 0x95B3, 0x95B5, 0x95B7, 0x95B9, 0x95BB, 0x95C1, + 0x95C5, 0x95C9, 0x95E1, 0x95F6, 0x9641, 0x9645, 0x9649, 0x9651, + 0x9653, 0x9655, 0x9661, 0x9681, 0x9682, 0x9685, 0x9689, 0x9691, + 0x9693, 0x9695, 0x9697, 0x96A1, 0x96B6, 0x96C1, 0x96D7, 0x96E1, + 0x96E5, 0x96E9, 0x96F3, 0x96F5, 0x96F7, 0x9741, 0x9745, 0x9749, + 0x9751, 0x9757, 0x9761, 0x9762, 0x9765, 0x9768, 0x9769, 0x976B, + 0x9771, 0x9773, 0x9775, 0x9777, 0x9781, 0x97A1, 0x97A2, 0x97A5, + 0x97A8, 0x97A9, 0x97B1, 0x97B3, 0x97B5, 0x97B6, 0x97B7, 0x97B8, + 0x9861, 0x9862, 0x9865, 0x9869, 0x9871, 0x9873, 0x9875, 0x9876, + 0x9877, 0x987D, 0x9881, 0x9882, 0x9885, 0x9889, 0x9891, 0x9893, + 0x9895, 0x9896, 0x9897, 0x98E1, 0x98E2, 0x98E5, 0x98E9, 0x98EB, + 0x98EC, 0x98F1, 0x98F3, 0x98F5, 0x98F6, 0x98F7, 0x98FD, 0x9941, + 0x9942, 0x9945, 0x9949, 0x9951, 0x9953, 0x9955, 0x9956, 0x9957, + 0x9961, 0x9976, 0x99A1, 0x99A2, 0x99A5, 0x99A9, 0x99B7, 0x99C1, + 0x99C9, 0x99E1, 0x9A41, 0x9A45, 0x9A81, 0x9A82, 0x9A85, 0x9A89, + 0x9A90, 0x9A91, 0x9A97, 0x9AC1, 0x9AE1, 0x9AE5, 0x9AE9, 0x9AF1, + 0x9AF3, 0x9AF7, 0x9B61, 0x9B62, 0x9B65, 0x9B68, 0x9B69, 0x9B71, + 0x9B73, 0x9B75, 0x9B81, 0x9B85, 0x9B89, 0x9B91, 0x9B93, 0x9BA1, + 0x9BA5, 0x9BA9, 0x9BB1, 0x9BB3, 0x9BB5, 0x9BB7, 0x9C61, 0x9C62, + 0x9C65, 0x9C69, 0x9C71, 0x9C73, 0x9C75, 0x9C76, 0x9C77, 0x9C78, + 0x9C7C, 0x9C7D, 0x9C81, 0x9C82, 0x9C85, 0x9C89, 0x9C91, 0x9C93, + 0x9C95, 0x9C96, 0x9C97, 0x9CA1, 0x9CA2, 0x9CA5, 0x9CB5, 0x9CB7, + 0x9CE1, 0x9CE2, 0x9CE5, 0x9CE9, 0x9CF1, 0x9CF3, 0x9CF5, 0x9CF6, + 0x9CF7, 0x9CFD, 0x9D41, 0x9D42, 0x9D45, 0x9D49, 0x9D51, 0x9D53, + 0x9D55, 0x9D57, 0x9D61, 0x9D62, 0x9D65, 0x9D69, 0x9D71, 0x9D73, + 0x9D75, 0x9D76, 0x9D77, 0x9D81, 0x9D85, 0x9D93, 0x9D95, 0x9DA1, + 0x9DA2, 0x9DA5, 0x9DA9, 0x9DB1, 0x9DB3, 0x9DB5, 0x9DB7, 0x9DC1, + 0x9DC5, 0x9DD7, 0x9DF6, 0x9E41, 0x9E45, 0x9E49, 0x9E51, 0x9E53, + 0x9E55, 0x9E57, 0x9E61, 0x9E65, 0x9E69, 0x9E73, 0x9E75, 0x9E77, + 0x9E81, 0x9E82, 0x9E85, 0x9E89, 0x9E91, 0x9E93, 0x9E95, 0x9E97, + 0x9EA1, 0x9EB6, 0x9EC1, 0x9EE1, 0x9EE2, 0x9EE5, 0x9EE9, 0x9EF1, + 0x9EF5, 0x9EF7, 0x9F41, 0x9F42, 0x9F45, 0x9F49, 0x9F51, 0x9F53, + 0x9F55, 0x9F57, 0x9F61, 0x9F62, 0x9F65, 0x9F69, 0x9F71, 0x9F73, + 0x9F75, 0x9F77, 0x9F78, 0x9F7B, 0x9F7C, 0x9FA1, 0x9FA2, 0x9FA5, + 0x9FA9, 0x9FB1, 0x9FB3, 0x9FB5, 0x9FB7, 0xA061, 0xA062, 0xA065, + 0xA067, 0xA068, 0xA069, 0xA06A, 0xA06B, 0xA071, 0xA073, 0xA075, + 0xA077, 0xA078, 0xA07B, 0xA07D, 0xA081, 0xA082, 0xA085, 0xA089, + 0xA091, 0xA093, 0xA095, 0xA096, 0xA097, 0xA098, 0xA0A1, 0xA0A2, + 0xA0A9, 0xA0B7, 0xA0E1, 0xA0E2, 0xA0E5, 0xA0E9, 0xA0EB, 0xA0F1, + 0xA0F3, 0xA0F5, 0xA0F7, 0xA0F8, 0xA0FD, 0xA141, 0xA142, 0xA145, + 0xA149, 0xA151, 0xA153, 0xA155, 0xA156, 0xA157, 0xA161, 0xA162, + 0xA165, 0xA169, 0xA175, 0xA176, 0xA177, 0xA179, 0xA181, 0xA1A1, + 0xA1A2, 0xA1A4, 0xA1A5, 0xA1A9, 0xA1AB, 0xA1B1, 0xA1B3, 0xA1B5, + 0xA1B7, 0xA1C1, 0xA1C5, 0xA1D6, 0xA1D7, 0xA241, 0xA245, 0xA249, + 0xA253, 0xA255, 0xA257, 0xA261, 0xA265, 0xA269, 0xA273, 0xA275, + 0xA281, 0xA282, 0xA283, 0xA285, 0xA288, 0xA289, 0xA28A, 0xA28B, + 0xA291, 0xA293, 0xA295, 0xA297, 0xA29B, 0xA29D, 0xA2A1, 0xA2A5, + 0xA2A9, 0xA2B3, 0xA2B5, 0xA2C1, 0xA2E1, 0xA2E5, 0xA2E9, 0xA341, + 0xA345, 0xA349, 0xA351, 0xA355, 0xA361, 0xA365, 0xA369, 0xA371, + 0xA375, 0xA3A1, 0xA3A2, 0xA3A5, 0xA3A8, 0xA3A9, 0xA3AB, 0xA3B1, + 0xA3B3, 0xA3B5, 0xA3B6, 0xA3B7, 0xA3B9, 0xA3BB, 0xA461, 0xA462, + 0xA463, 0xA464, 0xA465, 0xA468, 0xA469, 0xA46A, 0xA46B, 0xA46C, + 0xA471, 0xA473, 0xA475, 0xA477, 0xA47B, 0xA481, 0xA482, 0xA485, + 0xA489, 0xA491, 0xA493, 0xA495, 0xA496, 0xA497, 0xA49B, 0xA4A1, + 0xA4A2, 0xA4A5, 0xA4B3, 0xA4E1, 0xA4E2, 0xA4E5, 0xA4E8, 0xA4E9, + 0xA4EB, 0xA4F1, 0xA4F3, 0xA4F5, 0xA4F7, 0xA4F8, 0xA541, 0xA542, + 0xA545, 0xA548, 0xA549, 0xA551, 0xA553, 0xA555, 0xA556, 0xA557, + 0xA561, 0xA562, 0xA565, 0xA569, 0xA573, 0xA575, 0xA576, 0xA577, + 0xA57B, 0xA581, 0xA585, 0xA5A1, 0xA5A2, 0xA5A3, 0xA5A5, 0xA5A9, + 0xA5B1, 0xA5B3, 0xA5B5, 0xA5B7, 0xA5C1, 0xA5C5, 0xA5D6, 0xA5E1, + 0xA5F6, 0xA641, 0xA642, 0xA645, 0xA649, 0xA651, 0xA653, 0xA661, + 0xA665, 0xA681, 0xA682, 0xA685, 0xA688, 0xA689, 0xA68A, 0xA68B, + 0xA691, 0xA693, 0xA695, 0xA697, 0xA69B, 0xA69C, 0xA6A1, 0xA6A9, + 0xA6B6, 0xA6C1, 0xA6E1, 0xA6E2, 0xA6E5, 0xA6E9, 0xA6F7, 0xA741, + 0xA745, 0xA749, 0xA751, 0xA755, 0xA757, 0xA761, 0xA762, 0xA765, + 0xA769, 0xA771, 0xA773, 0xA775, 0xA7A1, 0xA7A2, 0xA7A5, 0xA7A9, + 0xA7AB, 0xA7B1, 0xA7B3, 0xA7B5, 0xA7B7, 0xA7B8, 0xA7B9, 0xA861, + 0xA862, 0xA865, 0xA869, 0xA86B, 0xA871, 0xA873, 0xA875, 0xA876, + 0xA877, 0xA87D, 0xA881, 0xA882, 0xA885, 0xA889, 0xA891, 0xA893, + 0xA895, 0xA896, 0xA897, 0xA8A1, 0xA8A2, 0xA8B1, 0xA8E1, 0xA8E2, + 0xA8E5, 0xA8E8, 0xA8E9, 0xA8F1, 0xA8F5, 0xA8F6, 0xA8F7, 0xA941, + 0xA957, 0xA961, 0xA962, 0xA971, 0xA973, 0xA975, 0xA976, 0xA977, + 0xA9A1, 0xA9A2, 0xA9A5, 0xA9A9, 0xA9B1, 0xA9B3, 0xA9B7, 0xAA41, + 0xAA61, 0xAA77, 0xAA81, 0xAA82, 0xAA85, 0xAA89, 0xAA91, 0xAA95, + 0xAA97, 0xAB41, 0xAB57, 0xAB61, 0xAB65, 0xAB69, 0xAB71, 0xAB73, + 0xABA1, 0xABA2, 0xABA5, 0xABA9, 0xABB1, 0xABB3, 0xABB5, 0xABB7, + 0xAC61, 0xAC62, 0xAC64, 0xAC65, 0xAC68, 0xAC69, 0xAC6A, 0xAC6B, + 0xAC71, 0xAC73, 0xAC75, 0xAC76, 0xAC77, 0xAC7B, 0xAC81, 0xAC82, + 0xAC85, 0xAC89, 0xAC91, 0xAC93, 0xAC95, 0xAC96, 0xAC97, 0xACA1, + 0xACA2, 0xACA5, 0xACA9, 0xACB1, 0xACB3, 0xACB5, 0xACB7, 0xACC1, + 0xACC5, 0xACC9, 0xACD1, 0xACD7, 0xACE1, 0xACE2, 0xACE3, 0xACE4, + 0xACE5, 0xACE8, 0xACE9, 0xACEB, 0xACEC, 0xACF1, 0xACF3, 0xACF5, + 0xACF6, 0xACF7, 0xACFC, 0xAD41, 0xAD42, 0xAD45, 0xAD49, 0xAD51, + 0xAD53, 0xAD55, 0xAD56, 0xAD57, 0xAD61, 0xAD62, 0xAD65, 0xAD69, + 0xAD71, 0xAD73, 0xAD75, 0xAD76, 0xAD77, 0xAD81, 0xAD85, 0xAD89, + 0xAD97, 0xADA1, 0xADA2, 0xADA3, 0xADA5, 0xADA9, 0xADAB, 0xADB1, + 0xADB3, 0xADB5, 0xADB7, 0xADBB, 0xADC1, 0xADC2, 0xADC5, 0xADC9, + 0xADD7, 0xADE1, 0xADE5, 0xADE9, 0xADF1, 0xADF5, 0xADF6, 0xAE41, + 0xAE45, 0xAE49, 0xAE51, 0xAE53, 0xAE55, 0xAE61, 0xAE62, 0xAE65, + 0xAE69, 0xAE71, 0xAE73, 0xAE75, 0xAE77, 0xAE81, 0xAE82, 0xAE85, + 0xAE88, 0xAE89, 0xAE91, 0xAE93, 0xAE95, 0xAE97, 0xAE99, 0xAE9B, + 0xAE9C, 0xAEA1, 0xAEB6, 0xAEC1, 0xAEC2, 0xAEC5, 0xAEC9, 0xAED1, + 0xAED7, 0xAEE1, 0xAEE2, 0xAEE5, 0xAEE9, 0xAEF1, 0xAEF3, 0xAEF5, + 0xAEF7, 0xAF41, 0xAF42, 0xAF49, 0xAF51, 0xAF55, 0xAF57, 0xAF61, + 0xAF62, 0xAF65, 0xAF69, 0xAF6A, 0xAF71, 0xAF73, 0xAF75, 0xAF77, + 0xAFA1, 0xAFA2, 0xAFA5, 0xAFA8, 0xAFA9, 0xAFB0, 0xAFB1, 0xAFB3, + 0xAFB5, 0xAFB7, 0xAFBC, 0xB061, 0xB062, 0xB064, 0xB065, 0xB069, + 0xB071, 0xB073, 0xB076, 0xB077, 0xB07D, 0xB081, 0xB082, 0xB085, + 0xB089, 0xB091, 0xB093, 0xB096, 0xB097, 0xB0B7, 0xB0E1, 0xB0E2, + 0xB0E5, 0xB0E9, 0xB0EB, 0xB0F1, 0xB0F3, 0xB0F6, 0xB0F7, 0xB141, + 0xB145, 0xB149, 0xB185, 0xB1A1, 0xB1A2, 0xB1A5, 0xB1A8, 0xB1A9, + 0xB1AB, 0xB1B1, 0xB1B3, 0xB1B7, 0xB1C1, 0xB1C2, 0xB1C5, 0xB1D6, + 0xB1E1, 0xB1F6, 0xB241, 0xB245, 0xB249, 0xB251, 0xB253, 0xB261, + 0xB281, 0xB282, 0xB285, 0xB289, 0xB291, 0xB293, 0xB297, 0xB2A1, + 0xB2B6, 0xB2C1, 0xB2E1, 0xB2E5, 0xB357, 0xB361, 0xB362, 0xB365, + 0xB369, 0xB36B, 0xB370, 0xB371, 0xB373, 0xB381, 0xB385, 0xB389, + 0xB391, 0xB3A1, 0xB3A2, 0xB3A5, 0xB3A9, 0xB3B1, 0xB3B3, 0xB3B5, + 0xB3B7, 0xB461, 0xB462, 0xB465, 0xB466, 0xB467, 0xB469, 0xB46A, + 0xB46B, 0xB470, 0xB471, 0xB473, 0xB475, 0xB476, 0xB477, 0xB47B, + 0xB47C, 0xB481, 0xB482, 0xB485, 0xB489, 0xB491, 0xB493, 0xB495, + 0xB496, 0xB497, 0xB4A1, 0xB4A2, 0xB4A5, 0xB4A9, 0xB4AC, 0xB4B1, + 0xB4B3, 0xB4B5, 0xB4B7, 0xB4BB, 0xB4BD, 0xB4C1, 0xB4C5, 0xB4C9, + 0xB4D3, 0xB4E1, 0xB4E2, 0xB4E5, 0xB4E6, 0xB4E8, 0xB4E9, 0xB4EA, + 0xB4EB, 0xB4F1, 0xB4F3, 0xB4F4, 0xB4F5, 0xB4F6, 0xB4F7, 0xB4F8, + 0xB4FA, 0xB4FC, 0xB541, 0xB542, 0xB545, 0xB549, 0xB551, 0xB553, + 0xB555, 0xB557, 0xB561, 0xB562, 0xB563, 0xB565, 0xB569, 0xB56B, + 0xB56C, 0xB571, 0xB573, 0xB574, 0xB575, 0xB576, 0xB577, 0xB57B, + 0xB57C, 0xB57D, 0xB581, 0xB585, 0xB589, 0xB591, 0xB593, 0xB595, + 0xB596, 0xB5A1, 0xB5A2, 0xB5A5, 0xB5A9, 0xB5AA, 0xB5AB, 0xB5AD, + 0xB5B0, 0xB5B1, 0xB5B3, 0xB5B5, 0xB5B7, 0xB5B9, 0xB5C1, 0xB5C2, + 0xB5C5, 0xB5C9, 0xB5D1, 0xB5D3, 0xB5D5, 0xB5D6, 0xB5D7, 0xB5E1, + 0xB5E2, 0xB5E5, 0xB5F1, 0xB5F5, 0xB5F7, 0xB641, 0xB642, 0xB645, + 0xB649, 0xB651, 0xB653, 0xB655, 0xB657, 0xB661, 0xB662, 0xB665, + 0xB669, 0xB671, 0xB673, 0xB675, 0xB677, 0xB681, 0xB682, 0xB685, + 0xB689, 0xB68A, 0xB68B, 0xB691, 0xB693, 0xB695, 0xB697, 0xB6A1, + 0xB6A2, 0xB6A5, 0xB6A9, 0xB6B1, 0xB6B3, 0xB6B6, 0xB6B7, 0xB6C1, + 0xB6C2, 0xB6C5, 0xB6C9, 0xB6D1, 0xB6D3, 0xB6D7, 0xB6E1, 0xB6E2, + 0xB6E5, 0xB6E9, 0xB6F1, 0xB6F3, 0xB6F5, 0xB6F7, 0xB741, 0xB742, + 0xB745, 0xB749, 0xB751, 0xB753, 0xB755, 0xB757, 0xB759, 0xB761, + 0xB762, 0xB765, 0xB769, 0xB76F, 0xB771, 0xB773, 0xB775, 0xB777, + 0xB778, 0xB779, 0xB77A, 0xB77B, 0xB77C, 0xB77D, 0xB781, 0xB785, + 0xB789, 0xB791, 0xB795, 0xB7A1, 0xB7A2, 0xB7A5, 0xB7A9, 0xB7AA, + 0xB7AB, 0xB7B0, 0xB7B1, 0xB7B3, 0xB7B5, 0xB7B6, 0xB7B7, 0xB7B8, + 0xB7BC, 0xB861, 0xB862, 0xB865, 0xB867, 0xB868, 0xB869, 0xB86B, + 0xB871, 0xB873, 0xB875, 0xB876, 0xB877, 0xB878, 0xB881, 0xB882, + 0xB885, 0xB889, 0xB891, 0xB893, 0xB895, 0xB896, 0xB897, 0xB8A1, + 0xB8A2, 0xB8A5, 0xB8A7, 0xB8A9, 0xB8B1, 0xB8B7, 0xB8C1, 0xB8C5, + 0xB8C9, 0xB8E1, 0xB8E2, 0xB8E5, 0xB8E9, 0xB8EB, 0xB8F1, 0xB8F3, + 0xB8F5, 0xB8F7, 0xB8F8, 0xB941, 0xB942, 0xB945, 0xB949, 0xB951, + 0xB953, 0xB955, 0xB957, 0xB961, 0xB965, 0xB969, 0xB971, 0xB973, + 0xB976, 0xB977, 0xB981, 0xB9A1, 0xB9A2, 0xB9A5, 0xB9A9, 0xB9AB, + 0xB9B1, 0xB9B3, 0xB9B5, 0xB9B7, 0xB9B8, 0xB9B9, 0xB9BD, 0xB9C1, + 0xB9C2, 0xB9C9, 0xB9D3, 0xB9D5, 0xB9D7, 0xB9E1, 0xB9F6, 0xB9F7, + 0xBA41, 0xBA45, 0xBA49, 0xBA51, 0xBA53, 0xBA55, 0xBA57, 0xBA61, + 0xBA62, 0xBA65, 0xBA77, 0xBA81, 0xBA82, 0xBA85, 0xBA89, 0xBA8A, + 0xBA8B, 0xBA91, 0xBA93, 0xBA95, 0xBA97, 0xBAA1, 0xBAB6, 0xBAC1, + 0xBAE1, 0xBAE2, 0xBAE5, 0xBAE9, 0xBAF1, 0xBAF3, 0xBAF5, 0xBB41, + 0xBB45, 0xBB49, 0xBB51, 0xBB61, 0xBB62, 0xBB65, 0xBB69, 0xBB71, + 0xBB73, 0xBB75, 0xBB77, 0xBBA1, 0xBBA2, 0xBBA5, 0xBBA8, 0xBBA9, + 0xBBAB, 0xBBB1, 0xBBB3, 0xBBB5, 0xBBB7, 0xBBB8, 0xBBBB, 0xBBBC, + 0xBC61, 0xBC62, 0xBC65, 0xBC67, 0xBC69, 0xBC6C, 0xBC71, 0xBC73, + 0xBC75, 0xBC76, 0xBC77, 0xBC81, 0xBC82, 0xBC85, 0xBC89, 0xBC91, + 0xBC93, 0xBC95, 0xBC96, 0xBC97, 0xBCA1, 0xBCA5, 0xBCB7, 0xBCE1, + 0xBCE2, 0xBCE5, 0xBCE9, 0xBCF1, 0xBCF3, 0xBCF5, 0xBCF6, 0xBCF7, + 0xBD41, 0xBD57, 0xBD61, 0xBD76, 0xBDA1, 0xBDA2, 0xBDA5, 0xBDA9, + 0xBDB1, 0xBDB3, 0xBDB5, 0xBDB7, 0xBDB9, 0xBDC1, 0xBDC2, 0xBDC9, + 0xBDD6, 0xBDE1, 0xBDF6, 0xBE41, 0xBE45, 0xBE49, 0xBE51, 0xBE53, + 0xBE77, 0xBE81, 0xBE82, 0xBE85, 0xBE89, 0xBE91, 0xBE93, 0xBE97, + 0xBEA1, 0xBEB6, 0xBEB7, 0xBEE1, 0xBF41, 0xBF61, 0xBF71, 0xBF75, + 0xBF77, 0xBFA1, 0xBFA2, 0xBFA5, 0xBFA9, 0xBFB1, 0xBFB3, 0xBFB7, + 0xBFB8, 0xBFBD, 0xC061, 0xC062, 0xC065, 0xC067, 0xC069, 0xC071, + 0xC073, 0xC075, 0xC076, 0xC077, 0xC078, 0xC081, 0xC082, 0xC085, + 0xC089, 0xC091, 0xC093, 0xC095, 0xC096, 0xC097, 0xC0A1, 0xC0A5, + 0xC0A7, 0xC0A9, 0xC0B1, 0xC0B7, 0xC0E1, 0xC0E2, 0xC0E5, 0xC0E9, + 0xC0F1, 0xC0F3, 0xC0F5, 0xC0F6, 0xC0F7, 0xC141, 0xC142, 0xC145, + 0xC149, 0xC151, 0xC153, 0xC155, 0xC157, 0xC161, 0xC165, 0xC176, + 0xC181, 0xC185, 0xC197, 0xC1A1, 0xC1A2, 0xC1A5, 0xC1A9, 0xC1B1, + 0xC1B3, 0xC1B5, 0xC1B7, 0xC1C1, 0xC1C5, 0xC1C9, 0xC1D7, 0xC241, + 0xC245, 0xC249, 0xC251, 0xC253, 0xC255, 0xC257, 0xC261, 0xC271, + 0xC281, 0xC282, 0xC285, 0xC289, 0xC291, 0xC293, 0xC295, 0xC297, + 0xC2A1, 0xC2B6, 0xC2C1, 0xC2C5, 0xC2E1, 0xC2E5, 0xC2E9, 0xC2F1, + 0xC2F3, 0xC2F5, 0xC2F7, 0xC341, 0xC345, 0xC349, 0xC351, 0xC357, + 0xC361, 0xC362, 0xC365, 0xC369, 0xC371, 0xC373, 0xC375, 0xC377, + 0xC3A1, 0xC3A2, 0xC3A5, 0xC3A8, 0xC3A9, 0xC3AA, 0xC3B1, 0xC3B3, + 0xC3B5, 0xC3B7, 0xC461, 0xC462, 0xC465, 0xC469, 0xC471, 0xC473, + 0xC475, 0xC477, 0xC481, 0xC482, 0xC485, 0xC489, 0xC491, 0xC493, + 0xC495, 0xC496, 0xC497, 0xC4A1, 0xC4A2, 0xC4B7, 0xC4E1, 0xC4E2, + 0xC4E5, 0xC4E8, 0xC4E9, 0xC4F1, 0xC4F3, 0xC4F5, 0xC4F6, 0xC4F7, + 0xC541, 0xC542, 0xC545, 0xC549, 0xC551, 0xC553, 0xC555, 0xC557, + 0xC561, 0xC565, 0xC569, 0xC571, 0xC573, 0xC575, 0xC576, 0xC577, + 0xC581, 0xC5A1, 0xC5A2, 0xC5A5, 0xC5A9, 0xC5B1, 0xC5B3, 0xC5B5, + 0xC5B7, 0xC5C1, 0xC5C2, 0xC5C5, 0xC5C9, 0xC5D1, 0xC5D7, 0xC5E1, + 0xC5F7, 0xC641, 0xC649, 0xC661, 0xC681, 0xC682, 0xC685, 0xC689, + 0xC691, 0xC693, 0xC695, 0xC697, 0xC6A1, 0xC6A5, 0xC6A9, 0xC6B7, + 0xC6C1, 0xC6D7, 0xC6E1, 0xC6E2, 0xC6E5, 0xC6E9, 0xC6F1, 0xC6F3, + 0xC6F5, 0xC6F7, 0xC741, 0xC745, 0xC749, 0xC751, 0xC761, 0xC762, + 0xC765, 0xC769, 0xC771, 0xC773, 0xC777, 0xC7A1, 0xC7A2, 0xC7A5, + 0xC7A9, 0xC7B1, 0xC7B3, 0xC7B5, 0xC7B7, 0xC861, 0xC862, 0xC865, + 0xC869, 0xC86A, 0xC871, 0xC873, 0xC875, 0xC876, 0xC877, 0xC881, + 0xC882, 0xC885, 0xC889, 0xC891, 0xC893, 0xC895, 0xC896, 0xC897, + 0xC8A1, 0xC8B7, 0xC8E1, 0xC8E2, 0xC8E5, 0xC8E9, 0xC8EB, 0xC8F1, + 0xC8F3, 0xC8F5, 0xC8F6, 0xC8F7, 0xC941, 0xC942, 0xC945, 0xC949, + 0xC951, 0xC953, 0xC955, 0xC957, 0xC961, 0xC965, 0xC976, 0xC981, + 0xC985, 0xC9A1, 0xC9A2, 0xC9A5, 0xC9A9, 0xC9B1, 0xC9B3, 0xC9B5, + 0xC9B7, 0xC9BC, 0xC9C1, 0xC9C5, 0xC9E1, 0xCA41, 0xCA45, 0xCA55, + 0xCA57, 0xCA61, 0xCA81, 0xCA82, 0xCA85, 0xCA89, 0xCA91, 0xCA93, + 0xCA95, 0xCA97, 0xCAA1, 0xCAB6, 0xCAC1, 0xCAE1, 0xCAE2, 0xCAE5, + 0xCAE9, 0xCAF1, 0xCAF3, 0xCAF7, 0xCB41, 0xCB45, 0xCB49, 0xCB51, + 0xCB57, 0xCB61, 0xCB62, 0xCB65, 0xCB68, 0xCB69, 0xCB6B, 0xCB71, + 0xCB73, 0xCB75, 0xCB81, 0xCB85, 0xCB89, 0xCB91, 0xCB93, 0xCBA1, + 0xCBA2, 0xCBA5, 0xCBA9, 0xCBB1, 0xCBB3, 0xCBB5, 0xCBB7, 0xCC61, + 0xCC62, 0xCC63, 0xCC65, 0xCC69, 0xCC6B, 0xCC71, 0xCC73, 0xCC75, + 0xCC76, 0xCC77, 0xCC7B, 0xCC81, 0xCC82, 0xCC85, 0xCC89, 0xCC91, + 0xCC93, 0xCC95, 0xCC96, 0xCC97, 0xCCA1, 0xCCA2, 0xCCE1, 0xCCE2, + 0xCCE5, 0xCCE9, 0xCCF1, 0xCCF3, 0xCCF5, 0xCCF6, 0xCCF7, 0xCD41, + 0xCD42, 0xCD45, 0xCD49, 0xCD51, 0xCD53, 0xCD55, 0xCD57, 0xCD61, + 0xCD65, 0xCD69, 0xCD71, 0xCD73, 0xCD76, 0xCD77, 0xCD81, 0xCD89, + 0xCD93, 0xCD95, 0xCDA1, 0xCDA2, 0xCDA5, 0xCDA9, 0xCDB1, 0xCDB3, + 0xCDB5, 0xCDB7, 0xCDC1, 0xCDD7, 0xCE41, 0xCE45, 0xCE61, 0xCE65, + 0xCE69, 0xCE73, 0xCE75, 0xCE81, 0xCE82, 0xCE85, 0xCE88, 0xCE89, + 0xCE8B, 0xCE91, 0xCE93, 0xCE95, 0xCE97, 0xCEA1, 0xCEB7, 0xCEE1, + 0xCEE5, 0xCEE9, 0xCEF1, 0xCEF5, 0xCF41, 0xCF45, 0xCF49, 0xCF51, + 0xCF55, 0xCF57, 0xCF61, 0xCF65, 0xCF69, 0xCF71, 0xCF73, 0xCF75, + 0xCFA1, 0xCFA2, 0xCFA5, 0xCFA9, 0xCFB1, 0xCFB3, 0xCFB5, 0xCFB7, + 0xD061, 0xD062, 0xD065, 0xD069, 0xD06E, 0xD071, 0xD073, 0xD075, + 0xD077, 0xD081, 0xD082, 0xD085, 0xD089, 0xD091, 0xD093, 0xD095, + 0xD096, 0xD097, 0xD0A1, 0xD0B7, 0xD0E1, 0xD0E2, 0xD0E5, 0xD0E9, + 0xD0EB, 0xD0F1, 0xD0F3, 0xD0F5, 0xD0F7, 0xD141, 0xD142, 0xD145, + 0xD149, 0xD151, 0xD153, 0xD155, 0xD157, 0xD161, 0xD162, 0xD165, + 0xD169, 0xD171, 0xD173, 0xD175, 0xD176, 0xD177, 0xD181, 0xD185, + 0xD189, 0xD193, 0xD1A1, 0xD1A2, 0xD1A5, 0xD1A9, 0xD1AE, 0xD1B1, + 0xD1B3, 0xD1B5, 0xD1B7, 0xD1BB, 0xD1C1, 0xD1C2, 0xD1C5, 0xD1C9, + 0xD1D5, 0xD1D7, 0xD1E1, 0xD1E2, 0xD1E5, 0xD1F5, 0xD1F7, 0xD241, + 0xD242, 0xD245, 0xD249, 0xD253, 0xD255, 0xD257, 0xD261, 0xD265, + 0xD269, 0xD273, 0xD275, 0xD281, 0xD282, 0xD285, 0xD289, 0xD28E, + 0xD291, 0xD295, 0xD297, 0xD2A1, 0xD2A5, 0xD2A9, 0xD2B1, 0xD2B7, + 0xD2C1, 0xD2C2, 0xD2C5, 0xD2C9, 0xD2D7, 0xD2E1, 0xD2E2, 0xD2E5, + 0xD2E9, 0xD2F1, 0xD2F3, 0xD2F5, 0xD2F7, 0xD341, 0xD342, 0xD345, + 0xD349, 0xD351, 0xD355, 0xD357, 0xD361, 0xD362, 0xD365, 0xD367, + 0xD368, 0xD369, 0xD36A, 0xD371, 0xD373, 0xD375, 0xD377, 0xD37B, + 0xD381, 0xD385, 0xD389, 0xD391, 0xD393, 0xD397, 0xD3A1, 0xD3A2, + 0xD3A5, 0xD3A9, 0xD3B1, 0xD3B3, 0xD3B5, 0xD3B7 +}; + +/** + * ks symbols + */ +static unsigned tblhhtg_ks[] = +{ + 0xC7D1, 0xB1DB, 0xB0FA, 0xC4C4, 0xC7BB, 0xC5CD, noneks, noneks, + 0xA2B1, 0xA3DF, 0xA2D5, 0xA6B1, 0xA1B8, 0xA1B9, 0xA3DF, 0xA1DA, + 0xA2C6, 0xA2CC, 0xA2CB, noneks, noneks, 0xA6BE, 0xA6B9, 0xA6C1, + 0xA6C2, 0xA6B4, 0xA6AD, 0xA6AF, 0xA6B0, 0xA6C3, 0xA6C4, noneks, + 0xA6AE, 0xA6B0, 0xA2D7, 0xA1E1, 0xA1D6, noneks, 0xA6BC, 0xA6B7, + 0xA6B1, 0xA6AE, 0xA6B5, 0xA6B3, 0xA6B2, 0xA6AC, 0xA6B6, 0xA6BA, + 0xA6BF, 0xA6B8, 0xA6BD, 0xA6C5, 0xA6C6, 0xA6C8, 0xA6C7, 0xA6C0, + 0xA6BB, noneks, noneks, noneks, 0xA1E1, 0xA1E1, 0xA1E1, 0xA1E1 +}; + +/** + * kssm symbols + */ +static unsigned hhtg_tg[] = +{ + 0xD065, 0x8B69, 0x89C1, 0xC4F1, 0xCF41, 0xC8E1, 0xD3C5, 0xD931, + 0xD931, 0xD481, 0xD482, 0xD488, 0xD48A, 0xD48F, 0xD493, 0xD494, + 0xD4B0, 0xD4B1, 0xD4B2, 0xD931, 0xD931, 0xD4B5, 0xD4B6, 0xD4B7, + 0xD4B8, 0xD4B9, 0xD4BA, 0xD4BB, 0xD4BC, 0xD4BD, 0xD4BE, 0xD496, + 0xD497, 0xD49C, 0xD4A9, 0xD4AF, 0xD4F4, 0xD4F5, 0xD4C6, 0xD4C7, + 0xD4C8, 0xD4C9, 0xD4CA, 0xD4CB, 0xD4CC, 0xD4CD, 0xD4CE, 0xD4CF, + 0xD4D0, 0xD4D1, 0xD4D2, 0xD4D3, 0xD4D4, 0xD4D5, 0xD4D6, 0xD4D7, + 0xD4D8, 0xD4F7, 0xD4FA, 0xD4FE, 0xD4DC, 0xD4DD, 0xD4DE, 0xD4DF +}; + +#define LINEBASE 0x3013 + +// ? +static char LineCharDir(hchar ch) +{ + static char index2dir[] = { 10, 11, 9, 14, 15, 13, 6, 7, 5, 3, 12 }; + + return (LINEBASE <= ch && ch < LINEBASE + 11 * 7) ? + index2dir[(ch - LINEBASE) % 11] : 0; +} + + +/** + * Convert hwp's special character to ks + */ +static hchar s_hh2ks(hchar hh) +{ + hchar i, idx = hh >> 8; + + if (hh == 0x81 || hh == 0x82) + return '\"'; + else if (hh == 0x83 || hh == 0x84) + return '\''; + if (idx == 0x1F) + { + idx = 170; + i = hh & 0xff; + if (i >= 0x60) + { + idx++; + i -= 0x60; + } + return (idx << 8) | (i + 160); + } + if ((idx == 0x1F && (hh & 0xff) >= 0xC0) || (hh == 0x1F00)) + return 0; + if (idx < 0x34 || idx >= 0x38) + return 0x2020; + if (hh >= HCA_TG) + { + return sal::static_int_cast((tblhhtg_ks[hh - HCA_TG])); + } + hh -= HCA_KSS; + idx = hh / 0x60 + 161; + i = hh % 0x60 + 160; + if (idx == 170) + idx += 2; + return (idx << 8) | i; +} + + +/** + * Convert hwp's special character to kssm + */ +static hchar s_hh2kssm(hchar hh) +{ + hchar i, idx = hh >> 8; + + if ((idx < 0x34 || idx >= 0x38) && idx != 0x1F) + return 0; + if (hh >= HCA_TG) + return sal::static_int_cast((hhtg_tg[hh - HCA_TG])); + if (idx == 0x1F) + hh = hh - 0x1F00 + 0x360; + else + { + hh -= HCA_KSS; + if (hh >= 0x360) + hh += 0xC0; + } + idx = hh / 0xC0 + 217; + i = hh % 0xC0; + if (i >= 95) + i -= 2; + i += 48; + if (i >= 127) + i += 18; + return (idx << 8) | i; +} + + +static hchar lineCharConv(hchar ch) +{ + int flag; + + switch (ch) + { + case 0x3060 + '\'' - 31: + case 0x3060 + '\"' - 31: + ch--; + + case 0x3060 + '\'' - 32: + case 0x3060 + '\"' - 32: + case 0x3060 + '{' - 32: + case 0x3060 + '[' - 32: + case 0x3060 + ']' - 32: + case 0x3060 + '}' - 32: + return ch - (0x3060 - 32); + } + flag = LineCharDir(ch); + switch (flag) + { + case 3: + return '-'; + case 12: + return '|'; + default: + return '+'; + } +} + + +static int KsSearch(hchar c) +{ + int lo, hi, mid; + hchar c2; + + lo = mid = 0; + hi = 2350 - 1; + + while (lo <= hi) + { + mid = (lo + hi) >> 1; + c2 = ksTbl[mid]; + if (c == c2) + break; + if (c < c2) + hi = mid - 1; + else + lo = mid + 1; + } + return mid; +} + + +static hchar cdkssm2ks_han(hchar kssm) +{ + unsigned int index; + unsigned char lo, hi; + +/* "" */ + if (kssm == 0xd3c5) + return 0xc7d1; + + index = KsSearch(kssm); + if (kssm != ksTbl[index]) + return jaso2ks(kssm); + hi = sal::static_int_cast(index / (0xFE - 0xA1 + 1) + 0xB0); + lo = sal::static_int_cast(index % (0xFE - 0xA1 + 1) + 0xA1); + return lo | (hi << 8); +} + + +#define IsHangul(c) ((c) & 0x8000) +#define IsHanja(c) (((c) & 0x4000)==0x4000) +#define IsJapan(c) (((c) > 0x1f00 && (c) < 0x1fb7)) + +static const hchar jaso_hh_code[] = +{ + 34881, 35905, 33860, 36929, 33862, 33863, 37953, 38977, 40001, 33866, + 33867, + 33868, 33869, 33870, 33871, 33872, 41025, 42049, 43073, 33876, 44097, + 45121, + 46145, 47169, 48193, 49217, 50241, 51265, 52289, 53313, 33889, 33921, + 33953, + 33985, 34017, 34113, 34145, 34177, 34209, 34241, 34273, 34369, 34401, + 34433, + 34465, 34497, 34529, 34625, 34657, 34689, 34721 +}; + +/* os: unused +static int is_jaso(hchar hh) +{ + unsigned int i; + + for (i = 0; i < SAL_N_ELEMENTS(jaso_hh_code); i++) + if (hh == jaso_hh_code[i]) + return 1; + return 0; +}*/ + + +static hchar jaso2ks(hchar hh) +{ + unsigned int i; + + for (i = 0; i < SAL_N_ELEMENTS(jaso_hh_code); i++) + if (hh == jaso_hh_code[i]) + { + return sal::static_int_cast(0xa4a1 + i); + } + return 0; +} + + +//1 00011 00 001 00011 +static hchar choseong_to_unicode[] = +{ + 0x111e, 0, 0x1100, 0x1101, 0x1102, 0x1103, 0x1104, 0x1105, + 0x1106, 0x1107, 0x1108, 0x1109, 0x110a, 0x110b, 0x110c, 0x110d, + 0x110e, 0x110f, 0x1110, 0x1111, 0x1112, 0x1120, 0x1121, 0x1127, + 0x112b, 0x112d, 0x112f, 0x1132, 0x1136, 0x1140, 0x114c, 0x1158 +}; +/* ߼ 0 1 ٸ ڵ  ִ. ̺κп Ģ ̾ƶ. */ +static hchar joongseong_to_unicode[] = +{ + 0, 0, 0, 0x1161, 0x1162, 0x1163, 0x1164, 0x1165, + 0, 0, 0x1166, 0x1167, 0x1168, 0x1169, 0x116a, 0x116b, + 0, 0x1188, 0x116c, 0x116d, 0x116e, 0x116f, 0x1170, 0x1171, + 0x1191, 0x1194, 0x1172, 0x1173, 0x1174, 0x1175, 0x119e, 0x11a1 +}; + +static hchar jongseong_to_unicode[] = +{ + 0x11d9, 0 , 0x11a8, 0x11a9, 0x11aa, 0x11ab, 0x11ac, 0x11ad, + 0x11ae, 0x11af, 0x11b0, 0x11b1, 0x11b2, 0x11b3, 0x11b4, 0x11b5, + 0x11b6, 0x11b7, 0x11e6, 0x11b8, 0x11b9, 0x11ba, 0x11bb, 0x11bc, + 0x11bd, 0x11be, 0x11bf, 0x11c0, 0x11c1, 0x11c2, 0x11eb, 0x11f0 +}; + +/* ߼ 0 1ΰ */ +/* ó 32 ڸ, 32 . + * 0x8000 ~ 0xa413 32 , 0x0400 0x8400 ٽ 32 ȴ. + * ڸ𿵿 Ϲ ̺ ü ̺ . + */ +/* 308.. 1152 308 844 ڸ̴. */ +static hchar jamo_to_unicode[] = +{ + 0x3131, 0x3132, 0x3133, 0x3134, 0x3135, 0x3136, 0x3137, 0x3138, + 0x3139, 0x313a, 0x313b, 0x313c, 0x313d, 0x313e, 0x313f, 0x3140, + 0x3141, 0x3142, 0x3143, 0x3144, 0x3145, 0x3146, 0x3147, 0x3148, + 0x3149, 0x314a, 0x314b, 0x314c, 0x314d, 0x314e, 0x3172, 0x3173, + + 0x3176, 0x317a, 0x317c, 0x317d, 0x317e, 0x3185, 0x3178, 0x317f, + 0x3181, 0x316d, 0x11c3, 0x11c4, 0x1113, 0x1114, 0x1115, 0x1116, + 0x11c7, 0x11c8, 0x11c9, 0x11ca, 0x11cb, 0x11cc, 0x11cd, 0x11ce, + 0x11cf, 0x11d0, 0x11d1, 0x11d2, 0x11d3, 0x11d4, 0x11d5, 0x11d6, + + 0x11d7, 0x11d8, 0x111b, 0x11da, 0x11db, 0x11dc, 0x11dd, 0x11de, + 0x11df, 0x11e0, 0x11e1, 0x11e2, 0x111f, 0x11e3, 0x1122, 0x1123, + 0x1124, 0x1125, 0x1126, 0x1128, 0x1129, 0x112a, 0x11e5, 0x112c, + 0x112e, 0x1130, 0x1131, 0x1133, 0x1134, 0x1135, 0x1137, 0x1138, + + 0x1139, 0x113a, 0x113b, 0x113c, 0x113d, 0x113e, 0x113f, 0x1141, + 0x11ed, 0x1142, 0x1143, 0x1144, 0x1145, 0x1146, 0x1147, 0x1148, + 0x1149, 0x11ef, 0x114a, 0x114b, 0x11f1, 0x11f2, 0x114d, 0x114e, + 0x114f, 0x1150, 0x1151, 0x1152, 0x1153, 0x1154, 0x1155, 0x1156, + + 0x1157, 0x11f5, 0x11f6, 0x11f7, 0x11f8, 0x11f9, 0x1176, 0x1177, + 0x1178, 0x1179, 0x117a, 0x117b, 0x117c, 0x117d, 0x117e, 0x117f, + 0x1180, 0x1181, 0x1182, 0x1183, 0x1184, 0x1185, 0x1186, 0x1187, + 0x1189, 0x118a, 0x118b, 0x118c, 0x118d, 0x118e, 0x118f, 0x1190, + + 0x1192, 0x1193, 0x1195, 0x1196, 0x1197, 0x1198, 0x1199, 0x119a, + 0x119b, 0x119c, 0x119d, 0x119f, 0x11a0, 0x11a2, 0x11a8, 0x11a9, + 0x11aa, 0x11ab, 0x11ac, 0x11ad, 0x11ae, 0x1104, 0x11af, 0x11b0, + 0x11b1, 0x11b2, 0x11b3, 0x11b4, 0x11b5, 0x11b6, 0x11b7, 0x11b8, + + 0x1108, 0x11b9, 0x11ba, 0x11bb, 0x11bc, 0x11bd, 0x3149, 0x11be, + 0x11bf, 0x11c0, 0x11c1, 0x11c2, 0x111e, 0x1120, 0x1127, 0x11e7, + 0x11e8, 0x11ea, 0x1136, 0x1158, 0x11e6, 0x11eb, 0x11f0, 0x11d9, + 0x11c3, 0x11c4, 0x11c5, 0x1114, 0x11c6, 0x1116, 0x11c7, 0x11c8, + + 0x11c9, 0x11ca, 0x11cb, 0x3169, 0x11cd, 0x11ce, 0x11cf, 0x1119, + 0x11d1, 0x11d2, 0x11d3, 0x11d4, 0x11d5, 0x11d6, 0x11d7, 0x11d8, + 0x111b, 0x11da, 0x11db, 0x11dc, 0x11dd, 0x11de, 0x11df, 0x11e0, + 0x11e1, 0x11e2, 0x111f, 0x11e3, 0x1122, 0x1123, 0x1124, 0x1125, + + 0x1126, 0x1128, 0x1129, 0x11e4, 0x11e5, 0x112c, 0x112e, 0x1130, + 0x1131, 0x1133, 0x1134, 0x1135, 0x1137, 0x1138, 0x1139, 0x113a, + 0x113b, 0x113c, 0x113d, 0x113e, 0x113f, 0x11ec, 0x11ed, 0x1142, + 0x1143, 0x1144, 0x1145, 0x1146, 0x1147, 0x1148, 0x1149, 0x11ef, + + 0x114a, 0x114b, 0x11f1, 0x11f2, 0x114d, 0x114e, 0x114f, 0x1150, + 0x1151, 0x1152, 0x1153, 0x1154, 0x1155, 0x1156, 0x1157, 0x11f5, + 0x11f6, 0x11f7, 0x11f8, 0x11f9 +}; + +struct JamoComp{ + int size; + hchar v1; + hchar v2; + hchar v3; +}; +/* 704 + 12 = 706 */ +static JamoComp jamocomp1_to_unicode[] = +{ + {3, 0x1100, 0x1161, 0x11e7}, {3, 0x1100, 0x1161, 0x3167}, + {3, 0x1100, 0x1161, 0x11dd}, {3, 0x1100, 0x1161, 0x11e2}, + {3, 0x1100, 0x1161, 0x11e5}, {3, 0x1100, 0x1161, 0x11f1}, + {3, 0x1100, 0x1163, 0x11e2}, {3, 0x1100, 0x1163, 0x11f9}, + {3, 0x1100, 0x1165, 0x11e7}, {3, 0x1100, 0x1165, 0x11c7}, + {3, 0x1100, 0x1165, 0x11dd}, {3, 0x1100, 0x1165, 0x11e2}, + + {3, 0x1100, 0x1165, 0x11e3}, {3, 0x1100, 0x1167, 0x11e7}, + {3, 0x1100, 0x1167, 0x11f1}, {3, 0x1100, 0x1167, 0x11f9}, + {3, 0x1100, 0x1169, 0x11d6}, {3, 0x1100, 0x1169, 0x11dd}, + {3, 0x1100, 0x1169, 0x11e2}, {3, 0x1100, 0x1169, 0x11f1}, + {3, 0x1100, 0x1169, 0x11f7}, {3, 0x1100, 0x1169, 0x11f8}, + {3, 0x1100, 0x116a, 0x11f9}, {3, 0x1100, 0x116d, 0x11e2}, + {3, 0x1100, 0x116e, 0x11c7}, {3, 0x1100, 0x116e, 0x11cd}, + {3, 0x1100, 0x116e, 0x11da}, {3, 0x1100, 0x116e, 0x11dd}, + + {3, 0x1100, 0x116e, 0x11e2}, {3, 0x1100, 0x116e, 0x11f6}, + {3, 0x1100, 0x116e, 0x11f9}, {3, 0x1100, 0x116f, 0x11c7}, + {3, 0x1100, 0x116f, 0x11f9}, {3, 0x1100, 0x1172, 0x11e2}, + {3, 0x1100, 0x1172, 0x11f9}, {3, 0x1100, 0x1173, 0x11c7}, + {3, 0x1100, 0x1173, 0x11dd}, {3, 0x1100, 0x1173, 0x11df}, + {3, 0x1100, 0x1173, 0x11e2}, {3, 0x1100, 0x1173, 0x11f9}, + {3, 0x1100, 0x1174, 0x11f9}, {3, 0x1100, 0x1175, 0x11e7}, + {3, 0x1100, 0x1175, 0x11cd}, {3, 0x1100, 0x1175, 0x11e2}, + + {3, 0x1100, 0x1175, 0x11f9}, {3, 0x1100, 0x1191, 0x11f9}, + {3, 0x1100, 0x119e, 0x11e7}, {3, 0x1100, 0x119e, 0x11d3}, + {3, 0x1100, 0x119e, 0x11d5}, {3, 0x1100, 0x119e, 0x11e3}, + {3, 0x1100, 0x11a1, 0x11f1}, {2, 0x1100, 0x1176, 0x0000}, + {2, 0x1100, 0x1178, 0x0000}, {2, 0x1100, 0x117c, 0x0000}, + {3, 0x1100, 0x117c, 0x11ab}, {3, 0x1100, 0x117c, 0x11af}, + {3, 0x1100, 0x117c, 0x11b7}, {2, 0x1100, 0x1189, 0x0000}, + {3, 0x1100, 0x1189, 0x11ab}, {3, 0x1100, 0x1189, 0x11bc}, + + {2, 0x1100, 0x118b, 0x0000}, {3, 0x1100, 0x118b, 0x11ab}, + {2, 0x1100, 0x118c, 0x0000}, {2, 0x1100, 0x118d, 0x0000}, + {2, 0x1100, 0x1192, 0x0000}, {3, 0x1100, 0x1192, 0x11bc}, + {2, 0x1100, 0x1195, 0x0000}, {2, 0x1100, 0x1196, 0x0000}, + {2, 0x1100, 0x1198, 0x0000}, {2, 0x1100, 0x119b, 0x0000}, + {2, 0x1100, 0x119c, 0x0000}, {2, 0x1100, 0x119d, 0x0000}, + {2, 0x1100, 0x119f, 0x0000}, {3, 0x1100, 0x119f, 0x11bc}, + {3, 0x1101, 0x1163, 0x11e2}, {3, 0x1101, 0x1165, 0x11ec}, + + {3, 0x1101, 0x1165, 0x11ed}, {3, 0x1101, 0x116e, 0x11e2}, + {3, 0x1101, 0x1172, 0x11e2}, {3, 0x1101, 0x1175, 0x11e2}, + {3, 0x1101, 0x1175, 0x11f9}, {3, 0x1101, 0x1191, 0x11bc}, + {2, 0x1101, 0x1176, 0x0000}, {2, 0x1101, 0x117b, 0x0000}, + {2, 0x1101, 0x1189, 0x0000}, {2, 0x1101, 0x118c, 0x0000}, + {2, 0x1101, 0x1198, 0x0000}, {3, 0x1102, 0x1161, 0x11e7}, + {3, 0x1102, 0x1161, 0x11c4}, {3, 0x1102, 0x1161, 0x11da}, + {3, 0x1102, 0x1161, 0x11dd}, {3, 0x1102, 0x1161, 0x11e2}, + + {3, 0x1102, 0x1161, 0x11f9}, {3, 0x1102, 0x1165, 0x11db}, + {3, 0x1102, 0x1165, 0x11dd}, {3, 0x1102, 0x1165, 0x11e3}, + {3, 0x1102, 0x1167, 0x11c5}, {3, 0x1102, 0x1167, 0x11c7}, + {3, 0x1102, 0x1167, 0x11f9}, {3, 0x1102, 0x1169, 0x11e2}, + {3, 0x1102, 0x1169, 0x11e4}, {3, 0x1102, 0x1169, 0x11f3}, + {3, 0x1102, 0x116e, 0x11c6}, {3, 0x1102, 0x116e, 0x11c7}, + {3, 0x1102, 0x116e, 0x11c8}, {3, 0x1102, 0x116e, 0x11dd}, + {3, 0x1102, 0x116e, 0x11e2}, {3, 0x1102, 0x116e, 0x11f5}, + + {3, 0x1102, 0x1172, 0x11e2}, {3, 0x1102, 0x1173, 0x11c3}, + {3, 0x1102, 0x1175, 0x11c3}, {3, 0x1102, 0x1175, 0x11dd}, + {3, 0x1102, 0x1175, 0x11e2}, {3, 0x1102, 0x119e, 0x11d7}, + {2, 0x1102, 0x1176, 0x0000}, {2, 0x1102, 0x117c, 0x0000}, + {3, 0x1102, 0x117c, 0x11a8}, {2, 0x1102, 0x118c, 0x0000}, + {2, 0x1102, 0x1196, 0x0000}, {2, 0x1102, 0x1197, 0x0000}, + {2, 0x1102, 0x1198, 0x0000}, {2, 0x1102, 0x119b, 0x0000}, + {3, 0x1103, 0x1161, 0x11e7}, {3, 0x1103, 0x1161, 0x11c7}, + + {3, 0x1103, 0x1161, 0x1119}, {3, 0x1103, 0x1161, 0x11db}, + {3, 0x1103, 0x1161, 0x11dd}, {3, 0x1103, 0x1161, 0x11e2}, + {3, 0x1103, 0x1161, 0x11f1}, {3, 0x1103, 0x1161, 0x11f9}, + {3, 0x1103, 0x1163, 0x11e2}, {3, 0x1103, 0x1163, 0x11f1}, + {3, 0x1103, 0x1165, 0x11dd}, {3, 0x1103, 0x1167, 0x11f9}, + {3, 0x1103, 0x1169, 0x11e7}, {3, 0x1103, 0x1169, 0x11d6}, + {3, 0x1103, 0x1169, 0x11e2}, {3, 0x1103, 0x1169, 0x11f1}, + {3, 0x1103, 0x116d, 0x11e2}, {3, 0x1103, 0x116e, 0x11ce}, + + {3, 0x1103, 0x116e, 0x1119}, {3, 0x1103, 0x116e, 0x11da}, + {3, 0x1103, 0x116e, 0x11e2}, {3, 0x1103, 0x1172, 0x11e2}, + {3, 0x1103, 0x1173, 0x11cd}, {3, 0x1103, 0x1173, 0x11ce}, + {3, 0x1103, 0x1173, 0x11e2}, {3, 0x1103, 0x1173, 0x11e3}, + {3, 0x1103, 0x1173, 0x11f1}, {3, 0x1103, 0x1174, 0x11f9}, + {3, 0x1103, 0x1175, 0x11f9}, {3, 0x1103, 0x119e, 0x11e7}, + {3, 0x1103, 0x119e, 0x11e8}, {3, 0x1103, 0x119e, 0x11ea}, + {3, 0x1103, 0x119e, 0x11c3}, {3, 0x1103, 0x119e, 0x11cc}, + + {3, 0x1103, 0x119e, 0x11e3}, {3, 0x1103, 0x119e, 0x11e9}, + {2, 0x1103, 0x1176, 0x0000}, {2, 0x1103, 0x1178, 0x0000}, + {2, 0x1103, 0x117c, 0x0000}, {3, 0x1103, 0x117c, 0x11b7}, + {2, 0x1103, 0x1189, 0x0000}, {3, 0x1103, 0x1189, 0x11ab}, + {2, 0x1103, 0x118c, 0x0000}, {2, 0x1103, 0x1195, 0x0000}, + {2, 0x1103, 0x1196, 0x0000}, {2, 0x1103, 0x1198, 0x0000}, + {2, 0x1103, 0x1199, 0x0000}, {3, 0x1103, 0x1199, 0x11ab}, + {3, 0x1103, 0x1199, 0x11bc}, {3, 0x1104, 0x1161, 0x11d8}, + + {3, 0x1104, 0x1161, 0x11e2}, {3, 0x1104, 0x1161, 0x11f9}, + {3, 0x1104, 0x1163, 0x11e2}, {3, 0x1104, 0x1169, 0x11e2}, + {3, 0x1104, 0x1169, 0x11f9}, {3, 0x1104, 0x116d, 0x11e2}, + {3, 0x1104, 0x116e, 0x11e2}, {3, 0x1104, 0x116e, 0x11f9}, + {3, 0x1104, 0x1172, 0x11e2}, {3, 0x1104, 0x1173, 0x11e2}, + {3, 0x1104, 0x1175, 0x11f9}, {2, 0x1104, 0x117b, 0x0000}, + {2, 0x1104, 0x118c, 0x0000}, {2, 0x1104, 0x1198, 0x0000}, + {3, 0x1105, 0x1161, 0x11e7}, {3, 0x1105, 0x1161, 0x11dd}, + + {3, 0x1105, 0x1161, 0x11e2}, {3, 0x1105, 0x1161, 0x11f5}, + {3, 0x1105, 0x1161, 0x11f9}, {3, 0x1105, 0x1163, 0x11e2}, + {3, 0x1105, 0x1167, 0x11c7}, {3, 0x1105, 0x1167, 0x11e2}, + {3, 0x1105, 0x1167, 0x11f9}, {3, 0x1105, 0x1169, 0x11dd}, + {3, 0x1105, 0x1169, 0x11e2}, {3, 0x1105, 0x1169, 0x11f1}, + {3, 0x1105, 0x116d, 0x11dd}, {3, 0x1105, 0x116d, 0x11e2}, + {3, 0x1105, 0x116e, 0x11dd}, {3, 0x1105, 0x116e, 0x11e2}, + {3, 0x1105, 0x1172, 0x11e2}, {3, 0x1105, 0x1173, 0x11dd}, + + {3, 0x1105, 0x1173, 0x11e2}, {3, 0x1105, 0x1175, 0x11dd}, + {3, 0x1105, 0x1175, 0x11e2}, {3, 0x1105, 0x1175, 0x11f9}, + {3, 0x1105, 0x119e, 0x11d7}, {3, 0x1105, 0x119e, 0x11dc}, + {3, 0x1105, 0x119e, 0x11dd}, {2, 0x1105, 0x1176, 0x0000}, + +/* -- ȹٲ , 3 2 ٲپ ־ . */ + {2, 0x1105, 0x1178, 0x0000}, {2, 0x1105, 0x117a, 0x0000}, + {2, 0x1105, 0x117b, 0x0000}, {2, 0x1105, 0x1186, 0x0000}, + {2, 0x1105, 0x1187, 0x0000}, {2, 0x1105, 0x118c, 0x0000}, + {2, 0x1105, 0x1195, 0x0000}, {2, 0x1105, 0x1196, 0x0000}, + + {2, 0x1105, 0x1198, 0x0000}, {2, 0x1105, 0x1199, 0x0000}, + {3, 0x1105, 0x1199, 0x11bc}, {2, 0x1105, 0x119b, 0x0000}, + {2, 0x111a, 0x1163, 0x0000}, {3, 0x111a, 0x1163, 0x11bc}, + {3, 0x1106, 0x1161, 0x11e8}, {3, 0x1106, 0x1161, 0x11c7}, + {3, 0x1106, 0x1161, 0x11cd}, {3, 0x1106, 0x1161, 0x1119}, + {3, 0x1106, 0x1161, 0x11d8}, {3, 0x1106, 0x1161, 0x11e2}, + {3, 0x1106, 0x1163, 0x11e2}, {3, 0x1106, 0x1165, 0x11c6}, + {3, 0x1106, 0x1165, 0x11f9}, {3, 0x1106, 0x1169, 0x11c6}, + + {3, 0x1106, 0x1169, 0x11dd}, {3, 0x1106, 0x1169, 0x11e2}, + {3, 0x1106, 0x116d, 0x11e2}, {3, 0x1106, 0x116e, 0x11e7}, + {3, 0x1106, 0x116e, 0x11c7}, {3, 0x1106, 0x116e, 0x11e2}, + {3, 0x1106, 0x116e, 0x11ec}, {3, 0x1106, 0x116e, 0x11ed}, + {3, 0x1106, 0x116e, 0x11f9}, {3, 0x1106, 0x116f, 0x11f9}, + {3, 0x1106, 0x1173, 0x11e7}, {3, 0x1106, 0x1174, 0x11f9}, + {3, 0x1106, 0x1175, 0x11e7}, {3, 0x1106, 0x1175, 0x11f6}, + {3, 0x1106, 0x1175, 0x11f9}, {3, 0x1106, 0x119e, 0x11c3}, + + {2, 0x1106, 0x1176, 0x0000}, {2, 0x1106, 0x1178, 0x0000}, + {2, 0x1106, 0x117c, 0x0000}, {3, 0x1106, 0x117c, 0x11af}, + {2, 0x1106, 0x1182, 0x0000}, {2, 0x1106, 0x1183, 0x0000}, + {2, 0x1106, 0x118c, 0x0000}, {2, 0x1106, 0x1196, 0x0000}, + {3, 0x1106, 0x1196, 0x11b7}, {2, 0x1106, 0x1198, 0x0000}, + {2, 0x1106, 0x119f, 0x0000}, {3, 0x1106, 0x119f, 0x11ab}, + {3, 0x1106, 0x119f, 0x11bc}, {3, 0x1107, 0x1161, 0x11e7}, + {3, 0x1107, 0x1161, 0x11c9}, {3, 0x1107, 0x1161, 0x11dd}, + + {3, 0x1107, 0x1161, 0x11e2}, {3, 0x1107, 0x1161, 0x11e3}, + {3, 0x1107, 0x1161, 0x11f1}, {3, 0x1107, 0x1161, 0x11f6}, + {3, 0x1107, 0x1161, 0x11f9}, {3, 0x1107, 0x1165, 0x11c7}, + {3, 0x1107, 0x1167, 0x11f1}, {3, 0x1107, 0x1169, 0x11e7}, + {3, 0x1107, 0x1169, 0x11dd}, {3, 0x1107, 0x1169, 0x11e2}, + {3, 0x1107, 0x116d, 0x11e2}, {3, 0x1107, 0x116e, 0x11e7}, + {3, 0x1107, 0x116e, 0x11c7}, {3, 0x1107, 0x116e, 0x1119}, + {3, 0x1107, 0x116e, 0x11d1}, {3, 0x1107, 0x116e, 0x11d2}, + + {3, 0x1107, 0x116e, 0x11e2}, {3, 0x1107, 0x116e, 0x11ef}, + {3, 0x1107, 0x116e, 0x11f9}, {3, 0x1107, 0x116f, 0x11f9}, + {3, 0x1107, 0x1173, 0x11e7}, {3, 0x1107, 0x1173, 0x11c3}, + {3, 0x1107, 0x1175, 0x11e7}, {3, 0x1107, 0x1175, 0x11e2}, + {3, 0x1107, 0x1175, 0x11f1}, {3, 0x1107, 0x1175, 0x11f9}, + {3, 0x1107, 0x119e, 0x11c3}, {3, 0x1107, 0x119e, 0x11d5}, + {3, 0x1107, 0x119e, 0x11e3}, {3, 0x1107, 0x11a1, 0x11f1}, + {2, 0x1107, 0x1176, 0x0000}, {2, 0x1107, 0x1177, 0x0000}, + + {2, 0x1107, 0x1178, 0x0000}, {2, 0x1107, 0x117c, 0x0000}, + {3, 0x1107, 0x117c, 0x11a8}, {3, 0x1107, 0x117c, 0x11af}, + {3, 0x1107, 0x117c, 0x11b7}, {3, 0x1107, 0x117c, 0x11bc}, + {2, 0x1107, 0x1182, 0x0000}, {2, 0x1107, 0x118c, 0x0000}, + {2, 0x1107, 0x1196, 0x0000}, {2, 0x1107, 0x1198, 0x0000}, + {2, 0x1107, 0x119a, 0x0000}, {2, 0x1107, 0x119f, 0x0000}, + {3, 0x1107, 0x119f, 0x11ab}, {3, 0x1107, 0x119f, 0x11bc}, + {3, 0x1108, 0x1161, 0x11e2}, {3, 0x1108, 0x1167, 0x11f9}, + + {3, 0x1108, 0x1169, 0x11e2}, {3, 0x1108, 0x116e, 0x11e2}, + {3, 0x1108, 0x1174, 0x11f9}, {3, 0x1108, 0x1175, 0x11f9}, + {3, 0x1121, 0x116a, 0x11f9}, {3, 0x1121, 0x119e, 0x114d}, + {2, 0x1121, 0x118c, 0x0000}, {2, 0x1121, 0x1198, 0x0000}, + {3, 0x1109, 0x1161, 0x11ca}, {3, 0x1109, 0x1161, 0x11dd}, + {3, 0x1109, 0x1161, 0x11e2}, {3, 0x1109, 0x1161, 0x11f1}, + {3, 0x1109, 0x1161, 0x11f9}, {3, 0x1109, 0x1163, 0x11e2}, + {3, 0x1109, 0x1163, 0x11f1}, {3, 0x1109, 0x1165, 0x11e7}, + + {3, 0x1109, 0x1165, 0x11c3}, {3, 0x1109, 0x1165, 0x11ec}, + {3, 0x1109, 0x1165, 0x11ed}, {3, 0x1109, 0x1167, 0x11e7}, + {3, 0x1109, 0x1167, 0x11d5}, {3, 0x1109, 0x1167, 0x11dd}, + {3, 0x1109, 0x1167, 0x11e3}, {3, 0x1109, 0x1167, 0x11f1}, + {3, 0x1109, 0x1167, 0x11f9}, {3, 0x1109, 0x1169, 0x11c7}, + {3, 0x1109, 0x1169, 0x11e2}, {3, 0x1109, 0x116a, 0x11f9}, + {3, 0x1109, 0x116b, 0x11f9}, {3, 0x1109, 0x116d, 0x11e2}, + {3, 0x1109, 0x116d, 0x11f1}, {3, 0x1109, 0x116e, 0x11e7}, + + {3, 0x1109, 0x116e, 0x11e2}, {3, 0x1109, 0x116e, 0x11f9}, + {3, 0x1109, 0x1172, 0x11e2}, {3, 0x1109, 0x1173, 0x11e2}, + {3, 0x1109, 0x1173, 0x11e3}, {3, 0x1109, 0x1173, 0x11f1}, + {3, 0x1109, 0x1174, 0x11f9}, {3, 0x1109, 0x1175, 0x11c7}, + {3, 0x1109, 0x1175, 0x11ce}, {3, 0x1109, 0x1175, 0x11da}, + {3, 0x1109, 0x1175, 0x11e2}, {3, 0x1109, 0x1175, 0x11f9}, + {3, 0x1109, 0x1191, 0x11f9}, {3, 0x1109, 0x119e, 0x11ca}, + {3, 0x1109, 0x119e, 0x11d6}, {3, 0x1109, 0x119e, 0x11f1}, + + {3, 0x1109, 0x119e, 0x11e3}, {3, 0x1109, 0x11a1, 0x11dd}, + {3, 0x1109, 0x11a1, 0x11f1}, {2, 0x1109, 0x1176, 0x0000}, + {2, 0x1109, 0x1177, 0x0000}, {2, 0x1109, 0x1178, 0x0000}, + {2, 0x1109, 0x117c, 0x0000}, {3, 0x1109, 0x117c, 0x11a8}, + {3, 0x1109, 0x117c, 0x11af}, {3, 0x1109, 0x117c, 0x11b7}, + {3, 0x1109, 0x117c, 0x11bc}, {2, 0x1109, 0x117e, 0x0000}, + {2, 0x1109, 0x1189, 0x0000}, {3, 0x1109, 0x1189, 0x11ab}, + {2, 0x1109, 0x118c, 0x0000}, {2, 0x1109, 0x1190, 0x0000}, + + {2, 0x1109, 0x1192, 0x0000}, {3, 0x1109, 0x1192, 0x11bc} +}; + +//#define IS_OLD_HAN(x) (((x) >= 0x8020 && (x) <= 0x83ff ) || ( (x) >= 0x8420 && (x) <= 0x843f )) // beside these, there are very much characters in the hangul. +int hcharconv(hchar ch, hchar *dest, int codeType) +{ + unsigned char lo; + //printf("hcharconv[%04x]\n",ch); + if (ch < 128){ + dest[0] = ch; + return 1; + } + if (IsHangul(ch)) + { + hchar ch2 = ch; + if (codeType == KS) + ch = cdkssm2ks_han(ch); + else if( codeType == UNICODE ){ + if( ch2 == 0xd3c5 ){ + dest[0] = 0xd55c; + return 1 ; + } + int res = kssm_hangul_to_ucs2(ch, dest); + //printf("hcharconv Hangul[%04x]\n",dest[0]); + return res; + } + dest[0] = ch; + return 1; + } + /* ڴ 0x4000 4888 . */ + else if (IsHanja(ch)) + { + unsigned int index; + unsigned char hi; + /* 4888̿ Ʒѱۿ Ȯ̴. ̰Ϳ ؼ + ڵ峪 ϼڵ ȯ ̺ ̴. + */ + if ((index = ch - 0x4000) >= 4888) + { + if( codeType == UNICODE ) + dest[0]= 0x25A1; + else + dest[0]= 0xA1E0; + return 1; + } + if (codeType == KS) + { + /* ڵ ڵ ڵ ڵ 0xA1 - 0xFE . + ڵ忡 üִ 0xFE - 0xA1 +1 ̴. + */ + hi = sal::static_int_cast(index / (0xFE - 0xA1 + 1) + 0xCA); + lo = sal::static_int_cast(index % (0xFE - 0xA1 + 1) + 0xA1); + ch = (hi << 8) | lo; + } + else if(codeType == UNICODE){ + hi = sal::static_int_cast(index / (0xFE - 0xA1 + 1) + 0xCA); + lo = sal::static_int_cast(index % (0xFE - 0xA1 + 1) + 0xA1); + ch = (hi << 8) | lo; + ch = ksc5601_han_to_ucs2(ch); + } + else + { + hi = sal::static_int_cast(index / (0x100 - 0x31 - 0x11 - 2) + 0xE0); + lo = sal::static_int_cast(index % (0x100 - 0x31 - 0x11 - 2) + 0x31); + if (lo >= 0x7F) + lo += 0x12; + ch = (hi << 8) | lo; + } + //printf("hcharconv Hanja[%04x]\n",ch); + dest[0] = ch; + return 1; + } + if (LineCharDir(ch)) + { + dest[0] = lineCharConv(ch); + return 1; + } + else if (0x2f00 <= ch && ch <= 0x2f6f && (ch & 0x0f) < 9) + { +// bullet + lo = sal::static_int_cast(ch & 0x0f); + + if( codeType != KSSM ) + { + if (ch < 0x2f10) ch = 0xa1e0; + else if (ch < 0x2f20) ch = 0xa1db; + else if (ch < 0x2f30) ch = 0xa1de; + else if (ch < 0x2f40) ch = 0xa1e2; + else if (ch < 0x2f50) ch = 0xa1e4; + else if (ch < 0x2f60) ch = 0xa2b7; + else ch = 0xa2b9; + + ch = (lo < 6) ? ch : ch + 1; + if( codeType == UNICODE) + ch = ksc5601_sym_to_ucs2(ch); + } + else + { + if (ch < 0x2f10) ch = 0xd970; + else if (ch < 0x2f20) ch = 0xd96b; + else if (ch < 0x2f30) ch = 0xd96e; + else if (ch < 0x2f40) ch = 0xd972; + else if (ch < 0x2f50) ch = 0xd974; + else if (ch < 0x2f60) ch = 0xd9b7; + else ch = 0xd9b9; + ch = (lo < 6) ? ch : ch + 1; + } + //printf("hcharconv Bullet[%04x]\n",ch); + dest[0] = ch; + return 1 ; + } +/** + * Ư ڵ + * Ʒѱۿ 0x3400 Ưڰ ۵ȴ. 0xA1A0 + */ + else + { + if( codeType != KSSM ) + { + //printf("code[0x%04x]\n",ch); + hchar ch2 = ch; + ch = s_hh2ks(ch); + //printf("code ks[0x%04x]\n",ch); + if( codeType == UNICODE ){ + if (ch < 128){ + dest[0] = ch; + return 1; + } + /* ѱ۰ǻ : 0x37c0 ~ 0x37c5 */ + if( ch2 >= 0x37c0 && ch2 <= 0x37c5 ){ + if( ch2 == 0x37c0 ) dest[0] = 0xd55c; + else if( ch2 == 0x37c1 ) dest[0] = 0xae00; + else if( ch2 == 0x37c2 ) dest[0] = 0xacfc; + else if( ch2 == 0x37c3 ) dest[0] = 0xcef4; + else if( ch2 == 0x37c4 ) dest[0] = 0xd4e8; + else if( ch2 == 0x37c5 ) dest[0] = 0xd130; + return 1; + } + if( ch == 0x2020 ){ + switch( ch2 ){ + case 0x309b : + ch = 0xff62; + break; + case 0x309d : + ch = 0xff63; + break; + default: + ch = 0x25a1; + break; + } + } + else{ + ch = ksc5601_sym_to_ucs2(ch); + } + //printf("code ucs2[0x%04x]\n",ch); + } + } + else{ + ch = s_hh2kssm(ch); + } + + if (ch == 0){ // not '?', but square mark + if( codeType == UNICODE ) + dest[0] = 0x25A1; + else + dest[0] = 0xA1E0; + return 1; + } + //printf("hcharconv Special[%04x]\n",ch); + dest[0] = ch; + return 1; + } +} + +/* ѱ . */ +int kssm_hangul_to_ucs2(hchar ch, hchar *dest) +{ + hchar choseong, joongseong, jongseong; + + choseong = ((ch >> 10) & 0x1f); + joongseong = ((ch >> 5) & 0x1f); + jongseong = (ch & 0x1f) ; + + //printf("kssm_hangul_to_ucs2 : [%d,%d,%d]\n", choseong,joongseong,jongseong); + + if( joongseong < 2 ){ /* յ ߼=0,1 */ + if( joongseong == 0 && ch < 0xa414 ){ /* ڸ */ + int index = choseong * 32 + jongseong; + dest[0] = jamo_to_unicode[index]; + return 1; + } + else{ /* ڸ : ̺ ̿ϼ */ + unsigned int index = choseong * 32 + jongseong - 308; + if( index < SAL_N_ELEMENTS(jamocomp1_to_unicode) ){ + dest[0] = jamocomp1_to_unicode[index].v1; + dest[1] = jamocomp1_to_unicode[index].v2; + dest[2] = jamocomp1_to_unicode[index].v3; + return jamocomp1_to_unicode[index].size; + } + dest[0] = 0x25a1; // empty square. + return 1; + } + } + else if ( choseong == 1 && jongseong == 1 ){ /* */ + dest[0] = joongseong_to_unicode[joongseong]; + return 1; + } + else if ( joongseong == 2 && jongseong == 1 ){ /* */ + dest[0] = choseong_to_unicode[choseong]; + return 1; + } + else if( choseong > 20 || choseong == 0 || + joongseong == 17 || joongseong == 24 || + joongseong == 25 || joongseong > 29 || + jongseong == 0 || jongseong == 18 || + jongseong > 29 || + choseong == 1 || joongseong == 2 /* ϼ ѱ */ + ) { /* */ + int count = 0; + if( choseong != 1 ){ + dest[count] = choseong_to_unicode[choseong]; + count++; + } + if( joongseong > 2 ){ + dest[count] = joongseong_to_unicode[joongseong]; + count++; + } + if( jongseong != 1 ){ + dest[count] = jongseong_to_unicode[jongseong]; + count++; + } + return count; + } + + choseong -= 2; + if( joongseong < 0x8 ) + joongseong -= 3; + else if( joongseong < 0x10 ) + joongseong -= 5; + else if( joongseong < 0x18 ) + joongseong -= 7; + else + joongseong -= 9; + + choseong *= (NUM_JOONGSEONG * NUM_JONGSEONG); + joongseong *= NUM_JONGSEONG; + jongseong -= jongseong > 0x12 ? 2 : 1; + + dest[0] = UNI_HANGUL_FIRST + choseong + joongseong + jongseong; + return 1; +} + +hchar ksc5601_sym_to_ucs2 (hchar input) +{ + unsigned char ch = sal::static_int_cast(input >> 8); + unsigned char ch2; + int idx; + + ch2 = sal::static_int_cast(input & 0xff); + idx = (ch - 0xA1) * 94 + (ch2 - 0xA1); + if (idx <= 1114 && idx >= 0){ + hchar value = ksc5601_sym_to_ucs[idx]; + return value ? value : 0x25a1; + } + return 0x25a1; +} + +hchar ksc5601_han_to_ucs2 (hchar input) +{ + unsigned char ch = sal::static_int_cast(input >> 8); + unsigned char ch2; + int idx; + + ch2 = sal::static_int_cast(input & 0xff); + idx = (ch - 0xA1) * 94 + (ch2 - 0xA1); + if (idx >= 3854){ + // Hanja : row 42 - row 93 : 3854 = 94 * (42-1) + hchar value = ksc5601_hanja_to_ucs[idx - 3854]; + return value ? value : '?'; + } + return '?'; +} + +hchar* hstr2ucsstr(hchar* hstr, hchar* ubuf) +{ + int i = 0, j; + int res; + hchar dest[3]; + hchar *tmp = ubuf; + for( ; *hstr ; ){ + res = hcharconv(*hstr++, dest, UNICODE); + for( j = 0 ; j < res ; j++) + tmp[i++] = dest[j]; + } + + tmp[i]= '\0'; + return ubuf; +} +/** + * ĽƮ ϼƮ ȯѴ + */ +int hstr2ksstr(hchar* hstr, char* buf) +{ + + int i = 0, res, j; + int c; + hchar dest[3]; + char *tmp = buf; + for( ; *hstr ; ) + { + res = hcharconv(*hstr++, dest, KS); + for( j = 0 ; j < res ; j++ ){ + c = dest[j]; + if( c < 32 ) c = ' '; + else if( c < 256 ) + tmp[i++] = sal::static_int_cast(c); + else + { + tmp[i++] = sal::static_int_cast((c >> 8 ) & 0xff); + tmp[i++] = sal::static_int_cast(c & 0xff); + } + } + } + tmp[i]= '\0'; + + return i; +} + + +/* + * ѱۿ ڱ ִ kcharŸ ڿ + * ѱۿ ϴ hcharŸ ڿ ȯѴ. + */ +unsigned short *kstr2hstr( unsigned char *src, unsigned short *dest ) +{ + int i=0, ii; + unsigned short* tmp = dest; + + for(i=0,ii=0 ; src[i] != '\0' ; i++,ii++ ) + { + if ( src[i] < 127 ) + { + tmp[ii] = src[i]; + } + else + { + tmp[ii] = src[i] << 8 | src[i+1]; + i++; + } + } + tmp[ii] = '\0'; + return dest; +} + + +/** + * Transfer interger to string following format + */ +char* Int2Str(int value, const char *format, char *buf) +{ + sprintf(buf,format,value); + return buf; +} + + +/* colorε Ͽ Ÿǽ color ȯ */ +char *hcolor2str(uchar color, uchar shade, char *buf, bool bIsChar) +{ + unsigned short red,green,blue; + + switch( (int)color ) + { + case 0 : // black + red = 0xff * (100 - shade ) /100; + green = 0xff * (100 - shade ) /100; + blue = 0xff * (100 - shade ) /100; + break; + case 1: // blue + red = 0xff * (100 - shade ) /100; + green = 0xff * (100 - shade ) /100; + blue = 0xff; + break; + case 2: // green + red = 0xff * (100 - shade ) /100; + if( bIsChar ) + green = 0x80; + else + green = 0xff; + blue = 0xff * (100 - shade ) /100; + break; + case 3: // cyan + red = 0xff * (100 - shade ) /100; + green = 0xff; + blue = 0xff; + break; + case 4: // red + red = 0xff; + green = 0xff * (100 - shade ) /100; + blue = 0xff * (100 - shade ) /100; + break; + case 5: // magenta + red = 0xff; + green = 0xff * (100 - shade ) /100; + blue = 0xff; + break; + case 6: //yellow + red = 0xff; + green = 0xff; + blue = 0xff * (100 - shade ) /100; + break; + case 7: //white + default: + red = 0xff; + green = 0xff; + blue = 0xff; + break; + } + + sprintf(buf,"#%02x%02x%02x", red, green, blue); + return buf; +} + + +char *urltounix(const char *src, char *dest ) +{ + if( src[0] == 'C' && src[1] == ':' && src[2] == '\\' ) // Home Dir + { + unsigned int i, len; + sprintf(dest,"file://%s/", getenv("HOME") ); + len = strlen( dest ); + + for( i = 0 ; i + 3 < strlen(src) ; i++ ) + { + if( src[i + 3] == '\\') + dest[i + len] = '/'; + else + dest[i + len] = src[ i +3]; + } + dest[i + len] = '\0'; + return dest; + } + else if( src[0] == 'D' && src[1] == ':' && src[2] == '\\' ) // Root Dir + { + unsigned int i, len; + sprintf(dest,"file:///"); + len = strlen( dest ); + for( i = 0 ; i + 3 < strlen(src) ; i++ ) + { + if( src[i + 3] == '\\') + dest[i + len] = '/'; + else + dest[i + len] = src[i+3]; + } + dest[i + len] = '\0'; + return dest; + } + else if( !strncmp(src,"http",4) ) // Start from "http" + { + unsigned int i; + for( i = 0 ; i < strlen(src) ; i++ ) + { + if( src[i] == '\\') + dest[i] = '/'; + else + dest[i] = src[i]; + } + dest[i] = '\0'; + return dest; + } + else + { + unsigned int i, len, srclen; + srclen = strlen(src); + char ext[4]; + strncpy(ext,src + srclen - 3,3); + ext[3]=0; +#ifdef _WIN32 + if( _strnicmp(ext,"HWP",3) && _strnicmp(ext,"HWT",3)) +#else + if( strcasecmp(ext,"HWP") && strcasecmp(ext,"HWT")) +#endif + sprintf(dest, "http://"); + len = strlen(dest); + for( i = 0 ; i < strlen(src) ; i++ ) + { + if( src[i] == '\\') + dest[i+len] = '/'; + else + dest[i+len] = src[i]; + } + dest[i+len] = '\0'; + return dest; + } +} + +#ifdef _WIN32 +char *urltowin(const char *src, char *dest ) +{ + if( !_strnicmp(src, "http", 4)) + { + int i; + for( i = 0 ; i < sal::static_int_cast(strlen(src)) ; i++ ) + { + if( src[i] == '\\') + dest[i] = '/'; + else + dest[i] = src[i]; + } + dest[i] = '\0'; + return dest; + } + else + { + int i, len, srclen; + srclen = strlen(src); + char ext[4]; + strncpy(ext,src + srclen - 3,3); + ext[3]=0; + //printf("hcode.cxx : ext = %s\n",ext); + + if( !_strnicmp(ext,"HWP",3) || !_strnicmp(ext,"HWT",3)){ + strcpy(dest,src); + return dest; + } + sprintf(dest, "http://"); + len = strlen(dest); + for( i = 0 ; i < sal::static_int_cast(strlen(src)) ; i++ ) + { + if( src[i] == '\\') + dest[i+len] = '/'; + else + dest[i+len] = src[i]; + } + dest[i+len] = '\0'; + return dest; + } +} +#endif + +char* base64_encode_string( const uchar *buf, unsigned int len ) +{ + char basis_64[] = + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + char * out; + int inPos = 0; + int outPos = 0; + int c1, c2, c3; + unsigned int i; + + out=(char *)malloc( (len*4/3)+8 ); + +/* Get three characters at a time and encode them. */ + for (i=0; i < len/3; ++i) + { + c1 = buf[inPos++] & 0xFF; + c2 = buf[inPos++] & 0xFF; + c3 = buf[inPos++] & 0xFF; + out[outPos++] = basis_64[(c1 & 0xFC) >> 2]; + out[outPos++] = basis_64[((c1 & 0x03) << 4) | ((c2 & 0xF0) >> 4)]; + out[outPos++] = basis_64[((c2 & 0x0F) << 2) | ((c3 & 0xC0) >> 6)]; + out[outPos++] = basis_64[c3 & 0x3F]; + } + +/* Encode the remaining one or two characters. */ + + switch (len % 3) + { + case 0: + break; + case 1: + c1 = buf[inPos] & 0xFF; + out[outPos++] = basis_64[(c1 & 0xFC) >> 2]; + out[outPos++] = basis_64[((c1 & 0x03) << 4)]; + out[outPos++] = '='; + out[outPos++] = '='; + break; + case 2: + c1 = buf[inPos++] & 0xFF; + c2 = buf[inPos] & 0xFF; + out[outPos++] = basis_64[(c1 & 0xFC) >> 2]; + out[outPos++] = basis_64[((c1 & 0x03) << 4) | ((c2 & 0xF0) >> 4)]; + out[outPos++] = basis_64[((c2 & 0x0F) << 2)]; + out[outPos++] = '='; + break; + } + out[outPos] = 0; + return out; +} + +double calcAngle(int x1, int y1, int x2, int y2) +{ + y1 = -y1; + y2 = -y2; + if( x2 == x1 ){ + if( y2 >= y1 ) + return 0.; + else + return 270.; + } + double angle; + angle = (180 / PI) * atan( ( y2 - y1 ) * 1.0 / ( x2 - x1 )); + if( y2 >= y1 ){ /* 1,2и */ + if( angle < 0. ) + angle += 180.; + } + else{ /* 3, 4 и */ + if( angle > 0 ) + angle += 180.; + else + angle += 360.; + } + return angle; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/hwpfilter/source/hfont.cpp b/hwpfilter/source/hfont.cpp deleted file mode 100644 index 12c8705ba17f..000000000000 --- a/hwpfilter/source/hfont.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "precompile.h" -#include "hwplib.h" -#include "hwpfile.h" -#include "hfont.h" -/* Լ HWP ؼϴ κ̴. */ - -HWPFont::HWPFont(void) -{ - for (int ii = 0; ii < NLanguage; ii++) - { - nFonts[ii] = 0; - fontnames[ii] = NULL; - } -} - - -HWPFont::~HWPFont(void) -{ - for (int ii = 0; ii < NLanguage; ii++) - { - nFonts[ii] = 0; - delete[]fontnames[ii]; - } -} - - -int HWPFont::AddFont(int lang, const char *font) -{ - int nfonts; - - if (!(lang >= 0 && lang < NLanguage)) - return 0; - nfonts = nFonts[lang]; - if (MAXFONTS <= nfonts) - return 0; - strncpy(fontnames[lang] + FONTNAMELEN * nfonts, font, FONTNAMELEN - 1); - nFonts[lang]++; - return nfonts; -} - - -const char *HWPFont::GetFontName(int lang, int id) -{ - if (!(lang >= 0 && lang < NLanguage)) - return 0; - if (id < 0 || nFonts[lang] <= id) - return 0; - return fontnames[lang] + id * FONTNAMELEN; -} - - -static char buffer[FONTNAMELEN]; - -bool HWPFont::Read(HWPFile & hwpf) -{ - int lang = 0; - short nfonts = 0; - -//printf("HWPFont::Read : lang = %d\n",NLanguage); - for(lang = 0; lang < NLanguage; lang++) - { - hwpf.Read2b(&nfonts, 1); - if (!(nfonts > 0 && nfonts < MAXFONTS)) - { - return !hwpf.SetState(HWP_InvalidFileFormat); - } - fontnames[lang] = new char[nfonts * FONTNAMELEN]; - - memset(fontnames[lang], 0, nfonts * FONTNAMELEN); - for (int jj = 0; jj < nfonts; jj++) - { - hwpf.ReadBlock(buffer, FONTNAMELEN); - AddFont(lang, buffer); - } - } - - return !hwpf.State(); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/hwpfilter/source/hfont.cxx b/hwpfilter/source/hfont.cxx new file mode 100644 index 000000000000..12c8705ba17f --- /dev/null +++ b/hwpfilter/source/hfont.cxx @@ -0,0 +1,108 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "precompile.h" +#include "hwplib.h" +#include "hwpfile.h" +#include "hfont.h" +/* Լ HWP ؼϴ κ̴. */ + +HWPFont::HWPFont(void) +{ + for (int ii = 0; ii < NLanguage; ii++) + { + nFonts[ii] = 0; + fontnames[ii] = NULL; + } +} + + +HWPFont::~HWPFont(void) +{ + for (int ii = 0; ii < NLanguage; ii++) + { + nFonts[ii] = 0; + delete[]fontnames[ii]; + } +} + + +int HWPFont::AddFont(int lang, const char *font) +{ + int nfonts; + + if (!(lang >= 0 && lang < NLanguage)) + return 0; + nfonts = nFonts[lang]; + if (MAXFONTS <= nfonts) + return 0; + strncpy(fontnames[lang] + FONTNAMELEN * nfonts, font, FONTNAMELEN - 1); + nFonts[lang]++; + return nfonts; +} + + +const char *HWPFont::GetFontName(int lang, int id) +{ + if (!(lang >= 0 && lang < NLanguage)) + return 0; + if (id < 0 || nFonts[lang] <= id) + return 0; + return fontnames[lang] + id * FONTNAMELEN; +} + + +static char buffer[FONTNAMELEN]; + +bool HWPFont::Read(HWPFile & hwpf) +{ + int lang = 0; + short nfonts = 0; + +//printf("HWPFont::Read : lang = %d\n",NLanguage); + for(lang = 0; lang < NLanguage; lang++) + { + hwpf.Read2b(&nfonts, 1); + if (!(nfonts > 0 && nfonts < MAXFONTS)) + { + return !hwpf.SetState(HWP_InvalidFileFormat); + } + fontnames[lang] = new char[nfonts * FONTNAMELEN]; + + memset(fontnames[lang], 0, nfonts * FONTNAMELEN); + for (int jj = 0; jj < nfonts; jj++) + { + hwpf.ReadBlock(buffer, FONTNAMELEN); + AddFont(lang, buffer); + } + } + + return !hwpf.State(); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/hwpfilter/source/hgzip.cpp b/hwpfilter/source/hgzip.cpp deleted file mode 100644 index 13811d2069a8..000000000000 --- a/hwpfilter/source/hgzip.cpp +++ /dev/null @@ -1,340 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "precompile.h" - -#include -#include -#include -#include -#include "hgzip.h" -#include "hstream.h" - -#ifndef local -# define local static -#endif - -#define Z_BUFSIZE (1024 * 4) - -#define ALLOC(size) malloc(size) -#define TRYFREE(p) {if (p) free(p);} - -#define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */ -#define HEAD_CRC 0x02 /* bit 1 set: header CRC present */ -#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */ -#define ORIG_NAME 0x08 /* bit 3 set: original file name present */ -#define COMMENT 0x10 /* bit 4 set: file comment present */ -#define RESERVED 0xE0 /* bits 5..7: reserved */ - -local int get_byte(gz_stream * s); -local int destroy(gz_stream * s); -local uLong getLong(gz_stream * s); - -/* =========================================================================== - Opens a gzip (.gz) file for reading or writing. The mode parameter - is as in fopen ("rb" or "wb"). The file is given either by file descriptor - or path name (if fd == -1). - gz_open return NULL if the file could not be opened or if there was - insufficient memory to allocate the (de)compression state; errno - can be checked to distinguish the two cases (if errno is zero, the - zlib error is Z_MEM_ERROR). -*/ -gz_stream *gz_open(HStream & _stream) -{ - int err; - //int level = Z_DEFAULT_COMPRESSION; /* compression level */ - -// char *p = (char*)mode; - //char fmode[80]; /* copy of mode, without the compression level */ - //char *m = fmode; - gz_stream *s; - - s = (gz_stream *) ALLOC(sizeof(gz_stream)); - if (!s) - return Z_NULL; - s->stream.zalloc = (alloc_func) 0; - s->stream.zfree = (free_func) 0; - s->stream.opaque = (voidpf) 0; - s->stream.next_in = s->inbuf = Z_NULL; - s->stream.next_out = s->outbuf = Z_NULL; - s->stream.avail_in = s->stream.avail_out = 0; -//s->_inputstream = NULL; - s->z_err = Z_OK; - s->z_eof = 0; - s->crc = crc32(0L, Z_NULL, 0); - s->msg = NULL; - s->transparent = 0; - - s->mode = 'r'; - -//realking - err = inflateInit2(&(s->stream), -MAX_WBITS); - s->stream.next_in = s->inbuf = (Byte *) ALLOC(Z_BUFSIZE); - - if (err != Z_OK || s->inbuf == Z_NULL) - { - return destroy(s), (gz_stream *) Z_NULL; - } - - s->stream.avail_out = Z_BUFSIZE; - - errno = 0; - s->_inputstream = &_stream; - - return (gz_stream *) s; -} - - -/* =========================================================================== - Read a byte from a gz_stream; update next_in and avail_in. Return EOF - for end of file. - IN assertion: the stream s has been sucessfully opened for reading. -*/ -local int get_byte(gz_stream * s) -{ - if (s->z_eof) - return EOF; - if (s->stream.avail_in == 0) - { - errno = 0; - - s->stream.avail_in = s->_inputstream->readBytes(s->inbuf, Z_BUFSIZE); - if (s->stream.avail_in == 0) - { - s->z_eof = 1; - return EOF; - } - s->stream.next_in = s->inbuf; - } - s->stream.avail_in--; - return *(s->stream.next_in)++; -} - - -/* =========================================================================== - * Cleanup then free the given gz_stream. Return a zlib error code. - * Try freeing in the reverse order of allocations. - */ -local int destroy(gz_stream * s) -{ - int err = Z_OK; - - if (!s) - return Z_STREAM_ERROR; - - TRYFREE(s->msg); - - if (s->stream.state != NULL) - { - err = inflateEnd(&(s->stream)); - } - if (s->z_err < 0) - err = s->z_err; - - TRYFREE(s->inbuf); - TRYFREE(s->outbuf); - TRYFREE(s); - return err; -} - - -// typedef unsigned char Byte -// typedef Byte FAR Bytef; -/* =========================================================================== - Reads the given number of uncompressed bytes from the compressed file. - gz_read returns the number of bytes actually read (0 for end of file). -*/ -int gz_read(gz_stream * file, voidp buf, unsigned len) -{ -//printf("@@ gz_read : len : %d\t",len); - gz_stream *s = (gz_stream *) file; - Bytef *start = (Bytef *) buf; /* starting point for crc computation */ - Byte *next_out; /* == stream.next_out but not forced far (for MSDOS) */ - if (s == NULL) - return Z_STREAM_ERROR; - - if (s->z_err == Z_DATA_ERROR || s->z_err == Z_ERRNO) - return -1; - if (s->z_err == Z_STREAM_END) - return 0; /* EOF */ - - s->stream.next_out = next_out = (Bytef *) buf; - s->stream.avail_out = len; - - while (s->stream.avail_out != 0) - { - if (s->transparent) - { -/* Copy first the lookahead bytes: */ - uInt n = s->stream.avail_in; - - if (n > s->stream.avail_out) - n = s->stream.avail_out; - if (n > 0) - { - memcpy(s->stream.next_out, s->stream.next_in, n); - next_out += n; - s->stream.next_out = next_out; - s->stream.next_in += n; - s->stream.avail_out -= n; - s->stream.avail_in -= n; - } - if (s->stream.avail_out > 0) - { - s->stream.avail_out -= - s->_inputstream->readBytes(next_out, s->stream.avail_out); - } - return (int) (len - s->stream.avail_out); - } - if (s->stream.avail_in == 0 && !s->z_eof) - { - - errno = 0; - s->stream.avail_in = s->_inputstream->readBytes(s->inbuf, Z_BUFSIZE); - if (s->stream.avail_in == 0) - { - s->z_eof = 1; - break; - } - s->stream.next_in = s->inbuf; - } - s->z_err = inflate(&(s->stream), Z_NO_FLUSH); - - if (s->z_err == Z_STREAM_END) - { -/* Check CRC and original size */ - s->crc = crc32(s->crc, start, (uInt) (s->stream.next_out - start)); - start = s->stream.next_out; - - if (getLong(s) != s->crc || getLong(s) != s->stream.total_out) - { - s->z_err = Z_DATA_ERROR; - } - else if (s->z_err == Z_OK) - { - inflateReset(&(s->stream)); - s->crc = crc32(0L, Z_NULL, 0); - } - } - if (s->z_err != Z_OK || s->z_eof) - break; - } - s->crc = crc32(s->crc, start, (uInt) (s->stream.next_out - start)); - return (int) (len - s->stream.avail_out); -} - -/* =========================================================================== - Flushes all pending output into the compressed file. The parameter - flush is as in the deflate() function. - gz_flush should be called only when strictly necessary because it can - degrade compression. -*/ -int gz_flush(gz_stream * file, int flush) -{ - uInt len; - int done = 0; - gz_stream *s = (gz_stream *) file; - - if (s == NULL || s->mode != 'w') - return Z_STREAM_ERROR; - - s->stream.avail_in = 0; /* should be zero already anyway */ - - for (;;) - { - len = Z_BUFSIZE - s->stream.avail_out; - if (len != 0) - { -/* - if ((uInt)fwrite(s->outbuf, 1, len, s->file) != len) { - s->z_err = Z_ERRNO; - return Z_ERRNO; - } - */ - s->stream.next_out = s->outbuf; - s->stream.avail_out = Z_BUFSIZE; - } - if (done) - break; - s->z_err = deflate(&(s->stream), flush); - -/* deflate has finished flushing only when it hasn't used up - * all the available space in the output buffer: - */ - done = (s->stream.avail_out != 0 || s->z_err == Z_STREAM_END); - - if (s->z_err != Z_OK && s->z_err != Z_STREAM_END) - break; - } - return s->z_err == Z_STREAM_END ? Z_OK : s->z_err; -} - - -/* =========================================================================== - Reads a long in LSB order from the given gz_stream. Sets -*/ -local uLong getLong(gz_stream * s) -{ - uLong x = (uLong) get_byte(s); - int c; - - x += ((uLong) get_byte(s)) << 8; - x += ((uLong) get_byte(s)) << 16; - c = get_byte(s); - if (c == EOF) - s->z_err = Z_DATA_ERROR; - x += ((uLong) c) << 24; - return x; -} - - -/* =========================================================================== - Flushes all pending output if necessary, closes the compressed file - and deallocates all the (de)compression state. -*/ -int gz_close(gz_stream * file) -{ -// int err; - gz_stream *s = (gz_stream *) file; - - if (s == NULL) - return Z_STREAM_ERROR; -#if 0 - if (s->mode == 'w') - { - err = gz_flush(file, Z_FINISH); - if (err != Z_OK) - return destroy(s); - putLong(s->file, s->crc); - putLong(s->file, s->stream.total_in); - } -#endif - return destroy(s); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/hwpfilter/source/hgzip.cxx b/hwpfilter/source/hgzip.cxx new file mode 100644 index 000000000000..13811d2069a8 --- /dev/null +++ b/hwpfilter/source/hgzip.cxx @@ -0,0 +1,340 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "precompile.h" + +#include +#include +#include +#include +#include "hgzip.h" +#include "hstream.h" + +#ifndef local +# define local static +#endif + +#define Z_BUFSIZE (1024 * 4) + +#define ALLOC(size) malloc(size) +#define TRYFREE(p) {if (p) free(p);} + +#define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */ +#define HEAD_CRC 0x02 /* bit 1 set: header CRC present */ +#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */ +#define ORIG_NAME 0x08 /* bit 3 set: original file name present */ +#define COMMENT 0x10 /* bit 4 set: file comment present */ +#define RESERVED 0xE0 /* bits 5..7: reserved */ + +local int get_byte(gz_stream * s); +local int destroy(gz_stream * s); +local uLong getLong(gz_stream * s); + +/* =========================================================================== + Opens a gzip (.gz) file for reading or writing. The mode parameter + is as in fopen ("rb" or "wb"). The file is given either by file descriptor + or path name (if fd == -1). + gz_open return NULL if the file could not be opened or if there was + insufficient memory to allocate the (de)compression state; errno + can be checked to distinguish the two cases (if errno is zero, the + zlib error is Z_MEM_ERROR). +*/ +gz_stream *gz_open(HStream & _stream) +{ + int err; + //int level = Z_DEFAULT_COMPRESSION; /* compression level */ + +// char *p = (char*)mode; + //char fmode[80]; /* copy of mode, without the compression level */ + //char *m = fmode; + gz_stream *s; + + s = (gz_stream *) ALLOC(sizeof(gz_stream)); + if (!s) + return Z_NULL; + s->stream.zalloc = (alloc_func) 0; + s->stream.zfree = (free_func) 0; + s->stream.opaque = (voidpf) 0; + s->stream.next_in = s->inbuf = Z_NULL; + s->stream.next_out = s->outbuf = Z_NULL; + s->stream.avail_in = s->stream.avail_out = 0; +//s->_inputstream = NULL; + s->z_err = Z_OK; + s->z_eof = 0; + s->crc = crc32(0L, Z_NULL, 0); + s->msg = NULL; + s->transparent = 0; + + s->mode = 'r'; + +//realking + err = inflateInit2(&(s->stream), -MAX_WBITS); + s->stream.next_in = s->inbuf = (Byte *) ALLOC(Z_BUFSIZE); + + if (err != Z_OK || s->inbuf == Z_NULL) + { + return destroy(s), (gz_stream *) Z_NULL; + } + + s->stream.avail_out = Z_BUFSIZE; + + errno = 0; + s->_inputstream = &_stream; + + return (gz_stream *) s; +} + + +/* =========================================================================== + Read a byte from a gz_stream; update next_in and avail_in. Return EOF + for end of file. + IN assertion: the stream s has been sucessfully opened for reading. +*/ +local int get_byte(gz_stream * s) +{ + if (s->z_eof) + return EOF; + if (s->stream.avail_in == 0) + { + errno = 0; + + s->stream.avail_in = s->_inputstream->readBytes(s->inbuf, Z_BUFSIZE); + if (s->stream.avail_in == 0) + { + s->z_eof = 1; + return EOF; + } + s->stream.next_in = s->inbuf; + } + s->stream.avail_in--; + return *(s->stream.next_in)++; +} + + +/* =========================================================================== + * Cleanup then free the given gz_stream. Return a zlib error code. + * Try freeing in the reverse order of allocations. + */ +local int destroy(gz_stream * s) +{ + int err = Z_OK; + + if (!s) + return Z_STREAM_ERROR; + + TRYFREE(s->msg); + + if (s->stream.state != NULL) + { + err = inflateEnd(&(s->stream)); + } + if (s->z_err < 0) + err = s->z_err; + + TRYFREE(s->inbuf); + TRYFREE(s->outbuf); + TRYFREE(s); + return err; +} + + +// typedef unsigned char Byte +// typedef Byte FAR Bytef; +/* =========================================================================== + Reads the given number of uncompressed bytes from the compressed file. + gz_read returns the number of bytes actually read (0 for end of file). +*/ +int gz_read(gz_stream * file, voidp buf, unsigned len) +{ +//printf("@@ gz_read : len : %d\t",len); + gz_stream *s = (gz_stream *) file; + Bytef *start = (Bytef *) buf; /* starting point for crc computation */ + Byte *next_out; /* == stream.next_out but not forced far (for MSDOS) */ + if (s == NULL) + return Z_STREAM_ERROR; + + if (s->z_err == Z_DATA_ERROR || s->z_err == Z_ERRNO) + return -1; + if (s->z_err == Z_STREAM_END) + return 0; /* EOF */ + + s->stream.next_out = next_out = (Bytef *) buf; + s->stream.avail_out = len; + + while (s->stream.avail_out != 0) + { + if (s->transparent) + { +/* Copy first the lookahead bytes: */ + uInt n = s->stream.avail_in; + + if (n > s->stream.avail_out) + n = s->stream.avail_out; + if (n > 0) + { + memcpy(s->stream.next_out, s->stream.next_in, n); + next_out += n; + s->stream.next_out = next_out; + s->stream.next_in += n; + s->stream.avail_out -= n; + s->stream.avail_in -= n; + } + if (s->stream.avail_out > 0) + { + s->stream.avail_out -= + s->_inputstream->readBytes(next_out, s->stream.avail_out); + } + return (int) (len - s->stream.avail_out); + } + if (s->stream.avail_in == 0 && !s->z_eof) + { + + errno = 0; + s->stream.avail_in = s->_inputstream->readBytes(s->inbuf, Z_BUFSIZE); + if (s->stream.avail_in == 0) + { + s->z_eof = 1; + break; + } + s->stream.next_in = s->inbuf; + } + s->z_err = inflate(&(s->stream), Z_NO_FLUSH); + + if (s->z_err == Z_STREAM_END) + { +/* Check CRC and original size */ + s->crc = crc32(s->crc, start, (uInt) (s->stream.next_out - start)); + start = s->stream.next_out; + + if (getLong(s) != s->crc || getLong(s) != s->stream.total_out) + { + s->z_err = Z_DATA_ERROR; + } + else if (s->z_err == Z_OK) + { + inflateReset(&(s->stream)); + s->crc = crc32(0L, Z_NULL, 0); + } + } + if (s->z_err != Z_OK || s->z_eof) + break; + } + s->crc = crc32(s->crc, start, (uInt) (s->stream.next_out - start)); + return (int) (len - s->stream.avail_out); +} + +/* =========================================================================== + Flushes all pending output into the compressed file. The parameter + flush is as in the deflate() function. + gz_flush should be called only when strictly necessary because it can + degrade compression. +*/ +int gz_flush(gz_stream * file, int flush) +{ + uInt len; + int done = 0; + gz_stream *s = (gz_stream *) file; + + if (s == NULL || s->mode != 'w') + return Z_STREAM_ERROR; + + s->stream.avail_in = 0; /* should be zero already anyway */ + + for (;;) + { + len = Z_BUFSIZE - s->stream.avail_out; + if (len != 0) + { +/* + if ((uInt)fwrite(s->outbuf, 1, len, s->file) != len) { + s->z_err = Z_ERRNO; + return Z_ERRNO; + } + */ + s->stream.next_out = s->outbuf; + s->stream.avail_out = Z_BUFSIZE; + } + if (done) + break; + s->z_err = deflate(&(s->stream), flush); + +/* deflate has finished flushing only when it hasn't used up + * all the available space in the output buffer: + */ + done = (s->stream.avail_out != 0 || s->z_err == Z_STREAM_END); + + if (s->z_err != Z_OK && s->z_err != Z_STREAM_END) + break; + } + return s->z_err == Z_STREAM_END ? Z_OK : s->z_err; +} + + +/* =========================================================================== + Reads a long in LSB order from the given gz_stream. Sets +*/ +local uLong getLong(gz_stream * s) +{ + uLong x = (uLong) get_byte(s); + int c; + + x += ((uLong) get_byte(s)) << 8; + x += ((uLong) get_byte(s)) << 16; + c = get_byte(s); + if (c == EOF) + s->z_err = Z_DATA_ERROR; + x += ((uLong) c) << 24; + return x; +} + + +/* =========================================================================== + Flushes all pending output if necessary, closes the compressed file + and deallocates all the (de)compression state. +*/ +int gz_close(gz_stream * file) +{ +// int err; + gz_stream *s = (gz_stream *) file; + + if (s == NULL) + return Z_STREAM_ERROR; +#if 0 + if (s->mode == 'w') + { + err = gz_flush(file, Z_FINISH); + if (err != Z_OK) + return destroy(s); + putLong(s->file, s->crc); + putLong(s->file, s->stream.total_in); + } +#endif + return destroy(s); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/hwpfilter/source/himgutil.cpp b/hwpfilter/source/himgutil.cpp deleted file mode 100644 index 3d94280f6135..000000000000 --- a/hwpfilter/source/himgutil.cpp +++ /dev/null @@ -1,172 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "precompile.h" - -#include -#include -#include - -#include "hwplib.h" -#include "htags.h" -#include "himgutil.h" - - -static int ImageMagicType(const uchar * magicno) -{ - int rv = RFT_UNKNOWN; - - if (strncmp((char *) magicno, "GIF87a", 6) == 0 || - strncmp((char *) magicno, "GIF89a", 6) == 0) - rv = RFT_GIF; - else if (strncmp((char *) magicno, "VIEW", 4) == 0 || - strncmp((char *) magicno, "WEIV", 4) == 0) - rv = RFT_PM; - else if (magicno[0] == 'P' && magicno[1] >= '1' && magicno[1] <= '6') - rv = RFT_PBM; -/* note: have to check XPM before XBM, as first 2 chars are the same */ - else if (strncmp((char *) magicno, "/* XPM */", 9) == 0) - rv = RFT_XPM; - else if (strncmp((char *) magicno, "#define", 7) == 0 || - (magicno[0] == '/' && magicno[1] == '*')) - rv = RFT_XBM; - else if (magicno[0] == 0x59 && (magicno[1] & 0x7f) == 0x26 && - magicno[2] == 0x6a && (magicno[3] & 0x7f) == 0x15) - rv = RFT_SUNRAS; - else if (magicno[0] == 'B' && magicno[1] == 'M') - rv = RFT_BMP; - else if (magicno[0] == 0x52 && magicno[1] == 0xcc) - rv = RFT_UTAHRLE; - else if ((magicno[0] == 0x01 && magicno[1] == 0xda) || - (magicno[0] == 0xda && magicno[1] == 0x01)) - rv = RFT_IRIS; - else if (magicno[0] == 0x1f && magicno[1] == 0x9d) - rv = RFT_COMPRESS; - else if (magicno[0] == 0x0a && magicno[1] <= 5) - rv = RFT_PCX; - else if (strncmp((char *) magicno, "FORM", 4) == 0 && - strncmp((char *) magicno + 8, "ILBM", 4) == 0) - rv = RFT_IFF; - else if (magicno[0] == 0 && magicno[1] == 0 && - magicno[2] == 2 && magicno[3] == 0 && - magicno[4] == 0 && magicno[5] == 0 && - magicno[6] == 0 && magicno[7] == 0) - rv = RFT_TARGA; - else if (magicno[4] == 0x00 && magicno[5] == 0x00 && - magicno[6] == 0x00 && magicno[7] == 0x07) - rv = RFT_XWD; - else if (strncmp((char *) magicno, "SIMPLE ", 8) == 0 && - magicno[29] == 'T') - rv = RFT_FITS; - else if (magicno[0] == 0xff && magicno[1] == 0xd8 && magicno[2] == 0xff) - rv = RFT_JFIF; - else if ((magicno[0] == 'M' && magicno[1] == 'M') || - (magicno[0] == 'I' && magicno[1] == 'I')) - rv = RFT_TIFF; - else if (strncmp((char *) magicno, "%!", 2) == 0 || - strncmp((char *) magicno, "\004%!", 3) == 0) - rv = RFT_PS; - else if (strncmp((char *) magicno, "\xd7\xcd\xc6\x9a", 4) == 0 || - strncmp((char *) magicno, "\x01\x00\x09\x00\x00\x03", 6) == 0) - rv = RFT_WMF; - - return rv; -} - -const char *GetEmbImgname(const EmPicture * empic) -{ - static char fname[256]; - char *ptr; - const char *ext; - - if (tmpnam(fname) == NULL) - return NULL; - if (!empic || !empic->name[0] || (0 == (ptr = strrchr(fname, DIRSEP)))) - return NULL; - switch (ImageMagicType((uchar *) empic->data)) - { - case RFT_GIF: - ext = "gif"; - break; - case RFT_PM: - ext = "pm"; - break; - case RFT_PBM: - ext = "pbm"; - break; - case RFT_XBM: - ext = "xbm"; - break; - case RFT_SUNRAS: - ext = "ras"; - break; - case RFT_BMP: - ext = "bmp"; - break; - case RFT_UTAHRLE: - ext = "rle"; - break; - case RFT_PCX: - ext = "pcx"; - break; - case RFT_JFIF: - ext = "jpg"; - break; - case RFT_TIFF: - ext = "tif"; - break; - case RFT_PDSVICAR: - ext = "pds"; - break; - case RFT_PS: - ext = "ps"; - break; - case RFT_IFF: - ext = "iff"; - break; - case RFT_TARGA: - ext = "tga"; - break; - case RFT_XPM: - ext = "xpm"; - break; - case RFT_XWD: - ext = "xwd"; - break; - case RFT_WMF: - ext = "wmf"; - break; - default: - ext = "666"; - break; - }; - sprintf(ptr + 1, "mz_%s.%s", empic->name,ext); - return fname; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/hwpfilter/source/himgutil.cxx b/hwpfilter/source/himgutil.cxx new file mode 100644 index 000000000000..3d94280f6135 --- /dev/null +++ b/hwpfilter/source/himgutil.cxx @@ -0,0 +1,172 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "precompile.h" + +#include +#include +#include + +#include "hwplib.h" +#include "htags.h" +#include "himgutil.h" + + +static int ImageMagicType(const uchar * magicno) +{ + int rv = RFT_UNKNOWN; + + if (strncmp((char *) magicno, "GIF87a", 6) == 0 || + strncmp((char *) magicno, "GIF89a", 6) == 0) + rv = RFT_GIF; + else if (strncmp((char *) magicno, "VIEW", 4) == 0 || + strncmp((char *) magicno, "WEIV", 4) == 0) + rv = RFT_PM; + else if (magicno[0] == 'P' && magicno[1] >= '1' && magicno[1] <= '6') + rv = RFT_PBM; +/* note: have to check XPM before XBM, as first 2 chars are the same */ + else if (strncmp((char *) magicno, "/* XPM */", 9) == 0) + rv = RFT_XPM; + else if (strncmp((char *) magicno, "#define", 7) == 0 || + (magicno[0] == '/' && magicno[1] == '*')) + rv = RFT_XBM; + else if (magicno[0] == 0x59 && (magicno[1] & 0x7f) == 0x26 && + magicno[2] == 0x6a && (magicno[3] & 0x7f) == 0x15) + rv = RFT_SUNRAS; + else if (magicno[0] == 'B' && magicno[1] == 'M') + rv = RFT_BMP; + else if (magicno[0] == 0x52 && magicno[1] == 0xcc) + rv = RFT_UTAHRLE; + else if ((magicno[0] == 0x01 && magicno[1] == 0xda) || + (magicno[0] == 0xda && magicno[1] == 0x01)) + rv = RFT_IRIS; + else if (magicno[0] == 0x1f && magicno[1] == 0x9d) + rv = RFT_COMPRESS; + else if (magicno[0] == 0x0a && magicno[1] <= 5) + rv = RFT_PCX; + else if (strncmp((char *) magicno, "FORM", 4) == 0 && + strncmp((char *) magicno + 8, "ILBM", 4) == 0) + rv = RFT_IFF; + else if (magicno[0] == 0 && magicno[1] == 0 && + magicno[2] == 2 && magicno[3] == 0 && + magicno[4] == 0 && magicno[5] == 0 && + magicno[6] == 0 && magicno[7] == 0) + rv = RFT_TARGA; + else if (magicno[4] == 0x00 && magicno[5] == 0x00 && + magicno[6] == 0x00 && magicno[7] == 0x07) + rv = RFT_XWD; + else if (strncmp((char *) magicno, "SIMPLE ", 8) == 0 && + magicno[29] == 'T') + rv = RFT_FITS; + else if (magicno[0] == 0xff && magicno[1] == 0xd8 && magicno[2] == 0xff) + rv = RFT_JFIF; + else if ((magicno[0] == 'M' && magicno[1] == 'M') || + (magicno[0] == 'I' && magicno[1] == 'I')) + rv = RFT_TIFF; + else if (strncmp((char *) magicno, "%!", 2) == 0 || + strncmp((char *) magicno, "\004%!", 3) == 0) + rv = RFT_PS; + else if (strncmp((char *) magicno, "\xd7\xcd\xc6\x9a", 4) == 0 || + strncmp((char *) magicno, "\x01\x00\x09\x00\x00\x03", 6) == 0) + rv = RFT_WMF; + + return rv; +} + +const char *GetEmbImgname(const EmPicture * empic) +{ + static char fname[256]; + char *ptr; + const char *ext; + + if (tmpnam(fname) == NULL) + return NULL; + if (!empic || !empic->name[0] || (0 == (ptr = strrchr(fname, DIRSEP)))) + return NULL; + switch (ImageMagicType((uchar *) empic->data)) + { + case RFT_GIF: + ext = "gif"; + break; + case RFT_PM: + ext = "pm"; + break; + case RFT_PBM: + ext = "pbm"; + break; + case RFT_XBM: + ext = "xbm"; + break; + case RFT_SUNRAS: + ext = "ras"; + break; + case RFT_BMP: + ext = "bmp"; + break; + case RFT_UTAHRLE: + ext = "rle"; + break; + case RFT_PCX: + ext = "pcx"; + break; + case RFT_JFIF: + ext = "jpg"; + break; + case RFT_TIFF: + ext = "tif"; + break; + case RFT_PDSVICAR: + ext = "pds"; + break; + case RFT_PS: + ext = "ps"; + break; + case RFT_IFF: + ext = "iff"; + break; + case RFT_TARGA: + ext = "tga"; + break; + case RFT_XPM: + ext = "xpm"; + break; + case RFT_XWD: + ext = "xwd"; + break; + case RFT_WMF: + ext = "wmf"; + break; + default: + ext = "666"; + break; + }; + sprintf(ptr + 1, "mz_%s.%s", empic->name,ext); + return fname; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/hwpfilter/source/hinfo.cpp b/hwpfilter/source/hinfo.cpp deleted file mode 100644 index fb57e49d6de3..000000000000 --- a/hwpfilter/source/hinfo.cpp +++ /dev/null @@ -1,208 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "precompile.h" - -#include "hwplib.h" -#include "hinfo.h" -#include "hwpfile.h" - -// Info Block - - -static bool HWPReadInfoBlock(void *ptr, int len, HWPFile & hwpf) -{ - hwpf.info_block_len = len; - if (0 == len) - return true; - else - return hwpf.ReadBlock(ptr, len) ? true : false; -} - - -// Document Information - -HWPInfo::HWPInfo(void) -{ - info_block = 0; - back_info.isset = false; -} - - -HWPInfo::~HWPInfo(void) -{ - if (info_block) - delete[]info_block; - info_block = 0; -} - - -/** - * о̴ Լ ( 128 bytes ) - * ν( 30 bytes ) ġ ̴. - */ -bool HWPInfo::Read(HWPFile & hwpf) -{ - hwpf.Read2b(&cur_col, 1); /* Ŀ ġ ܹȣ */ - hwpf.Read2b(&cur_row, 1); /* ĭ */ - - hwpf.Read1b(&paper.paper_kind, 1); /* */ - hwpf.Read1b(&paper.paper_direction, 1); /* */ - -// paper geometry information - paper.paper_height = (short) hwpf.Read2b(); /* */ - paper.paper_width = (short) hwpf.Read2b(); /* ʺ */ - paper.top_margin = (short) hwpf.Read2b(); /* */ - paper.bottom_margin = (short) hwpf.Read2b(); /* Ʒ */ - paper.left_margin = (short) hwpf.Read2b(); /* */ - paper.right_margin = (short) hwpf.Read2b(); /* */ - paper.header_length = (short) hwpf.Read2b(); /* Ӹ */ - paper.footer_length = (short) hwpf.Read2b(); /* */ - paper.gutter_length = (short) hwpf.Read2b(); /* */ - hwpf.Read2b(&readonly, 1); /* */ - hwpf.Read1b(reserved1, 4); /* */ - hwpf.Read1b(&chain_info.chain_page_no, 1); /* ȣ 1-, 0-ν (μ⿡ ) */ - hwpf.Read1b(&chain_info.chain_footnote_no, 1);/* ֹȣ 1- 0-ν */ - /* μ ̸ */ - hwpf.Read1b(chain_info.chain_filename, CHAIN_MAX_PATH); - - hwpf.Read1b(annotation, ANNOTATION_LEN); /* ̴ ( ̴ ) */ - hwpf.Read2b(&encrypted, 1); /* ȣ 0-, ׿-ȣɸ */ -//hwpf.Read1b(reserved2, 6); /* Ʒ 3ǰ ٲ. */ - hwpf.Read2b(&beginpagenum,1); /* ۹ȣ */ - -// footnote - hwpf.Read2b(&beginfnnum,1); /* ۹ȣ */ - hwpf.Read2b(&countfn,1); /* */ - splinetext = (short) hwpf.Read2b(); - splinefn = (short) hwpf.Read2b(); - spfnfn = (short) hwpf.Read2b(); - hwpf.Read1b(&fnchar, 1); - hwpf.Read1b(&fnlinetype, 1); -// border layout - for (int ii = 0; ii < 4; ++ii) - bordermargin[ii] = (short) hwpf.Read2b(); - hwpf.Read2b(&borderline, 1); - - hwpf.Read1b(&empty_line_hide, 1); - hwpf.Read1b(&table_move, 1); - hwpf.Read1b(&compressed, 1); - - hwpf.Read1b(&reserved3, 1); - - hwpf.Read2b(&info_block_len, 1); - if (hwpf.State()) - return false; - -/* д´. */ - if (!summary.Read(hwpf)) - return false; - if (info_block_len > 0) - { - info_block = new unsigned char[info_block_len + 1]; - - if (0 == info_block || - !HWPReadInfoBlock(info_block, info_block_len, hwpf)) - return false; - } - -/* hwpf 缳 Ѵ. */ - hwpf.compressed = compressed ? true : false; - hwpf.encrypted = encrypted ? true : false; - hwpf.info_block_len = info_block_len; - hwpf.SetCompressed(hwpf.compressed); - - return (!hwpf.State()); -} - - -// Document Summary - -bool HWPSummary::Read(HWPFile & hwpf) -{ - hwpf.Read2b(title, 56); - hwpf.Read2b(subject, 56); - hwpf.Read2b(author, 56); - hwpf.Read2b(date, 56); - hwpf.Read2b(keyword[0], 56); - hwpf.Read2b(keyword[1], 56); - hwpf.Read2b(etc[0], 56); - hwpf.Read2b(etc[1], 56); - hwpf.Read2b(etc[2], 56); - - return (!hwpf.State()); -} - - -bool ParaShape::Read(HWPFile & hwpf) -{ - pagebreak = 0; - left_margin = (short) hwpf.Read2b(); - right_margin = (short) hwpf.Read2b(); - indent = (short) hwpf.Read2b(); - lspacing = (short) hwpf.Read2b(); - pspacing_next = (short) hwpf.Read2b(); - - hwpf.Read1b(&condense, 1); - hwpf.Read1b(&arrange_type, 1); - for (int ii = 0; ii < MAXTABS; ii++) - { - hwpf.Read1b(&tabs[ii].type, 1); - hwpf.Read1b(&tabs[ii].dot_continue, 1); - tabs[ii].position = (short) hwpf.Read2b(); - } - hwpf.Read1b(&coldef.ncols, 1); - hwpf.Read1b(&coldef.separator, 1); - coldef.spacing = (short) hwpf.Read2b(); - coldef.columnlen = (short) hwpf.Read2b(); - coldef.columnlen0 = (short) hwpf.Read2b(); - hwpf.Read1b(&shade, 1); - hwpf.Read1b(&outline, 1); - hwpf.Read1b(&outline_continue, 1); - pspacing_prev = (short) hwpf.Read2b(); - - hwpf.Read1b(reserved, 2); - return (!hwpf.State()); -} - - -bool CharShape::Read(HWPFile & hwpf) -{ - size = (short) hwpf.Read2b(); - hwpf.Read1b(font, NLanguage); - hwpf.Read1b(ratio, NLanguage); - hwpf.Read1b(space, NLanguage); - hwpf.Read1b(color, 2); - hwpf.Read1b(&shade, 1); - hwpf.Read1b(&attr, 1); - hwpf.Read1b(reserved, 4); - - return (!hwpf.State()); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/hwpfilter/source/hinfo.cxx b/hwpfilter/source/hinfo.cxx new file mode 100644 index 000000000000..fb57e49d6de3 --- /dev/null +++ b/hwpfilter/source/hinfo.cxx @@ -0,0 +1,208 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "precompile.h" + +#include "hwplib.h" +#include "hinfo.h" +#include "hwpfile.h" + +// Info Block + + +static bool HWPReadInfoBlock(void *ptr, int len, HWPFile & hwpf) +{ + hwpf.info_block_len = len; + if (0 == len) + return true; + else + return hwpf.ReadBlock(ptr, len) ? true : false; +} + + +// Document Information + +HWPInfo::HWPInfo(void) +{ + info_block = 0; + back_info.isset = false; +} + + +HWPInfo::~HWPInfo(void) +{ + if (info_block) + delete[]info_block; + info_block = 0; +} + + +/** + * о̴ Լ ( 128 bytes ) + * ν( 30 bytes ) ġ ̴. + */ +bool HWPInfo::Read(HWPFile & hwpf) +{ + hwpf.Read2b(&cur_col, 1); /* Ŀ ġ ܹȣ */ + hwpf.Read2b(&cur_row, 1); /* ĭ */ + + hwpf.Read1b(&paper.paper_kind, 1); /* */ + hwpf.Read1b(&paper.paper_direction, 1); /* */ + +// paper geometry information + paper.paper_height = (short) hwpf.Read2b(); /* */ + paper.paper_width = (short) hwpf.Read2b(); /* ʺ */ + paper.top_margin = (short) hwpf.Read2b(); /* */ + paper.bottom_margin = (short) hwpf.Read2b(); /* Ʒ */ + paper.left_margin = (short) hwpf.Read2b(); /* */ + paper.right_margin = (short) hwpf.Read2b(); /* */ + paper.header_length = (short) hwpf.Read2b(); /* Ӹ */ + paper.footer_length = (short) hwpf.Read2b(); /* */ + paper.gutter_length = (short) hwpf.Read2b(); /* */ + hwpf.Read2b(&readonly, 1); /* */ + hwpf.Read1b(reserved1, 4); /* */ + hwpf.Read1b(&chain_info.chain_page_no, 1); /* ȣ 1-, 0-ν (μ⿡ ) */ + hwpf.Read1b(&chain_info.chain_footnote_no, 1);/* ֹȣ 1- 0-ν */ + /* μ ̸ */ + hwpf.Read1b(chain_info.chain_filename, CHAIN_MAX_PATH); + + hwpf.Read1b(annotation, ANNOTATION_LEN); /* ̴ ( ̴ ) */ + hwpf.Read2b(&encrypted, 1); /* ȣ 0-, ׿-ȣɸ */ +//hwpf.Read1b(reserved2, 6); /* Ʒ 3ǰ ٲ. */ + hwpf.Read2b(&beginpagenum,1); /* ۹ȣ */ + +// footnote + hwpf.Read2b(&beginfnnum,1); /* ۹ȣ */ + hwpf.Read2b(&countfn,1); /* */ + splinetext = (short) hwpf.Read2b(); + splinefn = (short) hwpf.Read2b(); + spfnfn = (short) hwpf.Read2b(); + hwpf.Read1b(&fnchar, 1); + hwpf.Read1b(&fnlinetype, 1); +// border layout + for (int ii = 0; ii < 4; ++ii) + bordermargin[ii] = (short) hwpf.Read2b(); + hwpf.Read2b(&borderline, 1); + + hwpf.Read1b(&empty_line_hide, 1); + hwpf.Read1b(&table_move, 1); + hwpf.Read1b(&compressed, 1); + + hwpf.Read1b(&reserved3, 1); + + hwpf.Read2b(&info_block_len, 1); + if (hwpf.State()) + return false; + +/* д´. */ + if (!summary.Read(hwpf)) + return false; + if (info_block_len > 0) + { + info_block = new unsigned char[info_block_len + 1]; + + if (0 == info_block || + !HWPReadInfoBlock(info_block, info_block_len, hwpf)) + return false; + } + +/* hwpf 缳 Ѵ. */ + hwpf.compressed = compressed ? true : false; + hwpf.encrypted = encrypted ? true : false; + hwpf.info_block_len = info_block_len; + hwpf.SetCompressed(hwpf.compressed); + + return (!hwpf.State()); +} + + +// Document Summary + +bool HWPSummary::Read(HWPFile & hwpf) +{ + hwpf.Read2b(title, 56); + hwpf.Read2b(subject, 56); + hwpf.Read2b(author, 56); + hwpf.Read2b(date, 56); + hwpf.Read2b(keyword[0], 56); + hwpf.Read2b(keyword[1], 56); + hwpf.Read2b(etc[0], 56); + hwpf.Read2b(etc[1], 56); + hwpf.Read2b(etc[2], 56); + + return (!hwpf.State()); +} + + +bool ParaShape::Read(HWPFile & hwpf) +{ + pagebreak = 0; + left_margin = (short) hwpf.Read2b(); + right_margin = (short) hwpf.Read2b(); + indent = (short) hwpf.Read2b(); + lspacing = (short) hwpf.Read2b(); + pspacing_next = (short) hwpf.Read2b(); + + hwpf.Read1b(&condense, 1); + hwpf.Read1b(&arrange_type, 1); + for (int ii = 0; ii < MAXTABS; ii++) + { + hwpf.Read1b(&tabs[ii].type, 1); + hwpf.Read1b(&tabs[ii].dot_continue, 1); + tabs[ii].position = (short) hwpf.Read2b(); + } + hwpf.Read1b(&coldef.ncols, 1); + hwpf.Read1b(&coldef.separator, 1); + coldef.spacing = (short) hwpf.Read2b(); + coldef.columnlen = (short) hwpf.Read2b(); + coldef.columnlen0 = (short) hwpf.Read2b(); + hwpf.Read1b(&shade, 1); + hwpf.Read1b(&outline, 1); + hwpf.Read1b(&outline_continue, 1); + pspacing_prev = (short) hwpf.Read2b(); + + hwpf.Read1b(reserved, 2); + return (!hwpf.State()); +} + + +bool CharShape::Read(HWPFile & hwpf) +{ + size = (short) hwpf.Read2b(); + hwpf.Read1b(font, NLanguage); + hwpf.Read1b(ratio, NLanguage); + hwpf.Read1b(space, NLanguage); + hwpf.Read1b(color, 2); + hwpf.Read1b(&shade, 1); + hwpf.Read1b(&attr, 1); + hwpf.Read1b(reserved, 4); + + return (!hwpf.State()); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/hwpfilter/source/hiodev.cpp b/hwpfilter/source/hiodev.cpp deleted file mode 100644 index 0416a96c7091..000000000000 --- a/hwpfilter/source/hiodev.cpp +++ /dev/null @@ -1,366 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifdef __GNUG__ -#pragma implementation "hiodev.h" -#endif - -#include -#include -// DVO: add zlib/ prefix -#ifdef SYSTEM_ZLIB -#include -#else -#include -#endif -#ifdef WIN32 -# include -#else -# include -#endif - -#include "hwplib.h" -#include "hgzip.h" -#include "hiodev.h" -#include "hwpfile.h" -#include "hstream.h" - -const int BUFSIZE = 1024; -static uchar rBuf[BUFSIZE]; - -// HIODev abstract class -HIODev::HIODev() -{ - init(); -} - - -HIODev::~HIODev() -{ -} - - -void HIODev::init() -{ - compressed = false; -} - - -int HIODev::read1b(void *ptr, int nmemb) -{ - uchar *p = (uchar *) ptr; - int ii; - - if (state()) - return -1; - for (ii = 0; ii < nmemb; ii++) - { - p[ii] = sal::static_int_cast(read1b()); - if (state()) - break; - } - return ii; -} - - -int HIODev::read2b(void *ptr, int nmemb) -{ - ushort *p = (ushort *) ptr; - int ii; - - if (state()) - return -1; - for (ii = 0; ii < nmemb; ii++) - { - p[ii] = sal::static_int_cast(read2b()); - if (state()) - break; - } - return ii; -} - - -int HIODev::read4b(void *ptr, int nmemb) -{ - ulong *p = (ulong *) ptr; - int ii; - - if (state()) - return -1; - for (ii = 0; ii < nmemb; ii++) - { - p[ii] = read4b(); - if (state()) - break; - } - return ii; -} - - -// hfileiodev class -HStreamIODev::HStreamIODev(HStream & stream):_stream(stream) -{ - init(); -} - - -HStreamIODev::~HStreamIODev() -{ - close(); -} - - -void HStreamIODev::init() -{ - _gzfp = NULL; - compressed = false; -} - - -bool HStreamIODev::open() -{ - if (!(_stream.available())) - return false; - return true; -} - - -void HStreamIODev::flush(void) -{ - if (_gzfp) - gz_flush(_gzfp, Z_FINISH); -} - - -void HStreamIODev::close(void) -{ -/* ÷ ݴ´. */ - this->flush(); - if (_gzfp) - gz_close(_gzfp); /* gz_close() calls stream_closeInput() */ - else - _stream.closeInput(); - _gzfp = NULL; -} - - -int HStreamIODev::state(void) const -{ - return 0; -} - - -/* zlib κ */ -bool HStreamIODev::setCompressed(bool flag) -{ - compressed = flag; - if (flag == true) - return 0 != (_gzfp = gz_open(_stream)); - else if (_gzfp) - { - gz_flush(_gzfp, Z_FINISH); - gz_close(_gzfp); - _gzfp = 0; - } - return true; -} - - -// IO routines - -#define GZREAD(ptr,len) (_gzfp?gz_read(_gzfp,ptr,len):0) - -int HStreamIODev::read1b() -{ - int res = (compressed) ? GZREAD(rBuf, 1) : _stream.readBytes(rBuf, 1); - - if (res <= 0) - return -1; - else - return (unsigned char) rBuf[0]; -} - - -int HStreamIODev::read2b() -{ - int res = (compressed) ? GZREAD(rBuf, 2) : _stream.readBytes(rBuf, 2); - - if (res <= 0) - return -1; - else - return ((unsigned char) rBuf[1] << 8 | (unsigned char) rBuf[0]); -} - - -long HStreamIODev::read4b() -{ - int res = (compressed) ? GZREAD(rBuf, 4) : _stream.readBytes(rBuf, 4); - - if (res <= 0) - return -1; - else - return ((unsigned char) rBuf[3] << 24 | (unsigned char) rBuf[2] << 16 | - (unsigned char) rBuf[1] << 8 | (unsigned char) rBuf[0]); -} - - -int HStreamIODev::readBlock(void *ptr, int size) -{ - int count = - (compressed) ? GZREAD(ptr, size) : _stream.readBytes((byte *) ptr, - - size); - - return count; -} - - -int HStreamIODev::skipBlock(int size) -{ - if (compressed){ - if( size <= BUFSIZE ) - return GZREAD(rBuf, size); - else{ - int remain = size; - while(remain){ - if( remain > BUFSIZE ) - remain -= GZREAD(rBuf, BUFSIZE); - else{ - remain -= GZREAD(rBuf, remain); - break; - } - } - return size - remain; - } - } - return _stream.skipBytes(size); -} - - -HMemIODev::HMemIODev(char *s, int len) -{ - init(); - ptr = (uchar *) s; - length = len; -} - - -HMemIODev::~HMemIODev() -{ - close(); -} - - -void HMemIODev::init() -{ - ptr = 0; - length = 0; - pos = 0; -} - - -bool HMemIODev::open() -{ - return true; -} - - -void HMemIODev::flush(void) -{ -} - - -void HMemIODev::close(void) -{ -} - - -int HMemIODev::state(void) const -{ - if (pos <= length) - return 0; - else - return -1; -} - - -bool HMemIODev::setCompressed(bool ) -{ - return false; -} - - -int HMemIODev::read1b() -{ - if (pos <= length) - return ptr[pos++]; - else - return 0; -} - - -int HMemIODev::read2b() -{ - pos += 2; - if (pos <= length) - return ptr[pos - 1] << 8 | ptr[pos - 2]; - else - return 0; -} - - -long HMemIODev::read4b() -{ - pos += 4; - if (pos <= length) - return DWORD(ptr[pos - 1] << 24 | ptr[pos - 2] << 16 | - ptr[pos - 3] << 8 | ptr[pos - 4]); - else - return 0; -} - - -int HMemIODev::readBlock(void *p, int size) -{ - if (length < pos + size) - size = length - pos; - memcpy(p, ptr + pos, size); - pos += size; - return size; -} - - -int HMemIODev::skipBlock(int size) -{ - if (length < pos + size) - return 0; - pos += size; - return size; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/hwpfilter/source/hiodev.cxx b/hwpfilter/source/hiodev.cxx new file mode 100644 index 000000000000..0416a96c7091 --- /dev/null +++ b/hwpfilter/source/hiodev.cxx @@ -0,0 +1,366 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifdef __GNUG__ +#pragma implementation "hiodev.h" +#endif + +#include +#include +// DVO: add zlib/ prefix +#ifdef SYSTEM_ZLIB +#include +#else +#include +#endif +#ifdef WIN32 +# include +#else +# include +#endif + +#include "hwplib.h" +#include "hgzip.h" +#include "hiodev.h" +#include "hwpfile.h" +#include "hstream.h" + +const int BUFSIZE = 1024; +static uchar rBuf[BUFSIZE]; + +// HIODev abstract class +HIODev::HIODev() +{ + init(); +} + + +HIODev::~HIODev() +{ +} + + +void HIODev::init() +{ + compressed = false; +} + + +int HIODev::read1b(void *ptr, int nmemb) +{ + uchar *p = (uchar *) ptr; + int ii; + + if (state()) + return -1; + for (ii = 0; ii < nmemb; ii++) + { + p[ii] = sal::static_int_cast(read1b()); + if (state()) + break; + } + return ii; +} + + +int HIODev::read2b(void *ptr, int nmemb) +{ + ushort *p = (ushort *) ptr; + int ii; + + if (state()) + return -1; + for (ii = 0; ii < nmemb; ii++) + { + p[ii] = sal::static_int_cast(read2b()); + if (state()) + break; + } + return ii; +} + + +int HIODev::read4b(void *ptr, int nmemb) +{ + ulong *p = (ulong *) ptr; + int ii; + + if (state()) + return -1; + for (ii = 0; ii < nmemb; ii++) + { + p[ii] = read4b(); + if (state()) + break; + } + return ii; +} + + +// hfileiodev class +HStreamIODev::HStreamIODev(HStream & stream):_stream(stream) +{ + init(); +} + + +HStreamIODev::~HStreamIODev() +{ + close(); +} + + +void HStreamIODev::init() +{ + _gzfp = NULL; + compressed = false; +} + + +bool HStreamIODev::open() +{ + if (!(_stream.available())) + return false; + return true; +} + + +void HStreamIODev::flush(void) +{ + if (_gzfp) + gz_flush(_gzfp, Z_FINISH); +} + + +void HStreamIODev::close(void) +{ +/* ÷ ݴ´. */ + this->flush(); + if (_gzfp) + gz_close(_gzfp); /* gz_close() calls stream_closeInput() */ + else + _stream.closeInput(); + _gzfp = NULL; +} + + +int HStreamIODev::state(void) const +{ + return 0; +} + + +/* zlib κ */ +bool HStreamIODev::setCompressed(bool flag) +{ + compressed = flag; + if (flag == true) + return 0 != (_gzfp = gz_open(_stream)); + else if (_gzfp) + { + gz_flush(_gzfp, Z_FINISH); + gz_close(_gzfp); + _gzfp = 0; + } + return true; +} + + +// IO routines + +#define GZREAD(ptr,len) (_gzfp?gz_read(_gzfp,ptr,len):0) + +int HStreamIODev::read1b() +{ + int res = (compressed) ? GZREAD(rBuf, 1) : _stream.readBytes(rBuf, 1); + + if (res <= 0) + return -1; + else + return (unsigned char) rBuf[0]; +} + + +int HStreamIODev::read2b() +{ + int res = (compressed) ? GZREAD(rBuf, 2) : _stream.readBytes(rBuf, 2); + + if (res <= 0) + return -1; + else + return ((unsigned char) rBuf[1] << 8 | (unsigned char) rBuf[0]); +} + + +long HStreamIODev::read4b() +{ + int res = (compressed) ? GZREAD(rBuf, 4) : _stream.readBytes(rBuf, 4); + + if (res <= 0) + return -1; + else + return ((unsigned char) rBuf[3] << 24 | (unsigned char) rBuf[2] << 16 | + (unsigned char) rBuf[1] << 8 | (unsigned char) rBuf[0]); +} + + +int HStreamIODev::readBlock(void *ptr, int size) +{ + int count = + (compressed) ? GZREAD(ptr, size) : _stream.readBytes((byte *) ptr, + + size); + + return count; +} + + +int HStreamIODev::skipBlock(int size) +{ + if (compressed){ + if( size <= BUFSIZE ) + return GZREAD(rBuf, size); + else{ + int remain = size; + while(remain){ + if( remain > BUFSIZE ) + remain -= GZREAD(rBuf, BUFSIZE); + else{ + remain -= GZREAD(rBuf, remain); + break; + } + } + return size - remain; + } + } + return _stream.skipBytes(size); +} + + +HMemIODev::HMemIODev(char *s, int len) +{ + init(); + ptr = (uchar *) s; + length = len; +} + + +HMemIODev::~HMemIODev() +{ + close(); +} + + +void HMemIODev::init() +{ + ptr = 0; + length = 0; + pos = 0; +} + + +bool HMemIODev::open() +{ + return true; +} + + +void HMemIODev::flush(void) +{ +} + + +void HMemIODev::close(void) +{ +} + + +int HMemIODev::state(void) const +{ + if (pos <= length) + return 0; + else + return -1; +} + + +bool HMemIODev::setCompressed(bool ) +{ + return false; +} + + +int HMemIODev::read1b() +{ + if (pos <= length) + return ptr[pos++]; + else + return 0; +} + + +int HMemIODev::read2b() +{ + pos += 2; + if (pos <= length) + return ptr[pos - 1] << 8 | ptr[pos - 2]; + else + return 0; +} + + +long HMemIODev::read4b() +{ + pos += 4; + if (pos <= length) + return DWORD(ptr[pos - 1] << 24 | ptr[pos - 2] << 16 | + ptr[pos - 3] << 8 | ptr[pos - 4]); + else + return 0; +} + + +int HMemIODev::readBlock(void *p, int size) +{ + if (length < pos + size) + size = length - pos; + memcpy(p, ptr + pos, size); + pos += size; + return size; +} + + +int HMemIODev::skipBlock(int size) +{ + if (length < pos + size) + return 0; + pos += size; + return size; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/hwpfilter/source/hpara.cpp b/hwpfilter/source/hpara.cpp deleted file mode 100644 index 06a5786d90ea..000000000000 --- a/hwpfilter/source/hpara.cpp +++ /dev/null @@ -1,318 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "precompile.h" - -#include "hwplib.h" -#include "hwpfile.h" -#include "hpara.h" -#include "hbox.h" -#include "hutil.h" -#include "hutil.h" - -bool LineInfo::Read(HWPFile & hwpf, HWPPara *pPara) -{ - pos = sal::static_int_cast(hwpf.Read2b()); - space_width = (short) hwpf.Read2b(); - height = (short) hwpf.Read2b(); -// internal informations - pgy = (short) hwpf.Read2b(); - sx = (short) hwpf.Read2b(); - psx = (short) hwpf.Read2b(); - pex = (short) hwpf.Read2b(); - height_sp = 0; - - if( pex >> 15 & 0x01 ) - { - if( pex & 0x01 ) - hwpf.AddPage(); - pPara->pshape.reserved[0] = sal::static_int_cast(pex & 0x01); - pPara->pshape.reserved[1] = sal::static_int_cast(pex & 0x02); - } - - return (!hwpf.State()); -} - - -HWPPara::HWPPara(void) -{ - _next = NULL; - linfo = NULL; - cshapep = NULL; - hhstr = NULL; - pno = 0; - -} - - -HWPPara::~HWPPara(void) -{ - if (linfo) - delete[]linfo; - if (cshapep) - delete[]cshapep; - if (hhstr) - { -// virtual destructor -/* C++은 null에 대해서도 동작한다. */ - for (int ii = 0; ii < nch; ++ii) - delete hhstr[ii]; - - delete[]hhstr; - } - -} - - -int HWPPara::Read(HWPFile & hwpf, unsigned char flag) -{ - unsigned char same_cshape; - register int ii; - scflag = flag; -// Paragraph Information - hwpf.Read1b(&reuse_shape, 1); - hwpf.Read2b(&nch, 1); - hwpf.Read2b(&nline, 1); - hwpf.Read1b(&contain_cshape, 1); - hwpf.Read1b(&etcflag, 1); - hwpf.Read4b(&ctrlflag, 1); - hwpf.Read1b(&pstyno, 1); - - -/* Paragraph 대표 글자 */ - cshape.Read(hwpf); - if (nch > 0) - hwpf.AddCharShape(&cshape); - -/* Paragraph 문단 모양 */ - if (nch && !reuse_shape) - { - pshape.Read(hwpf); - pshape.cshape = &cshape; - pshape.pagebreak = etcflag; - } - - linfo = new LineInfo[nline]; - for (ii = 0; ii < nline; ii++) - { - linfo[ii].Read(hwpf, this); - } - if( etcflag & 0x04 ){ - hwpf.AddColumnInfo(); - } - - if (nch && !reuse_shape){ - if( pshape.coldef.ncols > 1 ){ - hwpf.SetColumnDef( &pshape.coldef ); - } - } - - - if( nline > 0 ) - { - begin_ypos = linfo[0].pgy; - } - else - { - begin_ypos = 0; - } - - if (contain_cshape) - { - cshapep = new CharShape[nch]; - if (!cshapep) - { - perror("Memory Allocation: cshape\n"); - return false; - } - - for (ii = 0; ii < nch; ii++) - { - - hwpf.Read1b(&same_cshape, 1); - if (!same_cshape) - { - cshapep[ii].Read(hwpf); - if (nch > 1) - hwpf.AddCharShape(&cshapep[ii]); - } - else if (ii == 0) - cshapep[ii] = cshape; - else - cshapep[ii] = cshapep[ii - 1]; - } - } -// read string - hhstr = new HBox *[nch]; - for (ii = 0; ii < nch; ii++) - hhstr[ii] = 0; - ii = 0; - while (ii < nch) - { - if (0 == (hhstr[ii] = readHBox(hwpf))) - return false; - if (hhstr[ii]->hh == CH_END_PARA) - break; - if( hhstr[ii]->hh < CH_END_PARA ) - pshape.reserved[0] = 0; - ii += hhstr[ii]->WSize(); - } - return nch && !hwpf.State(); -} - - -HWPPara *HWPPara::Next(void) -{ - return _next; -} - - -CharShape *HWPPara::GetCharShape(int pos) -{ - if (contain_cshape == 0) - return &cshape; - return cshapep + pos; -} - - -ParaShape *HWPPara::GetParaShape(void) -{ - return &pshape; -} - - -HBox *HWPPara::readHBox(HWPFile & hwpf) -{ - hchar hh = sal::static_int_cast(hwpf.Read2b()); - HBox *hbox = 0; - - if (hwpf.State() != HWP_NoError) - return 0; - - if (hh > 31 || hh == CH_END_PARA) - hbox = new HBox(hh); - else if (IS_SP_SKIP_BLOCK(hh)) - hbox = new SkipData(hh); - else - { - switch (hh) - { - case CH_FIELD: // 5 - hbox = new FieldCode; - break; - case CH_BOOKMARK: // 6 - hbox = new Bookmark; - break; - case CH_DATE_FORM: // 7 - hbox = new DateFormat; - break; - case CH_DATE_CODE: // 8 - hbox = new DateCode; - break; - case CH_TAB: // 9 - hbox = new Tab; - break; - case CH_TEXT_BOX: // 10 - hbox = new TxtBox; - break; - case CH_PICTURE: // 11 - hbox = new Picture; - break; - case CH_LINE: // 14 - hbox = new Line; - break; - case CH_HIDDEN: // 15 - hbox = new Hidden; - break; - case CH_HEADER_FOOTER: // 16 - hbox = new HeaderFooter; - break; - case CH_FOOTNOTE: // 17 - hbox = new Footnote; - break; - case CH_AUTO_NUM: // 18 - hbox = new AutoNum; - break; - case CH_NEW_NUM: // 19 - hbox = new NewNum; - break; - case CH_SHOW_PAGE_NUM: // 20 - hbox = new ShowPageNum; - break; - case CH_PAGE_NUM_CTRL: // 21 - hbox = new PageNumCtrl; - break; - case CH_MAIL_MERGE: // 22 - hbox = new MailMerge; - break; - case CH_COMPOSE: // 23 - hbox = new Compose; - break; - case CH_HYPHEN: // 24 - hbox = new Hyphen; - break; - case CH_TOC_MARK: // 25 - hbox = new TocMark; - break; - case CH_INDEX_MARK: // 26 - hbox = new IndexMark; - break; - case CH_OUTLINE: // 28 - hbox = new Outline; - break; - case CH_KEEP_SPACE: // 30 - hbox = new KeepSpace; - break; - case CH_FIXED_SPACE: // 31 - hbox = new FixedSpace; - break; - default: - break; - } - } - if (!hbox || !hbox->Read(hwpf)) - { - delete hbox; - - return 0; - } - if( hh == CH_TEXT_BOX || hh == CH_PICTURE || hh == CH_LINE ) - { - FBox *fbox = static_cast(hbox); - if( ( fbox->style.anchor_type == 1) && ( fbox->pgy >= begin_ypos) ) - { - //strange construct to compile without warning - int nTemp = fbox->pgy; - nTemp -= begin_ypos; - fbox->pgy = sal::static_int_cast(nTemp); - } - } - return hbox; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/hwpfilter/source/hpara.cxx b/hwpfilter/source/hpara.cxx new file mode 100644 index 000000000000..06a5786d90ea --- /dev/null +++ b/hwpfilter/source/hpara.cxx @@ -0,0 +1,318 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "precompile.h" + +#include "hwplib.h" +#include "hwpfile.h" +#include "hpara.h" +#include "hbox.h" +#include "hutil.h" +#include "hutil.h" + +bool LineInfo::Read(HWPFile & hwpf, HWPPara *pPara) +{ + pos = sal::static_int_cast(hwpf.Read2b()); + space_width = (short) hwpf.Read2b(); + height = (short) hwpf.Read2b(); +// internal informations + pgy = (short) hwpf.Read2b(); + sx = (short) hwpf.Read2b(); + psx = (short) hwpf.Read2b(); + pex = (short) hwpf.Read2b(); + height_sp = 0; + + if( pex >> 15 & 0x01 ) + { + if( pex & 0x01 ) + hwpf.AddPage(); + pPara->pshape.reserved[0] = sal::static_int_cast(pex & 0x01); + pPara->pshape.reserved[1] = sal::static_int_cast(pex & 0x02); + } + + return (!hwpf.State()); +} + + +HWPPara::HWPPara(void) +{ + _next = NULL; + linfo = NULL; + cshapep = NULL; + hhstr = NULL; + pno = 0; + +} + + +HWPPara::~HWPPara(void) +{ + if (linfo) + delete[]linfo; + if (cshapep) + delete[]cshapep; + if (hhstr) + { +// virtual destructor +/* C++은 null에 대해서도 동작한다. */ + for (int ii = 0; ii < nch; ++ii) + delete hhstr[ii]; + + delete[]hhstr; + } + +} + + +int HWPPara::Read(HWPFile & hwpf, unsigned char flag) +{ + unsigned char same_cshape; + register int ii; + scflag = flag; +// Paragraph Information + hwpf.Read1b(&reuse_shape, 1); + hwpf.Read2b(&nch, 1); + hwpf.Read2b(&nline, 1); + hwpf.Read1b(&contain_cshape, 1); + hwpf.Read1b(&etcflag, 1); + hwpf.Read4b(&ctrlflag, 1); + hwpf.Read1b(&pstyno, 1); + + +/* Paragraph 대표 글자 */ + cshape.Read(hwpf); + if (nch > 0) + hwpf.AddCharShape(&cshape); + +/* Paragraph 문단 모양 */ + if (nch && !reuse_shape) + { + pshape.Read(hwpf); + pshape.cshape = &cshape; + pshape.pagebreak = etcflag; + } + + linfo = new LineInfo[nline]; + for (ii = 0; ii < nline; ii++) + { + linfo[ii].Read(hwpf, this); + } + if( etcflag & 0x04 ){ + hwpf.AddColumnInfo(); + } + + if (nch && !reuse_shape){ + if( pshape.coldef.ncols > 1 ){ + hwpf.SetColumnDef( &pshape.coldef ); + } + } + + + if( nline > 0 ) + { + begin_ypos = linfo[0].pgy; + } + else + { + begin_ypos = 0; + } + + if (contain_cshape) + { + cshapep = new CharShape[nch]; + if (!cshapep) + { + perror("Memory Allocation: cshape\n"); + return false; + } + + for (ii = 0; ii < nch; ii++) + { + + hwpf.Read1b(&same_cshape, 1); + if (!same_cshape) + { + cshapep[ii].Read(hwpf); + if (nch > 1) + hwpf.AddCharShape(&cshapep[ii]); + } + else if (ii == 0) + cshapep[ii] = cshape; + else + cshapep[ii] = cshapep[ii - 1]; + } + } +// read string + hhstr = new HBox *[nch]; + for (ii = 0; ii < nch; ii++) + hhstr[ii] = 0; + ii = 0; + while (ii < nch) + { + if (0 == (hhstr[ii] = readHBox(hwpf))) + return false; + if (hhstr[ii]->hh == CH_END_PARA) + break; + if( hhstr[ii]->hh < CH_END_PARA ) + pshape.reserved[0] = 0; + ii += hhstr[ii]->WSize(); + } + return nch && !hwpf.State(); +} + + +HWPPara *HWPPara::Next(void) +{ + return _next; +} + + +CharShape *HWPPara::GetCharShape(int pos) +{ + if (contain_cshape == 0) + return &cshape; + return cshapep + pos; +} + + +ParaShape *HWPPara::GetParaShape(void) +{ + return &pshape; +} + + +HBox *HWPPara::readHBox(HWPFile & hwpf) +{ + hchar hh = sal::static_int_cast(hwpf.Read2b()); + HBox *hbox = 0; + + if (hwpf.State() != HWP_NoError) + return 0; + + if (hh > 31 || hh == CH_END_PARA) + hbox = new HBox(hh); + else if (IS_SP_SKIP_BLOCK(hh)) + hbox = new SkipData(hh); + else + { + switch (hh) + { + case CH_FIELD: // 5 + hbox = new FieldCode; + break; + case CH_BOOKMARK: // 6 + hbox = new Bookmark; + break; + case CH_DATE_FORM: // 7 + hbox = new DateFormat; + break; + case CH_DATE_CODE: // 8 + hbox = new DateCode; + break; + case CH_TAB: // 9 + hbox = new Tab; + break; + case CH_TEXT_BOX: // 10 + hbox = new TxtBox; + break; + case CH_PICTURE: // 11 + hbox = new Picture; + break; + case CH_LINE: // 14 + hbox = new Line; + break; + case CH_HIDDEN: // 15 + hbox = new Hidden; + break; + case CH_HEADER_FOOTER: // 16 + hbox = new HeaderFooter; + break; + case CH_FOOTNOTE: // 17 + hbox = new Footnote; + break; + case CH_AUTO_NUM: // 18 + hbox = new AutoNum; + break; + case CH_NEW_NUM: // 19 + hbox = new NewNum; + break; + case CH_SHOW_PAGE_NUM: // 20 + hbox = new ShowPageNum; + break; + case CH_PAGE_NUM_CTRL: // 21 + hbox = new PageNumCtrl; + break; + case CH_MAIL_MERGE: // 22 + hbox = new MailMerge; + break; + case CH_COMPOSE: // 23 + hbox = new Compose; + break; + case CH_HYPHEN: // 24 + hbox = new Hyphen; + break; + case CH_TOC_MARK: // 25 + hbox = new TocMark; + break; + case CH_INDEX_MARK: // 26 + hbox = new IndexMark; + break; + case CH_OUTLINE: // 28 + hbox = new Outline; + break; + case CH_KEEP_SPACE: // 30 + hbox = new KeepSpace; + break; + case CH_FIXED_SPACE: // 31 + hbox = new FixedSpace; + break; + default: + break; + } + } + if (!hbox || !hbox->Read(hwpf)) + { + delete hbox; + + return 0; + } + if( hh == CH_TEXT_BOX || hh == CH_PICTURE || hh == CH_LINE ) + { + FBox *fbox = static_cast(hbox); + if( ( fbox->style.anchor_type == 1) && ( fbox->pgy >= begin_ypos) ) + { + //strange construct to compile without warning + int nTemp = fbox->pgy; + nTemp -= begin_ypos; + fbox->pgy = sal::static_int_cast(nTemp); + } + } + return hbox; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/hwpfilter/source/hstream.cpp b/hwpfilter/source/hstream.cpp deleted file mode 100644 index c6b8c24a2152..000000000000 --- a/hwpfilter/source/hstream.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include -#include -#include "hstream.h" - -HStream::HStream() : size(0), pos(0) -{ - seq = 0; -} - - -HStream::~HStream() -{ - if( seq ) - free( seq ); -} - - -void HStream::addData( const byte *buf, int aToAdd) -{ - seq = (byte *)realloc( seq, size + aToAdd ); - memcpy( seq + size, buf, aToAdd ); - size += aToAdd; -} - - -int HStream::readBytes(byte * buf, int aToRead) -{ - if (aToRead >= (size - pos)) - aToRead = size - pos; - for (int i = 0; i < aToRead; i++) - buf[i] = seq[pos++]; - return aToRead; -} - - -int HStream::skipBytes(int aToSkip) -{ - if (aToSkip >= (size - pos)) - aToSkip = size - pos; - pos += aToSkip; - return aToSkip; -} - - -int HStream::available() const -{ - return size - pos; -} - - -void HStream::closeInput() -{ -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/hwpfilter/source/hstream.cxx b/hwpfilter/source/hstream.cxx new file mode 100644 index 000000000000..c6b8c24a2152 --- /dev/null +++ b/hwpfilter/source/hstream.cxx @@ -0,0 +1,83 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include +#include +#include "hstream.h" + +HStream::HStream() : size(0), pos(0) +{ + seq = 0; +} + + +HStream::~HStream() +{ + if( seq ) + free( seq ); +} + + +void HStream::addData( const byte *buf, int aToAdd) +{ + seq = (byte *)realloc( seq, size + aToAdd ); + memcpy( seq + size, buf, aToAdd ); + size += aToAdd; +} + + +int HStream::readBytes(byte * buf, int aToRead) +{ + if (aToRead >= (size - pos)) + aToRead = size - pos; + for (int i = 0; i < aToRead; i++) + buf[i] = seq[pos++]; + return aToRead; +} + + +int HStream::skipBytes(int aToSkip) +{ + if (aToSkip >= (size - pos)) + aToSkip = size - pos; + pos += aToSkip; + return aToSkip; +} + + +int HStream::available() const +{ + return size - pos; +} + + +void HStream::closeInput() +{ +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/hwpfilter/source/hstyle.cpp b/hwpfilter/source/hstyle.cpp deleted file mode 100644 index 8cce811067a0..000000000000 --- a/hwpfilter/source/hstyle.cpp +++ /dev/null @@ -1,154 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "precompile.h" - -#include "hwplib.h" -#include "hwpfile.h" -#include "hstyle.h" - -enum -{ MAXSTYLENAME = 20 }; - -#define DATA ((StyleData *)style) - -struct StyleData -{ - char name[MAXSTYLENAME + 1]; - CharShape cshape; - ParaShape pshape; -}; - -static char buffer[MAXSTYLENAME + 1]; - -HWPStyle::HWPStyle(void) -{ - nstyles = 0; - style = 0; -} - - -HWPStyle::~HWPStyle(void) -{ - delete[]DATA; - nstyles = 0; -} - - -int HWPStyle::Num(void) const -{ - return nstyles; -} - - -char *HWPStyle::GetName(int n) const -{ - if (!(n >= 0 && n < nstyles)) - return 0; - return DATA[n].name; -} - - -void HWPStyle::SetName(int n, char *name) -{ - if (n >= 0 && n < nstyles) - { - if (name) - strncpy(DATA[n].name, name, MAXSTYLENAME); - else - DATA[n].name[0] = 0; - } -} - - -CharShape *HWPStyle::GetCharShape(int n) const -{ - if (!(n >= 0 && n < nstyles)) - return 0; - return &DATA[n].cshape; -} - - -void HWPStyle::SetCharShape(int n, CharShape * cshapep) -{ - if (n >= 0 && n < nstyles) - { - if (cshapep) - DATA[n].cshape = *cshapep; - else - memset(&DATA[n].cshape, 0, sizeof(CharShape)); - } -} - - -ParaShape *HWPStyle::GetParaShape(int n) const -{ - if (!(n >= 0 && n < nstyles)) - return 0; - return &DATA[n].pshape; -} - - -void HWPStyle::SetParaShape(int n, ParaShape * pshapep) -{ - if (n >= 0 && n < nstyles) - { - if (pshapep) - DATA[n].pshape = *pshapep; - else - memset(&DATA[n].pshape, 0, sizeof(ParaShape)); - } -} - - -bool HWPStyle::Read(HWPFile & hwpf) -{ - CharShape cshape; - ParaShape pshape; - - hwpf.Read2b(&nstyles, 1); - style = new StyleData[nstyles]; - if (!style) - return false; - - for (int ii = 0; ii < nstyles; ii++) - { - hwpf.ReadBlock(buffer, MAXSTYLENAME); - cshape.Read(hwpf); - pshape.Read(hwpf); - - SetName(ii, buffer); - SetCharShape(ii, &cshape); - SetParaShape(ii, &pshape); - if (hwpf.State()) - return false; - } - return true; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/hwpfilter/source/hstyle.cxx b/hwpfilter/source/hstyle.cxx new file mode 100644 index 000000000000..8cce811067a0 --- /dev/null +++ b/hwpfilter/source/hstyle.cxx @@ -0,0 +1,154 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "precompile.h" + +#include "hwplib.h" +#include "hwpfile.h" +#include "hstyle.h" + +enum +{ MAXSTYLENAME = 20 }; + +#define DATA ((StyleData *)style) + +struct StyleData +{ + char name[MAXSTYLENAME + 1]; + CharShape cshape; + ParaShape pshape; +}; + +static char buffer[MAXSTYLENAME + 1]; + +HWPStyle::HWPStyle(void) +{ + nstyles = 0; + style = 0; +} + + +HWPStyle::~HWPStyle(void) +{ + delete[]DATA; + nstyles = 0; +} + + +int HWPStyle::Num(void) const +{ + return nstyles; +} + + +char *HWPStyle::GetName(int n) const +{ + if (!(n >= 0 && n < nstyles)) + return 0; + return DATA[n].name; +} + + +void HWPStyle::SetName(int n, char *name) +{ + if (n >= 0 && n < nstyles) + { + if (name) + strncpy(DATA[n].name, name, MAXSTYLENAME); + else + DATA[n].name[0] = 0; + } +} + + +CharShape *HWPStyle::GetCharShape(int n) const +{ + if (!(n >= 0 && n < nstyles)) + return 0; + return &DATA[n].cshape; +} + + +void HWPStyle::SetCharShape(int n, CharShape * cshapep) +{ + if (n >= 0 && n < nstyles) + { + if (cshapep) + DATA[n].cshape = *cshapep; + else + memset(&DATA[n].cshape, 0, sizeof(CharShape)); + } +} + + +ParaShape *HWPStyle::GetParaShape(int n) const +{ + if (!(n >= 0 && n < nstyles)) + return 0; + return &DATA[n].pshape; +} + + +void HWPStyle::SetParaShape(int n, ParaShape * pshapep) +{ + if (n >= 0 && n < nstyles) + { + if (pshapep) + DATA[n].pshape = *pshapep; + else + memset(&DATA[n].pshape, 0, sizeof(ParaShape)); + } +} + + +bool HWPStyle::Read(HWPFile & hwpf) +{ + CharShape cshape; + ParaShape pshape; + + hwpf.Read2b(&nstyles, 1); + style = new StyleData[nstyles]; + if (!style) + return false; + + for (int ii = 0; ii < nstyles; ii++) + { + hwpf.ReadBlock(buffer, MAXSTYLENAME); + cshape.Read(hwpf); + pshape.Read(hwpf); + + SetName(ii, buffer); + SetCharShape(ii, &cshape); + SetParaShape(ii, &pshape); + if (hwpf.State()) + return false; + } + return true; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/hwpfilter/source/htags.cpp b/hwpfilter/source/htags.cpp deleted file mode 100644 index 30244a83f9b8..000000000000 --- a/hwpfilter/source/htags.cpp +++ /dev/null @@ -1,167 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "precompile.h" - -#ifdef __GNUG__ -#pragma implementation "htags.h" -#endif - -#include - -#include "hwplib.h" -#include "hwpfile.h" -#include "htags.h" -#include "himgutil.h" - -bool HyperText::Read(HWPFile & hwpf) -{ - hwpf.Read1b(filename, 256); - hwpf.Read2b(bookmark, 16); - hwpf.Read1b(macro, 325); - hwpf.Read1b(&type, 1); - hwpf.Read1b(reserve, 3); - if( type == 2 ) - { - for( int i = 1; i < 256; i++) - { - filename[i-1] = filename[i]; - if( filename[i] == 0 ) - break; - } - } - return true; -} - - -EmPicture::EmPicture(int tsize):size(tsize - 32) -{ - if (size <= 0) - data = 0; - else - data = new uchar[size]; -} -#ifdef WIN32 -#define unlink _unlink -#endif -EmPicture::~EmPicture(void) -{ -// clear temporary image file - char *fname = (char *) GetEmbImgname(this); - - if (fname && access(fname, 0) == 0) - unlink(fname); - if (data) - delete[]data; -}; - -bool EmPicture::Read(HWPFile & hwpf) -{ - if (size <= 0) - return false; - hwpf.Read1b(name, 16); - hwpf.Read1b(type, 16); - name[0] = 'H'; - name[1] = 'W'; - name[2] = 'P'; - if (hwpf.ReadBlock(data, size) == 0) - return false; - return true; -} - - -OlePicture::OlePicture(int tsize) -{ - size = tsize - 4; - if (size <= 0) - return; -#ifdef WIN32 - pis = 0L; -#else - pis = new char[size]; -#endif -}; - -OlePicture::~OlePicture(void) -{ -#ifdef WIN32 - if( pis ) - pis->Release(); -#else - delete[] pis; -#endif -}; - -#define FILESTG_SIGNATURE_NORMAL 0xF8995568 - -bool OlePicture::Read(HWPFile & hwpf) -{ - if (size <= 0) - return false; - -// We process only FILESTG_SIGNATURE_NORMAL. - hwpf.Read4b(&signature, 1); - if (signature != FILESTG_SIGNATURE_NORMAL) - return false; -#ifdef WIN32 - char *data = new char[size]; - if( data == 0 || hwpf.ReadBlock(data,size) == 0 ) - { - delete [] data; - return false; - } - FILE *fp; - char tname[200]; - wchar_t wtname[200]; - tmpnam(tname); - if (0 == (fp = fopen(tname, "wb"))) - { - delete [] data; - return false; - } - fwrite(data, size, 1, fp); - delete [] data; - fclose(fp); - MultiByteToWideChar(CP_ACP, 0, tname, -1, wtname, 200); - if( StgOpenStorage(wtname, NULL, - STGM_READWRITE|STGM_SHARE_EXCLUSIVE|STGM_TRANSACTED, - NULL, 0, &pis) != S_OK ) { - pis = 0; - unlink(tname); - return false; - } - unlink(tname); -#else - if (pis == 0 || hwpf.ReadBlock(pis, size) == 0) - return false; -#endif - - return true; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/hwpfilter/source/htags.cxx b/hwpfilter/source/htags.cxx new file mode 100644 index 000000000000..30244a83f9b8 --- /dev/null +++ b/hwpfilter/source/htags.cxx @@ -0,0 +1,167 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "precompile.h" + +#ifdef __GNUG__ +#pragma implementation "htags.h" +#endif + +#include + +#include "hwplib.h" +#include "hwpfile.h" +#include "htags.h" +#include "himgutil.h" + +bool HyperText::Read(HWPFile & hwpf) +{ + hwpf.Read1b(filename, 256); + hwpf.Read2b(bookmark, 16); + hwpf.Read1b(macro, 325); + hwpf.Read1b(&type, 1); + hwpf.Read1b(reserve, 3); + if( type == 2 ) + { + for( int i = 1; i < 256; i++) + { + filename[i-1] = filename[i]; + if( filename[i] == 0 ) + break; + } + } + return true; +} + + +EmPicture::EmPicture(int tsize):size(tsize - 32) +{ + if (size <= 0) + data = 0; + else + data = new uchar[size]; +} +#ifdef WIN32 +#define unlink _unlink +#endif +EmPicture::~EmPicture(void) +{ +// clear temporary image file + char *fname = (char *) GetEmbImgname(this); + + if (fname && access(fname, 0) == 0) + unlink(fname); + if (data) + delete[]data; +}; + +bool EmPicture::Read(HWPFile & hwpf) +{ + if (size <= 0) + return false; + hwpf.Read1b(name, 16); + hwpf.Read1b(type, 16); + name[0] = 'H'; + name[1] = 'W'; + name[2] = 'P'; + if (hwpf.ReadBlock(data, size) == 0) + return false; + return true; +} + + +OlePicture::OlePicture(int tsize) +{ + size = tsize - 4; + if (size <= 0) + return; +#ifdef WIN32 + pis = 0L; +#else + pis = new char[size]; +#endif +}; + +OlePicture::~OlePicture(void) +{ +#ifdef WIN32 + if( pis ) + pis->Release(); +#else + delete[] pis; +#endif +}; + +#define FILESTG_SIGNATURE_NORMAL 0xF8995568 + +bool OlePicture::Read(HWPFile & hwpf) +{ + if (size <= 0) + return false; + +// We process only FILESTG_SIGNATURE_NORMAL. + hwpf.Read4b(&signature, 1); + if (signature != FILESTG_SIGNATURE_NORMAL) + return false; +#ifdef WIN32 + char *data = new char[size]; + if( data == 0 || hwpf.ReadBlock(data,size) == 0 ) + { + delete [] data; + return false; + } + FILE *fp; + char tname[200]; + wchar_t wtname[200]; + tmpnam(tname); + if (0 == (fp = fopen(tname, "wb"))) + { + delete [] data; + return false; + } + fwrite(data, size, 1, fp); + delete [] data; + fclose(fp); + MultiByteToWideChar(CP_ACP, 0, tname, -1, wtname, 200); + if( StgOpenStorage(wtname, NULL, + STGM_READWRITE|STGM_SHARE_EXCLUSIVE|STGM_TRANSACTED, + NULL, 0, &pis) != S_OK ) { + pis = 0; + unlink(tname); + return false; + } + unlink(tname); +#else + if (pis == 0 || hwpf.ReadBlock(pis, size) == 0) + return false; +#endif + + return true; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/hwpfilter/source/hutil.cpp b/hwpfilter/source/hutil.cpp deleted file mode 100644 index 2827bda4e88a..000000000000 --- a/hwpfilter/source/hutil.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "precompile.h" - -#include -#include "hwpfile.h" -#include "hbox.h" - -static char *get_one_roman(int num, char one, char five, char ten, char *str) -{ - static const char *one_strs[] = - { - "", "i", "ii", "iii", "iv", "v", "vi", "vii", "viii", "ix" - }; - - strcpy(str, one_strs[num]); - while (*str) - { - switch (*str) - { - case 'i': - *str = one; - break; - case 'v': - *str = five; - break; - case 'x': - *str = ten; - } - str++; - } - return str; -} - - -void num2roman(int num, char *buf) -{ - char *pt; - - pt = get_one_roman((num / 100) % 10, 'c', 'd', 'm', buf); - pt = get_one_roman((num / 10) % 10, 'x', 'l', 'c', pt); - get_one_roman(num % 10, 'i', 'v', 'x', pt); -} - - -void str2hstr(const char *c, hchar * i) -{ - hchar ch; - - while( 0 != (ch = *c++)) - { - if (ch & 0x80) - { - if (*c > 32) - { - *i++ = (ch << 8) | *c; - c++; - } - } - else - *i++ = ch; - } - *i = 0; -} - - -int hstrlen(const hchar * s) -{ - register int n = 0; - - while (*s++) - n++; - return (n); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/hwpfilter/source/hutil.cxx b/hwpfilter/source/hutil.cxx new file mode 100644 index 000000000000..2827bda4e88a --- /dev/null +++ b/hwpfilter/source/hutil.cxx @@ -0,0 +1,102 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "precompile.h" + +#include +#include "hwpfile.h" +#include "hbox.h" + +static char *get_one_roman(int num, char one, char five, char ten, char *str) +{ + static const char *one_strs[] = + { + "", "i", "ii", "iii", "iv", "v", "vi", "vii", "viii", "ix" + }; + + strcpy(str, one_strs[num]); + while (*str) + { + switch (*str) + { + case 'i': + *str = one; + break; + case 'v': + *str = five; + break; + case 'x': + *str = ten; + } + str++; + } + return str; +} + + +void num2roman(int num, char *buf) +{ + char *pt; + + pt = get_one_roman((num / 100) % 10, 'c', 'd', 'm', buf); + pt = get_one_roman((num / 10) % 10, 'x', 'l', 'c', pt); + get_one_roman(num % 10, 'i', 'v', 'x', pt); +} + + +void str2hstr(const char *c, hchar * i) +{ + hchar ch; + + while( 0 != (ch = *c++)) + { + if (ch & 0x80) + { + if (*c > 32) + { + *i++ = (ch << 8) | *c; + c++; + } + } + else + *i++ = ch; + } + *i = 0; +} + + +int hstrlen(const hchar * s) +{ + register int n = 0; + + while (*s++) + n++; + return (n); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/hwpfilter/source/hwp.component b/hwpfilter/source/hwp.component index 5280cfbbd46b..972c6a61d5b3 100644 --- a/hwpfilter/source/hwp.component +++ b/hwpfilter/source/hwp.component @@ -30,5 +30,6 @@ xmlns="http://openoffice.org/2010/uno-components"> + diff --git a/hwpfilter/source/hwpeq.cpp b/hwpfilter/source/hwpeq.cpp deleted file mode 100644 index 0808d5100b55..000000000000 --- a/hwpfilter/source/hwpeq.cpp +++ /dev/null @@ -1,754 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * - ************************************************************************/ - -#include -#include -#include -#include - -// DVO: always use standard headers: -#include -#include -using namespace std; - -#include "mzstring.h" -#include "hwpeq.h" -#include -#include - -/* @Man: hwp LaTeX ٲٱ */ -#ifdef WIN32 -# define ENDL "\r\n" -#else /* !WIN32 */ -# define ENDL "\n" -#endif - -#define WS " \t\r\n\v\f" - -#define EQ_CASE 0x01 // case sensitive cmd -#define EQ_ENV 0x02 // equiv to latex environment -#define EQ_ATOP 0x04 // must revert order - -#define IS_WS(ch) (strchr(WS, ch)) -#define IS_BINARY(ch) (strchr("+-<=>", ch)) - -#ifdef WIN32 -#define STRICMP stricmp -#else -#define STRICMP strcasecmp -#endif - -// sub and sup scipt script status -enum { SCRIPT_NONE, SCRIPT_SUB, SCRIPT_SUP, SCRIPT_ALL}; - -static int eq_word(MzString& outs, istream *strm, int script = SCRIPT_NONE); -static bool eq_sentence(MzString& outs, istream *strm, const char *end = 0); - -struct hwpeq { - const char *key; // hwp math keyword - const char *latex; // corresponding latex keywork - int nargs; // # of argument - unsigned char flag; // case sensitive? -}; - -static hwpeq eq_tbl[] = { - { "!=", "\\equiv ", 0, 0 }, - { "#", "\\\\", 0, 0 }, - { "+-", "\\pm ", 0, 0 }, - { "-+", "\\mp ", 0, 0 }, - { "<=", "\\leq ", 0, 0 }, - { "==", "\\equiv ", 0, 0 }, - { ">=", "\\geq ", 0, 0 }, - { "Pr", NULL, 0, 0 }, - { "^", "^", 1, 0 }, - { "_", "_", 1, 0 }, - { "`", "\\;", 0, 0 }, - { "acute", NULL, 1, 0 }, - { "aleph", NULL, 0, 0 }, - { "alpha", NULL, 0, EQ_CASE }, - { "amalg", NULL, 0, 0 }, - { "and", NULL, 0, 0 }, - { "angle", NULL, 0, 0 }, - { "angstrom", NULL, 0, 0 }, - { "approx", NULL, 0, 0 }, - { "arc", NULL, 0, 0 }, - { "arccos", NULL, 0, 0 }, - { "arch", NULL, 0, 0 }, - { "arcsin", NULL, 0, 0 }, - { "arctan", NULL, 0, 0 }, - { "arg", NULL, 0, 0 }, - { "assert", "\\vdash", 0, 0 }, - { "ast", NULL, 0, 0 }, - { "asymp", NULL, 0, 0 }, - { "atop", NULL, 1, EQ_ATOP }, - { "backslash", NULL, 0, 0 }, - { "bar", NULL, 1, 0 }, - { "because", NULL, 0, 0 }, - { "beta", NULL, 0, EQ_CASE }, - { "big", NULL, 0, EQ_CASE }, - { "bigcap", NULL, 0, 0 }, - { "bigcirc", NULL, 0, 0 }, - { "bigcup", NULL, 0, 0 }, - { "bigg", NULL, 0, EQ_CASE }, - { "bigodiv", NULL, 0, 0 }, - { "bigodot", NULL, 0, 0 }, - { "bigominus", NULL, 0, 0 }, - { "bigoplus", NULL, 0, 0 }, - { "bigotimes", NULL, 0, 0 }, - { "bigsqcap", NULL, 0, 0 }, - { "bigsqcup", NULL, 0, 0 }, - { "biguplus", NULL, 0, 0 }, - { "bigvee", NULL, 0, 0 }, - { "bigwedge", NULL, 0, 0 }, - { "binom", NULL, 2, 0 }, - { "bmatrix", NULL, 0, EQ_ENV }, - { "bold", NULL, 0, 0 }, - { "bot", NULL, 0, 0 }, - { "breve", NULL, 1, 0 }, - { "buildrel", NULL, 0, 0 }, // LATER - { "bullet", NULL, 0, 0 }, - { "cap", NULL, 0, 0 }, - { "cases", NULL, 0, EQ_ENV }, - { "ccol", NULL, 0, 0 }, /* η  */ - { "cdot", NULL, 0, 0 }, - { "cdots", NULL, 0, 0 }, - { "check", NULL, 1, 0 }, - { "chi", NULL, 0, EQ_CASE }, - { "choose", NULL, 0, EQ_ATOP }, - { "circ", NULL, 0, 0 }, - { "col", NULL, 0, 0 }, // LATER - { "cong", NULL, 0, 0 }, - { "coprod", NULL, 0, 0 }, - { "cos", NULL, 0, 0 }, - { "cosec", NULL, 0, 0 }, - { "cosh", NULL, 0, 0 }, - { "cot", NULL, 0, 0 }, - { "coth", NULL, 0, 0 }, - { "cpile", NULL, 0, 0 }, // LATER - { "csc", NULL, 0, 0 }, - { "cup", NULL, 0, 0 }, - { "dagger", NULL, 0, 0 }, - { "dashv", NULL, 0, 0 }, - { "ddagger", NULL, 0, 0 }, - { "ddot", NULL, 1, 0 }, - { "ddots", NULL, 0, 0 }, - { "def", NULL, 0, 0 }, - { "deg", NULL, 0, 0 }, - { "del", NULL, 0, 0 }, - { "delta", NULL, 0, EQ_CASE }, - { "diamond", NULL, 0, 0 }, - { "dim", NULL, 0, 0 }, - { "div", NULL, 0, 0 }, - { "divide", NULL, 0, 0 }, - { "dline", NULL, 0, 0 }, - { "dmatrix", NULL, 0, EQ_ENV }, - { "dot", NULL, 1, 0 }, - { "doteq", NULL, 0, 0 }, - { "dotsaxis", NULL, 0, 0 }, - { "dotsdiag", NULL, 0, 0 }, - { "dotslow", "\\ldots", 0, 0 }, - { "dotsvert", "\\vdots", 0, 0 }, - { "downarrow", NULL, 0, EQ_CASE }, - { "dsum", "+", 0, 0 }, - { "dyad", NULL, 0, 0 }, // LATER - { "ell", NULL, 0, 0 }, - { "emptyset", NULL, 0, 0 }, - { "epsilon", NULL, 0, EQ_CASE }, - { "eqalign", NULL, 0, EQ_ENV }, - { "equiv", NULL, 0, 0 }, - { "eta", NULL, 0, EQ_CASE }, - { "exarrow", NULL, 0, 0 }, - { "exist", "\\exists", 0, 0 }, - { "exists", NULL, 0, 0 }, - { "exp", NULL, 0, EQ_CASE }, - { "for", NULL, 0, 0 }, - { "forall", NULL, 0, 0 }, - { "from", "_", 1, 0 }, - { "gamma", NULL, 0, EQ_CASE }, - { "gcd", NULL, 0, 0 }, - { "ge", "\\geq", 0, 0 }, - { "geq", NULL, 0, 0 }, - { "ggg", NULL, 0, 0 }, - { "grad", NULL, 0, 0 }, - { "grave", NULL, 1, 0 }, - { "hat", "\\widehat", 1, 0 }, - { "hbar", NULL, 0, 0 }, - { "hom", NULL, 0, 0 }, - { "hookleft", NULL, 0, 0 }, - { "hookright", NULL, 0, 0 }, - { "identical", NULL, 0, 0 }, // LATER - { "if", NULL, 0, 0 }, - { "imag", NULL, 0, 0 }, - { "image", NULL, 0, 0 }, - { "imath", NULL, 0, 0 }, - { "in", NULL, 0, 0 }, - { "inf", "\\infty", 0, 0 }, - { "infinity", "\\infty", 0, 0 }, - { "infty", NULL, 0, 0 }, - { "int", NULL, 0, 0 }, - { "integral", "\\int", 0, 0 }, - { "inter", "\\bigcap", 0, 0 }, - { "iota", NULL, 0, EQ_CASE }, - { "iso", NULL, 0, 0 }, // ams - { "it", NULL, 0, 0 }, - { "jmath", NULL, 0, 0 }, - { "kappa", NULL, 0, EQ_CASE }, - { "ker", NULL, 0, 0 }, - { "lambda", NULL, 0, EQ_CASE }, - { "land", NULL, 0, 0 }, // LATER - { "langle", NULL, 0, 0 }, - { "larrow", "\\leftarrow", 0, EQ_CASE }, - { "lbrace", NULL, 0, 0 }, - { "lbrack", "[", 0, 0 }, - { "lceil", NULL, 0, 0 }, - { "lcol", NULL, 0, 0 }, // LATER - { "ldots", NULL, 0, 0 }, - { "le", NULL, 0, 0 }, - { "left", NULL, 0, 0 }, - { "leftarrow", NULL, 0, EQ_CASE }, - { "leq", NULL, 0, 0 }, - { "lfloor", NULL, 0, 0 }, - { "lg", NULL, 0, 0 }, - { "lim", NULL, 0, EQ_CASE }, - { "line", "\\vert", 0, 0 }, - { "liter", "\\ell", 0, 0 }, - { "lll", NULL, 0, 0 }, // ams - { "ln", NULL, 0, 0 }, - { "log", NULL, 0, 0 }, - { "lor", "\\vee", 0, 0 }, - { "lparen", "(", 0, 0 }, - { "lpile", NULL, 0, 0 }, // LATER - { "lrarrow", "\\leftrightarrow", 0, EQ_CASE }, - { "lrharpoons", "\\leftrightharpoons",0, 0 }, - { "mapsto", NULL, 0, 0 }, - { "massert", "\\dashv", 0, 0 }, - { "matrix", NULL, 0, EQ_ENV }, - { "max", NULL, 0, 0 }, - { "mho", NULL, 0, 0 }, // ams - { "min", NULL, 0, 0 }, - { "minusplus", NULL, 0, 0 }, - { "mit", "", 0, 0 }, // font - { "mod", "\\bmod", 0, 0 }, - { "models", NULL, 0, 0 }, - { "msangle", NULL, 0, 0 }, // LATER - { "mu", NULL, 0, EQ_CASE }, - { "nabla", NULL, 0, 0 }, - { "ne", NULL, 0, 0 }, - { "nearrow", NULL, 0, 0 }, - { "neg", NULL, 0, 0 }, - { "neq", NULL, 0, 0 }, - { "nequiv", NULL, 0, 0 }, - { "ni", NULL, 0, 0 }, - { "not", NULL, 0, 0 }, - { "notin", NULL, 0, 0 }, - { "nu", NULL, 0, EQ_CASE }, - { "nwarrow", NULL, 0, 0 }, - { "odiv", NULL, 0, 0 }, - { "odot", NULL, 0, 0 }, - { "oint", NULL, 0, 0 }, - { "omega", NULL, 0, EQ_CASE }, - { "omicron", NULL, 0, EQ_CASE }, - { "ominus", NULL, 0, 0 }, - { "oplus", NULL, 0, 0 }, - { "or ", NULL, 0, 0 }, - { "oslash", NULL, 0, 0 }, - { "otimes", NULL, 0, 0 }, - { "over", NULL, 1, EQ_ATOP }, - { "overline", NULL, 1, 0 }, - { "owns", "\\ni", 0, 0 }, - { "parallel", NULL, 0, 0 }, - { "partial", NULL, 0, 0 }, - { "phantom", NULL, 0, 0 }, - { "phi", NULL, 0, EQ_CASE }, - { "pi", NULL, 0, EQ_CASE }, - { "pile", NULL, 0, 0 }, // LATER - { "plusminus", "\\pm", 0, 0 }, - { "pmatrix", NULL, 0, EQ_ENV }, - { "prec", NULL, 0, 0 }, - { "prep", NULL, 0, 0 }, - { "prime", NULL, 0, 0 }, - { "prod", NULL, 0, 0 }, - { "propto", NULL, 0, 0 }, - { "psi", NULL, 0, EQ_CASE }, - { "rangle", NULL, 0, 0 }, - { "rarrow", "\\rightarrow", 0, EQ_CASE }, - { "rbrace", "]", 0, 0 }, - { "rbrace", NULL, 0, 0 }, - { "rceil", NULL, 0, 0 }, - { "rcol", NULL, 0, 0 }, // LATER - { "real", "\\Re", 0, 0 }, - { "reimage", NULL, 0, 0 }, - { "rel", NULL, 0, 0 }, - { "rfloor", NULL, 0, 0 }, - { "rho", NULL, 0, EQ_CASE }, - { "right", NULL, 0, 0 }, - { "rightarrow", NULL, 0, EQ_CASE }, - { "rlharpoons", NULL, 0, 0 }, - { "rm", NULL, 0, 0 }, - { "root", "\\sqrt", 1, 0 }, - { "rparen", ")", 0, 0 }, - { "rpile", NULL, 0, 0 }, // LATER - { "rtangle", NULL, 0, 0 }, - { "sangle", NULL, 0, 0 }, - { "scale", NULL, 0, 0 }, - { "searrow", NULL, 0, 0 }, - { "sec", NULL, 0, 0 }, - { "sigma", NULL, 0, EQ_CASE }, - { "sim", NULL, 0, 0 }, - { "simeq", NULL, 0, 0 }, - { "sin", NULL, 0, 0 }, - { "sinh", NULL, 0, 0 }, - { "slash", NULL, 0, 0 }, - { "smallint", NULL, 0, 0 }, - { "smallinter", NULL, 0, 0 }, - { "smalloint", NULL, 0, 0 }, - { "smallprod", NULL, 0, 0 }, - { "smallsum", NULL, 0, 0 }, - { "smallunion", NULL, 0, 0 }, - { "smcoprod", NULL, 0, 0 }, - { "sqcap", NULL, 0, 0 }, - { "sqcup", NULL, 0, 0 }, - { "sqrt", NULL, 1, 0 }, - { "sqsubset", NULL, 0, 0 }, - { "sqsubseteq", NULL, 0, 0 }, - { "sqsupset", NULL, 0, 0 }, - { "sqsupseteq", NULL, 0, 0 }, - { "star", NULL, 0, 0 }, - { "sub", "_", 0, 0 }, - { "subset", NULL, 0, 0 }, - { "subseteq", NULL, 0, 0 }, - { "succ", NULL, 0, 0 }, - { "sum", NULL, 0, 0 }, - { "sup", "^", 0, 0 }, - { "superset", NULL, 0, 0 }, - { "supset", NULL, 0, 0 }, - { "supseteq", NULL, 0, 0 }, - { "swarrow", NULL, 0, 0 }, - { "tan", NULL, 0, 0 }, - { "tanh", NULL, 0, 0 }, - { "tau", NULL, 0, EQ_CASE }, - { "therefore", NULL, 0, 0 }, - { "theta", NULL, 0, EQ_CASE }, - { "tilde", "\\widetilde", 1, 0 }, - { "times", NULL, 0, 0 }, - { "to", "^", 1, 0 }, - { "top", NULL, 0, 0 }, - { "triangle", NULL, 0, 0 }, - { "triangled", NULL, 0, 0 }, - { "trianglel", NULL, 0, 0 }, - { "triangler", NULL, 0, 0 }, - { "triangleu", NULL, 0, 0 }, - { "udarrow", "\\updownarrow",0, EQ_CASE }, - { "under", "\\underline", 1, 0 }, - { "underline", "\\underline", 1, 0 }, - { "union", "\\bigcup", 0, 0 }, - { "uparrow", NULL, 0, EQ_CASE }, - { "uplus", NULL, 0, 0 }, - { "upsilon", NULL, 0, EQ_CASE }, - { "varepsilon", NULL, 0, 0 }, - { "varphi", NULL, 0, 0 }, - { "varpi", NULL, 0, 0 }, - { "varrho", NULL, 0, 0 }, - { "varsigma", NULL, 0, 0 }, - { "vartheta", NULL, 0, 0 }, - { "varupsilon", NULL, 0, 0 }, - { "vdash", NULL, 0, 0 }, - { "vdots", NULL, 0, 0 }, - { "vec", NULL, 1, 0 }, - { "vee", NULL, 0, 0 }, - { "vert", NULL, 0, 0 }, - { "wedge", NULL, 0, 0 }, - { "wp", NULL, 0, 0 }, - { "xi", NULL, 0, EQ_CASE }, - { "xor", NULL, 0, 0 }, - { "zeta", NULL, 0, EQ_CASE } -}; - -static hwpeq *lookup_eqn(char *str) -{ - static int eqCount = SAL_N_ELEMENTS(eq_tbl); - int m, k, l = 0, r = eqCount; - hwpeq *result = 0; - - while( l < r ) { - m = (l + r) / 2; - k = strcmp(eq_tbl[m].key, str); - if( k == 0 ) { - result = eq_tbl + m;; - break; - } - else if( k < 0 ) - l = m + 1; - else - r = m; - } - return result; -} - -/* ùڸ 빮̰ų 빮ڸ ҹڷ ٲ۴. */ - -static char *make_keyword( char *keyword, const char *token) -{ - assert(keyword); - char *ptr; - int result = true, len = strlen(token); - - if( 255 < len ) - strncpy(keyword, token, 255); - else - strcpy(keyword, token); - - if( (token[0] & 0x80) || islower(token[0]) || - strlen(token) < 2 ) - return keyword; - - int capital = isupper(keyword[1]); - for( ptr = keyword + 2; *ptr && result; ptr++ ) - if( (*ptr & 0x80) || - (!capital && isupper(*ptr)) || - (capital && islower(*ptr)) ) - result = false; - - if( result ) { - ptr = keyword; - while( *ptr ) { - if( isupper(*ptr) ) - *ptr = sal::static_int_cast(tolower(*ptr)); - ptr++; - } - } - return keyword; -} - -// token reading funtion -struct eq_stack { - MzString white; - MzString token; - istream *strm; - - eq_stack() { strm = 0; }; - bool state(istream *s) { - if( strm != s) { white = 0; token = 0; } - return token.length() != 0; - } -}; - -static eq_stack *stk = 0; - -void push_token(MzString &white, MzString &token, istream *strm) -{ - // one time stack - assert(stk->state(strm) == false); - - stk->white = white; - stk->token = token; - stk->strm = strm; -} - -/* ū ̸ ȯѴ. */ -/* control char, control sequence, binary sequence, - alphabet string, sigle character */ -static int next_token(MzString &white, MzString &token, istream *strm) -{ - register int ch = 0; - - if( stk->state(strm) ) { - white = stk->white; - token = stk->token; - stk->token = 0; - stk->white = 0; - return token.length(); - } - - token = 0; - white = 0; - if( !strm->good() || (ch = strm->get()) == EOF ) - return 0; - - // read preceeding ws - if( IS_WS(ch) ) { - do white << (char) ch; - while( IS_WS(ch = strm->get()) ); - } - - if( ch == '\\' || ch & 0x80 || isalpha(ch) ) { - if( ch == '\\' ) { - token << (char) ch; - ch = strm->get(); - } - do { - token << (char) ch; - ch = strm->get(); - } while( ch != EOF && (ch & 0x80 || isalpha(ch)) ) ; - strm->putback(sal::static_int_cast(ch)); - /* sub, sub, over, atop Ư ó - next_state() ġ ̴. - */ - if( !STRICMP("sub", token) || !STRICMP("from", token) || - !STRICMP("sup", token) || !STRICMP("to", token) || - !STRICMP("over", token) || !STRICMP("atop", token) || - !STRICMP("left", token) || !STRICMP("right", token) ) - { - char buf[256]; - make_keyword(buf, token); - token = buf; - } - if( !token.compare("sub") || !token.compare("from") ) - token = "_"; - if( !token.compare("sup") || !token.compare("to") ) - token = "^"; - } - else if( IS_BINARY(ch) ) { - do token << (char) ch; - while( IS_BINARY(ch = strm->get()) ); - strm->putback(sal::static_int_cast(ch)); - } - else if( isdigit(ch) ) { - do token << (char) ch; - while( isdigit(ch = strm->get()) ); - strm->putback(sal::static_int_cast(ch)); - } - else - token << (char) ch; - - return token.length(); -} - -static int read_white_space(MzString& outs, istream *strm) -{ - int result; - - if( stk->state(strm) ) { - outs << stk->white; - stk->white = 0; - result = stk->token[0]; - } - else { - int ch; - while( IS_WS(ch = strm->get()) ) - outs << (char )ch; - strm->putback(sal::static_int_cast(ch)); - result = ch; - } - return result; -} - -/* μ ʿ ׸ space brace - sqrt {ab}c = sqrt{ab} c - (, } grouping - ^, _ յڷ Ѵ. - - sqrt μ ִ - sqrt a -> sqrt{a} - sqrt {a} -> sqrt{a} - 1 ̻ μ ִ μ鰣 ش. - \frac a b -> frac{a}{b} - over - a over b -> {a}over{b} - */ - -static int eq_word(MzString& outs, istream *strm, int status) -{ - MzString token, white, state; - int result; - char keyword[256]; - hwpeq *eq; - - next_token(white, token, strm); - if (token.length() <= 0) - return 0; - result = token[0]; - - if( token.compare("{") == 0 ) { - state << white << token; - eq_sentence(state, strm, "}"); - } - else if( token.compare("left") == 0 ) { - state << white << token; - next_token(white, token, strm); - state << white << token; - - eq_sentence(state, strm, "right"); - - next_token(white, token, strm); - state << white << token; - } - else { - /* token */ - int script_status = SCRIPT_NONE; - while( 1 ) { - state << white << token; - make_keyword(keyword, token); - if( token[0] == '^' ) - script_status |= SCRIPT_SUP; - else if( token[0] == '_' ) - script_status |= SCRIPT_SUB; - else - script_status = SCRIPT_NONE; - - if( 0 != (eq = lookup_eqn(keyword)) ) { - int nargs = eq->nargs; - int ch; - while( nargs-- ) { - ch = read_white_space(state, strm); - if( ch != '{' ) state << '{'; - eq_word(state, strm, script_status); - if( ch != '{' ) state << '}'; - } - } - - if( !next_token(white, token, strm) ) - break; - // end loop and restart with this - if( (token[0] == '^' && status && !(status & SCRIPT_SUP)) || - (token[0] == '_' && status && !(status & SCRIPT_SUB)) || - strcmp("over", token) == 0 || strcmp("atop", token) == 0 || - strchr("{}#&`", token[0]) || - (!strchr("^_", token[0]) && white.length()) ) { - push_token(white, token, strm); - break; - } - } - } - outs << state; - - return result; -} - -static bool eq_sentence(MzString& outs, istream *strm, const char *end) -{ - MzString state; - MzString white, token; - bool multiline = false; - - read_white_space(outs, strm); - while( eq_word(state, strm) ) { - if( !next_token(white, token, strm) || - (end && strcmp(token.c_str(), end) == 0) ) - { - state << white << token; - break; - } - push_token(white, token, strm); - if( !token.compare("atop") || !token.compare("over") ) - outs << '{' << state << '}'; - else { - if( !token.compare("#") ) - multiline = true; - outs << state; - } - state = 0; - read_white_space(outs, strm); - } - outs << state; - return multiline; -} - -static char eq2ltxconv(MzString& sstr, istream *strm, const char *sentinel) -{ - MzString white, token; - char key[256]; - int ch, result; - hwpeq *eq = 0; - - while( 0 != (result = next_token(white, token, strm)) ) { - if( sentinel && (result == 1) && strchr(sentinel, token[0]) ) - break; - make_keyword(key, token); - if( (eq = lookup_eqn(key)) != 0 ) { - if( eq->latex ) - strcpy(key, eq->latex); - else { - key[0] = '\\'; - strcpy(key + 1, eq->key); - } - if( (eq->flag & EQ_CASE) && isupper(token[0]) ) - key[1] = sal::static_int_cast(toupper(key[1])); - token = key; - } - - if( token[0] == '{' ) { // grouping - sstr << white << token; - eq2ltxconv(sstr, strm, "}"); - sstr << '}'; - } - else if( eq && (eq->flag & EQ_ENV) ) { - next_token(white, token, strm); - if( token[0] != '{' ) return 0; - sstr << "\\begin" << "{" << eq->key << "}" << ENDL ; - eq2ltxconv(sstr, strm, "}"); - if( sstr[sstr.length() - 1] != '\n' ) - sstr << ENDL ; - sstr << "\\end" << "{" << eq->key << "}" << ENDL ; - } - else if( eq && (eq->flag & EQ_ATOP) ) { - if( sstr.length() == 0 ) - sstr << '{'; - else { - int pos = sstr.rfind('}'); - if( 0 < pos) - sstr.replace(pos, ' '); - } - sstr << token; - while( (ch = strm->get()) != EOF && IS_WS(ch) ) - sstr << (char)ch; - if( ch != '{' ) - sstr << "{}"; - else { - eq2ltxconv(sstr, strm, "}"); - sstr << '}'; - } - } - else - sstr << white << token; - } - return token[0]; -} - -void eq2latex(MzString& outs, char *s) -{ - assert(s); - if( stk == 0 ) - stk = new eq_stack; - - MzString tstr; - - istringstream tstrm(s); - bool eqnarray = eq_sentence(tstr, &tstrm); - istringstream strm(tstr.c_str()); - - if( eqnarray ) - outs << "\\begin{array}{rllll}" << ENDL; - eq2ltxconv(outs, &strm, 0); - outs << ENDL; - if( eqnarray ) - outs << "\\end{array}" << ENDL; - delete stk; - stk = 0; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/hwpfilter/source/hwpeq.cxx b/hwpfilter/source/hwpeq.cxx new file mode 100644 index 000000000000..0808d5100b55 --- /dev/null +++ b/hwpfilter/source/hwpeq.cxx @@ -0,0 +1,754 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * + ************************************************************************/ + +#include +#include +#include +#include + +// DVO: always use standard headers: +#include +#include +using namespace std; + +#include "mzstring.h" +#include "hwpeq.h" +#include +#include + +/* @Man: hwp LaTeX ٲٱ */ +#ifdef WIN32 +# define ENDL "\r\n" +#else /* !WIN32 */ +# define ENDL "\n" +#endif + +#define WS " \t\r\n\v\f" + +#define EQ_CASE 0x01 // case sensitive cmd +#define EQ_ENV 0x02 // equiv to latex environment +#define EQ_ATOP 0x04 // must revert order + +#define IS_WS(ch) (strchr(WS, ch)) +#define IS_BINARY(ch) (strchr("+-<=>", ch)) + +#ifdef WIN32 +#define STRICMP stricmp +#else +#define STRICMP strcasecmp +#endif + +// sub and sup scipt script status +enum { SCRIPT_NONE, SCRIPT_SUB, SCRIPT_SUP, SCRIPT_ALL}; + +static int eq_word(MzString& outs, istream *strm, int script = SCRIPT_NONE); +static bool eq_sentence(MzString& outs, istream *strm, const char *end = 0); + +struct hwpeq { + const char *key; // hwp math keyword + const char *latex; // corresponding latex keywork + int nargs; // # of argument + unsigned char flag; // case sensitive? +}; + +static hwpeq eq_tbl[] = { + { "!=", "\\equiv ", 0, 0 }, + { "#", "\\\\", 0, 0 }, + { "+-", "\\pm ", 0, 0 }, + { "-+", "\\mp ", 0, 0 }, + { "<=", "\\leq ", 0, 0 }, + { "==", "\\equiv ", 0, 0 }, + { ">=", "\\geq ", 0, 0 }, + { "Pr", NULL, 0, 0 }, + { "^", "^", 1, 0 }, + { "_", "_", 1, 0 }, + { "`", "\\;", 0, 0 }, + { "acute", NULL, 1, 0 }, + { "aleph", NULL, 0, 0 }, + { "alpha", NULL, 0, EQ_CASE }, + { "amalg", NULL, 0, 0 }, + { "and", NULL, 0, 0 }, + { "angle", NULL, 0, 0 }, + { "angstrom", NULL, 0, 0 }, + { "approx", NULL, 0, 0 }, + { "arc", NULL, 0, 0 }, + { "arccos", NULL, 0, 0 }, + { "arch", NULL, 0, 0 }, + { "arcsin", NULL, 0, 0 }, + { "arctan", NULL, 0, 0 }, + { "arg", NULL, 0, 0 }, + { "assert", "\\vdash", 0, 0 }, + { "ast", NULL, 0, 0 }, + { "asymp", NULL, 0, 0 }, + { "atop", NULL, 1, EQ_ATOP }, + { "backslash", NULL, 0, 0 }, + { "bar", NULL, 1, 0 }, + { "because", NULL, 0, 0 }, + { "beta", NULL, 0, EQ_CASE }, + { "big", NULL, 0, EQ_CASE }, + { "bigcap", NULL, 0, 0 }, + { "bigcirc", NULL, 0, 0 }, + { "bigcup", NULL, 0, 0 }, + { "bigg", NULL, 0, EQ_CASE }, + { "bigodiv", NULL, 0, 0 }, + { "bigodot", NULL, 0, 0 }, + { "bigominus", NULL, 0, 0 }, + { "bigoplus", NULL, 0, 0 }, + { "bigotimes", NULL, 0, 0 }, + { "bigsqcap", NULL, 0, 0 }, + { "bigsqcup", NULL, 0, 0 }, + { "biguplus", NULL, 0, 0 }, + { "bigvee", NULL, 0, 0 }, + { "bigwedge", NULL, 0, 0 }, + { "binom", NULL, 2, 0 }, + { "bmatrix", NULL, 0, EQ_ENV }, + { "bold", NULL, 0, 0 }, + { "bot", NULL, 0, 0 }, + { "breve", NULL, 1, 0 }, + { "buildrel", NULL, 0, 0 }, // LATER + { "bullet", NULL, 0, 0 }, + { "cap", NULL, 0, 0 }, + { "cases", NULL, 0, EQ_ENV }, + { "ccol", NULL, 0, 0 }, /* η  */ + { "cdot", NULL, 0, 0 }, + { "cdots", NULL, 0, 0 }, + { "check", NULL, 1, 0 }, + { "chi", NULL, 0, EQ_CASE }, + { "choose", NULL, 0, EQ_ATOP }, + { "circ", NULL, 0, 0 }, + { "col", NULL, 0, 0 }, // LATER + { "cong", NULL, 0, 0 }, + { "coprod", NULL, 0, 0 }, + { "cos", NULL, 0, 0 }, + { "cosec", NULL, 0, 0 }, + { "cosh", NULL, 0, 0 }, + { "cot", NULL, 0, 0 }, + { "coth", NULL, 0, 0 }, + { "cpile", NULL, 0, 0 }, // LATER + { "csc", NULL, 0, 0 }, + { "cup", NULL, 0, 0 }, + { "dagger", NULL, 0, 0 }, + { "dashv", NULL, 0, 0 }, + { "ddagger", NULL, 0, 0 }, + { "ddot", NULL, 1, 0 }, + { "ddots", NULL, 0, 0 }, + { "def", NULL, 0, 0 }, + { "deg", NULL, 0, 0 }, + { "del", NULL, 0, 0 }, + { "delta", NULL, 0, EQ_CASE }, + { "diamond", NULL, 0, 0 }, + { "dim", NULL, 0, 0 }, + { "div", NULL, 0, 0 }, + { "divide", NULL, 0, 0 }, + { "dline", NULL, 0, 0 }, + { "dmatrix", NULL, 0, EQ_ENV }, + { "dot", NULL, 1, 0 }, + { "doteq", NULL, 0, 0 }, + { "dotsaxis", NULL, 0, 0 }, + { "dotsdiag", NULL, 0, 0 }, + { "dotslow", "\\ldots", 0, 0 }, + { "dotsvert", "\\vdots", 0, 0 }, + { "downarrow", NULL, 0, EQ_CASE }, + { "dsum", "+", 0, 0 }, + { "dyad", NULL, 0, 0 }, // LATER + { "ell", NULL, 0, 0 }, + { "emptyset", NULL, 0, 0 }, + { "epsilon", NULL, 0, EQ_CASE }, + { "eqalign", NULL, 0, EQ_ENV }, + { "equiv", NULL, 0, 0 }, + { "eta", NULL, 0, EQ_CASE }, + { "exarrow", NULL, 0, 0 }, + { "exist", "\\exists", 0, 0 }, + { "exists", NULL, 0, 0 }, + { "exp", NULL, 0, EQ_CASE }, + { "for", NULL, 0, 0 }, + { "forall", NULL, 0, 0 }, + { "from", "_", 1, 0 }, + { "gamma", NULL, 0, EQ_CASE }, + { "gcd", NULL, 0, 0 }, + { "ge", "\\geq", 0, 0 }, + { "geq", NULL, 0, 0 }, + { "ggg", NULL, 0, 0 }, + { "grad", NULL, 0, 0 }, + { "grave", NULL, 1, 0 }, + { "hat", "\\widehat", 1, 0 }, + { "hbar", NULL, 0, 0 }, + { "hom", NULL, 0, 0 }, + { "hookleft", NULL, 0, 0 }, + { "hookright", NULL, 0, 0 }, + { "identical", NULL, 0, 0 }, // LATER + { "if", NULL, 0, 0 }, + { "imag", NULL, 0, 0 }, + { "image", NULL, 0, 0 }, + { "imath", NULL, 0, 0 }, + { "in", NULL, 0, 0 }, + { "inf", "\\infty", 0, 0 }, + { "infinity", "\\infty", 0, 0 }, + { "infty", NULL, 0, 0 }, + { "int", NULL, 0, 0 }, + { "integral", "\\int", 0, 0 }, + { "inter", "\\bigcap", 0, 0 }, + { "iota", NULL, 0, EQ_CASE }, + { "iso", NULL, 0, 0 }, // ams + { "it", NULL, 0, 0 }, + { "jmath", NULL, 0, 0 }, + { "kappa", NULL, 0, EQ_CASE }, + { "ker", NULL, 0, 0 }, + { "lambda", NULL, 0, EQ_CASE }, + { "land", NULL, 0, 0 }, // LATER + { "langle", NULL, 0, 0 }, + { "larrow", "\\leftarrow", 0, EQ_CASE }, + { "lbrace", NULL, 0, 0 }, + { "lbrack", "[", 0, 0 }, + { "lceil", NULL, 0, 0 }, + { "lcol", NULL, 0, 0 }, // LATER + { "ldots", NULL, 0, 0 }, + { "le", NULL, 0, 0 }, + { "left", NULL, 0, 0 }, + { "leftarrow", NULL, 0, EQ_CASE }, + { "leq", NULL, 0, 0 }, + { "lfloor", NULL, 0, 0 }, + { "lg", NULL, 0, 0 }, + { "lim", NULL, 0, EQ_CASE }, + { "line", "\\vert", 0, 0 }, + { "liter", "\\ell", 0, 0 }, + { "lll", NULL, 0, 0 }, // ams + { "ln", NULL, 0, 0 }, + { "log", NULL, 0, 0 }, + { "lor", "\\vee", 0, 0 }, + { "lparen", "(", 0, 0 }, + { "lpile", NULL, 0, 0 }, // LATER + { "lrarrow", "\\leftrightarrow", 0, EQ_CASE }, + { "lrharpoons", "\\leftrightharpoons",0, 0 }, + { "mapsto", NULL, 0, 0 }, + { "massert", "\\dashv", 0, 0 }, + { "matrix", NULL, 0, EQ_ENV }, + { "max", NULL, 0, 0 }, + { "mho", NULL, 0, 0 }, // ams + { "min", NULL, 0, 0 }, + { "minusplus", NULL, 0, 0 }, + { "mit", "", 0, 0 }, // font + { "mod", "\\bmod", 0, 0 }, + { "models", NULL, 0, 0 }, + { "msangle", NULL, 0, 0 }, // LATER + { "mu", NULL, 0, EQ_CASE }, + { "nabla", NULL, 0, 0 }, + { "ne", NULL, 0, 0 }, + { "nearrow", NULL, 0, 0 }, + { "neg", NULL, 0, 0 }, + { "neq", NULL, 0, 0 }, + { "nequiv", NULL, 0, 0 }, + { "ni", NULL, 0, 0 }, + { "not", NULL, 0, 0 }, + { "notin", NULL, 0, 0 }, + { "nu", NULL, 0, EQ_CASE }, + { "nwarrow", NULL, 0, 0 }, + { "odiv", NULL, 0, 0 }, + { "odot", NULL, 0, 0 }, + { "oint", NULL, 0, 0 }, + { "omega", NULL, 0, EQ_CASE }, + { "omicron", NULL, 0, EQ_CASE }, + { "ominus", NULL, 0, 0 }, + { "oplus", NULL, 0, 0 }, + { "or ", NULL, 0, 0 }, + { "oslash", NULL, 0, 0 }, + { "otimes", NULL, 0, 0 }, + { "over", NULL, 1, EQ_ATOP }, + { "overline", NULL, 1, 0 }, + { "owns", "\\ni", 0, 0 }, + { "parallel", NULL, 0, 0 }, + { "partial", NULL, 0, 0 }, + { "phantom", NULL, 0, 0 }, + { "phi", NULL, 0, EQ_CASE }, + { "pi", NULL, 0, EQ_CASE }, + { "pile", NULL, 0, 0 }, // LATER + { "plusminus", "\\pm", 0, 0 }, + { "pmatrix", NULL, 0, EQ_ENV }, + { "prec", NULL, 0, 0 }, + { "prep", NULL, 0, 0 }, + { "prime", NULL, 0, 0 }, + { "prod", NULL, 0, 0 }, + { "propto", NULL, 0, 0 }, + { "psi", NULL, 0, EQ_CASE }, + { "rangle", NULL, 0, 0 }, + { "rarrow", "\\rightarrow", 0, EQ_CASE }, + { "rbrace", "]", 0, 0 }, + { "rbrace", NULL, 0, 0 }, + { "rceil", NULL, 0, 0 }, + { "rcol", NULL, 0, 0 }, // LATER + { "real", "\\Re", 0, 0 }, + { "reimage", NULL, 0, 0 }, + { "rel", NULL, 0, 0 }, + { "rfloor", NULL, 0, 0 }, + { "rho", NULL, 0, EQ_CASE }, + { "right", NULL, 0, 0 }, + { "rightarrow", NULL, 0, EQ_CASE }, + { "rlharpoons", NULL, 0, 0 }, + { "rm", NULL, 0, 0 }, + { "root", "\\sqrt", 1, 0 }, + { "rparen", ")", 0, 0 }, + { "rpile", NULL, 0, 0 }, // LATER + { "rtangle", NULL, 0, 0 }, + { "sangle", NULL, 0, 0 }, + { "scale", NULL, 0, 0 }, + { "searrow", NULL, 0, 0 }, + { "sec", NULL, 0, 0 }, + { "sigma", NULL, 0, EQ_CASE }, + { "sim", NULL, 0, 0 }, + { "simeq", NULL, 0, 0 }, + { "sin", NULL, 0, 0 }, + { "sinh", NULL, 0, 0 }, + { "slash", NULL, 0, 0 }, + { "smallint", NULL, 0, 0 }, + { "smallinter", NULL, 0, 0 }, + { "smalloint", NULL, 0, 0 }, + { "smallprod", NULL, 0, 0 }, + { "smallsum", NULL, 0, 0 }, + { "smallunion", NULL, 0, 0 }, + { "smcoprod", NULL, 0, 0 }, + { "sqcap", NULL, 0, 0 }, + { "sqcup", NULL, 0, 0 }, + { "sqrt", NULL, 1, 0 }, + { "sqsubset", NULL, 0, 0 }, + { "sqsubseteq", NULL, 0, 0 }, + { "sqsupset", NULL, 0, 0 }, + { "sqsupseteq", NULL, 0, 0 }, + { "star", NULL, 0, 0 }, + { "sub", "_", 0, 0 }, + { "subset", NULL, 0, 0 }, + { "subseteq", NULL, 0, 0 }, + { "succ", NULL, 0, 0 }, + { "sum", NULL, 0, 0 }, + { "sup", "^", 0, 0 }, + { "superset", NULL, 0, 0 }, + { "supset", NULL, 0, 0 }, + { "supseteq", NULL, 0, 0 }, + { "swarrow", NULL, 0, 0 }, + { "tan", NULL, 0, 0 }, + { "tanh", NULL, 0, 0 }, + { "tau", NULL, 0, EQ_CASE }, + { "therefore", NULL, 0, 0 }, + { "theta", NULL, 0, EQ_CASE }, + { "tilde", "\\widetilde", 1, 0 }, + { "times", NULL, 0, 0 }, + { "to", "^", 1, 0 }, + { "top", NULL, 0, 0 }, + { "triangle", NULL, 0, 0 }, + { "triangled", NULL, 0, 0 }, + { "trianglel", NULL, 0, 0 }, + { "triangler", NULL, 0, 0 }, + { "triangleu", NULL, 0, 0 }, + { "udarrow", "\\updownarrow",0, EQ_CASE }, + { "under", "\\underline", 1, 0 }, + { "underline", "\\underline", 1, 0 }, + { "union", "\\bigcup", 0, 0 }, + { "uparrow", NULL, 0, EQ_CASE }, + { "uplus", NULL, 0, 0 }, + { "upsilon", NULL, 0, EQ_CASE }, + { "varepsilon", NULL, 0, 0 }, + { "varphi", NULL, 0, 0 }, + { "varpi", NULL, 0, 0 }, + { "varrho", NULL, 0, 0 }, + { "varsigma", NULL, 0, 0 }, + { "vartheta", NULL, 0, 0 }, + { "varupsilon", NULL, 0, 0 }, + { "vdash", NULL, 0, 0 }, + { "vdots", NULL, 0, 0 }, + { "vec", NULL, 1, 0 }, + { "vee", NULL, 0, 0 }, + { "vert", NULL, 0, 0 }, + { "wedge", NULL, 0, 0 }, + { "wp", NULL, 0, 0 }, + { "xi", NULL, 0, EQ_CASE }, + { "xor", NULL, 0, 0 }, + { "zeta", NULL, 0, EQ_CASE } +}; + +static hwpeq *lookup_eqn(char *str) +{ + static int eqCount = SAL_N_ELEMENTS(eq_tbl); + int m, k, l = 0, r = eqCount; + hwpeq *result = 0; + + while( l < r ) { + m = (l + r) / 2; + k = strcmp(eq_tbl[m].key, str); + if( k == 0 ) { + result = eq_tbl + m;; + break; + } + else if( k < 0 ) + l = m + 1; + else + r = m; + } + return result; +} + +/* ùڸ 빮̰ų 빮ڸ ҹڷ ٲ۴. */ + +static char *make_keyword( char *keyword, const char *token) +{ + assert(keyword); + char *ptr; + int result = true, len = strlen(token); + + if( 255 < len ) + strncpy(keyword, token, 255); + else + strcpy(keyword, token); + + if( (token[0] & 0x80) || islower(token[0]) || + strlen(token) < 2 ) + return keyword; + + int capital = isupper(keyword[1]); + for( ptr = keyword + 2; *ptr && result; ptr++ ) + if( (*ptr & 0x80) || + (!capital && isupper(*ptr)) || + (capital && islower(*ptr)) ) + result = false; + + if( result ) { + ptr = keyword; + while( *ptr ) { + if( isupper(*ptr) ) + *ptr = sal::static_int_cast(tolower(*ptr)); + ptr++; + } + } + return keyword; +} + +// token reading funtion +struct eq_stack { + MzString white; + MzString token; + istream *strm; + + eq_stack() { strm = 0; }; + bool state(istream *s) { + if( strm != s) { white = 0; token = 0; } + return token.length() != 0; + } +}; + +static eq_stack *stk = 0; + +void push_token(MzString &white, MzString &token, istream *strm) +{ + // one time stack + assert(stk->state(strm) == false); + + stk->white = white; + stk->token = token; + stk->strm = strm; +} + +/* ū ̸ ȯѴ. */ +/* control char, control sequence, binary sequence, + alphabet string, sigle character */ +static int next_token(MzString &white, MzString &token, istream *strm) +{ + register int ch = 0; + + if( stk->state(strm) ) { + white = stk->white; + token = stk->token; + stk->token = 0; + stk->white = 0; + return token.length(); + } + + token = 0; + white = 0; + if( !strm->good() || (ch = strm->get()) == EOF ) + return 0; + + // read preceeding ws + if( IS_WS(ch) ) { + do white << (char) ch; + while( IS_WS(ch = strm->get()) ); + } + + if( ch == '\\' || ch & 0x80 || isalpha(ch) ) { + if( ch == '\\' ) { + token << (char) ch; + ch = strm->get(); + } + do { + token << (char) ch; + ch = strm->get(); + } while( ch != EOF && (ch & 0x80 || isalpha(ch)) ) ; + strm->putback(sal::static_int_cast(ch)); + /* sub, sub, over, atop Ư ó + next_state() ġ ̴. + */ + if( !STRICMP("sub", token) || !STRICMP("from", token) || + !STRICMP("sup", token) || !STRICMP("to", token) || + !STRICMP("over", token) || !STRICMP("atop", token) || + !STRICMP("left", token) || !STRICMP("right", token) ) + { + char buf[256]; + make_keyword(buf, token); + token = buf; + } + if( !token.compare("sub") || !token.compare("from") ) + token = "_"; + if( !token.compare("sup") || !token.compare("to") ) + token = "^"; + } + else if( IS_BINARY(ch) ) { + do token << (char) ch; + while( IS_BINARY(ch = strm->get()) ); + strm->putback(sal::static_int_cast(ch)); + } + else if( isdigit(ch) ) { + do token << (char) ch; + while( isdigit(ch = strm->get()) ); + strm->putback(sal::static_int_cast(ch)); + } + else + token << (char) ch; + + return token.length(); +} + +static int read_white_space(MzString& outs, istream *strm) +{ + int result; + + if( stk->state(strm) ) { + outs << stk->white; + stk->white = 0; + result = stk->token[0]; + } + else { + int ch; + while( IS_WS(ch = strm->get()) ) + outs << (char )ch; + strm->putback(sal::static_int_cast(ch)); + result = ch; + } + return result; +} + +/* μ ʿ ׸ space brace + sqrt {ab}c = sqrt{ab} c + (, } grouping + ^, _ յڷ Ѵ. + + sqrt μ ִ + sqrt a -> sqrt{a} + sqrt {a} -> sqrt{a} + 1 ̻ μ ִ μ鰣 ش. + \frac a b -> frac{a}{b} + over + a over b -> {a}over{b} + */ + +static int eq_word(MzString& outs, istream *strm, int status) +{ + MzString token, white, state; + int result; + char keyword[256]; + hwpeq *eq; + + next_token(white, token, strm); + if (token.length() <= 0) + return 0; + result = token[0]; + + if( token.compare("{") == 0 ) { + state << white << token; + eq_sentence(state, strm, "}"); + } + else if( token.compare("left") == 0 ) { + state << white << token; + next_token(white, token, strm); + state << white << token; + + eq_sentence(state, strm, "right"); + + next_token(white, token, strm); + state << white << token; + } + else { + /* token */ + int script_status = SCRIPT_NONE; + while( 1 ) { + state << white << token; + make_keyword(keyword, token); + if( token[0] == '^' ) + script_status |= SCRIPT_SUP; + else if( token[0] == '_' ) + script_status |= SCRIPT_SUB; + else + script_status = SCRIPT_NONE; + + if( 0 != (eq = lookup_eqn(keyword)) ) { + int nargs = eq->nargs; + int ch; + while( nargs-- ) { + ch = read_white_space(state, strm); + if( ch != '{' ) state << '{'; + eq_word(state, strm, script_status); + if( ch != '{' ) state << '}'; + } + } + + if( !next_token(white, token, strm) ) + break; + // end loop and restart with this + if( (token[0] == '^' && status && !(status & SCRIPT_SUP)) || + (token[0] == '_' && status && !(status & SCRIPT_SUB)) || + strcmp("over", token) == 0 || strcmp("atop", token) == 0 || + strchr("{}#&`", token[0]) || + (!strchr("^_", token[0]) && white.length()) ) { + push_token(white, token, strm); + break; + } + } + } + outs << state; + + return result; +} + +static bool eq_sentence(MzString& outs, istream *strm, const char *end) +{ + MzString state; + MzString white, token; + bool multiline = false; + + read_white_space(outs, strm); + while( eq_word(state, strm) ) { + if( !next_token(white, token, strm) || + (end && strcmp(token.c_str(), end) == 0) ) + { + state << white << token; + break; + } + push_token(white, token, strm); + if( !token.compare("atop") || !token.compare("over") ) + outs << '{' << state << '}'; + else { + if( !token.compare("#") ) + multiline = true; + outs << state; + } + state = 0; + read_white_space(outs, strm); + } + outs << state; + return multiline; +} + +static char eq2ltxconv(MzString& sstr, istream *strm, const char *sentinel) +{ + MzString white, token; + char key[256]; + int ch, result; + hwpeq *eq = 0; + + while( 0 != (result = next_token(white, token, strm)) ) { + if( sentinel && (result == 1) && strchr(sentinel, token[0]) ) + break; + make_keyword(key, token); + if( (eq = lookup_eqn(key)) != 0 ) { + if( eq->latex ) + strcpy(key, eq->latex); + else { + key[0] = '\\'; + strcpy(key + 1, eq->key); + } + if( (eq->flag & EQ_CASE) && isupper(token[0]) ) + key[1] = sal::static_int_cast(toupper(key[1])); + token = key; + } + + if( token[0] == '{' ) { // grouping + sstr << white << token; + eq2ltxconv(sstr, strm, "}"); + sstr << '}'; + } + else if( eq && (eq->flag & EQ_ENV) ) { + next_token(white, token, strm); + if( token[0] != '{' ) return 0; + sstr << "\\begin" << "{" << eq->key << "}" << ENDL ; + eq2ltxconv(sstr, strm, "}"); + if( sstr[sstr.length() - 1] != '\n' ) + sstr << ENDL ; + sstr << "\\end" << "{" << eq->key << "}" << ENDL ; + } + else if( eq && (eq->flag & EQ_ATOP) ) { + if( sstr.length() == 0 ) + sstr << '{'; + else { + int pos = sstr.rfind('}'); + if( 0 < pos) + sstr.replace(pos, ' '); + } + sstr << token; + while( (ch = strm->get()) != EOF && IS_WS(ch) ) + sstr << (char)ch; + if( ch != '{' ) + sstr << "{}"; + else { + eq2ltxconv(sstr, strm, "}"); + sstr << '}'; + } + } + else + sstr << white << token; + } + return token[0]; +} + +void eq2latex(MzString& outs, char *s) +{ + assert(s); + if( stk == 0 ) + stk = new eq_stack; + + MzString tstr; + + istringstream tstrm(s); + bool eqnarray = eq_sentence(tstr, &tstrm); + istringstream strm(tstr.c_str()); + + if( eqnarray ) + outs << "\\begin{array}{rllll}" << ENDL; + eq2ltxconv(outs, &strm, 0); + outs << ENDL; + if( eqnarray ) + outs << "\\end{array}" << ENDL; + delete stk; + stk = 0; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/hwpfilter/source/hwpfile.cpp b/hwpfilter/source/hwpfile.cpp deleted file mode 100644 index b77cc1dad25f..000000000000 --- a/hwpfilter/source/hwpfile.cpp +++ /dev/null @@ -1,658 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "precompile.h" - -#include -#include -#include -#include -#include "hwplib.h" -#include "hwpfile.h" -#include "hiodev.h" -#include "hfont.h" -#include "hstyle.h" -#include "hbox.h" -#include "hpara.h" -#include "htags.h" -#include "hcode.h" -#include "hstream.h" - -#define HWPHeadLen 128 -#define HWPSummaryLen 1008 - -#define FILESTG_SIGNATURE 0xF8995567 -#define FILESTG_SIGNATURE_NORMAL 0xF8995568 - -HWPFile *HWPFile::cur_doc = 0; -static int ccount = 0; -static int pcount = 0; -static int datecodecount = 0; - -HWPFile::HWPFile() - : version(HWP_V30) - , compressed(false) - , encrypted(false) - , linenumber(0) - , info_block_len(0) - , error_code(HWP_NoError) - , oledata(0) - , m_nCurrentPage(1) - , m_nMaxSettedPage(0) - , hiodev(0) - , currenthyper(0) -{ - SetCurrentDoc(this); -} - -/** - * TODO : ߰ ŸϸƮ ޸ - */ -HWPFile::~HWPFile() -{ - if (oledata) - delete oledata; - - if (hiodev) - delete hiodev; - - LinkedListIterator < ColumnInfo > it_column(&columnlist); - for (; it_column.current(); it_column++) - delete it_column.current(); - - LinkedListIterator < HWPPara > it(&plist); - for (; it.current(); it++) - delete it.current(); - - LinkedListIterator < Table > tbl(&tables); - for (; tbl.current(); tbl++) - delete tbl.current(); - - LinkedListIterator < HyperText > hyp(&hyperlist); - for (; hyp.current(); hyp++) - { - delete hyp.current(); - } -} - -int HWPFile::ReadHwpFile(HStream & stream) -{ - if (Open(stream) != HWP_NoError) - return State(); - InfoRead(); - FontRead(); - StyleRead(); - AddColumnInfo(); - ParaListRead(); - TagsRead(); - - return State(); -} - -int detect_hwp_version(const char *str) -{ - if (memcmp(V20SIGNATURE, str, HWPIDLen) == 0) - return HWP_V20; - else if (memcmp(V21SIGNATURE, str, HWPIDLen) == 0) - return HWP_V21; - else if (memcmp(V30SIGNATURE, str, HWPIDLen) == 0) - return HWP_V30; - return 0; -} - -// HIODev wrapper - -int HWPFile::Open(HStream & stream) -{ - HStreamIODev *hstreamio; - - if (0 == (hstreamio = new HStreamIODev(stream))) - { - printf(" hstreamio is not instanciate \n"); - return SetState(errno); - } - if (!hstreamio->open()) - { - delete hstreamio; - - return SetState(HWP_EMPTY_FILE); - } - SetIODevice(hstreamio); - - char idstr[HWPIDLen]; - - if (ReadBlock(idstr, HWPIDLen) <= 0 - || HWP_V30 != (version = detect_hwp_version(idstr))) - { - return SetState(HWP_UNSUPPORTED_VERSION); - } - return HWP_NoError; -} - - -int HWPFile::State(void) const -{ - return error_code; -} - - -int HWPFile::SetState(int errcode) -{ - error_code = errcode; - return error_code; -} - - -int HWPFile::Read1b(void) -{ - return hiodev ? hiodev->read1b() : -1; -} - - -int HWPFile::Read2b(void) -{ - return hiodev ? hiodev->read2b() : -1; -} - - -long HWPFile::Read4b(void) -{ - return hiodev ? hiodev->read4b() : -1; -} - - -int HWPFile::Read1b(void *ptr, size_t nmemb) -{ - return hiodev ? hiodev->read1b(ptr, nmemb) : 0; -} - - -int HWPFile::Read2b(void *ptr, size_t nmemb) -{ - return hiodev ? hiodev->read2b(ptr, nmemb) : 0; -} - - -int HWPFile::Read4b(void *ptr, size_t nmemb) -{ - return hiodev ? hiodev->read4b(ptr, nmemb) : 0; -} - - -size_t HWPFile::ReadBlock(void *ptr, size_t size) -{ - return hiodev ? hiodev->readBlock(ptr, size) : 0; -} - - -size_t HWPFile::SkipBlock(size_t size) -{ - return hiodev ? hiodev->skipBlock(size) : 0; -} - - -bool HWPFile::SetCompressed(bool flag) -{ - return hiodev ? hiodev->setCompressed(flag) : false; -} - - -HIODev *HWPFile::SetIODevice(HIODev * new_hiodev) -{ - HIODev *old_hiodev = hiodev; - - hiodev = new_hiodev; - return old_hiodev; -} - - -// end of HIODev wrapper - -bool HWPFile::InfoRead(void) -{ - return _hwpInfo.Read(*this); -} - - -bool HWPFile::FontRead(void) -{ - return _hwpFont.Read(*this); -} - - -bool HWPFile::StyleRead(void) -{ - return _hwpStyle.Read(*this); -} - - -bool HWPFile::ParaListRead(void) -{ - return ReadParaList(plist); -} - -bool HWPFile::ReadParaList(LinkedList < HWPPara > &aplist, unsigned char flag) -{ - LinkedListIterator < HWPPara > it(&aplist); - - HWPPara *spNode = new HWPPara; - unsigned char tmp_etcflag; - unsigned char prev_etcflag = 0; - while (spNode->Read(*this, flag)) - { - if( !(spNode->etcflag & 0x04) ){ - tmp_etcflag = spNode->etcflag; - spNode->etcflag = prev_etcflag; - prev_etcflag = tmp_etcflag; - } - if (spNode->nch && spNode->reuse_shape) - { - if (aplist.count()){ - spNode->pshape = aplist.last()->pshape; - } - else{ - spNode->nch = 0; - spNode->reuse_shape = 0; - } - } - spNode->pshape.pagebreak = spNode->etcflag; - if( spNode->nch ) - AddParaShape( &spNode->pshape ); - - if (aplist.count()) - aplist.last()->SetNext(spNode); - aplist.insert(spNode, -1); - spNode = new HWPPara; - } - delete spNode; - - return true; -} - - -bool HWPFile::TagsRead(void) -{ - ulong tag; - long size; - - while (1) - { - tag = Read4b(); - size = Read4b(); - if (size <= 0 && tag > 0){ - continue; - } - - if (tag == FILETAG_END_OF_COMPRESSED || - tag == FILETAG_END_OF_UNCOMPRESSED) - return true; - switch (tag) - { - case FILETAG_EMBEDDED_PICTURE: - { - EmPicture *emb = new EmPicture(size); - - if (true == emb->Read(*this)) - emblist.insert(emb, -1); - else - delete emb; - } - break; - case FILETAG_OLE_OBJECT: - if (oledata) - delete oledata; - oledata = new OlePicture(size); - oledata->Read(*this); - break; - case FILETAG_HYPERTEXT: - { - if( (size % 617) != 0 ) - SkipBlock( size ); - else - for( int i = 0 ; i < size/617 ; i++) - { - HyperText *hypert = new HyperText; - hypert->Read(*this); - hyperlist.insert(hypert, -1); - } - break; - } - case 6: - { - ReadBlock(_hwpInfo.back_info.reserved1, 8); - _hwpInfo.back_info.luminance = Read4b(); - _hwpInfo.back_info.contrast = Read4b(); - _hwpInfo.back_info.effect = sal::static_int_cast(Read1b()); - ReadBlock(_hwpInfo.back_info.reserved2, 7); - ReadBlock(_hwpInfo.back_info.filename, 260); - ReadBlock(_hwpInfo.back_info.color, 3); - unsigned short nFlag = sal::static_int_cast(Read2b()); - _hwpInfo.back_info.flag = nFlag >> 8 ; - int nRange = Read4b(); - _hwpInfo.back_info.range = nRange >> 24; - ReadBlock(_hwpInfo.back_info.reserved3, 27); - _hwpInfo.back_info.size = Read4b(); - - _hwpInfo.back_info.data = new char[(unsigned int)_hwpInfo.back_info.size]; - ReadBlock(_hwpInfo.back_info.data, _hwpInfo.back_info.size); - - if( _hwpInfo.back_info.size > 0 ) - _hwpInfo.back_info.type = 2; - else if( _hwpInfo.back_info.filename[0] ) - _hwpInfo.back_info.type = 1; - else - _hwpInfo.back_info.type = 0; - - - _hwpInfo.back_info.isset = true; - - break; - } - case FILETAG_PRESENTATION: - case FILETAG_PREVIEW_IMAGE: - case FILETAG_PREVIEW_TEXT: - default: - SkipBlock(size); - } - } -} - - -ColumnDef *HWPFile::GetColumnDef(int num) -{ - ColumnInfo *cinfo = columnlist.find(num); - if( cinfo ) - return cinfo->coldef; - else - return 0; -} -/* @return ε 1 Ѵ. */ -int HWPFile::GetPageMasterNum(int page) -{ - LinkedListIterator it(&columnlist); - ColumnInfo *now = 0; - int i; - - for( i = 1 ; it.current() ; it++, i++){ - now = it.current(); - if( page < now->start_page ) - return i-1; - } - return i-1; -} - -HyperText *HWPFile::GetHyperText() -{ - return hyperlist.find(currenthyper++); -} - -EmPicture *HWPFile::GetEmPicture(Picture * pic) -{ - char *name = pic->picinfo.picembed.embname; - - name[0] = 'H'; - name[1] = 'W'; - name[2] = 'P'; - - LinkedListIterator < EmPicture > it(&emblist); - for (; it.current(); it++) - if (strcmp(name, it.current()->name) == 0) - return it.current(); - return 0; -} - -EmPicture *HWPFile::GetEmPictureByName(char * name) -{ - name[0] = 'H'; - name[1] = 'W'; - name[2] = 'P'; - - LinkedListIterator < EmPicture > it(&emblist); - for (; it.current(); it++) - if (strcmp(name, it.current()->name) == 0) - return it.current(); - return 0; -} - - -void HWPFile::AddBox(FBox * box) -{ -// LATER if we don't use box->next(), -// AddBox() and GetBoxHead() are useless; - if (blist.count()) - { - box->prev = blist.last(); - box->prev->next = box; - } - else - box->prev = 0; - blist.insert(box, -1); -} - - -ParaShape *HWPFile::getParaShape(int index) -{ - return pslist.find(index); -} - - -CharShape *HWPFile::getCharShape(int index) -{ - return cslist.find(index); -} - - -FBoxStyle *HWPFile::getFBoxStyle(int index) -{ - return fbslist.find(index); -} - -DateCode *HWPFile::getDateCode(int index) -{ - return datecodes.find(index); -} - -HeaderFooter *HWPFile::getHeaderFooter(int index) -{ - return headerfooters.find(index); -} - -ShowPageNum *HWPFile::getPageNumber(int index) -{ - return pagenumbers.find(index); -} - -Table *HWPFile::getTable(int index) -{ - return tables.find(index); -} - -void HWPFile::AddParaShape(ParaShape * pshape) -{ - int nscount = 0; - for(int j = 0 ; j < MAXTABS-1 ; j++) - { - if( j > 0 && pshape->tabs[j].position == 0 ) - break; - if( pshape->tabs[0].position == 0 ){ - if( pshape->tabs[j].type || pshape->tabs[j].dot_continue || - (pshape->tabs[j].position != 1000 *j) ) - nscount = j; - } - else{ - if( pshape->tabs[j].type || pshape->tabs[j].dot_continue || - (pshape->tabs[j].position != 1000 * (j + 1)) ) - nscount = j; - } - } - if( nscount ) - pshape->tabs[MAXTABS-1].type = sal::static_int_cast(nscount); - int value = compareParaShape(pshape); - if( value == 0 || nscount ) - { - pshape->index = ++pcount; - pslist.insert(pshape, -1); - } - else - pshape->index = value; -} - - -void HWPFile::AddCharShape(CharShape * cshape) -{ - int value = compareCharShape(cshape); - if( value == 0 ) - { - cshape->index = ++ccount; - cslist.insert(cshape, -1); - } - else - cshape->index = value; -} - -void HWPFile::AddColumnInfo() -{ - ColumnInfo *cinfo = new ColumnInfo(m_nCurrentPage); - columnlist.insert(cinfo, -1); - setMaxSettedPage(); -} - -void HWPFile::SetColumnDef(ColumnDef *coldef) -{ - ColumnInfo *cinfo = columnlist.last(); - if( cinfo->bIsSet ) - return; - cinfo->coldef = coldef; - cinfo->bIsSet = true; -} - -void HWPFile::AddDateFormat(DateCode * hbox) -{ - hbox->key = sal::static_int_cast(++datecodecount); - datecodes.insert(hbox, -1); -} - -void HWPFile::AddPageNumber(ShowPageNum * hbox) -{ - pagenumbers.insert(hbox, -1); -} - -void HWPFile::AddHeaderFooter(HeaderFooter * hbox) -{ - headerfooters.insert(hbox, -1); -} - -void HWPFile::AddTable(Table * hbox) -{ - tables.insert(hbox, -1); -} - -void HWPFile::AddFBoxStyle(FBoxStyle * fbstyle) -{ - fbslist.insert(fbstyle, -1); -} - -int HWPFile::compareCharShape(CharShape *shape) -{ - int count = cslist.count(); - if( count > 0 ) - { - CharShape *cshape=0; - for(int i = 0; i< count; i++) - { - cshape = cslist.find(i); - - if( shape->size == cshape->size && - shape->font[0] == cshape->font[0] && - shape->ratio[0] == cshape->ratio[0] && - shape->space[0] == cshape->space[0] && - shape->color[1] == cshape->color[1] && - shape->color[0] == cshape->color[0] && - shape->shade == cshape->shade && - shape->attr == cshape->attr ) - { - return cshape->index; - } - } - } - return 0; -} - - -int HWPFile::compareParaShape(ParaShape *shape) -{ - int count = pslist.count(); - if( count > 0 ) - { - ParaShape *pshape=0; - for(int i = 0; i< count; i++) - { - pshape = pslist.find(i); - if( shape->left_margin == pshape->left_margin && - shape->right_margin == pshape->right_margin && - shape->pspacing_prev == pshape->pspacing_prev && - shape->pspacing_next == pshape->pspacing_next && - shape->indent == pshape->indent && - shape->lspacing == pshape->lspacing && - shape->arrange_type == pshape->arrange_type && - shape->outline == pshape->outline && - shape->pagebreak == pshape->pagebreak) - { - if( shape->cshape->size == pshape->cshape->size && - shape->cshape->font[0] == pshape->cshape->font[0] && - shape->cshape->ratio[0] == pshape->cshape->ratio[0] && - shape->cshape->space[0] == pshape->cshape->space[0] && - shape->cshape->color[1] == pshape->cshape->color[1] && - shape->cshape->color[0] == pshape->cshape->color[0] && - shape->cshape->shade == pshape->cshape->shade && - shape->cshape->attr == pshape->cshape->attr ) - { - return pshape->index; - } - } - } - } - return 0; -} - - -HWPFile *GetCurrentDoc(void) -{ - return HWPFile::cur_doc; -} - - -HWPFile *SetCurrentDoc(HWPFile * hwpfp) -{ - HWPFile *org = HWPFile::cur_doc; - - HWPFile::cur_doc = hwpfp; - return org; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/hwpfilter/source/hwpfile.cxx b/hwpfilter/source/hwpfile.cxx new file mode 100644 index 000000000000..b77cc1dad25f --- /dev/null +++ b/hwpfilter/source/hwpfile.cxx @@ -0,0 +1,658 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "precompile.h" + +#include +#include +#include +#include +#include "hwplib.h" +#include "hwpfile.h" +#include "hiodev.h" +#include "hfont.h" +#include "hstyle.h" +#include "hbox.h" +#include "hpara.h" +#include "htags.h" +#include "hcode.h" +#include "hstream.h" + +#define HWPHeadLen 128 +#define HWPSummaryLen 1008 + +#define FILESTG_SIGNATURE 0xF8995567 +#define FILESTG_SIGNATURE_NORMAL 0xF8995568 + +HWPFile *HWPFile::cur_doc = 0; +static int ccount = 0; +static int pcount = 0; +static int datecodecount = 0; + +HWPFile::HWPFile() + : version(HWP_V30) + , compressed(false) + , encrypted(false) + , linenumber(0) + , info_block_len(0) + , error_code(HWP_NoError) + , oledata(0) + , m_nCurrentPage(1) + , m_nMaxSettedPage(0) + , hiodev(0) + , currenthyper(0) +{ + SetCurrentDoc(this); +} + +/** + * TODO : ߰ ŸϸƮ ޸ + */ +HWPFile::~HWPFile() +{ + if (oledata) + delete oledata; + + if (hiodev) + delete hiodev; + + LinkedListIterator < ColumnInfo > it_column(&columnlist); + for (; it_column.current(); it_column++) + delete it_column.current(); + + LinkedListIterator < HWPPara > it(&plist); + for (; it.current(); it++) + delete it.current(); + + LinkedListIterator < Table > tbl(&tables); + for (; tbl.current(); tbl++) + delete tbl.current(); + + LinkedListIterator < HyperText > hyp(&hyperlist); + for (; hyp.current(); hyp++) + { + delete hyp.current(); + } +} + +int HWPFile::ReadHwpFile(HStream & stream) +{ + if (Open(stream) != HWP_NoError) + return State(); + InfoRead(); + FontRead(); + StyleRead(); + AddColumnInfo(); + ParaListRead(); + TagsRead(); + + return State(); +} + +int detect_hwp_version(const char *str) +{ + if (memcmp(V20SIGNATURE, str, HWPIDLen) == 0) + return HWP_V20; + else if (memcmp(V21SIGNATURE, str, HWPIDLen) == 0) + return HWP_V21; + else if (memcmp(V30SIGNATURE, str, HWPIDLen) == 0) + return HWP_V30; + return 0; +} + +// HIODev wrapper + +int HWPFile::Open(HStream & stream) +{ + HStreamIODev *hstreamio; + + if (0 == (hstreamio = new HStreamIODev(stream))) + { + printf(" hstreamio is not instanciate \n"); + return SetState(errno); + } + if (!hstreamio->open()) + { + delete hstreamio; + + return SetState(HWP_EMPTY_FILE); + } + SetIODevice(hstreamio); + + char idstr[HWPIDLen]; + + if (ReadBlock(idstr, HWPIDLen) <= 0 + || HWP_V30 != (version = detect_hwp_version(idstr))) + { + return SetState(HWP_UNSUPPORTED_VERSION); + } + return HWP_NoError; +} + + +int HWPFile::State(void) const +{ + return error_code; +} + + +int HWPFile::SetState(int errcode) +{ + error_code = errcode; + return error_code; +} + + +int HWPFile::Read1b(void) +{ + return hiodev ? hiodev->read1b() : -1; +} + + +int HWPFile::Read2b(void) +{ + return hiodev ? hiodev->read2b() : -1; +} + + +long HWPFile::Read4b(void) +{ + return hiodev ? hiodev->read4b() : -1; +} + + +int HWPFile::Read1b(void *ptr, size_t nmemb) +{ + return hiodev ? hiodev->read1b(ptr, nmemb) : 0; +} + + +int HWPFile::Read2b(void *ptr, size_t nmemb) +{ + return hiodev ? hiodev->read2b(ptr, nmemb) : 0; +} + + +int HWPFile::Read4b(void *ptr, size_t nmemb) +{ + return hiodev ? hiodev->read4b(ptr, nmemb) : 0; +} + + +size_t HWPFile::ReadBlock(void *ptr, size_t size) +{ + return hiodev ? hiodev->readBlock(ptr, size) : 0; +} + + +size_t HWPFile::SkipBlock(size_t size) +{ + return hiodev ? hiodev->skipBlock(size) : 0; +} + + +bool HWPFile::SetCompressed(bool flag) +{ + return hiodev ? hiodev->setCompressed(flag) : false; +} + + +HIODev *HWPFile::SetIODevice(HIODev * new_hiodev) +{ + HIODev *old_hiodev = hiodev; + + hiodev = new_hiodev; + return old_hiodev; +} + + +// end of HIODev wrapper + +bool HWPFile::InfoRead(void) +{ + return _hwpInfo.Read(*this); +} + + +bool HWPFile::FontRead(void) +{ + return _hwpFont.Read(*this); +} + + +bool HWPFile::StyleRead(void) +{ + return _hwpStyle.Read(*this); +} + + +bool HWPFile::ParaListRead(void) +{ + return ReadParaList(plist); +} + +bool HWPFile::ReadParaList(LinkedList < HWPPara > &aplist, unsigned char flag) +{ + LinkedListIterator < HWPPara > it(&aplist); + + HWPPara *spNode = new HWPPara; + unsigned char tmp_etcflag; + unsigned char prev_etcflag = 0; + while (spNode->Read(*this, flag)) + { + if( !(spNode->etcflag & 0x04) ){ + tmp_etcflag = spNode->etcflag; + spNode->etcflag = prev_etcflag; + prev_etcflag = tmp_etcflag; + } + if (spNode->nch && spNode->reuse_shape) + { + if (aplist.count()){ + spNode->pshape = aplist.last()->pshape; + } + else{ + spNode->nch = 0; + spNode->reuse_shape = 0; + } + } + spNode->pshape.pagebreak = spNode->etcflag; + if( spNode->nch ) + AddParaShape( &spNode->pshape ); + + if (aplist.count()) + aplist.last()->SetNext(spNode); + aplist.insert(spNode, -1); + spNode = new HWPPara; + } + delete spNode; + + return true; +} + + +bool HWPFile::TagsRead(void) +{ + ulong tag; + long size; + + while (1) + { + tag = Read4b(); + size = Read4b(); + if (size <= 0 && tag > 0){ + continue; + } + + if (tag == FILETAG_END_OF_COMPRESSED || + tag == FILETAG_END_OF_UNCOMPRESSED) + return true; + switch (tag) + { + case FILETAG_EMBEDDED_PICTURE: + { + EmPicture *emb = new EmPicture(size); + + if (true == emb->Read(*this)) + emblist.insert(emb, -1); + else + delete emb; + } + break; + case FILETAG_OLE_OBJECT: + if (oledata) + delete oledata; + oledata = new OlePicture(size); + oledata->Read(*this); + break; + case FILETAG_HYPERTEXT: + { + if( (size % 617) != 0 ) + SkipBlock( size ); + else + for( int i = 0 ; i < size/617 ; i++) + { + HyperText *hypert = new HyperText; + hypert->Read(*this); + hyperlist.insert(hypert, -1); + } + break; + } + case 6: + { + ReadBlock(_hwpInfo.back_info.reserved1, 8); + _hwpInfo.back_info.luminance = Read4b(); + _hwpInfo.back_info.contrast = Read4b(); + _hwpInfo.back_info.effect = sal::static_int_cast(Read1b()); + ReadBlock(_hwpInfo.back_info.reserved2, 7); + ReadBlock(_hwpInfo.back_info.filename, 260); + ReadBlock(_hwpInfo.back_info.color, 3); + unsigned short nFlag = sal::static_int_cast(Read2b()); + _hwpInfo.back_info.flag = nFlag >> 8 ; + int nRange = Read4b(); + _hwpInfo.back_info.range = nRange >> 24; + ReadBlock(_hwpInfo.back_info.reserved3, 27); + _hwpInfo.back_info.size = Read4b(); + + _hwpInfo.back_info.data = new char[(unsigned int)_hwpInfo.back_info.size]; + ReadBlock(_hwpInfo.back_info.data, _hwpInfo.back_info.size); + + if( _hwpInfo.back_info.size > 0 ) + _hwpInfo.back_info.type = 2; + else if( _hwpInfo.back_info.filename[0] ) + _hwpInfo.back_info.type = 1; + else + _hwpInfo.back_info.type = 0; + + + _hwpInfo.back_info.isset = true; + + break; + } + case FILETAG_PRESENTATION: + case FILETAG_PREVIEW_IMAGE: + case FILETAG_PREVIEW_TEXT: + default: + SkipBlock(size); + } + } +} + + +ColumnDef *HWPFile::GetColumnDef(int num) +{ + ColumnInfo *cinfo = columnlist.find(num); + if( cinfo ) + return cinfo->coldef; + else + return 0; +} +/* @return ε 1 Ѵ. */ +int HWPFile::GetPageMasterNum(int page) +{ + LinkedListIterator it(&columnlist); + ColumnInfo *now = 0; + int i; + + for( i = 1 ; it.current() ; it++, i++){ + now = it.current(); + if( page < now->start_page ) + return i-1; + } + return i-1; +} + +HyperText *HWPFile::GetHyperText() +{ + return hyperlist.find(currenthyper++); +} + +EmPicture *HWPFile::GetEmPicture(Picture * pic) +{ + char *name = pic->picinfo.picembed.embname; + + name[0] = 'H'; + name[1] = 'W'; + name[2] = 'P'; + + LinkedListIterator < EmPicture > it(&emblist); + for (; it.current(); it++) + if (strcmp(name, it.current()->name) == 0) + return it.current(); + return 0; +} + +EmPicture *HWPFile::GetEmPictureByName(char * name) +{ + name[0] = 'H'; + name[1] = 'W'; + name[2] = 'P'; + + LinkedListIterator < EmPicture > it(&emblist); + for (; it.current(); it++) + if (strcmp(name, it.current()->name) == 0) + return it.current(); + return 0; +} + + +void HWPFile::AddBox(FBox * box) +{ +// LATER if we don't use box->next(), +// AddBox() and GetBoxHead() are useless; + if (blist.count()) + { + box->prev = blist.last(); + box->prev->next = box; + } + else + box->prev = 0; + blist.insert(box, -1); +} + + +ParaShape *HWPFile::getParaShape(int index) +{ + return pslist.find(index); +} + + +CharShape *HWPFile::getCharShape(int index) +{ + return cslist.find(index); +} + + +FBoxStyle *HWPFile::getFBoxStyle(int index) +{ + return fbslist.find(index); +} + +DateCode *HWPFile::getDateCode(int index) +{ + return datecodes.find(index); +} + +HeaderFooter *HWPFile::getHeaderFooter(int index) +{ + return headerfooters.find(index); +} + +ShowPageNum *HWPFile::getPageNumber(int index) +{ + return pagenumbers.find(index); +} + +Table *HWPFile::getTable(int index) +{ + return tables.find(index); +} + +void HWPFile::AddParaShape(ParaShape * pshape) +{ + int nscount = 0; + for(int j = 0 ; j < MAXTABS-1 ; j++) + { + if( j > 0 && pshape->tabs[j].position == 0 ) + break; + if( pshape->tabs[0].position == 0 ){ + if( pshape->tabs[j].type || pshape->tabs[j].dot_continue || + (pshape->tabs[j].position != 1000 *j) ) + nscount = j; + } + else{ + if( pshape->tabs[j].type || pshape->tabs[j].dot_continue || + (pshape->tabs[j].position != 1000 * (j + 1)) ) + nscount = j; + } + } + if( nscount ) + pshape->tabs[MAXTABS-1].type = sal::static_int_cast(nscount); + int value = compareParaShape(pshape); + if( value == 0 || nscount ) + { + pshape->index = ++pcount; + pslist.insert(pshape, -1); + } + else + pshape->index = value; +} + + +void HWPFile::AddCharShape(CharShape * cshape) +{ + int value = compareCharShape(cshape); + if( value == 0 ) + { + cshape->index = ++ccount; + cslist.insert(cshape, -1); + } + else + cshape->index = value; +} + +void HWPFile::AddColumnInfo() +{ + ColumnInfo *cinfo = new ColumnInfo(m_nCurrentPage); + columnlist.insert(cinfo, -1); + setMaxSettedPage(); +} + +void HWPFile::SetColumnDef(ColumnDef *coldef) +{ + ColumnInfo *cinfo = columnlist.last(); + if( cinfo->bIsSet ) + return; + cinfo->coldef = coldef; + cinfo->bIsSet = true; +} + +void HWPFile::AddDateFormat(DateCode * hbox) +{ + hbox->key = sal::static_int_cast(++datecodecount); + datecodes.insert(hbox, -1); +} + +void HWPFile::AddPageNumber(ShowPageNum * hbox) +{ + pagenumbers.insert(hbox, -1); +} + +void HWPFile::AddHeaderFooter(HeaderFooter * hbox) +{ + headerfooters.insert(hbox, -1); +} + +void HWPFile::AddTable(Table * hbox) +{ + tables.insert(hbox, -1); +} + +void HWPFile::AddFBoxStyle(FBoxStyle * fbstyle) +{ + fbslist.insert(fbstyle, -1); +} + +int HWPFile::compareCharShape(CharShape *shape) +{ + int count = cslist.count(); + if( count > 0 ) + { + CharShape *cshape=0; + for(int i = 0; i< count; i++) + { + cshape = cslist.find(i); + + if( shape->size == cshape->size && + shape->font[0] == cshape->font[0] && + shape->ratio[0] == cshape->ratio[0] && + shape->space[0] == cshape->space[0] && + shape->color[1] == cshape->color[1] && + shape->color[0] == cshape->color[0] && + shape->shade == cshape->shade && + shape->attr == cshape->attr ) + { + return cshape->index; + } + } + } + return 0; +} + + +int HWPFile::compareParaShape(ParaShape *shape) +{ + int count = pslist.count(); + if( count > 0 ) + { + ParaShape *pshape=0; + for(int i = 0; i< count; i++) + { + pshape = pslist.find(i); + if( shape->left_margin == pshape->left_margin && + shape->right_margin == pshape->right_margin && + shape->pspacing_prev == pshape->pspacing_prev && + shape->pspacing_next == pshape->pspacing_next && + shape->indent == pshape->indent && + shape->lspacing == pshape->lspacing && + shape->arrange_type == pshape->arrange_type && + shape->outline == pshape->outline && + shape->pagebreak == pshape->pagebreak) + { + if( shape->cshape->size == pshape->cshape->size && + shape->cshape->font[0] == pshape->cshape->font[0] && + shape->cshape->ratio[0] == pshape->cshape->ratio[0] && + shape->cshape->space[0] == pshape->cshape->space[0] && + shape->cshape->color[1] == pshape->cshape->color[1] && + shape->cshape->color[0] == pshape->cshape->color[0] && + shape->cshape->shade == pshape->cshape->shade && + shape->cshape->attr == pshape->cshape->attr ) + { + return pshape->index; + } + } + } + } + return 0; +} + + +HWPFile *GetCurrentDoc(void) +{ + return HWPFile::cur_doc; +} + + +HWPFile *SetCurrentDoc(HWPFile * hwpfp) +{ + HWPFile *org = HWPFile::cur_doc; + + HWPFile::cur_doc = hwpfp; + return org; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/hwpfilter/source/hwpread.cpp b/hwpfilter/source/hwpread.cpp deleted file mode 100644 index b67b814fe211..000000000000 --- a/hwpfilter/source/hwpread.cpp +++ /dev/null @@ -1,814 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "precompile.h" - -#include "list.hxx" - -#include "hwpfile.h" -#include "hbox.h" -#include "hpara.h" -#include "drawing.h" -#include "htags.h" -#include "hcode.h" - -static short fboxnum = 1; -static int zindex = 1; -static int lnnumber = 0; - -int HBox::Read(HWPFile & ) -{ -// already read - return 1; -} - - -// skip block - -int SkipData::Read(HWPFile & hwpf) -{ - hwpf.Read4b(&data_block_len, 1); - hwpf.Read2b(&dummy, 1); - - if (!(IS_SP_SKIP_BLOCK(hh) && (hh == dummy))){ - return hwpf.SetState(HWP_InvalidFileFormat); - } - - data_block = new char[data_block_len]; - - return hwpf.Read1b(data_block, data_block_len); -} - - -// Field code(5) -int FieldCode::Read(HWPFile & hwpf) -{ - ulong size; - hchar dummy; - ulong len1; /* hcharŸ ڿ #1 */ - ulong len2; /* hcharŸ ڿ #2 */ - ulong len3; /* hcharŸ ڿ #3 */ - ulong binlen; /* ̳ʸ Ÿ */ - - hwpf.Read4b(&size, 1); - hwpf.Read2b(&dummy, 1); - hwpf.Read1b(&type, 2); - hwpf.Read4b(reserved1, 1); - hwpf.Read2b(&location_info, 1); - hwpf.Read1b(reserved2, 22); - hwpf.Read4b(&len1, 1); - hwpf.Read4b(&len2, 1); - hwpf.Read4b(&len3, 1); - hwpf.Read4b(&binlen, 1); - - str1 = new hchar[len1]; - str2 = new hchar[len2]; - str3 = new hchar[len3]; - bin = new char[binlen]; - - hwpf.Read2b(str1, len1/2); - hwpf.Read2b(str2, len2/2); - hwpf.Read2b(str3, len3/2); - - hwpf.ReadBlock(bin, binlen); - - if( type[0] == 3 && type[1] == 2 ){ /* 糯¥μ ؾ Ѵ. */ - DateCode *pDate = new DateCode; - for( int i = 0 ;i < (int)(len3/2) ; i++ ){ - if(str3[i] == 0 ) break; - if( i >= DATE_SIZE ) break; - pDate->format[i] = str3[i]; - } - hwpf.AddDateFormat(pDate); - m_pDate = pDate; - } - - return true; -} - - -// book mark(6) -int Bookmark::Read(HWPFile & hwpf) -{ - long len; - - hwpf.Read4b(&len, 1); - dummy = sal::static_int_cast(hwpf.Read2b()); - - if (!(len == 34))// 2 * (BMK_COMMENT_LEN + 1) + 2 - { - return hwpf.SetState(HWP_InvalidFileFormat); - } - if (!(hh == dummy && dummy == CH_BOOKMARK)){ - return hwpf.SetState(HWP_InvalidFileFormat); - } - - hwpf.Read2b(id, BMK_COMMENT_LEN + 1); - hwpf.Read2b(&type, 1); -//return hwpf.Read2b(&type, 1); - return 1; -} - - -// date format(7) - -int DateFormat::Read(HWPFile & hwpf) -{ - hwpf.Read2b(format, DATE_SIZE); - dummy = sal::static_int_cast(hwpf.Read2b()); - if (!(hh == dummy && CH_DATE_FORM == dummy)){ - return hwpf.SetState(HWP_InvalidFileFormat); - } - return true; -} - - -// date code(8) - -int DateCode::Read(HWPFile & hwpf) -{ - hwpf.Read2b(format, DATE_SIZE); - hwpf.Read2b(date, 6); - dummy = sal::static_int_cast(hwpf.Read2b()); - if (!(hh == dummy && CH_DATE_CODE == dummy)){ - return hwpf.SetState(HWP_InvalidFileFormat); - } - hwpf.AddDateFormat(this); - return true; -} - - -// tab(9) - -int Tab::Read(HWPFile & hwpf) -{ - width = hwpf.Read2b(); - leader = sal::static_int_cast(hwpf.Read2b()); - dummy = sal::static_int_cast(hwpf.Read2b()); - if (!(hh == dummy && CH_TAB == dummy)){ - return hwpf.SetState(HWP_InvalidFileFormat); - } - return true; -} - - -// tbox(10) TABLE BOX MATH BUTTON HYPERTEXT - -static void UpdateBBox(FBox * fbox) -{ - fbox->boundsy = fbox->pgy; - fbox->boundey = fbox->pgy + fbox->ys - 1; -} - - -void Cell::Read(HWPFile & hwpf) -{ - hwpf.Read2b(&p, 1); - hwpf.Read2b(&color, 1); - hwpf.Read2b(&x, 1); - hwpf.Read2b(&y, 1); - hwpf.Read2b(&w, 1); - hwpf.Read2b(&h, 1); - hwpf.Read2b(&txthigh, 1); - hwpf.Read2b(&cellhigh, 1); - - hwpf.Read1b(&flag, 1); - hwpf.Read1b(&changed, 1); - hwpf.Read1b(&used, 1); - hwpf.Read1b(&ver_align, 1); - hwpf.Read1b(linetype, 4); - hwpf.Read1b(&shade, 1); - hwpf.Read1b(&diagonal, 1); - hwpf.Read1b(&protect, 1); -} - - -int TxtBox::Read(HWPFile & hwpf) -{ - int ii, ncell; - - hwpf.Read2b(reserved, 2); - hwpf.Read2b(&dummy, 1); - - if (!(hh == dummy && CH_TEXT_BOX == dummy)){ - return hwpf.SetState(HWP_InvalidFileFormat); - } - hwpf.AddBox(this); - hwpf.Read2b(&style.cap_len, 1); - hwpf.Read2b(&dummy1, 1); - hwpf.Read2b(&next, 1); - hwpf.Read2b(&dummy2, 1); - - style.boxnum = fboxnum++; - zorder = zindex++; - hwpf.Read1b(&style.anchor_type, 1); - hwpf.Read1b(&style.txtflow, 1); - hwpf.Read2b(&style.xpos, 1); - hwpf.Read2b(&style.ypos, 1); - hwpf.Read2b(&option, 1); - hwpf.Read2b(&ctrl_ch, 1); - hwpf.Read2b(style.margin, 12); - hwpf.AddFBoxStyle(&style); - hwpf.Read2b(&box_xs, 1); - hwpf.Read2b(&box_ys, 1); - hwpf.Read2b(&cap_xs, 1); - hwpf.Read2b(&cap_ys, 1); - hwpf.Read2b(&style.cap_len, 1); - hwpf.Read2b(&xs, 1); - hwpf.Read2b(&ys, 1); - hwpf.Read2b(&cap_margin, 1); - hwpf.Read1b(&xpos_type, 1); - hwpf.Read1b(&ypos_type, 1); - hwpf.Read1b(&smart_linesp, 1); - hwpf.Read1b(&reserved1, 1); - hwpf.Read2b(&pgx, 1); - hwpf.Read2b(&pgy, 1); - hwpf.Read2b(&pgno, 1); - if( ( pgno +1 ) != hwpf.getCurrentPage() ) - pgno = sal::static_int_cast(hwpf.getCurrentPage() -1) ; - - hwpf.Read2b(&showpg, 1); - hwpf.Read2b(&cap_pos, 1); - hwpf.Read2b(&num, 1); - hwpf.Read2b(&dummy3, 1); - hwpf.Read2b(&baseline, 1); - hwpf.Read2b(&type, 1); - hwpf.Read2b(&nCell, 1); - hwpf.Read2b(&protect, 1); - switch (type) - { - case 0: //table - style.boxtype = 'T'; - break; - case 1: // text-box - style.boxtype = 'X'; - break; - case 2: // equation - style.boxtype = 'E'; - break; - case 3: // button - style.boxtype = 'B'; - break; - default: // other - style.boxtype = 'O'; - break; - } - - UpdateBBox(this); - - ncell = NCell(); - if (!(ncell > 0)){ - return hwpf.SetState(HWP_InvalidFileFormat); - } - - cell = new Cell[ncell]; - for (ii = 0; ii < ncell; ii++) - { - cell[ii].Read(hwpf); - cell[ii].key = sal::static_int_cast(ii); - } - if (ncell == 1) - style.cell = &cell[0]; - plists = new LinkedList < HWPPara >[ncell]; - for (ii = 0; ii < ncell; ii++) - hwpf.ReadParaList(plists[ii]); - // caption - hwpf.ReadParaList(caption); - - if( type == 0 ){ // if table? - Table *tbl = new Table; - for( ii = 0 ; ii < ncell; ii++) - { - tbl->columns.insert(cell[ii].x); - tbl->columns.insert(cell[ii].x + cell[ii].w); - tbl->rows.insert(cell[ii].y); - tbl->rows.insert(cell[ii].y + cell[ii].h); - } - TCell* *pArr = new TCell*[ncell]; - for( ii = 0 ; ii < ncell; ii++) - { - TCell *tcell = new TCell; - tcell->nColumnIndex = tbl->columns.getIndex(cell[ii].x); - tcell->nColumnSpan = tbl->columns.getIndex(cell[ii].x + cell[ii].w) - - tcell->nColumnIndex; - tcell->nRowIndex = tbl->rows.getIndex(cell[ii].y); - tcell->nRowSpan = tbl->rows.getIndex(cell[ii].y + cell[ii].h) - - tcell->nRowIndex; - tcell->pCell = &cell[ii]; - pArr[ii] = tcell; - } - TCell *tmp; - // Sort by row and column - for( ii = 0 ; ii < ncell - 1; ii++ ){ - for( int jj = ii ; jj < ncell ; jj++){ - if( pArr[ii]->nRowIndex > pArr[jj]->nRowIndex ){ - tmp = pArr[ii]; - pArr[ii] = pArr[jj]; - pArr[jj] = tmp; - } - } - for( int kk = ii ; kk > 0 ; kk--){ - if( ( pArr[kk]->nRowIndex == pArr[kk-1]->nRowIndex ) && - (pArr[kk]->nColumnIndex < pArr[kk-1]->nColumnIndex )){ - tmp = pArr[kk]; - pArr[kk] = pArr[kk-1]; - pArr[kk-1] = tmp; - } - } - } - for( ii = 0 ; ii < ncell ; ii++ ){ - tbl->cells.insert(pArr[ii]); - } - tbl->box = this; - hwpf.AddTable(tbl); - m_pTable = tbl; - delete[] pArr; - } - else - m_pTable = 0L; - - return !hwpf.State(); -} - - -// picture(11) -int Picture::Read(HWPFile & hwpf) -{ - hwpf.Read2b(reserved, 2); - hwpf.Read2b(&dummy, 1); - - if (!(hh == dummy && CH_PICTURE == dummy)){ - return hwpf.SetState(HWP_InvalidFileFormat); - } - hwpf.AddBox(this); - - hwpf.Read4b(&follow_block_size, 1); - hwpf.Read2b(&dummy1, 1); /* 4Ʈ */ - hwpf.Read2b(&dummy2, 1); - - style.boxnum = fboxnum++; - zorder = zindex++; - hwpf.Read1b(&style.anchor_type, 1); /* ġ */ - hwpf.Read1b(&style.txtflow, 1); /* ׸. 0-2(ڸ,,︲) */ - hwpf.Read2b(&style.xpos, 1); /* ġ : 1 , 2, 3 , ̿ = */ - hwpf.Read2b(&style.ypos, 1); /* ġ : 1 , 2 Ʒ, 3 , ̿ */ - hwpf.Read2b(&option, 1); /* Ÿɼ : ׵θ,׸,. bit . */ - hwpf.Read2b(&ctrl_ch, 1); /* ׻ 11 */ - hwpf.Read2b(style.margin, 12); /* : [0-2][] out/in/,[][0-3] ///Ʒ */ - hwpf.Read2b(&box_xs, 1); /* ڽũ */ - hwpf.Read2b(&box_ys, 1); /* */ - hwpf.Read2b(&cap_xs, 1); /* ĸ ũ */ - hwpf.Read2b(&cap_ys, 1); /* */ - hwpf.Read2b(&style.cap_len, 1); /* */ - hwpf.Read2b(&xs, 1); /* ü ũ(ڽ ũ + ĸ + ) */ - hwpf.Read2b(&ys, 1); /* */ - hwpf.Read2b(&cap_margin, 1); /* ĸ */ - hwpf.Read1b(&xpos_type, 1); - hwpf.Read1b(&ypos_type, 1); - hwpf.Read1b(&smart_linesp, 1); /* ٰ ȣ : 0 ̺ȣ, 1 ȣ */ - hwpf.Read1b(&reserved1, 1); - hwpf.Read2b(&pgx, 1); /* ڽ */ - hwpf.Read2b(&pgy, 1); /* */ - hwpf.Read2b(&pgno, 1); /* : 0 */ - hwpf.Read2b(&showpg, 1); /* ڽ */ - hwpf.Read2b(&cap_pos, 1); /* ĸġ 0 - 7 ޴. */ - hwpf.Read2b(&num, 1); /* ڽȣ 0 ؼ űϷùȣ */ - - hwpf.Read1b(&pictype, 1); /* ׸ */ - - skip[0] = (short) hwpf.Read2b(); /* ׸ ǥø ġ */ - skip[1] = (short) hwpf.Read2b(); /* */ - scale[0] = (short) hwpf.Read2b(); /* Ȯ : 0 , ̿ ۼƮ */ - scale[1] = (short) hwpf.Read2b(); /* */ - - hwpf.Read1b(picinfo.picun.path, 256); /* ׸ ̸ : Drawing ƴҶ. */ - hwpf.Read1b(reserved3, 9); /* //׸ȿ */ - - UpdateBBox(this); - if( pictype != PICTYPE_DRAW ) - style.cell = reserved3; - - if (follow_block_size != 0) - { - follow = new unsigned char[follow_block_size]; - - hwpf.Read1b(follow, follow_block_size); - if (pictype == PICTYPE_DRAW) - { - hmem = new HMemIODev((char *) follow, follow_block_size); - LoadDrawingObjectBlock(this); - style.cell = picinfo.picdraw.hdo; - delete hmem; - - hmem = 0; - } - else - { - if ((follow[3] << 24 | follow[2] << 16 | follow[1] << 8 | follow[0]) == 0x269) - { - ishyper = true; - } - } - } - - if( pictype != 3 ) - style.boxtype = 'G'; - else - style.boxtype = 'D'; - hwpf.AddFBoxStyle(&style); - -// cation - hwpf.ReadParaList(caption); - - return !hwpf.State(); -} - - -// line(15) - -Line::Line():FBox(CH_LINE) -{ -} - - -int Line::Read(HWPFile & hwpf) -{ - hwpf.Read2b(reserved, 2); - hwpf.Read2b(&dummy, 1); - - if (!(hh == dummy && CH_LINE == dummy)){ - return hwpf.SetState(HWP_InvalidFileFormat); - } - hwpf.AddBox(this); - - style.boxnum = fboxnum++; - zorder = zindex++; - style.boxtype = 'L'; - hwpf.Read1b(&reserved2, 8); - hwpf.Read1b(&style.anchor_type, 1); - hwpf.Read1b(&style.txtflow, 1); - hwpf.Read2b(&style.xpos, 1); - hwpf.Read2b(&style.ypos, 1); - hwpf.Read2b(&option, 1); - hwpf.Read2b(&ctrl_ch, 1); - hwpf.Read2b(style.margin, 12); - hwpf.AddFBoxStyle(&style); - hwpf.Read2b(&box_xs, 1); - hwpf.Read2b(&box_ys, 1); - hwpf.Read2b(&cap_xs, 1); - hwpf.Read2b(&cap_ys, 1); - hwpf.Read2b(&style.cap_len, 1); - hwpf.Read2b(&xs, 1); - hwpf.Read2b(&ys, 1); - lnnumber = style.boxnum; - hwpf.linenumber = 1; - hwpf.Read2b(&boundsy, 1); - hwpf.Read2b(&boundey, 1); - hwpf.Read1b(&boundx, 1); - hwpf.Read1b(&draw, 1); - - hwpf.Read2b(&pgx, 1); - hwpf.Read2b(&pgy, 1); - hwpf.Read2b(&pgno, 1); - hwpf.Read2b(&showpg, 1); - - hwpf.Read2b(&sx, 1); - hwpf.Read2b(&sy, 1); - hwpf.Read2b(&ex, 1); - hwpf.Read2b(&sy, 1); - hwpf.Read2b(&width, 1); - hwpf.Read2b(&shade, 1); - hwpf.Read2b(&color, 1); - style.xpos = width; - - return !hwpf.State(); -} - - -// hidden(15) -Hidden::Hidden():HBox(CH_HIDDEN) -{ -} - - -int Hidden::Read(HWPFile & hwpf) -{ - hwpf.Read2b(reserved, 2); - hwpf.Read2b(&dummy, 1); - if (!(hh == dummy && CH_HIDDEN == dummy)){ - return hwpf.SetState(HWP_InvalidFileFormat); - } - - hwpf.Read1b(info, 8); - hwpf.ReadParaList(plist); - - return !hwpf.State(); -} - - -// header/footer(16) -HeaderFooter::HeaderFooter():HBox(CH_HEADER_FOOTER) -{ - linenumber = 0; -} - - -int HeaderFooter::Read(HWPFile & hwpf) -{ - hwpf.Read2b(reserved, 2); - hwpf.Read2b(&dummy, 1); - if (!(hh == dummy && CH_HEADER_FOOTER == dummy)){ - return hwpf.SetState(HWP_InvalidFileFormat); - } - - hwpf.Read1b(info, 8); - hwpf.Read1b(&type, 1); - hwpf.Read1b(&where, 1); - lnnumber = 0; - hwpf.ReadParaList(plist, CH_HEADER_FOOTER); - linenumber = sal::static_int_cast(lnnumber); - m_nPageNumber = hwpf.getCurrentPage(); - hwpf.setMaxSettedPage(); - hwpf.AddHeaderFooter(this); - - return !hwpf.State(); -} - - -// footnote(17) -Footnote::Footnote():HBox(CH_FOOTNOTE) -{ -} - - -int Footnote::Read(HWPFile & hwpf) -{ - hwpf.Read2b(reserved, 2); - hwpf.Read2b(&dummy, 1); - if (!(hh == dummy && CH_FOOTNOTE == dummy)){ - return hwpf.SetState(HWP_InvalidFileFormat); - } - - hwpf.Read1b(info, 8); - hwpf.Read2b(&number, 1); - hwpf.Read2b(&type, 1); - width = (short) hwpf.Read2b(); - hwpf.ReadParaList(plist, CH_FOOTNOTE); - - return !hwpf.State(); -} - - -// auto number(18) -AutoNum::AutoNum():HBox(CH_AUTO_NUM) -{ -} - - -int AutoNum::Read(HWPFile & hwpf) -{ - hwpf.Read2b(&type, 1); - hwpf.Read2b(&number, 1); - hwpf.Read2b(&dummy, 1); - - if (!(hh == dummy)){ - return hwpf.SetState(HWP_InvalidFileFormat); - } - return !hwpf.State(); -} - - -// new number(19) -NewNum::NewNum():HBox(CH_NEW_NUM) -{ -} - - -int NewNum::Read(HWPFile & hwpf) -{ - hwpf.Read2b(&type, 1); - hwpf.Read2b(&number, 1); - hwpf.Read2b(&dummy, 1); - - if (!(hh == dummy)){ - return hwpf.SetState(HWP_InvalidFileFormat); - } - return !hwpf.State(); -} - - -// show page number (20) -ShowPageNum::ShowPageNum():HBox(CH_SHOW_PAGE_NUM) -{ -} - - -int ShowPageNum::Read(HWPFile & hwpf) -{ - hwpf.Read2b(&where, 1); - hwpf.Read2b(&shape, 1); - hwpf.Read2b(&dummy, 1); - - if (!(hh == dummy)){ - return hwpf.SetState(HWP_InvalidFileFormat); - } - m_nPageNumber = hwpf.getCurrentPage(); - hwpf.setMaxSettedPage(); - hwpf.AddPageNumber(this); - return !hwpf.State(); -} - - -/* Ȧʽ/߱ (21) */ -PageNumCtrl::PageNumCtrl():HBox(CH_PAGE_NUM_CTRL) -{ -} - - -int PageNumCtrl::Read(HWPFile & hwpf) -{ - hwpf.Read2b(&kind, 1); - hwpf.Read2b(&what, 1); - hwpf.Read2b(&dummy, 1); - - if (!(hh == dummy)){ - return hwpf.SetState(HWP_InvalidFileFormat); - } - return !hwpf.State(); -} - - -// mail merge(22) -MailMerge::MailMerge():HBox(CH_MAIL_MERGE) -{ -} - - -int MailMerge::Read(HWPFile & hwpf) -{ - hwpf.Read1b(field_name, 20); - hwpf.Read2b(&dummy, 1); - - if (!(hh == dummy)){ - return hwpf.SetState(HWP_InvalidFileFormat); - } - return !hwpf.State(); -} - - -// char compositon(23) -Compose::Compose():HBox(CH_COMPOSE) -{ -} - - -int Compose::Read(HWPFile & hwpf) -{ - hwpf.Read2b(compose, 3); - hwpf.Read2b(&dummy, 1); - - if (!(hh == dummy)){ - return hwpf.SetState(HWP_InvalidFileFormat); - } - return !hwpf.State(); -} - - -// hyphen(24) -Hyphen::Hyphen():HBox(CH_HYPHEN) -{ -} - - -int Hyphen::Read(HWPFile & hwpf) -{ - hwpf.Read2b(&width, 1); - hwpf.Read2b(&dummy, 1); - - if (!(hh == dummy)){ - return hwpf.SetState(HWP_InvalidFileFormat); - } - return !hwpf.State(); -} - - -// toc mark(25) -TocMark::TocMark():HBox(CH_TOC_MARK) -{ -} - - -int TocMark::Read(HWPFile & hwpf) -{ - hwpf.Read2b(&kind, 1); - hwpf.Read2b(&dummy, 1); - - if (!(hh == dummy)){ - return hwpf.SetState(HWP_InvalidFileFormat); - } - return !hwpf.State(); -} - - -// index mark(26) -IndexMark::IndexMark():HBox(CH_INDEX_MARK) -{ -} - - -int IndexMark::Read(HWPFile & hwpf) -{ - hwpf.Read2b(&keyword1, 60); - hwpf.Read2b(&keyword2, 60); - hwpf.Read2b(&pgno, 1); - hwpf.Read2b(&dummy, 1); - - if (!(hh == dummy)){ - return hwpf.SetState(HWP_InvalidFileFormat); - } - return !hwpf.State(); -} - - -// outline(28) -Outline::Outline():HBox(CH_OUTLINE) -{ -} - - -int Outline::Read(HWPFile & hwpf) -{ - hwpf.Read2b(&kind, 1); - hwpf.Read1b(&shape, 1); - hwpf.Read1b(&level, 1); - hwpf.Read2b(number, 7); - hwpf.Read2b(user_shape, 7); - hwpf.Read2b(deco, 14); - hwpf.Read2b(&dummy, 1); - - if (!(hh == dummy)){ - return hwpf.SetState(HWP_InvalidFileFormat); - } - return !hwpf.State(); -} - - -/* ĭ(30) */ -KeepSpace::KeepSpace():HBox(CH_KEEP_SPACE) -{ -} - - -int KeepSpace::Read(HWPFile & hwpf) -{ - hwpf.Read2b(&dummy, 1); - - if (!(hh == dummy)){ - return hwpf.SetState(HWP_InvalidFileFormat); - } - return !hwpf.State(); -} - - -/* ĭ(31) */ -FixedSpace::FixedSpace():HBox(CH_FIXED_SPACE) -{ -} - - -int FixedSpace::Read(HWPFile & hwpf) -{ - hwpf.Read2b(&dummy, 1); - - if (!(hh == dummy)){ - return hwpf.SetState(HWP_InvalidFileFormat); - } - return !hwpf.State(); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/hwpfilter/source/hwpread.cxx b/hwpfilter/source/hwpread.cxx new file mode 100644 index 000000000000..b67b814fe211 --- /dev/null +++ b/hwpfilter/source/hwpread.cxx @@ -0,0 +1,814 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "precompile.h" + +#include "list.hxx" + +#include "hwpfile.h" +#include "hbox.h" +#include "hpara.h" +#include "drawing.h" +#include "htags.h" +#include "hcode.h" + +static short fboxnum = 1; +static int zindex = 1; +static int lnnumber = 0; + +int HBox::Read(HWPFile & ) +{ +// already read + return 1; +} + + +// skip block + +int SkipData::Read(HWPFile & hwpf) +{ + hwpf.Read4b(&data_block_len, 1); + hwpf.Read2b(&dummy, 1); + + if (!(IS_SP_SKIP_BLOCK(hh) && (hh == dummy))){ + return hwpf.SetState(HWP_InvalidFileFormat); + } + + data_block = new char[data_block_len]; + + return hwpf.Read1b(data_block, data_block_len); +} + + +// Field code(5) +int FieldCode::Read(HWPFile & hwpf) +{ + ulong size; + hchar dummy; + ulong len1; /* hcharŸ ڿ #1 */ + ulong len2; /* hcharŸ ڿ #2 */ + ulong len3; /* hcharŸ ڿ #3 */ + ulong binlen; /* ̳ʸ Ÿ */ + + hwpf.Read4b(&size, 1); + hwpf.Read2b(&dummy, 1); + hwpf.Read1b(&type, 2); + hwpf.Read4b(reserved1, 1); + hwpf.Read2b(&location_info, 1); + hwpf.Read1b(reserved2, 22); + hwpf.Read4b(&len1, 1); + hwpf.Read4b(&len2, 1); + hwpf.Read4b(&len3, 1); + hwpf.Read4b(&binlen, 1); + + str1 = new hchar[len1]; + str2 = new hchar[len2]; + str3 = new hchar[len3]; + bin = new char[binlen]; + + hwpf.Read2b(str1, len1/2); + hwpf.Read2b(str2, len2/2); + hwpf.Read2b(str3, len3/2); + + hwpf.ReadBlock(bin, binlen); + + if( type[0] == 3 && type[1] == 2 ){ /* 糯¥μ ؾ Ѵ. */ + DateCode *pDate = new DateCode; + for( int i = 0 ;i < (int)(len3/2) ; i++ ){ + if(str3[i] == 0 ) break; + if( i >= DATE_SIZE ) break; + pDate->format[i] = str3[i]; + } + hwpf.AddDateFormat(pDate); + m_pDate = pDate; + } + + return true; +} + + +// book mark(6) +int Bookmark::Read(HWPFile & hwpf) +{ + long len; + + hwpf.Read4b(&len, 1); + dummy = sal::static_int_cast(hwpf.Read2b()); + + if (!(len == 34))// 2 * (BMK_COMMENT_LEN + 1) + 2 + { + return hwpf.SetState(HWP_InvalidFileFormat); + } + if (!(hh == dummy && dummy == CH_BOOKMARK)){ + return hwpf.SetState(HWP_InvalidFileFormat); + } + + hwpf.Read2b(id, BMK_COMMENT_LEN + 1); + hwpf.Read2b(&type, 1); +//return hwpf.Read2b(&type, 1); + return 1; +} + + +// date format(7) + +int DateFormat::Read(HWPFile & hwpf) +{ + hwpf.Read2b(format, DATE_SIZE); + dummy = sal::static_int_cast(hwpf.Read2b()); + if (!(hh == dummy && CH_DATE_FORM == dummy)){ + return hwpf.SetState(HWP_InvalidFileFormat); + } + return true; +} + + +// date code(8) + +int DateCode::Read(HWPFile & hwpf) +{ + hwpf.Read2b(format, DATE_SIZE); + hwpf.Read2b(date, 6); + dummy = sal::static_int_cast(hwpf.Read2b()); + if (!(hh == dummy && CH_DATE_CODE == dummy)){ + return hwpf.SetState(HWP_InvalidFileFormat); + } + hwpf.AddDateFormat(this); + return true; +} + + +// tab(9) + +int Tab::Read(HWPFile & hwpf) +{ + width = hwpf.Read2b(); + leader = sal::static_int_cast(hwpf.Read2b()); + dummy = sal::static_int_cast(hwpf.Read2b()); + if (!(hh == dummy && CH_TAB == dummy)){ + return hwpf.SetState(HWP_InvalidFileFormat); + } + return true; +} + + +// tbox(10) TABLE BOX MATH BUTTON HYPERTEXT + +static void UpdateBBox(FBox * fbox) +{ + fbox->boundsy = fbox->pgy; + fbox->boundey = fbox->pgy + fbox->ys - 1; +} + + +void Cell::Read(HWPFile & hwpf) +{ + hwpf.Read2b(&p, 1); + hwpf.Read2b(&color, 1); + hwpf.Read2b(&x, 1); + hwpf.Read2b(&y, 1); + hwpf.Read2b(&w, 1); + hwpf.Read2b(&h, 1); + hwpf.Read2b(&txthigh, 1); + hwpf.Read2b(&cellhigh, 1); + + hwpf.Read1b(&flag, 1); + hwpf.Read1b(&changed, 1); + hwpf.Read1b(&used, 1); + hwpf.Read1b(&ver_align, 1); + hwpf.Read1b(linetype, 4); + hwpf.Read1b(&shade, 1); + hwpf.Read1b(&diagonal, 1); + hwpf.Read1b(&protect, 1); +} + + +int TxtBox::Read(HWPFile & hwpf) +{ + int ii, ncell; + + hwpf.Read2b(reserved, 2); + hwpf.Read2b(&dummy, 1); + + if (!(hh == dummy && CH_TEXT_BOX == dummy)){ + return hwpf.SetState(HWP_InvalidFileFormat); + } + hwpf.AddBox(this); + hwpf.Read2b(&style.cap_len, 1); + hwpf.Read2b(&dummy1, 1); + hwpf.Read2b(&next, 1); + hwpf.Read2b(&dummy2, 1); + + style.boxnum = fboxnum++; + zorder = zindex++; + hwpf.Read1b(&style.anchor_type, 1); + hwpf.Read1b(&style.txtflow, 1); + hwpf.Read2b(&style.xpos, 1); + hwpf.Read2b(&style.ypos, 1); + hwpf.Read2b(&option, 1); + hwpf.Read2b(&ctrl_ch, 1); + hwpf.Read2b(style.margin, 12); + hwpf.AddFBoxStyle(&style); + hwpf.Read2b(&box_xs, 1); + hwpf.Read2b(&box_ys, 1); + hwpf.Read2b(&cap_xs, 1); + hwpf.Read2b(&cap_ys, 1); + hwpf.Read2b(&style.cap_len, 1); + hwpf.Read2b(&xs, 1); + hwpf.Read2b(&ys, 1); + hwpf.Read2b(&cap_margin, 1); + hwpf.Read1b(&xpos_type, 1); + hwpf.Read1b(&ypos_type, 1); + hwpf.Read1b(&smart_linesp, 1); + hwpf.Read1b(&reserved1, 1); + hwpf.Read2b(&pgx, 1); + hwpf.Read2b(&pgy, 1); + hwpf.Read2b(&pgno, 1); + if( ( pgno +1 ) != hwpf.getCurrentPage() ) + pgno = sal::static_int_cast(hwpf.getCurrentPage() -1) ; + + hwpf.Read2b(&showpg, 1); + hwpf.Read2b(&cap_pos, 1); + hwpf.Read2b(&num, 1); + hwpf.Read2b(&dummy3, 1); + hwpf.Read2b(&baseline, 1); + hwpf.Read2b(&type, 1); + hwpf.Read2b(&nCell, 1); + hwpf.Read2b(&protect, 1); + switch (type) + { + case 0: //table + style.boxtype = 'T'; + break; + case 1: // text-box + style.boxtype = 'X'; + break; + case 2: // equation + style.boxtype = 'E'; + break; + case 3: // button + style.boxtype = 'B'; + break; + default: // other + style.boxtype = 'O'; + break; + } + + UpdateBBox(this); + + ncell = NCell(); + if (!(ncell > 0)){ + return hwpf.SetState(HWP_InvalidFileFormat); + } + + cell = new Cell[ncell]; + for (ii = 0; ii < ncell; ii++) + { + cell[ii].Read(hwpf); + cell[ii].key = sal::static_int_cast(ii); + } + if (ncell == 1) + style.cell = &cell[0]; + plists = new LinkedList < HWPPara >[ncell]; + for (ii = 0; ii < ncell; ii++) + hwpf.ReadParaList(plists[ii]); + // caption + hwpf.ReadParaList(caption); + + if( type == 0 ){ // if table? + Table *tbl = new Table; + for( ii = 0 ; ii < ncell; ii++) + { + tbl->columns.insert(cell[ii].x); + tbl->columns.insert(cell[ii].x + cell[ii].w); + tbl->rows.insert(cell[ii].y); + tbl->rows.insert(cell[ii].y + cell[ii].h); + } + TCell* *pArr = new TCell*[ncell]; + for( ii = 0 ; ii < ncell; ii++) + { + TCell *tcell = new TCell; + tcell->nColumnIndex = tbl->columns.getIndex(cell[ii].x); + tcell->nColumnSpan = tbl->columns.getIndex(cell[ii].x + cell[ii].w) - + tcell->nColumnIndex; + tcell->nRowIndex = tbl->rows.getIndex(cell[ii].y); + tcell->nRowSpan = tbl->rows.getIndex(cell[ii].y + cell[ii].h) - + tcell->nRowIndex; + tcell->pCell = &cell[ii]; + pArr[ii] = tcell; + } + TCell *tmp; + // Sort by row and column + for( ii = 0 ; ii < ncell - 1; ii++ ){ + for( int jj = ii ; jj < ncell ; jj++){ + if( pArr[ii]->nRowIndex > pArr[jj]->nRowIndex ){ + tmp = pArr[ii]; + pArr[ii] = pArr[jj]; + pArr[jj] = tmp; + } + } + for( int kk = ii ; kk > 0 ; kk--){ + if( ( pArr[kk]->nRowIndex == pArr[kk-1]->nRowIndex ) && + (pArr[kk]->nColumnIndex < pArr[kk-1]->nColumnIndex )){ + tmp = pArr[kk]; + pArr[kk] = pArr[kk-1]; + pArr[kk-1] = tmp; + } + } + } + for( ii = 0 ; ii < ncell ; ii++ ){ + tbl->cells.insert(pArr[ii]); + } + tbl->box = this; + hwpf.AddTable(tbl); + m_pTable = tbl; + delete[] pArr; + } + else + m_pTable = 0L; + + return !hwpf.State(); +} + + +// picture(11) +int Picture::Read(HWPFile & hwpf) +{ + hwpf.Read2b(reserved, 2); + hwpf.Read2b(&dummy, 1); + + if (!(hh == dummy && CH_PICTURE == dummy)){ + return hwpf.SetState(HWP_InvalidFileFormat); + } + hwpf.AddBox(this); + + hwpf.Read4b(&follow_block_size, 1); + hwpf.Read2b(&dummy1, 1); /* 4Ʈ */ + hwpf.Read2b(&dummy2, 1); + + style.boxnum = fboxnum++; + zorder = zindex++; + hwpf.Read1b(&style.anchor_type, 1); /* ġ */ + hwpf.Read1b(&style.txtflow, 1); /* ׸. 0-2(ڸ,,︲) */ + hwpf.Read2b(&style.xpos, 1); /* ġ : 1 , 2, 3 , ̿ = */ + hwpf.Read2b(&style.ypos, 1); /* ġ : 1 , 2 Ʒ, 3 , ̿ */ + hwpf.Read2b(&option, 1); /* Ÿɼ : ׵θ,׸,. bit . */ + hwpf.Read2b(&ctrl_ch, 1); /* ׻ 11 */ + hwpf.Read2b(style.margin, 12); /* : [0-2][] out/in/,[][0-3] ///Ʒ */ + hwpf.Read2b(&box_xs, 1); /* ڽũ */ + hwpf.Read2b(&box_ys, 1); /* */ + hwpf.Read2b(&cap_xs, 1); /* ĸ ũ */ + hwpf.Read2b(&cap_ys, 1); /* */ + hwpf.Read2b(&style.cap_len, 1); /* */ + hwpf.Read2b(&xs, 1); /* ü ũ(ڽ ũ + ĸ + ) */ + hwpf.Read2b(&ys, 1); /* */ + hwpf.Read2b(&cap_margin, 1); /* ĸ */ + hwpf.Read1b(&xpos_type, 1); + hwpf.Read1b(&ypos_type, 1); + hwpf.Read1b(&smart_linesp, 1); /* ٰ ȣ : 0 ̺ȣ, 1 ȣ */ + hwpf.Read1b(&reserved1, 1); + hwpf.Read2b(&pgx, 1); /* ڽ */ + hwpf.Read2b(&pgy, 1); /* */ + hwpf.Read2b(&pgno, 1); /* : 0 */ + hwpf.Read2b(&showpg, 1); /* ڽ */ + hwpf.Read2b(&cap_pos, 1); /* ĸġ 0 - 7 ޴. */ + hwpf.Read2b(&num, 1); /* ڽȣ 0 ؼ űϷùȣ */ + + hwpf.Read1b(&pictype, 1); /* ׸ */ + + skip[0] = (short) hwpf.Read2b(); /* ׸ ǥø ġ */ + skip[1] = (short) hwpf.Read2b(); /* */ + scale[0] = (short) hwpf.Read2b(); /* Ȯ : 0 , ̿ ۼƮ */ + scale[1] = (short) hwpf.Read2b(); /* */ + + hwpf.Read1b(picinfo.picun.path, 256); /* ׸ ̸ : Drawing ƴҶ. */ + hwpf.Read1b(reserved3, 9); /* //׸ȿ */ + + UpdateBBox(this); + if( pictype != PICTYPE_DRAW ) + style.cell = reserved3; + + if (follow_block_size != 0) + { + follow = new unsigned char[follow_block_size]; + + hwpf.Read1b(follow, follow_block_size); + if (pictype == PICTYPE_DRAW) + { + hmem = new HMemIODev((char *) follow, follow_block_size); + LoadDrawingObjectBlock(this); + style.cell = picinfo.picdraw.hdo; + delete hmem; + + hmem = 0; + } + else + { + if ((follow[3] << 24 | follow[2] << 16 | follow[1] << 8 | follow[0]) == 0x269) + { + ishyper = true; + } + } + } + + if( pictype != 3 ) + style.boxtype = 'G'; + else + style.boxtype = 'D'; + hwpf.AddFBoxStyle(&style); + +// cation + hwpf.ReadParaList(caption); + + return !hwpf.State(); +} + + +// line(15) + +Line::Line():FBox(CH_LINE) +{ +} + + +int Line::Read(HWPFile & hwpf) +{ + hwpf.Read2b(reserved, 2); + hwpf.Read2b(&dummy, 1); + + if (!(hh == dummy && CH_LINE == dummy)){ + return hwpf.SetState(HWP_InvalidFileFormat); + } + hwpf.AddBox(this); + + style.boxnum = fboxnum++; + zorder = zindex++; + style.boxtype = 'L'; + hwpf.Read1b(&reserved2, 8); + hwpf.Read1b(&style.anchor_type, 1); + hwpf.Read1b(&style.txtflow, 1); + hwpf.Read2b(&style.xpos, 1); + hwpf.Read2b(&style.ypos, 1); + hwpf.Read2b(&option, 1); + hwpf.Read2b(&ctrl_ch, 1); + hwpf.Read2b(style.margin, 12); + hwpf.AddFBoxStyle(&style); + hwpf.Read2b(&box_xs, 1); + hwpf.Read2b(&box_ys, 1); + hwpf.Read2b(&cap_xs, 1); + hwpf.Read2b(&cap_ys, 1); + hwpf.Read2b(&style.cap_len, 1); + hwpf.Read2b(&xs, 1); + hwpf.Read2b(&ys, 1); + lnnumber = style.boxnum; + hwpf.linenumber = 1; + hwpf.Read2b(&boundsy, 1); + hwpf.Read2b(&boundey, 1); + hwpf.Read1b(&boundx, 1); + hwpf.Read1b(&draw, 1); + + hwpf.Read2b(&pgx, 1); + hwpf.Read2b(&pgy, 1); + hwpf.Read2b(&pgno, 1); + hwpf.Read2b(&showpg, 1); + + hwpf.Read2b(&sx, 1); + hwpf.Read2b(&sy, 1); + hwpf.Read2b(&ex, 1); + hwpf.Read2b(&sy, 1); + hwpf.Read2b(&width, 1); + hwpf.Read2b(&shade, 1); + hwpf.Read2b(&color, 1); + style.xpos = width; + + return !hwpf.State(); +} + + +// hidden(15) +Hidden::Hidden():HBox(CH_HIDDEN) +{ +} + + +int Hidden::Read(HWPFile & hwpf) +{ + hwpf.Read2b(reserved, 2); + hwpf.Read2b(&dummy, 1); + if (!(hh == dummy && CH_HIDDEN == dummy)){ + return hwpf.SetState(HWP_InvalidFileFormat); + } + + hwpf.Read1b(info, 8); + hwpf.ReadParaList(plist); + + return !hwpf.State(); +} + + +// header/footer(16) +HeaderFooter::HeaderFooter():HBox(CH_HEADER_FOOTER) +{ + linenumber = 0; +} + + +int HeaderFooter::Read(HWPFile & hwpf) +{ + hwpf.Read2b(reserved, 2); + hwpf.Read2b(&dummy, 1); + if (!(hh == dummy && CH_HEADER_FOOTER == dummy)){ + return hwpf.SetState(HWP_InvalidFileFormat); + } + + hwpf.Read1b(info, 8); + hwpf.Read1b(&type, 1); + hwpf.Read1b(&where, 1); + lnnumber = 0; + hwpf.ReadParaList(plist, CH_HEADER_FOOTER); + linenumber = sal::static_int_cast(lnnumber); + m_nPageNumber = hwpf.getCurrentPage(); + hwpf.setMaxSettedPage(); + hwpf.AddHeaderFooter(this); + + return !hwpf.State(); +} + + +// footnote(17) +Footnote::Footnote():HBox(CH_FOOTNOTE) +{ +} + + +int Footnote::Read(HWPFile & hwpf) +{ + hwpf.Read2b(reserved, 2); + hwpf.Read2b(&dummy, 1); + if (!(hh == dummy && CH_FOOTNOTE == dummy)){ + return hwpf.SetState(HWP_InvalidFileFormat); + } + + hwpf.Read1b(info, 8); + hwpf.Read2b(&number, 1); + hwpf.Read2b(&type, 1); + width = (short) hwpf.Read2b(); + hwpf.ReadParaList(plist, CH_FOOTNOTE); + + return !hwpf.State(); +} + + +// auto number(18) +AutoNum::AutoNum():HBox(CH_AUTO_NUM) +{ +} + + +int AutoNum::Read(HWPFile & hwpf) +{ + hwpf.Read2b(&type, 1); + hwpf.Read2b(&number, 1); + hwpf.Read2b(&dummy, 1); + + if (!(hh == dummy)){ + return hwpf.SetState(HWP_InvalidFileFormat); + } + return !hwpf.State(); +} + + +// new number(19) +NewNum::NewNum():HBox(CH_NEW_NUM) +{ +} + + +int NewNum::Read(HWPFile & hwpf) +{ + hwpf.Read2b(&type, 1); + hwpf.Read2b(&number, 1); + hwpf.Read2b(&dummy, 1); + + if (!(hh == dummy)){ + return hwpf.SetState(HWP_InvalidFileFormat); + } + return !hwpf.State(); +} + + +// show page number (20) +ShowPageNum::ShowPageNum():HBox(CH_SHOW_PAGE_NUM) +{ +} + + +int ShowPageNum::Read(HWPFile & hwpf) +{ + hwpf.Read2b(&where, 1); + hwpf.Read2b(&shape, 1); + hwpf.Read2b(&dummy, 1); + + if (!(hh == dummy)){ + return hwpf.SetState(HWP_InvalidFileFormat); + } + m_nPageNumber = hwpf.getCurrentPage(); + hwpf.setMaxSettedPage(); + hwpf.AddPageNumber(this); + return !hwpf.State(); +} + + +/* Ȧʽ/߱ (21) */ +PageNumCtrl::PageNumCtrl():HBox(CH_PAGE_NUM_CTRL) +{ +} + + +int PageNumCtrl::Read(HWPFile & hwpf) +{ + hwpf.Read2b(&kind, 1); + hwpf.Read2b(&what, 1); + hwpf.Read2b(&dummy, 1); + + if (!(hh == dummy)){ + return hwpf.SetState(HWP_InvalidFileFormat); + } + return !hwpf.State(); +} + + +// mail merge(22) +MailMerge::MailMerge():HBox(CH_MAIL_MERGE) +{ +} + + +int MailMerge::Read(HWPFile & hwpf) +{ + hwpf.Read1b(field_name, 20); + hwpf.Read2b(&dummy, 1); + + if (!(hh == dummy)){ + return hwpf.SetState(HWP_InvalidFileFormat); + } + return !hwpf.State(); +} + + +// char compositon(23) +Compose::Compose():HBox(CH_COMPOSE) +{ +} + + +int Compose::Read(HWPFile & hwpf) +{ + hwpf.Read2b(compose, 3); + hwpf.Read2b(&dummy, 1); + + if (!(hh == dummy)){ + return hwpf.SetState(HWP_InvalidFileFormat); + } + return !hwpf.State(); +} + + +// hyphen(24) +Hyphen::Hyphen():HBox(CH_HYPHEN) +{ +} + + +int Hyphen::Read(HWPFile & hwpf) +{ + hwpf.Read2b(&width, 1); + hwpf.Read2b(&dummy, 1); + + if (!(hh == dummy)){ + return hwpf.SetState(HWP_InvalidFileFormat); + } + return !hwpf.State(); +} + + +// toc mark(25) +TocMark::TocMark():HBox(CH_TOC_MARK) +{ +} + + +int TocMark::Read(HWPFile & hwpf) +{ + hwpf.Read2b(&kind, 1); + hwpf.Read2b(&dummy, 1); + + if (!(hh == dummy)){ + return hwpf.SetState(HWP_InvalidFileFormat); + } + return !hwpf.State(); +} + + +// index mark(26) +IndexMark::IndexMark():HBox(CH_INDEX_MARK) +{ +} + + +int IndexMark::Read(HWPFile & hwpf) +{ + hwpf.Read2b(&keyword1, 60); + hwpf.Read2b(&keyword2, 60); + hwpf.Read2b(&pgno, 1); + hwpf.Read2b(&dummy, 1); + + if (!(hh == dummy)){ + return hwpf.SetState(HWP_InvalidFileFormat); + } + return !hwpf.State(); +} + + +// outline(28) +Outline::Outline():HBox(CH_OUTLINE) +{ +} + + +int Outline::Read(HWPFile & hwpf) +{ + hwpf.Read2b(&kind, 1); + hwpf.Read1b(&shape, 1); + hwpf.Read1b(&level, 1); + hwpf.Read2b(number, 7); + hwpf.Read2b(user_shape, 7); + hwpf.Read2b(deco, 14); + hwpf.Read2b(&dummy, 1); + + if (!(hh == dummy)){ + return hwpf.SetState(HWP_InvalidFileFormat); + } + return !hwpf.State(); +} + + +/* ĭ(30) */ +KeepSpace::KeepSpace():HBox(CH_KEEP_SPACE) +{ +} + + +int KeepSpace::Read(HWPFile & hwpf) +{ + hwpf.Read2b(&dummy, 1); + + if (!(hh == dummy)){ + return hwpf.SetState(HWP_InvalidFileFormat); + } + return !hwpf.State(); +} + + +/* ĭ(31) */ +FixedSpace::FixedSpace():HBox(CH_FIXED_SPACE) +{ +} + + +int FixedSpace::Read(HWPFile & hwpf) +{ + hwpf.Read2b(&dummy, 1); + + if (!(hh == dummy)){ + return hwpf.SetState(HWP_InvalidFileFormat); + } + return !hwpf.State(); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx index 07eee5d7e581..e23e2d9fc6c2 100644 --- a/hwpfilter/source/hwpreader.cxx +++ b/hwpfilter/source/hwpreader.cxx @@ -134,14 +134,8 @@ HwpReader::~HwpReader() } -#ifndef UDK100 sal_Bool HwpReader::filter(const Sequence< PropertyValue >& aDescriptor) throw(RuntimeException) -#else -void HwpReader::parseStream(const InputSource & structSource) -throw(SAXException, IOException, RuntimeException) -#endif { -#ifndef UDK100 Reference< XInputStream> rInputStream; for ( sal_Int32 i = 0; i < aDescriptor.getLength(); i++ ) { @@ -175,9 +169,6 @@ throw(SAXException, IOException, RuntimeException) break; } } -#else - Reference< XInputStream> rInputStream = structSource.aInputStream; -#endif HStream stream; Sequence < sal_Int8 > aBuffer; @@ -190,18 +181,11 @@ throw(SAXException, IOException, RuntimeException) stream.addData( (byte *)aBuffer.getConstArray(), nRead ); nTotal += nRead; } -#ifndef UDK100 + if( nTotal == 0 ) return sal_False; -#endif if (hwpfile.ReadHwpFile(stream)) - { -#ifdef UDK100 - throw SAXException(); -#else return sal_False; -#endif - } if (m_rxDocumentHandler.is()) m_rxDocumentHandler->startDocument(); @@ -239,10 +223,7 @@ throw(SAXException, IOException, RuntimeException) if (m_rxDocumentHandler.is()) m_rxDocumentHandler->endDocument(); -#ifndef UDK100 return sal_True; -#endif - } @@ -3762,17 +3743,13 @@ void HwpReader::makeFormula(TxtBox * hbox) pPar = pPar->Next(); } mybuf[l] = '\0'; -// rchars(ascii(mybuf)); -//#ifndef UDK100 + Formula *form = new Formula(mybuf); form->setDocumentHandler(m_rxDocumentHandler); form->setAttributeListImpl(pList); form->parse(); delete form; -//#endif - - } diff --git a/hwpfilter/source/lexer.cpp b/hwpfilter/source/lexer.cpp deleted file mode 100644 index 3c73a66ff48e..000000000000 --- a/hwpfilter/source/lexer.cpp +++ /dev/null @@ -1,2364 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - ************************************************************************/ - -/* A lexical scanner generated by flex */ - -/* Scanner skeleton version: - */ -#ifndef YY_STACK_USED -#define YY_STACK_USED 0 -#endif -#ifndef YY_ALWAYS_INTERACTIVE -#define YY_ALWAYS_INTERACTIVE 0 -#endif -#ifndef YY_NEVER_INTERACTIVE -#define YY_NEVER_INTERACTIVE 0 -#endif -#ifndef YY_MAIN -#define YY_MAIN 0 -#endif - -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 5 - -#include - - -/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ -#ifdef c_plusplus -#ifndef __cplusplus -#define __cplusplus -#endif -#endif - - -#ifdef __cplusplus - -#include -#ifndef WIN32 -#include -#else -#include -#endif - - -/* Use prototypes in function declarations. */ -#define YY_USE_PROTOS - -/* The "const" storage-class-modifier is valid. */ -#define YY_USE_CONST - -#else /* ! __cplusplus */ - -#if __STDC__ - -#define YY_USE_PROTOS -#define YY_USE_CONST - -#endif /* __STDC__ */ -#endif /* ! __cplusplus */ - -#ifdef YY_USE_CONST -#define yyconst const -#else -#define yyconst -#endif - - -#ifdef YY_USE_PROTOS -#define YY_PROTO(proto) proto -#else -#define YY_PROTO(proto) () -#endif - -/* Returned upon end-of-file. */ -#define YY_NULL 0 - -/* Promotes a possibly negative, possibly signed char to an unsigned - * integer for use as an array index. If the signed char is negative, - * we want to instead treat it as an 8-bit unsigned char, hence the - * double cast. - */ -#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) - -/* Enter a start condition. This macro really ought to take a parameter, - * but we do it the disgusting crufty way forced on us by the ()-less - * definition of BEGIN. - */ -#define BEGIN yy_start = 1 + 2 * - -/* Translate the current start state into a value that can be later handed - * to BEGIN to return to the state. The YYSTATE alias is for lex - * compatibility. - */ -#define YY_START ((yy_start - 1) / 2) -#define YYSTATE YY_START - -/* Action number for EOF rule of a given start state. */ -#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) - -/* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE yyrestart( yyin ) - -#define YY_END_OF_BUFFER_CHAR 0 - -/* Size of default input buffer. */ -#define YY_BUF_SIZE 16384 - -typedef struct yy_buffer_state *YY_BUFFER_STATE; - -extern int yyleng; -extern FILE *yyin, *yyout; - -#define EOB_ACT_CONTINUE_SCAN 0 -#define EOB_ACT_END_OF_FILE 1 -#define EOB_ACT_LAST_MATCH 2 - -/* The funky do-while in the following #define is used to turn the definition - * int a single C statement (which needs a semi-colon terminator). This - * avoids problems with code like: - * - * if ( condition_holds ) - * yyless( 5 ); - * else - * do_something_else(); - * - * Prior to using the do-while the compiler would get upset at the - * "else" because it interpreted the "if" statement as being all - * done when it reached the ';' after the yyless() call. - */ - -/* Return all but the first 'n' matched characters back to the input stream. */ - -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - *yy_cp = yy_hold_char; \ - YY_RESTORE_YY_MORE_OFFSET \ - yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up yytext again */ \ - } \ - while ( 0 ) - -//#define unput(c) yyunput( c, yytext_ptr ) - -/* The following is because we cannot portably get our hands on size_t - * (without autoconf's help, which isn't available because we want - * flex-generated scanners to compile on their own). - */ -typedef unsigned int yy_size_t; - - -struct yy_buffer_state - { - FILE *yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - yy_size_t yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - int yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; - - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; - - int yy_buffer_status; -#define YY_BUFFER_NEW 0 -#define YY_BUFFER_NORMAL 1 - /* When an EOF's been seen but there's still some text to process - * then we mark the buffer as YY_EOF_PENDING, to indicate that we - * shouldn't try reading from the input source any more. We might - * still have a bunch of tokens to match, though, because of - * possible backing-up. - * - * When we actually see the EOF, we change the status to "new" - * (via yyrestart()), so that the user can continue scanning by - * just pointing yyin at a new input file. - */ -#define YY_BUFFER_EOF_PENDING 2 - }; - -static YY_BUFFER_STATE yy_current_buffer = 0; - -/* We provide macros for accessing buffer states in case in the - * future we want to put the buffer states in a more general - * "scanner state". - */ -#define YY_CURRENT_BUFFER yy_current_buffer - - -/* yy_hold_char holds the character lost when yytext is formed. */ -static char yy_hold_char; - -static int yy_n_chars; /* number of characters read into yy_ch_buf */ - - -int yyleng; - -/* Points to current character in buffer. */ -static char *yy_c_buf_p = (char *) 0; -static int yy_init = 1; /* whether we need to initialize */ -static int yy_start = 0; /* start state number */ - -/* Flag which is used to allow yywrap()'s to do buffer switches - * instead of setting up a fresh yyin. A bit of a hack ... - */ -static int yy_did_buffer_switch_on_eof; - -void yyrestart YY_PROTO(( FILE *input_file )); - -void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer )); -void yy_load_buffer_state YY_PROTO(( void )); -YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size )); -void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b )); -void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file )); -void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b )); -#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer ) - -YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size )); -YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str )); -YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len )); - -static void *yy_flex_alloc YY_PROTO(( yy_size_t )); -static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t )); -static void yy_flex_free YY_PROTO(( void * )); - -#define yy_new_buffer yy_create_buffer - -#define yy_set_interactive(is_interactive) \ - { \ - if ( ! yy_current_buffer ) \ - yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ - yy_current_buffer->yy_is_interactive = is_interactive; \ - } - -#define yy_set_bol(at_bol) \ - { \ - if ( ! yy_current_buffer ) \ - yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ - yy_current_buffer->yy_at_bol = at_bol; \ - } - -#define YY_AT_BOL() (yy_current_buffer->yy_at_bol) - -typedef unsigned char YY_CHAR; -FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; -typedef int yy_state_type; -extern char *yytext; -#define yytext_ptr yytext - -static yy_state_type yy_get_previous_state YY_PROTO(( void )); -static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state )); -static int yy_get_next_buffer YY_PROTO(( void )); -static void yy_fatal_error YY_PROTO(( yyconst char msg[] )); - -/* Done after the current pattern has been matched and before the - * corresponding action - sets up yytext. - */ -#define YY_DO_BEFORE_ACTION \ - yytext_ptr = yy_bp; \ - yyleng = (int) (yy_cp - yy_bp); \ - yy_hold_char = *yy_cp; \ - *yy_cp = '\0'; \ - yy_c_buf_p = yy_cp; - -#define YY_NUM_RULES 45 -#define YY_END_OF_BUFFER 46 -static yyconst short int yy_accept[994] = - { 0, - 0, 0, 46, 44, 41, 41, 44, 42, 39, 37, - 37, 36, 39, 39, 44, 44, 38, 40, 35, 43, - 13, 21, 36, 36, 22, 16, 17, 0, 34, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 24, 0, 24, 0, 0, 0, 0, 0, - 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 42, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 4, 31, 5, 43, - 36, 20, 14, 15, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, - - 0, 0, 0, 10, 0, 0, 27, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 12, 12, 0, 0, - 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, - 0, 0, 0, 0, 12, 0, 27, 0, 0, 0, - 0, 0, 0, 0, 0, 11, 0, 9, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 23, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 27, - 27, 0, 0, 0, 0, 12, 0, 0, 8, 0, - - 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 27, 26, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 27, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 12, 27, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 27, - 0, 0, 27, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 11, 0, 0, 0, 0, 0, 0, 8, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 29, - 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, - 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - - 0, 0, 0, 0, 0, 0, 0, 30, 0, 0, - 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 28, 0, 0, 12, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, - - 0, 0, 0, 0, 0, 0, 25, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 32, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 12, 0, 12, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 33, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 19, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 12, 12, 0, 24, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 19, 0, 0, 0, 0, 0, 0, 0, - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0 - - } ; - -static yyconst int yy_ec[256] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, - 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 4, 1, 1, 1, 1, 5, 1, 6, - 7, 8, 8, 9, 10, 11, 8, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 13, 14, 15, - 16, 17, 1, 1, 18, 19, 20, 21, 22, 1, - 23, 1, 24, 25, 26, 27, 28, 29, 30, 31, - 1, 32, 33, 34, 35, 36, 1, 37, 1, 38, - 39, 40, 41, 42, 42, 1, 43, 44, 45, 46, - - 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, - 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, - 67, 68, 69, 70, 71, 72, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, - 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, - 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, - 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, - - 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, - 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, - 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, - 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, - 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, - 73, 73, 73, 73, 1 - } ; - -static yyconst int yy_meta[74] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1 - } ; - -static yyconst short int yy_base[995] = - { 0, - 0, 72, 1314, 1315, 1315, 1315, 1297, 1315, 1315, 1315, - 1295, 2, 8, 1294, 1281, 142, 1315, 1315, 1315, 1236, - 1315, 1315, 1296, 8, 1290, 1291, 1288, 1274, 1315, 0, - 0, 1253, 1, 1, 1259, 7, 1244, 1257, 8, 1236, - 1235, 1242, 35, 43, 1245, 0, 1237, 1251, 1242, 1245, - 1315, 46, 72, 171, 79, 62, 77, 184, 192, 92, - 1236, 2, 207, 216, 225, 234, 250, 46, 269, 278, - 295, 10, 111, 255, 10, 1243, 1315, 1315, 1315, 1216, - 1276, 1315, 1315, 1315, 1253, 1228, 1225, 1222, 1217, 1231, - 1227, 1237, 1214, 1217, 1234, 1221, 1315, 1213, 1223, 1215, - - 1217, 1223, 1214, 1315, 168, 1218, 1315, 1217, 1210, 1217, - 1216, 1201, 1216, 177, 1202, 1199, 1197, 34, 1216, 1209, - 1199, 181, 36, 164, 198, 1207, 119, 199, 1201, 1196, - 1196, 218, 1192, 1188, 225, 1205, 1191, 78, 40, 245, - 280, 1197, 175, 1184, 1192, 1187, 1198, 1182, 1179, 1198, - 101, 1197, 1179, 227, 1183, 1191, 1177, 1315, 1192, 1172, - 1190, 1189, 53, 1184, 1187, 260, 1167, 1171, 1184, 1168, - 1165, 248, 1177, 1166, 291, 1168, 1161, 1174, 1164, 1161, - 222, 268, 1160, 0, 1170, 1315, 1172, 1315, 247, 299, - 1152, 1170, 1155, 1155, 300, 1156, 1155, 1157, 1160, 1146, - - 1145, 1153, 302, 1152, 1139, 1158, 1144, 1152, 1147, 1143, - 1136, 308, 1146, 1137, 1150, 1136, 317, 1148, 308, 318, - 1147, 311, 1146, 322, 1145, 312, 1140, 319, 1128, 1134, - 324, 340, 1124, 333, 340, 1137, 1136, 1121, 1118, 1315, - 1129, 1121, 1134, 1114, 1120, 1118, 1122, 1117, 1128, 1114, - 1111, 1124, 1105, 1117, 1116, 1119, 1113, 1107, 1099, 1100, - 1102, 1107, 344, 1114, 1094, 1097, 1104, 1099, 327, 1092, - 347, 1094, 1095, 1096, 1315, 1105, 1096, 1103, 350, 1083, - 1099, 1079, 1088, 1079, 1095, 1094, 1094, 1088, 1076, 1085, - 1084, 1084, 1082, 1082, 1068, 1067, 1073, 1071, 1079, 1069, - - 1069, 1061, 1315, 1071, 1070, 1059, 1057, 1075, 1072, 1051, - 1060, 1050, 1053, 1052, 1058, 1054, 348, 1047, 1315, 1065, - 1045, 1048, 1061, 1055, 1052, 1040, 1039, 1043, 1042, 338, - 1035, 1048, 1035, 1048, 1038, 1039, 1029, 1031, 276, 1030, - 1027, 1026, 1038, 371, 1023, 1042, 1029, 1023, 355, 1024, - 1036, 1025, 372, 1036, 1032, 1028, 1025, 1020, 1017, 1016, - 1022, 1008, 1014, 1020, 1008, 1012, 1006, 1010, 1017, 1013, - 1008, 1007, 1014, 360, 997, 995, 997, 995, 1010, 372, - 1008, 993, 1002, 156, 1005, 1003, 1006, 1001, 997, 996, - 985, 987, 980, 991, 374, 980, 978, 977, 989, 990, - - 993, 992, 969, 990, 975, 988, 976, 986, 985, 981, - 379, 191, 983, 965, 962, 980, 979, 961, 955, 965, - 960, 374, 967, 965, 965, 967, 963, 969, 962, 963, - 947, 951, 950, 955, 962, 939, 945, 941, 938, 944, - 377, 383, 940, 938, 939, 949, 948, 943, 946, 945, - 944, 929, 936, 927, 930, 939, 921, 935, 922, 939, - 924, 933, 920, 935, 910, 922, 911, 912, 919, 1315, - 916, 928, 923, 907, 388, 906, 920, 916, 898, 914, - 920, 916, 907, 906, 898, 400, 901, 894, 900, 892, - 893, 392, 891, 898, 902, 907, 889, 888, 891, 895, - - 885, 901, 883, 879, 880, 879, 892, 405, 884, 886, - 889, 888, 872, 887, 878, 877, 887, 872, 865, 865, - 865, 876, 870, 863, 871, 863, 877, 860, 864, 870, - 869, 857, 856, 1315, 400, 866, 865, 851, 863, 849, - 861, 864, 859, 844, 848, 843, 856, 855, 840, 834, - 837, 843, 838, 403, 845, 843, 843, 834, 841, 829, - 1315, 842, 401, 824, 831, 826, 828, 841, 823, 831, - 834, 829, 822, 835, 820, 820, 818, 813, 822, 815, - 822, 823, 809, 802, 806, 810, 809, 800, 809, 801, - 1315, 803, 800, 801, 404, 807, 803, 805, 810, 803, - - 799, 805, 805, 803, 785, 786, 1315, 784, 800, 785, - 797, 787, 782, 780, 783, 778, 784, 776, 789, 784, - 783, 790, 785, 771, 787, 778, 768, 769, 778, 767, - 762, 776, 779, 770, 763, 758, 764, 774, 759, 93, - 126, 187, 225, 269, 333, 415, 345, 372, 388, 397, - 400, 417, 418, 408, 411, 427, 409, 418, 426, 417, - 419, 415, 417, 418, 419, 419, 423, 422, 422, 428, - 438, 438, 444, 432, 434, 434, 431, 442, 437, 446, - 449, 436, 456, 449, 454, 456, 443, 448, 445, 457, - 459, 459, 453, 450, 446, 469, 457, 463, 460, 454, - - 460, 471, 476, 473, 476, 458, 461, 468, 462, 471, - 484, 485, 466, 481, 484, 481, 473, 488, 475, 489, - 481, 475, 491, 491, 496, 482, 483, 495, 1315, 502, - 498, 490, 500, 503, 497, 487, 488, 498, 512, 508, - 501, 509, 512, 506, 514, 502, 520, 521, 518, 501, - 504, 505, 506, 523, 524, 525, 526, 527, 510, 519, - 523, 518, 528, 515, 538, 526, 532, 529, 523, 535, - 525, 534, 529, 533, 534, 542, 531, 544, 535, 536, - 543, 555, 556, 545, 541, 541, 540, 543, 558, 548, - 549, 552, 548, 563, 551, 550, 552, 557, 553, 565, - - 555, 568, 576, 563, 563, 572, 578, 562, 564, 576, - 582, 566, 582, 580, 577, 572, 573, 589, 574, 581, - 586, 576, 577, 581, 579, 583, 583, 597, 602, 590, - 587, 594, 606, 607, 597, 1315, 606, 591, 589, 590, - 594, 614, 596, 602, 600, 604, 600, 613, 603, 604, - 617, 605, 605, 604, 608, 628, 610, 619, 610, 619, - 615, 628, 636, 618, 619, 635, 640, 622, 628, 628, - 637, 626, 642, 643, 644, 646, 648, 647, 635, 640, - 641, 652, 658, 642, 652, 661, 640, 650, 652, 655, - 659, 651, 669, 656, 671, 668, 656, 666, 661, 676, - - 660, 678, 657, 666, 677, 666, 667, 680, 677, 682, - 673, 675, 676, 673, 674, 686, 676, 672, 691, 677, - 680, 681, 686, 683, 684, 696, 686, 687, 688, 692, - 702, 702, 687, 693, 697, 705, 696, 711, 701, 699, - 714, 701, 705, 713, 704, 708, 706, 711, 706, 719, - 713, 706, 710, 716, 718, 718, 713, 722, 723, 723, - 725, 718, 722, 728, 721, 730, 742, 727, 725, 748, - 727, 728, 729, 730, 731, 754, 733, 734, 743, 743, - 742, 747, 748, 746, 742, 748, 749, 754, 754, 755, - 748, 749, 1315, 814 - - } ; - -static yyconst short int yy_def[995] = - { 0, - 994, 994, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 0, 993 - - } ; - -static yyconst short int yy_nxt[1389] = - { 0, - 993, 5, 6, 7, 8, 9, 9, 10, 993, 11, - 993, 12, 23, 24, 13, 10, 14, 25, 23, 24, - 993, 993, 26, 993, 993, 993, 15, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 9, 16, - 9, 17, 112, 993, 170, 158, 88, 91, 171, 113, - 101, 92, 993, 86, 102, 107, 89, 93, 94, 87, - 188, 97, 95, 98, 103, 231, 238, 232, 9, 18, - 9, 19, 20, 5, 6, 7, 8, 9, 9, 10, - 266, 11, 294, 12, 106, 104, 13, 10, 14, 97, - 117, 267, 109, 110, 107, 108, 295, 186, 15, 118, - - 119, 120, 273, 121, 205, 122, 123, 107, 206, 315, - 9, 16, 9, 17, 124, 145, 146, 147, 125, 148, - 149, 138, 126, 150, 139, 140, 292, 151, 127, 141, - 152, 128, 142, 153, 129, 143, 154, 164, 293, 144, - 9, 18, 9, 19, 20, 29, 165, 166, 167, 737, - 29, 306, 168, 233, 29, 29, 234, 235, 107, 30, - 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, - 97, 51, 738, 280, 52, 53, 54, 55, 56, 57, - 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, - - 68, 69, 70, 71, 72, 73, 74, 75, 274, 76, - 77, 78, 79, 130, 255, 541, 131, 542, 256, 260, - 132, 133, 261, 275, 134, 271, 155, 135, 156, 107, - 157, 136, 158, 137, 160, 161, 299, 262, 162, 300, - 272, 281, 276, 159, 571, 282, 277, 186, 163, 172, - 572, 173, 174, 175, 176, 177, 178, 179, 182, 278, - 158, 180, 107, 181, 285, 183, 184, 189, 188, 309, - 107, 190, 185, 186, 186, 158, 187, 332, 188, 193, - 288, 191, 289, 310, 194, 290, 291, 188, 195, 192, - 336, 196, 200, 107, 197, 198, 201, 199, 296, 202, - - 188, 236, 323, 324, 186, 237, 107, 318, 337, 203, - 204, 207, 97, 208, 186, 209, 210, 211, 212, 213, - 216, 319, 297, 214, 217, 333, 499, 218, 219, 186, - 215, 500, 220, 107, 107, 221, 222, 226, 327, 223, - 224, 338, 225, 186, 227, 228, 343, 97, 351, 158, - 344, 229, 352, 186, 230, 374, 368, 158, 353, 365, - 371, 107, 369, 370, 188, 378, 379, 383, 372, 388, - 375, 376, 385, 386, 188, 396, 319, 389, 366, 380, - 430, 381, 391, 390, 275, 392, 186, 431, 489, 397, - 421, 433, 739, 393, 441, 742, 477, 509, 490, 398, - - 394, 422, 532, 423, 424, 425, 442, 434, 435, 478, - 443, 444, 445, 446, 447, 503, 510, 319, 538, 592, - 553, 569, 533, 579, 104, 743, 504, 593, 595, 513, - 744, 554, 539, 555, 556, 557, 558, 596, 570, 594, - 597, 619, 624, 664, 598, 632, 633, 620, 645, 625, - 683, 634, 678, 188, 706, 158, 158, 665, 646, 626, - 707, 740, 684, 79, 647, 741, 745, 79, 729, 746, - 748, 749, 97, 750, 751, 752, 747, 753, 754, 755, - 756, 158, 757, 758, 759, 760, 761, 762, 764, 765, - 766, 767, 188, 188, 768, 769, 770, 763, 771, 772, - - 773, 97, 774, 104, 775, 776, 777, 778, 104, 779, - 561, 780, 104, 781, 782, 783, 784, 785, 786, 158, - 186, 319, 319, 787, 788, 789, 790, 792, 793, 794, - 795, 796, 186, 797, 798, 799, 188, 800, 801, 802, - 803, 804, 805, 806, 807, 808, 791, 809, 810, 97, - 97, 561, 561, 188, 811, 812, 813, 814, 815, 97, - 158, 816, 817, 818, 97, 561, 819, 820, 821, 822, - 823, 824, 825, 826, 561, 827, 828, 829, 830, 561, - 831, 188, 832, 833, 834, 835, 836, 837, 838, 839, - 840, 841, 842, 843, 844, 845, 846, 104, 104, 97, - - 847, 848, 849, 319, 850, 319, 319, 851, 319, 319, - 852, 97, 853, 854, 97, 855, 856, 857, 858, 859, - 860, 861, 862, 863, 864, 865, 866, 867, 836, 868, - 158, 869, 870, 871, 186, 319, 872, 873, 874, 158, - 158, 158, 875, 876, 877, 878, 879, 880, 188, 188, - 881, 882, 729, 561, 561, 883, 884, 886, 887, 888, - 889, 729, 78, 319, 319, 890, 729, 891, 561, 97, - 892, 893, 158, 885, 561, 894, 895, 896, 897, 899, - 900, 836, 901, 902, 903, 904, 905, 97, 906, 907, - 158, 97, 910, 836, 911, 898, 912, 913, 836, 908, - - 914, 915, 916, 917, 561, 909, 918, 104, 919, 920, - 921, 922, 923, 924, 729, 925, 926, 561, 927, 928, - 929, 561, 930, 729, 158, 158, 931, 932, 836, 933, - 188, 188, 934, 935, 936, 937, 561, 938, 97, 939, - 940, 941, 942, 943, 944, 945, 946, 947, 948, 949, - 950, 561, 951, 952, 953, 954, 955, 957, 958, 959, - 961, 962, 963, 964, 965, 966, 967, 186, 968, 969, - 561, 970, 971, 956, 972, 186, 960, 561, 973, 974, - 561, 975, 561, 976, 977, 836, 978, 979, 186, 561, - 981, 561, 982, 561, 983, 561, 984, 561, 836, 985, - - 561, 986, 186, 561, 980, 987, 988, 989, 990, 561, - 991, 992, 561, 561, 4, 736, 735, 734, 158, 561, - 733, 732, 731, 730, 107, 107, 729, 77, 728, 727, - 726, 77, 188, 725, 724, 723, 722, 97, 97, 721, - 720, 719, 718, 717, 186, 319, 716, 186, 715, 158, - 714, 319, 713, 712, 711, 710, 709, 708, 319, 705, - 319, 704, 703, 702, 107, 107, 107, 158, 701, 700, - 699, 104, 104, 698, 697, 696, 695, 694, 693, 692, - 691, 690, 689, 104, 688, 687, 686, 685, 186, 607, - 158, 682, 681, 680, 679, 677, 676, 186, 675, 674, - - 186, 186, 673, 672, 186, 275, 188, 671, 670, 669, - 668, 667, 666, 186, 186, 663, 158, 662, 158, 188, - 97, 661, 660, 659, 658, 657, 656, 655, 654, 653, - 79, 652, 29, 651, 97, 650, 649, 648, 644, 643, - 186, 642, 641, 188, 640, 158, 158, 639, 638, 97, - 637, 636, 635, 631, 630, 629, 628, 627, 607, 77, - 623, 622, 188, 97, 607, 97, 158, 621, 618, 275, - 188, 158, 617, 616, 158, 615, 614, 613, 158, 561, - 612, 188, 607, 611, 158, 610, 609, 608, 275, 607, - 606, 275, 605, 604, 603, 602, 601, 600, 599, 591, - - 590, 589, 158, 588, 587, 586, 585, 584, 583, 97, - 186, 188, 97, 275, 582, 581, 580, 578, 577, 576, - 575, 104, 104, 574, 573, 104, 568, 104, 104, 567, - 566, 565, 104, 564, 104, 188, 563, 562, 561, 560, - 559, 552, 551, 550, 549, 548, 547, 546, 545, 544, - 543, 107, 540, 97, 537, 536, 186, 535, 534, 531, - 530, 529, 107, 528, 527, 526, 525, 524, 523, 522, - 521, 520, 519, 518, 517, 516, 515, 29, 514, 512, - 511, 158, 508, 507, 506, 505, 502, 319, 186, 501, - 498, 497, 496, 495, 494, 493, 492, 491, 488, 487, - - 486, 485, 484, 483, 482, 481, 480, 188, 479, 476, - 475, 474, 97, 473, 472, 471, 470, 469, 97, 468, - 467, 466, 465, 186, 464, 463, 462, 461, 460, 459, - 458, 457, 456, 107, 107, 455, 158, 454, 186, 453, - 452, 451, 450, 449, 448, 188, 440, 439, 438, 437, - 436, 432, 429, 428, 427, 426, 104, 420, 419, 418, - 417, 416, 415, 414, 413, 412, 411, 410, 409, 158, - 104, 408, 407, 406, 405, 404, 104, 403, 402, 401, - 158, 400, 399, 395, 387, 97, 384, 382, 377, 373, - 367, 364, 363, 362, 361, 360, 359, 358, 357, 356, - - 355, 354, 188, 188, 350, 349, 348, 347, 346, 345, - 342, 341, 340, 339, 335, 334, 97, 331, 330, 186, - 329, 328, 326, 325, 107, 322, 321, 158, 320, 317, - 316, 314, 313, 275, 312, 158, 107, 311, 308, 307, - 188, 305, 304, 303, 302, 97, 301, 298, 186, 107, - 287, 286, 284, 186, 283, 279, 270, 269, 268, 265, - 264, 263, 259, 104, 258, 257, 104, 104, 104, 254, - 253, 252, 251, 250, 249, 248, 104, 247, 246, 245, - 244, 104, 97, 243, 242, 241, 240, 81, 80, 239, - 169, 116, 104, 115, 114, 111, 105, 104, 104, 100, - - 99, 96, 90, 85, 84, 83, 82, 81, 80, 28, - 27, 22, 21, 993, 3, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993 - } ; - -static yyconst short int yy_chk[1389] = - { 0, - 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, - 0, 1, 12, 12, 1, 1, 1, 13, 24, 24, - 0, 0, 13, 0, 0, 0, 1, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, - 1, 1, 46, 0, 62, 184, 31, 33, 62, 46, - 39, 33, 0, 30, 39, 184, 31, 33, 34, 30, - 75, 36, 34, 36, 39, 72, 75, 72, 1, 1, - 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, - 118, 2, 139, 2, 43, 43, 2, 2, 2, 44, - 52, 118, 44, 44, 43, 43, 139, 123, 2, 52, - - 52, 52, 123, 52, 68, 52, 52, 163, 68, 163, - 2, 2, 2, 2, 53, 56, 56, 56, 53, 56, - 56, 55, 53, 56, 55, 55, 138, 56, 53, 55, - 57, 53, 55, 57, 53, 55, 57, 60, 138, 55, - 2, 2, 2, 2, 2, 16, 60, 60, 60, 640, - 16, 151, 60, 73, 16, 16, 73, 73, 151, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 127, 16, 641, 127, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - - 16, 16, 16, 16, 16, 16, 16, 16, 124, 16, - 16, 16, 16, 54, 105, 384, 54, 384, 105, 114, - 54, 54, 114, 124, 54, 122, 58, 54, 58, 122, - 58, 54, 58, 54, 59, 59, 143, 114, 59, 143, - 122, 128, 125, 58, 412, 128, 125, 642, 59, 63, - 412, 63, 63, 63, 63, 63, 63, 63, 64, 125, - 63, 63, 63, 63, 132, 64, 64, 65, 132, 154, - 181, 65, 64, 64, 643, 65, 64, 181, 64, 66, - 135, 65, 135, 154, 66, 135, 135, 65, 66, 65, - 189, 66, 67, 140, 66, 66, 67, 66, 140, 67, - - 67, 74, 172, 172, 67, 74, 140, 166, 189, 67, - 67, 69, 74, 69, 74, 69, 69, 69, 69, 69, - 70, 166, 141, 69, 70, 182, 339, 70, 70, 644, - 69, 339, 70, 182, 141, 70, 70, 71, 175, 70, - 70, 190, 70, 141, 71, 71, 195, 190, 203, 175, - 195, 71, 203, 212, 71, 222, 219, 190, 203, 217, - 220, 217, 219, 219, 212, 224, 224, 226, 220, 231, - 222, 222, 228, 228, 226, 234, 224, 231, 217, 224, - 269, 224, 232, 231, 235, 232, 235, 269, 330, 234, - 263, 271, 645, 232, 279, 647, 317, 349, 330, 235, - - 232, 263, 374, 263, 263, 263, 279, 271, 271, 317, - 279, 279, 279, 279, 279, 344, 349, 353, 380, 441, - 395, 411, 374, 422, 422, 648, 344, 441, 442, 353, - 649, 395, 380, 395, 395, 395, 395, 442, 411, 441, - 442, 475, 486, 535, 442, 492, 492, 475, 508, 486, - 563, 492, 554, 554, 595, 650, 651, 535, 508, 486, - 595, 646, 563, 652, 508, 646, 653, 654, 655, 656, - 657, 658, 659, 660, 661, 662, 656, 663, 664, 665, - 666, 667, 668, 669, 670, 671, 672, 673, 674, 675, - 676, 677, 678, 679, 680, 681, 682, 673, 683, 684, - - 685, 686, 687, 688, 689, 690, 691, 692, 693, 694, - 695, 696, 697, 698, 699, 700, 701, 702, 703, 704, - 705, 706, 707, 708, 709, 710, 711, 712, 713, 714, - 715, 716, 717, 718, 719, 720, 721, 722, 723, 724, - 725, 726, 727, 728, 730, 731, 711, 732, 733, 734, - 735, 736, 737, 738, 739, 740, 741, 742, 743, 744, - 745, 746, 747, 748, 749, 750, 751, 752, 753, 754, - 755, 756, 757, 758, 759, 760, 761, 762, 763, 764, - 765, 766, 767, 768, 769, 770, 771, 772, 773, 774, - 775, 776, 777, 778, 779, 780, 781, 782, 783, 784, - - 785, 786, 787, 788, 789, 790, 791, 792, 793, 794, - 795, 796, 797, 798, 799, 800, 801, 802, 803, 804, - 805, 806, 807, 808, 809, 810, 811, 812, 813, 814, - 815, 816, 817, 818, 819, 820, 821, 822, 823, 824, - 825, 826, 827, 828, 829, 830, 831, 832, 833, 834, - 835, 837, 838, 839, 840, 841, 842, 843, 844, 845, - 846, 847, 848, 849, 850, 851, 852, 853, 854, 855, - 856, 857, 858, 842, 859, 860, 861, 862, 863, 864, - 865, 866, 867, 868, 869, 870, 871, 872, 873, 874, - 875, 876, 877, 878, 879, 863, 880, 881, 882, 876, - - 883, 884, 885, 886, 887, 876, 888, 889, 890, 891, - 892, 893, 894, 895, 896, 897, 898, 899, 900, 901, - 902, 903, 904, 905, 906, 907, 908, 909, 910, 911, - 912, 913, 914, 915, 916, 917, 918, 919, 920, 921, - 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, - 932, 933, 934, 935, 936, 937, 938, 939, 940, 941, - 942, 943, 944, 945, 946, 947, 948, 949, 950, 951, - 952, 953, 954, 938, 955, 956, 941, 957, 958, 959, - 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, - 970, 971, 972, 973, 974, 975, 976, 977, 978, 979, - - 980, 981, 982, 983, 967, 984, 985, 986, 987, 988, - 989, 990, 991, 992, 994, 639, 638, 637, 636, 635, - 634, 633, 632, 631, 630, 629, 628, 627, 626, 625, - 624, 623, 622, 621, 620, 619, 618, 617, 616, 615, - 614, 613, 612, 611, 610, 609, 608, 606, 605, 604, - 603, 602, 601, 600, 599, 598, 597, 596, 594, 593, - 592, 590, 589, 588, 587, 586, 585, 584, 583, 582, - 581, 580, 579, 578, 577, 576, 575, 574, 573, 572, - 571, 570, 569, 568, 567, 566, 565, 564, 562, 560, - 559, 558, 557, 556, 555, 553, 552, 551, 550, 549, - - 548, 547, 546, 545, 544, 543, 542, 541, 540, 539, - 538, 537, 536, 533, 532, 531, 530, 529, 528, 527, - 526, 525, 524, 523, 522, 521, 520, 519, 518, 517, - 516, 515, 514, 513, 512, 511, 510, 509, 507, 506, - 505, 504, 503, 502, 501, 500, 499, 498, 497, 496, - 495, 494, 493, 491, 490, 489, 488, 487, 485, 484, - 483, 482, 481, 480, 479, 478, 477, 476, 474, 473, - 472, 471, 469, 468, 467, 466, 465, 464, 463, 462, - 461, 460, 459, 458, 457, 456, 455, 454, 453, 452, - 451, 450, 449, 448, 447, 446, 445, 444, 443, 440, - - 439, 438, 437, 436, 435, 434, 433, 432, 431, 430, - 429, 428, 427, 426, 425, 424, 423, 421, 420, 419, - 418, 417, 416, 415, 414, 413, 410, 409, 408, 407, - 406, 405, 404, 403, 402, 401, 400, 399, 398, 397, - 396, 394, 393, 392, 391, 390, 389, 388, 387, 386, - 385, 383, 382, 381, 379, 378, 377, 376, 375, 373, - 372, 371, 370, 369, 368, 367, 366, 365, 364, 363, - 362, 361, 360, 359, 358, 357, 356, 355, 354, 352, - 351, 350, 348, 347, 346, 345, 343, 342, 341, 340, - 338, 337, 336, 335, 334, 333, 332, 331, 329, 328, - - 327, 326, 325, 324, 323, 322, 321, 320, 318, 316, - 315, 314, 313, 312, 311, 310, 309, 308, 307, 306, - 305, 304, 302, 301, 300, 299, 298, 297, 296, 295, - 294, 293, 292, 291, 290, 289, 288, 287, 286, 285, - 284, 283, 282, 281, 280, 278, 277, 276, 274, 273, - 272, 270, 268, 267, 266, 265, 264, 262, 261, 260, - 259, 258, 257, 256, 255, 254, 253, 252, 251, 250, - 249, 248, 247, 246, 245, 244, 243, 242, 241, 239, - 238, 237, 236, 233, 230, 229, 227, 225, 223, 221, - 218, 216, 215, 214, 213, 211, 210, 209, 208, 207, - - 206, 205, 204, 202, 201, 200, 199, 198, 197, 196, - 194, 193, 192, 191, 187, 185, 183, 180, 179, 178, - 177, 176, 174, 173, 171, 170, 169, 168, 167, 165, - 164, 162, 161, 160, 159, 157, 156, 155, 153, 152, - 150, 149, 148, 147, 146, 145, 144, 142, 137, 136, - 134, 133, 131, 130, 129, 126, 121, 120, 119, 117, - 116, 115, 113, 112, 111, 110, 109, 108, 106, 103, - 102, 101, 100, 99, 98, 96, 95, 94, 93, 92, - 91, 90, 89, 88, 87, 86, 85, 81, 80, 76, - 61, 50, 49, 48, 47, 45, 42, 41, 40, 38, - - 37, 35, 32, 28, 27, 26, 25, 23, 20, 15, - 14, 11, 7, 3, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, - 993, 993, 993, 993, 993, 993, 993, 993 - } ; - -static yy_state_type yy_last_accepting_state; -static char *yy_last_accepting_cpos; - -/* The intent behind this definition is that it'll catch - * any uses of REJECT which flex missed. - */ -#define REJECT reject_used_but_not_detected -#define yymore() yymore_used_but_not_detected -#define YY_MORE_ADJ 0 -#define YY_RESTORE_YY_MORE_OFFSET -char *yytext; -#line 1 "lexer.l" -#define INITIAL 0 -#line 2 "lexer.l" -#include -#include -#include "nodes.h" - -#ifdef WIN32 -#define strdup _strdup -#define fileno _fileno -#define isatty _isatty -#endif - -/* enlarge token buffer to tokenize whole strings */ -#undef YYLMAX -#define YYLMAX 64000 - -#ifdef __cplusplus -extern "C" { -#endif -#include "grammar.h" -int yywrap(); -#ifdef __cplusplus -} -#endif - -#ifdef WIN32 -extern YYSTYPE yylval; -#endif -#ifdef TOKEN_DEBUG -#define token_debug printf -#else -int token_debug(const char *format, ...); -#endif -#line 1026 "lex.yy.c" - -/* Macros after this point can all be overridden by user definitions in - * section 1. - */ - -#ifndef YY_SKIP_YYWRAP -#ifdef __cplusplus -extern "C" int yywrap YY_PROTO(( void )); -#else -extern int yywrap YY_PROTO(( void )); -#endif -#endif - -#ifndef YY_NO_UNPUT -//static void yyunput YY_PROTO(( int c, char *buf_ptr )); -#endif - -#ifndef yytext_ptr -static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int )); -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen YY_PROTO(( yyconst char * )); -#endif - -#ifndef YY_NO_INPUT -#ifdef __cplusplus -static int yyinput YY_PROTO(( void )); -#else -static int input YY_PROTO(( void )); -#endif -#endif - -#if YY_STACK_USED -static int yy_start_stack_ptr = 0; -static int yy_start_stack_depth = 0; -static int *yy_start_stack = 0; -#ifndef YY_NO_PUSH_STATE -static void yy_push_state YY_PROTO(( int new_state )); -#endif -#ifndef YY_NO_POP_STATE -static void yy_pop_state YY_PROTO(( void )); -#endif -#ifndef YY_NO_TOP_STATE -static int yy_top_state YY_PROTO(( void )); -#endif - -#else -#define YY_NO_PUSH_STATE 1 -#define YY_NO_POP_STATE 1 -#define YY_NO_TOP_STATE 1 -#endif - -#ifdef YY_MALLOC_DECL -YY_MALLOC_DECL -#else -#if __STDC__ -#ifndef __cplusplus -#include -#endif -#else -/* Just try to get by without declaring the routines. This will fail - * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int) - * or sizeof(void*) != sizeof(int). - */ -#endif -#endif - -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#define YY_READ_BUF_SIZE 8192 -#endif - -/* Copy whatever the last rule matched to the standard output. */ - -#ifndef ECHO -/* This used to be an fputs(), but since the string might contain NUL's, - * we now use fwrite(). - */ -#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0) -#endif - -/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, - * is returned in "result". - */ -#ifndef YY_INPUT -#define YY_INPUT(buf,result,max_size) \ - if ( yy_current_buffer->yy_is_interactive ) \ - { \ - int c = '*', n; \ - for ( n = 0; n < max_size && \ - (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ - buf[n] = (char) c; \ - if ( c == '\n' ) \ - buf[n++] = (char) c; \ - if ( c == EOF && ferror( yyin ) ) \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - result = n; \ - } \ - else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \ - && ferror( yyin ) ) \ - YY_FATAL_ERROR( "input in flex scanner failed" ); -#endif - -/* No semi-colon after return; correct usage is to write "yyterminate();" - - * we don't want an extra ';' after the "return" because that will cause - * some compilers to complain about unreachable statements. - */ -#ifndef yyterminate -#define yyterminate() return YY_NULL -#endif - -/* Number of entries by which start-condition stack grows. */ -#ifndef YY_START_STACK_INCR -#define YY_START_STACK_INCR 25 -#endif - -/* Report a fatal error. */ -#ifndef YY_FATAL_ERROR -#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) -#endif - -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. - */ -#ifndef YY_DECL -#define YY_DECL int yylex YY_PROTO(( void )) -#endif - -/* Code executed at the beginning of each rule, after yytext and yyleng - * have been set up. - */ -#ifndef YY_USER_ACTION -#define YY_USER_ACTION -#endif - -/* Code executed at the end of each rule. */ -#ifndef YY_BREAK -#define YY_BREAK break; -#endif - -#define YY_RULE_SETUP \ - YY_USER_ACTION - -YY_DECL - { - register yy_state_type yy_current_state; - register char *yy_cp, *yy_bp; - register int yy_act; - -#line 90 "lexer.l" - -#line 1179 "lex.yy.c" - - if ( yy_init ) - { - yy_init = 0; - -#ifdef YY_USER_INIT - YY_USER_INIT; -#endif - - if ( ! yy_start ) - yy_start = 1; /* first start state */ - - if ( ! yyin ) - yyin = stdin; - - if ( ! yyout ) - yyout = stdout; - - if ( ! yy_current_buffer ) - yy_current_buffer = - yy_create_buffer( yyin, YY_BUF_SIZE ); - - yy_load_buffer_state(); - } - - while ( 1 ) /* loops until end-of-file is reached */ - { - yy_cp = yy_c_buf_p; - - /* Support of yytext. */ - *yy_cp = yy_hold_char; - - /* yy_bp points to the position in yy_ch_buf of the start of - * the current run. - */ - yy_bp = yy_cp; - - yy_current_state = yy_start; -yy_match: - do - { - register YY_CHAR yy_c = sal::static_int_cast(yy_ec[YY_SC_TO_UI(*yy_cp)]); - if ( yy_accept[yy_current_state] ) - { - yy_last_accepting_state = yy_current_state; - yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 994 ) - yy_c = sal::static_int_cast(yy_meta[(unsigned int) yy_c]); - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - ++yy_cp; - } - while ( yy_base[yy_current_state] != 1315 ); - -yy_find_action: - yy_act = yy_accept[yy_current_state]; - if ( yy_act == 0 ) - { /* have to back up */ - yy_cp = yy_last_accepting_cpos; - yy_current_state = yy_last_accepting_state; - yy_act = yy_accept[yy_current_state]; - } - - YY_DO_BEFORE_ACTION; - - -do_action: /* This label is used only to access EOF actions. */ - - - switch ( yy_act ) - { /* beginning of action switch */ - case 0: /* must back up */ - /* undo the effects of YY_DO_BEFORE_ACTION */ - *yy_cp = yy_hold_char; - yy_cp = yy_last_accepting_cpos; - yy_current_state = yy_last_accepting_state; - goto yy_find_action; - -case 1: -YY_RULE_SETUP -#line 91 "lexer.l" -{ yylval.str = yytext+1; token_debug(" ==>Begin[%s]\n",yytext+1); return EQBEGIN; } - //YY_BREAK -case 2: -YY_RULE_SETUP -#line 92 "lexer.l" -{ yylval.str = yytext+1; token_debug(" ==>End[%s]\n",yytext+1); return EQEND; } - //YY_BREAK -case 3: -YY_RULE_SETUP -#line 93 "lexer.l" -{ yylval.str = yytext+1; token_debug(" ==>Left[%s]\n",yytext+1); return EQLEFT; } - //YY_BREAK -case 4: -YY_RULE_SETUP -#line 94 "lexer.l" -{ yylval.str = yytext+1; token_debug(" ==>LeftDelim[%s]\n",yytext+1); return LEFT_DELIM; } - //YY_BREAK -case 5: -YY_RULE_SETUP -#line 95 "lexer.l" -{ yylval.str = yytext+1; token_debug(" ==>RightDelim[%s]\n",yytext+1); return RIGHT_DELIM; } - //YY_BREAK -case 6: -YY_RULE_SETUP -#line 96 "lexer.l" -{ yylval.str = yytext+1; token_debug(" ==>Right[%s]\n",yytext+1); return EQRIGHT; } - //YY_BREAK -case 7: -YY_RULE_SETUP -#line 97 "lexer.l" -{ yylval.str = yytext; token_debug(" ==>NewLine[%s]\n",yytext); return NEWLINE; } - //YY_BREAK -case 8: -YY_RULE_SETUP -#line 99 "lexer.l" -{ yylval.str = yytext+1; token_debug(" ==>Accent[%s]\n",yytext+1); return ACCENT; } - //YY_BREAK -case 9: -YY_RULE_SETUP -#line 100 "lexer.l" -{ yylval.str = yytext+1; token_debug(" ==>Small_Greek[%s]\n",yytext+1); return SMALL_GREEK; } - //YY_BREAK -case 10: -YY_RULE_SETUP -#line 101 "lexer.l" -{ yylval.str = yytext+1; token_debug(" ==>Capital_Greek[%s]\n",yytext+1); return CAPITAL_GREEK; } - //YY_BREAK -case 11: -YY_RULE_SETUP -#line 102 "lexer.l" -{ yylval.str = yytext+1; token_debug(" ==>Binary_Operator[%s]\n",yytext+1); return BINARY_OPERATOR; } - //YY_BREAK -case 12: -YY_RULE_SETUP -#line 103 "lexer.l" -{ yylval.str = yytext+1; token_debug(" ==>Relation_Symbol[%s]\n",yytext+1); return RELATION_OPERATOR; } - //YY_BREAK -case 13: -YY_RULE_SETUP -#line 105 "lexer.l" -{ yylval.str = strdup("neq"); token_debug(" ==>Relation_Symbol[neq]\n"); return RELATION_OPERATOR; } - //YY_BREAK -case 14: -YY_RULE_SETUP -#line 106 "lexer.l" -{ yylval.str = strdup("vmlt"); token_debug(" ==>Relation_Symbol[neq]\n"); return RELATION_OPERATOR; } - //YY_BREAK -case 15: -YY_RULE_SETUP -#line 107 "lexer.l" -{ yylval.str = strdup("vmgt"); token_debug(" ==>Relation_Symbol[neq]\n"); return RELATION_OPERATOR; } - //YY_BREAK -case 16: -YY_RULE_SETUP -#line 108 "lexer.l" -{ yylval.str = strdup("mlt"); token_debug(" ==>Relation_Symbol[neq]\n"); return RELATION_OPERATOR; } - //YY_BREAK -case 17: -YY_RULE_SETUP -#line 109 "lexer.l" -{ yylval.str = strdup("mgt"); token_debug(" ==>Relation_Symbol[neq]\n"); return RELATION_OPERATOR; } - //YY_BREAK -case 18: -YY_RULE_SETUP -#line 110 "lexer.l" -{ yylval.str = yytext; token_debug(" ==>Relation_Symbol[neq]\n"); return RELATION_OPERATOR; } - //YY_BREAK -case 19: -YY_RULE_SETUP -#line 112 "lexer.l" -{ yylval.str = yytext+1; token_debug(" ==>Arrow[%s]\n",yytext+1); return ARROW; } - //YY_BREAK -case 20: -YY_RULE_SETUP -#line 113 "lexer.l" -{ yylval.str = strdup("leftrightarrow"); token_debug(" ==>Arrow[leftrightarrow]\n"); return ARROW; } - //YY_BREAK -case 21: -YY_RULE_SETUP -#line 114 "lexer.l" -{ yylval.str = strdup("rightarrow"); token_debug(" ==>Arrow[rightarrow]\n"); return ARROW; } - //YY_BREAK -case 22: -YY_RULE_SETUP -#line 115 "lexer.l" -{ yylval.str = strdup("leftarrow"); token_debug(" ==>Arrow[leftarrow]\n"); return ARROW; } - //YY_BREAK - -case 23: -YY_RULE_SETUP -#line 116 "lexer.l" -{ token_debug(" ==>Ignore[\\rm]\n"); } - //YY_BREAK -case 24: -YY_RULE_SETUP -#line 117 "lexer.l" -{ yylval.str = yytext+1; token_debug(" ==>General_Iden[%s]\n",yytext+1); return GENERAL_IDEN; } - //YY_BREAK -case 25: -YY_RULE_SETUP -#line 118 "lexer.l" -{ yylval.str = yytext+1; token_debug(" ==>General_Oper[%s]\n",yytext+1); return GENERAL_OPER; } - //YY_BREAK -case 26: -YY_RULE_SETUP -#line 119 "lexer.l" -{ yylval.str = yytext+1; token_debug(" ==>Big_Symbol[%s]\n",yytext+1); return BIG_SYMBOL; } - //YY_BREAK -case 27: -YY_RULE_SETUP -#line 120 "lexer.l" -{ yylval.str = yytext+1; token_debug(" ==>Function[%s]\n",yytext+1); return FUNCTION; } - //YY_BREAK -case 28: -YY_RULE_SETUP -#line 121 "lexer.l" -{ yylval.str = yytext+1; token_debug(" ==>Root[%s]\n",yytext+1); return ROOT; } - //YY_BREAK -case 29: -YY_RULE_SETUP -#line 122 "lexer.l" -{ yylval.str = yytext+1; token_debug(" ==>Fraction[%s]\n",yytext+1); return FRACTION; } - //YY_BREAK -case 30: -YY_RULE_SETUP -#line 123 "lexer.l" -{ yylval.str = yytext+1; token_debug(" ==>Over[%s]\n",yytext+1); return EQOVER; } - //YY_BREAK -case 31: -YY_RULE_SETUP -#line 124 "lexer.l" -{ yylval.str = yytext+1; token_debug(" ==>Delimeter[%s]\n",yytext+1); return DELIMETER; } - //YY_BREAK -case 32: -YY_RULE_SETUP -#line 125 "lexer.l" -{ yylval.str = yytext+1; token_debug(" ==>Large_Delim[%s]\n",yytext+1); return LARGE_DELIM; } - //YY_BREAK -case 33: -YY_RULE_SETUP -#line 126 "lexer.l" -{ yylval.str = yytext+1; token_debug(" ==>Decoration[%s]\n",yytext+1); return DECORATION; } - //YY_BREAK -case 34: -YY_RULE_SETUP -#line 127 "lexer.l" -{ yylval.str = yytext+1; token_debug(" ==>Space_Symbol[%s]\n",yytext+1); /*return SPACE_SYMBOL;*/ } - //YY_BREAK -case 35: -YY_RULE_SETUP -#line 128 "lexer.l" -{ yylval.str = strdup("quad"); token_debug(" ==>Space_Symbol[quad]\n"); /* return SPACE_SYMBOL;*/ } - //YY_BREAK -case 36: -YY_RULE_SETUP -#line 129 "lexer.l" -{ yylval.dval = yytext; token_debug(" ==>Digit[%s]\n",yytext); return DIGIT; } - //YY_BREAK -case 37: -YY_RULE_SETUP -#line 130 "lexer.l" -{ yylval.str = yytext; token_debug(" ==>Operator[%s]\n",yytext); return OPERATOR; } - //YY_BREAK -case 38: -YY_RULE_SETUP -#line 131 "lexer.l" -{ token_debug(" ==>SubSup[%s]\n",yytext); return yytext[0]; } - //YY_BREAK -case 39: -YY_RULE_SETUP -#line 132 "lexer.l" -{ token_debug(" ==>Paren[%s]\n",yytext); return yytext[0];} - //YY_BREAK -case 40: -YY_RULE_SETUP -#line 133 "lexer.l" -{ token_debug(" ==>Abs[%s]\n",yytext); return yytext[0];} - //YY_BREAK -case 41: -YY_RULE_SETUP -#line 134 "lexer.l" -{ token_debug(" ==>Space[0x%2x]\n",yytext[0]); } - YY_BREAK -case 42: -YY_RULE_SETUP -#line 135 "lexer.l" -{ token_debug(" ==>Ignore[0x%2x]\n",yytext[0]); } - YY_BREAK -case 43: -YY_RULE_SETUP -#line 136 "lexer.l" -{ yylval.str = yytext; token_debug(" ==>String[%s]\n",yytext); return STRING; } - //YY_BREAK -case 44: -YY_RULE_SETUP -#line 137 "lexer.l" -{ yylval.str = yytext; token_debug(" ==>Else[%s]\n",yytext); return CHARACTER; } - //YY_BREAK -case 45: -YY_RULE_SETUP -#line 138 "lexer.l" -ECHO; - YY_BREAK -#line 1487 "lex.yy.c" -case YY_STATE_EOF(INITIAL): - yyterminate(); - - case YY_END_OF_BUFFER: - { - /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1; - - /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = yy_hold_char; - YY_RESTORE_YY_MORE_OFFSET - - if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW ) - { - /* We're scanning a new file or input source. It's - * possible that this happened because the user - * just pointed yyin at a new source and called - * yylex(). If so, then we have to assure - * consistency between yy_current_buffer and our - * globals. Here is the right place to do so, because - * this is the first action (other than possibly a - * back-up) that will match for the new input source. - */ - yy_n_chars = yy_current_buffer->yy_n_chars; - yy_current_buffer->yy_input_file = yyin; - yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL; - } - - /* Note that here we test for yy_c_buf_p "<=" to the position - * of the first EOB in the buffer, since yy_c_buf_p will - * already have been incremented past the NUL character - * (since all states make transitions on EOB to the - * end-of-buffer state). Contrast this with the test - * in input(). - */ - if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] ) - { /* This was really a NUL. */ - yy_state_type yy_next_state; - - yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state(); - - /* Okay, we're now positioned to make the NUL - * transition. We couldn't have - * yy_get_previous_state() go ahead and do it - * for us because it doesn't know how to deal - * with the possibility of jamming (and we don't - * want to build jamming into it because then it - * will run more slowly). - */ - - yy_next_state = yy_try_NUL_trans( yy_current_state ); - - yy_bp = yytext_ptr + YY_MORE_ADJ; - - if ( yy_next_state ) - { - /* Consume the NUL. */ - yy_cp = ++yy_c_buf_p; - yy_current_state = yy_next_state; - goto yy_match; - } - - else - { - yy_cp = yy_c_buf_p; - goto yy_find_action; - } - } - - else switch ( yy_get_next_buffer() ) - { - case EOB_ACT_END_OF_FILE: - { - yy_did_buffer_switch_on_eof = 0; - - if ( yywrap() ) - { - /* Note: because we've taken care in - * yy_get_next_buffer() to have set up - * yytext, we can now set up - * yy_c_buf_p so that if some total - * hoser (like flex itself) wants to - * call the scanner after we return the - * YY_NULL, it'll still work - another - * YY_NULL will get returned. - */ - yy_c_buf_p = yytext_ptr + YY_MORE_ADJ; - - yy_act = YY_STATE_EOF(YY_START); - goto do_action; - } - - else - { - if ( ! yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; - } - break; - } - - case EOB_ACT_CONTINUE_SCAN: - yy_c_buf_p = - yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state(); - - yy_cp = yy_c_buf_p; - yy_bp = yytext_ptr + YY_MORE_ADJ; - goto yy_match; - - case EOB_ACT_LAST_MATCH: - yy_c_buf_p = - &yy_current_buffer->yy_ch_buf[yy_n_chars]; - - yy_current_state = yy_get_previous_state(); - - yy_cp = yy_c_buf_p; - yy_bp = yytext_ptr + YY_MORE_ADJ; - goto yy_find_action; - } - break; - } - - default: - YY_FATAL_ERROR( - "fatal flex scanner internal error--no action found" ); - } /* end of action switch */ - } /* end of scanning one token */ - } /* end of yylex */ - - -/* yy_get_next_buffer - try to read in a new buffer - * - * Returns a code representing an action: - * EOB_ACT_LAST_MATCH - - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position - * EOB_ACT_END_OF_FILE - end of file - */ - -static int yy_get_next_buffer() - { - register char *dest = yy_current_buffer->yy_ch_buf; - register char *source = yytext_ptr; - register int number_to_move, i; - int ret_val; - - if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] ) - YY_FATAL_ERROR( - "fatal flex scanner internal error--end of buffer missed" ); - - if ( yy_current_buffer->yy_fill_buffer == 0 ) - { /* Don't try to fill the buffer, so this is an EOF. */ - if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 ) - { - /* We matched a single character, the EOB, so - * treat this as a final EOF. - */ - return EOB_ACT_END_OF_FILE; - } - - else - { - /* We matched some text prior to the EOB, first - * process it. - */ - return EOB_ACT_LAST_MATCH; - } - } - - /* Try to read more data. */ - - /* First move last chars to start of buffer. */ - number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1; - - for ( i = 0; i < number_to_move; ++i ) - *(dest++) = *(source++); - - if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING ) - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - yy_current_buffer->yy_n_chars = yy_n_chars = 0; - - else - { - int num_to_read = - yy_current_buffer->yy_buf_size - number_to_move - 1; - - while ( num_to_read <= 0 ) - { /* Not enough room in the buffer - grow it. */ -#ifdef YY_USES_REJECT - YY_FATAL_ERROR( -"input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); -#else - - /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = yy_current_buffer; - - int yy_c_buf_p_offset = - (int) (yy_c_buf_p - b->yy_ch_buf); - - if ( b->yy_is_our_buffer ) - { - int new_size = b->yy_buf_size * 2; - - if ( new_size <= 0 ) - b->yy_buf_size += b->yy_buf_size / 8; - else - b->yy_buf_size *= 2; - - b->yy_ch_buf = (char *) - /* Include room in for 2 EOB chars. */ - yy_flex_realloc( (void *) b->yy_ch_buf, - b->yy_buf_size + 2 ); - } - else - /* Can't grow it, we don't own it. */ - b->yy_ch_buf = 0; - - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( - "fatal error - scanner input buffer overflow" ); - - yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; - - num_to_read = yy_current_buffer->yy_buf_size - - number_to_move - 1; -#endif - } - - if ( num_to_read > YY_READ_BUF_SIZE ) - num_to_read = YY_READ_BUF_SIZE; - - /* Read in more data. */ - YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]), - yy_n_chars, num_to_read ); - - yy_current_buffer->yy_n_chars = yy_n_chars; - } - - if ( yy_n_chars == 0 ) - { - if ( number_to_move == YY_MORE_ADJ ) - { - ret_val = EOB_ACT_END_OF_FILE; - yyrestart( yyin ); - } - - else - { - ret_val = EOB_ACT_LAST_MATCH; - yy_current_buffer->yy_buffer_status = - YY_BUFFER_EOF_PENDING; - } - } - - else - ret_val = EOB_ACT_CONTINUE_SCAN; - - yy_n_chars += number_to_move; - yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR; - yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; - - yytext_ptr = &yy_current_buffer->yy_ch_buf[0]; - - return ret_val; - } - - -/* yy_get_previous_state - get the state just before the EOB char was reached */ - -static yy_state_type yy_get_previous_state() - { - register yy_state_type yy_current_state; - register char *yy_cp; - - yy_current_state = yy_start; - - for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp ) - { - register YY_CHAR yy_c = sal::static_int_cast(*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); - if ( yy_accept[yy_current_state] ) - { - yy_last_accepting_state = yy_current_state; - yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 994 ) - yy_c = sal::static_int_cast(yy_meta[(unsigned int) yy_c]); - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - } - - return yy_current_state; - } - - -/* yy_try_NUL_trans - try to make a transition on the NUL character - * - * synopsis - * next_state = yy_try_NUL_trans( current_state ); - */ - -#ifdef YY_USE_PROTOS -static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state ) -#else -static yy_state_type yy_try_NUL_trans( yy_current_state ) -yy_state_type yy_current_state; -#endif - { - register int yy_is_jam; - register char *yy_cp = yy_c_buf_p; - - register YY_CHAR yy_c = 1; - if ( yy_accept[yy_current_state] ) - { - yy_last_accepting_state = yy_current_state; - yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 994 ) - yy_c = sal::static_int_cast(yy_meta[(unsigned int) yy_c]); - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 993); - - return yy_is_jam ? 0 : yy_current_state; - } - -#ifdef __cplusplus -static int yyinput() -#else -static int input() -#endif - { - int c; - - *yy_c_buf_p = yy_hold_char; - - if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) - { - /* yy_c_buf_p now points to the character we want to return. - * If this occurs *before* the EOB characters, then it's a - * valid NUL; if not, then we've hit the end of the buffer. - */ - if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] ) - /* This was really a NUL. */ - *yy_c_buf_p = '\0'; - - else - { /* need more input */ - int offset = yy_c_buf_p - yytext_ptr; - ++yy_c_buf_p; - - switch ( yy_get_next_buffer() ) - { - case EOB_ACT_LAST_MATCH: - /* This happens because yy_g_n_b() - * sees that we've accumulated a - * token and flags that we need to - * try matching the token before - * proceeding. But for input(), - * there's no matching to consider. - * So convert the EOB_ACT_LAST_MATCH - * to EOB_ACT_END_OF_FILE. - */ - - /* Reset buffer status. */ - yyrestart( yyin ); - - /* fall through */ - - case EOB_ACT_END_OF_FILE: - { - if ( yywrap() ) - return EOF; - - if ( ! yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; -#ifdef __cplusplus - return yyinput(); -#else - return input(); -#endif - } - - case EOB_ACT_CONTINUE_SCAN: - yy_c_buf_p = yytext_ptr + offset; - break; - } - } - } - - c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */ - *yy_c_buf_p = '\0'; /* preserve yytext */ - yy_hold_char = *++yy_c_buf_p; - - - return c; - } - - -#ifdef YY_USE_PROTOS -void yyrestart( FILE *input_file ) -#else -void yyrestart( input_file ) -FILE *input_file; -#endif - { - if ( ! yy_current_buffer ) - yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); - - yy_init_buffer( yy_current_buffer, input_file ); - yy_load_buffer_state(); - } - - -#ifdef YY_USE_PROTOS -void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) -#else -void yy_switch_to_buffer( new_buffer ) -YY_BUFFER_STATE new_buffer; -#endif - { - if ( yy_current_buffer == new_buffer ) - return; - - if ( yy_current_buffer ) - { - /* Flush out information for old buffer. */ - *yy_c_buf_p = yy_hold_char; - yy_current_buffer->yy_buf_pos = yy_c_buf_p; - yy_current_buffer->yy_n_chars = yy_n_chars; - } - - yy_current_buffer = new_buffer; - yy_load_buffer_state(); - - /* We don't actually know whether we did this switch during - * EOF (yywrap()) processing, but the only time this flag - * is looked at is after yywrap() is called, so it's safe - * to go ahead and always set it. - */ - yy_did_buffer_switch_on_eof = 1; - } - - -#ifdef YY_USE_PROTOS -void yy_load_buffer_state( void ) -#else -void yy_load_buffer_state() -#endif - { - yy_n_chars = yy_current_buffer->yy_n_chars; - yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos; - yyin = yy_current_buffer->yy_input_file; - yy_hold_char = *yy_c_buf_p; - } - - -#ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_create_buffer( FILE *file, int size ) -#else -YY_BUFFER_STATE yy_create_buffer( file, size ) -FILE *file; -int size; -#endif - { - YY_BUFFER_STATE b; - - b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_buf_size = size; - - /* yy_ch_buf has to be 2 characters longer than the size given because - * we need to put in 2 end-of-buffer characters. - */ - b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 ); - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_is_our_buffer = 1; - - yy_init_buffer( b, file ); - - return b; - } - - -#ifdef YY_USE_PROTOS -void yy_delete_buffer( YY_BUFFER_STATE b ) -#else -void yy_delete_buffer( b ) -YY_BUFFER_STATE b; -#endif - { - if ( ! b ) - return; - - if ( b == yy_current_buffer ) - yy_current_buffer = (YY_BUFFER_STATE) 0; - - if ( b->yy_is_our_buffer ) - yy_flex_free( (void *) b->yy_ch_buf ); - - yy_flex_free( (void *) b ); - } - - -#ifndef YY_ALWAYS_INTERACTIVE -#ifndef YY_NEVER_INTERACTIVE -extern int isatty YY_PROTO(( int )); -#endif -#endif - -#ifdef YY_USE_PROTOS -void yy_init_buffer( YY_BUFFER_STATE b, FILE *file ) -#else -void yy_init_buffer( b, file ) -YY_BUFFER_STATE b; -FILE *file; -#endif - - - { - yy_flush_buffer( b ); - - b->yy_input_file = file; - b->yy_fill_buffer = 1; - -#if YY_ALWAYS_INTERACTIVE - b->yy_is_interactive = 1; -#else -#if YY_NEVER_INTERACTIVE - b->yy_is_interactive = 0; -#else - b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; -#endif -#endif - } - - -#ifdef YY_USE_PROTOS -void yy_flush_buffer( YY_BUFFER_STATE b ) -#else -void yy_flush_buffer( b ) -YY_BUFFER_STATE b; -#endif - - { - if ( ! b ) - return; - - b->yy_n_chars = 0; - - /* We always need two end-of-buffer characters. The first causes - * a transition to the end-of-buffer state. The second causes - * a jam in that state. - */ - b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; - b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; - - b->yy_buf_pos = &b->yy_ch_buf[0]; - - b->yy_at_bol = 1; - b->yy_buffer_status = YY_BUFFER_NEW; - - if ( b == yy_current_buffer ) - yy_load_buffer_state(); - } - - -#ifndef YY_NO_SCAN_BUFFER -#ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size ) -#else -YY_BUFFER_STATE yy_scan_buffer( base, size ) -char *base; -yy_size_t size; -#endif - { - YY_BUFFER_STATE b; - - if ( size < 2 || - base[size-2] != YY_END_OF_BUFFER_CHAR || - base[size-1] != YY_END_OF_BUFFER_CHAR ) - /* They forgot to leave room for the EOB's. */ - return 0; - - b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); - - b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ - b->yy_buf_pos = b->yy_ch_buf = base; - b->yy_is_our_buffer = 0; - b->yy_input_file = 0; - b->yy_n_chars = b->yy_buf_size; - b->yy_is_interactive = 0; - b->yy_at_bol = 1; - b->yy_fill_buffer = 0; - b->yy_buffer_status = YY_BUFFER_NEW; - - yy_switch_to_buffer( b ); - - return b; - } -#endif - - -#ifndef YY_NO_SCAN_STRING -#ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str ) -#else -YY_BUFFER_STATE yy_scan_string( yy_str ) -yyconst char *yy_str; -#endif - { - int len; - for ( len = 0; yy_str[len]; ++len ) - ; - - return yy_scan_bytes( yy_str, len ); - } -#endif - - -#ifndef YY_NO_SCAN_BYTES -#ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len ) -#else -YY_BUFFER_STATE yy_scan_bytes( bytes, len ) -yyconst char *bytes; -int len; -#endif - { - YY_BUFFER_STATE b; - char *buf; - yy_size_t n; - int i; - - /* Get memory for full buffer, including space for trailing EOB's. */ - n = len + 2; - buf = (char *) yy_flex_alloc( n ); - if ( ! buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); - - for ( i = 0; i < len; ++i ) - buf[i] = bytes[i]; - - buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR; - - b = yy_scan_buffer( buf, n ); - if ( ! b ) - YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); - - /* It's okay to grow etc. this buffer, and we should throw it - * away when we're done. - */ - b->yy_is_our_buffer = 1; - - return b; - } -#endif - - -#ifndef YY_NO_PUSH_STATE -#ifdef YY_USE_PROTOS -static void yy_push_state( int new_state ) -#else -static void yy_push_state( new_state ) -int new_state; -#endif - { - if ( yy_start_stack_ptr >= yy_start_stack_depth ) - { - yy_size_t new_size; - - yy_start_stack_depth += YY_START_STACK_INCR; - new_size = yy_start_stack_depth * sizeof( int ); - - if ( ! yy_start_stack ) - yy_start_stack = (int *) yy_flex_alloc( new_size ); - - else - yy_start_stack = (int *) yy_flex_realloc( - (void *) yy_start_stack, new_size ); - - if ( ! yy_start_stack ) - YY_FATAL_ERROR( - "out of memory expanding start-condition stack" ); - } - - yy_start_stack[yy_start_stack_ptr++] = YY_START; - - BEGIN(new_state); - } -#endif - - -#ifndef YY_NO_POP_STATE -static void yy_pop_state() - { - if ( --yy_start_stack_ptr < 0 ) - YY_FATAL_ERROR( "start-condition stack underflow" ); - - BEGIN(yy_start_stack[yy_start_stack_ptr]); - } -#endif - - -#ifndef YY_NO_TOP_STATE -static int yy_top_state() - { - return yy_start_stack[yy_start_stack_ptr - 1]; - } -#endif - -#ifndef YY_EXIT_FAILURE -#define YY_EXIT_FAILURE 2 -#endif - -#ifdef YY_USE_PROTOS -static void yy_fatal_error( yyconst char msg[] ) -#else -static void yy_fatal_error( msg ) -char msg[]; -#endif - { - (void) fprintf( stderr, "%s\n", msg ); - exit( YY_EXIT_FAILURE ); - } - - - -/* Redefine yyless() so it works in section 3 code. */ - -#undef yyless -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - yytext[yyleng] = yy_hold_char; \ - yy_c_buf_p = yytext + n; \ - yy_hold_char = *yy_c_buf_p; \ - *yy_c_buf_p = '\0'; \ - yyleng = n; \ - } \ - while ( 0 ) - - -/* Internal utility routines. */ - -#ifndef yytext_ptr -#ifdef YY_USE_PROTOS -static void yy_flex_strncpy( char *s1, yyconst char *s2, int n ) -#else -static void yy_flex_strncpy( s1, s2, n ) -char *s1; -yyconst char *s2; -int n; -#endif - { - register int i; - for ( i = 0; i < n; ++i ) - s1[i] = s2[i]; - } -#endif - -#ifdef YY_NEED_STRLEN -#ifdef YY_USE_PROTOS -static int yy_flex_strlen( yyconst char *s ) -#else -static int yy_flex_strlen( s ) -yyconst char *s; -#endif - { - register int n; - for ( n = 0; s[n]; ++n ) - ; - - return n; - } -#endif - - -#ifdef YY_USE_PROTOS -static void *yy_flex_alloc( yy_size_t size ) -#else -static void *yy_flex_alloc( size ) -yy_size_t size; -#endif - { - return (void *) malloc( size ); - } - -#ifdef YY_USE_PROTOS -static void *yy_flex_realloc( void *ptr, yy_size_t size ) -#else -static void *yy_flex_realloc( ptr, size ) -void *ptr; -yy_size_t size; -#endif - { - /* The cast to (char *) in the following accommodates both - * implementations that use char* generic pointers, and those - * that use void* generic pointers. It works with the latter - * because both ANSI C and C++ allow castless assignment from - * any pointer type to void*, and deal with argument conversions - * as though doing an assignment. - */ - return (void *) realloc( (char *) ptr, size ); - } - -#ifdef YY_USE_PROTOS -static void yy_flex_free( void *ptr ) -#else -static void yy_flex_free( ptr ) -void *ptr; -#endif - { - free( ptr ); - } - -#if YY_MAIN -int main() - { - yylex(); - return 0; - } -#endif -#line 138 "lexer.l" - - -void initFlex(const char *_code ) -{ - yy_switch_to_buffer( yy_scan_string(_code) ); -} - -int yywrap() -{ - yy_delete_buffer( YY_CURRENT_BUFFER ); - return 1; -} - -#ifndef TOKEN_DEBUG -int token_debug(const char * /*format*/, ...) -{ - return 0; -} -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/hwpfilter/source/lexer.cxx b/hwpfilter/source/lexer.cxx new file mode 100644 index 000000000000..3c73a66ff48e --- /dev/null +++ b/hwpfilter/source/lexer.cxx @@ -0,0 +1,2364 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + ************************************************************************/ + +/* A lexical scanner generated by flex */ + +/* Scanner skeleton version: + */ +#ifndef YY_STACK_USED +#define YY_STACK_USED 0 +#endif +#ifndef YY_ALWAYS_INTERACTIVE +#define YY_ALWAYS_INTERACTIVE 0 +#endif +#ifndef YY_NEVER_INTERACTIVE +#define YY_NEVER_INTERACTIVE 0 +#endif +#ifndef YY_MAIN +#define YY_MAIN 0 +#endif + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 + +#include + + +/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ +#ifdef c_plusplus +#ifndef __cplusplus +#define __cplusplus +#endif +#endif + + +#ifdef __cplusplus + +#include +#ifndef WIN32 +#include +#else +#include +#endif + + +/* Use prototypes in function declarations. */ +#define YY_USE_PROTOS + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +#if __STDC__ + +#define YY_USE_PROTOS +#define YY_USE_CONST + +#endif /* __STDC__ */ +#endif /* ! __cplusplus */ + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + + +#ifdef YY_USE_PROTOS +#define YY_PROTO(proto) proto +#else +#define YY_PROTO(proto) () +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an unsigned + * integer for use as an array index. If the signed char is negative, + * we want to instead treat it as an 8-bit unsigned char, hence the + * double cast. + */ +#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN yy_start = 1 + 2 * + +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START ((yy_start - 1) / 2) +#define YYSTATE YY_START + +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart( yyin ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#define YY_BUF_SIZE 16384 + +typedef struct yy_buffer_state *YY_BUFFER_STATE; + +extern int yyleng; +extern FILE *yyin, *yyout; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + +/* The funky do-while in the following #define is used to turn the definition + * int a single C statement (which needs a semi-colon terminator). This + * avoids problems with code like: + * + * if ( condition_holds ) + * yyless( 5 ); + * else + * do_something_else(); + * + * Prior to using the do-while the compiler would get upset at the + * "else" because it interpreted the "if" statement as being all + * done when it reached the ';' after the yyless() call. + */ + +/* Return all but the first 'n' matched characters back to the input stream. */ + +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + *yy_cp = yy_hold_char; \ + YY_RESTORE_YY_MORE_OFFSET \ + yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) + +//#define unput(c) yyunput( c, yytext_ptr ) + +/* The following is because we cannot portably get our hands on size_t + * (without autoconf's help, which isn't available because we want + * flex-generated scanners to compile on their own). + */ +typedef unsigned int yy_size_t; + + +struct yy_buffer_state + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + int yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + }; + +static YY_BUFFER_STATE yy_current_buffer = 0; + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + */ +#define YY_CURRENT_BUFFER yy_current_buffer + + +/* yy_hold_char holds the character lost when yytext is formed. */ +static char yy_hold_char; + +static int yy_n_chars; /* number of characters read into yy_ch_buf */ + + +int yyleng; + +/* Points to current character in buffer. */ +static char *yy_c_buf_p = (char *) 0; +static int yy_init = 1; /* whether we need to initialize */ +static int yy_start = 0; /* start state number */ + +/* Flag which is used to allow yywrap()'s to do buffer switches + * instead of setting up a fresh yyin. A bit of a hack ... + */ +static int yy_did_buffer_switch_on_eof; + +void yyrestart YY_PROTO(( FILE *input_file )); + +void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer )); +void yy_load_buffer_state YY_PROTO(( void )); +YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size )); +void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b )); +void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file )); +void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b )); +#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer ) + +YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size )); +YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str )); +YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len )); + +static void *yy_flex_alloc YY_PROTO(( yy_size_t )); +static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t )); +static void yy_flex_free YY_PROTO(( void * )); + +#define yy_new_buffer yy_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! yy_current_buffer ) \ + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ + yy_current_buffer->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! yy_current_buffer ) \ + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ + yy_current_buffer->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (yy_current_buffer->yy_at_bol) + +typedef unsigned char YY_CHAR; +FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; +typedef int yy_state_type; +extern char *yytext; +#define yytext_ptr yytext + +static yy_state_type yy_get_previous_state YY_PROTO(( void )); +static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state )); +static int yy_get_next_buffer YY_PROTO(( void )); +static void yy_fatal_error YY_PROTO(( yyconst char msg[] )); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + yytext_ptr = yy_bp; \ + yyleng = (int) (yy_cp - yy_bp); \ + yy_hold_char = *yy_cp; \ + *yy_cp = '\0'; \ + yy_c_buf_p = yy_cp; + +#define YY_NUM_RULES 45 +#define YY_END_OF_BUFFER 46 +static yyconst short int yy_accept[994] = + { 0, + 0, 0, 46, 44, 41, 41, 44, 42, 39, 37, + 37, 36, 39, 39, 44, 44, 38, 40, 35, 43, + 13, 21, 36, 36, 22, 16, 17, 0, 34, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 24, 0, 24, 0, 0, 0, 0, 0, + 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 42, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 4, 31, 5, 43, + 36, 20, 14, 15, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, + + 0, 0, 0, 10, 0, 0, 27, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 12, 12, 0, 0, + 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, + 0, 0, 0, 0, 12, 0, 27, 0, 0, 0, + 0, 0, 0, 0, 0, 11, 0, 9, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 23, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 27, + 27, 0, 0, 0, 0, 12, 0, 0, 8, 0, + + 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 27, 26, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 27, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 12, 27, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 27, + 0, 0, 27, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 11, 0, 0, 0, 0, 0, 0, 8, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 29, + 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, + 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 30, 0, 0, + 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 28, 0, 0, 12, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 25, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 32, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 12, 0, 12, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 33, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 19, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 12, 12, 0, 24, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 19, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0 + + } ; + +static yyconst int yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 4, 1, 1, 1, 1, 5, 1, 6, + 7, 8, 8, 9, 10, 11, 8, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 13, 14, 15, + 16, 17, 1, 1, 18, 19, 20, 21, 22, 1, + 23, 1, 24, 25, 26, 27, 28, 29, 30, 31, + 1, 32, 33, 34, 35, 36, 1, 37, 1, 38, + 39, 40, 41, 42, 42, 1, 43, 44, 45, 46, + + 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, + 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, + 67, 68, 69, 70, 71, 72, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, + 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, + 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, + 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, + + 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, + 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, + 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, + 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, + 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, + 73, 73, 73, 73, 1 + } ; + +static yyconst int yy_meta[74] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1 + } ; + +static yyconst short int yy_base[995] = + { 0, + 0, 72, 1314, 1315, 1315, 1315, 1297, 1315, 1315, 1315, + 1295, 2, 8, 1294, 1281, 142, 1315, 1315, 1315, 1236, + 1315, 1315, 1296, 8, 1290, 1291, 1288, 1274, 1315, 0, + 0, 1253, 1, 1, 1259, 7, 1244, 1257, 8, 1236, + 1235, 1242, 35, 43, 1245, 0, 1237, 1251, 1242, 1245, + 1315, 46, 72, 171, 79, 62, 77, 184, 192, 92, + 1236, 2, 207, 216, 225, 234, 250, 46, 269, 278, + 295, 10, 111, 255, 10, 1243, 1315, 1315, 1315, 1216, + 1276, 1315, 1315, 1315, 1253, 1228, 1225, 1222, 1217, 1231, + 1227, 1237, 1214, 1217, 1234, 1221, 1315, 1213, 1223, 1215, + + 1217, 1223, 1214, 1315, 168, 1218, 1315, 1217, 1210, 1217, + 1216, 1201, 1216, 177, 1202, 1199, 1197, 34, 1216, 1209, + 1199, 181, 36, 164, 198, 1207, 119, 199, 1201, 1196, + 1196, 218, 1192, 1188, 225, 1205, 1191, 78, 40, 245, + 280, 1197, 175, 1184, 1192, 1187, 1198, 1182, 1179, 1198, + 101, 1197, 1179, 227, 1183, 1191, 1177, 1315, 1192, 1172, + 1190, 1189, 53, 1184, 1187, 260, 1167, 1171, 1184, 1168, + 1165, 248, 1177, 1166, 291, 1168, 1161, 1174, 1164, 1161, + 222, 268, 1160, 0, 1170, 1315, 1172, 1315, 247, 299, + 1152, 1170, 1155, 1155, 300, 1156, 1155, 1157, 1160, 1146, + + 1145, 1153, 302, 1152, 1139, 1158, 1144, 1152, 1147, 1143, + 1136, 308, 1146, 1137, 1150, 1136, 317, 1148, 308, 318, + 1147, 311, 1146, 322, 1145, 312, 1140, 319, 1128, 1134, + 324, 340, 1124, 333, 340, 1137, 1136, 1121, 1118, 1315, + 1129, 1121, 1134, 1114, 1120, 1118, 1122, 1117, 1128, 1114, + 1111, 1124, 1105, 1117, 1116, 1119, 1113, 1107, 1099, 1100, + 1102, 1107, 344, 1114, 1094, 1097, 1104, 1099, 327, 1092, + 347, 1094, 1095, 1096, 1315, 1105, 1096, 1103, 350, 1083, + 1099, 1079, 1088, 1079, 1095, 1094, 1094, 1088, 1076, 1085, + 1084, 1084, 1082, 1082, 1068, 1067, 1073, 1071, 1079, 1069, + + 1069, 1061, 1315, 1071, 1070, 1059, 1057, 1075, 1072, 1051, + 1060, 1050, 1053, 1052, 1058, 1054, 348, 1047, 1315, 1065, + 1045, 1048, 1061, 1055, 1052, 1040, 1039, 1043, 1042, 338, + 1035, 1048, 1035, 1048, 1038, 1039, 1029, 1031, 276, 1030, + 1027, 1026, 1038, 371, 1023, 1042, 1029, 1023, 355, 1024, + 1036, 1025, 372, 1036, 1032, 1028, 1025, 1020, 1017, 1016, + 1022, 1008, 1014, 1020, 1008, 1012, 1006, 1010, 1017, 1013, + 1008, 1007, 1014, 360, 997, 995, 997, 995, 1010, 372, + 1008, 993, 1002, 156, 1005, 1003, 1006, 1001, 997, 996, + 985, 987, 980, 991, 374, 980, 978, 977, 989, 990, + + 993, 992, 969, 990, 975, 988, 976, 986, 985, 981, + 379, 191, 983, 965, 962, 980, 979, 961, 955, 965, + 960, 374, 967, 965, 965, 967, 963, 969, 962, 963, + 947, 951, 950, 955, 962, 939, 945, 941, 938, 944, + 377, 383, 940, 938, 939, 949, 948, 943, 946, 945, + 944, 929, 936, 927, 930, 939, 921, 935, 922, 939, + 924, 933, 920, 935, 910, 922, 911, 912, 919, 1315, + 916, 928, 923, 907, 388, 906, 920, 916, 898, 914, + 920, 916, 907, 906, 898, 400, 901, 894, 900, 892, + 893, 392, 891, 898, 902, 907, 889, 888, 891, 895, + + 885, 901, 883, 879, 880, 879, 892, 405, 884, 886, + 889, 888, 872, 887, 878, 877, 887, 872, 865, 865, + 865, 876, 870, 863, 871, 863, 877, 860, 864, 870, + 869, 857, 856, 1315, 400, 866, 865, 851, 863, 849, + 861, 864, 859, 844, 848, 843, 856, 855, 840, 834, + 837, 843, 838, 403, 845, 843, 843, 834, 841, 829, + 1315, 842, 401, 824, 831, 826, 828, 841, 823, 831, + 834, 829, 822, 835, 820, 820, 818, 813, 822, 815, + 822, 823, 809, 802, 806, 810, 809, 800, 809, 801, + 1315, 803, 800, 801, 404, 807, 803, 805, 810, 803, + + 799, 805, 805, 803, 785, 786, 1315, 784, 800, 785, + 797, 787, 782, 780, 783, 778, 784, 776, 789, 784, + 783, 790, 785, 771, 787, 778, 768, 769, 778, 767, + 762, 776, 779, 770, 763, 758, 764, 774, 759, 93, + 126, 187, 225, 269, 333, 415, 345, 372, 388, 397, + 400, 417, 418, 408, 411, 427, 409, 418, 426, 417, + 419, 415, 417, 418, 419, 419, 423, 422, 422, 428, + 438, 438, 444, 432, 434, 434, 431, 442, 437, 446, + 449, 436, 456, 449, 454, 456, 443, 448, 445, 457, + 459, 459, 453, 450, 446, 469, 457, 463, 460, 454, + + 460, 471, 476, 473, 476, 458, 461, 468, 462, 471, + 484, 485, 466, 481, 484, 481, 473, 488, 475, 489, + 481, 475, 491, 491, 496, 482, 483, 495, 1315, 502, + 498, 490, 500, 503, 497, 487, 488, 498, 512, 508, + 501, 509, 512, 506, 514, 502, 520, 521, 518, 501, + 504, 505, 506, 523, 524, 525, 526, 527, 510, 519, + 523, 518, 528, 515, 538, 526, 532, 529, 523, 535, + 525, 534, 529, 533, 534, 542, 531, 544, 535, 536, + 543, 555, 556, 545, 541, 541, 540, 543, 558, 548, + 549, 552, 548, 563, 551, 550, 552, 557, 553, 565, + + 555, 568, 576, 563, 563, 572, 578, 562, 564, 576, + 582, 566, 582, 580, 577, 572, 573, 589, 574, 581, + 586, 576, 577, 581, 579, 583, 583, 597, 602, 590, + 587, 594, 606, 607, 597, 1315, 606, 591, 589, 590, + 594, 614, 596, 602, 600, 604, 600, 613, 603, 604, + 617, 605, 605, 604, 608, 628, 610, 619, 610, 619, + 615, 628, 636, 618, 619, 635, 640, 622, 628, 628, + 637, 626, 642, 643, 644, 646, 648, 647, 635, 640, + 641, 652, 658, 642, 652, 661, 640, 650, 652, 655, + 659, 651, 669, 656, 671, 668, 656, 666, 661, 676, + + 660, 678, 657, 666, 677, 666, 667, 680, 677, 682, + 673, 675, 676, 673, 674, 686, 676, 672, 691, 677, + 680, 681, 686, 683, 684, 696, 686, 687, 688, 692, + 702, 702, 687, 693, 697, 705, 696, 711, 701, 699, + 714, 701, 705, 713, 704, 708, 706, 711, 706, 719, + 713, 706, 710, 716, 718, 718, 713, 722, 723, 723, + 725, 718, 722, 728, 721, 730, 742, 727, 725, 748, + 727, 728, 729, 730, 731, 754, 733, 734, 743, 743, + 742, 747, 748, 746, 742, 748, 749, 754, 754, 755, + 748, 749, 1315, 814 + + } ; + +static yyconst short int yy_def[995] = + { 0, + 994, 994, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 0, 993 + + } ; + +static yyconst short int yy_nxt[1389] = + { 0, + 993, 5, 6, 7, 8, 9, 9, 10, 993, 11, + 993, 12, 23, 24, 13, 10, 14, 25, 23, 24, + 993, 993, 26, 993, 993, 993, 15, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 9, 16, + 9, 17, 112, 993, 170, 158, 88, 91, 171, 113, + 101, 92, 993, 86, 102, 107, 89, 93, 94, 87, + 188, 97, 95, 98, 103, 231, 238, 232, 9, 18, + 9, 19, 20, 5, 6, 7, 8, 9, 9, 10, + 266, 11, 294, 12, 106, 104, 13, 10, 14, 97, + 117, 267, 109, 110, 107, 108, 295, 186, 15, 118, + + 119, 120, 273, 121, 205, 122, 123, 107, 206, 315, + 9, 16, 9, 17, 124, 145, 146, 147, 125, 148, + 149, 138, 126, 150, 139, 140, 292, 151, 127, 141, + 152, 128, 142, 153, 129, 143, 154, 164, 293, 144, + 9, 18, 9, 19, 20, 29, 165, 166, 167, 737, + 29, 306, 168, 233, 29, 29, 234, 235, 107, 30, + 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, + 97, 51, 738, 280, 52, 53, 54, 55, 56, 57, + 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, + + 68, 69, 70, 71, 72, 73, 74, 75, 274, 76, + 77, 78, 79, 130, 255, 541, 131, 542, 256, 260, + 132, 133, 261, 275, 134, 271, 155, 135, 156, 107, + 157, 136, 158, 137, 160, 161, 299, 262, 162, 300, + 272, 281, 276, 159, 571, 282, 277, 186, 163, 172, + 572, 173, 174, 175, 176, 177, 178, 179, 182, 278, + 158, 180, 107, 181, 285, 183, 184, 189, 188, 309, + 107, 190, 185, 186, 186, 158, 187, 332, 188, 193, + 288, 191, 289, 310, 194, 290, 291, 188, 195, 192, + 336, 196, 200, 107, 197, 198, 201, 199, 296, 202, + + 188, 236, 323, 324, 186, 237, 107, 318, 337, 203, + 204, 207, 97, 208, 186, 209, 210, 211, 212, 213, + 216, 319, 297, 214, 217, 333, 499, 218, 219, 186, + 215, 500, 220, 107, 107, 221, 222, 226, 327, 223, + 224, 338, 225, 186, 227, 228, 343, 97, 351, 158, + 344, 229, 352, 186, 230, 374, 368, 158, 353, 365, + 371, 107, 369, 370, 188, 378, 379, 383, 372, 388, + 375, 376, 385, 386, 188, 396, 319, 389, 366, 380, + 430, 381, 391, 390, 275, 392, 186, 431, 489, 397, + 421, 433, 739, 393, 441, 742, 477, 509, 490, 398, + + 394, 422, 532, 423, 424, 425, 442, 434, 435, 478, + 443, 444, 445, 446, 447, 503, 510, 319, 538, 592, + 553, 569, 533, 579, 104, 743, 504, 593, 595, 513, + 744, 554, 539, 555, 556, 557, 558, 596, 570, 594, + 597, 619, 624, 664, 598, 632, 633, 620, 645, 625, + 683, 634, 678, 188, 706, 158, 158, 665, 646, 626, + 707, 740, 684, 79, 647, 741, 745, 79, 729, 746, + 748, 749, 97, 750, 751, 752, 747, 753, 754, 755, + 756, 158, 757, 758, 759, 760, 761, 762, 764, 765, + 766, 767, 188, 188, 768, 769, 770, 763, 771, 772, + + 773, 97, 774, 104, 775, 776, 777, 778, 104, 779, + 561, 780, 104, 781, 782, 783, 784, 785, 786, 158, + 186, 319, 319, 787, 788, 789, 790, 792, 793, 794, + 795, 796, 186, 797, 798, 799, 188, 800, 801, 802, + 803, 804, 805, 806, 807, 808, 791, 809, 810, 97, + 97, 561, 561, 188, 811, 812, 813, 814, 815, 97, + 158, 816, 817, 818, 97, 561, 819, 820, 821, 822, + 823, 824, 825, 826, 561, 827, 828, 829, 830, 561, + 831, 188, 832, 833, 834, 835, 836, 837, 838, 839, + 840, 841, 842, 843, 844, 845, 846, 104, 104, 97, + + 847, 848, 849, 319, 850, 319, 319, 851, 319, 319, + 852, 97, 853, 854, 97, 855, 856, 857, 858, 859, + 860, 861, 862, 863, 864, 865, 866, 867, 836, 868, + 158, 869, 870, 871, 186, 319, 872, 873, 874, 158, + 158, 158, 875, 876, 877, 878, 879, 880, 188, 188, + 881, 882, 729, 561, 561, 883, 884, 886, 887, 888, + 889, 729, 78, 319, 319, 890, 729, 891, 561, 97, + 892, 893, 158, 885, 561, 894, 895, 896, 897, 899, + 900, 836, 901, 902, 903, 904, 905, 97, 906, 907, + 158, 97, 910, 836, 911, 898, 912, 913, 836, 908, + + 914, 915, 916, 917, 561, 909, 918, 104, 919, 920, + 921, 922, 923, 924, 729, 925, 926, 561, 927, 928, + 929, 561, 930, 729, 158, 158, 931, 932, 836, 933, + 188, 188, 934, 935, 936, 937, 561, 938, 97, 939, + 940, 941, 942, 943, 944, 945, 946, 947, 948, 949, + 950, 561, 951, 952, 953, 954, 955, 957, 958, 959, + 961, 962, 963, 964, 965, 966, 967, 186, 968, 969, + 561, 970, 971, 956, 972, 186, 960, 561, 973, 974, + 561, 975, 561, 976, 977, 836, 978, 979, 186, 561, + 981, 561, 982, 561, 983, 561, 984, 561, 836, 985, + + 561, 986, 186, 561, 980, 987, 988, 989, 990, 561, + 991, 992, 561, 561, 4, 736, 735, 734, 158, 561, + 733, 732, 731, 730, 107, 107, 729, 77, 728, 727, + 726, 77, 188, 725, 724, 723, 722, 97, 97, 721, + 720, 719, 718, 717, 186, 319, 716, 186, 715, 158, + 714, 319, 713, 712, 711, 710, 709, 708, 319, 705, + 319, 704, 703, 702, 107, 107, 107, 158, 701, 700, + 699, 104, 104, 698, 697, 696, 695, 694, 693, 692, + 691, 690, 689, 104, 688, 687, 686, 685, 186, 607, + 158, 682, 681, 680, 679, 677, 676, 186, 675, 674, + + 186, 186, 673, 672, 186, 275, 188, 671, 670, 669, + 668, 667, 666, 186, 186, 663, 158, 662, 158, 188, + 97, 661, 660, 659, 658, 657, 656, 655, 654, 653, + 79, 652, 29, 651, 97, 650, 649, 648, 644, 643, + 186, 642, 641, 188, 640, 158, 158, 639, 638, 97, + 637, 636, 635, 631, 630, 629, 628, 627, 607, 77, + 623, 622, 188, 97, 607, 97, 158, 621, 618, 275, + 188, 158, 617, 616, 158, 615, 614, 613, 158, 561, + 612, 188, 607, 611, 158, 610, 609, 608, 275, 607, + 606, 275, 605, 604, 603, 602, 601, 600, 599, 591, + + 590, 589, 158, 588, 587, 586, 585, 584, 583, 97, + 186, 188, 97, 275, 582, 581, 580, 578, 577, 576, + 575, 104, 104, 574, 573, 104, 568, 104, 104, 567, + 566, 565, 104, 564, 104, 188, 563, 562, 561, 560, + 559, 552, 551, 550, 549, 548, 547, 546, 545, 544, + 543, 107, 540, 97, 537, 536, 186, 535, 534, 531, + 530, 529, 107, 528, 527, 526, 525, 524, 523, 522, + 521, 520, 519, 518, 517, 516, 515, 29, 514, 512, + 511, 158, 508, 507, 506, 505, 502, 319, 186, 501, + 498, 497, 496, 495, 494, 493, 492, 491, 488, 487, + + 486, 485, 484, 483, 482, 481, 480, 188, 479, 476, + 475, 474, 97, 473, 472, 471, 470, 469, 97, 468, + 467, 466, 465, 186, 464, 463, 462, 461, 460, 459, + 458, 457, 456, 107, 107, 455, 158, 454, 186, 453, + 452, 451, 450, 449, 448, 188, 440, 439, 438, 437, + 436, 432, 429, 428, 427, 426, 104, 420, 419, 418, + 417, 416, 415, 414, 413, 412, 411, 410, 409, 158, + 104, 408, 407, 406, 405, 404, 104, 403, 402, 401, + 158, 400, 399, 395, 387, 97, 384, 382, 377, 373, + 367, 364, 363, 362, 361, 360, 359, 358, 357, 356, + + 355, 354, 188, 188, 350, 349, 348, 347, 346, 345, + 342, 341, 340, 339, 335, 334, 97, 331, 330, 186, + 329, 328, 326, 325, 107, 322, 321, 158, 320, 317, + 316, 314, 313, 275, 312, 158, 107, 311, 308, 307, + 188, 305, 304, 303, 302, 97, 301, 298, 186, 107, + 287, 286, 284, 186, 283, 279, 270, 269, 268, 265, + 264, 263, 259, 104, 258, 257, 104, 104, 104, 254, + 253, 252, 251, 250, 249, 248, 104, 247, 246, 245, + 244, 104, 97, 243, 242, 241, 240, 81, 80, 239, + 169, 116, 104, 115, 114, 111, 105, 104, 104, 100, + + 99, 96, 90, 85, 84, 83, 82, 81, 80, 28, + 27, 22, 21, 993, 3, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993 + } ; + +static yyconst short int yy_chk[1389] = + { 0, + 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, + 0, 1, 12, 12, 1, 1, 1, 13, 24, 24, + 0, 0, 13, 0, 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, + 1, 1, 46, 0, 62, 184, 31, 33, 62, 46, + 39, 33, 0, 30, 39, 184, 31, 33, 34, 30, + 75, 36, 34, 36, 39, 72, 75, 72, 1, 1, + 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, + 118, 2, 139, 2, 43, 43, 2, 2, 2, 44, + 52, 118, 44, 44, 43, 43, 139, 123, 2, 52, + + 52, 52, 123, 52, 68, 52, 52, 163, 68, 163, + 2, 2, 2, 2, 53, 56, 56, 56, 53, 56, + 56, 55, 53, 56, 55, 55, 138, 56, 53, 55, + 57, 53, 55, 57, 53, 55, 57, 60, 138, 55, + 2, 2, 2, 2, 2, 16, 60, 60, 60, 640, + 16, 151, 60, 73, 16, 16, 73, 73, 151, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 127, 16, 641, 127, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + + 16, 16, 16, 16, 16, 16, 16, 16, 124, 16, + 16, 16, 16, 54, 105, 384, 54, 384, 105, 114, + 54, 54, 114, 124, 54, 122, 58, 54, 58, 122, + 58, 54, 58, 54, 59, 59, 143, 114, 59, 143, + 122, 128, 125, 58, 412, 128, 125, 642, 59, 63, + 412, 63, 63, 63, 63, 63, 63, 63, 64, 125, + 63, 63, 63, 63, 132, 64, 64, 65, 132, 154, + 181, 65, 64, 64, 643, 65, 64, 181, 64, 66, + 135, 65, 135, 154, 66, 135, 135, 65, 66, 65, + 189, 66, 67, 140, 66, 66, 67, 66, 140, 67, + + 67, 74, 172, 172, 67, 74, 140, 166, 189, 67, + 67, 69, 74, 69, 74, 69, 69, 69, 69, 69, + 70, 166, 141, 69, 70, 182, 339, 70, 70, 644, + 69, 339, 70, 182, 141, 70, 70, 71, 175, 70, + 70, 190, 70, 141, 71, 71, 195, 190, 203, 175, + 195, 71, 203, 212, 71, 222, 219, 190, 203, 217, + 220, 217, 219, 219, 212, 224, 224, 226, 220, 231, + 222, 222, 228, 228, 226, 234, 224, 231, 217, 224, + 269, 224, 232, 231, 235, 232, 235, 269, 330, 234, + 263, 271, 645, 232, 279, 647, 317, 349, 330, 235, + + 232, 263, 374, 263, 263, 263, 279, 271, 271, 317, + 279, 279, 279, 279, 279, 344, 349, 353, 380, 441, + 395, 411, 374, 422, 422, 648, 344, 441, 442, 353, + 649, 395, 380, 395, 395, 395, 395, 442, 411, 441, + 442, 475, 486, 535, 442, 492, 492, 475, 508, 486, + 563, 492, 554, 554, 595, 650, 651, 535, 508, 486, + 595, 646, 563, 652, 508, 646, 653, 654, 655, 656, + 657, 658, 659, 660, 661, 662, 656, 663, 664, 665, + 666, 667, 668, 669, 670, 671, 672, 673, 674, 675, + 676, 677, 678, 679, 680, 681, 682, 673, 683, 684, + + 685, 686, 687, 688, 689, 690, 691, 692, 693, 694, + 695, 696, 697, 698, 699, 700, 701, 702, 703, 704, + 705, 706, 707, 708, 709, 710, 711, 712, 713, 714, + 715, 716, 717, 718, 719, 720, 721, 722, 723, 724, + 725, 726, 727, 728, 730, 731, 711, 732, 733, 734, + 735, 736, 737, 738, 739, 740, 741, 742, 743, 744, + 745, 746, 747, 748, 749, 750, 751, 752, 753, 754, + 755, 756, 757, 758, 759, 760, 761, 762, 763, 764, + 765, 766, 767, 768, 769, 770, 771, 772, 773, 774, + 775, 776, 777, 778, 779, 780, 781, 782, 783, 784, + + 785, 786, 787, 788, 789, 790, 791, 792, 793, 794, + 795, 796, 797, 798, 799, 800, 801, 802, 803, 804, + 805, 806, 807, 808, 809, 810, 811, 812, 813, 814, + 815, 816, 817, 818, 819, 820, 821, 822, 823, 824, + 825, 826, 827, 828, 829, 830, 831, 832, 833, 834, + 835, 837, 838, 839, 840, 841, 842, 843, 844, 845, + 846, 847, 848, 849, 850, 851, 852, 853, 854, 855, + 856, 857, 858, 842, 859, 860, 861, 862, 863, 864, + 865, 866, 867, 868, 869, 870, 871, 872, 873, 874, + 875, 876, 877, 878, 879, 863, 880, 881, 882, 876, + + 883, 884, 885, 886, 887, 876, 888, 889, 890, 891, + 892, 893, 894, 895, 896, 897, 898, 899, 900, 901, + 902, 903, 904, 905, 906, 907, 908, 909, 910, 911, + 912, 913, 914, 915, 916, 917, 918, 919, 920, 921, + 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, + 932, 933, 934, 935, 936, 937, 938, 939, 940, 941, + 942, 943, 944, 945, 946, 947, 948, 949, 950, 951, + 952, 953, 954, 938, 955, 956, 941, 957, 958, 959, + 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, + 970, 971, 972, 973, 974, 975, 976, 977, 978, 979, + + 980, 981, 982, 983, 967, 984, 985, 986, 987, 988, + 989, 990, 991, 992, 994, 639, 638, 637, 636, 635, + 634, 633, 632, 631, 630, 629, 628, 627, 626, 625, + 624, 623, 622, 621, 620, 619, 618, 617, 616, 615, + 614, 613, 612, 611, 610, 609, 608, 606, 605, 604, + 603, 602, 601, 600, 599, 598, 597, 596, 594, 593, + 592, 590, 589, 588, 587, 586, 585, 584, 583, 582, + 581, 580, 579, 578, 577, 576, 575, 574, 573, 572, + 571, 570, 569, 568, 567, 566, 565, 564, 562, 560, + 559, 558, 557, 556, 555, 553, 552, 551, 550, 549, + + 548, 547, 546, 545, 544, 543, 542, 541, 540, 539, + 538, 537, 536, 533, 532, 531, 530, 529, 528, 527, + 526, 525, 524, 523, 522, 521, 520, 519, 518, 517, + 516, 515, 514, 513, 512, 511, 510, 509, 507, 506, + 505, 504, 503, 502, 501, 500, 499, 498, 497, 496, + 495, 494, 493, 491, 490, 489, 488, 487, 485, 484, + 483, 482, 481, 480, 479, 478, 477, 476, 474, 473, + 472, 471, 469, 468, 467, 466, 465, 464, 463, 462, + 461, 460, 459, 458, 457, 456, 455, 454, 453, 452, + 451, 450, 449, 448, 447, 446, 445, 444, 443, 440, + + 439, 438, 437, 436, 435, 434, 433, 432, 431, 430, + 429, 428, 427, 426, 425, 424, 423, 421, 420, 419, + 418, 417, 416, 415, 414, 413, 410, 409, 408, 407, + 406, 405, 404, 403, 402, 401, 400, 399, 398, 397, + 396, 394, 393, 392, 391, 390, 389, 388, 387, 386, + 385, 383, 382, 381, 379, 378, 377, 376, 375, 373, + 372, 371, 370, 369, 368, 367, 366, 365, 364, 363, + 362, 361, 360, 359, 358, 357, 356, 355, 354, 352, + 351, 350, 348, 347, 346, 345, 343, 342, 341, 340, + 338, 337, 336, 335, 334, 333, 332, 331, 329, 328, + + 327, 326, 325, 324, 323, 322, 321, 320, 318, 316, + 315, 314, 313, 312, 311, 310, 309, 308, 307, 306, + 305, 304, 302, 301, 300, 299, 298, 297, 296, 295, + 294, 293, 292, 291, 290, 289, 288, 287, 286, 285, + 284, 283, 282, 281, 280, 278, 277, 276, 274, 273, + 272, 270, 268, 267, 266, 265, 264, 262, 261, 260, + 259, 258, 257, 256, 255, 254, 253, 252, 251, 250, + 249, 248, 247, 246, 245, 244, 243, 242, 241, 239, + 238, 237, 236, 233, 230, 229, 227, 225, 223, 221, + 218, 216, 215, 214, 213, 211, 210, 209, 208, 207, + + 206, 205, 204, 202, 201, 200, 199, 198, 197, 196, + 194, 193, 192, 191, 187, 185, 183, 180, 179, 178, + 177, 176, 174, 173, 171, 170, 169, 168, 167, 165, + 164, 162, 161, 160, 159, 157, 156, 155, 153, 152, + 150, 149, 148, 147, 146, 145, 144, 142, 137, 136, + 134, 133, 131, 130, 129, 126, 121, 120, 119, 117, + 116, 115, 113, 112, 111, 110, 109, 108, 106, 103, + 102, 101, 100, 99, 98, 96, 95, 94, 93, 92, + 91, 90, 89, 88, 87, 86, 85, 81, 80, 76, + 61, 50, 49, 48, 47, 45, 42, 41, 40, 38, + + 37, 35, 32, 28, 27, 26, 25, 23, 20, 15, + 14, 11, 7, 3, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, + 993, 993, 993, 993, 993, 993, 993, 993 + } ; + +static yy_state_type yy_last_accepting_state; +static char *yy_last_accepting_cpos; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +char *yytext; +#line 1 "lexer.l" +#define INITIAL 0 +#line 2 "lexer.l" +#include +#include +#include "nodes.h" + +#ifdef WIN32 +#define strdup _strdup +#define fileno _fileno +#define isatty _isatty +#endif + +/* enlarge token buffer to tokenize whole strings */ +#undef YYLMAX +#define YYLMAX 64000 + +#ifdef __cplusplus +extern "C" { +#endif +#include "grammar.h" +int yywrap(); +#ifdef __cplusplus +} +#endif + +#ifdef WIN32 +extern YYSTYPE yylval; +#endif +#ifdef TOKEN_DEBUG +#define token_debug printf +#else +int token_debug(const char *format, ...); +#endif +#line 1026 "lex.yy.c" + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int yywrap YY_PROTO(( void )); +#else +extern int yywrap YY_PROTO(( void )); +#endif +#endif + +#ifndef YY_NO_UNPUT +//static void yyunput YY_PROTO(( int c, char *buf_ptr )); +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int )); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen YY_PROTO(( yyconst char * )); +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus +static int yyinput YY_PROTO(( void )); +#else +static int input YY_PROTO(( void )); +#endif +#endif + +#if YY_STACK_USED +static int yy_start_stack_ptr = 0; +static int yy_start_stack_depth = 0; +static int *yy_start_stack = 0; +#ifndef YY_NO_PUSH_STATE +static void yy_push_state YY_PROTO(( int new_state )); +#endif +#ifndef YY_NO_POP_STATE +static void yy_pop_state YY_PROTO(( void )); +#endif +#ifndef YY_NO_TOP_STATE +static int yy_top_state YY_PROTO(( void )); +#endif + +#else +#define YY_NO_PUSH_STATE 1 +#define YY_NO_POP_STATE 1 +#define YY_NO_TOP_STATE 1 +#endif + +#ifdef YY_MALLOC_DECL +YY_MALLOC_DECL +#else +#if __STDC__ +#ifndef __cplusplus +#include +#endif +#else +/* Just try to get by without declaring the routines. This will fail + * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int) + * or sizeof(void*) != sizeof(int). + */ +#endif +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#define YY_READ_BUF_SIZE 8192 +#endif + +/* Copy whatever the last rule matched to the standard output. */ + +#ifndef ECHO +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + if ( yy_current_buffer->yy_is_interactive ) \ + { \ + int c = '*', n; \ + for ( n = 0; n < max_size && \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \ + && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) +#endif + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL int yylex YY_PROTO(( void )) +#endif + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +YY_DECL + { + register yy_state_type yy_current_state; + register char *yy_cp, *yy_bp; + register int yy_act; + +#line 90 "lexer.l" + +#line 1179 "lex.yy.c" + + if ( yy_init ) + { + yy_init = 0; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! yy_start ) + yy_start = 1; /* first start state */ + + if ( ! yyin ) + yyin = stdin; + + if ( ! yyout ) + yyout = stdout; + + if ( ! yy_current_buffer ) + yy_current_buffer = + yy_create_buffer( yyin, YY_BUF_SIZE ); + + yy_load_buffer_state(); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = yy_c_buf_p; + + /* Support of yytext. */ + *yy_cp = yy_hold_char; + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = yy_start; +yy_match: + do + { + register YY_CHAR yy_c = sal::static_int_cast(yy_ec[YY_SC_TO_UI(*yy_cp)]); + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 994 ) + yy_c = sal::static_int_cast(yy_meta[(unsigned int) yy_c]); + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + ++yy_cp; + } + while ( yy_base[yy_current_state] != 1315 ); + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + if ( yy_act == 0 ) + { /* have to back up */ + yy_cp = yy_last_accepting_cpos; + yy_current_state = yy_last_accepting_state; + yy_act = yy_accept[yy_current_state]; + } + + YY_DO_BEFORE_ACTION; + + +do_action: /* This label is used only to access EOF actions. */ + + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = yy_hold_char; + yy_cp = yy_last_accepting_cpos; + yy_current_state = yy_last_accepting_state; + goto yy_find_action; + +case 1: +YY_RULE_SETUP +#line 91 "lexer.l" +{ yylval.str = yytext+1; token_debug(" ==>Begin[%s]\n",yytext+1); return EQBEGIN; } + //YY_BREAK +case 2: +YY_RULE_SETUP +#line 92 "lexer.l" +{ yylval.str = yytext+1; token_debug(" ==>End[%s]\n",yytext+1); return EQEND; } + //YY_BREAK +case 3: +YY_RULE_SETUP +#line 93 "lexer.l" +{ yylval.str = yytext+1; token_debug(" ==>Left[%s]\n",yytext+1); return EQLEFT; } + //YY_BREAK +case 4: +YY_RULE_SETUP +#line 94 "lexer.l" +{ yylval.str = yytext+1; token_debug(" ==>LeftDelim[%s]\n",yytext+1); return LEFT_DELIM; } + //YY_BREAK +case 5: +YY_RULE_SETUP +#line 95 "lexer.l" +{ yylval.str = yytext+1; token_debug(" ==>RightDelim[%s]\n",yytext+1); return RIGHT_DELIM; } + //YY_BREAK +case 6: +YY_RULE_SETUP +#line 96 "lexer.l" +{ yylval.str = yytext+1; token_debug(" ==>Right[%s]\n",yytext+1); return EQRIGHT; } + //YY_BREAK +case 7: +YY_RULE_SETUP +#line 97 "lexer.l" +{ yylval.str = yytext; token_debug(" ==>NewLine[%s]\n",yytext); return NEWLINE; } + //YY_BREAK +case 8: +YY_RULE_SETUP +#line 99 "lexer.l" +{ yylval.str = yytext+1; token_debug(" ==>Accent[%s]\n",yytext+1); return ACCENT; } + //YY_BREAK +case 9: +YY_RULE_SETUP +#line 100 "lexer.l" +{ yylval.str = yytext+1; token_debug(" ==>Small_Greek[%s]\n",yytext+1); return SMALL_GREEK; } + //YY_BREAK +case 10: +YY_RULE_SETUP +#line 101 "lexer.l" +{ yylval.str = yytext+1; token_debug(" ==>Capital_Greek[%s]\n",yytext+1); return CAPITAL_GREEK; } + //YY_BREAK +case 11: +YY_RULE_SETUP +#line 102 "lexer.l" +{ yylval.str = yytext+1; token_debug(" ==>Binary_Operator[%s]\n",yytext+1); return BINARY_OPERATOR; } + //YY_BREAK +case 12: +YY_RULE_SETUP +#line 103 "lexer.l" +{ yylval.str = yytext+1; token_debug(" ==>Relation_Symbol[%s]\n",yytext+1); return RELATION_OPERATOR; } + //YY_BREAK +case 13: +YY_RULE_SETUP +#line 105 "lexer.l" +{ yylval.str = strdup("neq"); token_debug(" ==>Relation_Symbol[neq]\n"); return RELATION_OPERATOR; } + //YY_BREAK +case 14: +YY_RULE_SETUP +#line 106 "lexer.l" +{ yylval.str = strdup("vmlt"); token_debug(" ==>Relation_Symbol[neq]\n"); return RELATION_OPERATOR; } + //YY_BREAK +case 15: +YY_RULE_SETUP +#line 107 "lexer.l" +{ yylval.str = strdup("vmgt"); token_debug(" ==>Relation_Symbol[neq]\n"); return RELATION_OPERATOR; } + //YY_BREAK +case 16: +YY_RULE_SETUP +#line 108 "lexer.l" +{ yylval.str = strdup("mlt"); token_debug(" ==>Relation_Symbol[neq]\n"); return RELATION_OPERATOR; } + //YY_BREAK +case 17: +YY_RULE_SETUP +#line 109 "lexer.l" +{ yylval.str = strdup("mgt"); token_debug(" ==>Relation_Symbol[neq]\n"); return RELATION_OPERATOR; } + //YY_BREAK +case 18: +YY_RULE_SETUP +#line 110 "lexer.l" +{ yylval.str = yytext; token_debug(" ==>Relation_Symbol[neq]\n"); return RELATION_OPERATOR; } + //YY_BREAK +case 19: +YY_RULE_SETUP +#line 112 "lexer.l" +{ yylval.str = yytext+1; token_debug(" ==>Arrow[%s]\n",yytext+1); return ARROW; } + //YY_BREAK +case 20: +YY_RULE_SETUP +#line 113 "lexer.l" +{ yylval.str = strdup("leftrightarrow"); token_debug(" ==>Arrow[leftrightarrow]\n"); return ARROW; } + //YY_BREAK +case 21: +YY_RULE_SETUP +#line 114 "lexer.l" +{ yylval.str = strdup("rightarrow"); token_debug(" ==>Arrow[rightarrow]\n"); return ARROW; } + //YY_BREAK +case 22: +YY_RULE_SETUP +#line 115 "lexer.l" +{ yylval.str = strdup("leftarrow"); token_debug(" ==>Arrow[leftarrow]\n"); return ARROW; } + //YY_BREAK + +case 23: +YY_RULE_SETUP +#line 116 "lexer.l" +{ token_debug(" ==>Ignore[\\rm]\n"); } + //YY_BREAK +case 24: +YY_RULE_SETUP +#line 117 "lexer.l" +{ yylval.str = yytext+1; token_debug(" ==>General_Iden[%s]\n",yytext+1); return GENERAL_IDEN; } + //YY_BREAK +case 25: +YY_RULE_SETUP +#line 118 "lexer.l" +{ yylval.str = yytext+1; token_debug(" ==>General_Oper[%s]\n",yytext+1); return GENERAL_OPER; } + //YY_BREAK +case 26: +YY_RULE_SETUP +#line 119 "lexer.l" +{ yylval.str = yytext+1; token_debug(" ==>Big_Symbol[%s]\n",yytext+1); return BIG_SYMBOL; } + //YY_BREAK +case 27: +YY_RULE_SETUP +#line 120 "lexer.l" +{ yylval.str = yytext+1; token_debug(" ==>Function[%s]\n",yytext+1); return FUNCTION; } + //YY_BREAK +case 28: +YY_RULE_SETUP +#line 121 "lexer.l" +{ yylval.str = yytext+1; token_debug(" ==>Root[%s]\n",yytext+1); return ROOT; } + //YY_BREAK +case 29: +YY_RULE_SETUP +#line 122 "lexer.l" +{ yylval.str = yytext+1; token_debug(" ==>Fraction[%s]\n",yytext+1); return FRACTION; } + //YY_BREAK +case 30: +YY_RULE_SETUP +#line 123 "lexer.l" +{ yylval.str = yytext+1; token_debug(" ==>Over[%s]\n",yytext+1); return EQOVER; } + //YY_BREAK +case 31: +YY_RULE_SETUP +#line 124 "lexer.l" +{ yylval.str = yytext+1; token_debug(" ==>Delimeter[%s]\n",yytext+1); return DELIMETER; } + //YY_BREAK +case 32: +YY_RULE_SETUP +#line 125 "lexer.l" +{ yylval.str = yytext+1; token_debug(" ==>Large_Delim[%s]\n",yytext+1); return LARGE_DELIM; } + //YY_BREAK +case 33: +YY_RULE_SETUP +#line 126 "lexer.l" +{ yylval.str = yytext+1; token_debug(" ==>Decoration[%s]\n",yytext+1); return DECORATION; } + //YY_BREAK +case 34: +YY_RULE_SETUP +#line 127 "lexer.l" +{ yylval.str = yytext+1; token_debug(" ==>Space_Symbol[%s]\n",yytext+1); /*return SPACE_SYMBOL;*/ } + //YY_BREAK +case 35: +YY_RULE_SETUP +#line 128 "lexer.l" +{ yylval.str = strdup("quad"); token_debug(" ==>Space_Symbol[quad]\n"); /* return SPACE_SYMBOL;*/ } + //YY_BREAK +case 36: +YY_RULE_SETUP +#line 129 "lexer.l" +{ yylval.dval = yytext; token_debug(" ==>Digit[%s]\n",yytext); return DIGIT; } + //YY_BREAK +case 37: +YY_RULE_SETUP +#line 130 "lexer.l" +{ yylval.str = yytext; token_debug(" ==>Operator[%s]\n",yytext); return OPERATOR; } + //YY_BREAK +case 38: +YY_RULE_SETUP +#line 131 "lexer.l" +{ token_debug(" ==>SubSup[%s]\n",yytext); return yytext[0]; } + //YY_BREAK +case 39: +YY_RULE_SETUP +#line 132 "lexer.l" +{ token_debug(" ==>Paren[%s]\n",yytext); return yytext[0];} + //YY_BREAK +case 40: +YY_RULE_SETUP +#line 133 "lexer.l" +{ token_debug(" ==>Abs[%s]\n",yytext); return yytext[0];} + //YY_BREAK +case 41: +YY_RULE_SETUP +#line 134 "lexer.l" +{ token_debug(" ==>Space[0x%2x]\n",yytext[0]); } + YY_BREAK +case 42: +YY_RULE_SETUP +#line 135 "lexer.l" +{ token_debug(" ==>Ignore[0x%2x]\n",yytext[0]); } + YY_BREAK +case 43: +YY_RULE_SETUP +#line 136 "lexer.l" +{ yylval.str = yytext; token_debug(" ==>String[%s]\n",yytext); return STRING; } + //YY_BREAK +case 44: +YY_RULE_SETUP +#line 137 "lexer.l" +{ yylval.str = yytext; token_debug(" ==>Else[%s]\n",yytext); return CHARACTER; } + //YY_BREAK +case 45: +YY_RULE_SETUP +#line 138 "lexer.l" +ECHO; + YY_BREAK +#line 1487 "lex.yy.c" +case YY_STATE_EOF(INITIAL): + yyterminate(); + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = yy_hold_char; + YY_RESTORE_YY_MORE_OFFSET + + if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between yy_current_buffer and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + yy_n_chars = yy_current_buffer->yy_n_chars; + yy_current_buffer->yy_input_file = yyin; + yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state(); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state ); + + yy_bp = yytext_ptr + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++yy_c_buf_p; + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = yy_c_buf_p; + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer() ) + { + case EOB_ACT_END_OF_FILE: + { + yy_did_buffer_switch_on_eof = 0; + + if ( yywrap() ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + yy_c_buf_p = yytext_ptr + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + yy_c_buf_p = + yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state(); + + yy_cp = yy_c_buf_p; + yy_bp = yytext_ptr + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + yy_c_buf_p = + &yy_current_buffer->yy_ch_buf[yy_n_chars]; + + yy_current_state = yy_get_previous_state(); + + yy_cp = yy_c_buf_p; + yy_bp = yytext_ptr + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ + } /* end of yylex */ + + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ + +static int yy_get_next_buffer() + { + register char *dest = yy_current_buffer->yy_ch_buf; + register char *source = yytext_ptr; + register int number_to_move, i; + int ret_val; + + if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( yy_current_buffer->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + yy_current_buffer->yy_n_chars = yy_n_chars = 0; + + else + { + int num_to_read = + yy_current_buffer->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ +#ifdef YY_USES_REJECT + YY_FATAL_ERROR( +"input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); +#else + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = yy_current_buffer; + + int yy_c_buf_p_offset = + (int) (yy_c_buf_p - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + int new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + yy_flex_realloc( (void *) b->yy_ch_buf, + b->yy_buf_size + 2 ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = 0; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = yy_current_buffer->yy_buf_size - + number_to_move - 1; +#endif + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]), + yy_n_chars, num_to_read ); + + yy_current_buffer->yy_n_chars = yy_n_chars; + } + + if ( yy_n_chars == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + yy_current_buffer->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + yy_n_chars += number_to_move; + yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR; + yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + + yytext_ptr = &yy_current_buffer->yy_ch_buf[0]; + + return ret_val; + } + + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + +static yy_state_type yy_get_previous_state() + { + register yy_state_type yy_current_state; + register char *yy_cp; + + yy_current_state = yy_start; + + for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp ) + { + register YY_CHAR yy_c = sal::static_int_cast(*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 994 ) + yy_c = sal::static_int_cast(yy_meta[(unsigned int) yy_c]); + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + } + + return yy_current_state; + } + + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + +#ifdef YY_USE_PROTOS +static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state ) +#else +static yy_state_type yy_try_NUL_trans( yy_current_state ) +yy_state_type yy_current_state; +#endif + { + register int yy_is_jam; + register char *yy_cp = yy_c_buf_p; + + register YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 994 ) + yy_c = sal::static_int_cast(yy_meta[(unsigned int) yy_c]); + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_is_jam = (yy_current_state == 993); + + return yy_is_jam ? 0 : yy_current_state; + } + +#ifdef __cplusplus +static int yyinput() +#else +static int input() +#endif + { + int c; + + *yy_c_buf_p = yy_hold_char; + + if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] ) + /* This was really a NUL. */ + *yy_c_buf_p = '\0'; + + else + { /* need more input */ + int offset = yy_c_buf_p - yytext_ptr; + ++yy_c_buf_p; + + switch ( yy_get_next_buffer() ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyin ); + + /* fall through */ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap() ) + return EOF; + + if ( ! yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(); +#else + return input(); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + yy_c_buf_p = yytext_ptr + offset; + break; + } + } + } + + c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */ + *yy_c_buf_p = '\0'; /* preserve yytext */ + yy_hold_char = *++yy_c_buf_p; + + + return c; + } + + +#ifdef YY_USE_PROTOS +void yyrestart( FILE *input_file ) +#else +void yyrestart( input_file ) +FILE *input_file; +#endif + { + if ( ! yy_current_buffer ) + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); + + yy_init_buffer( yy_current_buffer, input_file ); + yy_load_buffer_state(); + } + + +#ifdef YY_USE_PROTOS +void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) +#else +void yy_switch_to_buffer( new_buffer ) +YY_BUFFER_STATE new_buffer; +#endif + { + if ( yy_current_buffer == new_buffer ) + return; + + if ( yy_current_buffer ) + { + /* Flush out information for old buffer. */ + *yy_c_buf_p = yy_hold_char; + yy_current_buffer->yy_buf_pos = yy_c_buf_p; + yy_current_buffer->yy_n_chars = yy_n_chars; + } + + yy_current_buffer = new_buffer; + yy_load_buffer_state(); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + yy_did_buffer_switch_on_eof = 1; + } + + +#ifdef YY_USE_PROTOS +void yy_load_buffer_state( void ) +#else +void yy_load_buffer_state() +#endif + { + yy_n_chars = yy_current_buffer->yy_n_chars; + yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos; + yyin = yy_current_buffer->yy_input_file; + yy_hold_char = *yy_c_buf_p; + } + + +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_create_buffer( FILE *file, int size ) +#else +YY_BUFFER_STATE yy_create_buffer( file, size ) +FILE *file; +int size; +#endif + { + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer( b, file ); + + return b; + } + + +#ifdef YY_USE_PROTOS +void yy_delete_buffer( YY_BUFFER_STATE b ) +#else +void yy_delete_buffer( b ) +YY_BUFFER_STATE b; +#endif + { + if ( ! b ) + return; + + if ( b == yy_current_buffer ) + yy_current_buffer = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + yy_flex_free( (void *) b->yy_ch_buf ); + + yy_flex_free( (void *) b ); + } + + +#ifndef YY_ALWAYS_INTERACTIVE +#ifndef YY_NEVER_INTERACTIVE +extern int isatty YY_PROTO(( int )); +#endif +#endif + +#ifdef YY_USE_PROTOS +void yy_init_buffer( YY_BUFFER_STATE b, FILE *file ) +#else +void yy_init_buffer( b, file ) +YY_BUFFER_STATE b; +FILE *file; +#endif + + + { + yy_flush_buffer( b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + +#if YY_ALWAYS_INTERACTIVE + b->yy_is_interactive = 1; +#else +#if YY_NEVER_INTERACTIVE + b->yy_is_interactive = 0; +#else + b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; +#endif +#endif + } + + +#ifdef YY_USE_PROTOS +void yy_flush_buffer( YY_BUFFER_STATE b ) +#else +void yy_flush_buffer( b ) +YY_BUFFER_STATE b; +#endif + + { + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == yy_current_buffer ) + yy_load_buffer_state(); + } + + +#ifndef YY_NO_SCAN_BUFFER +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size ) +#else +YY_BUFFER_STATE yy_scan_buffer( base, size ) +char *base; +yy_size_t size; +#endif + { + YY_BUFFER_STATE b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return 0; + + b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); + + b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = 0; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + yy_switch_to_buffer( b ); + + return b; + } +#endif + + +#ifndef YY_NO_SCAN_STRING +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str ) +#else +YY_BUFFER_STATE yy_scan_string( yy_str ) +yyconst char *yy_str; +#endif + { + int len; + for ( len = 0; yy_str[len]; ++len ) + ; + + return yy_scan_bytes( yy_str, len ); + } +#endif + + +#ifndef YY_NO_SCAN_BYTES +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len ) +#else +YY_BUFFER_STATE yy_scan_bytes( bytes, len ) +yyconst char *bytes; +int len; +#endif + { + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + int i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = len + 2; + buf = (char *) yy_flex_alloc( n ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); + + for ( i = 0; i < len; ++i ) + buf[i] = bytes[i]; + + buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR; + + b = yy_scan_buffer( buf, n ); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); + + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; + } +#endif + + +#ifndef YY_NO_PUSH_STATE +#ifdef YY_USE_PROTOS +static void yy_push_state( int new_state ) +#else +static void yy_push_state( new_state ) +int new_state; +#endif + { + if ( yy_start_stack_ptr >= yy_start_stack_depth ) + { + yy_size_t new_size; + + yy_start_stack_depth += YY_START_STACK_INCR; + new_size = yy_start_stack_depth * sizeof( int ); + + if ( ! yy_start_stack ) + yy_start_stack = (int *) yy_flex_alloc( new_size ); + + else + yy_start_stack = (int *) yy_flex_realloc( + (void *) yy_start_stack, new_size ); + + if ( ! yy_start_stack ) + YY_FATAL_ERROR( + "out of memory expanding start-condition stack" ); + } + + yy_start_stack[yy_start_stack_ptr++] = YY_START; + + BEGIN(new_state); + } +#endif + + +#ifndef YY_NO_POP_STATE +static void yy_pop_state() + { + if ( --yy_start_stack_ptr < 0 ) + YY_FATAL_ERROR( "start-condition stack underflow" ); + + BEGIN(yy_start_stack[yy_start_stack_ptr]); + } +#endif + + +#ifndef YY_NO_TOP_STATE +static int yy_top_state() + { + return yy_start_stack[yy_start_stack_ptr - 1]; + } +#endif + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +#ifdef YY_USE_PROTOS +static void yy_fatal_error( yyconst char msg[] ) +#else +static void yy_fatal_error( msg ) +char msg[]; +#endif + { + (void) fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); + } + + + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + yytext[yyleng] = yy_hold_char; \ + yy_c_buf_p = yytext + n; \ + yy_hold_char = *yy_c_buf_p; \ + *yy_c_buf_p = '\0'; \ + yyleng = n; \ + } \ + while ( 0 ) + + +/* Internal utility routines. */ + +#ifndef yytext_ptr +#ifdef YY_USE_PROTOS +static void yy_flex_strncpy( char *s1, yyconst char *s2, int n ) +#else +static void yy_flex_strncpy( s1, s2, n ) +char *s1; +yyconst char *s2; +int n; +#endif + { + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; + } +#endif + +#ifdef YY_NEED_STRLEN +#ifdef YY_USE_PROTOS +static int yy_flex_strlen( yyconst char *s ) +#else +static int yy_flex_strlen( s ) +yyconst char *s; +#endif + { + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; + } +#endif + + +#ifdef YY_USE_PROTOS +static void *yy_flex_alloc( yy_size_t size ) +#else +static void *yy_flex_alloc( size ) +yy_size_t size; +#endif + { + return (void *) malloc( size ); + } + +#ifdef YY_USE_PROTOS +static void *yy_flex_realloc( void *ptr, yy_size_t size ) +#else +static void *yy_flex_realloc( ptr, size ) +void *ptr; +yy_size_t size; +#endif + { + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); + } + +#ifdef YY_USE_PROTOS +static void yy_flex_free( void *ptr ) +#else +static void yy_flex_free( ptr ) +void *ptr; +#endif + { + free( ptr ); + } + +#if YY_MAIN +int main() + { + yylex(); + return 0; + } +#endif +#line 138 "lexer.l" + + +void initFlex(const char *_code ) +{ + yy_switch_to_buffer( yy_scan_string(_code) ); +} + +int yywrap() +{ + yy_delete_buffer( YY_CURRENT_BUFFER ); + return 1; +} + +#ifndef TOKEN_DEBUG +int token_debug(const char * /*format*/, ...) +{ + return 0; +} +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/hwpfilter/source/list.hxx b/hwpfilter/source/list.hxx index cbc8d56b0ff2..c4df08e0a0f3 100644 --- a/hwpfilter/source/list.hxx +++ b/hwpfilter/source/list.hxx @@ -36,7 +36,7 @@ * USE STL CONTAINERS FOR NEW CODE! * * The classes LinkedList and LinkedListIterator were originally - * implemented in two files LinkedList.cpp/.h, whose license would not + * implemented in two files LinkedList.cxx/.h, whose license would not * allow re-distribution through OpenOffice.org. This file * re-implements the same functionality, based on the STL. */ @@ -92,7 +92,7 @@ public: void reset( ); /// set iterator to first element - // bug-compatible with original LinkedList.h/cpp: Ignore parameter! + // bug-compatible with original LinkedList.h/cxx: Ignore parameter! void operator++( int ); /// advance iterator by one step (ignore n !!!) void operator--( int ); /// go one step backwards (ignore n !!!) @@ -261,7 +261,7 @@ void LinkedListIterator::operator++( int ) { ASSERT( mpList != NULL ); - // bug-compatible with LinkedList.cpp: ignore parameter! + // bug-compatible with LinkedList.cxx: ignore parameter! mnPosition ++; } @@ -270,7 +270,7 @@ void LinkedListIterator::operator--( int ) { ASSERT( mpList != NULL ); - // bug-compatible with LinkedList.cpp: ignore parameter! + // bug-compatible with LinkedList.cxx: ignore parameter! mnPosition --; } diff --git a/hwpfilter/source/makefile.mk b/hwpfilter/source/makefile.mk deleted file mode 100644 index a8e137b6851b..000000000000 --- a/hwpfilter/source/makefile.mk +++ /dev/null @@ -1,103 +0,0 @@ -#************************************************************************* NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2000, 2010 Oracle and/or its affiliates. -# -# OpenOffice.org - a multi-platform office productivity suite -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# -# for a copy of the LGPLv3 License. -# -#************************************************************************* - -PRJ=.. - -PRJNAME=hwpfilter -TARGET=hwp - -USE_DEFFILE=TRUE -ENABLE_EXCEPTIONS=TRUE - -# --- Settings ----------------------------------------------------- - -.INCLUDE : settings.mk - -# --- Files -------------------------------------------------------- - -.IF "$(SYSTEM_ZLIB)" == "YES" -CFLAGS+=-DSYSTEM_ZLIB -.ENDIF - -SLOFILES = \ - $(SLO)$/attributes.obj \ - $(SLO)$/cspline.obj \ - $(SLO)$/fontmap.obj \ - $(SLO)$/formula.obj \ - $(SLO)$/grammar.obj \ - $(SLO)$/hbox.obj \ - $(SLO)$/hcode.obj \ - $(SLO)$/hfont.obj \ - $(SLO)$/hgzip.obj \ - $(SLO)$/himgutil.obj \ - $(SLO)$/hinfo.obj \ - $(SLO)$/hiodev.obj \ - $(SLO)$/hpara.obj \ - $(SLO)$/hstream.obj \ - $(SLO)$/hstyle.obj \ - $(SLO)$/htags.obj \ - $(SLO)$/hutil.obj \ - $(SLO)$/hwpeq.obj \ - $(SLO)$/hwpfile.obj \ - $(SLO)$/hwpread.obj \ - $(SLO)$/hwpreader.obj \ - $(SLO)$/lexer.obj \ - $(SLO)$/mzstring.obj \ - $(SLO)$/solver.obj - -# --- Shared-Library ----------------------------------------------- - -SHL1TARGET= $(TARGET) - -SHL1STDLIBS= \ - $(COMPHELPERLIB) \ - $(CPPULIB) \ - $(CPPUHELPERLIB)\ - $(SALLIB) \ - $(ZLIB3RDLIB) - -.IF "$(GUI)"=="WNT" -SHL1STDLIBS+= \ - $(OLE32LIB) $(UUIDLIB) -.ENDIF # "$(GUI)"=="WNT" - - -SHL1DEF= $(MISC)$/$(SHL1TARGET).def -SHL1LIBS= $(SLB)$/$(TARGET).lib -SHL1VERSIONMAP = $(SOLARENV)/src/component.map - -DEF1NAME=$(SHL1TARGET) - -# --- Tagets ------------------------------------------------------- - -.INCLUDE : target.mk - -ALLTAR : $(MISC)/hwp.component - -$(MISC)/hwp.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \ - hwp.component - $(XSLTPROC) --nonet --stringparam uri \ - '$(COMPONENTPREFIX_BASIS_NATIVE)$(SHL1TARGETN:f)' -o $@ \ - $(SOLARENV)/bin/createcomponent.xslt hwp.component diff --git a/hwpfilter/source/mzstring.cpp b/hwpfilter/source/mzstring.cpp deleted file mode 100644 index c8d7e977bdac..000000000000 --- a/hwpfilter/source/mzstring.cpp +++ /dev/null @@ -1,312 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -/* PURPOSE - * supposed to be used instead of std::string - */ - -#ifdef __GNUG__ -#pragma implementation "mzstring.h" -#endif - -#include "mzstring.h" - -#ifndef WIN32 -#else - - #if defined _MSC_VER - #pragma warning(push, 1) - #endif -# include - #if defined _MSC_VER - #pragma warning(pop) - #endif -#endif /* WIN32 */ -#include -#include -#include - -#ifndef WIN32 -# define wsprintf sprintf -#endif - -const int AllocSize = 8; - -inline int get_alloc_size(int len) -{ - return (len + AllocSize - 1) / AllocSize * AllocSize; -} - - -MzString::MzString() -{ - Length = 0; - Allocated = 0; - Data = 0; -} - - -MzString::~MzString() -{ - if (Data) - free(Data); -} - - -MzString &MzString::operator = (MzString &s) -{ - int n = s.length(); - if (allocate(n)) - { - if (n > 0) memcpy(Data, s.Data, n); - Length = n; - } - return *this; -} - - -MzString &MzString::operator = (const char *s) -{ - if (s == NULL) - s = ""; - int n = strlen(s); - if (allocate(n)) - { - if (n > 0) memcpy(Data, s, n); - Length = n; - } - return *this; -} - - -void MzString::append(const char *s, int slen) -{ - if(!s || slen <= 0) - return; - - int new_len = Length + slen; - if (resize(new_len)) - { - memcpy(Data + Length, s, slen); - Length = new_len; - } -} - - -void MzString::append(MzString const &s) -{ - if (s.Data) - append(s.Data, s.length()); -} - - -void MzString::append(const char *s) -{ - if (!s) return; - append(s, strlen(s)); -} - - -int MzString::compare(const char *s) -{ - if (!Data) return -1; - if (s==NULL) return 1; - - Data[Length] = 0; - return strcmp(Data, s); -} - - -int MzString::find(char ch) -{ - return find(ch,0); -} - - -int MzString::find(char ch, int pos) -{ - for (int i = pos; i < Length; i++) - { - if (Data[i] == ch) - return i; - } - return -1; -} - - -int MzString::rfind(char ch) -{ - return rfind(ch, Length - 1); -} - - -int MzString::rfind(char ch, int pos) -{ - if (pos >= Length) - return -1; - - while (pos >= 0) - { - if (Data[pos] == ch) - return pos; - pos--; - } - return -1; -} - - -// += operator - -MzString &MzString::operator += (char ch) -{ - append(&ch, 1); - return *this; -} - - -MzString &MzString::operator += (const char *str) -{ - append(str); - return *this; -} - - -MzString &MzString::operator += (MzString const &s) -{ - append(s); - return *this; -} - - -// << operator -MzString &MzString::operator << (const char *str) -{ - append(str); - return *this; -} - - -MzString &MzString::operator << (char ch) -{ - append(&ch, 1); - return *this; -} - - -MzString &MzString::operator << (int i) -{ - char str[80]; - - wsprintf(str, "%d", i); - append(str); - return *this; -} - - -MzString &MzString::operator << (long l) -{ - char str[80]; - - wsprintf(str, "%ld", l); - append(str); - return *this; -} - - -MzString &MzString::operator << (MzString const &s) -{ - append(s); - return *this; -} - - -char MzString::operator [] (int n) -{ - if (Data && 0 <= n && n < Length) - return Data[n]; - - return 0; -} - - -void MzString::replace(int pos, char ch) -{ - if (Data && 0 <= pos && pos < Length) - Data[pos] = ch; -} - - -//------------------------------------------------------------------------ -// Private Methods. -// - -bool MzString::allocate(int len) -{ - len++; // In case we want to add a null. - - if (len < 0) - return false; - - if (Data) - { - if (len < Allocated) - return true; - else - { - int n = get_alloc_size(len); - char *p = (char *)realloc(Data, n); - if (p) - { - Data = p; - Allocated = n; - return true; - } - } - } - else - { -// In case we want to add a null. - int n = get_alloc_size(len); - Data = (char *)malloc(n); - if (Data) - { - Allocated = n; - return true; - } - } - - return false; -} - - -bool MzString::resize(int len) -{ - return allocate(len); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/hwpfilter/source/mzstring.cxx b/hwpfilter/source/mzstring.cxx new file mode 100644 index 000000000000..c8d7e977bdac --- /dev/null +++ b/hwpfilter/source/mzstring.cxx @@ -0,0 +1,312 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +/* PURPOSE + * supposed to be used instead of std::string + */ + +#ifdef __GNUG__ +#pragma implementation "mzstring.h" +#endif + +#include "mzstring.h" + +#ifndef WIN32 +#else + + #if defined _MSC_VER + #pragma warning(push, 1) + #endif +# include + #if defined _MSC_VER + #pragma warning(pop) + #endif +#endif /* WIN32 */ +#include +#include +#include + +#ifndef WIN32 +# define wsprintf sprintf +#endif + +const int AllocSize = 8; + +inline int get_alloc_size(int len) +{ + return (len + AllocSize - 1) / AllocSize * AllocSize; +} + + +MzString::MzString() +{ + Length = 0; + Allocated = 0; + Data = 0; +} + + +MzString::~MzString() +{ + if (Data) + free(Data); +} + + +MzString &MzString::operator = (MzString &s) +{ + int n = s.length(); + if (allocate(n)) + { + if (n > 0) memcpy(Data, s.Data, n); + Length = n; + } + return *this; +} + + +MzString &MzString::operator = (const char *s) +{ + if (s == NULL) + s = ""; + int n = strlen(s); + if (allocate(n)) + { + if (n > 0) memcpy(Data, s, n); + Length = n; + } + return *this; +} + + +void MzString::append(const char *s, int slen) +{ + if(!s || slen <= 0) + return; + + int new_len = Length + slen; + if (resize(new_len)) + { + memcpy(Data + Length, s, slen); + Length = new_len; + } +} + + +void MzString::append(MzString const &s) +{ + if (s.Data) + append(s.Data, s.length()); +} + + +void MzString::append(const char *s) +{ + if (!s) return; + append(s, strlen(s)); +} + + +int MzString::compare(const char *s) +{ + if (!Data) return -1; + if (s==NULL) return 1; + + Data[Length] = 0; + return strcmp(Data, s); +} + + +int MzString::find(char ch) +{ + return find(ch,0); +} + + +int MzString::find(char ch, int pos) +{ + for (int i = pos; i < Length; i++) + { + if (Data[i] == ch) + return i; + } + return -1; +} + + +int MzString::rfind(char ch) +{ + return rfind(ch, Length - 1); +} + + +int MzString::rfind(char ch, int pos) +{ + if (pos >= Length) + return -1; + + while (pos >= 0) + { + if (Data[pos] == ch) + return pos; + pos--; + } + return -1; +} + + +// += operator + +MzString &MzString::operator += (char ch) +{ + append(&ch, 1); + return *this; +} + + +MzString &MzString::operator += (const char *str) +{ + append(str); + return *this; +} + + +MzString &MzString::operator += (MzString const &s) +{ + append(s); + return *this; +} + + +// << operator +MzString &MzString::operator << (const char *str) +{ + append(str); + return *this; +} + + +MzString &MzString::operator << (char ch) +{ + append(&ch, 1); + return *this; +} + + +MzString &MzString::operator << (int i) +{ + char str[80]; + + wsprintf(str, "%d", i); + append(str); + return *this; +} + + +MzString &MzString::operator << (long l) +{ + char str[80]; + + wsprintf(str, "%ld", l); + append(str); + return *this; +} + + +MzString &MzString::operator << (MzString const &s) +{ + append(s); + return *this; +} + + +char MzString::operator [] (int n) +{ + if (Data && 0 <= n && n < Length) + return Data[n]; + + return 0; +} + + +void MzString::replace(int pos, char ch) +{ + if (Data && 0 <= pos && pos < Length) + Data[pos] = ch; +} + + +//------------------------------------------------------------------------ +// Private Methods. +// + +bool MzString::allocate(int len) +{ + len++; // In case we want to add a null. + + if (len < 0) + return false; + + if (Data) + { + if (len < Allocated) + return true; + else + { + int n = get_alloc_size(len); + char *p = (char *)realloc(Data, n); + if (p) + { + Data = p; + Allocated = n; + return true; + } + } + } + else + { +// In case we want to add a null. + int n = get_alloc_size(len); + Data = (char *)malloc(n); + if (Data) + { + Allocated = n; + return true; + } + } + + return false; +} + + +bool MzString::resize(int len) +{ + return allocate(len); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/hwpfilter/source/solver.cpp b/hwpfilter/source/solver.cpp deleted file mode 100644 index 9748769b5d24..000000000000 --- a/hwpfilter/source/solver.cpp +++ /dev/null @@ -1,187 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include -#include "solver.h" - -//--------------------------------------------------------------------------- -double** mgcLinearSystemD::NewMatrix (int N) -{ - double** A = new double*[N]; - if ( !A ) - return 0; - - for (int row = 0; row < N; row++) - { - A[row] = new double[N]; - if ( !A[row] ) - { - for (int i = 0; i < row; i++) - delete[] A[i]; - delete[] A; - return 0; - } - for (int col = 0; col < N; col++) - A[row][col] = 0; - } - return A; -} -//--------------------------------------------------------------------------- -void mgcLinearSystemD::DeleteMatrix (int N, double** A) -{ - for (int row = 0; row < N; row++) - delete[] A[row]; - delete[] A; -} -//--------------------------------------------------------------------------- -double* mgcLinearSystemD::NewVector (int N) -{ - double* B = new double[N]; - if ( !B ) - return 0; - - for (int row = 0; row < N; row++) - B[row] = 0; - return B; -} -//--------------------------------------------------------------------------- -int mgcLinearSystemD::Solve (int n, double** a, double* b) -{ - int* indxc = new int[n]; - if ( !indxc ) - return 0; - int* indxr = new int[n]; - if ( !indxr ) { - delete[] indxc; - return 0; - } - int* ipiv = new int[n]; - if ( !ipiv ) { - delete[] indxc; - delete[] indxr; - return 0; - } - - int i, j, k; - int irow = 0; - int icol = 0; - double big, pivinv, save; - - for (j = 0; j < n; j++) - ipiv[j] = 0; - - for (i = 0; i < n; i++) - { - big = 0; - for (j = 0; j < n; j++) - { - if ( ipiv[j] != 1 ) - { - for (k = 0; k < n; k++) - { - if ( ipiv[k] == 0 ) - { - if ( fabs(a[j][k]) >= big ) - { - big = fabs(a[j][k]); - irow = j; - icol = k; - } - } - else if ( ipiv[k] > 1 ) - { - delete[] ipiv; - delete[] indxr; - delete[] indxc; - return 0; - } - } - } - } - ipiv[icol]++; - - if ( irow != icol ) - { - double* rowptr = a[irow]; - a[irow] = a[icol]; - a[icol] = rowptr; - - save = b[irow]; - b[irow] = b[icol]; - b[icol] = save; - } - - indxr[i] = irow; - indxc[i] = icol; - if ( a[icol][icol] == 0 ) - { - delete[] ipiv; - delete[] indxr; - delete[] indxc; - return 0; - } - - pivinv = 1/a[icol][icol]; - a[icol][icol] = 1; - for (k = 0; k < n; k++) - a[icol][k] *= pivinv; - b[icol] *= pivinv; - - for (j = 0; j < n; j++) - { - if ( j != icol ) - { - save = a[j][icol]; - a[j][icol] = 0; - for (k = 0; k < n; k++) - a[j][k] -= a[icol][k]*save; - b[j] -= b[icol]*save; - } - } - } - - for (j = n-1; j >= 0; j--) - { - if ( indxr[j] != indxc[j] ) - { - for (k = 0; k < n; k++) - { - save = a[k][indxr[j]]; - a[k][indxr[j]] = a[k][indxc[j]]; - a[k][indxc[j]] = save; - } - } - } - - delete[] ipiv; - delete[] indxr; - delete[] indxc; - return 1; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/hwpfilter/source/solver.cxx b/hwpfilter/source/solver.cxx new file mode 100644 index 000000000000..9748769b5d24 --- /dev/null +++ b/hwpfilter/source/solver.cxx @@ -0,0 +1,187 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include +#include "solver.h" + +//--------------------------------------------------------------------------- +double** mgcLinearSystemD::NewMatrix (int N) +{ + double** A = new double*[N]; + if ( !A ) + return 0; + + for (int row = 0; row < N; row++) + { + A[row] = new double[N]; + if ( !A[row] ) + { + for (int i = 0; i < row; i++) + delete[] A[i]; + delete[] A; + return 0; + } + for (int col = 0; col < N; col++) + A[row][col] = 0; + } + return A; +} +//--------------------------------------------------------------------------- +void mgcLinearSystemD::DeleteMatrix (int N, double** A) +{ + for (int row = 0; row < N; row++) + delete[] A[row]; + delete[] A; +} +//--------------------------------------------------------------------------- +double* mgcLinearSystemD::NewVector (int N) +{ + double* B = new double[N]; + if ( !B ) + return 0; + + for (int row = 0; row < N; row++) + B[row] = 0; + return B; +} +//--------------------------------------------------------------------------- +int mgcLinearSystemD::Solve (int n, double** a, double* b) +{ + int* indxc = new int[n]; + if ( !indxc ) + return 0; + int* indxr = new int[n]; + if ( !indxr ) { + delete[] indxc; + return 0; + } + int* ipiv = new int[n]; + if ( !ipiv ) { + delete[] indxc; + delete[] indxr; + return 0; + } + + int i, j, k; + int irow = 0; + int icol = 0; + double big, pivinv, save; + + for (j = 0; j < n; j++) + ipiv[j] = 0; + + for (i = 0; i < n; i++) + { + big = 0; + for (j = 0; j < n; j++) + { + if ( ipiv[j] != 1 ) + { + for (k = 0; k < n; k++) + { + if ( ipiv[k] == 0 ) + { + if ( fabs(a[j][k]) >= big ) + { + big = fabs(a[j][k]); + irow = j; + icol = k; + } + } + else if ( ipiv[k] > 1 ) + { + delete[] ipiv; + delete[] indxr; + delete[] indxc; + return 0; + } + } + } + } + ipiv[icol]++; + + if ( irow != icol ) + { + double* rowptr = a[irow]; + a[irow] = a[icol]; + a[icol] = rowptr; + + save = b[irow]; + b[irow] = b[icol]; + b[icol] = save; + } + + indxr[i] = irow; + indxc[i] = icol; + if ( a[icol][icol] == 0 ) + { + delete[] ipiv; + delete[] indxr; + delete[] indxc; + return 0; + } + + pivinv = 1/a[icol][icol]; + a[icol][icol] = 1; + for (k = 0; k < n; k++) + a[icol][k] *= pivinv; + b[icol] *= pivinv; + + for (j = 0; j < n; j++) + { + if ( j != icol ) + { + save = a[j][icol]; + a[j][icol] = 0; + for (k = 0; k < n; k++) + a[j][k] -= a[icol][k]*save; + b[j] -= b[icol]*save; + } + } + } + + for (j = n-1; j >= 0; j--) + { + if ( indxr[j] != indxc[j] ) + { + for (k = 0; k < n; k++) + { + save = a[k][indxr[j]]; + a[k][indxr[j]] = a[k][indxc[j]]; + a[k][indxc[j]] = save; + } + } + } + + delete[] ipiv; + delete[] indxr; + delete[] indxc; + return 1; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit