2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: custom.c /main/7 1996/11/15 11:55:52 rswiston $ */
25 Copyright (c) 1988, 1989 Hewlett-Packard Co.
28 /* Custom.c contains standard PARSER functions, customized for the HP
29 HelpTag formatting system. */
37 /* Standard startup code doesn't have room to load inherited environments
38 in some cases. Since they're not used, don't bother. (Using Microsoft
40 void _setenvp(M_NOPAR);
44 /* Write input file and line number for an error message */
45 void m_dumpline(file, line)
53 sprintf(buffer, "%d", line);
56 { /* no entity file */
60 m_errline(inFileName);
64 { /* yes, entity file */
65 mbyte = MakeMByteString(file);
68 m_free(mbyte, "multi-byte string");
72 /* Write error message prefix */
73 void m_eprefix(M_NOPAR)
75 m_errline("\n*****\n");
76 m_dumpline(m_thisfile(), m_thisline());
80 /* Process error message text */
88 if (m_errfile) putc(*p, m_errfile);
96 /* Write error message suffix */
97 void m_esuffix(M_NOPAR)
101 if (++m_errcnt == m_errlim)
103 m_error("Too many errors, processing stopped");
115 if (status == 77) /* tell helptag to re-run for forward xrefs */
129 exit(1); /* tell helptag to quit */
131 exit(2); /* tell helptag to continue to next phases */
137 /* Get-char procedure */
144 char mbyte[32]; /* make this bigger than any possible multi-byte char */
146 static M_WCHAR wcr = 0, wsb, wsp, wtb;
149 /* Unix/Dos compatibility: 0D0A handling */
152 mbtowc(&wcr, "\r", 1);
153 mbtowc(&wsb, "\032", 1);
156 mbtowc(&wsp, &space, 1);
159 mbtowc(&wtb, &tab, 1);
165 #ifdef NO_IBM_PATCH_U446072
166 /* -------------------------------------------------------------- */
167 /* Note that the call to fflush before each call to getc is */
168 /* a workaround for a bug in the re-entrant (thread-safe) getc */
169 /* function. Earlier versions of AIX did not have this problem. */
170 /* Made it very specific to AIX 4.2. The bug might appear again */
171 /* in future releases of AIX. Hopefully this comment would help */
172 /* to identify the problem quickly in case it appears again. */
173 /* -------------------------------------------------------------- */
177 if ((c = getc((FILE *)m_ptr)) == EOF) return(EOF);
179 #ifdef NO_IBM_PATCH_U446072
187 if (mblen(mbyte,length) != -1) break; /* hurray! */
188 if (length == MB_CUR_MAX)
189 { /* reached max without a hit */
190 m_error("An invalid multi-byte character was found in the input");
196 #ifdef NO_IBM_PATCH_U446072
197 /* -------------------------------------------------------------- */
198 /* Note that the call to fflush before each call to getc is */
199 /* a workaround for a bug in the re-entrant (thread-safe) getc */
200 /* function. Earlier versions of AIX did not have this problem. */
201 /* Made it very specific to AIX 4.2. The bug might appear again */
202 /* in future releases of AIX. Hopefully this comment would help */
203 /* to identify the problem quickly in case it appears again. */
204 /* -------------------------------------------------------------- */
208 if ((c = getc((FILE *) m_ptr)) == EOF)
210 m_error("End-of-file found in within a multi-byte character");
214 mbtowc(&wc,mbyte,length);
217 while ((wc == wcr) || (wc == wsb));
219 /* Change tabs to spaces */
220 if (wc == wtb) return((int) wsp);
224 /* Open SYSTEM entity procedure */
225 void *m_openent(entcontent)
233 mb_entcontent = MakeMByteString(entcontent);
234 if (!mb_entcontent || !*mb_entcontent) {
235 m_free(mb_entcontent, "multi-byte string");
236 return NULL; /* null file name, don't open a directory */
239 open = fopen(mb_entcontent, "r");
242 m_free(mb_entcontent, "multi-byte string");
243 return((void *) open);
246 for (searchp = path ; searchp ; searchp = searchp->next)
249 m_malloc(strlen(searchp->directory) +
250 strlen(mb_entcontent) + 1,
252 strcpy(filename, searchp->directory);
253 strcat(filename, mb_entcontent);
254 open = fopen(filename, "r");
255 m_free(filename, "filename");
258 m_free(mb_entcontent, "multi-byte string");
259 return((void *) open);
263 m_free(mb_entcontent, "multi-byte string");
267 /* Open input file */
268 void *m_openfirst(M_NOPAR)
270 return((void *) inFile);
273 /* Set program options */
278 m_optstring(m_argv[2]);
282 /* Process signon message text, stripping out MARKUP version number, so
283 only one version number will appear */
290 if (q = strstr(p, VERSION)) {
292 q = strstr(pCopy, VERSION);
301 /* All entity declarations have been processed. */
306 /* Write debugging trace information */
318 mb_p = MakeMByteString(p);
320 m_free(mb_p,"multi-byte string");