hbase

heirloom base
git clone git://git.2f30.org/hbase
Log | Files | Refs | README

allprint.c (1945B)


      1 /*
      2  * CDDL HEADER START
      3  *
      4  * The contents of this file are subject to the terms of the
      5  * Common Development and Distribution License, Version 1.0 only
      6  * (the "License").  You may not use this file except in compliance
      7  * with the License.
      8  *
      9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
     10  * or http://www.opensolaris.org/os/licensing.
     11  * See the License for the specific language governing permissions
     12  * and limitations under the License.
     13  *
     14  * When distributing Covered Code, include this CDDL HEADER in each
     15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
     16  * If applicable, add the following below this CDDL HEADER, with the
     17  * fields enclosed by brackets "[]" replaced with your own identifying
     18  * information: Portions Copyright [yyyy] [name of copyright owner]
     19  *
     20  * CDDL HEADER END
     21  */
     22 /*
     23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
     24  * Use is subject to license terms.
     25  */
     26 
     27 /*	Copyright (c) 1989 AT&T	*/
     28 /*	  All Rights Reserved  	*/
     29 
     30 /*	from OpenSolaris "allprint.c	6.11	05/06/08 SMI"	*/
     31 
     32 /*
     33  * Portions Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany
     34  *
     35  * Sccsid @(#)allprint.c	1.4 (gritter) 11/27/05
     36  */
     37 
     38 #include <stdio.h>
     39 #include <stdlib.h>
     40 #include <ctype.h>
     41 #ifdef	__sun
     42 #include <sys/euc.h>
     43 #include <widec.h>
     44 #endif
     45 #include <wctype.h>
     46 #include <wchar.h>
     47 
     48 extern FILE *yyout;
     49 
     50 #ifndef JLSLEX
     51 #define	CHR    char
     52 #endif
     53 
     54 #ifdef WOPTION
     55 #define	CHR	wchar_t
     56 #define	sprint	sprint_w
     57 #define	allprint	allprint_w
     58 #endif
     59 
     60 #ifdef EOPTION
     61 #define	CHR	wchar_t
     62 #endif
     63 
     64 void
     65 allprint(CHR c)
     66 {
     67 	switch (c) {
     68 	case '\n':
     69 		fprintf(yyout, "\\n");
     70 		break;
     71 	case '\t':
     72 		fprintf(yyout, "\\t");
     73 		break;
     74 	case '\b':
     75 		fprintf(yyout, "\\b");
     76 		break;
     77 	case ' ':
     78 		fprintf(yyout, "\\_");
     79 		break;
     80 	default:
     81 		if (!iswprint(c))
     82 		    fprintf(yyout, "\\x%-2x", (int)c);
     83 		else
     84 		    putwc(c, yyout);
     85 		break;
     86 	}
     87 }
     88 
     89 void
     90 sprint(CHR *s)
     91 {
     92 	while (*s)
     93 		allprint(*s++);
     94 }