1 /* This file is part of the program psim. 2 3 Copyright (C) 1994-1995, Andrew Cagney <cagney@highland.com.au> 4 5 This program is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation; either version 3 of the License, or 8 (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program; if not, see <http://www.gnu.org/licenses/>. 17 18 */ 19 20 #include <ctype.h> 21 #include <stdio.h> 22 #include <stdlib.h> 23 #include <string.h> 24 25 #include "lf.h" 26 #include "lf-ppc.h" 27 28 int 29 lf_print__c_code(lf *file, 30 const char *code) 31 { 32 int nr = 0; 33 const char *chp = code; 34 int in_bit_field = 0; 35 while (*chp != '\0') { 36 if (*chp == '\t') 37 chp++; 38 if (*chp == '#') 39 lf_indent_suppress(file); 40 while (*chp != '\0' && *chp != '\n') { 41 if (chp[0] == '{' && !isspace(chp[1])) { 42 in_bit_field = 1; 43 nr += lf_putchr(file, '_'); 44 } 45 else if (in_bit_field && chp[0] == ':') { 46 nr += lf_putchr(file, '_'); 47 } 48 else if (in_bit_field && *chp == '}') { 49 nr += lf_putchr(file, '_'); 50 in_bit_field = 0; 51 } 52 else { 53 nr += lf_putchr(file, *chp); 54 } 55 chp++; 56 } 57 if (in_bit_field) 58 ERROR("bit field paren miss match some where\n"); 59 if (*chp == '\n') { 60 nr += lf_putchr(file, '\n'); 61 chp++; 62 } 63 } 64 nr += lf_putchr(file, '\n'); 65 return nr; 66 } 67