Deleted Added
full compact
treesource.c (204431) treesource.c (204433)
1/*
2 * (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2005.
3 *
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version.

--- 38 unchanged lines hidden (view full) ---

47static void write_prefix(FILE *f, int level)
48{
49 int i;
50
51 for (i = 0; i < level; i++)
52 fputc('\t', f);
53}
54
1/*
2 * (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2005.
3 *
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version.

--- 38 unchanged lines hidden (view full) ---

47static void write_prefix(FILE *f, int level)
48{
49 int i;
50
51 for (i = 0; i < level; i++)
52 fputc('\t', f);
53}
54
55int isstring(char c)
55static int isstring(char c)
56{
57 return (isprint(c)
58 || (c == '\0')
59 || strchr("\a\b\t\n\v\f\r", c));
60}
61
62static void write_propval_string(FILE *f, struct data val)
63{
64 const char *str = val.val;
65 int i;
56{
57 return (isprint(c)
58 || (c == '\0')
59 || strchr("\a\b\t\n\v\f\r", c));
60}
61
62static void write_propval_string(FILE *f, struct data val)
63{
64 const char *str = val.val;
65 int i;
66 int newchunk = 1;
67 struct marker *m = val.markers;
68
69 assert(str[val.len-1] == '\0');
70
66 struct marker *m = val.markers;
67
68 assert(str[val.len-1] == '\0');
69
70 while (m && (m->offset == 0)) {
71 if (m->type == LABEL)
72 fprintf(f, "%s: ", m->ref);
73 m = m->next;
74 }
75 fprintf(f, "\"");
76
71 for (i = 0; i < (val.len-1); i++) {
72 char c = str[i];
73
77 for (i = 0; i < (val.len-1); i++) {
78 char c = str[i];
79
74 if (newchunk) {
75 while (m && (m->offset <= i)) {
76 if (m->type == LABEL) {
77 assert(m->offset == i);
78 fprintf(f, "%s: ", m->ref);
79 }
80 m = m->next;
81 }
82 fprintf(f, "\"");
83 newchunk = 0;
84 }
85
86 switch (c) {
87 case '\a':
88 fprintf(f, "\\a");
89 break;
90 case '\b':
91 fprintf(f, "\\b");
92 break;
93 case '\t':

--- 14 unchanged lines hidden (view full) ---

108 case '\\':
109 fprintf(f, "\\\\");
110 break;
111 case '\"':
112 fprintf(f, "\\\"");
113 break;
114 case '\0':
115 fprintf(f, "\", ");
80 switch (c) {
81 case '\a':
82 fprintf(f, "\\a");
83 break;
84 case '\b':
85 fprintf(f, "\\b");
86 break;
87 case '\t':

--- 14 unchanged lines hidden (view full) ---

102 case '\\':
103 fprintf(f, "\\\\");
104 break;
105 case '\"':
106 fprintf(f, "\\\"");
107 break;
108 case '\0':
109 fprintf(f, "\", ");
116 newchunk = 1;
110 while (m && (m->offset < i)) {
111 if (m->type == LABEL) {
112 assert(m->offset == (i+1));
113 fprintf(f, "%s: ", m->ref);
114 }
115 m = m->next;
116 }
117 fprintf(f, "\"");
117 break;
118 default:
119 if (isprint(c))
120 fprintf(f, "%c", c);
121 else
122 fprintf(f, "\\x%02hhx", c);
123 }
124 }

--- 154 unchanged lines hidden ---
118 break;
119 default:
120 if (isprint(c))
121 fprintf(f, "%c", c);
122 else
123 fprintf(f, "\\x%02hhx", c);
124 }
125 }

--- 154 unchanged lines hidden ---